Kyle Swenson | 8d8f654 | 2021-03-15 11:02:55 -0600 | [diff] [blame^] | 1 | <refentry id="vidioc-enum-fmt"> |
| 2 | <refmeta> |
| 3 | <refentrytitle>ioctl VIDIOC_ENUM_FMT</refentrytitle> |
| 4 | &manvol; |
| 5 | </refmeta> |
| 6 | |
| 7 | <refnamediv> |
| 8 | <refname>VIDIOC_ENUM_FMT</refname> |
| 9 | <refpurpose>Enumerate image formats</refpurpose> |
| 10 | </refnamediv> |
| 11 | |
| 12 | <refsynopsisdiv> |
| 13 | <funcsynopsis> |
| 14 | <funcprototype> |
| 15 | <funcdef>int <function>ioctl</function></funcdef> |
| 16 | <paramdef>int <parameter>fd</parameter></paramdef> |
| 17 | <paramdef>int <parameter>request</parameter></paramdef> |
| 18 | <paramdef>struct v4l2_fmtdesc |
| 19 | *<parameter>argp</parameter></paramdef> |
| 20 | </funcprototype> |
| 21 | </funcsynopsis> |
| 22 | </refsynopsisdiv> |
| 23 | |
| 24 | <refsect1> |
| 25 | <title>Arguments</title> |
| 26 | |
| 27 | <variablelist> |
| 28 | <varlistentry> |
| 29 | <term><parameter>fd</parameter></term> |
| 30 | <listitem> |
| 31 | <para>&fd;</para> |
| 32 | </listitem> |
| 33 | </varlistentry> |
| 34 | <varlistentry> |
| 35 | <term><parameter>request</parameter></term> |
| 36 | <listitem> |
| 37 | <para>VIDIOC_ENUM_FMT</para> |
| 38 | </listitem> |
| 39 | </varlistentry> |
| 40 | <varlistentry> |
| 41 | <term><parameter>argp</parameter></term> |
| 42 | <listitem> |
| 43 | <para></para> |
| 44 | </listitem> |
| 45 | </varlistentry> |
| 46 | </variablelist> |
| 47 | </refsect1> |
| 48 | |
| 49 | <refsect1> |
| 50 | <title>Description</title> |
| 51 | |
| 52 | <para>To enumerate image formats applications initialize the |
| 53 | <structfield>type</structfield> and <structfield>index</structfield> |
| 54 | field of &v4l2-fmtdesc; and call the |
| 55 | <constant>VIDIOC_ENUM_FMT</constant> ioctl with a pointer to this |
| 56 | structure. Drivers fill the rest of the structure or return an |
| 57 | &EINVAL;. All formats are enumerable by beginning at index zero and |
| 58 | incrementing by one until <errorcode>EINVAL</errorcode> is |
| 59 | returned.</para> |
| 60 | |
| 61 | <para>Note that after switching input or output the list of enumerated image |
| 62 | formats may be different.</para> |
| 63 | |
| 64 | <table pgwide="1" frame="none" id="v4l2-fmtdesc"> |
| 65 | <title>struct <structname>v4l2_fmtdesc</structname></title> |
| 66 | <tgroup cols="3"> |
| 67 | &cs-str; |
| 68 | <tbody valign="top"> |
| 69 | <row> |
| 70 | <entry>__u32</entry> |
| 71 | <entry><structfield>index</structfield></entry> |
| 72 | <entry>Number of the format in the enumeration, set by |
| 73 | the application. This is in no way related to the <structfield> |
| 74 | pixelformat</structfield> field.</entry> |
| 75 | </row> |
| 76 | <row> |
| 77 | <entry>__u32</entry> |
| 78 | <entry><structfield>type</structfield></entry> |
| 79 | <entry>Type of the data stream, set by the application. |
| 80 | Only these types are valid here: |
| 81 | <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant>, |
| 82 | <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant>, |
| 83 | <constant>V4L2_BUF_TYPE_VIDEO_OUTPUT</constant>, |
| 84 | <constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE</constant> and |
| 85 | <constant>V4L2_BUF_TYPE_VIDEO_OVERLAY</constant>. See <xref linkend="v4l2-buf-type" />.</entry> |
| 86 | </row> |
| 87 | <row> |
| 88 | <entry>__u32</entry> |
| 89 | <entry><structfield>flags</structfield></entry> |
| 90 | <entry>See <xref linkend="fmtdesc-flags" /></entry> |
| 91 | </row> |
| 92 | <row> |
| 93 | <entry>__u8</entry> |
| 94 | <entry><structfield>description</structfield>[32]</entry> |
| 95 | <entry>Description of the format, a NUL-terminated ASCII |
| 96 | string. This information is intended for the user, for example: "YUV |
| 97 | 4:2:2".</entry> |
| 98 | </row> |
| 99 | <row> |
| 100 | <entry>__u32</entry> |
| 101 | <entry><structfield>pixelformat</structfield></entry> |
| 102 | <entry>The image format identifier. This is a |
| 103 | four character code as computed by the v4l2_fourcc() |
| 104 | macro:</entry> |
| 105 | </row> |
| 106 | <row> |
| 107 | <entry spanname="hspan"><para><programlisting id="v4l2-fourcc"> |
| 108 | #define v4l2_fourcc(a,b,c,d) (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) |
| 109 | </programlisting></para><para>Several image formats are already |
| 110 | defined by this specification in <xref linkend="pixfmt" />. Note these |
| 111 | codes are not the same as those used in the Windows world.</para></entry> |
| 112 | </row> |
| 113 | <row> |
| 114 | <entry>__u32</entry> |
| 115 | <entry><structfield>reserved</structfield>[4]</entry> |
| 116 | <entry>Reserved for future extensions. Drivers must set |
| 117 | the array to zero.</entry> |
| 118 | </row> |
| 119 | </tbody> |
| 120 | </tgroup> |
| 121 | </table> |
| 122 | |
| 123 | <table pgwide="1" frame="none" id="fmtdesc-flags"> |
| 124 | <title>Image Format Description Flags</title> |
| 125 | <tgroup cols="3"> |
| 126 | &cs-def; |
| 127 | <tbody valign="top"> |
| 128 | <row> |
| 129 | <entry><constant>V4L2_FMT_FLAG_COMPRESSED</constant></entry> |
| 130 | <entry>0x0001</entry> |
| 131 | <entry>This is a compressed format.</entry> |
| 132 | </row> |
| 133 | <row> |
| 134 | <entry><constant>V4L2_FMT_FLAG_EMULATED</constant></entry> |
| 135 | <entry>0x0002</entry> |
| 136 | <entry>This format is not native to the device but emulated |
| 137 | through software (usually libv4l2), where possible try to use a native format |
| 138 | instead for better performance.</entry> |
| 139 | </row> |
| 140 | </tbody> |
| 141 | </tgroup> |
| 142 | </table> |
| 143 | </refsect1> |
| 144 | |
| 145 | <refsect1> |
| 146 | &return-value; |
| 147 | |
| 148 | <variablelist> |
| 149 | <varlistentry> |
| 150 | <term><errorcode>EINVAL</errorcode></term> |
| 151 | <listitem> |
| 152 | <para>The &v4l2-fmtdesc; <structfield>type</structfield> |
| 153 | is not supported or the <structfield>index</structfield> is out of |
| 154 | bounds.</para> |
| 155 | </listitem> |
| 156 | </varlistentry> |
| 157 | </variablelist> |
| 158 | </refsect1> |
| 159 | </refentry> |