1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT</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&#160;A.&#160;Function Reference"><link rel="prev" href="vidioc-subdev-g-crop.html" title="ioctl VIDIOC_SUBDEV_G_CROP, VIDIOC_SUBDEV_S_CROP"><link rel="next" href="vidioc-subdev-g-frame-interval.html" title="ioctl VIDIOC_SUBDEV_G_FRAME_INTERVAL, VIDIOC_SUBDEV_S_FRAME_INTERVAL"></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_FMT, VIDIOC_SUBDEV_S_FMT</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="vidioc-subdev-g-crop.html">Prev</a>&#160;</td><th width="60%" align="center">Appendix&#160;A.&#160;Function Reference</th><td width="20%" align="right">&#160;<a accesskey="n" href="vidioc-subdev-g-frame-interval.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="vidioc-subdev-g-fmt"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT &#8212; Get or set the data format 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>&#160;</td><td>int <var class="pdparam">request</var>, </td></tr><tr><td>&#160;</td><td>struct v4l2_subdev_format *<var class="pdparam">argp</var>
2	<code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1116627228"></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_FMT, VIDIOC_SUBDEV_S_FMT</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="idp1116699404"></a><h2>Description</h2><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Experimental</h3><p>This is an <a class="link" href="hist-v4l2.html#experimental" title="Experimental API Elements">experimental</a>
3      interface and may change in the future.</p></div><p>These ioctls are used to negotiate the frame format at specific
4    subdev pads in the image pipeline.</p><p>To retrieve the current format applications set the
5    <em class="structfield"><code>pad</code></em> field of a struct&#160;<a class="link" href="vidioc-subdev-g-fmt.html#v4l2-subdev-format" title="Table&#160;A.106.&#160;struct v4l2_subdev_format">v4l2_subdev_format</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>. When they call the
9    <code class="constant">VIDIOC_SUBDEV_G_FMT</code> ioctl with a pointer to this
10    structure the driver fills the members of the <em class="structfield"><code>format</code></em>
11    field.</p><p>To change the current format applications set both the
12    <em class="structfield"><code>pad</code></em> and <em class="structfield"><code>which</code></em> fields
13    and all members of the <em class="structfield"><code>format</code></em> field. When they
14    call the <code class="constant">VIDIOC_SUBDEV_S_FMT</code> ioctl with a pointer to this
15    structure the driver verifies the requested format, adjusts it based on the
16    hardware capabilities and configures the device. Upon return the
17    struct&#160;<a class="link" href="vidioc-subdev-g-fmt.html#v4l2-subdev-format" title="Table&#160;A.106.&#160;struct v4l2_subdev_format">v4l2_subdev_format</a> contains the current format as would be returned by a
18    <code class="constant">VIDIOC_SUBDEV_G_FMT</code> call.</p><p>Applications can query the device capabilities by setting the
19    <em class="structfield"><code>which</code></em> to
20    <code class="constant">V4L2_SUBDEV_FORMAT_TRY</code>. When set, 'try' formats are not
21    applied to the device by the driver, but are changed exactly as active
22    formats and stored in the sub-device file handle. Two applications querying
23    the same sub-device would thus not interact with each other.</p><p>For instance, to try a format at the output pad of a sub-device,
24    applications would first set the try format at the sub-device input with the
25    <code class="constant">VIDIOC_SUBDEV_S_FMT</code> ioctl. They would then either
26    retrieve the default format at the output pad with the
27    <code class="constant">VIDIOC_SUBDEV_G_FMT</code> ioctl, or set the desired output
28    pad format with the <code class="constant">VIDIOC_SUBDEV_S_FMT</code> ioctl and check
29    the returned value.</p><p>Try formats do not depend on active formats, but can depend on the
30    current links configuration or sub-device controls value. For instance, a
31    low-pass noise filter might crop pixels at the frame boundaries, modifying
32    its output frame size.</p><p>Drivers must not return an error solely because the requested format
33    doesn't match the device capabilities. They must instead modify the format
34    to match what the hardware can provide. The modified format should be as
35    close as possible to the original request.</p><div class="table"><a name="v4l2-subdev-format"></a><p class="title"><b>Table&#160;A.106.&#160;struct <span class="structname">v4l2_subdev_format</span></b></p><div class="table-contents"><table summary="struct v4l2_subdev_format" 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 controller API.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>which</code></em></td><td valign="top">Format to modified, from enum&#160;<a class="link" href="vidioc-subdev-g-fmt.html#v4l2-subdev-format-whence" title="Table&#160;A.107.&#160;enum v4l2_subdev_format_whence">v4l2_subdev_format_whence</a>.</td></tr><tr><td valign="top">struct&#160;<a class="link" href="subdev.html#v4l2-mbus-framefmt" title="Table&#160;4.20.&#160;struct v4l2_mbus_framefmt">v4l2_mbus_framefmt</a></td><td valign="top"><em class="structfield"><code>format</code></em></td><td valign="top">Definition of an image format, see <a class="xref" href="subdev.html#v4l2-mbus-framefmt" title="Table&#160;4.20.&#160;struct v4l2_mbus_framefmt">Table&#160;4.20, &#8220;struct <span class="structname">v4l2_mbus_framefmt</span>&#8221;</a> for details.</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
36	    set the array to zero.</td></tr></tbody></table></div></div><br class="table-break"><div class="table"><a name="v4l2-subdev-format-whence"></a><p class="title"><b>Table&#160;A.107.&#160;enum <span class="structname">v4l2_subdev_format_whence</span></b></p><div class="table-contents"><table summary="enum v4l2_subdev_format_whence" width="100%" border="0"><colgroup><col class="c1"><col class="c2"><col class="c3"></colgroup><tbody valign="top"><tr><td valign="top">V4L2_SUBDEV_FORMAT_TRY</td><td valign="top">0</td><td valign="top">Try formats, used for querying device capabilities.</td></tr><tr><td valign="top">V4L2_SUBDEV_FORMAT_ACTIVE</td><td valign="top">1</td><td valign="top">Active formats, applied to the hardware.</td></tr></tbody></table></div></div><br class="table-break"></div><div class="refsect1"><a name="idp1116721740"></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&#160;19.1.&#160;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 format can't be changed because the pad is currently busy.
37	  This can be caused, for instance, by an active video stream on the
38	  pad. The ioctl must not be retried without performing another action
39	  to fix the problem first. Only returned by
40	  <code class="constant">VIDIOC_SUBDEV_S_FMT</code></p></dd><dt><span class="term"><span class="errorcode">EINVAL</span></span></dt><dd><p>The struct&#160;<a class="link" href="vidioc-subdev-g-fmt.html#v4l2-subdev-format" title="Table&#160;A.106.&#160;struct v4l2_subdev_format">v4l2_subdev_format</a> <em class="structfield"><code>pad</code></em>
41	  references a non-existing pad, or the <em class="structfield"><code>which</code></em>
42	  field references a non-existing format.</p></dd></dl></div></div><div class="refsect1"><a name="idp1116726812"></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&#160;19.1.&#160;Generic error codes">Generic Error Codes</a> chapter.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="vidioc-subdev-g-crop.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="user-func.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="vidioc-subdev-g-frame-interval.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_SUBDEV_G_CROP, VIDIOC_SUBDEV_S_CROP&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;ioctl VIDIOC_SUBDEV_G_FRAME_INTERVAL, VIDIOC_SUBDEV_S_FRAME_INTERVAL</td></tr></table></div></body></html>
43