/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* * Surface DTX (clipboard detachment system driver) user-space interface. * * Definitions, structs, and IOCTLs for the /dev/surface/dtx misc device. This * device allows user-space to control the clipboard detachment process on * Surface Book series devices. * * Copyright (C) 2020-2021 Maximilian Luz <[email protected]> */ #ifndef _UAPI_LINUX_SURFACE_AGGREGATOR_DTX_H #define _UAPI_LINUX_SURFACE_AGGREGATOR_DTX_H #include <linux/ioctl.h> #include <linux/types.h> /* Status/error categories */ #define SDTX_CATEGORY_STATUS … #define SDTX_CATEGORY_RUNTIME_ERROR … #define SDTX_CATEGORY_HARDWARE_ERROR … #define SDTX_CATEGORY_UNKNOWN … #define SDTX_CATEGORY_MASK … #define SDTX_CATEGORY(value) … #define SDTX_STATUS(code) … #define SDTX_ERR_RT(code) … #define SDTX_ERR_HW(code) … #define SDTX_UNKNOWN(code) … #define SDTX_SUCCESS(value) … /* Latch status values */ #define SDTX_LATCH_CLOSED … #define SDTX_LATCH_OPENED … /* Base state values */ #define SDTX_BASE_DETACHED … #define SDTX_BASE_ATTACHED … /* Runtime errors (non-critical) */ #define SDTX_DETACH_NOT_FEASIBLE … #define SDTX_DETACH_TIMEDOUT … /* Hardware errors (critical) */ #define SDTX_ERR_FAILED_TO_OPEN … #define SDTX_ERR_FAILED_TO_REMAIN_OPEN … #define SDTX_ERR_FAILED_TO_CLOSE … /* Base types */ #define SDTX_DEVICE_TYPE_HID … #define SDTX_DEVICE_TYPE_SSH … #define SDTX_DEVICE_TYPE_MASK … #define SDTX_DEVICE_TYPE(value) … #define SDTX_BASE_TYPE_HID(id) … #define SDTX_BASE_TYPE_SSH(id) … /** * enum sdtx_device_mode - Mode describing how (and if) the clipboard is * attached to the base of the device. * @SDTX_DEVICE_MODE_TABLET: The clipboard is detached from the base and the * device operates as tablet. * @SDTX_DEVICE_MODE_LAPTOP: The clipboard is attached normally to the base * and the device operates as laptop. * @SDTX_DEVICE_MODE_STUDIO: The clipboard is attached to the base in reverse. * The device operates as tablet with keyboard and * touchpad deactivated, however, the base battery * and, if present in the specific device model, dGPU * are available to the system. */ enum sdtx_device_mode { … }; /** * struct sdtx_event - Event provided by reading from the DTX device file. * @length: Length of the event payload, in bytes. * @code: Event code, detailing what type of event this is. * @data: Payload of the event, containing @length bytes. * * See &enum sdtx_event_code for currently valid event codes. */ struct sdtx_event { … } __attribute__((packed)); /** * enum sdtx_event_code - Code describing the type of an event. * @SDTX_EVENT_REQUEST: Detachment request event type. * @SDTX_EVENT_CANCEL: Cancel detachment process event type. * @SDTX_EVENT_BASE_CONNECTION: Base/clipboard connection change event type. * @SDTX_EVENT_LATCH_STATUS: Latch status change event type. * @SDTX_EVENT_DEVICE_MODE: Device mode change event type. * * Used in &struct sdtx_event to describe the type of the event. Further event * codes are reserved for future use. Any event parser should be able to * gracefully handle unknown events, i.e. by simply skipping them. * * Consult the DTX user-space interface documentation for details regarding * the individual event types. */ enum sdtx_event_code { … }; /** * struct sdtx_base_info - Describes if and what type of base is connected. * @state: The state of the connection. Valid values are %SDTX_BASE_DETACHED, * %SDTX_BASE_ATTACHED, and %SDTX_DETACH_NOT_FEASIBLE (in case a base * is attached but low clipboard battery prevents detachment). Other * values are currently reserved. * @base_id: The type of base connected. Zero if no base is connected. */ struct sdtx_base_info { … } __attribute__((packed)); /* IOCTLs */ #define SDTX_IOCTL_EVENTS_ENABLE … #define SDTX_IOCTL_EVENTS_DISABLE … #define SDTX_IOCTL_LATCH_LOCK … #define SDTX_IOCTL_LATCH_UNLOCK … #define SDTX_IOCTL_LATCH_REQUEST … #define SDTX_IOCTL_LATCH_CONFIRM … #define SDTX_IOCTL_LATCH_HEARTBEAT … #define SDTX_IOCTL_LATCH_CANCEL … #define SDTX_IOCTL_GET_BASE_INFO … #define SDTX_IOCTL_GET_DEVICE_MODE … #define SDTX_IOCTL_GET_LATCH_STATUS … #endif /* _UAPI_LINUX_SURFACE_AGGREGATOR_DTX_H */