vidioc-g-fmt.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <refentry id="vidioc-g-fmt">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_G_FMT, VIDIOC_S_FMT,
  4. VIDIOC_TRY_FMT</refentrytitle>
  5. &manvol;
  6. </refmeta>
  7. <refnamediv>
  8. <refname>VIDIOC_G_FMT</refname>
  9. <refname>VIDIOC_S_FMT</refname>
  10. <refname>VIDIOC_TRY_FMT</refname>
  11. <refpurpose>Get or set the data format, try a format</refpurpose>
  12. </refnamediv>
  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_format
  20. *<parameter>argp</parameter></paramdef>
  21. </funcprototype>
  22. </funcsynopsis>
  23. </refsynopsisdiv>
  24. <refsect1>
  25. <title>Arguments</title>
  26. <variablelist>
  27. <varlistentry>
  28. <term><parameter>fd</parameter></term>
  29. <listitem>
  30. <para>&fd;</para>
  31. </listitem>
  32. </varlistentry>
  33. <varlistentry>
  34. <term><parameter>request</parameter></term>
  35. <listitem>
  36. <para>VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT</para>
  37. </listitem>
  38. </varlistentry>
  39. <varlistentry>
  40. <term><parameter>argp</parameter></term>
  41. <listitem>
  42. <para></para>
  43. </listitem>
  44. </varlistentry>
  45. </variablelist>
  46. </refsect1>
  47. <refsect1>
  48. <title>Description</title>
  49. <para>These ioctls are used to negotiate the format of data
  50. (typically image format) exchanged between driver and
  51. application.</para>
  52. <para>To query the current parameters applications set the
  53. <structfield>type</structfield> field of a struct
  54. <structname>v4l2_format</structname> to the respective buffer (stream)
  55. type. For example video capture devices use
  56. <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> or
  57. <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant>. When the application
  58. calls the <constant>VIDIOC_G_FMT</constant> ioctl with a pointer to
  59. this structure the driver fills the respective member of the
  60. <structfield>fmt</structfield> union. In case of video capture devices
  61. that is either the &v4l2-pix-format; <structfield>pix</structfield> or
  62. the &v4l2-pix-format-mplane; <structfield>pix_mp</structfield> member.
  63. When the requested buffer type is not supported drivers return an
  64. &EINVAL;.</para>
  65. <para>To change the current format parameters applications
  66. initialize the <structfield>type</structfield> field and all
  67. fields of the respective <structfield>fmt</structfield>
  68. union member. For details see the documentation of the various devices
  69. types in <xref linkend="devices" />. Good practice is to query the
  70. current parameters first, and to
  71. modify only those parameters not suitable for the application. When
  72. the application calls the <constant>VIDIOC_S_FMT</constant> ioctl
  73. with a pointer to a <structname>v4l2_format</structname> structure
  74. the driver checks
  75. and adjusts the parameters against hardware abilities. Drivers
  76. should not return an error code unless the <structfield>type</structfield> field is invalid, this is
  77. a mechanism to fathom device capabilities and to approach parameters
  78. acceptable for both the application and driver. On success the driver
  79. may program the hardware, allocate resources and generally prepare for
  80. data exchange.
  81. Finally the <constant>VIDIOC_S_FMT</constant> ioctl returns the
  82. current format parameters as <constant>VIDIOC_G_FMT</constant> does.
  83. Very simple, inflexible devices may even ignore all input and always
  84. return the default parameters. However all V4L2 devices exchanging
  85. data with the application must implement the
  86. <constant>VIDIOC_G_FMT</constant> and
  87. <constant>VIDIOC_S_FMT</constant> ioctl. When the requested buffer
  88. type is not supported drivers return an &EINVAL; on a
  89. <constant>VIDIOC_S_FMT</constant> attempt. When I/O is already in
  90. progress or the resource is not available for other reasons drivers
  91. return the &EBUSY;.</para>
  92. <para>The <constant>VIDIOC_TRY_FMT</constant> ioctl is equivalent
  93. to <constant>VIDIOC_S_FMT</constant> with one exception: it does not
  94. change driver state. It can also be called at any time, never
  95. returning <errorcode>EBUSY</errorcode>. This function is provided to
  96. negotiate parameters, to learn about hardware limitations, without
  97. disabling I/O or possibly time consuming hardware preparations.
  98. Although strongly recommended drivers are not required to implement
  99. this ioctl.</para>
  100. <para>The format as returned by <constant>VIDIOC_TRY_FMT</constant>
  101. must be identical to what <constant>VIDIOC_S_FMT</constant> returns for
  102. the same input or output.</para>
  103. <table pgwide="1" frame="none" id="v4l2-format">
  104. <title>struct <structname>v4l2_format</structname></title>
  105. <tgroup cols="4">
  106. <colspec colname="c1" />
  107. <colspec colname="c2" />
  108. <colspec colname="c3" />
  109. <colspec colname="c4" />
  110. <tbody valign="top">
  111. <row>
  112. <entry>__u32</entry>
  113. <entry><structfield>type</structfield></entry>
  114. <entry></entry>
  115. <entry>Type of the data stream, see <xref
  116. linkend="v4l2-buf-type" />.</entry>
  117. </row>
  118. <row>
  119. <entry>union</entry>
  120. <entry><structfield>fmt</structfield></entry>
  121. </row>
  122. <row>
  123. <entry></entry>
  124. <entry>&v4l2-pix-format;</entry>
  125. <entry><structfield>pix</structfield></entry>
  126. <entry>Definition of an image format, see <xref
  127. linkend="pixfmt" />, used by video capture and output
  128. devices.</entry>
  129. </row>
  130. <row>
  131. <entry></entry>
  132. <entry>&v4l2-pix-format-mplane;</entry>
  133. <entry><structfield>pix_mp</structfield></entry>
  134. <entry>Definition of an image format, see <xref
  135. linkend="pixfmt" />, used by video capture and output
  136. devices that support the <link linkend="planar-apis">multi-planar
  137. version of the API</link>.</entry>
  138. </row>
  139. <row>
  140. <entry></entry>
  141. <entry>&v4l2-window;</entry>
  142. <entry><structfield>win</structfield></entry>
  143. <entry>Definition of an overlaid image, see <xref
  144. linkend="overlay" />, used by video overlay devices.</entry>
  145. </row>
  146. <row>
  147. <entry></entry>
  148. <entry>&v4l2-vbi-format;</entry>
  149. <entry><structfield>vbi</structfield></entry>
  150. <entry>Raw VBI capture or output parameters. This is
  151. discussed in more detail in <xref linkend="raw-vbi" />. Used by raw VBI
  152. capture and output devices.</entry>
  153. </row>
  154. <row>
  155. <entry></entry>
  156. <entry>&v4l2-sliced-vbi-format;</entry>
  157. <entry><structfield>sliced</structfield></entry>
  158. <entry>Sliced VBI capture or output parameters. See
  159. <xref linkend="sliced" /> for details. Used by sliced VBI
  160. capture and output devices.</entry>
  161. </row>
  162. <row>
  163. <entry></entry>
  164. <entry>&v4l2-sdr-format;</entry>
  165. <entry><structfield>sdr</structfield></entry>
  166. <entry>Definition of a data format, see
  167. <xref linkend="pixfmt" />, used by SDR capture and output devices.</entry>
  168. </row>
  169. <row>
  170. <entry></entry>
  171. <entry>__u8</entry>
  172. <entry><structfield>raw_data</structfield>[200]</entry>
  173. <entry>Place holder for future extensions.</entry>
  174. </row>
  175. </tbody>
  176. </tgroup>
  177. </table>
  178. </refsect1>
  179. <refsect1>
  180. &return-value;
  181. <variablelist>
  182. <varlistentry>
  183. <term><errorcode>EINVAL</errorcode></term>
  184. <listitem>
  185. <para>The &v4l2-format; <structfield>type</structfield>
  186. field is invalid or the requested buffer type not supported.</para>
  187. </listitem>
  188. </varlistentry>
  189. </variablelist>
  190. </refsect1>
  191. </refentry>