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 <[email protected]> 8 * Sakari Ailus <[email protected]> 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 */ 25 enum 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 * @reserved: drivers and applications must zero this array 36 */ 37 struct v4l2_subdev_format { 38 __u32 which; 39 __u32 pad; 40 struct v4l2_mbus_framefmt format; 41 __u32 reserved[8]; 42 }; 43 44 /** 45 * struct v4l2_subdev_crop - Pad-level crop settings 46 * @which: format type (from enum v4l2_subdev_format_whence) 47 * @pad: pad number, as reported by the media API 48 * @rect: pad crop rectangle boundaries 49 * @reserved: drivers and applications must zero this array 50 */ 51 struct v4l2_subdev_crop { 52 __u32 which; 53 __u32 pad; 54 struct v4l2_rect rect; 55 __u32 reserved[8]; 56 }; 57 58 #define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE 0x00000001 59 #define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC 0x00000002 60 #define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC 0x00000004 61 #define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC 62 #define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION 0x00000008 63 64 /** 65 * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration 66 * @pad: pad number, as reported by the media API 67 * @index: format index during enumeration 68 * @code: format code (MEDIA_BUS_FMT_ definitions) 69 * @which: format type (from enum v4l2_subdev_format_whence) 70 * @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*) 71 * @reserved: drivers and applications must zero this array 72 */ 73 struct v4l2_subdev_mbus_code_enum { 74 __u32 pad; 75 __u32 index; 76 __u32 code; 77 __u32 which; 78 __u32 flags; 79 __u32 reserved[7]; 80 }; 81 82 /** 83 * struct v4l2_subdev_frame_size_enum - Media bus format enumeration 84 * @index: format index during enumeration 85 * @pad: pad number, as reported by the media API 86 * @code: format code (MEDIA_BUS_FMT_ definitions) 87 * @min_width: minimum frame width, in pixels 88 * @max_width: maximum frame width, in pixels 89 * @min_height: minimum frame height, in pixels 90 * @max_height: maximum frame height, in pixels 91 * @which: format type (from enum v4l2_subdev_format_whence) 92 * @reserved: drivers and applications must zero this array 93 */ 94 struct v4l2_subdev_frame_size_enum { 95 __u32 index; 96 __u32 pad; 97 __u32 code; 98 __u32 min_width; 99 __u32 max_width; 100 __u32 min_height; 101 __u32 max_height; 102 __u32 which; 103 __u32 reserved[8]; 104 }; 105 106 /** 107 * struct v4l2_subdev_frame_interval - Pad-level frame rate 108 * @pad: pad number, as reported by the media API 109 * @interval: frame interval in seconds 110 * @reserved: drivers and applications must zero this array 111 */ 112 struct v4l2_subdev_frame_interval { 113 __u32 pad; 114 struct v4l2_fract interval; 115 __u32 reserved[9]; 116 }; 117 118 /** 119 * struct v4l2_subdev_frame_interval_enum - Frame interval enumeration 120 * @pad: pad number, as reported by the media API 121 * @index: frame interval index during enumeration 122 * @code: format code (MEDIA_BUS_FMT_ definitions) 123 * @width: frame width in pixels 124 * @height: frame height in pixels 125 * @interval: frame interval in seconds 126 * @which: format type (from enum v4l2_subdev_format_whence) 127 * @reserved: drivers and applications must zero this array 128 */ 129 struct v4l2_subdev_frame_interval_enum { 130 __u32 index; 131 __u32 pad; 132 __u32 code; 133 __u32 width; 134 __u32 height; 135 struct v4l2_fract interval; 136 __u32 which; 137 __u32 reserved[8]; 138 }; 139 140 /** 141 * struct v4l2_subdev_selection - selection info 142 * 143 * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY 144 * @pad: pad number, as reported by the media API 145 * @target: Selection target, used to choose one of possible rectangles, 146 * defined in v4l2-common.h; V4L2_SEL_TGT_* . 147 * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*. 148 * @r: coordinates of the selection window 149 * @reserved: for future use, set to zero for now 150 * 151 * Hardware may use multiple helper windows to process a video stream. 152 * The structure is used to exchange this selection areas between 153 * an application and a driver. 154 */ 155 struct v4l2_subdev_selection { 156 __u32 which; 157 __u32 pad; 158 __u32 target; 159 __u32 flags; 160 struct v4l2_rect r; 161 __u32 reserved[8]; 162 }; 163 164 /** 165 * struct v4l2_subdev_capability - subdev capabilities 166 * @version: the driver versioning number 167 * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_* 168 * @reserved: for future use, set to zero for now 169 */ 170 struct v4l2_subdev_capability { 171 __u32 version; 172 __u32 capabilities; 173 __u32 reserved[14]; 174 }; 175 176 /* The v4l2 sub-device video device node is registered in read-only mode. */ 177 #define V4L2_SUBDEV_CAP_RO_SUBDEV 0x00000001 178 179 /* The v4l2 sub-device supports routing and multiplexed streams. */ 180 #define V4L2_SUBDEV_CAP_STREAMS 0x00000002 181 182 /* 183 * Is the route active? An active route will start when streaming is enabled 184 * on a video node. 185 */ 186 #define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0) 187 188 /** 189 * struct v4l2_subdev_route - A route inside a subdev 190 * 191 * @sink_pad: the sink pad index 192 * @sink_stream: the sink stream identifier 193 * @source_pad: the source pad index 194 * @source_stream: the source stream identifier 195 * @flags: route flags V4L2_SUBDEV_ROUTE_FL_* 196 * @reserved: drivers and applications must zero this array 197 */ 198 struct v4l2_subdev_route { 199 __u32 sink_pad; 200 __u32 sink_stream; 201 __u32 source_pad; 202 __u32 source_stream; 203 __u32 flags; 204 __u32 reserved[5]; 205 }; 206 207 /** 208 * struct v4l2_subdev_routing - Subdev routing information 209 * 210 * @which: configuration type (from enum v4l2_subdev_format_whence) 211 * @num_routes: the total number of routes in the routes array 212 * @routes: pointer to the routes array 213 * @reserved: drivers and applications must zero this array 214 */ 215 struct v4l2_subdev_routing { 216 __u32 which; 217 __u32 num_routes; 218 __u64 routes; 219 __u32 reserved[6]; 220 }; 221 222 /* Backwards compatibility define --- to be removed */ 223 #define v4l2_subdev_edid v4l2_edid 224 225 #define VIDIOC_SUBDEV_QUERYCAP _IOR('V', 0, struct v4l2_subdev_capability) 226 #define VIDIOC_SUBDEV_G_FMT _IOWR('V', 4, struct v4l2_subdev_format) 227 #define VIDIOC_SUBDEV_S_FMT _IOWR('V', 5, struct v4l2_subdev_format) 228 #define VIDIOC_SUBDEV_G_FRAME_INTERVAL _IOWR('V', 21, struct v4l2_subdev_frame_interval) 229 #define VIDIOC_SUBDEV_S_FRAME_INTERVAL _IOWR('V', 22, struct v4l2_subdev_frame_interval) 230 #define VIDIOC_SUBDEV_ENUM_MBUS_CODE _IOWR('V', 2, struct v4l2_subdev_mbus_code_enum) 231 #define VIDIOC_SUBDEV_ENUM_FRAME_SIZE _IOWR('V', 74, struct v4l2_subdev_frame_size_enum) 232 #define VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL _IOWR('V', 75, struct v4l2_subdev_frame_interval_enum) 233 #define VIDIOC_SUBDEV_G_CROP _IOWR('V', 59, struct v4l2_subdev_crop) 234 #define VIDIOC_SUBDEV_S_CROP _IOWR('V', 60, struct v4l2_subdev_crop) 235 #define VIDIOC_SUBDEV_G_SELECTION _IOWR('V', 61, struct v4l2_subdev_selection) 236 #define VIDIOC_SUBDEV_S_SELECTION _IOWR('V', 62, struct v4l2_subdev_selection) 237 #define VIDIOC_SUBDEV_G_ROUTING _IOWR('V', 38, struct v4l2_subdev_routing) 238 #define VIDIOC_SUBDEV_S_ROUTING _IOWR('V', 39, struct v4l2_subdev_routing) 239 /* The following ioctls are identical to the ioctls in videodev2.h */ 240 #define VIDIOC_SUBDEV_G_STD _IOR('V', 23, v4l2_std_id) 241 #define VIDIOC_SUBDEV_S_STD _IOW('V', 24, v4l2_std_id) 242 #define VIDIOC_SUBDEV_ENUMSTD _IOWR('V', 25, struct v4l2_standard) 243 #define VIDIOC_SUBDEV_G_EDID _IOWR('V', 40, struct v4l2_edid) 244 #define VIDIOC_SUBDEV_S_EDID _IOWR('V', 41, struct v4l2_edid) 245 #define VIDIOC_SUBDEV_QUERYSTD _IOR('V', 63, v4l2_std_id) 246 #define VIDIOC_SUBDEV_S_DV_TIMINGS _IOWR('V', 87, struct v4l2_dv_timings) 247 #define VIDIOC_SUBDEV_G_DV_TIMINGS _IOWR('V', 88, struct v4l2_dv_timings) 248 #define VIDIOC_SUBDEV_ENUM_DV_TIMINGS _IOWR('V', 98, struct v4l2_enum_dv_timings) 249 #define VIDIOC_SUBDEV_QUERY_DV_TIMINGS _IOR('V', 99, struct v4l2_dv_timings) 250 #define VIDIOC_SUBDEV_DV_TIMINGS_CAP _IOWR('V', 100, struct v4l2_dv_timings_cap) 251 252 #endif 253