Commit 5a11b845 authored by Ricardo Ribalda Delgado's avatar Ricardo Ribalda Delgado Committed by Greg Kroah-Hartman

media: v4l2-ctrl: Fix flags field on Control events

commit 9cac9d2f 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: default avatarDimitrios Katsaros <patcherwork@gmail.com>
Signed-off-by: default avatarRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0870fb4c
...@@ -1200,6 +1200,16 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, ...@@ -1200,6 +1200,16 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
} }
EXPORT_SYMBOL(v4l2_ctrl_fill); EXPORT_SYMBOL(v4l2_ctrl_fill);
static u32 user_flags(const struct v4l2_ctrl *ctrl)
{
u32 flags = ctrl->flags;
if (ctrl->is_ptr)
flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
return flags;
}
static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes) static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes)
{ {
memset(ev->reserved, 0, sizeof(ev->reserved)); memset(ev->reserved, 0, sizeof(ev->reserved));
...@@ -1207,7 +1217,7 @@ static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 change ...@@ -1207,7 +1217,7 @@ static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 change
ev->id = ctrl->id; ev->id = ctrl->id;
ev->u.ctrl.changes = changes; ev->u.ctrl.changes = changes;
ev->u.ctrl.type = ctrl->type; ev->u.ctrl.type = ctrl->type;
ev->u.ctrl.flags = ctrl->flags; ev->u.ctrl.flags = user_flags(ctrl);
if (ctrl->is_ptr) if (ctrl->is_ptr)
ev->u.ctrl.value64 = 0; ev->u.ctrl.value64 = 0;
else else
...@@ -2536,10 +2546,8 @@ int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctr ...@@ -2536,10 +2546,8 @@ int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctr
else else
qc->id = ctrl->id; qc->id = ctrl->id;
strlcpy(qc->name, ctrl->name, sizeof(qc->name)); strlcpy(qc->name, ctrl->name, sizeof(qc->name));
qc->flags = ctrl->flags; qc->flags = user_flags(ctrl);
qc->type = ctrl->type; qc->type = ctrl->type;
if (ctrl->is_ptr)
qc->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
qc->elem_size = ctrl->elem_size; qc->elem_size = ctrl->elem_size;
qc->elems = ctrl->elems; qc->elems = ctrl->elems;
qc->nr_of_dims = ctrl->nr_of_dims; qc->nr_of_dims = ctrl->nr_of_dims;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment