vidioc-decoder-cmd.xml 9.2 KB

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