Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Shuah Khan
On 01/23/2015 08:00 AM, Shuah Khan wrote:
 On 01/23/2015 02:50 AM, Hans Verkuil wrote:
 Hi Shuah,

 On 01/23/2015 12:42 AM, Shuah Khan wrote:
 Convert au0828 to use videobuf2. Tested with NTSC.
 Tested video and vbi devices with xawtv, tvtime,
 and vlc. Ran v4l2-compliance to ensure there are
 no regressions. video now has no failures and vbi
 has 3 fewer failures.

 video before:
 test VIDIOC_G_FMT: FAIL 3 failures
 Total: 72, Succeeded: 69, Failed: 3, Warnings: 0

 Video after:
 Total: 72, Succeeded: 72, Failed: 0, Warnings: 18

 vbi before:
 test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
 test VIDIOC_EXPBUF: FAIL
 test USERPTR: FAIL
 Total: 72, Succeeded: 66, Failed: 6, Warnings: 0

 vbi after:
 test VIDIOC_QUERYCAP: FAIL
 test MMAP: FAIL
 Total: 78, Succeeded: 75, Failed: 3, Warnings: 0

 There shouldn't be any fails for VBI. That really needs to be fixed.
 Esp. the QUERYCAP fail should be easy to fix.

 BTW, can you paste the full v4l2-compliance output next time? That's
 more informative than just these summaries.

 
 I will re-run the tests and fix it and resend the patch. I think I was
 seeing querycap compliance failure when run with -V0 option and not when
 I run it without. I can attach the full log.
 

Hi Hans,

Finally some sanity. When I ran the compliance test on vbi device
with incorrect options, hence it was treated as a video device which
explains the following fail message:
fail: v4l2-compliance.cpp(347): node-is_video  !(dcaps  video_caps)
test VIDIOC_QUERYCAP: FAIL

This is my bad - I must have did command recall and just changed the
device file. Sorry for the confusion.

Re-ran the test correctly this time and I don't see any querycap errors.
Please see attached files for vbi and video. I will resend the patch
with updated change log with the correct results.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
Driver Info:
Driver name   : au0828
Card type : Hauppauge HVR950Q
Bus info  : usb-:00:10.1-2
Driver version: 3.19.0
Capabilities  : 0x85230011
Video Capture
VBI Capture
Tuner
Audio
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x05230010
VBI Capture
Tuner
Audio
Read/Write
Streaming
Extended Pix Format

Compliance test for device /dev/vbi0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second vbi open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK
test VIDIOC_G/S_FREQUENCY: OK
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK
Inputs: 3 Audio Inputs: 2 Tuners: 1

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 5 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not 
Supported)
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test 

Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Devin Heitmueller
Hi Shuah,

 TRY_FMT and S_FMT both don't handle invalid pixelformats. Looks like
 there is reason behind this based on the comments:

  /* format-fmt.pix.width only support 720 and height 480 */
 if (width != 720)
 width = 720;
 if (height != 480)
 height = 480;

This actually isn't a bug, and in fact I believe the v4l2-compliance
tool prints out a URL to a thread you should read.  It has to do with
the HVR-950q hardware delivering UYVY video and the behavior being
unspecified for how non-supported pixel formats should be handled
until relatively recently.  As a result, it behaves that way so apps
like tvtime don't break due to expecting legacy behavior.

It has nothing to do with the resolution - in fact the driver is doing
exactly what it is supposed to (if you provide an unsupported
resolution, the driver is supposed to pass back a resolution that is
good and still return success).  It's the application's responsibility
to look at the resolution in the struct after the ioctl call and make
sure it hasn't changed (and if it has, the app should adjust its
expectations accordingly).

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


Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Shuah Khan
On 01/23/2015 12:17 PM, Shuah Khan wrote:
 On 01/23/2015 08:00 AM, Shuah Khan wrote:
 On 01/23/2015 02:50 AM, Hans Verkuil wrote:
 Hi Shuah,

 On 01/23/2015 12:42 AM, Shuah Khan wrote:
 Convert au0828 to use videobuf2. Tested with NTSC.
 Tested video and vbi devices with xawtv, tvtime,
 and vlc. Ran v4l2-compliance to ensure there are
 no regressions. video now has no failures and vbi
 has 3 fewer failures.

 video before:
 test VIDIOC_G_FMT: FAIL 3 failures
 Total: 72, Succeeded: 69, Failed: 3, Warnings: 0

 Video after:
 Total: 72, Succeeded: 72, Failed: 0, Warnings: 18

 vbi before:
 test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
 test VIDIOC_EXPBUF: FAIL
 test USERPTR: FAIL
 Total: 72, Succeeded: 66, Failed: 6, Warnings: 0

 vbi after:
 test VIDIOC_QUERYCAP: FAIL
 test MMAP: FAIL
 Total: 78, Succeeded: 75, Failed: 3, Warnings: 0

 There shouldn't be any fails for VBI. That really needs to be fixed.
 Esp. the QUERYCAP fail should be easy to fix.

 BTW, can you paste the full v4l2-compliance output next time? That's
 more informative than just these summaries.


 I will re-run the tests and fix it and resend the patch. I think I was
 seeing querycap compliance failure when run with -V0 option and not when
 I run it without. I can attach the full log.

 
 Hi Hans,
 
 Finally some sanity. When I ran the compliance test on vbi device
 with incorrect options, hence it was treated as a video device which
 explains the following fail message:
 fail: v4l2-compliance.cpp(347): node-is_video  !(dcaps  video_caps)
   test VIDIOC_QUERYCAP: FAIL
 
 This is my bad - I must have did command recall and just changed the
 device file. Sorry for the confusion.
 
 Re-ran the test correctly this time and I don't see any querycap errors.
 Please see attached files for vbi and video. I will resend the patch
 with updated change log with the correct results.
 
TRY_FMT and S_FMT both don't handle invalid pixelformats. Looks like
there is reason behind this based on the comments:

 /* format-fmt.pix.width only support 720 and height 480 */
if (width != 720)
width = 720;
if (height != 480)
height = 480;

-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
--
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


Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Hans Verkuil
Hi Shuah,

On 01/23/2015 12:42 AM, Shuah Khan wrote:
 Convert au0828 to use videobuf2. Tested with NTSC.
 Tested video and vbi devices with xawtv, tvtime,
 and vlc. Ran v4l2-compliance to ensure there are
 no regressions. video now has no failures and vbi
 has 3 fewer failures.
 
 video before:
 test VIDIOC_G_FMT: FAIL 3 failures
 Total: 72, Succeeded: 69, Failed: 3, Warnings: 0
 
 Video after:
 Total: 72, Succeeded: 72, Failed: 0, Warnings: 18
 
 vbi before:
 test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
 test VIDIOC_EXPBUF: FAIL
 test USERPTR: FAIL
 Total: 72, Succeeded: 66, Failed: 6, Warnings: 0
 
 vbi after:
 test VIDIOC_QUERYCAP: FAIL
 test MMAP: FAIL
 Total: 78, Succeeded: 75, Failed: 3, Warnings: 0

There shouldn't be any fails for VBI. That really needs to be fixed.
Esp. the QUERYCAP fail should be easy to fix.

BTW, can you paste the full v4l2-compliance output next time? That's
more informative than just these summaries.

Regards,

Hans
--
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


Re: [PATCH v4] media: au0828 - convert to use videobuf2

2015-01-23 Thread Shuah Khan
On 01/23/2015 02:50 AM, Hans Verkuil wrote:
 Hi Shuah,
 
 On 01/23/2015 12:42 AM, Shuah Khan wrote:
 Convert au0828 to use videobuf2. Tested with NTSC.
 Tested video and vbi devices with xawtv, tvtime,
 and vlc. Ran v4l2-compliance to ensure there are
 no regressions. video now has no failures and vbi
 has 3 fewer failures.

 video before:
 test VIDIOC_G_FMT: FAIL 3 failures
 Total: 72, Succeeded: 69, Failed: 3, Warnings: 0

 Video after:
 Total: 72, Succeeded: 72, Failed: 0, Warnings: 18

 vbi before:
 test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
 test VIDIOC_EXPBUF: FAIL
 test USERPTR: FAIL
 Total: 72, Succeeded: 66, Failed: 6, Warnings: 0

 vbi after:
 test VIDIOC_QUERYCAP: FAIL
 test MMAP: FAIL
 Total: 78, Succeeded: 75, Failed: 3, Warnings: 0
 
 There shouldn't be any fails for VBI. That really needs to be fixed.
 Esp. the QUERYCAP fail should be easy to fix.
 
 BTW, can you paste the full v4l2-compliance output next time? That's
 more informative than just these summaries.
 

I will re-run the tests and fix it and resend the patch. I think I was
seeing querycap compliance failure when run with -V0 option and not when
I run it without. I can attach the full log.

thanks,
-- Shuah

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
--
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 v4] media: au0828 - convert to use videobuf2

2015-01-22 Thread Shuah Khan
Convert au0828 to use videobuf2. Tested with NTSC.
Tested video and vbi devices with xawtv, tvtime,
and vlc. Ran v4l2-compliance to ensure there are
no regressions. video now has no failures and vbi
has 3 fewer failures.

video before:
test VIDIOC_G_FMT: FAIL 3 failures
Total: 72, Succeeded: 69, Failed: 3, Warnings: 0

Video after:
Total: 72, Succeeded: 72, Failed: 0, Warnings: 18

vbi before:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
test VIDIOC_EXPBUF: FAIL
test USERPTR: FAIL
Total: 72, Succeeded: 66, Failed: 6, Warnings: 0

vbi after:
test VIDIOC_QUERYCAP: FAIL
test MMAP: FAIL
Total: 78, Succeeded: 75, Failed: 3, Warnings: 0

Signed-off-by: Shuah Khan shua...@osg.samsung.com
---
Changes since patch v3:
- Removed unnecessary ret = 0 in au0828_v4l2_open()
- Rest of the patches in the v3 series are good.
  No need to resend them.

 drivers/media/usb/au0828/Kconfig|   2 +-
 drivers/media/usb/au0828/au0828-vbi.c   | 122 ++--
 drivers/media/usb/au0828/au0828-video.c | 962 
 drivers/media/usb/au0828/au0828.h   |  61 +-
 4 files changed, 443 insertions(+), 704 deletions(-)

diff --git a/drivers/media/usb/au0828/Kconfig b/drivers/media/usb/au0828/Kconfig
index 1d410ac..78b797e 100644
--- a/drivers/media/usb/au0828/Kconfig
+++ b/drivers/media/usb/au0828/Kconfig
@@ -4,7 +4,7 @@ config VIDEO_AU0828
depends on I2C  INPUT  DVB_CORE  USB
select I2C_ALGOBIT
select VIDEO_TVEEPROM
-   select VIDEOBUF_VMALLOC
+   select VIDEOBUF2_VMALLOC
select DVB_AU8522_DTV if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_MXL5007T if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/usb/au0828/au0828-vbi.c 
b/drivers/media/usb/au0828/au0828-vbi.c
index 932d24f..f67247c 100644
--- a/drivers/media/usb/au0828/au0828-vbi.c
+++ b/drivers/media/usb/au0828/au0828-vbi.c
@@ -28,111 +28,67 @@
 #include linux/init.h
 #include linux/slab.h
 
-static unsigned int vbibufs = 5;
-module_param(vbibufs, int, 0644);
-MODULE_PARM_DESC(vbibufs, number of vbi buffers, range 2-32);
-
 /* -- */
 
-static void
-free_buffer(struct videobuf_queue *vq, struct au0828_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 au0828_fh *fh  = vq-priv_data;
-   struct au0828_dev*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-isoc_ctl.vbi_buf == buf)
-   dev-isoc_ctl.vbi_buf = NULL;
-   spin_unlock_irqrestore(dev-slock, flags);
+   struct au0828_dev *dev = vb2_get_drv_priv(vq);
+   unsigned long img_size = dev-vbi_width * dev-vbi_height * 2;
+   unsigned long size;
 
-   videobuf_vmalloc_free(buf-vb);
-   buf-vb.state = VIDEOBUF_NEEDS_INIT;
-}
-
-static int
-vbi_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
-{
-   struct au0828_fh *fh  = q-priv_data;
-   struct au0828_dev*dev = fh-dev;
+   size = fmt ? (fmt-fmt.vbi.samples_per_line *
+   (fmt-fmt.vbi.count[0] + fmt-fmt.vbi.count[1])) : img_size;
+   if (size  img_size)
+   return -EINVAL;
 
-   *size = dev-vbi_width * dev-vbi_height * 2;
+   *nplanes = 1;
+   sizes[0] = size;
 
-   if (0 == *count)
-   *count = vbibufs;
-   if (*count  2)
-   *count = 2;
-   if (*count  32)
-   *count = 32;
return 0;
 }
 
-static int
-vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
-   enum v4l2_field field)
+static int vbi_buffer_prepare(struct vb2_buffer *vb)
 {
-   struct au0828_fh *fh  = q-priv_data;
-   struct au0828_dev*dev = fh-dev;
+   struct au0828_dev *dev = vb2_get_drv_priv(vb-vb2_queue);
struct au0828_buffer *buf = container_of(vb, struct au0828_buffer, vb);
-   int  rc = 0;
+   unsigned long size;
 
-   buf-vb.size = dev-vbi_width * dev-vbi_height * 2;
+   size = dev-vbi_width * dev-vbi_height * 2;
 
-   if (0 != buf-vb.baddrbuf-vb.bsize  buf-vb.size)
+   if (vb2_plane_size(vb, 0)  size) {
+