1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>ioctl VIDIOC_ENUM_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 A. Function Reference"><link rel="prev" href="vidioc-enum-dv-timings.html" title="ioctl VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS"><link rel="next" href="vidioc-enum-framesizes.html" title="ioctl VIDIOC_ENUM_FRAMESIZES"></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_ENUM_FMT</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="vidioc-enum-dv-timings.html">Prev</a> </td><th width="60%" align="center">Appendix A. Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="vidioc-enum-framesizes.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="vidioc-enum-fmt"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_ENUM_FMT — Enumerate image formats</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_fmtdesc 2*<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1112832628"></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_ENUM_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="idp1112836644"></a><h2>Description</h2><p>To enumerate image formats applications initialize the 3<em class="structfield"><code>type</code></em> and <em class="structfield"><code>index</code></em> 4field of struct <a class="link" href="vidioc-enum-fmt.html#v4l2-fmtdesc" title="Table A.28. struct v4l2_fmtdesc">v4l2_fmtdesc</a> and call the 5<code class="constant">VIDIOC_ENUM_FMT</code> ioctl with a pointer to this 6structure. Drivers fill the rest of the structure or return an 7<span class="errorcode">EINVAL</span> error code. All formats are enumerable by beginning at index zero and 8incrementing by one until <span class="errorcode">EINVAL</span> is 9returned.</p><p>Note that after switching input or output the list of enumerated image 10formats may be different.</p><div class="table"><a name="v4l2-fmtdesc"></a><p class="title"><b>Table A.28. struct <span class="structname">v4l2_fmtdesc</span></b></p><div class="table-contents"><table summary="struct v4l2_fmtdesc" 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>index</code></em></td><td valign="top">Number of the format in the enumeration, set by 11the application. This is in no way related to the <em class="structfield"><code> 12pixelformat</code></em> field.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>type</code></em></td><td valign="top">Type of the data stream, set by the application. 13Only these types are valid here: 14<code class="constant">V4L2_BUF_TYPE_VIDEO_CAPTURE</code>, 15<code class="constant">V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</code>, 16<code class="constant">V4L2_BUF_TYPE_VIDEO_OUTPUT</code>, 17<code class="constant">V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE</code> and 18<code class="constant">V4L2_BUF_TYPE_VIDEO_OVERLAY</code>. See <a class="xref" href="buffer.html#v4l2-buf-type" title="Table 3.3. enum v4l2_buf_type">Table 3.3, “enum v4l2_buf_type”</a>.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>flags</code></em></td><td valign="top">See <a class="xref" href="vidioc-enum-fmt.html#fmtdesc-flags" title="Table A.29. Image Format Description Flags">Table A.29, “Image Format Description Flags”</a></td></tr><tr><td valign="top">__u8</td><td valign="top"><em class="structfield"><code>description</code></em>[32]</td><td valign="top">Description of the format, a NUL-terminated ASCII 19string. This information is intended for the user, for example: "YUV 204:2:2".</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>pixelformat</code></em></td><td valign="top">The image format identifier. This is a 21four character code as computed by the v4l2_fourcc() 22macro:</td></tr><tr><td colspan="3" valign="top"><p><a name="v4l2-fourcc"></a></p><pre class="programlisting"> 23#define v4l2_fourcc(a,b,c,d) (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) 24</pre><p>Several image formats are already 25defined by this specification in <a class="xref" href="pixfmt.html" title="Chapter 2. Image Formats">Chapter 2, <i>Image Formats</i></a>. Note these 26codes are not the same as those used in the Windows world.</p></td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>reserved</code></em>[4]</td><td valign="top">Reserved for future extensions. Drivers must set 27the array to zero.</td></tr></tbody></table></div></div><br class="table-break"><div class="table"><a name="fmtdesc-flags"></a><p class="title"><b>Table A.29. Image Format Description Flags</b></p><div class="table-contents"><table summary="Image Format Description Flags" width="100%" border="0"><colgroup><col class="c1"><col class="c2"><col class="c3"></colgroup><tbody valign="top"><tr><td valign="top"><code class="constant">V4L2_FMT_FLAG_COMPRESSED</code></td><td valign="top">0x0001</td><td valign="top">This is a compressed format.</td></tr><tr><td valign="top"><code class="constant">V4L2_FMT_FLAG_EMULATED</code></td><td valign="top">0x0002</td><td valign="top">This format is not native to the device but emulated 28through software (usually libv4l2), where possible try to use a native format 29instead for better performance.</td></tr></tbody></table></div></div><br class="table-break"></div><div class="refsect1"><a name="idp1112857652"></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">EINVAL</span></span></dt><dd><p>The struct <a class="link" href="vidioc-enum-fmt.html#v4l2-fmtdesc" title="Table A.28. struct v4l2_fmtdesc">v4l2_fmtdesc</a> <em class="structfield"><code>type</code></em> 30is not supported or the <em class="structfield"><code>index</code></em> is out of 31bounds.</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-enum-dv-timings.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-enum-framesizes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ioctl VIDIOC_ENUM_FRAMESIZES</td></tr></table></div></body></html> 32