Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: driver-api: Update Surface Aggregator user-space interface documentation

Update the controller-device user-space interface (cdev) documentation
for the newly introduced IOCTLs and event interface.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210604134755.535590-8-luzmaximilian@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Maximilian Luz and committed by
Hans de Goede
8ae20054 cbd224e0

+122 -5
+122 -5
Documentation/driver-api/surface_aggregator/clients/cdev.rst
··· 1 1 .. SPDX-License-Identifier: GPL-2.0+ 2 2 3 - .. |u8| replace:: :c:type:`u8 <u8>` 4 - .. |u16| replace:: :c:type:`u16 <u16>` 5 3 .. |ssam_cdev_request| replace:: :c:type:`struct ssam_cdev_request <ssam_cdev_request>` 6 4 .. |ssam_cdev_request_flags| replace:: :c:type:`enum ssam_cdev_request_flags <ssam_cdev_request_flags>` 5 + .. |ssam_cdev_event| replace:: :c:type:`struct ssam_cdev_event <ssam_cdev_event>` 7 6 8 7 ============================== 9 8 User-Space EC Interface (cdev) ··· 21 22 22 23 A small python library and scripts for accessing this interface can be found 23 24 at https://github.com/linux-surface/surface-aggregator-module/tree/master/scripts/ssam. 25 + 26 + .. contents:: 27 + 28 + 29 + Receiving Events 30 + ================ 31 + 32 + Events can be received by reading from the device-file. The are represented by 33 + the |ssam_cdev_event| datatype. 34 + 35 + Before events are available to be read, however, the desired notifiers must be 36 + registered via the ``SSAM_CDEV_NOTIF_REGISTER`` IOCTL. Notifiers are, in 37 + essence, callbacks, called when the EC sends an event. They are, in this 38 + interface, associated with a specific target category and device-file-instance. 39 + They forward any event of this category to the buffer of the corresponding 40 + instance, from which it can then be read. 41 + 42 + Notifiers themselves do not enable events on the EC. Thus, it may additionally 43 + be necessary to enable events via the ``SSAM_CDEV_EVENT_ENABLE`` IOCTL. While 44 + notifiers work per-client (i.e. per-device-file-instance), events are enabled 45 + globally, for the EC and all of its clients (regardless of userspace or 46 + non-userspace). The ``SSAM_CDEV_EVENT_ENABLE`` and ``SSAM_CDEV_EVENT_DISABLE`` 47 + IOCTLs take care of reference counting the events, such that an event is 48 + enabled as long as there is a client that has requested it. 49 + 50 + Note that enabled events are not automatically disabled once the client 51 + instance is closed. Therefore any client process (or group of processes) should 52 + balance their event enable calls with the corresponding event disable calls. It 53 + is, however, perfectly valid to enable and disable events on different client 54 + instances. For example, it is valid to set up notifiers and read events on 55 + client instance ``A``, enable those events on instance ``B`` (note that these 56 + will also be received by A since events are enabled/disabled globally), and 57 + after no more events are desired, disable the previously enabled events via 58 + instance ``C``. 24 59 25 60 26 61 Controller IOCTLs ··· 78 45 - ``REQUEST`` 79 46 - Perform synchronous SAM request. 80 47 48 + * - ``0xA5`` 49 + - ``2`` 50 + - ``W`` 51 + - ``NOTIF_REGISTER`` 52 + - Register event notifier. 81 53 82 - ``REQUEST`` 83 - ----------- 54 + * - ``0xA5`` 55 + - ``3`` 56 + - ``W`` 57 + - ``NOTIF_UNREGISTER`` 58 + - Unregister event notifier. 59 + 60 + * - ``0xA5`` 61 + - ``4`` 62 + - ``W`` 63 + - ``EVENT_ENABLE`` 64 + - Enable event source. 65 + 66 + * - ``0xA5`` 67 + - ``5`` 68 + - ``W`` 69 + - ``EVENT_DISABLE`` 70 + - Disable event source. 71 + 72 + 73 + ``SSAM_CDEV_REQUEST`` 74 + --------------------- 84 75 85 76 Defined as ``_IOWR(0xA5, 1, struct ssam_cdev_request)``. 86 77 ··· 139 82 inside the IOCTL, but the request ``status`` member may still be negative in 140 83 case the actual execution of the request failed after it has been submitted. 141 84 142 - A full definition of the argument struct is provided below: 85 + A full definition of the argument struct is provided below. 86 + 87 + ``SSAM_CDEV_NOTIF_REGISTER`` 88 + ---------------------------- 89 + 90 + Defined as ``_IOW(0xA5, 2, struct ssam_cdev_notifier_desc)``. 91 + 92 + Register a notifier for the event target category specified in the given 93 + notifier description with the specified priority. Notifiers registration is 94 + required to receive events, but does not enable events themselves. After a 95 + notifier for a specific target category has been registered, all events of that 96 + category will be forwarded to the userspace client and can then be read from 97 + the device file instance. Note that events may have to be enabled, e.g. via the 98 + ``SSAM_CDEV_EVENT_ENABLE`` IOCTL, before the EC will send them. 99 + 100 + Only one notifier can be registered per target category and client instance. If 101 + a notifier has already been registered, this IOCTL will fail with ``-EEXIST``. 102 + 103 + Notifiers will automatically be removed when the device file instance is 104 + closed. 105 + 106 + ``SSAM_CDEV_NOTIF_UNREGISTER`` 107 + ------------------------------ 108 + 109 + Defined as ``_IOW(0xA5, 3, struct ssam_cdev_notifier_desc)``. 110 + 111 + Unregisters the notifier associated with the specified target category. The 112 + priority field will be ignored by this IOCTL. If no notifier has been 113 + registered for this client instance and the given category, this IOCTL will 114 + fail with ``-ENOENT``. 115 + 116 + ``SSAM_CDEV_EVENT_ENABLE`` 117 + -------------------------- 118 + 119 + Defined as ``_IOW(0xA5, 4, struct ssam_cdev_event_desc)``. 120 + 121 + Enable the event associated with the given event descriptor. 122 + 123 + Note that this call will not register a notifier itself, it will only enable 124 + events on the controller. If you want to receive events by reading from the 125 + device file, you will need to register the corresponding notifier(s) on that 126 + instance. 127 + 128 + Events are not automatically disabled when the device file is closed. This must 129 + be done manually, via a call to the ``SSAM_CDEV_EVENT_DISABLE`` IOCTL. 130 + 131 + ``SSAM_CDEV_EVENT_DISABLE`` 132 + --------------------------- 133 + 134 + Defined as ``_IOW(0xA5, 5, struct ssam_cdev_event_desc)``. 135 + 136 + Disable the event associated with the given event descriptor. 137 + 138 + Note that this will not unregister any notifiers. Events may still be received 139 + and forwarded to user-space after this call. The only safe way of stopping 140 + events from being received is unregistering all previously registered 141 + notifiers. 142 + 143 + 144 + Structures and Enums 145 + ==================== 143 146 144 147 .. kernel-doc:: include/uapi/linux/surface_aggregator/cdev.h