1 .. -*- coding: utf-8; mode: rst -*-
3 .. _VIDIOC_SUBDEV_G_FMT:
5 **********************************************
6 ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT
7 **********************************************
12 VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Get or set the data format on a subdev pad
18 .. c:function:: int ioctl( int fd, VIDIOC_SUBDEV_G_FMT, struct v4l2_subdev_format *argp )
19 :name: VIDIOC_SUBDEV_G_FMT
21 .. c:function:: int ioctl( int fd, VIDIOC_SUBDEV_S_FMT, struct v4l2_subdev_format *argp )
22 :name: VIDIOC_SUBDEV_S_FMT
29 File descriptor returned by :ref:`open() <func-open>`.
32 Pointer to struct :c:type:`v4l2_subdev_format`.
38 These ioctls are used to negotiate the frame format at specific subdev
39 pads in the image pipeline.
41 To retrieve the current format applications set the ``pad`` field of a
42 struct :c:type:`v4l2_subdev_format` to the desired
43 pad number as reported by the media API and the ``which`` field to
44 ``V4L2_SUBDEV_FORMAT_ACTIVE``. When they call the
45 ``VIDIOC_SUBDEV_G_FMT`` ioctl with a pointer to this structure the
46 driver fills the members of the ``format`` field.
48 To change the current format applications set both the ``pad`` and
49 ``which`` fields and all members of the ``format`` field. When they call
50 the ``VIDIOC_SUBDEV_S_FMT`` ioctl with a pointer to this structure the
51 driver verifies the requested format, adjusts it based on the hardware
52 capabilities and configures the device. Upon return the struct
53 :c:type:`v4l2_subdev_format` contains the current
54 format as would be returned by a ``VIDIOC_SUBDEV_G_FMT`` call.
56 Applications can query the device capabilities by setting the ``which``
57 to ``V4L2_SUBDEV_FORMAT_TRY``. When set, 'try' formats are not applied
58 to the device by the driver, but are changed exactly as active formats
59 and stored in the sub-device file handle. Two applications querying the
60 same sub-device would thus not interact with each other.
62 For instance, to try a format at the output pad of a sub-device,
63 applications would first set the try format at the sub-device input with
64 the ``VIDIOC_SUBDEV_S_FMT`` ioctl. They would then either retrieve the
65 default format at the output pad with the ``VIDIOC_SUBDEV_G_FMT`` ioctl,
66 or set the desired output pad format with the ``VIDIOC_SUBDEV_S_FMT``
67 ioctl and check the returned value.
69 Try formats do not depend on active formats, but can depend on the
70 current links configuration or sub-device controls value. For instance,
71 a low-pass noise filter might crop pixels at the frame boundaries,
72 modifying its output frame size.
74 Drivers must not return an error solely because the requested format
75 doesn't match the device capabilities. They must instead modify the
76 format to match what the hardware can provide. The modified format
77 should be as close as possible to the original request.
80 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
82 .. c:type:: v4l2_subdev_format
84 .. flat-table:: struct v4l2_subdev_format
91 - Pad number as reported by the media controller API.
94 - Format to modified, from enum
95 :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
96 * - struct :c:type:`v4l2_mbus_framefmt`
98 - Definition of an image format, see :c:type:`v4l2_mbus_framefmt` for
102 - Reserved for future extensions. Applications and drivers must set
107 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
109 .. _v4l2-subdev-format-whence:
111 .. flat-table:: enum v4l2_subdev_format_whence
116 * - V4L2_SUBDEV_FORMAT_TRY
118 - Try formats, used for querying device capabilities.
119 * - V4L2_SUBDEV_FORMAT_ACTIVE
121 - Active formats, applied to the hardware.
127 On success 0 is returned, on error -1 and the ``errno`` variable is set
128 appropriately. The generic error codes are described at the
129 :ref:`Generic Error Codes <gen-errors>` chapter.
132 The format can't be changed because the pad is currently busy. This
133 can be caused, for instance, by an active video stream on the pad.
134 The ioctl must not be retried without performing another action to
135 fix the problem first. Only returned by ``VIDIOC_SUBDEV_S_FMT``
138 The struct :c:type:`v4l2_subdev_format`
139 ``pad`` references a non-existing pad, or the ``which`` field
140 references a non-existing format.
145 On success 0 is returned, on error -1 and the ``errno`` variable is set
146 appropriately. The generic error codes are described at the
147 :ref:`Generic Error Codes <gen-errors>` chapter.