1
2
3
4
5
6
7 #ifndef ISHTP_HID__H
8 #define ISHTP_HID__H
9
10
11 #define ISH_HID_VENDOR 0x8086
12 #define ISH_HID_PRODUCT 0x22D8
13 #define ISH_HID_VERSION 0x0200
14
15 #define CMD_MASK 0x7F
16 #define IS_RESPONSE 0x80
17
18
19 extern void (*hid_print_trace)(void *unused, const char *format, ...);
20 #define hid_ishtp_trace(client, ...) \
21 (hid_print_trace)(NULL, __VA_ARGS__)
22
23
24 static const guid_t hid_ishtp_guid =
25 GUID_INIT(0x33AECD58, 0xB679, 0x4E54,
26 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26);
27
28
29 struct hostif_msg_hdr {
30 uint8_t command;
31 uint8_t device_id;
32 uint8_t status;
33 uint8_t flags;
34 uint16_t size;
35 } __packed;
36
37 struct hostif_msg {
38 struct hostif_msg_hdr hdr;
39 } __packed;
40
41 struct hostif_msg_to_sensor {
42 struct hostif_msg_hdr hdr;
43 uint8_t report_id;
44 } __packed;
45
46 struct device_info {
47 uint32_t dev_id;
48 uint8_t dev_class;
49 uint16_t pid;
50 uint16_t vid;
51 } __packed;
52
53 struct ishtp_version {
54 uint8_t major;
55 uint8_t minor;
56 uint8_t hotfix;
57 uint16_t build;
58 } __packed;
59
60
61 struct report_list {
62 uint16_t total_size;
63 uint8_t num_of_reports;
64 uint8_t flags;
65 struct {
66 uint16_t size_of_report;
67 uint8_t report[1];
68 } __packed reports[1];
69 } __packed;
70
71
72 #define HOSTIF_HID_COMMAND_BASE 0
73 #define HOSTIF_GET_HID_DESCRIPTOR 0
74 #define HOSTIF_GET_REPORT_DESCRIPTOR 1
75 #define HOSTIF_GET_FEATURE_REPORT 2
76 #define HOSTIF_SET_FEATURE_REPORT 3
77 #define HOSTIF_GET_INPUT_REPORT 4
78 #define HOSTIF_PUBLISH_INPUT_REPORT 5
79 #define HOSTIF_PUBLISH_INPUT_REPORT_LIST 6
80 #define HOSTIF_DM_COMMAND_BASE 32
81 #define HOSTIF_DM_ENUM_DEVICES 33
82 #define HOSTIF_DM_ADD_DEVICE 34
83
84 #define MAX_HID_DEVICES 32
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 struct ishtp_cl_data {
116
117 bool enum_devices_done;
118 bool hid_descr_done;
119 bool report_descr_done;
120 bool init_done;
121 bool suspended;
122
123 unsigned int num_hid_devices;
124 unsigned int cur_hid_dev;
125 unsigned int hid_dev_count;
126
127 struct device_info *hid_devices;
128 unsigned char *report_descr[MAX_HID_DEVICES];
129 int report_descr_size[MAX_HID_DEVICES];
130 struct hid_device *hid_sensor_hubs[MAX_HID_DEVICES];
131 unsigned char *hid_descr[MAX_HID_DEVICES];
132 int hid_descr_size[MAX_HID_DEVICES];
133
134 wait_queue_head_t init_wait;
135 wait_queue_head_t ishtp_resume_wait;
136 struct ishtp_cl *hid_ishtp_cl;
137
138
139 unsigned int bad_recv_cnt;
140 int multi_packet_cnt;
141
142 struct work_struct work;
143 struct ishtp_cl_device *cl_device;
144 };
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 struct ishtp_hid_data {
160 int index;
161 bool request_done;
162 struct ishtp_cl_data *client_data;
163 wait_queue_head_t hid_wait;
164
165
166 bool raw_get_req;
167 u8 *raw_buf;
168 size_t raw_buf_size;
169 };
170
171
172 void hid_ishtp_set_feature(struct hid_device *hid, char *buf, unsigned int len,
173 int report_id);
174 void hid_ishtp_get_report(struct hid_device *hid, int report_id,
175 int report_type);
176 int ishtp_hid_probe(unsigned int cur_hid_dev,
177 struct ishtp_cl_data *client_data);
178 void ishtp_hid_remove(struct ishtp_cl_data *client_data);
179 int ishtp_hid_link_ready_wait(struct ishtp_cl_data *client_data);
180 void ishtp_hid_wakeup(struct hid_device *hid);
181
182 #endif