diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2015-10-27 22:50:37 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-12-18 10:48:19 -0500 |
commit | df9ecb0cad14b952a2865f8b3af86b2bbadfab45 (patch) | |
tree | a6a9501e8fc5a3a59e6e3fbf54e8e5c5559aaf23 | |
parent | ecc2fe20e63a21b7db23065ff061b66fbc08e08b (diff) |
[media] vb2: drop v4l2_format argument from queue_setup
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, 356 insertions, 520 deletions
diff --git a/Documentation/video4linux/v4l2-pci-skeleton.c b/Documentation/video4linux/v4l2-pci-skeleton.c index 1c8b102a6529..79af0c041056 100644 --- a/Documentation/video4linux/v4l2-pci-skeleton.c +++ b/Documentation/video4linux/v4l2-pci-skeleton.c | |||
@@ -163,11 +163,10 @@ static irqreturn_t skeleton_irq(int irq, void *dev_id) | |||
163 | * minimum number: many DMA engines need a minimum of 2 buffers in the | 163 | * minimum number: many DMA engines need a minimum of 2 buffers in the |
164 | * queue and you need to have another available for userspace processing. | 164 | * queue and you need to have another available for userspace processing. |
165 | */ | 165 | */ |
166 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 166 | static int queue_setup(struct vb2_queue *vq, |
167 | unsigned int *nbuffers, unsigned int *nplanes, | 167 | unsigned int *nbuffers, unsigned int *nplanes, |
168 | unsigned int sizes[], void *alloc_ctxs[]) | 168 | unsigned int sizes[], void *alloc_ctxs[]) |
169 | { | 169 | { |
170 | const struct v4l2_format *fmt = parg; | ||
171 | struct skeleton *skel = vb2_get_drv_priv(vq); | 170 | struct skeleton *skel = vb2_get_drv_priv(vq); |
172 | 171 | ||
173 | skel->field = skel->format.field; | 172 | skel->field = skel->format.field; |
@@ -183,12 +182,12 @@ static int queue_setup(struct vb2_queue *vq, const void *parg, | |||
183 | 182 | ||
184 | if (vq->num_buffers + *nbuffers < 3) | 183 | if (vq->num_buffers + *nbuffers < 3) |
185 | *nbuffers = 3 - vq->num_buffers; | 184 | *nbuffers = 3 - vq->num_buffers; |
185 | alloc_ctxs[0] = skel->alloc_ctx; | ||
186 | 186 | ||
187 | if (fmt && fmt->fmt.pix.sizeimage < skel->format.sizeimage) | 187 | if (*nplanes) |
188 | return -EINVAL; | 188 | return sizes[0] < skel->format.sizeimage ? -EINVAL : 0; |
189 | *nplanes = 1; | 189 | *nplanes = 1; |
190 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : skel->format.sizeimage; | 190 | sizes[0] = skel->format.sizeimage; |
191 | alloc_ctxs[0] = skel->alloc_ctx; | ||
192 | return 0; | 191 | return 0; |
193 | } | 192 | } |
194 | 193 | ||
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c index d214f22ed305..3f3e2b12e5e7 100644 --- a/drivers/input/touchscreen/sur40.c +++ b/drivers/input/touchscreen/sur40.c | |||
@@ -644,22 +644,21 @@ static void sur40_disconnect(struct usb_interface *interface) | |||
644 | * minimum number: many DMA engines need a minimum of 2 buffers in the | 644 | * minimum number: many DMA engines need a minimum of 2 buffers in the |
645 | * queue and you need to have another available for userspace processing. | 645 | * queue and you need to have another available for userspace processing. |
646 | */ | 646 | */ |
647 | static int sur40_queue_setup(struct vb2_queue *q, const void *parg, | 647 | static int sur40_queue_setup(struct vb2_queue *q, |
648 | unsigned int *nbuffers, unsigned int *nplanes, | 648 | unsigned int *nbuffers, unsigned int *nplanes, |
649 | unsigned int sizes[], void *alloc_ctxs[]) | 649 | unsigned int sizes[], void *alloc_ctxs[]) |
650 | { | 650 | { |
651 | const struct v4l2_format *fmt = parg; | ||
652 | struct sur40_state *sur40 = vb2_get_drv_priv(q); | 651 | struct sur40_state *sur40 = vb2_get_drv_priv(q); |
653 | 652 | ||
654 | if (q->num_buffers + *nbuffers < 3) | 653 | if (q->num_buffers + *nbuffers < 3) |
655 | *nbuffers = 3 - q->num_buffers; | 654 | *nbuffers = 3 - q->num_buffers; |
655 | alloc_ctxs[0] = sur40->alloc_ctx; | ||
656 | 656 | ||
657 | if (fmt && fmt->fmt.pix.sizeimage < sur40_video_format.sizeimage) | 657 | if (*nplanes) |
658 | return -EINVAL; | 658 | return sizes[0] < sur40_video_format.sizeimage ? -EINVAL : 0; |
659 | 659 | ||
660 | *nplanes = 1; | 660 | *nplanes = 1; |
661 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : sur40_video_format.sizeimage; | 661 | sizes[0] = sur40_video_format.sizeimage; |
662 | alloc_ctxs[0] = sur40->alloc_ctx; | ||
663 | 662 | ||
664 | return 0; | 663 | return 0; |
665 | } | 664 | } |
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c index dcd8d94c1037..238191ddcf35 100644 --- a/drivers/media/dvb-frontends/rtl2832_sdr.c +++ b/drivers/media/dvb-frontends/rtl2832_sdr.c | |||
@@ -490,7 +490,7 @@ static int rtl2832_sdr_querycap(struct file *file, void *fh, | |||
490 | 490 | ||
491 | /* Videobuf2 operations */ | 491 | /* Videobuf2 operations */ |
492 | static int rtl2832_sdr_queue_setup(struct vb2_queue *vq, | 492 | static int rtl2832_sdr_queue_setup(struct vb2_queue *vq, |
493 | const void *parg, unsigned int *nbuffers, | 493 | unsigned int *nbuffers, |
494 | unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) | 494 | unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) |
495 | { | 495 | { |
496 | struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq); | 496 | struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq); |
diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c index 8cc78c522ac9..c0ba458f6cf3 100644 --- a/drivers/media/pci/cobalt/cobalt-v4l2.c +++ b/drivers/media/pci/cobalt/cobalt-v4l2.c | |||
@@ -43,11 +43,10 @@ static const struct v4l2_dv_timings cea1080p60 = V4L2_DV_BT_CEA_1920X1080P60; | |||
43 | 43 | ||
44 | /* vb2 DMA streaming ops */ | 44 | /* vb2 DMA streaming ops */ |
45 | 45 | ||
46 | static int cobalt_queue_setup(struct vb2_queue *q, const void *parg, | 46 | static int cobalt_queue_setup(struct vb2_queue *q, |
47 | unsigned int *num_buffers, unsigned int *num_planes, | 47 | unsigned int *num_buffers, unsigned int *num_planes, |
48 | unsigned int sizes[], void *alloc_ctxs[]) | 48 | unsigned int sizes[], void *alloc_ctxs[]) |
49 | { | 49 | { |
50 | const struct v4l2_format *fmt = parg; | ||
51 | struct cobalt_stream *s = q->drv_priv; | 50 | struct cobalt_stream *s = q->drv_priv; |
52 | unsigned size = s->stride * s->height; | 51 | unsigned size = s->stride * s->height; |
53 | 52 | ||
@@ -55,14 +54,11 @@ static int cobalt_queue_setup(struct vb2_queue *q, const void *parg, | |||
55 | *num_buffers = 3; | 54 | *num_buffers = 3; |
56 | if (*num_buffers > NR_BUFS) | 55 | if (*num_buffers > NR_BUFS) |
57 | *num_buffers = NR_BUFS; | 56 | *num_buffers = NR_BUFS; |
57 | alloc_ctxs[0] = s->cobalt->alloc_ctx; | ||
58 | if (*num_planes) | ||
59 | return sizes[0] < size ? -EINVAL : 0; | ||
58 | *num_planes = 1; | 60 | *num_planes = 1; |
59 | if (fmt) { | ||
60 | if (fmt->fmt.pix.sizeimage < size) | ||
61 | return -EINVAL; | ||
62 | size = fmt->fmt.pix.sizeimage; | ||
63 | } | ||
64 | sizes[0] = size; | 61 | sizes[0] = size; |
65 | alloc_ctxs[0] = s->cobalt->alloc_ctx; | ||
66 | return 0; | 62 | return 0; |
67 | } | 63 | } |
68 | 64 | ||
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index 2fe3708d8654..bd333875a1f7 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c | |||
@@ -1138,7 +1138,7 @@ static int cx23885_initialize_codec(struct cx23885_dev *dev, int startencoder) | |||
1138 | 1138 | ||
1139 | /* ------------------------------------------------------------------ */ | 1139 | /* ------------------------------------------------------------------ */ |
1140 | 1140 | ||
1141 | static int queue_setup(struct vb2_queue *q, const void *parg, | 1141 | static int queue_setup(struct vb2_queue *q, |
1142 | unsigned int *num_buffers, unsigned int *num_planes, | 1142 | unsigned int *num_buffers, unsigned int *num_planes, |
1143 | unsigned int sizes[], void *alloc_ctxs[]) | 1143 | unsigned int sizes[], void *alloc_ctxs[]) |
1144 | { | 1144 | { |
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index c4307ad8594c..5378d9380c05 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c | |||
@@ -92,7 +92,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | |||
92 | 92 | ||
93 | /* ------------------------------------------------------------------ */ | 93 | /* ------------------------------------------------------------------ */ |
94 | 94 | ||
95 | static int queue_setup(struct vb2_queue *q, const void *parg, | 95 | static int queue_setup(struct vb2_queue *q, |
96 | unsigned int *num_buffers, unsigned int *num_planes, | 96 | unsigned int *num_buffers, unsigned int *num_planes, |
97 | unsigned int sizes[], void *alloc_ctxs[]) | 97 | unsigned int sizes[], void *alloc_ctxs[]) |
98 | { | 98 | { |
diff --git a/drivers/media/pci/cx23885/cx23885-vbi.c b/drivers/media/pci/cx23885/cx23885-vbi.c index ab36d12e6ec7..39750ebcc04c 100644 --- a/drivers/media/pci/cx23885/cx23885-vbi.c +++ b/drivers/media/pci/cx23885/cx23885-vbi.c | |||
@@ -120,7 +120,7 @@ static int cx23885_start_vbi_dma(struct cx23885_dev *dev, | |||
120 | 120 | ||
121 | /* ------------------------------------------------------------------ */ | 121 | /* ------------------------------------------------------------------ */ |
122 | 122 | ||
123 | static int queue_setup(struct vb2_queue *q, const void *parg, | 123 | static int queue_setup(struct vb2_queue *q, |
124 | unsigned int *num_buffers, unsigned int *num_planes, | 124 | unsigned int *num_buffers, unsigned int *num_planes, |
125 | unsigned int sizes[], void *alloc_ctxs[]) | 125 | unsigned int sizes[], void *alloc_ctxs[]) |
126 | { | 126 | { |
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index 064e5fbf4cf1..93a3720d9116 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c | |||
@@ -333,7 +333,7 @@ static int cx23885_start_video_dma(struct cx23885_dev *dev, | |||
333 | return 0; | 333 | return 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | static int queue_setup(struct vb2_queue *q, const void *parg, | 336 | static int queue_setup(struct vb2_queue *q, |
337 | unsigned int *num_buffers, unsigned int *num_planes, | 337 | unsigned int *num_buffers, unsigned int *num_planes, |
338 | unsigned int sizes[], void *alloc_ctxs[]) | 338 | unsigned int sizes[], void *alloc_ctxs[]) |
339 | { | 339 | { |
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c index 26e3e296d615..644373dd2525 100644 --- a/drivers/media/pci/cx25821/cx25821-video.c +++ b/drivers/media/pci/cx25821/cx25821-video.c | |||
@@ -141,20 +141,20 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status) | |||
141 | return handled; | 141 | return handled; |
142 | } | 142 | } |
143 | 143 | ||
144 | static int cx25821_queue_setup(struct vb2_queue *q, const void *parg, | 144 | static int cx25821_queue_setup(struct vb2_queue *q, |
145 | unsigned int *num_buffers, unsigned int *num_planes, | 145 | unsigned int *num_buffers, unsigned int *num_planes, |
146 | unsigned int sizes[], void *alloc_ctxs[]) | 146 | unsigned int sizes[], void *alloc_ctxs[]) |
147 | { | 147 | { |
148 | const struct v4l2_format *fmt = parg; | ||
149 | struct cx25821_channel *chan = q->drv_priv; | 148 | struct cx25821_channel *chan = q->drv_priv; |
150 | unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3; | 149 | unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3; |
151 | 150 | ||
152 | if (fmt && fmt->fmt.pix.sizeimage < size) | 151 | alloc_ctxs[0] = chan->dev->alloc_ctx; |
153 | return -EINVAL; | 152 | |
153 | if (*num_planes) | ||
154 | return sizes[0] < size ? -EINVAL : 0; | ||
154 | 155 | ||
155 | *num_planes = 1; | 156 | *num_planes = 1; |
156 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size; | 157 | sizes[0] = size; |
157 | alloc_ctxs[0] = chan->dev->alloc_ctx; | ||
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | 160 | ||
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c index 27ffb24d73bb..3233d45d1e5b 100644 --- a/drivers/media/pci/cx88/cx88-blackbird.c +++ b/drivers/media/pci/cx88/cx88-blackbird.c | |||
@@ -637,7 +637,7 @@ static int blackbird_stop_codec(struct cx8802_dev *dev) | |||
637 | 637 | ||
638 | /* ------------------------------------------------------------------ */ | 638 | /* ------------------------------------------------------------------ */ |
639 | 639 | ||
640 | static int queue_setup(struct vb2_queue *q, const void *parg, | 640 | static int queue_setup(struct vb2_queue *q, |
641 | unsigned int *num_buffers, unsigned int *num_planes, | 641 | unsigned int *num_buffers, unsigned int *num_planes, |
642 | unsigned int sizes[], void *alloc_ctxs[]) | 642 | unsigned int sizes[], void *alloc_ctxs[]) |
643 | { | 643 | { |
diff --git a/drivers/media/pci/cx88/cx88-dvb.c b/drivers/media/pci/cx88/cx88-dvb.c index f04835073844..afb20756d7a5 100644 --- a/drivers/media/pci/cx88/cx88-dvb.c +++ b/drivers/media/pci/cx88/cx88-dvb.c | |||
@@ -82,7 +82,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | |||
82 | 82 | ||
83 | /* ------------------------------------------------------------------ */ | 83 | /* ------------------------------------------------------------------ */ |
84 | 84 | ||
85 | static int queue_setup(struct vb2_queue *q, const void *parg, | 85 | static int queue_setup(struct vb2_queue *q, |
86 | unsigned int *num_buffers, unsigned int *num_planes, | 86 | unsigned int *num_buffers, unsigned int *num_planes, |
87 | unsigned int sizes[], void *alloc_ctxs[]) | 87 | unsigned int sizes[], void *alloc_ctxs[]) |
88 | { | 88 | { |
diff --git a/drivers/media/pci/cx88/cx88-vbi.c b/drivers/media/pci/cx88/cx88-vbi.c index 007a5eee8e5e..ccc646d819f2 100644 --- a/drivers/media/pci/cx88/cx88-vbi.c +++ b/drivers/media/pci/cx88/cx88-vbi.c | |||
@@ -107,7 +107,7 @@ int cx8800_restart_vbi_queue(struct cx8800_dev *dev, | |||
107 | 107 | ||
108 | /* ------------------------------------------------------------------ */ | 108 | /* ------------------------------------------------------------------ */ |
109 | 109 | ||
110 | static int queue_setup(struct vb2_queue *q, const void *parg, | 110 | static int queue_setup(struct vb2_queue *q, |
111 | unsigned int *num_buffers, unsigned int *num_planes, | 111 | unsigned int *num_buffers, unsigned int *num_planes, |
112 | unsigned int sizes[], void *alloc_ctxs[]) | 112 | unsigned int sizes[], void *alloc_ctxs[]) |
113 | { | 113 | { |
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c index 5996d06b86cb..5f331df65fb9 100644 --- a/drivers/media/pci/cx88/cx88-video.c +++ b/drivers/media/pci/cx88/cx88-video.c | |||
@@ -429,7 +429,7 @@ static int restart_video_queue(struct cx8800_dev *dev, | |||
429 | 429 | ||
430 | /* ------------------------------------------------------------------ */ | 430 | /* ------------------------------------------------------------------ */ |
431 | 431 | ||
432 | static int queue_setup(struct vb2_queue *q, const void *parg, | 432 | static int queue_setup(struct vb2_queue *q, |
433 | unsigned int *num_buffers, unsigned int *num_planes, | 433 | unsigned int *num_buffers, unsigned int *num_planes, |
434 | unsigned int sizes[], void *alloc_ctxs[]) | 434 | unsigned int sizes[], void *alloc_ctxs[]) |
435 | { | 435 | { |
diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c index d84abde5ea29..f09bd73bd16f 100644 --- a/drivers/media/pci/dt3155/dt3155.c +++ b/drivers/media/pci/dt3155/dt3155.c | |||
@@ -131,22 +131,21 @@ static int wait_i2c_reg(void __iomem *addr) | |||
131 | } | 131 | } |
132 | 132 | ||
133 | static int | 133 | static int |
134 | dt3155_queue_setup(struct vb2_queue *vq, const void *parg, | 134 | dt3155_queue_setup(struct vb2_queue *vq, |
135 | unsigned int *nbuffers, unsigned int *num_planes, | 135 | unsigned int *nbuffers, unsigned int *num_planes, |
136 | unsigned int sizes[], void *alloc_ctxs[]) | 136 | unsigned int sizes[], void *alloc_ctxs[]) |
137 | 137 | ||
138 | { | 138 | { |
139 | const struct v4l2_format *fmt = parg; | ||
140 | struct dt3155_priv *pd = vb2_get_drv_priv(vq); | 139 | struct dt3155_priv *pd = vb2_get_drv_priv(vq); |
141 | unsigned size = pd->width * pd->height; | 140 | unsigned size = pd->width * pd->height; |
142 | 141 | ||
143 | if (vq->num_buffers + *nbuffers < 2) | 142 | if (vq->num_buffers + *nbuffers < 2) |
144 | *nbuffers = 2 - vq->num_buffers; | 143 | *nbuffers = 2 - vq->num_buffers; |
145 | if (fmt && fmt->fmt.pix.sizeimage < size) | ||
146 | return -EINVAL; | ||
147 | *num_planes = 1; | ||
148 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size; | ||
149 | alloc_ctxs[0] = pd->alloc_ctx; | 144 | alloc_ctxs[0] = pd->alloc_ctx; |
145 | if (*num_planes) | ||
146 | return sizes[0] < size ? -EINVAL : 0; | ||
147 | *num_planes = 1; | ||
148 | sizes[0] = size; | ||
150 | return 0; | 149 | return 0; |
151 | } | 150 | } |
152 | 151 | ||
diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c index 3fdbd81b5580..58a8e9db5748 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c | |||
@@ -277,7 +277,6 @@ static irqreturn_t netup_unidvb_isr(int irq, void *dev_id) | |||
277 | } | 277 | } |
278 | 278 | ||
279 | static int netup_unidvb_queue_setup(struct vb2_queue *vq, | 279 | static int netup_unidvb_queue_setup(struct vb2_queue *vq, |
280 | const void *parg, | ||
281 | unsigned int *nbuffers, | 280 | unsigned int *nbuffers, |
282 | unsigned int *nplanes, | 281 | unsigned int *nplanes, |
283 | unsigned int sizes[], | 282 | unsigned int sizes[], |
diff --git a/drivers/media/pci/saa7134/saa7134-ts.c b/drivers/media/pci/saa7134/saa7134-ts.c index 7fb5ee7e20ac..0584a2adbe99 100644 --- a/drivers/media/pci/saa7134/saa7134-ts.c +++ b/drivers/media/pci/saa7134/saa7134-ts.c | |||
@@ -116,7 +116,7 @@ int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2) | |||
116 | } | 116 | } |
117 | EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare); | 117 | EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare); |
118 | 118 | ||
119 | int saa7134_ts_queue_setup(struct vb2_queue *q, const void *parg, | 119 | int saa7134_ts_queue_setup(struct vb2_queue *q, |
120 | unsigned int *nbuffers, unsigned int *nplanes, | 120 | unsigned int *nbuffers, unsigned int *nplanes, |
121 | unsigned int sizes[], void *alloc_ctxs[]) | 121 | unsigned int sizes[], void *alloc_ctxs[]) |
122 | { | 122 | { |
diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c b/drivers/media/pci/saa7134/saa7134-vbi.c index 6271b0eb0265..e76da37c4a8a 100644 --- a/drivers/media/pci/saa7134/saa7134-vbi.c +++ b/drivers/media/pci/saa7134/saa7134-vbi.c | |||
@@ -138,7 +138,7 @@ static int buffer_prepare(struct vb2_buffer *vb2) | |||
138 | saa7134_buffer_startpage(buf)); | 138 | saa7134_buffer_startpage(buf)); |
139 | } | 139 | } |
140 | 140 | ||
141 | static int queue_setup(struct vb2_queue *q, const void *parg, | 141 | static int queue_setup(struct vb2_queue *q, |
142 | unsigned int *nbuffers, unsigned int *nplanes, | 142 | unsigned int *nbuffers, unsigned int *nplanes, |
143 | unsigned int sizes[], void *alloc_ctxs[]) | 143 | unsigned int sizes[], void *alloc_ctxs[]) |
144 | { | 144 | { |
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 4d3a7fb6f475..a63c1366a64e 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c | |||
@@ -904,7 +904,7 @@ static int buffer_prepare(struct vb2_buffer *vb2) | |||
904 | saa7134_buffer_startpage(buf)); | 904 | saa7134_buffer_startpage(buf)); |
905 | } | 905 | } |
906 | 906 | ||
907 | static int queue_setup(struct vb2_queue *q, const void *parg, | 907 | static int queue_setup(struct vb2_queue *q, |
908 | unsigned int *nbuffers, unsigned int *nplanes, | 908 | unsigned int *nbuffers, unsigned int *nplanes, |
909 | unsigned int sizes[], void *alloc_ctxs[]) | 909 | unsigned int sizes[], void *alloc_ctxs[]) |
910 | { | 910 | { |
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index 7cc758294550..5938bc781999 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h | |||
@@ -820,7 +820,7 @@ void saa7134_video_fini(struct saa7134_dev *dev); | |||
820 | 820 | ||
821 | int saa7134_ts_buffer_init(struct vb2_buffer *vb2); | 821 | int saa7134_ts_buffer_init(struct vb2_buffer *vb2); |
822 | int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2); | 822 | int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2); |
823 | int saa7134_ts_queue_setup(struct vb2_queue *q, const void *parg, | 823 | int saa7134_ts_queue_setup(struct vb2_queue *q, |
824 | unsigned int *nbuffers, unsigned int *nplanes, | 824 | unsigned int *nbuffers, unsigned int *nplanes, |
825 | unsigned int sizes[], void *alloc_ctxs[]); | 825 | unsigned int sizes[], void *alloc_ctxs[]); |
826 | int saa7134_ts_start_streaming(struct vb2_queue *vq, unsigned int count); | 826 | int saa7134_ts_start_streaming(struct vb2_queue *vq, unsigned int count); |
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c index 4432fd69b7cb..1f81f8d3649e 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | |||
@@ -663,7 +663,6 @@ static int solo_ring_thread(void *data) | |||
663 | } | 663 | } |
664 | 664 | ||
665 | static int solo_enc_queue_setup(struct vb2_queue *q, | 665 | static int solo_enc_queue_setup(struct vb2_queue *q, |
666 | const void *parg, | ||
667 | unsigned int *num_buffers, | 666 | unsigned int *num_buffers, |
668 | unsigned int *num_planes, unsigned int sizes[], | 667 | unsigned int *num_planes, unsigned int sizes[], |
669 | void *alloc_ctxs[]) | 668 | void *alloc_ctxs[]) |
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c index f7ce493b1fee..212d15efc26b 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c | |||
@@ -313,7 +313,7 @@ static void solo_stop_thread(struct solo_dev *solo_dev) | |||
313 | solo_dev->kthread = NULL; | 313 | solo_dev->kthread = NULL; |
314 | } | 314 | } |
315 | 315 | ||
316 | static int solo_queue_setup(struct vb2_queue *q, const void *parg, | 316 | static int solo_queue_setup(struct vb2_queue *q, |
317 | unsigned int *num_buffers, unsigned int *num_planes, | 317 | unsigned int *num_buffers, unsigned int *num_planes, |
318 | unsigned int sizes[], void *alloc_ctxs[]) | 318 | unsigned int sizes[], void *alloc_ctxs[]) |
319 | { | 319 | { |
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c index 6367b455a7e7..b8b06fb7bec2 100644 --- a/drivers/media/pci/sta2x11/sta2x11_vip.c +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c | |||
@@ -265,7 +265,7 @@ static void vip_active_buf_next(struct sta2x11_vip *vip) | |||
265 | 265 | ||
266 | 266 | ||
267 | /* Videobuf2 Operations */ | 267 | /* Videobuf2 Operations */ |
268 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 268 | static int queue_setup(struct vb2_queue *vq, |
269 | unsigned int *nbuffers, unsigned int *nplanes, | 269 | unsigned int *nbuffers, unsigned int *nplanes, |
270 | unsigned int sizes[], void *alloc_ctxs[]) | 270 | unsigned int sizes[], void *alloc_ctxs[]) |
271 | { | 271 | { |
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c index 46642ef9151b..2e71af15ddb0 100644 --- a/drivers/media/pci/tw68/tw68-video.c +++ b/drivers/media/pci/tw68/tw68-video.c | |||
@@ -376,28 +376,28 @@ static int tw68_buffer_count(unsigned int size, unsigned int count) | |||
376 | /* ------------------------------------------------------------- */ | 376 | /* ------------------------------------------------------------- */ |
377 | /* vb2 queue operations */ | 377 | /* vb2 queue operations */ |
378 | 378 | ||
379 | static int tw68_queue_setup(struct vb2_queue *q, const void *parg, | 379 | static int tw68_queue_setup(struct vb2_queue *q, |
380 | unsigned int *num_buffers, unsigned int *num_planes, | 380 | unsigned int *num_buffers, unsigned int *num_planes, |
381 | unsigned int sizes[], void *alloc_ctxs[]) | 381 | unsigned int sizes[], void *alloc_ctxs[]) |
382 | { | 382 | { |
383 | const struct v4l2_format *fmt = parg; | ||
384 | struct tw68_dev *dev = vb2_get_drv_priv(q); | 383 | struct tw68_dev *dev = vb2_get_drv_priv(q); |
385 | unsigned tot_bufs = q->num_buffers + *num_buffers; | 384 | unsigned tot_bufs = q->num_buffers + *num_buffers; |
385 | unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3; | ||
386 | 386 | ||
387 | sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; | 387 | if (tot_bufs < 2) |
388 | tot_bufs = 2; | ||
389 | tot_bufs = tw68_buffer_count(size, tot_bufs); | ||
390 | *num_buffers = tot_bufs - q->num_buffers; | ||
388 | alloc_ctxs[0] = dev->alloc_ctx; | 391 | alloc_ctxs[0] = dev->alloc_ctx; |
389 | /* | 392 | /* |
390 | * We allow create_bufs, but only if the sizeimage is the same as the | 393 | * We allow create_bufs, but only if the sizeimage is >= as the |
391 | * current sizeimage. The tw68_buffer_count calculation becomes quite | 394 | * current sizeimage. The tw68_buffer_count calculation becomes quite |
392 | * difficult otherwise. | 395 | * difficult otherwise. |
393 | */ | 396 | */ |
394 | if (fmt && fmt->fmt.pix.sizeimage < sizes[0]) | 397 | if (*num_planes) |
395 | return -EINVAL; | 398 | return sizes[0] < size ? -EINVAL : 0; |
396 | *num_planes = 1; | 399 | *num_planes = 1; |
397 | if (tot_bufs < 2) | 400 | sizes[0] = size; |
398 | tot_bufs = 2; | ||
399 | tot_bufs = tw68_buffer_count(sizes[0], tot_bufs); | ||
400 | *num_buffers = tot_bufs - q->num_buffers; | ||
401 | 401 | ||
402 | return 0; | 402 | return 0; |
403 | } | 403 | } |
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c index f0480d687f17..e434c8ef5c5e 100644 --- a/drivers/media/platform/am437x/am437x-vpfe.c +++ b/drivers/media/platform/am437x/am437x-vpfe.c | |||
@@ -1898,7 +1898,6 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe) | |||
1898 | /* | 1898 | /* |
1899 | * vpfe_queue_setup - Callback function for buffer setup. | 1899 | * vpfe_queue_setup - Callback function for buffer setup. |
1900 | * @vq: vb2_queue ptr | 1900 | * @vq: vb2_queue ptr |
1901 | * @fmt: v4l2 format | ||
1902 | * @nbuffers: ptr to number of buffers requested by application | 1901 | * @nbuffers: ptr to number of buffers requested by application |
1903 | * @nplanes:: contains number of distinct video planes needed to hold a frame | 1902 | * @nplanes:: contains number of distinct video planes needed to hold a frame |
1904 | * @sizes[]: contains the size (in bytes) of each plane. | 1903 | * @sizes[]: contains the size (in bytes) of each plane. |
@@ -1908,22 +1907,24 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe) | |||
1908 | * the buffer count and buffer size | 1907 | * the buffer count and buffer size |
1909 | */ | 1908 | */ |
1910 | static int vpfe_queue_setup(struct vb2_queue *vq, | 1909 | static int vpfe_queue_setup(struct vb2_queue *vq, |
1911 | const void *parg, | ||
1912 | unsigned int *nbuffers, unsigned int *nplanes, | 1910 | unsigned int *nbuffers, unsigned int *nplanes, |
1913 | unsigned int sizes[], void *alloc_ctxs[]) | 1911 | unsigned int sizes[], void *alloc_ctxs[]) |
1914 | { | 1912 | { |
1915 | const struct v4l2_format *fmt = parg; | ||
1916 | struct vpfe_device *vpfe = vb2_get_drv_priv(vq); | 1913 | struct vpfe_device *vpfe = vb2_get_drv_priv(vq); |
1917 | 1914 | unsigned size = vpfe->fmt.fmt.pix.sizeimage; | |
1918 | if (fmt && fmt->fmt.pix.sizeimage < vpfe->fmt.fmt.pix.sizeimage) | ||
1919 | return -EINVAL; | ||
1920 | 1915 | ||
1921 | if (vq->num_buffers + *nbuffers < 3) | 1916 | if (vq->num_buffers + *nbuffers < 3) |
1922 | *nbuffers = 3 - vq->num_buffers; | 1917 | *nbuffers = 3 - vq->num_buffers; |
1918 | alloc_ctxs[0] = vpfe->alloc_ctx; | ||
1919 | |||
1920 | if (*nplanes) { | ||
1921 | if (sizes[0] < size) | ||
1922 | return -EINVAL; | ||
1923 | size = sizes[0]; | ||
1924 | } | ||
1923 | 1925 | ||
1924 | *nplanes = 1; | 1926 | *nplanes = 1; |
1925 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : vpfe->fmt.fmt.pix.sizeimage; | 1927 | sizes[0] = size; |
1926 | alloc_ctxs[0] = vpfe->alloc_ctx; | ||
1927 | 1928 | ||
1928 | vpfe_dbg(1, vpfe, | 1929 | vpfe_dbg(1, vpfe, |
1929 | "nbuffers=%d, size=%u\n", *nbuffers, sizes[0]); | 1930 | "nbuffers=%d, size=%u\n", *nbuffers, sizes[0]); |
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c index 7764b9c482ef..8ecc05a8e5ae 100644 --- a/drivers/media/platform/blackfin/bfin_capture.c +++ b/drivers/media/platform/blackfin/bfin_capture.c | |||
@@ -202,22 +202,20 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev) | |||
202 | } | 202 | } |
203 | 203 | ||
204 | static int bcap_queue_setup(struct vb2_queue *vq, | 204 | static int bcap_queue_setup(struct vb2_queue *vq, |
205 | const void *parg, | ||
206 | unsigned int *nbuffers, unsigned int *nplanes, | 205 | unsigned int *nbuffers, unsigned int *nplanes, |
207 | unsigned int sizes[], void *alloc_ctxs[]) | 206 | unsigned int sizes[], void *alloc_ctxs[]) |
208 | { | 207 | { |
209 | const struct v4l2_format *fmt = parg; | ||
210 | struct bcap_device *bcap_dev = vb2_get_drv_priv(vq); | 208 | struct bcap_device *bcap_dev = vb2_get_drv_priv(vq); |
211 | 209 | ||
212 | if (fmt && fmt->fmt.pix.sizeimage < bcap_dev->fmt.sizeimage) | ||
213 | return -EINVAL; | ||
214 | |||
215 | if (vq->num_buffers + *nbuffers < 2) | 210 | if (vq->num_buffers + *nbuffers < 2) |
216 | *nbuffers = 2; | 211 | *nbuffers = 2; |
212 | alloc_ctxs[0] = bcap_dev->alloc_ctx; | ||
213 | |||
214 | if (*nplanes) | ||
215 | return sizes[0] < bcap_dev->fmt.sizeimage ? -EINVAL : 0; | ||
217 | 216 | ||
218 | *nplanes = 1; | 217 | *nplanes = 1; |
219 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : bcap_dev->fmt.sizeimage; | 218 | sizes[0] = bcap_dev->fmt.sizeimage; |
220 | alloc_ctxs[0] = bcap_dev->alloc_ctx; | ||
221 | 219 | ||
222 | return 0; | 220 | return 0; |
223 | } | 221 | } |
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index f821627d015b..cf5be54d462d 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c | |||
@@ -1131,7 +1131,7 @@ static void set_default_params(struct coda_ctx *ctx) | |||
1131 | /* | 1131 | /* |
1132 | * Queue operations | 1132 | * Queue operations |
1133 | */ | 1133 | */ |
1134 | static int coda_queue_setup(struct vb2_queue *vq, const void *parg, | 1134 | static int coda_queue_setup(struct vb2_queue *vq, |
1135 | unsigned int *nbuffers, unsigned int *nplanes, | 1135 | unsigned int *nbuffers, unsigned int *nplanes, |
1136 | unsigned int sizes[], void *alloc_ctxs[]) | 1136 | unsigned int sizes[], void *alloc_ctxs[]) |
1137 | { | 1137 | { |
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 6d91422c4e4c..3fc21766d3a8 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c | |||
@@ -228,28 +228,27 @@ static int vpbe_buffer_prepare(struct vb2_buffer *vb) | |||
228 | * This function allocates memory for the buffers | 228 | * This function allocates memory for the buffers |
229 | */ | 229 | */ |
230 | static int | 230 | static int |
231 | vpbe_buffer_queue_setup(struct vb2_queue *vq, const void *parg, | 231 | vpbe_buffer_queue_setup(struct vb2_queue *vq, |
232 | unsigned int *nbuffers, unsigned int *nplanes, | 232 | unsigned int *nbuffers, unsigned int *nplanes, |
233 | unsigned int sizes[], void *alloc_ctxs[]) | 233 | unsigned int sizes[], void *alloc_ctxs[]) |
234 | 234 | ||
235 | { | 235 | { |
236 | const struct v4l2_format *fmt = parg; | ||
237 | /* Get the file handle object and layer object */ | 236 | /* Get the file handle object and layer object */ |
238 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); | 237 | struct vpbe_layer *layer = vb2_get_drv_priv(vq); |
239 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; | 238 | struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; |
240 | 239 | ||
241 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n"); | 240 | v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n"); |
242 | 241 | ||
243 | if (fmt && fmt->fmt.pix.sizeimage < layer->pix_fmt.sizeimage) | ||
244 | return -EINVAL; | ||
245 | |||
246 | /* Store number of buffers allocated in numbuffer member */ | 242 | /* Store number of buffers allocated in numbuffer member */ |
247 | if (vq->num_buffers + *nbuffers < VPBE_DEFAULT_NUM_BUFS) | 243 | if (vq->num_buffers + *nbuffers < VPBE_DEFAULT_NUM_BUFS) |
248 | *nbuffers = VPBE_DEFAULT_NUM_BUFS - vq->num_buffers; | 244 | *nbuffers = VPBE_DEFAULT_NUM_BUFS - vq->num_buffers; |
245 | alloc_ctxs[0] = layer->alloc_ctx; | ||
246 | |||
247 | if (*nplanes) | ||
248 | return sizes[0] < layer->pix_fmt.sizeimage ? -EINVAL : 0; | ||
249 | 249 | ||
250 | *nplanes = 1; | 250 | *nplanes = 1; |
251 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : layer->pix_fmt.sizeimage; | 251 | sizes[0] = layer->pix_fmt.sizeimage; |
252 | alloc_ctxs[0] = layer->alloc_ctx; | ||
253 | 252 | ||
254 | return 0; | 253 | return 0; |
255 | } | 254 | } |
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index c1e573b7cc6f..fad5b383706f 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c | |||
@@ -104,7 +104,6 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb) | |||
104 | /** | 104 | /** |
105 | * vpif_buffer_queue_setup : Callback function for buffer setup. | 105 | * vpif_buffer_queue_setup : Callback function for buffer setup. |
106 | * @vq: vb2_queue ptr | 106 | * @vq: vb2_queue ptr |
107 | * @fmt: v4l2 format | ||
108 | * @nbuffers: ptr to number of buffers requested by application | 107 | * @nbuffers: ptr to number of buffers requested by application |
109 | * @nplanes:: contains number of distinct video planes needed to hold a frame | 108 | * @nplanes:: contains number of distinct video planes needed to hold a frame |
110 | * @sizes[]: contains the size (in bytes) of each plane. | 109 | * @sizes[]: contains the size (in bytes) of each plane. |
@@ -114,26 +113,26 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb) | |||
114 | * the buffer count and buffer size | 113 | * the buffer count and buffer size |
115 | */ | 114 | */ |
116 | static int vpif_buffer_queue_setup(struct vb2_queue *vq, | 115 | static int vpif_buffer_queue_setup(struct vb2_queue *vq, |
117 | const void *parg, | ||
118 | unsigned int *nbuffers, unsigned int *nplanes, | 116 | unsigned int *nbuffers, unsigned int *nplanes, |
119 | unsigned int sizes[], void *alloc_ctxs[]) | 117 | unsigned int sizes[], void *alloc_ctxs[]) |
120 | { | 118 | { |
121 | const struct v4l2_format *fmt = parg; | ||
122 | struct channel_obj *ch = vb2_get_drv_priv(vq); | 119 | struct channel_obj *ch = vb2_get_drv_priv(vq); |
123 | struct common_obj *common; | 120 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; |
124 | 121 | unsigned size = common->fmt.fmt.pix.sizeimage; | |
125 | common = &ch->common[VPIF_VIDEO_INDEX]; | ||
126 | 122 | ||
127 | vpif_dbg(2, debug, "vpif_buffer_setup\n"); | 123 | vpif_dbg(2, debug, "vpif_buffer_setup\n"); |
128 | 124 | ||
129 | if (fmt && fmt->fmt.pix.sizeimage < common->fmt.fmt.pix.sizeimage) | 125 | if (*nplanes) { |
130 | return -EINVAL; | 126 | if (sizes[0] < size) |
127 | return -EINVAL; | ||
128 | size = sizes[0]; | ||
129 | } | ||
131 | 130 | ||
132 | if (vq->num_buffers + *nbuffers < 3) | 131 | if (vq->num_buffers + *nbuffers < 3) |
133 | *nbuffers = 3 - vq->num_buffers; | 132 | *nbuffers = 3 - vq->num_buffers; |
134 | 133 | ||
135 | *nplanes = 1; | 134 | *nplanes = 1; |
136 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : common->fmt.fmt.pix.sizeimage; | 135 | sizes[0] = size; |
137 | alloc_ctxs[0] = common->alloc_ctx; | 136 | alloc_ctxs[0] = common->alloc_ctx; |
138 | 137 | ||
139 | /* Calculate the offset for Y and C data in the buffer */ | 138 | /* Calculate the offset for Y and C data in the buffer */ |
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index fd2780306c17..534b50ace3a3 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c | |||
@@ -99,7 +99,6 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb) | |||
99 | /** | 99 | /** |
100 | * vpif_buffer_queue_setup : Callback function for buffer setup. | 100 | * vpif_buffer_queue_setup : Callback function for buffer setup. |
101 | * @vq: vb2_queue ptr | 101 | * @vq: vb2_queue ptr |
102 | * @fmt: v4l2 format | ||
103 | * @nbuffers: ptr to number of buffers requested by application | 102 | * @nbuffers: ptr to number of buffers requested by application |
104 | * @nplanes:: contains number of distinct video planes needed to hold a frame | 103 | * @nplanes:: contains number of distinct video planes needed to hold a frame |
105 | * @sizes[]: contains the size (in bytes) of each plane. | 104 | * @sizes[]: contains the size (in bytes) of each plane. |
@@ -109,22 +108,24 @@ static int vpif_buffer_prepare(struct vb2_buffer *vb) | |||
109 | * the buffer count and buffer size | 108 | * the buffer count and buffer size |
110 | */ | 109 | */ |
111 | static int vpif_buffer_queue_setup(struct vb2_queue *vq, | 110 | static int vpif_buffer_queue_setup(struct vb2_queue *vq, |
112 | const void *parg, | ||
113 | unsigned int *nbuffers, unsigned int *nplanes, | 111 | unsigned int *nbuffers, unsigned int *nplanes, |
114 | unsigned int sizes[], void *alloc_ctxs[]) | 112 | unsigned int sizes[], void *alloc_ctxs[]) |
115 | { | 113 | { |
116 | const struct v4l2_format *fmt = parg; | ||
117 | struct channel_obj *ch = vb2_get_drv_priv(vq); | 114 | struct channel_obj *ch = vb2_get_drv_priv(vq); |
118 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; | 115 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; |
116 | unsigned size = common->fmt.fmt.pix.sizeimage; | ||
119 | 117 | ||
120 | if (fmt && fmt->fmt.pix.sizeimage < common->fmt.fmt.pix.sizeimage) | 118 | if (*nplanes) { |
121 | return -EINVAL; | 119 | if (sizes[0] < size) |
120 | return -EINVAL; | ||
121 | size = sizes[0]; | ||
122 | } | ||
122 | 123 | ||
123 | if (vq->num_buffers + *nbuffers < 3) | 124 | if (vq->num_buffers + *nbuffers < 3) |
124 | *nbuffers = 3 - vq->num_buffers; | 125 | *nbuffers = 3 - vq->num_buffers; |
125 | 126 | ||
126 | *nplanes = 1; | 127 | *nplanes = 1; |
127 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : common->fmt.fmt.pix.sizeimage; | 128 | sizes[0] = size; |
128 | alloc_ctxs[0] = common->alloc_ctx; | 129 | alloc_ctxs[0] = common->alloc_ctx; |
129 | 130 | ||
130 | /* Calculate the offset for Y and C data in the buffer */ | 131 | /* Calculate the offset for Y and C data in the buffer */ |
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c index d82e717acba7..ea9230ef35e3 100644 --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c | |||
@@ -212,7 +212,6 @@ put_device: | |||
212 | } | 212 | } |
213 | 213 | ||
214 | static int gsc_m2m_queue_setup(struct vb2_queue *vq, | 214 | static int gsc_m2m_queue_setup(struct vb2_queue *vq, |
215 | const void *parg, | ||
216 | unsigned int *num_buffers, unsigned int *num_planes, | 215 | unsigned int *num_buffers, unsigned int *num_planes, |
217 | unsigned int sizes[], void *allocators[]) | 216 | unsigned int sizes[], void *allocators[]) |
218 | { | 217 | { |
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 99e57320e6f7..beadccb8abd7 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c | |||
@@ -338,37 +338,36 @@ int fimc_capture_resume(struct fimc_dev *fimc) | |||
338 | 338 | ||
339 | } | 339 | } |
340 | 340 | ||
341 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 341 | static int queue_setup(struct vb2_queue *vq, |
342 | unsigned int *num_buffers, unsigned int *num_planes, | 342 | unsigned int *num_buffers, unsigned int *num_planes, |
343 | unsigned int sizes[], void *allocators[]) | 343 | unsigned int sizes[], void *allocators[]) |
344 | { | 344 | { |
345 | const struct v4l2_format *pfmt = parg; | ||
346 | const struct v4l2_pix_format_mplane *pixm = NULL; | ||
347 | struct fimc_ctx *ctx = vq->drv_priv; | 345 | struct fimc_ctx *ctx = vq->drv_priv; |
348 | struct fimc_frame *frame = &ctx->d_frame; | 346 | struct fimc_frame *frame = &ctx->d_frame; |
349 | struct fimc_fmt *fmt = frame->fmt; | 347 | struct fimc_fmt *fmt = frame->fmt; |
350 | unsigned long wh; | 348 | unsigned long wh = frame->f_width * frame->f_height; |
351 | int i; | 349 | int i; |
352 | 350 | ||
353 | if (pfmt) { | ||
354 | pixm = &pfmt->fmt.pix_mp; | ||
355 | fmt = fimc_find_format(&pixm->pixelformat, NULL, | ||
356 | FMT_FLAGS_CAM | FMT_FLAGS_M2M, -1); | ||
357 | wh = pixm->width * pixm->height; | ||
358 | } else { | ||
359 | wh = frame->f_width * frame->f_height; | ||
360 | } | ||
361 | |||
362 | if (fmt == NULL) | 351 | if (fmt == NULL) |
363 | return -EINVAL; | 352 | return -EINVAL; |
364 | 353 | ||
354 | if (*num_planes) { | ||
355 | if (*num_planes != fmt->memplanes) | ||
356 | return -EINVAL; | ||
357 | for (i = 0; i < *num_planes; i++) { | ||
358 | if (sizes[i] < (wh * fmt->depth[i]) / 8) | ||
359 | return -EINVAL; | ||
360 | allocators[i] = ctx->fimc_dev->alloc_ctx; | ||
361 | } | ||
362 | return 0; | ||
363 | } | ||
364 | |||
365 | *num_planes = fmt->memplanes; | 365 | *num_planes = fmt->memplanes; |
366 | 366 | ||
367 | for (i = 0; i < fmt->memplanes; i++) { | 367 | for (i = 0; i < fmt->memplanes; i++) { |
368 | unsigned int size = (wh * fmt->depth[i]) / 8; | 368 | unsigned int size = (wh * fmt->depth[i]) / 8; |
369 | if (pixm) | 369 | |
370 | sizes[i] = max(size, pixm->plane_fmt[i].sizeimage); | 370 | if (fimc_fmt_is_user_defined(fmt->color)) |
371 | else if (fimc_fmt_is_user_defined(fmt->color)) | ||
372 | sizes[i] = frame->payload[i]; | 371 | sizes[i] = frame->payload[i]; |
373 | else | 372 | else |
374 | sizes[i] = max_t(u32, size, frame->payload[i]); | 373 | sizes[i] = max_t(u32, size, frame->payload[i]); |
diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c index f88a36908489..273e7a5c7256 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c | |||
@@ -39,39 +39,36 @@ | |||
39 | #include "fimc-is-param.h" | 39 | #include "fimc-is-param.h" |
40 | 40 | ||
41 | static int isp_video_capture_queue_setup(struct vb2_queue *vq, | 41 | static int isp_video_capture_queue_setup(struct vb2_queue *vq, |
42 | const void *parg, | ||
43 | unsigned int *num_buffers, unsigned int *num_planes, | 42 | unsigned int *num_buffers, unsigned int *num_planes, |
44 | unsigned int sizes[], void *allocators[]) | 43 | unsigned int sizes[], void *allocators[]) |
45 | { | 44 | { |
46 | const struct v4l2_format *pfmt = parg; | ||
47 | struct fimc_isp *isp = vb2_get_drv_priv(vq); | 45 | struct fimc_isp *isp = vb2_get_drv_priv(vq); |
48 | struct v4l2_pix_format_mplane *vid_fmt = &isp->video_capture.pixfmt; | 46 | struct v4l2_pix_format_mplane *vid_fmt = &isp->video_capture.pixfmt; |
49 | const struct v4l2_pix_format_mplane *pixm = NULL; | 47 | const struct fimc_fmt *fmt = isp->video_capture.format; |
50 | const struct fimc_fmt *fmt; | ||
51 | unsigned int wh, i; | 48 | unsigned int wh, i; |
52 | 49 | ||
53 | if (pfmt) { | 50 | wh = vid_fmt->width * vid_fmt->height; |
54 | pixm = &pfmt->fmt.pix_mp; | ||
55 | fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, -1); | ||
56 | wh = pixm->width * pixm->height; | ||
57 | } else { | ||
58 | fmt = isp->video_capture.format; | ||
59 | wh = vid_fmt->width * vid_fmt->height; | ||
60 | } | ||
61 | 51 | ||
62 | if (fmt == NULL) | 52 | if (fmt == NULL) |
63 | return -EINVAL; | 53 | return -EINVAL; |
64 | 54 | ||
65 | *num_buffers = clamp_t(u32, *num_buffers, FIMC_ISP_REQ_BUFS_MIN, | 55 | *num_buffers = clamp_t(u32, *num_buffers, FIMC_ISP_REQ_BUFS_MIN, |
66 | FIMC_ISP_REQ_BUFS_MAX); | 56 | FIMC_ISP_REQ_BUFS_MAX); |
57 | if (*num_planes) { | ||
58 | if (*num_planes != fmt->memplanes) | ||
59 | return -EINVAL; | ||
60 | for (i = 0; i < *num_planes; i++) { | ||
61 | if (sizes[i] < (wh * fmt->depth[i]) / 8) | ||
62 | return -EINVAL; | ||
63 | allocators[i] = isp->alloc_ctx; | ||
64 | } | ||
65 | return 0; | ||
66 | } | ||
67 | |||
67 | *num_planes = fmt->memplanes; | 68 | *num_planes = fmt->memplanes; |
68 | 69 | ||
69 | for (i = 0; i < fmt->memplanes; i++) { | 70 | for (i = 0; i < fmt->memplanes; i++) { |
70 | unsigned int size = (wh * fmt->depth[i]) / 8; | 71 | sizes[i] = (wh * fmt->depth[i]) / 8; |
71 | if (pixm) | ||
72 | sizes[i] = max(size, pixm->plane_fmt[i].sizeimage); | ||
73 | else | ||
74 | sizes[i] = size; | ||
75 | allocators[i] = isp->alloc_ctx; | 72 | allocators[i] = isp->alloc_ctx; |
76 | } | 73 | } |
77 | 74 | ||
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 6f76afd909c4..15d6fc983951 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c | |||
@@ -355,37 +355,34 @@ static void stop_streaming(struct vb2_queue *q) | |||
355 | fimc_lite_stop_capture(fimc, false); | 355 | fimc_lite_stop_capture(fimc, false); |
356 | } | 356 | } |
357 | 357 | ||
358 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 358 | static int queue_setup(struct vb2_queue *vq, |
359 | unsigned int *num_buffers, unsigned int *num_planes, | 359 | unsigned int *num_buffers, unsigned int *num_planes, |
360 | unsigned int sizes[], void *allocators[]) | 360 | unsigned int sizes[], void *allocators[]) |
361 | { | 361 | { |
362 | const struct v4l2_format *pfmt = parg; | ||
363 | const struct v4l2_pix_format_mplane *pixm = NULL; | ||
364 | struct fimc_lite *fimc = vq->drv_priv; | 362 | struct fimc_lite *fimc = vq->drv_priv; |
365 | struct flite_frame *frame = &fimc->out_frame; | 363 | struct flite_frame *frame = &fimc->out_frame; |
366 | const struct fimc_fmt *fmt = frame->fmt; | 364 | const struct fimc_fmt *fmt = frame->fmt; |
367 | unsigned long wh; | 365 | unsigned long wh = frame->f_width * frame->f_height; |
368 | int i; | 366 | int i; |
369 | 367 | ||
370 | if (pfmt) { | ||
371 | pixm = &pfmt->fmt.pix_mp; | ||
372 | fmt = fimc_lite_find_format(&pixm->pixelformat, NULL, 0, -1); | ||
373 | wh = pixm->width * pixm->height; | ||
374 | } else { | ||
375 | wh = frame->f_width * frame->f_height; | ||
376 | } | ||
377 | |||
378 | if (fmt == NULL) | 368 | if (fmt == NULL) |
379 | return -EINVAL; | 369 | return -EINVAL; |
380 | 370 | ||
371 | if (*num_planes) { | ||
372 | if (*num_planes != fmt->memplanes) | ||
373 | return -EINVAL; | ||
374 | for (i = 0; i < *num_planes; i++) { | ||
375 | if (sizes[i] < (wh * fmt->depth[i]) / 8) | ||
376 | return -EINVAL; | ||
377 | allocators[i] = fimc->alloc_ctx; | ||
378 | } | ||
379 | return 0; | ||
380 | } | ||
381 | |||
381 | *num_planes = fmt->memplanes; | 382 | *num_planes = fmt->memplanes; |
382 | 383 | ||
383 | for (i = 0; i < fmt->memplanes; i++) { | 384 | for (i = 0; i < fmt->memplanes; i++) { |
384 | unsigned int size = (wh * fmt->depth[i]) / 8; | 385 | sizes[i] = (wh * fmt->depth[i]) / 8; |
385 | if (pixm) | ||
386 | sizes[i] = max(size, pixm->plane_fmt[i].sizeimage); | ||
387 | else | ||
388 | sizes[i] = size; | ||
389 | allocators[i] = fimc->alloc_ctx; | 386 | allocators[i] = fimc->alloc_ctx; |
390 | } | 387 | } |
391 | 388 | ||
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c index 4d1d64a46b21..4c04b5964624 100644 --- a/drivers/media/platform/exynos4-is/fimc-m2m.c +++ b/drivers/media/platform/exynos4-is/fimc-m2m.c | |||
@@ -176,7 +176,7 @@ static void fimc_job_abort(void *priv) | |||
176 | fimc_m2m_shutdown(priv); | 176 | fimc_m2m_shutdown(priv); |
177 | } | 177 | } |
178 | 178 | ||
179 | static int fimc_queue_setup(struct vb2_queue *vq, const void *parg, | 179 | static int fimc_queue_setup(struct vb2_queue *vq, |
180 | unsigned int *num_buffers, unsigned int *num_planes, | 180 | unsigned int *num_buffers, unsigned int *num_planes, |
181 | unsigned int sizes[], void *allocators[]) | 181 | unsigned int sizes[], void *allocators[]) |
182 | { | 182 | { |
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c index 29973f9bf8db..652eebdbcd8e 100644 --- a/drivers/media/platform/m2m-deinterlace.c +++ b/drivers/media/platform/m2m-deinterlace.c | |||
@@ -798,7 +798,6 @@ struct vb2_dc_conf { | |||
798 | }; | 798 | }; |
799 | 799 | ||
800 | static int deinterlace_queue_setup(struct vb2_queue *vq, | 800 | static int deinterlace_queue_setup(struct vb2_queue *vq, |
801 | const void *parg, | ||
802 | unsigned int *nbuffers, unsigned int *nplanes, | 801 | unsigned int *nbuffers, unsigned int *nplanes, |
803 | unsigned int sizes[], void *alloc_ctxs[]) | 802 | unsigned int sizes[], void *alloc_ctxs[]) |
804 | { | 803 | { |
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index 4f2ec88ab890..7080a88b6a95 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c | |||
@@ -1049,24 +1049,25 @@ static int mcam_read_setup(struct mcam_camera *cam) | |||
1049 | */ | 1049 | */ |
1050 | 1050 | ||
1051 | static int mcam_vb_queue_setup(struct vb2_queue *vq, | 1051 | static int mcam_vb_queue_setup(struct vb2_queue *vq, |
1052 | const void *parg, unsigned int *nbufs, | 1052 | unsigned int *nbufs, |
1053 | unsigned int *num_planes, unsigned int sizes[], | 1053 | unsigned int *num_planes, unsigned int sizes[], |
1054 | void *alloc_ctxs[]) | 1054 | void *alloc_ctxs[]) |
1055 | { | 1055 | { |
1056 | const struct v4l2_format *fmt = parg; | ||
1057 | struct mcam_camera *cam = vb2_get_drv_priv(vq); | 1056 | struct mcam_camera *cam = vb2_get_drv_priv(vq); |
1058 | int minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2; | 1057 | int minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2; |
1058 | unsigned size = cam->pix_format.sizeimage; | ||
1059 | 1059 | ||
1060 | if (fmt && fmt->fmt.pix.sizeimage < cam->pix_format.sizeimage) | ||
1061 | return -EINVAL; | ||
1062 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : cam->pix_format.sizeimage; | ||
1063 | *num_planes = 1; /* Someday we have to support planar formats... */ | ||
1064 | if (*nbufs < minbufs) | 1060 | if (*nbufs < minbufs) |
1065 | *nbufs = minbufs; | 1061 | *nbufs = minbufs; |
1066 | if (cam->buffer_mode == B_DMA_contig) | 1062 | if (cam->buffer_mode == B_DMA_contig) |
1067 | alloc_ctxs[0] = cam->vb_alloc_ctx; | 1063 | alloc_ctxs[0] = cam->vb_alloc_ctx; |
1068 | else if (cam->buffer_mode == B_DMA_sg) | 1064 | else if (cam->buffer_mode == B_DMA_sg) |
1069 | alloc_ctxs[0] = cam->vb_alloc_ctx_sg; | 1065 | alloc_ctxs[0] = cam->vb_alloc_ctx_sg; |
1066 | |||
1067 | if (*num_planes) | ||
1068 | return sizes[0] < size ? -EINVAL : 0; | ||
1069 | sizes[0] = size; | ||
1070 | *num_planes = 1; /* Someday we have to support planar formats... */ | ||
1070 | return 0; | 1071 | return 0; |
1071 | } | 1072 | } |
1072 | 1073 | ||
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c index 03a1b606655d..cb7d4b518318 100644 --- a/drivers/media/platform/mx2_emmaprp.c +++ b/drivers/media/platform/mx2_emmaprp.c | |||
@@ -689,7 +689,6 @@ static const struct v4l2_ioctl_ops emmaprp_ioctl_ops = { | |||
689 | * Queue operations | 689 | * Queue operations |
690 | */ | 690 | */ |
691 | static int emmaprp_queue_setup(struct vb2_queue *vq, | 691 | static int emmaprp_queue_setup(struct vb2_queue *vq, |
692 | const void *parg, | ||
693 | unsigned int *nbuffers, unsigned int *nplanes, | 692 | unsigned int *nbuffers, unsigned int *nplanes, |
694 | unsigned int sizes[], void *alloc_ctxs[]) | 693 | unsigned int sizes[], void *alloc_ctxs[]) |
695 | { | 694 | { |
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index f4f591652432..9cc4878f784f 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c | |||
@@ -320,7 +320,6 @@ isp_video_check_format(struct isp_video *video, struct isp_video_fh *vfh) | |||
320 | */ | 320 | */ |
321 | 321 | ||
322 | static int isp_video_queue_setup(struct vb2_queue *queue, | 322 | static int isp_video_queue_setup(struct vb2_queue *queue, |
323 | const void *parg, | ||
324 | unsigned int *count, unsigned int *num_planes, | 323 | unsigned int *count, unsigned int *num_planes, |
325 | unsigned int sizes[], void *alloc_ctxs[]) | 324 | unsigned int sizes[], void *alloc_ctxs[]) |
326 | { | 325 | { |
diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c index 86d2a3d18241..742f13ee67a9 100644 --- a/drivers/media/platform/rcar_jpu.c +++ b/drivers/media/platform/rcar_jpu.c | |||
@@ -1015,28 +1015,33 @@ error_free: | |||
1015 | * ============================================================================ | 1015 | * ============================================================================ |
1016 | */ | 1016 | */ |
1017 | static int jpu_queue_setup(struct vb2_queue *vq, | 1017 | static int jpu_queue_setup(struct vb2_queue *vq, |
1018 | const void *parg, | ||
1019 | unsigned int *nbuffers, unsigned int *nplanes, | 1018 | unsigned int *nbuffers, unsigned int *nplanes, |
1020 | unsigned int sizes[], void *alloc_ctxs[]) | 1019 | unsigned int sizes[], void *alloc_ctxs[]) |
1021 | { | 1020 | { |
1022 | const struct v4l2_format *fmt = parg; | ||
1023 | struct jpu_ctx *ctx = vb2_get_drv_priv(vq); | 1021 | struct jpu_ctx *ctx = vb2_get_drv_priv(vq); |
1024 | struct jpu_q_data *q_data; | 1022 | struct jpu_q_data *q_data; |
1025 | unsigned int i; | 1023 | unsigned int i; |
1026 | 1024 | ||
1027 | q_data = jpu_get_q_data(ctx, vq->type); | 1025 | q_data = jpu_get_q_data(ctx, vq->type); |
1028 | 1026 | ||
1029 | *nplanes = q_data->format.num_planes; | 1027 | if (*nplanes) { |
1028 | if (*nplanes != q_data->format.num_planes) | ||
1029 | return -EINVAL; | ||
1030 | 1030 | ||
1031 | for (i = 0; i < *nplanes; i++) { | 1031 | for (i = 0; i < *nplanes; i++) { |
1032 | unsigned int q_size = q_data->format.plane_fmt[i].sizeimage; | 1032 | unsigned int q_size = q_data->format.plane_fmt[i].sizeimage; |
1033 | unsigned int f_size = fmt ? | ||
1034 | fmt->fmt.pix_mp.plane_fmt[i].sizeimage : 0; | ||
1035 | 1033 | ||
1036 | if (fmt && f_size < q_size) | 1034 | if (sizes[i] < q_size) |
1037 | return -EINVAL; | 1035 | return -EINVAL; |
1036 | alloc_ctxs[i] = ctx->jpu->alloc_ctx; | ||
1037 | } | ||
1038 | return 0; | ||
1039 | } | ||
1038 | 1040 | ||
1039 | sizes[i] = fmt ? f_size : q_size; | 1041 | *nplanes = q_data->format.num_planes; |
1042 | |||
1043 | for (i = 0; i < *nplanes; i++) { | ||
1044 | sizes[i] = q_data->format.plane_fmt[i].sizeimage; | ||
1040 | alloc_ctxs[i] = ctx->jpu->alloc_ctx; | 1045 | alloc_ctxs[i] = ctx->jpu->alloc_ctx; |
1041 | } | 1046 | } |
1042 | 1047 | ||
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c index 537b858cb94a..68e651295ded 100644 --- a/drivers/media/platform/s3c-camif/camif-capture.c +++ b/drivers/media/platform/s3c-camif/camif-capture.c | |||
@@ -435,39 +435,28 @@ static void stop_streaming(struct vb2_queue *vq) | |||
435 | camif_stop_capture(vp); | 435 | camif_stop_capture(vp); |
436 | } | 436 | } |
437 | 437 | ||
438 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 438 | static int queue_setup(struct vb2_queue *vq, |
439 | unsigned int *num_buffers, unsigned int *num_planes, | 439 | unsigned int *num_buffers, unsigned int *num_planes, |
440 | unsigned int sizes[], void *allocators[]) | 440 | unsigned int sizes[], void *allocators[]) |
441 | { | 441 | { |
442 | const struct v4l2_format *pfmt = parg; | ||
443 | const struct v4l2_pix_format *pix = NULL; | ||
444 | struct camif_vp *vp = vb2_get_drv_priv(vq); | 442 | struct camif_vp *vp = vb2_get_drv_priv(vq); |
445 | struct camif_dev *camif = vp->camif; | 443 | struct camif_dev *camif = vp->camif; |
446 | struct camif_frame *frame = &vp->out_frame; | 444 | struct camif_frame *frame = &vp->out_frame; |
447 | const struct camif_fmt *fmt; | 445 | const struct camif_fmt *fmt = vp->out_fmt; |
448 | unsigned int size; | 446 | unsigned int size; |
449 | 447 | ||
450 | if (pfmt) { | 448 | if (fmt == NULL) |
451 | pix = &pfmt->fmt.pix; | 449 | return -EINVAL; |
452 | fmt = s3c_camif_find_format(vp, &pix->pixelformat, -1); | ||
453 | if (fmt == NULL) | ||
454 | return -EINVAL; | ||
455 | size = (pix->width * pix->height * fmt->depth) / 8; | ||
456 | } else { | ||
457 | fmt = vp->out_fmt; | ||
458 | if (fmt == NULL) | ||
459 | return -EINVAL; | ||
460 | size = (frame->f_width * frame->f_height * fmt->depth) / 8; | ||
461 | } | ||
462 | |||
463 | *num_planes = 1; | ||
464 | 450 | ||
465 | if (pix) | 451 | size = (frame->f_width * frame->f_height * fmt->depth) / 8; |
466 | sizes[0] = max(size, pix->sizeimage); | ||
467 | else | ||
468 | sizes[0] = size; | ||
469 | allocators[0] = camif->alloc_ctx; | 452 | allocators[0] = camif->alloc_ctx; |
470 | 453 | ||
454 | if (*num_planes) | ||
455 | return sizes[0] < size ? -EINVAL : 0; | ||
456 | |||
457 | *num_planes = 1; | ||
458 | sizes[0] = size; | ||
459 | |||
471 | pr_debug("size: %u\n", sizes[0]); | 460 | pr_debug("size: %u\n", sizes[0]); |
472 | return 0; | 461 | return 0; |
473 | } | 462 | } |
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c index e1936d9d27da..12b4415bc283 100644 --- a/drivers/media/platform/s5p-g2d/g2d.c +++ b/drivers/media/platform/s5p-g2d/g2d.c | |||
@@ -101,7 +101,7 @@ static struct g2d_frame *get_frame(struct g2d_ctx *ctx, | |||
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | static int g2d_queue_setup(struct vb2_queue *vq, const void *parg, | 104 | static int g2d_queue_setup(struct vb2_queue *vq, |
105 | unsigned int *nbuffers, unsigned int *nplanes, | 105 | unsigned int *nbuffers, unsigned int *nplanes, |
106 | unsigned int sizes[], void *alloc_ctxs[]) | 106 | unsigned int sizes[], void *alloc_ctxs[]) |
107 | { | 107 | { |
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 4a608cbe0fdb..30440b0609af 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c | |||
@@ -2430,7 +2430,6 @@ static struct v4l2_m2m_ops exynos4_jpeg_m2m_ops = { | |||
2430 | */ | 2430 | */ |
2431 | 2431 | ||
2432 | static int s5p_jpeg_queue_setup(struct vb2_queue *vq, | 2432 | static int s5p_jpeg_queue_setup(struct vb2_queue *vq, |
2433 | const void *parg, | ||
2434 | unsigned int *nbuffers, unsigned int *nplanes, | 2433 | unsigned int *nbuffers, unsigned int *nplanes, |
2435 | unsigned int sizes[], void *alloc_ctxs[]) | 2434 | unsigned int sizes[], void *alloc_ctxs[]) |
2436 | { | 2435 | { |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c index 1c4998c221a2..dabf26399a9e 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | |||
@@ -888,7 +888,7 @@ static const struct v4l2_ioctl_ops s5p_mfc_dec_ioctl_ops = { | |||
888 | }; | 888 | }; |
889 | 889 | ||
890 | static int s5p_mfc_queue_setup(struct vb2_queue *vq, | 890 | static int s5p_mfc_queue_setup(struct vb2_queue *vq, |
891 | const void *parg, unsigned int *buf_count, | 891 | unsigned int *buf_count, |
892 | unsigned int *plane_count, unsigned int psize[], | 892 | unsigned int *plane_count, unsigned int psize[], |
893 | void *allocators[]) | 893 | void *allocators[]) |
894 | { | 894 | { |
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c index 115b7dac1d4c..9916cded4a72 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | |||
@@ -1818,7 +1818,6 @@ static int check_vb_with_fmt(struct s5p_mfc_fmt *fmt, struct vb2_buffer *vb) | |||
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | static int s5p_mfc_queue_setup(struct vb2_queue *vq, | 1820 | static int s5p_mfc_queue_setup(struct vb2_queue *vq, |
1821 | const void *parg, | ||
1822 | unsigned int *buf_count, unsigned int *plane_count, | 1821 | unsigned int *buf_count, unsigned int *plane_count, |
1823 | unsigned int psize[], void *allocators[]) | 1822 | unsigned int psize[], void *allocators[]) |
1824 | { | 1823 | { |
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c index dc1c679e136c..d9e7f030294c 100644 --- a/drivers/media/platform/s5p-tv/mixer_video.c +++ b/drivers/media/platform/s5p-tv/mixer_video.c | |||
@@ -881,7 +881,7 @@ static const struct v4l2_file_operations mxr_fops = { | |||
881 | .unlocked_ioctl = video_ioctl2, | 881 | .unlocked_ioctl = video_ioctl2, |
882 | }; | 882 | }; |
883 | 883 | ||
884 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 884 | static int queue_setup(struct vb2_queue *vq, |
885 | unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], | 885 | unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], |
886 | void *alloc_ctxs[]) | 886 | void *alloc_ctxs[]) |
887 | { | 887 | { |
diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c index d6ab33e7060a..82c39f305b54 100644 --- a/drivers/media/platform/sh_veu.c +++ b/drivers/media/platform/sh_veu.c | |||
@@ -865,32 +865,14 @@ static const struct v4l2_ioctl_ops sh_veu_ioctl_ops = { | |||
865 | /* ========== Queue operations ========== */ | 865 | /* ========== Queue operations ========== */ |
866 | 866 | ||
867 | static int sh_veu_queue_setup(struct vb2_queue *vq, | 867 | static int sh_veu_queue_setup(struct vb2_queue *vq, |
868 | const void *parg, | ||
869 | unsigned int *nbuffers, unsigned int *nplanes, | 868 | unsigned int *nbuffers, unsigned int *nplanes, |
870 | unsigned int sizes[], void *alloc_ctxs[]) | 869 | unsigned int sizes[], void *alloc_ctxs[]) |
871 | { | 870 | { |
872 | const struct v4l2_format *f = parg; | ||
873 | struct sh_veu_dev *veu = vb2_get_drv_priv(vq); | 871 | struct sh_veu_dev *veu = vb2_get_drv_priv(vq); |
874 | struct sh_veu_vfmt *vfmt; | 872 | struct sh_veu_vfmt *vfmt = sh_veu_get_vfmt(veu, vq->type); |
875 | unsigned int size, count = *nbuffers; | 873 | unsigned int count = *nbuffers; |
876 | 874 | unsigned int size = vfmt->bytesperline * vfmt->frame.height * | |
877 | if (f) { | 875 | vfmt->fmt->depth / vfmt->fmt->ydepth; |
878 | const struct v4l2_pix_format *pix = &f->fmt.pix; | ||
879 | const struct sh_veu_format *fmt = sh_veu_find_fmt(f); | ||
880 | struct v4l2_format ftmp = *f; | ||
881 | |||
882 | if (fmt->fourcc != pix->pixelformat) | ||
883 | return -EINVAL; | ||
884 | sh_veu_try_fmt(&ftmp, fmt); | ||
885 | if (ftmp.fmt.pix.width != pix->width || | ||
886 | ftmp.fmt.pix.height != pix->height) | ||
887 | return -EINVAL; | ||
888 | size = pix->bytesperline ? pix->bytesperline * pix->height * fmt->depth / fmt->ydepth : | ||
889 | pix->width * pix->height * fmt->depth / fmt->ydepth; | ||
890 | } else { | ||
891 | vfmt = sh_veu_get_vfmt(veu, vq->type); | ||
892 | size = vfmt->bytesperline * vfmt->frame.height * vfmt->fmt->depth / vfmt->fmt->ydepth; | ||
893 | } | ||
894 | 876 | ||
895 | if (count < 2) | 877 | if (count < 2) |
896 | *nbuffers = count = 2; | 878 | *nbuffers = count = 2; |
@@ -900,6 +882,11 @@ static int sh_veu_queue_setup(struct vb2_queue *vq, | |||
900 | *nbuffers = count; | 882 | *nbuffers = count; |
901 | } | 883 | } |
902 | 884 | ||
885 | if (*nplanes) { | ||
886 | alloc_ctxs[0] = veu->alloc_ctx; | ||
887 | return sizes[0] < size ? -EINVAL : 0; | ||
888 | } | ||
889 | |||
903 | *nplanes = 1; | 890 | *nplanes = 1; |
904 | sizes[0] = size; | 891 | sizes[0] = size; |
905 | alloc_ctxs[0] = veu->alloc_ctx; | 892 | alloc_ctxs[0] = veu->alloc_ctx; |
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c index 544e2b5a2ec3..fd0524ec1ccc 100644 --- a/drivers/media/platform/sh_vou.c +++ b/drivers/media/platform/sh_vou.c | |||
@@ -243,22 +243,21 @@ static void sh_vou_stream_config(struct sh_vou_device *vou_dev) | |||
243 | } | 243 | } |
244 | 244 | ||
245 | /* Locking: caller holds fop_lock mutex */ | 245 | /* Locking: caller holds fop_lock mutex */ |
246 | static int sh_vou_queue_setup(struct vb2_queue *vq, const void *parg, | 246 | static int sh_vou_queue_setup(struct vb2_queue *vq, |
247 | unsigned int *nbuffers, unsigned int *nplanes, | 247 | unsigned int *nbuffers, unsigned int *nplanes, |
248 | unsigned int sizes[], void *alloc_ctxs[]) | 248 | unsigned int sizes[], void *alloc_ctxs[]) |
249 | { | 249 | { |
250 | const struct v4l2_format *fmt = parg; | ||
251 | struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq); | 250 | struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq); |
252 | struct v4l2_pix_format *pix = &vou_dev->pix; | 251 | struct v4l2_pix_format *pix = &vou_dev->pix; |
253 | int bytes_per_line = vou_fmt[vou_dev->pix_idx].bpp * pix->width / 8; | 252 | int bytes_per_line = vou_fmt[vou_dev->pix_idx].bpp * pix->width / 8; |
254 | 253 | ||
255 | dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); | 254 | dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); |
256 | 255 | ||
257 | if (fmt && fmt->fmt.pix.sizeimage < pix->height * bytes_per_line) | ||
258 | return -EINVAL; | ||
259 | *nplanes = 1; | ||
260 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : pix->height * bytes_per_line; | ||
261 | alloc_ctxs[0] = vou_dev->alloc_ctx; | 256 | alloc_ctxs[0] = vou_dev->alloc_ctx; |
257 | if (*nplanes) | ||
258 | return sizes[0] < pix->height * bytes_per_line ? -EINVAL : 0; | ||
259 | *nplanes = 1; | ||
260 | sizes[0] = pix->height * bytes_per_line; | ||
262 | return 0; | 261 | return 0; |
263 | } | 262 | } |
264 | 263 | ||
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c index f5f815d792b7..b78aa0250b2a 100644 --- a/drivers/media/platform/soc_camera/atmel-isi.c +++ b/drivers/media/platform/soc_camera/atmel-isi.c | |||
@@ -303,7 +303,7 @@ static int atmel_isi_wait_status(struct atmel_isi *isi, int wait_reset) | |||
303 | /* ------------------------------------------------------------------ | 303 | /* ------------------------------------------------------------------ |
304 | Videobuf operations | 304 | Videobuf operations |
305 | ------------------------------------------------------------------*/ | 305 | ------------------------------------------------------------------*/ |
306 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 306 | static int queue_setup(struct vb2_queue *vq, |
307 | unsigned int *nbuffers, unsigned int *nplanes, | 307 | unsigned int *nbuffers, unsigned int *nplanes, |
308 | unsigned int sizes[], void *alloc_ctxs[]) | 308 | unsigned int sizes[], void *alloc_ctxs[]) |
309 | { | 309 | { |
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c index 276beaefca7c..8889b299a742 100644 --- a/drivers/media/platform/soc_camera/mx2_camera.c +++ b/drivers/media/platform/soc_camera/mx2_camera.c | |||
@@ -469,21 +469,15 @@ static void mx2_camera_clock_stop(struct soc_camera_host *ici) | |||
469 | * Videobuf operations | 469 | * Videobuf operations |
470 | */ | 470 | */ |
471 | static int mx2_videobuf_setup(struct vb2_queue *vq, | 471 | static int mx2_videobuf_setup(struct vb2_queue *vq, |
472 | const void *parg, | ||
473 | unsigned int *count, unsigned int *num_planes, | 472 | unsigned int *count, unsigned int *num_planes, |
474 | unsigned int sizes[], void *alloc_ctxs[]) | 473 | unsigned int sizes[], void *alloc_ctxs[]) |
475 | { | 474 | { |
476 | const struct v4l2_format *fmt = parg; | ||
477 | struct soc_camera_device *icd = soc_camera_from_vb2q(vq); | 475 | struct soc_camera_device *icd = soc_camera_from_vb2q(vq); |
478 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 476 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
479 | struct mx2_camera_dev *pcdev = ici->priv; | 477 | struct mx2_camera_dev *pcdev = ici->priv; |
480 | 478 | ||
481 | dev_dbg(icd->parent, "count=%d, size=%d\n", *count, sizes[0]); | 479 | dev_dbg(icd->parent, "count=%d, size=%d\n", *count, sizes[0]); |
482 | 480 | ||
483 | /* TODO: support for VIDIOC_CREATE_BUFS not ready */ | ||
484 | if (fmt != NULL) | ||
485 | return -ENOTTY; | ||
486 | |||
487 | alloc_ctxs[0] = pcdev->alloc_ctx; | 481 | alloc_ctxs[0] = pcdev->alloc_ctx; |
488 | 482 | ||
489 | sizes[0] = icd->sizeimage; | 483 | sizes[0] = icd->sizeimage; |
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c index 046ebf0b56a0..bbe01e86a0ca 100644 --- a/drivers/media/platform/soc_camera/mx3_camera.c +++ b/drivers/media/platform/soc_camera/mx3_camera.c | |||
@@ -185,11 +185,9 @@ static void mx3_cam_dma_done(void *arg) | |||
185 | * Calculate the __buffer__ (not data) size and number of buffers. | 185 | * Calculate the __buffer__ (not data) size and number of buffers. |
186 | */ | 186 | */ |
187 | static int mx3_videobuf_setup(struct vb2_queue *vq, | 187 | static int mx3_videobuf_setup(struct vb2_queue *vq, |
188 | const void *parg, | ||
189 | unsigned int *count, unsigned int *num_planes, | 188 | unsigned int *count, unsigned int *num_planes, |
190 | unsigned int sizes[], void *alloc_ctxs[]) | 189 | unsigned int sizes[], void *alloc_ctxs[]) |
191 | { | 190 | { |
192 | const struct v4l2_format *fmt = parg; | ||
193 | struct soc_camera_device *icd = soc_camera_from_vb2q(vq); | 191 | struct soc_camera_device *icd = soc_camera_from_vb2q(vq); |
194 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 192 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
195 | struct mx3_camera_dev *mx3_cam = ici->priv; | 193 | struct mx3_camera_dev *mx3_cam = ici->priv; |
@@ -197,33 +195,6 @@ static int mx3_videobuf_setup(struct vb2_queue *vq, | |||
197 | if (!mx3_cam->idmac_channel[0]) | 195 | if (!mx3_cam->idmac_channel[0]) |
198 | return -EINVAL; | 196 | return -EINVAL; |
199 | 197 | ||
200 | if (fmt) { | ||
201 | const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd, | ||
202 | fmt->fmt.pix.pixelformat); | ||
203 | unsigned int bytes_per_line; | ||
204 | int ret; | ||
205 | |||
206 | if (!xlate) | ||
207 | return -EINVAL; | ||
208 | |||
209 | ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width, | ||
210 | xlate->host_fmt); | ||
211 | if (ret < 0) | ||
212 | return ret; | ||
213 | |||
214 | bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret); | ||
215 | |||
216 | ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line, | ||
217 | fmt->fmt.pix.height); | ||
218 | if (ret < 0) | ||
219 | return ret; | ||
220 | |||
221 | sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret); | ||
222 | } else { | ||
223 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ | ||
224 | sizes[0] = icd->sizeimage; | ||
225 | } | ||
226 | |||
227 | alloc_ctxs[0] = mx3_cam->alloc_ctx; | 198 | alloc_ctxs[0] = mx3_cam->alloc_ctx; |
228 | 199 | ||
229 | if (!vq->num_buffers) | 200 | if (!vq->num_buffers) |
@@ -232,9 +203,14 @@ static int mx3_videobuf_setup(struct vb2_queue *vq, | |||
232 | if (!*count) | 203 | if (!*count) |
233 | *count = 2; | 204 | *count = 2; |
234 | 205 | ||
206 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ | ||
207 | if (!*num_planes) | ||
208 | sizes[0] = icd->sizeimage; | ||
209 | else if (sizes[0] < icd->sizeimage) | ||
210 | return -EINVAL; | ||
211 | |||
235 | /* If *num_planes != 0, we have already verified *count. */ | 212 | /* If *num_planes != 0, we have already verified *count. */ |
236 | if (!*num_planes && | 213 | if (sizes[0] * *count + mx3_cam->buf_total > MAX_VIDEO_MEM * 1024 * 1024) |
237 | sizes[0] * *count + mx3_cam->buf_total > MAX_VIDEO_MEM * 1024 * 1024) | ||
238 | *count = (MAX_VIDEO_MEM * 1024 * 1024 - mx3_cam->buf_total) / | 214 | *count = (MAX_VIDEO_MEM * 1024 * 1024 - mx3_cam->buf_total) / |
239 | sizes[0]; | 215 | sizes[0]; |
240 | 216 | ||
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 5d90f39cbb3e..b0043cd209aa 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c | |||
@@ -531,46 +531,14 @@ struct rcar_vin_cam { | |||
531 | * required | 531 | * required |
532 | */ | 532 | */ |
533 | static int rcar_vin_videobuf_setup(struct vb2_queue *vq, | 533 | static int rcar_vin_videobuf_setup(struct vb2_queue *vq, |
534 | const void *parg, | ||
535 | unsigned int *count, | 534 | unsigned int *count, |
536 | unsigned int *num_planes, | 535 | unsigned int *num_planes, |
537 | unsigned int sizes[], void *alloc_ctxs[]) | 536 | unsigned int sizes[], void *alloc_ctxs[]) |
538 | { | 537 | { |
539 | const struct v4l2_format *fmt = parg; | ||
540 | struct soc_camera_device *icd = soc_camera_from_vb2q(vq); | 538 | struct soc_camera_device *icd = soc_camera_from_vb2q(vq); |
541 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 539 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
542 | struct rcar_vin_priv *priv = ici->priv; | 540 | struct rcar_vin_priv *priv = ici->priv; |
543 | 541 | ||
544 | if (fmt) { | ||
545 | const struct soc_camera_format_xlate *xlate; | ||
546 | unsigned int bytes_per_line; | ||
547 | int ret; | ||
548 | |||
549 | if (fmt->fmt.pix.sizeimage < icd->sizeimage) | ||
550 | return -EINVAL; | ||
551 | |||
552 | xlate = soc_camera_xlate_by_fourcc(icd, | ||
553 | fmt->fmt.pix.pixelformat); | ||
554 | if (!xlate) | ||
555 | return -EINVAL; | ||
556 | ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width, | ||
557 | xlate->host_fmt); | ||
558 | if (ret < 0) | ||
559 | return ret; | ||
560 | |||
561 | bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret); | ||
562 | |||
563 | ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line, | ||
564 | fmt->fmt.pix.height); | ||
565 | if (ret < 0) | ||
566 | return ret; | ||
567 | |||
568 | sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret); | ||
569 | } else { | ||
570 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ | ||
571 | sizes[0] = icd->sizeimage; | ||
572 | } | ||
573 | |||
574 | alloc_ctxs[0] = priv->alloc_ctx; | 542 | alloc_ctxs[0] = priv->alloc_ctx; |
575 | 543 | ||
576 | if (!vq->num_buffers) | 544 | if (!vq->num_buffers) |
@@ -580,14 +548,18 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq, | |||
580 | *count = 2; | 548 | *count = 2; |
581 | priv->vb_count = *count; | 549 | priv->vb_count = *count; |
582 | 550 | ||
583 | *num_planes = 1; | ||
584 | |||
585 | /* Number of hardware slots */ | 551 | /* Number of hardware slots */ |
586 | if (is_continuous_transfer(priv)) | 552 | if (is_continuous_transfer(priv)) |
587 | priv->nr_hw_slots = MAX_BUFFER_NUM; | 553 | priv->nr_hw_slots = MAX_BUFFER_NUM; |
588 | else | 554 | else |
589 | priv->nr_hw_slots = 1; | 555 | priv->nr_hw_slots = 1; |
590 | 556 | ||
557 | if (*num_planes) | ||
558 | return sizes[0] < icd->sizeimage ? -EINVAL : 0; | ||
559 | |||
560 | sizes[0] = icd->sizeimage; | ||
561 | *num_planes = 1; | ||
562 | |||
591 | dev_dbg(icd->parent, "count=%d, size=%u\n", *count, sizes[0]); | 563 | dev_dbg(icd->parent, "count=%d, size=%u\n", *count, sizes[0]); |
592 | 564 | ||
593 | return 0; | 565 | return 0; |
diff --git a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c index ad21307878cf..4e9bc04b92cb 100644 --- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | |||
@@ -210,43 +210,14 @@ static int sh_mobile_ceu_soft_reset(struct sh_mobile_ceu_dev *pcdev) | |||
210 | * for the current frame format if required | 210 | * for the current frame format if required |
211 | */ | 211 | */ |
212 | static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq, | 212 | static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq, |
213 | const void *parg, | ||
214 | unsigned int *count, unsigned int *num_planes, | 213 | unsigned int *count, unsigned int *num_planes, |
215 | unsigned int sizes[], void *alloc_ctxs[]) | 214 | unsigned int sizes[], void *alloc_ctxs[]) |
216 | { | 215 | { |
217 | const struct v4l2_format *fmt = parg; | ||
218 | struct soc_camera_device *icd = container_of(vq, | 216 | struct soc_camera_device *icd = container_of(vq, |
219 | struct soc_camera_device, vb2_vidq); | 217 | struct soc_camera_device, vb2_vidq); |
220 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); | 218 | struct soc_camera_host *ici = to_soc_camera_host(icd->parent); |
221 | struct sh_mobile_ceu_dev *pcdev = ici->priv; | 219 | struct sh_mobile_ceu_dev *pcdev = ici->priv; |
222 | 220 | ||
223 | if (fmt) { | ||
224 | const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd, | ||
225 | fmt->fmt.pix.pixelformat); | ||
226 | unsigned int bytes_per_line; | ||
227 | int ret; | ||
228 | |||
229 | if (!xlate) | ||
230 | return -EINVAL; | ||
231 | |||
232 | ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width, | ||
233 | xlate->host_fmt); | ||
234 | if (ret < 0) | ||
235 | return ret; | ||
236 | |||
237 | bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret); | ||
238 | |||
239 | ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line, | ||
240 | fmt->fmt.pix.height); | ||
241 | if (ret < 0) | ||
242 | return ret; | ||
243 | |||
244 | sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret); | ||
245 | } else { | ||
246 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ | ||
247 | sizes[0] = icd->sizeimage; | ||
248 | } | ||
249 | |||
250 | alloc_ctxs[0] = pcdev->alloc_ctx; | 221 | alloc_ctxs[0] = pcdev->alloc_ctx; |
251 | 222 | ||
252 | if (!vq->num_buffers) | 223 | if (!vq->num_buffers) |
@@ -255,8 +226,14 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq, | |||
255 | if (!*count) | 226 | if (!*count) |
256 | *count = 2; | 227 | *count = 2; |
257 | 228 | ||
229 | /* Called from VIDIOC_REQBUFS or in compatibility mode */ | ||
230 | if (!*num_planes) | ||
231 | sizes[0] = icd->sizeimage; | ||
232 | else if (sizes[0] < icd->sizeimage) | ||
233 | return -EINVAL; | ||
234 | |||
258 | /* If *num_planes != 0, we have already verified *count. */ | 235 | /* If *num_planes != 0, we have already verified *count. */ |
259 | if (pcdev->video_limit && !*num_planes) { | 236 | if (pcdev->video_limit) { |
260 | size_t size = PAGE_ALIGN(sizes[0]) * *count; | 237 | size_t size = PAGE_ALIGN(sizes[0]) * *count; |
261 | 238 | ||
262 | if (size + pcdev->buf_total > pcdev->video_limit) | 239 | if (size + pcdev->buf_total > pcdev->video_limit) |
diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c index a0d267e017f6..81871d6ae823 100644 --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c | |||
@@ -438,11 +438,9 @@ static void bdisp_ctrls_delete(struct bdisp_ctx *ctx) | |||
438 | } | 438 | } |
439 | 439 | ||
440 | static int bdisp_queue_setup(struct vb2_queue *vq, | 440 | static int bdisp_queue_setup(struct vb2_queue *vq, |
441 | const void *parg, | ||
442 | unsigned int *nb_buf, unsigned int *nb_planes, | 441 | unsigned int *nb_buf, unsigned int *nb_planes, |
443 | unsigned int sizes[], void *allocators[]) | 442 | unsigned int sizes[], void *allocators[]) |
444 | { | 443 | { |
445 | const struct v4l2_format *fmt = parg; | ||
446 | struct bdisp_ctx *ctx = vb2_get_drv_priv(vq); | 444 | struct bdisp_ctx *ctx = vb2_get_drv_priv(vq); |
447 | struct bdisp_frame *frame = ctx_get_frame(ctx, vq->type); | 445 | struct bdisp_frame *frame = ctx_get_frame(ctx, vq->type); |
448 | 446 | ||
@@ -455,13 +453,13 @@ static int bdisp_queue_setup(struct vb2_queue *vq, | |||
455 | dev_err(ctx->bdisp_dev->dev, "Invalid format\n"); | 453 | dev_err(ctx->bdisp_dev->dev, "Invalid format\n"); |
456 | return -EINVAL; | 454 | return -EINVAL; |
457 | } | 455 | } |
456 | allocators[0] = ctx->bdisp_dev->alloc_ctx; | ||
458 | 457 | ||
459 | if (fmt && fmt->fmt.pix.sizeimage < frame->sizeimage) | 458 | if (*nb_planes) |
460 | return -EINVAL; | 459 | return sizes[0] < frame->sizeimage ? -EINVAL : 0; |
461 | 460 | ||
462 | *nb_planes = 1; | 461 | *nb_planes = 1; |
463 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : frame->sizeimage; | 462 | sizes[0] = frame->sizeimage; |
464 | allocators[0] = ctx->bdisp_dev->alloc_ctx; | ||
465 | 463 | ||
466 | return 0; | 464 | return 0; |
467 | } | 465 | } |
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c index de24effd984f..e8ed2652eb07 100644 --- a/drivers/media/platform/ti-vpe/vpe.c +++ b/drivers/media/platform/ti-vpe/vpe.c | |||
@@ -1796,7 +1796,6 @@ static const struct v4l2_ioctl_ops vpe_ioctl_ops = { | |||
1796 | * Queue operations | 1796 | * Queue operations |
1797 | */ | 1797 | */ |
1798 | static int vpe_queue_setup(struct vb2_queue *vq, | 1798 | static int vpe_queue_setup(struct vb2_queue *vq, |
1799 | const void *parg, | ||
1800 | unsigned int *nbuffers, unsigned int *nplanes, | 1799 | unsigned int *nbuffers, unsigned int *nplanes, |
1801 | unsigned int sizes[], void *alloc_ctxs[]) | 1800 | unsigned int sizes[], void *alloc_ctxs[]) |
1802 | { | 1801 | { |
diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c index e18fb9f9ed2f..93e1d256b13a 100644 --- a/drivers/media/platform/vim2m.c +++ b/drivers/media/platform/vim2m.c | |||
@@ -710,11 +710,9 @@ static const struct v4l2_ioctl_ops vim2m_ioctl_ops = { | |||
710 | */ | 710 | */ |
711 | 711 | ||
712 | static int vim2m_queue_setup(struct vb2_queue *vq, | 712 | static int vim2m_queue_setup(struct vb2_queue *vq, |
713 | const void *parg, | ||
714 | unsigned int *nbuffers, unsigned int *nplanes, | 713 | unsigned int *nbuffers, unsigned int *nplanes, |
715 | unsigned int sizes[], void *alloc_ctxs[]) | 714 | unsigned int sizes[], void *alloc_ctxs[]) |
716 | { | 715 | { |
717 | const struct v4l2_format *fmt = parg; | ||
718 | struct vim2m_ctx *ctx = vb2_get_drv_priv(vq); | 716 | struct vim2m_ctx *ctx = vb2_get_drv_priv(vq); |
719 | struct vim2m_q_data *q_data; | 717 | struct vim2m_q_data *q_data; |
720 | unsigned int size, count = *nbuffers; | 718 | unsigned int size, count = *nbuffers; |
@@ -723,17 +721,14 @@ static int vim2m_queue_setup(struct vb2_queue *vq, | |||
723 | 721 | ||
724 | size = q_data->width * q_data->height * q_data->fmt->depth >> 3; | 722 | size = q_data->width * q_data->height * q_data->fmt->depth >> 3; |
725 | 723 | ||
726 | if (fmt) { | ||
727 | if (fmt->fmt.pix.sizeimage < size) | ||
728 | return -EINVAL; | ||
729 | size = fmt->fmt.pix.sizeimage; | ||
730 | } | ||
731 | |||
732 | while (size * count > MEM2MEM_VID_MEM_LIMIT) | 724 | while (size * count > MEM2MEM_VID_MEM_LIMIT) |
733 | (count)--; | 725 | (count)--; |
726 | *nbuffers = count; | ||
727 | |||
728 | if (*nplanes) | ||
729 | return sizes[0] < size ? -EINVAL : 0; | ||
734 | 730 | ||
735 | *nplanes = 1; | 731 | *nplanes = 1; |
736 | *nbuffers = count; | ||
737 | sizes[0] = size; | 732 | sizes[0] = size; |
738 | 733 | ||
739 | /* | 734 | /* |
diff --git a/drivers/media/platform/vivid/vivid-sdr-cap.c b/drivers/media/platform/vivid/vivid-sdr-cap.c index 082c401764ce..6eeeff9d1ae2 100644 --- a/drivers/media/platform/vivid/vivid-sdr-cap.c +++ b/drivers/media/platform/vivid/vivid-sdr-cap.c | |||
@@ -213,7 +213,7 @@ static int vivid_thread_sdr_cap(void *data) | |||
213 | return 0; | 213 | return 0; |
214 | } | 214 | } |
215 | 215 | ||
216 | static int sdr_cap_queue_setup(struct vb2_queue *vq, const void *parg, | 216 | static int sdr_cap_queue_setup(struct vb2_queue *vq, |
217 | unsigned *nbuffers, unsigned *nplanes, | 217 | unsigned *nbuffers, unsigned *nplanes, |
218 | unsigned sizes[], void *alloc_ctxs[]) | 218 | unsigned sizes[], void *alloc_ctxs[]) |
219 | { | 219 | { |
diff --git a/drivers/media/platform/vivid/vivid-vbi-cap.c b/drivers/media/platform/vivid/vivid-vbi-cap.c index e903d023e9df..d6d12e104aea 100644 --- a/drivers/media/platform/vivid/vivid-vbi-cap.c +++ b/drivers/media/platform/vivid/vivid-vbi-cap.c | |||
@@ -137,7 +137,7 @@ void vivid_sliced_vbi_cap_process(struct vivid_dev *dev, | |||
137 | buf->vb.timestamp.tv_sec += dev->time_wrap_offset; | 137 | buf->vb.timestamp.tv_sec += dev->time_wrap_offset; |
138 | } | 138 | } |
139 | 139 | ||
140 | static int vbi_cap_queue_setup(struct vb2_queue *vq, const void *parg, | 140 | static int vbi_cap_queue_setup(struct vb2_queue *vq, |
141 | unsigned *nbuffers, unsigned *nplanes, | 141 | unsigned *nbuffers, unsigned *nplanes, |
142 | unsigned sizes[], void *alloc_ctxs[]) | 142 | unsigned sizes[], void *alloc_ctxs[]) |
143 | { | 143 | { |
diff --git a/drivers/media/platform/vivid/vivid-vbi-out.c b/drivers/media/platform/vivid/vivid-vbi-out.c index 75c5709f938e..3c5a469e6f49 100644 --- a/drivers/media/platform/vivid/vivid-vbi-out.c +++ b/drivers/media/platform/vivid/vivid-vbi-out.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "vivid-vbi-out.h" | 27 | #include "vivid-vbi-out.h" |
28 | #include "vivid-vbi-cap.h" | 28 | #include "vivid-vbi-cap.h" |
29 | 29 | ||
30 | static int vbi_out_queue_setup(struct vb2_queue *vq, const void *parg, | 30 | static int vbi_out_queue_setup(struct vb2_queue *vq, |
31 | unsigned *nbuffers, unsigned *nplanes, | 31 | unsigned *nbuffers, unsigned *nplanes, |
32 | unsigned sizes[], void *alloc_ctxs[]) | 32 | unsigned sizes[], void *alloc_ctxs[]) |
33 | { | 33 | { |
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c index 9cc07c65a564..b84f081c1b92 100644 --- a/drivers/media/platform/vivid/vivid-vid-cap.c +++ b/drivers/media/platform/vivid/vivid-vid-cap.c | |||
@@ -95,11 +95,10 @@ static const struct v4l2_discrete_probe webcam_probe = { | |||
95 | VIVID_WEBCAM_SIZES | 95 | VIVID_WEBCAM_SIZES |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static int vid_cap_queue_setup(struct vb2_queue *vq, const void *parg, | 98 | static int vid_cap_queue_setup(struct vb2_queue *vq, |
99 | unsigned *nbuffers, unsigned *nplanes, | 99 | unsigned *nbuffers, unsigned *nplanes, |
100 | unsigned sizes[], void *alloc_ctxs[]) | 100 | unsigned sizes[], void *alloc_ctxs[]) |
101 | { | 101 | { |
102 | const struct v4l2_format *fmt = parg; | ||
103 | struct vivid_dev *dev = vb2_get_drv_priv(vq); | 102 | struct vivid_dev *dev = vb2_get_drv_priv(vq); |
104 | unsigned buffers = tpg_g_buffers(&dev->tpg); | 103 | unsigned buffers = tpg_g_buffers(&dev->tpg); |
105 | unsigned h = dev->fmt_cap_rect.height; | 104 | unsigned h = dev->fmt_cap_rect.height; |
@@ -122,27 +121,16 @@ static int vid_cap_queue_setup(struct vb2_queue *vq, const void *parg, | |||
122 | dev->queue_setup_error = false; | 121 | dev->queue_setup_error = false; |
123 | return -EINVAL; | 122 | return -EINVAL; |
124 | } | 123 | } |
125 | if (fmt) { | 124 | if (*nplanes) { |
126 | const struct v4l2_pix_format_mplane *mp; | ||
127 | struct v4l2_format mp_fmt; | ||
128 | const struct vivid_fmt *vfmt; | ||
129 | |||
130 | if (!V4L2_TYPE_IS_MULTIPLANAR(fmt->type)) { | ||
131 | fmt_sp2mp(fmt, &mp_fmt); | ||
132 | fmt = &mp_fmt; | ||
133 | } | ||
134 | mp = &fmt->fmt.pix_mp; | ||
135 | /* | 125 | /* |
136 | * Check if the number of planes in the specified format match | 126 | * Check if the number of requested planes match |
137 | * the number of buffers in the current format. You can't mix that. | 127 | * the number of buffers in the current format. You can't mix that. |
138 | */ | 128 | */ |
139 | if (mp->num_planes != buffers) | 129 | if (*nplanes != buffers) |
140 | return -EINVAL; | 130 | return -EINVAL; |
141 | vfmt = vivid_get_format(dev, mp->pixelformat); | ||
142 | for (p = 0; p < buffers; p++) { | 131 | for (p = 0; p < buffers; p++) { |
143 | sizes[p] = mp->plane_fmt[p].sizeimage; | ||
144 | if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h + | 132 | if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h + |
145 | vfmt->data_offset[p]) | 133 | dev->fmt_cap->data_offset[p]) |
146 | return -EINVAL; | 134 | return -EINVAL; |
147 | } | 135 | } |
148 | } else { | 136 | } else { |
diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c index 1f3b08166e74..64e4d66482c1 100644 --- a/drivers/media/platform/vivid/vivid-vid-out.c +++ b/drivers/media/platform/vivid/vivid-vid-out.c | |||
@@ -31,11 +31,10 @@ | |||
31 | #include "vivid-kthread-out.h" | 31 | #include "vivid-kthread-out.h" |
32 | #include "vivid-vid-out.h" | 32 | #include "vivid-vid-out.h" |
33 | 33 | ||
34 | static int vid_out_queue_setup(struct vb2_queue *vq, const void *parg, | 34 | static int vid_out_queue_setup(struct vb2_queue *vq, |
35 | unsigned *nbuffers, unsigned *nplanes, | 35 | unsigned *nbuffers, unsigned *nplanes, |
36 | unsigned sizes[], void *alloc_ctxs[]) | 36 | unsigned sizes[], void *alloc_ctxs[]) |
37 | { | 37 | { |
38 | const struct v4l2_format *fmt = parg; | ||
39 | struct vivid_dev *dev = vb2_get_drv_priv(vq); | 38 | struct vivid_dev *dev = vb2_get_drv_priv(vq); |
40 | const struct vivid_fmt *vfmt = dev->fmt_out; | 39 | const struct vivid_fmt *vfmt = dev->fmt_out; |
41 | unsigned planes = vfmt->buffers; | 40 | unsigned planes = vfmt->buffers; |
@@ -64,26 +63,16 @@ static int vid_out_queue_setup(struct vb2_queue *vq, const void *parg, | |||
64 | return -EINVAL; | 63 | return -EINVAL; |
65 | } | 64 | } |
66 | 65 | ||
67 | if (fmt) { | 66 | if (*nplanes) { |
68 | const struct v4l2_pix_format_mplane *mp; | ||
69 | struct v4l2_format mp_fmt; | ||
70 | |||
71 | if (!V4L2_TYPE_IS_MULTIPLANAR(fmt->type)) { | ||
72 | fmt_sp2mp(fmt, &mp_fmt); | ||
73 | fmt = &mp_fmt; | ||
74 | } | ||
75 | mp = &fmt->fmt.pix_mp; | ||
76 | /* | 67 | /* |
77 | * Check if the number of planes in the specified format match | 68 | * Check if the number of requested planes match |
78 | * the number of planes in the current format. You can't mix that. | 69 | * the number of planes in the current format. You can't mix that. |
79 | */ | 70 | */ |
80 | if (mp->num_planes != planes) | 71 | if (*nplanes != planes) |
81 | return -EINVAL; | 72 | return -EINVAL; |
82 | sizes[0] = mp->plane_fmt[0].sizeimage; | ||
83 | if (sizes[0] < size) | 73 | if (sizes[0] < size) |
84 | return -EINVAL; | 74 | return -EINVAL; |
85 | for (p = 1; p < planes; p++) { | 75 | for (p = 1; p < planes; p++) { |
86 | sizes[p] = mp->plane_fmt[p].sizeimage; | ||
87 | if (sizes[p] < dev->bytesperline_out[p] * h) | 76 | if (sizes[p] < dev->bytesperline_out[p] * h) |
88 | return -EINVAL; | 77 | return -EINVAL; |
89 | } | 78 | } |
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 5ce88e1f5d71..1eebf58bbecb 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c | |||
@@ -274,35 +274,6 @@ static int __vsp1_video_try_format(struct vsp1_video *video, | |||
274 | return 0; | 274 | return 0; |
275 | } | 275 | } |
276 | 276 | ||
277 | static bool | ||
278 | vsp1_video_format_adjust(struct vsp1_video *video, | ||
279 | const struct v4l2_pix_format_mplane *format, | ||
280 | struct v4l2_pix_format_mplane *adjust) | ||
281 | { | ||
282 | unsigned int i; | ||
283 | |||
284 | *adjust = *format; | ||
285 | __vsp1_video_try_format(video, adjust, NULL); | ||
286 | |||
287 | if (format->width != adjust->width || | ||
288 | format->height != adjust->height || | ||
289 | format->pixelformat != adjust->pixelformat || | ||
290 | format->num_planes != adjust->num_planes) | ||
291 | return false; | ||
292 | |||
293 | for (i = 0; i < format->num_planes; ++i) { | ||
294 | if (format->plane_fmt[i].bytesperline != | ||
295 | adjust->plane_fmt[i].bytesperline) | ||
296 | return false; | ||
297 | |||
298 | adjust->plane_fmt[i].sizeimage = | ||
299 | max(adjust->plane_fmt[i].sizeimage, | ||
300 | format->plane_fmt[i].sizeimage); | ||
301 | } | ||
302 | |||
303 | return true; | ||
304 | } | ||
305 | |||
306 | /* ----------------------------------------------------------------------------- | 277 | /* ----------------------------------------------------------------------------- |
307 | * Pipeline Management | 278 | * Pipeline Management |
308 | */ | 279 | */ |
@@ -787,26 +758,24 @@ void vsp1_pipelines_resume(struct vsp1_device *vsp1) | |||
787 | */ | 758 | */ |
788 | 759 | ||
789 | static int | 760 | static int |
790 | vsp1_video_queue_setup(struct vb2_queue *vq, const void *parg, | 761 | vsp1_video_queue_setup(struct vb2_queue *vq, |
791 | unsigned int *nbuffers, unsigned int *nplanes, | 762 | unsigned int *nbuffers, unsigned int *nplanes, |
792 | unsigned int sizes[], void *alloc_ctxs[]) | 763 | unsigned int sizes[], void *alloc_ctxs[]) |
793 | { | 764 | { |
794 | const struct v4l2_format *fmt = parg; | ||
795 | struct vsp1_video *video = vb2_get_drv_priv(vq); | 765 | struct vsp1_video *video = vb2_get_drv_priv(vq); |
796 | const struct v4l2_pix_format_mplane *format; | 766 | const struct v4l2_pix_format_mplane *format = &video->format; |
797 | struct v4l2_pix_format_mplane pix_mp; | ||
798 | unsigned int i; | 767 | unsigned int i; |
799 | 768 | ||
800 | if (fmt) { | 769 | if (*nplanes) { |
801 | /* Make sure the format is valid and adjust the sizeimage field | 770 | if (*nplanes != format->num_planes) |
802 | * if needed. | ||
803 | */ | ||
804 | if (!vsp1_video_format_adjust(video, &fmt->fmt.pix_mp, &pix_mp)) | ||
805 | return -EINVAL; | 771 | return -EINVAL; |
806 | 772 | ||
807 | format = &pix_mp; | 773 | for (i = 0; i < *nplanes; i++) { |
808 | } else { | 774 | if (sizes[i] < format->plane_fmt[i].sizeimage) |
809 | format = &video->format; | 775 | return -EINVAL; |
776 | alloc_ctxs[i] = video->alloc_ctx; | ||
777 | } | ||
778 | return 0; | ||
810 | } | 779 | } |
811 | 780 | ||
812 | *nplanes = format->num_planes; | 781 | *nplanes = format->num_planes; |
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index d11cc7072cd5..8532cab2ec77 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c | |||
@@ -309,21 +309,19 @@ static void xvip_dma_complete(void *param) | |||
309 | } | 309 | } |
310 | 310 | ||
311 | static int | 311 | static int |
312 | xvip_dma_queue_setup(struct vb2_queue *vq, const void *parg, | 312 | xvip_dma_queue_setup(struct vb2_queue *vq, |
313 | unsigned int *nbuffers, unsigned int *nplanes, | 313 | unsigned int *nbuffers, unsigned int *nplanes, |
314 | unsigned int sizes[], void *alloc_ctxs[]) | 314 | unsigned int sizes[], void *alloc_ctxs[]) |
315 | { | 315 | { |
316 | const struct v4l2_format *fmt = parg; | ||
317 | struct xvip_dma *dma = vb2_get_drv_priv(vq); | 316 | struct xvip_dma *dma = vb2_get_drv_priv(vq); |
318 | 317 | ||
318 | alloc_ctxs[0] = dma->alloc_ctx; | ||
319 | /* Make sure the image size is large enough. */ | 319 | /* Make sure the image size is large enough. */ |
320 | if (fmt && fmt->fmt.pix.sizeimage < dma->format.sizeimage) | 320 | if (*nplanes) |
321 | return -EINVAL; | 321 | return sizes[0] < dma->format.sizeimage ? -EINVAL : 0; |
322 | 322 | ||
323 | *nplanes = 1; | 323 | *nplanes = 1; |
324 | 324 | sizes[0] = dma->format.sizeimage; | |
325 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : dma->format.sizeimage; | ||
326 | alloc_ctxs[0] = dma->alloc_ctx; | ||
327 | 325 | ||
328 | return 0; | 326 | return 0; |
329 | } | 327 | } |
diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c index fcbb49757614..518d511e49ee 100644 --- a/drivers/media/usb/airspy/airspy.c +++ b/drivers/media/usb/airspy/airspy.c | |||
@@ -488,7 +488,7 @@ static void airspy_disconnect(struct usb_interface *intf) | |||
488 | 488 | ||
489 | /* Videobuf2 operations */ | 489 | /* Videobuf2 operations */ |
490 | static int airspy_queue_setup(struct vb2_queue *vq, | 490 | static int airspy_queue_setup(struct vb2_queue *vq, |
491 | const void *parg, unsigned int *nbuffers, | 491 | unsigned int *nbuffers, |
492 | unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) | 492 | unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) |
493 | { | 493 | { |
494 | struct airspy *s = vb2_get_drv_priv(vq); | 494 | struct airspy *s = vb2_get_drv_priv(vq); |
diff --git a/drivers/media/usb/au0828/au0828-vbi.c b/drivers/media/usb/au0828/au0828-vbi.c index 130c8b49bf7f..b4efc103ae57 100644 --- a/drivers/media/usb/au0828/au0828-vbi.c +++ b/drivers/media/usb/au0828/au0828-vbi.c | |||
@@ -30,23 +30,17 @@ | |||
30 | 30 | ||
31 | /* ------------------------------------------------------------------ */ | 31 | /* ------------------------------------------------------------------ */ |
32 | 32 | ||
33 | static int vbi_queue_setup(struct vb2_queue *vq, const void *parg, | 33 | static int vbi_queue_setup(struct vb2_queue *vq, |
34 | unsigned int *nbuffers, unsigned int *nplanes, | 34 | unsigned int *nbuffers, unsigned int *nplanes, |
35 | unsigned int sizes[], void *alloc_ctxs[]) | 35 | unsigned int sizes[], void *alloc_ctxs[]) |
36 | { | 36 | { |
37 | const struct v4l2_format *fmt = parg; | ||
38 | struct au0828_dev *dev = vb2_get_drv_priv(vq); | 37 | struct au0828_dev *dev = vb2_get_drv_priv(vq); |
39 | unsigned long img_size = dev->vbi_width * dev->vbi_height * 2; | 38 | unsigned long size = dev->vbi_width * dev->vbi_height * 2; |
40 | unsigned long size; | ||
41 | |||
42 | size = fmt ? (fmt->fmt.vbi.samples_per_line * | ||
43 | (fmt->fmt.vbi.count[0] + fmt->fmt.vbi.count[1])) : img_size; | ||
44 | if (size < img_size) | ||
45 | return -EINVAL; | ||
46 | 39 | ||
40 | if (*nplanes) | ||
41 | return sizes[0] < size ? -EINVAL : 0; | ||
47 | *nplanes = 1; | 42 | *nplanes = 1; |
48 | sizes[0] = size; | 43 | sizes[0] = size; |
49 | |||
50 | return 0; | 44 | return 0; |
51 | } | 45 | } |
52 | 46 | ||
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 45c622e234f7..427d58e6b85e 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c | |||
@@ -638,19 +638,15 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb) | |||
638 | return rc; | 638 | return rc; |
639 | } | 639 | } |
640 | 640 | ||
641 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 641 | static int queue_setup(struct vb2_queue *vq, |
642 | unsigned int *nbuffers, unsigned int *nplanes, | 642 | unsigned int *nbuffers, unsigned int *nplanes, |
643 | unsigned int sizes[], void *alloc_ctxs[]) | 643 | unsigned int sizes[], void *alloc_ctxs[]) |
644 | { | 644 | { |
645 | const struct v4l2_format *fmt = parg; | ||
646 | struct au0828_dev *dev = vb2_get_drv_priv(vq); | 645 | struct au0828_dev *dev = vb2_get_drv_priv(vq); |
647 | unsigned long img_size = dev->height * dev->bytesperline; | 646 | unsigned long size = dev->height * dev->bytesperline; |
648 | unsigned long size; | ||
649 | |||
650 | size = fmt ? fmt->fmt.pix.sizeimage : img_size; | ||
651 | if (size < img_size) | ||
652 | return -EINVAL; | ||
653 | 647 | ||
648 | if (*nplanes) | ||
649 | return sizes[0] < size ? -EINVAL : 0; | ||
654 | *nplanes = 1; | 650 | *nplanes = 1; |
655 | sizes[0] = size; | 651 | sizes[0] = size; |
656 | 652 | ||
diff --git a/drivers/media/usb/em28xx/em28xx-vbi.c b/drivers/media/usb/em28xx/em28xx-vbi.c index e23c285b3108..fe94c9225dd7 100644 --- a/drivers/media/usb/em28xx/em28xx-vbi.c +++ b/drivers/media/usb/em28xx/em28xx-vbi.c | |||
@@ -31,26 +31,22 @@ | |||
31 | 31 | ||
32 | /* ------------------------------------------------------------------ */ | 32 | /* ------------------------------------------------------------------ */ |
33 | 33 | ||
34 | static int vbi_queue_setup(struct vb2_queue *vq, const void *parg, | 34 | static int vbi_queue_setup(struct vb2_queue *vq, |
35 | unsigned int *nbuffers, unsigned int *nplanes, | 35 | unsigned int *nbuffers, unsigned int *nplanes, |
36 | unsigned int sizes[], void *alloc_ctxs[]) | 36 | unsigned int sizes[], void *alloc_ctxs[]) |
37 | { | 37 | { |
38 | const struct v4l2_format *fmt = parg; | ||
39 | struct em28xx *dev = vb2_get_drv_priv(vq); | 38 | struct em28xx *dev = vb2_get_drv_priv(vq); |
40 | struct em28xx_v4l2 *v4l2 = dev->v4l2; | 39 | struct em28xx_v4l2 *v4l2 = dev->v4l2; |
41 | unsigned long size; | 40 | unsigned long size = v4l2->vbi_width * v4l2->vbi_height * 2; |
42 | 41 | ||
43 | if (fmt) | ||
44 | size = fmt->fmt.pix.sizeimage; | ||
45 | else | ||
46 | size = v4l2->vbi_width * v4l2->vbi_height * 2; | ||
47 | |||
48 | if (0 == *nbuffers) | ||
49 | *nbuffers = 32; | ||
50 | if (*nbuffers < 2) | 42 | if (*nbuffers < 2) |
51 | *nbuffers = 2; | 43 | *nbuffers = 2; |
52 | if (*nbuffers > 32) | 44 | |
53 | *nbuffers = 32; | 45 | if (*nplanes) { |
46 | if (sizes[0] < size) | ||
47 | return -EINVAL; | ||
48 | size = sizes[0]; | ||
49 | } | ||
54 | 50 | ||
55 | *nplanes = 1; | 51 | *nplanes = 1; |
56 | sizes[0] = size; | 52 | sizes[0] = size; |
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index bba205246b22..235a03885198 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c | |||
@@ -871,30 +871,19 @@ static void res_free(struct em28xx *dev, enum v4l2_buf_type f_type) | |||
871 | Videobuf2 operations | 871 | Videobuf2 operations |
872 | ------------------------------------------------------------------*/ | 872 | ------------------------------------------------------------------*/ |
873 | 873 | ||
874 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 874 | static int queue_setup(struct vb2_queue *vq, |
875 | unsigned int *nbuffers, unsigned int *nplanes, | 875 | unsigned int *nbuffers, unsigned int *nplanes, |
876 | unsigned int sizes[], void *alloc_ctxs[]) | 876 | unsigned int sizes[], void *alloc_ctxs[]) |
877 | { | 877 | { |
878 | const struct v4l2_format *fmt = parg; | ||
879 | struct em28xx *dev = vb2_get_drv_priv(vq); | 878 | struct em28xx *dev = vb2_get_drv_priv(vq); |
880 | struct em28xx_v4l2 *v4l2 = dev->v4l2; | 879 | struct em28xx_v4l2 *v4l2 = dev->v4l2; |
881 | unsigned long size; | 880 | unsigned long size = |
882 | |||
883 | if (fmt) | ||
884 | size = fmt->fmt.pix.sizeimage; | ||
885 | else | ||
886 | size = | ||
887 | (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3; | 881 | (v4l2->width * v4l2->height * v4l2->format->depth + 7) >> 3; |
888 | 882 | ||
889 | if (size == 0) | 883 | if (*nplanes) |
890 | return -EINVAL; | 884 | return sizes[0] < size ? -EINVAL : 0; |
891 | |||
892 | if (0 == *nbuffers) | ||
893 | *nbuffers = 32; | ||
894 | |||
895 | *nplanes = 1; | 885 | *nplanes = 1; |
896 | sizes[0] = size; | 886 | sizes[0] = size; |
897 | |||
898 | return 0; | 887 | return 0; |
899 | } | 888 | } |
900 | 889 | ||
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c b/drivers/media/usb/go7007/go7007-v4l2.c index ae5038b8a1ef..358c1c186d03 100644 --- a/drivers/media/usb/go7007/go7007-v4l2.c +++ b/drivers/media/usb/go7007/go7007-v4l2.c | |||
@@ -369,7 +369,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
369 | } | 369 | } |
370 | 370 | ||
371 | static int go7007_queue_setup(struct vb2_queue *q, | 371 | static int go7007_queue_setup(struct vb2_queue *q, |
372 | const void *parg, | ||
373 | unsigned int *num_buffers, unsigned int *num_planes, | 372 | unsigned int *num_buffers, unsigned int *num_planes, |
374 | unsigned int sizes[], void *alloc_ctxs[]) | 373 | unsigned int sizes[], void *alloc_ctxs[]) |
375 | { | 374 | { |
diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c index e05bfec90f46..d0c416ddd5e7 100644 --- a/drivers/media/usb/hackrf/hackrf.c +++ b/drivers/media/usb/hackrf/hackrf.c | |||
@@ -750,7 +750,7 @@ static void hackrf_return_all_buffers(struct vb2_queue *vq, | |||
750 | } | 750 | } |
751 | 751 | ||
752 | static int hackrf_queue_setup(struct vb2_queue *vq, | 752 | static int hackrf_queue_setup(struct vb2_queue *vq, |
753 | const void *parg, unsigned int *nbuffers, | 753 | unsigned int *nbuffers, |
754 | unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) | 754 | unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) |
755 | { | 755 | { |
756 | struct hackrf_dev *dev = vb2_get_drv_priv(vq); | 756 | struct hackrf_dev *dev = vb2_get_drv_priv(vq); |
diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c index e06a21a4fbd9..c104315fdc17 100644 --- a/drivers/media/usb/msi2500/msi2500.c +++ b/drivers/media/usb/msi2500/msi2500.c | |||
@@ -616,7 +616,6 @@ static int msi2500_querycap(struct file *file, void *fh, | |||
616 | 616 | ||
617 | /* Videobuf2 operations */ | 617 | /* Videobuf2 operations */ |
618 | static int msi2500_queue_setup(struct vb2_queue *vq, | 618 | static int msi2500_queue_setup(struct vb2_queue *vq, |
619 | const void *parg, | ||
620 | unsigned int *nbuffers, | 619 | unsigned int *nbuffers, |
621 | unsigned int *nplanes, unsigned int sizes[], | 620 | unsigned int *nplanes, unsigned int sizes[], |
622 | void *alloc_ctxs[]) | 621 | void *alloc_ctxs[]) |
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c index b79c36fd8cd2..e90e4946afaf 100644 --- a/drivers/media/usb/pwc/pwc-if.c +++ b/drivers/media/usb/pwc/pwc-if.c | |||
@@ -571,7 +571,7 @@ static void pwc_video_release(struct v4l2_device *v) | |||
571 | /***************************************************************************/ | 571 | /***************************************************************************/ |
572 | /* Videobuf2 operations */ | 572 | /* Videobuf2 operations */ |
573 | 573 | ||
574 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 574 | static int queue_setup(struct vb2_queue *vq, |
575 | unsigned int *nbuffers, unsigned int *nplanes, | 575 | unsigned int *nbuffers, unsigned int *nplanes, |
576 | unsigned int sizes[], void *alloc_ctxs[]) | 576 | unsigned int sizes[], void *alloc_ctxs[]) |
577 | { | 577 | { |
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index e7acb12ad21d..82bdd42f76b5 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c | |||
@@ -660,7 +660,7 @@ static void s2255_fillbuff(struct s2255_vc *vc, | |||
660 | Videobuf operations | 660 | Videobuf operations |
661 | ------------------------------------------------------------------*/ | 661 | ------------------------------------------------------------------*/ |
662 | 662 | ||
663 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 663 | static int queue_setup(struct vb2_queue *vq, |
664 | unsigned int *nbuffers, unsigned int *nplanes, | 664 | unsigned int *nbuffers, unsigned int *nplanes, |
665 | unsigned int sizes[], void *alloc_ctxs[]) | 665 | unsigned int sizes[], void *alloc_ctxs[]) |
666 | { | 666 | { |
diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c index 9a69bb559602..77131fd614a5 100644 --- a/drivers/media/usb/stk1160/stk1160-v4l.c +++ b/drivers/media/usb/stk1160/stk1160-v4l.c | |||
@@ -664,7 +664,7 @@ static const struct v4l2_ioctl_ops stk1160_ioctl_ops = { | |||
664 | /* | 664 | /* |
665 | * Videobuf2 operations | 665 | * Videobuf2 operations |
666 | */ | 666 | */ |
667 | static int queue_setup(struct vb2_queue *vq, const void *parg, | 667 | static int queue_setup(struct vb2_queue *vq, |
668 | unsigned int *nbuffers, unsigned int *nplanes, | 668 | unsigned int *nbuffers, unsigned int *nplanes, |
669 | unsigned int sizes[], void *alloc_ctxs[]) | 669 | unsigned int sizes[], void *alloc_ctxs[]) |
670 | { | 670 | { |
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c index e645c9df2d94..05cbd2f4b445 100644 --- a/drivers/media/usb/usbtv/usbtv-video.c +++ b/drivers/media/usb/usbtv/usbtv-video.c | |||
@@ -599,19 +599,18 @@ static struct v4l2_file_operations usbtv_fops = { | |||
599 | }; | 599 | }; |
600 | 600 | ||
601 | static int usbtv_queue_setup(struct vb2_queue *vq, | 601 | static int usbtv_queue_setup(struct vb2_queue *vq, |
602 | const void *parg, unsigned int *nbuffers, | 602 | unsigned int *nbuffers, |
603 | unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) | 603 | unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) |
604 | { | 604 | { |
605 | const struct v4l2_format *fmt = parg; | ||
606 | struct usbtv *usbtv = vb2_get_drv_priv(vq); | 605 | struct usbtv *usbtv = vb2_get_drv_priv(vq); |
607 | unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32); | 606 | unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32); |
608 | 607 | ||
609 | if (vq->num_buffers + *nbuffers < 2) | 608 | if (vq->num_buffers + *nbuffers < 2) |
610 | *nbuffers = 2 - vq->num_buffers; | 609 | *nbuffers = 2 - vq->num_buffers; |
610 | if (*nplanes) | ||
611 | return sizes[0] < size ? -EINVAL : 0; | ||
611 | *nplanes = 1; | 612 | *nplanes = 1; |
612 | if (fmt && fmt->fmt.pix.sizeimage < size) | 613 | sizes[0] = size; |
613 | return -EINVAL; | ||
614 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size; | ||
615 | 614 | ||
616 | return 0; | 615 | return 0; |
617 | } | 616 | } |
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index cfb868a48b5f..54394722756f 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c | |||
@@ -69,23 +69,19 @@ static void uvc_queue_return_buffers(struct uvc_video_queue *queue, | |||
69 | * videobuf2 queue operations | 69 | * videobuf2 queue operations |
70 | */ | 70 | */ |
71 | 71 | ||
72 | static int uvc_queue_setup(struct vb2_queue *vq, const void *parg, | 72 | static int uvc_queue_setup(struct vb2_queue *vq, |
73 | unsigned int *nbuffers, unsigned int *nplanes, | 73 | unsigned int *nbuffers, unsigned int *nplanes, |
74 | unsigned int sizes[], void *alloc_ctxs[]) | 74 | unsigned int sizes[], void *alloc_ctxs[]) |
75 | { | 75 | { |
76 | const struct v4l2_format *fmt = parg; | ||
77 | struct uvc_video_queue *queue = vb2_get_drv_priv(vq); | 76 | struct uvc_video_queue *queue = vb2_get_drv_priv(vq); |
78 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); | 77 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); |
78 | unsigned size = stream->ctrl.dwMaxVideoFrameSize; | ||
79 | 79 | ||
80 | /* Make sure the image size is large enough. */ | 80 | /* Make sure the image size is large enough. */ |
81 | if (fmt && fmt->fmt.pix.sizeimage < stream->ctrl.dwMaxVideoFrameSize) | 81 | if (*nplanes) |
82 | return -EINVAL; | 82 | return sizes[0] < size ? -EINVAL : 0; |
83 | |||
84 | *nplanes = 1; | 83 | *nplanes = 1; |
85 | 84 | sizes[0] = size; | |
86 | sizes[0] = fmt ? fmt->fmt.pix.sizeimage | ||
87 | : stream->ctrl.dwMaxVideoFrameSize; | ||
88 | |||
89 | return 0; | 85 | return 0; |
90 | } | 86 | } |
91 | 87 | ||
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 33bdd81065e8..ebce7c793f28 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -621,7 +621,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, | |||
621 | * Ask the driver how many buffers and planes per buffer it requires. | 621 | * Ask the driver how many buffers and planes per buffer it requires. |
622 | * Driver also sets the size and allocator context for each plane. | 622 | * Driver also sets the size and allocator context for each plane. |
623 | */ | 623 | */ |
624 | ret = call_qop(q, queue_setup, q, NULL, &num_buffers, &num_planes, | 624 | ret = call_qop(q, queue_setup, q, &num_buffers, &num_planes, |
625 | q->plane_sizes, q->alloc_ctx); | 625 | q->plane_sizes, q->alloc_ctx); |
626 | if (ret) | 626 | if (ret) |
627 | return ret; | 627 | return ret; |
@@ -646,8 +646,15 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, | |||
646 | */ | 646 | */ |
647 | if (!ret && allocated_buffers < num_buffers) { | 647 | if (!ret && allocated_buffers < num_buffers) { |
648 | num_buffers = allocated_buffers; | 648 | num_buffers = allocated_buffers; |
649 | /* | ||
650 | * num_planes is set by the previous queue_setup(), but since it | ||
651 | * signals to queue_setup() whether it is called from create_bufs() | ||
652 | * vs reqbufs() we zero it here to signal that queue_setup() is | ||
653 | * called for the reqbufs() case. | ||
654 | */ | ||
655 | num_planes = 0; | ||
649 | 656 | ||
650 | ret = call_qop(q, queue_setup, q, NULL, &num_buffers, | 657 | ret = call_qop(q, queue_setup, q, &num_buffers, |
651 | &num_planes, q->plane_sizes, q->alloc_ctx); | 658 | &num_planes, q->plane_sizes, q->alloc_ctx); |
652 | 659 | ||
653 | if (!ret && allocated_buffers < num_buffers) | 660 | if (!ret && allocated_buffers < num_buffers) |
@@ -701,7 +708,8 @@ EXPORT_SYMBOL_GPL(vb2_core_reqbufs); | |||
701 | * from vidioc_create_bufs handler in driver. | 708 | * from vidioc_create_bufs handler in driver. |
702 | */ | 709 | */ |
703 | int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, | 710 | int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, |
704 | unsigned int *count, const void *parg) | 711 | unsigned int *count, unsigned requested_planes, |
712 | const unsigned requested_sizes[]) | ||
705 | { | 713 | { |
706 | unsigned int num_planes = 0, num_buffers, allocated_buffers; | 714 | unsigned int num_planes = 0, num_buffers, allocated_buffers; |
707 | int ret; | 715 | int ret; |
@@ -720,11 +728,16 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, | |||
720 | 728 | ||
721 | num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers); | 729 | num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers); |
722 | 730 | ||
731 | if (requested_planes && requested_sizes) { | ||
732 | num_planes = requested_planes; | ||
733 | memcpy(q->plane_sizes, requested_sizes, sizeof(q->plane_sizes)); | ||
734 | } | ||
735 | |||
723 | /* | 736 | /* |
724 | * Ask the driver, whether the requested number of buffers, planes per | 737 | * Ask the driver, whether the requested number of buffers, planes per |
725 | * buffer and their sizes are acceptable | 738 | * buffer and their sizes are acceptable |
726 | */ | 739 | */ |
727 | ret = call_qop(q, queue_setup, q, parg, &num_buffers, | 740 | ret = call_qop(q, queue_setup, q, &num_buffers, |
728 | &num_planes, q->plane_sizes, q->alloc_ctx); | 741 | &num_planes, q->plane_sizes, q->alloc_ctx); |
729 | if (ret) | 742 | if (ret) |
730 | return ret; | 743 | return ret; |
@@ -747,7 +760,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, | |||
747 | * q->num_buffers contains the total number of buffers, that the | 760 | * q->num_buffers contains the total number of buffers, that the |
748 | * queue driver has set up | 761 | * queue driver has set up |
749 | */ | 762 | */ |
750 | ret = call_qop(q, queue_setup, q, parg, &num_buffers, | 763 | ret = call_qop(q, queue_setup, q, &num_buffers, |
751 | &num_planes, q->plane_sizes, q->alloc_ctx); | 764 | &num_planes, q->plane_sizes, q->alloc_ctx); |
752 | 765 | ||
753 | if (!ret && allocated_buffers < num_buffers) | 766 | if (!ret && allocated_buffers < num_buffers) |
diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c index 2d1e5b7d85a2..1b5c695f6c59 100644 --- a/drivers/media/v4l2-core/videobuf2-v4l2.c +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c | |||
@@ -525,14 +525,52 @@ EXPORT_SYMBOL_GPL(vb2_prepare_buf); | |||
525 | */ | 525 | */ |
526 | int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) | 526 | int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) |
527 | { | 527 | { |
528 | int ret = vb2_verify_memory_type(q, create->memory, | 528 | unsigned requested_planes = 1; |
529 | create->format.type); | 529 | unsigned requested_sizes[VIDEO_MAX_PLANES]; |
530 | struct v4l2_format *f = &create->format; | ||
531 | int ret = vb2_verify_memory_type(q, create->memory, f->type); | ||
532 | unsigned i; | ||
530 | 533 | ||
531 | create->index = q->num_buffers; | 534 | create->index = q->num_buffers; |
532 | if (create->count == 0) | 535 | if (create->count == 0) |
533 | return ret != -EBUSY ? ret : 0; | 536 | return ret != -EBUSY ? ret : 0; |
537 | |||
538 | switch (f->type) { | ||
539 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | ||
540 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | ||
541 | requested_planes = f->fmt.pix_mp.num_planes; | ||
542 | if (requested_planes == 0 || | ||
543 | requested_planes > VIDEO_MAX_PLANES) | ||
544 | return -EINVAL; | ||
545 | for (i = 0; i < requested_planes; i++) | ||
546 | requested_sizes[i] = | ||
547 | f->fmt.pix_mp.plane_fmt[i].sizeimage; | ||
548 | break; | ||
549 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
550 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | ||
551 | requested_sizes[0] = f->fmt.pix.sizeimage; | ||
552 | break; | ||
553 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
554 | case V4L2_BUF_TYPE_VBI_OUTPUT: | ||
555 | requested_sizes[0] = f->fmt.vbi.samples_per_line * | ||
556 | (f->fmt.vbi.count[0] + f->fmt.vbi.count[1]); | ||
557 | break; | ||
558 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | ||
559 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | ||
560 | requested_sizes[0] = f->fmt.sliced.io_size; | ||
561 | break; | ||
562 | case V4L2_BUF_TYPE_SDR_CAPTURE: | ||
563 | case V4L2_BUF_TYPE_SDR_OUTPUT: | ||
564 | requested_sizes[0] = f->fmt.sdr.buffersize; | ||
565 | break; | ||
566 | default: | ||
567 | return -EINVAL; | ||
568 | } | ||
569 | for (i = 0; i < requested_planes; i++) | ||
570 | if (requested_sizes[i] == 0) | ||
571 | return -EINVAL; | ||
534 | return ret ? ret : vb2_core_create_bufs(q, create->memory, | 572 | return ret ? ret : vb2_core_create_bufs(q, create->memory, |
535 | &create->count, &create->format); | 573 | &create->count, requested_planes, requested_sizes); |
536 | } | 574 | } |
537 | EXPORT_SYMBOL_GPL(vb2_create_bufs); | 575 | EXPORT_SYMBOL_GPL(vb2_create_bufs); |
538 | 576 | ||
@@ -1440,8 +1478,8 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv, | |||
1440 | return res; | 1478 | return res; |
1441 | if (vb2_queue_is_busy(vdev, file)) | 1479 | if (vb2_queue_is_busy(vdev, file)) |
1442 | return -EBUSY; | 1480 | return -EBUSY; |
1443 | res = vb2_core_create_bufs(vdev->queue, p->memory, &p->count, | 1481 | |
1444 | &p->format); | 1482 | res = vb2_create_bufs(vdev->queue, p); |
1445 | if (res == 0) | 1483 | if (res == 0) |
1446 | vdev->queue->owner = file->private_data; | 1484 | vdev->queue->owner = file->private_data; |
1447 | return res; | 1485 | return res; |
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 0fdff91624fd..77b4fc6fd2ee 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c | |||
@@ -1078,7 +1078,7 @@ vpfe_g_dv_timings(struct file *file, void *fh, | |||
1078 | * the buffer nbuffers and buffer size | 1078 | * the buffer nbuffers and buffer size |
1079 | */ | 1079 | */ |
1080 | static int | 1080 | static int |
1081 | vpfe_buffer_queue_setup(struct vb2_queue *vq, const void *parg, | 1081 | vpfe_buffer_queue_setup(struct vb2_queue *vq, |
1082 | unsigned int *nbuffers, unsigned int *nplanes, | 1082 | unsigned int *nbuffers, unsigned int *nplanes, |
1083 | unsigned int sizes[], void *alloc_ctxs[]) | 1083 | unsigned int sizes[], void *alloc_ctxs[]) |
1084 | { | 1084 | { |
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index 2a0158bb4974..17741e37a73c 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c | |||
@@ -287,7 +287,6 @@ iss_video_check_format(struct iss_video *video, struct iss_video_fh *vfh) | |||
287 | */ | 287 | */ |
288 | 288 | ||
289 | static int iss_video_queue_setup(struct vb2_queue *vq, | 289 | static int iss_video_queue_setup(struct vb2_queue *vq, |
290 | const void *parg, | ||
291 | unsigned int *count, unsigned int *num_planes, | 290 | unsigned int *count, unsigned int *num_planes, |
292 | unsigned int sizes[], void *alloc_ctxs[]) | 291 | unsigned int sizes[], void *alloc_ctxs[]) |
293 | { | 292 | { |
diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c index 51d4a1703af2..f5921989873d 100644 --- a/drivers/usb/gadget/function/uvc_queue.c +++ b/drivers/usb/gadget/function/uvc_queue.c | |||
@@ -41,7 +41,7 @@ | |||
41 | * videobuf2 queue operations | 41 | * videobuf2 queue operations |
42 | */ | 42 | */ |
43 | 43 | ||
44 | static int uvc_queue_setup(struct vb2_queue *vq, const void *parg, | 44 | static int uvc_queue_setup(struct vb2_queue *vq, |
45 | unsigned int *nbuffers, unsigned int *nplanes, | 45 | unsigned int *nbuffers, unsigned int *nplanes, |
46 | unsigned int sizes[], void *alloc_ctxs[]) | 46 | unsigned int sizes[], void *alloc_ctxs[]) |
47 | { | 47 | { |
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 647ebfe5174f..b47d1e2f4364 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h | |||
@@ -268,21 +268,26 @@ struct vb2_buffer { | |||
268 | * struct vb2_ops - driver-specific callbacks | 268 | * struct vb2_ops - driver-specific callbacks |
269 | * | 269 | * |
270 | * @queue_setup: called from VIDIOC_REQBUFS and VIDIOC_CREATE_BUFS | 270 | * @queue_setup: called from VIDIOC_REQBUFS and VIDIOC_CREATE_BUFS |
271 | * handlers before memory allocation, or, if | 271 | * handlers before memory allocation. It can be called |
272 | * *num_planes != 0, after the allocation to verify a | 272 | * twice: if the original number of requested buffers |
273 | * smaller number of buffers. Driver should return | 273 | * could not be allocated, then it will be called a |
274 | * the required number of buffers in *num_buffers, the | 274 | * second time with the actually allocated number of |
275 | * required number of planes per buffer in *num_planes; the | 275 | * buffers to verify if that is OK. |
276 | * size of each plane should be set in the sizes[] array | 276 | * The driver should return the required number of buffers |
277 | * and optional per-plane allocator specific context in the | 277 | * in *num_buffers, the required number of planes per |
278 | * alloc_ctxs[] array. When called from VIDIOC_REQBUFS, | 278 | * buffer in *num_planes, the size of each plane should be |
279 | * fmt == NULL, the driver has to use the currently | 279 | * set in the sizes[] array and optional per-plane |
280 | * configured format and *num_buffers is the total number | 280 | * allocator specific context in the alloc_ctxs[] array. |
281 | * of buffers, that are being allocated. When called from | 281 | * When called from VIDIOC_REQBUFS, *num_planes == 0, the |
282 | * VIDIOC_CREATE_BUFS, fmt != NULL and it describes the | 282 | * driver has to use the currently configured format to |
283 | * target frame format (if the format isn't valid the | 283 | * determine the plane sizes and *num_buffers is the total |
284 | * callback must return -EINVAL). In this case *num_buffers | 284 | * number of buffers that are being allocated. When called |
285 | * are being allocated additionally to q->num_buffers. | 285 | * from VIDIOC_CREATE_BUFS, *num_planes != 0 and it |
286 | * describes the requested number of planes and sizes[] | ||
287 | * contains the requested plane sizes. If either | ||
288 | * *num_planes or the requested sizes are invalid callback | ||
289 | * must return -EINVAL. In this case *num_buffers are | ||
290 | * being allocated additionally to q->num_buffers. | ||
286 | * @wait_prepare: release any locks taken while calling vb2 functions; | 291 | * @wait_prepare: release any locks taken while calling vb2 functions; |
287 | * it is called before an ioctl needs to wait for a new | 292 | * it is called before an ioctl needs to wait for a new |
288 | * buffer to arrive; required to avoid a deadlock in | 293 | * buffer to arrive; required to avoid a deadlock in |
@@ -344,7 +349,7 @@ struct vb2_buffer { | |||
344 | * pre-queued buffers before calling STREAMON. | 349 | * pre-queued buffers before calling STREAMON. |
345 | */ | 350 | */ |
346 | struct vb2_ops { | 351 | struct vb2_ops { |
347 | int (*queue_setup)(struct vb2_queue *q, const void *parg, | 352 | int (*queue_setup)(struct vb2_queue *q, |
348 | unsigned int *num_buffers, unsigned int *num_planes, | 353 | unsigned int *num_buffers, unsigned int *num_planes, |
349 | unsigned int sizes[], void *alloc_ctxs[]); | 354 | unsigned int sizes[], void *alloc_ctxs[]); |
350 | 355 | ||
@@ -507,7 +512,8 @@ int vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); | |||
507 | int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, | 512 | int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, |
508 | unsigned int *count); | 513 | unsigned int *count); |
509 | int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, | 514 | int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, |
510 | unsigned int *count, const void *parg); | 515 | unsigned int *count, unsigned requested_planes, |
516 | const unsigned int requested_sizes[]); | ||
511 | int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); | 517 | int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); |
512 | int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); | 518 | int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); |
513 | int vb2_core_dqbuf(struct vb2_queue *q, void *pb, bool nonblocking); | 519 | int vb2_core_dqbuf(struct vb2_queue *q, void *pb, bool nonblocking); |