Merge tag 'iwlwifi-next-for-kalle-2016-07-01' of git://git.kernel.org/pub/scm/linux...
[sfrench/cifs-2.6.git] / Documentation / DocBook / media / v4l / vidioc-subdev-g-fmt.xml
1 <refentry id="vidioc-subdev-g-fmt">
2   <refmeta>
3     <refentrytitle>ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT</refentrytitle>
4     &manvol;
5   </refmeta>
6
7   <refnamediv>
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>
11   </refnamediv>
12
13   <refsynopsisdiv>
14     <funcsynopsis>
15       <funcprototype>
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>
20         </paramdef>
21       </funcprototype>
22     </funcsynopsis>
23   </refsynopsisdiv>
24
25   <refsect1>
26     <title>Arguments</title>
27
28     <variablelist>
29       <varlistentry>
30         <term><parameter>fd</parameter></term>
31         <listitem>
32           <para>&fd;</para>
33         </listitem>
34       </varlistentry>
35       <varlistentry>
36         <term><parameter>request</parameter></term>
37         <listitem>
38           <para>VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT</para>
39         </listitem>
40       </varlistentry>
41       <varlistentry>
42         <term><parameter>argp</parameter></term>
43         <listitem>
44           <para></para>
45         </listitem>
46       </varlistentry>
47     </variablelist>
48   </refsect1>
49
50   <refsect1>
51     <title>Description</title>
52
53     <para>These ioctls are used to negotiate the frame format at specific
54     subdev pads in the image pipeline.</para>
55
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>
63     field.</para>
64
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>
73
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>
80
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>
88
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>
93
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>
98
99     <table pgwide="1" frame="none" id="v4l2-subdev-format">
100       <title>struct <structname>v4l2_subdev_format</structname></title>
101       <tgroup cols="3">
102         &cs-str;
103         <tbody valign="top">
104           <row>
105             <entry>__u32</entry>
106             <entry><structfield>pad</structfield></entry>
107             <entry>Pad number as reported by the media controller API.</entry>
108           </row>
109           <row>
110             <entry>__u32</entry>
111             <entry><structfield>which</structfield></entry>
112             <entry>Format to modified, from &v4l2-subdev-format-whence;.</entry>
113           </row>
114           <row>
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>
119           </row>
120           <row>
121             <entry>__u32</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>
125           </row>
126         </tbody>
127       </tgroup>
128     </table>
129
130     <table pgwide="1" frame="none" id="v4l2-subdev-format-whence">
131       <title>enum <structname>v4l2_subdev_format_whence</structname></title>
132       <tgroup cols="3">
133         &cs-def;
134         <tbody valign="top">
135           <row>
136             <entry>V4L2_SUBDEV_FORMAT_TRY</entry>
137             <entry>0</entry>
138             <entry>Try formats, used for querying device capabilities.</entry>
139           </row>
140           <row>
141             <entry>V4L2_SUBDEV_FORMAT_ACTIVE</entry>
142             <entry>1</entry>
143             <entry>Active formats, applied to the hardware.</entry>
144           </row>
145         </tbody>
146       </tgroup>
147     </table>
148   </refsect1>
149
150   <refsect1>
151     &return-value;
152
153     <variablelist>
154       <varlistentry>
155         <term><errorcode>EBUSY</errorcode></term>
156         <listitem>
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>
162         </listitem>
163       </varlistentry>
164       <varlistentry>
165         <term><errorcode>EINVAL</errorcode></term>
166         <listitem>
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>
170         </listitem>
171       </varlistentry>
172     </variablelist>
173   </refsect1>
174   <refsect1>
175     &return-value;
176   </refsect1>
177 </refentry>