vidioc-g-crop.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <refentry id="vidioc-g-crop">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_G_CROP, VIDIOC_S_CROP</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_G_CROP</refname>
  8. <refname>VIDIOC_S_CROP</refname>
  9. <refpurpose>Get or set the current cropping rectangle</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_crop *<parameter>argp</parameter></paramdef>
  18. </funcprototype>
  19. </funcsynopsis>
  20. <funcsynopsis>
  21. <funcprototype>
  22. <funcdef>int <function>ioctl</function></funcdef>
  23. <paramdef>int <parameter>fd</parameter></paramdef>
  24. <paramdef>int <parameter>request</parameter></paramdef>
  25. <paramdef>const struct v4l2_crop *<parameter>argp</parameter></paramdef>
  26. </funcprototype>
  27. </funcsynopsis>
  28. </refsynopsisdiv>
  29. <refsect1>
  30. <title>Arguments</title>
  31. <variablelist>
  32. <varlistentry>
  33. <term><parameter>fd</parameter></term>
  34. <listitem>
  35. <para>&fd;</para>
  36. </listitem>
  37. </varlistentry>
  38. <varlistentry>
  39. <term><parameter>request</parameter></term>
  40. <listitem>
  41. <para>VIDIOC_G_CROP, VIDIOC_S_CROP</para>
  42. </listitem>
  43. </varlistentry>
  44. <varlistentry>
  45. <term><parameter>argp</parameter></term>
  46. <listitem>
  47. <para></para>
  48. </listitem>
  49. </varlistentry>
  50. </variablelist>
  51. </refsect1>
  52. <refsect1>
  53. <title>Description</title>
  54. <para>To query the cropping rectangle size and position
  55. applications set the <structfield>type</structfield> field of a
  56. <structname>v4l2_crop</structname> structure to the respective buffer
  57. (stream) type and call the <constant>VIDIOC_G_CROP</constant> ioctl
  58. with a pointer to this structure. The driver fills the rest of the
  59. structure or returns the &EINVAL; if cropping is not supported.</para>
  60. <para>To change the cropping rectangle applications initialize the
  61. <structfield>type</structfield> and &v4l2-rect; substructure named
  62. <structfield>c</structfield> of a v4l2_crop structure and call the
  63. <constant>VIDIOC_S_CROP</constant> ioctl with a pointer to this
  64. structure.</para>
  65. <para>Do not use the multiplanar buffer types. Use <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant>
  66. instead of <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant>
  67. and use <constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant> instead of
  68. <constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE</constant>.</para>
  69. <para>The driver first adjusts the requested dimensions against
  70. hardware limits, &ie; the bounds given by the capture/output window,
  71. and it rounds to the closest possible values of horizontal and
  72. vertical offset, width and height. In particular the driver must round
  73. the vertical offset of the cropping rectangle to frame lines modulo
  74. two, such that the field order cannot be confused.</para>
  75. <para>Second the driver adjusts the image size (the opposite
  76. rectangle of the scaling process, source or target depending on the
  77. data direction) to the closest size possible while maintaining the
  78. current horizontal and vertical scaling factor.</para>
  79. <para>Finally the driver programs the hardware with the actual
  80. cropping and image parameters. <constant>VIDIOC_S_CROP</constant> is a
  81. write-only ioctl, it does not return the actual parameters. To query
  82. them applications must call <constant>VIDIOC_G_CROP</constant> and
  83. &VIDIOC-G-FMT;. When the parameters are unsuitable the application may
  84. modify the cropping or image parameters and repeat the cycle until
  85. satisfactory parameters have been negotiated.</para>
  86. <para>When cropping is not supported then no parameters are
  87. changed and <constant>VIDIOC_S_CROP</constant> returns the
  88. &EINVAL;.</para>
  89. <table pgwide="1" frame="none" id="v4l2-crop">
  90. <title>struct <structname>v4l2_crop</structname></title>
  91. <tgroup cols="3">
  92. &cs-str;
  93. <tbody valign="top">
  94. <row>
  95. <entry>__u32</entry>
  96. <entry><structfield>type</structfield></entry>
  97. <entry>Type of the data stream, set by the application.
  98. Only these types are valid here: <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant>,
  99. <constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant> and
  100. <constant>V4L2_BUF_TYPE_VIDEO_OVERLAY</constant>. See <xref linkend="v4l2-buf-type" />.</entry>
  101. </row>
  102. <row>
  103. <entry>&v4l2-rect;</entry>
  104. <entry><structfield>c</structfield></entry>
  105. <entry>Cropping rectangle. The same co-ordinate system as
  106. for &v4l2-cropcap; <structfield>bounds</structfield> is used.</entry>
  107. </row>
  108. </tbody>
  109. </tgroup>
  110. </table>
  111. </refsect1>
  112. <refsect1>
  113. &return-value;
  114. </refsect1>
  115. </refentry>