vidioc-g-fmt.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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>. When the application
  57. calls the <constant>VIDIOC_G_FMT</constant> ioctl with a pointer to
  58. this structure the driver fills the respective member of the
  59. <structfield>fmt</structfield> union. In case of video capture devices
  60. that is the &v4l2-pix-format; <structfield>pix</structfield> member.
  61. When the requested buffer type is not supported drivers return an
  62. &EINVAL;.</para>
  63. <para>To change the current format parameters applications
  64. initialize the <structfield>type</structfield> field and all
  65. fields of the respective <structfield>fmt</structfield>
  66. union member. For details see the documentation of the various devices
  67. types in <xref linkend="devices" />. Good practice is to query the
  68. current parameters first, and to
  69. modify only those parameters not suitable for the application. When
  70. the application calls the <constant>VIDIOC_S_FMT</constant> ioctl
  71. with a pointer to a <structname>v4l2_format</structname> structure
  72. the driver checks
  73. and adjusts the parameters against hardware abilities. Drivers
  74. should not return an error code unless the input is ambiguous, this is
  75. a mechanism to fathom device capabilities and to approach parameters
  76. acceptable for both the application and driver. On success the driver
  77. may program the hardware, allocate resources and generally prepare for
  78. data exchange.
  79. Finally the <constant>VIDIOC_S_FMT</constant> ioctl returns the
  80. current format parameters as <constant>VIDIOC_G_FMT</constant> does.
  81. Very simple, inflexible devices may even ignore all input and always
  82. return the default parameters. However all V4L2 devices exchanging
  83. data with the application must implement the
  84. <constant>VIDIOC_G_FMT</constant> and
  85. <constant>VIDIOC_S_FMT</constant> ioctl. When the requested buffer
  86. type is not supported drivers return an &EINVAL; on a
  87. <constant>VIDIOC_S_FMT</constant> attempt. When I/O is already in
  88. progress or the resource is not available for other reasons drivers
  89. return the &EBUSY;.</para>
  90. <para>The <constant>VIDIOC_TRY_FMT</constant> ioctl is equivalent
  91. to <constant>VIDIOC_S_FMT</constant> with one exception: it does not
  92. change driver state. It can also be called at any time, never
  93. returning <errorcode>EBUSY</errorcode>. This function is provided to
  94. negotiate parameters, to learn about hardware limitations, without
  95. disabling I/O or possibly time consuming hardware preparations.
  96. Although strongly recommended drivers are not required to implement
  97. this ioctl.</para>
  98. <table pgwide="1" frame="none" id="v4l2-format">
  99. <title>struct <structname>v4l2_format</structname></title>
  100. <tgroup cols="4">
  101. <colspec colname="c1" />
  102. <colspec colname="c2" />
  103. <colspec colname="c3" />
  104. <colspec colname="c4" />
  105. <tbody valign="top">
  106. <row>
  107. <entry>&v4l2-buf-type;</entry>
  108. <entry><structfield>type</structfield></entry>
  109. <entry></entry>
  110. <entry>Type of the data stream, see <xref
  111. linkend="v4l2-buf-type" />.</entry>
  112. </row>
  113. <row>
  114. <entry>union</entry>
  115. <entry><structfield>fmt</structfield></entry>
  116. </row>
  117. <row>
  118. <entry></entry>
  119. <entry>&v4l2-pix-format;</entry>
  120. <entry><structfield>pix</structfield></entry>
  121. <entry>Definition of an image format, see <xref
  122. linkend="pixfmt" />, used by video capture and output
  123. devices.</entry>
  124. </row>
  125. <row>
  126. <entry></entry>
  127. <entry>&v4l2-window;</entry>
  128. <entry><structfield>win</structfield></entry>
  129. <entry>Definition of an overlaid image, see <xref
  130. linkend="overlay" />, used by video overlay devices.</entry>
  131. </row>
  132. <row>
  133. <entry></entry>
  134. <entry>&v4l2-vbi-format;</entry>
  135. <entry><structfield>vbi</structfield></entry>
  136. <entry>Raw VBI capture or output parameters. This is
  137. discussed in more detail in <xref linkend="raw-vbi" />. Used by raw VBI
  138. capture and output devices.</entry>
  139. </row>
  140. <row>
  141. <entry></entry>
  142. <entry>&v4l2-sliced-vbi-format;</entry>
  143. <entry><structfield>sliced</structfield></entry>
  144. <entry>Sliced VBI capture or output parameters. See
  145. <xref linkend="sliced" /> for details. Used by sliced VBI
  146. capture and output devices.</entry>
  147. </row>
  148. <row>
  149. <entry></entry>
  150. <entry>__u8</entry>
  151. <entry><structfield>raw_data</structfield>[200]</entry>
  152. <entry>Place holder for future extensions and custom
  153. (driver defined) formats with <structfield>type</structfield>
  154. <constant>V4L2_BUF_TYPE_PRIVATE</constant> and higher.</entry>
  155. </row>
  156. </tbody>
  157. </tgroup>
  158. </table>
  159. </refsect1>
  160. <refsect1>
  161. &return-value;
  162. <variablelist>
  163. <varlistentry>
  164. <term><errorcode>EBUSY</errorcode></term>
  165. <listitem>
  166. <para>The data format cannot be changed at this
  167. time, for example because I/O is already in progress.</para>
  168. </listitem>
  169. </varlistentry>
  170. <varlistentry>
  171. <term><errorcode>EINVAL</errorcode></term>
  172. <listitem>
  173. <para>The &v4l2-format; <structfield>type</structfield>
  174. field is invalid, the requested buffer type not supported, or
  175. <constant>VIDIOC_TRY_FMT</constant> was called and is not
  176. supported with this buffer type.</para>
  177. </listitem>
  178. </varlistentry>
  179. </variablelist>
  180. </refsect1>
  181. </refentry>
  182. <!--
  183. Local Variables:
  184. mode: sgml
  185. sgml-parent-document: "v4l2.sgml"
  186. indent-tabs-mode: nil
  187. End:
  188. -->