Re: [PATCH 15/15] em28xx: convert to videobuf2

2013-01-08 Thread Frank Schäfer
Am 04.01.2013 21:59, schrieb Devin Heitmueller:
 This patch converts the em28xx driver over to videobuf2.  It is
 likely that em28xx_fh can go away entirely, but that will come in
 a separate patch.

 [mche...@redhat.com: fix a non-trivial merge conflict with some VBI
  patches]

 Signed-off-by: Devin Heitmueller dheitmuel...@kernellabs.com
 ---
  drivers/media/usb/em28xx/Kconfig|3 +-
  drivers/media/usb/em28xx/em28xx-cards.c |7 +-
  drivers/media/usb/em28xx/em28xx-dvb.c   |4 +-
  drivers/media/usb/em28xx/em28xx-vbi.c   |  123 ++---
  drivers/media/usb/em28xx/em28xx-video.c |  743 
 +++
  drivers/media/usb/em28xx/em28xx.h   |   30 +-
  6 files changed, 327 insertions(+), 583 deletions(-)

 diff --git a/drivers/media/usb/em28xx/Kconfig 
 b/drivers/media/usb/em28xx/Kconfig
 index 094c4ec..c754a80 100644
 --- a/drivers/media/usb/em28xx/Kconfig
 +++ b/drivers/media/usb/em28xx/Kconfig
 @@ -3,7 +3,7 @@ config VIDEO_EM28XX
   depends on VIDEO_DEV  I2C
   select VIDEO_TUNER
   select VIDEO_TVEEPROM
 - select VIDEOBUF_VMALLOC
 + select VIDEOBUF2_VMALLOC
   select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
   select VIDEO_TVP5150 if MEDIA_SUBDRV_AUTOSELECT
   select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT
 @@ -48,7 +48,6 @@ config VIDEO_EM28XX_DVB
   select DVB_S5H1409 if MEDIA_SUBDRV_AUTOSELECT
   select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT
   select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT
 - select VIDEOBUF_DVB
   ---help---
 This adds support for DVB cards based on the
 Empiatech em28xx chips.
 diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
 b/drivers/media/usb/em28xx/em28xx-cards.c
 index 4117d38..0a4c868 100644
 --- a/drivers/media/usb/em28xx/em28xx-cards.c
 +++ b/drivers/media/usb/em28xx/em28xx-cards.c
 @@ -57,7 +57,7 @@ module_param(disable_usb_speed_check, int, 0444);
  MODULE_PARM_DESC(disable_usb_speed_check,
override min bandwidth requirement of 480M bps);
  
 -static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
 +static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U };
  module_param_array(card,  int, NULL, 0444);
  MODULE_PARM_DESC(card, card type);
  
 @@ -2965,6 +2965,8 @@ static int em28xx_init_dev(struct em28xx *dev, struct 
 usb_device *udev,
   const char *chip_name = default_chip_name;
  
   dev-udev = udev;
 + mutex_init(dev-vb_queue_lock);
 + mutex_init(dev-vb_vbi_queue_lock);
   mutex_init(dev-ctrl_urb_lock);
   spin_lock_init(dev-slock);
  
 @@ -3411,6 +3413,9 @@ static int em28xx_usb_probe(struct usb_interface 
 *interface,
   /* save our data pointer in this interface device */
   usb_set_intfdata(interface, dev);
  
 + /* initialize videobuf2 stuff */
 + em28xx_vb2_setup(dev);
 +
   /* allocate device struct */
   mutex_init(dev-lock);
   mutex_lock(dev-lock);
 diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
 b/drivers/media/usb/em28xx/em28xx-dvb.c
 index a70b19e..01bb800 100644
 --- a/drivers/media/usb/em28xx/em28xx-dvb.c
 +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
 @@ -27,7 +27,9 @@
  
  #include em28xx.h
  #include media/v4l2-common.h
 -#include media/videobuf-vmalloc.h
 +#include dvb_demux.h
 +#include dvb_net.h
 +#include dmxdev.h
  #include media/tuner.h
  #include tuner-simple.h
  #include linux/gpio.h
 diff --git a/drivers/media/usb/em28xx/em28xx-vbi.c 
 b/drivers/media/usb/em28xx/em28xx-vbi.c
 index d74713b..9fcfc910 100644
 --- a/drivers/media/usb/em28xx/em28xx-vbi.c
 +++ b/drivers/media/usb/em28xx/em28xx-vbi.c
 @@ -41,105 +41,72 @@ MODULE_PARM_DESC(vbi_debug, enable debug messages 
 [vbi]);
  
  /* -- */
  
 -static void
 -free_buffer(struct videobuf_queue *vq, struct em28xx_buffer *buf)
 +static int vbi_queue_setup(struct vb2_queue *vq, const struct v4l2_format 
 *fmt,
 +   unsigned int *nbuffers, unsigned int *nplanes,
 +   unsigned int sizes[], void *alloc_ctxs[])
  {
 - struct em28xx_fh *fh  = vq-priv_data;
 - struct em28xx*dev = fh-dev;
 - unsigned long flags = 0;
 - if (in_interrupt())
 - BUG();
 -
 - /* We used to wait for the buffer to finish here, but this didn't work
 -because, as we were keeping the state as VIDEOBUF_QUEUED,
 -videobuf_queue_cancel marked it as finished for us.
 -(Also, it could wedge forever if the hardware was misconfigured.)
 -
 -This should be safe; by the time we get here, the buffer isn't
 -queued anymore. If we ever start marking the buffers as
 -VIDEOBUF_ACTIVE, it won't be, though.
 - */
 - spin_lock_irqsave(dev-slock, flags);
 - if (dev-usb_ctl.vbi_buf == buf)
 - dev-usb_ctl.vbi_buf = NULL;
 - spin_unlock_irqrestore(dev-slock, flags);
 + struct em28xx 

Re: [PATCH 15/15] em28xx: convert to videobuf2

2013-01-08 Thread Devin Heitmueller
On Tue, Jan 8, 2013 at 1:40 PM, Frank Schäfer
fschaefer@googlemail.com wrote:
 Bad news. :(
 The patch seems to break USB bulk transfer mode. The framerate is zero.
 I've tested with the Silvercrest webcam and the Cinergy 200. Both
 devices work fine when selecting isoc transfers.

I'll take a look.  I cannot actively debug it since I don't have any
devices which do bulk, but I'll at least see if anything jumps out at
me.

If I had to guess, probably something related to the setting up of the
USB alternate.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/15] em28xx: convert to videobuf2

2013-01-04 Thread Devin Heitmueller
This patch converts the em28xx driver over to videobuf2.  It is
likely that em28xx_fh can go away entirely, but that will come in
a separate patch.

[mche...@redhat.com: fix a non-trivial merge conflict with some VBI
 patches]

Signed-off-by: Devin Heitmueller dheitmuel...@kernellabs.com
---
 drivers/media/usb/em28xx/Kconfig|3 +-
 drivers/media/usb/em28xx/em28xx-cards.c |7 +-
 drivers/media/usb/em28xx/em28xx-dvb.c   |4 +-
 drivers/media/usb/em28xx/em28xx-vbi.c   |  123 ++---
 drivers/media/usb/em28xx/em28xx-video.c |  743 +++
 drivers/media/usb/em28xx/em28xx.h   |   30 +-
 6 files changed, 327 insertions(+), 583 deletions(-)

diff --git a/drivers/media/usb/em28xx/Kconfig b/drivers/media/usb/em28xx/Kconfig
index 094c4ec..c754a80 100644
--- a/drivers/media/usb/em28xx/Kconfig
+++ b/drivers/media/usb/em28xx/Kconfig
@@ -3,7 +3,7 @@ config VIDEO_EM28XX
depends on VIDEO_DEV  I2C
select VIDEO_TUNER
select VIDEO_TVEEPROM
-   select VIDEOBUF_VMALLOC
+   select VIDEOBUF2_VMALLOC
select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_TVP5150 if MEDIA_SUBDRV_AUTOSELECT
select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT
@@ -48,7 +48,6 @@ config VIDEO_EM28XX_DVB
select DVB_S5H1409 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT
-   select VIDEOBUF_DVB
---help---
  This adds support for DVB cards based on the
  Empiatech em28xx chips.
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 4117d38..0a4c868 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -57,7 +57,7 @@ module_param(disable_usb_speed_check, int, 0444);
 MODULE_PARM_DESC(disable_usb_speed_check,
 override min bandwidth requirement of 480M bps);
 
-static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
+static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U };
 module_param_array(card,  int, NULL, 0444);
 MODULE_PARM_DESC(card, card type);
 
@@ -2965,6 +2965,8 @@ static int em28xx_init_dev(struct em28xx *dev, struct 
usb_device *udev,
const char *chip_name = default_chip_name;
 
dev-udev = udev;
+   mutex_init(dev-vb_queue_lock);
+   mutex_init(dev-vb_vbi_queue_lock);
mutex_init(dev-ctrl_urb_lock);
spin_lock_init(dev-slock);
 
@@ -3411,6 +3413,9 @@ static int em28xx_usb_probe(struct usb_interface 
*interface,
/* save our data pointer in this interface device */
usb_set_intfdata(interface, dev);
 
+   /* initialize videobuf2 stuff */
+   em28xx_vb2_setup(dev);
+
/* allocate device struct */
mutex_init(dev-lock);
mutex_lock(dev-lock);
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
b/drivers/media/usb/em28xx/em28xx-dvb.c
index a70b19e..01bb800 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -27,7 +27,9 @@
 
 #include em28xx.h
 #include media/v4l2-common.h
-#include media/videobuf-vmalloc.h
+#include dvb_demux.h
+#include dvb_net.h
+#include dmxdev.h
 #include media/tuner.h
 #include tuner-simple.h
 #include linux/gpio.h
diff --git a/drivers/media/usb/em28xx/em28xx-vbi.c 
b/drivers/media/usb/em28xx/em28xx-vbi.c
index d74713b..9fcfc910 100644
--- a/drivers/media/usb/em28xx/em28xx-vbi.c
+++ b/drivers/media/usb/em28xx/em28xx-vbi.c
@@ -41,105 +41,72 @@ MODULE_PARM_DESC(vbi_debug, enable debug messages [vbi]);
 
 /* -- */
 
-static void
-free_buffer(struct videobuf_queue *vq, struct em28xx_buffer *buf)
+static int vbi_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
+   unsigned int *nbuffers, unsigned int *nplanes,
+   unsigned int sizes[], void *alloc_ctxs[])
 {
-   struct em28xx_fh *fh  = vq-priv_data;
-   struct em28xx*dev = fh-dev;
-   unsigned long flags = 0;
-   if (in_interrupt())
-   BUG();
-
-   /* We used to wait for the buffer to finish here, but this didn't work
-  because, as we were keeping the state as VIDEOBUF_QUEUED,
-  videobuf_queue_cancel marked it as finished for us.
-  (Also, it could wedge forever if the hardware was misconfigured.)
-
-  This should be safe; by the time we get here, the buffer isn't
-  queued anymore. If we ever start marking the buffers as
-  VIDEOBUF_ACTIVE, it won't be, though.
-   */
-   spin_lock_irqsave(dev-slock, flags);
-   if (dev-usb_ctl.vbi_buf == buf)
-   dev-usb_ctl.vbi_buf = NULL;
-   spin_unlock_irqrestore(dev-slock, flags);
+   struct em28xx *dev = vb2_get_drv_priv(vq);
+   unsigned long size;
 
-