aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/DocBook/v4l/media-func-open.xml
blob: f7df034dc9edeb9b535eb7748aac66e3b61f1cbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<refentry id="media-func-open">
  <refmeta>
    <refentrytitle>media open()</refentrytitle>
    &manvol;
  </refmeta>

  <refnamediv>
    <refname>media-open</refname>
    <refpurpose>Open a media device</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcsynopsisinfo>#include &lt;fcntl.h&gt;</funcsynopsisinfo>
      <funcprototype>
	<funcdef>int <function>open</function></funcdef>
	<paramdef>const char *<parameter>device_name</parameter></paramdef>
	<paramdef>int <parameter>flags</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>

  <refsect1>
    <title>Arguments</title>

    <variablelist>
      <varlistentry>
	<term><parameter>device_name</parameter></term>
	<listitem>
	  <para>Device to be opened.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter>flags</parameter></term>
	<listitem>
	  <para>Open flags. Access mode must be either <constant>O_RDONLY</constant>
	  or <constant>O_RDWR</constant>. Other flags have no effect.</para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  <refsect1>
    <title>Description</title>
    <para>To open a media device applications call <function>open()</function>
    with the desired device name. The function has no side effects; the device
    configuration remain unchanged.</para>
    <para>When the device is opened in read-only mode, attemps to modify its
    configuration will result in an error, and <varname>errno</varname> will be
    set to <errorcode>EBADF</errorcode>.</para>
  </refsect1>
  <refsect1>
    <title>Return Value</title>

    <para><function>open</function> returns the new file descriptor on success.
    On error, -1 is returned, and <varname>errno</varname> is set appropriately.
    Possible error codes are:</para>

    <variablelist>
      <varlistentry>
	<term><errorcode>EACCES</errorcode></term>
	<listitem>
	  <para>The requested access to the file is not allowed.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>EMFILE</errorcode></term>
	<listitem>
	  <para>The  process  already  has  the  maximum number of files open.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>ENFILE</errorcode></term>
	<listitem>
	  <para>The system limit on the total number of open files has been
	  reached.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>ENOMEM</errorcode></term>
	<listitem>
	  <para>Insufficient kernel memory was available.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><errorcode>ENXIO</errorcode></term>
	<listitem>
	  <para>No device corresponding to this device special file exists.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
</refentry>