Skip to content

Commit

Permalink
Merge tag 'hid-for-linus-2024091602' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/hid/hid

Pull HID updates from Jiri Kosina:

 - New HID over SPI driver for Goodix devices that don't follow
   Microsoft's HID-over-SPI specification, so a separate driver is
   needed. Currently supported device is GT7986U touchscreen (Charles
   Wang)

 - support for new hardware features in Wacom driver (high-res wheel
   scrolling, touchstrings with relative motions, support for two
   touchrings) (Jason Gerecke)

 - support for customized vendor firmware loading in intel-ish driver
   (Zhang Lixu)

 - fix for theoretical race condition in i2c-hid (Dmitry Torokhov)

 - support for HIDIOCREVOKE -- evdev's EVIOCREVOKE equivalent in hidraw
   (Peter Hutterer)

 - initial hidraw selftest implementation (Benjamin Tissoires)

 - constification of device-specific report descriptors (Thomas
   Weißschuh)

 - other small assorted fixes and device ID / quirk additions

* tag 'hid-for-linus-2024091602' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (54 commits)
  hid: cp2112: Use irq_get_trigger_type() helper
  HID: i2c-hid: ensure various commands do not interfere with each other
  HID: multitouch: Add support for Thinkpad X12 Gen 2 Kbd Portfolio
  HID: wacom: Do not warn about dropped packets for first packet
  HID: wacom: Support sequence numbers smaller than 16-bit
  HID: lg: constify fixed up report descriptor
  HID: uclogic: constify fixed up report descriptor
  HID: waltop: constify fixed up report descriptor
  HID: sony: constify fixed up report descriptor
  HID: pxrc: constify fixed up report descriptor
  HID: steelseries: constify fixed up report descriptor
  HID: viewsonic: constify fixed up report descriptor
  HID: vrc2: constify fixed up report descriptor
  HID: xiaomi: constify fixed up report descriptor
  HID: maltron: constify fixed up report descriptor
  HID: keytouch: constify fixed up report descriptor
  HID: holtek-kbd: constify fixed up report descriptor
  HID: dr: constify fixed up report descriptor
  HID: bigbenff: constify fixed up report descriptor
  HID: picoLCD: Use backlight power constants
  ...
  • Loading branch information
Linus Torvalds committed Sep 19, 2024
2 parents d5e65d1 + 0aa0437 commit a65b3c3
Show file tree
Hide file tree
Showing 90 changed files with 2,150 additions and 732 deletions.
4 changes: 3 additions & 1 deletion Documentation/devicetree/bindings/input/elan,ekth6915.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ properties:
- enum:
- elan,ekth5015m
- const: elan,ekth6915
- const: elan,ekth6915
- enum:
- elan,ekth6915
- elan,ekth6a12nay

reg:
const: 0x10
Expand Down
71 changes: 71 additions & 0 deletions Documentation/devicetree/bindings/input/goodix,gt7986u.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/input/goodix,gt7986u.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: GOODIX GT7986U SPI HID Touchscreen

maintainers:
- Charles Wang <charles.goodix@gmail.com>

description: Supports the Goodix GT7986U touchscreen.
This touch controller reports data packaged according to the HID protocol,
but is incompatible with Microsoft's HID-over-SPI protocol.

allOf:
- $ref: /schemas/spi/spi-peripheral-props.yaml#

properties:
compatible:
enum:
- goodix,gt7986u

reg:
maxItems: 1

interrupts:
maxItems: 1

reset-gpios:
maxItems: 1

goodix,hid-report-addr:
$ref: /schemas/types.yaml#/definitions/uint32
description:
The register address for retrieving HID report data.
This address is related to the device firmware and may
change after a firmware update.

spi-max-frequency: true

additionalProperties: false

required:
- compatible
- reg
- interrupts
- reset-gpios
- goodix,hid-report-addr

examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/gpio/gpio.h>
spi {
#address-cells = <1>;
#size-cells = <0>;
touchscreen@0 {
compatible = "goodix,gt7986u";
reg = <0>;
interrupt-parent = <&gpio>;
interrupts = <25 IRQ_TYPE_LEVEL_LOW>;
reset-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
spi-max-frequency = <10000000>;
goodix,hid-report-addr = <0x22c8c>;
};
};
...
29 changes: 29 additions & 0 deletions Documentation/hid/intel-ish-hid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,35 @@ For more detailed information, please refer to the flow descriptions provided be
| ISHTP Driver | | ISH Bootloader |
+---------------+ +-----------------+

Vendor Custom Firmware Loading
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The firmware running inside ISH can be provided by Intel or developed by vendors using the Firmware Development Kit (FDK) provided by Intel.
Intel will upstream the Intel-built firmware to the ``linux-firmware.git`` repository, located under the path ``intel/ish/``. For the Lunar Lake platform, the Intel-built ISH firmware will be named ``ish_lnlm.bin``.
Vendors who wish to upstream their custom firmware should follow these guidelines for naming their firmware files:

- The firmware filename should use one of the following patterns:

- ``ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_NAME_CRC32}_${PRODUCT_SKU_CRC32}.bin``
- ``ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_SKU_CRC32}.bin``
- ``ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_NAME_CRC32}.bin``
- ``ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}.bin``

- ``${intel_plat_gen}`` indicates the Intel platform generation (e.g., ``lnlm`` for Lunar Lake) and must not exceed 8 characters in length.
- ``${SYS_VENDOR_CRC32}`` is the CRC32 checksum of the ``sys_vendor`` value from the DMI field ``DMI_SYS_VENDOR``.
- ``${PRODUCT_NAME_CRC32}`` is the CRC32 checksum of the ``product_name`` value from the DMI field ``DMI_PRODUCT_NAME``.
- ``${PRODUCT_SKU_CRC32}`` is the CRC32 checksum of the ``product_sku`` value from the DMI field ``DMI_PRODUCT_SKU``.

During system boot, the ISH Linux driver will attempt to load the firmware in the following order, prioritizing custom firmware with more precise matching patterns:

1. ``intel/ish/ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_NAME_CRC32}_${PRODUCT_SKU_CRC32}.bin``
2. ``intel/ish/ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_SKU_CRC32}.bin``
3. ``intel/ish/ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}_${PRODUCT_NAME_CRC32}.bin``
4. ``intel/ish/ish_${intel_plat_gen}_${SYS_VENDOR_CRC32}.bin``
5. ``intel/ish/ish_${intel_plat_gen}.bin``

The driver will load the first matching firmware and skip the rest. If no matching firmware is found, it will proceed to the next pattern in the specified order. If all searches fail, the default Intel firmware, listed last in the order above, will be loaded.

ISH Debugging
-------------

Expand Down
6 changes: 6 additions & 0 deletions drivers/hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,12 @@ config HID_VIVALDI_COMMON
option so that drivers can use common code to parse the HID
descriptors for vivaldi function row keymap.

config HID_GOODIX_SPI
tristate "Goodix GT7986U SPI HID touchscreen"
depends on SPI_MASTER
help
Support for Goodix GT7986U SPI HID touchscreen device.

config HID_GOOGLE_HAMMER
tristate "Google Hammer Keyboard"
select HID_VIVALDI_COMMON
Expand Down
1 change: 1 addition & 0 deletions drivers/hid/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ obj-$(CONFIG_HID_GEMBIRD) += hid-gembird.o
obj-$(CONFIG_HID_GFRM) += hid-gfrm.o
obj-$(CONFIG_HID_GLORIOUS) += hid-glorious.o
obj-$(CONFIG_HID_VIVALDI_COMMON) += hid-vivaldi-common.o
obj-$(CONFIG_HID_GOODIX_SPI) += hid-goodix-spi.o
obj-$(CONFIG_HID_GOOGLE_HAMMER) += hid-google-hammer.o
obj-$(CONFIG_HID_GOOGLE_STADIA_FF) += hid-google-stadiaff.o
obj-$(CONFIG_HID_VIVALDI) += hid-vivaldi.o
Expand Down
2 changes: 0 additions & 2 deletions drivers/hid/amd-sfh-hid/amd_sfh_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ struct amdtp_hid_data {
};

/* Interface functions between HID LL driver and AMD SFH client */
void hid_amdtp_set_feature(struct hid_device *hid, char *buf, u32 len, int report_id);
void hid_amdtp_get_report(struct hid_device *hid, int report_id, int report_type);
int amdtp_hid_probe(u32 cur_hid_dev, struct amdtp_cl_data *cli_data);
void amdtp_hid_remove(struct amdtp_cl_data *cli_data);
int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type);
Expand Down
4 changes: 2 additions & 2 deletions drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ static void amd_sfh_set_ops(struct amd_mp2_dev *mp2)

sfh_interface_init(mp2);
mp2_ops = mp2->mp2_ops;
mp2_ops->clear_intr = amd_sfh_clear_intr_v2,
mp2_ops->init_intr = amd_sfh_irq_init_v2,
mp2_ops->clear_intr = amd_sfh_clear_intr_v2;
mp2_ops->init_intr = amd_sfh_irq_init_v2;
mp2_ops->suspend = amd_sfh_suspend;
mp2_ops->resume = amd_sfh_resume;
mp2_ops->remove = amd_mp2_pci_remove;
Expand Down
6 changes: 2 additions & 4 deletions drivers/hid/bpf/hid_bpf_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int dispatch_hid_bpf_output_report(struct hid_device *hdev,
}
EXPORT_SYMBOL_GPL(dispatch_hid_bpf_output_report);

u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size)
u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, const u8 *rdesc, unsigned int *size)
{
int ret;
struct hid_bpf_ctx_kern ctx_kern = {
Expand Down Expand Up @@ -179,9 +179,7 @@ u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *s
*size = ret;
}

rdesc = krealloc(ctx_kern.data, *size, GFP_KERNEL);

return rdesc;
return krealloc(ctx_kern.data, *size, GFP_KERNEL);

ignore_bpf:
kfree(ctx_kern.data);
Expand Down
2 changes: 1 addition & 1 deletion drivers/hid/hid-apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ static void apple_battery_timer_tick(struct timer_list *t)
* MacBook JIS keyboard has wrong logical maximum
* Magic Keyboard JIS has wrong logical maximum
*/
static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
static const __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
struct apple_sc *asc = hid_get_drvdata(hdev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/hid/hid-asus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ static const __u8 asus_g752_fixed_rdesc[] = {
0x2A, 0xFF, 0x00, /* Usage Maximum (0xFF) */
};

static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
static const __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/hid/hid-aureal.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "hid-ids.h"

static __u8 *aureal_report_fixup(struct hid_device *hdev, __u8 *rdesc,
static const __u8 *aureal_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
if (*rsize >= 54 && rdesc[52] == 0x25 && rdesc[53] == 0x01) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/hid/hid-bigbenff.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
* - map previously unused analog trigger data to Z/RZ
* - simplify feature and output descriptor
*/
static __u8 pid0902_rdesc_fixed[] = {
static const __u8 pid0902_rdesc_fixed[] = {
0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
0x09, 0x05, /* Usage (Game Pad) */
0xA1, 0x01, /* Collection (Application) */
Expand Down Expand Up @@ -464,12 +464,12 @@ static int bigben_probe(struct hid_device *hid,
return error;
}

static __u8 *bigben_report_fixup(struct hid_device *hid, __u8 *rdesc,
static const __u8 *bigben_report_fixup(struct hid_device *hid, __u8 *rdesc,
unsigned int *rsize)
{
if (*rsize == PID0902_RDESC_ORIG_SIZE) {
rdesc = pid0902_rdesc_fixed;
*rsize = sizeof(pid0902_rdesc_fixed);
return pid0902_rdesc_fixed;
} else
hid_warn(hid, "unexpected rdesc, please submit for review\n");
return rdesc;
Expand Down
2 changes: 1 addition & 1 deletion drivers/hid/hid-cherry.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Cherry Cymotion keyboard have an invalid HID report descriptor,
* that needs fixing before we can parse it.
*/
static __u8 *ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
static const __u8 *ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
if (*rsize >= 18 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/hid/hid-chicony.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
return 1;
}

static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
static const __u8 *ch_switch12_report_fixup(struct hid_device *hdev,
__u8 *rdesc, unsigned int *rsize)
{
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);

Expand Down
6 changes: 3 additions & 3 deletions drivers/hid/hid-cmedia.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MODULE_LICENSE("GPL");
/* Fixed report descriptor of HS-100B audio chip
* Bit 4 is an abolute Microphone mute usage instead of being unassigned.
*/
static __u8 hs100b_rdesc_fixed[] = {
static const __u8 hs100b_rdesc_fixed[] = {
0x05, 0x0C, /* Usage Page (Consumer), */
0x09, 0x01, /* Usage (Consumer Control), */
0xA1, 0x01, /* Collection (Application), */
Expand Down Expand Up @@ -199,13 +199,13 @@ static struct hid_driver cmhid_driver = {
.input_mapping = cmhid_input_mapping,
};

static __u8 *cmhid_hs100b_report_fixup(struct hid_device *hid, __u8 *rdesc,
static const __u8 *cmhid_hs100b_report_fixup(struct hid_device *hid, __u8 *rdesc,
unsigned int *rsize)
{
if (*rsize == HS100B_RDESC_ORIG_SIZE) {
hid_info(hid, "Fixing CMedia HS-100B report descriptor\n");
rdesc = hs100b_rdesc_fixed;
*rsize = sizeof(hs100b_rdesc_fixed);
return hs100b_rdesc_fixed;
}
return rdesc;
}
Expand Down
39 changes: 32 additions & 7 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static void hid_device_release(struct device *dev)
* items, though they are not used yet.
*/

static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
static const u8 *fetch_item(const __u8 *start, const __u8 *end, struct hid_item *item)
{
u8 b;

Expand Down Expand Up @@ -880,8 +880,8 @@ static int hid_scan_report(struct hid_device *hid)
{
struct hid_parser *parser;
struct hid_item item;
__u8 *start = hid->dev_rdesc;
__u8 *end = start + hid->dev_rsize;
const __u8 *start = hid->dev_rdesc;
const __u8 *end = start + hid->dev_rsize;
static int (*dispatch_type[])(struct hid_parser *parser,
struct hid_item *item) = {
hid_scan_main,
Expand Down Expand Up @@ -946,7 +946,7 @@ static int hid_scan_report(struct hid_device *hid)
* Allocate the device report as read by the bus driver. This function should
* only be called from parse() in ll drivers.
*/
int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
int hid_parse_report(struct hid_device *hid, const __u8 *start, unsigned size)
{
hid->dev_rdesc = kmemdup(start, size, GFP_KERNEL);
if (!hid->dev_rdesc)
Expand Down Expand Up @@ -1204,10 +1204,10 @@ int hid_open_report(struct hid_device *device)
struct hid_parser *parser;
struct hid_item item;
unsigned int size;
__u8 *start;
const __u8 *start;
__u8 *buf;
__u8 *end;
__u8 *next;
const __u8 *end;
const __u8 *next;
int ret;
int i;
static int (*dispatch_type[])(struct hid_parser *parser,
Expand Down Expand Up @@ -1912,6 +1912,31 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
}
EXPORT_SYMBOL_GPL(hid_set_field);

struct hid_field *hid_find_field(struct hid_device *hdev, unsigned int report_type,
unsigned int application, unsigned int usage)
{
struct list_head *report_list = &hdev->report_enum[report_type].report_list;
struct hid_report *report;
int i, j;

list_for_each_entry(report, report_list, list) {
if (report->application != application)
continue;

for (i = 0; i < report->maxfield; i++) {
struct hid_field *field = report->field[i];

for (j = 0; j < field->maxusage; j++) {
if (field->usage[j].hid == usage)
return field;
}
}
}

return NULL;
}
EXPORT_SYMBOL_GPL(hid_find_field);

static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
const u8 *data)
{
Expand Down
4 changes: 2 additions & 2 deletions drivers/hid/hid-corsair.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ static int corsair_input_mapping(struct hid_device *dev,
* - USB ID 1b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse
*/

static __u8 *corsair_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
static const __u8 *corsair_mouse_report_fixup(struct hid_device *hdev,
__u8 *rdesc, unsigned int *rsize)
{
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);

Expand Down
4 changes: 2 additions & 2 deletions drivers/hid/hid-cougar.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ static void cougar_fix_g6_mapping(void)
/*
* Constant-friendly rdesc fixup for mouse interface
*/
static __u8 *cougar_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
static const __u8 *cougar_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
if (*rsize >= 117 && rdesc[2] == 0x09 && rdesc[3] == 0x02 &&
(rdesc[115] | rdesc[116] << 8) >= HID_MAX_USAGES) {
Expand Down
7 changes: 2 additions & 5 deletions drivers/hid/hid-cp2112.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,6 @@ static void cp2112_gpio_poll_callback(struct work_struct *work)
{
struct cp2112_device *dev = container_of(work, struct cp2112_device,
gpio_poll_worker.work);
struct irq_data *d;
u8 gpio_mask;
u32 irq_type;
int irq, virq, ret;
Expand All @@ -1111,12 +1110,10 @@ static void cp2112_gpio_poll_callback(struct work_struct *work)
if (!irq)
continue;

d = irq_get_irq_data(irq);
if (!d)
irq_type = irq_get_trigger_type(irq);
if (!irq_type)
continue;

irq_type = irqd_get_trigger_type(d);

if (gpio_mask & BIT(virq)) {
/* Level High */

Expand Down
Loading

0 comments on commit a65b3c3

Please sign in to comment.