Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e34db066 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab
Browse files

[media] media: coda: set up buffers to be sized as negotiated with s_fmt



This fixes a failure in vb2_qbuf in user pointer mode where
__qbuf_userptr checks if the buffer queued by userspace is large
enough. The failure would happen if coda_queue_setup was called
with empty fmt (and thus set the expected buffer size to the maximum
resolution), and userspace queues buffers of smaller size -
corresponding to the negotiated dimensions - were queued.
Explicitly setting sizeimage to the value negotiated via s_fmt
fixes the issue.

Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Acked-by: default avatarJavier Martin <javier.martin@vista-silicon.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c566c789
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -818,18 +818,11 @@ static int coda_queue_setup(struct vb2_queue *vq,
				unsigned int sizes[], void *alloc_ctxs[])
{
	struct coda_ctx *ctx = vb2_get_drv_priv(vq);
	struct coda_q_data *q_data;
	unsigned int size;

	if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
		if (fmt)
			size = fmt->fmt.pix.width *
				fmt->fmt.pix.height * 3 / 2;
		else
			size = MAX_W *
				MAX_H * 3 / 2;
	} else {
		size = CODA_MAX_FRAME_SIZE;
	}
	q_data = get_q_data(ctx, vq->type);
	size = q_data->sizeimage;

	*nplanes = 1;
	sizes[0] = size;