Commit dcea5601 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: v4l2-ctrls: use ref in helper instead of ctrl

The next patch needs the reference to a control instead of the
control itself, so change struct v4l2_ctrl_helper accordingly.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 178543a3
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
struct v4l2_ctrl_helper { struct v4l2_ctrl_helper {
/* Pointer to the control reference of the master control */ /* Pointer to the control reference of the master control */
struct v4l2_ctrl_ref *mref; struct v4l2_ctrl_ref *mref;
/* The control corresponding to the v4l2_ext_control ID field. */ /* The control ref corresponding to the v4l2_ext_control ID field. */
struct v4l2_ctrl *ctrl; struct v4l2_ctrl_ref *ref;
/* v4l2_ext_control index of the next control belonging to the /* v4l2_ext_control index of the next control belonging to the
same cluster, or 0 if there isn't any. */ same cluster, or 0 if there isn't any. */
u32 next; u32 next;
...@@ -2908,6 +2908,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, ...@@ -2908,6 +2908,7 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
ref = find_ref_lock(hdl, id); ref = find_ref_lock(hdl, id);
if (ref == NULL) if (ref == NULL)
return -EINVAL; return -EINVAL;
h->ref = ref;
ctrl = ref->ctrl; ctrl = ref->ctrl;
if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED)
return -EINVAL; return -EINVAL;
...@@ -2930,7 +2931,6 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, ...@@ -2930,7 +2931,6 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
} }
/* Store the ref to the master control of the cluster */ /* Store the ref to the master control of the cluster */
h->mref = ref; h->mref = ref;
h->ctrl = ctrl;
/* Initially set next to 0, meaning that there is no other /* Initially set next to 0, meaning that there is no other
control in this helper array belonging to the same control in this helper array belonging to the same
cluster */ cluster */
...@@ -3015,7 +3015,7 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs ...@@ -3015,7 +3015,7 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs
cs->error_idx = cs->count; cs->error_idx = cs->count;
for (i = 0; !ret && i < cs->count; i++) for (i = 0; !ret && i < cs->count; i++)
if (helpers[i].ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY) if (helpers[i].ref->ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY)
ret = -EACCES; ret = -EACCES;
for (i = 0; !ret && i < cs->count; i++) { for (i = 0; !ret && i < cs->count; i++) {
...@@ -3050,7 +3050,7 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs ...@@ -3050,7 +3050,7 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs
do { do {
ret = ctrl_to_user(cs->controls + idx, ret = ctrl_to_user(cs->controls + idx,
helpers[idx].ctrl); helpers[idx].ref->ctrl);
idx = helpers[idx].next; idx = helpers[idx].next;
} while (!ret && idx); } while (!ret && idx);
} }
...@@ -3202,7 +3202,7 @@ static int validate_ctrls(struct v4l2_ext_controls *cs, ...@@ -3202,7 +3202,7 @@ static int validate_ctrls(struct v4l2_ext_controls *cs,
cs->error_idx = cs->count; cs->error_idx = cs->count;
for (i = 0; i < cs->count; i++) { for (i = 0; i < cs->count; i++) {
struct v4l2_ctrl *ctrl = helpers[i].ctrl; struct v4l2_ctrl *ctrl = helpers[i].ref->ctrl;
union v4l2_ctrl_ptr p_new; union v4l2_ctrl_ptr p_new;
cs->error_idx = i; cs->error_idx = i;
...@@ -3314,7 +3314,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, ...@@ -3314,7 +3314,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
do { do {
/* Check if the auto control is part of the /* Check if the auto control is part of the
list, and remember the new value. */ list, and remember the new value. */
if (helpers[tmp_idx].ctrl == master) if (helpers[tmp_idx].ref->ctrl == master)
new_auto_val = cs->controls[tmp_idx].value; new_auto_val = cs->controls[tmp_idx].value;
tmp_idx = helpers[tmp_idx].next; tmp_idx = helpers[tmp_idx].next;
} while (tmp_idx); } while (tmp_idx);
...@@ -3327,7 +3327,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, ...@@ -3327,7 +3327,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
/* Copy the new caller-supplied control values. /* Copy the new caller-supplied control values.
user_to_new() sets 'is_new' to 1. */ user_to_new() sets 'is_new' to 1. */
do { do {
struct v4l2_ctrl *ctrl = helpers[idx].ctrl; struct v4l2_ctrl *ctrl = helpers[idx].ref->ctrl;
ret = user_to_new(cs->controls + idx, ctrl); ret = user_to_new(cs->controls + idx, ctrl);
if (!ret && ctrl->is_ptr) if (!ret && ctrl->is_ptr)
...@@ -3343,7 +3343,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, ...@@ -3343,7 +3343,7 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
idx = i; idx = i;
do { do {
ret = new_to_user(cs->controls + idx, ret = new_to_user(cs->controls + idx,
helpers[idx].ctrl); helpers[idx].ref->ctrl);
idx = helpers[idx].next; idx = helpers[idx].next;
} while (!ret && idx); } while (!ret && idx);
} }
......
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