0001
0002
0003
0004
0005
0006
0007 #ifndef ISHTP_HID__H
0008 #define ISHTP_HID__H
0009
0010
0011 #define ISH_HID_VENDOR 0x8086
0012 #define ISH_HID_PRODUCT 0x22D8
0013 #define ISH_HID_VERSION 0x0200
0014
0015 #define CMD_MASK 0x7F
0016 #define IS_RESPONSE 0x80
0017
0018
0019 extern ishtp_print_log ishtp_hid_print_trace;
0020 #define hid_ishtp_trace(client, ...) \
0021 (ishtp_hid_print_trace)(NULL, __VA_ARGS__)
0022
0023
0024 struct hostif_msg_hdr {
0025 uint8_t command;
0026 uint8_t device_id;
0027 uint8_t status;
0028 uint8_t flags;
0029 uint16_t size;
0030 } __packed;
0031
0032 struct hostif_msg {
0033 struct hostif_msg_hdr hdr;
0034 } __packed;
0035
0036 struct hostif_msg_to_sensor {
0037 struct hostif_msg_hdr hdr;
0038 uint8_t report_id;
0039 } __packed;
0040
0041 struct device_info {
0042 uint32_t dev_id;
0043 uint8_t dev_class;
0044 uint16_t pid;
0045 uint16_t vid;
0046 } __packed;
0047
0048 struct ishtp_version {
0049 uint8_t major;
0050 uint8_t minor;
0051 uint8_t hotfix;
0052 uint16_t build;
0053 } __packed;
0054
0055
0056 struct report_list {
0057 uint16_t total_size;
0058 uint8_t num_of_reports;
0059 uint8_t flags;
0060 struct {
0061 uint16_t size_of_report;
0062 uint8_t report[1];
0063 } __packed reports[1];
0064 } __packed;
0065
0066
0067 #define HOSTIF_HID_COMMAND_BASE 0
0068 #define HOSTIF_GET_HID_DESCRIPTOR 0
0069 #define HOSTIF_GET_REPORT_DESCRIPTOR 1
0070 #define HOSTIF_GET_FEATURE_REPORT 2
0071 #define HOSTIF_SET_FEATURE_REPORT 3
0072 #define HOSTIF_GET_INPUT_REPORT 4
0073 #define HOSTIF_PUBLISH_INPUT_REPORT 5
0074 #define HOSTIF_PUBLISH_INPUT_REPORT_LIST 6
0075 #define HOSTIF_DM_COMMAND_BASE 32
0076 #define HOSTIF_DM_ENUM_DEVICES 33
0077 #define HOSTIF_DM_ADD_DEVICE 34
0078
0079 #define MAX_HID_DEVICES 32
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 struct ishtp_cl_data {
0111
0112 bool enum_devices_done;
0113 bool hid_descr_done;
0114 bool report_descr_done;
0115 bool init_done;
0116 bool suspended;
0117
0118 unsigned int num_hid_devices;
0119 unsigned int cur_hid_dev;
0120 unsigned int hid_dev_count;
0121
0122 struct device_info *hid_devices;
0123 unsigned char *report_descr[MAX_HID_DEVICES];
0124 int report_descr_size[MAX_HID_DEVICES];
0125 struct hid_device *hid_sensor_hubs[MAX_HID_DEVICES];
0126 unsigned char *hid_descr[MAX_HID_DEVICES];
0127 int hid_descr_size[MAX_HID_DEVICES];
0128
0129 wait_queue_head_t init_wait;
0130 wait_queue_head_t ishtp_resume_wait;
0131 struct ishtp_cl *hid_ishtp_cl;
0132
0133
0134 unsigned int bad_recv_cnt;
0135 int multi_packet_cnt;
0136
0137 struct work_struct work;
0138 struct work_struct resume_work;
0139 struct ishtp_cl_device *cl_device;
0140 };
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 struct ishtp_hid_data {
0156 int index;
0157 bool request_done;
0158 struct ishtp_cl_data *client_data;
0159 wait_queue_head_t hid_wait;
0160
0161
0162 bool raw_get_req;
0163 u8 *raw_buf;
0164 size_t raw_buf_size;
0165 };
0166
0167
0168 void hid_ishtp_set_feature(struct hid_device *hid, char *buf, unsigned int len,
0169 int report_id);
0170 void hid_ishtp_get_report(struct hid_device *hid, int report_id,
0171 int report_type);
0172 int ishtp_hid_probe(unsigned int cur_hid_dev,
0173 struct ishtp_cl_data *client_data);
0174 void ishtp_hid_remove(struct ishtp_cl_data *client_data);
0175 int ishtp_hid_link_ready_wait(struct ishtp_cl_data *client_data);
0176 void ishtp_hid_wakeup(struct hid_device *hid);
0177
0178 #endif