diff mbox series

[13/13] media: coda: fix unset field and fail on invalid field in buf_prepare

Message ID 20190412155135.13907-13-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series [01/13] media: coda: move register debugging to coda_debug level 3 | expand

Commit Message

Philipp Zabel April 12, 2019, 3:51 p.m. UTC
v4l2-compliance likes to queue a buffer with field set to V4L2_FIELD_ANY
and expects it to be returned corrected to a valid field.

Follow vicodec in handling this in the buf_prepare callback.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda/coda-common.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Ezequiel Garcia April 25, 2019, 6:55 p.m. UTC | #1
On Fri, 2019-04-12 at 17:51 +0200, Philipp Zabel wrote:
> v4l2-compliance likes to queue a buffer with field set to V4L2_FIELD_ANY
> and expects it to be returned corrected to a valid field.
> 
> Follow vicodec in handling this in the buf_prepare callback.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/media/platform/coda/coda-common.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
> index 1cd0fb5b1c5b..1d8e0a045df1 100644
> --- a/drivers/media/platform/coda/coda-common.c
> +++ b/drivers/media/platform/coda/coda-common.c
> @@ -1515,10 +1515,20 @@ static int coda_queue_setup(struct vb2_queue *vq,
>  
>  static int coda_buf_prepare(struct vb2_buffer *vb)
>  {
> +	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
>  	struct coda_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
>  	struct coda_q_data *q_data;
>  
>  	q_data = get_q_data(ctx, vb->vb2_queue->type);
> +	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_warn(&ctx->dev->v4l2_dev,
> +				  "%s field isn't supported\n", __func__);
> +			return -EINVAL;
> +		}
> +	}
>  
>  	if (vb2_plane_size(vb, 0) < q_data->sizeimage) {
>  		v4l2_warn(&ctx->dev->v4l2_dev,

I believe instead of this, you can just populate your buf_out_validate
like this:

static int coda_buf_out_validate(struct vb2_buffer *vb)
{
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);

        vbuf->field = V4L2_FIELD_NONE;
        return 0;
}

Thanks,
Eze
diff mbox series

Patch

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 1cd0fb5b1c5b..1d8e0a045df1 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1515,10 +1515,20 @@  static int coda_queue_setup(struct vb2_queue *vq,
 
 static int coda_buf_prepare(struct vb2_buffer *vb)
 {
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 	struct coda_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
 	struct coda_q_data *q_data;
 
 	q_data = get_q_data(ctx, vb->vb2_queue->type);
+	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_warn(&ctx->dev->v4l2_dev,
+				  "%s field isn't supported\n", __func__);
+			return -EINVAL;
+		}
+	}
 
 	if (vb2_plane_size(vb, 0) < q_data->sizeimage) {
 		v4l2_warn(&ctx->dev->v4l2_dev,