Linux 6.1.31 headers
This commit is contained in:
147
linux/surface_aggregator/cdev.h
Normal file
147
linux/surface_aggregator/cdev.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
||||
/*
|
||||
* Surface System Aggregator Module (SSAM) user-space EC interface.
|
||||
*
|
||||
* Definitions, structs, and IOCTLs for the /dev/surface/aggregator misc
|
||||
* device. This device provides direct user-space access to the SSAM EC.
|
||||
* Intended for debugging and development.
|
||||
*
|
||||
* Copyright (C) 2020-2021 Maximilian Luz <luzmaximilian@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_SURFACE_AGGREGATOR_CDEV_H
|
||||
#define _LINUX_SURFACE_AGGREGATOR_CDEV_H
|
||||
|
||||
#include <linux/ioctl.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
/**
|
||||
* enum ssam_cdev_request_flags - Request flags for SSAM cdev request IOCTL.
|
||||
*
|
||||
* @SSAM_CDEV_REQUEST_HAS_RESPONSE:
|
||||
* Specifies that the request expects a response. If not set, the request
|
||||
* will be directly completed after its underlying packet has been
|
||||
* transmitted. If set, the request transport system waits for a response
|
||||
* of the request.
|
||||
*
|
||||
* @SSAM_CDEV_REQUEST_UNSEQUENCED:
|
||||
* Specifies that the request should be transmitted via an unsequenced
|
||||
* packet. If set, the request must not have a response, meaning that this
|
||||
* flag and the %SSAM_CDEV_REQUEST_HAS_RESPONSE flag are mutually
|
||||
* exclusive.
|
||||
*/
|
||||
enum ssam_cdev_request_flags {
|
||||
SSAM_CDEV_REQUEST_HAS_RESPONSE = 0x01,
|
||||
SSAM_CDEV_REQUEST_UNSEQUENCED = 0x02,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ssam_cdev_request - Controller request IOCTL argument.
|
||||
* @target_category: Target category of the SAM request.
|
||||
* @target_id: Target ID of the SAM request.
|
||||
* @command_id: Command ID of the SAM request.
|
||||
* @instance_id: Instance ID of the SAM request.
|
||||
* @flags: Request flags (see &enum ssam_cdev_request_flags).
|
||||
* @status: Request status (output).
|
||||
* @payload: Request payload (input data).
|
||||
* @payload.data: Pointer to request payload data.
|
||||
* @payload.length: Length of request payload data (in bytes).
|
||||
* @response: Request response (output data).
|
||||
* @response.data: Pointer to response buffer.
|
||||
* @response.length: On input: Capacity of response buffer (in bytes).
|
||||
* On output: Length of request response (number of bytes
|
||||
* in the buffer that are actually used).
|
||||
*/
|
||||
struct ssam_cdev_request {
|
||||
__u8 target_category;
|
||||
__u8 target_id;
|
||||
__u8 command_id;
|
||||
__u8 instance_id;
|
||||
__u16 flags;
|
||||
__s16 status;
|
||||
|
||||
struct {
|
||||
__u64 data;
|
||||
__u16 length;
|
||||
__u8 __pad[6];
|
||||
} payload;
|
||||
|
||||
struct {
|
||||
__u64 data;
|
||||
__u16 length;
|
||||
__u8 __pad[6];
|
||||
} response;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* struct ssam_cdev_notifier_desc - Notifier descriptor.
|
||||
* @priority: Priority value determining the order in which notifier
|
||||
* callbacks will be called. A higher value means higher
|
||||
* priority, i.e. the associated callback will be executed
|
||||
* earlier than other (lower priority) callbacks.
|
||||
* @target_category: The event target category for which this notifier should
|
||||
* receive events.
|
||||
*
|
||||
* Specifies the notifier that should be registered or unregistered,
|
||||
* specifically with which priority and for which target category of events.
|
||||
*/
|
||||
struct ssam_cdev_notifier_desc {
|
||||
__s32 priority;
|
||||
__u8 target_category;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* struct ssam_cdev_event_desc - Event descriptor.
|
||||
* @reg: Registry via which the event will be enabled/disabled.
|
||||
* @reg.target_category: Target category for the event registry requests.
|
||||
* @reg.target_id: Target ID for the event registry requests.
|
||||
* @reg.cid_enable: Command ID for the event-enable request.
|
||||
* @reg.cid_disable: Command ID for the event-disable request.
|
||||
* @id: ID specifying the event.
|
||||
* @id.target_category: Target category of the event source.
|
||||
* @id.instance: Instance ID of the event source.
|
||||
* @flags: Flags used for enabling the event.
|
||||
*
|
||||
* Specifies which event should be enabled/disabled and how to do that.
|
||||
*/
|
||||
struct ssam_cdev_event_desc {
|
||||
struct {
|
||||
__u8 target_category;
|
||||
__u8 target_id;
|
||||
__u8 cid_enable;
|
||||
__u8 cid_disable;
|
||||
} reg;
|
||||
|
||||
struct {
|
||||
__u8 target_category;
|
||||
__u8 instance;
|
||||
} id;
|
||||
|
||||
__u8 flags;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* struct ssam_cdev_event - SSAM event sent by the EC.
|
||||
* @target_category: Target category of the event source. See &enum ssam_ssh_tc.
|
||||
* @target_id: Target ID of the event source.
|
||||
* @command_id: Command ID of the event.
|
||||
* @instance_id: Instance ID of the event source.
|
||||
* @length: Length of the event payload in bytes.
|
||||
* @data: Event payload data.
|
||||
*/
|
||||
struct ssam_cdev_event {
|
||||
__u8 target_category;
|
||||
__u8 target_id;
|
||||
__u8 command_id;
|
||||
__u8 instance_id;
|
||||
__u16 length;
|
||||
__u8 data[];
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#define SSAM_CDEV_REQUEST _IOWR(0xA5, 1, struct ssam_cdev_request)
|
||||
#define SSAM_CDEV_NOTIF_REGISTER _IOW(0xA5, 2, struct ssam_cdev_notifier_desc)
|
||||
#define SSAM_CDEV_NOTIF_UNREGISTER _IOW(0xA5, 3, struct ssam_cdev_notifier_desc)
|
||||
#define SSAM_CDEV_EVENT_ENABLE _IOW(0xA5, 4, struct ssam_cdev_event_desc)
|
||||
#define SSAM_CDEV_EVENT_DISABLE _IOW(0xA5, 5, struct ssam_cdev_event_desc)
|
||||
|
||||
#endif /* _LINUX_SURFACE_AGGREGATOR_CDEV_H */
|
146
linux/surface_aggregator/dtx.h
Normal file
146
linux/surface_aggregator/dtx.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/* 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 <luzmaximilian@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_SURFACE_AGGREGATOR_DTX_H
|
||||
#define _LINUX_SURFACE_AGGREGATOR_DTX_H
|
||||
|
||||
#include <linux/ioctl.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
/* Status/error categories */
|
||||
#define SDTX_CATEGORY_STATUS 0x0000
|
||||
#define SDTX_CATEGORY_RUNTIME_ERROR 0x1000
|
||||
#define SDTX_CATEGORY_HARDWARE_ERROR 0x2000
|
||||
#define SDTX_CATEGORY_UNKNOWN 0xf000
|
||||
|
||||
#define SDTX_CATEGORY_MASK 0xf000
|
||||
#define SDTX_CATEGORY(value) ((value) & SDTX_CATEGORY_MASK)
|
||||
|
||||
#define SDTX_STATUS(code) ((code) | SDTX_CATEGORY_STATUS)
|
||||
#define SDTX_ERR_RT(code) ((code) | SDTX_CATEGORY_RUNTIME_ERROR)
|
||||
#define SDTX_ERR_HW(code) ((code) | SDTX_CATEGORY_HARDWARE_ERROR)
|
||||
#define SDTX_UNKNOWN(code) ((code) | SDTX_CATEGORY_UNKNOWN)
|
||||
|
||||
#define SDTX_SUCCESS(value) (SDTX_CATEGORY(value) == SDTX_CATEGORY_STATUS)
|
||||
|
||||
/* Latch status values */
|
||||
#define SDTX_LATCH_CLOSED SDTX_STATUS(0x00)
|
||||
#define SDTX_LATCH_OPENED SDTX_STATUS(0x01)
|
||||
|
||||
/* Base state values */
|
||||
#define SDTX_BASE_DETACHED SDTX_STATUS(0x00)
|
||||
#define SDTX_BASE_ATTACHED SDTX_STATUS(0x01)
|
||||
|
||||
/* Runtime errors (non-critical) */
|
||||
#define SDTX_DETACH_NOT_FEASIBLE SDTX_ERR_RT(0x01)
|
||||
#define SDTX_DETACH_TIMEDOUT SDTX_ERR_RT(0x02)
|
||||
|
||||
/* Hardware errors (critical) */
|
||||
#define SDTX_ERR_FAILED_TO_OPEN SDTX_ERR_HW(0x01)
|
||||
#define SDTX_ERR_FAILED_TO_REMAIN_OPEN SDTX_ERR_HW(0x02)
|
||||
#define SDTX_ERR_FAILED_TO_CLOSE SDTX_ERR_HW(0x03)
|
||||
|
||||
/* Base types */
|
||||
#define SDTX_DEVICE_TYPE_HID 0x0100
|
||||
#define SDTX_DEVICE_TYPE_SSH 0x0200
|
||||
|
||||
#define SDTX_DEVICE_TYPE_MASK 0x0f00
|
||||
#define SDTX_DEVICE_TYPE(value) ((value) & SDTX_DEVICE_TYPE_MASK)
|
||||
|
||||
#define SDTX_BASE_TYPE_HID(id) ((id) | SDTX_DEVICE_TYPE_HID)
|
||||
#define SDTX_BASE_TYPE_SSH(id) ((id) | SDTX_DEVICE_TYPE_SSH)
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
SDTX_DEVICE_MODE_TABLET = 0x00,
|
||||
SDTX_DEVICE_MODE_LAPTOP = 0x01,
|
||||
SDTX_DEVICE_MODE_STUDIO = 0x02,
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
__u16 length;
|
||||
__u16 code;
|
||||
__u8 data[];
|
||||
} __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 {
|
||||
SDTX_EVENT_REQUEST = 1,
|
||||
SDTX_EVENT_CANCEL = 2,
|
||||
SDTX_EVENT_BASE_CONNECTION = 3,
|
||||
SDTX_EVENT_LATCH_STATUS = 4,
|
||||
SDTX_EVENT_DEVICE_MODE = 5,
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
__u16 state;
|
||||
__u16 base_id;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* IOCTLs */
|
||||
#define SDTX_IOCTL_EVENTS_ENABLE _IO(0xa5, 0x21)
|
||||
#define SDTX_IOCTL_EVENTS_DISABLE _IO(0xa5, 0x22)
|
||||
|
||||
#define SDTX_IOCTL_LATCH_LOCK _IO(0xa5, 0x23)
|
||||
#define SDTX_IOCTL_LATCH_UNLOCK _IO(0xa5, 0x24)
|
||||
|
||||
#define SDTX_IOCTL_LATCH_REQUEST _IO(0xa5, 0x25)
|
||||
#define SDTX_IOCTL_LATCH_CONFIRM _IO(0xa5, 0x26)
|
||||
#define SDTX_IOCTL_LATCH_HEARTBEAT _IO(0xa5, 0x27)
|
||||
#define SDTX_IOCTL_LATCH_CANCEL _IO(0xa5, 0x28)
|
||||
|
||||
#define SDTX_IOCTL_GET_BASE_INFO _IOR(0xa5, 0x29, struct sdtx_base_info)
|
||||
#define SDTX_IOCTL_GET_DEVICE_MODE _IOR(0xa5, 0x2a, __u16)
|
||||
#define SDTX_IOCTL_GET_LATCH_STATUS _IOR(0xa5, 0x2b, __u16)
|
||||
|
||||
#endif /* _LINUX_SURFACE_AGGREGATOR_DTX_H */
|
Reference in New Issue
Block a user