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