1 .. SPDX-License-Identifier: GFDL-1.1-no-invari 1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2 .. c:namespace:: V4L 2 .. c:namespace:: V4L 3 3 4 .. _VIDIOC_SUBDEV_G_FMT: 4 .. _VIDIOC_SUBDEV_G_FMT: 5 5 6 ********************************************** 6 ********************************************** 7 ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT 7 ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT 8 ********************************************** 8 ********************************************** 9 9 10 Name 10 Name 11 ==== 11 ==== 12 12 13 VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Ge 13 VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Get or set the data format on a subdev pad 14 14 15 Synopsis 15 Synopsis 16 ======== 16 ======== 17 17 18 .. c:macro:: VIDIOC_SUBDEV_G_FMT 18 .. c:macro:: VIDIOC_SUBDEV_G_FMT 19 19 20 ``int ioctl(int fd, VIDIOC_SUBDEV_G_FMT, struc 20 ``int ioctl(int fd, VIDIOC_SUBDEV_G_FMT, struct v4l2_subdev_format *argp)`` 21 21 22 .. c:macro:: VIDIOC_SUBDEV_S_FMT 22 .. c:macro:: VIDIOC_SUBDEV_S_FMT 23 23 24 ``int ioctl(int fd, VIDIOC_SUBDEV_S_FMT, struc 24 ``int ioctl(int fd, VIDIOC_SUBDEV_S_FMT, struct v4l2_subdev_format *argp)`` 25 25 26 Arguments 26 Arguments 27 ========= 27 ========= 28 28 29 ``fd`` 29 ``fd`` 30 File descriptor returned by :c:func:`open( 30 File descriptor returned by :c:func:`open()`. 31 31 32 ``argp`` 32 ``argp`` 33 Pointer to struct :c:type:`v4l2_subdev_for 33 Pointer to struct :c:type:`v4l2_subdev_format`. 34 34 35 Description 35 Description 36 =========== 36 =========== 37 37 38 These ioctls are used to negotiate the frame f 38 These ioctls are used to negotiate the frame format at specific subdev 39 pads in the image pipeline. 39 pads in the image pipeline. 40 40 41 To retrieve the current format applications se 41 To retrieve the current format applications set the ``pad`` field of a 42 struct :c:type:`v4l2_subdev_format` to the des 42 struct :c:type:`v4l2_subdev_format` to the desired 43 pad number as reported by the media API and th 43 pad number as reported by the media API and the ``which`` field to 44 ``V4L2_SUBDEV_FORMAT_ACTIVE``. When they call 44 ``V4L2_SUBDEV_FORMAT_ACTIVE``. When they call the 45 ``VIDIOC_SUBDEV_G_FMT`` ioctl with a pointer t 45 ``VIDIOC_SUBDEV_G_FMT`` ioctl with a pointer to this structure the 46 driver fills the members of the ``format`` fie 46 driver fills the members of the ``format`` field. 47 47 48 To change the current format applications set 48 To change the current format applications set both the ``pad`` and 49 ``which`` fields and all members of the ``form 49 ``which`` fields and all members of the ``format`` field. When they call 50 the ``VIDIOC_SUBDEV_S_FMT`` ioctl with a point 50 the ``VIDIOC_SUBDEV_S_FMT`` ioctl with a pointer to this structure the 51 driver verifies the requested format, adjusts 51 driver verifies the requested format, adjusts it based on the hardware 52 capabilities and configures the device. Upon r 52 capabilities and configures the device. Upon return the struct 53 :c:type:`v4l2_subdev_format` contains the curr 53 :c:type:`v4l2_subdev_format` contains the current 54 format as would be returned by a ``VIDIOC_SUBD 54 format as would be returned by a ``VIDIOC_SUBDEV_G_FMT`` call. 55 55 56 Applications can query the device capabilities 56 Applications can query the device capabilities by setting the ``which`` 57 to ``V4L2_SUBDEV_FORMAT_TRY``. When set, 'try' 57 to ``V4L2_SUBDEV_FORMAT_TRY``. When set, 'try' formats are not applied 58 to the device by the driver, but are changed e 58 to the device by the driver, but are changed exactly as active formats 59 and stored in the sub-device file handle. Two 59 and stored in the sub-device file handle. Two applications querying the 60 same sub-device would thus not interact with e 60 same sub-device would thus not interact with each other. 61 61 62 For instance, to try a format at the output pa 62 For instance, to try a format at the output pad of a sub-device, 63 applications would first set the try format at 63 applications would first set the try format at the sub-device input with 64 the ``VIDIOC_SUBDEV_S_FMT`` ioctl. They would 64 the ``VIDIOC_SUBDEV_S_FMT`` ioctl. They would then either retrieve the 65 default format at the output pad with the ``VI 65 default format at the output pad with the ``VIDIOC_SUBDEV_G_FMT`` ioctl, 66 or set the desired output pad format with the 66 or set the desired output pad format with the ``VIDIOC_SUBDEV_S_FMT`` 67 ioctl and check the returned value. 67 ioctl and check the returned value. 68 68 69 Try formats do not depend on active formats, b 69 Try formats do not depend on active formats, but can depend on the 70 current links configuration or sub-device cont 70 current links configuration or sub-device controls value. For instance, 71 a low-pass noise filter might crop pixels at t 71 a low-pass noise filter might crop pixels at the frame boundaries, 72 modifying its output frame size. 72 modifying its output frame size. 73 73 74 If the subdev device node has been registered 74 If the subdev device node has been registered in read-only mode, calls to 75 ``VIDIOC_SUBDEV_S_FMT`` are only valid if the 75 ``VIDIOC_SUBDEV_S_FMT`` are only valid if the ``which`` field is set to 76 ``V4L2_SUBDEV_FORMAT_TRY``, otherwise an error 76 ``V4L2_SUBDEV_FORMAT_TRY``, otherwise an error is returned and the errno 77 variable is set to ``-EPERM``. 77 variable is set to ``-EPERM``. 78 78 79 Drivers must not return an error solely becaus 79 Drivers must not return an error solely because the requested format 80 doesn't match the device capabilities. They mu 80 doesn't match the device capabilities. They must instead modify the 81 format to match what the hardware can provide. 81 format to match what the hardware can provide. The modified format 82 should be as close as possible to the original 82 should be as close as possible to the original request. 83 83 84 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm 84 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}| 85 85 86 .. c:type:: v4l2_subdev_format 86 .. c:type:: v4l2_subdev_format 87 87 88 .. flat-table:: struct v4l2_subdev_format 88 .. flat-table:: struct v4l2_subdev_format 89 :header-rows: 0 89 :header-rows: 0 90 :stub-columns: 0 90 :stub-columns: 0 91 :widths: 1 1 2 91 :widths: 1 1 2 92 92 93 * - __u32 93 * - __u32 94 - ``pad`` 94 - ``pad`` 95 - Pad number as reported by the media co 95 - Pad number as reported by the media controller API. 96 * - __u32 96 * - __u32 97 - ``which`` 97 - ``which`` 98 - Format to modified, from enum 98 - Format to modified, from enum 99 :ref:`v4l2_subdev_format_whence <v4l2- 99 :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`. 100 * - struct :c:type:`v4l2_mbus_framefmt` 100 * - struct :c:type:`v4l2_mbus_framefmt` 101 - ``format`` 101 - ``format`` 102 - Definition of an image format, see :c: 102 - Definition of an image format, see :c:type:`v4l2_mbus_framefmt` for 103 details. 103 details. 104 * - __u32 104 * - __u32 105 - ``stream`` 105 - ``stream`` 106 - Stream identifier. 106 - Stream identifier. 107 * - __u32 107 * - __u32 108 - ``reserved``\ [7] 108 - ``reserved``\ [7] 109 - Reserved for future extensions. Applic 109 - Reserved for future extensions. Applications and drivers must set 110 the array to zero. 110 the array to zero. 111 111 112 112 113 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm 113 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}| 114 114 115 .. _v4l2-subdev-format-whence: 115 .. _v4l2-subdev-format-whence: 116 116 117 .. flat-table:: enum v4l2_subdev_format_whence 117 .. flat-table:: enum v4l2_subdev_format_whence 118 :header-rows: 0 118 :header-rows: 0 119 :stub-columns: 0 119 :stub-columns: 0 120 :widths: 3 1 4 120 :widths: 3 1 4 121 121 122 * - V4L2_SUBDEV_FORMAT_TRY 122 * - V4L2_SUBDEV_FORMAT_TRY 123 - 0 123 - 0 124 - Try formats, used for querying device 124 - Try formats, used for querying device capabilities. 125 * - V4L2_SUBDEV_FORMAT_ACTIVE 125 * - V4L2_SUBDEV_FORMAT_ACTIVE 126 - 1 126 - 1 127 - Active formats, applied to the hardwar 127 - Active formats, applied to the hardware. 128 128 129 Return Value 129 Return Value 130 ============ 130 ============ 131 131 132 On success 0 is returned, on error -1 and the 132 On success 0 is returned, on error -1 and the ``errno`` variable is set 133 appropriately. The generic error codes are des 133 appropriately. The generic error codes are described at the 134 :ref:`Generic Error Codes <gen-errors>` chapte 134 :ref:`Generic Error Codes <gen-errors>` chapter. 135 135 136 EBUSY 136 EBUSY 137 The format can't be changed because the pa 137 The format can't be changed because the pad is currently busy. This 138 can be caused, for instance, by an active 138 can be caused, for instance, by an active video stream on the pad. 139 The ioctl must not be retried without perf 139 The ioctl must not be retried without performing another action to 140 fix the problem first. Only returned by `` 140 fix the problem first. Only returned by ``VIDIOC_SUBDEV_S_FMT`` 141 141 142 EINVAL 142 EINVAL 143 The struct :c:type:`v4l2_subdev_format` `` 143 The struct :c:type:`v4l2_subdev_format` ``pad`` references a non-existing 144 pad, or the ``which`` field has an unsuppo 144 pad, or the ``which`` field has an unsupported value. 145 145 146 EPERM 146 EPERM 147 The ``VIDIOC_SUBDEV_S_FMT`` ioctl has been 147 The ``VIDIOC_SUBDEV_S_FMT`` ioctl has been called on a read-only subdevice 148 and the ``which`` field is set to ``V4L2_S 148 and the ``which`` field is set to ``V4L2_SUBDEV_FORMAT_ACTIVE``. 149 149 150 ============ 150 ============ 151 151 152 On success 0 is returned, on error -1 and the 152 On success 0 is returned, on error -1 and the ``errno`` variable is set 153 appropriately. The generic error codes are des 153 appropriately. The generic error codes are described at the 154 :ref:`Generic Error Codes <gen-errors>` chapte 154 :ref:`Generic Error Codes <gen-errors>` chapter.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.