diff options
Diffstat (limited to 'include/media/v4l2-ctrls.h')
| -rw-r--r-- | include/media/v4l2-ctrls.h | 222 |
1 files changed, 173 insertions, 49 deletions
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 16f7f2606516..b7cd7a665e35 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h | |||
| @@ -36,6 +36,25 @@ struct v4l2_subscribed_event; | |||
| 36 | struct v4l2_fh; | 36 | struct v4l2_fh; |
| 37 | struct poll_table_struct; | 37 | struct poll_table_struct; |
| 38 | 38 | ||
| 39 | /** union v4l2_ctrl_ptr - A pointer to a control value. | ||
| 40 | * @p_s32: Pointer to a 32-bit signed value. | ||
| 41 | * @p_s64: Pointer to a 64-bit signed value. | ||
| 42 | * @p_u8: Pointer to a 8-bit unsigned value. | ||
| 43 | * @p_u16: Pointer to a 16-bit unsigned value. | ||
| 44 | * @p_u32: Pointer to a 32-bit unsigned value. | ||
| 45 | * @p_char: Pointer to a string. | ||
| 46 | * @p: Pointer to a compound value. | ||
| 47 | */ | ||
| 48 | union v4l2_ctrl_ptr { | ||
| 49 | s32 *p_s32; | ||
| 50 | s64 *p_s64; | ||
| 51 | u8 *p_u8; | ||
| 52 | u16 *p_u16; | ||
| 53 | u32 *p_u32; | ||
| 54 | char *p_char; | ||
| 55 | void *p; | ||
| 56 | }; | ||
| 57 | |||
| 39 | /** struct v4l2_ctrl_ops - The control operations that the driver has to provide. | 58 | /** struct v4l2_ctrl_ops - The control operations that the driver has to provide. |
| 40 | * @g_volatile_ctrl: Get a new value for this control. Generally only relevant | 59 | * @g_volatile_ctrl: Get a new value for this control. Generally only relevant |
| 41 | * for volatile (and usually read-only) controls such as a control | 60 | * for volatile (and usually read-only) controls such as a control |
| @@ -54,6 +73,23 @@ struct v4l2_ctrl_ops { | |||
| 54 | int (*s_ctrl)(struct v4l2_ctrl *ctrl); | 73 | int (*s_ctrl)(struct v4l2_ctrl *ctrl); |
| 55 | }; | 74 | }; |
| 56 | 75 | ||
| 76 | /** struct v4l2_ctrl_type_ops - The control type operations that the driver has to provide. | ||
| 77 | * @equal: return true if both values are equal. | ||
| 78 | * @init: initialize the value. | ||
| 79 | * @log: log the value. | ||
| 80 | * @validate: validate the value. Return 0 on success and a negative value otherwise. | ||
| 81 | */ | ||
| 82 | struct v4l2_ctrl_type_ops { | ||
| 83 | bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx, | ||
| 84 | union v4l2_ctrl_ptr ptr1, | ||
| 85 | union v4l2_ctrl_ptr ptr2); | ||
| 86 | void (*init)(const struct v4l2_ctrl *ctrl, u32 idx, | ||
| 87 | union v4l2_ctrl_ptr ptr); | ||
| 88 | void (*log)(const struct v4l2_ctrl *ctrl); | ||
| 89 | int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx, | ||
| 90 | union v4l2_ctrl_ptr ptr); | ||
| 91 | }; | ||
| 92 | |||
| 57 | typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); | 93 | typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); |
| 58 | 94 | ||
| 59 | /** struct v4l2_ctrl - The control structure. | 95 | /** struct v4l2_ctrl - The control structure. |
| @@ -66,6 +102,8 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); | |||
| 66 | * @is_new: Set when the user specified a new value for this control. It | 102 | * @is_new: Set when the user specified a new value for this control. It |
| 67 | * is also set when called from v4l2_ctrl_handler_setup. Drivers | 103 | * is also set when called from v4l2_ctrl_handler_setup. Drivers |
| 68 | * should never set this flag. | 104 | * should never set this flag. |
| 105 | * @has_changed: Set when the current value differs from the new value. Drivers | ||
| 106 | * should never use this flag. | ||
| 69 | * @is_private: If set, then this control is private to its handler and it | 107 | * @is_private: If set, then this control is private to its handler and it |
| 70 | * will not be added to any other handlers. Drivers can set | 108 | * will not be added to any other handlers. Drivers can set |
| 71 | * this flag. | 109 | * this flag. |
| @@ -73,6 +111,13 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); | |||
| 73 | * members are in 'automatic' mode or 'manual' mode. This is | 111 | * members are in 'automatic' mode or 'manual' mode. This is |
| 74 | * used for autogain/gain type clusters. Drivers should never | 112 | * used for autogain/gain type clusters. Drivers should never |
| 75 | * set this flag directly. | 113 | * set this flag directly. |
| 114 | * @is_int: If set, then this control has a simple integer value (i.e. it | ||
| 115 | * uses ctrl->val). | ||
| 116 | * @is_string: If set, then this control has type V4L2_CTRL_TYPE_STRING. | ||
| 117 | * @is_ptr: If set, then this control is an array and/or has type >= V4L2_CTRL_COMPOUND_TYPES | ||
| 118 | * and/or has type V4L2_CTRL_TYPE_STRING. In other words, struct | ||
| 119 | * v4l2_ext_control uses field p to point to the data. | ||
| 120 | * @is_array: If set, then this control contains an N-dimensional array. | ||
| 76 | * @has_volatiles: If set, then one or more members of the cluster are volatile. | 121 | * @has_volatiles: If set, then one or more members of the cluster are volatile. |
| 77 | * Drivers should never touch this flag. | 122 | * Drivers should never touch this flag. |
| 78 | * @call_notify: If set, then call the handler's notify function whenever the | 123 | * @call_notify: If set, then call the handler's notify function whenever the |
| @@ -83,6 +128,7 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); | |||
| 83 | * value, then the whole cluster is in manual mode. Drivers should | 128 | * value, then the whole cluster is in manual mode. Drivers should |
| 84 | * never set this flag directly. | 129 | * never set this flag directly. |
| 85 | * @ops: The control ops. | 130 | * @ops: The control ops. |
| 131 | * @type_ops: The control type ops. | ||
| 86 | * @id: The control ID. | 132 | * @id: The control ID. |
| 87 | * @name: The control name. | 133 | * @name: The control name. |
| 88 | * @type: The control type. | 134 | * @type: The control type. |
| @@ -90,6 +136,10 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); | |||
| 90 | * @maximum: The control's maximum value. | 136 | * @maximum: The control's maximum value. |
| 91 | * @default_value: The control's default value. | 137 | * @default_value: The control's default value. |
| 92 | * @step: The control's step value for non-menu controls. | 138 | * @step: The control's step value for non-menu controls. |
| 139 | * @elems: The number of elements in the N-dimensional array. | ||
| 140 | * @elem_size: The size in bytes of the control. | ||
| 141 | * @dims: The size of each dimension. | ||
| 142 | * @nr_of_dims:The number of dimensions in @dims. | ||
| 93 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it | 143 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it |
| 94 | * easy to skip menu items that are not valid. If bit X is set, | 144 | * easy to skip menu items that are not valid. If bit X is set, |
| 95 | * then menu item X is skipped. Of course, this only works for | 145 | * then menu item X is skipped. Of course, this only works for |
| @@ -104,7 +154,6 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); | |||
| 104 | * @cur: The control's current value. | 154 | * @cur: The control's current value. |
| 105 | * @val: The control's new s32 value. | 155 | * @val: The control's new s32 value. |
| 106 | * @val64: The control's new s64 value. | 156 | * @val64: The control's new s64 value. |
| 107 | * @string: The control's new string value. | ||
| 108 | * @priv: The control's private pointer. For use by the driver. It is | 157 | * @priv: The control's private pointer. For use by the driver. It is |
| 109 | * untouched by the control framework. Note that this pointer is | 158 | * untouched by the control framework. Note that this pointer is |
| 110 | * not freed when the control is deleted. Should this be needed | 159 | * not freed when the control is deleted. Should this be needed |
| @@ -121,37 +170,44 @@ struct v4l2_ctrl { | |||
| 121 | unsigned int done:1; | 170 | unsigned int done:1; |
| 122 | 171 | ||
| 123 | unsigned int is_new:1; | 172 | unsigned int is_new:1; |
| 173 | unsigned int has_changed:1; | ||
| 124 | unsigned int is_private:1; | 174 | unsigned int is_private:1; |
| 125 | unsigned int is_auto:1; | 175 | unsigned int is_auto:1; |
| 176 | unsigned int is_int:1; | ||
| 177 | unsigned int is_string:1; | ||
| 178 | unsigned int is_ptr:1; | ||
| 179 | unsigned int is_array:1; | ||
| 126 | unsigned int has_volatiles:1; | 180 | unsigned int has_volatiles:1; |
| 127 | unsigned int call_notify:1; | 181 | unsigned int call_notify:1; |
| 128 | unsigned int manual_mode_value:8; | 182 | unsigned int manual_mode_value:8; |
| 129 | 183 | ||
| 130 | const struct v4l2_ctrl_ops *ops; | 184 | const struct v4l2_ctrl_ops *ops; |
| 185 | const struct v4l2_ctrl_type_ops *type_ops; | ||
| 131 | u32 id; | 186 | u32 id; |
| 132 | const char *name; | 187 | const char *name; |
| 133 | enum v4l2_ctrl_type type; | 188 | enum v4l2_ctrl_type type; |
| 134 | s32 minimum, maximum, default_value; | 189 | s64 minimum, maximum, default_value; |
| 190 | u32 elems; | ||
| 191 | u32 elem_size; | ||
| 192 | u32 dims[V4L2_CTRL_MAX_DIMS]; | ||
| 193 | u32 nr_of_dims; | ||
| 135 | union { | 194 | union { |
| 136 | u32 step; | 195 | u64 step; |
| 137 | u32 menu_skip_mask; | 196 | u64 menu_skip_mask; |
| 138 | }; | 197 | }; |
| 139 | union { | 198 | union { |
| 140 | const char * const *qmenu; | 199 | const char * const *qmenu; |
| 141 | const s64 *qmenu_int; | 200 | const s64 *qmenu_int; |
| 142 | }; | 201 | }; |
| 143 | unsigned long flags; | 202 | unsigned long flags; |
| 144 | union { | 203 | void *priv; |
| 204 | s32 val; | ||
| 205 | struct { | ||
| 145 | s32 val; | 206 | s32 val; |
| 146 | s64 val64; | ||
| 147 | char *string; | ||
| 148 | } cur; | 207 | } cur; |
| 149 | union { | 208 | |
| 150 | s32 val; | 209 | union v4l2_ctrl_ptr p_new; |
| 151 | s64 val64; | 210 | union v4l2_ctrl_ptr p_cur; |
| 152 | char *string; | ||
| 153 | }; | ||
| 154 | void *priv; | ||
| 155 | }; | 211 | }; |
| 156 | 212 | ||
| 157 | /** struct v4l2_ctrl_ref - The control reference. | 213 | /** struct v4l2_ctrl_ref - The control reference. |
| @@ -205,6 +261,7 @@ struct v4l2_ctrl_handler { | |||
| 205 | 261 | ||
| 206 | /** struct v4l2_ctrl_config - Control configuration structure. | 262 | /** struct v4l2_ctrl_config - Control configuration structure. |
| 207 | * @ops: The control ops. | 263 | * @ops: The control ops. |
| 264 | * @type_ops: The control type ops. Only needed for compound controls. | ||
| 208 | * @id: The control ID. | 265 | * @id: The control ID. |
| 209 | * @name: The control name. | 266 | * @name: The control name. |
| 210 | * @type: The control type. | 267 | * @type: The control type. |
| @@ -212,13 +269,15 @@ struct v4l2_ctrl_handler { | |||
| 212 | * @max: The control's maximum value. | 269 | * @max: The control's maximum value. |
| 213 | * @step: The control's step value for non-menu controls. | 270 | * @step: The control's step value for non-menu controls. |
| 214 | * @def: The control's default value. | 271 | * @def: The control's default value. |
| 272 | * @dims: The size of each dimension. | ||
| 273 | * @elem_size: The size in bytes of the control. | ||
| 215 | * @flags: The control's flags. | 274 | * @flags: The control's flags. |
| 216 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it | 275 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it |
| 217 | * easy to skip menu items that are not valid. If bit X is set, | 276 | * easy to skip menu items that are not valid. If bit X is set, |
| 218 | * then menu item X is skipped. Of course, this only works for | 277 | * then menu item X is skipped. Of course, this only works for |
| 219 | * menus with <= 32 menu items. There are no menus that come | 278 | * menus with <= 64 menu items. There are no menus that come |
| 220 | * close to that number, so this is OK. Should we ever need more, | 279 | * close to that number, so this is OK. Should we ever need more, |
| 221 | * then this will have to be extended to a u64 or a bit array. | 280 | * then this will have to be extended to a bit array. |
| 222 | * @qmenu: A const char * array for all menu items. Array entries that are | 281 | * @qmenu: A const char * array for all menu items. Array entries that are |
| 223 | * empty strings ("") correspond to non-existing menu items (this | 282 | * empty strings ("") correspond to non-existing menu items (this |
| 224 | * is in addition to the menu_skip_mask above). The last entry | 283 | * is in addition to the menu_skip_mask above). The last entry |
| @@ -228,15 +287,18 @@ struct v4l2_ctrl_handler { | |||
| 228 | */ | 287 | */ |
| 229 | struct v4l2_ctrl_config { | 288 | struct v4l2_ctrl_config { |
| 230 | const struct v4l2_ctrl_ops *ops; | 289 | const struct v4l2_ctrl_ops *ops; |
| 290 | const struct v4l2_ctrl_type_ops *type_ops; | ||
| 231 | u32 id; | 291 | u32 id; |
| 232 | const char *name; | 292 | const char *name; |
| 233 | enum v4l2_ctrl_type type; | 293 | enum v4l2_ctrl_type type; |
| 234 | s32 min; | 294 | s64 min; |
| 235 | s32 max; | 295 | s64 max; |
| 236 | u32 step; | 296 | u64 step; |
| 237 | s32 def; | 297 | s64 def; |
| 298 | u32 dims[V4L2_CTRL_MAX_DIMS]; | ||
| 299 | u32 elem_size; | ||
| 238 | u32 flags; | 300 | u32 flags; |
| 239 | u32 menu_skip_mask; | 301 | u64 menu_skip_mask; |
| 240 | const char * const *qmenu; | 302 | const char * const *qmenu; |
| 241 | const s64 *qmenu_int; | 303 | const s64 *qmenu_int; |
| 242 | unsigned int is_private:1; | 304 | unsigned int is_private:1; |
| @@ -257,7 +319,7 @@ struct v4l2_ctrl_config { | |||
| 257 | * control framework this function will no longer be exported. | 319 | * control framework this function will no longer be exported. |
| 258 | */ | 320 | */ |
| 259 | void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, | 321 | void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, |
| 260 | s32 *min, s32 *max, s32 *step, s32 *def, u32 *flags); | 322 | s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags); |
| 261 | 323 | ||
| 262 | 324 | ||
| 263 | /** v4l2_ctrl_handler_init_class() - Initialize the control handler. | 325 | /** v4l2_ctrl_handler_init_class() - Initialize the control handler. |
| @@ -307,6 +369,24 @@ int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, | |||
| 307 | */ | 369 | */ |
| 308 | void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl); | 370 | void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl); |
| 309 | 371 | ||
| 372 | /** v4l2_ctrl_lock() - Helper function to lock the handler | ||
| 373 | * associated with the control. | ||
| 374 | * @ctrl: The control to lock. | ||
| 375 | */ | ||
| 376 | static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl) | ||
| 377 | { | ||
| 378 | mutex_lock(ctrl->handler->lock); | ||
| 379 | } | ||
| 380 | |||
| 381 | /** v4l2_ctrl_unlock() - Helper function to unlock the handler | ||
| 382 | * associated with the control. | ||
| 383 | * @ctrl: The control to unlock. | ||
| 384 | */ | ||
| 385 | static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl) | ||
| 386 | { | ||
| 387 | mutex_unlock(ctrl->handler->lock); | ||
| 388 | } | ||
| 389 | |||
| 310 | /** v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging | 390 | /** v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging |
| 311 | * to the handler to initialize the hardware to the current control values. | 391 | * to the handler to initialize the hardware to the current control values. |
| 312 | * @hdl: The control handler. | 392 | * @hdl: The control handler. |
| @@ -362,7 +442,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, | |||
| 362 | */ | 442 | */ |
| 363 | struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, | 443 | struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, |
| 364 | const struct v4l2_ctrl_ops *ops, | 444 | const struct v4l2_ctrl_ops *ops, |
| 365 | u32 id, s32 min, s32 max, u32 step, s32 def); | 445 | u32 id, s64 min, s64 max, u64 step, s64 def); |
| 366 | 446 | ||
| 367 | /** v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 menu control. | 447 | /** v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 menu control. |
| 368 | * @hdl: The control handler. | 448 | * @hdl: The control handler. |
| @@ -372,9 +452,9 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, | |||
| 372 | * @mask: The control's skip mask for menu controls. This makes it | 452 | * @mask: The control's skip mask for menu controls. This makes it |
| 373 | * easy to skip menu items that are not valid. If bit X is set, | 453 | * easy to skip menu items that are not valid. If bit X is set, |
| 374 | * then menu item X is skipped. Of course, this only works for | 454 | * then menu item X is skipped. Of course, this only works for |
| 375 | * menus with <= 32 menu items. There are no menus that come | 455 | * menus with <= 64 menu items. There are no menus that come |
| 376 | * close to that number, so this is OK. Should we ever need more, | 456 | * close to that number, so this is OK. Should we ever need more, |
| 377 | * then this will have to be extended to a u64 or a bit array. | 457 | * then this will have to be extended to a bit array. |
| 378 | * @def: The control's default value. | 458 | * @def: The control's default value. |
| 379 | * | 459 | * |
| 380 | * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value | 460 | * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value |
| @@ -384,7 +464,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, | |||
| 384 | */ | 464 | */ |
| 385 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | 465 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, |
| 386 | const struct v4l2_ctrl_ops *ops, | 466 | const struct v4l2_ctrl_ops *ops, |
| 387 | u32 id, s32 max, s32 mask, s32 def); | 467 | u32 id, u8 max, u64 mask, u8 def); |
| 388 | 468 | ||
| 389 | /** v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control | 469 | /** v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control |
| 390 | * with driver specific menu. | 470 | * with driver specific menu. |
| @@ -395,9 +475,9 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | |||
| 395 | * @mask: The control's skip mask for menu controls. This makes it | 475 | * @mask: The control's skip mask for menu controls. This makes it |
| 396 | * easy to skip menu items that are not valid. If bit X is set, | 476 | * easy to skip menu items that are not valid. If bit X is set, |
| 397 | * then menu item X is skipped. Of course, this only works for | 477 | * then menu item X is skipped. Of course, this only works for |
| 398 | * menus with <= 32 menu items. There are no menus that come | 478 | * menus with <= 64 menu items. There are no menus that come |
| 399 | * close to that number, so this is OK. Should we ever need more, | 479 | * close to that number, so this is OK. Should we ever need more, |
| 400 | * then this will have to be extended to a u64 or a bit array. | 480 | * then this will have to be extended to a bit array. |
| 401 | * @def: The control's default value. | 481 | * @def: The control's default value. |
| 402 | * @qmenu: The new menu. | 482 | * @qmenu: The new menu. |
| 403 | * | 483 | * |
| @@ -406,8 +486,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | |||
| 406 | * | 486 | * |
| 407 | */ | 487 | */ |
| 408 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, | 488 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, |
| 409 | const struct v4l2_ctrl_ops *ops, u32 id, s32 max, | 489 | const struct v4l2_ctrl_ops *ops, u32 id, u8 max, |
| 410 | s32 mask, s32 def, const char * const *qmenu); | 490 | u64 mask, u8 def, const char * const *qmenu); |
| 411 | 491 | ||
| 412 | /** v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. | 492 | /** v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. |
| 413 | * @hdl: The control handler. | 493 | * @hdl: The control handler. |
| @@ -424,7 +504,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, | |||
| 424 | */ | 504 | */ |
| 425 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, | 505 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, |
| 426 | const struct v4l2_ctrl_ops *ops, | 506 | const struct v4l2_ctrl_ops *ops, |
| 427 | u32 id, s32 max, s32 def, const s64 *qmenu_int); | 507 | u32 id, u8 max, u8 def, const s64 *qmenu_int); |
| 428 | 508 | ||
| 429 | /** v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler. | 509 | /** v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler. |
| 430 | * @hdl: The control handler. | 510 | * @hdl: The control handler. |
| @@ -542,6 +622,11 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); | |||
| 542 | */ | 622 | */ |
| 543 | void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); | 623 | void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); |
| 544 | 624 | ||
| 625 | |||
| 626 | /** __v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() */ | ||
| 627 | int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, | ||
| 628 | s64 min, s64 max, u64 step, s64 def); | ||
| 629 | |||
| 545 | /** v4l2_ctrl_modify_range() - Update the range of a control. | 630 | /** v4l2_ctrl_modify_range() - Update the range of a control. |
| 546 | * @ctrl: The control to update. | 631 | * @ctrl: The control to update. |
| 547 | * @min: The control's minimum value. | 632 | * @min: The control's minimum value. |
| @@ -559,25 +644,16 @@ void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); | |||
| 559 | * This function assumes that the control handler is not locked and will | 644 | * This function assumes that the control handler is not locked and will |
| 560 | * take the lock itself. | 645 | * take the lock itself. |
| 561 | */ | 646 | */ |
| 562 | int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, | 647 | static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, |
| 563 | s32 min, s32 max, u32 step, s32 def); | 648 | s64 min, s64 max, u64 step, s64 def) |
| 564 | |||
| 565 | /** v4l2_ctrl_lock() - Helper function to lock the handler | ||
| 566 | * associated with the control. | ||
| 567 | * @ctrl: The control to lock. | ||
| 568 | */ | ||
| 569 | static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl) | ||
| 570 | { | 649 | { |
| 571 | mutex_lock(ctrl->handler->lock); | 650 | int rval; |
| 572 | } | ||
| 573 | 651 | ||
| 574 | /** v4l2_ctrl_unlock() - Helper function to unlock the handler | 652 | v4l2_ctrl_lock(ctrl); |
| 575 | * associated with the control. | 653 | rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def); |
| 576 | * @ctrl: The control to unlock. | 654 | v4l2_ctrl_unlock(ctrl); |
| 577 | */ | 655 | |
| 578 | static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl) | 656 | return rval; |
| 579 | { | ||
| 580 | mutex_unlock(ctrl->handler->lock); | ||
| 581 | } | 657 | } |
| 582 | 658 | ||
| 583 | /** v4l2_ctrl_notify() - Function to set a notify callback for a control. | 659 | /** v4l2_ctrl_notify() - Function to set a notify callback for a control. |
| @@ -605,6 +681,8 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void | |||
| 605 | */ | 681 | */ |
| 606 | s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); | 682 | s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); |
| 607 | 683 | ||
| 684 | /** __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl(). */ | ||
| 685 | int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); | ||
| 608 | /** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver. | 686 | /** v4l2_ctrl_s_ctrl() - Helper function to set the control's value from within a driver. |
| 609 | * @ctrl: The control. | 687 | * @ctrl: The control. |
| 610 | * @val: The new value. | 688 | * @val: The new value. |
| @@ -615,7 +693,16 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); | |||
| 615 | * | 693 | * |
| 616 | * This function is for integer type controls only. | 694 | * This function is for integer type controls only. |
| 617 | */ | 695 | */ |
| 618 | int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); | 696 | static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) |
| 697 | { | ||
| 698 | int rval; | ||
| 699 | |||
| 700 | v4l2_ctrl_lock(ctrl); | ||
| 701 | rval = __v4l2_ctrl_s_ctrl(ctrl, val); | ||
| 702 | v4l2_ctrl_unlock(ctrl); | ||
| 703 | |||
| 704 | return rval; | ||
| 705 | } | ||
| 619 | 706 | ||
| 620 | /** v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value from within a driver. | 707 | /** v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value from within a driver. |
| 621 | * @ctrl: The control. | 708 | * @ctrl: The control. |
| @@ -628,6 +715,9 @@ int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); | |||
| 628 | */ | 715 | */ |
| 629 | s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl); | 716 | s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl); |
| 630 | 717 | ||
| 718 | /** __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64(). */ | ||
| 719 | int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val); | ||
| 720 | |||
| 631 | /** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value from within a driver. | 721 | /** v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value from within a driver. |
| 632 | * @ctrl: The control. | 722 | * @ctrl: The control. |
| 633 | * @val: The new value. | 723 | * @val: The new value. |
| @@ -638,7 +728,40 @@ s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl); | |||
| 638 | * | 728 | * |
| 639 | * This function is for 64-bit integer type controls only. | 729 | * This function is for 64-bit integer type controls only. |
| 640 | */ | 730 | */ |
| 641 | int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val); | 731 | static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) |
| 732 | { | ||
| 733 | int rval; | ||
| 734 | |||
| 735 | v4l2_ctrl_lock(ctrl); | ||
| 736 | rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val); | ||
| 737 | v4l2_ctrl_unlock(ctrl); | ||
| 738 | |||
| 739 | return rval; | ||
| 740 | } | ||
| 741 | |||
| 742 | /** __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string(). */ | ||
| 743 | int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s); | ||
| 744 | |||
| 745 | /** v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value from within a driver. | ||
| 746 | * @ctrl: The control. | ||
| 747 | * @s: The new string. | ||
| 748 | * | ||
| 749 | * This set the control's new string safely by going through the control | ||
| 750 | * framework. This function will lock the control's handler, so it cannot be | ||
| 751 | * used from within the &v4l2_ctrl_ops functions. | ||
| 752 | * | ||
| 753 | * This function is for string type controls only. | ||
| 754 | */ | ||
| 755 | static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) | ||
| 756 | { | ||
| 757 | int rval; | ||
| 758 | |||
| 759 | v4l2_ctrl_lock(ctrl); | ||
| 760 | rval = __v4l2_ctrl_s_ctrl_string(ctrl, s); | ||
| 761 | v4l2_ctrl_unlock(ctrl); | ||
| 762 | |||
| 763 | return rval; | ||
| 764 | } | ||
| 642 | 765 | ||
| 643 | /* Internal helper functions that deal with control events. */ | 766 | /* Internal helper functions that deal with control events. */ |
| 644 | extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; | 767 | extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; |
| @@ -659,6 +782,7 @@ unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait); | |||
| 659 | 782 | ||
| 660 | /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ | 783 | /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ |
| 661 | int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); | 784 | int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); |
| 785 | int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctrl *qc); | ||
| 662 | int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm); | 786 | int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm); |
| 663 | int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl); | 787 | int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl); |
| 664 | int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, | 788 | int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, |
