Merge tag 'block-6.9-20240315' of git://git.kernel.dk/linux
[linux-2.6-block.git] / include / uapi / linux / v4l2-subdev.h
CommitLineData
e2be04c7 1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
333c8b97
LP
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>
333c8b97
LP
9 */
10
11#ifndef __LINUX_V4L2_SUBDEV_H
12#define __LINUX_V4L2_SUBDEV_H
13
a418bb3f 14#include <linux/const.h>
333c8b97
LP
15#include <linux/ioctl.h>
16#include <linux/types.h>
5689b288 17#include <linux/v4l2-common.h>
333c8b97
LP
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 */
25enum 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)
2f91e10e 35 * @stream: stream number, defined in subdev routing
f12b81e4 36 * @reserved: drivers and applications must zero this array
333c8b97
LP
37 */
38struct v4l2_subdev_format {
39 __u32 which;
40 __u32 pad;
41 struct v4l2_mbus_framefmt format;
2f91e10e
TV
42 __u32 stream;
43 __u32 reserved[7];
333c8b97
LP
44};
45
f6a5cb1b
AK
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
2f91e10e 51 * @stream: stream number, defined in subdev routing
f12b81e4 52 * @reserved: drivers and applications must zero this array
f6a5cb1b
AK
53 */
54struct v4l2_subdev_crop {
55 __u32 which;
56 __u32 pad;
57 struct v4l2_rect rect;
2f91e10e
TV
58 __u32 stream;
59 __u32 reserved[7];
f6a5cb1b
AK
60};
61
62aacfa9
DH
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
333c8b97
LP
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
32b32ce8 72 * @code: format code (MEDIA_BUS_FMT_ definitions)
e1c47e73 73 * @which: format type (from enum v4l2_subdev_format_whence)
62aacfa9 74 * @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
2f91e10e 75 * @stream: stream number, defined in subdev routing
f12b81e4 76 * @reserved: drivers and applications must zero this array
333c8b97
LP
77 */
78struct v4l2_subdev_mbus_code_enum {
79 __u32 pad;
80 __u32 index;
81 __u32 code;
e1c47e73 82 __u32 which;
62aacfa9 83 __u32 flags;
2f91e10e
TV
84 __u32 stream;
85 __u32 reserved[6];
333c8b97
LP
86};
87
88/**
89 * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
333c8b97 90 * @index: format index during enumeration
f12b81e4 91 * @pad: pad number, as reported by the media API
32b32ce8 92 * @code: format code (MEDIA_BUS_FMT_ definitions)
f12b81e4
HV
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
e1c47e73 97 * @which: format type (from enum v4l2_subdev_format_whence)
2f91e10e 98 * @stream: stream number, defined in subdev routing
f12b81e4 99 * @reserved: drivers and applications must zero this array
333c8b97
LP
100 */
101struct 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;
e1c47e73 109 __u32 which;
2f91e10e
TV
110 __u32 stream;
111 __u32 reserved[7];
333c8b97
LP
112};
113
35c3017a
LP
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
2f91e10e 118 * @stream: stream number, defined in subdev routing
805d4311 119 * @which: interval type (from enum v4l2_subdev_format_whence)
f12b81e4 120 * @reserved: drivers and applications must zero this array
35c3017a
LP
121 */
122struct v4l2_subdev_frame_interval {
123 __u32 pad;
124 struct v4l2_fract interval;
2f91e10e 125 __u32 stream;
805d4311
LP
126 __u32 which;
127 __u32 reserved[7];
35c3017a
LP
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
32b32ce8 134 * @code: format code (MEDIA_BUS_FMT_ definitions)
35c3017a
LP
135 * @width: frame width in pixels
136 * @height: frame height in pixels
137 * @interval: frame interval in seconds
805d4311 138 * @which: interval type (from enum v4l2_subdev_format_whence)
2f91e10e 139 * @stream: stream number, defined in subdev routing
f12b81e4 140 * @reserved: drivers and applications must zero this array
35c3017a
LP
141 */
142struct 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;
e1c47e73 149 __u32 which;
2f91e10e
TV
150 __u32 stream;
151 __u32 reserved[7];
35c3017a
LP
152};
153
ae184cda
SA
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
5689b288
SA
159 * @target: Selection target, used to choose one of possible rectangles,
160 * defined in v4l2-common.h; V4L2_SEL_TGT_* .
563df3d0 161 * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
ae184cda 162 * @r: coordinates of the selection window
2f91e10e 163 * @stream: stream number, defined in subdev routing
ae184cda
SA
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 */
170struct v4l2_subdev_selection {
171 __u32 which;
172 __u32 pad;
173 __u32 target;
174 __u32 flags;
175 struct v4l2_rect r;
2f91e10e
TV
176 __u32 stream;
177 __u32 reserved[7];
ae184cda
SA
178};
179
6446ec6c
HV
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 */
186struct 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. */
a53e3c18 193#define V4L2_SUBDEV_CAP_RO_SUBDEV 0x00000001
6446ec6c 194
9a6b5bf4
TV
195/* The v4l2 sub-device supports routing and multiplexed streams. */
196#define V4L2_SUBDEV_CAP_STREAMS 0x00000002
197
a418bb3f
LP
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 */
214struct 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 */
231struct v4l2_subdev_routing {
232 __u32 which;
233 __u32 num_routes;
234 __u64 routes;
235 __u32 reserved[6];
236};
237
f57fa295
TV
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 */
805d4311
LP
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)
f57fa295
TV
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 */
259struct v4l2_subdev_client_capability {
260 __u64 capabilities;
261};
262
254a4777
HV
263/* Backwards compatibility define --- to be removed */
264#define v4l2_subdev_edid v4l2_edid
777f4f85 265
6446ec6c 266#define VIDIOC_SUBDEV_QUERYCAP _IOR('V', 0, struct v4l2_subdev_capability)
c4fa146c
LP
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)
a418bb3f
LP
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)
f57fa295
TV
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
9cfd65e8 283/* The following ioctls are identical to the ioctls in videodev2.h */
56ab8cdb
NS
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)
c4fa146c
LP
287#define VIDIOC_SUBDEV_G_EDID _IOWR('V', 40, struct v4l2_edid)
288#define VIDIOC_SUBDEV_S_EDID _IOWR('V', 41, struct v4l2_edid)
56ab8cdb 289#define VIDIOC_SUBDEV_QUERYSTD _IOR('V', 63, v4l2_std_id)
9cfd65e8
LP
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)
333c8b97
LP
295
296#endif