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 4.14 25/33] HID: apple: Fix logical maximum and usage maximum of Magic Keyboard JIS
Date: Thu, 14 Oct 2021 16:53:57 +0200	[thread overview]
Message-ID: <20211014145209.641180923@linuxfoundation.org> (raw)
In-Reply-To: <20211014145208.775270267@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 b58ab769aa7b..4e3dd3f55a96 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -304,12 +304,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 14:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 14:53 [PATCH 4.14 00/33] 4.14.251-rc1 review Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 01/33] Partially revert "usb: Kconfig: using select for USB_COMMON dependency" Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 02/33] USB: cdc-acm: fix racy tty buffer accesses Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 03/33] USB: cdc-acm: fix break reporting Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 04/33] ovl: fix missing negative dentry check in ovl_rename() Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 05/33] nfsd4: Handle the NFSv4 READDIR dircount hint being zero Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 06/33] xen/balloon: fix cancelled balloon action Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 07/33] ARM: dts: omap3430-sdp: Fix NAND device node Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 08/33] ARM: dts: qcom: apq8064: use compatible which contains chipid Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 09/33] bpf: add also cbpf long jump test cases with heavy expansion Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 10/33] bpf, mips: Validate conditional branch offsets Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 11/33] xtensa: call irqchip_init only when CONFIG_USE_OF is selected Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 12/33] bpf: Fix integer overflow in prealloc_elems_and_freelist() Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 13/33] phy: mdio: fix memory leak Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 14/33] net_sched: fix NULL deref in fifo_set_limit() Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 15/33] powerpc/fsl/dts: Fix phy-connection-type for fm1mac3 Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 16/33] ptp_pch: Load module automatically if ID matches Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 17/33] ARM: imx6: disable the GIC CPU interface before calling stby-poweroff sequence Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 18/33] net: bridge: use nla_total_size_64bit() in br_get_linkxstats_size() Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 19/33] netlink: annotate data races around nlk->bound Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 20/33] drm/nouveau/debugfs: fix file release memory leak Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 21/33] rtnetlink: fix if_nlmsg_stats_size() under estimation Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 22/33] i40e: fix endless loop under rtnl Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 23/33] i2c: acpi: fix resource leak in reconfiguration device addition Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 24/33] net: phy: bcm7xxx: Fixed indirect MMD operations Greg Kroah-Hartman
2021-10-14 14:53 ` Greg Kroah-Hartman [this message]
2021-10-14 14:53 ` [PATCH 4.14 26/33] netfilter: ip6_tables: zero-initialize fragment offset Greg Kroah-Hartman
2021-10-14 14:53 ` [PATCH 4.14 27/33] mac80211: Drop frames from invalid MAC address in ad-hoc mode Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 4.14 28/33] m68k: Handle arrivals of multiple signals correctly Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 4.14 29/33] net: sun: SUNVNET_COMMON should depend on INET Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 4.14 30/33] scsi: ses: Fix unsigned comparison with less than zero Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 4.14 31/33] scsi: virtio_scsi: Fix spelling mistake "Unsupport" -> "Unsupported" Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 4.14 32/33] perf/x86: Reset destroy callback on event init failure Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 4.14 33/33] sched: Always inline is_percpu_thread() Greg Kroah-Hartman
2021-10-15  7:21 ` [PATCH 4.14 00/33] 4.14.251-rc1 review Samuel Zou
2021-10-15 17:49 ` Daniel Díaz
2021-10-15 17:57   ` Daniel Díaz
2021-10-15 22:28 ` 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=20211014145209.641180923@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