305 lines · c
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */2/*3 * V4L2 subdev userspace API4 *5 * Copyright (C) 2010 Nokia Corporation6 *7 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>8 * Sakari Ailus <sakari.ailus@iki.fi>9 */10 11#ifndef __LINUX_V4L2_SUBDEV_H12#define __LINUX_V4L2_SUBDEV_H13 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 type22 * @V4L2_SUBDEV_FORMAT_TRY: try format, for negotiation only23 * @V4L2_SUBDEV_FORMAT_ACTIVE: active format, applied to the device24 */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 format32 * @which: format type (from enum v4l2_subdev_format_whence)33 * @pad: pad number, as reported by the media API34 * @format: media bus format (format code and frame size)35 * @stream: stream number, defined in subdev routing36 * @reserved: drivers and applications must zero this array37 */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 settings48 * @which: format type (from enum v4l2_subdev_format_whence)49 * @pad: pad number, as reported by the media API50 * @rect: pad crop rectangle boundaries51 * @stream: stream number, defined in subdev routing52 * @reserved: drivers and applications must zero this array53 *54 * The subdev crop API is an obsolete interface and may be removed in the55 * future. It is superseded by the selection API. No new extensions to this56 * 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 0x0000000167#define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC 0x0000000268#define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC 0x0000000469#define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC70#define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION 0x0000000871 72/**73 * struct v4l2_subdev_mbus_code_enum - Media bus format enumeration74 * @pad: pad number, as reported by the media API75 * @index: format index during enumeration76 * @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 routing80 * @reserved: drivers and applications must zero this array81 */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 enumeration94 * @index: format index during enumeration95 * @pad: pad number, as reported by the media API96 * @code: format code (MEDIA_BUS_FMT_ definitions)97 * @min_width: minimum frame width, in pixels98 * @max_width: maximum frame width, in pixels99 * @min_height: minimum frame height, in pixels100 * @max_height: maximum frame height, in pixels101 * @which: format type (from enum v4l2_subdev_format_whence)102 * @stream: stream number, defined in subdev routing103 * @reserved: drivers and applications must zero this array104 */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 rate120 * @pad: pad number, as reported by the media API121 * @interval: frame interval in seconds122 * @stream: stream number, defined in subdev routing123 * @which: interval type (from enum v4l2_subdev_format_whence)124 * @reserved: drivers and applications must zero this array125 */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 enumeration136 * @pad: pad number, as reported by the media API137 * @index: frame interval index during enumeration138 * @code: format code (MEDIA_BUS_FMT_ definitions)139 * @width: frame width in pixels140 * @height: frame height in pixels141 * @interval: frame interval in seconds142 * @which: interval type (from enum v4l2_subdev_format_whence)143 * @stream: stream number, defined in subdev routing144 * @reserved: drivers and applications must zero this array145 */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 info160 *161 * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY162 * @pad: pad number, as reported by the media API163 * @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 window167 * @stream: stream number, defined in subdev routing168 * @reserved: for future use, set to zero for now169 *170 * Hardware may use multiple helper windows to process a video stream.171 * The structure is used to exchange this selection areas between172 * 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 capabilities186 * @version: the driver versioning number187 * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*188 * @reserved: for future use, set to zero for now189 */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 0x00000001198 199/* The v4l2 sub-device supports routing and multiplexed streams. */200#define V4L2_SUBDEV_CAP_STREAMS 0x00000002201 202/*203 * Is the route active? An active route will start when streaming is enabled204 * 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 subdev210 *211 * @sink_pad: the sink pad index212 * @sink_stream: the sink stream identifier213 * @source_pad: the source pad index214 * @source_stream: the source stream identifier215 * @flags: route flags V4L2_SUBDEV_ROUTE_FL_*216 * @reserved: drivers and applications must zero this array217 */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 information229 *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, not232 * modified by the kernel233 * @routes: pointer to the routes array234 * @num_routes: the total number of routes, possibly more than fits in the235 * routes array236 * @reserved: drivers and applications must zero this array237 */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 not249 * set (which is the default), the 'stream' fields will be forced to 0 by the250 * 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. If256 * this is not set (which is the default), the which field is forced to257 * 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 accessing263 * the subdev264 *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_edid273 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#endif305