]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
v4l: ctrls: Provide an unlocked variant of v4l2_ctrl_modify_range()
authorSakari Ailus <sakari.ailus@linux.intel.com>
Tue, 12 Apr 2016 03:24:34 +0000 (11:24 +0800)
committermobile promotions <svcmobile_promotions@nvidia.com>
Thu, 12 May 2016 02:31:07 +0000 (19:31 -0700)
Drivers may use the v4l2_ctrl_modify_range() internally as part of other
operations that need to be both serialised using a driver's lock which can
also be used to serialise access to the control handler. Provide an unlocked
version of the function, __v4l2_ctrl_modify_range() which then may be used
by drivers for the purpose.

Bug 200184502

Change-Id: I2d10f917fd4072882971a7f8d5b46a5829dde64b
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>
Signed-off-by: Ken Chang <kenc@nvidia.com>
(cherry picked from commit 24879d4ae4d6fe76dc63395a0ea3e2caaafc036b)
Reviewed-on: http://git-master/r/1123990
Signed-off-by: Bryan Wu <pengw@nvidia.com>
Reviewed-on: http://git-master/r/1141900
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
drivers/media/v4l2-core/v4l2-ctrls.c
include/media/v4l2-ctrls.h

index fccd08b66d1a04e16cfc127bb672e2c0fbe18e4d..11f1a73528330d2cf9997ef816a1db978fc19473 100644 (file)
@@ -2793,12 +2793,14 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void
 }
 EXPORT_SYMBOL(v4l2_ctrl_notify);
 
-int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
+int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
                        s32 min, s32 max, u32 step, s32 def)
 {
        int ret = check_range(ctrl->type, min, max, step, def);
        struct v4l2_ext_control c;
 
+       lockdep_assert_held(ctrl->handler->lock);
+
        switch (ctrl->type) {
        case V4L2_CTRL_TYPE_INTEGER:
        case V4L2_CTRL_TYPE_BOOLEAN:
@@ -2811,7 +2813,6 @@ int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
        default:
                return -EINVAL;
        }
-       v4l2_ctrl_lock(ctrl);
        ctrl->minimum = min;
        ctrl->maximum = max;
        ctrl->step = step;
@@ -2823,10 +2824,9 @@ int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
                ret = set_ctrl(NULL, ctrl, &c, V4L2_EVENT_CTRL_CH_RANGE);
        else
                send_event(NULL, ctrl, V4L2_EVENT_CTRL_CH_RANGE);
-       v4l2_ctrl_unlock(ctrl);
        return ret;
 }
-EXPORT_SYMBOL(v4l2_ctrl_modify_range);
+EXPORT_SYMBOL(__v4l2_ctrl_modify_range);
 
 static int v4l2_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned elems)
 {
index 47ada23345a195973c3942681566244d50c7f34d..fa45680e75822c0b54b5ca3261f32733f14990ef 100644 (file)
@@ -542,6 +542,28 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
   */
 void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
 
+/** __v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() */
+int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
+                       s32 min, s32 max, u32 step, s32 def);
+
+/** v4l2_ctrl_lock() - Helper function to lock the handler
+  * associated with the control.
+  * @ctrl:     The control to lock.
+  */
+static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
+{
+       mutex_lock(ctrl->handler->lock);
+}
+
+/** v4l2_ctrl_lock() - Helper function to unlock the handler
+  * associated with the control.
+  * @ctrl:     The control to unlock.
+  */
+static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
+{
+       mutex_unlock(ctrl->handler->lock);
+}
+
 /** v4l2_ctrl_modify_range() - Update the range of a control.
   * @ctrl:     The control to update.
   * @min:      The control's minimum value.
@@ -559,25 +581,16 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
   * This function assumes that the control handler is not locked and will
   * take the lock itself.
   */
-int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
-                       s32 min, s32 max, u32 step, s32 def);
-
-/** v4l2_ctrl_lock() - Helper function to lock the handler
-  * associated with the control.
-  * @ctrl:     The control to lock.
-  */
-static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
+static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
+                       s32 min, s32 max, u32 step, s32 def)
 {
-       mutex_lock(ctrl->handler->lock);
-}
+       int rval;
 
-/** v4l2_ctrl_lock() - Helper function to unlock the handler
-  * associated with the control.
-  * @ctrl:     The control to unlock.
-  */
-static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
-{
-       mutex_unlock(ctrl->handler->lock);
+       v4l2_ctrl_lock(ctrl);
+       rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
+       v4l2_ctrl_unlock(ctrl);
+
+       return rval;
 }
 
 /** v4l2_ctrl_notify() - Function to set a notify callback for a control.