From: Hans Verkuil <[email protected]>

This is not allowed by the spec and does in fact not make any sense.
Return -EINVAL if this is the case.

Signed-off-by: Hans Verkuil <[email protected]>
---
 drivers/media/v4l2-core/videobuf2-core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index afd1268..8984187 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1526,6 +1526,15 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
                        __func__, ret);
                return ret;
        }
+       if (V4L2_TYPE_IS_OUTPUT(q->type) && b->field == V4L2_FIELD_ALTERNATE) {
+               /*
+                * If field is ALTERNATE, then we return an error.
+                * If the format's field is ALTERNATE, then the buffer's field
+                * should be either TOP or BOTTOM, but using ALTERNATE here as
+                * well makes no sense.
+                */
+               return -EINVAL;
+       }
 
        vb->state = VB2_BUF_STATE_PREPARING;
        vb->v4l2_buf.timestamp.tv_sec = 0;
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to