Path: blob/master/Documentation/DocBook/v4l/media-func-open.xml
10821 views
<refentry id="media-func-open">1<refmeta>2<refentrytitle>media open()</refentrytitle>3&manvol;4</refmeta>56<refnamediv>7<refname>media-open</refname>8<refpurpose>Open a media 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 be either <constant>O_RDONLY</constant>36or <constant>O_RDWR</constant>. Other flags have no effect.</para>37</listitem>38</varlistentry>39</variablelist>40</refsect1>41<refsect1>42<title>Description</title>43<para>To open a media device applications call <function>open()</function>44with the desired device name. The function has no side effects; the device45configuration remain unchanged.</para>46<para>When the device is opened in read-only mode, attemps to modify its47configuration will result in an error, and <varname>errno</varname> will be48set to <errorcode>EBADF</errorcode>.</para>49</refsect1>50<refsect1>51<title>Return Value</title>5253<para><function>open</function> returns the new file descriptor on success.54On error, -1 is returned, and <varname>errno</varname> is set appropriately.55Possible error codes are:</para>5657<variablelist>58<varlistentry>59<term><errorcode>EACCES</errorcode></term>60<listitem>61<para>The requested access to the file is not allowed.</para>62</listitem>63</varlistentry>64<varlistentry>65<term><errorcode>EMFILE</errorcode></term>66<listitem>67<para>The process already has the maximum number of files open.68</para>69</listitem>70</varlistentry>71<varlistentry>72<term><errorcode>ENFILE</errorcode></term>73<listitem>74<para>The system limit on the total number of open files has been75reached.</para>76</listitem>77</varlistentry>78<varlistentry>79<term><errorcode>ENOMEM</errorcode></term>80<listitem>81<para>Insufficient kernel memory was available.</para>82</listitem>83</varlistentry>84<varlistentry>85<term><errorcode>ENXIO</errorcode></term>86<listitem>87<para>No device corresponding to this device special file exists.88</para>89</listitem>90</varlistentry>91</variablelist>92</refsect1>93</refentry>949596