1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Common/core components for the Surface System Aggregator Module (SSAM) HID
4 * transport driver. Provides support for integrated HID devices on Microsoft
10 #ifndef SURFACE_HID_CORE_H
11 #define SURFACE_HID_CORE_H
13 #include <linux/hid.h>
15 #include <linux/types.h>
17 #include <linux/surface_aggregator/controller.h>
18 #include <linux/surface_aggregator/device.h>
20 enum surface_hid_descriptor_entry {
21 SURFACE_HID_DESC_HID = 0,
22 SURFACE_HID_DESC_REPORT = 1,
23 SURFACE_HID_DESC_ATTRS = 2,
26 struct surface_hid_descriptor {
27 __u8 desc_len; /* = 9 */
28 __u8 desc_type; /* = HID_DT_HID */
31 __u8 num_descriptors; /* = 1 */
33 __u8 report_desc_type; /* = HID_DT_REPORT */
34 __le16 report_desc_len;
37 static_assert(sizeof(struct surface_hid_descriptor) == 9);
39 struct surface_hid_attributes {
47 static_assert(sizeof(struct surface_hid_attributes) == 32);
49 struct surface_hid_device;
51 struct surface_hid_device_ops {
52 int (*get_descriptor)(struct surface_hid_device *shid, u8 entry, u8 *buf, size_t len);
53 int (*output_report)(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len);
54 int (*get_feature_report)(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len);
55 int (*set_feature_report)(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len);
58 struct surface_hid_device {
60 struct ssam_controller *ctrl;
61 struct ssam_device_uid uid;
63 struct surface_hid_descriptor hid_desc;
64 struct surface_hid_attributes attrs;
66 struct ssam_event_notifier notif;
67 struct hid_device *hid;
69 struct surface_hid_device_ops ops;
72 int surface_hid_device_add(struct surface_hid_device *shid);
73 void surface_hid_device_destroy(struct surface_hid_device *shid);
75 extern const struct dev_pm_ops surface_hid_pm_ops;
77 #endif /* SURFACE_HID_CORE_H */