Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: V4L
0003 
0004 .. _VIDIOC_SUBDEV_G_FMT:
0005 
0006 **********************************************
0007 ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT
0008 **********************************************
0009 
0010 Name
0011 ====
0012 
0013 VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Get or set the data format on a subdev pad
0014 
0015 Synopsis
0016 ========
0017 
0018 .. c:macro:: VIDIOC_SUBDEV_G_FMT
0019 
0020 ``int ioctl(int fd, VIDIOC_SUBDEV_G_FMT, struct v4l2_subdev_format *argp)``
0021 
0022 .. c:macro:: VIDIOC_SUBDEV_S_FMT
0023 
0024 ``int ioctl(int fd, VIDIOC_SUBDEV_S_FMT, struct v4l2_subdev_format *argp)``
0025 
0026 Arguments
0027 =========
0028 
0029 ``fd``
0030     File descriptor returned by :c:func:`open()`.
0031 
0032 ``argp``
0033     Pointer to struct :c:type:`v4l2_subdev_format`.
0034 
0035 Description
0036 ===========
0037 
0038 These ioctls are used to negotiate the frame format at specific subdev
0039 pads in the image pipeline.
0040 
0041 To retrieve the current format applications set the ``pad`` field of a
0042 struct :c:type:`v4l2_subdev_format` to the desired
0043 pad number as reported by the media API and the ``which`` field to
0044 ``V4L2_SUBDEV_FORMAT_ACTIVE``. When they call the
0045 ``VIDIOC_SUBDEV_G_FMT`` ioctl with a pointer to this structure the
0046 driver fills the members of the ``format`` field.
0047 
0048 To change the current format applications set both the ``pad`` and
0049 ``which`` fields and all members of the ``format`` field. When they call
0050 the ``VIDIOC_SUBDEV_S_FMT`` ioctl with a pointer to this structure the
0051 driver verifies the requested format, adjusts it based on the hardware
0052 capabilities and configures the device. Upon return the struct
0053 :c:type:`v4l2_subdev_format` contains the current
0054 format as would be returned by a ``VIDIOC_SUBDEV_G_FMT`` call.
0055 
0056 Applications can query the device capabilities by setting the ``which``
0057 to ``V4L2_SUBDEV_FORMAT_TRY``. When set, 'try' formats are not applied
0058 to the device by the driver, but are changed exactly as active formats
0059 and stored in the sub-device file handle. Two applications querying the
0060 same sub-device would thus not interact with each other.
0061 
0062 For instance, to try a format at the output pad of a sub-device,
0063 applications would first set the try format at the sub-device input with
0064 the ``VIDIOC_SUBDEV_S_FMT`` ioctl. They would then either retrieve the
0065 default format at the output pad with the ``VIDIOC_SUBDEV_G_FMT`` ioctl,
0066 or set the desired output pad format with the ``VIDIOC_SUBDEV_S_FMT``
0067 ioctl and check the returned value.
0068 
0069 Try formats do not depend on active formats, but can depend on the
0070 current links configuration or sub-device controls value. For instance,
0071 a low-pass noise filter might crop pixels at the frame boundaries,
0072 modifying its output frame size.
0073 
0074 If the subdev device node has been registered in read-only mode, calls to
0075 ``VIDIOC_SUBDEV_S_FMT`` are only valid if the ``which`` field is set to
0076 ``V4L2_SUBDEV_FORMAT_TRY``, otherwise an error is returned and the errno
0077 variable is set to ``-EPERM``.
0078 
0079 Drivers must not return an error solely because the requested format
0080 doesn't match the device capabilities. They must instead modify the
0081 format to match what the hardware can provide. The modified format
0082 should be as close as possible to the original request.
0083 
0084 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
0085 
0086 .. c:type:: v4l2_subdev_format
0087 
0088 .. flat-table:: struct v4l2_subdev_format
0089     :header-rows:  0
0090     :stub-columns: 0
0091     :widths:       1 1 2
0092 
0093     * - __u32
0094       - ``pad``
0095       - Pad number as reported by the media controller API.
0096     * - __u32
0097       - ``which``
0098       - Format to modified, from enum
0099         :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
0100     * - struct :c:type:`v4l2_mbus_framefmt`
0101       - ``format``
0102       - Definition of an image format, see :c:type:`v4l2_mbus_framefmt` for
0103         details.
0104     * - __u32
0105       - ``reserved``\ [8]
0106       - Reserved for future extensions. Applications and drivers must set
0107         the array to zero.
0108 
0109 
0110 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
0111 
0112 .. _v4l2-subdev-format-whence:
0113 
0114 .. flat-table:: enum v4l2_subdev_format_whence
0115     :header-rows:  0
0116     :stub-columns: 0
0117     :widths:       3 1 4
0118 
0119     * - V4L2_SUBDEV_FORMAT_TRY
0120       - 0
0121       - Try formats, used for querying device capabilities.
0122     * - V4L2_SUBDEV_FORMAT_ACTIVE
0123       - 1
0124       - Active formats, applied to the hardware.
0125 
0126 Return Value
0127 ============
0128 
0129 On success 0 is returned, on error -1 and the ``errno`` variable is set
0130 appropriately. The generic error codes are described at the
0131 :ref:`Generic Error Codes <gen-errors>` chapter.
0132 
0133 EBUSY
0134     The format can't be changed because the pad is currently busy. This
0135     can be caused, for instance, by an active video stream on the pad.
0136     The ioctl must not be retried without performing another action to
0137     fix the problem first. Only returned by ``VIDIOC_SUBDEV_S_FMT``
0138 
0139 EINVAL
0140     The struct :c:type:`v4l2_subdev_format`
0141     ``pad`` references a non-existing pad, or the ``which`` field
0142     references a non-existing format.
0143 
0144 EPERM
0145     The ``VIDIOC_SUBDEV_S_FMT`` ioctl has been called on a read-only subdevice
0146     and the ``which`` field is set to ``V4L2_SUBDEV_FORMAT_ACTIVE``.
0147 
0148 ============
0149 
0150 On success 0 is returned, on error -1 and the ``errno`` variable is set
0151 appropriately. The generic error codes are described at the
0152 :ref:`Generic Error Codes <gen-errors>` chapter.