18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: CEC
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _cec-func-open:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci**********
78c2ecf20Sopenharmony_cicec open()
88c2ecf20Sopenharmony_ci**********
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciName
118c2ecf20Sopenharmony_ci====
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cicec-open - Open a cec device
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciSynopsis
168c2ecf20Sopenharmony_ci========
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci.. code-block:: c
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci    #include <fcntl.h>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci.. c:function:: int open( const char *device_name, int flags )
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciArguments
258c2ecf20Sopenharmony_ci=========
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci``device_name``
288c2ecf20Sopenharmony_ci    Device to be opened.
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci``flags``
318c2ecf20Sopenharmony_ci    Open flags. Access mode must be ``O_RDWR``.
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci    When the ``O_NONBLOCK`` flag is given, the
348c2ecf20Sopenharmony_ci    :ref:`CEC_RECEIVE <CEC_RECEIVE>` and :ref:`CEC_DQEVENT <CEC_DQEVENT>` ioctls
358c2ecf20Sopenharmony_ci    will return the ``EAGAIN`` error code when no message or event is available, and
368c2ecf20Sopenharmony_ci    ioctls :ref:`CEC_TRANSMIT <CEC_TRANSMIT>`,
378c2ecf20Sopenharmony_ci    :ref:`CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>` and
388c2ecf20Sopenharmony_ci    :ref:`CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
398c2ecf20Sopenharmony_ci    all return 0.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci    Other flags have no effect.
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciDescription
448c2ecf20Sopenharmony_ci===========
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciTo open a cec device applications call :c:func:`open()` with the
478c2ecf20Sopenharmony_cidesired device name. The function has no side effects; the device
488c2ecf20Sopenharmony_ciconfiguration remain unchanged.
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciWhen the device is opened in read-only mode, attempts to modify its
518c2ecf20Sopenharmony_ciconfiguration will result in an error, and ``errno`` will be set to
528c2ecf20Sopenharmony_ciEBADF.
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciReturn Value
558c2ecf20Sopenharmony_ci============
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci:c:func:`open()` returns the new file descriptor on success. On error,
588c2ecf20Sopenharmony_ci-1 is returned, and ``errno`` is set appropriately. Possible error codes
598c2ecf20Sopenharmony_ciinclude:
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci``EACCES``
628c2ecf20Sopenharmony_ci    The requested access to the file is not allowed.
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci``EMFILE``
658c2ecf20Sopenharmony_ci    The process already has the maximum number of files open.
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci``ENFILE``
688c2ecf20Sopenharmony_ci    The system limit on the total number of open files has been reached.
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci``ENOMEM``
718c2ecf20Sopenharmony_ci    Insufficient kernel memory was available.
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci``ENXIO``
748c2ecf20Sopenharmony_ci    No device corresponding to this device special file exists.
75