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