brintos

brintos / linux-shallow public Read only

0
0
Text · 5.2 KiB · 35dddc5 Raw
179 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * ISHTP-HID glue driver's definitions.4 *5 * Copyright (c) 2014-2016, Intel Corporation.6 */7#ifndef ISHTP_HID__H8#define	ISHTP_HID__H9 10/* The fixed ISH product and vendor id */11#define	ISH_HID_VENDOR	0x808612#define	ISH_HID_PRODUCT	0x22D813#define	ISH_HID_VERSION	0x020014 15#define	CMD_MASK	0x7F16#define	IS_RESPONSE	0x8017 18/* Used to dump to Linux trace buffer, if enabled */19extern ishtp_print_log ishtp_hid_print_trace;20#define hid_ishtp_trace(client, ...) \21	(ishtp_hid_print_trace)(NULL, __VA_ARGS__)22 23/* ISH HID message structure */24struct hostif_msg_hdr {25	uint8_t	command; /* Bit 7: is_response */26	uint8_t	device_id;27	uint8_t	status;28	uint8_t	flags;29	uint16_t size;30} __packed;31 32struct hostif_msg {33	struct hostif_msg_hdr	hdr;34} __packed;35 36struct hostif_msg_to_sensor {37	struct hostif_msg_hdr	hdr;38	uint8_t	report_id;39} __packed;40 41struct device_info {42	uint32_t dev_id;43	uint8_t dev_class;44	uint16_t pid;45	uint16_t vid;46} __packed;47 48struct ishtp_version {49	uint8_t	major;50	uint8_t	minor;51	uint8_t	hotfix;52	uint16_t build;53} __packed;54 55/* struct for ISHTP aggregated input data */56struct report_list {57	uint16_t total_size;58	uint8_t	num_of_reports;59	uint8_t	flags;60	struct {61		uint16_t	size_of_report;62		uint8_t report[1];63	} __packed reports[1];64} __packed;65 66/* HOSTIF commands */67#define	HOSTIF_HID_COMMAND_BASE			068#define	HOSTIF_GET_HID_DESCRIPTOR		069#define	HOSTIF_GET_REPORT_DESCRIPTOR		170#define HOSTIF_GET_FEATURE_REPORT		271#define	HOSTIF_SET_FEATURE_REPORT		372#define	HOSTIF_GET_INPUT_REPORT			473#define	HOSTIF_PUBLISH_INPUT_REPORT		574#define	HOSTIF_PUBLISH_INPUT_REPORT_LIST	675#define	HOSTIF_DM_COMMAND_BASE			3276#define	HOSTIF_DM_ENUM_DEVICES			3377#define	HOSTIF_DM_ADD_DEVICE			3478 79#define	MAX_HID_DEVICES				3280 81/**82 * struct ishtp_cl_data - Encapsulate per ISH TP HID Client83 * @enum_device_done:	Enum devices response complete flag84 * @hid_descr_done:	HID descriptor complete flag85 * @report_descr_done:	Get report descriptor complete flag86 * @init_done:		Init process completed successfully87 * @suspended:		System is under suspend state or in progress88 * @num_hid_devices:	Number of HID devices enumerated in this client89 * @cur_hid_dev:	This keeps track of the device index for which90 *			initialization and registration with HID core91 *			in progress.92 * @hid_devices:	Store vid/pid/devid for each enumerated HID device93 * @report_descr:	Stores the raw report descriptors for each HID device94 * @report_descr_size:	Report description of size of above repo_descr[]95 * @hid_sensor_hubs:	Pointer to hid_device for all HID device, so that96 *			when clients are removed, they can be freed97 * @hid_descr:		Pointer to hid descriptor for each enumerated hid98 *			device99 * @hid_descr_size:	Size of each above report descriptor100 * @init_wait:		Wait queue to wait during initialization, where the101 *			client send message to ISH FW and wait for response102 * @ishtp_hid_wait:	The wait for get report during wait callback from hid103 *			core104 * @bad_recv_cnt:	Running count of packets received with error105 * @multi_packet_cnt:	Count of fragmented packet count106 *107 * This structure is used to store completion flags and per client data like108 * report description, number of HID devices etc.109 */110struct ishtp_cl_data {111	/* completion flags */112	bool enum_devices_done;113	bool hid_descr_done;114	bool report_descr_done;115	bool init_done;116	bool suspended;117 118	unsigned int num_hid_devices;119	unsigned int cur_hid_dev;120	unsigned int hid_dev_count;121 122	struct device_info *hid_devices;123	unsigned char *report_descr[MAX_HID_DEVICES];124	int report_descr_size[MAX_HID_DEVICES];125	struct hid_device *hid_sensor_hubs[MAX_HID_DEVICES];126	unsigned char *hid_descr[MAX_HID_DEVICES];127	int hid_descr_size[MAX_HID_DEVICES];128 129	wait_queue_head_t init_wait;130	wait_queue_head_t ishtp_resume_wait;131	struct ishtp_cl *hid_ishtp_cl;132 133	/* Statistics */134	unsigned int bad_recv_cnt;135	int multi_packet_cnt;136 137	struct work_struct work;138	struct work_struct resume_work;139	struct ishtp_cl_device *cl_device;140};141 142/**143 * struct ishtp_hid_data - Per instance HID data144 * @index:		Device index in the order of enumeration145 * @request_done:	Get Feature/Input report complete flag146 *			used during get/set request from hid core147 * @client_data:	Link to the client instance148 * @hid_wait:		Completion waitq149 *150 * @raw_get_req:	Flag indicating raw get request ongoing151 * @raw_buf:		raw request buffer filled on receiving get report152 * @raw_buf_size:	raw request buffer size153 * Used to tie hid hid->driver data to driver client instance154 */155struct ishtp_hid_data {156	int index;157	bool request_done;158	struct ishtp_cl_data *client_data;159	wait_queue_head_t hid_wait;160 161	/* raw request */162	bool raw_get_req;163	u8 *raw_buf;164	size_t raw_buf_size;165};166 167/* Interface functions between HID LL driver and ISH TP client */168void hid_ishtp_set_feature(struct hid_device *hid, char *buf, unsigned int len,169			   int report_id);170void hid_ishtp_get_report(struct hid_device *hid, int report_id,171			  int report_type);172int ishtp_hid_probe(unsigned int cur_hid_dev,173		    struct ishtp_cl_data *client_data);174void ishtp_hid_remove(struct ishtp_cl_data *client_data);175int ishtp_hid_link_ready_wait(struct ishtp_cl_data *client_data);176void ishtp_hid_wakeup(struct hid_device *hid);177 178#endif	/* ISHTP_HID__H */179