About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

Documentation / DocBook / media / v4l / vidioc-g-selection.xml




Custom Search

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

Information is copyright its respective author. All material is available from the Linux Kernel Source distributed under a GPL License. This page is provided as a free service by mjmwired.net.