2 * ISHTP-HID glue driver's definitions.
4 * Copyright (c) 2014-2016, Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 /* The fixed ISH product and vendor id */
19 #define ISH_HID_VENDOR 0x8086
20 #define ISH_HID_PRODUCT 0x22D8
21 #define ISH_HID_VERSION 0x0200
24 #define IS_RESPONSE 0x80
26 /* Used to dump to Linux trace buffer, if enabled */
27 #define hid_ishtp_trace(client, ...) \
28 client->cl_device->ishtp_dev->print_log(\
29 client->cl_device->ishtp_dev, __VA_ARGS__)
31 /* ISH Transport protocol (ISHTP in short) GUID */
32 static const uuid_le hid_ishtp_guid
= UUID_LE(0x33AECD58, 0xB679, 0x4E54,
33 0x9B, 0xD9, 0xA0, 0x4D, 0x34,
36 /* ISH HID message structure */
37 struct hostif_msg_hdr
{
38 uint8_t command
; /* Bit 7: is_response */
46 struct hostif_msg_hdr hdr
;
49 struct hostif_msg_to_sensor
{
50 struct hostif_msg_hdr hdr
;
61 struct ishtp_version
{
68 /* struct for ISHTP aggregated input data */
71 uint8_t num_of_reports
;
74 uint16_t size_of_report
;
76 } __packed reports
[1];
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
92 #define MAX_HID_DEVICES 32
95 * struct ishtp_cl_data - Encapsulate per ISH TP HID Client
96 * @enum_device_done: Enum devices response complete flag
97 * @hid_descr_done: HID descriptor complete flag
98 * @report_descr_done: Get report descriptor complete flag
99 * @init_done: Init process completed successfully
100 * @suspended: System is under suspend state or in progress
101 * @num_hid_devices: Number of HID devices enumerated in this client
102 * @cur_hid_dev: This keeps track of the device index for which
103 * initialization and registration with HID core
105 * @hid_devices: Store vid/pid/devid for each enumerated HID device
106 * @report_descr: Stores the raw report descriptors for each HID device
107 * @report_descr_size: Report description of size of above repo_descr[]
108 * @hid_sensor_hubs: Pointer to hid_device for all HID device, so that
109 * when clients are removed, they can be freed
110 * @hid_descr: Pointer to hid descriptor for each enumerated hid
112 * @hid_descr_size: Size of each above report descriptor
113 * @init_wait: Wait queue to wait during initialization, where the
114 * client send message to ISH FW and wait for response
115 * @ishtp_hid_wait: The wait for get report during wait callback from hid
117 * @bad_recv_cnt: Running count of packets received with error
118 * @multi_packet_cnt: Count of fragmented packet count
120 * This structure is used to store completion flags and per client data like
121 * like report description, number of HID devices etc.
123 struct ishtp_cl_data
{
124 /* completion flags */
125 bool enum_devices_done
;
127 bool report_descr_done
;
131 unsigned int num_hid_devices
;
132 unsigned int cur_hid_dev
;
133 unsigned int hid_dev_count
;
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
];
142 wait_queue_head_t init_wait
;
143 wait_queue_head_t ishtp_resume_wait
;
144 struct ishtp_cl
*hid_ishtp_cl
;
147 unsigned int bad_recv_cnt
;
148 int multi_packet_cnt
;
150 struct work_struct work
;
151 struct ishtp_cl_device
*cl_device
;
155 * struct ishtp_hid_data - Per instance HID data
156 * @index: Device index in the order of enumeration
157 * @request_done: Get Feature/Input report complete flag
158 * used during get/set request from hid core
159 * @client_data: Link to the client instance
160 * @hid_wait: Completion waitq
162 * Used to tie hid hid->driver data to driver client instance
164 struct ishtp_hid_data
{
167 struct ishtp_cl_data
*client_data
;
168 wait_queue_head_t hid_wait
;
171 /* Interface functions between HID LL driver and ISH TP client */
172 void hid_ishtp_set_feature(struct hid_device
*hid
, char *buf
, unsigned int len
,
174 void hid_ishtp_get_report(struct hid_device
*hid
, int report_id
,
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
);
182 #endif /* ISHTP_HID__H */