]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
[media] vb2: drop v4l2_format argument from queue_setup
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 28 Oct 2015 02:50:37 +0000 (00:50 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 18 Dec 2015 15:48:19 +0000 (13:48 -0200)
The queue_setup callback has a void pointer that is just for V4L2
and is the pointer to the v4l2_format struct that was passed to
VIDIOC_CREATE_BUFS. The idea was that drivers would use the information
from that struct to buffers suitable for the requested format.

After the vb2 split series this pointer is now a void pointer,
which is ugly, and the reality is that all existing drivers will
effectively just look at the sizeimage field of v4l2_format.

To make this more generic the queue_setup callback is changed:
the void pointer is dropped, instead if the *num_planes argument
is 0, then use the current format size, if it is non-zero, then
it contains the number of requested planes and the sizes array
contains the requested sizes. If either is unsupported, then return
-EINVAL, otherwise use the requested size(s).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
81 files changed:
Documentation/video4linux/v4l2-pci-skeleton.c
drivers/input/touchscreen/sur40.c
drivers/media/dvb-frontends/rtl2832_sdr.c
drivers/media/pci/cobalt/cobalt-v4l2.c
drivers/media/pci/cx23885/cx23885-417.c
drivers/media/pci/cx23885/cx23885-dvb.c
drivers/media/pci/cx23885/cx23885-vbi.c
drivers/media/pci/cx23885/cx23885-video.c
drivers/media/pci/cx25821/cx25821-video.c
drivers/media/pci/cx88/cx88-blackbird.c
drivers/media/pci/cx88/cx88-dvb.c
drivers/media/pci/cx88/cx88-vbi.c
drivers/media/pci/cx88/cx88-video.c
drivers/media/pci/dt3155/dt3155.c
drivers/media/pci/netup_unidvb/netup_unidvb_core.c
drivers/media/pci/saa7134/saa7134-ts.c
drivers/media/pci/saa7134/saa7134-vbi.c
drivers/media/pci/saa7134/saa7134-video.c
drivers/media/pci/saa7134/saa7134.h
drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
drivers/media/pci/solo6x10/solo6x10-v4l2.c
drivers/media/pci/sta2x11/sta2x11_vip.c
drivers/media/pci/tw68/tw68-video.c
drivers/media/platform/am437x/am437x-vpfe.c
drivers/media/platform/blackfin/bfin_capture.c
drivers/media/platform/coda/coda-common.c
drivers/media/platform/davinci/vpbe_display.c
drivers/media/platform/davinci/vpif_capture.c
drivers/media/platform/davinci/vpif_display.c
drivers/media/platform/exynos-gsc/gsc-m2m.c
drivers/media/platform/exynos4-is/fimc-capture.c
drivers/media/platform/exynos4-is/fimc-isp-video.c
drivers/media/platform/exynos4-is/fimc-lite.c
drivers/media/platform/exynos4-is/fimc-m2m.c
drivers/media/platform/m2m-deinterlace.c
drivers/media/platform/marvell-ccic/mcam-core.c
drivers/media/platform/mx2_emmaprp.c
drivers/media/platform/omap3isp/ispvideo.c
drivers/media/platform/rcar_jpu.c
drivers/media/platform/s3c-camif/camif-capture.c
drivers/media/platform/s5p-g2d/g2d.c
drivers/media/platform/s5p-jpeg/jpeg-core.c
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
drivers/media/platform/s5p-tv/mixer_video.c
drivers/media/platform/sh_veu.c
drivers/media/platform/sh_vou.c
drivers/media/platform/soc_camera/atmel-isi.c
drivers/media/platform/soc_camera/mx2_camera.c
drivers/media/platform/soc_camera/mx3_camera.c
drivers/media/platform/soc_camera/rcar_vin.c
drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
drivers/media/platform/sti/bdisp/bdisp-v4l2.c
drivers/media/platform/ti-vpe/vpe.c
drivers/media/platform/vim2m.c
drivers/media/platform/vivid/vivid-sdr-cap.c
drivers/media/platform/vivid/vivid-vbi-cap.c
drivers/media/platform/vivid/vivid-vbi-out.c
drivers/media/platform/vivid/vivid-vid-cap.c
drivers/media/platform/vivid/vivid-vid-out.c
drivers/media/platform/vsp1/vsp1_video.c
drivers/media/platform/xilinx/xilinx-dma.c
drivers/media/usb/airspy/airspy.c
drivers/media/usb/au0828/au0828-vbi.c
drivers/media/usb/au0828/au0828-video.c
drivers/media/usb/em28xx/em28xx-vbi.c
drivers/media/usb/em28xx/em28xx-video.c
drivers/media/usb/go7007/go7007-v4l2.c
drivers/media/usb/hackrf/hackrf.c
drivers/media/usb/msi2500/msi2500.c
drivers/media/usb/pwc/pwc-if.c
drivers/media/usb/s2255/s2255drv.c
drivers/media/usb/stk1160/stk1160-v4l.c
drivers/media/usb/usbtv/usbtv-video.c
drivers/media/usb/uvc/uvc_queue.c
drivers/media/v4l2-core/videobuf2-core.c
drivers/media/v4l2-core/videobuf2-v4l2.c
drivers/staging/media/davinci_vpfe/vpfe_video.c
drivers/staging/media/omap4iss/iss_video.c
drivers/usb/gadget/function/uvc_queue.c
include/media/videobuf2-core.h

index 1c8b102a65299f71bbc1c324388a815fbf4f8665..79af0c0410565f0eaae17b4be4e5185aff3f9ea8 100644 (file)
@@ -163,11 +163,10 @@ static irqreturn_t skeleton_irq(int irq, void *dev_id)
  * minimum number: many DMA engines need a minimum of 2 buffers in the
  * queue and you need to have another available for userspace processing.
  */
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                       unsigned int *nbuffers, unsigned int *nplanes,
                       unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct skeleton *skel = vb2_get_drv_priv(vq);
 
        skel->field = skel->format.field;
@@ -183,12 +182,12 @@ static int queue_setup(struct vb2_queue *vq, const void *parg,
 
        if (vq->num_buffers + *nbuffers < 3)
                *nbuffers = 3 - vq->num_buffers;
+       alloc_ctxs[0] = skel->alloc_ctx;
 
-       if (fmt && fmt->fmt.pix.sizeimage < skel->format.sizeimage)
-               return -EINVAL;
+       if (*nplanes)
+               return sizes[0] < skel->format.sizeimage ? -EINVAL : 0;
        *nplanes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : skel->format.sizeimage;
-       alloc_ctxs[0] = skel->alloc_ctx;
+       sizes[0] = skel->format.sizeimage;
        return 0;
 }
 
index d214f22ed305aab0773fe783c2e692c62fc342eb..3f3e2b12e5e7f7d42849d65e75aba1a2be18b5c8 100644 (file)
@@ -644,22 +644,21 @@ static void sur40_disconnect(struct usb_interface *interface)
  * minimum number: many DMA engines need a minimum of 2 buffers in the
  * queue and you need to have another available for userspace processing.
  */
-static int sur40_queue_setup(struct vb2_queue *q, const void *parg,
+static int sur40_queue_setup(struct vb2_queue *q,
                       unsigned int *nbuffers, unsigned int *nplanes,
                       unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct sur40_state *sur40 = vb2_get_drv_priv(q);
 
        if (q->num_buffers + *nbuffers < 3)
                *nbuffers = 3 - q->num_buffers;
+       alloc_ctxs[0] = sur40->alloc_ctx;
 
-       if (fmt && fmt->fmt.pix.sizeimage < sur40_video_format.sizeimage)
-               return -EINVAL;
+       if (*nplanes)
+               return sizes[0] < sur40_video_format.sizeimage ? -EINVAL : 0;
 
        *nplanes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : sur40_video_format.sizeimage;
-       alloc_ctxs[0] = sur40->alloc_ctx;
+       sizes[0] = sur40_video_format.sizeimage;
 
        return 0;
 }
index dcd8d94c10376ce31ab691a1c460696c14d876b2..238191ddcf351484aab0326e2da4b4d02a35c12b 100644 (file)
@@ -490,7 +490,7 @@ static int rtl2832_sdr_querycap(struct file *file, void *fh,
 
 /* Videobuf2 operations */
 static int rtl2832_sdr_queue_setup(struct vb2_queue *vq,
-               const void *parg, unsigned int *nbuffers,
+               unsigned int *nbuffers,
                unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
 {
        struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq);
index 8cc78c522ac9426e0a1d187b9f7a955f6265c2aa..c0ba458f6cf3781a05839d2b47a36711ad6daa3d 100644 (file)
@@ -43,11 +43,10 @@ static const struct v4l2_dv_timings cea1080p60 = V4L2_DV_BT_CEA_1920X1080P60;
 
 /* vb2 DMA streaming ops */
 
-static int cobalt_queue_setup(struct vb2_queue *q, const void *parg,
+static int cobalt_queue_setup(struct vb2_queue *q,
                        unsigned int *num_buffers, unsigned int *num_planes,
                        unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct cobalt_stream *s = q->drv_priv;
        unsigned size = s->stride * s->height;
 
@@ -55,14 +54,11 @@ static int cobalt_queue_setup(struct vb2_queue *q, const void *parg,
                *num_buffers = 3;
        if (*num_buffers > NR_BUFS)
                *num_buffers = NR_BUFS;
+       alloc_ctxs[0] = s->cobalt->alloc_ctx;
+       if (*num_planes)
+               return sizes[0] < size ? -EINVAL : 0;
        *num_planes = 1;
-       if (fmt) {
-               if (fmt->fmt.pix.sizeimage < size)
-                       return -EINVAL;
-               size = fmt->fmt.pix.sizeimage;
-       }
        sizes[0] = size;
-       alloc_ctxs[0] = s->cobalt->alloc_ctx;
        return 0;
 }
 
index 2fe3708d8654684c0fd35a3d2c42e2daafe01224..bd333875a1f708c5fa05f8fadeb6ef4d851b3d68 100644 (file)
@@ -1138,7 +1138,7 @@ static int cx23885_initialize_codec(struct cx23885_dev *dev, int startencoder)
 
 /* ------------------------------------------------------------------ */
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index c4307ad8594c577e074aab2cb2728f3c42db01a8..5378d9380c05fb3df7728fb73cfb0198a4452285 100644 (file)
@@ -92,7 +92,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 /* ------------------------------------------------------------------ */
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index ab36d12e6ec79d7f1bfbecc8fabeb8d0e84b7650..39750ebcc04cf4d1970b2ccff42dc57f969cea85 100644 (file)
@@ -120,7 +120,7 @@ static int cx23885_start_vbi_dma(struct cx23885_dev    *dev,
 
 /* ------------------------------------------------------------------ */
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 064e5fbf4cf1958aa4f37b1a14e591297359225d..93a3720d9116047ab37a7ad813b25a2920d61b26 100644 (file)
@@ -333,7 +333,7 @@ static int cx23885_start_video_dma(struct cx23885_dev *dev,
        return 0;
 }
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 26e3e296d615afdc87d0b49253f3b56772c7f3cd..644373dd252589a8e81afa133e6d6ef084a2eddd 100644 (file)
@@ -141,20 +141,20 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status)
        return handled;
 }
 
-static int cx25821_queue_setup(struct vb2_queue *q, const void *parg,
+static int cx25821_queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct cx25821_channel *chan = q->drv_priv;
        unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3;
 
-       if (fmt && fmt->fmt.pix.sizeimage < size)
-               return -EINVAL;
+       alloc_ctxs[0] = chan->dev->alloc_ctx;
+
+       if (*num_planes)
+               return sizes[0] < size ? -EINVAL : 0;
 
        *num_planes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size;
-       alloc_ctxs[0] = chan->dev->alloc_ctx;
+       sizes[0] = size;
        return 0;
 }
 
index 27ffb24d73bb6f3a8c0e307143638c18a7f12998..3233d45d1e5baa108a9b6e706f73956a859f1dce 100644 (file)
@@ -637,7 +637,7 @@ static int blackbird_stop_codec(struct cx8802_dev *dev)
 
 /* ------------------------------------------------------------------ */
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index f04835073844be588918f94eb4022bf62567eb44..afb20756d7a56ef54ed49c6b3eaf3d78878f7888 100644 (file)
@@ -82,7 +82,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 /* ------------------------------------------------------------------ */
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 007a5eee8e5ed50db347e4f984785f4c5b4e54b4..ccc646d819f285bba6a17c95b82fd56335d149ec 100644 (file)
@@ -107,7 +107,7 @@ int cx8800_restart_vbi_queue(struct cx8800_dev    *dev,
 
 /* ------------------------------------------------------------------ */
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 5996d06b86cb87b2a7f9746178724b1e19cb96e2..5f331df65fb9717471b7cd6cbdcf220caf5a7c12 100644 (file)
@@ -429,7 +429,7 @@ static int restart_video_queue(struct cx8800_dev    *dev,
 
 /* ------------------------------------------------------------------ */
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index d84abde5ea295ddb0963b86364933a53c944bc22..f09bd73bd16f9713162a132735305e276e2e3521 100644 (file)
@@ -131,22 +131,21 @@ static int wait_i2c_reg(void __iomem *addr)
 }
 
 static int
-dt3155_queue_setup(struct vb2_queue *vq, const void *parg,
+dt3155_queue_setup(struct vb2_queue *vq,
                unsigned int *nbuffers, unsigned int *num_planes,
                unsigned int sizes[], void *alloc_ctxs[])
 
 {
-       const struct v4l2_format *fmt = parg;
        struct dt3155_priv *pd = vb2_get_drv_priv(vq);
        unsigned size = pd->width * pd->height;
 
        if (vq->num_buffers + *nbuffers < 2)
                *nbuffers = 2 - vq->num_buffers;
-       if (fmt && fmt->fmt.pix.sizeimage < size)
-               return -EINVAL;
-       *num_planes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size;
        alloc_ctxs[0] = pd->alloc_ctx;
+       if (*num_planes)
+               return sizes[0] < size ? -EINVAL : 0;
+       *num_planes = 1;
+       sizes[0] = size;
        return 0;
 }
 
index 3fdbd81b558060c1029c6bf621a45d2aa9fd9016..58a8e9db57489fea49137e7ff2715a155d06aadb 100644 (file)
@@ -277,7 +277,6 @@ static irqreturn_t netup_unidvb_isr(int irq, void *dev_id)
 }
 
 static int netup_unidvb_queue_setup(struct vb2_queue *vq,
-                                   const void *parg,
                                    unsigned int *nbuffers,
                                    unsigned int *nplanes,
                                    unsigned int sizes[],
index 7fb5ee7e20acfe37cd4e6df68f7800ef203f2d5c..0584a2adbe9904486b3c4b8e97d658fb123ad600 100644 (file)
@@ -116,7 +116,7 @@ int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2)
 }
 EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare);
 
-int saa7134_ts_queue_setup(struct vb2_queue *q, const void *parg,
+int saa7134_ts_queue_setup(struct vb2_queue *q,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 6271b0eb02653a11290b2e35909d3834385f8f25..e76da37c4a8a25810f87679d9cce24aadf8aafb1 100644 (file)
@@ -138,7 +138,7 @@ static int buffer_prepare(struct vb2_buffer *vb2)
                                    saa7134_buffer_startpage(buf));
 }
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 4d3a7fb6f4756949f7428a5db6cc5735ac72fa53..a63c1366a64efad4ad837a5ae927a3417b39d580 100644 (file)
@@ -904,7 +904,7 @@ static int buffer_prepare(struct vb2_buffer *vb2)
                                    saa7134_buffer_startpage(buf));
 }
 
-static int queue_setup(struct vb2_queue *q, const void *parg,
+static int queue_setup(struct vb2_queue *q,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 7cc7582945508778ba0a0ab4c7f08e95b392ce73..5938bc7819998dfa6b741822143801f327662d33 100644 (file)
@@ -820,7 +820,7 @@ void saa7134_video_fini(struct saa7134_dev *dev);
 
 int saa7134_ts_buffer_init(struct vb2_buffer *vb2);
 int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2);
-int saa7134_ts_queue_setup(struct vb2_queue *q, const void *parg,
+int saa7134_ts_queue_setup(struct vb2_queue *q,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[]);
 int saa7134_ts_start_streaming(struct vb2_queue *vq, unsigned int count);
index 4432fd69b7cbf86db946fb9aa6bfa753cb21434c..1f81f8d3649e55515c87db7534c3ceeab6993386 100644 (file)
@@ -663,7 +663,6 @@ static int solo_ring_thread(void *data)
 }
 
 static int solo_enc_queue_setup(struct vb2_queue *q,
-                               const void *parg,
                                unsigned int *num_buffers,
                                unsigned int *num_planes, unsigned int sizes[],
                                void *alloc_ctxs[])
index f7ce493b1feed72c27dd4f9d58e1ebe15bec5708..212d15efc26bfd9620e6c038af810143a3db9ab8 100644 (file)
@@ -313,7 +313,7 @@ static void solo_stop_thread(struct solo_dev *solo_dev)
        solo_dev->kthread = NULL;
 }
 
-static int solo_queue_setup(struct vb2_queue *q, const void *parg,
+static int solo_queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 6367b455a7e7ea4f2b053b222b12d6f67b1589bd..b8b06fb7bec2dcd93cf70fe5c452e7aa681e81d5 100644 (file)
@@ -265,7 +265,7 @@ static void vip_active_buf_next(struct sta2x11_vip *vip)
 
 
 /* Videobuf2 Operations */
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                       unsigned int *nbuffers, unsigned int *nplanes,
                       unsigned int sizes[], void *alloc_ctxs[])
 {
index 46642ef9151b644413c3de4e33ee5e9279d2107d..2e71af15ddb0693bc4c3c5856913d2bd17bc2eb5 100644 (file)
@@ -376,28 +376,28 @@ static int tw68_buffer_count(unsigned int size, unsigned int count)
 /* ------------------------------------------------------------- */
 /* vb2 queue operations                                          */
 
-static int tw68_queue_setup(struct vb2_queue *q, const void *parg,
+static int tw68_queue_setup(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct tw68_dev *dev = vb2_get_drv_priv(q);
        unsigned tot_bufs = q->num_buffers + *num_buffers;
+       unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3;
 
-       sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3;
+       if (tot_bufs < 2)
+               tot_bufs = 2;
+       tot_bufs = tw68_buffer_count(size, tot_bufs);
+       *num_buffers = tot_bufs - q->num_buffers;
        alloc_ctxs[0] = dev->alloc_ctx;
        /*
-        * We allow create_bufs, but only if the sizeimage is the same as the
+        * We allow create_bufs, but only if the sizeimage is >= as the
         * current sizeimage. The tw68_buffer_count calculation becomes quite
         * difficult otherwise.
         */
-       if (fmt && fmt->fmt.pix.sizeimage < sizes[0])
-               return -EINVAL;
+       if (*num_planes)
+               return sizes[0] < size ? -EINVAL : 0;
        *num_planes = 1;
-       if (tot_bufs < 2)
-               tot_bufs = 2;
-       tot_bufs = tw68_buffer_count(sizes[0], tot_bufs);
-       *num_buffers = tot_bufs - q->num_buffers;
+       sizes[0] = size;
 
        return 0;
 }
index f0480d687f174b259affc527713a394187e069ee..e434c8ef5c5ebf025a590a26b8ea17389d2369ff 100644 (file)
@@ -1898,7 +1898,6 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe)
 /*
  * vpfe_queue_setup - Callback function for buffer setup.
  * @vq: vb2_queue ptr
- * @fmt: v4l2 format
  * @nbuffers: ptr to number of buffers requested by application
  * @nplanes:: contains number of distinct video planes needed to hold a frame
  * @sizes[]: contains the size (in bytes) of each plane.
@@ -1908,22 +1907,24 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe)
  * the buffer count and buffer size
  */
 static int vpfe_queue_setup(struct vb2_queue *vq,
-                           const void *parg,
                            unsigned int *nbuffers, unsigned int *nplanes,
                            unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct vpfe_device *vpfe = vb2_get_drv_priv(vq);
-
-       if (fmt && fmt->fmt.pix.sizeimage < vpfe->fmt.fmt.pix.sizeimage)
-               return -EINVAL;
+       unsigned size = vpfe->fmt.fmt.pix.sizeimage;
 
        if (vq->num_buffers + *nbuffers < 3)
                *nbuffers = 3 - vq->num_buffers;
+       alloc_ctxs[0] = vpfe->alloc_ctx;
+
+       if (*nplanes) {
+               if (sizes[0] < size)
+                       return -EINVAL;
+               size = sizes[0];
+       }
 
        *nplanes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : vpfe->fmt.fmt.pix.sizeimage;
-       alloc_ctxs[0] = vpfe->alloc_ctx;
+       sizes[0] = size;
 
        vpfe_dbg(1, vpfe,
                "nbuffers=%d, size=%u\n", *nbuffers, sizes[0]);
index 7764b9c482ef9f2af8e1f2b84fd1ebd4454f1d29..8ecc05a8e5ae28fb2f96147470fd03e584530ef0 100644 (file)
@@ -202,22 +202,20 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev)
 }
 
 static int bcap_queue_setup(struct vb2_queue *vq,
-                               const void *parg,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
 
-       if (fmt && fmt->fmt.pix.sizeimage < bcap_dev->fmt.sizeimage)
-               return -EINVAL;
-
        if (vq->num_buffers + *nbuffers < 2)
                *nbuffers = 2;
+       alloc_ctxs[0] = bcap_dev->alloc_ctx;
+
+       if (*nplanes)
+               return sizes[0] < bcap_dev->fmt.sizeimage ? -EINVAL : 0;
 
        *nplanes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : bcap_dev->fmt.sizeimage;
-       alloc_ctxs[0] = bcap_dev->alloc_ctx;
+       sizes[0] = bcap_dev->fmt.sizeimage;
 
        return 0;
 }
index f821627d015bab3fd5c99ea9a8d72781cb342568..cf5be54d462d9d546d7ea121cc89f6829ce8b139 100644 (file)
@@ -1131,7 +1131,7 @@ static void set_default_params(struct coda_ctx *ctx)
 /*
  * Queue operations
  */
-static int coda_queue_setup(struct vb2_queue *vq, const void *parg,
+static int coda_queue_setup(struct vb2_queue *vq,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
index 6d91422c4e4c755f0b73d6806a9be31e7c00307c..3fc21766d3a8c25c407a23e2878ed4942139bc05 100644 (file)
@@ -228,28 +228,27 @@ static int vpbe_buffer_prepare(struct vb2_buffer *vb)
  * This function allocates memory for the buffers
  */
 static int
-vpbe_buffer_queue_setup(struct vb2_queue *vq, const void *parg,
+vpbe_buffer_queue_setup(struct vb2_queue *vq,
                        unsigned int *nbuffers, unsigned int *nplanes,
                        unsigned int sizes[], void *alloc_ctxs[])
 
 {
-       const struct v4l2_format *fmt = parg;
        /* Get the file handle object and layer object */
        struct vpbe_layer *layer = vb2_get_drv_priv(vq);
        struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
 
        v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n");
 
-       if (fmt && fmt->fmt.pix.sizeimage < layer->pix_fmt.sizeimage)
-               return -EINVAL;
-
        /* Store number of buffers allocated in numbuffer member */
        if (vq->num_buffers + *nbuffers < VPBE_DEFAULT_NUM_BUFS)
                *nbuffers = VPBE_DEFAULT_NUM_BUFS - vq->num_buffers;
+       alloc_ctxs[0] = layer->alloc_ctx;
+
+       if (*nplanes)
+               return sizes[0] < layer->pix_fmt.sizeimage ? -EINVAL : 0;
 
        *nplanes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : layer->pix_fmt.sizeimage;
-       alloc_ctxs[0] = layer->alloc_ctx;
+       sizes[0] = layer->pix_fmt.sizeimage;
 
        return 0;
 }
index c1e573b7cc6fb9ee66d6bcc05b7e977ecdc708c3..fad5b383706fa892f6f84a4eae7dcf5af687f7b9 100644 (file)
@@ -104,7 +104,6 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb)
 /**
  * vpif_buffer_queue_setup : Callback function for buffer setup.
  * @vq: vb2_queue ptr
- * @fmt: v4l2 format
  * @nbuffers: ptr to number of buffers requested by application
  * @nplanes:: contains number of distinct video planes needed to hold a frame
  * @sizes[]: contains the size (in bytes) of each plane.
@@ -114,26 +113,26 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb)
  * the buffer count and buffer size
  */
 static int vpif_buffer_queue_setup(struct vb2_queue *vq,
-                               const void *parg,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct channel_obj *ch = vb2_get_drv_priv(vq);
-       struct common_obj *common;
-
-       common = &ch->common[VPIF_VIDEO_INDEX];
+       struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
+       unsigned size = common->fmt.fmt.pix.sizeimage;
 
        vpif_dbg(2, debug, "vpif_buffer_setup\n");
 
-       if (fmt && fmt->fmt.pix.sizeimage < common->fmt.fmt.pix.sizeimage)
-               return -EINVAL;
+       if (*nplanes) {
+               if (sizes[0] < size)
+                       return -EINVAL;
+               size = sizes[0];
+       }
 
        if (vq->num_buffers + *nbuffers < 3)
                *nbuffers = 3 - vq->num_buffers;
 
        *nplanes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : common->fmt.fmt.pix.sizeimage;
+       sizes[0] = size;
        alloc_ctxs[0] = common->alloc_ctx;
 
        /* Calculate the offset for Y and C data in the buffer */
index fd2780306c1771eae234e74b621c0ac2920ce415..534b50ace3a3a57b1c242bcf563a0c95e252e820 100644 (file)
@@ -99,7 +99,6 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb)
 /**
  * vpif_buffer_queue_setup : Callback function for buffer setup.
  * @vq: vb2_queue ptr
- * @fmt: v4l2 format
  * @nbuffers: ptr to number of buffers requested by application
  * @nplanes:: contains number of distinct video planes needed to hold a frame
  * @sizes[]: contains the size (in bytes) of each plane.
@@ -109,22 +108,24 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb)
  * the buffer count and buffer size
  */
 static int vpif_buffer_queue_setup(struct vb2_queue *vq,
-                               const void *parg,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct channel_obj *ch = vb2_get_drv_priv(vq);
        struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
+       unsigned size = common->fmt.fmt.pix.sizeimage;
 
-       if (fmt && fmt->fmt.pix.sizeimage < common->fmt.fmt.pix.sizeimage)
-               return -EINVAL;
+       if (*nplanes) {
+               if (sizes[0] < size)
+                       return -EINVAL;
+               size = sizes[0];
+       }
 
        if (vq->num_buffers + *nbuffers < 3)
                *nbuffers = 3 - vq->num_buffers;
 
        *nplanes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : common->fmt.fmt.pix.sizeimage;
+       sizes[0] = size;
        alloc_ctxs[0] = common->alloc_ctx;
 
        /* Calculate the offset for Y and C data  in the buffer */
index d82e717acba7b76e90254afcddd605a7b99c8ca8..ea9230ef35e3fd5fa56c3c423a384bddcdd87595 100644 (file)
@@ -212,7 +212,6 @@ static void gsc_m2m_device_run(void *priv)
 }
 
 static int gsc_m2m_queue_setup(struct vb2_queue *vq,
-                       const void *parg,
                        unsigned int *num_buffers, unsigned int *num_planes,
                        unsigned int sizes[], void *allocators[])
 {
index 99e57320e6f7b530984a6655a0152e77bb512ceb..beadccb8abd7344c4b6f4dc20fea8e8586c10f0e 100644 (file)
@@ -338,37 +338,36 @@ int fimc_capture_resume(struct fimc_dev *fimc)
 
 }
 
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                       unsigned int *num_buffers, unsigned int *num_planes,
                       unsigned int sizes[], void *allocators[])
 {
-       const struct v4l2_format *pfmt = parg;
-       const struct v4l2_pix_format_mplane *pixm = NULL;
        struct fimc_ctx *ctx = vq->drv_priv;
        struct fimc_frame *frame = &ctx->d_frame;
        struct fimc_fmt *fmt = frame->fmt;
-       unsigned long wh;
+       unsigned long wh = frame->f_width * frame->f_height;
        int i;
 
-       if (pfmt) {
-               pixm = &pfmt->fmt.pix_mp;
-               fmt = fimc_find_format(&pixm->pixelformat, NULL,
-                                      FMT_FLAGS_CAM | FMT_FLAGS_M2M, -1);
-               wh = pixm->width * pixm->height;
-       } else {
-               wh = frame->f_width * frame->f_height;
-       }
-
        if (fmt == NULL)
                return -EINVAL;
 
+       if (*num_planes) {
+               if (*num_planes != fmt->memplanes)
+                       return -EINVAL;
+               for (i = 0; i < *num_planes; i++) {
+                       if (sizes[i] < (wh * fmt->depth[i]) / 8)
+                               return -EINVAL;
+                       allocators[i] = ctx->fimc_dev->alloc_ctx;
+               }
+               return 0;
+       }
+
        *num_planes = fmt->memplanes;
 
        for (i = 0; i < fmt->memplanes; i++) {
                unsigned int size = (wh * fmt->depth[i]) / 8;
-               if (pixm)
-                       sizes[i] = max(size, pixm->plane_fmt[i].sizeimage);
-               else if (fimc_fmt_is_user_defined(fmt->color))
+
+               if (fimc_fmt_is_user_defined(fmt->color))
                        sizes[i] = frame->payload[i];
                else
                        sizes[i] = max_t(u32, size, frame->payload[i]);
index f88a3690848938c96833bcfdceed5c4b03f33380..273e7a5c7256249fe6fba807e08ad10c19ffaf1c 100644 (file)
 #include "fimc-is-param.h"
 
 static int isp_video_capture_queue_setup(struct vb2_queue *vq,
-                       const void *parg,
                        unsigned int *num_buffers, unsigned int *num_planes,
                        unsigned int sizes[], void *allocators[])
 {
-       const struct v4l2_format *pfmt = parg;
        struct fimc_isp *isp = vb2_get_drv_priv(vq);
        struct v4l2_pix_format_mplane *vid_fmt = &isp->video_capture.pixfmt;
-       const struct v4l2_pix_format_mplane *pixm = NULL;
-       const struct fimc_fmt *fmt;
+       const struct fimc_fmt *fmt = isp->video_capture.format;
        unsigned int wh, i;
 
-       if (pfmt) {
-               pixm = &pfmt->fmt.pix_mp;
-               fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, -1);
-               wh = pixm->width * pixm->height;
-       } else {
-               fmt = isp->video_capture.format;
-               wh = vid_fmt->width * vid_fmt->height;
-       }
+       wh = vid_fmt->width * vid_fmt->height;
 
        if (fmt == NULL)
                return -EINVAL;
 
        *num_buffers = clamp_t(u32, *num_buffers, FIMC_ISP_REQ_BUFS_MIN,
                                                FIMC_ISP_REQ_BUFS_MAX);
+       if (*num_planes) {
+               if (*num_planes != fmt->memplanes)
+                       return -EINVAL;
+               for (i = 0; i < *num_planes; i++) {
+                       if (sizes[i] < (wh * fmt->depth[i]) / 8)
+                               return -EINVAL;
+                       allocators[i] = isp->alloc_ctx;
+               }
+               return 0;
+       }
+
        *num_planes = fmt->memplanes;
 
        for (i = 0; i < fmt->memplanes; i++) {
-               unsigned int size = (wh * fmt->depth[i]) / 8;
-               if (pixm)
-                       sizes[i] = max(size, pixm->plane_fmt[i].sizeimage);
-               else
-                       sizes[i] = size;
+               sizes[i] = (wh * fmt->depth[i]) / 8;
                allocators[i] = isp->alloc_ctx;
        }
 
index 6f76afd909c4b345f9972747767a8a31a7f45811..15d6fc983951cca31adb669e7e25ecf79f43d933 100644 (file)
@@ -355,37 +355,34 @@ static void stop_streaming(struct vb2_queue *q)
        fimc_lite_stop_capture(fimc, false);
 }
 
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                       unsigned int *num_buffers, unsigned int *num_planes,
                       unsigned int sizes[], void *allocators[])
 {
-       const struct v4l2_format *pfmt = parg;
-       const struct v4l2_pix_format_mplane *pixm = NULL;
        struct fimc_lite *fimc = vq->drv_priv;
        struct flite_frame *frame = &fimc->out_frame;
        const struct fimc_fmt *fmt = frame->fmt;
-       unsigned long wh;
+       unsigned long wh = frame->f_width * frame->f_height;
        int i;
 
-       if (pfmt) {
-               pixm = &pfmt->fmt.pix_mp;
-               fmt = fimc_lite_find_format(&pixm->pixelformat, NULL, 0, -1);
-               wh = pixm->width * pixm->height;
-       } else {
-               wh = frame->f_width * frame->f_height;
-       }
-
        if (fmt == NULL)
                return -EINVAL;
 
+       if (*num_planes) {
+               if (*num_planes != fmt->memplanes)
+                       return -EINVAL;
+               for (i = 0; i < *num_planes; i++) {
+                       if (sizes[i] < (wh * fmt->depth[i]) / 8)
+                               return -EINVAL;
+                       allocators[i] = fimc->alloc_ctx;
+               }
+               return 0;
+       }
+
        *num_planes = fmt->memplanes;
 
        for (i = 0; i < fmt->memplanes; i++) {
-               unsigned int size = (wh * fmt->depth[i]) / 8;
-               if (pixm)
-                       sizes[i] = max(size, pixm->plane_fmt[i].sizeimage);
-               else
-                       sizes[i] = size;
+               sizes[i] = (wh * fmt->depth[i]) / 8;
                allocators[i] = fimc->alloc_ctx;
        }
 
index 4d1d64a46b2155770dead95d8a23c60bd664475f..4c04b596462404efbf41602931800b9a5fba372f 100644 (file)
@@ -176,7 +176,7 @@ static void fimc_job_abort(void *priv)
        fimc_m2m_shutdown(priv);
 }
 
-static int fimc_queue_setup(struct vb2_queue *vq, const void *parg,
+static int fimc_queue_setup(struct vb2_queue *vq,
                            unsigned int *num_buffers, unsigned int *num_planes,
                            unsigned int sizes[], void *allocators[])
 {
index 29973f9bf8db5c0fa9eff5840c965b0466b3aa17..652eebdbcd8ec73a4fb4e34203626dd3bc9333d5 100644 (file)
@@ -798,7 +798,6 @@ struct vb2_dc_conf {
 };
 
 static int deinterlace_queue_setup(struct vb2_queue *vq,
-                               const void *parg,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
index 4f2ec88ab89032492791b5e5ad7cecfc2bb9ed9e..7080a88b6a95b36707c93ff2cfe004d92133c809 100644 (file)
@@ -1049,24 +1049,25 @@ static int mcam_read_setup(struct mcam_camera *cam)
  */
 
 static int mcam_vb_queue_setup(struct vb2_queue *vq,
-               const void *parg, unsigned int *nbufs,
+               unsigned int *nbufs,
                unsigned int *num_planes, unsigned int sizes[],
                void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct mcam_camera *cam = vb2_get_drv_priv(vq);
        int minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2;
+       unsigned size = cam->pix_format.sizeimage;
 
-       if (fmt && fmt->fmt.pix.sizeimage < cam->pix_format.sizeimage)
-               return -EINVAL;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : cam->pix_format.sizeimage;
-       *num_planes = 1; /* Someday we have to support planar formats... */
        if (*nbufs < minbufs)
                *nbufs = minbufs;
        if (cam->buffer_mode == B_DMA_contig)
                alloc_ctxs[0] = cam->vb_alloc_ctx;
        else if (cam->buffer_mode == B_DMA_sg)
                alloc_ctxs[0] = cam->vb_alloc_ctx_sg;
+
+       if (*num_planes)
+               return sizes[0] < size ? -EINVAL : 0;
+       sizes[0] = size;
+       *num_planes = 1; /* Someday we have to support planar formats... */
        return 0;
 }
 
index 03a1b606655df8cf81cafea470d600107be58e05..cb7d4b518318b299e16f1e8711c66132281316c3 100644 (file)
@@ -689,7 +689,6 @@ static const struct v4l2_ioctl_ops emmaprp_ioctl_ops = {
  * Queue operations
  */
 static int emmaprp_queue_setup(struct vb2_queue *vq,
-                               const void *parg,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
index f4f591652432df898ea924a1a8f2585b08785a1f..9cc4878f784f075090fe6d205875ea5394037259 100644 (file)
@@ -320,7 +320,6 @@ isp_video_check_format(struct isp_video *video, struct isp_video_fh *vfh)
  */
 
 static int isp_video_queue_setup(struct vb2_queue *queue,
-                                const void *parg,
                                 unsigned int *count, unsigned int *num_planes,
                                 unsigned int sizes[], void *alloc_ctxs[])
 {
index 86d2a3d18241096d4d4384f62a851ed767c93766..742f13ee67a9206d0ac91784ad76d6517ac8a54a 100644 (file)
@@ -1015,28 +1015,33 @@ static int jpu_controls_create(struct jpu_ctx *ctx)
  * ============================================================================
  */
 static int jpu_queue_setup(struct vb2_queue *vq,
-                          const void *parg,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct jpu_ctx *ctx = vb2_get_drv_priv(vq);
        struct jpu_q_data *q_data;
        unsigned int i;
 
        q_data = jpu_get_q_data(ctx, vq->type);
 
-       *nplanes = q_data->format.num_planes;
+       if (*nplanes) {
+               if (*nplanes != q_data->format.num_planes)
+                       return -EINVAL;
 
-       for (i = 0; i < *nplanes; i++) {
-               unsigned int q_size = q_data->format.plane_fmt[i].sizeimage;
-               unsigned int f_size = fmt ?
-                       fmt->fmt.pix_mp.plane_fmt[i].sizeimage : 0;
+               for (i = 0; i < *nplanes; i++) {
+                       unsigned int q_size = q_data->format.plane_fmt[i].sizeimage;
 
-               if (fmt && f_size < q_size)
-                       return -EINVAL;
+                       if (sizes[i] < q_size)
+                               return -EINVAL;
+                       alloc_ctxs[i] = ctx->jpu->alloc_ctx;
+               }
+               return 0;
+       }
 
-               sizes[i] = fmt ? f_size : q_size;
+       *nplanes = q_data->format.num_planes;
+
+       for (i = 0; i < *nplanes; i++) {
+               sizes[i] = q_data->format.plane_fmt[i].sizeimage;
                alloc_ctxs[i] = ctx->jpu->alloc_ctx;
        }
 
index 537b858cb94a62c36d93cc57c1c1dc0091be1514..68e651295ded11530eed52d5b25ae2c838fb7e17 100644 (file)
@@ -435,39 +435,28 @@ static void stop_streaming(struct vb2_queue *vq)
        camif_stop_capture(vp);
 }
 
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                       unsigned int *num_buffers, unsigned int *num_planes,
                       unsigned int sizes[], void *allocators[])
 {
-       const struct v4l2_format *pfmt = parg;
-       const struct v4l2_pix_format *pix = NULL;
        struct camif_vp *vp = vb2_get_drv_priv(vq);
        struct camif_dev *camif = vp->camif;
        struct camif_frame *frame = &vp->out_frame;
-       const struct camif_fmt *fmt;
+       const struct camif_fmt *fmt = vp->out_fmt;
        unsigned int size;
 
-       if (pfmt) {
-               pix = &pfmt->fmt.pix;
-               fmt = s3c_camif_find_format(vp, &pix->pixelformat, -1);
-               if (fmt == NULL)
-                       return -EINVAL;
-               size = (pix->width * pix->height * fmt->depth) / 8;
-       } else {
-               fmt = vp->out_fmt;
-               if (fmt == NULL)
-                       return -EINVAL;
-               size = (frame->f_width * frame->f_height * fmt->depth) / 8;
-       }
-
-       *num_planes = 1;
+       if (fmt == NULL)
+               return -EINVAL;
 
-       if (pix)
-               sizes[0] = max(size, pix->sizeimage);
-       else
-               sizes[0] = size;
+       size = (frame->f_width * frame->f_height * fmt->depth) / 8;
        allocators[0] = camif->alloc_ctx;
 
+       if (*num_planes)
+               return sizes[0] < size ? -EINVAL : 0;
+
+       *num_planes = 1;
+       sizes[0] = size;
+
        pr_debug("size: %u\n", sizes[0]);
        return 0;
 }
index e1936d9d27dacd8d9c3d5f0398569266d72493ac..12b4415bc283526355faadfbd243b4c4015adee8 100644 (file)
@@ -101,7 +101,7 @@ static struct g2d_frame *get_frame(struct g2d_ctx *ctx,
        }
 }
 
-static int g2d_queue_setup(struct vb2_queue *vq, const void *parg,
+static int g2d_queue_setup(struct vb2_queue *vq,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 4a608cbe0fdb4628975db86730b3ba28f3dae24a..30440b0609af6499d26c8bf8451f21a1cdd61dc1 100644 (file)
@@ -2430,7 +2430,6 @@ static struct v4l2_m2m_ops exynos4_jpeg_m2m_ops = {
  */
 
 static int s5p_jpeg_queue_setup(struct vb2_queue *vq,
-                          const void *parg,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 1c4998c221a26ab9a5786f01551a358495953109..dabf26399a9e0d90e96b65098e337b16ba5db967 100644 (file)
@@ -888,7 +888,7 @@ static const struct v4l2_ioctl_ops s5p_mfc_dec_ioctl_ops = {
 };
 
 static int s5p_mfc_queue_setup(struct vb2_queue *vq,
-                       const void *parg, unsigned int *buf_count,
+                       unsigned int *buf_count,
                        unsigned int *plane_count, unsigned int psize[],
                        void *allocators[])
 {
index 115b7dac1d4cdfffaf361a6638423442879f0c42..9916cded4a724e055efd8b69602a6df9bcbfeba8 100644 (file)
@@ -1818,7 +1818,6 @@ static int check_vb_with_fmt(struct s5p_mfc_fmt *fmt, struct vb2_buffer *vb)
 }
 
 static int s5p_mfc_queue_setup(struct vb2_queue *vq,
-                       const void *parg,
                        unsigned int *buf_count, unsigned int *plane_count,
                        unsigned int psize[], void *allocators[])
 {
index dc1c679e136c18456d09697e8d65bd87d67c37c4..d9e7f030294c7b3bcfa4f3d1984353a734f69898 100644 (file)
@@ -881,7 +881,7 @@ static const struct v4l2_file_operations mxr_fops = {
        .unlocked_ioctl = video_ioctl2,
 };
 
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
        unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[],
        void *alloc_ctxs[])
 {
index d6ab33e7060aa824accddf2e295d77062f37984c..82c39f305b54067b25011078c7f0f522d7c61284 100644 (file)
@@ -865,32 +865,14 @@ static const struct v4l2_ioctl_ops sh_veu_ioctl_ops = {
                /* ========== Queue operations ========== */
 
 static int sh_veu_queue_setup(struct vb2_queue *vq,
-                             const void *parg,
                              unsigned int *nbuffers, unsigned int *nplanes,
                              unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *f = parg;
        struct sh_veu_dev *veu = vb2_get_drv_priv(vq);
-       struct sh_veu_vfmt *vfmt;
-       unsigned int size, count = *nbuffers;
-
-       if (f) {
-               const struct v4l2_pix_format *pix = &f->fmt.pix;
-               const struct sh_veu_format *fmt = sh_veu_find_fmt(f);
-               struct v4l2_format ftmp = *f;
-
-               if (fmt->fourcc != pix->pixelformat)
-                       return -EINVAL;
-               sh_veu_try_fmt(&ftmp, fmt);
-               if (ftmp.fmt.pix.width != pix->width ||
-                   ftmp.fmt.pix.height != pix->height)
-                       return -EINVAL;
-               size = pix->bytesperline ? pix->bytesperline * pix->height * fmt->depth / fmt->ydepth :
-                       pix->width * pix->height * fmt->depth / fmt->ydepth;
-       } else {
-               vfmt = sh_veu_get_vfmt(veu, vq->type);
-               size = vfmt->bytesperline * vfmt->frame.height * vfmt->fmt->depth / vfmt->fmt->ydepth;
-       }
+       struct sh_veu_vfmt *vfmt = sh_veu_get_vfmt(veu, vq->type);
+       unsigned int count = *nbuffers;
+       unsigned int size = vfmt->bytesperline * vfmt->frame.height *
+               vfmt->fmt->depth / vfmt->fmt->ydepth;
 
        if (count < 2)
                *nbuffers = count = 2;
@@ -900,6 +882,11 @@ static int sh_veu_queue_setup(struct vb2_queue *vq,
                *nbuffers = count;
        }
 
+       if (*nplanes) {
+               alloc_ctxs[0] = veu->alloc_ctx;
+               return sizes[0] < size ? -EINVAL : 0;
+       }
+
        *nplanes = 1;
        sizes[0] = size;
        alloc_ctxs[0] = veu->alloc_ctx;
index 544e2b5a2ec34b53b1c2951d0f8486b582a8057d..fd0524ec1ccc13a11a3384bc7b54b7f1639f1ef6 100644 (file)
@@ -243,22 +243,21 @@ static void sh_vou_stream_config(struct sh_vou_device *vou_dev)
 }
 
 /* Locking: caller holds fop_lock mutex */
-static int sh_vou_queue_setup(struct vb2_queue *vq, const void *parg,
+static int sh_vou_queue_setup(struct vb2_queue *vq,
                       unsigned int *nbuffers, unsigned int *nplanes,
                       unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq);
        struct v4l2_pix_format *pix = &vou_dev->pix;
        int bytes_per_line = vou_fmt[vou_dev->pix_idx].bpp * pix->width / 8;
 
        dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__);
 
-       if (fmt && fmt->fmt.pix.sizeimage < pix->height * bytes_per_line)
-               return -EINVAL;
-       *nplanes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : pix->height * bytes_per_line;
        alloc_ctxs[0] = vou_dev->alloc_ctx;
+       if (*nplanes)
+               return sizes[0] < pix->height * bytes_per_line ? -EINVAL : 0;
+       *nplanes = 1;
+       sizes[0] = pix->height * bytes_per_line;
        return 0;
 }
 
index f5f815d792b7ec56094ed9abe6da153189f214a5..b78aa0250b2a7ad3be8b4c64579ccd2eaebce552 100644 (file)
@@ -303,7 +303,7 @@ static int atmel_isi_wait_status(struct atmel_isi *isi, int wait_reset)
 /* ------------------------------------------------------------------
        Videobuf operations
    ------------------------------------------------------------------*/
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
index 276beaefca7cda5e84596f5b7a8296c338013275..8889b299a74205c03d54facacf1b0cfeefbbfc79 100644 (file)
@@ -469,21 +469,15 @@ static void mx2_camera_clock_stop(struct soc_camera_host *ici)
  *  Videobuf operations
  */
 static int mx2_videobuf_setup(struct vb2_queue *vq,
-                       const void *parg,
                        unsigned int *count, unsigned int *num_planes,
                        unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct mx2_camera_dev *pcdev = ici->priv;
 
        dev_dbg(icd->parent, "count=%d, size=%d\n", *count, sizes[0]);
 
-       /* TODO: support for VIDIOC_CREATE_BUFS not ready */
-       if (fmt != NULL)
-               return -ENOTTY;
-
        alloc_ctxs[0] = pcdev->alloc_ctx;
 
        sizes[0] = icd->sizeimage;
index 046ebf0b56a0ee6e46ef9b527ff894338e8c043b..bbe01e86a0cadf22d24588b00a360a9b3b335760 100644 (file)
@@ -185,11 +185,9 @@ static void mx3_cam_dma_done(void *arg)
  * Calculate the __buffer__ (not data) size and number of buffers.
  */
 static int mx3_videobuf_setup(struct vb2_queue *vq,
-                       const void *parg,
                        unsigned int *count, unsigned int *num_planes,
                        unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct mx3_camera_dev *mx3_cam = ici->priv;
@@ -197,33 +195,6 @@ static int mx3_videobuf_setup(struct vb2_queue *vq,
        if (!mx3_cam->idmac_channel[0])
                return -EINVAL;
 
-       if (fmt) {
-               const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd,
-                                                               fmt->fmt.pix.pixelformat);
-               unsigned int bytes_per_line;
-               int ret;
-
-               if (!xlate)
-                       return -EINVAL;
-
-               ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width,
-                                             xlate->host_fmt);
-               if (ret < 0)
-                       return ret;
-
-               bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret);
-
-               ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line,
-                                         fmt->fmt.pix.height);
-               if (ret < 0)
-                       return ret;
-
-               sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret);
-       } else {
-               /* Called from VIDIOC_REQBUFS or in compatibility mode */
-               sizes[0] = icd->sizeimage;
-       }
-
        alloc_ctxs[0] = mx3_cam->alloc_ctx;
 
        if (!vq->num_buffers)
@@ -232,9 +203,14 @@ static int mx3_videobuf_setup(struct vb2_queue *vq,
        if (!*count)
                *count = 2;
 
+       /* Called from VIDIOC_REQBUFS or in compatibility mode */
+       if (!*num_planes)
+               sizes[0] = icd->sizeimage;
+       else if (sizes[0] < icd->sizeimage)
+               return -EINVAL;
+
        /* If *num_planes != 0, we have already verified *count. */
-       if (!*num_planes &&
-           sizes[0] * *count + mx3_cam->buf_total > MAX_VIDEO_MEM * 1024 * 1024)
+       if (sizes[0] * *count + mx3_cam->buf_total > MAX_VIDEO_MEM * 1024 * 1024)
                *count = (MAX_VIDEO_MEM * 1024 * 1024 - mx3_cam->buf_total) /
                        sizes[0];
 
index 5d90f39cbb3ea6708c59b3767dc2105d5270341b..b0043cd209aa794def2876a038ecb2f6c96cc240 100644 (file)
@@ -531,46 +531,14 @@ struct rcar_vin_cam {
  * required
  */
 static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
-                                  const void *parg,
                                   unsigned int *count,
                                   unsigned int *num_planes,
                                   unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct rcar_vin_priv *priv = ici->priv;
 
-       if (fmt) {
-               const struct soc_camera_format_xlate *xlate;
-               unsigned int bytes_per_line;
-               int ret;
-
-               if (fmt->fmt.pix.sizeimage < icd->sizeimage)
-                       return -EINVAL;
-
-               xlate = soc_camera_xlate_by_fourcc(icd,
-                                                  fmt->fmt.pix.pixelformat);
-               if (!xlate)
-                       return -EINVAL;
-               ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width,
-                                             xlate->host_fmt);
-               if (ret < 0)
-                       return ret;
-
-               bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret);
-
-               ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line,
-                                         fmt->fmt.pix.height);
-               if (ret < 0)
-                       return ret;
-
-               sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret);
-       } else {
-               /* Called from VIDIOC_REQBUFS or in compatibility mode */
-               sizes[0] = icd->sizeimage;
-       }
-
        alloc_ctxs[0] = priv->alloc_ctx;
 
        if (!vq->num_buffers)
@@ -580,14 +548,18 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
                *count = 2;
        priv->vb_count = *count;
 
-       *num_planes = 1;
-
        /* Number of hardware slots */
        if (is_continuous_transfer(priv))
                priv->nr_hw_slots = MAX_BUFFER_NUM;
        else
                priv->nr_hw_slots = 1;
 
+       if (*num_planes)
+               return sizes[0] < icd->sizeimage ? -EINVAL : 0;
+
+       sizes[0] = icd->sizeimage;
+       *num_planes = 1;
+
        dev_dbg(icd->parent, "count=%d, size=%u\n", *count, sizes[0]);
 
        return 0;
index ad21307878cf3488caacc50677a4938356e18c76..4e9bc04b92cbff316f5368e49a70b634d4fc6c0b 100644 (file)
@@ -210,43 +210,14 @@ static int sh_mobile_ceu_soft_reset(struct sh_mobile_ceu_dev *pcdev)
  *               for the current frame format if required
  */
 static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq,
-                       const void *parg,
                        unsigned int *count, unsigned int *num_planes,
                        unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct soc_camera_device *icd = container_of(vq,
                        struct soc_camera_device, vb2_vidq);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
 
-       if (fmt) {
-               const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd,
-                                                               fmt->fmt.pix.pixelformat);
-               unsigned int bytes_per_line;
-               int ret;
-
-               if (!xlate)
-                       return -EINVAL;
-
-               ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width,
-                                             xlate->host_fmt);
-               if (ret < 0)
-                       return ret;
-
-               bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret);
-
-               ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line,
-                                         fmt->fmt.pix.height);
-               if (ret < 0)
-                       return ret;
-
-               sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret);
-       } else {
-               /* Called from VIDIOC_REQBUFS or in compatibility mode */
-               sizes[0] = icd->sizeimage;
-       }
-
        alloc_ctxs[0] = pcdev->alloc_ctx;
 
        if (!vq->num_buffers)
@@ -255,8 +226,14 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq,
        if (!*count)
                *count = 2;
 
+       /* Called from VIDIOC_REQBUFS or in compatibility mode */
+       if (!*num_planes)
+               sizes[0] = icd->sizeimage;
+       else if (sizes[0] < icd->sizeimage)
+               return -EINVAL;
+
        /* If *num_planes != 0, we have already verified *count. */
-       if (pcdev->video_limit && !*num_planes) {
+       if (pcdev->video_limit) {
                size_t size = PAGE_ALIGN(sizes[0]) * *count;
 
                if (size + pcdev->buf_total > pcdev->video_limit)
index a0d267e017f61cfd224e20a49a7f61ff11dbfe57..81871d6ae823ac900e8e89911faeb771ee116111 100644 (file)
@@ -438,11 +438,9 @@ static void bdisp_ctrls_delete(struct bdisp_ctx *ctx)
 }
 
 static int bdisp_queue_setup(struct vb2_queue *vq,
-                            const void *parg,
                             unsigned int *nb_buf, unsigned int *nb_planes,
                             unsigned int sizes[], void *allocators[])
 {
-       const struct v4l2_format *fmt = parg;
        struct bdisp_ctx *ctx = vb2_get_drv_priv(vq);
        struct bdisp_frame *frame = ctx_get_frame(ctx, vq->type);
 
@@ -455,13 +453,13 @@ static int bdisp_queue_setup(struct vb2_queue *vq,
                dev_err(ctx->bdisp_dev->dev, "Invalid format\n");
                return -EINVAL;
        }
+       allocators[0] = ctx->bdisp_dev->alloc_ctx;
 
-       if (fmt && fmt->fmt.pix.sizeimage < frame->sizeimage)
-               return -EINVAL;
+       if (*nb_planes)
+               return sizes[0] < frame->sizeimage ? -EINVAL : 0;
 
        *nb_planes = 1;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : frame->sizeimage;
-       allocators[0] = ctx->bdisp_dev->alloc_ctx;
+       sizes[0] = frame->sizeimage;
 
        return 0;
 }
index de24effd984fb3a360e269d31c483bf269f4e2b2..e8ed2652eb0775363894619713d41253dbb13684 100644 (file)
@@ -1796,7 +1796,6 @@ static const struct v4l2_ioctl_ops vpe_ioctl_ops = {
  * Queue operations
  */
 static int vpe_queue_setup(struct vb2_queue *vq,
-                          const void *parg,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index e18fb9f9ed2f7795414f79deed1c19f6cf334374..93e1d256b13a3168ed3f8078dfa94113ad2e7f46 100644 (file)
@@ -710,11 +710,9 @@ static const struct v4l2_ioctl_ops vim2m_ioctl_ops = {
  */
 
 static int vim2m_queue_setup(struct vb2_queue *vq,
-                               const void *parg,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct vim2m_ctx *ctx = vb2_get_drv_priv(vq);
        struct vim2m_q_data *q_data;
        unsigned int size, count = *nbuffers;
@@ -723,17 +721,14 @@ static int vim2m_queue_setup(struct vb2_queue *vq,
 
        size = q_data->width * q_data->height * q_data->fmt->depth >> 3;
 
-       if (fmt) {
-               if (fmt->fmt.pix.sizeimage < size)
-                       return -EINVAL;
-               size = fmt->fmt.pix.sizeimage;
-       }
-
        while (size * count > MEM2MEM_VID_MEM_LIMIT)
                (count)--;
+       *nbuffers = count;
+
+       if (*nplanes)
+               return sizes[0] < size ? -EINVAL : 0;
 
        *nplanes = 1;
-       *nbuffers = count;
        sizes[0] = size;
 
        /*
index 082c401764ce8ed359df38708d69ee5c649edbf4..6eeeff9d1ae2fb98d417e6dcad84ca309e8f1eea 100644 (file)
@@ -213,7 +213,7 @@ static int vivid_thread_sdr_cap(void *data)
        return 0;
 }
 
-static int sdr_cap_queue_setup(struct vb2_queue *vq, const void *parg,
+static int sdr_cap_queue_setup(struct vb2_queue *vq,
                       unsigned *nbuffers, unsigned *nplanes,
                       unsigned sizes[], void *alloc_ctxs[])
 {
index e903d023e9dfa941c1c627bb683138d6b259b46e..d6d12e104aea077f020215712840181d67f7e342 100644 (file)
@@ -137,7 +137,7 @@ void vivid_sliced_vbi_cap_process(struct vivid_dev *dev,
        buf->vb.timestamp.tv_sec += dev->time_wrap_offset;
 }
 
-static int vbi_cap_queue_setup(struct vb2_queue *vq, const void *parg,
+static int vbi_cap_queue_setup(struct vb2_queue *vq,
                       unsigned *nbuffers, unsigned *nplanes,
                       unsigned sizes[], void *alloc_ctxs[])
 {
index 75c5709f938e989d57d449041c182d2813500533..3c5a469e6f49799faf846647e059d8d8c46cacbd 100644 (file)
@@ -27,7 +27,7 @@
 #include "vivid-vbi-out.h"
 #include "vivid-vbi-cap.h"
 
-static int vbi_out_queue_setup(struct vb2_queue *vq, const void *parg,
+static int vbi_out_queue_setup(struct vb2_queue *vq,
                       unsigned *nbuffers, unsigned *nplanes,
                       unsigned sizes[], void *alloc_ctxs[])
 {
index 9cc07c65a564e4dd873a089657f0c6cbbdc61e92..b84f081c1b929b9e89d577fbdf585c30e836d34a 100644 (file)
@@ -95,11 +95,10 @@ static const struct v4l2_discrete_probe webcam_probe = {
        VIVID_WEBCAM_SIZES
 };
 
-static int vid_cap_queue_setup(struct vb2_queue *vq, const void *parg,
+static int vid_cap_queue_setup(struct vb2_queue *vq,
                       unsigned *nbuffers, unsigned *nplanes,
                       unsigned sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct vivid_dev *dev = vb2_get_drv_priv(vq);
        unsigned buffers = tpg_g_buffers(&dev->tpg);
        unsigned h = dev->fmt_cap_rect.height;
@@ -122,27 +121,16 @@ static int vid_cap_queue_setup(struct vb2_queue *vq, const void *parg,
                dev->queue_setup_error = false;
                return -EINVAL;
        }
-       if (fmt) {
-               const struct v4l2_pix_format_mplane *mp;
-               struct v4l2_format mp_fmt;
-               const struct vivid_fmt *vfmt;
-
-               if (!V4L2_TYPE_IS_MULTIPLANAR(fmt->type)) {
-                       fmt_sp2mp(fmt, &mp_fmt);
-                       fmt = &mp_fmt;
-               }
-               mp = &fmt->fmt.pix_mp;
+       if (*nplanes) {
                /*
-                * Check if the number of planes in the specified format match
+                * Check if the number of requested planes match
                 * the number of buffers in the current format. You can't mix that.
                 */
-               if (mp->num_planes != buffers)
+               if (*nplanes != buffers)
                        return -EINVAL;
-               vfmt = vivid_get_format(dev, mp->pixelformat);
                for (p = 0; p < buffers; p++) {
-                       sizes[p] = mp->plane_fmt[p].sizeimage;
                        if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h +
-                                                       vfmt->data_offset[p])
+                                               dev->fmt_cap->data_offset[p])
                                return -EINVAL;
                }
        } else {
index 1f3b08166e7489d453fda1bdeddb08232e2737a2..64e4d66482c1f35e42a1739c6bb56824108fb5c3 100644 (file)
 #include "vivid-kthread-out.h"
 #include "vivid-vid-out.h"
 
-static int vid_out_queue_setup(struct vb2_queue *vq, const void *parg,
+static int vid_out_queue_setup(struct vb2_queue *vq,
                       unsigned *nbuffers, unsigned *nplanes,
                       unsigned sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct vivid_dev *dev = vb2_get_drv_priv(vq);
        const struct vivid_fmt *vfmt = dev->fmt_out;
        unsigned planes = vfmt->buffers;
@@ -64,26 +63,16 @@ static int vid_out_queue_setup(struct vb2_queue *vq, const void *parg,
                return -EINVAL;
        }
 
-       if (fmt) {
-               const struct v4l2_pix_format_mplane *mp;
-               struct v4l2_format mp_fmt;
-
-               if (!V4L2_TYPE_IS_MULTIPLANAR(fmt->type)) {
-                       fmt_sp2mp(fmt, &mp_fmt);
-                       fmt = &mp_fmt;
-               }
-               mp = &fmt->fmt.pix_mp;
+       if (*nplanes) {
                /*
-                * Check if the number of planes in the specified format match
+                * Check if the number of requested planes match
                 * the number of planes in the current format. You can't mix that.
                 */
-               if (mp->num_planes != planes)
+               if (*nplanes != planes)
                        return -EINVAL;
-               sizes[0] = mp->plane_fmt[0].sizeimage;
                if (sizes[0] < size)
                        return -EINVAL;
                for (p = 1; p < planes; p++) {
-                       sizes[p] = mp->plane_fmt[p].sizeimage;
                        if (sizes[p] < dev->bytesperline_out[p] * h)
                                return -EINVAL;
                }
index 5ce88e1f5d710cea2e8fab573019750b20a7df1f..1eebf58bbecb713fec5b4e4f05463082a58d42cb 100644 (file)
@@ -274,35 +274,6 @@ static int __vsp1_video_try_format(struct vsp1_video *video,
        return 0;
 }
 
-static bool
-vsp1_video_format_adjust(struct vsp1_video *video,
-                        const struct v4l2_pix_format_mplane *format,
-                        struct v4l2_pix_format_mplane *adjust)
-{
-       unsigned int i;
-
-       *adjust = *format;
-       __vsp1_video_try_format(video, adjust, NULL);
-
-       if (format->width != adjust->width ||
-           format->height != adjust->height ||
-           format->pixelformat != adjust->pixelformat ||
-           format->num_planes != adjust->num_planes)
-               return false;
-
-       for (i = 0; i < format->num_planes; ++i) {
-               if (format->plane_fmt[i].bytesperline !=
-                   adjust->plane_fmt[i].bytesperline)
-                       return false;
-
-               adjust->plane_fmt[i].sizeimage =
-                       max(adjust->plane_fmt[i].sizeimage,
-                           format->plane_fmt[i].sizeimage);
-       }
-
-       return true;
-}
-
 /* -----------------------------------------------------------------------------
  * Pipeline Management
  */
@@ -787,26 +758,24 @@ void vsp1_pipelines_resume(struct vsp1_device *vsp1)
  */
 
 static int
-vsp1_video_queue_setup(struct vb2_queue *vq, const void *parg,
+vsp1_video_queue_setup(struct vb2_queue *vq,
                     unsigned int *nbuffers, unsigned int *nplanes,
                     unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct vsp1_video *video = vb2_get_drv_priv(vq);
-       const struct v4l2_pix_format_mplane *format;
-       struct v4l2_pix_format_mplane pix_mp;
+       const struct v4l2_pix_format_mplane *format = &video->format;
        unsigned int i;
 
-       if (fmt) {
-               /* Make sure the format is valid and adjust the sizeimage field
-                * if needed.
-                */
-               if (!vsp1_video_format_adjust(video, &fmt->fmt.pix_mp, &pix_mp))
+       if (*nplanes) {
+               if (*nplanes != format->num_planes)
                        return -EINVAL;
 
-               format = &pix_mp;
-       } else {
-               format = &video->format;
+               for (i = 0; i < *nplanes; i++) {
+                       if (sizes[i] < format->plane_fmt[i].sizeimage)
+                               return -EINVAL;
+                       alloc_ctxs[i] = video->alloc_ctx;
+               }
+               return 0;
        }
 
        *nplanes = format->num_planes;
index d11cc7072cd59d2c873dfe68863676b1e8731f42..8532cab2ec7799a6c1123f27a90165889b2077ac 100644 (file)
@@ -309,21 +309,19 @@ static void xvip_dma_complete(void *param)
 }
 
 static int
-xvip_dma_queue_setup(struct vb2_queue *vq, const void *parg,
+xvip_dma_queue_setup(struct vb2_queue *vq,
                     unsigned int *nbuffers, unsigned int *nplanes,
                     unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct xvip_dma *dma = vb2_get_drv_priv(vq);
 
+       alloc_ctxs[0] = dma->alloc_ctx;
        /* Make sure the image size is large enough. */
-       if (fmt && fmt->fmt.pix.sizeimage < dma->format.sizeimage)
-               return -EINVAL;
+       if (*nplanes)
+               return sizes[0] < dma->format.sizeimage ? -EINVAL : 0;
 
        *nplanes = 1;
-
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : dma->format.sizeimage;
-       alloc_ctxs[0] = dma->alloc_ctx;
+       sizes[0] = dma->format.sizeimage;
 
        return 0;
 }
index fcbb49757614487aa0a88e2740bc0dcd4ff73236..518d511e49eeedd2b7da29eca6d4d3c0389a9e86 100644 (file)
@@ -488,7 +488,7 @@ static void airspy_disconnect(struct usb_interface *intf)
 
 /* Videobuf2 operations */
 static int airspy_queue_setup(struct vb2_queue *vq,
-               const void *parg, unsigned int *nbuffers,
+               unsigned int *nbuffers,
                unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
 {
        struct airspy *s = vb2_get_drv_priv(vq);
index 130c8b49bf7fb56a2ca460c8bbf37ea9faf984c5..b4efc103ae5786b5e2297032a4d4b00e86655f09 100644 (file)
 
 /* ------------------------------------------------------------------ */
 
-static int vbi_queue_setup(struct vb2_queue *vq, const void *parg,
+static int vbi_queue_setup(struct vb2_queue *vq,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct au0828_dev *dev = vb2_get_drv_priv(vq);
-       unsigned long img_size = dev->vbi_width * dev->vbi_height * 2;
-       unsigned long size;
-
-       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;
+       unsigned long size = dev->vbi_width * dev->vbi_height * 2;
 
+       if (*nplanes)
+               return sizes[0] < size ? -EINVAL : 0;
        *nplanes = 1;
        sizes[0] = size;
-
        return 0;
 }
 
index 45c622e234f7fb4bade7608cfdda352f908b608e..427d58e6b85e9333200d4dafe723299733c03268 100644 (file)
@@ -638,19 +638,15 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
        return rc;
 }
 
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                       unsigned int *nbuffers, unsigned int *nplanes,
                       unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct au0828_dev *dev = vb2_get_drv_priv(vq);
-       unsigned long img_size = dev->height * dev->bytesperline;
-       unsigned long size;
-
-       size = fmt ? fmt->fmt.pix.sizeimage : img_size;
-       if (size < img_size)
-               return -EINVAL;
+       unsigned long size = dev->height * dev->bytesperline;
 
+       if (*nplanes)
+               return sizes[0] < size ? -EINVAL : 0;
        *nplanes = 1;
        sizes[0] = size;
 
index e23c285b3108f7f687f57b7ec4389ef1195640b2..fe94c9225dd7f18ce413f56347551bc7de961688 100644 (file)
 
 /* ------------------------------------------------------------------ */
 
-static int vbi_queue_setup(struct vb2_queue *vq, const void *parg,
+static int vbi_queue_setup(struct vb2_queue *vq,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct em28xx *dev = vb2_get_drv_priv(vq);
        struct em28xx_v4l2 *v4l2 = dev->v4l2;
-       unsigned long size;
+       unsigned long size = v4l2->vbi_width * v4l2->vbi_height * 2;
 
-       if (fmt)
-               size = fmt->fmt.pix.sizeimage;
-       else
-               size = v4l2->vbi_width * v4l2->vbi_height * 2;
-
-       if (0 == *nbuffers)
-               *nbuffers = 32;
        if (*nbuffers < 2)
                *nbuffers = 2;
-       if (*nbuffers > 32)
-               *nbuffers = 32;
+
+       if (*nplanes) {
+               if (sizes[0] < size)
+                       return -EINVAL;
+               size = sizes[0];
+       }
 
        *nplanes = 1;
        sizes[0] = size;
index bba205246b220f788232d8a831ef4b4071c46686..235a03885198a87d88b85c298e2f1f527ba6b768 100644 (file)
@@ -871,30 +871,19 @@ static void res_free(struct em28xx *dev, enum v4l2_buf_type f_type)
        Videobuf2 operations
    ------------------------------------------------------------------*/
 
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                       unsigned int *nbuffers, unsigned int *nplanes,
                       unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct em28xx *dev = vb2_get_drv_priv(vq);
        struct em28xx_v4l2 *v4l2 = dev->v4l2;
-       unsigned long size;
-
-       if (fmt)
-               size = fmt->fmt.pix.sizeimage;
-       else
-               size =
+       unsigned long size =
                    (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3;
 
-       if (size == 0)
-               return -EINVAL;
-
-       if (0 == *nbuffers)
-               *nbuffers = 32;
-
+       if (*nplanes)
+               return sizes[0] < size ? -EINVAL : 0;
        *nplanes = 1;
        sizes[0] = size;
-
        return 0;
 }
 
index ae5038b8a1efb481a9e4f12434c2844281057377..358c1c186d0335aaad237354dd679cd22b7dccf5 100644 (file)
@@ -369,7 +369,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
 }
 
 static int go7007_queue_setup(struct vb2_queue *q,
-               const void *parg,
                unsigned int *num_buffers, unsigned int *num_planes,
                unsigned int sizes[], void *alloc_ctxs[])
 {
index e05bfec90f4608b0d8ebce199351dfe89db11994..d0c416ddd5e7b2f8f37c2927f7d655c7f9d61cea 100644 (file)
@@ -750,7 +750,7 @@ static void hackrf_return_all_buffers(struct vb2_queue *vq,
 }
 
 static int hackrf_queue_setup(struct vb2_queue *vq,
-               const void *parg, unsigned int *nbuffers,
+               unsigned int *nbuffers,
                unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
 {
        struct hackrf_dev *dev = vb2_get_drv_priv(vq);
index e06a21a4fbd9a30bdb3c86f4cfb41f9de3833ddd..c104315fdc17217f4fad27b6c86e017fa126b7b2 100644 (file)
@@ -616,7 +616,6 @@ static int msi2500_querycap(struct file *file, void *fh,
 
 /* Videobuf2 operations */
 static int msi2500_queue_setup(struct vb2_queue *vq,
-                              const void *parg,
                               unsigned int *nbuffers,
                               unsigned int *nplanes, unsigned int sizes[],
                               void *alloc_ctxs[])
index b79c36fd8cd24c66d441c5b807cb65a65b6673f6..e90e4946afafac17f6e94addbc8cdd39d806238c 100644 (file)
@@ -571,7 +571,7 @@ static void pwc_video_release(struct v4l2_device *v)
 /***************************************************************************/
 /* Videobuf2 operations */
 
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
index e7acb12ad21d1e5ae4fe69c4d6eb2cee7b8ddc73..82bdd42f76b540ee2b50d19d5853c7e0327c29dd 100644 (file)
@@ -660,7 +660,7 @@ static void s2255_fillbuff(struct s2255_vc *vc,
    Videobuf operations
    ------------------------------------------------------------------*/
 
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                       unsigned int *nbuffers, unsigned int *nplanes,
                       unsigned int sizes[], void *alloc_ctxs[])
 {
index 9a69bb559602cde69dba2cf41874b5e454b5cee7..77131fd614a5e763e4fcefedfed81a1154889b00 100644 (file)
@@ -664,7 +664,7 @@ static const struct v4l2_ioctl_ops stk1160_ioctl_ops = {
 /*
  * Videobuf2 operations
  */
-static int queue_setup(struct vb2_queue *vq, const void *parg,
+static int queue_setup(struct vb2_queue *vq,
                                unsigned int *nbuffers, unsigned int *nplanes,
                                unsigned int sizes[], void *alloc_ctxs[])
 {
index e645c9df2d9401919e82d875f73c37389b09f73b..05cbd2f4b4458d9cf9ccc0c84c70a31f12e5029b 100644 (file)
@@ -599,19 +599,18 @@ static struct v4l2_file_operations usbtv_fops = {
 };
 
 static int usbtv_queue_setup(struct vb2_queue *vq,
-       const void *parg, unsigned int *nbuffers,
+       unsigned int *nbuffers,
        unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct usbtv *usbtv = vb2_get_drv_priv(vq);
        unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32);
 
        if (vq->num_buffers + *nbuffers < 2)
                *nbuffers = 2 - vq->num_buffers;
+       if (*nplanes)
+               return sizes[0] < size ? -EINVAL : 0;
        *nplanes = 1;
-       if (fmt && fmt->fmt.pix.sizeimage < size)
-               return -EINVAL;
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size;
+       sizes[0] = size;
 
        return 0;
 }
index cfb868a48b5f02ad4e76c11072b4ce0b33a2890e..54394722756f16211984b0150d9461c9014d0a5c 100644 (file)
@@ -69,23 +69,19 @@ static void uvc_queue_return_buffers(struct uvc_video_queue *queue,
  * videobuf2 queue operations
  */
 
-static int uvc_queue_setup(struct vb2_queue *vq, const void *parg,
+static int uvc_queue_setup(struct vb2_queue *vq,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
-       const struct v4l2_format *fmt = parg;
        struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
        struct uvc_streaming *stream = uvc_queue_to_stream(queue);
+       unsigned size = stream->ctrl.dwMaxVideoFrameSize;
 
        /* Make sure the image size is large enough. */
-       if (fmt && fmt->fmt.pix.sizeimage < stream->ctrl.dwMaxVideoFrameSize)
-               return -EINVAL;
-
+       if (*nplanes)
+               return sizes[0] < size ? -EINVAL : 0;
        *nplanes = 1;
-
-       sizes[0] = fmt ? fmt->fmt.pix.sizeimage
-                : stream->ctrl.dwMaxVideoFrameSize;
-
+       sizes[0] = size;
        return 0;
 }
 
index 33bdd81065e81cd66de55fd533d8bda86b0c678f..ebce7c793f286a78f500fc32541b25d3c096777d 100644 (file)
@@ -621,7 +621,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
         * Ask the driver how many buffers and planes per buffer it requires.
         * Driver also sets the size and allocator context for each plane.
         */
-       ret = call_qop(q, queue_setup, q, NULL, &num_buffers, &num_planes,
+       ret = call_qop(q, queue_setup, q, &num_buffers, &num_planes,
                       q->plane_sizes, q->alloc_ctx);
        if (ret)
                return ret;
@@ -646,8 +646,15 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
         */
        if (!ret && allocated_buffers < num_buffers) {
                num_buffers = allocated_buffers;
+               /*
+                * num_planes is set by the previous queue_setup(), but since it
+                * signals to queue_setup() whether it is called from create_bufs()
+                * vs reqbufs() we zero it here to signal that queue_setup() is
+                * called for the reqbufs() case.
+                */
+               num_planes = 0;
 
-               ret = call_qop(q, queue_setup, q, NULL, &num_buffers,
+               ret = call_qop(q, queue_setup, q, &num_buffers,
                               &num_planes, q->plane_sizes, q->alloc_ctx);
 
                if (!ret && allocated_buffers < num_buffers)
@@ -701,7 +708,8 @@ EXPORT_SYMBOL_GPL(vb2_core_reqbufs);
  * from vidioc_create_bufs handler in driver.
  */
 int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
-               unsigned int *count, const void *parg)
+               unsigned int *count, unsigned requested_planes,
+               const unsigned requested_sizes[])
 {
        unsigned int num_planes = 0, num_buffers, allocated_buffers;
        int ret;
@@ -720,11 +728,16 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
 
        num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers);
 
+       if (requested_planes && requested_sizes) {
+               num_planes = requested_planes;
+               memcpy(q->plane_sizes, requested_sizes, sizeof(q->plane_sizes));
+       }
+
        /*
         * Ask the driver, whether the requested number of buffers, planes per
         * buffer and their sizes are acceptable
         */
-       ret = call_qop(q, queue_setup, q, parg, &num_buffers,
+       ret = call_qop(q, queue_setup, q, &num_buffers,
                       &num_planes, q->plane_sizes, q->alloc_ctx);
        if (ret)
                return ret;
@@ -747,7 +760,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
                 * q->num_buffers contains the total number of buffers, that the
                 * queue driver has set up
                 */
-               ret = call_qop(q, queue_setup, q, parg, &num_buffers,
+               ret = call_qop(q, queue_setup, q, &num_buffers,
                               &num_planes, q->plane_sizes, q->alloc_ctx);
 
                if (!ret && allocated_buffers < num_buffers)
index 2d1e5b7d85a27e776fb1bb5bf911765b0ed441e8..1b5c695f6c5913327554c01f2b5251b96ed5fac7 100644 (file)
@@ -525,14 +525,52 @@ EXPORT_SYMBOL_GPL(vb2_prepare_buf);
  */
 int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
 {
-       int ret = vb2_verify_memory_type(q, create->memory,
-                       create->format.type);
+       unsigned requested_planes = 1;
+       unsigned requested_sizes[VIDEO_MAX_PLANES];
+       struct v4l2_format *f = &create->format;
+       int ret = vb2_verify_memory_type(q, create->memory, f->type);
+       unsigned i;
 
        create->index = q->num_buffers;
        if (create->count == 0)
                return ret != -EBUSY ? ret : 0;
+
+       switch (f->type) {
+       case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
+       case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
+               requested_planes = f->fmt.pix_mp.num_planes;
+               if (requested_planes == 0 ||
+                   requested_planes > VIDEO_MAX_PLANES)
+                       return -EINVAL;
+               for (i = 0; i < requested_planes; i++)
+                       requested_sizes[i] =
+                               f->fmt.pix_mp.plane_fmt[i].sizeimage;
+               break;
+       case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+       case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+               requested_sizes[0] = f->fmt.pix.sizeimage;
+               break;
+       case V4L2_BUF_TYPE_VBI_CAPTURE:
+       case V4L2_BUF_TYPE_VBI_OUTPUT:
+               requested_sizes[0] = f->fmt.vbi.samples_per_line *
+                       (f->fmt.vbi.count[0] + f->fmt.vbi.count[1]);
+               break;
+       case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
+       case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
+               requested_sizes[0] = f->fmt.sliced.io_size;
+               break;
+       case V4L2_BUF_TYPE_SDR_CAPTURE:
+       case V4L2_BUF_TYPE_SDR_OUTPUT:
+               requested_sizes[0] = f->fmt.sdr.buffersize;
+               break;
+       default:
+               return -EINVAL;
+       }
+       for (i = 0; i < requested_planes; i++)
+               if (requested_sizes[i] == 0)
+                       return -EINVAL;
        return ret ? ret : vb2_core_create_bufs(q, create->memory,
-               &create->count, &create->format);
+               &create->count, requested_planes, requested_sizes);
 }
 EXPORT_SYMBOL_GPL(vb2_create_bufs);
 
@@ -1440,8 +1478,8 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,
                return res;
        if (vb2_queue_is_busy(vdev, file))
                return -EBUSY;
-       res = vb2_core_create_bufs(vdev->queue, p->memory, &p->count,
-                       &p->format);
+
+       res = vb2_create_bufs(vdev->queue, p);
        if (res == 0)
                vdev->queue->owner = file->private_data;
        return res;
index 0fdff91624fd6d649857f1b71e4fb70ad7382d48..77b4fc6fd2eeab243025f40e6e75c5652bddc416 100644 (file)
@@ -1078,7 +1078,7 @@ vpfe_g_dv_timings(struct file *file, void *fh,
  * the buffer nbuffers and buffer size
  */
 static int
-vpfe_buffer_queue_setup(struct vb2_queue *vq, const void *parg,
+vpfe_buffer_queue_setup(struct vb2_queue *vq,
                        unsigned int *nbuffers, unsigned int *nplanes,
                        unsigned int sizes[], void *alloc_ctxs[])
 {
index 2a0158bb497420b63f527a45b9bbada740136e37..17741e37a73c67e09b2d3c23ca3d6e231825ecfa 100644 (file)
@@ -287,7 +287,6 @@ iss_video_check_format(struct iss_video *video, struct iss_video_fh *vfh)
  */
 
 static int iss_video_queue_setup(struct vb2_queue *vq,
-                                const void *parg,
                                 unsigned int *count, unsigned int *num_planes,
                                 unsigned int sizes[], void *alloc_ctxs[])
 {
index 51d4a1703af2721ef4c8079c413fe70d911b7291..f5921989873d21accc33d0c9729948b6e7b020f5 100644 (file)
@@ -41,7 +41,7 @@
  * videobuf2 queue operations
  */
 
-static int uvc_queue_setup(struct vb2_queue *vq, const void *parg,
+static int uvc_queue_setup(struct vb2_queue *vq,
                           unsigned int *nbuffers, unsigned int *nplanes,
                           unsigned int sizes[], void *alloc_ctxs[])
 {
index 647ebfe5174f623b27723924a521cc3f483329dd..b47d1e2f4364abeb07b5b4421fe7ad57e90f6dd6 100644 (file)
@@ -268,21 +268,26 @@ struct vb2_buffer {
  * struct vb2_ops - driver-specific callbacks
  *
  * @queue_setup:       called from VIDIOC_REQBUFS and VIDIOC_CREATE_BUFS
- *                     handlers before memory allocation, or, if
- *                     *num_planes != 0, after the allocation to verify a
- *                     smaller number of buffers. Driver should return
- *                     the required number of buffers in *num_buffers, the
- *                     required number of planes per buffer in *num_planes; the
- *                     size of each plane should be set in the sizes[] array
- *                     and optional per-plane allocator specific context in the
- *                     alloc_ctxs[] array. When called from VIDIOC_REQBUFS,
- *                     fmt == NULL, the driver has to use the currently
- *                     configured format and *num_buffers is the total number
- *                     of buffers, that are being allocated. When called from
- *                     VIDIOC_CREATE_BUFS, fmt != NULL and it describes the
- *                     target frame format (if the format isn't valid the
- *                     callback must return -EINVAL). In this case *num_buffers
- *                     are being allocated additionally to q->num_buffers.
+ *                     handlers before memory allocation. It can be called
+ *                     twice: if the original number of requested buffers
+ *                     could not be allocated, then it will be called a
+ *                     second time with the actually allocated number of
+ *                     buffers to verify if that is OK.
+ *                     The driver should return the required number of buffers
+ *                     in *num_buffers, the required number of planes per
+ *                     buffer in *num_planes, the size of each plane should be
+ *                     set in the sizes[] array and optional per-plane
+ *                     allocator specific context in the alloc_ctxs[] array.
+ *                     When called from VIDIOC_REQBUFS, *num_planes == 0, the
+ *                     driver has to use the currently configured format to
+ *                     determine the plane sizes and *num_buffers is the total
+ *                     number of buffers that are being allocated. When called
+ *                     from VIDIOC_CREATE_BUFS, *num_planes != 0 and it
+ *                     describes the requested number of planes and sizes[]
+ *                     contains the requested plane sizes. If either
+ *                     *num_planes or the requested sizes are invalid callback
+ *                     must return -EINVAL. In this case *num_buffers are
+ *                     being allocated additionally to q->num_buffers.
  * @wait_prepare:      release any locks taken while calling vb2 functions;
  *                     it is called before an ioctl needs to wait for a new
  *                     buffer to arrive; required to avoid a deadlock in
@@ -344,7 +349,7 @@ struct vb2_buffer {
  *                     pre-queued buffers before calling STREAMON.
  */
 struct vb2_ops {
-       int (*queue_setup)(struct vb2_queue *q, const void *parg,
+       int (*queue_setup)(struct vb2_queue *q,
                           unsigned int *num_buffers, unsigned int *num_planes,
                           unsigned int sizes[], void *alloc_ctxs[]);
 
@@ -507,7 +512,8 @@ int vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb);
 int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
                unsigned int *count);
 int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
-               unsigned int *count, const void *parg);
+               unsigned int *count, unsigned requested_planes,
+               const unsigned int requested_sizes[]);
 int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb);
 int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb);
 int vb2_core_dqbuf(struct vb2_queue *q, void *pb, bool nonblocking);