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 failures.
Video compliance test results summary:
Total: 75, Succeeded: 75, Failed: 0, Warnings: 18
Vbi compliance test results summary:
Total: 75, Succeeded: 75, Failed: 0, Warnings: 0
Signed-off-by: Shuah Khan shua...@osg.samsung.com
---
Changes sunce patch v5:
- Fixed lock warning in au0828_stop_streaming() caused
by calling v4l2_device_call_all(dev-v4l2_dev, 0, video,
s_stream, 0); while holding slock. Removed call to
audio_setup which causes audio glitch.
- Fixed au0828_analog_register() error paths to release
vb2 queues.
Changes since patch v4:
- Updated commit log with correct compliance test
results.
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 | 963
drivers/media/usb/au0828/au0828.h | 61 +-
4 files changed, 442 insertions(+), 706 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)
+