cec-func-open.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. .. -*- coding: utf-8; mode: rst -*-
  2. .. _cec-func-open:
  3. **********
  4. cec open()
  5. **********
  6. Name
  7. ====
  8. cec-open - Open a cec device
  9. Synopsis
  10. ========
  11. .. code-block:: c
  12. #include <fcntl.h>
  13. .. c:function:: int open( const char *device_name, int flags )
  14. :name: cec-open
  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() <cec-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() <cec-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. ``ENXIO``
  51. No device corresponding to this device special file exists.