xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/cec/cec-func-open.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun.. c:namespace:: CEC
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun.. _cec-func-open:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun**********
7*4882a593Smuzhiyuncec open()
8*4882a593Smuzhiyun**********
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunName
11*4882a593Smuzhiyun====
12*4882a593Smuzhiyun
13*4882a593Smuzhiyuncec-open - Open a cec device
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunSynopsis
16*4882a593Smuzhiyun========
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun.. code-block:: c
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun    #include <fcntl.h>
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun.. c:function:: int open( const char *device_name, int flags )
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunArguments
25*4882a593Smuzhiyun=========
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun``device_name``
28*4882a593Smuzhiyun    Device to be opened.
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun``flags``
31*4882a593Smuzhiyun    Open flags. Access mode must be ``O_RDWR``.
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun    When the ``O_NONBLOCK`` flag is given, the
34*4882a593Smuzhiyun    :ref:`CEC_RECEIVE <CEC_RECEIVE>` and :ref:`CEC_DQEVENT <CEC_DQEVENT>` ioctls
35*4882a593Smuzhiyun    will return the ``EAGAIN`` error code when no message or event is available, and
36*4882a593Smuzhiyun    ioctls :ref:`CEC_TRANSMIT <CEC_TRANSMIT>`,
37*4882a593Smuzhiyun    :ref:`CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>` and
38*4882a593Smuzhiyun    :ref:`CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
39*4882a593Smuzhiyun    all return 0.
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun    Other flags have no effect.
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunDescription
44*4882a593Smuzhiyun===========
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunTo open a cec device applications call :c:func:`open()` with the
47*4882a593Smuzhiyundesired device name. The function has no side effects; the device
48*4882a593Smuzhiyunconfiguration remain unchanged.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunWhen the device is opened in read-only mode, attempts to modify its
51*4882a593Smuzhiyunconfiguration will result in an error, and ``errno`` will be set to
52*4882a593SmuzhiyunEBADF.
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunReturn Value
55*4882a593Smuzhiyun============
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun:c:func:`open()` returns the new file descriptor on success. On error,
58*4882a593Smuzhiyun-1 is returned, and ``errno`` is set appropriately. Possible error codes
59*4882a593Smuzhiyuninclude:
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun``EACCES``
62*4882a593Smuzhiyun    The requested access to the file is not allowed.
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun``EMFILE``
65*4882a593Smuzhiyun    The process already has the maximum number of files open.
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun``ENFILE``
68*4882a593Smuzhiyun    The system limit on the total number of open files has been reached.
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun``ENOMEM``
71*4882a593Smuzhiyun    Insufficient kernel memory was available.
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun``ENXIO``
74*4882a593Smuzhiyun    No device corresponding to this device special file exists.
75