From 7ab2184246bd0b32e427ff60bfa07a2435011ce2 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Mon, 18 Mar 2019 12:14:20 -0700 Subject: HID: intel-ish-hid: Hide members of struct ishtp_cl_device ISH clients don't need to access any field of struct ishtp_cl_device. To avoid this create an interface functions instead where it is required. In the case of ishtp_cl_allocate(), modify the parameters so that the clients don't have to dereference. Clients can also use tracing, here a new interface is added to get the common trace function pointer, instead of direct call. The new interface functions defined in one external header file, named intel-ish-client-if.h. This is the only header files all ISHTP clients must include. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- include/linux/intel-ish-client-if.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/linux/intel-ish-client-if.h (limited to 'include') diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h new file mode 100644 index 000000000000..11e285172735 --- /dev/null +++ b/include/linux/intel-ish-client-if.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Intel ISH client Interface definitions + * + * Copyright (c) 2019, Intel Corporation. + */ + +#ifndef _INTEL_ISH_CLIENT_IF_H_ +#define _INTEL_ISH_CLIENT_IF_H_ + +struct ishtp_cl_device; + +/* Get the device * from ishtp device instance */ +struct device *ishtp_device(struct ishtp_cl_device *cl_device); +/* Trace interface for clients */ +void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); + +#endif /* _INTEL_ISH_CLIENT_IF_H_ */ -- cgit From e00a864f976ab2646929ae82aa65ccd05a4f7539 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Mon, 18 Mar 2019 12:14:22 -0700 Subject: HID: intel-ish-hid: Move driver registry functions Move the driver registry with the ishtp bus to the common interface file, which clients can include. Also rename __ishtp_cl_driver_register() to ishtp_cl_driver_register() and removed define for ishtp_cl_driver_register. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- include/linux/intel-ish-client-if.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index 11e285172735..abc0b8122f07 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -10,6 +10,31 @@ struct ishtp_cl_device; +/** + * struct ishtp_cl_device - ISHTP device handle + * @driver: driver instance on a bus + * @name: Name of the device for probe + * @probe: driver callback for device probe + * @remove: driver callback on device removal + * + * Client drivers defines to get probed/removed for ISHTP client device. + */ +struct ishtp_cl_driver { + struct device_driver driver; + const char *name; + const guid_t *guid; + int (*probe)(struct ishtp_cl_device *dev); + int (*remove)(struct ishtp_cl_device *dev); + int (*reset)(struct ishtp_cl_device *dev); + const struct dev_pm_ops *pm; +}; + +int ishtp_cl_driver_register(struct ishtp_cl_driver *driver, + struct module *owner); +void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver); +int ishtp_register_event_cb(struct ishtp_cl_device *device, + void (*read_cb)(struct ishtp_cl_device *)); + /* Get the device * from ishtp device instance */ struct device *ishtp_device(struct ishtp_cl_device *cl_device); /* Trace interface for clients */ -- cgit From 8991eb309e1faa04ce1ca950d89dd36e3c8584cd Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Mon, 18 Mar 2019 12:14:24 -0700 Subject: HID: intel-ish-hid: Move the common functions from client.h Move the interface functions in client.h to common include. These are already abstracted well to use as is. Also move any associated structures used by these functions. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- include/linux/intel-ish-client-if.h | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'include') diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index abc0b8122f07..7ce172f656f8 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -9,6 +9,16 @@ #define _INTEL_ISH_CLIENT_IF_H_ struct ishtp_cl_device; +struct ishtp_cl; + +/* Client state */ +enum cl_state { + ISHTP_CL_INITIALIZING = 0, + ISHTP_CL_CONNECTING, + ISHTP_CL_CONNECTED, + ISHTP_CL_DISCONNECTING, + ISHTP_CL_DISCONNECTED +}; /** * struct ishtp_cl_device - ISHTP device handle @@ -29,6 +39,32 @@ struct ishtp_cl_driver { const struct dev_pm_ops *pm; }; +/** + * struct ishtp_msg_data - ISHTP message data struct + * @size: Size of data in the *data + * @data: Pointer to data + */ +struct ishtp_msg_data { + uint32_t size; + unsigned char *data; +}; + +/* + * struct ishtp_cl_rb - request block structure + * @list: Link to list members + * @cl: ISHTP client instance + * @buffer: message header + * @buf_idx: Index into buffer + * @read_time: unused at this time + */ +struct ishtp_cl_rb { + struct list_head list; + struct ishtp_cl *cl; + struct ishtp_msg_data buffer; + unsigned long buf_idx; + unsigned long read_time; +}; + int ishtp_cl_driver_register(struct ishtp_cl_driver *driver, struct module *owner); void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver); @@ -40,4 +76,16 @@ struct device *ishtp_device(struct ishtp_cl_device *cl_device); /* Trace interface for clients */ void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); +struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); +void ishtp_cl_free(struct ishtp_cl *cl); +int ishtp_cl_link(struct ishtp_cl *cl); +void ishtp_cl_unlink(struct ishtp_cl *cl); +int ishtp_cl_disconnect(struct ishtp_cl *cl); +int ishtp_cl_connect(struct ishtp_cl *cl); +int ishtp_cl_send(struct ishtp_cl *cl, uint8_t *buf, size_t length); +int ishtp_cl_flush_queues(struct ishtp_cl *cl); +int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); +bool ishtp_cl_tx_empty(struct ishtp_cl *cl); +struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); + #endif /* _INTEL_ISH_CLIENT_IF_H_ */ -- cgit From 51cbc7079ecae545be93c137edeb7453d28b9ec9 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Mon, 18 Mar 2019 12:14:25 -0700 Subject: HID: intel-ish-hid: Add interface functions for struct ishtp_cl Instead of directly accessing members of struct ishtp_cl, create interface functions to access them. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- include/linux/intel-ish-client-if.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index 7ce172f656f8..526e3048e09f 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -87,5 +87,12 @@ int ishtp_cl_flush_queues(struct ishtp_cl *cl); int ishtp_cl_io_rb_recycle(struct ishtp_cl_rb *rb); bool ishtp_cl_tx_empty(struct ishtp_cl *cl); struct ishtp_cl_rb *ishtp_cl_rx_get_rb(struct ishtp_cl *cl); +void *ishtp_get_client_data(struct ishtp_cl *cl); +void ishtp_set_client_data(struct ishtp_cl *cl, void *data); +struct ishtp_device *ishtp_get_ishtp_device(struct ishtp_cl *cl); +void ishtp_set_tx_ring_size(struct ishtp_cl *cl, int size); +void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size); +void ishtp_set_connection_state(struct ishtp_cl *cl, int state); +void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id); #endif /* _INTEL_ISH_CLIENT_IF_H_ */ -- cgit From 5f7224cf418511b9d3c40d35b098d15f9e4e7404 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Mon, 18 Mar 2019 12:14:26 -0700 Subject: HID: intel-ish-hid: Move functions related to bus and device Move function idefinitions related to bus and device to common header file. Also create new function to get fw client id and move ish_hw_reset() from inline to exported function. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- include/linux/intel-ish-client-if.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index 526e3048e09f..e98bfbb1e07e 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -9,7 +9,9 @@ #define _INTEL_ISH_CLIENT_IF_H_ struct ishtp_cl_device; +struct ishtp_device; struct ishtp_cl; +struct ishtp_fw_client; /* Client state */ enum cl_state { @@ -95,4 +97,14 @@ void ishtp_set_rx_ring_size(struct ishtp_cl *cl, int size); void ishtp_set_connection_state(struct ishtp_cl *cl, int state); void ishtp_cl_set_fw_client_id(struct ishtp_cl *cl, int fw_client_id); +void ishtp_put_device(struct ishtp_cl_device *cl_dev); +void ishtp_get_device(struct ishtp_cl_device *cl_dev); +void ishtp_set_drvdata(struct ishtp_cl_device *cl_device, void *data); +void *ishtp_get_drvdata(struct ishtp_cl_device *cl_device); +int ishtp_register_event_cb(struct ishtp_cl_device *device, + void (*read_cb)(struct ishtp_cl_device *)); +struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev, + const guid_t *uuid); +int ishtp_get_fw_client_id(struct ishtp_fw_client *fw_client); +int ish_hw_reset(struct ishtp_device *dev); #endif /* _INTEL_ISH_CLIENT_IF_H_ */ -- cgit From 0e568a16af403263f8e421f1f10b91f9f15b52c3 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Mon, 18 Mar 2019 12:14:28 -0700 Subject: HID: intel-ish-hid: Add interface function for PCI device pointer Instead of directly accessing PCI device poitner via struct ishtp_cl, create interface function for same. This is required for DMA transfer. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jiri Kosina --- include/linux/intel-ish-client-if.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/intel-ish-client-if.h b/include/linux/intel-ish-client-if.h index e98bfbb1e07e..16255c2ca2f4 100644 --- a/include/linux/intel-ish-client-if.h +++ b/include/linux/intel-ish-client-if.h @@ -77,6 +77,8 @@ int ishtp_register_event_cb(struct ishtp_cl_device *device, struct device *ishtp_device(struct ishtp_cl_device *cl_device); /* Trace interface for clients */ void *ishtp_trace_callback(struct ishtp_cl_device *cl_device); +/* Get device pointer of PCI device for DMA acces */ +struct device *ishtp_get_pci_device(struct ishtp_cl_device *cl_device); struct ishtp_cl *ishtp_cl_allocate(struct ishtp_cl_device *cl_device); void ishtp_cl_free(struct ishtp_cl *cl); -- cgit From 58e75155009cc800005629955d3482f36a1e0eec Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 27 Mar 2019 11:18:48 +0100 Subject: HID: core: move Usage Page concatenation to Main item As seen on some USB wireless keyboards manufactured by Primax, the HID parser was using some assumptions that are not always true. In this case it's s the fact that, inside the scope of a main item, an Usage Page will always precede an Usage. The spec is not pretty clear as 6.2.2.7 states "Any usage that follows is interpreted as a Usage ID and concatenated with the Usage Page". While 6.2.2.8 states "When the parser encounters a main item it concatenates the last declared Usage Page with a Usage to form a complete usage value." Being somewhat contradictory it was decided to match Window's implementation, which follows 6.2.2.8. In summary, the patch moves the Usage Page concatenation from the local item parsing function to the main item parsing function. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Terry Junge Signed-off-by: Benjamin Tissoires --- include/linux/hid.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index f9707d1dcb58..ac0c70b4ce10 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -417,6 +417,7 @@ struct hid_global { struct hid_local { unsigned usage[HID_MAX_USAGES]; /* usage array */ + u8 usage_size[HID_MAX_USAGES]; /* usage size array */ unsigned collection_index[HID_MAX_USAGES]; /* collection index array */ unsigned usage_index; unsigned usage_minimum; -- cgit From c9121cf637331b6fc07a60708c6ca0a161e7deb5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 20 Apr 2019 13:21:56 +0200 Subject: HID: logitech-dj: add support for 27 MHz receivers Most Logitech wireless keyboard and mice using the 27 MHz are hidpp10 devices, add support to logitech-dj for their receivers. Doing so leads to 2 improvements: 1) All these devices share the same USB product-id for their receiver, making it impossible to properly map some special keys / buttons which differ from device to device. Adding support to logitech-dj to see these as hidpp10 devices allows us to get the actual device-id from the keyboard / mouse. 2) It enables battery-monitoring of these devices This patch uses a new HID group for 27Mhz devices, since the logitech-hidpp code needs to be able to differentiate them from other devices instantiated by the logitech-dj code. Signed-off-by: Hans de Goede Signed-off-by: Benjamin Tissoires --- include/linux/hid.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index f9707d1dcb58..9f161fa5cbd4 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -382,6 +382,7 @@ struct hid_item { #define HID_GROUP_WACOM 0x0101 #define HID_GROUP_LOGITECH_DJ_DEVICE 0x0102 #define HID_GROUP_STEAM 0x0103 +#define HID_GROUP_LOGITECH_27MHZ_DEVICE 0x0104 /* * HID protocol status -- cgit From d43c17ead879ba7c076dc2f5fd80cd76047c9ff4 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 3 Apr 2019 16:20:20 +0200 Subject: HID: input: make sure the wheel high resolution multiplier is set Some old mice have a tendency to not accept the high resolution multiplier. They reply with a -EPIPE which was previously ignored. Force the call to resolution multiplier to be synchronous and actually check for the answer. If this fails, consider the mouse like a normal one. Fixes: 2dc702c991e377 ("HID: input: use the Resolution Multiplier for high-resolution scrolling") Link: https://bugzilla.redhat.com/show_bug.cgi?id=1700071 Reported-and-tested-by: James Feeney Cc: stable@vger.kernel.org # v5.0+ Signed-off-by: Benjamin Tissoires --- include/linux/hid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index f9707d1dcb58..2c69340d372d 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -893,7 +893,7 @@ struct hid_field *hidinput_get_led_field(struct hid_device *hid); unsigned int hidinput_count_leds(struct hid_device *hid); __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code); void hid_output_report(struct hid_report *report, __u8 *data); -void __hid_request(struct hid_device *hid, struct hid_report *rep, int reqtype); +int __hid_request(struct hid_device *hid, struct hid_report *rep, int reqtype); u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags); struct hid_device *hid_allocate_device(void); struct hid_report *hid_register_report(struct hid_device *device, -- cgit