Skip to content

Commit a45f158

Browse files
lotheacJiri Kosina
authored andcommitted
HID: lenovo: fixup Lenovo Yoga Slim 7x Keyboard rdesc
The keyboard of this device has the following in its report description for Usage (Keyboard) in Collection (Application): # 0x15, 0x00, // Logical Minimum (0) 52 # 0x25, 0x65, // Logical Maximum (101) 54 # 0x05, 0x07, // Usage Page (Keyboard) 56 # 0x19, 0x00, // Usage Minimum (0) 58 # 0x29, 0xdd, // Usage Maximum (221) 60 # 0x81, 0x00, // Input (Data,Arr,Abs) 62 Since the Usage Min/Max range exceeds the Logical Min/Max range, keypresses outside the Logical range are not recognized. This includes, for example, the Japanese language keyboard variant's keys for |, _ and \. Fixup the report description to make the Logical range match the Usage range, fixing the interpretation of keypresses above 101 on this device. Signed-off-by: Lauri Tirkkonen <lauri@hacktheplanet.fi> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent beab067 commit a45f158

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@
718718
#define USB_DEVICE_ID_ITE_LENOVO_YOGA2 0x8350
719719
#define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720 0x837a
720720
#define USB_DEVICE_ID_ITE_LENOVO_YOGA900 0x8396
721+
#define I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_KEYBOARD 0x8987
721722
#define USB_DEVICE_ID_ITE8595 0x8595
722723
#define USB_DEVICE_ID_ITE_MEDION_E1239T 0xce50
723724

drivers/hid/hid-lenovo.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ static const __u8 lenovo_tpIIbtkbd_need_fixup_collection[] = {
148148
0x81, 0x01, /* Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) */
149149
};
150150

151+
static const __u8 lenovo_yoga7x_kbd_need_fixup_collection[] = {
152+
0x15, 0x00, // Logical Minimum (0)
153+
0x25, 0x65, // Logical Maximum (101)
154+
0x05, 0x07, // Usage Page (Keyboard)
155+
0x19, 0x00, // Usage Minimum (0)
156+
0x29, 0xDD, // Usage Maximum (221)
157+
};
158+
151159
static const __u8 *lenovo_report_fixup(struct hid_device *hdev, __u8 *rdesc,
152160
unsigned int *rsize)
153161
{
@@ -177,6 +185,13 @@ static const __u8 *lenovo_report_fixup(struct hid_device *hdev, __u8 *rdesc,
177185
rdesc[260] = 0x01; /* report count (2) = 0x01 */
178186
}
179187
break;
188+
case I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_KEYBOARD:
189+
if (*rsize == 176 &&
190+
memcmp(&rdesc[52], lenovo_yoga7x_kbd_need_fixup_collection,
191+
sizeof(lenovo_yoga7x_kbd_need_fixup_collection)) == 0) {
192+
rdesc[55] = rdesc[61]; // logical maximum = usage maximum
193+
}
194+
break;
180195
}
181196
return rdesc;
182197
}
@@ -1538,6 +1553,8 @@ static const struct hid_device_id lenovo_devices[] = {
15381553
USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X12_TAB) },
15391554
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
15401555
USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X12_TAB2) },
1556+
{ HID_DEVICE(BUS_I2C, HID_GROUP_GENERIC,
1557+
USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_KEYBOARD) },
15411558
{ }
15421559
};
15431560

0 commit comments

Comments
 (0)