blob: ed784e98c293931dafb09267107ce65e6e6811ae [file] [log] [blame]
Hans Verkuil09965172010-08-01 14:32:42 -03001/*
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03002 * V4L2 controls support header.
3 *
4 * Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Hans Verkuil09965172010-08-01 14:32:42 -030015 */
16
17#ifndef _V4L2_CTRLS_H
18#define _V4L2_CTRLS_H
19
20#include <linux/list.h>
Andrzej Hajdaa19dec62013-06-28 05:44:22 -030021#include <linux/mutex.h>
Laurent Pinchart01c40c02010-11-19 11:20:06 -030022#include <linux/videodev2.h>
Hans Verkuil52beedd2018-05-21 04:54:37 -040023#include <media/media-request.h>
Hans Verkuil09965172010-08-01 14:32:42 -030024
25/* forward references */
Laurent Pinchart528f0f72012-04-23 08:20:35 -030026struct file;
Hans Verkuil09965172010-08-01 14:32:42 -030027struct v4l2_ctrl_handler;
Hans Verkuileb5b16e2011-06-14 10:04:06 -030028struct v4l2_ctrl_helper;
Hans Verkuil09965172010-08-01 14:32:42 -030029struct v4l2_ctrl;
30struct video_device;
31struct v4l2_subdev;
Hans Verkuil77068d32011-06-13 18:55:58 -030032struct v4l2_subscribed_event;
Hans Verkuil6e239392011-06-07 11:13:44 -030033struct v4l2_fh;
Hans Verkuila26243b2012-01-27 16:18:42 -030034struct poll_table_struct;
Hans Verkuil09965172010-08-01 14:32:42 -030035
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030036/**
37 * union v4l2_ctrl_ptr - A pointer to a control value.
Hans Verkuil01760772014-04-27 03:22:17 -030038 * @p_s32: Pointer to a 32-bit signed value.
39 * @p_s64: Pointer to a 64-bit signed value.
Hans Verkuildda4a4d2014-06-10 07:30:04 -030040 * @p_u8: Pointer to a 8-bit unsigned value.
41 * @p_u16: Pointer to a 16-bit unsigned value.
Hans Verkuil811c5082014-07-21 10:45:37 -030042 * @p_u32: Pointer to a 32-bit unsigned value.
Hans Verkuil01760772014-04-27 03:22:17 -030043 * @p_char: Pointer to a string.
44 * @p: Pointer to a compound value.
45 */
46union v4l2_ctrl_ptr {
47 s32 *p_s32;
48 s64 *p_s64;
Hans Verkuildda4a4d2014-06-10 07:30:04 -030049 u8 *p_u8;
50 u16 *p_u16;
Hans Verkuil811c5082014-07-21 10:45:37 -030051 u32 *p_u32;
Hans Verkuil01760772014-04-27 03:22:17 -030052 char *p_char;
53 void *p;
54};
55
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030056/**
57 * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -030058 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030059 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
60 * for volatile (and usually read-only) controls such as a control
61 * that returns the current signal strength which changes
62 * continuously.
63 * If not set, then the currently cached value will be returned.
64 * @try_ctrl: Test whether the control's value is valid. Only relevant when
65 * the usual min/max/step checks are not sufficient.
66 * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
67 * ctrl->handler->lock is held when these ops are called, so no
68 * one else can access controls owned by that handler.
69 */
Hans Verkuil09965172010-08-01 14:32:42 -030070struct v4l2_ctrl_ops {
71 int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
72 int (*try_ctrl)(struct v4l2_ctrl *ctrl);
73 int (*s_ctrl)(struct v4l2_ctrl *ctrl);
74};
75
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030076/**
77 * struct v4l2_ctrl_type_ops - The control type operations that the driver
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -030078 * has to provide.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030079 *
80 * @equal: return true if both values are equal.
81 * @init: initialize the value.
82 * @log: log the value.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -030083 * @validate: validate the value. Return 0 on success and a negative value
84 * otherwise.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -030085 */
Hans Verkuil01760772014-04-27 03:22:17 -030086struct v4l2_ctrl_type_ops {
Hans Verkuil998e7652014-06-10 07:55:00 -030087 bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx,
Hans Verkuil01760772014-04-27 03:22:17 -030088 union v4l2_ctrl_ptr ptr1,
89 union v4l2_ctrl_ptr ptr2);
Hans Verkuil998e7652014-06-10 07:55:00 -030090 void (*init)(const struct v4l2_ctrl *ctrl, u32 idx,
Hans Verkuil01760772014-04-27 03:22:17 -030091 union v4l2_ctrl_ptr ptr);
92 void (*log)(const struct v4l2_ctrl *ctrl);
Hans Verkuil998e7652014-06-10 07:55:00 -030093 int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx,
Hans Verkuil01760772014-04-27 03:22:17 -030094 union v4l2_ctrl_ptr ptr);
95};
96
Mauro Carvalho Chehab2257e182016-08-29 17:26:15 -030097/**
98 * typedef v4l2_ctrl_notify_fnc - typedef for a notify argument with a function
99 * that should be called when a control value has changed.
100 *
101 * @ctrl: pointer to struct &v4l2_ctrl
102 * @priv: control private data
103 *
104 * This typedef definition is used as an argument to v4l2_ctrl_notify()
105 * and as an argument at struct &v4l2_ctrl_handler.
106 */
Hans Verkuil8ac7a942012-09-07 04:46:39 -0300107typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
108
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300109/**
110 * struct v4l2_ctrl - The control structure.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300111 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300112 * @node: The list node.
113 * @ev_subs: The list of control event subscriptions.
114 * @handler: The handler that owns the control.
115 * @cluster: Point to start of cluster array.
116 * @ncontrols: Number of controls in cluster array.
117 * @done: Internal flag: set for each processed control.
118 * @is_new: Set when the user specified a new value for this control. It
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300119 * is also set when called from v4l2_ctrl_handler_setup(). Drivers
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300120 * should never set this flag.
121 * @has_changed: Set when the current value differs from the new value. Drivers
122 * should never use this flag.
123 * @is_private: If set, then this control is private to its handler and it
124 * will not be added to any other handlers. Drivers can set
125 * this flag.
126 * @is_auto: If set, then this control selects whether the other cluster
127 * members are in 'automatic' mode or 'manual' mode. This is
128 * used for autogain/gain type clusters. Drivers should never
129 * set this flag directly.
130 * @is_int: If set, then this control has a simple integer value (i.e. it
131 * uses ctrl->val).
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300132 * @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING.
133 * @is_ptr: If set, then this control is an array and/or has type >=
134 * %V4L2_CTRL_COMPOUND_TYPES
135 * and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300136 * v4l2_ext_control uses field p to point to the data.
137 * @is_array: If set, then this control contains an N-dimensional array.
138 * @has_volatiles: If set, then one or more members of the cluster are volatile.
139 * Drivers should never touch this flag.
140 * @call_notify: If set, then call the handler's notify function whenever the
141 * control's value changes.
142 * @manual_mode_value: If the is_auto flag is set, then this is the value
143 * of the auto control that determines if that control is in
144 * manual mode. So if the value of the auto control equals this
145 * value, then the whole cluster is in manual mode. Drivers should
146 * never set this flag directly.
147 * @ops: The control ops.
148 * @type_ops: The control type ops.
149 * @id: The control ID.
150 * @name: The control name.
151 * @type: The control type.
152 * @minimum: The control's minimum value.
153 * @maximum: The control's maximum value.
154 * @default_value: The control's default value.
155 * @step: The control's step value for non-menu controls.
156 * @elems: The number of elements in the N-dimensional array.
157 * @elem_size: The size in bytes of the control.
158 * @dims: The size of each dimension.
159 * @nr_of_dims:The number of dimensions in @dims.
160 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
161 * easy to skip menu items that are not valid. If bit X is set,
162 * then menu item X is skipped. Of course, this only works for
163 * menus with <= 32 menu items. There are no menus that come
164 * close to that number, so this is OK. Should we ever need more,
165 * then this will have to be extended to a u64 or a bit array.
166 * @qmenu: A const char * array for all menu items. Array entries that are
167 * empty strings ("") correspond to non-existing menu items (this
168 * is in addition to the menu_skip_mask above). The last entry
169 * must be NULL.
Mauro Carvalho Chehab20139f12017-09-27 12:25:21 -0400170 * Used only if the @type is %V4L2_CTRL_TYPE_MENU.
171 * @qmenu_int: A 64-bit integer array for with integer menu items.
172 * The size of array must be equal to the menu size, e. g.:
173 * :math:`ceil(\frac{maximum - minimum}{step}) + 1`.
174 * Used only if the @type is %V4L2_CTRL_TYPE_INTEGER_MENU.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300175 * @flags: The control's flags.
Mauro Carvalho Chehab20139f12017-09-27 12:25:21 -0400176 * @cur: Structure to store the current value.
177 * @cur.val: The control's current value, if the @type is represented via
178 * a u32 integer (see &enum v4l2_ctrl_type).
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300179 * @val: The control's new s32 value.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300180 * @priv: The control's private pointer. For use by the driver. It is
181 * untouched by the control framework. Note that this pointer is
182 * not freed when the control is deleted. Should this be needed
183 * then a new internal bitfield can be added to tell the framework
184 * to free this pointer.
Baruch Siachbf7b7042018-07-05 05:38:00 -0400185 * @p_cur: The control's current value represented via a union which
Mauro Carvalho Chehab7dc87912015-08-22 08:22:03 -0300186 * provides a standard way of accessing control types
187 * through a pointer.
Baruch Siachbf7b7042018-07-05 05:38:00 -0400188 * @p_new: The control's new value represented via a union which provides
Mauro Carvalho Chehab7dc87912015-08-22 08:22:03 -0300189 * a standard way of accessing control types
190 * through a pointer.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300191 */
Hans Verkuil09965172010-08-01 14:32:42 -0300192struct v4l2_ctrl {
193 /* Administrative fields */
194 struct list_head node;
Hans Verkuil77068d32011-06-13 18:55:58 -0300195 struct list_head ev_subs;
Hans Verkuil09965172010-08-01 14:32:42 -0300196 struct v4l2_ctrl_handler *handler;
197 struct v4l2_ctrl **cluster;
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300198 unsigned int ncontrols;
199
Hans Verkuil09965172010-08-01 14:32:42 -0300200 unsigned int done:1;
201
Hans Verkuil2a863792011-01-11 14:45:03 -0300202 unsigned int is_new:1;
Hans Verkuil9ea1b7a2014-01-17 08:25:26 -0300203 unsigned int has_changed:1;
Hans Verkuil09965172010-08-01 14:32:42 -0300204 unsigned int is_private:1;
Hans Verkuil72d877c2011-06-10 05:44:36 -0300205 unsigned int is_auto:1;
Hans Verkuild9a25472014-06-12 07:54:16 -0300206 unsigned int is_int:1;
207 unsigned int is_string:1;
208 unsigned int is_ptr:1;
Hans Verkuil998e7652014-06-10 07:55:00 -0300209 unsigned int is_array:1;
Hans Verkuil5626b8c2011-08-26 07:53:53 -0300210 unsigned int has_volatiles:1;
Hans Verkuil8ac7a942012-09-07 04:46:39 -0300211 unsigned int call_notify:1;
Hans Verkuil82a7c042011-06-28 10:43:13 -0300212 unsigned int manual_mode_value:8;
Hans Verkuil09965172010-08-01 14:32:42 -0300213
214 const struct v4l2_ctrl_ops *ops;
Hans Verkuil01760772014-04-27 03:22:17 -0300215 const struct v4l2_ctrl_type_ops *type_ops;
Hans Verkuil09965172010-08-01 14:32:42 -0300216 u32 id;
217 const char *name;
218 enum v4l2_ctrl_type type;
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300219 s64 minimum, maximum, default_value;
Hans Verkuil20d88ee2014-06-12 07:55:21 -0300220 u32 elems;
Hans Verkuild9a25472014-06-12 07:54:16 -0300221 u32 elem_size;
Hans Verkuil20d88ee2014-06-12 07:55:21 -0300222 u32 dims[V4L2_CTRL_MAX_DIMS];
223 u32 nr_of_dims;
Hans Verkuil09965172010-08-01 14:32:42 -0300224 union {
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300225 u64 step;
226 u64 menu_skip_mask;
Hans Verkuil09965172010-08-01 14:32:42 -0300227 };
Sakari Ailusce580fe2011-08-04 13:51:11 -0300228 union {
229 const char * const *qmenu;
230 const s64 *qmenu_int;
231 };
Hans Verkuil09965172010-08-01 14:32:42 -0300232 unsigned long flags;
Hans Verkuil09965172010-08-01 14:32:42 -0300233 void *priv;
Hans Verkuil2a9ec372014-04-27 03:38:13 -0300234 s32 val;
235 struct {
Hans Verkuild9a25472014-06-12 07:54:16 -0300236 s32 val;
Hans Verkuild9a25472014-06-12 07:54:16 -0300237 } cur;
Hans Verkuil01760772014-04-27 03:22:17 -0300238
239 union v4l2_ctrl_ptr p_new;
240 union v4l2_ctrl_ptr p_cur;
Hans Verkuil09965172010-08-01 14:32:42 -0300241};
242
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300243/**
244 * struct v4l2_ctrl_ref - The control reference.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300245 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300246 * @node: List node for the sorted list.
247 * @next: Single-link list node for the hash.
248 * @ctrl: The actual control information.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300249 * @helper: Pointer to helper struct. Used internally in
Mauro Carvalho Chehabfb911612016-08-29 18:43:02 -0300250 * ``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``.
Hans Verkuilda1b1ae2018-05-21 04:54:36 -0400251 * @from_other_dev: If true, then @ctrl was defined in another
252 * device than the &struct v4l2_ctrl_handler.
Hans Verkuil6fa6f832018-05-21 04:54:40 -0400253 * @req_done: Internal flag: if the control handler containing this control
254 * reference is bound to a media request, then this is set when
255 * the control has been applied. This prevents applying controls
256 * from a cluster with multiple controls twice (when the first
257 * control of a cluster is applied, they all are).
258 * @req: If set, this refers to another request that sets this control.
Hans Verkuil52beedd2018-05-21 04:54:37 -0400259 * @p_req: If the control handler containing this control reference
260 * is bound to a media request, then this points to the
261 * value of the control that should be applied when the request
262 * is executed, or to the value of the control at the time
263 * that the request was completed.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300264 *
265 * Each control handler has a list of these refs. The list_head is used to
266 * keep a sorted-by-control-ID list of all controls, while the next pointer
267 * is used to link the control in the hash's bucket.
268 */
Hans Verkuil09965172010-08-01 14:32:42 -0300269struct v4l2_ctrl_ref {
270 struct list_head node;
271 struct v4l2_ctrl_ref *next;
272 struct v4l2_ctrl *ctrl;
Hans Verkuileb5b16e2011-06-14 10:04:06 -0300273 struct v4l2_ctrl_helper *helper;
Hans Verkuilda1b1ae2018-05-21 04:54:36 -0400274 bool from_other_dev;
Hans Verkuil6fa6f832018-05-21 04:54:40 -0400275 bool req_done;
276 struct v4l2_ctrl_ref *req;
Hans Verkuil52beedd2018-05-21 04:54:37 -0400277 union v4l2_ctrl_ptr p_req;
Hans Verkuil09965172010-08-01 14:32:42 -0300278};
279
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300280/**
281 * struct v4l2_ctrl_handler - The control handler keeps track of all the
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300282 * controls: both the controls owned by the handler and those inherited
283 * from other handlers.
284 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300285 * @_lock: Default for "lock".
286 * @lock: Lock to control access to this handler and its controls.
287 * May be replaced by the user right after init.
288 * @ctrls: The list of controls owned by this handler.
289 * @ctrl_refs: The list of control references.
290 * @cached: The last found control reference. It is common that the same
291 * control is needed multiple times, so this is a simple
292 * optimization.
293 * @buckets: Buckets for the hashing. Allows for quick control lookup.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300294 * @notify: A notify callback that is called whenever the control changes
295 * value.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300296 * Note that the handler's lock is held when the notify function
297 * is called!
298 * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
299 * @nr_of_buckets: Total number of buckets in the array.
300 * @error: The error code of the first failed control addition.
Hans Verkuil6fa6f832018-05-21 04:54:40 -0400301 * @request_is_queued: True if the request was queued.
302 * @requests: List to keep track of open control handler request objects.
303 * For the parent control handler (@req_obj.req == NULL) this
304 * is the list header. When the parent control handler is
305 * removed, it has to unbind and put all these requests since
306 * they refer to the parent.
307 * @requests_queued: List of the queued requests. This determines the order
308 * in which these controls are applied. Once the request is
309 * completed it is removed from this list.
Hans Verkuil52beedd2018-05-21 04:54:37 -0400310 * @req_obj: The &struct media_request_object, used to link into a
311 * &struct media_request. This request object has a refcount.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300312 */
Hans Verkuil09965172010-08-01 14:32:42 -0300313struct v4l2_ctrl_handler {
Sakari Ailus77e7c4e2012-01-24 21:05:34 -0300314 struct mutex _lock;
315 struct mutex *lock;
Hans Verkuil09965172010-08-01 14:32:42 -0300316 struct list_head ctrls;
317 struct list_head ctrl_refs;
318 struct v4l2_ctrl_ref *cached;
319 struct v4l2_ctrl_ref **buckets;
Hans Verkuil8ac7a942012-09-07 04:46:39 -0300320 v4l2_ctrl_notify_fnc notify;
321 void *notify_priv;
Hans Verkuil09965172010-08-01 14:32:42 -0300322 u16 nr_of_buckets;
323 int error;
Hans Verkuil6fa6f832018-05-21 04:54:40 -0400324 bool request_is_queued;
325 struct list_head requests;
326 struct list_head requests_queued;
Hans Verkuil52beedd2018-05-21 04:54:37 -0400327 struct media_request_object req_obj;
Hans Verkuil09965172010-08-01 14:32:42 -0300328};
329
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300330/**
331 * struct v4l2_ctrl_config - Control configuration structure.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300332 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300333 * @ops: The control ops.
334 * @type_ops: The control type ops. Only needed for compound controls.
335 * @id: The control ID.
336 * @name: The control name.
337 * @type: The control type.
338 * @min: The control's minimum value.
339 * @max: The control's maximum value.
340 * @step: The control's step value for non-menu controls.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300341 * @def: The control's default value.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300342 * @dims: The size of each dimension.
343 * @elem_size: The size in bytes of the control.
344 * @flags: The control's flags.
345 * @menu_skip_mask: The control's skip mask for menu controls. This makes it
346 * easy to skip menu items that are not valid. If bit X is set,
347 * then menu item X is skipped. Of course, this only works for
348 * menus with <= 64 menu items. There are no menus that come
349 * close to that number, so this is OK. Should we ever need more,
350 * then this will have to be extended to a bit array.
351 * @qmenu: A const char * array for all menu items. Array entries that are
352 * empty strings ("") correspond to non-existing menu items (this
353 * is in addition to the menu_skip_mask above). The last entry
354 * must be NULL.
Mauro Carvalho Chehab7dc87912015-08-22 08:22:03 -0300355 * @qmenu_int: A const s64 integer array for all menu items of the type
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300356 * V4L2_CTRL_TYPE_INTEGER_MENU.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300357 * @is_private: If set, then this control is private to its handler and it
358 * will not be added to any other handlers.
359 */
Hans Verkuil09965172010-08-01 14:32:42 -0300360struct v4l2_ctrl_config {
361 const struct v4l2_ctrl_ops *ops;
Hans Verkuil01760772014-04-27 03:22:17 -0300362 const struct v4l2_ctrl_type_ops *type_ops;
Hans Verkuil09965172010-08-01 14:32:42 -0300363 u32 id;
364 const char *name;
365 enum v4l2_ctrl_type type;
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300366 s64 min;
367 s64 max;
368 u64 step;
369 s64 def;
Hans Verkuil20d88ee2014-06-12 07:55:21 -0300370 u32 dims[V4L2_CTRL_MAX_DIMS];
Hans Verkuild9a25472014-06-12 07:54:16 -0300371 u32 elem_size;
Hans Verkuil09965172010-08-01 14:32:42 -0300372 u32 flags;
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300373 u64 menu_skip_mask;
Hans Verkuil513521e2010-12-29 14:25:52 -0300374 const char * const *qmenu;
Sakari Ailusce580fe2011-08-04 13:51:11 -0300375 const s64 *qmenu_int;
Hans Verkuil09965172010-08-01 14:32:42 -0300376 unsigned int is_private:1;
Hans Verkuil09965172010-08-01 14:32:42 -0300377};
378
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300379/**
380 * v4l2_ctrl_fill - Fill in the control fields based on the control ID.
381 *
382 * @id: ID of the control
Mauro Carvalho Chehab67c672e2017-08-12 05:57:05 -0400383 * @name: pointer to be filled with a string with the name of the control
384 * @type: pointer for storing the type of the control
385 * @min: pointer for storing the minimum value for the control
386 * @max: pointer for storing the maximum value for the control
387 * @step: pointer for storing the control step
388 * @def: pointer for storing the default value for the control
389 * @flags: pointer for storing the flags to be used on the control
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300390 *
391 * This works for all standard V4L2 controls.
392 * For non-standard controls it will only fill in the given arguments
Mauro Carvalho Chehab67c672e2017-08-12 05:57:05 -0400393 * and @name content will be set to %NULL.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300394 *
395 * This function will overwrite the contents of @name, @type and @flags.
396 * The contents of @min, @max, @step and @def may be modified depending on
397 * the type.
398 *
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300399 * .. note::
400 *
401 * Do not use in drivers! It is used internally for backwards compatibility
402 * control handling only. Once all drivers are converted to use the new
403 * control framework this function will no longer be exported.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300404 */
Hans Verkuil09965172010-08-01 14:32:42 -0300405void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
Hans Verkuil0ba2aeb2014-04-16 09:41:25 -0300406 s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
Hans Verkuil09965172010-08-01 14:32:42 -0300407
408
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300409/**
410 * v4l2_ctrl_handler_init_class() - Initialize the control handler.
411 * @hdl: The control handler.
412 * @nr_of_controls_hint: A hint of how many controls this handler is
413 * expected to refer to. This is the total number, so including
414 * any inherited controls. It doesn't have to be precise, but if
415 * it is way off, then you either waste memory (too many buckets
416 * are allocated) or the control lookup becomes slower (not enough
417 * buckets are allocated, so there are more slow list lookups).
418 * It will always work, though.
419 * @key: Used by the lock validator if CONFIG_LOCKDEP is set.
420 * @name: Used by the lock validator if CONFIG_LOCKDEP is set.
421 *
Mauro Carvalho Chehab2257e182016-08-29 17:26:15 -0300422 * .. attention::
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300423 *
Mauro Carvalho Chehab2257e182016-08-29 17:26:15 -0300424 * Never use this call directly, always use the v4l2_ctrl_handler_init()
425 * macro that hides the @key and @name arguments.
426 *
427 * Return: returns an error if the buckets could not be allocated. This
428 * error will also be stored in @hdl->error.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300429 */
Andy Walls6cd247e2013-03-09 05:55:11 -0300430int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300431 unsigned int nr_of_controls_hint,
Andy Walls6cd247e2013-03-09 05:55:11 -0300432 struct lock_class_key *key, const char *name);
433
434#ifdef CONFIG_LOCKDEP
Mauro Carvalho Chehab2257e182016-08-29 17:26:15 -0300435
436/**
Mauro Carvalho Chehabe383ce02016-09-22 07:59:03 -0300437 * v4l2_ctrl_handler_init - helper function to create a static struct
438 * &lock_class_key and calls v4l2_ctrl_handler_init_class()
Mauro Carvalho Chehab2257e182016-08-29 17:26:15 -0300439 *
440 * @hdl: The control handler.
441 * @nr_of_controls_hint: A hint of how many controls this handler is
442 * expected to refer to. This is the total number, so including
443 * any inherited controls. It doesn't have to be precise, but if
444 * it is way off, then you either waste memory (too many buckets
445 * are allocated) or the control lookup becomes slower (not enough
446 * buckets are allocated, so there are more slow list lookups).
447 * It will always work, though.
448 *
449 * This helper function creates a static struct &lock_class_key and
450 * calls v4l2_ctrl_handler_init_class(), providing a proper name for the lock
451 * validador.
452 *
453 * Use this helper function to initialize a control handler.
454 */
Andy Walls6cd247e2013-03-09 05:55:11 -0300455#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
456( \
457 ({ \
458 static struct lock_class_key _key; \
459 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \
460 &_key, \
461 KBUILD_BASENAME ":" \
462 __stringify(__LINE__) ":" \
463 "(" #hdl ")->_lock"); \
464 }) \
465)
466#else
467#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
468 v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
469#endif
Hans Verkuil09965172010-08-01 14:32:42 -0300470
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300471/**
472 * v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
473 * the control list.
474 * @hdl: The control handler.
475 *
476 * Does nothing if @hdl == NULL.
477 */
Hans Verkuil09965172010-08-01 14:32:42 -0300478void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
479
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300480/**
481 * v4l2_ctrl_lock() - Helper function to lock the handler
482 * associated with the control.
483 * @ctrl: The control to lock.
484 */
Sakari Ailus605b3842014-06-12 13:09:39 -0300485static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
486{
487 mutex_lock(ctrl->handler->lock);
488}
489
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300490/**
491 * v4l2_ctrl_unlock() - Helper function to unlock the handler
492 * associated with the control.
493 * @ctrl: The control to unlock.
494 */
Sakari Ailus605b3842014-06-12 13:09:39 -0300495static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
496{
497 mutex_unlock(ctrl->handler->lock);
498}
499
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300500/**
Sakari Ailuscc0140e2017-05-26 05:21:37 -0300501 * __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
502 * to the handler to initialize the hardware to the current control values. The
503 * caller is responsible for acquiring the control handler mutex on behalf of
504 * __v4l2_ctrl_handler_setup().
505 * @hdl: The control handler.
506 *
507 * Button controls will be skipped, as are read-only controls.
508 *
509 * If @hdl == NULL, then this just returns 0.
510 */
511int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
512
513/**
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300514 * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
515 * to the handler to initialize the hardware to the current control values.
516 * @hdl: The control handler.
517 *
518 * Button controls will be skipped, as are read-only controls.
519 *
520 * If @hdl == NULL, then this just returns 0.
521 */
Hans Verkuil09965172010-08-01 14:32:42 -0300522int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
523
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300524/**
525 * v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
526 * @hdl: The control handler.
527 * @prefix: The prefix to use when logging the control values. If the
528 * prefix does not end with a space, then ": " will be added
529 * after the prefix. If @prefix == NULL, then no prefix will be
530 * used.
531 *
532 * For use with VIDIOC_LOG_STATUS.
533 *
534 * Does nothing if @hdl == NULL.
535 */
Hans Verkuil09965172010-08-01 14:32:42 -0300536void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
537 const char *prefix);
538
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300539/**
540 * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300541 * control.
542 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300543 * @hdl: The control handler.
544 * @cfg: The control's configuration data.
545 * @priv: The control's driver-specific private data.
546 *
547 * If the &v4l2_ctrl struct could not be allocated then NULL is returned
548 * and @hdl->error is set to the error code (if it wasn't set already).
549 */
Hans Verkuil09965172010-08-01 14:32:42 -0300550struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300551 const struct v4l2_ctrl_config *cfg,
552 void *priv);
Hans Verkuil09965172010-08-01 14:32:42 -0300553
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300554/**
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300555 * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu
556 * control.
557 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300558 * @hdl: The control handler.
559 * @ops: The control ops.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300560 * @id: The control ID.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300561 * @min: The control's minimum value.
562 * @max: The control's maximum value.
563 * @step: The control's step value
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300564 * @def: The control's default value.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300565 *
566 * If the &v4l2_ctrl struct could not be allocated, or the control
567 * ID is not known, then NULL is returned and @hdl->error is set to the
568 * appropriate error code (if it wasn't set already).
569 *
570 * If @id refers to a menu control, then this function will return NULL.
571 *
572 * Use v4l2_ctrl_new_std_menu() when adding menu controls.
573 */
Hans Verkuil09965172010-08-01 14:32:42 -0300574struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300575 const struct v4l2_ctrl_ops *ops,
576 u32 id, s64 min, s64 max, u64 step,
577 s64 def);
Hans Verkuil09965172010-08-01 14:32:42 -0300578
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300579/**
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300580 * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2
581 * menu control.
582 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300583 * @hdl: The control handler.
584 * @ops: The control ops.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300585 * @id: The control ID.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300586 * @max: The control's maximum value.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300587 * @mask: The control's skip mask for menu controls. This makes it
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300588 * easy to skip menu items that are not valid. If bit X is set,
589 * then menu item X is skipped. Of course, this only works for
590 * menus with <= 64 menu items. There are no menus that come
591 * close to that number, so this is OK. Should we ever need more,
592 * then this will have to be extended to a bit array.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300593 * @def: The control's default value.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300594 *
595 * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
596 * determines which menu items are to be skipped.
597 *
598 * If @id refers to a non-menu control, then this function will return NULL.
599 */
Hans Verkuil09965172010-08-01 14:32:42 -0300600struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300601 const struct v4l2_ctrl_ops *ops,
602 u32 id, u8 max, u64 mask, u8 def);
Hans Verkuil09965172010-08-01 14:32:42 -0300603
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300604/**
605 * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300606 * with driver specific menu.
607 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300608 * @hdl: The control handler.
609 * @ops: The control ops.
610 * @id: The control ID.
611 * @max: The control's maximum value.
612 * @mask: The control's skip mask for menu controls. This makes it
613 * easy to skip menu items that are not valid. If bit X is set,
614 * then menu item X is skipped. Of course, this only works for
615 * menus with <= 64 menu items. There are no menus that come
616 * close to that number, so this is OK. Should we ever need more,
617 * then this will have to be extended to a bit array.
618 * @def: The control's default value.
619 * @qmenu: The new menu.
620 *
621 * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
622 * menu of this control.
623 *
624 */
Lad, Prabhakar117a7112012-09-18 15:54:38 -0300625struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300626 const struct v4l2_ctrl_ops *ops,
627 u32 id, u8 max,
628 u64 mask, u8 def,
629 const char * const *qmenu);
Lad, Prabhakar117a7112012-09-18 15:54:38 -0300630
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300631/**
632 * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300633 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300634 * @hdl: The control handler.
635 * @ops: The control ops.
636 * @id: The control ID.
637 * @max: The control's maximum value.
638 * @def: The control's default value.
639 * @qmenu_int: The control's menu entries.
640 *
641 * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly
642 * takes as an argument an array of integers determining the menu items.
643 *
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300644 * If @id refers to a non-integer-menu control, then this function will
645 * return %NULL.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300646 */
Sylwester Nawrocki515f3282012-05-06 15:30:44 -0300647struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300648 const struct v4l2_ctrl_ops *ops,
649 u32 id, u8 max, u8 def,
650 const s64 *qmenu_int);
Sylwester Nawrocki515f3282012-05-06 15:30:44 -0300651
Mauro Carvalho Chehab2257e182016-08-29 17:26:15 -0300652/**
653 * typedef v4l2_ctrl_filter - Typedef to define the filter function to be
654 * used when adding a control handler.
655 *
656 * @ctrl: pointer to struct &v4l2_ctrl.
657 */
658
Mauro Carvalho Chehab6d85d7d2016-07-22 10:58:03 -0300659typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl);
660
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300661/**
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300662 * v4l2_ctrl_add_handler() - Add all controls from handler @add to
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300663 * handler @hdl.
664 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300665 * @hdl: The control handler.
666 * @add: The control handler whose controls you want to add to
667 * the @hdl control handler.
668 * @filter: This function will filter which controls should be added.
Hans Verkuilda1b1ae2018-05-21 04:54:36 -0400669 * @from_other_dev: If true, then the controls in @add were defined in another
670 * device than @hdl.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300671 *
672 * Does nothing if either of the two handlers is a NULL pointer.
673 * If @filter is NULL, then all controls are added. Otherwise only those
674 * controls for which @filter returns true will be added.
675 * In case of an error @hdl->error will be set to the error code (if it
676 * wasn't set already).
677 */
Hans Verkuil09965172010-08-01 14:32:42 -0300678int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
Hans Verkuil34a6b7d2012-09-14 07:15:03 -0300679 struct v4l2_ctrl_handler *add,
Hans Verkuilda1b1ae2018-05-21 04:54:36 -0400680 v4l2_ctrl_filter filter,
681 bool from_other_dev);
Hans Verkuil09965172010-08-01 14:32:42 -0300682
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300683/**
684 * v4l2_ctrl_radio_filter() - Standard filter for radio controls.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300685 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300686 * @ctrl: The control that is filtered.
687 *
688 * This will return true for any controls that are valid for radio device
689 * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
690 * transmitter class controls.
691 *
692 * This function is to be used with v4l2_ctrl_add_handler().
693 */
Hans Verkuil34a6b7d2012-09-14 07:15:03 -0300694bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
Hans Verkuil09965172010-08-01 14:32:42 -0300695
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300696/**
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300697 * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging
698 * to that cluster.
699 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300700 * @ncontrols: The number of controls in this cluster.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300701 * @controls: The cluster control array of size @ncontrols.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300702 */
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300703void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls);
Hans Verkuil09965172010-08-01 14:32:42 -0300704
705
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300706/**
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300707 * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging
708 * to that cluster and set it up for autofoo/foo-type handling.
709 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300710 * @ncontrols: The number of controls in this cluster.
711 * @controls: The cluster control array of size @ncontrols. The first control
712 * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
713 * @manual_val: The value for the first control in the cluster that equals the
714 * manual setting.
715 * @set_volatile: If true, then all controls except the first auto control will
716 * be volatile.
717 *
718 * Use for control groups where one control selects some automatic feature and
719 * the other controls are only active whenever the automatic feature is turned
720 * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
721 * red and blue balance, etc.
722 *
723 * The behavior of such controls is as follows:
724 *
725 * When the autofoo control is set to automatic, then any manual controls
726 * are set to inactive and any reads will call g_volatile_ctrl (if the control
727 * was marked volatile).
728 *
729 * When the autofoo control is set to manual, then any manual controls will
730 * be marked active, and any reads will just return the current value without
731 * going through g_volatile_ctrl.
732 *
Mauro Carvalho Chehab2257e182016-08-29 17:26:15 -0300733 * In addition, this function will set the %V4L2_CTRL_FLAG_UPDATE flag
734 * on the autofoo control and %V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300735 * if autofoo is in auto mode.
736 */
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300737void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
738 struct v4l2_ctrl **controls,
739 u8 manual_val, bool set_volatile);
Hans Verkuil72d877c2011-06-10 05:44:36 -0300740
741
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300742/**
743 * v4l2_ctrl_find() - Find a control with the given ID.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300744 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300745 * @hdl: The control handler.
746 * @id: The control ID to find.
747 *
748 * If @hdl == NULL this will return NULL as well. Will lock the handler so
749 * do not use from inside &v4l2_ctrl_ops.
750 */
Hans Verkuil09965172010-08-01 14:32:42 -0300751struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
752
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300753/**
754 * v4l2_ctrl_activate() - Make the control active or inactive.
755 * @ctrl: The control to (de)activate.
756 * @active: True if the control should become active.
757 *
758 * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
759 * Does nothing if @ctrl == NULL.
760 * This will usually be called from within the s_ctrl op.
761 * The V4L2_EVENT_CTRL event will be generated afterwards.
762 *
763 * This function assumes that the control handler is locked.
764 */
Hans Verkuil09965172010-08-01 14:32:42 -0300765void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
766
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300767/**
768 * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300769 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300770 * @ctrl: The control to (de)activate.
771 * @grabbed: True if the control should become grabbed.
772 *
773 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
774 * Does nothing if @ctrl == NULL.
775 * The V4L2_EVENT_CTRL event will be generated afterwards.
776 * This will usually be called when starting or stopping streaming in the
777 * driver.
778 *
779 * This function assumes that the control handler is not locked and will
780 * take the lock itself.
781 */
Hans Verkuil09965172010-08-01 14:32:42 -0300782void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
783
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300784/**
785 *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range()
786 *
787 * @ctrl: The control to update.
788 * @min: The control's minimum value.
789 * @max: The control's maximum value.
790 * @step: The control's step value
791 * @def: The control's default value.
792 *
793 * Update the range of a control on the fly. This works for control types
794 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
795 * @step value is interpreted as a menu_skip_mask.
796 *
797 * An error is returned if one of the range arguments is invalid for this
798 * control type.
799 *
Hans Verkuil97eee232018-02-03 08:18:14 -0500800 * The caller is responsible for acquiring the control handler mutex on behalf
801 * of __v4l2_ctrl_modify_range().
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300802 */
Sakari Ailus5a573922014-06-12 13:09:40 -0300803int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
804 s64 min, s64 max, u64 step, s64 def);
805
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300806/**
807 * v4l2_ctrl_modify_range() - Update the range of a control.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300808 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300809 * @ctrl: The control to update.
810 * @min: The control's minimum value.
811 * @max: The control's maximum value.
812 * @step: The control's step value
813 * @def: The control's default value.
814 *
815 * Update the range of a control on the fly. This works for control types
816 * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
817 * @step value is interpreted as a menu_skip_mask.
818 *
819 * An error is returned if one of the range arguments is invalid for this
820 * control type.
821 *
822 * This function assumes that the control handler is not locked and will
823 * take the lock itself.
824 */
Sakari Ailus5a573922014-06-12 13:09:40 -0300825static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
826 s64 min, s64 max, u64 step, s64 def)
827{
828 int rval;
829
830 v4l2_ctrl_lock(ctrl);
831 rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
832 v4l2_ctrl_unlock(ctrl);
833
834 return rval;
835}
Sylwester Nawrocki2ccbe772013-01-19 15:51:55 -0300836
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300837/**
838 * v4l2_ctrl_notify() - Function to set a notify callback for a control.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300839 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300840 * @ctrl: The control.
841 * @notify: The callback function.
842 * @priv: The callback private handle, passed as argument to the callback.
843 *
844 * This function sets a callback function for the control. If @ctrl is NULL,
845 * then it will do nothing. If @notify is NULL, then the notify callback will
846 * be removed.
847 *
848 * There can be only one notify. If another already exists, then a WARN_ON
849 * will be issued and the function will do nothing.
850 */
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300851void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify,
852 void *priv);
Hans Verkuil8ac7a942012-09-07 04:46:39 -0300853
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300854/**
855 * v4l2_ctrl_get_name() - Get the name of the control
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300856 *
Hans Verkuil79fbc202014-11-23 09:39:54 -0300857 * @id: The control ID.
858 *
859 * This function returns the name of the given control ID or NULL if it isn't
860 * a known control.
861 */
862const char *v4l2_ctrl_get_name(u32 id);
863
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300864/**
865 * v4l2_ctrl_get_menu() - Get the menu string array of the control
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300866 *
Hans Verkuil79fbc202014-11-23 09:39:54 -0300867 * @id: The control ID.
868 *
869 * This function returns the NULL-terminated menu string array name of the
870 * given control ID or NULL if it isn't a known menu control.
871 */
872const char * const *v4l2_ctrl_get_menu(u32 id);
873
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300874/**
875 * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300876 *
Hans Verkuil79fbc202014-11-23 09:39:54 -0300877 * @id: The control ID.
878 * @len: The size of the integer array.
879 *
880 * This function returns the integer array of the given control ID or NULL if it
881 * if it isn't a known integer menu control.
882 */
883const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
884
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300885/**
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300886 * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from
887 * within a driver.
888 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300889 * @ctrl: The control.
890 *
891 * This returns the control's value safely by going through the control
892 * framework. This function will lock the control's handler, so it cannot be
893 * used from within the &v4l2_ctrl_ops functions.
894 *
895 * This function is for integer type controls only.
896 */
Hans Verkuil09965172010-08-01 14:32:42 -0300897s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
898
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300899/**
900 * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300901 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300902 * @ctrl: The control.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300903 * @val: TheControls name new value.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300904 *
Hans Verkuil904aef02016-06-15 09:57:48 -0300905 * This sets the control's new value safely by going through the control
906 * framework. This function assumes the control's handler is already locked,
907 * allowing it to be used from within the &v4l2_ctrl_ops functions.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300908 *
909 * This function is for integer type controls only.
910 */
Sakari Ailus0c4348a2014-06-12 13:09:42 -0300911int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300912
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300913/**
914 * v4l2_ctrl_s_ctrl() - Helper function to set the control's value from
915 * within a driver.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300916 * @ctrl: The control.
917 * @val: The new value.
918 *
Hans Verkuil904aef02016-06-15 09:57:48 -0300919 * This sets the control's new value safely by going through the control
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300920 * framework. This function will lock the control's handler, so it cannot be
921 * used from within the &v4l2_ctrl_ops functions.
922 *
923 * This function is for integer type controls only.
924 */
Sakari Ailus0c4348a2014-06-12 13:09:42 -0300925static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
926{
927 int rval;
928
929 v4l2_ctrl_lock(ctrl);
930 rval = __v4l2_ctrl_s_ctrl(ctrl, val);
931 v4l2_ctrl_unlock(ctrl);
932
933 return rval;
934}
Hans Verkuil09965172010-08-01 14:32:42 -0300935
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300936/**
937 * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
938 * from within a driver.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300939 *
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300940 * @ctrl: The control.
941 *
942 * This returns the control's value safely by going through the control
943 * framework. This function will lock the control's handler, so it cannot be
944 * used from within the &v4l2_ctrl_ops functions.
945 *
946 * This function is for 64-bit integer type controls only.
947 */
Laurent Pinchart03d52852012-07-23 09:15:21 -0300948s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
949
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300950/**
951 * __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64().
952 *
953 * @ctrl: The control.
954 * @val: The new value.
955 *
Hans Verkuil904aef02016-06-15 09:57:48 -0300956 * This sets the control's new value safely by going through the control
957 * framework. This function assumes the control's handler is already locked,
958 * allowing it to be used from within the &v4l2_ctrl_ops functions.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300959 *
960 * This function is for 64-bit integer type controls only.
961 */
Sakari Ailus0c4348a2014-06-12 13:09:42 -0300962int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
963
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300964/**
965 * v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300966 * from within a driver.
967 *
968 * @ctrl: The control.
969 * @val: The new value.
970 *
Hans Verkuil904aef02016-06-15 09:57:48 -0300971 * This sets the control's new value safely by going through the control
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300972 * framework. This function will lock the control's handler, so it cannot be
973 * used from within the &v4l2_ctrl_ops functions.
974 *
975 * This function is for 64-bit integer type controls only.
976 */
Sakari Ailus0c4348a2014-06-12 13:09:42 -0300977static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
978{
979 int rval;
980
981 v4l2_ctrl_lock(ctrl);
982 rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
983 v4l2_ctrl_unlock(ctrl);
984
985 return rval;
986}
Laurent Pinchart03d52852012-07-23 09:15:21 -0300987
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -0300988/**
989 * __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300990 *
991 * @ctrl: The control.
992 * @s: The new string.
993 *
Hans Verkuil904aef02016-06-15 09:57:48 -0300994 * This sets the control's new string safely by going through the control
995 * framework. This function assumes the control's handler is already locked,
996 * allowing it to be used from within the &v4l2_ctrl_ops functions.
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -0300997 *
998 * This function is for string type controls only.
999 */
Hans Verkuil5d0360a2014-07-21 10:45:42 -03001000int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
1001
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001002/**
1003 * v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -03001004 * from within a driver.
1005 *
1006 * @ctrl: The control.
1007 * @s: The new string.
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001008 *Controls name
Hans Verkuil904aef02016-06-15 09:57:48 -03001009 * This sets the control's new string safely by going through the control
Mauro Carvalho Chehab8c2721d2015-08-22 08:03:49 -03001010 * framework. This function will lock the control's handler, so it cannot be
1011 * used from within the &v4l2_ctrl_ops functions.
1012 *
1013 * This function is for string type controls only.
1014 */
Hans Verkuil5d0360a2014-07-21 10:45:42 -03001015static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
1016{
1017 int rval;
1018
1019 v4l2_ctrl_lock(ctrl);
1020 rval = __v4l2_ctrl_s_ctrl_string(ctrl, s);
1021 v4l2_ctrl_unlock(ctrl);
1022
1023 return rval;
1024}
1025
Hans Verkuilce727572011-06-10 05:56:39 -03001026/* Internal helper functions that deal with control events. */
Hans de Goede3e3661492012-04-08 12:59:47 -03001027extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001028
1029/**
1030 * v4l2_ctrl_replace - Function to be used as a callback to
1031 * &struct v4l2_subscribed_event_ops replace\(\)
1032 *
Mauro Carvalho Chehabf8441a42016-08-29 19:29:58 -03001033 * @old: pointer to struct &v4l2_event with the reported
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001034 * event;
Mauro Carvalho Chehabf8441a42016-08-29 19:29:58 -03001035 * @new: pointer to struct &v4l2_event with the modified
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001036 * event;
1037 */
Hans de Goede3e3661492012-04-08 12:59:47 -03001038void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001039
1040/**
1041 * v4l2_ctrl_merge - Function to be used as a callback to
1042 * &struct v4l2_subscribed_event_ops merge(\)
1043 *
Mauro Carvalho Chehabf8441a42016-08-29 19:29:58 -03001044 * @old: pointer to struct &v4l2_event with the reported
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001045 * event;
Mauro Carvalho Chehabf8441a42016-08-29 19:29:58 -03001046 * @new: pointer to struct &v4l2_event with the merged
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001047 * event;
1048 */
Hans de Goede3e3661492012-04-08 12:59:47 -03001049void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
Hans Verkuil6e239392011-06-07 11:13:44 -03001050
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001051/**
1052 * v4l2_ctrl_log_status - helper function to implement %VIDIOC_LOG_STATUS ioctl
1053 *
1054 * @file: pointer to struct file
1055 * @fh: unused. Kept just to be compatible to the arguments expected by
1056 * &struct v4l2_ioctl_ops.vidioc_log_status.
1057 *
1058 * Can be used as a vidioc_log_status function that just dumps all controls
1059 * associated with the filehandle.
1060 */
Hans Verkuile2ecb252012-02-02 08:20:53 -03001061int v4l2_ctrl_log_status(struct file *file, void *fh);
1062
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001063/**
1064 * v4l2_ctrl_subscribe_event - Subscribes to an event
1065 *
1066 *
1067 * @fh: pointer to struct v4l2_fh
1068 * @sub: pointer to &struct v4l2_event_subscription
1069 *
1070 * Can be used as a vidioc_subscribe_event function that just subscribes
1071 * control events.
1072 */
Hans Verkuila26243b2012-01-27 16:18:42 -03001073int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
Hans Verkuil85f5fe32012-09-04 11:46:09 -03001074 const struct v4l2_event_subscription *sub);
Hans Verkuila26243b2012-01-27 16:18:42 -03001075
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001076/**
1077 * v4l2_ctrl_poll - function to be used as a callback to the poll()
1078 * That just polls for control events.
1079 *
1080 * @file: pointer to struct file
1081 * @wait: pointer to struct poll_table_struct
1082 */
Al Viroc23e0cb2017-07-03 03:02:56 -04001083__poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
Hans Verkuila26243b2012-01-27 16:18:42 -03001084
Hans Verkuil6fa6f832018-05-21 04:54:40 -04001085/**
1086 * v4l2_ctrl_request_setup - helper function to apply control values in a request
1087 *
1088 * @req: The request
1089 * @parent: The parent control handler ('priv' in media_request_object_find())
1090 *
1091 * This is a helper function to call the control handler's s_ctrl callback with
1092 * the control values contained in the request. Do note that this approach of
1093 * applying control values in a request is only applicable to memory-to-memory
1094 * devices.
1095 */
1096void v4l2_ctrl_request_setup(struct media_request *req,
1097 struct v4l2_ctrl_handler *parent);
1098
1099/**
1100 * v4l2_ctrl_request_complete - Complete a control handler request object
1101 *
1102 * @req: The request
1103 * @parent: The parent control handler ('priv' in media_request_object_find())
1104 *
1105 * This function is to be called on each control handler that may have had a
1106 * request object associated with it, i.e. control handlers of a driver that
1107 * supports requests.
1108 *
1109 * The function first obtains the values of any volatile controls in the control
1110 * handler and attach them to the request. Then, the function completes the
1111 * request object.
1112 */
1113void v4l2_ctrl_request_complete(struct media_request *req,
1114 struct v4l2_ctrl_handler *hdl);
1115
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001116/* Helpers for ioctl_ops */
Hans Verkuil09965172010-08-01 14:32:42 -03001117
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001118/**
1119 * v4l2_queryctrl - Helper function to implement
1120 * :ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
1121 *
1122 * @hdl: pointer to &struct v4l2_ctrl_handler
1123 * @qc: pointer to &struct v4l2_queryctrl
1124 *
1125 * If hdl == NULL then they will all return -EINVAL.
1126 */
1127int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
1128
1129/**
1130 * v4l2_query_ext_ctrl - Helper function to implement
1131 * :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
1132 *
1133 * @hdl: pointer to &struct v4l2_ctrl_handler
1134 * @qc: pointer to &struct v4l2_query_ext_ctrl
1135 *
1136 * If hdl == NULL then they will all return -EINVAL.
1137 */
1138int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl,
1139 struct v4l2_query_ext_ctrl *qc);
1140
1141/**
1142 * v4l2_querymenu - Helper function to implement
1143 * :ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl
1144 *
1145 * @hdl: pointer to &struct v4l2_ctrl_handler
1146 * @qm: pointer to &struct v4l2_querymenu
1147 *
1148 * If hdl == NULL then they will all return -EINVAL.
1149 */
1150int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
1151
1152/**
1153 * v4l2_g_ctrl - Helper function to implement
1154 * :ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
1155 *
1156 * @hdl: pointer to &struct v4l2_ctrl_handler
1157 * @ctrl: pointer to &struct v4l2_control
1158 *
1159 * If hdl == NULL then they will all return -EINVAL.
1160 */
1161int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
1162
1163/**
1164 * v4l2_s_ctrl - Helper function to implement
1165 * :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
1166 *
1167 * @fh: pointer to &struct v4l2_fh
1168 * @hdl: pointer to &struct v4l2_ctrl_handler
1169 *
1170 * @ctrl: pointer to &struct v4l2_control
1171 *
1172 * If hdl == NULL then they will all return -EINVAL.
1173 */
1174int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
1175 struct v4l2_control *ctrl);
1176
1177/**
1178 * v4l2_g_ext_ctrls - Helper function to implement
1179 * :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1180 *
1181 * @hdl: pointer to &struct v4l2_ctrl_handler
1182 * @c: pointer to &struct v4l2_ext_controls
1183 *
1184 * If hdl == NULL then they will all return -EINVAL.
1185 */
1186int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl,
1187 struct v4l2_ext_controls *c);
1188
1189/**
1190 * v4l2_try_ext_ctrls - Helper function to implement
1191 * :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1192 *
1193 * @hdl: pointer to &struct v4l2_ctrl_handler
1194 * @c: pointer to &struct v4l2_ext_controls
1195 *
1196 * If hdl == NULL then they will all return -EINVAL.
1197 */
1198int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
1199 struct v4l2_ext_controls *c);
1200
1201/**
1202 * v4l2_s_ext_ctrls - Helper function to implement
1203 * :ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
1204 *
1205 * @fh: pointer to &struct v4l2_fh
1206 * @hdl: pointer to &struct v4l2_ctrl_handler
1207 * @c: pointer to &struct v4l2_ext_controls
1208 *
1209 * If hdl == NULL then they will all return -EINVAL.
1210 */
1211int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
1212 struct v4l2_ext_controls *c);
1213
1214/**
1215 * v4l2_ctrl_subdev_subscribe_event - Helper function to implement
Mauro Carvalho Chehab4a3fad72018-01-04 06:47:28 -05001216 * as a &struct v4l2_subdev_core_ops subscribe_event function
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001217 * that just subscribes control events.
1218 *
1219 * @sd: pointer to &struct v4l2_subdev
1220 * @fh: pointer to &struct v4l2_fh
1221 * @sub: pointer to &struct v4l2_event_subscription
1222 */
Sylwester Nawrocki22fa4272013-01-22 19:00:23 -03001223int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
1224 struct v4l2_event_subscription *sub);
1225
Mauro Carvalho Chehab8ec4bee2016-07-22 13:57:29 -03001226/**
1227 * v4l2_ctrl_subdev_log_status - Log all controls owned by subdev's control
1228 * handler.
1229 *
1230 * @sd: pointer to &struct v4l2_subdev
1231 */
Sylwester Nawrockiffa9b9f2013-01-22 19:01:02 -03001232int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
1233
Hans Verkuil09965172010-08-01 14:32:42 -03001234#endif