2011-08-19 18:00:04 +08:00
|
|
|
<refentry id="vidioc-g-selection">
|
|
|
|
|
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>ioctl VIDIOC_G_SELECTION, VIDIOC_S_SELECTION</refentrytitle>
|
|
|
|
&manvol;
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>VIDIOC_G_SELECTION</refname>
|
|
|
|
<refname>VIDIOC_S_SELECTION</refname>
|
|
|
|
<refpurpose>Get or set one of the selection rectangles</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>ioctl</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fd</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>request</parameter></paramdef>
|
|
|
|
<paramdef>struct v4l2_selection *<parameter>argp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Arguments</title>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>fd</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>&fd;</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>request</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>VIDIOC_G_SELECTION, VIDIOC_S_SELECTION</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>argp</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para></para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
|
|
|
|
<para>The ioctls are used to query and configure selection rectangles.</para>
|
|
|
|
|
2014-06-13 15:47:37 +08:00
|
|
|
<para>To query the cropping (composing) rectangle set &v4l2-selection;
|
2012-03-09 17:46:28 +08:00
|
|
|
<structfield> type </structfield> field to the respective buffer type.
|
2015-03-16 04:51:54 +08:00
|
|
|
Do not use the multiplanar buffer types. Use <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant>
|
|
|
|
instead of <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant> and use
|
2014-06-13 15:47:37 +08:00
|
|
|
<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant> instead of
|
|
|
|
<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE</constant>. The next step is
|
2012-03-09 17:46:28 +08:00
|
|
|
setting the value of &v4l2-selection; <structfield>target</structfield> field
|
2014-06-13 15:47:37 +08:00
|
|
|
to <constant>V4L2_SEL_TGT_CROP</constant> (<constant>V4L2_SEL_TGT_COMPOSE</constant>).
|
|
|
|
Please refer to table <xref linkend="v4l2-selections-common" /> or <xref linkend="selection-api" />
|
|
|
|
for additional targets. The <structfield>flags</structfield> and <structfield>reserved
|
2012-03-09 17:46:28 +08:00
|
|
|
</structfield> fields of &v4l2-selection; are ignored and they must be filled
|
|
|
|
with zeros. The driver fills the rest of the structure or
|
2011-08-19 18:00:04 +08:00
|
|
|
returns &EINVAL; if incorrect buffer type or target was used. If cropping
|
|
|
|
(composing) is not supported then the active rectangle is not mutable and it is
|
2012-03-09 17:46:28 +08:00
|
|
|
always equal to the bounds rectangle. Finally, the &v4l2-rect;
|
|
|
|
<structfield>r</structfield> rectangle is filled with the current cropping
|
2011-08-19 18:00:04 +08:00
|
|
|
(composing) coordinates. The coordinates are expressed in driver-dependent
|
|
|
|
units. The only exception are rectangles for images in raw formats, whose
|
2014-06-13 15:47:37 +08:00
|
|
|
coordinates are always expressed in pixels.</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
|
2014-06-13 15:47:37 +08:00
|
|
|
<para>To change the cropping (composing) rectangle set the &v4l2-selection;
|
2012-03-09 17:46:28 +08:00
|
|
|
<structfield>type</structfield> field to the respective buffer type. Do not
|
2014-06-13 15:47:37 +08:00
|
|
|
use multiplanar buffers. Use <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant>
|
|
|
|
instead of <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant>. Use
|
|
|
|
<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant> instead of
|
|
|
|
<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE</constant>. The next step is
|
2012-03-09 17:46:28 +08:00
|
|
|
setting the value of &v4l2-selection; <structfield>target</structfield> to
|
2014-06-13 15:47:37 +08:00
|
|
|
<constant>V4L2_SEL_TGT_CROP</constant> (<constant>V4L2_SEL_TGT_COMPOSE</constant>).
|
|
|
|
Please refer to table <xref linkend="v4l2-selections-common" /> or <xref linkend="selection-api" />
|
|
|
|
for additional targets. The &v4l2-rect; <structfield>r</structfield> rectangle need to be
|
2012-03-09 17:46:28 +08:00
|
|
|
set to the desired active area. Field &v4l2-selection; <structfield> reserved
|
|
|
|
</structfield> is ignored and must be filled with zeros. The driver may adjust
|
|
|
|
coordinates of the requested rectangle. An application may
|
|
|
|
introduce constraints to control rounding behaviour. The &v4l2-selection;
|
|
|
|
<structfield>flags</structfield> field must be set to one of the following:
|
2011-08-19 18:00:04 +08:00
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para><constant>0</constant> - The driver can adjust the rectangle size freely
|
|
|
|
and shall choose a crop/compose rectangle as close as possible to the requested
|
|
|
|
one.</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para><constant>V4L2_SEL_FLAG_GE</constant> - The driver is not allowed to
|
|
|
|
shrink the rectangle. The original rectangle must lay inside the adjusted
|
|
|
|
one.</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para><constant>V4L2_SEL_FLAG_LE</constant> - The driver is not allowed to
|
|
|
|
enlarge the rectangle. The adjusted rectangle must lay inside the original
|
|
|
|
one.</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para><constant>V4L2_SEL_FLAG_GE | V4L2_SEL_FLAG_LE</constant> - The driver
|
|
|
|
must choose the size exactly the same as in the requested rectangle.</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
|
|
|
|
Please refer to <xref linkend="sel-const-adjust" />.
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para> The driver may have to adjusts the requested dimensions against hardware
|
|
|
|
limits and other parts as the pipeline, i.e. the bounds given by the
|
|
|
|
capture/output window or TV display. The closest possible values of horizontal
|
|
|
|
and vertical offset and sizes are chosen according to following priority:
|
|
|
|
|
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
2012-03-09 17:46:28 +08:00
|
|
|
<para>Satisfy constraints from &v4l2-selection; <structfield>flags</structfield>.</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Adjust width, height, left, and top to hardware limits and alignments.</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Keep center of adjusted rectangle as close as possible to the original one.</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Keep width and height as close as possible to original ones.</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>Keep horizontal and vertical offset as close as possible to original ones.</para>
|
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
|
2012-03-09 17:46:28 +08:00
|
|
|
On success the &v4l2-rect; <structfield>r</structfield> field contains
|
2011-08-19 18:00:04 +08:00
|
|
|
the adjusted rectangle. When the parameters are unsuitable the application may
|
|
|
|
modify the cropping (composing) or image parameters and repeat the cycle until
|
|
|
|
satisfactory parameters have been negotiated. If constraints flags have to be
|
2014-06-13 15:47:37 +08:00
|
|
|
violated at then ERANGE is returned. The error indicates that <emphasis>there
|
|
|
|
exist no rectangle</emphasis> that satisfies the constraints.</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
|
2012-06-14 03:01:10 +08:00
|
|
|
<para>Selection targets and flags are documented in <xref
|
2012-06-02 00:56:53 +08:00
|
|
|
linkend="v4l2-selections-common"/>.</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
|
2012-08-14 17:10:01 +08:00
|
|
|
<para>
|
2011-08-19 18:00:04 +08:00
|
|
|
<figure id="sel-const-adjust">
|
|
|
|
<title>Size adjustments with constraint flags.</title>
|
|
|
|
<mediaobject>
|
|
|
|
<imageobject>
|
|
|
|
<imagedata fileref="constraints.png" format="PNG" />
|
|
|
|
</imageobject>
|
|
|
|
<textobject>
|
|
|
|
<phrase>Behaviour of rectangle adjustment for different constraint
|
|
|
|
flags.</phrase>
|
|
|
|
</textobject>
|
|
|
|
</mediaobject>
|
|
|
|
</figure>
|
2012-08-14 17:10:01 +08:00
|
|
|
</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
|
2012-08-14 17:10:01 +08:00
|
|
|
<para>
|
2011-08-19 18:00:04 +08:00
|
|
|
<table pgwide="1" frame="none" id="v4l2-selection">
|
|
|
|
<title>struct <structname>v4l2_selection</structname></title>
|
|
|
|
<tgroup cols="3">
|
|
|
|
&cs-str;
|
|
|
|
<tbody valign="top">
|
|
|
|
<row>
|
|
|
|
<entry>__u32</entry>
|
|
|
|
<entry><structfield>type</structfield></entry>
|
2012-03-09 17:46:28 +08:00
|
|
|
<entry>Type of the buffer (from &v4l2-buf-type;).</entry>
|
2011-08-19 18:00:04 +08:00
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>__u32</entry>
|
|
|
|
<entry><structfield>target</structfield></entry>
|
2012-06-02 00:56:53 +08:00
|
|
|
<entry>Used to select between <link linkend="v4l2-selections-common"> cropping
|
2012-03-09 17:46:28 +08:00
|
|
|
and composing rectangles</link>.</entry>
|
2011-08-19 18:00:04 +08:00
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>__u32</entry>
|
|
|
|
<entry><structfield>flags</structfield></entry>
|
2012-03-09 17:46:28 +08:00
|
|
|
<entry>Flags controlling the selection rectangle adjustments, refer to
|
2012-06-14 03:01:10 +08:00
|
|
|
<link linkend="v4l2-selection-flags">selection flags</link>.</entry>
|
2011-08-19 18:00:04 +08:00
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>&v4l2-rect;</entry>
|
|
|
|
<entry><structfield>r</structfield></entry>
|
2012-03-09 17:46:28 +08:00
|
|
|
<entry>The selection rectangle.</entry>
|
2011-08-19 18:00:04 +08:00
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>__u32</entry>
|
|
|
|
<entry><structfield>reserved[9]</structfield></entry>
|
2015-06-05 16:11:15 +08:00
|
|
|
<entry>Reserved fields for future use. Drivers and applications must zero this array.</entry>
|
2011-08-19 18:00:04 +08:00
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</table>
|
2012-08-14 17:10:01 +08:00
|
|
|
</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
&return-value;
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><errorcode>EINVAL</errorcode></term>
|
|
|
|
<listitem>
|
2012-03-09 17:46:28 +08:00
|
|
|
<para>Given buffer type <structfield>type</structfield> or
|
|
|
|
the selection target <structfield>target</structfield> is not supported,
|
|
|
|
or the <structfield>flags</structfield> argument is not valid.</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><errorcode>ERANGE</errorcode></term>
|
|
|
|
<listitem>
|
2012-03-09 17:46:28 +08:00
|
|
|
<para>It is not possible to adjust &v4l2-rect; <structfield>
|
2016-04-27 07:41:21 +08:00
|
|
|
r</structfield> rectangle to satisfy all constraints given in the
|
2012-03-09 17:46:28 +08:00
|
|
|
<structfield>flags</structfield> argument.</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><errorcode>EBUSY</errorcode></term>
|
|
|
|
<listitem>
|
2012-03-09 17:46:28 +08:00
|
|
|
<para>It is not possible to apply change of the selection rectangle
|
|
|
|
at the moment. Usually because streaming is in progress.</para>
|
2011-08-19 18:00:04 +08:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
</refentry>
|