xref: /linux/include/uapi/linux/v4l2-subdev.h (revision 6fd600d742744dc7ef7fc65ca26daa2b1163158a)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * V4L2 subdev userspace API
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * Copyright (C) 2010 Nokia Corporation
6607ca46eSDavid Howells  *
7607ca46eSDavid Howells  * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
8607ca46eSDavid Howells  *	     Sakari Ailus <sakari.ailus@iki.fi>
9607ca46eSDavid Howells  */
10607ca46eSDavid Howells 
11607ca46eSDavid Howells #ifndef __LINUX_V4L2_SUBDEV_H
12607ca46eSDavid Howells #define __LINUX_V4L2_SUBDEV_H
13607ca46eSDavid Howells 
14a418bb3fSLaurent Pinchart #include <linux/const.h>
15607ca46eSDavid Howells #include <linux/ioctl.h>
16607ca46eSDavid Howells #include <linux/types.h>
17607ca46eSDavid Howells #include <linux/v4l2-common.h>
18607ca46eSDavid Howells #include <linux/v4l2-mediabus.h>
19607ca46eSDavid Howells 
20607ca46eSDavid Howells /**
21607ca46eSDavid Howells  * enum v4l2_subdev_format_whence - Media bus format type
22607ca46eSDavid Howells  * @V4L2_SUBDEV_FORMAT_TRY: try format, for negotiation only
23607ca46eSDavid Howells  * @V4L2_SUBDEV_FORMAT_ACTIVE: active format, applied to the device
24607ca46eSDavid Howells  */
25607ca46eSDavid Howells enum v4l2_subdev_format_whence {
26607ca46eSDavid Howells 	V4L2_SUBDEV_FORMAT_TRY = 0,
27607ca46eSDavid Howells 	V4L2_SUBDEV_FORMAT_ACTIVE = 1,
28607ca46eSDavid Howells };
29607ca46eSDavid Howells 
30607ca46eSDavid Howells /**
31607ca46eSDavid Howells  * struct v4l2_subdev_format - Pad-level media bus format
32607ca46eSDavid Howells  * @which: format type (from enum v4l2_subdev_format_whence)
33607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
34607ca46eSDavid Howells  * @format: media bus format (format code and frame size)
352f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
36f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
37607ca46eSDavid Howells  */
38607ca46eSDavid Howells struct v4l2_subdev_format {
39607ca46eSDavid Howells 	__u32 which;
40607ca46eSDavid Howells 	__u32 pad;
41607ca46eSDavid Howells 	struct v4l2_mbus_framefmt format;
422f91e10eSTomi Valkeinen 	__u32 stream;
432f91e10eSTomi Valkeinen 	__u32 reserved[7];
44607ca46eSDavid Howells };
45607ca46eSDavid Howells 
46607ca46eSDavid Howells /**
47607ca46eSDavid Howells  * struct v4l2_subdev_crop - Pad-level crop settings
48607ca46eSDavid Howells  * @which: format type (from enum v4l2_subdev_format_whence)
49607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
50607ca46eSDavid Howells  * @rect: pad crop rectangle boundaries
512f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
52f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
53c580efb9SLaurent Pinchart  *
54c580efb9SLaurent Pinchart  * The subdev crop API is an obsolete interface and may be removed in the
55c580efb9SLaurent Pinchart  * future. It is superseded by the selection API. No new extensions to this
56c580efb9SLaurent Pinchart  * structure will be accepted.
57607ca46eSDavid Howells  */
58607ca46eSDavid Howells struct v4l2_subdev_crop {
59607ca46eSDavid Howells 	__u32 which;
60607ca46eSDavid Howells 	__u32 pad;
61607ca46eSDavid Howells 	struct v4l2_rect rect;
622f91e10eSTomi Valkeinen 	__u32 stream;
632f91e10eSTomi Valkeinen 	__u32 reserved[7];
64607ca46eSDavid Howells };
65607ca46eSDavid Howells 
6662aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE	0x00000001
6762aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC	0x00000002
6862aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC	0x00000004
6962aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC	V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC
7062aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION	0x00000008
7162aacfa9SDafna Hirschfeld 
72607ca46eSDavid Howells /**
73607ca46eSDavid Howells  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
74607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
75607ca46eSDavid Howells  * @index: format index during enumeration
7632b32ce8SBoris BREZILLON  * @code: format code (MEDIA_BUS_FMT_ definitions)
77e1c47e73SHans Verkuil  * @which: format type (from enum v4l2_subdev_format_whence)
7862aacfa9SDafna Hirschfeld  * @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
792f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
80f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
81607ca46eSDavid Howells  */
82607ca46eSDavid Howells struct v4l2_subdev_mbus_code_enum {
83607ca46eSDavid Howells 	__u32 pad;
84607ca46eSDavid Howells 	__u32 index;
85607ca46eSDavid Howells 	__u32 code;
86e1c47e73SHans Verkuil 	__u32 which;
8762aacfa9SDafna Hirschfeld 	__u32 flags;
882f91e10eSTomi Valkeinen 	__u32 stream;
892f91e10eSTomi Valkeinen 	__u32 reserved[6];
90607ca46eSDavid Howells };
91607ca46eSDavid Howells 
92607ca46eSDavid Howells /**
93607ca46eSDavid Howells  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
94607ca46eSDavid Howells  * @index: format index during enumeration
95f12b81e4SHans Verkuil  * @pad: pad number, as reported by the media API
9632b32ce8SBoris BREZILLON  * @code: format code (MEDIA_BUS_FMT_ definitions)
97f12b81e4SHans Verkuil  * @min_width: minimum frame width, in pixels
98f12b81e4SHans Verkuil  * @max_width: maximum frame width, in pixels
99f12b81e4SHans Verkuil  * @min_height: minimum frame height, in pixels
100f12b81e4SHans Verkuil  * @max_height: maximum frame height, in pixels
101e1c47e73SHans Verkuil  * @which: format type (from enum v4l2_subdev_format_whence)
1022f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
103f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
104607ca46eSDavid Howells  */
105607ca46eSDavid Howells struct v4l2_subdev_frame_size_enum {
106607ca46eSDavid Howells 	__u32 index;
107607ca46eSDavid Howells 	__u32 pad;
108607ca46eSDavid Howells 	__u32 code;
109607ca46eSDavid Howells 	__u32 min_width;
110607ca46eSDavid Howells 	__u32 max_width;
111607ca46eSDavid Howells 	__u32 min_height;
112607ca46eSDavid Howells 	__u32 max_height;
113e1c47e73SHans Verkuil 	__u32 which;
1142f91e10eSTomi Valkeinen 	__u32 stream;
1152f91e10eSTomi Valkeinen 	__u32 reserved[7];
116607ca46eSDavid Howells };
117607ca46eSDavid Howells 
118607ca46eSDavid Howells /**
119607ca46eSDavid Howells  * struct v4l2_subdev_frame_interval - Pad-level frame rate
120607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
121607ca46eSDavid Howells  * @interval: frame interval in seconds
1222f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
123805d4311SLaurent Pinchart  * @which: interval type (from enum v4l2_subdev_format_whence)
124f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
125607ca46eSDavid Howells  */
126607ca46eSDavid Howells struct v4l2_subdev_frame_interval {
127607ca46eSDavid Howells 	__u32 pad;
128607ca46eSDavid Howells 	struct v4l2_fract interval;
1292f91e10eSTomi Valkeinen 	__u32 stream;
130805d4311SLaurent Pinchart 	__u32 which;
131805d4311SLaurent Pinchart 	__u32 reserved[7];
132607ca46eSDavid Howells };
133607ca46eSDavid Howells 
134607ca46eSDavid Howells /**
135607ca46eSDavid Howells  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
136607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
137607ca46eSDavid Howells  * @index: frame interval index during enumeration
13832b32ce8SBoris BREZILLON  * @code: format code (MEDIA_BUS_FMT_ definitions)
139607ca46eSDavid Howells  * @width: frame width in pixels
140607ca46eSDavid Howells  * @height: frame height in pixels
141607ca46eSDavid Howells  * @interval: frame interval in seconds
142805d4311SLaurent Pinchart  * @which: interval type (from enum v4l2_subdev_format_whence)
1432f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
144f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
145607ca46eSDavid Howells  */
146607ca46eSDavid Howells struct v4l2_subdev_frame_interval_enum {
147607ca46eSDavid Howells 	__u32 index;
148607ca46eSDavid Howells 	__u32 pad;
149607ca46eSDavid Howells 	__u32 code;
150607ca46eSDavid Howells 	__u32 width;
151607ca46eSDavid Howells 	__u32 height;
152607ca46eSDavid Howells 	struct v4l2_fract interval;
153e1c47e73SHans Verkuil 	__u32 which;
1542f91e10eSTomi Valkeinen 	__u32 stream;
1552f91e10eSTomi Valkeinen 	__u32 reserved[7];
156607ca46eSDavid Howells };
157607ca46eSDavid Howells 
158607ca46eSDavid Howells /**
159607ca46eSDavid Howells  * struct v4l2_subdev_selection - selection info
160607ca46eSDavid Howells  *
161607ca46eSDavid Howells  * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY
162607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
163607ca46eSDavid Howells  * @target: Selection target, used to choose one of possible rectangles,
164607ca46eSDavid Howells  *	    defined in v4l2-common.h; V4L2_SEL_TGT_* .
165607ca46eSDavid Howells  * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
166607ca46eSDavid Howells  * @r: coordinates of the selection window
1672f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
168607ca46eSDavid Howells  * @reserved: for future use, set to zero for now
169607ca46eSDavid Howells  *
170607ca46eSDavid Howells  * Hardware may use multiple helper windows to process a video stream.
171607ca46eSDavid Howells  * The structure is used to exchange this selection areas between
172607ca46eSDavid Howells  * an application and a driver.
173607ca46eSDavid Howells  */
174607ca46eSDavid Howells struct v4l2_subdev_selection {
175607ca46eSDavid Howells 	__u32 which;
176607ca46eSDavid Howells 	__u32 pad;
177607ca46eSDavid Howells 	__u32 target;
178607ca46eSDavid Howells 	__u32 flags;
179607ca46eSDavid Howells 	struct v4l2_rect r;
1802f91e10eSTomi Valkeinen 	__u32 stream;
1812f91e10eSTomi Valkeinen 	__u32 reserved[7];
182607ca46eSDavid Howells };
183607ca46eSDavid Howells 
1846446ec6cSHans Verkuil /**
1856446ec6cSHans Verkuil  * struct v4l2_subdev_capability - subdev capabilities
1866446ec6cSHans Verkuil  * @version: the driver versioning number
1876446ec6cSHans Verkuil  * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*
1886446ec6cSHans Verkuil  * @reserved: for future use, set to zero for now
1896446ec6cSHans Verkuil  */
1906446ec6cSHans Verkuil struct v4l2_subdev_capability {
1916446ec6cSHans Verkuil 	__u32 version;
1926446ec6cSHans Verkuil 	__u32 capabilities;
1936446ec6cSHans Verkuil 	__u32 reserved[14];
1946446ec6cSHans Verkuil };
1956446ec6cSHans Verkuil 
1966446ec6cSHans Verkuil /* The v4l2 sub-device video device node is registered in read-only mode. */
197a53e3c18SHans Verkuil #define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001
1986446ec6cSHans Verkuil 
1999a6b5bf4STomi Valkeinen /* The v4l2 sub-device supports routing and multiplexed streams. */
2009a6b5bf4STomi Valkeinen #define V4L2_SUBDEV_CAP_STREAMS			0x00000002
2019a6b5bf4STomi Valkeinen 
202a418bb3fSLaurent Pinchart /*
203a418bb3fSLaurent Pinchart  * Is the route active? An active route will start when streaming is enabled
204a418bb3fSLaurent Pinchart  * on a video node.
205a418bb3fSLaurent Pinchart  */
206a418bb3fSLaurent Pinchart #define V4L2_SUBDEV_ROUTE_FL_ACTIVE		(1U << 0)
207a418bb3fSLaurent Pinchart 
208a418bb3fSLaurent Pinchart /**
209a418bb3fSLaurent Pinchart  * struct v4l2_subdev_route - A route inside a subdev
210a418bb3fSLaurent Pinchart  *
211a418bb3fSLaurent Pinchart  * @sink_pad: the sink pad index
212a418bb3fSLaurent Pinchart  * @sink_stream: the sink stream identifier
213a418bb3fSLaurent Pinchart  * @source_pad: the source pad index
214a418bb3fSLaurent Pinchart  * @source_stream: the source stream identifier
215a418bb3fSLaurent Pinchart  * @flags: route flags V4L2_SUBDEV_ROUTE_FL_*
216a418bb3fSLaurent Pinchart  * @reserved: drivers and applications must zero this array
217a418bb3fSLaurent Pinchart  */
218a418bb3fSLaurent Pinchart struct v4l2_subdev_route {
219a418bb3fSLaurent Pinchart 	__u32 sink_pad;
220a418bb3fSLaurent Pinchart 	__u32 sink_stream;
221a418bb3fSLaurent Pinchart 	__u32 source_pad;
222a418bb3fSLaurent Pinchart 	__u32 source_stream;
223a418bb3fSLaurent Pinchart 	__u32 flags;
224a418bb3fSLaurent Pinchart 	__u32 reserved[5];
225a418bb3fSLaurent Pinchart };
226a418bb3fSLaurent Pinchart 
227a418bb3fSLaurent Pinchart /**
228a418bb3fSLaurent Pinchart  * struct v4l2_subdev_routing - Subdev routing information
229a418bb3fSLaurent Pinchart  *
230a418bb3fSLaurent Pinchart  * @which: configuration type (from enum v4l2_subdev_format_whence)
231*83a22a07SSakari Ailus  * @len_routes: the length of the routes array, in routes; set by the user, not
232*83a22a07SSakari Ailus  *		modified by the kernel
233a418bb3fSLaurent Pinchart  * @routes: pointer to the routes array
234*83a22a07SSakari Ailus  * @num_routes: the total number of routes, possibly more than fits in the
235*83a22a07SSakari Ailus  *		routes array
236a418bb3fSLaurent Pinchart  * @reserved: drivers and applications must zero this array
237a418bb3fSLaurent Pinchart  */
238a418bb3fSLaurent Pinchart struct v4l2_subdev_routing {
239a418bb3fSLaurent Pinchart 	__u32 which;
240*83a22a07SSakari Ailus 	__u32 len_routes;
241a418bb3fSLaurent Pinchart 	__u64 routes;
242*83a22a07SSakari Ailus 	__u32 num_routes;
243*83a22a07SSakari Ailus 	__u32 reserved[11];
244a418bb3fSLaurent Pinchart };
245a418bb3fSLaurent Pinchart 
246f57fa295STomi Valkeinen /*
247f57fa295STomi Valkeinen  * The client is aware of streams. Setting this flag enables the use of 'stream'
248f57fa295STomi Valkeinen  * fields (referring to the stream number) with various ioctls. If this is not
249f57fa295STomi Valkeinen  * set (which is the default), the 'stream' fields will be forced to 0 by the
250f57fa295STomi Valkeinen  * kernel.
251f57fa295STomi Valkeinen  */
2525d33213fSDan Carpenter #define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
253f57fa295STomi Valkeinen 
254805d4311SLaurent Pinchart /*
255805d4311SLaurent Pinchart  * The client is aware of the struct v4l2_subdev_frame_interval which field. If
256805d4311SLaurent Pinchart  * this is not set (which is the default), the which field is forced to
257805d4311SLaurent Pinchart  * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
258805d4311SLaurent Pinchart  */
259805d4311SLaurent Pinchart #define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
260805d4311SLaurent Pinchart 
261f57fa295STomi Valkeinen /**
262f57fa295STomi Valkeinen  * struct v4l2_subdev_client_capability - Capabilities of the client accessing
263f57fa295STomi Valkeinen  *					  the subdev
264f57fa295STomi Valkeinen  *
265f57fa295STomi Valkeinen  * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags.
266f57fa295STomi Valkeinen  */
267f57fa295STomi Valkeinen struct v4l2_subdev_client_capability {
268f57fa295STomi Valkeinen 	__u64 capabilities;
269f57fa295STomi Valkeinen };
270f57fa295STomi Valkeinen 
271254a4777SHans Verkuil /* Backwards compatibility define --- to be removed */
272254a4777SHans Verkuil #define v4l2_subdev_edid v4l2_edid
273607ca46eSDavid Howells 
2746446ec6cSHans Verkuil #define VIDIOC_SUBDEV_QUERYCAP			_IOR('V',  0, struct v4l2_subdev_capability)
275607ca46eSDavid Howells #define VIDIOC_SUBDEV_G_FMT			_IOWR('V',  4, struct v4l2_subdev_format)
276607ca46eSDavid Howells #define VIDIOC_SUBDEV_S_FMT			_IOWR('V',  5, struct v4l2_subdev_format)
277c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_G_FRAME_INTERVAL		_IOWR('V', 21, struct v4l2_subdev_frame_interval)
278c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_S_FRAME_INTERVAL		_IOWR('V', 22, struct v4l2_subdev_frame_interval)
279c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_ENUM_MBUS_CODE		_IOWR('V',  2, struct v4l2_subdev_mbus_code_enum)
280c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_ENUM_FRAME_SIZE		_IOWR('V', 74, struct v4l2_subdev_frame_size_enum)
281c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL	_IOWR('V', 75, struct v4l2_subdev_frame_interval_enum)
282607ca46eSDavid Howells #define VIDIOC_SUBDEV_G_CROP			_IOWR('V', 59, struct v4l2_subdev_crop)
283607ca46eSDavid Howells #define VIDIOC_SUBDEV_S_CROP			_IOWR('V', 60, struct v4l2_subdev_crop)
284c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_G_SELECTION		_IOWR('V', 61, struct v4l2_subdev_selection)
285c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection)
286a418bb3fSLaurent Pinchart #define VIDIOC_SUBDEV_G_ROUTING			_IOWR('V', 38, struct v4l2_subdev_routing)
287a418bb3fSLaurent Pinchart #define VIDIOC_SUBDEV_S_ROUTING			_IOWR('V', 39, struct v4l2_subdev_routing)
288f57fa295STomi Valkeinen #define VIDIOC_SUBDEV_G_CLIENT_CAP		_IOR('V',  101, struct v4l2_subdev_client_capability)
289f57fa295STomi Valkeinen #define VIDIOC_SUBDEV_S_CLIENT_CAP		_IOWR('V',  102, struct v4l2_subdev_client_capability)
290f57fa295STomi Valkeinen 
2919cfd65e8SLaurent Pinchart /* The following ioctls are identical to the ioctls in videodev2.h */
29256ab8cdbSNiklas Söderlund #define VIDIOC_SUBDEV_G_STD			_IOR('V', 23, v4l2_std_id)
29356ab8cdbSNiklas Söderlund #define VIDIOC_SUBDEV_S_STD			_IOW('V', 24, v4l2_std_id)
29456ab8cdbSNiklas Söderlund #define VIDIOC_SUBDEV_ENUMSTD			_IOWR('V', 25, struct v4l2_standard)
295254a4777SHans Verkuil #define VIDIOC_SUBDEV_G_EDID			_IOWR('V', 40, struct v4l2_edid)
296254a4777SHans Verkuil #define VIDIOC_SUBDEV_S_EDID			_IOWR('V', 41, struct v4l2_edid)
29756ab8cdbSNiklas Söderlund #define VIDIOC_SUBDEV_QUERYSTD			_IOR('V', 63, v4l2_std_id)
2989cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_S_DV_TIMINGS		_IOWR('V', 87, struct v4l2_dv_timings)
2999cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_G_DV_TIMINGS		_IOWR('V', 88, struct v4l2_dv_timings)
3009cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_ENUM_DV_TIMINGS		_IOWR('V', 98, struct v4l2_enum_dv_timings)
3019cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_QUERY_DV_TIMINGS		_IOR('V', 99, struct v4l2_dv_timings)
3029cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_DV_TIMINGS_CAP		_IOWR('V', 100, struct v4l2_dv_timings_cap)
303607ca46eSDavid Howells 
304607ca46eSDavid Howells #endif
305