From patchwork Thu Feb 3 12:21:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 539767 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 87980C433F5 for ; Thu, 3 Feb 2022 12:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350489AbiBCMVT (ORCPT ); Thu, 3 Feb 2022 07:21:19 -0500 Received: from mail-bmxind01olkn2060.outbound.protection.outlook.com ([40.92.103.60]:56032 "EHLO IND01-BMX-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229379AbiBCMVS (ORCPT ); Thu, 3 Feb 2022 07:21:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DtnwqqrpkxWmgCSRYAgNa3uGHkQQcW8LRLN4KFvFpMzrS1P7WZ9335eEEQMtU+jERkWGXf/iKZGizNs/9/jgpxXx+8YS8G3PvIE6uu1wpbHAwBmyHNz8I4RVs6jJeVMT9fPosCoQYNYzmEaHtGb/P8TtWmOlBk4uuH1uGpM+BmvOCRy6VNLWHpl4hY3BSEEgWa3VLJ4rUeIdBz4BCtGvne2LI4+eik4/UtC46MqAhl4knJcY8r4eHTZea1QFma15hBsiAtDyeN6bz5Tq4mCu8aFGV0PUhSSjs3UX4kYnXR4ft8L0EX2/vyDE8RVLfcIhMw0hZLbyJNUvgPJP95QzAA== 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=+7is92ihNGd6dPnvuiggr8at82p5e/oKjnfVvb6maXk=; b=bLC1PHpNo4zSF9zr4SfLtA/5zbtnhg7+3E9oQ+xvSYOD3r7s+rN62dA3DLGfO8im+2cqCwYgG8UwAeGf7REA94I+6skyQPNwxI7cbqpnu69ocyfWOepUHVBMqHC7a4SMBNfZ4tSOKn8odETMWqcILC5cUEzWidXJWa9sLbLjNE2QCwEoOzWKA3RUkO8BtihxkgfDofqFtNEMD36Z5+8DwP+eTHnTzjTe88AWv3uj4Ttg//cYGzX5qmF/bd/nM7mYLxDgRXapWnHCezWOAY7AR27j0dSMK8nzAmr2L1ldEpXZEQ7djD/hVfUqXA7xkV09ja14hSLKlgTojds2tdCTsg== 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=+7is92ihNGd6dPnvuiggr8at82p5e/oKjnfVvb6maXk=; b=MaBFQccwXhQ2vaW7Yu1gGEWBfKJbHSpgXxma17y3zDU+G8yl2sJgUboHfhIO8aiS7Y5aO4+xxP61X0W6mBMDRIEFdO4FrV5vV6jFUcqkHOc+7LGoprK61KE/bpkGT0UCc/949B7di+pGEhmxgxs15ahQVigLVOG7H+Ctu1B1MpDlN66OSws5gBgDErReKZZNXLpL0ngI//pFVgu4G+K0edEqJSqXx7daL5q8tJvjp71houxCnUu6oNlDjrs4MWlzRN7tbemKPy9zXZ0LGgBOEsfoGBwoLCIYVeIJ+QB3sblEDVRGNBc4SF4CLLt8+n/UjyMoLjaCN3sEnnmv/r+m1w== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by MAXPR01MB2320.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:59::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.20; Thu, 3 Feb 2022 12:21:13 +0000 Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055]) by PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055%9]) with mapi id 15.20.4951.012; Thu, 3 Feb 2022 12:21:13 +0000 From: Aditya Garg To: "jkosina@suse.cz" , Jiri Kosina , "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 v3 1/3] HID: apple: Add support for keyboard backlight on certain T2 Macs. Thread-Topic: [PATCH v3 1/3] HID: apple: Add support for keyboard backlight on certain T2 Macs. Thread-Index: AQHYGPiIph7UJPakWU+x6MdA3b9YOw== Date: Thu, 3 Feb 2022 12:21:13 +0000 Message-ID: References: <67E7EA8B-CF21-4794-B7B4-96873EE70EF6@live.com> <1088ECFE-B356-4731-AC8A-09A4421DD7D1@live.com> In-Reply-To: <1088ECFE-B356-4731-AC8A-09A4421DD7D1@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: [eeUxHezq7LijH3/azKQIrHRgjvQ4BZPrxouD7lvj9xgn2k28AS1Tq1tjNOkkibvG] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fdd86464-bb04-4490-2aee-08d9e70fab4f x-ms-traffictypediagnostic: MAXPR01MB2320:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: GpMzPP32Ti3tTCsLQU6MLRC0ihxEQJGh3J0AT+ElCHoWKKuhD2g9vf4DKlerz6ykVEzoyMx6DdLzsKx8SdicRsqH0rwsuv+oUuUwTKpk+fdHzDPbNPxifvHArf6zIm8uROKkpEq5M7oOcthVD4A4dpDZTaKUsJlu557LRCHQC0g/2lQ2KskRc8EAglgpQvSzLc5HJXQ+gjfhcku4X20P3f0p39ulfBJF/0GDe4RpZY2WNtuF5gRJibQhbNZHxc9oLytPe+WYPOh4gkuE6u1y83gYnpltcYOAqWwEQFm8uSgpqdNvP2XLwGidxNDxWr21cX1uYYmivcBucKtE8NrReW/ba3NDpAODx5jzsZUAfhvSDHzOYtpIKS8v+XQ2Ur6GYSHMEFZGJ+c0HZ9KcyYuM4/TpWtiU7NBnQY6KMDaf/zHFGtuYobwM3hCIPU7c+DJs5tUHeR7F78MpCGYNJKaEzT2IVJoM+Q3drzBh83XPCjNgdI2mpNCjo0JdZYS0V79zndynzv4kk0YeF2eDM+fr78y37BFezdOECYWubBBDgNubfbMH2hL00R7WpMkQYpag3GFHbWiXbFUAzQjxGfpng== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: qYX3W4q3uX6QD8c5tbECTcw7T9M+zkMKImvvJSIfK3O2hWWvCjIpMzaHHBcewktyo7di5jkIUODjQc3hR7B0SompqsOKZ1DQqQf4gpwSmw/Jrt5j1KvAqs3GMGrZViBzjHnRzhITaBygpTTSp1R8Qizj8tCoJ025AdGxkQblon+zAI5wrdP2Jf+GaQZwMs3S6vsMmeGF7DZA2f40PvgXBCv+1X0kXyJhAcwGMKwJzOtHvcIFyDYG5LCFRcLz2YlOYRQzDLZ2kqWxb6RcmlgpBKFLCh0ScnQUJvUysJLkDe78KQX6toVWt6gpl0r+6R7EzGb9qeDl7Sy7zvHLobTAjvjMqgDUtWYK2pZZX2S5g7dHqlbflN/S9m1BtGUG7ik+QM7+0SJDnOIO5MKJ9I3MkAFgvCNKMoXcR0/Kxr03xxoe8RA/YB0pqoov9IHAuQHqU8Rizbrrv+p6oqh0Efx7JrkN659uTUqq1froZ60vjD4lliXGu+PFtgIsiGSwQyEKp8I+FeyjndukgyeJ13Awdm9sb67HI+N+ENsBbH3bR/o4WWVNhmpk6T/wA7FliI6GNTL9lNnVs6HCHseYgVTTys0Rqc0+fguMNHryUs9YR3P6bVpb5Xdmr/DDrVUeK61sCxtcnBeGJuHcQOXPkIteKetSkwgmoeCCoJMsZ0e6Vb2w+Rvi2hXnZTUKnIK2nmuOL2iJQGnwHBTs7A7uJuXJZvwyhCTw5UtIJDrJHkDqt5+eKXz0z/a3ZSJr+fAr0rfe5NaCWgwUaJg7z/HxEe5tNKHAP1MMtlLqPf6FXCRlbYeXiz2B+rqU29NGf2mYUFnUEik2eZrAMy1N9ipAbp0/Vv9XJn3bEQuoKtmzqOWIRIG6AgU1Hm1cVQrp7jtWuJbDsXKjUONQoRbKF2eneaVdQX80frFXshtRqh11jsKC1R0KilUoK8yyahAdQmYh+I85WXldI0nj2kUQ9p3rKGkGmggei16PWKJlWVWcyUDHy34WKbfKRDebCjmKTQY2cN6Rs6qxbt5srcCbAJKC5zXYOw== Content-ID: 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: fdd86464-bb04-4490-2aee-08d9e70fab4f X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2022 12:21:13.3472 (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: MAXPR01MB2320 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 --- v2 :- Use better approach to map fn keys v3 :- Use BIT(10) for APPLE_BACKLIGHT_CTL since 0x0200 (BIT (9)) has been used. 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 BIT(10) #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 Thu Feb 3 12:22:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 540211 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 18A87C433EF for ; Thu, 3 Feb 2022 12:22:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350499AbiBCMWQ (ORCPT ); Thu, 3 Feb 2022 07:22:16 -0500 Received: from mail-bmxind01olkn2020.outbound.protection.outlook.com ([40.92.103.20]:36098 "EHLO IND01-BMX-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238772AbiBCMWO (ORCPT ); Thu, 3 Feb 2022 07:22:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c777byYqlohGQCCY9D2bkZPUshNZaWbnRjC8G16gXo8DWXfyQe5eSKijGhp0h2lnNsdHmqrmgIt9HBGZAJtitWXTYj/egCC+21mpR+dCLLkA1jGCqTHyRkCkB3lk0AH/NYsKNL4Kwbkb5VDYdrhUtiVwPE+MaJdmEzugSXwoMvf6bLMbLWXZOYaTF3eDHcyN+jD9om7pihg7aeAsyvHpZVX8IzSpmKoWn/Vi1vw6+MUjRq03Edac/0SU2y7c+ouq7tLihJL9qCYrICTVAblKRES0sYpL/22QMNKM0jZGRDLCTDPcL8GQZ2iB5BLAvlWE4P9KjUjcCNEZXttdEyjROQ== 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=3ynjlUzo6Cjav7qfolIYsnNjiLNNvNMTJYB0yphqWXk=; b=ch+a8pQ0FMuLwyAWv19msoWgCWuncgn//BUJQjIaNDddrz7+Ip/tnM7up0OJL9TbBYn6+/8txqF5mDY9+p05+QZeF8FG0TZ42CY9LbB9CnrMpA8EiTmzTKqBYO/Ibb0au2aDcGEjfUbvh7Q1RrY+DDKZM9errGCi+LiXAeD0GLTHsV1s6QlJ5rq5Fm9CocGib1FMSUsMWAVrZIWV9drmEUT70+tjH2AqIE11m78XNE0WLJ7jGjzBlnBFPmhpVrPuXaoe7cIdEQNDNE56nwrB2d7Egr9seYNfblbMFsCShGGoGFM2lm4wrwgutTh7+A819Xmj+wH6z34yG7OiWZFGOg== 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=3ynjlUzo6Cjav7qfolIYsnNjiLNNvNMTJYB0yphqWXk=; b=WqVJl7Ods14oq9Hq8HtJF349nCI18HJbaxD3KMu7//rpZfCnMsjJhSn8e3XDwx+vxUikTRXXkjum73CH5WiBGcX36jHEhzFp54pUz2bUm2aExsc8aiBkaB31KI8oTmBmi8/aUNF+bd2AcbglOSm/1c711Zm6oOStfol+OHBqHk/lYml35hfm+i3sqCoG0QiiZVHXXAeNy3NqSzbFB7QsG3pRSgp8ddtR2tCI9OAS+FXRohhsCq7WLCvwmf8S9w3LvXRnoS6l+awaGuT7AQIp9Ued+j26nEl/SVE5gXFXlvsORrwlhoBfqpCPH6sThsxx3wbkkrEKJC0lxvvUAL1wRw== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by PN3PR01MB6934.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:a9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 3 Feb 2022 12:22:09 +0000 Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055]) by PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055%9]) with mapi id 15.20.4951.012; Thu, 3 Feb 2022 12:22:09 +0000 From: Aditya Garg To: "jkosina@suse.cz" , Jiri Kosina , "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 v3 2/3] HID: apple: Add necessary IDs and configuration for T2 Macs. Thread-Topic: [PATCH v3 2/3] HID: apple: Add necessary IDs and configuration for T2 Macs. Thread-Index: AQHYGPiqg2IJkgvOJ0+WrzX+lSIq1Q== Date: Thu, 3 Feb 2022 12:22:09 +0000 Message-ID: <9981348D-0D48-4613-A46E-03E9A1897E59@live.com> References: <67E7EA8B-CF21-4794-B7B4-96873EE70EF6@live.com> <1088ECFE-B356-4731-AC8A-09A4421DD7D1@live.com> 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: [lplVlAXoVd0ph1gcJqS8z7VrKMkfFF/H7qgHpw9DPtpRPINyB1qK9l5OVn53k46U] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 089af0f4-0157-42df-abf0-08d9e70fccf8 x-ms-traffictypediagnostic: PN3PR01MB6934:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2jcfK4A9aerpPldO9dwq+uJPJVVg8ZGyKM4hlW9vUniqhtEo2T3PU4q7tPugQAO2r1o83yvSyy5JweHfSwtyShHdzJFunRmihTYwJFiDbSTia14ztyfLLz2iF0JkcGM8vf8mrP/C3pddFAxVZijUobemMbrN9UQSTVtfsQ1RWbK5/3AaVR2GeH1NDHwqYlX9SeCRWvd7a5vnnwHRyv1dj4QFZwqqTiHUhspzOoPQpswQBDHy1aWcJkmyV6dOSlg3v9kM9i9r9AFwnOjAWqOygjMYRD1MCw+2r6Q0sysKiduSCTQSwJD7evN7uS4pKm4aweluyGhaquSqHQP2tRmGyJNx3RvEZEy2OQ+wf6jlB8U0P9ocyfNwWLfQOsiZXuPKVsg/+2oHsfUMGeuJpwDAcqBRMIAn7EKbtgsChzTm0cHQYR3zuCZAccR5f4uJT+pZByGM8q3a+2UNL3zxV8SDElsMaU7lhAP/wWirSU17AAC5jpdvlFh8ofd/5j/dOZ/QDR38RZ5NH3VWu8jFTjUAkd75lfLRROEtXuHeZ/gwP5nDrxRG3DR6WSaGql+zyScgNiVZNu46ehYDsS1XeFDNCQ== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: 8ExBi5FbXdsju5H12cktLBXEzlw2OxxQuvb37onW2MXUEhRRHxeG/XSUAiU0s2+FDGkpIE1hQmn8oz/KZXi00TDSWxhvRFNs4Yo/vmAT+3EXRfhZLrEfmI5ZH+ZLyhKRxr8JkQT0xicye+VyRdJv+jQ3I5iQWhWikjIjk+WFTut+KGb2l0gx9c0mGkxOAzFHXmYVMm9JxZ7MzPpwyj95NC3VNFJr3G721Xx+UOdg+Mp49jIIpZyAetfzhG319/mCyKyGe/0amw+hXVFkwdbPrCI/tDhgIEaYsyvSilsC7X7ISTiB7I3SaWnrRWlZEACJPV4bbCidtah8P5p6xLKzkV96Ja5GVmLHvRN5VOoAzSAa8dxXL7D4arvG65AlR77YCxTGvNrjPMtA+puX9X47wYdquFnbHxA3ProWuO8LZr4x8U+ey8Nuf/uDSFs4JiGkHi6xnPFVJ1JbB9gxQz7c6g8mc2Xjd272R6uA4Y5qftodjfkfuhD2EFZpjBmXUX7O+oI/b2IJcE6JISekCPrH5ryHMaEIHBvUjBuJ8L9ZLKxENCMNsD0D3pbAuZVhvYtuf5q/0aP7c5/k86B2DfnSKVP0U+1MFZj8P8EK1THLLNs0LyU0ZrRiNyCDSC67etlFS9IpiAYUoeSGb3cNu8kJnUi98iJyGZ2iNu4Nj5G4If4I5XxxdjXsK6hG8dsTBaOaM9BCmOg/UVWQlLAyFnhwMdKoIWEaS79qj82gaZ65KRyR94RUT/z8GMRgQRQzOOi3pyq5BaMpDKtSQqxWN9PITywY9bYMmoQ+gejoU/NxZrOQ/ZVje5ZWW6nHi2mRcRj5R23GK72UBcTDibHzQK0NKNvcB/58mvDHM92lzKiDHPHnVyKXTyW3s5KQPvXIsjW5bBIaA6hxlJ843f0JifM0CTK5iffYjy27xtjTuOVsBRzgj4JcxnLS5/xr01FpFQxVqX77aoRWtZKA5nWgF7LOZhyQyc1VtPuUnySXJqKSKzawiVsem7UZKgLpmYzDpyNyhed7srcvFOYw2T2qlqvYCQ== Content-ID: 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: 089af0f4-0157-42df-abf0-08d9e70fccf8 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2022 12:22:09.8541 (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: PN3PR01MB6934 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 --- v2 :- Use better approach to map fn keys v3 :- Use BIT(10) for APPLE_BACKLIGHT_CTL since 0x0200 (BIT (9)) has been used. 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 Thu Feb 3 12:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 539766 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 B2229C433F5 for ; Thu, 3 Feb 2022 12:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229379AbiBCMXI (ORCPT ); Thu, 3 Feb 2022 07:23:08 -0500 Received: from mail-bmxind01olkn2074.outbound.protection.outlook.com ([40.92.103.74]:3758 "EHLO IND01-BMX-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231842AbiBCMXH (ORCPT ); Thu, 3 Feb 2022 07:23:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WnSnL6JHc6DiAI5E7XUQDz0fsi8pdhrdXXyBYoYcUY/gsPXV/yXOzBPyqYYMq0voJyhoxaNYG//9cmg82b7U5YuZYPV9ZVP/POP9LjCly9ibJmsVaGIaTE42evpKb+JipBuIgOA2OAU9l9g5lCnXdgr/LrdbFt+v3JJQ4DaZzHTAUJbkSdtoBVDBnNAphnVKf/lvfJxMW0OE6mjb3kvbhUig1i2LNcayvk5fP6NP8XKCQFiizXteRk5O9pKMSIczzElpKTVn0BIjlfmEYEfigBsNE9tYFlNmvGV1PTX5G7M1hAjqLFdXIaQ32vcy2HJwSN6cwQuF5zwbxVz/HnRAmw== 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=31G4u6wEIIkwYzOfWErw6RaNsoVqvqzkGZmfnLC8M+Y=; b=kmtv0R/YAdjy8m6FfE5zJl5p+pGunrcAEEvdpc4Bd4zlDyySdFTmW9P7D6pOjsTiVBSZ82LXCxXltuHRYye2femg4/zsg/7AR7g78uEA4lwUcBWoJ72mDfxzbDgv5Vm71hxyv0SD6h3OmL6v6WozKl+3FsV+16ZUpsnqqPi53e6orZrKXedTZaw6r7fSIdqDgYN7+wYZ3c9LZ3sJvz/MaoeE1rW6YuMXUpDfqqGbVoCXSyK3nZLo+pq6JrlZLn1cfxFawezBT50mr6Wf4R5YugUq/ng0//GUcbOPcsRC9reTNbrZYdwI7XJehnBpKS9P7ZyJL1FdswWoclIQWvb36Q== 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=31G4u6wEIIkwYzOfWErw6RaNsoVqvqzkGZmfnLC8M+Y=; b=XhdIt85AOVY7Lg8OcBZ8gwWvSLaWlNY43XJaMu3E8s3GZ2bx4hJdLBWPRPjghiiTx0Zfot5xu5ml1y117oQPut82r6dazKZmmPC4nGajfA524AresKuvbwhPQCpzOuMOq0CdLPKJCTVN64s3NmEPc/D50k9m26EJOvr1O77yY0GyDvLhYTLa3TRD2YjxdCE3l2ytnYwqHwhP3VLMeqw3Dc+qr0YxL32mk8Didpw8SlU8EnteJqh9yYnV6+l/qDXlO0O+Z9v4MLYjeRA3wjr4O6jo8Hzea8fpsbT52afjSKUjVCt8ypxNJf10JIfxL2XzDKn9ga5dTj5pKrdGk6mQbQ== Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1b::13) by PN3PR01MB6934.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:a9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 3 Feb 2022 12:23:02 +0000 Received: from PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055]) by PNZPR01MB4415.INDPRD01.PROD.OUTLOOK.COM ([fe80::d19b:7cd1:3760:b055%9]) with mapi id 15.20.4951.012; Thu, 3 Feb 2022 12:23:02 +0000 From: Aditya Garg To: "jkosina@suse.cz" , Jiri Kosina , "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 v3 3/3] HID: apple: Add fn mapping for MacBook Pros with Touch Bar Thread-Topic: [PATCH v3 3/3] HID: apple: Add fn mapping for MacBook Pros with Touch Bar Thread-Index: AQHYGPjJEELh7X6UMkCMSdLNxORFRg== Date: Thu, 3 Feb 2022 12:23:02 +0000 Message-ID: References: <67E7EA8B-CF21-4794-B7B4-96873EE70EF6@live.com> <1088ECFE-B356-4731-AC8A-09A4421DD7D1@live.com> <9981348D-0D48-4613-A46E-03E9A1897E59@live.com> In-Reply-To: <9981348D-0D48-4613-A46E-03E9A1897E59@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: [v8fSPPYqYFnVLCqIq7YI6GxCi/p4bvY2Z2Lbi1V86uaCoOfE6euGa2B9aCccVU+r] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c62a2cce-35d7-45e5-1d25-08d9e70fec6e x-ms-traffictypediagnostic: PN3PR01MB6934:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: XXQD3jKnoQgTbErPoBCYKew7C60DuJP8YbnpIf5A18qMHzGRzGLuoeFBBVFymo/JTSVoD17tlDPTAW1eVuI7Csy7TS9DbTvO17NrOiJb0bZ5HVqlp2nBgmXQQK2ftDshOOvdv1FZwiGz9IHLFHS+3Kec+85ePOK5pYnn7CVzT+jTWfS4RvGYwE8+aEQA5DJdUcZ5/WYgsNhsVsqhF76CbItPexnlAvlenHM7y6gaKLaEllV0jDSBuouxpCISEkpFviSsHqTl6c2TWPLgAy+gAUR43MppxzsUNf2FdcKClr0T52cYh02wasqupAubDCmhXTwg51Kf58mL4ApBSms2/QkrtHVH0LAGke2alPLlG2AvqhlcnGdzRrR6j0yHGvFjHq1hvav0p61dqDgcndZNMJopR7R1VeL7P3i+epTudGNVHRu40LGZFf07aP27l81Bzpsj9ZPcLIYBBIVJ+WWdWSnN5g+8Vwezy0unBqULtGixjyDDXnxrIy76rYgVReZpRhAttL1cyVoPECCfFtB58T8JGZFVKuRJJxm9tpwqiAv8dM849CgPckwQ7bL+rWRJ62R6mJQZQfe3jalrT9Qesg== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: zXHt7zcLPsz8DdSZ96MaMT3uTMG5SrSyf07dks1bdPUEKSMS8o5b3dUSjQjoU7UJT2/TFyA+TDHno+DbwTqQPKKtphbBxNimB9pLPj2CpUNCjtdUfKGFLPGUSeWCMRd5L7hEOB9hz9RQDMkny4y5tjkc47YNFU/LkdB02JlrhXq3MFameUT7Nq4u5m5Jc9Oir+fxPSa3JLHqP3TDmue2jOtPvo+HqkvTi05DGXcXmUlq/Do46G0EgDcCFxaZv7GCipRnUJJwS8AAYhuFq49a/3bZPN4U6DI1qivHTdUfRJ0bffKrrdKD3MsQ2eMZbx9S44zTmrvWuTBxkbrU3A1kZR8gZdnY/rhgRcgsqeB+MohM553V3gYDUeR9zl+fjgJZWBxfpJV1/FiB+m5hKdFDyK2npaQnuWFKnMIwKHbaWq0EehZRjH7qhyfVtaNl+d1OvvC8DbDlqWFbLrOBDyT7q3F9osqF5kz048g3YLB+ve/8APE+S7EpBoa1SSLZXypBR0xjdFWp95n5b3oD5v1D1pLw0s4sc6p/H5I+0FsErD1B2aU7dRPsaiS3tF/ddHKkNGY2xAdKx48wFk77rmkTMTtkOwMcXmBNFk8LZxAarTLFlAkjwALZoI7gTzOi2TP/jc4z3gU/ZL4vx0UFVqolMDrluAj+e28BmEGLv4qRAWBVq0v+qU/Bbh1E/s94FX/6/4unM74KLl5JCmXoXej2EsI6yCKQjj21Ojvel9EgzQABTUUirWVbYubvzLsKIEvd3iqt1HiyxuXYRJrxHMPM3IHLrJA/neZiUUk7HTU6Pf+v7KFiiKSUihMKWr3xww1RjbEV+g+M45zjGSXE3nuX6zV5AiT/ZPRZskfL7I1Zbsg1ROu05vNamQ2SBSzQwxar7SJrZxJDVkn+d4jN/hu1jkCWtaXPlWO2tqOxwg4vUwyFvPL3pQnn2I5iTN2MvNZQdlI+R/LOQERXd0qy3MPTfO2SpE6/pC72WU/MUUYfT+t/kk1tCcf/8l30K3tcg/1t0XwBnMyWHwHAroB3c1j/pw== Content-ID: <4B76671B3AEB7E42AA39D2E1335B6AA6@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: c62a2cce-35d7-45e5-1d25-08d9e70fec6e X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2022 12:23:02.6488 (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: PN3PR01MB6934 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 --- v2 :- Use better approach to map fn keys v3 :- Use BIT(10) for APPLE_BACKLIGHT_CTL since 0x0200 (BIT (9)) has been used. 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);