Commit 0c4348ad authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] v4l: ctrls: Unlocked variants of v4l2_ctrl_s_ctrl{,_int64}()

Implement unlocked variants of v4l2_ctrl_s_ctrl() and
v4l2_ctrl_s_ctrl_int64(). As drivers need to set controls as they access
driver internal state elsewhere than in the control framework unlocked
variants of these functions become handy.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 5a573925
...@@ -3175,27 +3175,41 @@ int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *control) ...@@ -3175,27 +3175,41 @@ int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *control)
} }
EXPORT_SYMBOL(v4l2_subdev_s_ctrl); EXPORT_SYMBOL(v4l2_subdev_s_ctrl);
int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
{ {
struct v4l2_ext_control c; struct v4l2_ext_control c;
int rval;
lockdep_assert_held(ctrl->handler->lock);
/* It's a driver bug if this happens. */ /* It's a driver bug if this happens. */
WARN_ON(!ctrl->is_int); WARN_ON(!ctrl->is_int);
c.value = val; c.value = val;
return set_ctrl_lock(NULL, ctrl, &c); rval = set_ctrl(NULL, ctrl, &c, 0);
if (!rval)
cur_to_user(&c, ctrl);
return rval;
} }
EXPORT_SYMBOL(v4l2_ctrl_s_ctrl); EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl);
int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
{ {
struct v4l2_ext_control c; struct v4l2_ext_control c;
int rval;
lockdep_assert_held(ctrl->handler->lock);
/* It's a driver bug if this happens. */ /* It's a driver bug if this happens. */
WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64);
c.value64 = val; c.value64 = val;
return set_ctrl_lock(NULL, ctrl, &c); rval = set_ctrl(NULL, ctrl, &c, 0);
if (!rval)
cur_to_user(&c, ctrl);
return rval;
} }
EXPORT_SYMBOL(v4l2_ctrl_s_ctrl_int64); EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_int64);
void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv)
{ {
......
...@@ -679,6 +679,8 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void ...@@ -679,6 +679,8 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void
*/ */
s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
/** __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl(). */
int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
/** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver. /** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver.
* @ctrl: The control. * @ctrl: The control.
* @val: The new value. * @val: The new value.
...@@ -689,7 +691,16 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); ...@@ -689,7 +691,16 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
* *
* This function is for integer type controls only. * This function is for integer type controls only.
*/ */
int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
{
int rval;
v4l2_ctrl_lock(ctrl);
rval = __v4l2_ctrl_s_ctrl(ctrl, val);
v4l2_ctrl_unlock(ctrl);
return rval;
}
/** v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value from within a driver. /** v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value from within a driver.
* @ctrl: The control. * @ctrl: The control.
...@@ -702,6 +713,9 @@ int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); ...@@ -702,6 +713,9 @@ int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
*/ */
s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl); s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
/** __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64(). */
int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
/** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value from within a driver. /** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value from within a driver.
* @ctrl: The control. * @ctrl: The control.
* @val: The new value. * @val: The new value.
...@@ -712,7 +726,16 @@ s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl); ...@@ -712,7 +726,16 @@ s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
* *
* This function is for 64-bit integer type controls only. * This function is for 64-bit integer type controls only.
*/ */
int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val); static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
{
int rval;
v4l2_ctrl_lock(ctrl);
rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
v4l2_ctrl_unlock(ctrl);
return rval;
}
/* Internal helper functions that deal with control events. */ /* Internal helper functions that deal with control events. */
extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
......
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