Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / Documentation / DocBook / media / v4l / vidioc-decoder-cmd.xml
1 <refentry id="vidioc-decoder-cmd">
2   <refmeta>
3     <refentrytitle>ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD</refentrytitle>
4     &manvol;
5   </refmeta>
6
7   <refnamediv>
8     <refname>VIDIOC_DECODER_CMD</refname>
9     <refname>VIDIOC_TRY_DECODER_CMD</refname>
10     <refpurpose>Execute an decoder 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_decoder_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_DECODER_CMD, VIDIOC_TRY_DECODER_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     <para>These ioctls control an audio/video (usually MPEG-) decoder.
53 <constant>VIDIOC_DECODER_CMD</constant> sends a command to the
54 decoder, <constant>VIDIOC_TRY_DECODER_CMD</constant> can be used to
55 try a command without actually executing it. To send a command applications
56 must initialize all fields of a &v4l2-decoder-cmd; and call
57 <constant>VIDIOC_DECODER_CMD</constant> or <constant>VIDIOC_TRY_DECODER_CMD</constant>
58 with a pointer to this structure.</para>
59
60     <para>The <structfield>cmd</structfield> field must contain the
61 command code. Some commands use the <structfield>flags</structfield> field for
62 additional information.
63 </para>
64
65     <para>A <function>write</function>() or &VIDIOC-STREAMON; call sends an implicit
66 START command to the decoder if it has not been started yet.
67 </para>
68
69     <para>A <function>close</function>() or &VIDIOC-STREAMOFF; call of a streaming
70 file descriptor sends an implicit immediate STOP command to the decoder, and all
71 buffered data is discarded.</para>
72
73     <para>These ioctls are optional, not all drivers may support
74 them. They were introduced in Linux 3.3.</para>
75
76     <table pgwide="1" frame="none" id="v4l2-decoder-cmd">
77       <title>struct <structname>v4l2_decoder_cmd</structname></title>
78       <tgroup cols="5">
79         &cs-str;
80         <tbody valign="top">
81           <row>
82             <entry>__u32</entry>
83             <entry><structfield>cmd</structfield></entry>
84             <entry></entry>
85             <entry></entry>
86             <entry>The decoder command, see <xref linkend="decoder-cmds" />.</entry>
87           </row>
88           <row>
89             <entry>__u32</entry>
90             <entry><structfield>flags</structfield></entry>
91             <entry></entry>
92             <entry></entry>
93             <entry>Flags to go with the command. If no flags are defined for
94 this command, drivers and applications must set this field to zero.</entry>
95           </row>
96           <row>
97             <entry>union</entry>
98             <entry>(anonymous)</entry>
99             <entry></entry>
100             <entry></entry>
101             <entry></entry>
102           </row>
103           <row>
104             <entry></entry>
105             <entry>struct</entry>
106             <entry><structfield>start</structfield></entry>
107             <entry></entry>
108             <entry>Structure containing additional data for the
109 <constant>V4L2_DEC_CMD_START</constant> command.</entry>
110           </row>
111           <row>
112             <entry></entry>
113             <entry></entry>
114             <entry>__s32</entry>
115             <entry><structfield>speed</structfield></entry>
116             <entry>Playback speed and direction. The playback speed is defined as
117 <structfield>speed</structfield>/1000 of the normal speed. So 1000 is normal playback.
118 Negative numbers denote reverse playback, so -1000 does reverse playback at normal
119 speed. Speeds -1, 0 and 1 have special meanings: speed 0 is shorthand for 1000
120 (normal playback). A speed of 1 steps just one frame forward, a speed of -1 steps
121 just one frame back.
122             </entry>
123           </row>
124           <row>
125             <entry></entry>
126             <entry></entry>
127             <entry>__u32</entry>
128             <entry><structfield>format</structfield></entry>
129             <entry>Format restrictions. This field is set by the driver, not the
130 application. Possible values are <constant>V4L2_DEC_START_FMT_NONE</constant> if
131 there are no format restrictions or <constant>V4L2_DEC_START_FMT_GOP</constant>
132 if the decoder operates on full GOPs (<wordasword>Group Of Pictures</wordasword>).
133 This is usually the case for reverse playback: the decoder needs full GOPs, which
134 it can then play in reverse order. So to implement reverse playback the application
135 must feed the decoder the last GOP in the video file, then the GOP before that, etc. etc.
136             </entry>
137           </row>
138           <row>
139             <entry></entry>
140             <entry>struct</entry>
141             <entry><structfield>stop</structfield></entry>
142             <entry></entry>
143             <entry>Structure containing additional data for the
144 <constant>V4L2_DEC_CMD_STOP</constant> command.</entry>
145           </row>
146           <row>
147             <entry></entry>
148             <entry></entry>
149             <entry>__u64</entry>
150             <entry><structfield>pts</structfield></entry>
151             <entry>Stop playback at this <structfield>pts</structfield> or immediately
152 if the playback is already past that timestamp. Leave to 0 if you want to stop after the
153 last frame was decoded.
154             </entry>
155           </row>
156           <row>
157             <entry></entry>
158             <entry>struct</entry>
159             <entry><structfield>raw</structfield></entry>
160             <entry></entry>
161             <entry></entry>
162           </row>
163           <row>
164             <entry></entry>
165             <entry></entry>
166             <entry>__u32</entry>
167             <entry><structfield>data</structfield>[16]</entry>
168             <entry>Reserved for future extensions. Drivers and
169 applications must set the array to zero.</entry>
170           </row>
171         </tbody>
172       </tgroup>
173     </table>
174
175     <table pgwide="1" frame="none" id="decoder-cmds">
176       <title>Decoder Commands</title>
177       <tgroup cols="3">
178         &cs-def;
179         <tbody valign="top">
180           <row>
181             <entry><constant>V4L2_DEC_CMD_START</constant></entry>
182             <entry>0</entry>
183             <entry>Start the decoder. When the decoder is already
184 running or paused, this command will just change the playback speed.
185 That means that calling <constant>V4L2_DEC_CMD_START</constant> when
186 the decoder was paused will <emphasis>not</emphasis> resume the decoder.
187 You have to explicitly call <constant>V4L2_DEC_CMD_RESUME</constant> for that.
188 This command has one flag:
189 <constant>V4L2_DEC_CMD_START_MUTE_AUDIO</constant>. If set, then audio will
190 be muted when playing back at a non-standard speed.
191             </entry>
192           </row>
193           <row>
194             <entry><constant>V4L2_DEC_CMD_STOP</constant></entry>
195             <entry>1</entry>
196             <entry>Stop the decoder. When the decoder is already stopped,
197 this command does nothing. This command has two flags:
198 if <constant>V4L2_DEC_CMD_STOP_TO_BLACK</constant> is set, then the decoder will
199 set the picture to black after it stopped decoding. Otherwise the last image will
200 repeat. If <constant>V4L2_DEC_CMD_STOP_IMMEDIATELY</constant> is set, then the decoder
201 stops immediately (ignoring the <structfield>pts</structfield> value), otherwise it
202 will keep decoding until timestamp >= pts or until the last of the pending data from
203 its internal buffers was decoded.
204 </entry>
205           </row>
206           <row>
207             <entry><constant>V4L2_DEC_CMD_PAUSE</constant></entry>
208             <entry>2</entry>
209             <entry>Pause the decoder. When the decoder has not been
210 started yet, the driver will return an &EPERM;. When the decoder is
211 already paused, this command does nothing. This command has one flag:
212 if <constant>V4L2_DEC_CMD_PAUSE_TO_BLACK</constant> is set, then set the
213 decoder output to black when paused.
214 </entry>
215           </row>
216           <row>
217             <entry><constant>V4L2_DEC_CMD_RESUME</constant></entry>
218             <entry>3</entry>
219             <entry>Resume decoding after a PAUSE command. When the
220 decoder has not been started yet, the driver will return an &EPERM;.
221 When the decoder is already running, this command does nothing. No
222 flags are defined for this command.</entry>
223           </row>
224         </tbody>
225       </tgroup>
226     </table>
227
228   </refsect1>
229
230   <refsect1>
231     &return-value;
232
233     <variablelist>
234       <varlistentry>
235         <term><errorcode>EINVAL</errorcode></term>
236         <listitem>
237           <para>The <structfield>cmd</structfield> field is invalid.</para>
238         </listitem>
239       </varlistentry>
240       <varlistentry>
241         <term><errorcode>EPERM</errorcode></term>
242         <listitem>
243           <para>The application sent a PAUSE or RESUME command when
244 the decoder was not running.</para>
245         </listitem>
246       </varlistentry>
247     </variablelist>
248   </refsect1>
249 </refentry>