cec-ioc-g-mode.rst 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. .. -*- coding: utf-8; mode: rst -*-
  2. .. _CEC_MODE:
  3. .. _CEC_G_MODE:
  4. .. _CEC_S_MODE:
  5. ********************************
  6. ioctls CEC_G_MODE and CEC_S_MODE
  7. ********************************
  8. CEC_G_MODE, CEC_S_MODE - Get or set exclusive use of the CEC adapter
  9. Synopsis
  10. ========
  11. .. c:function:: int ioctl( int fd, CEC_G_MODE, __u32 *argp )
  12. :name: CEC_G_MODE
  13. .. c:function:: int ioctl( int fd, CEC_S_MODE, __u32 *argp )
  14. :name: CEC_S_MODE
  15. Arguments
  16. =========
  17. ``fd``
  18. File descriptor returned by :c:func:`open() <cec-open>`.
  19. ``argp``
  20. Pointer to CEC mode.
  21. Description
  22. ===========
  23. By default any filehandle can use :ref:`CEC_TRANSMIT`, but in order to prevent
  24. applications from stepping on each others toes it must be possible to
  25. obtain exclusive access to the CEC adapter. This ioctl sets the
  26. filehandle to initiator and/or follower mode which can be exclusive
  27. depending on the chosen mode. The initiator is the filehandle that is
  28. used to initiate messages, i.e. it commands other CEC devices. The
  29. follower is the filehandle that receives messages sent to the CEC
  30. adapter and processes them. The same filehandle can be both initiator
  31. and follower, or this role can be taken by two different filehandles.
  32. When a CEC message is received, then the CEC framework will decide how
  33. it will be processed. If the message is a reply to an earlier
  34. transmitted message, then the reply is sent back to the filehandle that
  35. is waiting for it. In addition the CEC framework will process it.
  36. If the message is not a reply, then the CEC framework will process it
  37. first. If there is no follower, then the message is just discarded and a
  38. feature abort is sent back to the initiator if the framework couldn't
  39. process it. If there is a follower, then the message is passed on to the
  40. follower who will use :ref:`ioctl CEC_RECEIVE <CEC_RECEIVE>` to dequeue
  41. the new message. The framework expects the follower to make the right
  42. decisions.
  43. The CEC framework will process core messages unless requested otherwise
  44. by the follower. The follower can enable the passthrough mode. In that
  45. case, the CEC framework will pass on most core messages without
  46. processing them and the follower will have to implement those messages.
  47. There are some messages that the core will always process, regardless of
  48. the passthrough mode. See :ref:`cec-core-processing` for details.
  49. If there is no initiator, then any CEC filehandle can use
  50. :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`. If there is an exclusive
  51. initiator then only that initiator can call
  52. :ref:`CEC_TRANSMIT`. The follower can of course
  53. always call :ref:`ioctl CEC_TRANSMIT <CEC_TRANSMIT>`.
  54. Available initiator modes are:
  55. .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
  56. .. _cec-mode-initiator_e:
  57. .. flat-table:: Initiator Modes
  58. :header-rows: 0
  59. :stub-columns: 0
  60. :widths: 3 1 16
  61. * .. _`CEC-MODE-NO-INITIATOR`:
  62. - ``CEC_MODE_NO_INITIATOR``
  63. - 0x0
  64. - This is not an initiator, i.e. it cannot transmit CEC messages or
  65. make any other changes to the CEC adapter.
  66. * .. _`CEC-MODE-INITIATOR`:
  67. - ``CEC_MODE_INITIATOR``
  68. - 0x1
  69. - This is an initiator (the default when the device is opened) and
  70. it can transmit CEC messages and make changes to the CEC adapter,
  71. unless there is an exclusive initiator.
  72. * .. _`CEC-MODE-EXCL-INITIATOR`:
  73. - ``CEC_MODE_EXCL_INITIATOR``
  74. - 0x2
  75. - This is an exclusive initiator and this file descriptor is the
  76. only one that can transmit CEC messages and make changes to the
  77. CEC adapter. If someone else is already the exclusive initiator
  78. then an attempt to become one will return the ``EBUSY`` error code
  79. error.
  80. Available follower modes are:
  81. .. tabularcolumns:: |p{6.6cm}|p{0.9cm}|p{10.0cm}|
  82. .. _cec-mode-follower_e:
  83. .. flat-table:: Follower Modes
  84. :header-rows: 0
  85. :stub-columns: 0
  86. :widths: 3 1 16
  87. * .. _`CEC-MODE-NO-FOLLOWER`:
  88. - ``CEC_MODE_NO_FOLLOWER``
  89. - 0x00
  90. - This is not a follower (the default when the device is opened).
  91. * .. _`CEC-MODE-FOLLOWER`:
  92. - ``CEC_MODE_FOLLOWER``
  93. - 0x10
  94. - This is a follower and it will receive CEC messages unless there
  95. is an exclusive follower. You cannot become a follower if
  96. :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`
  97. was specified, the ``EINVAL`` error code is returned in that case.
  98. * .. _`CEC-MODE-EXCL-FOLLOWER`:
  99. - ``CEC_MODE_EXCL_FOLLOWER``
  100. - 0x20
  101. - This is an exclusive follower and only this file descriptor will
  102. receive CEC messages for processing. If someone else is already
  103. the exclusive follower then an attempt to become one will return
  104. the ``EBUSY`` error code. You cannot become a follower if
  105. :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`
  106. was specified, the ``EINVAL`` error code is returned in that case.
  107. * .. _`CEC-MODE-EXCL-FOLLOWER-PASSTHRU`:
  108. - ``CEC_MODE_EXCL_FOLLOWER_PASSTHRU``
  109. - 0x30
  110. - This is an exclusive follower and only this file descriptor will
  111. receive CEC messages for processing. In addition it will put the
  112. CEC device into passthrough mode, allowing the exclusive follower
  113. to handle most core messages instead of relying on the CEC
  114. framework for that. If someone else is already the exclusive
  115. follower then an attempt to become one will return the ``EBUSY`` error
  116. code. You cannot become a follower if :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>`
  117. is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` was specified,
  118. the ``EINVAL`` error code is returned in that case.
  119. * .. _`CEC-MODE-MONITOR`:
  120. - ``CEC_MODE_MONITOR``
  121. - 0xe0
  122. - Put the file descriptor into monitor mode. Can only be used in
  123. combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise EINVAL error
  124. code will be returned. In monitor mode all messages this CEC
  125. device transmits and all messages it receives (both broadcast
  126. messages and directed messages for one its logical addresses) will
  127. be reported. This is very useful for debugging. This is only
  128. allowed if the process has the ``CAP_NET_ADMIN`` capability. If
  129. that is not set, then the ``EPERM`` error code is returned.
  130. * .. _`CEC-MODE-MONITOR-ALL`:
  131. - ``CEC_MODE_MONITOR_ALL``
  132. - 0xf0
  133. - Put the file descriptor into 'monitor all' mode. Can only be used
  134. in combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise
  135. the ``EINVAL`` error code will be returned. In 'monitor all' mode all messages
  136. this CEC device transmits and all messages it receives, including
  137. directed messages for other CEC devices will be reported. This is
  138. very useful for debugging, but not all devices support this. This
  139. mode requires that the :ref:`CEC_CAP_MONITOR_ALL <CEC-CAP-MONITOR-ALL>` capability is set,
  140. otherwise the ``EINVAL`` error code is returned. This is only allowed if
  141. the process has the ``CAP_NET_ADMIN`` capability. If that is not
  142. set, then the ``EPERM`` error code is returned.
  143. Core message processing details:
  144. .. tabularcolumns:: |p{6.6cm}|p{10.9cm}|
  145. .. _cec-core-processing:
  146. .. flat-table:: Core Message Processing
  147. :header-rows: 0
  148. :stub-columns: 0
  149. :widths: 1 8
  150. * .. _`CEC-MSG-GET-CEC-VERSION`:
  151. - ``CEC_MSG_GET_CEC_VERSION``
  152. - When in passthrough mode this message has to be handled by
  153. userspace, otherwise the core will return the CEC version that was
  154. set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`.
  155. * .. _`CEC-MSG-GIVE-DEVICE-VENDOR-ID`:
  156. - ``CEC_MSG_GIVE_DEVICE_VENDOR_ID``
  157. - When in passthrough mode this message has to be handled by
  158. userspace, otherwise the core will return the vendor ID that was
  159. set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`.
  160. * .. _`CEC-MSG-ABORT`:
  161. - ``CEC_MSG_ABORT``
  162. - When in passthrough mode this message has to be handled by
  163. userspace, otherwise the core will return a feature refused
  164. message as per the specification.
  165. * .. _`CEC-MSG-GIVE-PHYSICAL-ADDR`:
  166. - ``CEC_MSG_GIVE_PHYSICAL_ADDR``
  167. - When in passthrough mode this message has to be handled by
  168. userspace, otherwise the core will report the current physical
  169. address.
  170. * .. _`CEC-MSG-GIVE-OSD-NAME`:
  171. - ``CEC_MSG_GIVE_OSD_NAME``
  172. - When in passthrough mode this message has to be handled by
  173. userspace, otherwise the core will report the current OSD name as
  174. was set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`.
  175. * .. _`CEC-MSG-GIVE-FEATURES`:
  176. - ``CEC_MSG_GIVE_FEATURES``
  177. - When in passthrough mode this message has to be handled by
  178. userspace, otherwise the core will report the current features as
  179. was set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`
  180. or the message is ignored if the CEC version was older than 2.0.
  181. * .. _`CEC-MSG-USER-CONTROL-PRESSED`:
  182. - ``CEC_MSG_USER_CONTROL_PRESSED``
  183. - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key
  184. press. This message is always passed on to userspace.
  185. * .. _`CEC-MSG-USER-CONTROL-RELEASED`:
  186. - ``CEC_MSG_USER_CONTROL_RELEASED``
  187. - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key
  188. release. This message is always passed on to userspace.
  189. * .. _`CEC-MSG-REPORT-PHYSICAL-ADDR`:
  190. - ``CEC_MSG_REPORT_PHYSICAL_ADDR``
  191. - The CEC framework will make note of the reported physical address
  192. and then just pass the message on to userspace.
  193. Return Value
  194. ============
  195. On success 0 is returned, on error -1 and the ``errno`` variable is set
  196. appropriately. The generic error codes are described at the
  197. :ref:`Generic Error Codes <gen-errors>` chapter.