1 <refentry id="vidioc-subdev-g-fmt">
3 <refentrytitle>ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT</refentrytitle>
8 <refname>VIDIOC_SUBDEV_G_FMT</refname>
9 <refname>VIDIOC_SUBDEV_S_FMT</refname>
10 <refpurpose>Get or set the data format on a subdev pad</refpurpose>
16 <funcdef>int <function>ioctl</function></funcdef>
17 <paramdef>int <parameter>fd</parameter></paramdef>
18 <paramdef>int <parameter>request</parameter></paramdef>
19 <paramdef>struct v4l2_subdev_format *<parameter>argp</parameter>
26 <title>Arguments</title>
30 <term><parameter>fd</parameter></term>
36 <term><parameter>request</parameter></term>
38 <para>VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT</para>
42 <term><parameter>argp</parameter></term>
51 <title>Description</title>
53 <para>These ioctls are used to negotiate the frame format at specific
54 subdev pads in the image pipeline.</para>
56 <para>To retrieve the current format applications set the
57 <structfield>pad</structfield> field of a &v4l2-subdev-format; to the
58 desired pad number as reported by the media API and the
59 <structfield>which</structfield> field to
60 <constant>V4L2_SUBDEV_FORMAT_ACTIVE</constant>. When they call the
61 <constant>VIDIOC_SUBDEV_G_FMT</constant> ioctl with a pointer to this
62 structure the driver fills the members of the <structfield>format</structfield>
65 <para>To change the current format applications set both the
66 <structfield>pad</structfield> and <structfield>which</structfield> fields
67 and all members of the <structfield>format</structfield> field. When they
68 call the <constant>VIDIOC_SUBDEV_S_FMT</constant> ioctl with a pointer to this
69 structure the driver verifies the requested format, adjusts it based on the
70 hardware capabilities and configures the device. Upon return the
71 &v4l2-subdev-format; contains the current format as would be returned by a
72 <constant>VIDIOC_SUBDEV_G_FMT</constant> call.</para>
74 <para>Applications can query the device capabilities by setting the
75 <structfield>which</structfield> to
76 <constant>V4L2_SUBDEV_FORMAT_TRY</constant>. When set, 'try' formats are not
77 applied to the device by the driver, but are changed exactly as active
78 formats and stored in the sub-device file handle. Two applications querying
79 the same sub-device would thus not interact with each other.</para>
81 <para>For instance, to try a format at the output pad of a sub-device,
82 applications would first set the try format at the sub-device input with the
83 <constant>VIDIOC_SUBDEV_S_FMT</constant> ioctl. They would then either
84 retrieve the default format at the output pad with the
85 <constant>VIDIOC_SUBDEV_G_FMT</constant> ioctl, or set the desired output
86 pad format with the <constant>VIDIOC_SUBDEV_S_FMT</constant> ioctl and check
87 the returned value.</para>
89 <para>Try formats do not depend on active formats, but can depend on the
90 current links configuration or sub-device controls value. For instance, a
91 low-pass noise filter might crop pixels at the frame boundaries, modifying
92 its output frame size.</para>
94 <para>Drivers must not return an error solely because the requested format
95 doesn't match the device capabilities. They must instead modify the format
96 to match what the hardware can provide. The modified format should be as
97 close as possible to the original request.</para>
99 <table pgwide="1" frame="none" id="v4l2-subdev-format">
100 <title>struct <structname>v4l2_subdev_format</structname></title>
106 <entry><structfield>pad</structfield></entry>
107 <entry>Pad number as reported by the media controller API.</entry>
111 <entry><structfield>which</structfield></entry>
112 <entry>Format to modified, from &v4l2-subdev-format-whence;.</entry>
115 <entry>&v4l2-mbus-framefmt;</entry>
116 <entry><structfield>format</structfield></entry>
117 <entry>Definition of an image format, see <xref
118 linkend="v4l2-mbus-framefmt" /> for details.</entry>
122 <entry><structfield>reserved</structfield>[8]</entry>
123 <entry>Reserved for future extensions. Applications and drivers must
124 set the array to zero.</entry>
130 <table pgwide="1" frame="none" id="v4l2-subdev-format-whence">
131 <title>enum <structname>v4l2_subdev_format_whence</structname></title>
136 <entry>V4L2_SUBDEV_FORMAT_TRY</entry>
138 <entry>Try formats, used for querying device capabilities.</entry>
141 <entry>V4L2_SUBDEV_FORMAT_ACTIVE</entry>
143 <entry>Active formats, applied to the hardware.</entry>
155 <term><errorcode>EBUSY</errorcode></term>
157 <para>The format can't be changed because the pad is currently busy.
158 This can be caused, for instance, by an active video stream on the
159 pad. The ioctl must not be retried without performing another action
160 to fix the problem first. Only returned by
161 <constant>VIDIOC_SUBDEV_S_FMT</constant></para>
165 <term><errorcode>EINVAL</errorcode></term>
167 <para>The &v4l2-subdev-format; <structfield>pad</structfield>
168 references a non-existing pad, or the <structfield>which</structfield>
169 field references a non-existing format.</para>