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  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23 
24 #ifndef __LINUX_V4L2_SUBDEV_H
25 #define __LINUX_V4L2_SUBDEV_H
26 
27 #include <linux/ioctl.h>
28 #include <linux/types.h>
29 #include <linux/v4l2-common.h>
30 #include <linux/v4l2-mediabus.h>
31 
32 /**
33  * enum v4l2_subdev_format_whence - Media bus format type
34  * @V4L2_SUBDEV_FORMAT_TRY: try format, for negotiation only
35  * @V4L2_SUBDEV_FORMAT_ACTIVE: active format, applied to the device
36  */
37 enum v4l2_subdev_format_whence {
38 	V4L2_SUBDEV_FORMAT_TRY = 0,
39 	V4L2_SUBDEV_FORMAT_ACTIVE = 1,
40 };
41 
42 /**
43  * struct v4l2_subdev_format - Pad-level media bus format
44  * @which: format type (from enum v4l2_subdev_format_whence)
45  * @pad: pad number, as reported by the media API
46  * @format: media bus format (format code and frame size)
47  * @reserved: drivers and applications must zero this array
48  */
49 struct v4l2_subdev_format {
50 	__u32 which;
51 	__u32 pad;
52 	struct v4l2_mbus_framefmt format;
53 	__u32 reserved[8];
54 };
55 
56 /**
57  * struct v4l2_subdev_crop - Pad-level crop settings
58  * @which: format type (from enum v4l2_subdev_format_whence)
59  * @pad: pad number, as reported by the media API
60  * @rect: pad crop rectangle boundaries
61  * @reserved: drivers and applications must zero this array
62  */
63 struct v4l2_subdev_crop {
64 	__u32 which;
65 	__u32 pad;
66 	struct v4l2_rect rect;
67 	__u32 reserved[8];
68 };
69 
70 #define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE	0x00000001
71 #define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC	0x00000002
72 #define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC	0x00000004
73 #define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC	V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC
74 #define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION	0x00000008
75 
76 /**
77  * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration
78  * @pad: pad number, as reported by the media API
79  * @index: format index during enumeration
80  * @code: format code (MEDIA_BUS_FMT_ definitions)
81  * @which: format type (from enum v4l2_subdev_format_whence)
82  * @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
83  * @reserved: drivers and applications must zero this array
84  */
85 struct v4l2_subdev_mbus_code_enum {
86 	__u32 pad;
87 	__u32 index;
88 	__u32 code;
89 	__u32 which;
90 	__u32 flags;
91 	__u32 reserved[7];
92 };
93 
94 /**
95  * struct v4l2_subdev_frame_size_enum - Media bus format enumeration
96  * @index: format index during enumeration
97  * @pad: pad number, as reported by the media API
98  * @code: format code (MEDIA_BUS_FMT_ definitions)
99  * @min_width: minimum frame width, in pixels
100  * @max_width: maximum frame width, in pixels
101  * @min_height: minimum frame height, in pixels
102  * @max_height: maximum frame height, in pixels
103  * @which: format type (from enum v4l2_subdev_format_whence)
104  * @reserved: drivers and applications must zero this array
105  */
106 struct v4l2_subdev_frame_size_enum {
107 	__u32 index;
108 	__u32 pad;
109 	__u32 code;
110 	__u32 min_width;
111 	__u32 max_width;
112 	__u32 min_height;
113 	__u32 max_height;
114 	__u32 which;
115 	__u32 reserved[8];
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  * @reserved: drivers and applications must zero this array
123  */
124 struct v4l2_subdev_frame_interval {
125 	__u32 pad;
126 	struct v4l2_fract interval;
127 	__u32 reserved[9];
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
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: format type (from enum v4l2_subdev_format_whence)
139  * @reserved: drivers and applications must zero this array
140  */
141 struct v4l2_subdev_frame_interval_enum {
142 	__u32 index;
143 	__u32 pad;
144 	__u32 code;
145 	__u32 width;
146 	__u32 height;
147 	struct v4l2_fract interval;
148 	__u32 which;
149 	__u32 reserved[8];
150 };
151 
152 /**
153  * struct v4l2_subdev_selection - selection info
154  *
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  * @reserved: for future use, set to zero for now
162  *
163  * Hardware may use multiple helper windows to process a video stream.
164  * The structure is used to exchange this selection areas between
165  * an application and a driver.
166  */
167 struct v4l2_subdev_selection {
168 	__u32 which;
169 	__u32 pad;
170 	__u32 target;
171 	__u32 flags;
172 	struct v4l2_rect r;
173 	__u32 reserved[8];
174 };
175 
176 /**
177  * struct v4l2_subdev_capability - subdev capabilities
178  * @version: the driver versioning number
179  * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*
180  * @reserved: for future use, set to zero for now
181  */
182 struct v4l2_subdev_capability {
183 	__u32 version;
184 	__u32 capabilities;
185 	__u32 reserved[14];
186 };
187 
188 /* The v4l2 sub-device video device node is registered in read-only mode. */
189 #define V4L2_SUBDEV_CAP_RO_SUBDEV		0x00000001
190 
191 /* Backwards compatibility define --- to be removed */
192 #define v4l2_subdev_edid v4l2_edid
193 
194 #define VIDIOC_SUBDEV_QUERYCAP			_IOR('V',  0, struct v4l2_subdev_capability)
195 #define VIDIOC_SUBDEV_G_FMT			_IOWR('V',  4, struct v4l2_subdev_format)
196 #define VIDIOC_SUBDEV_S_FMT			_IOWR('V',  5, struct v4l2_subdev_format)
197 #define VIDIOC_SUBDEV_G_FRAME_INTERVAL		_IOWR('V', 21, struct v4l2_subdev_frame_interval)
198 #define VIDIOC_SUBDEV_S_FRAME_INTERVAL		_IOWR('V', 22, struct v4l2_subdev_frame_interval)
199 #define VIDIOC_SUBDEV_ENUM_MBUS_CODE		_IOWR('V',  2, struct v4l2_subdev_mbus_code_enum)
200 #define VIDIOC_SUBDEV_ENUM_FRAME_SIZE		_IOWR('V', 74, struct v4l2_subdev_frame_size_enum)
201 #define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL	_IOWR('V', 75, struct v4l2_subdev_frame_interval_enum)
202 #define VIDIOC_SUBDEV_G_CROP			_IOWR('V', 59, struct v4l2_subdev_crop)
203 #define VIDIOC_SUBDEV_S_CROP			_IOWR('V', 60, struct v4l2_subdev_crop)
204 #define VIDIOC_SUBDEV_G_SELECTION		_IOWR('V', 61, struct v4l2_subdev_selection)
205 #define VIDIOC_SUBDEV_S_SELECTION		_IOWR('V', 62, struct v4l2_subdev_selection)
206 /* The following ioctls are identical to the ioctls in videodev2.h */
207 #define VIDIOC_SUBDEV_G_STD			_IOR('V', 23, v4l2_std_id)
208 #define VIDIOC_SUBDEV_S_STD			_IOW('V', 24, v4l2_std_id)
209 #define VIDIOC_SUBDEV_ENUMSTD			_IOWR('V', 25, struct v4l2_standard)
210 #define VIDIOC_SUBDEV_G_EDID			_IOWR('V', 40, struct v4l2_edid)
211 #define VIDIOC_SUBDEV_S_EDID			_IOWR('V', 41, struct v4l2_edid)
212 #define VIDIOC_SUBDEV_QUERYSTD			_IOR('V', 63, v4l2_std_id)
213 #define VIDIOC_SUBDEV_S_DV_TIMINGS		_IOWR('V', 87, struct v4l2_dv_timings)
214 #define VIDIOC_SUBDEV_G_DV_TIMINGS		_IOWR('V', 88, struct v4l2_dv_timings)
215 #define VIDIOC_SUBDEV_ENUM_DV_TIMINGS		_IOWR('V', 98, struct v4l2_enum_dv_timings)
216 #define VIDIOC_SUBDEV_QUERY_DV_TIMINGS		_IOR('V', 99, struct v4l2_dv_timings)
217 #define VIDIOC_SUBDEV_DV_TIMINGS_CAP		_IOWR('V', 100, struct v4l2_dv_timings_cap)
218 
219 #endif
220