About Kernel Documentation Linux Kernel Contact Linux Resources Linux Blog

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




Custom Search

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