v4l2-ctrls.h 38 KB

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