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