1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * V4L2 subdev userspace API
4  *
5  * Copyright (C) 2010 Nokia Corporation
6  *
7  * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
8  *	     Sakari Ailus <sakari.ailus@iki.fi>
9  */
10 
11 #ifndef __LINUX_V4L2_SUBDEV_H
12 #define __LINUX_V4L2_SUBDEV_H
13 
14 #include <linux/const.h>
15 #include <linux/ioctl.h>
16 #include <linux/types.h>
17 #include <linux/v4l2-common.h>
18 #include <linux/v4l2-mediabus.h>
19 
20 /**
21  * enum v4l2_subdev_format_whence - Media bus format type
22  * @V4L2_SUBDEV_FORMAT_TRY: try format, for negotiation only
23  * @V4L2_SUBDEV_FORMAT_ACTIVE: active format, applied to the device
24  */
25 enum v4l2_subdev_format_whence {
26 	V4L2_SUBDEV_FORMAT_TRY = 0,
27 	V4L2_SUBDEV_FORMAT_ACTIVE = 1,
28 };
29 
30 /**
31  * struct v4l2_subdev_format - Pad-level media bus format
32  * @which: format type (from enum v4l2_subdev_format_whence)
33  * @pad: pad number, as reported by the media API
34  * @format: media bus format (format code and frame size)
35  * @stream: stream number, defined in subdev routing
36  * @reserved: drivers and applications must zero this array
37  */
38 struct v4l2_subdev_format {
39 	__u32 which;
40 	__u32 pad;
41 	struct v4l2_mbus_framefmt format;
42 	__u32 stream;
43 	__u32 reserved[7];
44 };
45 
46 /**
47  * struct v4l2_subdev_crop - Pad-level crop settings
48  * @which: format type (from enum v4l2_subdev_format_whence)
49  * @pad: pad number, as reported by the media API
50  * @rect: pad crop rectangle boundaries
51  * @stream: stream number, defined in subdev routing
52  * @reserved: drivers and applications must zero this array
53  */
54 struct v4l2_subdev_crop {
55 	__u32 which;
56 	__u32 pad;
57 	struct v4l2_rect rect;
58 	__u32 stream;
59 	__u32 reserved[7];
60 };
61 
62 #define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE	0x00000001
63 #define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC	0x00000002
64 #define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC	0x00000004
65 #define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC	V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC
66 #define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION	0x00000008
67 
68 /**
69  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
70  * @pad: pad number, as reported by the media API
71  * @index: format index during enumeration
72  * @code: format code (MEDIA_BUS_FMT_ definitions)
73  * @which: format type (from enum v4l2_subdev_format_whence)
74  * @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
75  * @stream: stream number, defined in subdev routing
76  * @reserved: drivers and applications must zero this array
77  */
78 struct v4l2_subdev_mbus_code_enum {
79 	__u32 pad;
80 	__u32 index;
81 	__u32 code;
82 	__u32 which;
83 	__u32 flags;
84 	__u32 stream;
85 	__u32 reserved[6];
86 };
87 
88 /**
89  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
90  * @index: format index during enumeration
91  * @pad: pad number, as reported by the media API
92  * @code: format code (MEDIA_BUS_FMT_ definitions)
93  * @min_width: minimum frame width, in pixels
94  * @max_width: maximum frame width, in pixels
95  * @min_height: minimum frame height, in pixels
96  * @max_height: maximum frame height, in pixels
97  * @which: format type (from enum v4l2_subdev_format_whence)
98  * @stream: stream number, defined in subdev routing
99  * @reserved: drivers and applications must zero this array
100  */
101 struct v4l2_subdev_frame_size_enum {
102 	__u32 index;
103 	__u32 pad;
104 	__u32 code;
105 	__u32 min_width;
106 	__u32 max_width;
107 	__u32 min_height;
108 	__u32 max_height;
109 	__u32 which;
110 	__u32 stream;
111 	__u32 reserved[7];
112 };
113 
114 /**
115  * struct v4l2_subdev_frame_interval - Pad-level frame rate
116  * @pad: pad number, as reported by the media API
117  * @interval: frame interval in seconds
118  * @stream: stream number, defined in subdev routing
119  * @reserved: drivers and applications must zero this array
120  */
121 struct v4l2_subdev_frame_interval {
122 	__u32 pad;
123 	struct v4l2_fract interval;
124 	__u32 stream;
125 	__u32 reserved[8];
126 };
127 
128 /**
129  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
130  * @pad: pad number, as reported by the media API
131  * @index: frame interval index during enumeration
132  * @code: format code (MEDIA_BUS_FMT_ definitions)
133  * @width: frame width in pixels
134  * @height: frame height in pixels
135  * @interval: frame interval in seconds
136  * @which: format type (from enum v4l2_subdev_format_whence)
137  * @stream: stream number, defined in subdev routing
138  * @reserved: drivers and applications must zero this array
139  */
140 struct v4l2_subdev_frame_interval_enum {
141 	__u32 index;
142 	__u32 pad;
143 	__u32 code;
144 	__u32 width;
145 	__u32 height;
146 	struct v4l2_fract interval;
147 	__u32 which;
148 	__u32 stream;
149 	__u32 reserved[7];
150 };
151 
152 /**
153  * struct v4l2_subdev_selection - selection info
154  *
155  * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY
156  * @pad: pad number, as reported by the media API
157  * @target: Selection target, used to choose one of possible rectangles,
158  *	    defined in v4l2-common.h; V4L2_SEL_TGT_* .
159  * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
160  * @r: coordinates of the selection window
161  * @stream: stream number, defined in subdev routing
162  * @reserved: for future use, set to zero for now
163  *
164  * Hardware may use multiple helper windows to process a video stream.
165  * The structure is used to exchange this selection areas between
166  * an application and a driver.
167  */
168 struct v4l2_subdev_selection {
169 	__u32 which;
170 	__u32 pad;
171 	__u32 target;
172 	__u32 flags;
173 	struct v4l2_rect r;
174 	__u32 stream;
175 	__u32 reserved[7];
176 };
177 
178 /**
179  * struct v4l2_subdev_capability - subdev capabilities
180  * @version: the driver versioning number
181  * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*
182  * @reserved: for future use, set to zero for now
183  */
184 struct v4l2_subdev_capability {
185 	__u32 version;
186 	__u32 capabilities;
187 	__u32 reserved[14];
188 };
189 
190 /* The v4l2 sub-device video device node is registered in read-only mode. */
191 #define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001
192 
193 /* The v4l2 sub-device supports routing and multiplexed streams. */
194 #define V4L2_SUBDEV_CAP_STREAMS			0x00000002
195 
196 /*
197  * Is the route active? An active route will start when streaming is enabled
198  * on a video node.
199  */
200 #define V4L2_SUBDEV_ROUTE_FL_ACTIVE		(1U << 0)
201 
202 /**
203  * struct v4l2_subdev_route - A route inside a subdev
204  *
205  * @sink_pad: the sink pad index
206  * @sink_stream: the sink stream identifier
207  * @source_pad: the source pad index
208  * @source_stream: the source stream identifier
209  * @flags: route flags V4L2_SUBDEV_ROUTE_FL_*
210  * @reserved: drivers and applications must zero this array
211  */
212 struct v4l2_subdev_route {
213 	__u32 sink_pad;
214 	__u32 sink_stream;
215 	__u32 source_pad;
216 	__u32 source_stream;
217 	__u32 flags;
218 	__u32 reserved[5];
219 };
220 
221 /**
222  * struct v4l2_subdev_routing - Subdev routing information
223  *
224  * @which: configuration type (from enum v4l2_subdev_format_whence)
225  * @num_routes: the total number of routes in the routes array
226  * @routes: pointer to the routes array
227  * @reserved: drivers and applications must zero this array
228  */
229 struct v4l2_subdev_routing {
230 	__u32 which;
231 	__u32 num_routes;
232 	__u64 routes;
233 	__u32 reserved[6];
234 };
235 
236 /*
237  * The client is aware of streams. Setting this flag enables the use of 'stream'
238  * fields (referring to the stream number) with various ioctls. If this is not
239  * set (which is the default), the 'stream' fields will be forced to 0 by the
240  * kernel.
241  */
242  #define V4L2_SUBDEV_CLIENT_CAP_STREAMS		(1ULL << 0)
243 
244 /**
245  * struct v4l2_subdev_client_capability - Capabilities of the client accessing
246  *					  the subdev
247  *
248  * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags.
249  */
250 struct v4l2_subdev_client_capability {
251 	__u64 capabilities;
252 };
253 
254 /* Backwards compatibility define --- to be removed */
255 #define v4l2_subdev_edid v4l2_edid
256 
257 #define VIDIOC_SUBDEV_QUERYCAP			_IOR('V',  0, struct v4l2_subdev_capability)
258 #define VIDIOC_SUBDEV_G_FMT			_IOWR('V',  4, struct v4l2_subdev_format)
259 #define VIDIOC_SUBDEV_S_FMT			_IOWR('V',  5, struct v4l2_subdev_format)
260 #define VIDIOC_SUBDEV_G_FRAME_INTERVAL		_IOWR('V', 21, struct v4l2_subdev_frame_interval)
261 #define VIDIOC_SUBDEV_S_FRAME_INTERVAL		_IOWR('V', 22, struct v4l2_subdev_frame_interval)
262 #define VIDIOC_SUBDEV_ENUM_MBUS_CODE		_IOWR('V',  2, struct v4l2_subdev_mbus_code_enum)
263 #define VIDIOC_SUBDEV_ENUM_FRAME_SIZE		_IOWR('V', 74, struct v4l2_subdev_frame_size_enum)
264 #define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL	_IOWR('V', 75, struct v4l2_subdev_frame_interval_enum)
265 #define VIDIOC_SUBDEV_G_CROP			_IOWR('V', 59, struct v4l2_subdev_crop)
266 #define VIDIOC_SUBDEV_S_CROP			_IOWR('V', 60, struct v4l2_subdev_crop)
267 #define VIDIOC_SUBDEV_G_SELECTION		_IOWR('V', 61, struct v4l2_subdev_selection)
268 #define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection)
269 #define VIDIOC_SUBDEV_G_ROUTING			_IOWR('V', 38, struct v4l2_subdev_routing)
270 #define VIDIOC_SUBDEV_S_ROUTING			_IOWR('V', 39, struct v4l2_subdev_routing)
271 #define VIDIOC_SUBDEV_G_CLIENT_CAP		_IOR('V',  101, struct v4l2_subdev_client_capability)
272 #define VIDIOC_SUBDEV_S_CLIENT_CAP		_IOWR('V',  102, struct v4l2_subdev_client_capability)
273 
274 /* The following ioctls are identical to the ioctls in videodev2.h */
275 #define VIDIOC_SUBDEV_G_STD			_IOR('V', 23, v4l2_std_id)
276 #define VIDIOC_SUBDEV_S_STD			_IOW('V', 24, v4l2_std_id)
277 #define VIDIOC_SUBDEV_ENUMSTD			_IOWR('V', 25, struct v4l2_standard)
278 #define VIDIOC_SUBDEV_G_EDID			_IOWR('V', 40, struct v4l2_edid)
279 #define VIDIOC_SUBDEV_S_EDID			_IOWR('V', 41, struct v4l2_edid)
280 #define VIDIOC_SUBDEV_QUERYSTD			_IOR('V', 63, v4l2_std_id)
281 #define VIDIOC_SUBDEV_S_DV_TIMINGS		_IOWR('V', 87, struct v4l2_dv_timings)
282 #define VIDIOC_SUBDEV_G_DV_TIMINGS		_IOWR('V', 88, struct v4l2_dv_timings)
283 #define VIDIOC_SUBDEV_ENUM_DV_TIMINGS		_IOWR('V', 98, struct v4l2_enum_dv_timings)
284 #define VIDIOC_SUBDEV_QUERY_DV_TIMINGS		_IOR('V', 99, struct v4l2_dv_timings)
285 #define VIDIOC_SUBDEV_DV_TIMINGS_CAP		_IOWR('V', 100, struct v4l2_dv_timings_cap)
286 
287 #endif
288