Re: [PATCH v2 3/4] sta2x11_vip: convert to videobuf2 and control framework

2012-09-23 Thread Federico Vaga
> > +struct sta2x11_vip_fh {
> > +   struct v4l2_fh fh;
> > +};
> 
> No need to make a sta2x11_vip_fh struct, just use v4l2_fh directly. It
> doesn't add anything. In fact, it's not even used.

Thank you :)


> >  static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
> >  
> >   struct v4l2_format *f)
> >  
> >  {
> > 
> > -   struct video_device *dev = priv;
> > -   struct sta2x11_vip *vip = video_get_drvdata(dev);
> > +   struct sta2x11_vip *vip = video_drvdata(file);
> > 
> > int interlace_lim;
> > 
> > -   if (V4L2_PIX_FMT_UYVY != f->fmt.pix.pixelformat)
> > -   return -EINVAL;
> > -
> > 
> > if (V4L2_STD_525_60 & vip->std)
> > 
> > interlace_lim = 240;
> > 
> > else
> > 
> > @@ -827,6 +522,8 @@ static int vidioc_try_fmt_vid_cap(struct file
> > *file, void *priv,> 
> > return -EINVAL;
> 
> No -EINVAL allowed anymore in try_fmt_vid_cap. I generally handle
> unknown field values in try_fmt_vid_cap as if FIELD_ANY was
> specified.

ok, unknown -> any

> > 
> > memcpy(>format, >fmt.pix, sizeof(struct 
v4l2_pix_format));
> 
> Just use an assignment: vip->format = f->fmt.pix
> 

> > 
> > memcpy(>fmt.pix, >format, sizeof(struct 
v4l2_pix_format));
> 
> Assignment
> 

Fixed


> > -
> > 
> >  static const struct v4l2_ioctl_ops vip_ioctl_ops = {
> >  
> > .vidioc_querycap = vidioc_querycap,
> > 
> > -   .vidioc_s_std = vidioc_s_std,
> > +   /* FMT handling */
> > +   .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
> > +   .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
> > +   .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
> > +   .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,
> > +   /* Buffer handlers */
> > +   .vidioc_reqbufs = vb2_ioctl_reqbufs,
> > +   .vidioc_querybuf = vb2_ioctl_querybuf,
> > +   .vidioc_qbuf = vb2_ioctl_qbuf,
> > +   .vidioc_dqbuf = vb2_ioctl_dqbuf,
> > +   .vidioc_create_bufs = vb2_ioctl_create_bufs,
> 
> If you want to use create_bufs, then in queue_setup() you need to
> handle the fmt argument. See e.g. vivi.c for an example.

Fixed

I will send a patch v3 tomorrow
-- 
Federico Vaga
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 3/4] sta2x11_vip: convert to videobuf2 and control framework

2012-09-23 Thread Federico Vaga
  +struct sta2x11_vip_fh {
  +   struct v4l2_fh fh;
  +};
 
 No need to make a sta2x11_vip_fh struct, just use v4l2_fh directly. It
 doesn't add anything. In fact, it's not even used.

Thank you :)


   static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
   
struct v4l2_format *f)
   
   {
  
  -   struct video_device *dev = priv;
  -   struct sta2x11_vip *vip = video_get_drvdata(dev);
  +   struct sta2x11_vip *vip = video_drvdata(file);
  
  int interlace_lim;
  
  -   if (V4L2_PIX_FMT_UYVY != f-fmt.pix.pixelformat)
  -   return -EINVAL;
  -
  
  if (V4L2_STD_525_60  vip-std)
  
  interlace_lim = 240;
  
  else
  
  @@ -827,6 +522,8 @@ static int vidioc_try_fmt_vid_cap(struct file
  *file, void *priv, 
  return -EINVAL;
 
 No -EINVAL allowed anymore in try_fmt_vid_cap. I generally handle
 unknown field values in try_fmt_vid_cap as if FIELD_ANY was
 specified.

ok, unknown - any

  
  memcpy(vip-format, f-fmt.pix, sizeof(struct 
v4l2_pix_format));
 
 Just use an assignment: vip-format = f-fmt.pix
 

  
  memcpy(f-fmt.pix, vip-format, sizeof(struct 
v4l2_pix_format));
 
 Assignment
 

Fixed


  -
  
   static const struct v4l2_ioctl_ops vip_ioctl_ops = {
   
  .vidioc_querycap = vidioc_querycap,
  
  -   .vidioc_s_std = vidioc_s_std,
  +   /* FMT handling */
  +   .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
  +   .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
  +   .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
  +   .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,
  +   /* Buffer handlers */
  +   .vidioc_reqbufs = vb2_ioctl_reqbufs,
  +   .vidioc_querybuf = vb2_ioctl_querybuf,
  +   .vidioc_qbuf = vb2_ioctl_qbuf,
  +   .vidioc_dqbuf = vb2_ioctl_dqbuf,
  +   .vidioc_create_bufs = vb2_ioctl_create_bufs,
 
 If you want to use create_bufs, then in queue_setup() you need to
 handle the fmt argument. See e.g. vivi.c for an example.

Fixed

I will send a patch v3 tomorrow
-- 
Federico Vaga
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 3/4] sta2x11_vip: convert to videobuf2 and control framework

2012-09-21 Thread Hans Verkuil
On Fri September 21 2012 11:21:37 Federico Vaga wrote:
> This patch re-write the driver and use the videobuf2
> interface instead of the old videobuf. Moreover, it uses also
> the control framework which allows the driver to inherit
> controls from its subdevice (ADV7180)

Some more comments below, nothing major.

> Signed-off-by: Federico Vaga 
> Acked-by: Giancarlo Asnaghi 
> ---
>  drivers/media/pci/sta2x11/Kconfig   |2 +-
>  drivers/media/pci/sta2x11/sta2x11_vip.c | 1235 
> ++-
>  2 file modificati, 411 inserzioni(+), 826 rimozioni(-)
> 
> diff --git a/drivers/media/pci/sta2x11/Kconfig 
> b/drivers/media/pci/sta2x11/Kconfig
> index 6749f67..654339f 100644
> --- a/drivers/media/pci/sta2x11/Kconfig
> +++ b/drivers/media/pci/sta2x11/Kconfig
> @@ -2,7 +2,7 @@ config STA2X11_VIP
>   tristate "STA2X11 VIP Video For Linux"
>   depends on STA2X11
>   select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
> - select VIDEOBUF_DMA_CONTIG
> + select VIDEOBUF2_DMA_STREAMING
>   depends on PCI && VIDEO_V4L2 && VIRT_TO_BUS
>   help
> Say Y for support for STA2X11 VIP (Video Input Port) capture
> diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
> b/drivers/media/pci/sta2x11/sta2x11_vip.c
> index 4c10205..f423039 100644
> --- a/drivers/media/pci/sta2x11/sta2x11_vip.c
> +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
> @@ -1,6 +1,7 @@
>  /*
>   * This is the driver for the STA2x11 Video Input Port.
>   *
> + * Copyright (C) 2012   ST Microelectronics
>   * Copyright (C) 2010   WindRiver Systems, Inc.
>   *
>   * This program is free software; you can redistribute it and/or modify it
> @@ -19,36 +20,30 @@
>   * The full GNU General Public License is included in this distribution in
>   * the file called "COPYING".
>   *
> - * Author: Andreas Kies 
> - *   Vlad Lungu 
> - *
>   */
>  
>  #include 
>  #include 
>  #include 
>  #include 
> -#include 
> -
>  #include 
> -
>  #include 
> -
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
> -#include 
> +#include 
> +#include 
> +#include 
>  
>  #include "sta2x11_vip.h"
>  
> -#define DRV_NAME "sta2x11_vip"
>  #define DRV_VERSION "1.3"
>  
>  #ifndef PCI_DEVICE_ID_STMICRO_VIP
> @@ -63,8 +58,8 @@
>  #define DVP_TFS  0x08
>  #define DVP_BFO  0x0C
>  #define DVP_BFS  0x10
> -#define DVP_VTP 0x14
> -#define DVP_VBP 0x18
> +#define DVP_VTP  0x14
> +#define DVP_VBP  0x18
>  #define DVP_VMP  0x1C
>  #define DVP_ITM  0x98
>  #define DVP_ITS  0x9C
> @@ -84,44 +79,24 @@
>  
>  #define DVP_HLFLN_SD 0x0001
>  
> -#define REG_WRITE(vip, reg, value) iowrite32((value), (vip->iomem)+(reg))
> -#define REG_READ(vip, reg) ioread32((vip->iomem)+(reg))
> -
>  #define SAVE_COUNT 8
>  #define AUX_COUNT 3
>  #define IRQ_COUNT 1
>  
> -/**
> - * struct sta2x11_vip - All internal data for one instance of device
> - * @v4l2_dev: device registered in v4l layer
> - * @video_dev: properties of our device
> - * @pdev: PCI device
> - * @adapter: contains I2C adapter information
> - * @register_save_area: All relevant register are saved here during suspend
> - * @decoder: contains information about video DAC
> - * @format: pixel format, fixed UYVY
> - * @std: video standard (e.g. PAL/NTSC)
> - * @input: input line for video signal ( 0 or 1 )
> - * @users: Number of open of device ( max. 1 )
> - * @disabled: Device is in power down state
> - * @mutex: ensures exclusive opening of device
> - * @slock: for excluse acces of registers
> - * @vb_vidq: queue maintained by videobuf layer
> - * @capture: linked list of capture buffer
> - * @active: struct videobuf_buffer currently beingg filled
> - * @started: device is ready to capture frame
> - * @closing: device will be shut down
> - * @tcount: Number of top frames
> - * @bcount: Number of bottom frames
> - * @overflow: Number of FIFO overflows
> - * @mem_spare: small buffer of unused frame
> - * @dma_spare: dma addres of mem_spare
> - * @iomem: hardware base address
> - * @config: I2C and gpio config from platform
> - *
> - * All non-local data is accessed via this structure.
> - */
>  
> +struct vip_buffer {
> + struct vb2_buffer   vb;
> + struct list_headlist;
> + dma_addr_t  dma;
> +};
> +static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
> +{
> + return container_of(vb2, struct vip_buffer, vb);
> +}
> +
> +struct sta2x11_vip_fh {
> + struct v4l2_fh fh;
> +};

No need to make a sta2x11_vip_fh struct, just use v4l2_fh directly. It doesn't
add anything. In fact, it's not even used.

>  struct sta2x11_vip {
>   struct v4l2_device v4l2_dev;
>   struct video_device *video_dev;
> @@ -129,21 +104,27 @@ struct sta2x11_vip {
>   struct i2c_adapter *adapter;
>   unsigned int 

[PATCH v2 3/4] sta2x11_vip: convert to videobuf2 and control framework

2012-09-21 Thread Federico Vaga
This patch re-write the driver and use the videobuf2
interface instead of the old videobuf. Moreover, it uses also
the control framework which allows the driver to inherit
controls from its subdevice (ADV7180)

Signed-off-by: Federico Vaga 
Acked-by: Giancarlo Asnaghi 
---
 drivers/media/pci/sta2x11/Kconfig   |2 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c | 1235 ++-
 2 file modificati, 411 inserzioni(+), 826 rimozioni(-)

diff --git a/drivers/media/pci/sta2x11/Kconfig 
b/drivers/media/pci/sta2x11/Kconfig
index 6749f67..654339f 100644
--- a/drivers/media/pci/sta2x11/Kconfig
+++ b/drivers/media/pci/sta2x11/Kconfig
@@ -2,7 +2,7 @@ config STA2X11_VIP
tristate "STA2X11 VIP Video For Linux"
depends on STA2X11
select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
-   select VIDEOBUF_DMA_CONTIG
+   select VIDEOBUF2_DMA_STREAMING
depends on PCI && VIDEO_V4L2 && VIRT_TO_BUS
help
  Say Y for support for STA2X11 VIP (Video Input Port) capture
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 4c10205..f423039 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -1,6 +1,7 @@
 /*
  * This is the driver for the STA2x11 Video Input Port.
  *
+ * Copyright (C) 2012   ST Microelectronics
  * Copyright (C) 2010   WindRiver Systems, Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -19,36 +20,30 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Author: Andreas Kies 
- * Vlad Lungu 
- *
  */
 
 #include 
 #include 
 #include 
 #include 
-#include 
-
 #include 
-
 #include 
-
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
+#include 
+#include 
+#include 
 
 #include "sta2x11_vip.h"
 
-#define DRV_NAME "sta2x11_vip"
 #define DRV_VERSION "1.3"
 
 #ifndef PCI_DEVICE_ID_STMICRO_VIP
@@ -63,8 +58,8 @@
 #define DVP_TFS0x08
 #define DVP_BFO0x0C
 #define DVP_BFS0x10
-#define DVP_VTP 0x14
-#define DVP_VBP 0x18
+#define DVP_VTP0x14
+#define DVP_VBP0x18
 #define DVP_VMP0x1C
 #define DVP_ITM0x98
 #define DVP_ITS0x9C
@@ -84,44 +79,24 @@
 
 #define DVP_HLFLN_SD   0x0001
 
-#define REG_WRITE(vip, reg, value) iowrite32((value), (vip->iomem)+(reg))
-#define REG_READ(vip, reg) ioread32((vip->iomem)+(reg))
-
 #define SAVE_COUNT 8
 #define AUX_COUNT 3
 #define IRQ_COUNT 1
 
-/**
- * struct sta2x11_vip - All internal data for one instance of device
- * @v4l2_dev: device registered in v4l layer
- * @video_dev: properties of our device
- * @pdev: PCI device
- * @adapter: contains I2C adapter information
- * @register_save_area: All relevant register are saved here during suspend
- * @decoder: contains information about video DAC
- * @format: pixel format, fixed UYVY
- * @std: video standard (e.g. PAL/NTSC)
- * @input: input line for video signal ( 0 or 1 )
- * @users: Number of open of device ( max. 1 )
- * @disabled: Device is in power down state
- * @mutex: ensures exclusive opening of device
- * @slock: for excluse acces of registers
- * @vb_vidq: queue maintained by videobuf layer
- * @capture: linked list of capture buffer
- * @active: struct videobuf_buffer currently beingg filled
- * @started: device is ready to capture frame
- * @closing: device will be shut down
- * @tcount: Number of top frames
- * @bcount: Number of bottom frames
- * @overflow: Number of FIFO overflows
- * @mem_spare: small buffer of unused frame
- * @dma_spare: dma addres of mem_spare
- * @iomem: hardware base address
- * @config: I2C and gpio config from platform
- *
- * All non-local data is accessed via this structure.
- */
 
+struct vip_buffer {
+   struct vb2_buffer   vb;
+   struct list_headlist;
+   dma_addr_t  dma;
+};
+static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
+{
+   return container_of(vb2, struct vip_buffer, vb);
+}
+
+struct sta2x11_vip_fh {
+   struct v4l2_fh fh;
+};
 struct sta2x11_vip {
struct v4l2_device v4l2_dev;
struct video_device *video_dev;
@@ -129,21 +104,27 @@ struct sta2x11_vip {
struct i2c_adapter *adapter;
unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT];
struct v4l2_subdev *decoder;
-   struct v4l2_pix_format format;
-   v4l2_std_id std;
-   unsigned int input;
-   int users;
-   int disabled;
-   struct mutex mutex; /* exclusive access during open */
-   spinlock_t slock;   /* spin lock for hardware and queue access */
-   struct videobuf_queue vb_vidq;
-   struct list_head capture;
-   struct videobuf_buffer *active;
-   int 

[PATCH v2 3/4] sta2x11_vip: convert to videobuf2 and control framework

2012-09-21 Thread federico . vaga
From: Federico Vaga 

This patch re-write the driver and use the videobuf2
interface instead of the old videobuf. Moreover, it uses also
the control framework which allows the driver to inherit
controls from its subdevice (ADV7180)

Signed-off-by: Federico Vaga 
Acked-by: Giancarlo Asnaghi 
---
 drivers/media/pci/sta2x11/Kconfig   |2 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c | 1235 ++-
 2 file modificati, 411 inserzioni(+), 826 rimozioni(-)

diff --git a/drivers/media/pci/sta2x11/Kconfig 
b/drivers/media/pci/sta2x11/Kconfig
index 6749f67..654339f 100644
--- a/drivers/media/pci/sta2x11/Kconfig
+++ b/drivers/media/pci/sta2x11/Kconfig
@@ -2,7 +2,7 @@ config STA2X11_VIP
tristate "STA2X11 VIP Video For Linux"
depends on STA2X11
select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
-   select VIDEOBUF_DMA_CONTIG
+   select VIDEOBUF2_DMA_STREAMING
depends on PCI && VIDEO_V4L2 && VIRT_TO_BUS
help
  Say Y for support for STA2X11 VIP (Video Input Port) capture
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 4c10205..f423039 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -1,6 +1,7 @@
 /*
  * This is the driver for the STA2x11 Video Input Port.
  *
+ * Copyright (C) 2012   ST Microelectronics
  * Copyright (C) 2010   WindRiver Systems, Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -19,36 +20,30 @@
  * The full GNU General Public License is included in this distribution in
  * the file called "COPYING".
  *
- * Author: Andreas Kies 
- * Vlad Lungu 
- *
  */
 
 #include 
 #include 
 #include 
 #include 
-#include 
-
 #include 
-
 #include 
-
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
+#include 
+#include 
+#include 
 
 #include "sta2x11_vip.h"
 
-#define DRV_NAME "sta2x11_vip"
 #define DRV_VERSION "1.3"
 
 #ifndef PCI_DEVICE_ID_STMICRO_VIP
@@ -63,8 +58,8 @@
 #define DVP_TFS0x08
 #define DVP_BFO0x0C
 #define DVP_BFS0x10
-#define DVP_VTP 0x14
-#define DVP_VBP 0x18
+#define DVP_VTP0x14
+#define DVP_VBP0x18
 #define DVP_VMP0x1C
 #define DVP_ITM0x98
 #define DVP_ITS0x9C
@@ -84,44 +79,24 @@
 
 #define DVP_HLFLN_SD   0x0001
 
-#define REG_WRITE(vip, reg, value) iowrite32((value), (vip->iomem)+(reg))
-#define REG_READ(vip, reg) ioread32((vip->iomem)+(reg))
-
 #define SAVE_COUNT 8
 #define AUX_COUNT 3
 #define IRQ_COUNT 1
 
-/**
- * struct sta2x11_vip - All internal data for one instance of device
- * @v4l2_dev: device registered in v4l layer
- * @video_dev: properties of our device
- * @pdev: PCI device
- * @adapter: contains I2C adapter information
- * @register_save_area: All relevant register are saved here during suspend
- * @decoder: contains information about video DAC
- * @format: pixel format, fixed UYVY
- * @std: video standard (e.g. PAL/NTSC)
- * @input: input line for video signal ( 0 or 1 )
- * @users: Number of open of device ( max. 1 )
- * @disabled: Device is in power down state
- * @mutex: ensures exclusive opening of device
- * @slock: for excluse acces of registers
- * @vb_vidq: queue maintained by videobuf layer
- * @capture: linked list of capture buffer
- * @active: struct videobuf_buffer currently beingg filled
- * @started: device is ready to capture frame
- * @closing: device will be shut down
- * @tcount: Number of top frames
- * @bcount: Number of bottom frames
- * @overflow: Number of FIFO overflows
- * @mem_spare: small buffer of unused frame
- * @dma_spare: dma addres of mem_spare
- * @iomem: hardware base address
- * @config: I2C and gpio config from platform
- *
- * All non-local data is accessed via this structure.
- */
 
+struct vip_buffer {
+   struct vb2_buffer   vb;
+   struct list_headlist;
+   dma_addr_t  dma;
+};
+static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
+{
+   return container_of(vb2, struct vip_buffer, vb);
+}
+
+struct sta2x11_vip_fh {
+   struct v4l2_fh fh;
+};
 struct sta2x11_vip {
struct v4l2_device v4l2_dev;
struct video_device *video_dev;
@@ -129,21 +104,27 @@ struct sta2x11_vip {
struct i2c_adapter *adapter;
unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT];
struct v4l2_subdev *decoder;
-   struct v4l2_pix_format format;
-   v4l2_std_id std;
-   unsigned int input;
-   int users;
-   int disabled;
-   struct mutex mutex; /* exclusive access during open */
-   spinlock_t slock;   /* spin lock for hardware and queue access */
-   struct videobuf_queue vb_vidq;
-   struct list_head capture;
-   struct videobuf_buffer 

[PATCH v2 3/4] sta2x11_vip: convert to videobuf2 and control framework

2012-09-21 Thread federico . vaga
From: Federico Vaga federico.v...@gmail.com

This patch re-write the driver and use the videobuf2
interface instead of the old videobuf. Moreover, it uses also
the control framework which allows the driver to inherit
controls from its subdevice (ADV7180)

Signed-off-by: Federico Vaga federico.v...@gmail.com
Acked-by: Giancarlo Asnaghi giancarlo.asna...@st.com
---
 drivers/media/pci/sta2x11/Kconfig   |2 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c | 1235 ++-
 2 file modificati, 411 inserzioni(+), 826 rimozioni(-)

diff --git a/drivers/media/pci/sta2x11/Kconfig 
b/drivers/media/pci/sta2x11/Kconfig
index 6749f67..654339f 100644
--- a/drivers/media/pci/sta2x11/Kconfig
+++ b/drivers/media/pci/sta2x11/Kconfig
@@ -2,7 +2,7 @@ config STA2X11_VIP
tristate STA2X11 VIP Video For Linux
depends on STA2X11
select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
-   select VIDEOBUF_DMA_CONTIG
+   select VIDEOBUF2_DMA_STREAMING
depends on PCI  VIDEO_V4L2  VIRT_TO_BUS
help
  Say Y for support for STA2X11 VIP (Video Input Port) capture
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 4c10205..f423039 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -1,6 +1,7 @@
 /*
  * This is the driver for the STA2x11 Video Input Port.
  *
+ * Copyright (C) 2012   ST Microelectronics
  * Copyright (C) 2010   WindRiver Systems, Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -19,36 +20,30 @@
  * The full GNU General Public License is included in this distribution in
  * the file called COPYING.
  *
- * Author: Andreas Kies andreas.k...@windriver.com
- * Vlad Lungu vlad.lu...@windriver.com
- *
  */
 
 #include linux/types.h
 #include linux/kernel.h
 #include linux/module.h
 #include linux/init.h
-#include linux/vmalloc.h
-
 #include linux/videodev2.h
-
 #include linux/kmod.h
-
 #include linux/pci.h
 #include linux/interrupt.h
-#include linux/mutex.h
 #include linux/io.h
 #include linux/gpio.h
 #include linux/i2c.h
 #include linux/delay.h
 #include media/v4l2-common.h
 #include media/v4l2-device.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-ioctl.h
-#include media/videobuf-dma-contig.h
+#include media/v4l2-fh.h
+#include media/v4l2-event.h
+#include media/videobuf2-dma-streaming.h
 
 #include sta2x11_vip.h
 
-#define DRV_NAME sta2x11_vip
 #define DRV_VERSION 1.3
 
 #ifndef PCI_DEVICE_ID_STMICRO_VIP
@@ -63,8 +58,8 @@
 #define DVP_TFS0x08
 #define DVP_BFO0x0C
 #define DVP_BFS0x10
-#define DVP_VTP 0x14
-#define DVP_VBP 0x18
+#define DVP_VTP0x14
+#define DVP_VBP0x18
 #define DVP_VMP0x1C
 #define DVP_ITM0x98
 #define DVP_ITS0x9C
@@ -84,44 +79,24 @@
 
 #define DVP_HLFLN_SD   0x0001
 
-#define REG_WRITE(vip, reg, value) iowrite32((value), (vip-iomem)+(reg))
-#define REG_READ(vip, reg) ioread32((vip-iomem)+(reg))
-
 #define SAVE_COUNT 8
 #define AUX_COUNT 3
 #define IRQ_COUNT 1
 
-/**
- * struct sta2x11_vip - All internal data for one instance of device
- * @v4l2_dev: device registered in v4l layer
- * @video_dev: properties of our device
- * @pdev: PCI device
- * @adapter: contains I2C adapter information
- * @register_save_area: All relevant register are saved here during suspend
- * @decoder: contains information about video DAC
- * @format: pixel format, fixed UYVY
- * @std: video standard (e.g. PAL/NTSC)
- * @input: input line for video signal ( 0 or 1 )
- * @users: Number of open of device ( max. 1 )
- * @disabled: Device is in power down state
- * @mutex: ensures exclusive opening of device
- * @slock: for excluse acces of registers
- * @vb_vidq: queue maintained by videobuf layer
- * @capture: linked list of capture buffer
- * @active: struct videobuf_buffer currently beingg filled
- * @started: device is ready to capture frame
- * @closing: device will be shut down
- * @tcount: Number of top frames
- * @bcount: Number of bottom frames
- * @overflow: Number of FIFO overflows
- * @mem_spare: small buffer of unused frame
- * @dma_spare: dma addres of mem_spare
- * @iomem: hardware base address
- * @config: I2C and gpio config from platform
- *
- * All non-local data is accessed via this structure.
- */
 
+struct vip_buffer {
+   struct vb2_buffer   vb;
+   struct list_headlist;
+   dma_addr_t  dma;
+};
+static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
+{
+   return container_of(vb2, struct vip_buffer, vb);
+}
+
+struct sta2x11_vip_fh {
+   struct v4l2_fh fh;
+};
 struct sta2x11_vip {
struct v4l2_device v4l2_dev;
struct video_device *video_dev;
@@ -129,21 +104,27 @@ struct sta2x11_vip {
struct i2c_adapter *adapter;
unsigned int 

[PATCH v2 3/4] sta2x11_vip: convert to videobuf2 and control framework

2012-09-21 Thread Federico Vaga
This patch re-write the driver and use the videobuf2
interface instead of the old videobuf. Moreover, it uses also
the control framework which allows the driver to inherit
controls from its subdevice (ADV7180)

Signed-off-by: Federico Vaga federico.v...@gmail.com
Acked-by: Giancarlo Asnaghi giancarlo.asna...@st.com
---
 drivers/media/pci/sta2x11/Kconfig   |2 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c | 1235 ++-
 2 file modificati, 411 inserzioni(+), 826 rimozioni(-)

diff --git a/drivers/media/pci/sta2x11/Kconfig 
b/drivers/media/pci/sta2x11/Kconfig
index 6749f67..654339f 100644
--- a/drivers/media/pci/sta2x11/Kconfig
+++ b/drivers/media/pci/sta2x11/Kconfig
@@ -2,7 +2,7 @@ config STA2X11_VIP
tristate STA2X11 VIP Video For Linux
depends on STA2X11
select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
-   select VIDEOBUF_DMA_CONTIG
+   select VIDEOBUF2_DMA_STREAMING
depends on PCI  VIDEO_V4L2  VIRT_TO_BUS
help
  Say Y for support for STA2X11 VIP (Video Input Port) capture
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 4c10205..f423039 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -1,6 +1,7 @@
 /*
  * This is the driver for the STA2x11 Video Input Port.
  *
+ * Copyright (C) 2012   ST Microelectronics
  * Copyright (C) 2010   WindRiver Systems, Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -19,36 +20,30 @@
  * The full GNU General Public License is included in this distribution in
  * the file called COPYING.
  *
- * Author: Andreas Kies andreas.k...@windriver.com
- * Vlad Lungu vlad.lu...@windriver.com
- *
  */
 
 #include linux/types.h
 #include linux/kernel.h
 #include linux/module.h
 #include linux/init.h
-#include linux/vmalloc.h
-
 #include linux/videodev2.h
-
 #include linux/kmod.h
-
 #include linux/pci.h
 #include linux/interrupt.h
-#include linux/mutex.h
 #include linux/io.h
 #include linux/gpio.h
 #include linux/i2c.h
 #include linux/delay.h
 #include media/v4l2-common.h
 #include media/v4l2-device.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-ioctl.h
-#include media/videobuf-dma-contig.h
+#include media/v4l2-fh.h
+#include media/v4l2-event.h
+#include media/videobuf2-dma-streaming.h
 
 #include sta2x11_vip.h
 
-#define DRV_NAME sta2x11_vip
 #define DRV_VERSION 1.3
 
 #ifndef PCI_DEVICE_ID_STMICRO_VIP
@@ -63,8 +58,8 @@
 #define DVP_TFS0x08
 #define DVP_BFO0x0C
 #define DVP_BFS0x10
-#define DVP_VTP 0x14
-#define DVP_VBP 0x18
+#define DVP_VTP0x14
+#define DVP_VBP0x18
 #define DVP_VMP0x1C
 #define DVP_ITM0x98
 #define DVP_ITS0x9C
@@ -84,44 +79,24 @@
 
 #define DVP_HLFLN_SD   0x0001
 
-#define REG_WRITE(vip, reg, value) iowrite32((value), (vip-iomem)+(reg))
-#define REG_READ(vip, reg) ioread32((vip-iomem)+(reg))
-
 #define SAVE_COUNT 8
 #define AUX_COUNT 3
 #define IRQ_COUNT 1
 
-/**
- * struct sta2x11_vip - All internal data for one instance of device
- * @v4l2_dev: device registered in v4l layer
- * @video_dev: properties of our device
- * @pdev: PCI device
- * @adapter: contains I2C adapter information
- * @register_save_area: All relevant register are saved here during suspend
- * @decoder: contains information about video DAC
- * @format: pixel format, fixed UYVY
- * @std: video standard (e.g. PAL/NTSC)
- * @input: input line for video signal ( 0 or 1 )
- * @users: Number of open of device ( max. 1 )
- * @disabled: Device is in power down state
- * @mutex: ensures exclusive opening of device
- * @slock: for excluse acces of registers
- * @vb_vidq: queue maintained by videobuf layer
- * @capture: linked list of capture buffer
- * @active: struct videobuf_buffer currently beingg filled
- * @started: device is ready to capture frame
- * @closing: device will be shut down
- * @tcount: Number of top frames
- * @bcount: Number of bottom frames
- * @overflow: Number of FIFO overflows
- * @mem_spare: small buffer of unused frame
- * @dma_spare: dma addres of mem_spare
- * @iomem: hardware base address
- * @config: I2C and gpio config from platform
- *
- * All non-local data is accessed via this structure.
- */
 
+struct vip_buffer {
+   struct vb2_buffer   vb;
+   struct list_headlist;
+   dma_addr_t  dma;
+};
+static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
+{
+   return container_of(vb2, struct vip_buffer, vb);
+}
+
+struct sta2x11_vip_fh {
+   struct v4l2_fh fh;
+};
 struct sta2x11_vip {
struct v4l2_device v4l2_dev;
struct video_device *video_dev;
@@ -129,21 +104,27 @@ struct sta2x11_vip {
struct i2c_adapter *adapter;
unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT];

Re: [PATCH v2 3/4] sta2x11_vip: convert to videobuf2 and control framework

2012-09-21 Thread Hans Verkuil
On Fri September 21 2012 11:21:37 Federico Vaga wrote:
 This patch re-write the driver and use the videobuf2
 interface instead of the old videobuf. Moreover, it uses also
 the control framework which allows the driver to inherit
 controls from its subdevice (ADV7180)

Some more comments below, nothing major.

 Signed-off-by: Federico Vaga federico.v...@gmail.com
 Acked-by: Giancarlo Asnaghi giancarlo.asna...@st.com
 ---
  drivers/media/pci/sta2x11/Kconfig   |2 +-
  drivers/media/pci/sta2x11/sta2x11_vip.c | 1235 
 ++-
  2 file modificati, 411 inserzioni(+), 826 rimozioni(-)
 
 diff --git a/drivers/media/pci/sta2x11/Kconfig 
 b/drivers/media/pci/sta2x11/Kconfig
 index 6749f67..654339f 100644
 --- a/drivers/media/pci/sta2x11/Kconfig
 +++ b/drivers/media/pci/sta2x11/Kconfig
 @@ -2,7 +2,7 @@ config STA2X11_VIP
   tristate STA2X11 VIP Video For Linux
   depends on STA2X11
   select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
 - select VIDEOBUF_DMA_CONTIG
 + select VIDEOBUF2_DMA_STREAMING
   depends on PCI  VIDEO_V4L2  VIRT_TO_BUS
   help
 Say Y for support for STA2X11 VIP (Video Input Port) capture
 diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
 b/drivers/media/pci/sta2x11/sta2x11_vip.c
 index 4c10205..f423039 100644
 --- a/drivers/media/pci/sta2x11/sta2x11_vip.c
 +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
 @@ -1,6 +1,7 @@
  /*
   * This is the driver for the STA2x11 Video Input Port.
   *
 + * Copyright (C) 2012   ST Microelectronics
   * Copyright (C) 2010   WindRiver Systems, Inc.
   *
   * This program is free software; you can redistribute it and/or modify it
 @@ -19,36 +20,30 @@
   * The full GNU General Public License is included in this distribution in
   * the file called COPYING.
   *
 - * Author: Andreas Kies andreas.k...@windriver.com
 - *   Vlad Lungu vlad.lu...@windriver.com
 - *
   */
  
  #include linux/types.h
  #include linux/kernel.h
  #include linux/module.h
  #include linux/init.h
 -#include linux/vmalloc.h
 -
  #include linux/videodev2.h
 -
  #include linux/kmod.h
 -
  #include linux/pci.h
  #include linux/interrupt.h
 -#include linux/mutex.h
  #include linux/io.h
  #include linux/gpio.h
  #include linux/i2c.h
  #include linux/delay.h
  #include media/v4l2-common.h
  #include media/v4l2-device.h
 +#include media/v4l2-ctrls.h
  #include media/v4l2-ioctl.h
 -#include media/videobuf-dma-contig.h
 +#include media/v4l2-fh.h
 +#include media/v4l2-event.h
 +#include media/videobuf2-dma-streaming.h
  
  #include sta2x11_vip.h
  
 -#define DRV_NAME sta2x11_vip
  #define DRV_VERSION 1.3
  
  #ifndef PCI_DEVICE_ID_STMICRO_VIP
 @@ -63,8 +58,8 @@
  #define DVP_TFS  0x08
  #define DVP_BFO  0x0C
  #define DVP_BFS  0x10
 -#define DVP_VTP 0x14
 -#define DVP_VBP 0x18
 +#define DVP_VTP  0x14
 +#define DVP_VBP  0x18
  #define DVP_VMP  0x1C
  #define DVP_ITM  0x98
  #define DVP_ITS  0x9C
 @@ -84,44 +79,24 @@
  
  #define DVP_HLFLN_SD 0x0001
  
 -#define REG_WRITE(vip, reg, value) iowrite32((value), (vip-iomem)+(reg))
 -#define REG_READ(vip, reg) ioread32((vip-iomem)+(reg))
 -
  #define SAVE_COUNT 8
  #define AUX_COUNT 3
  #define IRQ_COUNT 1
  
 -/**
 - * struct sta2x11_vip - All internal data for one instance of device
 - * @v4l2_dev: device registered in v4l layer
 - * @video_dev: properties of our device
 - * @pdev: PCI device
 - * @adapter: contains I2C adapter information
 - * @register_save_area: All relevant register are saved here during suspend
 - * @decoder: contains information about video DAC
 - * @format: pixel format, fixed UYVY
 - * @std: video standard (e.g. PAL/NTSC)
 - * @input: input line for video signal ( 0 or 1 )
 - * @users: Number of open of device ( max. 1 )
 - * @disabled: Device is in power down state
 - * @mutex: ensures exclusive opening of device
 - * @slock: for excluse acces of registers
 - * @vb_vidq: queue maintained by videobuf layer
 - * @capture: linked list of capture buffer
 - * @active: struct videobuf_buffer currently beingg filled
 - * @started: device is ready to capture frame
 - * @closing: device will be shut down
 - * @tcount: Number of top frames
 - * @bcount: Number of bottom frames
 - * @overflow: Number of FIFO overflows
 - * @mem_spare: small buffer of unused frame
 - * @dma_spare: dma addres of mem_spare
 - * @iomem: hardware base address
 - * @config: I2C and gpio config from platform
 - *
 - * All non-local data is accessed via this structure.
 - */
  
 +struct vip_buffer {
 + struct vb2_buffer   vb;
 + struct list_headlist;
 + dma_addr_t  dma;
 +};
 +static inline struct vip_buffer *to_vip_buffer(struct vb2_buffer *vb2)
 +{
 + return container_of(vb2, struct vip_buffer, vb);
 +}
 +
 +struct sta2x11_vip_fh {
 + struct v4l2_fh fh;
 +};

No need to make a sta2x11_vip_fh struct, just use v4l2_fh directly. It