cec-func-open.rst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 :c:func:`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. .. note::
  32. This documents the proposed CEC API. This API is not yet finalized
  33. and is currently only available as a staging kernel module.
  34. To open a cec device applications call :c:func:`open()` with the
  35. desired device name. The function has no side effects; the device
  36. configuration remain unchanged.
  37. When the device is opened in read-only mode, attempts to modify its
  38. configuration will result in an error, and ``errno`` will be set to
  39. EBADF.
  40. Return Value
  41. ============
  42. :c:func:`open()` returns the new file descriptor on success. On error,
  43. -1 is returned, and ``errno`` is set appropriately. Possible error codes
  44. include:
  45. ``EACCES``
  46. The requested access to the file is not allowed.
  47. ``EMFILE``
  48. The process already has the maximum number of files open.
  49. ``ENFILE``
  50. The system limit on the total number of open files has been reached.
  51. ``ENOMEM``
  52. Insufficient kernel memory was available.
  53. ``ENXIO``
  54. No device corresponding to this device special file exists.