cec-ioc-g-mode.rst 9.9 KB

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