Commit df9ecb0c authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent ecc2fe20
...@@ -163,11 +163,10 @@ static irqreturn_t skeleton_irq(int irq, void *dev_id) ...@@ -163,11 +163,10 @@ static irqreturn_t skeleton_irq(int irq, void *dev_id)
* minimum number: many DMA engines need a minimum of 2 buffers in the * minimum number: many DMA engines need a minimum of 2 buffers in the
* queue and you need to have another available for userspace processing. * queue and you need to have another available for userspace processing.
*/ */
static int queue_setup(struct vb2_queue *vq, const void *parg, static int queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
const struct v4l2_format *fmt = parg;
struct skeleton *skel = vb2_get_drv_priv(vq); struct skeleton *skel = vb2_get_drv_priv(vq);
skel->field = skel->format.field; skel->field = skel->format.field;
...@@ -183,12 +182,12 @@ static int queue_setup(struct vb2_queue *vq, const void *parg, ...@@ -183,12 +182,12 @@ static int queue_setup(struct vb2_queue *vq, const void *parg,
if (vq->num_buffers + *nbuffers < 3) if (vq->num_buffers + *nbuffers < 3)
*nbuffers = 3 - vq->num_buffers; *nbuffers = 3 - vq->num_buffers;
alloc_ctxs[0] = skel->alloc_ctx;
if (fmt && fmt->fmt.pix.sizeimage < skel->format.sizeimage) if (*nplanes)
return -EINVAL; return sizes[0] < skel->format.sizeimage ? -EINVAL : 0;
*nplanes = 1; *nplanes = 1;
sizes[0] = fmt ? fmt->fmt.pix.sizeimage : skel->format.sizeimage; sizes[0] = skel->format.sizeimage;
alloc_ctxs[0] = skel->alloc_ctx;
return 0; return 0;
} }
......
...@@ -644,22 +644,21 @@ static void sur40_disconnect(struct usb_interface *interface) ...@@ -644,22 +644,21 @@ static void sur40_disconnect(struct usb_interface *interface)
* minimum number: many DMA engines need a minimum of 2 buffers in the * minimum number: many DMA engines need a minimum of 2 buffers in the
* queue and you need to have another available for userspace processing. * queue and you need to have another available for userspace processing.
*/ */
static int sur40_queue_setup(struct vb2_queue *q, const void *parg, static int sur40_queue_setup(struct vb2_queue *q,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
const struct v4l2_format *fmt = parg;
struct sur40_state *sur40 = vb2_get_drv_priv(q); struct sur40_state *sur40 = vb2_get_drv_priv(q);
if (q->num_buffers + *nbuffers < 3) if (q->num_buffers + *nbuffers < 3)
*nbuffers = 3 - q->num_buffers; *nbuffers = 3 - q->num_buffers;
alloc_ctxs[0] = sur40->alloc_ctx;
if (fmt && fmt->fmt.pix.sizeimage < sur40_video_format.sizeimage) if (*nplanes)
return -EINVAL; return sizes[0] < sur40_video_format.sizeimage ? -EINVAL : 0;
*nplanes = 1; *nplanes = 1;
sizes[0] = fmt ? fmt->fmt.pix.sizeimage : sur40_video_format.sizeimage; sizes[0] = sur40_video_format.sizeimage;
alloc_ctxs[0] = sur40->alloc_ctx;
return 0; return 0;
} }
......
...@@ -490,7 +490,7 @@ static int rtl2832_sdr_querycap(struct file *file, void *fh, ...@@ -490,7 +490,7 @@ static int rtl2832_sdr_querycap(struct file *file, void *fh,
/* Videobuf2 operations */ /* Videobuf2 operations */
static int rtl2832_sdr_queue_setup(struct vb2_queue *vq, static int rtl2832_sdr_queue_setup(struct vb2_queue *vq,
const void *parg, unsigned int *nbuffers, unsigned int *nbuffers,
unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
{ {
struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq); struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq);
......
...@@ -43,11 +43,10 @@ static const struct v4l2_dv_timings cea1080p60 = V4L2_DV_BT_CEA_1920X1080P60; ...@@ -43,11 +43,10 @@ static const struct v4l2_dv_timings cea1080p60 = V4L2_DV_BT_CEA_1920X1080P60;
/* vb2 DMA streaming ops */ /* vb2 DMA streaming ops */
static int cobalt_queue_setup(struct vb2_queue *q, const void *parg, static int cobalt_queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
const struct v4l2_format *fmt = parg;
struct cobalt_stream *s = q->drv_priv; struct cobalt_stream *s = q->drv_priv;
unsigned size = s->stride * s->height; unsigned size = s->stride * s->height;
...@@ -55,14 +54,11 @@ static int cobalt_queue_setup(struct vb2_queue *q, const void *parg, ...@@ -55,14 +54,11 @@ static int cobalt_queue_setup(struct vb2_queue *q, const void *parg,
*num_buffers = 3; *num_buffers = 3;
if (*num_buffers > NR_BUFS) if (*num_buffers > NR_BUFS)
*num_buffers = NR_BUFS; *num_buffers = NR_BUFS;
alloc_ctxs[0] = s->cobalt->alloc_ctx;
if (*num_planes)
return sizes[0] < size ? -EINVAL : 0;
*num_planes = 1; *num_planes = 1;
if (fmt) {
if (fmt->fmt.pix.sizeimage < size)
return -EINVAL;
size = fmt->fmt.pix.sizeimage;
}
sizes[0] = size; sizes[0] = size;
alloc_ctxs[0] = s->cobalt->alloc_ctx;
return 0; return 0;
} }
......
...@@ -1138,7 +1138,7 @@ static int cx23885_initialize_codec(struct cx23885_dev *dev, int startencoder) ...@@ -1138,7 +1138,7 @@ static int cx23885_initialize_codec(struct cx23885_dev *dev, int startencoder)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -92,7 +92,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); ...@@ -92,7 +92,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -120,7 +120,7 @@ static int cx23885_start_vbi_dma(struct cx23885_dev *dev, ...@@ -120,7 +120,7 @@ static int cx23885_start_vbi_dma(struct cx23885_dev *dev,
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -333,7 +333,7 @@ static int cx23885_start_video_dma(struct cx23885_dev *dev, ...@@ -333,7 +333,7 @@ static int cx23885_start_video_dma(struct cx23885_dev *dev,
return 0; return 0;
} }
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -141,20 +141,20 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status) ...@@ -141,20 +141,20 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status)
return handled; return handled;
} }
static int cx25821_queue_setup(struct vb2_queue *q, const void *parg, static int cx25821_queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
const struct v4l2_format *fmt = parg;
struct cx25821_channel *chan = q->drv_priv; struct cx25821_channel *chan = q->drv_priv;
unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3; unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3;
if (fmt && fmt->fmt.pix.sizeimage < size) alloc_ctxs[0] = chan->dev->alloc_ctx;
return -EINVAL;
if (*num_planes)
return sizes[0] < size ? -EINVAL : 0;
*num_planes = 1; *num_planes = 1;
sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size; sizes[0] = size;
alloc_ctxs[0] = chan->dev->alloc_ctx;
return 0; return 0;
} }
......
...@@ -637,7 +637,7 @@ static int blackbird_stop_codec(struct cx8802_dev *dev) ...@@ -637,7 +637,7 @@ static int blackbird_stop_codec(struct cx8802_dev *dev)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -82,7 +82,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); ...@@ -82,7 +82,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -107,7 +107,7 @@ int cx8800_restart_vbi_queue(struct cx8800_dev *dev, ...@@ -107,7 +107,7 @@ int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -429,7 +429,7 @@ static int restart_video_queue(struct cx8800_dev *dev, ...@@ -429,7 +429,7 @@ static int restart_video_queue(struct cx8800_dev *dev,
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -131,22 +131,21 @@ static int wait_i2c_reg(void __iomem *addr) ...@@ -131,22 +131,21 @@ static int wait_i2c_reg(void __iomem *addr)
} }
static int static int
dt3155_queue_setup(struct vb2_queue *vq, const void *parg, dt3155_queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers, unsigned int *num_planes, unsigned int *nbuffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
const struct v4l2_format *fmt = parg;
struct dt3155_priv *pd = vb2_get_drv_priv(vq); struct dt3155_priv *pd = vb2_get_drv_priv(vq);
unsigned size = pd->width * pd->height; unsigned size = pd->width * pd->height;
if (vq->num_buffers + *nbuffers < 2) if (vq->num_buffers + *nbuffers < 2)
*nbuffers = 2 - vq->num_buffers; *nbuffers = 2 - vq->num_buffers;
if (fmt && fmt->fmt.pix.sizeimage < size)
return -EINVAL;
*num_planes = 1;
sizes[0] = fmt ? fmt->fmt.pix.sizeimage : size;
alloc_ctxs[0] = pd->alloc_ctx; alloc_ctxs[0] = pd->alloc_ctx;
if (*num_planes)
return sizes[0] < size ? -EINVAL : 0;
*num_planes = 1;
sizes[0] = size;
return 0; return 0;
} }
......
...@@ -277,7 +277,6 @@ static irqreturn_t netup_unidvb_isr(int irq, void *dev_id) ...@@ -277,7 +277,6 @@ static irqreturn_t netup_unidvb_isr(int irq, void *dev_id)
} }
static int netup_unidvb_queue_setup(struct vb2_queue *vq, static int netup_unidvb_queue_setup(struct vb2_queue *vq,
const void *parg,
unsigned int *nbuffers, unsigned int *nbuffers,
unsigned int *nplanes, unsigned int *nplanes,
unsigned int sizes[], unsigned int sizes[],
......
...@@ -116,7 +116,7 @@ int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2) ...@@ -116,7 +116,7 @@ int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2)
} }
EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare); EXPORT_SYMBOL_GPL(saa7134_ts_buffer_prepare);
int saa7134_ts_queue_setup(struct vb2_queue *q, const void *parg, int saa7134_ts_queue_setup(struct vb2_queue *q,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -138,7 +138,7 @@ static int buffer_prepare(struct vb2_buffer *vb2) ...@@ -138,7 +138,7 @@ static int buffer_prepare(struct vb2_buffer *vb2)
saa7134_buffer_startpage(buf)); saa7134_buffer_startpage(buf));
} }
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -904,7 +904,7 @@ static int buffer_prepare(struct vb2_buffer *vb2) ...@@ -904,7 +904,7 @@ static int buffer_prepare(struct vb2_buffer *vb2)
saa7134_buffer_startpage(buf)); saa7134_buffer_startpage(buf));
} }
static int queue_setup(struct vb2_queue *q, const void *parg, static int queue_setup(struct vb2_queue *q,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -820,7 +820,7 @@ void saa7134_video_fini(struct saa7134_dev *dev); ...@@ -820,7 +820,7 @@ void saa7134_video_fini(struct saa7134_dev *dev);
int saa7134_ts_buffer_init(struct vb2_buffer *vb2); int saa7134_ts_buffer_init(struct vb2_buffer *vb2);
int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2); int saa7134_ts_buffer_prepare(struct vb2_buffer *vb2);
int saa7134_ts_queue_setup(struct vb2_queue *q, const void *parg, int saa7134_ts_queue_setup(struct vb2_queue *q,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]); unsigned int sizes[], void *alloc_ctxs[]);
int saa7134_ts_start_streaming(struct vb2_queue *vq, unsigned int count); int saa7134_ts_start_streaming(struct vb2_queue *vq, unsigned int count);
......
...@@ -663,7 +663,6 @@ static int solo_ring_thread(void *data) ...@@ -663,7 +663,6 @@ static int solo_ring_thread(void *data)
} }
static int solo_enc_queue_setup(struct vb2_queue *q, static int solo_enc_queue_setup(struct vb2_queue *q,
const void *parg,
unsigned int *num_buffers, unsigned int *num_buffers,
unsigned int *num_planes, unsigned int sizes[], unsigned int *num_planes, unsigned int sizes[],
void *alloc_ctxs[]) void *alloc_ctxs[])
......
...@@ -313,7 +313,7 @@ static void solo_stop_thread(struct solo_dev *solo_dev) ...@@ -313,7 +313,7 @@ static void solo_stop_thread(struct solo_dev *solo_dev)
solo_dev->kthread = NULL; solo_dev->kthread = NULL;
} }
static int solo_queue_setup(struct vb2_queue *q, const void *parg, static int solo_queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -265,7 +265,7 @@ static void vip_active_buf_next(struct sta2x11_vip *vip) ...@@ -265,7 +265,7 @@ static void vip_active_buf_next(struct sta2x11_vip *vip)
/* Videobuf2 Operations */ /* Videobuf2 Operations */
static int queue_setup(struct vb2_queue *vq, const void *parg, static int queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -376,28 +376,28 @@ static int tw68_buffer_count(unsigned int size, unsigned int count) ...@@ -376,28 +376,28 @@ static int tw68_buffer_count(unsigned int size, unsigned int count)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* vb2 queue operations */ /* vb2 queue operations */
static int tw68_queue_setup(struct vb2_queue *q, const void *parg, static int tw68_queue_setup(struct vb2_queue *q,
unsigned int *num_buffers, unsigned int *num_planes, unsigned int *num_buffers, unsigned int *num_planes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
const struct v4l2_format *fmt = parg;
struct tw68_dev *dev = vb2_get_drv_priv(q); struct tw68_dev *dev = vb2_get_drv_priv(q);
unsigned tot_bufs = q->num_buffers + *num_buffers; unsigned tot_bufs = q->num_buffers + *num_buffers;
unsigned size = (dev->fmt->depth * dev->width * dev->height) >> 3;
sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; if (tot_bufs < 2)
tot_bufs = 2;
tot_bufs = tw68_buffer_count(size, tot_bufs);
*num_buffers = tot_bufs - q->num_buffers;
alloc_ctxs[0] = dev->alloc_ctx; alloc_ctxs[0] = dev->alloc_ctx;
/* /*
* We allow create_bufs, but only if the sizeimage is the same as the * We allow create_bufs, but only if the sizeimage is >= as the
* current sizeimage. The tw68_buffer_count calculation becomes quite * current sizeimage. The tw68_buffer_count calculation becomes quite
* difficult otherwise. * difficult otherwise.
*/ */
if (fmt && fmt->fmt.pix.sizeimage < sizes[0]) if (*num_planes)
return -EINVAL; return sizes[0] < size ? -EINVAL : 0;
*num_planes = 1; *num_planes = 1;
if (tot_bufs < 2) sizes[0] = size;
tot_bufs = 2;
tot_bufs = tw68_buffer_count(sizes[0], tot_bufs);
*num_buffers = tot_bufs - q->num_buffers;
return 0; return 0;
} }
......
...@@ -1898,7 +1898,6 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe) ...@@ -1898,7 +1898,6 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe)
/* /*
* vpfe_queue_setup - Callback function for buffer setup. * vpfe_queue_setup - Callback function for buffer setup.
* @vq: vb2_queue ptr * @vq: vb2_queue ptr
* @fmt: v4l2 format
* @nbuffers: ptr to number of buffers requested by application * @nbuffers: ptr to number of buffers requested by application
* @nplanes:: contains number of distinct video planes needed to hold a frame * @nplanes:: contains number of distinct video planes needed to hold a frame
* @sizes[]: contains the size (in bytes) of each plane. * @sizes[]: contains the size (in bytes) of each plane.
...@@ -1908,22 +1907,24 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe) ...@@ -1908,22 +1907,24 @@ static void vpfe_calculate_offsets(struct vpfe_device *vpfe)
* the buffer count and buffer size * the buffer count and buffer size
*/ */
static int vpfe_queue_setup(struct vb2_queue *vq, static int vpfe_queue_setup(struct vb2_queue *vq,
const void *parg,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
const struct v4l2_format *fmt = parg;
struct vpfe_device *vpfe = vb2_get_drv_priv(vq); struct vpfe_device *vpfe = vb2_get_drv_priv(vq);
unsigned size = vpfe->fmt.fmt.pix.sizeimage;
if (fmt && fmt->fmt.pix.sizeimage < vpfe->fmt.fmt.pix.sizeimage)
return -EINVAL;
if (vq->num_buffers + *nbuffers < 3) if (vq->num_buffers + *nbuffers < 3)
*nbuffers = 3 - vq->num_buffers; *nbuffers = 3 - vq->num_buffers;
alloc_ctxs[0] = vpfe->alloc_ctx;
if (*nplanes) {
if (sizes[0] < size)
return -EINVAL;
size = sizes[0];
}
*nplanes = 1; *nplanes = 1;
sizes[0] = fmt ? fmt->fmt.pix.sizeimage : vpfe->fmt.fmt.pix.sizeimage; sizes[0] = size;
alloc_ctxs[0] = vpfe->alloc_ctx;
vpfe_dbg(1, vpfe, vpfe_dbg(1, vpfe,
"nbuffers=%d, size=%u\n", *nbuffers, sizes[0]); "nbuffers=%d, size=%u\n", *nbuffers, sizes[0]);
......
...@@ -202,22 +202,20 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev) ...@@ -202,22 +202,20 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev)
} }
static int bcap_queue_setup(struct vb2_queue *vq, static int bcap_queue_setup(struct vb2_queue *vq,
const void *parg,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
const struct v4l2_format *fmt = parg;
struct bcap_device *bcap_dev = vb2_get_drv_priv(vq); struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
if (fmt && fmt->fmt.pix.sizeimage < bcap_dev->fmt.sizeimage)
return -EINVAL;
if (vq->num_buffers + *nbuffers < 2) if (vq->num_buffers + *nbuffers < 2)
*nbuffers = 2; *nbuffers = 2;
alloc_ctxs[0] = bcap_dev->alloc_ctx;
if (*nplanes)
return sizes[0] < bcap_dev->fmt.sizeimage ? -EINVAL : 0;
*nplanes = 1; *nplanes = 1;
sizes[0] = fmt ? fmt->fmt.pix.sizeimage : bcap_dev->fmt.sizeimage; sizes[0] = bcap_dev->fmt.sizeimage;
alloc_ctxs[0] = bcap_dev->alloc_ctx;
return 0; return 0;
} }
......
...@@ -1131,7 +1131,7 @@ static void set_default_params(struct coda_ctx *ctx) ...@@ -1131,7 +1131,7 @@ static void set_default_params(struct coda_ctx *ctx)
/* /*
* Queue operations * Queue operations
*/ */
static int coda_queue_setup(struct vb2_queue *vq, const void *parg, static int coda_queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers, unsigned int *nplanes, unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[]) unsigned int sizes[], void *alloc_ctxs[])
{ {
......
...@@ -228,28 +228,27 @@ static int vpbe_buffer_prepare(struct vb2_buffer *vb) ...@@ -228,28 +228,27 @@ static int vpbe_buffer_prepare(struct vb2_buffer *vb)