1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
3 * V4L2 subdev userspace API
5 * Copyright (C) 2010 Nokia Corporation
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 * @reserved: drivers and applications must zero this array
121 struct v4l2_subdev_frame_interval {
123 struct v4l2_fract interval;
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
140 struct v4l2_subdev_frame_interval_enum {
146 struct v4l2_fract interval;
153 * struct v4l2_subdev_selection - selection info
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
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.
168 struct v4l2_subdev_selection {
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
184 struct v4l2_subdev_capability {
190 /* The v4l2 sub-device video device node is registered in read-only mode. */
191 #define V4L2_SUBDEV_CAP_RO_SUBDEV 0x00000001
193 /* The v4l2 sub-device supports routing and multiplexed streams. */
194 #define V4L2_SUBDEV_CAP_STREAMS 0x00000002
197 * Is the route active? An active route will start when streaming is enabled
200 #define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0)
203 * struct v4l2_subdev_route - A route inside a subdev
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
212 struct v4l2_subdev_route {
222 * struct v4l2_subdev_routing - Subdev routing information
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
229 struct v4l2_subdev_routing {
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
242 #define V4L2_SUBDEV_CLIENT_CAP_STREAMS (1U << 0)
245 * struct v4l2_subdev_client_capability - Capabilities of the client accessing
248 * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags.
250 struct v4l2_subdev_client_capability {
254 /* Backwards compatibility define --- to be removed */
255 #define v4l2_subdev_edid v4l2_edid
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)
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)