Merge branch 'for-3.4/drivers' of git://git.kernel.dk/linux-block
[sfrench/cifs-2.6.git] / Documentation / DocBook / media / v4l / vidioc-encoder-cmd.xml
1 <refentry id="vidioc-encoder-cmd">
2   <refmeta>
3     <refentrytitle>ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</refentrytitle>
4     &manvol;
5   </refmeta>
6
7   <refnamediv>
8     <refname>VIDIOC_ENCODER_CMD</refname>
9     <refname>VIDIOC_TRY_ENCODER_CMD</refname>
10     <refpurpose>Execute an encoder command</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_encoder_cmd *<parameter>argp</parameter></paramdef>
20       </funcprototype>
21     </funcsynopsis>
22   </refsynopsisdiv>
23
24   <refsect1>
25     <title>Arguments</title>
26
27     <variablelist>
28       <varlistentry>
29         <term><parameter>fd</parameter></term>
30         <listitem>
31           <para>&fd;</para>
32         </listitem>
33       </varlistentry>
34       <varlistentry>
35         <term><parameter>request</parameter></term>
36         <listitem>
37           <para>VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</para>
38         </listitem>
39       </varlistentry>
40       <varlistentry>
41         <term><parameter>argp</parameter></term>
42         <listitem>
43           <para></para>
44         </listitem>
45       </varlistentry>
46     </variablelist>
47   </refsect1>
48
49   <refsect1>
50     <title>Description</title>
51
52     <note>
53       <title>Experimental</title>
54
55       <para>This is an <link linkend="experimental">experimental</link>
56 interface and may change in the future.</para>
57     </note>
58
59     <para>These ioctls control an audio/video (usually MPEG-) encoder.
60 <constant>VIDIOC_ENCODER_CMD</constant> sends a command to the
61 encoder, <constant>VIDIOC_TRY_ENCODER_CMD</constant> can be used to
62 try a command without actually executing it.</para>
63
64     <para>To send a command applications must initialize all fields of a
65     &v4l2-encoder-cmd; and call
66     <constant>VIDIOC_ENCODER_CMD</constant> or
67     <constant>VIDIOC_TRY_ENCODER_CMD</constant> with a pointer to this
68     structure.</para>
69
70     <para>The <structfield>cmd</structfield> field must contain the
71 command code. The <structfield>flags</structfield> field is currently
72 only used by the STOP command and contains one bit: If the
73 <constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant> flag is set,
74 encoding will continue until the end of the current <wordasword>Group
75 Of Pictures</wordasword>, otherwise it will stop immediately.</para>
76
77     <para>A <function>read</function>() or &VIDIOC-STREAMON; call sends an implicit
78 START command to the encoder if it has not been started yet. After a STOP command,
79 <function>read</function>() calls will read the remaining data
80 buffered by the driver. When the buffer is empty,
81 <function>read</function>() will return zero and the next
82 <function>read</function>() call will restart the encoder.</para>
83
84     <para>A <function>close</function>() or &VIDIOC-STREAMOFF; call of a streaming
85 file descriptor sends an implicit immediate STOP to the encoder, and all buffered
86 data is discarded.</para>
87
88     <para>These ioctls are optional, not all drivers may support
89 them. They were introduced in Linux 2.6.21.</para>
90
91     <table pgwide="1" frame="none" id="v4l2-encoder-cmd">
92       <title>struct <structname>v4l2_encoder_cmd</structname></title>
93       <tgroup cols="3">
94         &cs-str;
95         <tbody valign="top">
96           <row>
97             <entry>__u32</entry>
98             <entry><structfield>cmd</structfield></entry>
99             <entry>The encoder command, see <xref linkend="encoder-cmds" />.</entry>
100           </row>
101           <row>
102             <entry>__u32</entry>
103             <entry><structfield>flags</structfield></entry>
104             <entry>Flags to go with the command, see <xref
105                 linkend="encoder-flags" />. If no flags are defined for
106 this command, drivers and applications must set this field to
107 zero.</entry>
108           </row>
109           <row>
110             <entry>__u32</entry>
111             <entry><structfield>data</structfield>[8]</entry>
112             <entry>Reserved for future extensions. Drivers and
113 applications must set the array to zero.</entry>
114           </row>
115         </tbody>
116       </tgroup>
117     </table>
118
119     <table pgwide="1" frame="none" id="encoder-cmds">
120       <title>Encoder Commands</title>
121       <tgroup cols="3">
122         &cs-def;
123         <tbody valign="top">
124           <row>
125             <entry><constant>V4L2_ENC_CMD_START</constant></entry>
126             <entry>0</entry>
127             <entry>Start the encoder. When the encoder is already
128 running or paused, this command does nothing. No flags are defined for
129 this command.</entry>
130           </row>
131           <row>
132             <entry><constant>V4L2_ENC_CMD_STOP</constant></entry>
133             <entry>1</entry>
134             <entry>Stop the encoder. When the
135 <constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant> flag is set,
136 encoding will continue until the end of the current <wordasword>Group
137 Of Pictures</wordasword>, otherwise encoding will stop immediately.
138 When the encoder is already stopped, this command does
139 nothing.</entry>
140           </row>
141           <row>
142             <entry><constant>V4L2_ENC_CMD_PAUSE</constant></entry>
143             <entry>2</entry>
144             <entry>Pause the encoder. When the encoder has not been
145 started yet, the driver will return an &EPERM;. When the encoder is
146 already paused, this command does nothing. No flags are defined for
147 this command.</entry>
148           </row>
149           <row>
150             <entry><constant>V4L2_ENC_CMD_RESUME</constant></entry>
151             <entry>3</entry>
152             <entry>Resume encoding after a PAUSE command. When the
153 encoder has not been started yet, the driver will return an &EPERM;.
154 When the encoder is already running, this command does nothing. No
155 flags are defined for this command.</entry>
156           </row>
157         </tbody>
158       </tgroup>
159     </table>
160
161     <table pgwide="1" frame="none" id="encoder-flags">
162       <title>Encoder Command Flags</title>
163       <tgroup cols="3">
164         &cs-def;
165         <tbody valign="top">
166           <row>
167             <entry><constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant></entry>
168             <entry>0x0001</entry>
169             <entry>Stop encoding at the end of the current <wordasword>Group Of
170 Pictures</wordasword>, rather than immediately.</entry>
171           </row>
172        </tbody>
173       </tgroup>
174     </table>
175   </refsect1>
176
177   <refsect1>
178     &return-value;
179
180     <variablelist>
181       <varlistentry>
182         <term><errorcode>EINVAL</errorcode></term>
183         <listitem>
184           <para>The <structfield>cmd</structfield> field is invalid.</para>
185         </listitem>
186       </varlistentry>
187       <varlistentry>
188         <term><errorcode>EPERM</errorcode></term>
189         <listitem>
190           <para>The application sent a PAUSE or RESUME command when
191 the encoder was not running.</para>
192         </listitem>
193       </varlistentry>
194     </variablelist>
195   </refsect1>
196 </refentry>