Path: blob/master/Documentation/DocBook/v4l/func-open.xml
10821 views
<refentry id="func-open">1<refmeta>2<refentrytitle>V4L2 open()</refentrytitle>3&manvol;4</refmeta>56<refnamediv>7<refname>v4l2-open</refname>8<refpurpose>Open a V4L2 device</refpurpose>9</refnamediv>1011<refsynopsisdiv>12<funcsynopsis>13<funcsynopsisinfo>#include <fcntl.h></funcsynopsisinfo>14<funcprototype>15<funcdef>int <function>open</function></funcdef>16<paramdef>const char *<parameter>device_name</parameter></paramdef>17<paramdef>int <parameter>flags</parameter></paramdef>18</funcprototype>19</funcsynopsis>20</refsynopsisdiv>2122<refsect1>23<title>Arguments</title>2425<variablelist>26<varlistentry>27<term><parameter>device_name</parameter></term>28<listitem>29<para>Device to be opened.</para>30</listitem>31</varlistentry>32<varlistentry>33<term><parameter>flags</parameter></term>34<listitem>35<para>Open flags. Access mode must be36<constant>O_RDWR</constant>. This is just a technicality, input devices37still support only reading and output devices only writing.</para>38<para>When the <constant>O_NONBLOCK</constant> flag is39given, the read() function and the &VIDIOC-DQBUF; ioctl will return40the &EAGAIN; when no data is available or no buffer is in the driver41outgoing queue, otherwise these functions block until data becomes42available. All V4L2 drivers exchanging data with applications must43support the <constant>O_NONBLOCK</constant> flag.</para>44<para>Other flags have no effect.</para>45</listitem>46</varlistentry>47</variablelist>48</refsect1>49<refsect1>50<title>Description</title>5152<para>To open a V4L2 device applications call53<function>open()</function> with the desired device name. This54function has no side effects; all data format parameters, current55input or output, control values or other properties remain unchanged.56At the first <function>open()</function> call after loading the driver57they will be reset to default values, drivers are never in an58undefined state.</para>59</refsect1>60<refsect1>61<title>Return Value</title>6263<para>On success <function>open</function> returns the new file64descriptor. On error -1 is returned, and the <varname>errno</varname>65variable is set appropriately. Possible error codes are:</para>6667<variablelist>68<varlistentry>69<term><errorcode>EACCES</errorcode></term>70<listitem>71<para>The caller has no permission to access the72device.</para>73</listitem>74</varlistentry>75<varlistentry>76<term><errorcode>EBUSY</errorcode></term>77<listitem>78<para>The driver does not support multiple opens and the79device is already in use.</para>80</listitem>81</varlistentry>82<varlistentry>83<term><errorcode>ENXIO</errorcode></term>84<listitem>85<para>No device corresponding to this device special file86exists.</para>87</listitem>88</varlistentry>89<varlistentry>90<term><errorcode>ENOMEM</errorcode></term>91<listitem>92<para>Not enough kernel memory was available to complete the93request.</para>94</listitem>95</varlistentry>96<varlistentry>97<term><errorcode>EMFILE</errorcode></term>98<listitem>99<para>The process already has the maximum number of100files open.</para>101</listitem>102</varlistentry>103<varlistentry>104<term><errorcode>ENFILE</errorcode></term>105<listitem>106<para>The limit on the total number of files open on the107system has been reached.</para>108</listitem>109</varlistentry>110</variablelist>111</refsect1>112</refentry>113114<!--115Local Variables:116mode: sgml117sgml-parent-document: "v4l2.sgml"118indent-tabs-mode: nil119End:120-->121122123