155 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _VIDIOC_SUBDEV_G_FMT:5 6**********************************************7ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT8**********************************************9 10Name11====12 13VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Get or set the data format on a subdev pad14 15Synopsis16========17 18.. c:macro:: VIDIOC_SUBDEV_G_FMT19 20``int ioctl(int fd, VIDIOC_SUBDEV_G_FMT, struct v4l2_subdev_format *argp)``21 22.. c:macro:: VIDIOC_SUBDEV_S_FMT23 24``int ioctl(int fd, VIDIOC_SUBDEV_S_FMT, struct v4l2_subdev_format *argp)``25 26Arguments27=========28 29``fd``30 File descriptor returned by :c:func:`open()`.31 32``argp``33 Pointer to struct :c:type:`v4l2_subdev_format`.34 35Description36===========37 38These ioctls are used to negotiate the frame format at specific subdev39pads in the image pipeline.40 41To retrieve the current format applications set the ``pad`` field of a42struct :c:type:`v4l2_subdev_format` to the desired43pad number as reported by the media API and the ``which`` field to44``V4L2_SUBDEV_FORMAT_ACTIVE``. When they call the45``VIDIOC_SUBDEV_G_FMT`` ioctl with a pointer to this structure the46driver fills the members of the ``format`` field.47 48To change the current format applications set both the ``pad`` and49``which`` fields and all members of the ``format`` field. When they call50the ``VIDIOC_SUBDEV_S_FMT`` ioctl with a pointer to this structure the51driver verifies the requested format, adjusts it based on the hardware52capabilities and configures the device. Upon return the struct53:c:type:`v4l2_subdev_format` contains the current54format as would be returned by a ``VIDIOC_SUBDEV_G_FMT`` call.55 56Applications can query the device capabilities by setting the ``which``57to ``V4L2_SUBDEV_FORMAT_TRY``. When set, 'try' formats are not applied58to the device by the driver, but are changed exactly as active formats59and stored in the sub-device file handle. Two applications querying the60same sub-device would thus not interact with each other.61 62For instance, to try a format at the output pad of a sub-device,63applications would first set the try format at the sub-device input with64the ``VIDIOC_SUBDEV_S_FMT`` ioctl. They would then either retrieve the65default format at the output pad with the ``VIDIOC_SUBDEV_G_FMT`` ioctl,66or set the desired output pad format with the ``VIDIOC_SUBDEV_S_FMT``67ioctl and check the returned value.68 69Try formats do not depend on active formats, but can depend on the70current links configuration or sub-device controls value. For instance,71a low-pass noise filter might crop pixels at the frame boundaries,72modifying its output frame size.73 74If the subdev device node has been registered in read-only mode, calls to75``VIDIOC_SUBDEV_S_FMT`` are only valid if the ``which`` field is set to76``V4L2_SUBDEV_FORMAT_TRY``, otherwise an error is returned and the errno77variable is set to ``-EPERM``.78 79Drivers must not return an error solely because the requested format80doesn't match the device capabilities. They must instead modify the81format to match what the hardware can provide. The modified format82should be as close as possible to the original request.83 84.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|85 86.. c:type:: v4l2_subdev_format87 88.. flat-table:: struct v4l2_subdev_format89 :header-rows: 090 :stub-columns: 091 :widths: 1 1 292 93 * - __u3294 - ``pad``95 - Pad number as reported by the media controller API.96 * - __u3297 - ``which``98 - Format to modified, from enum99 :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.100 * - struct :c:type:`v4l2_mbus_framefmt`101 - ``format``102 - Definition of an image format, see :c:type:`v4l2_mbus_framefmt` for103 details.104 * - __u32105 - ``stream``106 - Stream identifier.107 * - __u32108 - ``reserved``\ [7]109 - Reserved for future extensions. Applications and drivers must set110 the array to zero.111 112 113.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|114 115.. _v4l2-subdev-format-whence:116 117.. flat-table:: enum v4l2_subdev_format_whence118 :header-rows: 0119 :stub-columns: 0120 :widths: 3 1 4121 122 * - V4L2_SUBDEV_FORMAT_TRY123 - 0124 - Try formats, used for querying device capabilities.125 * - V4L2_SUBDEV_FORMAT_ACTIVE126 - 1127 - Active formats, applied to the hardware.128 129Return Value130============131 132On success 0 is returned, on error -1 and the ``errno`` variable is set133appropriately. The generic error codes are described at the134:ref:`Generic Error Codes <gen-errors>` chapter.135 136EBUSY137 The format can't be changed because the pad is currently busy. This138 can be caused, for instance, by an active video stream on the pad.139 The ioctl must not be retried without performing another action to140 fix the problem first. Only returned by ``VIDIOC_SUBDEV_S_FMT``141 142EINVAL143 The struct :c:type:`v4l2_subdev_format` ``pad`` references a non-existing144 pad, or the ``which`` field has an unsupported value.145 146EPERM147 The ``VIDIOC_SUBDEV_S_FMT`` ioctl has been called on a read-only subdevice148 and the ``which`` field is set to ``V4L2_SUBDEV_FORMAT_ACTIVE``.149 150============151 152On success 0 is returned, on error -1 and the ``errno`` variable is set153appropriately. The generic error codes are described at the154:ref:`Generic Error Codes <gen-errors>` chapter.155