master
  1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  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>
  9 */
 10
 11#ifndef __LINUX_V4L2_SUBDEV_H
 12#define __LINUX_V4L2_SUBDEV_H
 13
 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>
 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)
 35 * @stream: stream number, defined in subdev routing
 36 * @reserved: drivers and applications must zero this array
 37 */
 38struct v4l2_subdev_format {
 39	__u32 which;
 40	__u32 pad;
 41	struct v4l2_mbus_framefmt format;
 42	__u32 stream;
 43	__u32 reserved[7];
 44};
 45
 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
 51 * @stream: stream number, defined in subdev routing
 52 * @reserved: drivers and applications must zero this array
 53 *
 54 * The subdev crop API is an obsolete interface and may be removed in the
 55 * future. It is superseded by the selection API. No new extensions to this
 56 * structure will be accepted.
 57 */
 58struct v4l2_subdev_crop {
 59	__u32 which;
 60	__u32 pad;
 61	struct v4l2_rect rect;
 62	__u32 stream;
 63	__u32 reserved[7];
 64};
 65
 66#define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE	0x00000001
 67#define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC	0x00000002
 68#define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC	0x00000004
 69#define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC	V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC
 70#define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION	0x00000008
 71
 72/**
 73 * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
 74 * @pad: pad number, as reported by the media API
 75 * @index: format index during enumeration
 76 * @code: format code (MEDIA_BUS_FMT_ definitions)
 77 * @which: format type (from enum v4l2_subdev_format_whence)
 78 * @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
 79 * @stream: stream number, defined in subdev routing
 80 * @reserved: drivers and applications must zero this array
 81 */
 82struct v4l2_subdev_mbus_code_enum {
 83	__u32 pad;
 84	__u32 index;
 85	__u32 code;
 86	__u32 which;
 87	__u32 flags;
 88	__u32 stream;
 89	__u32 reserved[6];
 90};
 91
 92/**
 93 * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
 94 * @index: format index during enumeration
 95 * @pad: pad number, as reported by the media API
 96 * @code: format code (MEDIA_BUS_FMT_ definitions)
 97 * @min_width: minimum frame width, in pixels
 98 * @max_width: maximum frame width, in pixels
 99 * @min_height: minimum frame height, in pixels
100 * @max_height: maximum frame height, in pixels
101 * @which: format type (from enum v4l2_subdev_format_whence)
102 * @stream: stream number, defined in subdev routing
103 * @reserved: drivers and applications must zero this array
104 */
105struct v4l2_subdev_frame_size_enum {
106	__u32 index;
107	__u32 pad;
108	__u32 code;
109	__u32 min_width;
110	__u32 max_width;
111	__u32 min_height;
112	__u32 max_height;
113	__u32 which;
114	__u32 stream;
115	__u32 reserved[7];
116};
117
118/**
119 * struct v4l2_subdev_frame_interval - Pad-level frame rate
120 * @pad: pad number, as reported by the media API
121 * @interval: frame interval in seconds
122 * @stream: stream number, defined in subdev routing
123 * @which: interval type (from enum v4l2_subdev_format_whence)
124 * @reserved: drivers and applications must zero this array
125 */
126struct v4l2_subdev_frame_interval {
127	__u32 pad;
128	struct v4l2_fract interval;
129	__u32 stream;
130	__u32 which;
131	__u32 reserved[7];
132};
133
134/**
135 * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration
136 * @pad: pad number, as reported by the media API
137 * @index: frame interval index during enumeration
138 * @code: format code (MEDIA_BUS_FMT_ definitions)
139 * @width: frame width in pixels
140 * @height: frame height in pixels
141 * @interval: frame interval in seconds
142 * @which: interval type (from enum v4l2_subdev_format_whence)
143 * @stream: stream number, defined in subdev routing
144 * @reserved: drivers and applications must zero this array
145 */
146struct v4l2_subdev_frame_interval_enum {
147	__u32 index;
148	__u32 pad;
149	__u32 code;
150	__u32 width;
151	__u32 height;
152	struct v4l2_fract interval;
153	__u32 which;
154	__u32 stream;
155	__u32 reserved[7];
156};
157
158/**
159 * struct v4l2_subdev_selection - selection info
160 *
161 * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY
162 * @pad: pad number, as reported by the media API
163 * @target: Selection target, used to choose one of possible rectangles,
164 *	    defined in v4l2-common.h; V4L2_SEL_TGT_* .
165 * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
166 * @r: coordinates of the selection window
167 * @stream: stream number, defined in subdev routing
168 * @reserved: for future use, set to zero for now
169 *
170 * Hardware may use multiple helper windows to process a video stream.
171 * The structure is used to exchange this selection areas between
172 * an application and a driver.
173 */
174struct v4l2_subdev_selection {
175	__u32 which;
176	__u32 pad;
177	__u32 target;
178	__u32 flags;
179	struct v4l2_rect r;
180	__u32 stream;
181	__u32 reserved[7];
182};
183
184/**
185 * struct v4l2_subdev_capability - subdev capabilities
186 * @version: the driver versioning number
187 * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*
188 * @reserved: for future use, set to zero for now
189 */
190struct v4l2_subdev_capability {
191	__u32 version;
192	__u32 capabilities;
193	__u32 reserved[14];
194};
195
196/* The v4l2 sub-device video device node is registered in read-only mode. */
197#define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001
198
199/* The v4l2 sub-device supports routing and multiplexed streams. */
200#define V4L2_SUBDEV_CAP_STREAMS			0x00000002
201
202/*
203 * Is the route active? An active route will start when streaming is enabled
204 * on a video node.
205 */
206#define V4L2_SUBDEV_ROUTE_FL_ACTIVE		(1U << 0)
207
208/**
209 * struct v4l2_subdev_route - A route inside a subdev
210 *
211 * @sink_pad: the sink pad index
212 * @sink_stream: the sink stream identifier
213 * @source_pad: the source pad index
214 * @source_stream: the source stream identifier
215 * @flags: route flags V4L2_SUBDEV_ROUTE_FL_*
216 * @reserved: drivers and applications must zero this array
217 */
218struct v4l2_subdev_route {
219	__u32 sink_pad;
220	__u32 sink_stream;
221	__u32 source_pad;
222	__u32 source_stream;
223	__u32 flags;
224	__u32 reserved[5];
225};
226
227/**
228 * struct v4l2_subdev_routing - Subdev routing information
229 *
230 * @which: configuration type (from enum v4l2_subdev_format_whence)
231 * @len_routes: the length of the routes array, in routes; set by the user, not
232 *		modified by the kernel
233 * @routes: pointer to the routes array
234 * @num_routes: the total number of routes, possibly more than fits in the
235 *		routes array
236 * @reserved: drivers and applications must zero this array
237 */
238struct v4l2_subdev_routing {
239	__u32 which;
240	__u32 len_routes;
241	__u64 routes;
242	__u32 num_routes;
243	__u32 reserved[11];
244};
245
246/*
247 * The client is aware of streams. Setting this flag enables the use of 'stream'
248 * fields (referring to the stream number) with various ioctls. If this is not
249 * set (which is the default), the 'stream' fields will be forced to 0 by the
250 * kernel.
251 */
252#define V4L2_SUBDEV_CLIENT_CAP_STREAMS			(1ULL << 0)
253
254/*
255 * The client is aware of the struct v4l2_subdev_frame_interval which field. If
256 * this is not set (which is the default), the which field is forced to
257 * V4L2_SUBDEV_FORMAT_ACTIVE by the kernel.
258 */
259#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH	(1ULL << 1)
260
261/**
262 * struct v4l2_subdev_client_capability - Capabilities of the client accessing
263 *					  the subdev
264 *
265 * @capabilities: A bitmask of V4L2_SUBDEV_CLIENT_CAP_* flags.
266 */
267struct v4l2_subdev_client_capability {
268	__u64 capabilities;
269};
270
271/* Backwards compatibility define --- to be removed */
272#define v4l2_subdev_edid v4l2_edid
273
274#define VIDIOC_SUBDEV_QUERYCAP			_IOR('V',  0, struct v4l2_subdev_capability)
275#define VIDIOC_SUBDEV_G_FMT			_IOWR('V',  4, struct v4l2_subdev_format)
276#define VIDIOC_SUBDEV_S_FMT			_IOWR('V',  5, struct v4l2_subdev_format)
277#define VIDIOC_SUBDEV_G_FRAME_INTERVAL		_IOWR('V', 21, struct v4l2_subdev_frame_interval)
278#define VIDIOC_SUBDEV_S_FRAME_INTERVAL		_IOWR('V', 22, struct v4l2_subdev_frame_interval)
279#define VIDIOC_SUBDEV_ENUM_MBUS_CODE		_IOWR('V',  2, struct v4l2_subdev_mbus_code_enum)
280#define VIDIOC_SUBDEV_ENUM_FRAME_SIZE		_IOWR('V', 74, struct v4l2_subdev_frame_size_enum)
281#define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL	_IOWR('V', 75, struct v4l2_subdev_frame_interval_enum)
282#define VIDIOC_SUBDEV_G_CROP			_IOWR('V', 59, struct v4l2_subdev_crop)
283#define VIDIOC_SUBDEV_S_CROP			_IOWR('V', 60, struct v4l2_subdev_crop)
284#define VIDIOC_SUBDEV_G_SELECTION		_IOWR('V', 61, struct v4l2_subdev_selection)
285#define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection)
286#define VIDIOC_SUBDEV_G_ROUTING			_IOWR('V', 38, struct v4l2_subdev_routing)
287#define VIDIOC_SUBDEV_S_ROUTING			_IOWR('V', 39, struct v4l2_subdev_routing)
288#define VIDIOC_SUBDEV_G_CLIENT_CAP		_IOR('V',  101, struct v4l2_subdev_client_capability)
289#define VIDIOC_SUBDEV_S_CLIENT_CAP		_IOWR('V',  102, struct v4l2_subdev_client_capability)
290
291/* The following ioctls are identical to the ioctls in videodev2.h */
292#define VIDIOC_SUBDEV_G_STD			_IOR('V', 23, v4l2_std_id)
293#define VIDIOC_SUBDEV_S_STD			_IOW('V', 24, v4l2_std_id)
294#define VIDIOC_SUBDEV_ENUMSTD			_IOWR('V', 25, struct v4l2_standard)
295#define VIDIOC_SUBDEV_G_EDID			_IOWR('V', 40, struct v4l2_edid)
296#define VIDIOC_SUBDEV_S_EDID			_IOWR('V', 41, struct v4l2_edid)
297#define VIDIOC_SUBDEV_QUERYSTD			_IOR('V', 63, v4l2_std_id)
298#define VIDIOC_SUBDEV_S_DV_TIMINGS		_IOWR('V', 87, struct v4l2_dv_timings)
299#define VIDIOC_SUBDEV_G_DV_TIMINGS		_IOWR('V', 88, struct v4l2_dv_timings)
300#define VIDIOC_SUBDEV_ENUM_DV_TIMINGS		_IOWR('V', 98, struct v4l2_enum_dv_timings)
301#define VIDIOC_SUBDEV_QUERY_DV_TIMINGS		_IOR('V', 99, struct v4l2_dv_timings)
302#define VIDIOC_SUBDEV_DV_TIMINGS_CAP		_IOWR('V', 100, struct v4l2_dv_timings_cap)
303
304#endif