public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Mizuho Mori <morimolymoly@gmail.com>,
	Jiri Kosina <jkosina@suse.cz>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.4 03/16] HID: apple: Fix logical maximum and usage maximum of Magic Keyboard JIS
Date: Thu, 14 Oct 2021 16:54:06 +0200	[thread overview]
Message-ID: <20211014145207.421131864@linuxfoundation.org> (raw)
In-Reply-To: <20211014145207.314256898@linuxfoundation.org>

From: Mizuho Mori <morimolymoly@gmail.com>

[ Upstream commit 67fd71ba16a37c663d139f5ba5296f344d80d072 ]

Apple Magic Keyboard(JIS)'s Logical Maximum and Usage Maximum are wrong.

Below is a report descriptor.

0x05, 0x01,         /*  Usage Page (Desktop),                           */
0x09, 0x06,         /*  Usage (Keyboard),                               */
0xA1, 0x01,         /*  Collection (Application),                       */
0x85, 0x01,         /*      Report ID (1),                              */
0x05, 0x07,         /*      Usage Page (Keyboard),                      */
0x15, 0x00,         /*      Logical Minimum (0),                        */
0x25, 0x01,         /*      Logical Maximum (1),                        */
0x19, 0xE0,         /*      Usage Minimum (KB Leftcontrol),             */
0x29, 0xE7,         /*      Usage Maximum (KB Right GUI),               */
0x75, 0x01,         /*      Report Size (1),                            */
0x95, 0x08,         /*      Report Count (8),                           */
0x81, 0x02,         /*      Input (Variable),                           */
0x95, 0x05,         /*      Report Count (5),                           */
0x75, 0x01,         /*      Report Size (1),                            */
0x05, 0x08,         /*      Usage Page (LED),                           */
0x19, 0x01,         /*      Usage Minimum (01h),                        */
0x29, 0x05,         /*      Usage Maximum (05h),                        */
0x91, 0x02,         /*      Output (Variable),                          */
0x95, 0x01,         /*      Report Count (1),                           */
0x75, 0x03,         /*      Report Size (3),                            */
0x91, 0x03,         /*      Output (Constant, Variable),                */
0x95, 0x08,         /*      Report Count (8),                           */
0x75, 0x01,         /*      Report Size (1),                            */
0x15, 0x00,         /*      Logical Minimum (0),                        */
0x25, 0x01,         /*      Logical Maximum (1),                        */

here is a report descriptor which is parsed one in kernel.
see sys/kernel/debug/hid/<dev>/rdesc

05 01 09 06 a1 01 85 01 05 07
15 00 25 01 19 e0 29 e7 75 01
95 08 81 02 95 05 75 01 05 08
19 01 29 05 91 02 95 01 75 03
91 03 95 08 75 01 15 00 25 01
06 00 ff 09 03 81 03 95 06 75
08 15 00 25 [65] 05 07 19 00 29
[65] 81 00 95 01 75 01 15 00 25
01 05 0c 09 b8 81 02 95 01 75
01 06 01 ff 09 03 81 02 95 01
75 06 81 03 06 02 ff 09 55 85
55 15 00 26 ff 00 75 08 95 40
b1 a2 c0 06 00 ff 09 14 a1 01
85 90 05 84 75 01 95 03 15 00
25 01 09 61 05 85 09 44 09 46
81 02 95 05 81 01 75 08 95 01
15 00 26 ff 00 09 65 81 02 c0
00

Position 64(Logical Maximum) and 70(Usage Maximum) are 101.
Both should be 0xE7 to support JIS specific keys(ろ, Eisu, Kana, |) support.
position 117 is also 101 but not related(it is Usage 65h).

There are no difference of product id between JIS and ANSI.
They are same 0x0267.

Signed-off-by: Mizuho Mori <morimolymoly@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-apple.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 6909c045fece..07df64daf7da 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -301,12 +301,19 @@ static int apple_event(struct hid_device *hdev, struct hid_field *field,
 
 /*
  * 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,
 		unsigned int *rsize)
 {
 	struct apple_sc *asc = hid_get_drvdata(hdev);
 
+	if(*rsize >=71 && rdesc[70] == 0x65 && rdesc[64] == 0x65) {
+		hid_info(hdev,
+			 "fixing up Magic Keyboard JIS report descriptor\n");
+		rdesc[64] = rdesc[70] = 0xe7;
+	}
+
 	if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 &&
 			rdesc[53] == 0x65 && rdesc[59] == 0x65) {
 		hid_info(hdev,
-- 
2.33.0




  parent reply	other threads:[~2021-10-14 15:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 14:54 [PATCH 5.4 00/16] 5.4.154-rc1 review Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 01/16] net: phy: bcm7xxx: Fixed indirect MMD operations Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 02/16] ext4: correct the error path of ext4_write_inline_data_end() Greg Kroah-Hartman
2021-10-14 14:54 ` Greg Kroah-Hartman [this message]
2021-10-14 14:54 ` [PATCH 5.4 04/16] netfilter: ip6_tables: zero-initialize fragment offset Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 05/16] HID: wacom: Add new Intuos BT (CTL-4100WL/CTL-6100WL) device IDs Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 06/16] netfilter: nf_nat_masquerade: make async masq_inet6_event handling generic Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 07/16] netfilter: nf_nat_masquerade: defer conntrack walk to work queue Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 08/16] mac80211: Drop frames from invalid MAC address in ad-hoc mode Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 09/16] m68k: Handle arrivals of multiple signals correctly Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 10/16] net: prevent user from passing illegal stab size Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 11/16] mac80211: check return value of rhashtable_init Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 12/16] net: sun: SUNVNET_COMMON should depend on INET Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 13/16] drm/amdgpu: fix gart.bo pin_count leak Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 14/16] scsi: ses: Fix unsigned comparison with less than zero Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 15/16] scsi: virtio_scsi: Fix spelling mistake "Unsupport" -> "Unsupported" Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.4 16/16] sched: Always inline is_percpu_thread() Greg Kroah-Hartman
2021-10-14 21:45 ` [PATCH 5.4 00/16] 5.4.154-rc1 review Florian Fainelli
2021-10-14 22:39 ` Shuah Khan
2021-10-15  7:22 ` Samuel Zou
2021-10-15 14:31 ` Sudip Mukherjee
2021-10-15 16:36 ` Daniel Díaz
2021-10-15 22:06 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211014145207.421131864@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=morimolymoly@gmail.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox