1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * V4L2 subdev userspace API
5 * Copyright (C) 2010 Nokia Corporation
7 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
8 * Sakari Ailus <sakari.ailus@iki.fi>
11 #ifndef __LINUX_V4L2_SUBDEV_H
12 #define __LINUX_V4L2_SUBDEV_H
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>
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
25 enum v4l2_subdev_format_whence {
26 V4L2_SUBDEV_FORMAT_TRY = 0,
27 V4L2_SUBDEV_FORMAT_ACTIVE = 1,
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
38 struct v4l2_subdev_format {
41 struct v4l2_mbus_framefmt format;
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
54 struct v4l2_subdev_crop {
57 struct v4l2_rect rect;
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
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
78 struct v4l2_subdev_mbus_code_enum {
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
101 struct v4l2_subdev_frame_size_enum {
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
122 struct v4l2_subdev_frame_interval {
124 struct v4l2_fract interval;
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
142 struct v4l2_subdev_frame_interval_enum {
148 struct v4l2_fract interval;
155 * struct v4l2_subdev_selection - selection info
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
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.
170 struct v4l2_subdev_selection {
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
186 struct v4l2_subdev_capability {
192 /* The v4l2 sub-device video device node is registered in read-only mode. */
193 #define V4L2_SUBDEV_CAP_RO_SUBDEV 0x00000001
195 /* The v4l2 sub-device supports routing and multiplexed streams. */
196 #define V4L2_SUBDEV_CAP_STREAMS 0x00000002
199 * Is the route active? An active route will start when streaming is enabled
202 #define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0)
205 * struct v4l2_subdev_route - A route inside a subdev
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
214 struct v4l2_subdev_route {
224 * struct v4l2_subdev_routing - Subdev routing information
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
231 struct v4l2_subdev_routing {
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
244 #define V4L2_SUBDEV_CLIENT_CAP_STREAMS (1ULL << 0)
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.
251 #define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH (1ULL << 1)
254 * struct v4l2_subdev_client_capability - Capabilities of the client accessing
257 * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags.
259 struct v4l2_subdev_client_capability {
263 /* Backwards compatibility define --- to be removed */
264 #define v4l2_subdev_edid v4l2_edid
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)
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)