dtx.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. .. |__u16| replace:: :c:type:`__u16 <__u16>`
  3. .. |sdtx_event| replace:: :c:type:`struct sdtx_event <sdtx_event>`
  4. .. |sdtx_event_code| replace:: :c:type:`enum sdtx_event_code <sdtx_event_code>`
  5. .. |sdtx_base_info| replace:: :c:type:`struct sdtx_base_info <sdtx_base_info>`
  6. .. |sdtx_device_mode| replace:: :c:type:`struct sdtx_device_mode <sdtx_device_mode>`
  7. ======================================================
  8. User-Space DTX (Clipboard Detachment System) Interface
  9. ======================================================
  10. The ``surface_dtx`` driver is responsible for proper clipboard detachment
  11. and re-attachment handling. To this end, it provides the ``/dev/surface/dtx``
  12. device file, through which it can interface with a user-space daemon. This
  13. daemon is then ultimately responsible for determining and taking necessary
  14. actions, such as unmounting devices attached to the base,
  15. unloading/reloading the graphics-driver, user-notifications, etc.
  16. There are two basic communication principles used in this driver: Commands
  17. (in other parts of the documentation also referred to as requests) and
  18. events. Commands are sent to the EC and may have a different implications in
  19. different contexts. Events are sent by the EC upon some internal state
  20. change. Commands are always driver-initiated, whereas events are always
  21. initiated by the EC.
  22. .. contents::
  23. Nomenclature
  24. ============
  25. * **Clipboard:**
  26. The detachable upper part of the Surface Book, housing the screen and CPU.
  27. * **Base:**
  28. The lower part of the Surface Book from which the clipboard can be
  29. detached, optionally (model dependent) housing the discrete GPU (dGPU).
  30. * **Latch:**
  31. The mechanism keeping the clipboard attached to the base in normal
  32. operation and allowing it to be detached when requested.
  33. * **Silently ignored commands:**
  34. The command is accepted by the EC as a valid command and acknowledged
  35. (following the standard communication protocol), but the EC does not act
  36. upon it, i.e. ignores it.e upper part of the
  37. Detachment Process
  38. ==================
  39. Warning: This part of the documentation is based on reverse engineering and
  40. testing and thus may contain errors or be incomplete.
  41. Latch States
  42. ------------
  43. The latch mechanism has two major states: *open* and *closed*. In the
  44. *closed* state (default), the clipboard is secured to the base, whereas in
  45. the *open* state, the clipboard can be removed by a user.
  46. The latch can additionally be locked and, correspondingly, unlocked, which
  47. can influence the detachment procedure. Specifically, this locking mechanism
  48. is intended to prevent the dGPU, positioned in the base of the device, from
  49. being hot-unplugged while in use. More details can be found in the
  50. documentation for the detachment procedure below. By default, the latch is
  51. unlocked.
  52. Detachment Procedure
  53. --------------------
  54. Note that the detachment process is governed fully by the EC. The
  55. ``surface_dtx`` driver only relays events from the EC to user-space and
  56. commands from user-space to the EC, i.e. it does not influence this process.
  57. The detachment process is started with the user pressing the *detach* button
  58. on the base of the device or executing the ``SDTX_IOCTL_LATCH_REQUEST`` IOCTL.
  59. Following that:
  60. 1. The EC turns on the indicator led on the detach-button, sends a
  61. *detach-request* event (``SDTX_EVENT_REQUEST``), and awaits further
  62. instructions/commands. In case the latch is unlocked, the led will flash
  63. green. If the latch has been locked, the led will be solid red
  64. 2. The event is, via the ``surface_dtx`` driver, relayed to user-space, where
  65. an appropriate user-space daemon can handle it and send instructions back
  66. to the EC via IOCTLs provided by this driver.
  67. 3. The EC waits for instructions from user-space and acts according to them.
  68. If the EC does not receive any instructions in a given period, it will
  69. time out and continue as follows:
  70. - If the latch is unlocked, the EC will open the latch and the clipboard
  71. can be detached from the base. This is the exact behavior as without
  72. this driver or any user-space daemon. See the ``SDTX_IOCTL_LATCH_CONFIRM``
  73. description below for more details on the follow-up behavior of the EC.
  74. - If the latch is locked, the EC will *not* open the latch, meaning the
  75. clipboard cannot be detached from the base. Furthermore, the EC sends
  76. an cancel event (``SDTX_EVENT_CANCEL``) detailing this with the cancel
  77. reason ``SDTX_DETACH_TIMEDOUT`` (see :ref:`events` for details).
  78. Valid responses by a user-space daemon to a detachment request event are:
  79. - Execute ``SDTX_IOCTL_LATCH_REQUEST``. This will immediately abort the
  80. detachment process. Furthermore, the EC will send a detach-request event,
  81. similar to the user pressing the detach-button to cancel said process (see
  82. below).
  83. - Execute ``SDTX_IOCTL_LATCH_CONFIRM``. This will cause the EC to open the
  84. latch, after which the user can separate clipboard and base.
  85. As this changes the latch state, a *latch-status* event
  86. (``SDTX_EVENT_LATCH_STATUS``) will be sent once the latch has been opened
  87. successfully. If the EC fails to open the latch, e.g. due to hardware
  88. error or low battery, a latch-cancel event (``SDTX_EVENT_CANCEL``) will be
  89. sent with the cancel reason indicating the specific failure.
  90. If the latch is currently locked, the latch will automatically be
  91. unlocked before it is opened.
  92. - Execute ``SDTX_IOCTL_LATCH_HEARTBEAT``. This will reset the internal timeout.
  93. No other actions will be performed, i.e. the detachment process will neither
  94. be completed nor canceled, and the EC will still be waiting for further
  95. responses.
  96. - Execute ``SDTX_IOCTL_LATCH_CANCEL``. This will abort the detachment process,
  97. similar to ``SDTX_IOCTL_LATCH_REQUEST``, described above, or the button
  98. press, described below. A *generic request* event (``SDTX_EVENT_REQUEST``)
  99. is send in response to this. In contrast to those, however, this command
  100. does not trigger a new detachment process if none is currently in
  101. progress.
  102. - Do nothing. The detachment process eventually times out as described in
  103. point 3.
  104. See :ref:`ioctls` for more details on these responses.
  105. It is important to note that, if the user presses the detach button at any
  106. point when a detachment operation is in progress (i.e. after the EC has sent
  107. the initial *detach-request* event (``SDTX_EVENT_REQUEST``) and before it
  108. received the corresponding response concluding the process), the detachment
  109. process is canceled on the EC-level and an identical event is being sent.
  110. Thus a *detach-request* event, by itself, does not signal the start of the
  111. detachment process.
  112. The detachment process may further be canceled by the EC due to hardware
  113. failures or a low clipboard battery. This is done via a cancel event
  114. (``SDTX_EVENT_CANCEL``) with the corresponding cancel reason.
  115. User-Space Interface Documentation
  116. ==================================
  117. Error Codes and Status Values
  118. -----------------------------
  119. Error and status codes are divided into different categories, which can be
  120. used to determine if the status code is an error, and, if it is, the
  121. severity and type of that error. The current categories are:
  122. .. flat-table:: Overview of Status/Error Categories.
  123. :widths: 2 1 3
  124. :header-rows: 1
  125. * - Name
  126. - Value
  127. - Short Description
  128. * - ``STATUS``
  129. - ``0x0000``
  130. - Non-error status codes.
  131. * - ``RUNTIME_ERROR``
  132. - ``0x1000``
  133. - Non-critical runtime errors.
  134. * - ``HARDWARE_ERROR``
  135. - ``0x2000``
  136. - Critical hardware failures.
  137. * - ``UNKNOWN``
  138. - ``0xF000``
  139. - Unknown error codes.
  140. Other categories are reserved for future use. The ``SDTX_CATEGORY()`` macro
  141. can be used to determine the category of any status value. The
  142. ``SDTX_SUCCESS()`` macro can be used to check if the status value is a
  143. success value (``SDTX_CATEGORY_STATUS``) or if it indicates a failure.
  144. Unknown status or error codes sent by the EC are assigned to the ``UNKNOWN``
  145. category by the driver and may be implemented via their own code in the
  146. future.
  147. Currently used error codes are:
  148. .. flat-table:: Overview of Error Codes.
  149. :widths: 2 1 1 3
  150. :header-rows: 1
  151. * - Name
  152. - Category
  153. - Value
  154. - Short Description
  155. * - ``SDTX_DETACH_NOT_FEASIBLE``
  156. - ``RUNTIME``
  157. - ``0x1001``
  158. - Detachment not feasible due to low clipboard battery.
  159. * - ``SDTX_DETACH_TIMEDOUT``
  160. - ``RUNTIME``
  161. - ``0x1002``
  162. - Detachment process timed out while the latch was locked.
  163. * - ``SDTX_ERR_FAILED_TO_OPEN``
  164. - ``HARDWARE``
  165. - ``0x2001``
  166. - Failed to open latch.
  167. * - ``SDTX_ERR_FAILED_TO_REMAIN_OPEN``
  168. - ``HARDWARE``
  169. - ``0x2002``
  170. - Failed to keep latch open.
  171. * - ``SDTX_ERR_FAILED_TO_CLOSE``
  172. - ``HARDWARE``
  173. - ``0x2003``
  174. - Failed to close latch.
  175. Other error codes are reserved for future use. Non-error status codes may
  176. overlap and are generally only unique within their use-case:
  177. .. flat-table:: Latch Status Codes.
  178. :widths: 2 1 1 3
  179. :header-rows: 1
  180. * - Name
  181. - Category
  182. - Value
  183. - Short Description
  184. * - ``SDTX_LATCH_CLOSED``
  185. - ``STATUS``
  186. - ``0x0000``
  187. - Latch is closed/has been closed.
  188. * - ``SDTX_LATCH_OPENED``
  189. - ``STATUS``
  190. - ``0x0001``
  191. - Latch is open/has been opened.
  192. .. flat-table:: Base State Codes.
  193. :widths: 2 1 1 3
  194. :header-rows: 1
  195. * - Name
  196. - Category
  197. - Value
  198. - Short Description
  199. * - ``SDTX_BASE_DETACHED``
  200. - ``STATUS``
  201. - ``0x0000``
  202. - Base has been detached/is not present.
  203. * - ``SDTX_BASE_ATTACHED``
  204. - ``STATUS``
  205. - ``0x0001``
  206. - Base has been attached/is present.
  207. Again, other codes are reserved for future use.
  208. .. _events:
  209. Events
  210. ------
  211. Events can be received by reading from the device file. They are disabled by
  212. default and have to be enabled by executing ``SDTX_IOCTL_EVENTS_ENABLE``
  213. first. All events follow the layout prescribed by |sdtx_event|. Specific
  214. event types can be identified by their event code, described in
  215. |sdtx_event_code|. Note that other event codes are reserved for future use,
  216. thus an event parser must be able to handle any unknown/unsupported event
  217. types gracefully, by relying on the payload length given in the event header.
  218. Currently provided event types are:
  219. .. flat-table:: Overview of DTX events.
  220. :widths: 2 1 1 3
  221. :header-rows: 1
  222. * - Name
  223. - Code
  224. - Payload
  225. - Short Description
  226. * - ``SDTX_EVENT_REQUEST``
  227. - ``1``
  228. - ``0`` bytes
  229. - Detachment process initiated/aborted.
  230. * - ``SDTX_EVENT_CANCEL``
  231. - ``2``
  232. - ``2`` bytes
  233. - EC canceled detachment process.
  234. * - ``SDTX_EVENT_BASE_CONNECTION``
  235. - ``3``
  236. - ``4`` bytes
  237. - Base connection state changed.
  238. * - ``SDTX_EVENT_LATCH_STATUS``
  239. - ``4``
  240. - ``2`` bytes
  241. - Latch status changed.
  242. * - ``SDTX_EVENT_DEVICE_MODE``
  243. - ``5``
  244. - ``2`` bytes
  245. - Device mode changed.
  246. Individual events in more detail:
  247. ``SDTX_EVENT_REQUEST``
  248. ^^^^^^^^^^^^^^^^^^^^^^
  249. Sent when a detachment process is started or, if in progress, aborted by the
  250. user, either via a detach button press or a detach request
  251. (``SDTX_IOCTL_LATCH_REQUEST``) being sent from user-space.
  252. Does not have any payload.
  253. ``SDTX_EVENT_CANCEL``
  254. ^^^^^^^^^^^^^^^^^^^^^
  255. Sent when a detachment process is canceled by the EC due to unfulfilled
  256. preconditions (e.g. clipboard battery too low to detach) or hardware
  257. failure. The reason for cancellation is given in the event payload detailed
  258. below and can be one of
  259. * ``SDTX_DETACH_TIMEDOUT``: Detachment timed out while the latch was locked.
  260. The latch has neither been opened nor unlocked.
  261. * ``SDTX_DETACH_NOT_FEASIBLE``: Detachment not feasible due to low clipboard
  262. battery.
  263. * ``SDTX_ERR_FAILED_TO_OPEN``: Could not open the latch (hardware failure).
  264. * ``SDTX_ERR_FAILED_TO_REMAIN_OPEN``: Could not keep the latch open (hardware
  265. failure).
  266. * ``SDTX_ERR_FAILED_TO_CLOSE``: Could not close the latch (hardware failure).
  267. Other error codes in this context are reserved for future use.
  268. These codes can be classified via the ``SDTX_CATEGORY()`` macro to discern
  269. between critical hardware errors (``SDTX_CATEGORY_HARDWARE_ERROR``) or
  270. runtime errors (``SDTX_CATEGORY_RUNTIME_ERROR``), the latter of which may
  271. happen during normal operation if certain preconditions for detachment are
  272. not given.
  273. .. flat-table:: Detachment Cancel Event Payload
  274. :widths: 1 1 4
  275. :header-rows: 1
  276. * - Field
  277. - Type
  278. - Description
  279. * - ``reason``
  280. - |__u16|
  281. - Reason for cancellation.
  282. ``SDTX_EVENT_BASE_CONNECTION``
  283. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  284. Sent when the base connection state has changed, i.e. when the base has been
  285. attached, detached, or detachment has become infeasible due to low clipboard
  286. battery. The new state and, if a base is connected, ID of the base is
  287. provided as payload of type |sdtx_base_info| with its layout presented
  288. below:
  289. .. flat-table:: Base-Connection-Change Event Payload
  290. :widths: 1 1 4
  291. :header-rows: 1
  292. * - Field
  293. - Type
  294. - Description
  295. * - ``state``
  296. - |__u16|
  297. - Base connection state.
  298. * - ``base_id``
  299. - |__u16|
  300. - Type of base connected (zero if none).
  301. Possible values for ``state`` are:
  302. * ``SDTX_BASE_DETACHED``,
  303. * ``SDTX_BASE_ATTACHED``, and
  304. * ``SDTX_DETACH_NOT_FEASIBLE``.
  305. Other values are reserved for future use.
  306. ``SDTX_EVENT_LATCH_STATUS``
  307. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  308. Sent when the latch status has changed, i.e. when the latch has been opened,
  309. closed, or an error occurred. The current status is provided as payload:
  310. .. flat-table:: Latch-Status-Change Event Payload
  311. :widths: 1 1 4
  312. :header-rows: 1
  313. * - Field
  314. - Type
  315. - Description
  316. * - ``status``
  317. - |__u16|
  318. - Latch status.
  319. Possible values for ``status`` are:
  320. * ``SDTX_LATCH_CLOSED``,
  321. * ``SDTX_LATCH_OPENED``,
  322. * ``SDTX_ERR_FAILED_TO_OPEN``,
  323. * ``SDTX_ERR_FAILED_TO_REMAIN_OPEN``, and
  324. * ``SDTX_ERR_FAILED_TO_CLOSE``.
  325. Other values are reserved for future use.
  326. ``SDTX_EVENT_DEVICE_MODE``
  327. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  328. Sent when the device mode has changed. The new device mode is provided as
  329. payload:
  330. .. flat-table:: Device-Mode-Change Event Payload
  331. :widths: 1 1 4
  332. :header-rows: 1
  333. * - Field
  334. - Type
  335. - Description
  336. * - ``mode``
  337. - |__u16|
  338. - Device operation mode.
  339. Possible values for ``mode`` are:
  340. * ``SDTX_DEVICE_MODE_TABLET``,
  341. * ``SDTX_DEVICE_MODE_LAPTOP``, and
  342. * ``SDTX_DEVICE_MODE_STUDIO``.
  343. Other values are reserved for future use.
  344. .. _ioctls:
  345. IOCTLs
  346. ------
  347. The following IOCTLs are provided:
  348. .. flat-table:: Overview of DTX IOCTLs
  349. :widths: 1 1 1 1 4
  350. :header-rows: 1
  351. * - Type
  352. - Number
  353. - Direction
  354. - Name
  355. - Description
  356. * - ``0xA5``
  357. - ``0x21``
  358. - ``-``
  359. - ``EVENTS_ENABLE``
  360. - Enable events for the current file descriptor.
  361. * - ``0xA5``
  362. - ``0x22``
  363. - ``-``
  364. - ``EVENTS_DISABLE``
  365. - Disable events for the current file descriptor.
  366. * - ``0xA5``
  367. - ``0x23``
  368. - ``-``
  369. - ``LATCH_LOCK``
  370. - Lock the latch.
  371. * - ``0xA5``
  372. - ``0x24``
  373. - ``-``
  374. - ``LATCH_UNLOCK``
  375. - Unlock the latch.
  376. * - ``0xA5``
  377. - ``0x25``
  378. - ``-``
  379. - ``LATCH_REQUEST``
  380. - Request clipboard detachment.
  381. * - ``0xA5``
  382. - ``0x26``
  383. - ``-``
  384. - ``LATCH_CONFIRM``
  385. - Confirm clipboard detachment request.
  386. * - ``0xA5``
  387. - ``0x27``
  388. - ``-``
  389. - ``LATCH_HEARTBEAT``
  390. - Send heartbeat signal to EC.
  391. * - ``0xA5``
  392. - ``0x28``
  393. - ``-``
  394. - ``LATCH_CANCEL``
  395. - Cancel detachment process.
  396. * - ``0xA5``
  397. - ``0x29``
  398. - ``R``
  399. - ``GET_BASE_INFO``
  400. - Get current base/connection information.
  401. * - ``0xA5``
  402. - ``0x2A``
  403. - ``R``
  404. - ``GET_DEVICE_MODE``
  405. - Get current device operation mode.
  406. * - ``0xA5``
  407. - ``0x2B``
  408. - ``R``
  409. - ``GET_LATCH_STATUS``
  410. - Get current device latch status.
  411. ``SDTX_IOCTL_EVENTS_ENABLE``
  412. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  413. Defined as ``_IO(0xA5, 0x22)``.
  414. Enable events for the current file descriptor. Events can be obtained by
  415. reading from the device, if enabled. Events are disabled by default.
  416. ``SDTX_IOCTL_EVENTS_DISABLE``
  417. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  418. Defined as ``_IO(0xA5, 0x22)``.
  419. Disable events for the current file descriptor. Events can be obtained by
  420. reading from the device, if enabled. Events are disabled by default.
  421. ``SDTX_IOCTL_LATCH_LOCK``
  422. ^^^^^^^^^^^^^^^^^^^^^^^^^
  423. Defined as ``_IO(0xA5, 0x23)``.
  424. Locks the latch, causing the detachment procedure to abort without opening
  425. the latch on timeout. The latch is unlocked by default. This command will be
  426. silently ignored if the latch is already locked.
  427. ``SDTX_IOCTL_LATCH_UNLOCK``
  428. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  429. Defined as ``_IO(0xA5, 0x24)``.
  430. Unlocks the latch, causing the detachment procedure to open the latch on
  431. timeout. The latch is unlocked by default. This command will not open the
  432. latch when sent during an ongoing detachment process. It will be silently
  433. ignored if the latch is already unlocked.
  434. ``SDTX_IOCTL_LATCH_REQUEST``
  435. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  436. Defined as ``_IO(0xA5, 0x25)``.
  437. Generic latch request. Behavior depends on the context: If no
  438. detachment-process is active, detachment is requested. Otherwise the
  439. currently active detachment-process will be aborted.
  440. If a detachment process is canceled by this operation, a generic detachment
  441. request event (``SDTX_EVENT_REQUEST``) will be sent.
  442. This essentially behaves the same as a detachment button press.
  443. ``SDTX_IOCTL_LATCH_CONFIRM``
  444. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  445. Defined as ``_IO(0xA5, 0x26)``.
  446. Acknowledges and confirms a latch request. If sent during an ongoing
  447. detachment process, this command causes the latch to be opened immediately.
  448. The latch will also be opened if it has been locked. In this case, the latch
  449. lock is reset to the unlocked state.
  450. This command will be silently ignored if there is currently no detachment
  451. procedure in progress.
  452. ``SDTX_IOCTL_LATCH_HEARTBEAT``
  453. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  454. Defined as ``_IO(0xA5, 0x27)``.
  455. Sends a heartbeat, essentially resetting the detachment timeout. This
  456. command can be used to keep the detachment process alive while work required
  457. for the detachment to succeed is still in progress.
  458. This command will be silently ignored if there is currently no detachment
  459. procedure in progress.
  460. ``SDTX_IOCTL_LATCH_CANCEL``
  461. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  462. Defined as ``_IO(0xA5, 0x28)``.
  463. Cancels detachment in progress (if any). If a detachment process is canceled
  464. by this operation, a generic detachment request event
  465. (``SDTX_EVENT_REQUEST``) will be sent.
  466. This command will be silently ignored if there is currently no detachment
  467. procedure in progress.
  468. ``SDTX_IOCTL_GET_BASE_INFO``
  469. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  470. Defined as ``_IOR(0xA5, 0x29, struct sdtx_base_info)``.
  471. Get the current base connection state (i.e. attached/detached) and the type
  472. of the base connected to the clipboard. This is command essentially provides
  473. a way to query the information provided by the base connection change event
  474. (``SDTX_EVENT_BASE_CONNECTION``).
  475. Possible values for ``struct sdtx_base_info.state`` are:
  476. * ``SDTX_BASE_DETACHED``,
  477. * ``SDTX_BASE_ATTACHED``, and
  478. * ``SDTX_DETACH_NOT_FEASIBLE``.
  479. Other values are reserved for future use.
  480. ``SDTX_IOCTL_GET_DEVICE_MODE``
  481. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  482. Defined as ``_IOR(0xA5, 0x2A, __u16)``.
  483. Returns the device operation mode, indicating if and how the base is
  484. attached to the clipboard. This is command essentially provides a way to
  485. query the information provided by the device mode change event
  486. (``SDTX_EVENT_DEVICE_MODE``).
  487. Returned values are:
  488. * ``SDTX_DEVICE_MODE_LAPTOP``
  489. * ``SDTX_DEVICE_MODE_TABLET``
  490. * ``SDTX_DEVICE_MODE_STUDIO``
  491. See |sdtx_device_mode| for details. Other values are reserved for future
  492. use.
  493. ``SDTX_IOCTL_GET_LATCH_STATUS``
  494. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  495. Defined as ``_IOR(0xA5, 0x2B, __u16)``.
  496. Get the current latch status or (presumably) the last error encountered when
  497. trying to open/close the latch. This is command essentially provides a way
  498. to query the information provided by the latch status change event
  499. (``SDTX_EVENT_LATCH_STATUS``).
  500. Returned values are:
  501. * ``SDTX_LATCH_CLOSED``,
  502. * ``SDTX_LATCH_OPENED``,
  503. * ``SDTX_ERR_FAILED_TO_OPEN``,
  504. * ``SDTX_ERR_FAILED_TO_REMAIN_OPEN``, and
  505. * ``SDTX_ERR_FAILED_TO_CLOSE``.
  506. Other values are reserved for future use.
  507. A Note on Base IDs
  508. ------------------
  509. Base types/IDs provided via ``SDTX_EVENT_BASE_CONNECTION`` or
  510. ``SDTX_IOCTL_GET_BASE_INFO`` are directly forwarded from the EC in the lower
  511. byte of the combined |__u16| value, with the driver storing the EC type from
  512. which this ID comes in the high byte (without this, base IDs over different
  513. types of ECs may be overlapping).
  514. The ``SDTX_DEVICE_TYPE()`` macro can be used to determine the EC device
  515. type. This can be one of
  516. * ``SDTX_DEVICE_TYPE_HID``, for Surface Aggregator Module over HID, and
  517. * ``SDTX_DEVICE_TYPE_SSH``, for Surface Aggregator Module over Surface Serial
  518. Hub.
  519. Note that currently only the ``SSH`` type EC is supported, however ``HID``
  520. type is reserved for future use.
  521. Structures and Enums
  522. --------------------
  523. .. kernel-doc:: include/uapi/linux/surface_aggregator/dtx.h
  524. API Users
  525. =========
  526. A user-space daemon utilizing this API can be found at
  527. https://github.com/linux-surface/surface-dtx-daemon.