vidioc-subdev-g-fmt.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <refentry id="vidioc-subdev-g-fmt">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_SUBDEV_G_FMT</refname>
  8. <refname>VIDIOC_SUBDEV_S_FMT</refname>
  9. <refpurpose>Get or set the data format on a subdev pad</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_subdev_format *<parameter>argp</parameter>
  18. </paramdef>
  19. </funcprototype>
  20. </funcsynopsis>
  21. </refsynopsisdiv>
  22. <refsect1>
  23. <title>Arguments</title>
  24. <variablelist>
  25. <varlistentry>
  26. <term><parameter>fd</parameter></term>
  27. <listitem>
  28. <para>&fd;</para>
  29. </listitem>
  30. </varlistentry>
  31. <varlistentry>
  32. <term><parameter>request</parameter></term>
  33. <listitem>
  34. <para>VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT</para>
  35. </listitem>
  36. </varlistentry>
  37. <varlistentry>
  38. <term><parameter>argp</parameter></term>
  39. <listitem>
  40. <para></para>
  41. </listitem>
  42. </varlistentry>
  43. </variablelist>
  44. </refsect1>
  45. <refsect1>
  46. <title>Description</title>
  47. <note>
  48. <title>Experimental</title>
  49. <para>This is an <link linkend="experimental">experimental</link>
  50. interface and may change in the future.</para>
  51. </note>
  52. <para>These ioctls are used to negotiate the frame format at specific
  53. subdev pads in the image pipeline.</para>
  54. <para>To retrieve the current format applications set the
  55. <structfield>pad</structfield> field of a &v4l2-subdev-format; to the
  56. desired pad number as reported by the media API and the
  57. <structfield>which</structfield> field to
  58. <constant>V4L2_SUBDEV_FORMAT_ACTIVE</constant>. When they call the
  59. <constant>VIDIOC_SUBDEV_G_FMT</constant> ioctl with a pointer to this
  60. structure the driver fills the members of the <structfield>format</structfield>
  61. field.</para>
  62. <para>To change the current format applications set both the
  63. <structfield>pad</structfield> and <structfield>which</structfield> fields
  64. and all members of the <structfield>format</structfield> field. When they
  65. call the <constant>VIDIOC_SUBDEV_S_FMT</constant> ioctl with a pointer to this
  66. structure the driver verifies the requested format, adjusts it based on the
  67. hardware capabilities and configures the device. Upon return the
  68. &v4l2-subdev-format; contains the current format as would be returned by a
  69. <constant>VIDIOC_SUBDEV_G_FMT</constant> call.</para>
  70. <para>Applications can query the device capabilities by setting the
  71. <structfield>which</structfield> to
  72. <constant>V4L2_SUBDEV_FORMAT_TRY</constant>. When set, 'try' formats are not
  73. applied to the device by the driver, but are changed exactly as active
  74. formats and stored in the sub-device file handle. Two applications querying
  75. the same sub-device would thus not interact with each other.</para>
  76. <para>For instance, to try a format at the output pad of a sub-device,
  77. applications would first set the try format at the sub-device input with the
  78. <constant>VIDIOC_SUBDEV_S_FMT</constant> ioctl. They would then either
  79. retrieve the default format at the output pad with the
  80. <constant>VIDIOC_SUBDEV_G_FMT</constant> ioctl, or set the desired output
  81. pad format with the <constant>VIDIOC_SUBDEV_S_FMT</constant> ioctl and check
  82. the returned value.</para>
  83. <para>Try formats do not depend on active formats, but can depend on the
  84. current links configuration or sub-device controls value. For instance, a
  85. low-pass noise filter might crop pixels at the frame boundaries, modifying
  86. its output frame size.</para>
  87. <para>Drivers must not return an error solely because the requested format
  88. doesn't match the device capabilities. They must instead modify the format
  89. to match what the hardware can provide. The modified format should be as
  90. close as possible to the original request.</para>
  91. <table pgwide="1" frame="none" id="v4l2-subdev-format">
  92. <title>struct <structname>v4l2_subdev_format</structname></title>
  93. <tgroup cols="3">
  94. &cs-str;
  95. <tbody valign="top">
  96. <row>
  97. <entry>__u32</entry>
  98. <entry><structfield>pad</structfield></entry>
  99. <entry>Pad number as reported by the media controller API.</entry>
  100. </row>
  101. <row>
  102. <entry>__u32</entry>
  103. <entry><structfield>which</structfield></entry>
  104. <entry>Format to modified, from &v4l2-subdev-format-whence;.</entry>
  105. </row>
  106. <row>
  107. <entry>&v4l2-mbus-framefmt;</entry>
  108. <entry><structfield>format</structfield></entry>
  109. <entry>Definition of an image format, see <xref
  110. linkend="v4l2-mbus-framefmt" /> for details.</entry>
  111. </row>
  112. <row>
  113. <entry>__u32</entry>
  114. <entry><structfield>reserved</structfield>[8]</entry>
  115. <entry>Reserved for future extensions. Applications and drivers must
  116. set the array to zero.</entry>
  117. </row>
  118. </tbody>
  119. </tgroup>
  120. </table>
  121. <table pgwide="1" frame="none" id="v4l2-subdev-format-whence">
  122. <title>enum <structname>v4l2_subdev_format_whence</structname></title>
  123. <tgroup cols="3">
  124. &cs-def;
  125. <tbody valign="top">
  126. <row>
  127. <entry>V4L2_SUBDEV_FORMAT_TRY</entry>
  128. <entry>0</entry>
  129. <entry>Try formats, used for querying device capabilities.</entry>
  130. </row>
  131. <row>
  132. <entry>V4L2_SUBDEV_FORMAT_ACTIVE</entry>
  133. <entry>1</entry>
  134. <entry>Active formats, applied to the hardware.</entry>
  135. </row>
  136. </tbody>
  137. </tgroup>
  138. </table>
  139. </refsect1>
  140. <refsect1>
  141. &return-value;
  142. <variablelist>
  143. <varlistentry>
  144. <term><errorcode>EBUSY</errorcode></term>
  145. <listitem>
  146. <para>The format can't be changed because the pad is currently busy.
  147. This can be caused, for instance, by an active video stream on the
  148. pad. The ioctl must not be retried without performing another action
  149. to fix the problem first. Only returned by
  150. <constant>VIDIOC_SUBDEV_S_FMT</constant></para>
  151. </listitem>
  152. </varlistentry>
  153. <varlistentry>
  154. <term><errorcode>EINVAL</errorcode></term>
  155. <listitem>
  156. <para>The &v4l2-subdev-format; <structfield>pad</structfield>
  157. references a non-existing pad, or the <structfield>which</structfield>
  158. field references a non-existing format.</para>
  159. </listitem>
  160. </varlistentry>
  161. </variablelist>
  162. </refsect1>
  163. <refsect1>
  164. &return-value;
  165. </refsect1>
  166. </refentry>