0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef SURFACE_HID_CORE_H
0011 #define SURFACE_HID_CORE_H
0012
0013 #include <linux/hid.h>
0014 #include <linux/pm.h>
0015 #include <linux/types.h>
0016
0017 #include <linux/surface_aggregator/controller.h>
0018 #include <linux/surface_aggregator/device.h>
0019
0020 enum surface_hid_descriptor_entry {
0021 SURFACE_HID_DESC_HID = 0,
0022 SURFACE_HID_DESC_REPORT = 1,
0023 SURFACE_HID_DESC_ATTRS = 2,
0024 };
0025
0026 struct surface_hid_descriptor {
0027 __u8 desc_len;
0028 __u8 desc_type;
0029 __le16 hid_version;
0030 __u8 country_code;
0031 __u8 num_descriptors;
0032
0033 __u8 report_desc_type;
0034 __le16 report_desc_len;
0035 } __packed;
0036
0037 static_assert(sizeof(struct surface_hid_descriptor) == 9);
0038
0039 struct surface_hid_attributes {
0040 __le32 length;
0041 __le16 vendor;
0042 __le16 product;
0043 __le16 version;
0044 __u8 _unknown[22];
0045 } __packed;
0046
0047 static_assert(sizeof(struct surface_hid_attributes) == 32);
0048
0049 struct surface_hid_device;
0050
0051 struct surface_hid_device_ops {
0052 int (*get_descriptor)(struct surface_hid_device *shid, u8 entry, u8 *buf, size_t len);
0053 int (*output_report)(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len);
0054 int (*get_feature_report)(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len);
0055 int (*set_feature_report)(struct surface_hid_device *shid, u8 rprt_id, u8 *buf, size_t len);
0056 };
0057
0058 struct surface_hid_device {
0059 struct device *dev;
0060 struct ssam_controller *ctrl;
0061 struct ssam_device_uid uid;
0062
0063 struct surface_hid_descriptor hid_desc;
0064 struct surface_hid_attributes attrs;
0065
0066 struct ssam_event_notifier notif;
0067 struct hid_device *hid;
0068
0069 struct surface_hid_device_ops ops;
0070 };
0071
0072 int surface_hid_device_add(struct surface_hid_device *shid);
0073 void surface_hid_device_destroy(struct surface_hid_device *shid);
0074
0075 extern const struct dev_pm_ops surface_hid_pm_ops;
0076
0077 #endif