From: Kieran Bingham <kieran@ksquared.org.uk> To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>, linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org Subject: Re: [PATCH v3 09/10] v4l: fdp1: Fix field validation when preparing buffer Date: Sun, 11 Sep 2016 17:45:51 +0100 [thread overview] Message-ID: <733020cd-f1b8-ff0c-0d95-1d205a67d38a@bingham.xyz> (raw) In-Reply-To: <1473287110-780-10-git-send-email-laurent.pinchart+renesas@ideasonboard.com> On 07/09/16 23:25, Laurent Pinchart wrote: > Ensure that the buffer field matches the field configured for the > format. Looks OK and tests fine. I think with the field 'serialiser' the driver didn't actually care what the buffers put in were (as long as they were sequential) but it certainly isn't a bad thing to verify they are what we were told they would be :D -- Reviewed-by: Kieran Bingham <kieran@bingham.xyz> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> > --- > drivers/media/platform/rcar_fdp1.c | 40 +++++++++++++++++++++++++++++++------- > 1 file changed, 33 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c > index 480f89381f15..c25531a919db 100644 > --- a/drivers/media/platform/rcar_fdp1.c > +++ b/drivers/media/platform/rcar_fdp1.c > @@ -1884,17 +1884,43 @@ static int fdp1_buf_prepare(struct vb2_buffer *vb) > > q_data = get_q_data(ctx, vb->vb2_queue->type); > > - /* Default to Progressive if ANY selected */ > - if (vbuf->field == V4L2_FIELD_ANY) > - vbuf->field = V4L2_FIELD_NONE; > + if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { > + bool field_valid = true; > + > + /* Validate the buffer field. */ > + switch (q_data->format.field) { > + case V4L2_FIELD_NONE: > + if (vbuf->field != V4L2_FIELD_NONE) > + field_valid = false; > + break; > + > + case V4L2_FIELD_ALTERNATE: > + if (vbuf->field != V4L2_FIELD_TOP && > + vbuf->field != V4L2_FIELD_BOTTOM) > + field_valid = false; > + break; > > - /* We only support progressive CAPTURE */ > - if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type) && > - vbuf->field != V4L2_FIELD_NONE) { > - dprintk(ctx->fdp1, "field isn't supported on capture\n"); > + case V4L2_FIELD_INTERLACED: > + case V4L2_FIELD_SEQ_TB: > + case V4L2_FIELD_SEQ_BT: > + case V4L2_FIELD_INTERLACED_TB: > + case V4L2_FIELD_INTERLACED_BT: > + if (vbuf->field != q_data->format.field) > + field_valid = false; > + break; > + } > + > + if (!field_valid) { > + dprintk(ctx->fdp1, > + "buffer field %u invalid for format field %u\n", > + vbuf->field, q_data->format.field); > return -EINVAL; > + } > + } else { > + vbuf->field = V4L2_FIELD_NONE; > } > > + /* Validate the planes sizes. */ > for (i = 0; i < q_data->format.num_planes; i++) { > unsigned long size = q_data->format.plane_fmt[i].sizeimage; > > -- Regards Kieran Bingham
WARNING: multiple messages have this Message-ID (diff)
From: Kieran Bingham <kieran@bingham.xyz> To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>, linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org Subject: Re: [PATCH v3 09/10] v4l: fdp1: Fix field validation when preparing buffer Date: Sun, 11 Sep 2016 17:45:51 +0100 [thread overview] Message-ID: <733020cd-f1b8-ff0c-0d95-1d205a67d38a@bingham.xyz> (raw) In-Reply-To: <1473287110-780-10-git-send-email-laurent.pinchart+renesas@ideasonboard.com> On 07/09/16 23:25, Laurent Pinchart wrote: > Ensure that the buffer field matches the field configured for the > format. Looks OK and tests fine. I think with the field 'serialiser' the driver didn't actually care what the buffers put in were (as long as they were sequential) but it certainly isn't a bad thing to verify they are what we were told they would be :D -- Reviewed-by: Kieran Bingham <kieran@bingham.xyz> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> > --- > drivers/media/platform/rcar_fdp1.c | 40 +++++++++++++++++++++++++++++++------- > 1 file changed, 33 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c > index 480f89381f15..c25531a919db 100644 > --- a/drivers/media/platform/rcar_fdp1.c > +++ b/drivers/media/platform/rcar_fdp1.c > @@ -1884,17 +1884,43 @@ static int fdp1_buf_prepare(struct vb2_buffer *vb) > > q_data = get_q_data(ctx, vb->vb2_queue->type); > > - /* Default to Progressive if ANY selected */ > - if (vbuf->field == V4L2_FIELD_ANY) > - vbuf->field = V4L2_FIELD_NONE; > + if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { > + bool field_valid = true; > + > + /* Validate the buffer field. */ > + switch (q_data->format.field) { > + case V4L2_FIELD_NONE: > + if (vbuf->field != V4L2_FIELD_NONE) > + field_valid = false; > + break; > + > + case V4L2_FIELD_ALTERNATE: > + if (vbuf->field != V4L2_FIELD_TOP && > + vbuf->field != V4L2_FIELD_BOTTOM) > + field_valid = false; > + break; > > - /* We only support progressive CAPTURE */ > - if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type) && > - vbuf->field != V4L2_FIELD_NONE) { > - dprintk(ctx->fdp1, "field isn't supported on capture\n"); > + case V4L2_FIELD_INTERLACED: > + case V4L2_FIELD_SEQ_TB: > + case V4L2_FIELD_SEQ_BT: > + case V4L2_FIELD_INTERLACED_TB: > + case V4L2_FIELD_INTERLACED_BT: > + if (vbuf->field != q_data->format.field) > + field_valid = false; > + break; > + } > + > + if (!field_valid) { > + dprintk(ctx->fdp1, > + "buffer field %u invalid for format field %u\n", > + vbuf->field, q_data->format.field); > return -EINVAL; > + } > + } else { > + vbuf->field = V4L2_FIELD_NONE; > } > > + /* Validate the planes sizes. */ > for (i = 0; i < q_data->format.num_planes; i++) { > unsigned long size = q_data->format.plane_fmt[i].sizeimage; > > -- Regards Kieran Bingham
next prev parent reply other threads:[~2016-09-11 16:45 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-09-07 22:25 [PATCH v3 00/10] v4l: platform: Add Renesas R-Car FDP1 Driver Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-07 22:25 ` [PATCH v3 01/10] v4l: ioctl: Clear the v4l2_pix_format_mplane reserved field Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-08 7:04 ` Sakari Ailus 2016-09-07 22:25 ` [PATCH v3 02/10] v4l: ctrls: Add deinterlacing mode control Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-08 9:04 ` Kieran Bingham 2016-09-08 9:04 ` Kieran Bingham 2016-10-21 14:34 ` Hans Verkuil 2016-10-24 9:07 ` Laurent Pinchart 2016-09-07 22:25 ` [PATCH v3 03/10] v4l: Extend FCP compatible list to support the FDP Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-07 22:25 ` [PATCH v3 04/10] v4l: Add Renesas R-Car FDP1 Driver Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-07 22:25 ` [PATCH v3 05/10] v4l: fdp1: vb2_queue dev conversion Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-08 9:05 ` Kieran Bingham 2016-09-08 9:05 ` Kieran Bingham 2016-09-07 22:25 ` [PATCH v3 06/10] v4l: fdp1: Incorporate miscellaneous review comments Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-11 16:35 ` Kieran Bingham 2016-09-11 16:35 ` Kieran Bingham 2016-09-07 22:25 ` [PATCH v3 07/10] v4l: fdp1: Remove unused struct fdp1_v4l2_buffer Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-09 7:29 ` Kieran Bingham 2016-09-09 7:29 ` Kieran Bingham 2016-09-07 22:25 ` [PATCH v3 08/10] v4l: fdp1: Rewrite format setting code Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-11 20:27 ` Kieran Bingham 2016-09-11 20:27 ` Kieran Bingham 2016-09-07 22:25 ` [PATCH v3 09/10] v4l: fdp1: Fix field validation when preparing buffer Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-11 16:45 ` Kieran Bingham [this message] 2016-09-11 16:45 ` Kieran Bingham 2016-09-07 22:25 ` [PATCH v3 10/10] v4l: fdp1: Store buffer information in vb2 buffer Laurent Pinchart 2016-09-07 22:25 ` Laurent Pinchart 2016-09-11 20:20 ` Kieran Bingham 2016-09-11 20:20 ` Kieran Bingham 2016-09-08 9:10 ` [PATCH v3 00/10] v4l: platform: Add Renesas R-Car FDP1 Driver Kieran Bingham 2016-09-08 9:10 ` Kieran Bingham
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=733020cd-f1b8-ff0c-0d95-1d205a67d38a@bingham.xyz \ --to=kieran@ksquared.org.uk \ --cc=laurent.pinchart+renesas@ideasonboard.com \ --cc=linux-media@vger.kernel.org \ --cc=linux-renesas-soc@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.