cec-func-open.rst 1.7 KB

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