brintos

brintos / linux-shallow public Read only

0
0
Text · 9.2 KiB · 3adb3d2 Raw
251 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _VIDIOC_ENUM_FMT:5 6*********************7ioctl VIDIOC_ENUM_FMT8*********************9 10Name11====12 13VIDIOC_ENUM_FMT - Enumerate image formats14 15Synopsis16========17 18.. c:macro:: VIDIOC_ENUM_FMT19 20``int ioctl(int fd, VIDIOC_ENUM_FMT, struct v4l2_fmtdesc *argp)``21 22Arguments23=========24 25``fd``26    File descriptor returned by :c:func:`open()`.27 28``argp``29    Pointer to struct :c:type:`v4l2_fmtdesc`.30 31Description32===========33 34To enumerate image formats applications initialize the ``type``, ``mbus_code``35and ``index`` fields of struct :c:type:`v4l2_fmtdesc` and call36the :ref:`VIDIOC_ENUM_FMT` ioctl with a pointer to this structure. Drivers37fill the rest of the structure or return an ``EINVAL`` error code. All38formats are enumerable by beginning at index zero and incrementing by39one until ``EINVAL`` is returned. If applicable, drivers shall return40formats in preference order, where preferred formats are returned before41(that is, with lower ``index`` value) less-preferred formats.42 43Depending on the ``V4L2_CAP_IO_MC`` :ref:`capability <device-capabilities>`,44the ``mbus_code`` field is handled differently:45 461) ``V4L2_CAP_IO_MC`` is not set (also known as a 'video-node-centric' driver)47 48   Applications shall initialize the ``mbus_code`` field to zero and drivers49   shall ignore the value of the field.50 51   Drivers shall enumerate all image formats.52 53   .. note::54 55      After switching the input or output the list of enumerated image56      formats may be different.57 582) ``V4L2_CAP_IO_MC`` is set (also known as an 'MC-centric' driver)59 60   If the ``mbus_code`` field is zero, then all image formats61   shall be enumerated.62 63   If the ``mbus_code`` field is initialized to a valid (non-zero)64   :ref:`media bus format code <v4l2-mbus-pixelcode>`, then drivers65   shall restrict enumeration to only the image formats that can produce66   (for video output devices) or be produced from (for video capture67   devices) that media bus code. If the ``mbus_code`` is unsupported by68   the driver, then ``EINVAL`` shall be returned.69 70   Regardless of the value of the ``mbus_code`` field, the enumerated image71   formats shall not depend on the active configuration of the video device72   or device pipeline.73 74.. c:type:: v4l2_fmtdesc75 76.. cssclass:: longtable77 78.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|79 80.. flat-table:: struct v4l2_fmtdesc81    :header-rows:  082    :stub-columns: 083    :widths:       1 1 284 85    * - __u3286      - ``index``87      - Number of the format in the enumeration, set by the application.88	This is in no way related to the ``pixelformat`` field.89    * - __u3290      - ``type``91      - Type of the data stream, set by the application. Only these types92	are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``,93	``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,94	``V4L2_BUF_TYPE_VIDEO_OUTPUT``,95	``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``,96	``V4L2_BUF_TYPE_VIDEO_OVERLAY``,97	``V4L2_BUF_TYPE_SDR_CAPTURE``,98	``V4L2_BUF_TYPE_SDR_OUTPUT``,99	``V4L2_BUF_TYPE_META_CAPTURE`` and100	``V4L2_BUF_TYPE_META_OUTPUT``.101	See :c:type:`v4l2_buf_type`.102    * - __u32103      - ``flags``104      - See :ref:`fmtdesc-flags`105    * - __u8106      - ``description``\ [32]107      - Description of the format, a NUL-terminated ASCII string. This108	information is intended for the user, for example: "YUV 4:2:2".109    * - __u32110      - ``pixelformat``111      - The image format identifier. This is a four character code as112	computed by the v4l2_fourcc() macro:113    * - :cspan:`2`114 115	.. _v4l2-fourcc:116 117	``#define v4l2_fourcc(a,b,c,d)``118 119	``(((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))``120 121	Several image formats are already defined by this specification in122	:ref:`pixfmt`.123 124	.. attention::125 126	   These codes are not the same as those used127	   in the Windows world.128    * - __u32129      - ``mbus_code``130      - Media bus code restricting the enumerated formats, set by the131        application. Only applicable to drivers that advertise the132        ``V4L2_CAP_IO_MC`` :ref:`capability <device-capabilities>`, shall be 0133        otherwise.134    * - __u32135      - ``reserved``\ [3]136      - Reserved for future extensions. Drivers must set the array to137	zero.138 139 140.. tabularcolumns:: |p{8.4cm}|p{1.8cm}|p{7.1cm}|141 142.. cssclass:: longtable143 144.. _fmtdesc-flags:145 146.. flat-table:: Image Format Description Flags147    :header-rows:  0148    :stub-columns: 0149    :widths:       3 1 4150 151    * - ``V4L2_FMT_FLAG_COMPRESSED``152      - 0x0001153      - This is a compressed format.154    * - ``V4L2_FMT_FLAG_EMULATED``155      - 0x0002156      - This format is not native to the device but emulated through157	software (usually libv4l2), where possible try to use a native158	format instead for better performance.159    * - ``V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM``160      - 0x0004161      - The hardware decoder for this compressed bytestream format (aka coded162	format) is capable of parsing a continuous bytestream. Applications do163	not need to parse the bytestream themselves to find the boundaries164	between frames/fields.165 166	This flag can only be used in combination with the167	``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to compressed168	formats only. This flag is valid for stateful decoders only.169    * - ``V4L2_FMT_FLAG_DYN_RESOLUTION``170      - 0x0008171      - Dynamic resolution switching is supported by the device for this172	compressed bytestream format (aka coded format). It will notify the user173	via the event ``V4L2_EVENT_SOURCE_CHANGE`` when changes in the video174	parameters are detected.175 176	This flag can only be used in combination with the177	``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to178	compressed formats only. This flag is valid for stateful codecs only.179    * - ``V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL``180      - 0x0010181      - The hardware encoder supports setting the ``CAPTURE`` coded frame182	interval separately from the ``OUTPUT`` raw frame interval.183	Setting the ``OUTPUT`` raw frame interval with :ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>`184	also sets the ``CAPTURE`` coded frame interval to the same value.185	If this flag is set, then the ``CAPTURE`` coded frame interval can be186	set to a different value afterwards. This is typically used for187	offline encoding where the ``OUTPUT`` raw frame interval is used as188	a hint for reserving hardware encoder resources and the ``CAPTURE`` coded189	frame interval is the actual frame rate embedded in the encoded video190	stream.191 192	This flag can only be used in combination with the193	``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to194        compressed formats only. This flag is valid for stateful encoders only.195    * - ``V4L2_FMT_FLAG_CSC_COLORSPACE``196      - 0x0020197      - The driver allows the application to try to change the default198	colorspace. This flag is relevant only for capture devices.199	The application can ask to configure the colorspace of the capture device200	when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with201	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.202    * - ``V4L2_FMT_FLAG_CSC_XFER_FUNC``203      - 0x0040204      - The driver allows the application to try to change the default205	transfer function. This flag is relevant only for capture devices.206	The application can ask to configure the transfer function of the capture207	device when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with208	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.209    * - ``V4L2_FMT_FLAG_CSC_YCBCR_ENC``210      - 0x0080211      - The driver allows the application to try to change the default212	Y'CbCr encoding. This flag is relevant only for capture devices.213	The application can ask to configure the Y'CbCr encoding of the capture device214	when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with215	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.216    * - ``V4L2_FMT_FLAG_CSC_HSV_ENC``217      - 0x0080218      - The driver allows the application to try to change the default219	HSV encoding. This flag is relevant only for capture devices.220	The application can ask to configure the HSV encoding of the capture device221	when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with222	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.223    * - ``V4L2_FMT_FLAG_CSC_QUANTIZATION``224      - 0x0100225      - The driver allows the application to try to change the default226	quantization. This flag is relevant only for capture devices.227	The application can ask to configure the quantization of the capture228	device when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with229	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.230    * - ``V4L2_FMT_FLAG_META_LINE_BASED``231      - 0x0200232      - The metadata format is line-based. In this case the ``width``,233	``height`` and ``bytesperline`` fields of :c:type:`v4l2_meta_format` are234	valid. The buffer consists of ``height`` lines, each having ``width``235	Data Units of data and the offset (in bytes) between the beginning of236	each two consecutive lines is ``bytesperline``.237 238Return Value239============240 241On success 0 is returned, on error -1 and the ``errno`` variable is set242appropriately. The generic error codes are described at the243:ref:`Generic Error Codes <gen-errors>` chapter.244 245EINVAL246    The struct :c:type:`v4l2_fmtdesc` ``type`` is not247    supported or the ``index`` is out of bounds.248 249    If ``V4L2_CAP_IO_MC`` is set and the specified ``mbus_code``250    is unsupported, then also return this error code.251