1*54f38fcaSMauro Carvalho Chehab.. Permission is granted to copy, distribute and/or modify this 2*54f38fcaSMauro Carvalho Chehab.. document under the terms of the GNU Free Documentation License, 3*54f38fcaSMauro Carvalho Chehab.. Version 1.1 or any later version published by the Free Software 4*54f38fcaSMauro Carvalho Chehab.. Foundation, with no Invariant Sections, no Front-Cover Texts 5*54f38fcaSMauro Carvalho Chehab.. and no Back-Cover Texts. A copy of the license is included at 6*54f38fcaSMauro Carvalho Chehab.. Documentation/userspace-api/media/fdl-appendix.rst. 7*54f38fcaSMauro Carvalho Chehab.. 8*54f38fcaSMauro Carvalho Chehab.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections 9*54f38fcaSMauro Carvalho Chehab 10*54f38fcaSMauro Carvalho Chehab.. _cec-func-open: 11*54f38fcaSMauro Carvalho Chehab 12*54f38fcaSMauro Carvalho Chehab********** 13*54f38fcaSMauro Carvalho Chehabcec open() 14*54f38fcaSMauro Carvalho Chehab********** 15*54f38fcaSMauro Carvalho Chehab 16*54f38fcaSMauro Carvalho ChehabName 17*54f38fcaSMauro Carvalho Chehab==== 18*54f38fcaSMauro Carvalho Chehab 19*54f38fcaSMauro Carvalho Chehabcec-open - Open a cec device 20*54f38fcaSMauro Carvalho Chehab 21*54f38fcaSMauro Carvalho ChehabSynopsis 22*54f38fcaSMauro Carvalho Chehab======== 23*54f38fcaSMauro Carvalho Chehab 24*54f38fcaSMauro Carvalho Chehab.. code-block:: c 25*54f38fcaSMauro Carvalho Chehab 26*54f38fcaSMauro Carvalho Chehab #include <fcntl.h> 27*54f38fcaSMauro Carvalho Chehab 28*54f38fcaSMauro Carvalho Chehab 29*54f38fcaSMauro Carvalho Chehab.. c:function:: int open( const char *device_name, int flags ) 30*54f38fcaSMauro Carvalho Chehab :name: cec-open 31*54f38fcaSMauro Carvalho Chehab 32*54f38fcaSMauro Carvalho Chehab 33*54f38fcaSMauro Carvalho ChehabArguments 34*54f38fcaSMauro Carvalho Chehab========= 35*54f38fcaSMauro Carvalho Chehab 36*54f38fcaSMauro Carvalho Chehab``device_name`` 37*54f38fcaSMauro Carvalho Chehab Device to be opened. 38*54f38fcaSMauro Carvalho Chehab 39*54f38fcaSMauro Carvalho Chehab``flags`` 40*54f38fcaSMauro Carvalho Chehab Open flags. Access mode must be ``O_RDWR``. 41*54f38fcaSMauro Carvalho Chehab 42*54f38fcaSMauro Carvalho Chehab When the ``O_NONBLOCK`` flag is given, the 43*54f38fcaSMauro Carvalho Chehab :ref:`CEC_RECEIVE <CEC_RECEIVE>` and :ref:`CEC_DQEVENT <CEC_DQEVENT>` ioctls 44*54f38fcaSMauro Carvalho Chehab will return the ``EAGAIN`` error code when no message or event is available, and 45*54f38fcaSMauro Carvalho Chehab ioctls :ref:`CEC_TRANSMIT <CEC_TRANSMIT>`, 46*54f38fcaSMauro Carvalho Chehab :ref:`CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>` and 47*54f38fcaSMauro Carvalho Chehab :ref:`CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>` 48*54f38fcaSMauro Carvalho Chehab all return 0. 49*54f38fcaSMauro Carvalho Chehab 50*54f38fcaSMauro Carvalho Chehab Other flags have no effect. 51*54f38fcaSMauro Carvalho Chehab 52*54f38fcaSMauro Carvalho Chehab 53*54f38fcaSMauro Carvalho ChehabDescription 54*54f38fcaSMauro Carvalho Chehab=========== 55*54f38fcaSMauro Carvalho Chehab 56*54f38fcaSMauro Carvalho ChehabTo open a cec device applications call :c:func:`open() <cec-open>` with the 57*54f38fcaSMauro Carvalho Chehabdesired device name. The function has no side effects; the device 58*54f38fcaSMauro Carvalho Chehabconfiguration remain unchanged. 59*54f38fcaSMauro Carvalho Chehab 60*54f38fcaSMauro Carvalho ChehabWhen the device is opened in read-only mode, attempts to modify its 61*54f38fcaSMauro Carvalho Chehabconfiguration will result in an error, and ``errno`` will be set to 62*54f38fcaSMauro Carvalho ChehabEBADF. 63*54f38fcaSMauro Carvalho Chehab 64*54f38fcaSMauro Carvalho Chehab 65*54f38fcaSMauro Carvalho ChehabReturn Value 66*54f38fcaSMauro Carvalho Chehab============ 67*54f38fcaSMauro Carvalho Chehab 68*54f38fcaSMauro Carvalho Chehab:c:func:`open() <cec-open>` returns the new file descriptor on success. On error, 69*54f38fcaSMauro Carvalho Chehab-1 is returned, and ``errno`` is set appropriately. Possible error codes 70*54f38fcaSMauro Carvalho Chehabinclude: 71*54f38fcaSMauro Carvalho Chehab 72*54f38fcaSMauro Carvalho Chehab``EACCES`` 73*54f38fcaSMauro Carvalho Chehab The requested access to the file is not allowed. 74*54f38fcaSMauro Carvalho Chehab 75*54f38fcaSMauro Carvalho Chehab``EMFILE`` 76*54f38fcaSMauro Carvalho Chehab The process already has the maximum number of files open. 77*54f38fcaSMauro Carvalho Chehab 78*54f38fcaSMauro Carvalho Chehab``ENFILE`` 79*54f38fcaSMauro Carvalho Chehab The system limit on the total number of open files has been reached. 80*54f38fcaSMauro Carvalho Chehab 81*54f38fcaSMauro Carvalho Chehab``ENOMEM`` 82*54f38fcaSMauro Carvalho Chehab Insufficient kernel memory was available. 83*54f38fcaSMauro Carvalho Chehab 84*54f38fcaSMauro Carvalho Chehab``ENXIO`` 85*54f38fcaSMauro Carvalho Chehab No device corresponding to this device special file exists. 86