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