xref: /linux/include/uapi/linux/v4l2-subdev.h (revision fe33c0fbed75dd464747c0faaedf94c7d8eb4101)
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
53607ca46eSDavid Howells  */
54607ca46eSDavid Howells struct v4l2_subdev_crop {
55607ca46eSDavid Howells 	__u32 which;
56607ca46eSDavid Howells 	__u32 pad;
57607ca46eSDavid Howells 	struct v4l2_rect rect;
582f91e10eSTomi Valkeinen 	__u32 stream;
592f91e10eSTomi Valkeinen 	__u32 reserved[7];
60607ca46eSDavid Howells };
61607ca46eSDavid Howells 
6262aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE	0x00000001
6362aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC	0x00000002
6462aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC	0x00000004
6562aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC	V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC
6662aacfa9SDafna Hirschfeld #define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION	0x00000008
6762aacfa9SDafna Hirschfeld 
68607ca46eSDavid Howells /**
69607ca46eSDavid Howells  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
70607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
71607ca46eSDavid Howells  * @index: format index during enumeration
7232b32ce8SBoris BREZILLON  * @code: format code (MEDIA_BUS_FMT_ definitions)
73e1c47e73SHans Verkuil  * @which: format type (from enum v4l2_subdev_format_whence)
7462aacfa9SDafna Hirschfeld  * @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
752f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
76f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
77607ca46eSDavid Howells  */
78607ca46eSDavid Howells struct v4l2_subdev_mbus_code_enum {
79607ca46eSDavid Howells 	__u32 pad;
80607ca46eSDavid Howells 	__u32 index;
81607ca46eSDavid Howells 	__u32 code;
82e1c47e73SHans Verkuil 	__u32 which;
8362aacfa9SDafna Hirschfeld 	__u32 flags;
842f91e10eSTomi Valkeinen 	__u32 stream;
852f91e10eSTomi Valkeinen 	__u32 reserved[6];
86607ca46eSDavid Howells };
87607ca46eSDavid Howells 
88607ca46eSDavid Howells /**
89607ca46eSDavid Howells  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
90607ca46eSDavid Howells  * @index: format index during enumeration
91f12b81e4SHans Verkuil  * @pad: pad number, as reported by the media API
9232b32ce8SBoris BREZILLON  * @code: format code (MEDIA_BUS_FMT_ definitions)
93f12b81e4SHans Verkuil  * @min_width: minimum frame width, in pixels
94f12b81e4SHans Verkuil  * @max_width: maximum frame width, in pixels
95f12b81e4SHans Verkuil  * @min_height: minimum frame height, in pixels
96f12b81e4SHans Verkuil  * @max_height: maximum frame height, in pixels
97e1c47e73SHans Verkuil  * @which: format type (from enum v4l2_subdev_format_whence)
982f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
99f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
100607ca46eSDavid Howells  */
101607ca46eSDavid Howells struct v4l2_subdev_frame_size_enum {
102607ca46eSDavid Howells 	__u32 index;
103607ca46eSDavid Howells 	__u32 pad;
104607ca46eSDavid Howells 	__u32 code;
105607ca46eSDavid Howells 	__u32 min_width;
106607ca46eSDavid Howells 	__u32 max_width;
107607ca46eSDavid Howells 	__u32 min_height;
108607ca46eSDavid Howells 	__u32 max_height;
109e1c47e73SHans Verkuil 	__u32 which;
1102f91e10eSTomi Valkeinen 	__u32 stream;
1112f91e10eSTomi Valkeinen 	__u32 reserved[7];
112607ca46eSDavid Howells };
113607ca46eSDavid Howells 
114607ca46eSDavid Howells /**
115607ca46eSDavid Howells  * struct v4l2_subdev_frame_interval - Pad-level frame rate
116607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
117607ca46eSDavid Howells  * @interval: frame interval in seconds
1182f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
119*805d4311SLaurent Pinchart  * @which: interval type (from enum v4l2_subdev_format_whence)
120f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
121607ca46eSDavid Howells  */
122607ca46eSDavid Howells struct v4l2_subdev_frame_interval {
123607ca46eSDavid Howells 	__u32 pad;
124607ca46eSDavid Howells 	struct v4l2_fract interval;
1252f91e10eSTomi Valkeinen 	__u32 stream;
126*805d4311SLaurent Pinchart 	__u32 which;
127*805d4311SLaurent Pinchart 	__u32 reserved[7];
128607ca46eSDavid Howells };
129607ca46eSDavid Howells 
130607ca46eSDavid Howells /**
131607ca46eSDavid Howells  * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
132607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
133607ca46eSDavid Howells  * @index: frame interval index during enumeration
13432b32ce8SBoris BREZILLON  * @code: format code (MEDIA_BUS_FMT_ definitions)
135607ca46eSDavid Howells  * @width: frame width in pixels
136607ca46eSDavid Howells  * @height: frame height in pixels
137607ca46eSDavid Howells  * @interval: frame interval in seconds
138*805d4311SLaurent Pinchart  * @which: interval type (from enum v4l2_subdev_format_whence)
1392f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
140f12b81e4SHans Verkuil  * @reserved: drivers and applications must zero this array
141607ca46eSDavid Howells  */
142607ca46eSDavid Howells struct v4l2_subdev_frame_interval_enum {
143607ca46eSDavid Howells 	__u32 index;
144607ca46eSDavid Howells 	__u32 pad;
145607ca46eSDavid Howells 	__u32 code;
146607ca46eSDavid Howells 	__u32 width;
147607ca46eSDavid Howells 	__u32 height;
148607ca46eSDavid Howells 	struct v4l2_fract interval;
149e1c47e73SHans Verkuil 	__u32 which;
1502f91e10eSTomi Valkeinen 	__u32 stream;
1512f91e10eSTomi Valkeinen 	__u32 reserved[7];
152607ca46eSDavid Howells };
153607ca46eSDavid Howells 
154607ca46eSDavid Howells /**
155607ca46eSDavid Howells  * struct v4l2_subdev_selection - selection info
156607ca46eSDavid Howells  *
157607ca46eSDavid Howells  * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY
158607ca46eSDavid Howells  * @pad: pad number, as reported by the media API
159607ca46eSDavid Howells  * @target: Selection target, used to choose one of possible rectangles,
160607ca46eSDavid Howells  *	    defined in v4l2-common.h; V4L2_SEL_TGT_* .
161607ca46eSDavid Howells  * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
162607ca46eSDavid Howells  * @r: coordinates of the selection window
1632f91e10eSTomi Valkeinen  * @stream: stream number, defined in subdev routing
164607ca46eSDavid Howells  * @reserved: for future use, set to zero for now
165607ca46eSDavid Howells  *
166607ca46eSDavid Howells  * Hardware may use multiple helper windows to process a video stream.
167607ca46eSDavid Howells  * The structure is used to exchange this selection areas between
168607ca46eSDavid Howells  * an application and a driver.
169607ca46eSDavid Howells  */
170607ca46eSDavid Howells struct v4l2_subdev_selection {
171607ca46eSDavid Howells 	__u32 which;
172607ca46eSDavid Howells 	__u32 pad;
173607ca46eSDavid Howells 	__u32 target;
174607ca46eSDavid Howells 	__u32 flags;
175607ca46eSDavid Howells 	struct v4l2_rect r;
1762f91e10eSTomi Valkeinen 	__u32 stream;
1772f91e10eSTomi Valkeinen 	__u32 reserved[7];
178607ca46eSDavid Howells };
179607ca46eSDavid Howells 
1806446ec6cSHans Verkuil /**
1816446ec6cSHans Verkuil  * struct v4l2_subdev_capability - subdev capabilities
1826446ec6cSHans Verkuil  * @version: the driver versioning number
1836446ec6cSHans Verkuil  * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*
1846446ec6cSHans Verkuil  * @reserved: for future use, set to zero for now
1856446ec6cSHans Verkuil  */
1866446ec6cSHans Verkuil struct v4l2_subdev_capability {
1876446ec6cSHans Verkuil 	__u32 version;
1886446ec6cSHans Verkuil 	__u32 capabilities;
1896446ec6cSHans Verkuil 	__u32 reserved[14];
1906446ec6cSHans Verkuil };
1916446ec6cSHans Verkuil 
1926446ec6cSHans Verkuil /* The v4l2 sub-device video device node is registered in read-only mode. */
193a53e3c18SHans Verkuil #define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001
1946446ec6cSHans Verkuil 
1959a6b5bf4STomi Valkeinen /* The v4l2 sub-device supports routing and multiplexed streams. */
1969a6b5bf4STomi Valkeinen #define V4L2_SUBDEV_CAP_STREAMS			0x00000002
1979a6b5bf4STomi Valkeinen 
198a418bb3fSLaurent Pinchart /*
199a418bb3fSLaurent Pinchart  * Is the route active? An active route will start when streaming is enabled
200a418bb3fSLaurent Pinchart  * on a video node.
201a418bb3fSLaurent Pinchart  */
202a418bb3fSLaurent Pinchart #define V4L2_SUBDEV_ROUTE_FL_ACTIVE		(1U << 0)
203a418bb3fSLaurent Pinchart 
204a418bb3fSLaurent Pinchart /**
205a418bb3fSLaurent Pinchart  * struct v4l2_subdev_route - A route inside a subdev
206a418bb3fSLaurent Pinchart  *
207a418bb3fSLaurent Pinchart  * @sink_pad: the sink pad index
208a418bb3fSLaurent Pinchart  * @sink_stream: the sink stream identifier
209a418bb3fSLaurent Pinchart  * @source_pad: the source pad index
210a418bb3fSLaurent Pinchart  * @source_stream: the source stream identifier
211a418bb3fSLaurent Pinchart  * @flags: route flags V4L2_SUBDEV_ROUTE_FL_*
212a418bb3fSLaurent Pinchart  * @reserved: drivers and applications must zero this array
213a418bb3fSLaurent Pinchart  */
214a418bb3fSLaurent Pinchart struct v4l2_subdev_route {
215a418bb3fSLaurent Pinchart 	__u32 sink_pad;
216a418bb3fSLaurent Pinchart 	__u32 sink_stream;
217a418bb3fSLaurent Pinchart 	__u32 source_pad;
218a418bb3fSLaurent Pinchart 	__u32 source_stream;
219a418bb3fSLaurent Pinchart 	__u32 flags;
220a418bb3fSLaurent Pinchart 	__u32 reserved[5];
221a418bb3fSLaurent Pinchart };
222a418bb3fSLaurent Pinchart 
223a418bb3fSLaurent Pinchart /**
224a418bb3fSLaurent Pinchart  * struct v4l2_subdev_routing - Subdev routing information
225a418bb3fSLaurent Pinchart  *
226a418bb3fSLaurent Pinchart  * @which: configuration type (from enum v4l2_subdev_format_whence)
227a418bb3fSLaurent Pinchart  * @num_routes: the total number of routes in the routes array
228a418bb3fSLaurent Pinchart  * @routes: pointer to the routes array
229a418bb3fSLaurent Pinchart  * @reserved: drivers and applications must zero this array
230a418bb3fSLaurent Pinchart  */
231a418bb3fSLaurent Pinchart struct v4l2_subdev_routing {
232a418bb3fSLaurent Pinchart 	__u32 which;
233a418bb3fSLaurent Pinchart 	__u32 num_routes;
234a418bb3fSLaurent Pinchart 	__u64 routes;
235a418bb3fSLaurent Pinchart 	__u32 reserved[6];
236a418bb3fSLaurent Pinchart };
237a418bb3fSLaurent Pinchart 
238f57fa295STomi Valkeinen /*
239f57fa295STomi Valkeinen  * The client is aware of streams. Setting this flag enables the use of 'stream'
240f57fa295STomi Valkeinen  * fields (referring to the stream number) with various ioctls. If this is not
241f57fa295STomi Valkeinen  * set (which is the default), the 'stream' fields will be forced to 0 by the
242f57fa295STomi Valkeinen  * kernel.
243f57fa295STomi Valkeinen  */
2445d33213fSDan Carpenter #define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
245f57fa295STomi Valkeinen 
246*805d4311SLaurent Pinchart /*
247*805d4311SLaurent Pinchart  * The client is aware of the struct v4l2_subdev_frame_interval which field. If
248*805d4311SLaurent Pinchart  * this is not set (which is the default), the which field is forced to
249*805d4311SLaurent Pinchart  * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
250*805d4311SLaurent Pinchart  */
251*805d4311SLaurent Pinchart #define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
252*805d4311SLaurent Pinchart 
253f57fa295STomi Valkeinen /**
254f57fa295STomi Valkeinen  * struct v4l2_subdev_client_capability - Capabilities of the client accessing
255f57fa295STomi Valkeinen  *					  the subdev
256f57fa295STomi Valkeinen  *
257f57fa295STomi Valkeinen  * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags.
258f57fa295STomi Valkeinen  */
259f57fa295STomi Valkeinen struct v4l2_subdev_client_capability {
260f57fa295STomi Valkeinen 	__u64 capabilities;
261f57fa295STomi Valkeinen };
262f57fa295STomi Valkeinen 
263254a4777SHans Verkuil /* Backwards compatibility define --- to be removed */
264254a4777SHans Verkuil #define v4l2_subdev_edid v4l2_edid
265607ca46eSDavid Howells 
2666446ec6cSHans Verkuil #define VIDIOC_SUBDEV_QUERYCAP			_IOR('V',  0, struct v4l2_subdev_capability)
267607ca46eSDavid Howells #define VIDIOC_SUBDEV_G_FMT			_IOWR('V',  4, struct v4l2_subdev_format)
268607ca46eSDavid Howells #define VIDIOC_SUBDEV_S_FMT			_IOWR('V',  5, struct v4l2_subdev_format)
269c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_G_FRAME_INTERVAL		_IOWR('V', 21, struct v4l2_subdev_frame_interval)
270c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_S_FRAME_INTERVAL		_IOWR('V', 22, struct v4l2_subdev_frame_interval)
271c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_ENUM_MBUS_CODE		_IOWR('V',  2, struct v4l2_subdev_mbus_code_enum)
272c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_ENUM_FRAME_SIZE		_IOWR('V', 74, struct v4l2_subdev_frame_size_enum)
273c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL	_IOWR('V', 75, struct v4l2_subdev_frame_interval_enum)
274607ca46eSDavid Howells #define VIDIOC_SUBDEV_G_CROP			_IOWR('V', 59, struct v4l2_subdev_crop)
275607ca46eSDavid Howells #define VIDIOC_SUBDEV_S_CROP			_IOWR('V', 60, struct v4l2_subdev_crop)
276c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_G_SELECTION		_IOWR('V', 61, struct v4l2_subdev_selection)
277c4fa146cSLaurent Pinchart #define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection)
278a418bb3fSLaurent Pinchart #define VIDIOC_SUBDEV_G_ROUTING			_IOWR('V', 38, struct v4l2_subdev_routing)
279a418bb3fSLaurent Pinchart #define VIDIOC_SUBDEV_S_ROUTING			_IOWR('V', 39, struct v4l2_subdev_routing)
280f57fa295STomi Valkeinen #define VIDIOC_SUBDEV_G_CLIENT_CAP		_IOR('V',  101, struct v4l2_subdev_client_capability)
281f57fa295STomi Valkeinen #define VIDIOC_SUBDEV_S_CLIENT_CAP		_IOWR('V',  102, struct v4l2_subdev_client_capability)
282f57fa295STomi Valkeinen 
2839cfd65e8SLaurent Pinchart /* The following ioctls are identical to the ioctls in videodev2.h */
28456ab8cdbSNiklas Söderlund #define VIDIOC_SUBDEV_G_STD			_IOR('V', 23, v4l2_std_id)
28556ab8cdbSNiklas Söderlund #define VIDIOC_SUBDEV_S_STD			_IOW('V', 24, v4l2_std_id)
28656ab8cdbSNiklas Söderlund #define VIDIOC_SUBDEV_ENUMSTD			_IOWR('V', 25, struct v4l2_standard)
287254a4777SHans Verkuil #define VIDIOC_SUBDEV_G_EDID			_IOWR('V', 40, struct v4l2_edid)
288254a4777SHans Verkuil #define VIDIOC_SUBDEV_S_EDID			_IOWR('V', 41, struct v4l2_edid)
28956ab8cdbSNiklas Söderlund #define VIDIOC_SUBDEV_QUERYSTD			_IOR('V', 63, v4l2_std_id)
2909cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_S_DV_TIMINGS		_IOWR('V', 87, struct v4l2_dv_timings)
2919cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_G_DV_TIMINGS		_IOWR('V', 88, struct v4l2_dv_timings)
2929cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_ENUM_DV_TIMINGS		_IOWR('V', 98, struct v4l2_enum_dv_timings)
2939cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_QUERY_DV_TIMINGS		_IOR('V', 99, struct v4l2_dv_timings)
2949cfd65e8SLaurent Pinchart #define VIDIOC_SUBDEV_DV_TIMINGS_CAP		_IOWR('V', 100, struct v4l2_dv_timings_cap)
295607ca46eSDavid Howells 
296607ca46eSDavid Howells #endif
297