Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4832538pxb; Thu, 14 Oct 2021 12:54:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZoLfxGOgVqRjzGf7u/g16MiJuowPHwlGg4zzceKCK5+Pkmx4zdvPjmr2D7ba3XNVSX4Gk X-Received: by 2002:a17:902:da8a:b0:13f:1a39:e02f with SMTP id j10-20020a170902da8a00b0013f1a39e02fmr7013615plx.82.1634241277867; Thu, 14 Oct 2021 12:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634241277; cv=none; d=google.com; s=arc-20160816; b=n3Xk1LnyJklN+Az/NHfUUXZ1oP1SNSz1js5YCD8VZroGlKmHm5UaPk1Qq48Q5+9HaS yyB0Auq3/XuRZlzQTrKf5OHVUDCJuwkIvs6o3yfPyYA7RCE+bhUfdy3b7LdL3gHT2Ppp Kb56u5SmfbyhmYIlZqcNMzNKsvTOA6Jm3G+jU7jfJ/zZhaopcPuJruSn7jZahmQx/K/S kNqpfXVQTWoisygszXnORflopGL56APff8lfd5RFMFnuaasasgP9HgSLc9Iz1JkyUSlU 3kyaj7pttEOHntb2FS/NrUeuxy5a8rZ5bYiFYHTkH4NruFeFI/3EmeZIvA0Rm2rnudBD 8ytg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bCzrU5edClYT/wqbFNFH5cFlT0oQDoCwA7kXgDewvAQ=; b=mGja7A1L8J5A7exsXw6nSqLlyKYkzC2R/qFUCix/d1rt3de/O3iy2LqpfE1ZE2sFvR 9MYm+T2zTAqKZrw4/8++0mDi18W1nBwzWBzUSdGkuz7dUlN9yQLrbGFbaNqjspD5B3fU n8CCh5FoJTrcZG1Vt/5o00ownGT/KT3F86WnEcz+iozNcJ0o85XkSau2sfkq750O6mBl h4XZCBHWV2FdboLLLaDz/d8lfRj4CnJqugcoFyNUDzi+OmTV5uQTZ6AMR1mo/pM8FhWL Hkf2smUtTAFdhjJzezIsZy7VtEE4lqfZfh+vSNj+S9DR0bEqg8+vL9RpAUP/CKfCqw+Z msxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TLe3+Epn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a22si5414645pgw.619.2021.10.14.12.54.22; Thu, 14 Oct 2021 12:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TLe3+Epn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233084AbhJNPHl (ORCPT + 99 others); Thu, 14 Oct 2021 11:07:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:51564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233102AbhJNPFu (ORCPT ); Thu, 14 Oct 2021 11:05:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B5C6E6124D; Thu, 14 Oct 2021 15:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634223685; bh=YTbHAH8Ua0A1AFT7YLouuXcef6ol2k5GX5NuXWheHAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLe3+EpnQjLHZuheCnGOWa4mXSyJVAszl5NPrWTMct6fZL9Z0y1pkd0rMAEMK1CNI CUd1wCXBR2nQ2HHpJLuBgYKSHkhKAaolGyZ2mNuaL6M7rrBAioQxhkvM0m9oZa/kbf GA9YyM/H72nX5QF19c44mL5KJ+Ki77Pd6VAiKVDA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mizuho Mori , Jiri Kosina , Sasha Levin Subject: [PATCH 5.14 07/30] HID: apple: Fix logical maximum and usage maximum of Magic Keyboard JIS Date: Thu, 14 Oct 2021 16:54:12 +0200 Message-Id: <20211014145209.760921893@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014145209.520017940@linuxfoundation.org> References: <20211014145209.520017940@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mizuho Mori [ 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//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 Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- 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 dc6bd4299c54..87edcd4ce07c 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -322,12 +322,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