aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2014-06-12 12:09:42 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-21 19:10:48 -0400
commit0c4348ada001181637b8f73482242166ba2fb56e (patch)
tree819c95c0cc6a31fea3730f3c9254d04cc1cb2c6a
parent5a573925159aeec1dd159627d849dc6c66000faf (diff)
[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: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c26
-rw-r--r--include/media/v4l2-ctrls.h27
2 files changed, 45 insertions, 8 deletions
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 9cd978334b89..1acc7aa9d7e2 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -3175,27 +3175,41 @@ int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *control)
3175} 3175}
3176EXPORT_SYMBOL(v4l2_subdev_s_ctrl); 3176EXPORT_SYMBOL(v4l2_subdev_s_ctrl);
3177 3177
3178int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) 3178int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
3179{ 3179{
3180 struct v4l2_ext_control c; 3180 struct v4l2_ext_control c;
3181 int rval;
3182
3183 lockdep_assert_held(ctrl->handler->lock);
3181 3184
3182 /* It's a driver bug if this happens. */ 3185 /* It's a driver bug if this happens. */
3183 WARN_ON(!ctrl->is_int); 3186 WARN_ON(!ctrl->is_int);
3184 c.value = val; 3187 c.value = val;
3185 return set_ctrl_lock(NULL, ctrl, &c); 3188 rval = set_ctrl(NULL, ctrl, &c, 0);
3189 if (!rval)
3190 cur_to_user(&c, ctrl);
3191
3192 return rval;
3186} 3193}
3187EXPORT_SYMBOL(v4l2_ctrl_s_ctrl); 3194EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl);
3188 3195
3189int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) 3196int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
3190{ 3197{
3191 struct v4l2_ext_control c; 3198 struct v4l2_ext_control c;
3199 int rval;
3200
3201 lockdep_assert_held(ctrl->handler->lock);
3192 3202
3193 /* It's a driver bug if this happens. */ 3203 /* It's a driver bug if this happens. */
3194 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64); 3204 WARN_ON(ctrl->is_ptr || ctrl->type != V4L2_CTRL_TYPE_INTEGER64);
3195 c.value64 = val; 3205 c.value64 = val;
3196 return set_ctrl_lock(NULL, ctrl, &c); 3206 rval = set_ctrl(NULL, ctrl, &c, 0);
3207 if (!rval)
3208 cur_to_user(&c, ctrl);
3209
3210 return rval;
3197} 3211}
3198EXPORT_SYMBOL(v4l2_ctrl_s_ctrl_int64); 3212EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_int64);
3199 3213
3200void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) 3214void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv)
3201{ 3215{
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 5d1a30ca29af..8c4edd69fa4b 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -679,6 +679,8 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void
679 */ 679 */
680s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); 680s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
681 681
682/** __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl(). */
683int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
682/** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver. 684/** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver.
683 * @ctrl: The control. 685 * @ctrl: The control.
684 * @val: The new value. 686 * @val: The new value.
@@ -689,7 +691,16 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
689 * 691 *
690 * This function is for integer type controls only. 692 * This function is for integer type controls only.
691 */ 693 */
692int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); 694static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
695{
696 int rval;
697
698 v4l2_ctrl_lock(ctrl);
699 rval = __v4l2_ctrl_s_ctrl(ctrl, val);
700 v4l2_ctrl_unlock(ctrl);
701
702 return rval;
703}
693 704
694/** v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value from within a driver. 705/** v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value from within a driver.
695 * @ctrl: The control. 706 * @ctrl: The control.
@@ -702,6 +713,9 @@ int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
702 */ 713 */
703s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl); 714s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
704 715
716/** __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64(). */
717int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
718
705/** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value from within a driver. 719/** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value from within a driver.
706 * @ctrl: The control. 720 * @ctrl: The control.
707 * @val: The new value. 721 * @val: The new value.
@@ -712,7 +726,16 @@ s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
712 * 726 *
713 * This function is for 64-bit integer type controls only. 727 * This function is for 64-bit integer type controls only.
714 */ 728 */
715int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val); 729static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
730{
731 int rval;
732
733 v4l2_ctrl_lock(ctrl);
734 rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
735 v4l2_ctrl_unlock(ctrl);
736
737 return rval;
738}
716 739
717/* Internal helper functions that deal with control events. */ 740/* Internal helper functions that deal with control events. */
718extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; 741extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;