Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 1 | /* |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 2 | * V4L2 controls support header. |
| 3 | * |
| 4 | * Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef _V4L2_CTRLS_H |
| 18 | #define _V4L2_CTRLS_H |
| 19 | |
| 20 | #include <linux/list.h> |
Andrzej Hajda | a19dec6 | 2013-06-28 05:44:22 -0300 | [diff] [blame] | 21 | #include <linux/mutex.h> |
Laurent Pinchart | 01c40c0 | 2010-11-19 11:20:06 -0300 | [diff] [blame] | 22 | #include <linux/videodev2.h> |
Hans Verkuil | 52beedd | 2018-05-21 04:54:37 -0400 | [diff] [blame] | 23 | #include <media/media-request.h> |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 24 | |
Hans Verkuil | 9514063 | 2018-12-05 06:28:20 -0500 | [diff] [blame] | 25 | /* |
| 26 | * Include the mpeg2 stateless codec compound control definitions. |
| 27 | * This will move to the public headers once this API is fully stable. |
| 28 | */ |
| 29 | #include <media/mpeg2-ctrls.h> |
| 30 | |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 31 | /* forward references */ |
Laurent Pinchart | 528f0f7 | 2012-04-23 08:20:35 -0300 | [diff] [blame] | 32 | struct file; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 33 | struct v4l2_ctrl_handler; |
Hans Verkuil | eb5b16e | 2011-06-14 10:04:06 -0300 | [diff] [blame] | 34 | struct v4l2_ctrl_helper; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 35 | struct v4l2_ctrl; |
| 36 | struct video_device; |
| 37 | struct v4l2_subdev; |
Hans Verkuil | 77068d3 | 2011-06-13 18:55:58 -0300 | [diff] [blame] | 38 | struct v4l2_subscribed_event; |
Hans Verkuil | 6e23939 | 2011-06-07 11:13:44 -0300 | [diff] [blame] | 39 | struct v4l2_fh; |
Hans Verkuil | a26243b | 2012-01-27 16:18:42 -0300 | [diff] [blame] | 40 | struct poll_table_struct; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 41 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 42 | /** |
| 43 | * union v4l2_ctrl_ptr - A pointer to a control value. |
Paul Kocialkowski | c27bb30 | 2018-09-13 10:51:52 -0400 | [diff] [blame] | 44 | * @p_s32: Pointer to a 32-bit signed value. |
| 45 | * @p_s64: Pointer to a 64-bit signed value. |
| 46 | * @p_u8: Pointer to a 8-bit unsigned value. |
| 47 | * @p_u16: Pointer to a 16-bit unsigned value. |
| 48 | * @p_u32: Pointer to a 32-bit unsigned value. |
| 49 | * @p_char: Pointer to a string. |
| 50 | * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure. |
| 51 | * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure. |
| 52 | * @p: Pointer to a compound value. |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 53 | */ |
| 54 | union v4l2_ctrl_ptr { |
| 55 | s32 *p_s32; |
| 56 | s64 *p_s64; |
Hans Verkuil | dda4a4d | 2014-06-10 07:30:04 -0300 | [diff] [blame] | 57 | u8 *p_u8; |
| 58 | u16 *p_u16; |
Hans Verkuil | 811c508 | 2014-07-21 10:45:37 -0300 | [diff] [blame] | 59 | u32 *p_u32; |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 60 | char *p_char; |
Paul Kocialkowski | c27bb30 | 2018-09-13 10:51:52 -0400 | [diff] [blame] | 61 | struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; |
| 62 | struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization; |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 63 | void *p; |
| 64 | }; |
| 65 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 66 | /** |
| 67 | * struct v4l2_ctrl_ops - The control operations that the driver has to provide. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 68 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 69 | * @g_volatile_ctrl: Get a new value for this control. Generally only relevant |
| 70 | * for volatile (and usually read-only) controls such as a control |
| 71 | * that returns the current signal strength which changes |
| 72 | * continuously. |
| 73 | * If not set, then the currently cached value will be returned. |
| 74 | * @try_ctrl: Test whether the control's value is valid. Only relevant when |
| 75 | * the usual min/max/step checks are not sufficient. |
| 76 | * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The |
| 77 | * ctrl->handler->lock is held when these ops are called, so no |
| 78 | * one else can access controls owned by that handler. |
| 79 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 80 | struct v4l2_ctrl_ops { |
| 81 | int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl); |
| 82 | int (*try_ctrl)(struct v4l2_ctrl *ctrl); |
| 83 | int (*s_ctrl)(struct v4l2_ctrl *ctrl); |
| 84 | }; |
| 85 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 86 | /** |
| 87 | * struct v4l2_ctrl_type_ops - The control type operations that the driver |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 88 | * has to provide. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 89 | * |
| 90 | * @equal: return true if both values are equal. |
| 91 | * @init: initialize the value. |
| 92 | * @log: log the value. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 93 | * @validate: validate the value. Return 0 on success and a negative value |
| 94 | * otherwise. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 95 | */ |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 96 | struct v4l2_ctrl_type_ops { |
Hans Verkuil | 998e765 | 2014-06-10 07:55:00 -0300 | [diff] [blame] | 97 | bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx, |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 98 | union v4l2_ctrl_ptr ptr1, |
| 99 | union v4l2_ctrl_ptr ptr2); |
Hans Verkuil | 998e765 | 2014-06-10 07:55:00 -0300 | [diff] [blame] | 100 | void (*init)(const struct v4l2_ctrl *ctrl, u32 idx, |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 101 | union v4l2_ctrl_ptr ptr); |
| 102 | void (*log)(const struct v4l2_ctrl *ctrl); |
Hans Verkuil | 998e765 | 2014-06-10 07:55:00 -0300 | [diff] [blame] | 103 | int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx, |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 104 | union v4l2_ctrl_ptr ptr); |
| 105 | }; |
| 106 | |
Mauro Carvalho Chehab | 2257e18 | 2016-08-29 17:26:15 -0300 | [diff] [blame] | 107 | /** |
| 108 | * typedef v4l2_ctrl_notify_fnc - typedef for a notify argument with a function |
| 109 | * that should be called when a control value has changed. |
| 110 | * |
| 111 | * @ctrl: pointer to struct &v4l2_ctrl |
| 112 | * @priv: control private data |
| 113 | * |
| 114 | * This typedef definition is used as an argument to v4l2_ctrl_notify() |
| 115 | * and as an argument at struct &v4l2_ctrl_handler. |
| 116 | */ |
Hans Verkuil | 8ac7a94 | 2012-09-07 04:46:39 -0300 | [diff] [blame] | 117 | typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); |
| 118 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 119 | /** |
| 120 | * struct v4l2_ctrl - The control structure. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 121 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 122 | * @node: The list node. |
| 123 | * @ev_subs: The list of control event subscriptions. |
| 124 | * @handler: The handler that owns the control. |
| 125 | * @cluster: Point to start of cluster array. |
| 126 | * @ncontrols: Number of controls in cluster array. |
| 127 | * @done: Internal flag: set for each processed control. |
| 128 | * @is_new: Set when the user specified a new value for this control. It |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 129 | * is also set when called from v4l2_ctrl_handler_setup(). Drivers |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 130 | * should never set this flag. |
| 131 | * @has_changed: Set when the current value differs from the new value. Drivers |
| 132 | * should never use this flag. |
| 133 | * @is_private: If set, then this control is private to its handler and it |
| 134 | * will not be added to any other handlers. Drivers can set |
| 135 | * this flag. |
| 136 | * @is_auto: If set, then this control selects whether the other cluster |
| 137 | * members are in 'automatic' mode or 'manual' mode. This is |
| 138 | * used for autogain/gain type clusters. Drivers should never |
| 139 | * set this flag directly. |
| 140 | * @is_int: If set, then this control has a simple integer value (i.e. it |
| 141 | * uses ctrl->val). |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 142 | * @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING. |
| 143 | * @is_ptr: If set, then this control is an array and/or has type >= |
| 144 | * %V4L2_CTRL_COMPOUND_TYPES |
| 145 | * and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 146 | * v4l2_ext_control uses field p to point to the data. |
| 147 | * @is_array: If set, then this control contains an N-dimensional array. |
| 148 | * @has_volatiles: If set, then one or more members of the cluster are volatile. |
| 149 | * Drivers should never touch this flag. |
| 150 | * @call_notify: If set, then call the handler's notify function whenever the |
| 151 | * control's value changes. |
| 152 | * @manual_mode_value: If the is_auto flag is set, then this is the value |
| 153 | * of the auto control that determines if that control is in |
| 154 | * manual mode. So if the value of the auto control equals this |
| 155 | * value, then the whole cluster is in manual mode. Drivers should |
| 156 | * never set this flag directly. |
| 157 | * @ops: The control ops. |
| 158 | * @type_ops: The control type ops. |
| 159 | * @id: The control ID. |
| 160 | * @name: The control name. |
| 161 | * @type: The control type. |
| 162 | * @minimum: The control's minimum value. |
| 163 | * @maximum: The control's maximum value. |
| 164 | * @default_value: The control's default value. |
| 165 | * @step: The control's step value for non-menu controls. |
| 166 | * @elems: The number of elements in the N-dimensional array. |
| 167 | * @elem_size: The size in bytes of the control. |
| 168 | * @dims: The size of each dimension. |
| 169 | * @nr_of_dims:The number of dimensions in @dims. |
| 170 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it |
| 171 | * easy to skip menu items that are not valid. If bit X is set, |
| 172 | * then menu item X is skipped. Of course, this only works for |
| 173 | * menus with <= 32 menu items. There are no menus that come |
| 174 | * close to that number, so this is OK. Should we ever need more, |
| 175 | * then this will have to be extended to a u64 or a bit array. |
| 176 | * @qmenu: A const char * array for all menu items. Array entries that are |
| 177 | * empty strings ("") correspond to non-existing menu items (this |
| 178 | * is in addition to the menu_skip_mask above). The last entry |
| 179 | * must be NULL. |
Mauro Carvalho Chehab | 20139f1 | 2017-09-27 12:25:21 -0400 | [diff] [blame] | 180 | * Used only if the @type is %V4L2_CTRL_TYPE_MENU. |
| 181 | * @qmenu_int: A 64-bit integer array for with integer menu items. |
| 182 | * The size of array must be equal to the menu size, e. g.: |
| 183 | * :math:`ceil(\frac{maximum - minimum}{step}) + 1`. |
| 184 | * Used only if the @type is %V4L2_CTRL_TYPE_INTEGER_MENU. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 185 | * @flags: The control's flags. |
Mauro Carvalho Chehab | 20139f1 | 2017-09-27 12:25:21 -0400 | [diff] [blame] | 186 | * @cur: Structure to store the current value. |
| 187 | * @cur.val: The control's current value, if the @type is represented via |
| 188 | * a u32 integer (see &enum v4l2_ctrl_type). |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 189 | * @val: The control's new s32 value. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 190 | * @priv: The control's private pointer. For use by the driver. It is |
| 191 | * untouched by the control framework. Note that this pointer is |
| 192 | * not freed when the control is deleted. Should this be needed |
| 193 | * then a new internal bitfield can be added to tell the framework |
| 194 | * to free this pointer. |
Baruch Siach | bf7b704 | 2018-07-05 05:38:00 -0400 | [diff] [blame] | 195 | * @p_cur: The control's current value represented via a union which |
Mauro Carvalho Chehab | 7dc8791 | 2015-08-22 08:22:03 -0300 | [diff] [blame] | 196 | * provides a standard way of accessing control types |
| 197 | * through a pointer. |
Baruch Siach | bf7b704 | 2018-07-05 05:38:00 -0400 | [diff] [blame] | 198 | * @p_new: The control's new value represented via a union which provides |
Mauro Carvalho Chehab | 7dc8791 | 2015-08-22 08:22:03 -0300 | [diff] [blame] | 199 | * a standard way of accessing control types |
| 200 | * through a pointer. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 201 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 202 | struct v4l2_ctrl { |
| 203 | /* Administrative fields */ |
| 204 | struct list_head node; |
Hans Verkuil | 77068d3 | 2011-06-13 18:55:58 -0300 | [diff] [blame] | 205 | struct list_head ev_subs; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 206 | struct v4l2_ctrl_handler *handler; |
| 207 | struct v4l2_ctrl **cluster; |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 208 | unsigned int ncontrols; |
| 209 | |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 210 | unsigned int done:1; |
| 211 | |
Hans Verkuil | 2a86379 | 2011-01-11 14:45:03 -0300 | [diff] [blame] | 212 | unsigned int is_new:1; |
Hans Verkuil | 9ea1b7a | 2014-01-17 08:25:26 -0300 | [diff] [blame] | 213 | unsigned int has_changed:1; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 214 | unsigned int is_private:1; |
Hans Verkuil | 72d877c | 2011-06-10 05:44:36 -0300 | [diff] [blame] | 215 | unsigned int is_auto:1; |
Hans Verkuil | d9a2547 | 2014-06-12 07:54:16 -0300 | [diff] [blame] | 216 | unsigned int is_int:1; |
| 217 | unsigned int is_string:1; |
| 218 | unsigned int is_ptr:1; |
Hans Verkuil | 998e765 | 2014-06-10 07:55:00 -0300 | [diff] [blame] | 219 | unsigned int is_array:1; |
Hans Verkuil | 5626b8c | 2011-08-26 07:53:53 -0300 | [diff] [blame] | 220 | unsigned int has_volatiles:1; |
Hans Verkuil | 8ac7a94 | 2012-09-07 04:46:39 -0300 | [diff] [blame] | 221 | unsigned int call_notify:1; |
Hans Verkuil | 82a7c04 | 2011-06-28 10:43:13 -0300 | [diff] [blame] | 222 | unsigned int manual_mode_value:8; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 223 | |
| 224 | const struct v4l2_ctrl_ops *ops; |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 225 | const struct v4l2_ctrl_type_ops *type_ops; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 226 | u32 id; |
| 227 | const char *name; |
| 228 | enum v4l2_ctrl_type type; |
Hans Verkuil | 0ba2aeb | 2014-04-16 09:41:25 -0300 | [diff] [blame] | 229 | s64 minimum, maximum, default_value; |
Hans Verkuil | 20d88ee | 2014-06-12 07:55:21 -0300 | [diff] [blame] | 230 | u32 elems; |
Hans Verkuil | d9a2547 | 2014-06-12 07:54:16 -0300 | [diff] [blame] | 231 | u32 elem_size; |
Hans Verkuil | 20d88ee | 2014-06-12 07:55:21 -0300 | [diff] [blame] | 232 | u32 dims[V4L2_CTRL_MAX_DIMS]; |
| 233 | u32 nr_of_dims; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 234 | union { |
Hans Verkuil | 0ba2aeb | 2014-04-16 09:41:25 -0300 | [diff] [blame] | 235 | u64 step; |
| 236 | u64 menu_skip_mask; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 237 | }; |
Sakari Ailus | ce580fe | 2011-08-04 13:51:11 -0300 | [diff] [blame] | 238 | union { |
| 239 | const char * const *qmenu; |
| 240 | const s64 *qmenu_int; |
| 241 | }; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 242 | unsigned long flags; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 243 | void *priv; |
Hans Verkuil | 2a9ec37 | 2014-04-27 03:38:13 -0300 | [diff] [blame] | 244 | s32 val; |
| 245 | struct { |
Hans Verkuil | d9a2547 | 2014-06-12 07:54:16 -0300 | [diff] [blame] | 246 | s32 val; |
Hans Verkuil | d9a2547 | 2014-06-12 07:54:16 -0300 | [diff] [blame] | 247 | } cur; |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 248 | |
| 249 | union v4l2_ctrl_ptr p_new; |
| 250 | union v4l2_ctrl_ptr p_cur; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 251 | }; |
| 252 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 253 | /** |
| 254 | * struct v4l2_ctrl_ref - The control reference. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 255 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 256 | * @node: List node for the sorted list. |
| 257 | * @next: Single-link list node for the hash. |
| 258 | * @ctrl: The actual control information. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 259 | * @helper: Pointer to helper struct. Used internally in |
Mauro Carvalho Chehab | fb91161 | 2016-08-29 18:43:02 -0300 | [diff] [blame] | 260 | * ``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``. |
Hans Verkuil | da1b1ae | 2018-05-21 04:54:36 -0400 | [diff] [blame] | 261 | * @from_other_dev: If true, then @ctrl was defined in another |
| 262 | * device than the &struct v4l2_ctrl_handler. |
Hans Verkuil | 6fa6f83 | 2018-05-21 04:54:40 -0400 | [diff] [blame] | 263 | * @req_done: Internal flag: if the control handler containing this control |
| 264 | * reference is bound to a media request, then this is set when |
| 265 | * the control has been applied. This prevents applying controls |
| 266 | * from a cluster with multiple controls twice (when the first |
| 267 | * control of a cluster is applied, they all are). |
| 268 | * @req: If set, this refers to another request that sets this control. |
Hans Verkuil | 52beedd | 2018-05-21 04:54:37 -0400 | [diff] [blame] | 269 | * @p_req: If the control handler containing this control reference |
| 270 | * is bound to a media request, then this points to the |
| 271 | * value of the control that should be applied when the request |
| 272 | * is executed, or to the value of the control at the time |
| 273 | * that the request was completed. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 274 | * |
| 275 | * Each control handler has a list of these refs. The list_head is used to |
| 276 | * keep a sorted-by-control-ID list of all controls, while the next pointer |
| 277 | * is used to link the control in the hash's bucket. |
| 278 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 279 | struct v4l2_ctrl_ref { |
| 280 | struct list_head node; |
| 281 | struct v4l2_ctrl_ref *next; |
| 282 | struct v4l2_ctrl *ctrl; |
Hans Verkuil | eb5b16e | 2011-06-14 10:04:06 -0300 | [diff] [blame] | 283 | struct v4l2_ctrl_helper *helper; |
Hans Verkuil | da1b1ae | 2018-05-21 04:54:36 -0400 | [diff] [blame] | 284 | bool from_other_dev; |
Hans Verkuil | 6fa6f83 | 2018-05-21 04:54:40 -0400 | [diff] [blame] | 285 | bool req_done; |
| 286 | struct v4l2_ctrl_ref *req; |
Hans Verkuil | 52beedd | 2018-05-21 04:54:37 -0400 | [diff] [blame] | 287 | union v4l2_ctrl_ptr p_req; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 288 | }; |
| 289 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 290 | /** |
| 291 | * struct v4l2_ctrl_handler - The control handler keeps track of all the |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 292 | * controls: both the controls owned by the handler and those inherited |
| 293 | * from other handlers. |
| 294 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 295 | * @_lock: Default for "lock". |
| 296 | * @lock: Lock to control access to this handler and its controls. |
| 297 | * May be replaced by the user right after init. |
| 298 | * @ctrls: The list of controls owned by this handler. |
| 299 | * @ctrl_refs: The list of control references. |
| 300 | * @cached: The last found control reference. It is common that the same |
| 301 | * control is needed multiple times, so this is a simple |
| 302 | * optimization. |
| 303 | * @buckets: Buckets for the hashing. Allows for quick control lookup. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 304 | * @notify: A notify callback that is called whenever the control changes |
| 305 | * value. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 306 | * Note that the handler's lock is held when the notify function |
| 307 | * is called! |
| 308 | * @notify_priv: Passed as argument to the v4l2_ctrl notify callback. |
| 309 | * @nr_of_buckets: Total number of buckets in the array. |
| 310 | * @error: The error code of the first failed control addition. |
Hans Verkuil | 6fa6f83 | 2018-05-21 04:54:40 -0400 | [diff] [blame] | 311 | * @request_is_queued: True if the request was queued. |
| 312 | * @requests: List to keep track of open control handler request objects. |
| 313 | * For the parent control handler (@req_obj.req == NULL) this |
| 314 | * is the list header. When the parent control handler is |
| 315 | * removed, it has to unbind and put all these requests since |
| 316 | * they refer to the parent. |
| 317 | * @requests_queued: List of the queued requests. This determines the order |
| 318 | * in which these controls are applied. Once the request is |
| 319 | * completed it is removed from this list. |
Hans Verkuil | 52beedd | 2018-05-21 04:54:37 -0400 | [diff] [blame] | 320 | * @req_obj: The &struct media_request_object, used to link into a |
| 321 | * &struct media_request. This request object has a refcount. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 322 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 323 | struct v4l2_ctrl_handler { |
Sakari Ailus | 77e7c4e | 2012-01-24 21:05:34 -0300 | [diff] [blame] | 324 | struct mutex _lock; |
| 325 | struct mutex *lock; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 326 | struct list_head ctrls; |
| 327 | struct list_head ctrl_refs; |
| 328 | struct v4l2_ctrl_ref *cached; |
| 329 | struct v4l2_ctrl_ref **buckets; |
Hans Verkuil | 8ac7a94 | 2012-09-07 04:46:39 -0300 | [diff] [blame] | 330 | v4l2_ctrl_notify_fnc notify; |
| 331 | void *notify_priv; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 332 | u16 nr_of_buckets; |
| 333 | int error; |
Hans Verkuil | 6fa6f83 | 2018-05-21 04:54:40 -0400 | [diff] [blame] | 334 | bool request_is_queued; |
| 335 | struct list_head requests; |
| 336 | struct list_head requests_queued; |
Hans Verkuil | 52beedd | 2018-05-21 04:54:37 -0400 | [diff] [blame] | 337 | struct media_request_object req_obj; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 338 | }; |
| 339 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 340 | /** |
| 341 | * struct v4l2_ctrl_config - Control configuration structure. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 342 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 343 | * @ops: The control ops. |
| 344 | * @type_ops: The control type ops. Only needed for compound controls. |
| 345 | * @id: The control ID. |
| 346 | * @name: The control name. |
| 347 | * @type: The control type. |
| 348 | * @min: The control's minimum value. |
| 349 | * @max: The control's maximum value. |
| 350 | * @step: The control's step value for non-menu controls. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 351 | * @def: The control's default value. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 352 | * @dims: The size of each dimension. |
| 353 | * @elem_size: The size in bytes of the control. |
| 354 | * @flags: The control's flags. |
| 355 | * @menu_skip_mask: The control's skip mask for menu controls. This makes it |
| 356 | * easy to skip menu items that are not valid. If bit X is set, |
| 357 | * then menu item X is skipped. Of course, this only works for |
| 358 | * menus with <= 64 menu items. There are no menus that come |
| 359 | * close to that number, so this is OK. Should we ever need more, |
| 360 | * then this will have to be extended to a bit array. |
| 361 | * @qmenu: A const char * array for all menu items. Array entries that are |
| 362 | * empty strings ("") correspond to non-existing menu items (this |
| 363 | * is in addition to the menu_skip_mask above). The last entry |
| 364 | * must be NULL. |
Mauro Carvalho Chehab | 7dc8791 | 2015-08-22 08:22:03 -0300 | [diff] [blame] | 365 | * @qmenu_int: A const s64 integer array for all menu items of the type |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 366 | * V4L2_CTRL_TYPE_INTEGER_MENU. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 367 | * @is_private: If set, then this control is private to its handler and it |
| 368 | * will not be added to any other handlers. |
| 369 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 370 | struct v4l2_ctrl_config { |
| 371 | const struct v4l2_ctrl_ops *ops; |
Hans Verkuil | 0176077 | 2014-04-27 03:22:17 -0300 | [diff] [blame] | 372 | const struct v4l2_ctrl_type_ops *type_ops; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 373 | u32 id; |
| 374 | const char *name; |
| 375 | enum v4l2_ctrl_type type; |
Hans Verkuil | 0ba2aeb | 2014-04-16 09:41:25 -0300 | [diff] [blame] | 376 | s64 min; |
| 377 | s64 max; |
| 378 | u64 step; |
| 379 | s64 def; |
Hans Verkuil | 20d88ee | 2014-06-12 07:55:21 -0300 | [diff] [blame] | 380 | u32 dims[V4L2_CTRL_MAX_DIMS]; |
Hans Verkuil | d9a2547 | 2014-06-12 07:54:16 -0300 | [diff] [blame] | 381 | u32 elem_size; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 382 | u32 flags; |
Hans Verkuil | 0ba2aeb | 2014-04-16 09:41:25 -0300 | [diff] [blame] | 383 | u64 menu_skip_mask; |
Hans Verkuil | 513521e | 2010-12-29 14:25:52 -0300 | [diff] [blame] | 384 | const char * const *qmenu; |
Sakari Ailus | ce580fe | 2011-08-04 13:51:11 -0300 | [diff] [blame] | 385 | const s64 *qmenu_int; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 386 | unsigned int is_private:1; |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 387 | }; |
| 388 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 389 | /** |
| 390 | * v4l2_ctrl_fill - Fill in the control fields based on the control ID. |
| 391 | * |
| 392 | * @id: ID of the control |
Mauro Carvalho Chehab | 67c672e | 2017-08-12 05:57:05 -0400 | [diff] [blame] | 393 | * @name: pointer to be filled with a string with the name of the control |
| 394 | * @type: pointer for storing the type of the control |
| 395 | * @min: pointer for storing the minimum value for the control |
| 396 | * @max: pointer for storing the maximum value for the control |
| 397 | * @step: pointer for storing the control step |
| 398 | * @def: pointer for storing the default value for the control |
| 399 | * @flags: pointer for storing the flags to be used on the control |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 400 | * |
| 401 | * This works for all standard V4L2 controls. |
| 402 | * For non-standard controls it will only fill in the given arguments |
Mauro Carvalho Chehab | 67c672e | 2017-08-12 05:57:05 -0400 | [diff] [blame] | 403 | * and @name content will be set to %NULL. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 404 | * |
| 405 | * This function will overwrite the contents of @name, @type and @flags. |
| 406 | * The contents of @min, @max, @step and @def may be modified depending on |
| 407 | * the type. |
| 408 | * |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 409 | * .. note:: |
| 410 | * |
| 411 | * Do not use in drivers! It is used internally for backwards compatibility |
| 412 | * control handling only. Once all drivers are converted to use the new |
| 413 | * control framework this function will no longer be exported. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 414 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 415 | void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, |
Hans Verkuil | 0ba2aeb | 2014-04-16 09:41:25 -0300 | [diff] [blame] | 416 | s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags); |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 417 | |
| 418 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 419 | /** |
| 420 | * v4l2_ctrl_handler_init_class() - Initialize the control handler. |
| 421 | * @hdl: The control handler. |
| 422 | * @nr_of_controls_hint: A hint of how many controls this handler is |
| 423 | * expected to refer to. This is the total number, so including |
| 424 | * any inherited controls. It doesn't have to be precise, but if |
| 425 | * it is way off, then you either waste memory (too many buckets |
| 426 | * are allocated) or the control lookup becomes slower (not enough |
| 427 | * buckets are allocated, so there are more slow list lookups). |
| 428 | * It will always work, though. |
| 429 | * @key: Used by the lock validator if CONFIG_LOCKDEP is set. |
| 430 | * @name: Used by the lock validator if CONFIG_LOCKDEP is set. |
| 431 | * |
Mauro Carvalho Chehab | 2257e18 | 2016-08-29 17:26:15 -0300 | [diff] [blame] | 432 | * .. attention:: |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 433 | * |
Mauro Carvalho Chehab | 2257e18 | 2016-08-29 17:26:15 -0300 | [diff] [blame] | 434 | * Never use this call directly, always use the v4l2_ctrl_handler_init() |
| 435 | * macro that hides the @key and @name arguments. |
| 436 | * |
| 437 | * Return: returns an error if the buckets could not be allocated. This |
| 438 | * error will also be stored in @hdl->error. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 439 | */ |
Andy Walls | 6cd247e | 2013-03-09 05:55:11 -0300 | [diff] [blame] | 440 | int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 441 | unsigned int nr_of_controls_hint, |
Andy Walls | 6cd247e | 2013-03-09 05:55:11 -0300 | [diff] [blame] | 442 | struct lock_class_key *key, const char *name); |
| 443 | |
| 444 | #ifdef CONFIG_LOCKDEP |
Mauro Carvalho Chehab | 2257e18 | 2016-08-29 17:26:15 -0300 | [diff] [blame] | 445 | |
| 446 | /** |
Mauro Carvalho Chehab | e383ce0 | 2016-09-22 07:59:03 -0300 | [diff] [blame] | 447 | * v4l2_ctrl_handler_init - helper function to create a static struct |
| 448 | * &lock_class_key and calls v4l2_ctrl_handler_init_class() |
Mauro Carvalho Chehab | 2257e18 | 2016-08-29 17:26:15 -0300 | [diff] [blame] | 449 | * |
| 450 | * @hdl: The control handler. |
| 451 | * @nr_of_controls_hint: A hint of how many controls this handler is |
| 452 | * expected to refer to. This is the total number, so including |
| 453 | * any inherited controls. It doesn't have to be precise, but if |
| 454 | * it is way off, then you either waste memory (too many buckets |
| 455 | * are allocated) or the control lookup becomes slower (not enough |
| 456 | * buckets are allocated, so there are more slow list lookups). |
| 457 | * It will always work, though. |
| 458 | * |
| 459 | * This helper function creates a static struct &lock_class_key and |
| 460 | * calls v4l2_ctrl_handler_init_class(), providing a proper name for the lock |
| 461 | * validador. |
| 462 | * |
| 463 | * Use this helper function to initialize a control handler. |
| 464 | */ |
Andy Walls | 6cd247e | 2013-03-09 05:55:11 -0300 | [diff] [blame] | 465 | #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \ |
| 466 | ( \ |
| 467 | ({ \ |
| 468 | static struct lock_class_key _key; \ |
| 469 | v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \ |
| 470 | &_key, \ |
| 471 | KBUILD_BASENAME ":" \ |
| 472 | __stringify(__LINE__) ":" \ |
| 473 | "(" #hdl ")->_lock"); \ |
| 474 | }) \ |
| 475 | ) |
| 476 | #else |
| 477 | #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \ |
| 478 | v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL) |
| 479 | #endif |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 480 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 481 | /** |
| 482 | * v4l2_ctrl_handler_free() - Free all controls owned by the handler and free |
| 483 | * the control list. |
| 484 | * @hdl: The control handler. |
| 485 | * |
| 486 | * Does nothing if @hdl == NULL. |
| 487 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 488 | void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl); |
| 489 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 490 | /** |
| 491 | * v4l2_ctrl_lock() - Helper function to lock the handler |
| 492 | * associated with the control. |
| 493 | * @ctrl: The control to lock. |
| 494 | */ |
Sakari Ailus | 605b384 | 2014-06-12 13:09:39 -0300 | [diff] [blame] | 495 | static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl) |
| 496 | { |
| 497 | mutex_lock(ctrl->handler->lock); |
| 498 | } |
| 499 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 500 | /** |
| 501 | * v4l2_ctrl_unlock() - Helper function to unlock the handler |
| 502 | * associated with the control. |
| 503 | * @ctrl: The control to unlock. |
| 504 | */ |
Sakari Ailus | 605b384 | 2014-06-12 13:09:39 -0300 | [diff] [blame] | 505 | static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl) |
| 506 | { |
| 507 | mutex_unlock(ctrl->handler->lock); |
| 508 | } |
| 509 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 510 | /** |
Sakari Ailus | cc0140e | 2017-05-26 05:21:37 -0300 | [diff] [blame] | 511 | * __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging |
| 512 | * to the handler to initialize the hardware to the current control values. The |
| 513 | * caller is responsible for acquiring the control handler mutex on behalf of |
| 514 | * __v4l2_ctrl_handler_setup(). |
| 515 | * @hdl: The control handler. |
| 516 | * |
| 517 | * Button controls will be skipped, as are read-only controls. |
| 518 | * |
| 519 | * If @hdl == NULL, then this just returns 0. |
| 520 | */ |
| 521 | int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl); |
| 522 | |
| 523 | /** |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 524 | * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging |
| 525 | * to the handler to initialize the hardware to the current control values. |
| 526 | * @hdl: The control handler. |
| 527 | * |
| 528 | * Button controls will be skipped, as are read-only controls. |
| 529 | * |
| 530 | * If @hdl == NULL, then this just returns 0. |
| 531 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 532 | int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl); |
| 533 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 534 | /** |
| 535 | * v4l2_ctrl_handler_log_status() - Log all controls owned by the handler. |
| 536 | * @hdl: The control handler. |
| 537 | * @prefix: The prefix to use when logging the control values. If the |
| 538 | * prefix does not end with a space, then ": " will be added |
| 539 | * after the prefix. If @prefix == NULL, then no prefix will be |
| 540 | * used. |
| 541 | * |
| 542 | * For use with VIDIOC_LOG_STATUS. |
| 543 | * |
| 544 | * Does nothing if @hdl == NULL. |
| 545 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 546 | void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl, |
| 547 | const char *prefix); |
| 548 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 549 | /** |
| 550 | * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2 |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 551 | * control. |
| 552 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 553 | * @hdl: The control handler. |
| 554 | * @cfg: The control's configuration data. |
| 555 | * @priv: The control's driver-specific private data. |
| 556 | * |
| 557 | * If the &v4l2_ctrl struct could not be allocated then NULL is returned |
| 558 | * and @hdl->error is set to the error code (if it wasn't set already). |
| 559 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 560 | struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 561 | const struct v4l2_ctrl_config *cfg, |
| 562 | void *priv); |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 563 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 564 | /** |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 565 | * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu |
| 566 | * control. |
| 567 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 568 | * @hdl: The control handler. |
| 569 | * @ops: The control ops. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 570 | * @id: The control ID. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 571 | * @min: The control's minimum value. |
| 572 | * @max: The control's maximum value. |
| 573 | * @step: The control's step value |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 574 | * @def: The control's default value. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 575 | * |
| 576 | * If the &v4l2_ctrl struct could not be allocated, or the control |
| 577 | * ID is not known, then NULL is returned and @hdl->error is set to the |
| 578 | * appropriate error code (if it wasn't set already). |
| 579 | * |
| 580 | * If @id refers to a menu control, then this function will return NULL. |
| 581 | * |
| 582 | * Use v4l2_ctrl_new_std_menu() when adding menu controls. |
| 583 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 584 | struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 585 | const struct v4l2_ctrl_ops *ops, |
| 586 | u32 id, s64 min, s64 max, u64 step, |
| 587 | s64 def); |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 588 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 589 | /** |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 590 | * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2 |
| 591 | * menu control. |
| 592 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 593 | * @hdl: The control handler. |
| 594 | * @ops: The control ops. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 595 | * @id: The control ID. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 596 | * @max: The control's maximum value. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 597 | * @mask: The control's skip mask for menu controls. This makes it |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 598 | * easy to skip menu items that are not valid. If bit X is set, |
| 599 | * then menu item X is skipped. Of course, this only works for |
| 600 | * menus with <= 64 menu items. There are no menus that come |
| 601 | * close to that number, so this is OK. Should we ever need more, |
| 602 | * then this will have to be extended to a bit array. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 603 | * @def: The control's default value. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 604 | * |
| 605 | * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value |
| 606 | * determines which menu items are to be skipped. |
| 607 | * |
| 608 | * If @id refers to a non-menu control, then this function will return NULL. |
| 609 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 610 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 611 | const struct v4l2_ctrl_ops *ops, |
| 612 | u32 id, u8 max, u64 mask, u8 def); |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 613 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 614 | /** |
| 615 | * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 616 | * with driver specific menu. |
| 617 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 618 | * @hdl: The control handler. |
| 619 | * @ops: The control ops. |
| 620 | * @id: The control ID. |
| 621 | * @max: The control's maximum value. |
| 622 | * @mask: The control's skip mask for menu controls. This makes it |
| 623 | * easy to skip menu items that are not valid. If bit X is set, |
| 624 | * then menu item X is skipped. Of course, this only works for |
| 625 | * menus with <= 64 menu items. There are no menus that come |
| 626 | * close to that number, so this is OK. Should we ever need more, |
| 627 | * then this will have to be extended to a bit array. |
| 628 | * @def: The control's default value. |
| 629 | * @qmenu: The new menu. |
| 630 | * |
| 631 | * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific |
| 632 | * menu of this control. |
| 633 | * |
| 634 | */ |
Lad, Prabhakar | 117a711 | 2012-09-18 15:54:38 -0300 | [diff] [blame] | 635 | struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 636 | const struct v4l2_ctrl_ops *ops, |
| 637 | u32 id, u8 max, |
| 638 | u64 mask, u8 def, |
| 639 | const char * const *qmenu); |
Lad, Prabhakar | 117a711 | 2012-09-18 15:54:38 -0300 | [diff] [blame] | 640 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 641 | /** |
| 642 | * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 643 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 644 | * @hdl: The control handler. |
| 645 | * @ops: The control ops. |
| 646 | * @id: The control ID. |
| 647 | * @max: The control's maximum value. |
| 648 | * @def: The control's default value. |
| 649 | * @qmenu_int: The control's menu entries. |
| 650 | * |
| 651 | * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly |
| 652 | * takes as an argument an array of integers determining the menu items. |
| 653 | * |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 654 | * If @id refers to a non-integer-menu control, then this function will |
| 655 | * return %NULL. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 656 | */ |
Sylwester Nawrocki | 515f328 | 2012-05-06 15:30:44 -0300 | [diff] [blame] | 657 | struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 658 | const struct v4l2_ctrl_ops *ops, |
| 659 | u32 id, u8 max, u8 def, |
| 660 | const s64 *qmenu_int); |
Sylwester Nawrocki | 515f328 | 2012-05-06 15:30:44 -0300 | [diff] [blame] | 661 | |
Mauro Carvalho Chehab | 2257e18 | 2016-08-29 17:26:15 -0300 | [diff] [blame] | 662 | /** |
| 663 | * typedef v4l2_ctrl_filter - Typedef to define the filter function to be |
| 664 | * used when adding a control handler. |
| 665 | * |
| 666 | * @ctrl: pointer to struct &v4l2_ctrl. |
| 667 | */ |
| 668 | |
Mauro Carvalho Chehab | 6d85d7d | 2016-07-22 10:58:03 -0300 | [diff] [blame] | 669 | typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl); |
| 670 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 671 | /** |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 672 | * v4l2_ctrl_add_handler() - Add all controls from handler @add to |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 673 | * handler @hdl. |
| 674 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 675 | * @hdl: The control handler. |
| 676 | * @add: The control handler whose controls you want to add to |
| 677 | * the @hdl control handler. |
| 678 | * @filter: This function will filter which controls should be added. |
Hans Verkuil | da1b1ae | 2018-05-21 04:54:36 -0400 | [diff] [blame] | 679 | * @from_other_dev: If true, then the controls in @add were defined in another |
| 680 | * device than @hdl. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 681 | * |
| 682 | * Does nothing if either of the two handlers is a NULL pointer. |
| 683 | * If @filter is NULL, then all controls are added. Otherwise only those |
| 684 | * controls for which @filter returns true will be added. |
| 685 | * In case of an error @hdl->error will be set to the error code (if it |
| 686 | * wasn't set already). |
| 687 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 688 | int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, |
Hans Verkuil | 34a6b7d | 2012-09-14 07:15:03 -0300 | [diff] [blame] | 689 | struct v4l2_ctrl_handler *add, |
Hans Verkuil | da1b1ae | 2018-05-21 04:54:36 -0400 | [diff] [blame] | 690 | v4l2_ctrl_filter filter, |
| 691 | bool from_other_dev); |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 692 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 693 | /** |
| 694 | * v4l2_ctrl_radio_filter() - Standard filter for radio controls. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 695 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 696 | * @ctrl: The control that is filtered. |
| 697 | * |
| 698 | * This will return true for any controls that are valid for radio device |
| 699 | * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM |
| 700 | * transmitter class controls. |
| 701 | * |
| 702 | * This function is to be used with v4l2_ctrl_add_handler(). |
| 703 | */ |
Hans Verkuil | 34a6b7d | 2012-09-14 07:15:03 -0300 | [diff] [blame] | 704 | bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl); |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 705 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 706 | /** |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 707 | * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging |
| 708 | * to that cluster. |
| 709 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 710 | * @ncontrols: The number of controls in this cluster. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 711 | * @controls: The cluster control array of size @ncontrols. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 712 | */ |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 713 | void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls); |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 714 | |
| 715 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 716 | /** |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 717 | * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging |
| 718 | * to that cluster and set it up for autofoo/foo-type handling. |
| 719 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 720 | * @ncontrols: The number of controls in this cluster. |
| 721 | * @controls: The cluster control array of size @ncontrols. The first control |
| 722 | * must be the 'auto' control (e.g. autogain, autoexposure, etc.) |
| 723 | * @manual_val: The value for the first control in the cluster that equals the |
| 724 | * manual setting. |
| 725 | * @set_volatile: If true, then all controls except the first auto control will |
| 726 | * be volatile. |
| 727 | * |
| 728 | * Use for control groups where one control selects some automatic feature and |
| 729 | * the other controls are only active whenever the automatic feature is turned |
| 730 | * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs |
| 731 | * red and blue balance, etc. |
| 732 | * |
| 733 | * The behavior of such controls is as follows: |
| 734 | * |
| 735 | * When the autofoo control is set to automatic, then any manual controls |
| 736 | * are set to inactive and any reads will call g_volatile_ctrl (if the control |
| 737 | * was marked volatile). |
| 738 | * |
| 739 | * When the autofoo control is set to manual, then any manual controls will |
| 740 | * be marked active, and any reads will just return the current value without |
| 741 | * going through g_volatile_ctrl. |
| 742 | * |
Mauro Carvalho Chehab | 2257e18 | 2016-08-29 17:26:15 -0300 | [diff] [blame] | 743 | * In addition, this function will set the %V4L2_CTRL_FLAG_UPDATE flag |
| 744 | * on the autofoo control and %V4L2_CTRL_FLAG_INACTIVE on the foo control(s) |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 745 | * if autofoo is in auto mode. |
| 746 | */ |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 747 | void v4l2_ctrl_auto_cluster(unsigned int ncontrols, |
| 748 | struct v4l2_ctrl **controls, |
| 749 | u8 manual_val, bool set_volatile); |
Hans Verkuil | 72d877c | 2011-06-10 05:44:36 -0300 | [diff] [blame] | 750 | |
| 751 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 752 | /** |
| 753 | * v4l2_ctrl_find() - Find a control with the given ID. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 754 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 755 | * @hdl: The control handler. |
| 756 | * @id: The control ID to find. |
| 757 | * |
| 758 | * If @hdl == NULL this will return NULL as well. Will lock the handler so |
| 759 | * do not use from inside &v4l2_ctrl_ops. |
| 760 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 761 | struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id); |
| 762 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 763 | /** |
| 764 | * v4l2_ctrl_activate() - Make the control active or inactive. |
| 765 | * @ctrl: The control to (de)activate. |
| 766 | * @active: True if the control should become active. |
| 767 | * |
| 768 | * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically. |
| 769 | * Does nothing if @ctrl == NULL. |
| 770 | * This will usually be called from within the s_ctrl op. |
| 771 | * The V4L2_EVENT_CTRL event will be generated afterwards. |
| 772 | * |
| 773 | * This function assumes that the control handler is locked. |
| 774 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 775 | void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); |
| 776 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 777 | /** |
Sakari Ailus | 7a9b109 | 2018-07-19 07:11:40 -0400 | [diff] [blame] | 778 | * __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab. |
| 779 | * |
| 780 | * @ctrl: The control to (de)activate. |
| 781 | * @grabbed: True if the control should become grabbed. |
| 782 | * |
| 783 | * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically. |
| 784 | * Does nothing if @ctrl == NULL. |
| 785 | * The V4L2_EVENT_CTRL event will be generated afterwards. |
| 786 | * This will usually be called when starting or stopping streaming in the |
| 787 | * driver. |
| 788 | * |
| 789 | * This function assumes that the control handler is locked by the caller. |
| 790 | */ |
| 791 | void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); |
| 792 | |
| 793 | /** |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 794 | * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 795 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 796 | * @ctrl: The control to (de)activate. |
| 797 | * @grabbed: True if the control should become grabbed. |
| 798 | * |
| 799 | * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically. |
| 800 | * Does nothing if @ctrl == NULL. |
| 801 | * The V4L2_EVENT_CTRL event will be generated afterwards. |
| 802 | * This will usually be called when starting or stopping streaming in the |
| 803 | * driver. |
| 804 | * |
| 805 | * This function assumes that the control handler is not locked and will |
| 806 | * take the lock itself. |
| 807 | */ |
Sakari Ailus | 7a9b109 | 2018-07-19 07:11:40 -0400 | [diff] [blame] | 808 | static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) |
| 809 | { |
| 810 | if (!ctrl) |
| 811 | return; |
| 812 | |
| 813 | v4l2_ctrl_lock(ctrl); |
| 814 | __v4l2_ctrl_grab(ctrl, grabbed); |
| 815 | v4l2_ctrl_unlock(ctrl); |
| 816 | } |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 817 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 818 | /** |
| 819 | *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() |
| 820 | * |
| 821 | * @ctrl: The control to update. |
| 822 | * @min: The control's minimum value. |
| 823 | * @max: The control's maximum value. |
| 824 | * @step: The control's step value |
| 825 | * @def: The control's default value. |
| 826 | * |
| 827 | * Update the range of a control on the fly. This works for control types |
| 828 | * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the |
| 829 | * @step value is interpreted as a menu_skip_mask. |
| 830 | * |
| 831 | * An error is returned if one of the range arguments is invalid for this |
| 832 | * control type. |
| 833 | * |
Hans Verkuil | 97eee23 | 2018-02-03 08:18:14 -0500 | [diff] [blame] | 834 | * The caller is responsible for acquiring the control handler mutex on behalf |
| 835 | * of __v4l2_ctrl_modify_range(). |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 836 | */ |
Sakari Ailus | 5a57392 | 2014-06-12 13:09:40 -0300 | [diff] [blame] | 837 | int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, |
| 838 | s64 min, s64 max, u64 step, s64 def); |
| 839 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 840 | /** |
| 841 | * v4l2_ctrl_modify_range() - Update the range of a control. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 842 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 843 | * @ctrl: The control to update. |
| 844 | * @min: The control's minimum value. |
| 845 | * @max: The control's maximum value. |
| 846 | * @step: The control's step value |
| 847 | * @def: The control's default value. |
| 848 | * |
| 849 | * Update the range of a control on the fly. This works for control types |
| 850 | * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the |
| 851 | * @step value is interpreted as a menu_skip_mask. |
| 852 | * |
| 853 | * An error is returned if one of the range arguments is invalid for this |
| 854 | * control type. |
| 855 | * |
| 856 | * This function assumes that the control handler is not locked and will |
| 857 | * take the lock itself. |
| 858 | */ |
Sakari Ailus | 5a57392 | 2014-06-12 13:09:40 -0300 | [diff] [blame] | 859 | static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl, |
| 860 | s64 min, s64 max, u64 step, s64 def) |
| 861 | { |
| 862 | int rval; |
| 863 | |
| 864 | v4l2_ctrl_lock(ctrl); |
| 865 | rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def); |
| 866 | v4l2_ctrl_unlock(ctrl); |
| 867 | |
| 868 | return rval; |
| 869 | } |
Sylwester Nawrocki | 2ccbe77 | 2013-01-19 15:51:55 -0300 | [diff] [blame] | 870 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 871 | /** |
| 872 | * v4l2_ctrl_notify() - Function to set a notify callback for a control. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 873 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 874 | * @ctrl: The control. |
| 875 | * @notify: The callback function. |
| 876 | * @priv: The callback private handle, passed as argument to the callback. |
| 877 | * |
| 878 | * This function sets a callback function for the control. If @ctrl is NULL, |
| 879 | * then it will do nothing. If @notify is NULL, then the notify callback will |
| 880 | * be removed. |
| 881 | * |
| 882 | * There can be only one notify. If another already exists, then a WARN_ON |
| 883 | * will be issued and the function will do nothing. |
| 884 | */ |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 885 | void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, |
| 886 | void *priv); |
Hans Verkuil | 8ac7a94 | 2012-09-07 04:46:39 -0300 | [diff] [blame] | 887 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 888 | /** |
| 889 | * v4l2_ctrl_get_name() - Get the name of the control |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 890 | * |
Hans Verkuil | 79fbc20 | 2014-11-23 09:39:54 -0300 | [diff] [blame] | 891 | * @id: The control ID. |
| 892 | * |
| 893 | * This function returns the name of the given control ID or NULL if it isn't |
| 894 | * a known control. |
| 895 | */ |
| 896 | const char *v4l2_ctrl_get_name(u32 id); |
| 897 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 898 | /** |
| 899 | * v4l2_ctrl_get_menu() - Get the menu string array of the control |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 900 | * |
Hans Verkuil | 79fbc20 | 2014-11-23 09:39:54 -0300 | [diff] [blame] | 901 | * @id: The control ID. |
| 902 | * |
| 903 | * This function returns the NULL-terminated menu string array name of the |
| 904 | * given control ID or NULL if it isn't a known menu control. |
| 905 | */ |
| 906 | const char * const *v4l2_ctrl_get_menu(u32 id); |
| 907 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 908 | /** |
| 909 | * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 910 | * |
Hans Verkuil | 79fbc20 | 2014-11-23 09:39:54 -0300 | [diff] [blame] | 911 | * @id: The control ID. |
| 912 | * @len: The size of the integer array. |
| 913 | * |
| 914 | * This function returns the integer array of the given control ID or NULL if it |
| 915 | * if it isn't a known integer menu control. |
| 916 | */ |
| 917 | const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len); |
| 918 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 919 | /** |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 920 | * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from |
| 921 | * within a driver. |
| 922 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 923 | * @ctrl: The control. |
| 924 | * |
| 925 | * This returns the control's value safely by going through the control |
| 926 | * framework. This function will lock the control's handler, so it cannot be |
| 927 | * used from within the &v4l2_ctrl_ops functions. |
| 928 | * |
| 929 | * This function is for integer type controls only. |
| 930 | */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 931 | s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); |
| 932 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 933 | /** |
| 934 | * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl(). |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 935 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 936 | * @ctrl: The control. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 937 | * @val: TheControls name new value. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 938 | * |
Hans Verkuil | 904aef0 | 2016-06-15 09:57:48 -0300 | [diff] [blame] | 939 | * This sets the control's new value safely by going through the control |
| 940 | * framework. This function assumes the control's handler is already locked, |
| 941 | * allowing it to be used from within the &v4l2_ctrl_ops functions. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 942 | * |
| 943 | * This function is for integer type controls only. |
| 944 | */ |
Sakari Ailus | 0c4348a | 2014-06-12 13:09:42 -0300 | [diff] [blame] | 945 | int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 946 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 947 | /** |
| 948 | * v4l2_ctrl_s_ctrl() - Helper function to set the control's value from |
| 949 | * within a driver. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 950 | * @ctrl: The control. |
| 951 | * @val: The new value. |
| 952 | * |
Hans Verkuil | 904aef0 | 2016-06-15 09:57:48 -0300 | [diff] [blame] | 953 | * This sets the control's new value safely by going through the control |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 954 | * framework. This function will lock the control's handler, so it cannot be |
| 955 | * used from within the &v4l2_ctrl_ops functions. |
| 956 | * |
| 957 | * This function is for integer type controls only. |
| 958 | */ |
Sakari Ailus | 0c4348a | 2014-06-12 13:09:42 -0300 | [diff] [blame] | 959 | static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) |
| 960 | { |
| 961 | int rval; |
| 962 | |
| 963 | v4l2_ctrl_lock(ctrl); |
| 964 | rval = __v4l2_ctrl_s_ctrl(ctrl, val); |
| 965 | v4l2_ctrl_unlock(ctrl); |
| 966 | |
| 967 | return rval; |
| 968 | } |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 969 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 970 | /** |
| 971 | * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value |
| 972 | * from within a driver. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 973 | * |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 974 | * @ctrl: The control. |
| 975 | * |
| 976 | * This returns the control's value safely by going through the control |
| 977 | * framework. This function will lock the control's handler, so it cannot be |
| 978 | * used from within the &v4l2_ctrl_ops functions. |
| 979 | * |
| 980 | * This function is for 64-bit integer type controls only. |
| 981 | */ |
Laurent Pinchart | 03d5285 | 2012-07-23 09:15:21 -0300 | [diff] [blame] | 982 | s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl); |
| 983 | |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 984 | /** |
| 985 | * __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64(). |
| 986 | * |
| 987 | * @ctrl: The control. |
| 988 | * @val: The new value. |
| 989 | * |
Hans Verkuil | 904aef0 | 2016-06-15 09:57:48 -0300 | [diff] [blame] | 990 | * This sets the control's new value safely by going through the control |
| 991 | * framework. This function assumes the control's handler is already locked, |
| 992 | * allowing it to be used from within the &v4l2_ctrl_ops functions. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 993 | * |
| 994 | * This function is for 64-bit integer type controls only. |
| 995 | */ |
Sakari Ailus | 0c4348a | 2014-06-12 13:09:42 -0300 | [diff] [blame] | 996 | int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val); |
| 997 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 998 | /** |
| 999 | * v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 1000 | * from within a driver. |
| 1001 | * |
| 1002 | * @ctrl: The control. |
| 1003 | * @val: The new value. |
| 1004 | * |
Hans Verkuil | 904aef0 | 2016-06-15 09:57:48 -0300 | [diff] [blame] | 1005 | * This sets the control's new value safely by going through the control |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 1006 | * framework. This function will lock the control's handler, so it cannot be |
| 1007 | * used from within the &v4l2_ctrl_ops functions. |
| 1008 | * |
| 1009 | * This function is for 64-bit integer type controls only. |
| 1010 | */ |
Sakari Ailus | 0c4348a | 2014-06-12 13:09:42 -0300 | [diff] [blame] | 1011 | static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) |
| 1012 | { |
| 1013 | int rval; |
| 1014 | |
| 1015 | v4l2_ctrl_lock(ctrl); |
| 1016 | rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val); |
| 1017 | v4l2_ctrl_unlock(ctrl); |
| 1018 | |
| 1019 | return rval; |
| 1020 | } |
Laurent Pinchart | 03d5285 | 2012-07-23 09:15:21 -0300 | [diff] [blame] | 1021 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1022 | /** |
| 1023 | * __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string(). |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 1024 | * |
| 1025 | * @ctrl: The control. |
| 1026 | * @s: The new string. |
| 1027 | * |
Hans Verkuil | 904aef0 | 2016-06-15 09:57:48 -0300 | [diff] [blame] | 1028 | * This sets the control's new string safely by going through the control |
| 1029 | * framework. This function assumes the control's handler is already locked, |
| 1030 | * allowing it to be used from within the &v4l2_ctrl_ops functions. |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 1031 | * |
| 1032 | * This function is for string type controls only. |
| 1033 | */ |
Hans Verkuil | 5d0360a | 2014-07-21 10:45:42 -0300 | [diff] [blame] | 1034 | int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s); |
| 1035 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1036 | /** |
| 1037 | * v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 1038 | * from within a driver. |
| 1039 | * |
| 1040 | * @ctrl: The control. |
| 1041 | * @s: The new string. |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1042 | *Controls name |
Hans Verkuil | 904aef0 | 2016-06-15 09:57:48 -0300 | [diff] [blame] | 1043 | * This sets the control's new string safely by going through the control |
Mauro Carvalho Chehab | 8c2721d | 2015-08-22 08:03:49 -0300 | [diff] [blame] | 1044 | * framework. This function will lock the control's handler, so it cannot be |
| 1045 | * used from within the &v4l2_ctrl_ops functions. |
| 1046 | * |
| 1047 | * This function is for string type controls only. |
| 1048 | */ |
Hans Verkuil | 5d0360a | 2014-07-21 10:45:42 -0300 | [diff] [blame] | 1049 | static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s) |
| 1050 | { |
| 1051 | int rval; |
| 1052 | |
| 1053 | v4l2_ctrl_lock(ctrl); |
| 1054 | rval = __v4l2_ctrl_s_ctrl_string(ctrl, s); |
| 1055 | v4l2_ctrl_unlock(ctrl); |
| 1056 | |
| 1057 | return rval; |
| 1058 | } |
| 1059 | |
Hans Verkuil | ce72757 | 2011-06-10 05:56:39 -0300 | [diff] [blame] | 1060 | /* Internal helper functions that deal with control events. */ |
Hans de Goede | 3e366149 | 2012-04-08 12:59:47 -0300 | [diff] [blame] | 1061 | extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1062 | |
| 1063 | /** |
| 1064 | * v4l2_ctrl_replace - Function to be used as a callback to |
| 1065 | * &struct v4l2_subscribed_event_ops replace\(\) |
| 1066 | * |
Mauro Carvalho Chehab | f8441a4 | 2016-08-29 19:29:58 -0300 | [diff] [blame] | 1067 | * @old: pointer to struct &v4l2_event with the reported |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1068 | * event; |
Mauro Carvalho Chehab | f8441a4 | 2016-08-29 19:29:58 -0300 | [diff] [blame] | 1069 | * @new: pointer to struct &v4l2_event with the modified |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1070 | * event; |
| 1071 | */ |
Hans de Goede | 3e366149 | 2012-04-08 12:59:47 -0300 | [diff] [blame] | 1072 | void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new); |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1073 | |
| 1074 | /** |
| 1075 | * v4l2_ctrl_merge - Function to be used as a callback to |
| 1076 | * &struct v4l2_subscribed_event_ops merge(\) |
| 1077 | * |
Mauro Carvalho Chehab | f8441a4 | 2016-08-29 19:29:58 -0300 | [diff] [blame] | 1078 | * @old: pointer to struct &v4l2_event with the reported |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1079 | * event; |
Mauro Carvalho Chehab | f8441a4 | 2016-08-29 19:29:58 -0300 | [diff] [blame] | 1080 | * @new: pointer to struct &v4l2_event with the merged |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1081 | * event; |
| 1082 | */ |
Hans de Goede | 3e366149 | 2012-04-08 12:59:47 -0300 | [diff] [blame] | 1083 | void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new); |
Hans Verkuil | 6e23939 | 2011-06-07 11:13:44 -0300 | [diff] [blame] | 1084 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1085 | /** |
| 1086 | * v4l2_ctrl_log_status - helper function to implement %VIDIOC_LOG_STATUS ioctl |
| 1087 | * |
| 1088 | * @file: pointer to struct file |
| 1089 | * @fh: unused. Kept just to be compatible to the arguments expected by |
| 1090 | * &struct v4l2_ioctl_ops.vidioc_log_status. |
| 1091 | * |
| 1092 | * Can be used as a vidioc_log_status function that just dumps all controls |
| 1093 | * associated with the filehandle. |
| 1094 | */ |
Hans Verkuil | e2ecb25 | 2012-02-02 08:20:53 -0300 | [diff] [blame] | 1095 | int v4l2_ctrl_log_status(struct file *file, void *fh); |
| 1096 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1097 | /** |
| 1098 | * v4l2_ctrl_subscribe_event - Subscribes to an event |
| 1099 | * |
| 1100 | * |
| 1101 | * @fh: pointer to struct v4l2_fh |
| 1102 | * @sub: pointer to &struct v4l2_event_subscription |
| 1103 | * |
| 1104 | * Can be used as a vidioc_subscribe_event function that just subscribes |
| 1105 | * control events. |
| 1106 | */ |
Hans Verkuil | a26243b | 2012-01-27 16:18:42 -0300 | [diff] [blame] | 1107 | int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, |
Hans Verkuil | 85f5fe3 | 2012-09-04 11:46:09 -0300 | [diff] [blame] | 1108 | const struct v4l2_event_subscription *sub); |
Hans Verkuil | a26243b | 2012-01-27 16:18:42 -0300 | [diff] [blame] | 1109 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1110 | /** |
| 1111 | * v4l2_ctrl_poll - function to be used as a callback to the poll() |
| 1112 | * That just polls for control events. |
| 1113 | * |
| 1114 | * @file: pointer to struct file |
| 1115 | * @wait: pointer to struct poll_table_struct |
| 1116 | */ |
Al Viro | c23e0cb | 2017-07-03 03:02:56 -0400 | [diff] [blame] | 1117 | __poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait); |
Hans Verkuil | a26243b | 2012-01-27 16:18:42 -0300 | [diff] [blame] | 1118 | |
Hans Verkuil | 6fa6f83 | 2018-05-21 04:54:40 -0400 | [diff] [blame] | 1119 | /** |
| 1120 | * v4l2_ctrl_request_setup - helper function to apply control values in a request |
| 1121 | * |
| 1122 | * @req: The request |
| 1123 | * @parent: The parent control handler ('priv' in media_request_object_find()) |
| 1124 | * |
| 1125 | * This is a helper function to call the control handler's s_ctrl callback with |
| 1126 | * the control values contained in the request. Do note that this approach of |
| 1127 | * applying control values in a request is only applicable to memory-to-memory |
| 1128 | * devices. |
| 1129 | */ |
| 1130 | void v4l2_ctrl_request_setup(struct media_request *req, |
| 1131 | struct v4l2_ctrl_handler *parent); |
| 1132 | |
| 1133 | /** |
| 1134 | * v4l2_ctrl_request_complete - Complete a control handler request object |
| 1135 | * |
| 1136 | * @req: The request |
| 1137 | * @parent: The parent control handler ('priv' in media_request_object_find()) |
| 1138 | * |
| 1139 | * This function is to be called on each control handler that may have had a |
| 1140 | * request object associated with it, i.e. control handlers of a driver that |
| 1141 | * supports requests. |
| 1142 | * |
| 1143 | * The function first obtains the values of any volatile controls in the control |
| 1144 | * handler and attach them to the request. Then, the function completes the |
| 1145 | * request object. |
| 1146 | */ |
| 1147 | void v4l2_ctrl_request_complete(struct media_request *req, |
Hans Verkuil | 5f611d7 | 2018-07-10 04:00:53 -0400 | [diff] [blame] | 1148 | struct v4l2_ctrl_handler *parent); |
| 1149 | |
| 1150 | /** |
| 1151 | * v4l2_ctrl_request_hdl_find - Find the control handler in the request |
| 1152 | * |
| 1153 | * @req: The request |
| 1154 | * @parent: The parent control handler ('priv' in media_request_object_find()) |
| 1155 | * |
| 1156 | * This function finds the control handler in the request. It may return |
| 1157 | * NULL if not found. When done, you must call v4l2_ctrl_request_put_hdl() |
| 1158 | * with the returned handler pointer. |
| 1159 | * |
| 1160 | * If the request is not in state VALIDATING or QUEUED, then this function |
| 1161 | * will always return NULL. |
| 1162 | * |
| 1163 | * Note that in state VALIDATING the req_queue_mutex is held, so |
| 1164 | * no objects can be added or deleted from the request. |
| 1165 | * |
| 1166 | * In state QUEUED it is the driver that will have to ensure this. |
| 1167 | */ |
| 1168 | struct v4l2_ctrl_handler *v4l2_ctrl_request_hdl_find(struct media_request *req, |
| 1169 | struct v4l2_ctrl_handler *parent); |
| 1170 | |
| 1171 | /** |
| 1172 | * v4l2_ctrl_request_hdl_put - Put the control handler |
| 1173 | * |
| 1174 | * @hdl: Put this control handler |
| 1175 | * |
| 1176 | * This function released the control handler previously obtained from' |
| 1177 | * v4l2_ctrl_request_hdl_find(). |
| 1178 | */ |
| 1179 | static inline void v4l2_ctrl_request_hdl_put(struct v4l2_ctrl_handler *hdl) |
| 1180 | { |
| 1181 | if (hdl) |
| 1182 | media_request_object_put(&hdl->req_obj); |
| 1183 | } |
| 1184 | |
| 1185 | /** |
| 1186 | * v4l2_ctrl_request_ctrl_find() - Find a control with the given ID. |
| 1187 | * |
| 1188 | * @hdl: The control handler from the request. |
| 1189 | * @id: The ID of the control to find. |
| 1190 | * |
| 1191 | * This function returns a pointer to the control if this control is |
| 1192 | * part of the request or NULL otherwise. |
| 1193 | */ |
| 1194 | struct v4l2_ctrl * |
| 1195 | v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id); |
Hans Verkuil | 6fa6f83 | 2018-05-21 04:54:40 -0400 | [diff] [blame] | 1196 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1197 | /* Helpers for ioctl_ops */ |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 1198 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1199 | /** |
| 1200 | * v4l2_queryctrl - Helper function to implement |
| 1201 | * :ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl |
| 1202 | * |
| 1203 | * @hdl: pointer to &struct v4l2_ctrl_handler |
| 1204 | * @qc: pointer to &struct v4l2_queryctrl |
| 1205 | * |
| 1206 | * If hdl == NULL then they will all return -EINVAL. |
| 1207 | */ |
| 1208 | int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); |
| 1209 | |
| 1210 | /** |
| 1211 | * v4l2_query_ext_ctrl - Helper function to implement |
| 1212 | * :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl |
| 1213 | * |
| 1214 | * @hdl: pointer to &struct v4l2_ctrl_handler |
| 1215 | * @qc: pointer to &struct v4l2_query_ext_ctrl |
| 1216 | * |
| 1217 | * If hdl == NULL then they will all return -EINVAL. |
| 1218 | */ |
| 1219 | int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, |
| 1220 | struct v4l2_query_ext_ctrl *qc); |
| 1221 | |
| 1222 | /** |
| 1223 | * v4l2_querymenu - Helper function to implement |
| 1224 | * :ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl |
| 1225 | * |
| 1226 | * @hdl: pointer to &struct v4l2_ctrl_handler |
| 1227 | * @qm: pointer to &struct v4l2_querymenu |
| 1228 | * |
| 1229 | * If hdl == NULL then they will all return -EINVAL. |
| 1230 | */ |
| 1231 | int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm); |
| 1232 | |
| 1233 | /** |
| 1234 | * v4l2_g_ctrl - Helper function to implement |
| 1235 | * :ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl |
| 1236 | * |
| 1237 | * @hdl: pointer to &struct v4l2_ctrl_handler |
| 1238 | * @ctrl: pointer to &struct v4l2_control |
| 1239 | * |
| 1240 | * If hdl == NULL then they will all return -EINVAL. |
| 1241 | */ |
| 1242 | int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl); |
| 1243 | |
| 1244 | /** |
| 1245 | * v4l2_s_ctrl - Helper function to implement |
| 1246 | * :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl |
| 1247 | * |
| 1248 | * @fh: pointer to &struct v4l2_fh |
| 1249 | * @hdl: pointer to &struct v4l2_ctrl_handler |
| 1250 | * |
| 1251 | * @ctrl: pointer to &struct v4l2_control |
| 1252 | * |
| 1253 | * If hdl == NULL then they will all return -EINVAL. |
| 1254 | */ |
| 1255 | int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, |
| 1256 | struct v4l2_control *ctrl); |
| 1257 | |
| 1258 | /** |
| 1259 | * v4l2_g_ext_ctrls - Helper function to implement |
| 1260 | * :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl |
| 1261 | * |
| 1262 | * @hdl: pointer to &struct v4l2_ctrl_handler |
Hans Verkuil | c41e9cf | 2018-05-21 04:54:42 -0400 | [diff] [blame] | 1263 | * @mdev: pointer to &struct media_device |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1264 | * @c: pointer to &struct v4l2_ext_controls |
| 1265 | * |
| 1266 | * If hdl == NULL then they will all return -EINVAL. |
| 1267 | */ |
Hans Verkuil | c41e9cf | 2018-05-21 04:54:42 -0400 | [diff] [blame] | 1268 | int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct media_device *mdev, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1269 | struct v4l2_ext_controls *c); |
| 1270 | |
| 1271 | /** |
| 1272 | * v4l2_try_ext_ctrls - Helper function to implement |
| 1273 | * :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl |
| 1274 | * |
| 1275 | * @hdl: pointer to &struct v4l2_ctrl_handler |
Hans Verkuil | c41e9cf | 2018-05-21 04:54:42 -0400 | [diff] [blame] | 1276 | * @mdev: pointer to &struct media_device |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1277 | * @c: pointer to &struct v4l2_ext_controls |
| 1278 | * |
| 1279 | * If hdl == NULL then they will all return -EINVAL. |
| 1280 | */ |
| 1281 | int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, |
Hans Verkuil | c41e9cf | 2018-05-21 04:54:42 -0400 | [diff] [blame] | 1282 | struct media_device *mdev, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1283 | struct v4l2_ext_controls *c); |
| 1284 | |
| 1285 | /** |
| 1286 | * v4l2_s_ext_ctrls - Helper function to implement |
| 1287 | * :ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl |
| 1288 | * |
| 1289 | * @fh: pointer to &struct v4l2_fh |
| 1290 | * @hdl: pointer to &struct v4l2_ctrl_handler |
Hans Verkuil | c41e9cf | 2018-05-21 04:54:42 -0400 | [diff] [blame] | 1291 | * @mdev: pointer to &struct media_device |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1292 | * @c: pointer to &struct v4l2_ext_controls |
| 1293 | * |
| 1294 | * If hdl == NULL then they will all return -EINVAL. |
| 1295 | */ |
| 1296 | int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, |
Hans Verkuil | c41e9cf | 2018-05-21 04:54:42 -0400 | [diff] [blame] | 1297 | struct media_device *mdev, |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1298 | struct v4l2_ext_controls *c); |
| 1299 | |
| 1300 | /** |
| 1301 | * v4l2_ctrl_subdev_subscribe_event - Helper function to implement |
Mauro Carvalho Chehab | 4a3fad7 | 2018-01-04 06:47:28 -0500 | [diff] [blame] | 1302 | * as a &struct v4l2_subdev_core_ops subscribe_event function |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1303 | * that just subscribes control events. |
| 1304 | * |
| 1305 | * @sd: pointer to &struct v4l2_subdev |
| 1306 | * @fh: pointer to &struct v4l2_fh |
| 1307 | * @sub: pointer to &struct v4l2_event_subscription |
| 1308 | */ |
Sylwester Nawrocki | 22fa427 | 2013-01-22 19:00:23 -0300 | [diff] [blame] | 1309 | int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, |
| 1310 | struct v4l2_event_subscription *sub); |
| 1311 | |
Mauro Carvalho Chehab | 8ec4bee | 2016-07-22 13:57:29 -0300 | [diff] [blame] | 1312 | /** |
| 1313 | * v4l2_ctrl_subdev_log_status - Log all controls owned by subdev's control |
| 1314 | * handler. |
| 1315 | * |
| 1316 | * @sd: pointer to &struct v4l2_subdev |
| 1317 | */ |
Sylwester Nawrocki | ffa9b9f | 2013-01-22 19:01:02 -0300 | [diff] [blame] | 1318 | int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd); |
| 1319 | |
Hans Verkuil | 0996517 | 2010-08-01 14:32:42 -0300 | [diff] [blame] | 1320 | #endif |