1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>ioctl VIDIOC_SUBDEV_G_CROP, VIDIOC_SUBDEV_S_CROP</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="user-func.html" title="Appendix A. Function Reference"><link rel="prev" href="vidioc-subdev-enum-mbus-code.html" title="ioctl VIDIOC_SUBDEV_ENUM_MBUS_CODE"><link rel="next" href="vidioc-subdev-g-fmt.html" title="ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ioctl VIDIOC_SUBDEV_G_CROP, VIDIOC_SUBDEV_S_CROP</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="vidioc-subdev-enum-mbus-code.html">Prev</a> </td><th width="60%" align="center">Appendix A. Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="vidioc-subdev-g-fmt.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="vidioc-subdev-g-crop"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_SUBDEV_G_CROP, VIDIOC_SUBDEV_S_CROP — Get or set the crop rectangle on a subdev pad</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">ioctl</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">request</var>, </td></tr><tr><td> </td><td>struct v4l2_subdev_crop *<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">ioctl</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">request</var>, </td></tr><tr><td> </td><td>const struct v4l2_subdev_crop *<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1116632028"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>fd</code></em></span></dt><dd><p>File descriptor returned by <a class="link" href="func-open.html" title="V4L2 open()"><code class="function">open()</code></a>.</p></dd><dt><span class="term"><em class="parameter"><code>request</code></em></span></dt><dd><p>VIDIOC_SUBDEV_G_CROP, VIDIOC_SUBDEV_S_CROP</p></dd><dt><span class="term"><em class="parameter"><code>argp</code></em></span></dt><dd><p></p></dd></dl></div></div><div class="refsect1"><a name="idp1116636140"></a><h2>Description</h2><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Obsolete</h3><p>This is an <a class="link" href="hist-v4l2.html#obsolete" title="Obsolete API Elements">obsolete</a> 2 interface and may be removed in the future. It is superseded by 3 <a class="link" href="vidioc-subdev-g-selection.html" title="ioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION">the selection 4 API</a>.</p></div><p>To retrieve the current crop rectangle applications set the 5 <em class="structfield"><code>pad</code></em> field of a struct <a class="link" href="vidioc-subdev-g-crop.html#v4l2-subdev-crop" title="Table A.105. struct v4l2_subdev_crop">v4l2_subdev_crop</a> to the 6 desired pad number as reported by the media API and the 7 <em class="structfield"><code>which</code></em> field to 8 <code class="constant">V4L2_SUBDEV_FORMAT_ACTIVE</code>. They then call the 9 <code class="constant">VIDIOC_SUBDEV_G_CROP</code> ioctl with a pointer to this 10 structure. The driver fills the members of the <em class="structfield"><code>rect</code></em> 11 field or returns <span class="errorcode">EINVAL</span> error code if the input arguments are invalid, or if cropping 12 is not supported on the given pad.</p><p>To change the current crop rectangle applications set both the 13 <em class="structfield"><code>pad</code></em> and <em class="structfield"><code>which</code></em> fields 14 and all members of the <em class="structfield"><code>rect</code></em> field. They then call 15 the <code class="constant">VIDIOC_SUBDEV_S_CROP</code> ioctl with a pointer to this 16 structure. The driver verifies the requested crop rectangle, adjusts it 17 based on the hardware capabilities and configures the device. Upon return 18 the struct <a class="link" href="vidioc-subdev-g-crop.html#v4l2-subdev-crop" title="Table A.105. struct v4l2_subdev_crop">v4l2_subdev_crop</a> contains the current format as would be returned 19 by a <code class="constant">VIDIOC_SUBDEV_G_CROP</code> call.</p><p>Applications can query the device capabilities by setting the 20 <em class="structfield"><code>which</code></em> to 21 <code class="constant">V4L2_SUBDEV_FORMAT_TRY</code>. When set, 'try' crop 22 rectangles are not applied to the device by the driver, but are mangled 23 exactly as active crop rectangles and stored in the sub-device file handle. 24 Two applications querying the same sub-device would thus not interact with 25 each other.</p><p>Drivers must not return an error solely because the requested crop 26 rectangle doesn't match the device capabilities. They must instead modify 27 the rectangle to match what the hardware can provide. The modified format 28 should be as close as possible to the original request.</p><div class="table"><a name="v4l2-subdev-crop"></a><p class="title"><b>Table A.105. struct <span class="structname">v4l2_subdev_crop</span></b></p><div class="table-contents"><table summary="struct v4l2_subdev_crop" width="100%" border="0"><colgroup><col class="c1"><col class="c2"><col class="c3"></colgroup><tbody valign="top"><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>pad</code></em></td><td valign="top">Pad number as reported by the media framework.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>which</code></em></td><td valign="top">Crop rectangle to get or set, from 29 enum <a class="link" href="vidioc-subdev-g-fmt.html#v4l2-subdev-format-whence" title="Table A.107. enum v4l2_subdev_format_whence">v4l2_subdev_format_whence</a>.</td></tr><tr><td valign="top">struct <a class="link" href="overlay.html#v4l2-rect" title="Table 4.3. struct v4l2_rect">v4l2_rect</a></td><td valign="top"><em class="structfield"><code>rect</code></em></td><td valign="top">Crop rectangle boundaries, in pixels.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>reserved</code></em>[8]</td><td valign="top">Reserved for future extensions. Applications and drivers must 30 set the array to zero.</td></tr></tbody></table></div></div><br class="table-break"></div><div class="refsect1"><a name="idp1116652308"></a><h2>Return Value</h2><p>On success <span class="returnvalue">0</span> is returned, on error <span class="returnvalue">-1</span> and the <code class="varname">errno</code> variable is set appropriately. The generic error codes are described at the <a class="link" href="gen_errors.html#gen-errors" title="Table 19.1. Generic error codes">Generic Error Codes</a> chapter.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">EBUSY</span></span></dt><dd><p>The crop rectangle can't be changed because the pad is currently 31 busy. This can be caused, for instance, by an active video stream on 32 the pad. The ioctl must not be retried without performing another 33 action to fix the problem first. Only returned by 34 <code class="constant">VIDIOC_SUBDEV_S_CROP</code></p></dd><dt><span class="term"><span class="errorcode">EINVAL</span></span></dt><dd><p>The struct <a class="link" href="vidioc-subdev-g-crop.html#v4l2-subdev-crop" title="Table A.105. struct v4l2_subdev_crop">v4l2_subdev_crop</a> <em class="structfield"><code>pad</code></em> 35 references a non-existing pad, the <em class="structfield"><code>which</code></em> 36 field references a non-existing format, or cropping is not supported 37 on the given subdev pad.</p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="vidioc-subdev-enum-mbus-code.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="user-func.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="vidioc-subdev-g-fmt.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_SUBDEV_ENUM_MBUS_CODE </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT</td></tr></table></div></body></html> 38