.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * V4L2 controls support header. |
---|
3 | 4 | * |
---|
4 | 5 | * 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 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #ifndef _V4L2_CTRLS_H |
---|
.. | .. |
---|
20 | 11 | #include <linux/list.h> |
---|
21 | 12 | #include <linux/mutex.h> |
---|
22 | 13 | #include <linux/videodev2.h> |
---|
| 14 | +#include <linux/android_kabi.h> |
---|
| 15 | +#include <media/media-request.h> |
---|
| 16 | + |
---|
| 17 | +/* |
---|
| 18 | + * Include the stateless codec compound control definitions. |
---|
| 19 | + * This will move to the public headers once this API is fully stable. |
---|
| 20 | + */ |
---|
| 21 | +#include <media/mpeg2-ctrls.h> |
---|
| 22 | +#include <media/fwht-ctrls.h> |
---|
| 23 | +#include <media/h264-ctrls.h> |
---|
| 24 | +#include <media/vp8-ctrls.h> |
---|
| 25 | +#include <media/hevc-ctrls.h> |
---|
23 | 26 | |
---|
24 | 27 | /* forward references */ |
---|
25 | 28 | struct file; |
---|
| 29 | +struct poll_table_struct; |
---|
| 30 | +struct v4l2_ctrl; |
---|
26 | 31 | struct v4l2_ctrl_handler; |
---|
27 | 32 | struct v4l2_ctrl_helper; |
---|
28 | | -struct v4l2_ctrl; |
---|
29 | | -struct video_device; |
---|
| 33 | +struct v4l2_fh; |
---|
| 34 | +struct v4l2_fwnode_device_properties; |
---|
30 | 35 | struct v4l2_subdev; |
---|
31 | 36 | struct v4l2_subscribed_event; |
---|
32 | | -struct v4l2_fh; |
---|
33 | | -struct poll_table_struct; |
---|
| 37 | +struct video_device; |
---|
34 | 38 | |
---|
35 | 39 | /** |
---|
36 | 40 | * union v4l2_ctrl_ptr - A pointer to a control value. |
---|
37 | | - * @p_s32: Pointer to a 32-bit signed value. |
---|
38 | | - * @p_s64: Pointer to a 64-bit signed value. |
---|
39 | | - * @p_u8: Pointer to a 8-bit unsigned value. |
---|
40 | | - * @p_u16: Pointer to a 16-bit unsigned value. |
---|
41 | | - * @p_u32: Pointer to a 32-bit unsigned value. |
---|
42 | | - * @p_char: Pointer to a string. |
---|
43 | | - * @p: Pointer to a compound value. |
---|
| 41 | + * @p_s32: Pointer to a 32-bit signed value. |
---|
| 42 | + * @p_s64: Pointer to a 64-bit signed value. |
---|
| 43 | + * @p_u8: Pointer to a 8-bit unsigned value. |
---|
| 44 | + * @p_u16: Pointer to a 16-bit unsigned value. |
---|
| 45 | + * @p_u32: Pointer to a 32-bit unsigned value. |
---|
| 46 | + * @p_char: Pointer to a string. |
---|
| 47 | + * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure. |
---|
| 48 | + * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure. |
---|
| 49 | + * @p_fwht_params: Pointer to a FWHT stateless parameters structure. |
---|
| 50 | + * @p_h264_sps: Pointer to a struct v4l2_ctrl_h264_sps. |
---|
| 51 | + * @p_h264_pps: Pointer to a struct v4l2_ctrl_h264_pps. |
---|
| 52 | + * @p_h264_scaling_matrix: Pointer to a struct v4l2_ctrl_h264_scaling_matrix. |
---|
| 53 | + * @p_h264_slice_params: Pointer to a struct v4l2_ctrl_h264_slice_params. |
---|
| 54 | + * @p_h264_decode_params: Pointer to a struct v4l2_ctrl_h264_decode_params. |
---|
| 55 | + * @p_h264_pred_weights: Pointer to a struct v4l2_ctrl_h264_pred_weights. |
---|
| 56 | + * @p_vp8_frame_header: Pointer to a VP8 frame header structure. |
---|
| 57 | + * @p_hevc_sps: Pointer to an HEVC sequence parameter set structure. |
---|
| 58 | + * @p_hevc_pps: Pointer to an HEVC picture parameter set structure. |
---|
| 59 | + * @p_hevc_slice_params: Pointer to an HEVC slice parameters structure. |
---|
| 60 | + * @p_hdr10_cll: Pointer to an HDR10 Content Light Level structure. |
---|
| 61 | + * @p_hdr10_mastering: Pointer to an HDR10 Mastering Display structure. |
---|
| 62 | + * @p_area: Pointer to an area. |
---|
| 63 | + * @p: Pointer to a compound value. |
---|
| 64 | + * @p_const: Pointer to a constant compound value. |
---|
44 | 65 | */ |
---|
45 | 66 | union v4l2_ctrl_ptr { |
---|
46 | 67 | s32 *p_s32; |
---|
.. | .. |
---|
49 | 70 | u16 *p_u16; |
---|
50 | 71 | u32 *p_u32; |
---|
51 | 72 | char *p_char; |
---|
| 73 | + struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; |
---|
| 74 | + struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization; |
---|
| 75 | + struct v4l2_ctrl_fwht_params *p_fwht_params; |
---|
| 76 | + struct v4l2_ctrl_h264_sps *p_h264_sps; |
---|
| 77 | + struct v4l2_ctrl_h264_pps *p_h264_pps; |
---|
| 78 | + struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix; |
---|
| 79 | + struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; |
---|
| 80 | + struct v4l2_ctrl_h264_decode_params *p_h264_decode_params; |
---|
| 81 | + struct v4l2_ctrl_h264_pred_weights *p_h264_pred_weights; |
---|
| 82 | + struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header; |
---|
| 83 | + struct v4l2_ctrl_hevc_sps *p_hevc_sps; |
---|
| 84 | + struct v4l2_ctrl_hevc_pps *p_hevc_pps; |
---|
| 85 | + struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params; |
---|
| 86 | + struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll; |
---|
| 87 | + struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; |
---|
| 88 | + struct v4l2_area *p_area; |
---|
52 | 89 | void *p; |
---|
| 90 | + const void *p_const; |
---|
| 91 | + |
---|
| 92 | + ANDROID_KABI_RESERVE(1); |
---|
| 93 | + ANDROID_KABI_RESERVE(2); |
---|
53 | 94 | }; |
---|
| 95 | + |
---|
| 96 | +/** |
---|
| 97 | + * v4l2_ctrl_ptr_create() - Helper function to return a v4l2_ctrl_ptr from a |
---|
| 98 | + * void pointer |
---|
| 99 | + * @ptr: The void pointer |
---|
| 100 | + */ |
---|
| 101 | +static inline union v4l2_ctrl_ptr v4l2_ctrl_ptr_create(void *ptr) |
---|
| 102 | +{ |
---|
| 103 | + union v4l2_ctrl_ptr p = { .p = ptr }; |
---|
| 104 | + |
---|
| 105 | + return p; |
---|
| 106 | +} |
---|
54 | 107 | |
---|
55 | 108 | /** |
---|
56 | 109 | * struct v4l2_ctrl_ops - The control operations that the driver has to provide. |
---|
.. | .. |
---|
70 | 123 | int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl); |
---|
71 | 124 | int (*try_ctrl)(struct v4l2_ctrl *ctrl); |
---|
72 | 125 | int (*s_ctrl)(struct v4l2_ctrl *ctrl); |
---|
| 126 | + |
---|
| 127 | + ANDROID_KABI_RESERVE(1); |
---|
73 | 128 | }; |
---|
74 | 129 | |
---|
75 | 130 | /** |
---|
.. | .. |
---|
91 | 146 | void (*log)(const struct v4l2_ctrl *ctrl); |
---|
92 | 147 | int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx, |
---|
93 | 148 | union v4l2_ctrl_ptr ptr); |
---|
| 149 | + |
---|
| 150 | + ANDROID_KABI_RESERVE(1); |
---|
94 | 151 | }; |
---|
95 | 152 | |
---|
96 | 153 | /** |
---|
.. | .. |
---|
181 | 238 | * not freed when the control is deleted. Should this be needed |
---|
182 | 239 | * then a new internal bitfield can be added to tell the framework |
---|
183 | 240 | * to free this pointer. |
---|
| 241 | + * @p_def: The control's default value represented via a union which |
---|
| 242 | + * provides a standard way of accessing control types |
---|
| 243 | + * through a pointer (for compound controls only). |
---|
184 | 244 | * @p_cur: The control's current value represented via a union which |
---|
185 | 245 | * provides a standard way of accessing control types |
---|
186 | 246 | * through a pointer. |
---|
.. | .. |
---|
235 | 295 | s32 val; |
---|
236 | 296 | } cur; |
---|
237 | 297 | |
---|
| 298 | + union v4l2_ctrl_ptr p_def; |
---|
238 | 299 | union v4l2_ctrl_ptr p_new; |
---|
239 | 300 | union v4l2_ctrl_ptr p_cur; |
---|
| 301 | + |
---|
| 302 | + ANDROID_KABI_RESERVE(1); |
---|
240 | 303 | }; |
---|
241 | 304 | |
---|
242 | 305 | /** |
---|
.. | .. |
---|
247 | 310 | * @ctrl: The actual control information. |
---|
248 | 311 | * @helper: Pointer to helper struct. Used internally in |
---|
249 | 312 | * ``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``. |
---|
| 313 | + * @from_other_dev: If true, then @ctrl was defined in another |
---|
| 314 | + * device than the &struct v4l2_ctrl_handler. |
---|
| 315 | + * @req_done: Internal flag: if the control handler containing this control |
---|
| 316 | + * reference is bound to a media request, then this is set when |
---|
| 317 | + * the control has been applied. This prevents applying controls |
---|
| 318 | + * from a cluster with multiple controls twice (when the first |
---|
| 319 | + * control of a cluster is applied, they all are). |
---|
| 320 | + * @valid_p_req: If set, then p_req contains the control value for the request. |
---|
| 321 | + * @p_req: If the control handler containing this control reference |
---|
| 322 | + * is bound to a media request, then this points to the |
---|
| 323 | + * value of the control that must be applied when the request |
---|
| 324 | + * is executed, or to the value of the control at the time |
---|
| 325 | + * that the request was completed. If @valid_p_req is false, |
---|
| 326 | + * then this control was never set for this request and the |
---|
| 327 | + * control will not be updated when this request is applied. |
---|
250 | 328 | * |
---|
251 | 329 | * Each control handler has a list of these refs. The list_head is used to |
---|
252 | 330 | * keep a sorted-by-control-ID list of all controls, while the next pointer |
---|
.. | .. |
---|
257 | 335 | struct v4l2_ctrl_ref *next; |
---|
258 | 336 | struct v4l2_ctrl *ctrl; |
---|
259 | 337 | struct v4l2_ctrl_helper *helper; |
---|
| 338 | + bool from_other_dev; |
---|
| 339 | + bool req_done; |
---|
| 340 | + bool valid_p_req; |
---|
| 341 | + union v4l2_ctrl_ptr p_req; |
---|
| 342 | + |
---|
| 343 | + ANDROID_KABI_RESERVE(1); |
---|
260 | 344 | }; |
---|
261 | 345 | |
---|
262 | 346 | /** |
---|
.. | .. |
---|
280 | 364 | * @notify_priv: Passed as argument to the v4l2_ctrl notify callback. |
---|
281 | 365 | * @nr_of_buckets: Total number of buckets in the array. |
---|
282 | 366 | * @error: The error code of the first failed control addition. |
---|
| 367 | + * @request_is_queued: True if the request was queued. |
---|
| 368 | + * @requests: List to keep track of open control handler request objects. |
---|
| 369 | + * For the parent control handler (@req_obj.ops == NULL) this |
---|
| 370 | + * is the list header. When the parent control handler is |
---|
| 371 | + * removed, it has to unbind and put all these requests since |
---|
| 372 | + * they refer to the parent. |
---|
| 373 | + * @requests_queued: List of the queued requests. This determines the order |
---|
| 374 | + * in which these controls are applied. Once the request is |
---|
| 375 | + * completed it is removed from this list. |
---|
| 376 | + * @req_obj: The &struct media_request_object, used to link into a |
---|
| 377 | + * &struct media_request. This request object has a refcount. |
---|
283 | 378 | */ |
---|
284 | 379 | struct v4l2_ctrl_handler { |
---|
285 | 380 | struct mutex _lock; |
---|
.. | .. |
---|
292 | 387 | void *notify_priv; |
---|
293 | 388 | u16 nr_of_buckets; |
---|
294 | 389 | int error; |
---|
| 390 | + bool request_is_queued; |
---|
| 391 | + struct list_head requests; |
---|
| 392 | + struct list_head requests_queued; |
---|
| 393 | + struct media_request_object req_obj; |
---|
| 394 | + |
---|
| 395 | + ANDROID_KABI_RESERVE(1); |
---|
295 | 396 | }; |
---|
296 | 397 | |
---|
297 | 398 | /** |
---|
.. | .. |
---|
306 | 407 | * @max: The control's maximum value. |
---|
307 | 408 | * @step: The control's step value for non-menu controls. |
---|
308 | 409 | * @def: The control's default value. |
---|
| 410 | + * @p_def: The control's default value for compound controls. |
---|
309 | 411 | * @dims: The size of each dimension. |
---|
310 | 412 | * @elem_size: The size in bytes of the control. |
---|
311 | 413 | * @flags: The control's flags. |
---|
.. | .. |
---|
334 | 436 | s64 max; |
---|
335 | 437 | u64 step; |
---|
336 | 438 | s64 def; |
---|
| 439 | + union v4l2_ctrl_ptr p_def; |
---|
337 | 440 | u32 dims[V4L2_CTRL_MAX_DIMS]; |
---|
338 | 441 | u32 elem_size; |
---|
339 | 442 | u32 flags; |
---|
.. | .. |
---|
341 | 444 | const char * const *qmenu; |
---|
342 | 445 | const s64 *qmenu_int; |
---|
343 | 446 | unsigned int is_private:1; |
---|
| 447 | + |
---|
| 448 | + ANDROID_KABI_RESERVE(1); |
---|
344 | 449 | }; |
---|
345 | 450 | |
---|
346 | 451 | /** |
---|
.. | .. |
---|
596 | 701 | const char * const *qmenu); |
---|
597 | 702 | |
---|
598 | 703 | /** |
---|
| 704 | + * v4l2_ctrl_new_std_compound() - Allocate and initialize a new standard V4L2 |
---|
| 705 | + * compound control. |
---|
| 706 | + * |
---|
| 707 | + * @hdl: The control handler. |
---|
| 708 | + * @ops: The control ops. |
---|
| 709 | + * @id: The control ID. |
---|
| 710 | + * @p_def: The control's default value. |
---|
| 711 | + * |
---|
| 712 | + * Sames as v4l2_ctrl_new_std(), but with support to compound controls, thanks |
---|
| 713 | + * to the @p_def field. Use v4l2_ctrl_ptr_create() to create @p_def from a |
---|
| 714 | + * pointer. Use v4l2_ctrl_ptr_create(NULL) if the default value of the |
---|
| 715 | + * compound control should be all zeroes. |
---|
| 716 | + * |
---|
| 717 | + */ |
---|
| 718 | +struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl, |
---|
| 719 | + const struct v4l2_ctrl_ops *ops, |
---|
| 720 | + u32 id, |
---|
| 721 | + const union v4l2_ctrl_ptr p_def); |
---|
| 722 | + |
---|
| 723 | +/** |
---|
599 | 724 | * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control. |
---|
600 | 725 | * |
---|
601 | 726 | * @hdl: The control handler. |
---|
.. | .. |
---|
605 | 730 | * @def: The control's default value. |
---|
606 | 731 | * @qmenu_int: The control's menu entries. |
---|
607 | 732 | * |
---|
608 | | - * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionaly |
---|
| 733 | + * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionally |
---|
609 | 734 | * takes as an argument an array of integers determining the menu items. |
---|
610 | 735 | * |
---|
611 | 736 | * If @id refers to a non-integer-menu control, then this function will |
---|
.. | .. |
---|
633 | 758 | * @add: The control handler whose controls you want to add to |
---|
634 | 759 | * the @hdl control handler. |
---|
635 | 760 | * @filter: This function will filter which controls should be added. |
---|
| 761 | + * @from_other_dev: If true, then the controls in @add were defined in another |
---|
| 762 | + * device than @hdl. |
---|
636 | 763 | * |
---|
637 | 764 | * Does nothing if either of the two handlers is a NULL pointer. |
---|
638 | 765 | * If @filter is NULL, then all controls are added. Otherwise only those |
---|
.. | .. |
---|
642 | 769 | */ |
---|
643 | 770 | int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, |
---|
644 | 771 | struct v4l2_ctrl_handler *add, |
---|
645 | | - v4l2_ctrl_filter filter); |
---|
| 772 | + v4l2_ctrl_filter filter, |
---|
| 773 | + bool from_other_dev); |
---|
646 | 774 | |
---|
647 | 775 | /** |
---|
648 | 776 | * v4l2_ctrl_radio_filter() - Standard filter for radio controls. |
---|
.. | .. |
---|
729 | 857 | void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); |
---|
730 | 858 | |
---|
731 | 859 | /** |
---|
| 860 | + * __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab. |
---|
| 861 | + * |
---|
| 862 | + * @ctrl: The control to (de)activate. |
---|
| 863 | + * @grabbed: True if the control should become grabbed. |
---|
| 864 | + * |
---|
| 865 | + * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically. |
---|
| 866 | + * Does nothing if @ctrl == NULL. |
---|
| 867 | + * The V4L2_EVENT_CTRL event will be generated afterwards. |
---|
| 868 | + * This will usually be called when starting or stopping streaming in the |
---|
| 869 | + * driver. |
---|
| 870 | + * |
---|
| 871 | + * This function assumes that the control handler is locked by the caller. |
---|
| 872 | + */ |
---|
| 873 | +void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); |
---|
| 874 | + |
---|
| 875 | +/** |
---|
732 | 876 | * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed. |
---|
733 | 877 | * |
---|
734 | 878 | * @ctrl: The control to (de)activate. |
---|
.. | .. |
---|
743 | 887 | * This function assumes that the control handler is not locked and will |
---|
744 | 888 | * take the lock itself. |
---|
745 | 889 | */ |
---|
746 | | -void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); |
---|
| 890 | +static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) |
---|
| 891 | +{ |
---|
| 892 | + if (!ctrl) |
---|
| 893 | + return; |
---|
| 894 | + |
---|
| 895 | + v4l2_ctrl_lock(ctrl); |
---|
| 896 | + __v4l2_ctrl_grab(ctrl, grabbed); |
---|
| 897 | + v4l2_ctrl_unlock(ctrl); |
---|
| 898 | +} |
---|
747 | 899 | |
---|
748 | 900 | /** |
---|
749 | 901 | *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() |
---|
.. | .. |
---|
864 | 1016 | * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl(). |
---|
865 | 1017 | * |
---|
866 | 1018 | * @ctrl: The control. |
---|
867 | | - * @val: TheControls name new value. |
---|
| 1019 | + * @val: The new value. |
---|
868 | 1020 | * |
---|
869 | 1021 | * This sets the control's new value safely by going through the control |
---|
870 | 1022 | * framework. This function assumes the control's handler is already locked, |
---|
.. | .. |
---|
969 | 1121 | * |
---|
970 | 1122 | * @ctrl: The control. |
---|
971 | 1123 | * @s: The new string. |
---|
972 | | - *Controls name |
---|
| 1124 | + * |
---|
973 | 1125 | * This sets the control's new string safely by going through the control |
---|
974 | 1126 | * framework. This function will lock the control's handler, so it cannot be |
---|
975 | 1127 | * used from within the &v4l2_ctrl_ops functions. |
---|
.. | .. |
---|
986 | 1138 | |
---|
987 | 1139 | return rval; |
---|
988 | 1140 | } |
---|
| 1141 | + |
---|
| 1142 | +/** |
---|
| 1143 | + * __v4l2_ctrl_s_ctrl_compound() - Unlocked variant to set a compound control |
---|
| 1144 | + * |
---|
| 1145 | + * @ctrl: The control. |
---|
| 1146 | + * @type: The type of the data. |
---|
| 1147 | + * @p: The new compound payload. |
---|
| 1148 | + * |
---|
| 1149 | + * This sets the control's new compound payload safely by going through the |
---|
| 1150 | + * control framework. This function assumes the control's handler is already |
---|
| 1151 | + * locked, allowing it to be used from within the &v4l2_ctrl_ops functions. |
---|
| 1152 | + * |
---|
| 1153 | + * This function is for compound type controls only. |
---|
| 1154 | + */ |
---|
| 1155 | +int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl, |
---|
| 1156 | + enum v4l2_ctrl_type type, const void *p); |
---|
| 1157 | + |
---|
| 1158 | +/** |
---|
| 1159 | + * v4l2_ctrl_s_ctrl_compound() - Helper function to set a compound control |
---|
| 1160 | + * from within a driver. |
---|
| 1161 | + * |
---|
| 1162 | + * @ctrl: The control. |
---|
| 1163 | + * @type: The type of the data. |
---|
| 1164 | + * @p: The new compound payload. |
---|
| 1165 | + * |
---|
| 1166 | + * This sets the control's new compound payload safely by going through the |
---|
| 1167 | + * control framework. This function will lock the control's handler, so it |
---|
| 1168 | + * cannot be used from within the &v4l2_ctrl_ops functions. |
---|
| 1169 | + * |
---|
| 1170 | + * This function is for compound type controls only. |
---|
| 1171 | + */ |
---|
| 1172 | +static inline int v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl, |
---|
| 1173 | + enum v4l2_ctrl_type type, |
---|
| 1174 | + const void *p) |
---|
| 1175 | +{ |
---|
| 1176 | + int rval; |
---|
| 1177 | + |
---|
| 1178 | + v4l2_ctrl_lock(ctrl); |
---|
| 1179 | + rval = __v4l2_ctrl_s_ctrl_compound(ctrl, type, p); |
---|
| 1180 | + v4l2_ctrl_unlock(ctrl); |
---|
| 1181 | + |
---|
| 1182 | + return rval; |
---|
| 1183 | +} |
---|
| 1184 | + |
---|
| 1185 | +/* Helper defines for area type controls */ |
---|
| 1186 | +#define __v4l2_ctrl_s_ctrl_area(ctrl, area) \ |
---|
| 1187 | + __v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area)) |
---|
| 1188 | +#define v4l2_ctrl_s_ctrl_area(ctrl, area) \ |
---|
| 1189 | + v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area)) |
---|
989 | 1190 | |
---|
990 | 1191 | /* Internal helper functions that deal with control events. */ |
---|
991 | 1192 | extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; |
---|
.. | .. |
---|
1045 | 1246 | * @wait: pointer to struct poll_table_struct |
---|
1046 | 1247 | */ |
---|
1047 | 1248 | __poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait); |
---|
| 1249 | + |
---|
| 1250 | +/** |
---|
| 1251 | + * v4l2_ctrl_request_setup - helper function to apply control values in a request |
---|
| 1252 | + * |
---|
| 1253 | + * @req: The request |
---|
| 1254 | + * @parent: The parent control handler ('priv' in media_request_object_find()) |
---|
| 1255 | + * |
---|
| 1256 | + * This is a helper function to call the control handler's s_ctrl callback with |
---|
| 1257 | + * the control values contained in the request. Do note that this approach of |
---|
| 1258 | + * applying control values in a request is only applicable to memory-to-memory |
---|
| 1259 | + * devices. |
---|
| 1260 | + */ |
---|
| 1261 | +int v4l2_ctrl_request_setup(struct media_request *req, |
---|
| 1262 | + struct v4l2_ctrl_handler *parent); |
---|
| 1263 | + |
---|
| 1264 | +/** |
---|
| 1265 | + * v4l2_ctrl_request_complete - Complete a control handler request object |
---|
| 1266 | + * |
---|
| 1267 | + * @req: The request |
---|
| 1268 | + * @parent: The parent control handler ('priv' in media_request_object_find()) |
---|
| 1269 | + * |
---|
| 1270 | + * This function is to be called on each control handler that may have had a |
---|
| 1271 | + * request object associated with it, i.e. control handlers of a driver that |
---|
| 1272 | + * supports requests. |
---|
| 1273 | + * |
---|
| 1274 | + * The function first obtains the values of any volatile controls in the control |
---|
| 1275 | + * handler and attach them to the request. Then, the function completes the |
---|
| 1276 | + * request object. |
---|
| 1277 | + */ |
---|
| 1278 | +void v4l2_ctrl_request_complete(struct media_request *req, |
---|
| 1279 | + struct v4l2_ctrl_handler *parent); |
---|
| 1280 | + |
---|
| 1281 | +/** |
---|
| 1282 | + * v4l2_ctrl_request_hdl_find - Find the control handler in the request |
---|
| 1283 | + * |
---|
| 1284 | + * @req: The request |
---|
| 1285 | + * @parent: The parent control handler ('priv' in media_request_object_find()) |
---|
| 1286 | + * |
---|
| 1287 | + * This function finds the control handler in the request. It may return |
---|
| 1288 | + * NULL if not found. When done, you must call v4l2_ctrl_request_put_hdl() |
---|
| 1289 | + * with the returned handler pointer. |
---|
| 1290 | + * |
---|
| 1291 | + * If the request is not in state VALIDATING or QUEUED, then this function |
---|
| 1292 | + * will always return NULL. |
---|
| 1293 | + * |
---|
| 1294 | + * Note that in state VALIDATING the req_queue_mutex is held, so |
---|
| 1295 | + * no objects can be added or deleted from the request. |
---|
| 1296 | + * |
---|
| 1297 | + * In state QUEUED it is the driver that will have to ensure this. |
---|
| 1298 | + */ |
---|
| 1299 | +struct v4l2_ctrl_handler *v4l2_ctrl_request_hdl_find(struct media_request *req, |
---|
| 1300 | + struct v4l2_ctrl_handler *parent); |
---|
| 1301 | + |
---|
| 1302 | +/** |
---|
| 1303 | + * v4l2_ctrl_request_hdl_put - Put the control handler |
---|
| 1304 | + * |
---|
| 1305 | + * @hdl: Put this control handler |
---|
| 1306 | + * |
---|
| 1307 | + * This function released the control handler previously obtained from' |
---|
| 1308 | + * v4l2_ctrl_request_hdl_find(). |
---|
| 1309 | + */ |
---|
| 1310 | +static inline void v4l2_ctrl_request_hdl_put(struct v4l2_ctrl_handler *hdl) |
---|
| 1311 | +{ |
---|
| 1312 | + if (hdl) |
---|
| 1313 | + media_request_object_put(&hdl->req_obj); |
---|
| 1314 | +} |
---|
| 1315 | + |
---|
| 1316 | +/** |
---|
| 1317 | + * v4l2_ctrl_request_ctrl_find() - Find a control with the given ID. |
---|
| 1318 | + * |
---|
| 1319 | + * @hdl: The control handler from the request. |
---|
| 1320 | + * @id: The ID of the control to find. |
---|
| 1321 | + * |
---|
| 1322 | + * This function returns a pointer to the control if this control is |
---|
| 1323 | + * part of the request or NULL otherwise. |
---|
| 1324 | + */ |
---|
| 1325 | +struct v4l2_ctrl * |
---|
| 1326 | +v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id); |
---|
1048 | 1327 | |
---|
1049 | 1328 | /* Helpers for ioctl_ops */ |
---|
1050 | 1329 | |
---|
.. | .. |
---|
1112 | 1391 | * :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl |
---|
1113 | 1392 | * |
---|
1114 | 1393 | * @hdl: pointer to &struct v4l2_ctrl_handler |
---|
| 1394 | + * @vdev: pointer to &struct video_device |
---|
| 1395 | + * @mdev: pointer to &struct media_device |
---|
1115 | 1396 | * @c: pointer to &struct v4l2_ext_controls |
---|
1116 | 1397 | * |
---|
1117 | 1398 | * If hdl == NULL then they will all return -EINVAL. |
---|
1118 | 1399 | */ |
---|
1119 | | -int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, |
---|
1120 | | - struct v4l2_ext_controls *c); |
---|
| 1400 | +int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct video_device *vdev, |
---|
| 1401 | + struct media_device *mdev, struct v4l2_ext_controls *c); |
---|
1121 | 1402 | |
---|
1122 | 1403 | /** |
---|
1123 | 1404 | * v4l2_try_ext_ctrls - Helper function to implement |
---|
1124 | 1405 | * :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl |
---|
1125 | 1406 | * |
---|
1126 | 1407 | * @hdl: pointer to &struct v4l2_ctrl_handler |
---|
| 1408 | + * @vdev: pointer to &struct video_device |
---|
| 1409 | + * @mdev: pointer to &struct media_device |
---|
1127 | 1410 | * @c: pointer to &struct v4l2_ext_controls |
---|
1128 | 1411 | * |
---|
1129 | 1412 | * If hdl == NULL then they will all return -EINVAL. |
---|
1130 | 1413 | */ |
---|
1131 | 1414 | int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, |
---|
| 1415 | + struct video_device *vdev, |
---|
| 1416 | + struct media_device *mdev, |
---|
1132 | 1417 | struct v4l2_ext_controls *c); |
---|
1133 | 1418 | |
---|
1134 | 1419 | /** |
---|
.. | .. |
---|
1137 | 1422 | * |
---|
1138 | 1423 | * @fh: pointer to &struct v4l2_fh |
---|
1139 | 1424 | * @hdl: pointer to &struct v4l2_ctrl_handler |
---|
| 1425 | + * @vdev: pointer to &struct video_device |
---|
| 1426 | + * @mdev: pointer to &struct media_device |
---|
1140 | 1427 | * @c: pointer to &struct v4l2_ext_controls |
---|
1141 | 1428 | * |
---|
1142 | 1429 | * If hdl == NULL then they will all return -EINVAL. |
---|
1143 | 1430 | */ |
---|
1144 | 1431 | int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, |
---|
| 1432 | + struct video_device *vdev, |
---|
| 1433 | + struct media_device *mdev, |
---|
1145 | 1434 | struct v4l2_ext_controls *c); |
---|
1146 | 1435 | |
---|
1147 | 1436 | /** |
---|
.. | .. |
---|
1164 | 1453 | */ |
---|
1165 | 1454 | int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd); |
---|
1166 | 1455 | |
---|
| 1456 | +/** |
---|
| 1457 | + * v4l2_ctrl_new_fwnode_properties() - Register controls for the device |
---|
| 1458 | + * properties |
---|
| 1459 | + * |
---|
| 1460 | + * @hdl: pointer to &struct v4l2_ctrl_handler to register controls on |
---|
| 1461 | + * @ctrl_ops: pointer to &struct v4l2_ctrl_ops to register controls with |
---|
| 1462 | + * @p: pointer to &struct v4l2_fwnode_device_properties |
---|
| 1463 | + * |
---|
| 1464 | + * This function registers controls associated to device properties, using the |
---|
| 1465 | + * property values contained in @p parameter, if the property has been set to |
---|
| 1466 | + * a value. |
---|
| 1467 | + * |
---|
| 1468 | + * Currently the following v4l2 controls are parsed and registered: |
---|
| 1469 | + * - V4L2_CID_CAMERA_ORIENTATION |
---|
| 1470 | + * - V4L2_CID_CAMERA_SENSOR_ROTATION; |
---|
| 1471 | + * |
---|
| 1472 | + * Controls already registered by the caller with the @hdl control handler are |
---|
| 1473 | + * not overwritten. Callers should register the controls they want to handle |
---|
| 1474 | + * themselves before calling this function. |
---|
| 1475 | + * |
---|
| 1476 | + * Return: 0 on success, a negative error code on failure. |
---|
| 1477 | + */ |
---|
| 1478 | +int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl, |
---|
| 1479 | + const struct v4l2_ctrl_ops *ctrl_ops, |
---|
| 1480 | + const struct v4l2_fwnode_device_properties *p); |
---|
1167 | 1481 | #endif |
---|