1 <refentry id="vidioc-g-crop">
3 <refentrytitle>ioctl VIDIOC_G_CROP, VIDIOC_S_CROP</refentrytitle>
8 <refname>VIDIOC_G_CROP</refname>
9 <refname>VIDIOC_S_CROP</refname>
10 <refpurpose>Get or set the current cropping rectangle</refpurpose>
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>
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>
33 <title>Arguments</title>
37 <term><parameter>fd</parameter></term>
43 <term><parameter>request</parameter></term>
45 <para>VIDIOC_G_CROP, VIDIOC_S_CROP</para>
49 <term><parameter>argp</parameter></term>
58 <title>Description</title>
60 <para>To query the cropping rectangle size and position
61 applications 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
64 with a pointer to this structure. The driver fills the rest of the
65 structure or returns the &EINVAL; if cropping is not supported.</para>
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
73 <para>The driver first adjusts the requested dimensions against
74 hardware limits, &ie; the bounds given by the capture/output window,
75 and it rounds to the closest possible values of horizontal and
76 vertical offset, width and height. In particular the driver must round
77 the vertical offset of the cropping rectangle to frame lines modulo
78 two, such that the field order cannot be confused.</para>
80 <para>Second the driver adjusts the image size (the opposite
81 rectangle of the scaling process, source or target depending on the
82 data direction) to the closest size possible while maintaining the
83 current horizontal and vertical scaling factor.</para>
85 <para>Finally the driver programs the hardware with the actual
86 cropping and image parameters. <constant>VIDIOC_S_CROP</constant> is a
87 write-only ioctl, it does not return the actual parameters. To query
88 them applications must call <constant>VIDIOC_G_CROP</constant> and
89 &VIDIOC-G-FMT;. When the parameters are unsuitable the application may
90 modify the cropping or image parameters and repeat the cycle until
91 satisfactory parameters have been negotiated.</para>
93 <para>When cropping is not supported then no parameters are
94 changed and <constant>VIDIOC_S_CROP</constant> returns the
97 <table pgwide="1" frame="none" id="v4l2-crop">
98 <title>struct <structname>v4l2_crop</structname></title>
103 <entry>&v4l2-buf-type;</entry>
104 <entry><structfield>type</structfield></entry>
105 <entry>Type of the data stream, set by the application.
106 Only these types are valid here: <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant>,
107 <constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant>,
108 <constant>V4L2_BUF_TYPE_VIDEO_OVERLAY</constant>, and custom (driver
109 defined) types with code <constant>V4L2_BUF_TYPE_PRIVATE</constant>
113 <entry>&v4l2-rect;</entry>
114 <entry><structfield>c</structfield></entry>
115 <entry>Cropping rectangle. The same co-ordinate system as
116 for &v4l2-cropcap; <structfield>bounds</structfield> is used.</entry>
128 <term><errorcode>EINVAL</errorcode></term>
130 <para>Cropping is not supported.</para>
140 sgml-parent-document: "v4l2.sgml"
141 indent-tabs-mode: nil