blob: 627860b33ae27dd49ded369ba3a0ecbefdd489a0 [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- coding: utf-8; mode: rst -*-
2
3.. _media-func-open:
4
5************
6media open()
7************
8
9*man media-open(2)*
10
11Open a media device
12
13
14Synopsis
15========
16
17.. code-block:: c
18
19 #include <fcntl.h>
20
21
Mauro Carvalho Chehabb7e67f62016-07-02 09:49:16 -030022.. cpp:function:: int open( const char *device_name, int flags )
Markus Heiser5377d912016-06-30 15:18:56 +020023
24Arguments
25=========
26
27``device_name``
28 Device to be opened.
29
30``flags``
31 Open flags. Access mode must be either ``O_RDONLY`` or ``O_RDWR``.
32 Other flags have no effect.
33
34
35Description
36===========
37
Mauro Carvalho Chehab760c7012016-07-04 12:56:17 -030038To open a media device applications call :ref:`open() <func-open>` with the
Markus Heiser5377d912016-06-30 15:18:56 +020039desired device name. The function has no side effects; the device
40configuration remain unchanged.
41
42When the device is opened in read-only mode, attempts to modify its
43configuration will result in an error, and ``errno`` will be set to
44EBADF.
45
46
47Return Value
48============
49
Mauro Carvalho Chehab760c7012016-07-04 12:56:17 -030050:ref:`open() <func-open>` returns the new file descriptor on success. On error,
Markus Heiser5377d912016-06-30 15:18:56 +020051-1 is returned, and ``errno`` is set appropriately. Possible error codes
52are:
53
54EACCES
55 The requested access to the file is not allowed.
56
57EMFILE
58 The process already has the maximum number of files open.
59
60ENFILE
61 The system limit on the total number of open files has been reached.
62
63ENOMEM
64 Insufficient kernel memory was available.
65
66ENXIO
67 No device corresponding to this device special file exists.