Skip to content

Commit 5a11b84

Browse files
ribaldagregkh
authored andcommitted
media: v4l2-ctrl: Fix flags field on Control events
commit 9cac9d2fb2fe0e0cadacdb94415b3fe49e3f724f upstream. VIDIOC_DQEVENT and VIDIOC_QUERY_EXT_CTRL should give the same output for the control flags field. This patch creates a new function user_flags(), that calculates the user exported flags value (which is different than the kernel internal flags structure). This function is then used by all the code that exports the internal flags to userspace. Reported-by: Dimitrios Katsaros <patcherwork@gmail.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0870fb4 commit 5a11b84

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

drivers/media/v4l2-core/v4l2-ctrls.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,14 +1200,24 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
12001200
}
12011201
EXPORT_SYMBOL(v4l2_ctrl_fill);
12021202

1203+
static u32 user_flags(const struct v4l2_ctrl *ctrl)
1204+
{
1205+
u32 flags = ctrl->flags;
1206+
1207+
if (ctrl->is_ptr)
1208+
flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
1209+
1210+
return flags;
1211+
}
1212+
12031213
static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes)
12041214
{
12051215
memset(ev->reserved, 0, sizeof(ev->reserved));
12061216
ev->type = V4L2_EVENT_CTRL;
12071217
ev->id = ctrl->id;
12081218
ev->u.ctrl.changes = changes;
12091219
ev->u.ctrl.type = ctrl->type;
1210-
ev->u.ctrl.flags = ctrl->flags;
1220+
ev->u.ctrl.flags = user_flags(ctrl);
12111221
if (ctrl->is_ptr)
12121222
ev->u.ctrl.value64 = 0;
12131223
else
@@ -2536,10 +2546,8 @@ int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctr
25362546
else
25372547
qc->id = ctrl->id;
25382548
strlcpy(qc->name, ctrl->name, sizeof(qc->name));
2539-
qc->flags = ctrl->flags;
2549+
qc->flags = user_flags(ctrl);
25402550
qc->type = ctrl->type;
2541-
if (ctrl->is_ptr)
2542-
qc->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
25432551
qc->elem_size = ctrl->elem_size;
25442552
qc->elems = ctrl->elems;
25452553
qc->nr_of_dims = ctrl->nr_of_dims;

0 commit comments

Comments
 (0)