v4l2-ctrls.h 56 KB

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