| Laurent Pinchart | 140d881 | 2010-08-18 11:41:22 -0300 | [diff] [blame] | 1 | <refentry id="media-func-open"> | 
|  | 2 | <refmeta> | 
|  | 3 | <refentrytitle>media open()</refentrytitle> | 
|  | 4 | &manvol; | 
|  | 5 | </refmeta> | 
|  | 6 |  | 
|  | 7 | <refnamediv> | 
|  | 8 | <refname>media-open</refname> | 
|  | 9 | <refpurpose>Open a media device</refpurpose> | 
|  | 10 | </refnamediv> | 
|  | 11 |  | 
|  | 12 | <refsynopsisdiv> | 
|  | 13 | <funcsynopsis> | 
|  | 14 | <funcsynopsisinfo>#include <fcntl.h></funcsynopsisinfo> | 
|  | 15 | <funcprototype> | 
|  | 16 | <funcdef>int <function>open</function></funcdef> | 
|  | 17 | <paramdef>const char *<parameter>device_name</parameter></paramdef> | 
|  | 18 | <paramdef>int <parameter>flags</parameter></paramdef> | 
|  | 19 | </funcprototype> | 
|  | 20 | </funcsynopsis> | 
|  | 21 | </refsynopsisdiv> | 
|  | 22 |  | 
|  | 23 | <refsect1> | 
|  | 24 | <title>Arguments</title> | 
|  | 25 |  | 
|  | 26 | <variablelist> | 
|  | 27 | <varlistentry> | 
|  | 28 | <term><parameter>device_name</parameter></term> | 
|  | 29 | <listitem> | 
|  | 30 | <para>Device to be opened.</para> | 
|  | 31 | </listitem> | 
|  | 32 | </varlistentry> | 
|  | 33 | <varlistentry> | 
|  | 34 | <term><parameter>flags</parameter></term> | 
|  | 35 | <listitem> | 
|  | 36 | <para>Open flags. Access mode must be either <constant>O_RDONLY</constant> | 
|  | 37 | or <constant>O_RDWR</constant>. Other flags have no effect.</para> | 
|  | 38 | </listitem> | 
|  | 39 | </varlistentry> | 
|  | 40 | </variablelist> | 
|  | 41 | </refsect1> | 
|  | 42 | <refsect1> | 
|  | 43 | <title>Description</title> | 
|  | 44 | <para>To open a media device applications call <function>open()</function> | 
|  | 45 | with the desired device name. The function has no side effects; the device | 
|  | 46 | configuration remain unchanged.</para> | 
|  | 47 | <para>When the device is opened in read-only mode, attemps to modify its | 
|  | 48 | configuration will result in an error, and <varname>errno</varname> will be | 
|  | 49 | set to <errorcode>EBADF</errorcode>.</para> | 
|  | 50 | </refsect1> | 
|  | 51 | <refsect1> | 
|  | 52 | <title>Return Value</title> | 
|  | 53 |  | 
|  | 54 | <para><function>open</function> returns the new file descriptor on success. | 
|  | 55 | On error, -1 is returned, and <varname>errno</varname> is set appropriately. | 
|  | 56 | Possible error codes are:</para> | 
|  | 57 |  | 
|  | 58 | <variablelist> | 
|  | 59 | <varlistentry> | 
|  | 60 | <term><errorcode>EACCES</errorcode></term> | 
|  | 61 | <listitem> | 
|  | 62 | <para>The requested access to the file is not allowed.</para> | 
|  | 63 | </listitem> | 
|  | 64 | </varlistentry> | 
|  | 65 | <varlistentry> | 
|  | 66 | <term><errorcode>EMFILE</errorcode></term> | 
|  | 67 | <listitem> | 
|  | 68 | <para>The  process  already  has  the  maximum number of files open. | 
|  | 69 | </para> | 
|  | 70 | </listitem> | 
|  | 71 | </varlistentry> | 
|  | 72 | <varlistentry> | 
|  | 73 | <term><errorcode>ENFILE</errorcode></term> | 
|  | 74 | <listitem> | 
|  | 75 | <para>The system limit on the total number of open files has been | 
|  | 76 | reached.</para> | 
|  | 77 | </listitem> | 
|  | 78 | </varlistentry> | 
|  | 79 | <varlistentry> | 
|  | 80 | <term><errorcode>ENOMEM</errorcode></term> | 
|  | 81 | <listitem> | 
|  | 82 | <para>Insufficient kernel memory was available.</para> | 
|  | 83 | </listitem> | 
|  | 84 | </varlistentry> | 
|  | 85 | <varlistentry> | 
|  | 86 | <term><errorcode>ENXIO</errorcode></term> | 
|  | 87 | <listitem> | 
|  | 88 | <para>No device corresponding to this device special file exists. | 
|  | 89 | </para> | 
|  | 90 | </listitem> | 
|  | 91 | </varlistentry> | 
|  | 92 | </variablelist> | 
|  | 93 | </refsect1> | 
|  | 94 | </refentry> |