Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3095471pxb; Fri, 4 Feb 2022 00:51:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1nMt73YvGHgkdeKyB2E6cpXK50/ZK2FuYCnsP2MUzerYBsGYzLYfOmQ1dkU+8t66R/ZWK X-Received: by 2002:a05:6402:1ac5:: with SMTP id ba5mr1978456edb.337.1643964699969; Fri, 04 Feb 2022 00:51:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643964699; cv=pass; d=google.com; s=arc-20160816; b=H8u+Uh3LpzSbosv41ixcgRXBNjh37vFWbk1B3NukYFh/3H1UKFYE0nxgtXuleAIjY4 RpXvXhJug3P3mlus6GKqy7Hmte3r322N++t6wSZy1xNFeOz+bxiAiymro2R2Zu+hzwlS cWVsDO4nviD/ZoLlGZNa1Lycm9qbLvdQeLdPHzHglwsOhGzsW6TXeJ0hZGpm1JbJ7omS q+YM/h/dhbKdggp5gzRw24oeDdWMmWTp2tbdy0xJNl2bxo0O5Mor/R1TO16IpgB392+7 MEdCThp18QiW/XE95XBl6cONJt5pJt8AXYApjz4uGSbAYzgs6sKmL5o4tBN5lX01CzRE WB8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=31G4u6wEIIkwYzOfWErw6RaNsoVqvqzkGZmfnLC8M+Y=; b=gGwIXusjzSMRNTslQ7HlHBDLebz2FGqRRXYLXK88Uo7TdZvtN2JRky8f1VmSvexy9e UF/CDf7w3AInZW319s9EFMADPIjWVHFvBWwLoyS3XyAIVY/M4YU4zgiFtMOrSlvKk7KN WjbmxEHxbEHusCrBNXktXdk8HSGGQP8mxm+eAu7n1sxg2n4FUeqm6S5lI8EvM3fgvXaN 4jLiU93HZi5LMYeMnSm6zvy4jAlnZFZ9/cPeRg2TeL4Srj3gFY+IKk9vWkYeZ7v6BBKU IMagugHwnU5DoDhqq9gqKGCIIN5xWR5ISmLFR/YVU1xMLO3dJiVVoT6NrimeFsk3VLUb R7OA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@live.com header.s=selector1 header.b=XhdIt85A; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=live.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb39si976250ejc.1.2022.02.04.00.51.14; Fri, 04 Feb 2022 00:51:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@live.com header.s=selector1 header.b=XhdIt85A; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=live.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239831AbiBCMXI (ORCPT + 99 others); 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: =?us-ascii?Q?zXHt7zcLPsz8DdSZ96MaMT3uTMG5SrSyf07dks1bdPUEKSMS8o5b3dUSjQjo?= =?us-ascii?Q?U7UJT2/TFyA+TDHno+DbwTqQPKKtphbBxNimB9pLPj2CpUNCjtdUfKGFLPGU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2SpE6/pC72WU/MUUYfT+t/kk1tCcf/8l30K3tc?= =?us-ascii?Q?g/1t0XwBnMyWHwHAroB3c1j/pw=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: <4B76671B3AEB7E42AA39D2E1335B6AA6@INDPRD01.PROD.OUTLOOK.COM> Content-Transfer-Encoding: quoted-printable 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-kernel@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 u= sed. 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_f= n_keys[] =3D { { } }; =20 +static const struct apple_key_translation macbookpro_no_esc_fn_keys[] =3D = { + { 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= [] =3D { + { 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[] =3D { { 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 =3D=3D USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2= 021 || hid->product =3D=3D USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021) table =3D apple2021_fn_keys; + else if (hid->product =3D=3D USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 || + hid->product =3D=3D USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 || + hid->product =3D=3D USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) + table =3D macbookpro_no_esc_fn_keys; + else if (hid->product =3D=3D USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K || + hid->product =3D=3D USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 || + hid->product =3D=3D USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F) + table =3D macbookpro_dedicated_esc_fn_keys; + else if (hid->product =3D=3D USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K || + hid->product =3D=3D USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K) + table =3D apple_fn_keys; else if (hid->product >=3D USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && hid->product <=3D USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) table =3D macbookair_fn_keys; @@ -480,6 +536,12 @@ static void apple_setup_input(struct input_dev *input) set_bit(KEY_NUMLOCK, input->keybit); =20 /* Enable all needed keys */ + for (trans =3D macbookpro_no_esc_fn_keys; trans->from; trans++) + set_bit(trans->to, input->keybit); + + for (trans =3D macbookpro_dedicated_esc_fn_keys; trans->from; trans++) + set_bit(trans->to, input->keybit); + for (trans =3D apple_fn_keys; trans->from; trans++) set_bit(trans->to, input->keybit); =20 --=20 2.25.1