From patchwork Sun May 29 10:02:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 12864144 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B9A6C433F5 for ; Sun, 29 May 2022 10:12:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbiE2KMH (ORCPT ); Sun, 29 May 2022 06:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbiE2KMG (ORCPT ); Sun, 29 May 2022 06:12:06 -0400 X-Greylist: delayed 533 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 29 May 2022 03:12:02 PDT Received: from mail.boiledscript.com (unknown [192.151.158.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0938425C47; Sun, 29 May 2022 03:12:02 -0700 (PDT) Date: Sun, 29 May 2022 18:02:30 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=dkim; t=1653818579; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jjq1DAlPmCj+12oFmUYPRHLaYrupTtjphtRxoBdBCnw=; b=sKl9nspg5/4kfLQj7l2aFAAkdPdc7wlvjLRpsOr0mfO1F5G0hSdMUvZdpz0uxYNR7dYRcO /Sb0OldzsAHdEwZLD8amFjSjEph4L6PPE5E1lz7rU6bnN/Ywv1zwyOIqBC2Lu7Qq9reeEv 54M/bSEqRngT4A7MtoUDehlPY5vgEFckWSJ9VTckmOp539a4mVtVCc7J9U9PEC+eFUy5m4 fAwYLY5Gbn4ib2epSWk3CC7EUpDs6uJ+vnxdNLyEP9mpNU+FTxF0Bm2aWFdGIBjGLEcNG8 CTmBbuEG57CjsSBVP+XXP15vKNlbSl95xygJ7R2fZdipA8jZBotbQ2T7H4J5hQ== From: Hilton Chain To: Jiri Kosina Cc: Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: apple: Reset quirks when Fn key is not found Message-ID: <20220529180230.17e9a0f9@ultrarare.space> MIME-Version: 1.0 Authentication-Results: mail.boiledscript.com; auth=pass smtp.mailfrom=hako@ultrarare.space X-Spamd-Bar: / Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From 6813a0a2c0f1a965f650abba3e1e4a8e79b40c26 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Sun, 29 May 2022 16:25:57 +0800 Subject: [PATCH] HID: apple: Reset quirks when Fn key is not found Commit a5fe7864d8ad ("HID: apple: Do not reset quirks when the Fn key is not found") re-involves the fnmode issue fixed in commit a5d81646fa29 ("HID: apple: Disable Fn-key key-re-mapping on clone keyboards"), as linked below. To make things work again, this commit reverts a5fe7864d8ad ("HID: apple: Do not reset quirks when the Fn key is not found") and the recent workaround fa33382c7f74 ("HID: apple: Properly handle function keys on Keychron keyboards") Link: https://lore.kernel.org/linux-input/f82dd7a1-a5c6-b651-846c-29f6df9436af@redhat.com/ Fixes: a5fe7864d8ad ("HID: apple: Do not reset quirks when the Fn key is not found") Signed-off-by: Hilton Chain Signed-off-by: Hilton Chain --- drivers/hid/hid-apple.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) base-commit: fdaf9a5840acaab18694a19e0eb0aa51162eeeed diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 42a568902f49..3b666dcb63f0 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "hid-ids.h" @@ -36,17 +35,16 @@ #define APPLE_NUMLOCK_EMULATION BIT(8) #define APPLE_RDESC_BATTERY BIT(9) #define APPLE_BACKLIGHT_CTL BIT(10) -#define APPLE_IS_KEYCHRON BIT(11) #define APPLE_FLAG_FKEY 0x01 #define HID_COUNTRY_INTERNATIONAL_ISO 13 #define APPLE_BATTERY_TIMEOUT_MS 60000 -static unsigned int fnmode = 3; +static unsigned int fnmode = 1; module_param(fnmode, uint, 0644); MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, " - "1 = fkeyslast, 2 = fkeysfirst, [3] = auto)"); + "[1] = fkeyslast, 2 = fkeysfirst)"); static int iso_layout = -1; module_param(iso_layout, int, 0644); @@ -351,7 +349,6 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, const struct apple_key_translation *trans, *table; bool do_translate; u16 code = 0; - unsigned int real_fnmode; u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN); @@ -362,13 +359,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, return 1; } - if (fnmode == 3) { - real_fnmode = (asc->quirks & APPLE_IS_KEYCHRON) ? 2 : 1; - } else { - real_fnmode = fnmode; - } - - if (real_fnmode) { + if (fnmode) { if (hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI || hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO || hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS || @@ -415,7 +406,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, if (!code) { if (trans->flags & APPLE_FLAG_FKEY) { - switch (real_fnmode) { + switch (fnmode) { case 1: do_translate = !asc->fn_on; break; @@ -664,14 +655,10 @@ static int apple_input_configured(struct hid_device *hdev, { struct apple_sc *asc = hid_get_drvdata(hdev); + /* Handling some non-Apple keyboards which use Apple's vendor ID */ if ((asc->quirks & APPLE_HAS_FN) && !asc->fn_found) { hid_info(hdev, "Fn key not found (Apple Wireless Keyboard clone?), disabling Fn key handling\n"); - asc->quirks &= ~APPLE_HAS_FN; - } - - if (strncmp(hdev->name, "Keychron", 8) == 0) { - hid_info(hdev, "Keychron keyboard detected; function keys will default to fnmode=2 behavior\n"); - asc->quirks |= APPLE_IS_KEYCHRON; + asc->quirks = 0; } return 0;