1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __LINUX_UVCVIDEO_H_
3 #define __LINUX_UVCVIDEO_H_
4 
5 #include <linux/ioctl.h>
6 #include <linux/types.h>
7 
8 /*
9  * Dynamic controls
10  */
11 
12 /* Data types for UVC control data */
13 #define UVC_CTRL_DATA_TYPE_RAW		0
14 #define UVC_CTRL_DATA_TYPE_SIGNED	1
15 #define UVC_CTRL_DATA_TYPE_UNSIGNED	2
16 #define UVC_CTRL_DATA_TYPE_BOOLEAN	3
17 #define UVC_CTRL_DATA_TYPE_ENUM		4
18 #define UVC_CTRL_DATA_TYPE_BITMASK	5
19 #define UVC_CTRL_DATA_TYPE_RECT		6
20 
21 /* Control flags */
22 #define UVC_CTRL_FLAG_SET_CUR		(1 << 0)
23 #define UVC_CTRL_FLAG_GET_CUR		(1 << 1)
24 #define UVC_CTRL_FLAG_GET_MIN		(1 << 2)
25 #define UVC_CTRL_FLAG_GET_MAX		(1 << 3)
26 #define UVC_CTRL_FLAG_GET_RES		(1 << 4)
27 #define UVC_CTRL_FLAG_GET_DEF		(1 << 5)
28 /* Control should be saved at suspend and restored at resume. */
29 #define UVC_CTRL_FLAG_RESTORE		(1 << 6)
30 /* Control can be updated by the camera. */
31 #define UVC_CTRL_FLAG_AUTO_UPDATE	(1 << 7)
32 /* Control supports asynchronous reporting */
33 #define UVC_CTRL_FLAG_ASYNCHRONOUS	(1 << 8)
34 
35 #define UVC_CTRL_FLAG_GET_RANGE \
36 	(UVC_CTRL_FLAG_GET_CUR | UVC_CTRL_FLAG_GET_MIN | \
37 	 UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | \
38 	 UVC_CTRL_FLAG_GET_DEF)
39 
40 #define UVC_MENU_NAME_LEN 32
41 
42 /* V4L2 driver-specific controls */
43 #define V4L2_CID_UVC_REGION_OF_INTEREST_RECT	(V4L2_CID_USER_UVC_BASE + 1)
44 #define V4L2_CID_UVC_REGION_OF_INTEREST_AUTO	(V4L2_CID_USER_UVC_BASE + 2)
45 #define V4L2_UVC_REGION_OF_INTEREST_AUTO_EXPOSURE		(1 << 0)
46 #define V4L2_UVC_REGION_OF_INTEREST_AUTO_IRIS			(1 << 1)
47 #define V4L2_UVC_REGION_OF_INTEREST_AUTO_WHITE_BALANCE		(1 << 2)
48 #define V4L2_UVC_REGION_OF_INTEREST_AUTO_FOCUS			(1 << 3)
49 #define V4L2_UVC_REGION_OF_INTEREST_AUTO_FACE_DETECT		(1 << 4)
50 #define V4L2_UVC_REGION_OF_INTEREST_AUTO_DETECT_AND_TRACK	(1 << 5)
51 #define V4L2_UVC_REGION_OF_INTEREST_AUTO_IMAGE_STABILIZATION	(1 << 6)
52 #define V4L2_UVC_REGION_OF_INTEREST_AUTO_HIGHER_QUALITY		(1 << 7)
53 
54 struct uvc_menu_info {
55 	__u32 value;
56 	__u8 name[UVC_MENU_NAME_LEN];
57 };
58 
59 struct uvc_xu_control_mapping {
60 	__u32 id;
61 	__u8 name[32];
62 	__u8 entity[16];
63 	__u8 selector;
64 
65 	__u8 size;
66 	__u8 offset;
67 	__u32 v4l2_type;
68 	__u32 data_type;
69 
70 	struct uvc_menu_info __user *menu_info;
71 	__u32 menu_count;
72 
73 	__u32 reserved[4];
74 };
75 
76 struct uvc_xu_control_query {
77 	__u8 unit;
78 	__u8 selector;
79 	__u8 query;		/* Video Class-Specific Request Code, */
80 				/* defined in linux/usb/video.h A.8.  */
81 	__u16 size;
82 	__u8 __user *data;
83 };
84 
85 #define UVCIOC_CTRL_MAP		_IOWR('u', 0x20, struct uvc_xu_control_mapping)
86 #define UVCIOC_CTRL_QUERY	_IOWR('u', 0x21, struct uvc_xu_control_query)
87 
88 /*
89  * Metadata node
90  */
91 
92 /**
93  * struct uvc_meta_buf - metadata buffer building block
94  * @ns: system timestamp of the payload in nanoseconds
95  * @sof: USB Frame Number
96  * @length: length of the payload header
97  * @flags: payload header flags
98  * @buf: optional device-specific header data
99  *
100  * UVC metadata nodes fill buffers with possibly multiple instances of this
101  * struct. The first two fields are added by the driver, they can be used for
102  * clock synchronisation. The rest is an exact copy of a UVC payload header.
103  * Only complete objects with complete buffers are included. Therefore it's
104  * always sizeof(meta->ns) + sizeof(meta->sof) + meta->length bytes large.
105  */
106 struct uvc_meta_buf {
107 	__u64 ns;
108 	__u16 sof;
109 	__u8 length;
110 	__u8 flags;
111 	__u8 buf[];
112 } __packed;
113 
114 #endif
115