cec-ioc-g-mode.rst 11 KB

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