Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4.8 171 lines 4.8 kB view raw
1.. -*- coding: utf-8; mode: rst -*- 2 3.. _VIDIOC_SUBDEV_G_FMT: 4 5********************************************** 6ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT 7********************************************** 8 9Name 10==== 11 12VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Get or set the data format on a subdev pad 13 14 15Synopsis 16======== 17 18.. cpp:function:: int ioctl( int fd, int request, struct v4l2_subdev_format *argp ) 19 20 21Arguments 22========= 23 24``fd`` 25 File descriptor returned by :ref:`open() <func-open>`. 26 27``request`` 28 VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT 29 30``argp`` 31 32 33Description 34=========== 35 36These ioctls are used to negotiate the frame format at specific subdev 37pads in the image pipeline. 38 39To retrieve the current format applications set the ``pad`` field of a 40struct :ref:`v4l2_subdev_format <v4l2-subdev-format>` to the desired 41pad number as reported by the media API and the ``which`` field to 42``V4L2_SUBDEV_FORMAT_ACTIVE``. When they call the 43``VIDIOC_SUBDEV_G_FMT`` ioctl with a pointer to this structure the 44driver fills the members of the ``format`` field. 45 46To change the current format applications set both the ``pad`` and 47``which`` fields and all members of the ``format`` field. When they call 48the ``VIDIOC_SUBDEV_S_FMT`` ioctl with a pointer to this structure the 49driver verifies the requested format, adjusts it based on the hardware 50capabilities and configures the device. Upon return the struct 51:ref:`v4l2_subdev_format <v4l2-subdev-format>` contains the current 52format as would be returned by a ``VIDIOC_SUBDEV_G_FMT`` call. 53 54Applications can query the device capabilities by setting the ``which`` 55to ``V4L2_SUBDEV_FORMAT_TRY``. When set, 'try' formats are not applied 56to the device by the driver, but are changed exactly as active formats 57and stored in the sub-device file handle. Two applications querying the 58same sub-device would thus not interact with each other. 59 60For instance, to try a format at the output pad of a sub-device, 61applications would first set the try format at the sub-device input with 62the ``VIDIOC_SUBDEV_S_FMT`` ioctl. They would then either retrieve the 63default format at the output pad with the ``VIDIOC_SUBDEV_G_FMT`` ioctl, 64or set the desired output pad format with the ``VIDIOC_SUBDEV_S_FMT`` 65ioctl and check the returned value. 66 67Try formats do not depend on active formats, but can depend on the 68current links configuration or sub-device controls value. For instance, 69a low-pass noise filter might crop pixels at the frame boundaries, 70modifying its output frame size. 71 72Drivers must not return an error solely because the requested format 73doesn't match the device capabilities. They must instead modify the 74format to match what the hardware can provide. The modified format 75should be as close as possible to the original request. 76 77 78.. _v4l2-subdev-format: 79 80.. flat-table:: struct v4l2_subdev_format 81 :header-rows: 0 82 :stub-columns: 0 83 :widths: 1 1 2 84 85 86 - .. row 1 87 88 - __u32 89 90 - ``pad`` 91 92 - Pad number as reported by the media controller API. 93 94 - .. row 2 95 96 - __u32 97 98 - ``which`` 99 100 - Format to modified, from enum 101 :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`. 102 103 - .. row 3 104 105 - struct :ref:`v4l2_mbus_framefmt <v4l2-mbus-framefmt>` 106 107 - ``format`` 108 109 - Definition of an image format, see :ref:`v4l2-mbus-framefmt` for 110 details. 111 112 - .. row 4 113 114 - __u32 115 116 - ``reserved``\ [8] 117 118 - Reserved for future extensions. Applications and drivers must set 119 the array to zero. 120 121 122 123.. _v4l2-subdev-format-whence: 124 125.. flat-table:: enum v4l2_subdev_format_whence 126 :header-rows: 0 127 :stub-columns: 0 128 :widths: 3 1 4 129 130 131 - .. row 1 132 133 - V4L2_SUBDEV_FORMAT_TRY 134 135 - 0 136 137 - Try formats, used for querying device capabilities. 138 139 - .. row 2 140 141 - V4L2_SUBDEV_FORMAT_ACTIVE 142 143 - 1 144 145 - Active formats, applied to the hardware. 146 147 148Return Value 149============ 150 151On success 0 is returned, on error -1 and the ``errno`` variable is set 152appropriately. The generic error codes are described at the 153:ref:`Generic Error Codes <gen-errors>` chapter. 154 155EBUSY 156 The format can't be changed because the pad is currently busy. This 157 can be caused, for instance, by an active video stream on the pad. 158 The ioctl must not be retried without performing another action to 159 fix the problem first. Only returned by ``VIDIOC_SUBDEV_S_FMT`` 160 161EINVAL 162 The struct :ref:`v4l2_subdev_format <v4l2-subdev-format>` 163 ``pad`` references a non-existing pad, or the ``which`` field 164 references a non-existing format. 165 166 167============ 168 169On success 0 is returned, on error -1 and the ``errno`` variable is set 170appropriately. The generic error codes are described at the 171:ref:`Generic Error Codes <gen-errors>` chapter.