From patchwork Mon Jan 24 15:08:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 12722292 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 2A756C433F5 for ; Mon, 24 Jan 2022 15:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238895AbiAXPIf (ORCPT ); Mon, 24 Jan 2022 10:08:35 -0500 Received: from mail-ma1ind01olkn0188.outbound.protection.outlook.com ([104.47.100.188]:59273 "EHLO IND01-MA1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235650AbiAXPIc (ORCPT ); Mon, 24 Jan 2022 10:08:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RwRn2RXKCdXkLUiV5+GesUCAloxWqgKloufF2Yi6CiGpLYYnTmA1g1i+TaI+VszSVBzPcE/5/SLv/03aS2n3eeis4e5esbImbsnhf/rBtERTfC44aK70v4OuOZXSRpbppGlqlvRmQzgZg6EmbOC34Q+VroQek8BXL87KMJKh4O5wE95JVG4gg0RZF0pMBKQMDee/5Ffz1tk+OsbjyNBEKQCLLfLlQ3nX9pVcO5Xv9uTlCHAUQukyt3bpCUL6hxrTclO/96TzM2BJH8hoapxW/Uda2H7RF1ESGQkWYH8/WQpsXtDm3TttWiGaj41hmyYecdTVBL1W7vpLL2Gf5b6fnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v2xEJg5lAvRAf9MnaHNNG/43w0bTMk7LDhCTq6RGs0M=; b=RqZYvTOZ8xlHSwEHyRIee+fsZftb9i/5Af/iAUw47h4YpMeiyenHQWne130kLANapFckZxXsxkgI9rjdb6kYrxHirhyAf36N7wxpRdxYFYlYTSds0HkmIXriw7f/XrJqYMXgg/U8JBaJk+baNUNenhF+OSsM+ei5uiTS7uXeWAuDEoYjDw4WWccKeGYOJrwMP9SEVafvZeEmVuhA2IxlWgwR0ikrn0zrfpQV0c0Il5nipnad7jP8yuK+3QOaaVmdkuyW8kUbeAK3CmXhmlYF12RpSI0WPIsXePDNKuGIu2RJ3oVbg/bHQohA3+ue1BCFBZ1mMXWeJqAc7U77K0kS7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v2xEJg5lAvRAf9MnaHNNG/43w0bTMk7LDhCTq6RGs0M=; b=PuQqZU4wC6DfVB8tnZXesniVud3SctFU+1ejIpbg2ecsufclJqt1xSRsKF1tGag6kMdQO8CZaMEifFBerGElcjpH7SG79AM5/ldXKQHnOtpnod/S5ujv0rIcC5YbvOJh+cz0ZG63ppet2ztJsK7GdmYL+7CUIpCv4KRxCowWlUNIOhdZa2BQtPIJ/5vj/7fyCAVi07Syqgzi8QTF2CVC+r7eadkOXkUrBZ+44uPxdmuOgAIYSjv8GH1HcqDWsXIeIi86MZUhL4GjMSRmQa8TG849GeoABvgFaivCeJ2ZTU8MeQwHMduezt9uPUfZvd2AWD2aQjXt5e+tLunOrTntGA== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by BM1PR01MB3937.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:6b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Mon, 24 Jan 2022 15:08:24 +0000 Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055]) by PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055%6]) with mapi id 15.20.4909.017; Mon, 24 Jan 2022 15:08:24 +0000 From: Aditya Garg To: "jkosina@suse.cz" , "jikos@kernel.org" , "alexhenrie24@gmail.com" , "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" , Linux Kernel Mailing List CC: "paul@mrarm.io" , Aun-Ali Zaidi , Orlando Chamberlain Subject: [PATCH v2 1/3] HID: apple: Add support for keyboard backlight on certain T2 Macs. Thread-Topic: [PATCH v2 1/3] HID: apple: Add support for keyboard backlight on certain T2 Macs. Thread-Index: AQHYETQ7OrzbolVjskCI2e3S4xhz6Q== Date: Mon, 24 Jan 2022 15:08:24 +0000 Message-ID: <67E7EA8B-CF21-4794-B7B4-96873EE70EF6@live.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [J3Hm8srR8x8QQyKpgj+K4dR7F9Hg9Wb2eiIDBHINiHtKeXIOo12pNYcFxzYnPZX0] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e35474c6-d514-438e-5883-08d9df4b5e3a x-ms-traffictypediagnostic: BM1PR01MB3937:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MjjY3yLYCvembAekc89PUz5aND1+CShOodtf2F9TmIa5Xs6174pAuY2b95Q+5OU21LIr2mMCxsQS3PujLlOw+PK9JMgLhlgu92tKkUtYen0tY61wpUT5v4TU65CfmFWLq/5qFGott+3B5NMmOgpYHQvA2x/pTRepogURWN0gMA8h1PYbfSjp19Lbowdk3/6OD465k5b5VRPLXjg5g27TxXMBbmO0Hus8EAKRiewfra6rpn9w2gG0KTBNU6n/L6fO/VLSeQC41H6F4Gt/SJqpXAti46rAgjQpqde0qoGOPpSYfPNJfZE66xWjgGq9cKaxuJ5sbstReLixh9TzDRmrJrWE7wAmOnG2MkaD7z0sjhlghMx3b9nqY9yvbtS56YCS/pn/DntltEWSInyEg6fojN6mW5N5HjnvfpNGcW2FX14TTn7iajTS7qfMr+KbV/nB6HL7oKYAgziGeFDfhjKc4w1fFITKRyY0691NzwuCcUG+kff2Og8GWCzvcEePQKJbJWhdDo0kcWzworvN/rKwJSfYmMQ6beQAaVz+u+2wvZfS1IxI64qxvZrxb4SA9LWA/f/hqlq9fPiM/tXEnoC9qw== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: Fj4ikm80S6evuUyAHNu+AnyT5KNJLuGdgTuz3Pjif2XibeCQd8QP54c8rWRaI06SFh5AlPw4JYKuxS/hB3n08SPiFSrS+FljOrLsoFnR6mOUfAIXSzFQEhHvUY7cXCY+GU0EEZiEfSlTMxMXWkqmmxaif8+fkIqhzyL4FWViwaovLjsL2PtsLr96uPw/or/4g2/5PfgofDQYWdL1ZNL5pBFXxJFPqNSMhgdnqOhoAC5hXlvpiGm+N/VvcCWoE5ZJnwUrktENOTsOAxK6h0iNt7PwGwd4FGVRFiBwg4gcNsntNut6btGwyfPxYoS6BocCh87zlJnqD+dbKpgjg5piVBNG0oZU5+Frgak37zGK7AomEuY/W03gTfDwTnr2P3TzXVY9rNOEYlDXiLpTj82NDt2jSgxwUMJz3g0Bk+XYCWHk5EwKYS5W9/BQsAvM+lWSBHFoCkcGyBhPXjinO3VyImtDEigUmPQIM5nILtA7DOuS9bl3ZCmoviPnQ6X7j+YT6pM0w1j2pE8Yn0qnu6J2oG4mvr7Bdmplng6vcV142duJNY14SiuwLC6RJC3/eyErcyE1A9OQsk8RngoUME1uytM/jogsu4eFnjr6SwU6IytJnaHrpkFZUbK4kCTxBj9Xov5EV1HQ4bziJ/oYzlLk5q6ZthlRuHhoB1C+6mv+1fM/s9QiEQAqeE8ahIf1eIoW5iXXwQSgS84X6HrCMABfw58NasAMGKJbq6ThYDt5uSLzm4bVS5P8IzaPbbsA/J8AFrwUe39ibCfDq924CD3iNqHDM4TuzNLRCol+Pmp18oOqOt4wWEtHD3wVR7LBMp+1fcr8GhiwJ/U9UE4XmEvTMgdu6QDOtga8lp01K1/So8eXLNXGZQK2V4TGZ4zc5TeiB6uYOoXPUkPijyyxA/H6Pi06tfnJxl2IPDKjNSeoSyy21ABQXImenJnxsQlyz2Nxcd8SwNKAbZoUA5JLj6JMBoXuOGRKkVh+YAcvT91STd3a7CpJP80xcAmOee6hw80JOr/AxxE2+KqeDQPBeKe04w== Content-ID: <0FCD9593E385C246AD9DB070084CAA85@INDPRD01.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-42ed3.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e35474c6-d514-438e-5883-08d9df4b5e3a X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2022 15:08:24.5590 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BM1PR01MB3937 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Paul Pawlowski This patch introduces the requisite plumbing for supporting keyboard backlight on T2-attached, USB exposed models. The quirk mechanism was used to reuse the existing hid-apple driver. Signed-off-by: Paul Pawlowski Signed-off-by: Aun-Ali Zaidi Signed-off-by: Aditya Garg --- drivers/hid/hid-apple.c | 125 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 24802a4a6..c22d445a9 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -7,6 +7,7 @@ * Copyright (c) 2005 Michael Haboustak for Concept2, Inc * Copyright (c) 2006-2007 Jiri Kosina * Copyright (c) 2008 Jiri Slaby + * Copyright (c) 2019 Paul Pawlowski */ /* @@ -33,6 +34,7 @@ /* BIT(7) reserved, was: APPLE_IGNORE_HIDINPUT */ #define APPLE_NUMLOCK_EMULATION BIT(8) #define APPLE_RDESC_BATTERY BIT(9) +#define APPLE_BACKLIGHT_CTL 0x0200 #define APPLE_FLAG_FKEY 0x01 @@ -61,6 +63,12 @@ MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. " "(For people who want to keep PC keyboard muscle memory. " "[0] = as-is, Mac layout, 1 = swapped, PC layout)"); +struct apple_sc_backlight { + struct led_classdev cdev; + struct hid_device *hdev; + unsigned short backlight_off, backlight_on_min, backlight_on_max; +}; + struct apple_sc { struct hid_device *hdev; unsigned long quirks; @@ -68,6 +76,7 @@ struct apple_sc { unsigned int fn_found; DECLARE_BITMAP(pressed_numlock, KEY_CNT); struct timer_list battery_timer; + struct apple_sc_backlight *backlight; }; struct apple_key_translation { @@ -76,6 +85,20 @@ struct apple_key_translation { u8 flags; }; +struct apple_backlight_config_report { + u8 report_id; + u8 version; + u16 backlight_off, backlight_on_min, backlight_on_max; +}; + +struct apple_backlight_set_report { + u8 report_id; + u8 version; + u16 backlight; + u16 rate; +}; + + static const struct apple_key_translation apple2021_fn_keys[] = { { KEY_BACKSPACE, KEY_DELETE }, { KEY_ENTER, KEY_INSERT }, @@ -530,6 +553,105 @@ static int apple_input_configured(struct hid_device *hdev, return 0; } +static bool apple_backlight_check_support(struct hid_device *hdev) +{ + int i; + unsigned int hid; + struct hid_report *report; + + list_for_each_entry(report, &hdev->report_enum[HID_INPUT_REPORT].report_list, list) { + for (i = 0; i < report->maxfield; i++) { + hid = report->field[i]->usage->hid; + if ((hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR && (hid & HID_USAGE) == 0xf) + return true; + } + } + + return false; +} + +static int apple_backlight_set(struct hid_device *hdev, u16 value, u16 rate) +{ + int ret = 0; + struct apple_backlight_set_report *rep; + + rep = kmalloc(sizeof(*rep), GFP_KERNEL); + if (rep == NULL) + return -ENOMEM; + + rep->report_id = 0xB0; + rep->version = 1; + rep->backlight = value; + rep->rate = rate; + + ret = hid_hw_raw_request(hdev, 0xB0u, (u8 *) rep, sizeof(*rep), + HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); + + kfree(rep); + return ret; +} + +static int apple_backlight_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct apple_sc_backlight *backlight = container_of(led_cdev, + struct apple_sc_backlight, cdev); + + return apple_backlight_set(backlight->hdev, brightness, 0); +} + +static int apple_backlight_init(struct hid_device *hdev) +{ + int ret; + struct apple_sc *asc = hid_get_drvdata(hdev); + struct apple_backlight_config_report *rep; + + if (!apple_backlight_check_support(hdev)) + return -EINVAL; + + rep = kmalloc(0x200, GFP_KERNEL); + if (rep == NULL) + return -ENOMEM; + + ret = hid_hw_raw_request(hdev, 0xBFu, (u8 *) rep, sizeof(*rep), + HID_FEATURE_REPORT, HID_REQ_GET_REPORT); + if (ret < 0) { + hid_err(hdev, "backlight request failed: %d\n", ret); + goto cleanup_and_exit; + } + if (ret < 8 || rep->version != 1) { + hid_err(hdev, "backlight config struct: bad version %i\n", rep->version); + ret = -EINVAL; + goto cleanup_and_exit; + } + + hid_dbg(hdev, "backlight config: off=%u, on_min=%u, on_max=%u\n", + rep->backlight_off, rep->backlight_on_min, rep->backlight_on_max); + + asc->backlight = devm_kzalloc(&hdev->dev, sizeof(*asc->backlight), GFP_KERNEL); + if (!asc->backlight) { + ret = -ENOMEM; + goto cleanup_and_exit; + } + + asc->backlight->hdev = hdev; + asc->backlight->cdev.name = "apple::kbd_backlight"; + asc->backlight->cdev.max_brightness = rep->backlight_on_max; + asc->backlight->cdev.brightness_set_blocking = apple_backlight_led_set; + + ret = apple_backlight_set(hdev, 0, 0); + if (ret < 0) { + hid_err(hdev, "backlight set request failed: %d\n", ret); + goto cleanup_and_exit; + } + + ret = devm_led_classdev_register(&hdev->dev, &asc->backlight->cdev); + +cleanup_and_exit: + kfree(rep); + return ret; +} + static int apple_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -565,6 +687,9 @@ static int apple_probe(struct hid_device *hdev, jiffies + msecs_to_jiffies(APPLE_BATTERY_TIMEOUT_MS)); apple_fetch_battery(hdev); + if (quirks & APPLE_BACKLIGHT_CTL) + apple_backlight_init(hdev); + return 0; } From patchwork Mon Jan 24 15:09:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 12722293 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 6D872C433F5 for ; Mon, 24 Jan 2022 15:09:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239990AbiAXPJw (ORCPT ); Mon, 24 Jan 2022 10:09:52 -0500 Received: from mail-bo1ind01olkn0188.outbound.protection.outlook.com ([104.47.101.188]:6121 "EHLO IND01-BO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240451AbiAXPJc (ORCPT ); Mon, 24 Jan 2022 10:09:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RXi1m06ailTtlCx6jS1XWQeO2/y32t8CG/n+dona5DOp3NVrjSR1tzAnK8CEYUKI24qh/hD42EKM3t2Bmb+OztTLH1qt27l3ZcGJwkCq7Rl14seCE1VtLtwYHyxURkVMZtNWGZ24uN1JnhaCXxVumW6HWCUVcq5v4iopV1ICpemMn4rwM7vd2Fq1F6sAlzrXABTuTGvLaHtyZOEE3vcHCM4Bd4iENR/+zxLmtKTGAsM/Zh48/GlyvtLHNbuGHHugaJPogxJSK636IyDlzSMJW372edkPFUmlQzl7jYtbseDBqFni4KHiQPcFm9ZkxnHOsEPmrbiYnV4Mf7b9g4cF5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=krma4VHb9sJrmprJ5mShOQ73B5oR6gD1pgrE1j02stg=; b=lPD7uGHUgcf0EUkxgjxZMBx41USKDo/o5aCJ14/QsbSr/xP7gLzGc1Hj3SUEYk4sgl2NAWjwR6aIhS5rp0fQOTa1w9rbVi9FhA3ILIhzAtIZOpC8I6etEYyi5VfmZ4ZPbyOL/4SQcCo72c9gdttZUurKUoKMhcEO0NnHQ2rZRiPMSA6sSDPqEex7MeKnSnkhpO8uQ8DEKPeqdxJRxuezJvVJ0Bc1Oj1T3x1qv17IAdIR1up/VUlrY70wJxM4y8jrGiIl/6lDDW4uSMYXSCYn+FvZarWrXqTWarK6colh2cfePYU5UJZp/so0OxXkGXrrucEX+CkHM29Ak7ajsFLBxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=krma4VHb9sJrmprJ5mShOQ73B5oR6gD1pgrE1j02stg=; b=vH6eSUowFnyDfMFZv5VrZs7Vqfg29lvVbCW7UVS4r5kJ8IHb7NXw6Zuc3IOp3Ptl5ZF2a9V7zph6tXFCuQlUwLVzTS3F44VHJdTko5/8vCPraD0f/3YZfkW9OpjsBeyV1gjkq45bBSZuHjumTqFEWNmJQtUKWxSnT7P8iuRN2/WQvvdfGYf89hHYIdu2aGasHPDvv7qLRBFjFsXsyIHzDES9sblWLtZgsgQnOa1HpSj0F8VC93y0lBMazzOoGwQomBBVq3x6l1TgZLmnR5+1tbDJRQkWD3qOfincXmnlL3L8G36ngdNu8Ni4me2KzJdXp7WoueOltUTfpDr/keXccg== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by PN3PR01MB5602.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:79::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.11; Mon, 24 Jan 2022 15:09:26 +0000 Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055]) by PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055%6]) with mapi id 15.20.4909.017; Mon, 24 Jan 2022 15:09:26 +0000 From: Aditya Garg To: "jkosina@suse.cz" , "jikos@kernel.org" , "alexhenrie24@gmail.com" , "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" , Linux Kernel Mailing List CC: "paul@mrarm.io" , Aun-Ali Zaidi , Orlando Chamberlain Subject: [PATCH v2 2/3] HID: apple: Add necessary IDs and configuration for T2 Macs. Thread-Topic: [PATCH v2 2/3] HID: apple: Add necessary IDs and configuration for T2 Macs. Thread-Index: AQHYETRgOOoNCnOlSkm/7/gwoQwsJg== Date: Mon, 24 Jan 2022 15:09:26 +0000 Message-ID: <4016C218-BF0B-484E-BDFD-A88FB7510E3E@live.com> References: <67E7EA8B-CF21-4794-B7B4-96873EE70EF6@live.com> In-Reply-To: <67E7EA8B-CF21-4794-B7B4-96873EE70EF6@live.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [cUDEZEmPH04O5OuJXardPieL0Y2uMQZCTw1U4EbJW7K0Bg4U56iuzCxHcUrLzCQL] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 85de07f2-9c0b-4b6d-e8dc-08d9df4b835e x-ms-traffictypediagnostic: PN3PR01MB5602:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: HMdfOrrLh8ixcZXWc1t9PidJ1194RvM35uCp2sZJo2ifnDHHR5LK0eJmt/6bXl4vIixwYTTnOzhEou3SeR19keriQo2ycHeQESMDVtgpFBvzfuNKbhOIO2ds9hal4hYIzFtLphMSBnrYCn82tU2ayz5iPO96DvgVU7jjdXMmRo45c9BVKWMzQ662Jer0p+Jq8YIvCDKnpmh5WTTj3OQwFbnxACAiGbI0+GE6Z6mHotgDTgvPTpboORCJau006qLiPaS+VjSmUn8xx6GRZw/P9U++pNA8NdsxFTDf3uTW+A2hb/cFYqH+U6L6CclkWQUIqtiRvhodT52nkRexVKgpRhJ+V5Ci2jkdV9dUmk9AMY4XOFlebdDz1ArfRhZZYrPtD5CMlwSM2AWYBtOKcA7+gMFL7ANW7BCyQuxrcdg3Pgwinr/TXlCmyBh6QbihLHKWPoXu0zAzeFbpkVVQThBvF/dV55j2hLNYGS4S3QJXLotHcqYpYPZbyKbNKfVQP6cMqhpRAMHdDeBuR7Rn2q63pWbSeQlFlQr/FAAhSQ6xwSBxM2MR88rU2xsYzlhoVIovz/oFty9X/YSJukJqqZTyNA== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: HREGBBI5y809FrbXyjHIdsALVxJX1xyAKBg0hEhCbSJuO42i8FR/iWcXdmxbcYxotzP961W9l3fwZx7PuwEc++1ZvuzX03AKMoImABxokRWRv1R/fsY4+Kbm3eXGlBYnj3UV8ryGuSORYiWnpqHAYzAJWdGGg2KHM77xDN9iEuC7PWMxTjaZ6QqrVqtBAiJD2ZKKpznZLkQMHyN11IicV+Ev98t0XEhn/GoVPQ81Zb0j4jwQQkK84TBK/qA5oLX6On/+JfXv69gHLFSIwWYM8qB2rWzeqACCmSfSHQQkNLWGI1eMv6FfGi8T15im9uGgDmHvoS30FZ6ODo/BPhWXoLKvRxV7TLpGo4uML1FHNGFdAwIDusO7DLTR4dkQ77zQnH8qI8uI6tAtcD4QykgGYnF53HUrKvz7tflKV881YG9N+4tjiuuwzT66L1kbAaB+GdWLNcHgc+QmTnBTDry7bym5uT/73+4WWgpY9YWNSXa7kvMxKAymiUsWMQaR4z/3BuJtSTLaOKu07C5ZGq9gzdLcbgEpb3zGAFLxIv+uN/o8k3d4VHUda9QK72PefjMq6fFjlGDrLHTMQEFoCg8oL04UKjBJcR0Y1dNow8IHuAN8zLJqWwau5n/FflTn+A5y1dYrGxmxU8sRavAQWi0erB97239GPSTABXo8/Hmf+v2c72zMKi45Yd4hHzJJnWA7+5KsP9u02uyaByB3yoHHF1MPETVHQJonEFzwvwSkYdXX5pY/IUropI9+ddwtjZljZZ2ghS1RlkiSRED1wW3ijyfBBk3TS2XpAzQYWkNLkYykndVlnh6Ox3jAiVltZHqYG9Ij6HSxBPRm2BkVxjaCKp67WMv38DDUgCT+8JCwOBOkFpasR1AUxzrDFUMkYIzvRmerTAhpiBEPpsMg23GtovfdAYXPboGjQ5tUmu0W9qDaMK/Y+V2UgVfLyjBKn/mBt/K6QRXX9ScyCgK+net0mrxAQW+GI/JKbti3/z0KuAYmk53MGqhR0dMQ66Qx32MxO78bdSo+P0TrMOujSKlTCQ== Content-ID: <84531C822ACD7844B3902304950043B8@INDPRD01.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-42ed3.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 85de07f2-9c0b-4b6d-e8dc-08d9df4b835e X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2022 15:09:26.8587 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN3PR01MB5602 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Aun-Ali Zaidi This patch adds the necessary IDs and configuration for Macs with the T2 Security chip. Signed-off-by: Aun-Ali Zaidi Signed-off-by: Aditya Garg --- drivers/hid/hid-apple.c | 16 ++++++++++++++++ drivers/hid/hid-ids.h | 8 ++++++++ drivers/hid/hid-quirks.c | 16 ++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index c22d445a9..823021c24 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -861,6 +861,22 @@ static const struct hid_device_id apple_devices[] = { .driver_data = APPLE_HAS_FN }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS), .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K), + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132), + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680), + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213), + .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K), + .driver_data = APPLE_HAS_FN }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223), + .driver_data = APPLE_HAS_FN }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K), + .driver_data = APPLE_HAS_FN }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F), + .driver_data = APPLE_HAS_FN }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 26cee452e..8ad26c20f 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -167,6 +167,14 @@ #define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI 0x0272 #define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273 #define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274 +#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K 0x027a +#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 0x027b +#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 0x027c +#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 0x027d +#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K 0x027e +#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 0x027f +#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K 0x0280 +#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F 0x0340 #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b #define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240 diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 9af1dc8ae..963cf2a2e 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -294,6 +294,14 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, @@ -929,6 +937,14 @@ static const struct hid_device_id hid_mouse_ignore_list[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, { } From patchwork Mon Jan 24 15:10:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 12722294 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 80418C433F5 for ; Mon, 24 Jan 2022 15:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240386AbiAXPKV (ORCPT ); Mon, 24 Jan 2022 10:10:21 -0500 Received: from mail-ma1ind01olkn0161.outbound.protection.outlook.com ([104.47.100.161]:25364 "EHLO IND01-MA1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240344AbiAXPKU (ORCPT ); Mon, 24 Jan 2022 10:10:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQz1oa7Fblji3i6n61NcfwmoDWQiPl+veVe6W8M4PsdPSdKsEXNxqDkaEN2+vO3P2q31EkBxfbKAI5KB+/JHhd5fLxKSBTokQoTEIDwnRl0Qw6WcswjXJlSdBG5QiN/a32+3c+1HiUdUpfUNmAihKikdhX3jNv5nD/eC4dMiNW4Gsf5bxdBDqKFtIGkCoKYIAYXkjX8JfmlcH2ZtoASEM9tBbVrWrGy9p9YuCEKdPFm6aobF5I/DlId08z4jaEXQyhRcUxrR/8fCM1NoXQCPVV4oHMENaAa7xRKdGO4129RvKP+wNvo7TtK2nwFz9nE1BGkNsIIhcBwEfjdAwGrjhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AopwVpOAznea4ixmV0qPlPP9esdg0CgE22pnNtuGawQ=; b=VSncOgvst7cJa/Oh6Vj2O7EROiITPh3KKLv+CbHQkhd/Q2jwAGlPS9c5pco1GgzDP44Uc3dI8NpSGeEZ4M6G8gHCMTq2oISZBxdPneNPJOhQBoFpmcs6QzpCtoXODULATuhMeQA54GDXyazwlFGQblDBpk79V6nu2SZISquYrNIjc8hQ3kn8ZuhRvV0gDDeXnF+c6D4NfMwHv86DEhdjtJk14VS4Q9OqNYP9hR29edXZhgTK72/tCO7bE18z0ky5NRmjiJ0L1N3R2z1RIEsow3/BWPjadgnYGc+ZphZQmLG6KgqfQmUvGbQJG3U9KXySQ8sJcrnyZZ5PxFROdp4SiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AopwVpOAznea4ixmV0qPlPP9esdg0CgE22pnNtuGawQ=; b=SWnWPeCQpLhyoiFfa3Tq8KUl9QshBJF06YUuV2NUTcczK7jDtdCkTUFFb0+2ZyJsxVqoizMBlBtqWY66ZRBQTG0TIRnfXZD7gsIISEGjsUFDVo2Tz22vGlCNAVtcnqpAqtTeqEeXtEmGMjt1cXvgYRoyYAkLdLar3ZUZ6VAilvrkZdrx4V4RauAwdpVQZOfuOx6DLBv7oPmHki1LBe5YE/1xjcV/ED14UdjzILxMAkCgTIJXbJTPjfhDtqQ3aeOT8LPAsKYxOLi3lxpB7pKC4rkcMwUUtlnRTf9hCXBGxPaXPFNKfIHL3xC32cYrUUo2kGC2+rlZ+4FbaMwV/aZCJA== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by PN3PR01MB5602.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:79::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.11; Mon, 24 Jan 2022 15:10:15 +0000 Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055]) by PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055%6]) with mapi id 15.20.4909.017; Mon, 24 Jan 2022 15:10:15 +0000 From: Aditya Garg To: "jkosina@suse.cz" , "jikos@kernel.org" , "alexhenrie24@gmail.com" , "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" , Linux Kernel Mailing List CC: "paul@mrarm.io" , Aun-Ali Zaidi , Orlando Chamberlain Subject: [PATCH v2 3/3] HID: apple: Add fn mapping for MacBook Pros with Touch Bar Thread-Topic: [PATCH v2 3/3] HID: apple: Add fn mapping for MacBook Pros with Touch Bar Thread-Index: AQHYETR9gng9woz2EE6lNBNyOEXQBw== Date: Mon, 24 Jan 2022 15:10:15 +0000 Message-ID: <9287244B-120D-49BD-B213-40651246FF6A@live.com> References: <67E7EA8B-CF21-4794-B7B4-96873EE70EF6@live.com> <4016C218-BF0B-484E-BDFD-A88FB7510E3E@live.com> In-Reply-To: <4016C218-BF0B-484E-BDFD-A88FB7510E3E@live.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [edbFmOejZcH9DItN6LD1DuXrJsXJYntjQZcWzpATP3YUahVQsoYy+BIC2MLOYWn3] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e9b94716-1125-40b0-f580-08d9df4ba05d x-ms-traffictypediagnostic: PN3PR01MB5602:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: N21xCnjbwyU/f3IrfXMgH0mK/6h2FFS751qFIRCYWaxO+tbwJPsJOYAFwLkwmPUygmHrI4J6f72nHtOmX/o1KuTvUa0tR4UWl5Pr3j1TzqDYT2k9gB/M69oDNUOlL3Wvzh/F+HThnAWXH4z75l4/J4dy6HZN3+ATAcWyIrPVB1hT/grPYh1fezgaTRC7O3GeaHxGpTyUQVHTdAJsCR3nEVi8EByjPe/uvVKgFwfKl7rHvLbF1CyD6t2Ud5qBKKw03GVPmW9NZUt/GbXOaNSXW7g7IR7ARLTDvLy0JZ0vCmYZ8uh6etQ3H2NsOYPWUoOfxptn2naHQw9bZRTVxBnbQif2NxfbhLatonf1bx2f+XU2UzWbaJ4lB9qNx+UE/G0wFOUWNcRnxmGuv5ohl/yu2ckZFzbTYab0/9H/+bT4UVQA+XGY2VQL2QYVpkGT7kVFggGUM8uGX6W/d7BnQauFvSXdh48BnAuJHVvRSvOSyZAUzt21h3iQ/1tLBBqN01XMWp7wfvBwHETaJf6brre7oc0Ip40y3K0hjpmW+hVL5gjQ0fhgd5oap9gHUTDFY5Kc0Krvt1SoOssG5vhWfY4kKg== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: Owo+uhUZsMggwLZohCKuGTA76eRrZNn53qrzkEyVaeT1sgANU/WMqrDU8E5RQYb+PBqVa9nmsbW2c+AywYSlZ/Q7gpFNQbsRXYvdHcXKhSa+bJUNOABLjNSylK2r0RN75HcwYkFM1qfjqEUSVq9xeYcxtyyMkUnqmx3+9ERETSQxLYdrsMTr5jHQaCuqqrErrtHcvPl/BXVbAkkL9plKK68ICbO7m8hbuM8sIyQ40JyK26v3fVF076mqtRoQwS/E850XWp9w3Ag2fTt+CYxksuUvsRY5wpV6IQ/peqtUSaBGO0xBw9jGL1v0IbAGe74RBW8QKdpKCwIfpnNNUF/V6vgg3NNZ/AyX/JIP/zTHCLAnhc5W6sKQiSwUXtD+hysJYx2hU+HlyliMELQvzEQ2DNcjZLqHcNwt3+1RMlEkPf5fddQygFDxJL4ayd55LDFF0IIethu8KCigxjNCfqVN0mqvfx3laMZVpui4w2lmbmUmyMjSVSI0sKjr1ZN9jc55RzKNvpyInp4q7KSiJraUwUZMxo96bGdDcq5SwMvBtPtQymdVsjgPKr46nhFNayhwFGHG5bq7VKSpt/Rn7ihP0hwnF5RnOsl8mhqwbWHnpgWxiR0E0OlNStbjjTW7UoMoY5TznL8daDzlWXodTRoeqdvxXM0Js11FqSHKhN2BZAkdGIwjdvF9XSvX2p92ruRdC8kzaHailnRSL+88zsPPi8Rpuyyhz8TSwtYzzEPdSFTPYx9Us+D86y65vJ4Ua0lN8pnd6ngVkFL8TCV7N4D2YImfHsgs6Sjq2OCbuX4Ah1oU5fD/oJEbaMF9Yubf6aZjraH5K41y2F46L1mA10lhojOwb3qkiAzhfcaMlkw7BSQH6+U5JkyP5qYkjxaexrlPt28QYq2WKh5VunU/MH+78sk729dUWb4RyyuosT2r+j1lG1I/cAIm0QS4s7TGBFhJ0UFFf4LS+U1G9CBB6OGpAwtRwckHjbhQDz7qiahTQ9ZetbBJwO7bffwf9mp4xWzJ93iDhiQ33zs6OfpsDgxTFQ== Content-ID: <4488A5207DB70942B5C9E0981371DC09@INDPRD01.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-42ed3.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e9b94716-1125-40b0-f580-08d9df4ba05d X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2022 15:10:15.4908 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN3PR01MB5602 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Aditya Garg This patch adds the Fn mapping for keyboards on certain T2 Macs. Signed-off-by: Aditya Garg --- drivers/hid/hid-apple.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 658d79375..5448e5a66 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -142,6 +142,51 @@ static const struct apple_key_translation macbookair_fn_keys[] = { { } }; +static const struct apple_key_translation macbookpro_no_esc_fn_keys[] = { + { KEY_BACKSPACE, KEY_DELETE }, + { KEY_ENTER, KEY_INSERT }, + { KEY_GRAVE, KEY_ESC }, + { KEY_1, KEY_F1 }, + { KEY_2, KEY_F2 }, + { KEY_3, KEY_F3 }, + { KEY_4, KEY_F4 }, + { KEY_5, KEY_F5 }, + { KEY_6, KEY_F6 }, + { KEY_7, KEY_F7 }, + { KEY_8, KEY_F8 }, + { KEY_9, KEY_F9 }, + { KEY_0, KEY_F10 }, + { KEY_MINUS, KEY_F11 }, + { KEY_EQUAL, KEY_F12 }, + { KEY_UP, KEY_PAGEUP }, + { KEY_DOWN, KEY_PAGEDOWN }, + { KEY_LEFT, KEY_HOME }, + { KEY_RIGHT, KEY_END }, + { } +}; + +static const struct apple_key_translation macbookpro_dedicated_esc_fn_keys[] = { + { KEY_BACKSPACE, KEY_DELETE }, + { KEY_ENTER, KEY_INSERT }, + { KEY_1, KEY_F1 }, + { KEY_2, KEY_F2 }, + { KEY_3, KEY_F3 }, + { KEY_4, KEY_F4 }, + { KEY_5, KEY_F5 }, + { KEY_6, KEY_F6 }, + { KEY_7, KEY_F7 }, + { KEY_8, KEY_F8 }, + { KEY_9, KEY_F9 }, + { KEY_0, KEY_F10 }, + { KEY_MINUS, KEY_F11 }, + { KEY_EQUAL, KEY_F12 }, + { KEY_UP, KEY_PAGEUP }, + { KEY_DOWN, KEY_PAGEDOWN }, + { KEY_LEFT, KEY_HOME }, + { KEY_RIGHT, KEY_END }, + { } +}; + static const struct apple_key_translation apple_fn_keys[] = { { KEY_BACKSPACE, KEY_DELETE }, { KEY_ENTER, KEY_INSERT }, @@ -269,6 +314,17 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 || hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021) table = apple2021_fn_keys; + else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 || + hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 || + hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) + table = macbookpro_no_esc_fn_keys; + else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K || + hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 || + hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F) + table = macbookpro_dedicated_esc_fn_keys; + else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K || + hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K) + table = apple_fn_keys; else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) table = macbookair_fn_keys; @@ -480,6 +536,12 @@ static void apple_setup_input(struct input_dev *input) set_bit(KEY_NUMLOCK, input->keybit); /* Enable all needed keys */ + for (trans = macbookpro_no_esc_fn_keys; trans->from; trans++) + set_bit(trans->to, input->keybit); + + for (trans = macbookpro_dedicated_esc_fn_keys; trans->from; trans++) + set_bit(trans->to, input->keybit); + for (trans = apple_fn_keys; trans->from; trans++) set_bit(trans->to, input->keybit);