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