diff mbox series

[1/2] media: rockchip: rga: fix field in OUTPUT buffers

Message ID 20240528-rk3568-rga-v1-1-b946e55d9d37@pengutronix.de (mailing list archive)
State New
Headers show
Series media: rockchip: rga: fix v4l2-compliance errors | expand

Commit Message

Michael Tretter May 28, 2024, 2:05 p.m. UTC
Returned buffers shouldn't contain V4L2_FIELD_ANY as field. Set the
field to V4L2_FIELD_NONE, if it isn't set.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 drivers/media/platform/rockchip/rga/rga-buf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Hans Verkuil May 30, 2024, 12:47 p.m. UTC | #1
On 28/05/2024 16:05, Michael Tretter wrote:
> Returned buffers shouldn't contain V4L2_FIELD_ANY as field. Set the
> field to V4L2_FIELD_NONE, if it isn't set.
> 
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
>  drivers/media/platform/rockchip/rga/rga-buf.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/platform/rockchip/rga/rga-buf.c
> index 662c81b6d0b5..77c7535893e3 100644
> --- a/drivers/media/platform/rockchip/rga/rga-buf.c
> +++ b/drivers/media/platform/rockchip/rga/rga-buf.c
> @@ -119,6 +119,16 @@ static int rga_buf_prepare(struct vb2_buffer *vb)
>  	if (IS_ERR(f))
>  		return PTR_ERR(f);
>  
> +	if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
> +		if (vbuf->field == V4L2_FIELD_ANY)
> +			vbuf->field = V4L2_FIELD_NONE;
> +		if (vbuf->field != V4L2_FIELD_NONE) {
> +			v4l2_err(&ctx->rga->v4l2_dev, "Unsupported field %s\n",
> +				 v4l2_field_names[vbuf->field]);

This should be v4l2_dbg: incorrect userspace data should not result in
spamming of the kernel log. It's fine to report it if debugging is enabled.

Regards,

	Hans

> +			return -EINVAL;
> +		}
> +	}
> +
>  	for (i = 0; i < vb->num_planes; i++) {
>  		vb2_set_plane_payload(vb, i, f->pix.plane_fmt[i].sizeimage);
>  
>
Michael Tretter May 31, 2024, 2:30 p.m. UTC | #2
On Thu, 30 May 2024 14:47:48 +0200, Hans Verkuil wrote:
> On 28/05/2024 16:05, Michael Tretter wrote:
> > Returned buffers shouldn't contain V4L2_FIELD_ANY as field. Set the
> > field to V4L2_FIELD_NONE, if it isn't set.
> > 
> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> > ---
> >  drivers/media/platform/rockchip/rga/rga-buf.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/platform/rockchip/rga/rga-buf.c
> > index 662c81b6d0b5..77c7535893e3 100644
> > --- a/drivers/media/platform/rockchip/rga/rga-buf.c
> > +++ b/drivers/media/platform/rockchip/rga/rga-buf.c
> > @@ -119,6 +119,16 @@ static int rga_buf_prepare(struct vb2_buffer *vb)
> >  	if (IS_ERR(f))
> >  		return PTR_ERR(f);
> >  
> > +	if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
> > +		if (vbuf->field == V4L2_FIELD_ANY)
> > +			vbuf->field = V4L2_FIELD_NONE;
> > +		if (vbuf->field != V4L2_FIELD_NONE) {
> > +			v4l2_err(&ctx->rga->v4l2_dev, "Unsupported field %s\n",
> > +				 v4l2_field_names[vbuf->field]);
> 
> This should be v4l2_dbg: incorrect userspace data should not result in
> spamming of the kernel log. It's fine to report it if debugging is enabled.

I cannot use v4l2_dbg here, as the debug module parameter for the RGA
driver is defined in a different file. I'll just drop the error message
in v2.

Michael

> 
> Regards,
> 
> 	Hans
> 
> > +			return -EINVAL;
> > +		}
> > +	}
> > +
> >  	for (i = 0; i < vb->num_planes; i++) {
> >  		vb2_set_plane_payload(vb, i, f->pix.plane_fmt[i].sizeimage);
> >  
> > 
> 
>
diff mbox series

Patch

diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/platform/rockchip/rga/rga-buf.c
index 662c81b6d0b5..77c7535893e3 100644
--- a/drivers/media/platform/rockchip/rga/rga-buf.c
+++ b/drivers/media/platform/rockchip/rga/rga-buf.c
@@ -119,6 +119,16 @@  static int rga_buf_prepare(struct vb2_buffer *vb)
 	if (IS_ERR(f))
 		return PTR_ERR(f);
 
+	if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
+		if (vbuf->field == V4L2_FIELD_ANY)
+			vbuf->field = V4L2_FIELD_NONE;
+		if (vbuf->field != V4L2_FIELD_NONE) {
+			v4l2_err(&ctx->rga->v4l2_dev, "Unsupported field %s\n",
+				 v4l2_field_names[vbuf->field]);
+			return -EINVAL;
+		}
+	}
+
 	for (i = 0; i < vb->num_planes; i++) {
 		vb2_set_plane_payload(vb, i, f->pix.plane_fmt[i].sizeimage);