xref: /linux/include/uapi/linux/v4l2-subdev.h (revision fe33c0fbed75dd464747c0faaedf94c7d8eb4101)
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  * @which: interval type (from enum v4l2_subdev_format_whence)
120  * @reserved: drivers and applications must zero this array
121  */
122 struct v4l2_subdev_frame_interval {
123 	__u32 pad;
124 	struct v4l2_fract interval;
125 	__u32 stream;
126 	__u32 which;
127 	__u32 reserved[7];
128 };
129 
130 /**
131  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
132  * @pad: pad number, as reported by the media API
133  * @index: frame interval index during enumeration
134  * @code: format code (MEDIA_BUS_FMT_ definitions)
135  * @width: frame width in pixels
136  * @height: frame height in pixels
137  * @interval: frame interval in seconds
138  * @which: interval type (from enum v4l2_subdev_format_whence)
139  * @stream: stream number, defined in subdev routing
140  * @reserved: drivers and applications must zero this array
141  */
142 struct v4l2_subdev_frame_interval_enum {
143 	__u32 index;
144 	__u32 pad;
145 	__u32 code;
146 	__u32 width;
147 	__u32 height;
148 	struct v4l2_fract interval;
149 	__u32 which;
150 	__u32 stream;
151 	__u32 reserved[7];
152 };
153 
154 /**
155  * struct v4l2_subdev_selection - selection info
156  *
157  * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY
158  * @pad: pad number, as reported by the media API
159  * @target: Selection target, used to choose one of possible rectangles,
160  *	    defined in v4l2-common.h; V4L2_SEL_TGT_* .
161  * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
162  * @r: coordinates of the selection window
163  * @stream: stream number, defined in subdev routing
164  * @reserved: for future use, set to zero for now
165  *
166  * Hardware may use multiple helper windows to process a video stream.
167  * The structure is used to exchange this selection areas between
168  * an application and a driver.
169  */
170 struct v4l2_subdev_selection {
171 	__u32 which;
172 	__u32 pad;
173 	__u32 target;
174 	__u32 flags;
175 	struct v4l2_rect r;
176 	__u32 stream;
177 	__u32 reserved[7];
178 };
179 
180 /**
181  * struct v4l2_subdev_capability - subdev capabilities
182  * @version: the driver versioning number
183  * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*
184  * @reserved: for future use, set to zero for now
185  */
186 struct v4l2_subdev_capability {
187 	__u32 version;
188 	__u32 capabilities;
189 	__u32 reserved[14];
190 };
191 
192 /* The v4l2 sub-device video device node is registered in read-only mode. */
193 #define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001
194 
195 /* The v4l2 sub-device supports routing and multiplexed streams. */
196 #define V4L2_SUBDEV_CAP_STREAMS			0x00000002
197 
198 /*
199  * Is the route active? An active route will start when streaming is enabled
200  * on a video node.
201  */
202 #define V4L2_SUBDEV_ROUTE_FL_ACTIVE		(1U << 0)
203 
204 /**
205  * struct v4l2_subdev_route - A route inside a subdev
206  *
207  * @sink_pad: the sink pad index
208  * @sink_stream: the sink stream identifier
209  * @source_pad: the source pad index
210  * @source_stream: the source stream identifier
211  * @flags: route flags V4L2_SUBDEV_ROUTE_FL_*
212  * @reserved: drivers and applications must zero this array
213  */
214 struct v4l2_subdev_route {
215 	__u32 sink_pad;
216 	__u32 sink_stream;
217 	__u32 source_pad;
218 	__u32 source_stream;
219 	__u32 flags;
220 	__u32 reserved[5];
221 };
222 
223 /**
224  * struct v4l2_subdev_routing - Subdev routing information
225  *
226  * @which: configuration type (from enum v4l2_subdev_format_whence)
227  * @num_routes: the total number of routes in the routes array
228  * @routes: pointer to the routes array
229  * @reserved: drivers and applications must zero this array
230  */
231 struct v4l2_subdev_routing {
232 	__u32 which;
233 	__u32 num_routes;
234 	__u64 routes;
235 	__u32 reserved[6];
236 };
237 
238 /*
239  * The client is aware of streams. Setting this flag enables the use of 'stream'
240  * fields (referring to the stream number) with various ioctls. If this is not
241  * set (which is the default), the 'stream' fields will be forced to 0 by the
242  * kernel.
243  */
244 #define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
245 
246 /*
247  * The client is aware of the struct v4l2_subdev_frame_interval which field. If
248  * this is not set (which is the default), the which field is forced to
249  * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
250  */
251 #define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
252 
253 /**
254  * struct v4l2_subdev_client_capability - Capabilities of the client accessing
255  *					  the subdev
256  *
257  * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags.
258  */
259 struct v4l2_subdev_client_capability {
260 	__u64 capabilities;
261 };
262 
263 /* Backwards compatibility define --- to be removed */
264 #define v4l2_subdev_edid v4l2_edid
265 
266 #define VIDIOC_SUBDEV_QUERYCAP			_IOR('V',  0, struct v4l2_subdev_capability)
267 #define VIDIOC_SUBDEV_G_FMT			_IOWR('V',  4, struct v4l2_subdev_format)
268 #define VIDIOC_SUBDEV_S_FMT			_IOWR('V',  5, struct v4l2_subdev_format)
269 #define VIDIOC_SUBDEV_G_FRAME_INTERVAL		_IOWR('V', 21, struct v4l2_subdev_frame_interval)
270 #define VIDIOC_SUBDEV_S_FRAME_INTERVAL		_IOWR('V', 22, struct v4l2_subdev_frame_interval)
271 #define VIDIOC_SUBDEV_ENUM_MBUS_CODE		_IOWR('V',  2, struct v4l2_subdev_mbus_code_enum)
272 #define VIDIOC_SUBDEV_ENUM_FRAME_SIZE		_IOWR('V', 74, struct v4l2_subdev_frame_size_enum)
273 #define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL	_IOWR('V', 75, struct v4l2_subdev_frame_interval_enum)
274 #define VIDIOC_SUBDEV_G_CROP			_IOWR('V', 59, struct v4l2_subdev_crop)
275 #define VIDIOC_SUBDEV_S_CROP			_IOWR('V', 60, struct v4l2_subdev_crop)
276 #define VIDIOC_SUBDEV_G_SELECTION		_IOWR('V', 61, struct v4l2_subdev_selection)
277 #define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection)
278 #define VIDIOC_SUBDEV_G_ROUTING			_IOWR('V', 38, struct v4l2_subdev_routing)
279 #define VIDIOC_SUBDEV_S_ROUTING			_IOWR('V', 39, struct v4l2_subdev_routing)
280 #define VIDIOC_SUBDEV_G_CLIENT_CAP		_IOR('V',  101, struct v4l2_subdev_client_capability)
281 #define VIDIOC_SUBDEV_S_CLIENT_CAP		_IOWR('V',  102, struct v4l2_subdev_client_capability)
282 
283 /* The following ioctls are identical to the ioctls in videodev2.h */
284 #define VIDIOC_SUBDEV_G_STD			_IOR('V', 23, v4l2_std_id)
285 #define VIDIOC_SUBDEV_S_STD			_IOW('V', 24, v4l2_std_id)
286 #define VIDIOC_SUBDEV_ENUMSTD			_IOWR('V', 25, struct v4l2_standard)
287 #define VIDIOC_SUBDEV_G_EDID			_IOWR('V', 40, struct v4l2_edid)
288 #define VIDIOC_SUBDEV_S_EDID			_IOWR('V', 41, struct v4l2_edid)
289 #define VIDIOC_SUBDEV_QUERYSTD			_IOR('V', 63, v4l2_std_id)
290 #define VIDIOC_SUBDEV_S_DV_TIMINGS		_IOWR('V', 87, struct v4l2_dv_timings)
291 #define VIDIOC_SUBDEV_G_DV_TIMINGS		_IOWR('V', 88, struct v4l2_dv_timings)
292 #define VIDIOC_SUBDEV_ENUM_DV_TIMINGS		_IOWR('V', 98, struct v4l2_enum_dv_timings)
293 #define VIDIOC_SUBDEV_QUERY_DV_TIMINGS		_IOR('V', 99, struct v4l2_dv_timings)
294 #define VIDIOC_SUBDEV_DV_TIMINGS_CAP		_IOWR('V', 100, struct v4l2_dv_timings_cap)
295 
296 #endif
297