From patchwork Thu Aug 8 11:54:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 818338 Received: from IND01-MAX-obe.outbound.protection.outlook.com (mail-maxind01olkn2029.outbound.protection.outlook.com [40.92.102.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 406DC4A33; Thu, 8 Aug 2024 11:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.102.29 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118074; cv=fail; b=SKHh9jsy7PqSKXNQonNsJAX8JYpLztg3tKV3623fNgQ8DK4MsW3yUNnzK1YUQLOb2NHDFJzfIA5+bPlYZmpGTcul6UcDt8k2nIn7zYmj0beQVcHvEshcU3FfPTh+Nq0zyzKe+S5MbW03RTJCPzSGlByGUnZ5o68sOknHyfcR0bA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118074; c=relaxed/simple; bh=Akx0MrXpd+JVj1ZDV4IdDdBaVXlyzdtgQ3clE80/1X4=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=uxYebRS24NfSvX/pFW+Bi+mWZZCFubgXiKBbGyL3moABizUzL9ufMzShdRLSadUnsL6ybZ9rJLdtaCQACFJ2RV8wg5QplsaVK5njYiNYI6x/GobaxcSoC5N38pIZQw6T2kshAib8nAnNL8iFQWgRA1Shteddmt5iTFj+mRI8/so= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=sPv6ilxc; arc=fail smtp.client-ip=40.92.102.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="sPv6ilxc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DUZupMM6GHkZlsHtl8hk7nv5IJu/D+7DwcoVYxJlUereL+a7FLtjHvDndAVkkteVwvkJpjr1b0DW7ONmR6lDQ/muV2cTcNBYSMf6tDaAwiCGOVW0oSVFKmcjoM1M0BK3ojRlug4bRQvEYha5qc8zI49a11nyspwzeQjuvxOsl82EyqV4iuhe2/w9img1wNhngcDBvb7zo3Mbs39EMCc547z3lUS9nOu/zq6WUFMc51yKxJl4OV3zIu0aXvNvA1vnhpJgrmu1kPuuTpsO9sqSqZrerDvKjKtU21M2DPBoVB5bRrBGCZurP6hJE1fG8X4dGZSIa3e419AuPjFoaR4GQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Akx0MrXpd+JVj1ZDV4IdDdBaVXlyzdtgQ3clE80/1X4=; b=uBvP5ZyiZ9HfsyOaxaUcKuw6duEyeUAV41yP+f3U0NPUgIBCOdEXsYWpd/dbovjOx+EjW3gyg9BkOjNZk8x8VQJPTiBiyMw+LDwwJtpebnD0Da7/SIYm1WCeIQTeTuc9MDDx759mGMTOUPJMQCN9Qk9/xRicPPtnFfruKFPHSpZw9mqK982d66ErjwIj6rN9AUlpqSMuy7Uypxm6Pp334UF+cSqluBEqRkSg9ny0WvlVtt8b+4AxDn9J+slnY/N5Twoeonm3s+6HHkT+PAmL93GXafPPAKPaypXmdeo9PX53S9WkZeiiMVQiKUSQSthaYwh0KxdtDyHDE1Inu5F7mA== 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=Akx0MrXpd+JVj1ZDV4IdDdBaVXlyzdtgQ3clE80/1X4=; b=sPv6ilxca09IIDetTPzuk7wibd1Q+IYlDNY5iSm33rtI/oPIG6wkpLvoYLslAQNCkP1gnCoHCWEfM2/KfcAy2qPkbEWzYfmz8EkgmQTfg65b/29S46LPytoJR04WcSd238xb3bBXg4RYZKLqHV6+gvknVs5MLmAV/MdXvCcnHEK46D3qIVGvts5BegpRUuVyCDQ37yKax3KML0xS01bb8ce2InywcM8nwzmu17aWBTfg0QetL7ym7OS+o8v8ZWfoKcNScIocz6cZjHwu5FyVvnSC+ov6s5ajzXVVURtGYwK+99V/a2vXG0NkxbCYfqDhTxD7o81nW8NUM9aAdAYJyQ== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by MA0P287MB0680.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:11b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 11:54:25 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%5]) with mapi id 15.20.7849.013; Thu, 8 Aug 2024 11:54:25 +0000 From: Aditya Garg To: "tzimmermann@suse.de" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "airlied@gmail.com" , "daniel@ffwll.ch" , Jiri Kosina , "bentiss@kernel.org" CC: Kerem Karabay , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "linux-input@vger.kernel.org" , Orlando Chamberlain Subject: [PATCH v2 1/9] HID: hid-appletb-bl: add driver for the backlight of Apple Touch Bars Thread-Topic: [PATCH v2 1/9] HID: hid-appletb-bl: add driver for the backlight of Apple Touch Bars Thread-Index: AQHa6Ym3gmD6gtRo4kOUi8viR/zBrg== Date: Thu, 8 Aug 2024 11:54:25 +0000 Message-ID: <0E5065B4-8E9E-4E4B-A504-54E20EDDACED@live.com> References: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> In-Reply-To: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [1wpSoEXkGnEJ0bP5ZmGrBaTVPEdm6vrcsqMxVRrxdpwpEAdQRNGTxOLj+V1bahP3b6dBYUHSUCo=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|MA0P287MB0680:EE_ x-ms-office365-filtering-correlation-id: 12ff68ce-f43d-4176-586b-08dcb7a0d9d4 x-microsoft-antispam: BCL:0; ARA:14566002|15080799003|19110799003|8060799006|461199028|440099028|3412199025|102099032; x-microsoft-antispam-message-info: 4U9Evb3llAGzTRc1bryvR7BM77FC55NHCKf1LhgPQtA6euvMak2IpJPY4yHdWi3YlyX27F2W6aGWjDWoymnJyZLTq6Lw2FTh+6L5NEdlPA9GdsgyYFNw6Tl/k2xqBSF/1HDiZGR6nNwzVT0/0dz/kf4Tpc49olF03HkScbkva9830VgqhotAmrQMHG2Ir3NkNa7rB9A2hyoRn9BSi2nJLjyaVJ7eKcZa+71yUu8QD0Nw2W3hoOJ9va4cIyPneEo3w0ILzMMeJ2em+B3wYqg/xqS0KxzhB8/8yaaNBF4pRTm4qiKNsr9Z67fFqf08QqnmZszkkAYFnv9QFa4LLRzRlSjSAZcJu+WGEzKj9QVNwHDJV+xRDyHk9PmMY+6/D8MNeudqqS/LCAuyLSLiU/QDnctm0ZyMjR+hGmXYSg7wPPzwD78+djAexUQdgXh48UMEGwukMTgdPT+DRQhJrlZUH39v2kqA6OBEIVQMjG6bznss3oQ4lFIww8azJwdOxKmgmImRJ2Djnbx2Uj1DhmDxqBRRulfskN5LDA1KaL5r+WkSDJ78QuXNtHvGCJtjOBZ91QO156wmKgAi4VEju6tjqSf4/vjxCp7/zd8WfVzLvAS8Xhun+sKjHTA0u8/NMBUd3Hy+x9zdkuyVNOFSdMdJ45AMd0d4oFINJ5WR6NXAKX9A7kpx7XF2MvEuJWMPY/Xq x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?D/1s4plgpCDUnm6zCdfK2lJuL6rc?= =?utf-8?q?iY/uSEtoKhbnFFqMBzQoojzSi5VC93MmNgfa7AAOsPIXpkghRDMPNa7xEWCJ678Yq?= =?utf-8?q?C0Qzw+vDAkOMrVY4G3lamj6r/5VsroE5LgyPbSZwrVKQP4h+KlfUztm336AYd1vyi?= =?utf-8?q?cnhcVT1iX3J7V3JnrCv/Euf9QVLxFymiPkOXkvccMC2EvfwnBF6pjVil8a3h9w3DU?= =?utf-8?q?4QmPNoEfeWzI6w4EZYFnH563t+1jO1Zhe8Vb2vSK04yTY5thTQVjt5FNLkv8m4v+Y?= =?utf-8?q?cvA6D2yTpTqC6+DlI8ypv7JSBe38OyqOQ4HEsAILbhKYBmFj4WuDdRmUsz2AhJ+iZ?= =?utf-8?q?IG6biJP0hAVKtPwH/4Z+xuEI1fEO+dYPH4BYw4TLwG4iLJrffdVnHLKbbotvm47jy?= =?utf-8?q?F2QxLXgJ3OBmbEMpk5mznHOzr057n4HfeZDZOWeaminRftEsH/rC5zcTGu/bmpB09?= =?utf-8?q?zndlyetx6+0AbIQAvzvquMHpRQr7JCJeIK8YnCoGnSydKvY5BLbBGp/7/AXOHXGFy?= =?utf-8?q?xbq2Tv03XIuMiDeYzJNdGsoJPAWnJOZ4ztpOIrgQBxYZeu7Zz4bYm8WqeN4UBFkXE?= =?utf-8?q?yXwRz0bqYUk+VDSgMeoDqmp6a0D5nnb+kO1Vu+mzZNfjXR9Ucctys64ztHGLAaHsr?= =?utf-8?q?xSFyGr2ICt7v2Mt5i84b94IB2LvWaiO9YwwDiPFSkw2KfzQNJH3mLaQx74RTPErtV?= =?utf-8?q?vl0qAQKGTAoHIzI7iJhNXA+LQiYA6em/lDl2Zxb5oN5dYIwcaXQTrl2IQhX8RmlX4?= =?utf-8?q?gGY0CLg/JilDcckaGtdwnRUw9DfC/6StEqMqfmaLeJjAa4pi489Px67nlA8+XcgTV?= =?utf-8?q?mwlLi18vgxbUT6TDtJ+M+gdb31SkaTtXkqKeO93GaqQveDtLByE1OqzcTE7wrfWpf?= =?utf-8?q?vkfSjyCLaIeMWEFKS/Zfc14uVTBxbWCIZU1nkbzlpD41j3HShXinHBH84BGX5Rg/c?= =?utf-8?q?5RmYDvDJXY1zQH2DJFSPnZh7RbQ8mF9637wZvWRHGAP7XT69ahDZPQn+7HHRoM3fQ?= =?utf-8?q?h0kB9a5lOtsNaK8mrrMpU5S9/JHh69JZiv1UXTYFjtFUvikEfc3YAAmutr+cr8LWP?= =?utf-8?q?7Z2m/IAELVEBR/+xO1PGwO1iuxO8hJg4maiQLXOjXrTCVlWsxOLwMXnEg7b+owMn9?= =?utf-8?q?2tqktH900R+7jUWBXTRuH+ph5cmNsuLEAIB4UmOi9P1V79jpYkO1BYHDgQdik4iAI?= =?utf-8?q?f/pY2oTIuKSjNnqqwo0zGrCBKfN0dcPmtqPiJMyc2n8YwAC1j/KB+7H3CrrVPFs7c?= =?utf-8?q?Viyitbtq7O+G75cz?= Content-ID: Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-24072.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0217.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 12ff68ce-f43d-4176-586b-08dcb7a0d9d4 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 11:54:25.6539 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: MA0P287MB0680 From: Kerem Karabay This commit adds a driver for the backlight of Apple Touch Bars on x86 Macs. Note that currently only T2 Macs are supported. This driver is based on previous work done by Ronald Tschalär . Signed-off-by: Kerem Karabay Co-developed-by: Aditya Garg Signed-off-by: Aditya Garg --- MAINTAINERS | 6 + drivers/hid/Kconfig | 10 ++ drivers/hid/Makefile | 1 + drivers/hid/hid-appletb-bl.c | 206 +++++++++++++++++++++++++++++++++++ drivers/hid/hid-quirks.c | 4 +- 5 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 drivers/hid/hid-appletb-bl.c diff --git a/MAINTAINERS b/MAINTAINERS index 8766f3e5e..ac27f41d4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9931,6 +9931,12 @@ F: include/linux/pm.h F: include/linux/suspend.h F: kernel/power/ +HID APPLE TOUCH BAR DRIVERS +M: Kerem Karabay +L: linux-input@vger.kernel.org +S: Maintained +F: drivers/hid/hid-appletb-* + HID CORE LAYER M: Jiri Kosina M: Benjamin Tissoires diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 08446c89e..4988c1fb2 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -148,6 +148,16 @@ config HID_APPLEIR Say Y here if you want support for Apple infrared remote control. +config HID_APPLETB_BL + tristate "Apple Touch Bar Backlight" + depends on BACKLIGHT_CLASS_DEVICE + help + Say Y here if you want support for the backlight of Touch Bars on x86 + MacBook Pros. + + To compile this driver as a module, choose M here: the + module will be called hid-appletb-bl. + config HID_ASUS tristate "Asus" depends on USB_HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index e40f1ddeb..1d825a474 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_HID_ALPS) += hid-alps.o obj-$(CONFIG_HID_ACRUX) += hid-axff.o obj-$(CONFIG_HID_APPLE) += hid-apple.o obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o +obj-$(CONFIG_HID_APPLETB_BL) += hid-appletb-bl.o obj-$(CONFIG_HID_CREATIVE_SB0540) += hid-creative-sb0540.o obj-$(CONFIG_HID_ASUS) += hid-asus.o obj-$(CONFIG_HID_AUREAL) += hid-aureal.o diff --git a/drivers/hid/hid-appletb-bl.c b/drivers/hid/hid-appletb-bl.c new file mode 100644 index 000000000..00bbe45df --- /dev/null +++ b/drivers/hid/hid-appletb-bl.c @@ -0,0 +1,206 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Apple Touch Bar Backlight Driver + * + * Copyright (c) 2017-2018 Ronald Tschalär + * Copyright (c) 2022-2023 Kerem Karabay + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include + +#include "hid-ids.h" + +#define APPLETB_BL_ON 1 +#define APPLETB_BL_DIM 3 +#define APPLETB_BL_OFF 4 + +#define HID_UP_APPLEVENDOR_TB_BL 0xff120000 + +#define HID_VD_APPLE_TB_BRIGHTNESS 0xff120001 +#define HID_USAGE_AUX1 0xff120020 +#define HID_USAGE_BRIGHTNESS 0xff120021 + +static int appletb_bl_def_brightness = 2; +module_param_named(brightness, appletb_bl_def_brightness, int, 0444); +MODULE_PARM_DESC(brightness, "Default brightness:\n" + " 0 - Touchbar is off\n" + " 1 - Dim brightness\n" + " [2] - Full brightness"); + +struct appletb_bl { + struct hid_field *aux1_field, *brightness_field; + struct backlight_device *bdev; + + bool full_on; +}; + +const u8 appletb_bl_brightness_map[] = { + APPLETB_BL_OFF, + APPLETB_BL_DIM, + APPLETB_BL_ON +}; + +static int appletb_bl_set_brightness(struct appletb_bl *bl, u8 brightness) +{ + struct hid_report *report = bl->brightness_field->report; + struct hid_device *hdev = report->device; + int ret; + + ret = hid_set_field(bl->aux1_field, 0, 1); + if (ret) { + hid_err(hdev, "Failed to set auxiliary field (%pe)\n", ERR_PTR(ret)); + return ret; + } + + ret = hid_set_field(bl->brightness_field, 0, brightness); + if (ret) { + hid_err(hdev, "Failed to set brightness field (%pe)\n", ERR_PTR(ret)); + return ret; + } + + if (!bl->full_on) { + ret = hid_hw_power(hdev, PM_HINT_FULLON); + if (ret < 0) { + hid_err(hdev, "Device didn't power on (%pe)\n", ERR_PTR(ret)); + return ret; + } + + bl->full_on = true; + } + + hid_hw_request(hdev, report, HID_REQ_SET_REPORT); + + if (brightness == APPLETB_BL_OFF) { + hid_hw_power(hdev, PM_HINT_NORMAL); + bl->full_on = false; + } + + return 0; +} + +static int appletb_bl_update_status(struct backlight_device *bdev) +{ + struct appletb_bl *bl = bl_get_data(bdev); + u16 brightness; + + if (bdev->props.state & BL_CORE_SUSPENDED) + brightness = 0; + else + brightness = backlight_get_brightness(bdev); + + return appletb_bl_set_brightness(bl, appletb_bl_brightness_map[brightness]); +} + +static const struct backlight_ops appletb_bl_backlight_ops = { + .options = BL_CORE_SUSPENDRESUME, + .update_status = appletb_bl_update_status, +}; + +static int appletb_bl_probe(struct hid_device *hdev, const struct hid_device_id *id) +{ + struct hid_field *aux1_field, *brightness_field; + struct backlight_properties bl_props = { 0 }; + struct device *dev = &hdev->dev; + struct appletb_bl *bl; + int ret; + + ret = hid_parse(hdev); + if (ret) + return dev_err_probe(dev, ret, "HID parse failed\n"); + + aux1_field = hid_find_field(hdev, HID_FEATURE_REPORT, + HID_VD_APPLE_TB_BRIGHTNESS, HID_USAGE_AUX1); + + brightness_field = hid_find_field(hdev, HID_FEATURE_REPORT, + HID_VD_APPLE_TB_BRIGHTNESS, HID_USAGE_BRIGHTNESS); + + if (!aux1_field || !brightness_field) + return -ENODEV; + + if (aux1_field->report != brightness_field->report) + return dev_err_probe(dev, -ENODEV, "Encountered unexpected report structure\n"); + + bl = devm_kzalloc(dev, sizeof(*bl), GFP_KERNEL); + if (!bl) + return -ENOMEM; + + ret = hid_hw_start(hdev, HID_CONNECT_DRIVER); + if (ret) + return dev_err_probe(dev, ret, "HID hardware start failed\n"); + + ret = hid_hw_open(hdev); + if (ret) { + dev_err_probe(dev, ret, "HID hardware open failed\n"); + goto stop_hw; + } + + bl->aux1_field = aux1_field; + bl->brightness_field = brightness_field; + + if (appletb_bl_def_brightness == 0) + ret = appletb_bl_set_brightness(bl, APPLETB_BL_OFF); + else if (appletb_bl_def_brightness == 1) + ret = appletb_bl_set_brightness(bl, APPLETB_BL_DIM); + else + ret = appletb_bl_set_brightness(bl, APPLETB_BL_ON); + + if (ret) { + dev_err_probe(dev, ret, "Failed to set touch bar brightness to off\n"); + goto close_hw; + } + + bl_props.type = BACKLIGHT_RAW; + bl_props.max_brightness = ARRAY_SIZE(appletb_bl_brightness_map) - 1; + + bl->bdev = devm_backlight_device_register(dev, "appletb_backlight", dev, bl, + &appletb_bl_backlight_ops, &bl_props); + if (IS_ERR(bl->bdev)) { + ret = PTR_ERR(bl->bdev); + dev_err_probe(dev, ret, "Failed to register backlight device\n"); + goto close_hw; + } + + hid_set_drvdata(hdev, bl); + + return 0; + +close_hw: + hid_hw_close(hdev); +stop_hw: + hid_hw_stop(hdev); + + return ret; +} + +static void appletb_bl_remove(struct hid_device *hdev) +{ + struct appletb_bl *bl = hid_get_drvdata(hdev); + + appletb_bl_set_brightness(bl, APPLETB_BL_OFF); + + hid_hw_close(hdev); + hid_hw_stop(hdev); +} + +static const struct hid_device_id appletb_bl_hid_ids[] = { + /* MacBook Pro's 2018, 2019, with T2 chip: iBridge DFR Brightness */ + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) }, + { } +}; +MODULE_DEVICE_TABLE(hid, appletb_bl_hid_ids); + +static struct hid_driver appletb_bl_hid_driver = { + .name = "hid-appletb-bl", + .id_table = appletb_bl_hid_ids, + .probe = appletb_bl_probe, + .remove = appletb_bl_remove, +}; +module_hid_driver(appletb_bl_hid_driver); + +MODULE_AUTHOR("Ronald Tschalär"); +MODULE_AUTHOR("Kerem Karabay "); +MODULE_DESCRIPTION("MacBookPro Touch Bar Backlight Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index e0bbf0c63..818d41a35 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -328,7 +328,6 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021) }, - { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) }, #endif #if IS_ENABLED(CONFIG_HID_APPLEIR) @@ -338,6 +337,9 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL5) }, #endif +#if IS_ENABLED(CONFIG_HID_APPLETB_BL) + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) }, +#endif #if IS_ENABLED(CONFIG_HID_ASUS) { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD) }, { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD) }, From patchwork Thu Aug 8 11:55:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 817801 Received: from IND01-BMX-obe.outbound.protection.outlook.com (mail-bmxind01olkn2105.outbound.protection.outlook.com [40.92.103.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14CA64A33; Thu, 8 Aug 2024 11:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.103.105 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118135; cv=fail; b=jnX4iEhIuYayJwrvKGUm5LE6iaBND2BhzO+K2hlaoSvDwnlzSAgLuppzvVgz8HnlJImWLmZhPm8cjxfKuszm1RpVildbqCfW9nwfHCV4oAuPyP+CXc7zpUvaSlsWnzBrKeZ/4bNxS5cs87DQNAxodOC4jhi1PANKr3dF28nax9A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118135; c=relaxed/simple; bh=Ga/M1/3AQHeq+4L170paz3HOKdDlLhcATXvdBhfkEks=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=aBf4o7MtOOIFvXA9uqsOKlnZJsRQNpBZXIRTmfrWwtqmC4MDLPZHovXQIHKoD8IUcHE6lprSngiWFxC5BOArFSi2ThKRN6E8+lRZ85fLFTbTCOsplfqsWKRDvX67IrYbZSUaBbEfnMYnchiY256DBDBQV5icQlNqYWlO9sxZ12g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=mzMiY/t6; arc=fail smtp.client-ip=40.92.103.105 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="mzMiY/t6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uunBHw7h7G2At1jfRud8hOofLNvwv2uxRjKi0Omu8i7u4Aj/P442YNI27/rqZbdvRdjdG7djGcVuLspkA0nlUJFDmC3FKT+TEGWscZ9RA2cwQu0WhJ1cNCmSIDEWLjJUYKxYNKTYwxlp5AOAWs6hEWQGfeCecRMOu1a4t0HHw3ROVmfmELt6U7sHmbGQbwIKrddWWcFUEZzjToIgjv3fq83c2pR1IwlWyPRodp+2O/3iGxASbrqozgFyBOyo90V2xnVJI6nVdU9I778yhtaUwUxm3TtJrX9Vxkc6Wv5C3CkycqtWNRbMajUH4CoEpsumzFmTfOcsJGSOWJ3eguQVbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Ga/M1/3AQHeq+4L170paz3HOKdDlLhcATXvdBhfkEks=; b=MDuiK3yPEEQbyaW3lyZobg49vJoF6yBu7uAtMyLAZUpmfVRdCRxN9PVllTh1yWyzEJHC2g2mFs8rNKuWGpbL6U6OPBwW5PN9fuDHygmlEvj9yQYdccNDgk+I2IWVSsJy3NSACdVhDqPCh6VPyuVvLDPGko8uUGhvPEyD518P7hEsNEy6JIq8DB9MEhSYnq7vf1ScIO+P79kganJDbhmoErgRpZdynwejM1rrYzOsiTlvSIeH1u01SLhKyQWh/DQriRgsWAe3rrTJkM1Jhb/zqA3DDwMoaE1wa0WRRyxJFsAksLYnt0+OoHfVttuP1T0Qhd+DCWfMBKMrtAILLDzhwQ== 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=Ga/M1/3AQHeq+4L170paz3HOKdDlLhcATXvdBhfkEks=; b=mzMiY/t6DmFbm18gKXbDITQXb4K1kEQUrr74fkPLSw14Wyoozbw9kTHQ7XumVtIzPZnUuDYLGjwSt0xyyrTDUEjxUcMx+YxRTzIxb4e4nomDpj25pScEq3vUWJiCktpCgUeJDCTEHOkBIxqalkzq6WQADGrNx6UPLPP1815834w09XUNPm3R6TtPRXmdaztvQu/bBjygSmr376ZPIT7La0BubEQ44O8LlrYsshUJ01Yc6BdNJQs2il7HlbSucf4I9peox4A5Ac/f9c7jRBpAfcO5QmXNqeQuETMQofiMbeTAB7jUuExCaRHStFLqgvfCLD0GDyMh8rFCxwnaHEB8Bg== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by MA0P287MB0066.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:32::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 11:55:26 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%5]) with mapi id 15.20.7849.013; Thu, 8 Aug 2024 11:55:26 +0000 From: Aditya Garg To: "tzimmermann@suse.de" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "airlied@gmail.com" , "daniel@ffwll.ch" , Jiri Kosina , "bentiss@kernel.org" CC: Kerem Karabay , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "linux-input@vger.kernel.org" , Orlando Chamberlain Subject: [PATCH v2 2/9] HID: hid-appletb-kbd: add driver for the keyboard mode of Apple Touch Bars Thread-Topic: [PATCH v2 2/9] HID: hid-appletb-kbd: add driver for the keyboard mode of Apple Touch Bars Thread-Index: AQHa6YnbNuqob1CVeU2yIVyua5P1AA== Date: Thu, 8 Aug 2024 11:55:26 +0000 Message-ID: <72D82E74-8EFF-4B1D-BBA8-0304D3775A4C@live.com> References: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> In-Reply-To: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [u0E79gfHO3u+Prxqz8BHui46KPpq+Mto5GMItaydNTCKf9klkHiNb/gxOqtdrfx3] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|MA0P287MB0066:EE_ x-ms-office365-filtering-correlation-id: 3b4a3125-b16b-468c-2b49-08dcb7a0fdf7 x-microsoft-antispam: BCL:0; ARA:14566002|15080799003|19110799003|461199028|8060799006|440099028|3412199025|102099032; x-microsoft-antispam-message-info: Ur98QxrgLrBRKlzfLByzv2309igeq5Hd37uABG87PnCdTSUycAy4E6hcC5lX8YOg6UlEJ4bD6SCqaJDRCr+a1UWBT9Gc6mNyPJhJ0dKMJjGcvo2D3uS32YbaBR2GXkhQ10HZG4+GAAXvh44mPxSmTaGhDPCBBuewLKu/d5xqhQXe3H/ZzEwWW5T4zlIOiT5ixbipmOPvWo4d1kJgKqIe10FEBj4NTIBqZRmZNffA0eVjLXYEzZ/2KKDuR3IILOvKS5X1oFZuJ7LZUtH1zmUAOXSVbebvic8ZQJVnchJVIHibsg1tmxPS4kqSBXl+enOj0b5XnWsA9mCSdX06pIWTYlQMiL3TuufIBKzcAFnTVCjhYDWQw9sloXArutoHkdirTQqQ+ILlyKj+418tNuRzfLuZYg81A1VpnZ4UzgA1mHrZ862qltNYDeL4507ef11einIWDaG8O5dHVzAxhLK084FemUnUqiC7O34dsuvuKz8m9r54OcWfQDk0cCpdIQgpy9Y5UXBKZueVGIpPEDJQw2D+Hie27eqyZUouLmJVzdtgVkr/qFmxUXx9AdJHeNHdsd4k5vJ01lqbhQBSWzLApWHx4oBgP55Jj3ZwMsN6tSl0Di8fukeFXhhlFlFosLkIK5lz+r0+FMA6qP/N1RRnpY4+uX6LjRF0vyfIKdgWgGWb8+4E9EWe94JsUrudA+6q x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?sD/6vjm8aFCyB2LpXZn6/gSPHotr?= =?utf-8?q?WHuSNZv5GJgW4cCR+S0AVUmJC8gHgHkCMokvLnEyq5XVnJZ25PHqFoEyeyfiJMxGr?= =?utf-8?q?fWSm99Rp07QLHP4pF+1PRLZlQJD7M7fliIeAHyyEfl2ygSjQoAorFwfwN0C5t98qM?= =?utf-8?q?NPFFqxn8bue+hMXk31xDRZ9inA0AgiZN7TwaI6g0j31Gd/atmK1UWHFcPxEqBLaF7?= =?utf-8?q?8z982obnfnJrILsApn34PJbThAme7Z6/sFxhAVhQ8Yw4Yl9tp2Q+Il656HcUIcED/?= =?utf-8?q?66zpMv9GdqQG2vlNgYbTkKlYgoEhwvfrdyFgRoujTvC8WKfqYiEJyz94HhQKOoPXA?= =?utf-8?q?UpmheWlhuvvo3WfBDXAImAmbGJPMMPRc0zCCcwDOsL7il+YTLsp/RGuDbwwppKpJI?= =?utf-8?q?KWhdXzEqFjD2d20EFSmBcMHvelL+GhGf4tYq1yio3iqi6f3v4yZlxyvk1waRc3jOv?= =?utf-8?q?/Cq//3eSDUFNqFYz1jF8MJ5uSz9rw2AVIltvuH28viX4GjukdcDZ8oqHxZLkccTWx?= =?utf-8?q?5YpEKmndLpiP1sCnqltTOeBIlwXQvLtHLMQH0e8822pn5xgcTZSGvskfI0rrV7efh?= =?utf-8?q?Rg03PqrI0YAsLSK0NSuL9pJzBcv3jkwQVL6fkcxkmX4PaaKFWDtD3H2KC1BK3vzQ9?= =?utf-8?q?LY79tAkcXQ/y9UxFEyuvpEsBuRIJ6HLStoPFM74DFMN6kLy9kQanRXFocHkep0eMy?= =?utf-8?q?wzVH+t+3b/ymIrNhvAtQF1CsI1Y85nyLkpARM2iZAhsajVEWufGFGTw6LY/FYiktN?= =?utf-8?q?WzdAbT8vryKqG9ZKMbnX/8MdGSS+mkRgDnCxUrcYiU2U252Zy+kZehiyIUXz1MFw/?= =?utf-8?q?IG73FKtK1yNVlK/902tXNnpVW+HjUjly5jNGeI6nbVcS5UupeWZMFWdWPOHy+if23?= =?utf-8?q?JV0XmNxzeS6vyn+cVDSZjSnq6DSc/c5nkoz12gFtVme0CRfx/1tgkQhYNMTzuz0kf?= =?utf-8?q?e2BcXG+IwH0JgCEo7M+DHPHXckVScuFKhGpS3ntktYagLaFJEr3a1o84kwiUPyHZd?= =?utf-8?q?ajMLgRndC0nMm3TBEHPCuMCypwbcLaZrTmN17eq2OXn/bWCqE3OJWjqnmPnuHby3z?= =?utf-8?q?UkDh0hwgU+AW9gojgGx6z9u2IPrzJE3nmyOgpInW5vs0HVRh3TycyrCMOhqGznrwk?= =?utf-8?q?Ir6ZjILXUgaYQDdyDel8/jvL98xX6IfFUre/0kogTOLx4D/qFTxPcsedgwjquybSM?= =?utf-8?q?coljjwJXWWEHes2eOmiLDwJxz79XZT+tNVn98/7d13x8zgP3DgqUq7rowkpVN7FFs?= =?utf-8?q?P+hui3EzjAMHm2Hj?= Content-ID: <31874532C110B549BD1040512CED2A8E@INDP287.PROD.OUTLOOK.COM> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-24072.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0217.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 3b4a3125-b16b-468c-2b49-08dcb7a0fdf7 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 11:55:26.2682 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: MA0P287MB0066 From: Kerem Karabay The Touch Bars found on x86 Macs support two USB configurations: one where the device presents itself as a HID keyboard and can display predefined sets of keys, and one where the operating system has full control over what is displayed. This commit adds a driver for the display functionality of the first configuration. Note that currently only T2 Macs are supported. This driver is based on previous work done by Ronald Tschalär . Signed-off-by: Kerem Karabay Co-developed-by: Aditya Garg Signed-off-by: Aditya Garg --- .../ABI/testing/sysfs-driver-hid-appletb-kbd | 13 + drivers/hid/Kconfig | 11 + drivers/hid/Makefile | 1 + drivers/hid/hid-appletb-kbd.c | 303 ++++++++++++++++++ drivers/hid/hid-quirks.c | 4 +- 5 files changed, 331 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-hid-appletb-kbd create mode 100644 drivers/hid/hid-appletb-kbd.c diff --git a/Documentation/ABI/testing/sysfs-driver-hid-appletb-kbd b/Documentation/ABI/testing/sysfs-driver-hid-appletb-kbd new file mode 100644 index 000000000..2a19584d0 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-hid-appletb-kbd @@ -0,0 +1,13 @@ +What: /sys/bus/hid/drivers/hid-appletb-kbd//mode +Date: September, 2023 +KernelVersion: 6.5 +Contact: linux-input@vger.kernel.org +Description: + The set of keys displayed on the Touch Bar. + Valid values are: + == ================= + 0 Escape key only + 1 Function keys + 2 Media/brightness keys + 3 None + == ================= diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 4988c1fb2..72b665eda 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -158,6 +158,17 @@ config HID_APPLETB_BL To compile this driver as a module, choose M here: the module will be called hid-appletb-bl. +config HID_APPLETB_KBD + tristate "Apple Touch Bar Keyboard Mode" + depends on USB_HID + help + Say Y here if you want support for the keyboard mode (escape, + function, media and brightness keys) of Touch Bars on x86 MacBook + Pros. + + To compile this driver as a module, choose M here: the + module will be called hid-appletb-kbd. + config HID_ASUS tristate "Asus" depends on USB_HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 1d825a474..d903c9a26 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_HID_ACRUX) += hid-axff.o obj-$(CONFIG_HID_APPLE) += hid-apple.o obj-$(CONFIG_HID_APPLEIR) += hid-appleir.o obj-$(CONFIG_HID_APPLETB_BL) += hid-appletb-bl.o +obj-$(CONFIG_HID_APPLETB_KBD) += hid-appletb-kbd.o obj-$(CONFIG_HID_CREATIVE_SB0540) += hid-creative-sb0540.o obj-$(CONFIG_HID_ASUS) += hid-asus.o obj-$(CONFIG_HID_AUREAL) += hid-aureal.o diff --git a/drivers/hid/hid-appletb-kbd.c b/drivers/hid/hid-appletb-kbd.c new file mode 100644 index 000000000..0b6ac8c59 --- /dev/null +++ b/drivers/hid/hid-appletb-kbd.c @@ -0,0 +1,303 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Apple Touch Bar Keyboard Mode Driver + * + * Copyright (c) 2017-2018 Ronald Tschalär + * Copyright (c) 2022-2023 Kerem Karabay + * Copyright (c) 2024 Aditya Garg + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hid-ids.h" + +#define APPLETB_KBD_MODE_ESC 0 +#define APPLETB_KBD_MODE_FN 1 +#define APPLETB_KBD_MODE_SPCL 2 +#define APPLETB_KBD_MODE_OFF 3 +#define APPLETB_KBD_MODE_MAX APPLETB_KBD_MODE_OFF + +#define HID_USAGE_MODE 0x00ff0004 + +static int appletb_tb_def_mode = APPLETB_KBD_MODE_FN; +module_param_named(mode, appletb_tb_def_mode, int, 0444); +MODULE_PARM_DESC(mode, "Default touchbar mode:\n" + " 0 - escape key only\n" + " [1] - function-keys only\n" + " 2 - special keys only"); + +struct appletb_kbd { + struct hid_field *mode_field; + + u8 saved_mode; + u8 current_mode; +}; + +static const struct key_entry appletb_kbd_keymap_spcl[] = { + { KE_KEY, KEY_ESC, { KEY_ESC } }, + { KE_KEY, KEY_F1, { KEY_BRIGHTNESSDOWN } }, + { KE_KEY, KEY_F2, { KEY_BRIGHTNESSUP } }, + { KE_KEY, KEY_F3, { KEY_RESERVED } }, + { KE_KEY, KEY_F4, { KEY_RESERVED } }, + { KE_KEY, KEY_F5, { KEY_KBDILLUMDOWN } }, + { KE_KEY, KEY_F6, { KEY_KBDILLUMUP } }, + { KE_KEY, KEY_F7, { KEY_PREVIOUSSONG } }, + { KE_KEY, KEY_F8, { KEY_PLAYPAUSE } }, + { KE_KEY, KEY_F9, { KEY_NEXTSONG } }, + { KE_KEY, KEY_F10, { KEY_MUTE } }, + { KE_KEY, KEY_F11, { KEY_VOLUMEDOWN } }, + { KE_KEY, KEY_F12, { KEY_VOLUMEUP } }, + { KE_END, 0 } +}; + +static int appletb_kbd_set_mode(struct appletb_kbd *kbd, u8 mode) +{ + struct hid_report *report = kbd->mode_field->report; + struct hid_device *hdev = report->device; + int ret; + + ret = hid_hw_power(hdev, PM_HINT_FULLON); + if (ret) { + hid_err(hdev, "Device didn't resume (%pe)\n", ERR_PTR(ret)); + return ret; + } + + ret = hid_set_field(kbd->mode_field, 0, mode); + if (ret) { + hid_err(hdev, "Failed to set mode field to %u (%pe)\n", mode, ERR_PTR(ret)); + goto power_normal; + } + + hid_hw_request(hdev, report, HID_REQ_SET_REPORT); + + kbd->current_mode = mode; + +power_normal: + hid_hw_power(hdev, PM_HINT_NORMAL); + + return ret; +} + +static ssize_t mode_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct appletb_kbd *kbd = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", kbd->current_mode); +} + +static ssize_t mode_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + struct appletb_kbd *kbd = dev_get_drvdata(dev); + u8 mode; + int ret; + + ret = kstrtou8(buf, 0, &mode); + if (ret) + return ret; + + if (mode > APPLETB_KBD_MODE_MAX) + return -EINVAL; + + ret = appletb_kbd_set_mode(kbd, mode); + + return ret < 0 ? ret : size; +} +static DEVICE_ATTR_RW(mode); + +struct attribute *appletb_kbd_attrs[] = { + &dev_attr_mode.attr, + NULL +}; +ATTRIBUTE_GROUPS(appletb_kbd); + +static int appletb_tb_key_to_slot(unsigned int code) +{ + switch (code) { + case KEY_ESC: + return 0; + case KEY_F1 ... KEY_F10: + return code - KEY_F1 + 1; + case KEY_F11 ... KEY_F12: + return code - KEY_F11 + 11; + + default: + return -EINVAL; + } +} + +static int appletb_kbd_hid_event(struct hid_device *hdev, struct hid_field *field, + struct hid_usage *usage, __s32 value) +{ + struct appletb_kbd *kbd = hid_get_drvdata(hdev); + struct key_entry *translation; + struct input_dev *input; + int slot; + + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_KEYBOARD || usage->type != EV_KEY) + return 0; + + input = field->hidinput->input; + + /* + * Skip non-touch-bar keys. + * + * Either the touch bar itself or usbhid generate a slew of key-down + * events for all the meta keys. None of which we're at all interested + * in. + */ + slot = appletb_tb_key_to_slot(usage->code); + if (slot < 0) + return 0; + + translation = sparse_keymap_entry_from_scancode(input, usage->code); + + if (translation && kbd->current_mode == APPLETB_KBD_MODE_SPCL) { + input_event(input, usage->type, translation->keycode, value); + + return 1; + } + + return kbd->current_mode == APPLETB_KBD_MODE_OFF; +} + +static int appletb_kbd_input_configured(struct hid_device *hdev, struct hid_input *hidinput) +{ + struct input_dev *input = hidinput->input; + + /* + * Clear various input capabilities that are blindly set by the hid + * driver (usbkbd.c) + */ + memset(input->evbit, 0, sizeof(input->evbit)); + memset(input->keybit, 0, sizeof(input->keybit)); + memset(input->ledbit, 0, sizeof(input->ledbit)); + + __set_bit(EV_REP, input->evbit); + + sparse_keymap_setup(input, appletb_kbd_keymap_spcl, NULL); + + for (int i = KEY_F1; i <= KEY_F12; i++) { + input_set_capability(input, EV_KEY, i); + } + + return 0; +} + +static int appletb_kbd_probe(struct hid_device *hdev, const struct hid_device_id *id) +{ + struct appletb_kbd *kbd; + struct device *dev = &hdev->dev; + struct hid_field *mode_field; + int ret; + + ret = hid_parse(hdev); + if (ret) + return dev_err_probe(dev, ret, "HID parse failed\n"); + + mode_field = hid_find_field(hdev, HID_OUTPUT_REPORT, + HID_GD_KEYBOARD, HID_USAGE_MODE); + if (!mode_field) + return -ENODEV; + + kbd = devm_kzalloc(dev, sizeof(*kbd), GFP_KERNEL); + if (!kbd) + return -ENOMEM; + + kbd->mode_field = mode_field; + + ret = hid_hw_start(hdev, HID_CONNECT_HIDINPUT); + if (ret) + return dev_err_probe(dev, ret, "HID hw start failed\n"); + + ret = hid_hw_open(hdev); + if (ret) { + dev_err_probe(dev, ret, "HID hw open failed\n"); + goto stop_hw; + } + + ret = appletb_kbd_set_mode(kbd, appletb_tb_def_mode); + if (ret) { + dev_err_probe(dev, ret, "Failed to set touchbar mode\n"); + goto close_hw; + } + + hid_set_drvdata(hdev, kbd); + + return 0; + +close_hw: + hid_hw_close(hdev); +stop_hw: + hid_hw_stop(hdev); + return ret; +} + +static void appletb_kbd_remove(struct hid_device *hdev) +{ + struct appletb_kbd *kbd = hid_get_drvdata(hdev); + + appletb_kbd_set_mode(kbd, APPLETB_KBD_MODE_OFF); + + hid_hw_close(hdev); + hid_hw_stop(hdev); +} + +#ifdef CONFIG_PM +static int appletb_kbd_suspend(struct hid_device *hdev, pm_message_t msg) +{ + struct appletb_kbd *kbd = hid_get_drvdata(hdev); + + kbd->saved_mode = kbd->current_mode; + appletb_kbd_set_mode(kbd, APPLETB_KBD_MODE_OFF); + + return 0; +} + +static int appletb_kbd_reset_resume(struct hid_device *hdev) +{ + struct appletb_kbd *kbd = hid_get_drvdata(hdev); + + appletb_kbd_set_mode(kbd, kbd->saved_mode); + + return 0; +} +#endif + +static const struct hid_device_id appletb_kbd_hid_ids[] = { + /* MacBook Pro's 2018, 2019, with T2 chip: iBridge Display */ + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) }, + { } +}; +MODULE_DEVICE_TABLE(hid, appletb_kbd_hid_ids); + +static struct hid_driver appletb_kbd_hid_driver = { + .name = "hid-appletb-kbd", + .id_table = appletb_kbd_hid_ids, + .probe = appletb_kbd_probe, + .remove = appletb_kbd_remove, + .event = appletb_kbd_hid_event, + .input_configured = appletb_kbd_input_configured, +#ifdef CONFIG_PM + .suspend = appletb_kbd_suspend, + .reset_resume = appletb_kbd_reset_resume, +#endif + .driver.dev_groups = appletb_kbd_groups, +}; +module_hid_driver(appletb_kbd_hid_driver); + +MODULE_AUTHOR("Ronald Tschalär"); +MODULE_AUTHOR("Kerem Karabay "); +MODULE_DESCRIPTION("MacBookPro Touch Bar Keyboard Mode Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 818d41a35..7c576d654 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -328,7 +328,6 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021) }, - { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) }, #endif #if IS_ENABLED(CONFIG_HID_APPLEIR) { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) }, @@ -340,6 +339,9 @@ static const struct hid_device_id hid_have_special_driver[] = { #if IS_ENABLED(CONFIG_HID_APPLETB_BL) { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) }, #endif +#if IS_ENABLED(CONFIG_HID_APPLETB_KBD) + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) }, +#endif #if IS_ENABLED(CONFIG_HID_ASUS) { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD) }, { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD) }, From patchwork Thu Aug 8 11:56:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 818337 Received: from IND01-BMX-obe.outbound.protection.outlook.com (mail-bmxind01olkn2052.outbound.protection.outlook.com [40.92.103.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9701F4A33; Thu, 8 Aug 2024 11:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.103.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118192; cv=fail; b=caxEd9iZLUAwFfyJyUIlgtO6fcjxUhnEFwGNF7Jlb+Fk3HFvvrWEreKsnh/Jjm2ZvKEUxFSz9maCqxSkX6edL57GTnJaW8b+3+t/WM0cCDepMB0JP81HiHuTTAUanDQ27I1fY+RhLF33nWyOrmXgFjOkWnVJ8o1zmDa7/7FgtPE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118192; c=relaxed/simple; bh=JSkjijAYgzH7WQ3jUUHmHMdD6vO8+MXa8Wh7CpofDLY=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=AEvZ7kS216OE1C8ANdtKM3u1e/jE71rigXfdBZ01I0euIBkn6MVtGbeusPJALliWLiUD6a6N8uR50r3r218WY0j6+UcTTr4nu66AfgqJFEjaCAYXp7vDIzr1csygdEizIEz7PRTP7QIW42Tl0V6T/9l9x0zr6tRAlOOlccdTMPs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=r4Gd8RV2; arc=fail smtp.client-ip=40.92.103.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="r4Gd8RV2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PbkmeLgDB8j4gvmeSjSEU25acE/3EdrMqlm46YroseRar5gF6wk9g01HeLRaVzB2d0PEpAufj8leAb756/x3M2p2uSH8QtSJ2hetNVJBWTl8XP7O5EoYbL+wHza4I+j5U/LcNghkfVBTxXIDm81Hyki4ThMTf+I3ASU6i8wao8l8fZTSF+awL/J66i2zPsa8qCg8n7LaZ9FPr9ktmbgurluxdUmhBerR+iUZLgyUoN/YaIx1yKiwd8hMgKSIFzSqthJNVhyKiXwwoNzLQA86BZ7FJ9Q/LeBBQ0sg4mhCbEY5ySd8lu95gd/YJ0ITu/PYxrJoqnEYIi6w/hpiR0G0rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=p4PHen4032PcthKi8HoFeGPNif8f7CRd94d/mUAn2RY=; b=kQhQGCryoUWptdH6ZC3AjBOMhrFv+I2gZthuuy2GB6BWeI4Sj/vdTfobJHL42mBd3GfJ36ToGwg2oYbZA7RnVZ5bX6YesmtSB47d5kc4A1fsUfR3AVB3Vbfrktu1xsflCiVrRIyGqcD3D6DhjuoTdXVCShWQCq6JYlROkw/HJbWWXKwGPUIwM6lW3KoveuViIK9ePyMc7Abixc0PpstVQoRGcwZ/+eeZtbiFjFYGmflwtscKz/YyTcaoPfXQS+X+BpHYkmvaZ4Pc892X52aKuiIOKSTUz9aJ2pcqMODTWTZwWeoIX2voTMXk70FTaTiGygFccEvW0S5tP0cjHQoDTg== 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=p4PHen4032PcthKi8HoFeGPNif8f7CRd94d/mUAn2RY=; b=r4Gd8RV2xWWNS90SF6UtKUSaRJm5mlvvPCPqev0aVXKj/aYL5/EHBq+7js2QZCo5/+OEo+mJtElToM0wZ90Dn8kmkCtKg2KO9rnClKhgqwU23/dJ0BUYE/jqk2I44PZPqtE28T3DyedrL1AwQlLCkOPh+qjcReg4s3GVAlB5eUyD5aEarQMwCZijlXLlK4c+EDPdw9M9bxebRkZBOiqUg64q1C8epdnv7yHdlXyroefRsDfL9JH27NjWXiqSP9qhNpolrz5++S9TTDxYmJhDLLu/tAguKHr4/0jlxjoPoHUNUazhzlFeVBPj7giRCx5wnxwLnSfPRPSIGsImMhoOHA== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by MA0P287MB0066.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:32::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 11:56:23 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%5]) with mapi id 15.20.7849.013; Thu, 8 Aug 2024 11:56:23 +0000 From: Aditya Garg To: "tzimmermann@suse.de" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "airlied@gmail.com" , "daniel@ffwll.ch" , Jiri Kosina , "bentiss@kernel.org" CC: Kerem Karabay , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "linux-input@vger.kernel.org" , Orlando Chamberlain Subject: [PATCH v3 3/9] HID: multitouch: support getting the contact ID from HID_DG_TRANSDUCER_INDEX fields Thread-Topic: [PATCH v3 3/9] HID: multitouch: support getting the contact ID from HID_DG_TRANSDUCER_INDEX fields Thread-Index: AQHa6Yn8D3YBQb5sakG9oCUs7mNuQQ== Date: Thu, 8 Aug 2024 11:56:22 +0000 Message-ID: References: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> In-Reply-To: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [0UbDxD8hIPHAY4pNGspzs9VBZwvOi+FpGEbdVrNq9mVPYIMfQkFK+QRCrOJMEHqf9C45K3x3QPk=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|MA0P287MB0066:EE_ x-ms-office365-filtering-correlation-id: c6803158-2f89-4814-a495-08dcb7a11f61 x-microsoft-antispam: BCL:0; ARA:14566002|15080799003|19110799003|461199028|8060799006|440099028|3412199025|102099032; x-microsoft-antispam-message-info: VMOp02w+IkqN4chi91PxK26h7UPtDNZ386lI2i2pQ8g7LWyBwBn5jt9a+qyfqk11/fXBfT1XOaS+7KXrTAjycHZ0pYTTHr5JlI/gz9ldCBBzMIZufkOFG1Zl5XMrLuUeQLL7+dVUAQyrlgm+FxrCdMaXoAwz/0cyIm8bTHYFmFwee4eqC2vjDwYQY0z6DA15NVUaZLEQCkFeI+I3MjDJsrIKeHfu8ypE3vNMy12TekhhFA6UOh4dg4oRzUB2SIVGjBsaFRFHgsMCmOwC/QoNby1EWNLOfRsFNvihPFXGdfMc1TP4GHniBM/OjYunb36ZEI4M3wlzwRRn23V+ajCbJ+Yax+IE3QmEZobst2OVwpL2bWsiFVfWJfLVVqIbKkGdEyJj1QTnk0IwPxD9XsRjbDo8HwfJ4vNNNW3kpOFEoBxPUPyXqalN54pMEy4QUOiFYd36kRsQL8Hg6ywqhEqDPxYQHGyXQA/icfJwwfzJVr/DuSllZoEL2LiOpKHcH24dWPeJ9+rE4NSUazJ+0mxPovWCkrUzgUveE9WO0N0HZfshWulS3VIhX9X6Gv9YruhOV9yukvospg4QEkZmqZ5MtTKgcqSpb5px/X0jXbwzQDjt1ZEEI8IDOnWcR57CW+KMTFdXL/mOsH3UAw85Wk0PcG7qNSzOkLK3HdlCWY5zVyIsfjMJ1l0qZBPoYtSP7fBP x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: +1y36dnAh2URHdmp+Ej1MGXtDpVIeSoqjobcUbKQouWSTDOl4E+eIQ1IEQemcFDpG6uSZdG1Tw2DLzA2ED69bKlNgxNPr4AuGzFiSIT1vyDK6omy59HxSfXkSitqb0ocbYQo/tAO8XTscPiHnvfYYR2WosYzWezJvgXZahZpI4zeqP9bWC1bnVjiXeK1WKpPnXIj65PdYm1636nSKt+EtSX+/GT/vrI54fNcNAKKW/Y2zRdLrc8vP4c2FW1lhuAWp2NeMUSYn0OUO2RyLKrrRzfpgf/CQEdhnyka8KaqfjBW9C6ExKJnoBHtYNlQtjZI1cFcyJWP+f4i24p4/UTNnM5qjIJrPADCajPjakZc1a1br1gngEE5UyAZSqlCcyBdsKKUqOwBNUgmGpNynN0JK6MG4N1+E43BynldW1P/zlTYsQfTZ2QVH+EY8pzNTbBK6WC+z5Z0VuXQkVzx6QHREIwZr3PPDzO8UfICXezxtjqbRPzAxRMlPOoA5ak+lsWRd9q13W/nsNDJf+zZ/f6dHtZFRy6JKODCnjUqFzNk+Cld+3Un5kbWBxAMxriGxJXG5cIKFIv6agiIAbzAyDv+Rtrbb7tZQlVa3Af9UIGyUC6Nu/U6G3KBTzXtXmG6FPmAUfxJxWdo9sfx87ePn/DSfWbjriBZY9yCvtq0kFMGtq/UJ8SxR/p28ofs7Hhz0J3Ed3tWwv9eElnsmZuoYDtvtxrodlHE5pvkUw1TI3yjKPjv66SbVsBeA3iEZ6dkS0eq+09ZWMIBu0wlueBjTxgfoUBiOXCW84cbAdTK9LU3UcHWyKrzVxoBNZgs75PNJvLUxoaVRr/H+Rd9hMUPeqcHClGOOucvgXbwrYcDByDYWTcNt8oaRSO8Yk83RPgqvWFZhKeU2F/cqg9rwbFQWaLC4SF/SLElYKUZwVw4gLzpPVi5t6ow9dkN8EruOADGGFRPxnNrU/5W8b75ptjCJJIbGZ3ZA6Nt6mCPRhp9hWFTwz5PtOByCsStXMQ6R6iX0w058k8yRgPViDQPA+TRrcJA3yDeyiv0A39mB+HFknjyCIsu6vAomxID/vQAH5NplCWGeCYuoNlSAVG2UZ18EF5pmWa2XMIVdB19khFc/1llOTdHi+c6WnHEyjDB7cFKrL5+8tWejvdoQCd/RKlWTAyNmD7w0Pi+j/RME1meJLJ1MvI/Dn1oLS9y+C1xWmp+Ik1ulPgS+g3YbHMFGZWuw8pUQ0WV+lke+bwYiSSr33d6dNgYyjnLeejO2Z83bq+RFaY535WJVuCZ5KGEwxR+X7hq/+IQiG+oCGNdtwRZtuicqaQRcJbLvF+ZZ8/QMbiVLf4q Content-ID: <51AD6AF97EE1EC45BE44B1C1DB7F0F3C@INDP287.PROD.OUTLOOK.COM> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-24072.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0217.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: c6803158-2f89-4814-a495-08dcb7a11f61 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 11:56:22.3273 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: MA0P287MB0066 From: Kerem Karabay This is needed to support Apple Touch Bars, where the contact ID is contained in fields with the HID_DG_TRANSDUCER_INDEX usage. Signed-off-by: Kerem Karabay Signed-off-by: Aditya Garg --- drivers/hid/hid-multitouch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 56fc78841..3e92789ed 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -635,7 +635,9 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td, if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { for (n = 0; n < field->report_count; n++) { - if (field->usage[n].hid == HID_DG_CONTACTID) { + unsigned int hid = field->usage[n].hid; + + if (hid == HID_DG_CONTACTID || hid == HID_DG_TRANSDUCER_INDEX) { rdata->is_mt_collection = true; break; } @@ -814,6 +816,7 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, MT_STORE_FIELD(tip_state); return 1; case HID_DG_CONTACTID: + case HID_DG_TRANSDUCER_INDEX: MT_STORE_FIELD(contactid); app->touches_by_report++; return 1; From patchwork Thu Aug 8 11:58:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 817800 Received: from IND01-MAX-obe.outbound.protection.outlook.com (mail-maxind01olkn2025.outbound.protection.outlook.com [40.92.102.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFE3518C32C; Thu, 8 Aug 2024 11:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.102.25 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118305; cv=fail; b=e8mkB87cYwmGpCWUb5PVB48ezz9GDx21hk/KlkgtThT4u8XC2dANhuS1qKY92qHs8T0qVtpTtkmgH3+Sd2RFqmzpu784aJzU0yQ1l/Eop7p98BTnxdRUX3Tm6hmxNm6Uj0CXW6Pp4a8bkW9HvXCDVaVqGx0s19qyiSBS1w1IAS4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118305; c=relaxed/simple; bh=q2zbI6iA4WSAgEi8Mnhut1ZJDb4ZdB1DAdsFrr6ISB8=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=QQmv7cuHII5dwDYGthMe3L5r8VUx2k4HzYZzMzYUejZpH0zpIJFrR3+ZgUyYvXJhylrQcKj4JwkgqnzCV/D1gn1LokeVxGhUICElu5juK8LKKJpSE+rOQ++MArdU/DVhlsJ3iPTK5+Cznb5INKBy6ix0WIWHyCPWFGheMNHU5uo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=UDZujMnQ; arc=fail smtp.client-ip=40.92.102.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="UDZujMnQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rORm3BH4A9bU4/q23DKqJKSzcKzUY1GZcH69EHPAJbJLragSeLgmX4U+he2uKGy8tCMVu5ItSIlV1nJD5fSi3yYQwe1dzTaY3x+7AOT/s3pdp/C6JRCT7kZkE4anu7FrlQgmn5cGPmeKAR+nJCDPWOTqjgAfw2dfEeccsVPlN0gyIK34RfQUbLAa5363c9ZNptGHFqhsoxz56t6VIhnRqhCVBn9XWtcdjXFbigkgSkjFeG7VyNeKUq8qpZeRTRz0zGnEo2MHqFfO2/5i1HmBs0WDoQEYbj8TDsXECtUW+Y3VxmxWZzX1v47bQar+ybYPvUSRvSFY60gxbdY4itC+SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=XbtXp3cnpQpbYNXYGShy2lxXGof4j5KkulzUYghWbSI=; b=vSmiipWN7qE7eOG6n2/L3Im9VnUgqiBV4BeQEWjSCC6oe/115BVGiKwl0UZO0XSliKnq0tMV/wIZePKYYBEQ/cuXTi2t3vcTvQRxk043/9OpymBUMJGSJjQ+UENjqmNfX5NaKJzuCfguCyhL1Hzb//tWw9TctViaPS8PH08wUxKP47Yp1cqzFsrTmxd11DwKnl6ClLn+Grla9BEG/7lE4JVebmzFrpc+2F6e86nUXhnSPHSrmsAz4+vAf7r6oI6gGRExy+UI2jrRQhRyQPgAFN9T7xK+p6VqogEl6GUtMzl6uJBd8lokrbXpERdRXttPAqXzTfysjjXqGtDfNJY08g== 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=XbtXp3cnpQpbYNXYGShy2lxXGof4j5KkulzUYghWbSI=; b=UDZujMnQCqInZOBBIvnDFL51wEnM6tJjiBn41/OHsFdsBDyT5gdh45Hs292Y1XLc0uoeV4b+6IEZm0A0kv5oCwEeqg1Zdep/l/e+KUWgEQQGklhPweBBDj2/U+eF/+OAJpUjmcZLcL5h82ey4xDGtlkKtK5xYfrlpij50OxGNLS3aLh43D9+ms0PLdQKD9DNzqYoZO5AF3rwthLIZ6M4wbEF57mym9ZgqqNyJNClx7SoMaHRTkBM36fz9gSzbTaODyrp825mxPDcCp5x16lbhkg8dnr7FgSKy2HOD+Q41ZyghIfvjIQinUk4WiCf1MZs5vXg9uBGM1KUEADxbQ2ykg== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by PN2P287MB0925.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:130::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 11:58:15 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%5]) with mapi id 15.20.7849.013; Thu, 8 Aug 2024 11:58:14 +0000 From: Aditya Garg To: "tzimmermann@suse.de" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "airlied@gmail.com" , "daniel@ffwll.ch" , Jiri Kosina , "bentiss@kernel.org" CC: Kerem Karabay , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "linux-input@vger.kernel.org" , Orlando Chamberlain Subject: [PATCH v2 4/9] HID: multitouch: support getting the tip state from HID_DG_TOUCH fields Thread-Topic: [PATCH v2 4/9] HID: multitouch: support getting the tip state from HID_DG_TOUCH fields Thread-Index: AQHa6Yo/9x8LYIWKpE2EWsODzD5prQ== Date: Thu, 8 Aug 2024 11:58:14 +0000 Message-ID: <05F523B5-7307-4022-A2B8-C3C96DA0A92D@live.com> References: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> In-Reply-To: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [s0hmGNe0aqpPFPGYqWnlUrWYGxAQuz7Un4o2+urBcMTFi6l9r9EvEyIcAmkMhtyunAeDCQiuykU=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|PN2P287MB0925:EE_ x-ms-office365-filtering-correlation-id: cf94d570-f6f7-4ddd-9483-08dcb7a16258 x-microsoft-antispam: BCL:0; ARA:14566002|19110799003|15080799003|461199028|8060799006|440099028|3412199025|102099032; x-microsoft-antispam-message-info: X1Q/SRuPV8DrbZJh3GCrjFiKLTc+fQJB/E/EGZZ2Lu/gbPIyxm2JY/GmY/qm1PLgibVMA3VOTGai6T5nYLuuKyR7uAW3OgjSkXaRSgEZvYLtwLTHo2c7bIjHxeAknCABCCXu4m8cegvLY6rcyYYwgBSu8bJG8y0jY+RNcmk+klSZw8FlCFvl+GxU3CGDSTtbH65ysmtb/a5PhivI+B9ufTl1IsNkLZhceKvzlGwroM2G1ZcyGCaPSL76SnDEBiyHtGAHOUb38U8d9MqavW2uwd97TBJgw//TM0cDNiCVuVLEDnjeYLNckMLgJkJYBYdGsRsf/yQsW/jUzbEnJpigjDRW2MP1IjruPjM8OV0+iR0+auaiOB7EjOUA+r0a/MI+tBzHUoGV/vVwhUCuBruWg5EkzDbc1dW+4zPiUvA6wYKP6v9cqpkzuq+K/DR6VZkRHymb9AxjhbxF2DzzhaZed5yiWLFxGhGyOZaPpW3USBzwZMV3/huguh2PUlY3JpftGIalnsxMAu8p6yO1EGlYTrQAmHq7DbzzzWRLie0rqNpuD4bt8IQsp1seqhbLiMkDp/IKQWqTd7JVWaDt4KjdmTDeFUNY71SgC/tkMZNzvcjxFRWxaKQ4I3wS4WdW5FuHBQ8NGqFp8Ap0OvRS5C6YfPoWYiboBIi3V1ojup0FaQS9ycPPsej2jrTTzUsRC/sv x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: E57u2z2EAPSCCaucQmg/gZGYW1lfjhOLOKm2ZuKxhTqPpz7e3svVzssay80+01d9uuk4AVtA1l6nuovy8eSBXobx/ck1tj8G1ja0gpUFb0EblwOg/OW7rst/pKWn2JAQLaWy6ntiFmslNSt1SgPS3T2ho6BSS5lOTy2ZP2hNDiX99htEP5qnUlF7ae+v72iIG0rfSme7eSx1p2igrx9rYFSCR4pm5OKME+bPtmrEwu22OgMZQxaBRfkmzKgAjzarZjs7IFT7xIJsHe+ZRjMmTDOoz0DoxOGyjyVrwmHtRyrok17q2wv/5KVknziv8vTSPW+cRQkYiRPXgkjSrl5xr9YSAF/iRf6G1vqHbDTRjAvVFJp4AYu9d1vlO6lAXlK3HgGjMxGUB/60joLxdn0OiBs7TZWaYPvHaBcdYgtDHA1ByHgR5MeO/9zbCK4Rt1UF3ylh4DGY+q0eALCs8LySZ7fRdWj6hLua8YNrnZua90FCmCSG5/YNjIYMRUAnMhfcY5GBHgzSsd0+KtTsJjKTwTwOnN/xU5s/FHY+XFZEAzqEc5UC8P6moLeoz8dv1Le9qbAyHO4LHQs580Bo48OqVUo+Ug1kar7v3LhBy+Ks6WSl/Eij/sYj8o36cRMecpNfpJIYHJhOdMtgRKw+aa8IuUNakK8/uWX8jbfWQ4PKO6q5vI8OR/qPxiczsYgGiUeun2JecXwQD6zlBe/In9vsyk5c85KEFRQzqRdYLkbAfl24h3qXvsWITQKzSXtOPSV9zEt1VXXRHHSAfwWA1ElPv54tMrcwJnbBkZwRSX0cS3jb1ZsVc5R4eqIf6fqUx+yM4QiD7stsFBgg4LOWJQyyG43eaMbJUvIWkBzLN0TbJ8e3KoigUVRq/xhlDf5dElFw6+tZ7Bo46K/nMWKwzHLjXVRPA3jrAHWlemkaSKrA1HK+0nks8RasPbcJ7doPJ01BtfQvy8fjE+CjEF7dAobR0WH/LHqLVV4kkmSZxU+fh93sRzhUUJod0sZxyV7kznaXiNhg/5rsP47/FaH6gPwioErsSr0/8i338gPuSc+tSDmxKdlkT8HsmEgi+PXeEKK8x/LCtX2Tzam9X5rucR0mxmErteyL+ZuhNRKYeUFgdkp2Yn8ZROjmS9UECEiYPK6/rf/BHVCaFwInTcQIyYqVfFrUrJyUfTHa7rQuW8Jan7WPljjjBjPQLymVS1dS6Q0wbdpKy/fdMZA52JITf+B4s1/EQn44HS2XZyJhr65+qf6rxV1fMjeJMGnfhfi7BGJIOUYYYYlaxY0o4EipsZrJXVgfPpxqEDz9zLu6c30I+6nATI5iIIg3VuZ9TS27Gz6i Content-ID: Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-24072.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0217.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: cf94d570-f6f7-4ddd-9483-08dcb7a16258 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 11:58:14.7055 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN2P287MB0925 From: Kerem Karabay This is necessary on Apple Touch Bars, where the tip state is contained in fields with the HID_DG_TOUCH usage. This feature is gated by a quirk in order to prevent breaking other devices, see commit c2ef8f21ea8f ("HID: multitouch: add support for trackpads"). Signed-off-by: Kerem Karabay Signed-off-by: Aditya Garg --- drivers/hid/hid-multitouch.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 3e92789ed..571435da5 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -72,6 +72,7 @@ MODULE_LICENSE("GPL"); #define MT_QUIRK_FORCE_MULTI_INPUT BIT(20) #define MT_QUIRK_DISABLE_WAKEUP BIT(21) #define MT_QUIRK_ORIENTATION_INVERT BIT(22) +#define MT_QUIRK_TOUCH_IS_TIPSTATE BIT(23) #define MT_INPUTMODE_TOUCHSCREEN 0x02 #define MT_INPUTMODE_TOUCHPAD 0x03 @@ -809,6 +810,15 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, MT_STORE_FIELD(confidence_state); return 1; + case HID_DG_TOUCH: + /* + * Legacy devices use TIPSWITCH and not TOUCH. + * Let's just ignore this field unless the quirk is set. + */ + if (!(cls->quirks & MT_QUIRK_TOUCH_IS_TIPSTATE)) + return -1; + + fallthrough; case HID_DG_TIPSWITCH: if (field->application != HID_GD_SYSTEM_MULTIAXIS) input_set_capability(hi->input, @@ -872,10 +882,6 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, case HID_DG_CONTACTMAX: /* contact max are global to the report */ return -1; - case HID_DG_TOUCH: - /* Legacy devices use TIPSWITCH and not TOUCH. - * Let's just ignore this field. */ - return -1; } /* let hid-input decide for the others */ return 0; From patchwork Thu Aug 8 11:59:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 818336 Received: from IND01-MAX-obe.outbound.protection.outlook.com (mail-maxind01olkn2051.outbound.protection.outlook.com [40.92.102.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E56C414A4DB; Thu, 8 Aug 2024 11:59:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.102.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118381; cv=fail; b=eDAaIuxsRG+Fiv2V+yxlF05sRaGuV1gGltzFevgnECwlLwF8XcG9awiYYkUfxIxnfK+R8apmKgiDYltIrDoP/kXwxin9okyiiOhlhvCJhtYldaH5x7ltNKkpXa/VmuCEgKdfPoWt9DInkKlZjKkaOwLQNYwtS0Dr6iFJjJfh7us= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118381; c=relaxed/simple; bh=vRQ56ui35j7gSUDh6/aC8rAWi07FjxWDnMNCtBkWUOY=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=P27JJpH6ih/QcgD3+SSFoayweaUmn7tr5G2t7tFWDn6aHSz8em2tASINs32HLz21mZyOw3JGtD7KrhwdjMR3QhfYWp7NzL6YfikPlEd/LXOmS+xnZIXSIvsxQ4hM4F//b7Ha5JconGJOry6jjCbFjhXhn0HFAiR/OdhsGpdRheQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=qjqXmB+G; arc=fail smtp.client-ip=40.92.102.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="qjqXmB+G" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BKnkKVIfrlN/QnuWgO/xQRvYPaDNsxN8ewzFadNd7BgT3eI0cItMVUTvZNziAn1BP+B7IyGZgCcHuQXwZgsVkH+PncB3UkEkKfhZ93TlSUjI+mN4TxgWFifIu9EuiBaRdhtHM4HU2zt65+JADDXiXJy8/biMg/LE7PDNLZHDYZVPUd4TlrSA/oZ8N4V2E5fQQ0Z+VhAljNrIHDcHfEyIjxFpfZRWtmLUw8zIx4SgQc+JBzbUsvZzE/xg/97PD7iSWUxi0Pddm/DE/C7dgOizNzBDib7BGslonP6FiNXx4VRkaOkDuGci2eWUkX7QWdfF8WI+TAJ+3RsDj8miMKDlFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=cIBzWghiSd/94g2S+ca6KQlE54fye1PXtvDLmTaqqw4=; b=X1jVWux/yAfmzKMS1iBEoKqlS4Qcfr9BNeuHbo4cIWE6s/ud9cTnchL2IV5MO2pztzPogJ+kivDEgtx7LCOhaOdcmvauUXox5PrJKSJziIGUHTdREYejdiV/e2VTCnP87KmcyQU8iz6Ri+mrf5wesJ/RDZFOEqcL1h/SJ0tX40FfYxaurZpNaBKKttRNikFHbr3H9tqeqiexPWJoDukqLPQnLgMOGzYDdHO6oQGbMpAb7U1hVRq6XyKL2uz3NE3p4QTD6rFzg3pkpI/XSKCavw3aH5vWB7eUgAIi/b2iUfQLX4oYNZJruRl7z08rKfM2OxhEh38qHX73FfDMKa8Ljg== 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=cIBzWghiSd/94g2S+ca6KQlE54fye1PXtvDLmTaqqw4=; b=qjqXmB+Gz1gH8un44FhAamAcUYUmRobZx1KlUR3SFpAZCzYpaC0xmD2VGmrcQ/iq1P6ul7C6it1VtXBfDiGwcPVpcjPANzXf5k9VTma9gaRYOQK0I1PF/RLYiSf+MeXEcmc0f6Lnc5MGJ/QUYTQvdicn4IJjmJLdzly0G204+XHuR4NsUupB1lUWNpi3xSL/waP9r2WaTF75uOsC0WJxl2cz/7DQrjFmNJl040FOurhP2ZeaAe3ZpWF6Kh+SaRL5K0rn8k5b908yX9THweWL/3AgBXob6NAY6+abt/PjDSOr0Pj6Q+fkBceTRKYpOFwb5jov4TktNXgiA0CQ4VVGSw== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by PN3P287MB0339.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:d0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 11:59:28 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%5]) with mapi id 15.20.7849.013; Thu, 8 Aug 2024 11:59:28 +0000 From: Aditya Garg To: "tzimmermann@suse.de" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "airlied@gmail.com" , "daniel@ffwll.ch" , Jiri Kosina , "bentiss@kernel.org" CC: Kerem Karabay , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "linux-input@vger.kernel.org" , Orlando Chamberlain Subject: [PATCH v2 5/9] HID: multitouch: take cls->maxcontacts into account for devices without a HID_DG_CONTACTMAX field too Thread-Topic: [PATCH v2 5/9] HID: multitouch: take cls->maxcontacts into account for devices without a HID_DG_CONTACTMAX field too Thread-Index: AQHa6YprE4GB4W58ekuSXmWzZRZGLA== Date: Thu, 8 Aug 2024 11:59:28 +0000 Message-ID: <53EA503C-0D5F-4648-8508-8DA12C8282D2@live.com> References: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> In-Reply-To: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [2hblk00hwwCLsEXuCWOc69nMz8sdAmxYYwwyNCq8YMFeDT3rSvGhoJglLAMseVkKhMehtxVcWaY=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|PN3P287MB0339:EE_ x-ms-office365-filtering-correlation-id: fb34778c-1cf7-47af-9d2a-08dcb7a18e49 x-microsoft-antispam: BCL:0; ARA:14566002|19110799003|461199028|8060799006|15080799003|440099028|3412199025|102099032; x-microsoft-antispam-message-info: q5N7SCLDH9W4K2X3afGlGyIBVl3QZv+aCIai5JpsCYv1CDyvk0xm4Qbz2IXmPvPjGNYnCs419AGEdLzGit2JdigKCxxXknTnRvvOch1KvhBX7gpRBMqk1XNY1HvUOIvdprAa6nrMfz6htbtSkmtqHQFMdsRumIZDuKvEd5Ss9ZFFmoS28EiI7/Dkpbzo/XmVR+s2uJFSli46NnsA96V9nconaB3L60wh7IYu5CU9GXg5qpyMZHrOldl40LkIkJBoVgVfs6Hiyav3roUEUnJANr9BxJwFNDanrW0bUReVWjIwroF/pLFvsRHp2Dy6TlodNzd72tHcCSh5rPEgk2tkZ02r5ZbVyoZAgbSpSIZUSfH9y4E1ZjrZrh/zfGIsPqiSXx/hPH28ianjAp6WaecvfnKyjns4OE53gnLlRuKstZvmyZVcwyvMdnj4EOBd+p9nzPbMXXiRiA5y04SkO1du5NG3eydHD3cHr6Ro6PYFaACskxdQ++MmYD4hmanp0ZYctBUF0bk0erdYkJ4IJNJqbn1y0g97hF50UmTS8Z3wMakixOz3FC4XCwjFISC3BAW1IW2boauJpsisHtyxfYG1UgYhPJIiwRINUJe0Oe5O/mYuo5dRn0d4aZNK1lXmiCp/tY1K2M2ul/JhWN7+bOq6iZ8ODe7kE+tLv6ggBPC/i++KABohnOaSHb5dxtqxCV9T x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: X9jmghm/ddvgc1ftvOKUa5612bjMPCSJO+tb2p2j1wseuLCG63CzKWAYNsa0EmV7dvQeNBS2p/FCqqZPlK8b1CLzMAFYANMjGdglq9fht06ML+pemdqD88VWatmmWTeNWmIM9x31bsJRh5Q1l9HuiXcaRvJAC8PELSJNKIpANfwRsVEct/DLmUzX6nH1CzTj4ghmJnGUsgLpJFajw6VQLQUEMHPPukaZMr5ff9NgH02NQl3YrTpuZfYYLvnWSUlfb95/V4Rk+KHtjpxmpQMDeb6uuE5PCB0fynNmVorjEbQ15fMJWb5Mtsq2Y1oTH29Cig0YAMZdLVzx8uToG9tMJYwxUfot7I7gJoTvV6sB6iycirNYsaiJSUUEgT2rw5Aumny0y+F03TebWQr8UGa1i+EgLuA2unZw64zdBxxJipNDT2P29soWvGCW5IFMA9MSfp28lkzRYnpJ+ZJUO9I7O60798LJwY/H1UFzP9Yioz37kwrHJ3iNgVzy81VYlVOWe7JC/DNkP09I/7/ahWCqU/rypb82u1gu445v5goMjPXPbn5UJWzKZug+lLFDu+SMlYvEyLrzwGxm+zGqjhyaEChP8K8yQA7ZVcVRTp+U/j3WA6HqvNkwtwoHgcxGPxbuZ5dUykZbKQHG4jsCYz4GvkEVmnjUjBFKy/ma1ifIO+8lKuj+x0t5xqomaUm96I4BhNffhdVrZvjfGWJDAG++vXAvF8QVL/fgBauDmOHZGeIwKVzM9Tg9tDxNbjcMap4MwCWCjWZ0RyQiI7b6VSlDEsOQFLKCIv2EfpZ4SegGINYxpDVaW5xIGDtXdLtLW3kqp5SJ2eYEtK+HkoQAbTc3F8Az1dhWLAaWyXLRUgH93KIyul+fBOTtcUJXUbY+Dk58f+cHDRgr0MocLTFrjMlUCgVpPrNNT8pb4lb/jO00+txPAsSnnvV28cuA0xdOctCSSJfPNNu6KtlPLUUgPeeedEKRP82HQUNCvnnYvTBLF/1Q7nF9bgaaEFtys5pW4h1pDuhplHMtst2rBKNSZmTb1nHdB27TL5VKZYNLnI6s5dDdApnTF1ADfImHImKKqW4Q7v5tr7RzNW11Ky7Pvku7pUOV/oO2fsI7EAs8eVw/3F6Xq8LjSPqCgz0pczWD8hIVdravOBTRiwh4XweM6gzXUiwnUm04o/RaiP67YRJvTq+amuplFO38oJSBAZTE7r587olUSChiEJBeKe5+qHyWDnFlnCxdzmksm6Bf9sIOzZvajeHkGwmtGtu5LkXHW6O7YgRuozCRvmh2NOt1huiHVy99V2yQ6mvZQuC+ic5hWLGuFl6Q+yTvUy6bKdKf4Y0D Content-ID: <53C2C860601E514581EAC7FA4CDFD8CB@INDP287.PROD.OUTLOOK.COM> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-24072.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0217.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: fb34778c-1cf7-47af-9d2a-08dcb7a18e49 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 11:59:28.4131 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN3P287MB0339 From: Kerem Karabay This is needed for Apple Touch Bars, where no HID_DG_CONTACTMAX field is present and the maximum contact count is greater than the default. Signed-off-by: Kerem Karabay Signed-off-by: Aditya Garg --- drivers/hid/hid-multitouch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 571435da5..60b675cd1 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -490,9 +490,6 @@ static void mt_feature_mapping(struct hid_device *hdev, if (!td->maxcontacts && field->logical_maximum <= MT_MAX_MAXCONTACT) td->maxcontacts = field->logical_maximum; - if (td->mtclass.maxcontacts) - /* check if the maxcontacts is given by the class */ - td->maxcontacts = td->mtclass.maxcontacts; break; case HID_DG_BUTTONTYPE: @@ -1309,6 +1306,10 @@ static int mt_touch_input_configured(struct hid_device *hdev, struct input_dev *input = hi->input; int ret; + /* check if the maxcontacts is given by the class */ + if (cls->maxcontacts) + td->maxcontacts = cls->maxcontacts; + if (!td->maxcontacts) td->maxcontacts = MT_DEFAULT_MAXCONTACT; From patchwork Thu Aug 8 12:00:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 817799 Received: from IND01-MAX-obe.outbound.protection.outlook.com (mail-maxind01olkn2077.outbound.protection.outlook.com [40.92.102.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B1FF126F1E; Thu, 8 Aug 2024 12:00:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.102.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118457; cv=fail; b=j0swIE3O6D/j5JL48PWfMk4bisI4L0VIAgLjSnzbCQxntbLHp6NnBo/0WrpD34jpA+29Z3Vb3g9YbELG/R6Ad6JNu7y9GZ+U8xMzCre0E17JYMro1Ctlthb0oOMsKcdE+n+hy+jkhTnMRgNDyXcpxzRHqk/G2av5cE6VrXVBaeE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118457; c=relaxed/simple; bh=CG+RvCJbU5YuQi5CqKwWSCmUDgAhpUXoQBcqo8GokC4=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=rIDST1NHK5Os2RNmOuuwJErahipW8zrBnFbghW0bY3+lwFlG/EBRO2FcD7wNnxWW7jc/dSZ1qQqdt3q5kxJvnyOP0RVF5A3o6YJhSyZr13MR0b531Y6LBWBT8OyC8kDUebRf3gl7Ye7KkJ/jqxuhPnL1gcijhbUKkAYivUR6t2E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=RrXgzK1B; arc=fail smtp.client-ip=40.92.102.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="RrXgzK1B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WG+GiLMtg6fnA/tN/YzkUHcrsqsEW6P0aPMPGRKsQNsDexG5BpJHyy6Ld2CRY0WXazUJEbgSSpJagxjHNqP9uuHWmfNwm93iCICvRKYJamvX2RkQg0MhcFWPD1D63qgqxhE30jzWWdSehDZaPFXgB0ZGW3WHaStKvTKDMA82tvjMzVRbCooGOauj0itQg0lLT2DzFJuojNJiNq481qA0JrvWa3cxuw+HZEuSeIOBGavnfonMMrVc+rEijNF3G4Q/Jzq6Y5GbHK1iCGEeF+hyWmoui42XUt371eDEmaVBTreh9SAU1VzwQgWqK4R6HHQOAwugrl5T7KoPIzWt34k+7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=oXj5HFioyjIOLcAdy/oXSpQUwhLoR7Iglk2c3NpVYu8=; b=d1pFSzP/z/yhQmaIZQSUKp1aNNugsW90VDsjOgQW5i7wcWj6LIWvcfex6ciCKkvMAr5NxDnIja/+OLjbLUmnTbIHJ+ocSoPAkV5rA0dbVQnT1ffiJYeqV8l9CWBsAnRHZGPUYteVsaltnFsyscPlkUF53kQIePQ95TQxwz34qa67ZdzXVUsVEZIyiy8RJzxGr6WFNv6C8sJ5VWvF8Ef8CZyJQAVFVV1hcvRQ4GuVFtkL3LT8CXXERMVB5koQ5heoEfziZyNmne/PWD+bI+Rzg14B4xUfjk0anzQW6Izpe+CafDdfM5AfzYdHkFTjUBrNmKQh1F8S27Fc8ZQZJgWqqQ== 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=oXj5HFioyjIOLcAdy/oXSpQUwhLoR7Iglk2c3NpVYu8=; b=RrXgzK1BeGFK4uXEfPkH9JLE4Ba9qaRkwFYmzC3X7SgHo9NvegiJpmZjlk9D596jYKwHg0AXeX2XRCLmYXZMejKDIogWZIMLTyPp5+UuVBUsGzkzalEQ1ld1/VSXAf3BZZVFLtyYGmg6cw0XAjsprEh4Q6TUrpjBOQD5iJrUYY8V0NKuRYoixWERA/ci93FcgTwC+EQmjqG681jxPrSUh9hfQWBAEOC+17Z3ksjVZHJnLgLK1TCp+4UipkW1+LhM6Cv+7Fa4V0A+RM+prdGdrBuo2NsBkEx9a12G3hbp8jGR0yUgviej+ln1J8QgpDWDexOpeehK6VQ3uvSj9fk1QQ== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by PN3P287MB0339.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:d0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 12:00:26 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%5]) with mapi id 15.20.7849.013; Thu, 8 Aug 2024 12:00:26 +0000 From: Aditya Garg To: "tzimmermann@suse.de" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "airlied@gmail.com" , "daniel@ffwll.ch" , Jiri Kosina , "bentiss@kernel.org" CC: Kerem Karabay , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "linux-input@vger.kernel.org" , Orlando Chamberlain Subject: [PATCH v2 6/9] HID: multitouch: allow specifying if a device is direct in a class Thread-Topic: [PATCH v2 6/9] HID: multitouch: allow specifying if a device is direct in a class Thread-Index: AQHa6YqOtWVqaK89t0a00KZy6o/VRw== Date: Thu, 8 Aug 2024 12:00:26 +0000 Message-ID: <592F8A13-42AA-45F8-A0FE-B0FB972CA767@live.com> References: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> In-Reply-To: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [omOktV6CXRNUGzAOb09ClJYOr3YR1j920ljlzIgAXGEEDxwXrMHCkUEQQw/Cu9jfnBh1Mxr4zr4=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|PN3P287MB0339:EE_ x-ms-office365-filtering-correlation-id: 99f6196e-f52d-413e-c933-08dcb7a1b112 x-microsoft-antispam: BCL:0; ARA:14566002|19110799003|461199028|8060799006|15080799003|440099028|3412199025|102099032; x-microsoft-antispam-message-info: cgf27mlgLfXzKjHES+JTRHa/cvugmIgh4thp/x4KWnSwrSCwy9lHSavUKu+8QV5vC2S/a00/Qugz++8TIQN+KQbC2YsDxcEqbnIiLxxOgm+qHCjRCol/1YbPQtFT9rG7D98i8vjOhBTaGWZYcjg2q5n1W53RRXZtTmvIEuBLsMrZYVHu2brFH1TlQnQKgVsD2VFBWy8Hfo9Ry8H26SJLVaeu1YmcVyLJIMGLeyV4c5nrZ2oeI0HLABFADoFjKEH7GGT1JFnAXe5O1ls4QqLb6P9fJvi0Rc3mBM498+bPswVTG6A6/y5dLOzEJA2xxYp1iHKtgPnHNRr/Xw+Ow4P1xzfeB4gWOm9kL9Tnl8dxT32iWFI8L7fK/nJSBlRZ8qjPadh3VpTIyazXzTd1zwel6gb+rykhKK8GqHD5kdmj5dhKzMVtrhF29DLM0krCs9ZfuC9ZP0pVURHOTlEKQzAiLHNmmgsA117qN73qVdJ81so/CzZ3n9SmQhp1rWUpT5c+oVj15nT36b3Fy02NHJGHnpQTlBx/XJ3pj61yg8pLCHZg7k58wqnIwPK+1qe4P4MBeHT+sMcpBTNUdYpH6BOzQgHHPqpeW1qwbvHf59VFYctJ07jLPs0Cya5EwSZcQ+KNHVeaNFqstrzxxjdlHrCMrj0XuLKHDPgOOD3U9uK7ATcGF2rCMRxiAQSWrUn3YOLu x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: yMjMDIzyGrYx6MmwMKgWia3Y3JMxLa8cFHLDX3EgKpPySq47/b5/fJDLDTJrW69YzM/vk/WDgWd4DYNk8oL2Z9GA9H1pN46MS5MUnaUekJ6TJKDl2MYPzfXW1ta0XIgtcXp2eq7n43R6503fy8I0xKRgI3d0OEUY/ORXl2GWE2EO5Tm7jrpbA7Wkdkci7sE/tpDZOSTon5AGErxT9HsHlM2CeQ6j6iP+oTJKfQrAv5g5fbHiOe7TIYJRk9O3Btp8DftzEmIskhGHbHmu+bZcewEV3uGzf27/Qn2f0dNuWG0qCwHjKn8ksu9rtDLrSJzkHfvpydFvAGD66gFoPcoFOsfMKuVa9upXEnjcDPogiJa9e8X0DhKlcLn75jxQ0W/4cLpjTMN1pNZRn3XPtNiuhRrvDKu7bqbcj7mPpj90cq1MWtZiqmCCyL3OrG57K0pnU/tkSMhHPI65Sx/MSe7EFQu5tkgsSuKDvmah0vJnlMm2LZAUTYVMoH0KhHYmZPXEpWWTS5r/wb6EqZ5tjDUKVgGXFJ3Rd7vI9ZP/oAA3e76FERm5wler3rChigCWeWHKaNQkeImpOskQ8JczPyG0nwrvRh5aXAmzYQJNqb0qUteI6V5KjA6p10znWf8vQM/zw+uUzPCsDXS1MXyxMyDV40uuJrfOLA8WQb0YTjSoCwU4voA6CVhI+krYLkHRFtJa7ksQOvQEkFpWr3uVrxy8q5dfrCOciH6baRPZYlwAD+yMHE4I/0ocBE0JFVf9h4XLANoVbYYhirU0dP0j3vXXRLh11icU1sP+CgGZzWd21yURE5JQ46Uc4x5a2c2ENMJkOnQJLIcQrF3daWBFI/IBGGRX8jpTosllxaV42RiVSktBzxg0T7xIv88Dvyr5dNh4fDEwox2W7juHFi/2bh9e869mpPQ2OGCaWCzTI5jR9fP95hvg1DCzf0kxEDZrupfAVWsKaU8RCnxie1W4/iaYwBYZoJ8HvPiqR4J000OC40kmgnrQeLqkQ8XWukUbI5spG790mzu+uQhANgCe1FqQra8r92xhN87GrE3heuoetlNCADG1njkZHPuVWpjm0xn5xo5goCX6hWwM+AwZCrk6k+wCXk0ImsmmPvr5ZxAUIYkzssSye22e0ixZ90ndMyJdGW1PLRT4QYUn3G2AgRSqt5UahHCUvo/lfdZWdHIvQMyXBsCbUiMxo1VWZHjh6+EAx56diEqw/AOdMNgViUaKrCjbL2tJF2UqDuc3mYKR0r84i/ihs16Wc4leLiAmluNVFCDUjjziNohmjb7H16Hib+1StvgFlaXFvttfuf86RJ/v2ms6inBBeubZdyACTYSA Content-ID: <664466181ABD6343B76ED75AA599CED5@INDP287.PROD.OUTLOOK.COM> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-24072.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0217.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 99f6196e-f52d-413e-c933-08dcb7a1b112 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 12:00:26.8147 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN3P287MB0339 From: Kerem Karabay Currently the driver determines the device type based on the application, but this value is not reliable on Apple Touch Bars, where the application is HID_DG_TOUCHPAD even though the devices are direct, so allow setting it in classes. Signed-off-by: Kerem Karabay Signed-off-by: Aditya Garg --- drivers/hid/hid-multitouch.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 60b675cd1..2948fbcbc 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -146,6 +146,7 @@ struct mt_class { __s32 sn_height; /* Signal/noise ratio for height events */ __s32 sn_pressure; /* Signal/noise ratio for pressure events */ __u8 maxcontacts; + bool is_direct; /* true for touchscreens */ bool is_indirect; /* true for touchpads */ bool export_all_inputs; /* do not ignore mouse, keyboards, etc... */ }; @@ -563,13 +564,13 @@ static struct mt_application *mt_allocate_application(struct mt_device *td, mt_application->application = application; INIT_LIST_HEAD(&mt_application->mt_usages); - if (application == HID_DG_TOUCHSCREEN) + if (application == HID_DG_TOUCHSCREEN && !td->mtclass.is_indirect) mt_application->mt_flags |= INPUT_MT_DIRECT; /* * Model touchscreens providing buttons as touchpads. */ - if (application == HID_DG_TOUCHPAD) { + if (application == HID_DG_TOUCHPAD && !td->mtclass.is_direct) { mt_application->mt_flags |= INPUT_MT_POINTER; td->inputmode_value = MT_INPUTMODE_TOUCHPAD; } @@ -1317,6 +1318,9 @@ static int mt_touch_input_configured(struct hid_device *hdev, if (td->serial_maybe) mt_post_parse_default_settings(td, app); + if (cls->is_direct) + app->mt_flags |= INPUT_MT_DIRECT; + if (cls->is_indirect) app->mt_flags |= INPUT_MT_POINTER; From patchwork Thu Aug 8 12:01:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 818335 Received: from IND01-BMX-obe.outbound.protection.outlook.com (mail-bmxind01olkn2060.outbound.protection.outlook.com [40.92.103.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99BD7126F1E; Thu, 8 Aug 2024 12:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.103.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118490; cv=fail; b=IpINjAH+kyurh9R5BtBxhhtKrjC6BJSjHOuD9IgCXGQeuQKYj+PqLxwCheSGISz+QxB2G9U5P5YJbcMx0ZnnwN8CWH4EqQ5OHvh4khrS1dIRd1yW4n2fw2QrHubZp25BX+HAN1oSUmCnyPWGdm0oEb9LZ+TUJT8PN7rN92Doqig= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723118490; c=relaxed/simple; bh=Epig5QAHDBVwrNvDZkDXr7kWymX9dQP5FAfFEisSWhU=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=BpEhJ1Fi4Rtmsxtu1C0n7ZZdkm7hkftKWpAG4dyUZfkEfmFVpCXw+O9gW0+ibBIml8PxjFV3HsQCa29eMw6LTTsr/t2pqzb3ac62Y/PFvDfWrVR6GezOVmAKVkiEuubY9LWfSpFOg+NYvRTX1VWZ6Lx3FvHCa9lZoKT+2WX5vRk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=prBxQf+E; arc=fail smtp.client-ip=40.92.103.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="prBxQf+E" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eXYvwCX86pkoFz4bY1LvYkwclunn84+yLwMWtvIG74pYKuL9CDRA52evxAeFEvlEDj+V3vSE6ojShcOEDIKNQ3awUhmS6cAMsklQTIfujWdl1L0zwexS44YDBl5Z0KQkkPqT/OjpiWsPbXlPGg7DwCfMvyCOumR4xCdrQ4yq90Lwal5zuKWzwRQR0FtDTdNEeLmZYS6KNcnZFBee2i74KLtcXUdHxSbS979vcFb5QcLgdQkBk2GRWWvFnOeDM9nHw2opzZE0uDp2xlCqMEGYWF7eRgkO/zr2ljbA/vTVrh9g4uLO4SmBBKrzerWGx7YTkpscUIrwKstZmWCUr0PkFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=iRg9eJxDc4ARlekO+g7uV6lPG0TkCEJFMy6dAol1E7M=; b=ehR6lkiQ4oykOwGz6gGKZKr8f3exF3faceqQnMfCSHQ7PmB8z5dYkHZGFY/BZGosSqFvVB5VwcdU37tJnkR8qEpp+u27VFL0NTHMUq1lQtFN+bDhG8vIuuv7ypOQmtejvzpyJxwmGF7JymXepEUJ5Gz/oBZfd2TZRDdlidATue99eAF7Ltx4VuC//UU5EvUQ8zB7VF7S60ilsC/3krglZBY0WKgi7Qp6Yn1/x4d9iREgFSAhXf6hSZRLoFuXi7smh+7byupDN158BWPEgjS00RI7hdFxz2bAv/5usyBTwrQZJ5v6XSFM/yzYIg9F0PizEBGSGGwKzwYoZxozTmEfkQ== 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=iRg9eJxDc4ARlekO+g7uV6lPG0TkCEJFMy6dAol1E7M=; b=prBxQf+Ee/7Cg8EORrhO9E108okFu8dOhJNLuwCj1zFvZecZgKACTTl6lXaBmxpmB1IrtQIc0YPQr94kj8Pugb4hwgyl2sGsZt7NP1oI6S94OiqAXUrQNKjJ9sZ2gRYJK9HVYXwZKzpBDUP1Fk9b+QQzA4+34qQjDSXZdymr4kpnKdleUf/XQRpuyUwPxt+GQm7dpATKynQzffqbs6vGycgOM90jEuROxL3lu7xwkpnXBmbwVLP7SCD4T3CxwsrCv1M9u8v40yUjHpqBpgywkyfLfTTbU7JJWVjhwuXJiAd8hNOEZ9beG3IePpo8zhklZ1w7LXLpKIahhj203TVHMw== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by PN3P287MB0339.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:d0::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14; Thu, 8 Aug 2024 12:01:22 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%5]) with mapi id 15.20.7849.013; Thu, 8 Aug 2024 12:01:22 +0000 From: Aditya Garg To: "tzimmermann@suse.de" , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "airlied@gmail.com" , "daniel@ffwll.ch" , Jiri Kosina , "bentiss@kernel.org" CC: Kerem Karabay , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "linux-input@vger.kernel.org" , Orlando Chamberlain Subject: [PATCH v2 7/9] HID: multitouch: add device ID for Apple Touch Bars Thread-Topic: [PATCH v2 7/9] HID: multitouch: add device ID for Apple Touch Bars Thread-Index: AQHa6YqvzOez1ap2/U+g7ZZ+h/G4ow== Date: Thu, 8 Aug 2024 12:01:22 +0000 Message-ID: <6AB25F04-EA02-4737-B5FD-77BAAEFA9DC7@live.com> References: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> In-Reply-To: <9550ADFD-0534-471D-94B4-EF370943CF80@live.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [TE0ZrEGgc/1+pS77m/Wjrt74y0yWy2FUAeTYdjUY9yu5UE/ij0wPUXUaM+8Mn4LDaE798j6EIVU=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|PN3P287MB0339:EE_ x-ms-office365-filtering-correlation-id: 3f263054-759b-4420-894e-08dcb7a1d214 x-microsoft-antispam: BCL:0; ARA:14566002|19110799003|461199028|8060799006|15080799003|440099028|3412199025|102099032; x-microsoft-antispam-message-info: mUfGQz7HYqFw2nSy/OVvOzWJEPoYbi9OaSo1Kf+yNcDeFitTwAeZkPMSbXqKexwNCJMzsKqJtlmzzJds5/70lPuo7Yamqbqq5ktu10i4U3F4Yp3iixn0OZ7h47m1EjxPsW2I131wYjL5V7B0T6DCKUw0KCF8w/qBX1lQkQppXttjB3FC08pPgIsgy9694wlWX0voDPgVeHOTuNnfF2qCwWzX3TyzkCi1yACcI5TzKi+FQpDPVSR6Jpk0m3qqzZSxJYAAV78s0OUnypUNA+O+liw3JsFBrTGUU0PsN1g36OZrYi2EtmNXVCZ1Q6GYF7xkHXjXhBXSnsmNKLdHXtISuGDrQ5iQtZU5bmfaDeV+8ELjvVdvschssgCohRC+N3y28C5eyZ6HpwxA5S39gNaxTU817WyvNpPK2k2WAzN6sLOcpJWugl/JJgWR0R6UsWaswT7e0oeURM4YRuKRVNcMF0/Gcz+ZDDi+HxGH8l61G3Tl2lNRZupHaKbvtGOxmyPHZtx/jS8MMfLxzTK7BH3YJwh6B1AHJeVf8KsocopAIpVsG6PN2GhRdhSwAHZC1+oue4o91sbCYyCRUF1ijqD2O2zyG+hdP980G+dQ/rtziI/SiW83yhe7gYEm06YnLFC6BFYdREPxrK9Pq6WBthpiydgaL7pRKg0xwKNsIRKty8EEqY+CEIQtCFGsMYPTdCmz x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: XY4qMeanqyQDILrA3IMiqebs0wv0dJ9/wwbRMsrP+B5ofxG6afa70GAm0wqDT6eNah+yiLyuwj5Hu0VUbLSoPzBeEtFcl0nstUDVkFTbNVaSUy3ftQKFHqDJRPk5pxDSpZsClRjKkbPKBXEFc4zBQy+G4IX0nTwxBHFQ59YgMb2xTR/cAxitT4oc0sjLcS4mvi/MkXsUTXL/jex/azOcKPvRpPHtwnXRITcn1j2YM9NRo+PPRul6Lp2cVVmWaGY4uibNMrtBNj3BQCzenKRmy05WDx4lHc8GR7o7JHslq9OdxRQXQIHs1GGIAqs0PQ9lonKJQtqjAPOh+odps0inaF37zwx7bD6owsbtabva+u/3sG5Lh8nMdB6PhSW4iO9tChW7MuxLY6Wlo90ZQO3Ddh4I7Ia8SdNDAl3ygnFxztowbspsLKPLAw+w7ZN5I8/6O6nEC98O41UYf4wDP7/IK06LEJ5lufA9FJuWM4IidXI7DPZlHwbWhZm0Qks+OJ7D8/GHP5fkOJlLnt59yDxs65b+1p7oai3q/0sUJBFf3G33a/9geLT1wCU4YrIaQHRnGFwlQBAHGFZcyFIVErt2j31sQBCkWkh1A9qiNi1sJ9Qpvwx8u1U+OrMcNgQJ4AwWyf8AaigmOAngfM1kLI41fR0gkxdap1JdkOLI8viV/U9EniMpER+wEui6TD2dTI6vhYdsi+PD3Beb2/f6OcsvgtOODqciCazkl7kkBD98gIVsvn/lKtrbB+xdlj8W5VgcJwwuom8bSGAdKN6nnf19ek9S8Ea5kzBygmx8RM7UGO1IB7+wVFymW8zacZFDWUjbuDND2cdYU+V1hTx0W9n1LzvrbpqjCcufQdZAa3JYNA/OXsDeQ88j5KLPiDVGiX+b8irvKY6N9x+wjREohaohK1NtD+T4xeZj+rm96gQCBLx4V7hMM4XWI9YBUO7Yxk31Au3rxTzwM9GK1aWH6pdzs/wM/PCGkmTNzKDqGwb94c9bAYbFFnJ3F8DWEvZJnv6PzFp8X5XYk/uoLU7qyPeYSNcdkqmUOypLkoIS0QCByav4QC06j4PDQdCy9s5PNposrS20GzYMnhR4R3yMvpdA5v7AEtLtvrJTISa+48ODN4LitjKBqkpzZgM57CQYErCJKjD/G3MwJrmq9gmftianTOANaO5shTMpEa4DAqbHbKz9K7XcpOhoXl/qQeWaK0BR/UgvBfbyc7ZWoaaedOXIUJw81JKuB47bE6UdJVvIDHy06eM26xr7NE5/SOuWnhR92vU+1eL6tqe1NXZLZlhoMWJXdM/yHKVu4pC/Q2qDrrTnrwN2Md+k3ZwLFtOdAMBp Content-ID: <83B75ECA2854B541BA20B45AF5B694BF@INDP287.PROD.OUTLOOK.COM> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-24072.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0217.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 3f263054-759b-4420-894e-08dcb7a1d214 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2024 12:01:22.1641 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN3P287MB0339 From: Kerem Karabay Note that this is device ID is for T2 Macs. Testing on T1 Macs would be appreciated. Signed-off-by: Kerem Karabay Signed-off-by: Aditya Garg --- drivers/hid/Kconfig | 1 + drivers/hid/hid-multitouch.c | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 72b665eda..35ef5d4ef 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -744,6 +744,7 @@ config HID_MULTITOUCH Say Y here if you have one of the following devices: - 3M PCT touch screens - ActionStar dual touch panels + - Touch Bars on x86 MacBook Pros - Atmel panels - Cando dual touch panels - Chunghwa panels diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 2948fbcbc..0fed95536 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -214,6 +214,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app); #define MT_CLS_GOOGLE 0x0111 #define MT_CLS_RAZER_BLADE_STEALTH 0x0112 #define MT_CLS_SMART_TECH 0x0113 +#define MT_CLS_APPLE_TOUCHBAR 0x0114 #define MT_DEFAULT_MAXCONTACT 10 #define MT_MAX_MAXCONTACT 250 @@ -398,6 +399,13 @@ static const struct mt_class mt_classes[] = { MT_QUIRK_CONTACT_CNT_ACCURATE | MT_QUIRK_SEPARATE_APP_REPORT, }, + { .name = MT_CLS_APPLE_TOUCHBAR, + .quirks = MT_QUIRK_HOVERING | + MT_QUIRK_TOUCH_IS_TIPSTATE | + MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE, + .is_direct = true, + .maxcontacts = 11, + }, { } }; @@ -1747,6 +1755,15 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) } } + ret = hid_parse(hdev); + if (ret != 0) + return ret; + + if (mtclass->name == MT_CLS_APPLE_TOUCHBAR && + !hid_find_field(hdev, HID_INPUT_REPORT, + HID_DG_TOUCHPAD, HID_DG_TRANSDUCER_INDEX)) + return -ENODEV; + td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL); if (!td) { dev_err(&hdev->dev, "cannot allocate multitouch data\n"); @@ -1794,10 +1811,6 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) timer_setup(&td->release_timer, mt_expired_timeout, 0); - ret = hid_parse(hdev); - if (ret != 0) - return ret; - if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID) mt_fix_const_fields(hdev, HID_DG_CONTACTID); @@ -2249,6 +2262,11 @@ static const struct hid_device_id mt_devices[] = { MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR2) }, + /* Apple Touch Bars */ + { .driver_data = MT_CLS_APPLE_TOUCHBAR, + HID_USB_DEVICE(USB_VENDOR_ID_APPLE, + USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) }, + /* Google MT devices */ { .driver_data = MT_CLS_GOOGLE, HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_GOOGLE,