Based on kernel version 3.9. Page generated on 2013-05-02 23:04 EST.
1 <refentry id="vidioc-g-selection"> 2 3 <refmeta> 4 <refentrytitle>ioctl VIDIOC_G_SELECTION, VIDIOC_S_SELECTION</refentrytitle> 5 &manvol; 6 </refmeta> 7 8 <refnamediv> 9 <refname>VIDIOC_G_SELECTION</refname> 10 <refname>VIDIOC_S_SELECTION</refname> 11 <refpurpose>Get or set one of the selection rectangles</refpurpose> 12 </refnamediv> 13 14 <refsynopsisdiv> 15 <funcsynopsis> 16 <funcprototype> 17 <funcdef>int <function>ioctl</function></funcdef> 18 <paramdef>int <parameter>fd</parameter></paramdef> 19 <paramdef>int <parameter>request</parameter></paramdef> 20 <paramdef>struct v4l2_selection *<parameter>argp</parameter></paramdef> 21 </funcprototype> 22 </funcsynopsis> 23 </refsynopsisdiv> 24 25 <refsect1> 26 <title>Arguments</title> 27 28 <variablelist> 29 <varlistentry> 30 <term><parameter>fd</parameter></term> 31 <listitem> 32 <para>&fd;</para> 33 </listitem> 34 </varlistentry> 35 <varlistentry> 36 <term><parameter>request</parameter></term> 37 <listitem> 38 <para>VIDIOC_G_SELECTION, VIDIOC_S_SELECTION</para> 39 </listitem> 40 </varlistentry> 41 <varlistentry> 42 <term><parameter>argp</parameter></term> 43 <listitem> 44 <para></para> 45 </listitem> 46 </varlistentry> 47 </variablelist> 48 </refsect1> 49 50 <refsect1> 51 <title>Description</title> 52 53 <note> 54 <title>Experimental</title> 55 <para>This is an <link linkend="experimental"> experimental </link> 56 interface and may change in the future.</para> 57 </note> 58 59 <para>The ioctls are used to query and configure selection rectangles.</para> 60 61 <para> To query the cropping (composing) rectangle set &v4l2-selection; 62 <structfield> type </structfield> field to the respective buffer type. 63 Do not use multiplanar buffers. Use <constant> V4L2_BUF_TYPE_VIDEO_CAPTURE 64 </constant> instead of <constant> V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 65 </constant>. Use <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT </constant> instead of 66 <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE </constant>. The next step is 67 setting the value of &v4l2-selection; <structfield>target</structfield> field 68 to <constant> V4L2_SEL_TGT_CROP </constant> (<constant> 69 V4L2_SEL_TGT_COMPOSE </constant>). Please refer to table <xref 70 linkend="v4l2-selections-common" /> or <xref linkend="selection-api" /> for additional 71 targets. The <structfield>flags</structfield> and <structfield>reserved 72 </structfield> fields of &v4l2-selection; are ignored and they must be filled 73 with zeros. The driver fills the rest of the structure or 74 returns &EINVAL; if incorrect buffer type or target was used. If cropping 75 (composing) is not supported then the active rectangle is not mutable and it is 76 always equal to the bounds rectangle. Finally, the &v4l2-rect; 77 <structfield>r</structfield> rectangle is filled with the current cropping 78 (composing) coordinates. The coordinates are expressed in driver-dependent 79 units. The only exception are rectangles for images in raw formats, whose 80 coordinates are always expressed in pixels. </para> 81 82 <para> To change the cropping (composing) rectangle set the &v4l2-selection; 83 <structfield>type</structfield> field to the respective buffer type. Do not 84 use multiplanar buffers. Use <constant> V4L2_BUF_TYPE_VIDEO_CAPTURE 85 </constant> instead of <constant> V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 86 </constant>. Use <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT </constant> instead of 87 <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE </constant>. The next step is 88 setting the value of &v4l2-selection; <structfield>target</structfield> to 89 <constant>V4L2_SEL_TGT_CROP</constant> (<constant> 90 V4L2_SEL_TGT_COMPOSE </constant>). Please refer to table <xref 91 linkend="v4l2-selections-common" /> or <xref linkend="selection-api" /> for additional 92 targets. The &v4l2-rect; <structfield>r</structfield> rectangle need to be 93 set to the desired active area. Field &v4l2-selection; <structfield> reserved 94 </structfield> is ignored and must be filled with zeros. The driver may adjust 95 coordinates of the requested rectangle. An application may 96 introduce constraints to control rounding behaviour. The &v4l2-selection; 97 <structfield>flags</structfield> field must be set to one of the following: 98 99 <itemizedlist> 100 <listitem> 101 <para><constant>0</constant> - The driver can adjust the rectangle size freely 102 and shall choose a crop/compose rectangle as close as possible to the requested 103 one.</para> 104 </listitem> 105 <listitem> 106 <para><constant>V4L2_SEL_FLAG_GE</constant> - The driver is not allowed to 107 shrink the rectangle. The original rectangle must lay inside the adjusted 108 one.</para> 109 </listitem> 110 <listitem> 111 <para><constant>V4L2_SEL_FLAG_LE</constant> - The driver is not allowed to 112 enlarge the rectangle. The adjusted rectangle must lay inside the original 113 one.</para> 114 </listitem> 115 <listitem> 116 <para><constant>V4L2_SEL_FLAG_GE | V4L2_SEL_FLAG_LE</constant> - The driver 117 must choose the size exactly the same as in the requested rectangle.</para> 118 </listitem> 119 </itemizedlist> 120 121 Please refer to <xref linkend="sel-const-adjust" />. 122 123 </para> 124 125 <para> The driver may have to adjusts the requested dimensions against hardware 126 limits and other parts as the pipeline, i.e. the bounds given by the 127 capture/output window or TV display. The closest possible values of horizontal 128 and vertical offset and sizes are chosen according to following priority: 129 130 <orderedlist> 131 <listitem> 132 <para>Satisfy constraints from &v4l2-selection; <structfield>flags</structfield>.</para> 133 </listitem> 134 <listitem> 135 <para>Adjust width, height, left, and top to hardware limits and alignments.</para> 136 </listitem> 137 <listitem> 138 <para>Keep center of adjusted rectangle as close as possible to the original one.</para> 139 </listitem> 140 <listitem> 141 <para>Keep width and height as close as possible to original ones.</para> 142 </listitem> 143 <listitem> 144 <para>Keep horizontal and vertical offset as close as possible to original ones.</para> 145 </listitem> 146 </orderedlist> 147 148 On success the &v4l2-rect; <structfield>r</structfield> field contains 149 the adjusted rectangle. When the parameters are unsuitable the application may 150 modify the cropping (composing) or image parameters and repeat the cycle until 151 satisfactory parameters have been negotiated. If constraints flags have to be 152 violated at then ERANGE is returned. The error indicates that <emphasis> there 153 exist no rectangle </emphasis> that satisfies the constraints.</para> 154 155 <para>Selection targets and flags are documented in <xref 156 linkend="v4l2-selections-common"/>.</para> 157 158 <para> 159 <figure id="sel-const-adjust"> 160 <title>Size adjustments with constraint flags.</title> 161 <mediaobject> 162 <imageobject> 163 <imagedata fileref="constraints.png" format="PNG" /> 164 </imageobject> 165 <textobject> 166 <phrase>Behaviour of rectangle adjustment for different constraint 167 flags.</phrase> 168 </textobject> 169 </mediaobject> 170 </figure> 171 </para> 172 173 <para> 174 <table pgwide="1" frame="none" id="v4l2-selection"> 175 <title>struct <structname>v4l2_selection</structname></title> 176 <tgroup cols="3"> 177 &cs-str; 178 <tbody valign="top"> 179 <row> 180 <entry>__u32</entry> 181 <entry><structfield>type</structfield></entry> 182 <entry>Type of the buffer (from &v4l2-buf-type;).</entry> 183 </row> 184 <row> 185 <entry>__u32</entry> 186 <entry><structfield>target</structfield></entry> 187 <entry>Used to select between <link linkend="v4l2-selections-common"> cropping 188 and composing rectangles</link>.</entry> 189 </row> 190 <row> 191 <entry>__u32</entry> 192 <entry><structfield>flags</structfield></entry> 193 <entry>Flags controlling the selection rectangle adjustments, refer to 194 <link linkend="v4l2-selection-flags">selection flags</link>.</entry> 195 </row> 196 <row> 197 <entry>&v4l2-rect;</entry> 198 <entry><structfield>r</structfield></entry> 199 <entry>The selection rectangle.</entry> 200 </row> 201 <row> 202 <entry>__u32</entry> 203 <entry><structfield>reserved[9]</structfield></entry> 204 <entry>Reserved fields for future use.</entry> 205 </row> 206 </tbody> 207 </tgroup> 208 </table> 209 </para> 210 </refsect1> 211 212 <refsect1> 213 &return-value; 214 <variablelist> 215 <varlistentry> 216 <term><errorcode>EINVAL</errorcode></term> 217 <listitem> 218 <para>Given buffer type <structfield>type</structfield> or 219 the selection target <structfield>target</structfield> is not supported, 220 or the <structfield>flags</structfield> argument is not valid.</para> 221 </listitem> 222 </varlistentry> 223 <varlistentry> 224 <term><errorcode>ERANGE</errorcode></term> 225 <listitem> 226 <para>It is not possible to adjust &v4l2-rect; <structfield> 227 r</structfield> rectangle to satisfy all contraints given in the 228 <structfield>flags</structfield> argument.</para> 229 </listitem> 230 </varlistentry> 231 <varlistentry> 232 <term><errorcode>EBUSY</errorcode></term> 233 <listitem> 234 <para>It is not possible to apply change of the selection rectangle 235 at the moment. Usually because streaming is in progress.</para> 236 </listitem> 237 </varlistentry> 238 </variablelist> 239 </refsect1> 240 241 </refentry>