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