From patchwork Fri Jan 21 08:24:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 12719483 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 A5411C433EF for ; Fri, 21 Jan 2022 08:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379550AbiAUIYv (ORCPT ); Fri, 21 Jan 2022 03:24:51 -0500 Received: from mail-ma1ind01olkn0160.outbound.protection.outlook.com ([104.47.100.160]:6123 "EHLO IND01-MA1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231208AbiAUIYv (ORCPT ); Fri, 21 Jan 2022 03:24:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jxcvu2kiCP7r2N9qeMma4BVIDakzDY05pP4FiYZOkvx24+rh8neTPohpY7864GfjY8pw/KgQnxeTtJZ4nu1Al6PEQlJ3+JT66idbRRekJBoWSAOQnAEnqT0mKyRiYbD+ijngrBYBPzicKID9KA1yLewdF7bqLBkZRC7iNKCqtQmSsssADbBf49SmHcFcsUZO2m9zMyYiyzMIYXbGi05Pt2pRczwNs/URzNvdOhM5eBh4X/Y8N7Z48diIaYUg0h7rjO2f4K+8n+0Z/cHV8KisGgb4IO2n2/rGo7hl7hW9UcDaZrf1v3miduJl6t+C1Iz4j6p0CIJz63kuTGiQBZ3fjA== 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=gmZQISuP4M2fXUhEAp1ENTNJ2UCMj26IQySGaaqEg6LYJ1nh2yfnyYmA2lMiLSATzo0EKAM32cnyRb9n7z92Nod2sAogGrLMMS5Xg2GJpC4ChYSBdgYnqUXst6cPAJa63NANwOGDrsjP3+ioHitRKxXMmmEKlm+sMnOoPVadi96PbwvIJTtX/FiBhRYuf6+J+B3+x9fgXZHffbEwndneY5oJb6zIYvw0/kLcn2q9GcqOzhs9PSWr8SU8BA+Fn24eSgDEUoN73GZl9JROkKJpVtpv/oUJFHy3LdZckYPJag7zV4mcV5OVdedvUazPxRo3wyFiSbNCDHlKTiyBjkptSQ== 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=V2HLAU/ILBU/K0T2agx2RrPOGrt/5WPrF7+7eswyS50nCb1iFKX0uWerCPY1FfJFlu6I1KhFqgGc8hrSgYayC/dsRUySUNU5ogIRVcngXbcYiwfGdjjlJ/SFWi5dNTtuSn7rqj2ho0leTsjEVkhKCDzgKYNtUQ/PzwDKiwXuWf385um/hQo1A7+6aOF8R35SgAxlB2ZPwG+NcejzIsWxtu7BwtAoLnY8oit141L0hGeRVaTwxErJuZpJ1bSE2uqzMuGqwcOI3tQa8fWtXzFw9BTxXuLN3sdCLTf5Hb9UFWVoo+z2DLmGMMUPXWWZ2YHRt/kS9vc8or0A1b2bkl818Q== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by MA0PR01MB6985.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:1d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Fri, 21 Jan 2022 08:24:47 +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.010; Fri, 21 Jan 2022 08:24:47 +0000 From: Aditya Garg To: "jikos@kernel.org" , "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" , Linux Kernel Mailing List CC: "paul@mrarm.io" , Aun-Ali Zaidi , Orlando Chamberlain Subject: [PATCH 1/3] HID: apple: Add support for keyboard backlight on certain T2 Macs. Thread-Topic: [PATCH 1/3] HID: apple: Add support for keyboard backlight on certain T2 Macs. Thread-Index: AQHYDqBZjIWX3vgB/0uO5aaDcJHAaA== Date: Fri, 21 Jan 2022 08:24:47 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [73oCnercoKD7mauPP+W/315O1W55sKwCtPG3mS4oXt9wgYUNYBMVUXYyzSgCmJWd] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a282ce57-3df7-4226-baf5-08d9dcb77c5b x-ms-traffictypediagnostic: MA0PR01MB6985:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MnnWvYTpujrPN+MMXLo2P9Mm4/6bZCNVL2ZQZ88FCUH19h7H1qdX18EoQKpSNbcsQs/RCxQBZO+hTp5ze4/0P+cCivmNXmUJcUnNfYa+p/Q5bHHu8YEJktHgalkgwBmuVxqjlfhbCQYvFAFCkbCKdoHd+T9D2LE8GYHdAjVNBbQF80bnkRNCKw496kng/uq9fFC7IoouulgIZ9eELZ7Zo5qXl/rYFtDLP6CHhE88rdBhEX7xRFjdycV/ayPqaAXJ8I83Ef+kve5+OhMfe9Etqukw32Pzz4sOtkwTsRCFYDWJKjJldjbGrx6+q1aawh4JeAxtQVDVxfpFoH9iqppCzUXfqjYx8S+o4L0VTAtVEcP6tliUd8f20iQ5NCAU8/S5btS44Z1VQRxC5d+raiS3QyeRrir/7ebeVlcnoLBuSWpT5pwuz2AdAKRRa6NSo3L6mKmya+ClJ42OqlWappk8HTHILJpxf/G+lAWFgBe0H4osGoCdaQgzIbVgA2m/0hh48uhJ/6MAPhAWlCdlN+EKr/qc2Mt9Si+jL586E3ttry6wNWyr9dNPtKGlOA79704p7oT03I/D/F8sjyCoHug7Dw== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: l6C53xGxCyVlt9EFrMW+WDtaFP7tWqGrLa28ZUDA1/aKZ/oLeDsaxnmZeyR63Y3YSV2Ba+yn7Jn6UexF/M39cK7J2SKAaOgYJ7wXPQTm3fCskyyDqg9XQ/xBAF8vkC3l1sq0SoWG/i56MzgMcishvjZMCuuijDVCOhJYo6I6O47MF7++TOklH6lSsCX3JLD00zvlyjotU/RJjjzwcCBA5PxqGljmPKq6p1U+VwKLSCV7mWiZ7XwT+t8+tkNB4tWTHWyZbcXwa8dQ/eZqcPzITc8XcNan0Tf0r7L6wWEAH/dBCZL8pdGZW8gPrF7qaPE+jO/oqPmiVo4zsNxbLcA1rUk+t3pbwnZEpYiQfymhzH2i4SSt3ujhikqQzuB0zlRzfZO0pd9sVchMxVN4Xn8IqcxwAXh82r/gohv/EOCYRKUemgSkgunSk1Ji1VPtY9S2lDguYvF2GYMeU8/r1eTqSt9krb8L2jIyf/7yCATGTo/JnTP1IZzyMoByRRBVFfFzoUeYBwUSWdkpo4xvMhHMNrvJDlwUCSLKO29WIc0ieIbit3QPqbmdomN7TeI67HCbU6VIvRwvHSTyPGEcL1QM4xZwnm+AIIZFpSAWhwkGC+zj9FSsahaSDFhtVXOvJp+gfM2+eGBjjdx1n7GEvaIaWlRz6bDhFxlOkFm6QRmrkBQnQuUCy6Cvl7PMVDn24nO0Q2aGqH7lPM8a95K6r06lrX7gFPt72ELIMybF/XsJS8a0Fe0Wd7OauTBllg2tF0MIPn9oPGdkRzOb7GLSalwGT3pQ3iNgz91KyH7UwaRUX34wdF4CEs1czaAbOwPSI1wVVqtHWvaaXtd0ab7YM6xQbK75XIlMWwA2iHkS3BJ5IeTaT1fMNXZWj0KZ/d5ED+BLq+2nBLfRSQupi2XmzFOVNUyQ0JAalkrXdkhG+OImm9W7/0T0uzrkNsiBTLZGylHP7Pa4TK9lNii/6yuadkNhpf57v67hxL7rZl7aGPac26vWWQkchSPy7N9VJxpIJ6MCI+qb7RVQU7Gorq4WJdTJLw== Content-ID: <44E5997F2033034E8255724357672870@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: a282ce57-3df7-4226-baf5-08d9dcb77c5b X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:24:47.2522 (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: MA0PR01MB6985 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 Fri Jan 21 08:25:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 12719484 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 916C7C433F5 for ; Fri, 21 Jan 2022 08:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231296AbiAUIZq (ORCPT ); Fri, 21 Jan 2022 03:25:46 -0500 Received: from mail-bo1ind01olkn0147.outbound.protection.outlook.com ([104.47.101.147]:59648 "EHLO IND01-BO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231208AbiAUIZq (ORCPT ); Fri, 21 Jan 2022 03:25:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ScIMvu2YVeiGKuB1n7LzL8OPAF/xb41xZZC3qVGtsLWF8flQ+1lbmDVfiPvrtaAOEFdX0tEDxdEQ0RFeAQZUNRiQo4UqhN7LppNtRihyTakCY6d1sLAFBGC+3CSjq4XuF9zmcNaBoRgL/r4W1j8vBMPdV6c05DLbysc1cIu+IRvjnXwbgx56umCx+/FPK7cA/IIhQDBwhwOULm+6cB8fyKBwCovAZcNik0DZ9iiy5/0/I4qQv2EslNbvZ4Veaty+Rqh0cHbRlK/qj2BIBAV5Ng/qHkbdYSZ4QyqbAFKMk2gmuD581hBTiIkcacAK92Bxi5+OBmFpdB003TEh12axBQ== 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=VW96kkoxUJcf39UfpaMJoEJtnzveWyFNBBQKPG1tkHZn9SfDwS8Q4VFEIETw+adHdriKqBtWfz0C3H+VvbK00mBbMhbtrcnaVjnMzDjtRUekQc/dgH+s1BthnxD0n9pAqDhljiPt3O9yKLuVq9FFmJTCdvq6I84VplOBlPJTLbtiySWtbpjIBabF4GvF/XFXY92lKzMF+4P6JIYtR9e8NvtPgK3WqGl1eYL3imXT2qdsiqayZf40A5M/Zv//DqTskgtgYNaz7sOBQMp491rALQNW2FljGqhDMglc/xCsAksuDjzdowbxA3m/72KKUqG3d+ggLGXzHCKvd6J4IwrDGw== 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=dTjB2wA6gBVHnVwK4+YAimElCXmvXbRfpHGaDbPYnTlrs7yM9sHqdSCJ/tOahkKxfBII/LXbdGPNdR4JZvWyMK8sOjR2Kc7NnEXpOlV5uuyWN9tdUBZyIhdkqm2QcwXD+wts4Cbqeekli5fdZaKeBVQjTXvnW3bB63adi+kKDh7CT2h33tCk7J9eDyNW9UIHsBWd4WHXrZFgYd4PioYJjtjzd9lv4fvUGYLSXGYM4bBnLmj9m8HxYRlcqRdIAqbrceRdTsnUHuXwzxWFbebikTHEqpmBHdP77YUU+ois4zfzj51+bvPDdur5YlJnZHqwqAArZrI7KrVZeqgpnY9WNA== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by MA1PR0101MB1862.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:27::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.12; Fri, 21 Jan 2022 08:25:41 +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.010; Fri, 21 Jan 2022 08:25:41 +0000 From: Aditya Garg To: "jikos@kernel.org" , "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" , Linux Kernel Mailing List CC: "paul@mrarm.io" , Aun-Ali Zaidi , Orlando Chamberlain Subject: [PATCH 2/3] HID: apple: Add necessary IDs and configuration for T2 Macs. Thread-Topic: [PATCH 2/3] HID: apple: Add necessary IDs and configuration for T2 Macs. Thread-Index: AQHYDqB6SoUV0oSPqkm4D6M98i+8cg== Date: Fri, 21 Jan 2022 08:25:41 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [MwWeujta4/e27wQmuOCKa9WKv/zWTQGacM49PqUB0mGexq+vxhI0ItF1M89y0EBM] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 29e43cde-5feb-4716-c137-08d9dcb79c92 x-ms-traffictypediagnostic: MA1PR0101MB1862:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wJRXh1qryOzPtPyRIVshdo0M5yo0fqU/OdyHvf8kJyGBoAzEvtwXW1+dARzjHMrZxo8cQINUhJxtE3ozEGNWne+NRysJYhYcHezsXNtoKY6/sURwmFealHOz51XS8liI0whJs2BavPVr7j2WnU1pFhZyHogo6w4d6FjdAW4rk3JHsm6iJkePA/oJiFdOd6ZObIJZ/0QmpVwPjZcuW21sW74SMq95nSpEnZdYNJiG+/ViHEAt5OxUq6esPBwUii32WdLF/ytQdjEAOKZNprEBSeA1xg3C3W6qHrDMbBSnEZML/dIRZ4KN6YXobaBXl0oTYjAN5DyQTBr8ONl+VMQLkYwE5JVMYbvnRN0fHrO6aLn8dXIMuAd2X+C8GF9nejYYldy/5xizhH0yMnayOSwPAn+iawKoO3a8C+jCeXzhsri463f8fXZKGWEnaHnyfkdSrVAQHMYw4qzEZURcN5CB2HusIB/eOlR+WB0nnydQEVR57zYFWUAqPG8AyCK+58/exzzjfi/w44ZLO1RjqRJn+LfjneIaiAHvYvfVZlHwhLox07TAW9AINOnZQP3T4u9ePUNVSNT31VxFWS1EnTRaOQ== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: zjEeYCZjCPwiSyJJGmJkMvlLwSMtzw03ATHaM6hqTiaQYL4uqUn5Gcq7F4TeMyMPNEpFkuNg+snUB+Jk0bSX2dPXGf6mmpdHqzYFkYq/sH2o55EkqRy/28fg7H8ZludaX13OZdLj2JvckUzWrS/MK8dqccriVJBSw0vNokSQbXFKxzy+TY236o2ufKnqlofCA6P+7kiJLC2Os675p8WrkMBKI+d6OQ8DUx+/OsjsnogW7S9x6z71Fe6YGdai+0s+gIsJA08MQlSUeXkf1y2Pi/bbk4R3Mvm0oc0w50RRI7hadq1exphtAqSyq6fMkUHLN0x4yFV6yUkjM/QCM5Iy5VfJNVLq9y3957Y/b8DFOrj3J93Cek1VQ505XudWASKRMfy3U9HcXW/OSbWCLLTaUwpAb62B4dItF4gEFJs17V9/aFN3ViG7eRtzVFHvkOfwKSED20stqOVKwOOJNxNDJ6KpT1MgQKW44x9hk6IyJbFNn9E9w8jNB1BgEGF1U5R+ZEuKTVAiuAglqsjWxQi4dgaKczPlQGeX0uMdWojy8kbe13j3tVUMR7ufDiypPRWFc+QEVbUNlC8WPWIGxGhQzA+X4UoFYtAFy3V5FcMpY17jPF+ADqVMngvA9kK3xcn0zTnftWmRfJimFcZ7Ax6QDCL3pPQQ7pGsZtvyg2K9HfGHMAX3zJM4PnvUkZrs3J4G4lM/5FNhqlRqN0q7RRxhdrn4ym67zTXn+/wyCBtvppvwV4zv2aL7XbJGOEZrl2aiIwd99ADu0mcPGTW48NDx8Ac/qELcB/JajDarDTKEeTmyfNkKJOCxjowq9/t1vWzvr9RrX1/QNY1S7Fi4j3TP3tocgMOOIf3/MyIi2Dw+xV2fyfu962sEQ/ejq5F3GEFyfl69aNjbO692D6PEZEQULsBe2eWuFdxMbVr0Y2JEfkJmh8c6/NCf4hLwW/v1Y4B6WFzu5qL7UR4lE2wZuezSSSObAb1T15qGnHMFURbqHbTyF2vqpYTwu+IOv3v9+OUhd54djMByXIm7zNv9Vc8aXQ== Content-ID: <7EE5585BCD26D94F819B92124ECBE31F@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: 29e43cde-5feb-4716-c137-08d9dcb79c92 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:25:41.2843 (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: MA1PR0101MB1862 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 Fri Jan 21 08:27:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 12719485 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 24958C433EF for ; Fri, 21 Jan 2022 08:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379574AbiAUI1P (ORCPT ); Fri, 21 Jan 2022 03:27:15 -0500 Received: from mail-ma1ind01olkn0143.outbound.protection.outlook.com ([104.47.100.143]:59954 "EHLO IND01-MA1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1379573AbiAUI1N (ORCPT ); Fri, 21 Jan 2022 03:27:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XmRwhMTaEAk8zsX0J3z8a5t7oZaOPuQ44M+VwbE7JWl5/zlAKnrbGWn0DHOQQpum8VKTkjf2QRRX1EXB4j4IrvnULNuafcACUYnV9/h9DriABAQTfr0iZmQTowfKbMRbC8t8Qcp0SNCoh0HT8zhlnWrst7wspak7UOvJpLCyfuBjUkMWqc6zfdIO9y5lkSiWGwTwjFktPcqItTp4fojc2W+khsYQX3km4aaKu2Ak0+2WvprC0z1nndMnFtFdgcqKPzaRWlWJZXY+kJcE9whswpKqUGxgzGfxi31mQHhh5/gFMp3M6X0M1ksqQKeeQYPEu1HbmRXa3a4N6Mbm9TuK5g== 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=4f42ynkZbwP5ZUApWLBQZYEGltlRoeTZrg9e2f+bVwU=; b=ne2AHurCPzobPYLEB0izGwpb0wM8Kp4IEQHS2YkGOsItp5BaT9TEsZq7sDYn4sonhCi+yvOc23iIiXrYJ0EeC6KW1PEiF84IywnQXDYFc7dTz2EGWykIuS9sAMOfSl3bUw3ARi+100dKtSvTLQqiCokSAgYIwjrlXm3YIh1i2g2rGflsV1PDLgWnrL+QAb++93Y9tfYDaWUtflfm9gOWKeTAHVfz7tgCuBa1TAtXh880RtkQYkvzLexjhYjk/ylRhc625w5IwZeQtXqSBLdVlWMqKTSB81hngJgaTIqYVsnkaGrj8q4LaDiZB2lzTqOQPx7PEGzgMdI01CuUCDtT6g== 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=4f42ynkZbwP5ZUApWLBQZYEGltlRoeTZrg9e2f+bVwU=; b=Kjb2fUVDtbgh2qhZVto54Zt42eXeb7aWhX2s2tS1wRhhi1FXbyV2FYjexU0GMbfTl+7XEHTIni8V0LFaI1yWI9ZBKSV54JDowRg9xJFOrJcQF/BHoucyYHlLswfEF9gXJCDVt+pE3+YzTFa4+EZb3G6vfbJVUKp2LTtwd5ZOiLGlClnrCB1sbC61I4Itln992PON6BjNH4DSgplKfVU/IxtEauoxwm/DHPbgLm/0b/hLdq1LNaW5Q1VVpsndJXZdxl0XbkvOci/RAR93BnbDDv2vRcpN1g7Bi7TyT/L2vV/TE6N94ujvqhRS+PgcHmNOhVWWlp9TOb/Bot5EOrwzNQ== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by PNZPR01MB4912.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:2d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Fri, 21 Jan 2022 08:27:08 +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.010; Fri, 21 Jan 2022 08:27:08 +0000 From: Aditya Garg To: "jikos@kernel.org" , "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" , Linux Kernel Mailing List CC: "paul@mrarm.io" , Aun-Ali Zaidi , Orlando Chamberlain Subject: [PATCH 3/3] HID: apple: Add fn mapping for MacBook Pros with Touch Bar Thread-Topic: [PATCH 3/3] HID: apple: Add fn mapping for MacBook Pros with Touch Bar Thread-Index: AQHYDqCtf+L8VNoQhkWQ1a/1M58sqw== Date: Fri, 21 Jan 2022 08:27:08 +0000 Message-ID: <658FB7A9-FFE1-43B3-8826-F06F4933DE76@live.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [/sfbNiChjDc2wttft6A+hb4rDXgLEYU8vp2wI2w5gE2M05vnQxEseJtUZAEFBNxk] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8fb7b702-2c52-4ed5-7b27-08d9dcb7d055 x-ms-traffictypediagnostic: PNZPR01MB4912:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: aUsA/mb/90JpmGXyyCdXOl+lNXhBJooQIfZwK7RZ9FiIbiH2KhMlY4yJbC6YLDHa7BeQB1CQTbgS6pd2WKjhSVXXbyIREmSTqkHBGOBSg6njWorD6Y3d3aYZdEWelNJwZWMQVv8DjxCBtrgb87R1pWxjMrrGaGz7QgpUZ+uZMYOGy36A7kf9UP56QStTvvnPb8FkyHwd6U4XslWeNrm3QdTXHrKFeuDEVC4uSK0TFIAVaTpwlajJg6DDkS3mS54Cx2iC1DbkvQiFueqETf9JHK5cOyb50BUF5tjt9/g9+pjUXQSL1mheHoNDJXLNaTr/Z6aMz75qPqFxsOIBMKoSN0P8UCPXv2ZfRXFo6tbogd/ynqf4aohWGDL/a3GlcdekUQ02giLrnpZcF3vgEKbUHQaFeAyiDkSNFSECnq+Rzo7vzuoagGdXpeOjv7c/SJjb9bFdxQtwM7ZZrfiHIZFnhXhNBIeLKUKXdBa6icM0K0bP/fCsYxr7daPOROgjkTq59OxmHzWwXvSKvX+Y9tjcQ7YWottnnX6Q3HkAbvaoO8BLUo/ohlwCSPyVHxCJnZlyDpSYrz6SxSt/VfH7Hp8oaw== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: CNP7ayXmtbQubBdoQbiOnk6R4LHc6Py7SRTv9jqlEEpBeks50ECIxnxSamuVGhvBleRSzvI1B+BaiwMgR+IhU+xlvER0f0OxEHJShGIJ/E2vNDDv9P35B0rSFcBUu9nKnwWwJSfBDpHX7XOMgXqycL/e4sLbY5boYCWXkN/XkwPJ1X9hAvordUP0m+3sNLCnBSzlOYqLkPh3lKmRcJdQaiurNqyQUZBSusBMJZ+Ur+js4cd+6rtRsGdH1U/GgNJWxgQbzu5BT+r0OB5tTrxKI9eHnHNo9r4aXbqR2u5SBWqQTMqH44GXJcC2f7Td3fDl111bOtlSgD+qlaneFAMAvVPWyf+/oK5nRgbJhIw4vweA7g4qjzQ4ADTLMpm3URHwYyjp9bZeaZtN+yJU3xuCMAh/vb3d//V7GUCahzOaA02ooxKQkMpY1yqWaH5Rke3FmHwxM87F8JrzpgjCPwZ1C/9IARBrqL+i5qGC3okaR8h8cuvKy1ZE004CxzxvgCOsJuypq/QPwLr1T0jssjtwRyFSubTUp6oH0fSSoga7kkw/igpDpPJ5Oxer6u5Y1XP1htNtVP4qgdOf9VofwtPyjWkEthnXANMz2Z6zrMUw5kPRCe5M9P89AX0gmTAcZJnGI6/VqVNxKLZmgMRgDlibxNrjBVbeoZmwW25+pYLrNDSoOBDMgg3wsCwTS212XW1KV16WI3SZ3dGh4RZwflaJiFizatk1HO2PTTPylj52o3LblL1Fw+5prDcE2OJYAMbxZ1VHCDgoU2+xJGP4xbhWQHEi+Tvp1p8gDhbzOAotPHiP0/2zDsoO6KQMZWyyduxNlm5fxvHaf/tDzbWHU+gWf+dIY6e+QWxSKU2NyUtunsMdhNzTooHu4u3dDobaMF0U7nZQj3m8ZBd55S7/vNNhRmkJoUhj9Ley6I9DFL0Z6Gi4hsvsXOuP7WnLZpLMjz1HWgJp6tP7kaOPoCKmpZZPF2gL8J3MHwA8vntR+jspahKtgkVBtyvOuN9XnqX/DQRZvoq4vH+pbex4mJmpZHYH7A== Content-ID: <0BEC3BFC18F6C049A97C07550AE38246@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: 8fb7b702-2c52-4ed5-7b27-08d9dcb7d055 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 08:27:08.1400 (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: PNZPR01MB4912 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 | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 823021c24..c4d21c617 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 }, @@ -272,6 +317,25 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) table = macbookair_fn_keys; + else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K && + hid->product <= USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F) { + switch (hid->product) { + /* MacBook Pros with esc on the touchbar */ + case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132: + case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680: + case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213: + table = macbookpro_no_esc_fn_keys; + break; + /* MacBook Pros with a dedicated esc key */ + case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K: + case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223: + case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F: + table = macbookpro_dedicated_esc_fn_keys; + break; + default: + table = apple_fn_keys; + } + } else if (hid->product < 0x21d || hid->product >= 0x300) table = powerbook_fn_keys; else @@ -480,6 +544,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);