From patchwork Tue Aug 6 13:47:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 817204 Received: from IND01-MAX-obe.outbound.protection.outlook.com (mail-maxind01olkn2091.outbound.protection.outlook.com [40.92.102.91]) (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 43D161D47AA; Tue, 6 Aug 2024 13:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.102.91 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722952075; cv=fail; b=aqp7oNNh63VtOj2QkvCzB5RM2hDYZxtERC89VKKf2MK4VhWgsf3lhVSGQ+YZseof9v4LYrTOW47b0ysYxgvERi5WrbVneWskNbUp21ZaFt8jBKPQMKrFeXBfg3F0vG4vYqgRVWktuhvcx+7fjFl/n+SaJZNBkaBAnf7JPilSAJY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722952075; c=relaxed/simple; bh=D0qLwSFECv9OWQd4m9QpT07h/bWMht6DoLCCCfEudIo=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=W0ULRAA2xUliZeG6a74U+57ugY/228r9sPfIur0N+oWQIQmhk+ThWsadwbPq3ON7EI5T9Q/xqHM98P75UVrhlbMf1nD7feV2BDLYOuyNIIzD/Furfs43ORqceIQQER81gtJ974wGBArgMU3ncpjQWjfnH0LE5JX8J46etKdsfI8= 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=jQFILm4O; arc=fail smtp.client-ip=40.92.102.91 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="jQFILm4O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SfLffjqrs7SUdsM/uzeSfeH3zzgDv/kn+ZfyUSD1HdquZZqD6Fd6exyN5twjx4C5exC5DydXuJu4fKWDoWFZFPc1Idy1Cms41x4RI4T8GLBTNNpwtetDpNHILzzln7YWv4nDHPRRFn0JOWRd5cGzJrkolMFrwrp3AB/3zu9YhqLM5COhqK0PeWqixM8uXTM2C/M9EtYJ8Pzt+6NP33chyToQLuNGoBlxXGy6Xv0BgqFPNdSAEwqOHOzJrpvSHkxVVfyAOidZgT5JYhypPi0jpeQBqd/0keBsYO839sMDQcRzw158iBLWEm3fhEmAOpTVgvpfzkwy/NjoMIuB9bhIDw== 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=D0qLwSFECv9OWQd4m9QpT07h/bWMht6DoLCCCfEudIo=; b=JDNoe9ApzXjDE/513IwTaKZaktT/+BXWkSwPqN1b1++IhR8r4DVAuuvv9rYWh+50TjMkGUJSSQT83hOjw5vMZy1lj989WDnu7Gme95wLOKtzM6Yb3t+jWdGE7X9TWlw4zd4Fpx4qspem8XhnWmKFFcNmsk5QwUKFXnUbJrfHjvOS0dbAw9nvyhTPf8yumxLKp1MTArpRiqkNQz/IiWCOUSkpS1+PLpIeN1+IwgqVKjNlBKoHpQOqtbCnwM++sGlLWfRDty4mJixr1BEFUH9k3KW3DVdw2jnOGbHfXLnDyuXaFF+661iT0tfNh7Q1bHQNN5O7R+pRNbstj1T2liayEg== 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=D0qLwSFECv9OWQd4m9QpT07h/bWMht6DoLCCCfEudIo=; b=jQFILm4O684X20plKXTVhGQth+resJwDy+dSmPNtJCZmqyyKEBYCjYme7taOKd1/9rDbAjHB+G/VhirYHJeI2dC08BBhwvOSYxvn+y9ZA8euBc6DDEQNAbxzO/gxIpYQSdNQSqXdQQbHDXsS3h3CjhT6khb9ZkERTJ24s+V1zc48xw4o7ec8XXrfLS2eoqhhxK6OpcQmJmlZcBT0OEWHOQtZIU9l3T94D+uDcpS+ZYGLf194DMdWmDbgnjIUTZN3SFsfEkh4h3VEqVnq3qkZs7TV/tWiQ7JQ/r5ieI6Of4vcwm2Zt6hvxf7c7xyHOWsdGGB+AaYM82bhw8nP0CwTbQ== Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:b3::9) by PN0P287MB2100.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:1bd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Tue, 6 Aug 2024 13:47:47 +0000 Received: from MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a]) by MA0P287MB0217.INDP287.PROD.OUTLOOK.COM ([fe80::98d2:3610:b33c:435a%4]) with mapi id 15.20.7828.023; Tue, 6 Aug 2024 13:47:47 +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 1/9] HID: hid-appletb-bl: add driver for the backlight of Apple Touch Bars Thread-Topic: [PATCH 1/9] HID: hid-appletb-bl: add driver for the backlight of Apple Touch Bars Thread-Index: AQHa6Ac4UNDG/AUcD0C1tqLHK7a9LA== Date: Tue, 6 Aug 2024 13:47:47 +0000 Message-ID: References: <021EE0BF-93CA-4A37-863F-851078A0EFB7@live.com> In-Reply-To: <021EE0BF-93CA-4A37-863F-851078A0EFB7@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: [2zUQohJ4MxBHBE9+g8CYoYs4EIZ9Xfc0ki+t5l2Bw/SSgkJdUZypuKaayXR+y4n9VyfE9arLOzA=] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MA0P287MB0217:EE_|PN0P287MB2100:EE_ x-ms-office365-filtering-correlation-id: df498a4e-873e-4fb9-f666-08dcb61e5b0e x-microsoft-antispam: BCL:0; ARA:14566002|19110799003|461199028|8060799006|102099032|3412199025|440099028; x-microsoft-antispam-message-info: K8FPzg8/28ktIIUtNm4dIGWjw83RIz5S4ttrfWrNe9siWOYZRTnGOUksOk2Fr5C6iso86b7ODQjE7Wk1p9inYuTtPcPP1ddvp6cl0JCibgGIgxagNMj56LGKadJBDtaf/kE6qxC5TEzTRxWoBS9MteLMUY/Fh4NK7iPHte2Qjww7u8tmG00AD9FLMxxs/3rxheEp3u3WpHSXxcJq8csnL6xPchK737XJjbX6HqzIZL2hGhmC8jx/KitKcCyC/Uddr0cFCr8rKFhHgH9rWG0raqumUgyfy4jTuCGLC5Hie2y7mpK4+AJRZTbvSCl8qXUx5z9pin88ckX25lzQGQoIMRhGHtIR7gHUfhTqAvXyJhkBncgi9mW6ITjGRG9qoeUzmnvRH0IkIRraqLw2rsZaa18VcSB/MCkHteqEJOOnm8LmgfDlRejXfKNC9/GPKm7BtFLj68q197X3dSVXHA/439hs5ZsBtbdoDNHEO7Qk4Jx4EHCn+LMoj4cpMzAwfbFQinl9lM4AqjMyafUW8GsvnHz2RRTZyzoNMA5hxqk3jex7hDvo6ByzMYONuMDAnSki+DV3gu71Hv6gW3xSeu9WObrXPdaXvJRhc/sfayCQCKpNBxXDROtkpjCHfvJ2rCKZSiu+Y/r+e4BRCDSccwmdnQ== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?T3bTlAI99p0xXuVI0tDDe3URGsvF?= =?utf-8?q?TFQ2Q9RlNcaMSITUHQQyv9jItnCE6NMtn6vkTPKkusFI+yjfvexbGvXEJ06l+r03z?= =?utf-8?q?GLedVw5wGkeQzCJYGKeRfsbzjP+bQFvbsiu1ZvOhkq9atqDzrMyb6+vzh2kyQ4Etq?= =?utf-8?q?lfy/V565raGBdpWz03AqnGULNHzhF6uY/iWX0ifin7l6mSmhFgViP4NRrv8GKQOIg?= =?utf-8?q?PD13rogWj8EWsbM5NAJ43brPrJ5kmjdNzAttkIoyo7dnj5ih3BrZ0rEBNePOH+hxC?= =?utf-8?q?CdqcnePGOFi1ubdJreKJXETSREfZaDiaHOKzA/0Ah1crnXwqycdbDs61P7K9PTNBk?= =?utf-8?q?rZhBe9Iny0tuPxKZIfoVDgSTez8CqEXMicx2/DmkG47k5flqc6l8yuhqmXVqlWIYt?= =?utf-8?q?FLDxpoTSMDT85swh+dFMrZ90QF6hQ7jy/pNtSsbr3Y6rFPvnnvVmd8QKQiDx5MNP4?= =?utf-8?q?gKI4UNtHDvmIMxNrhbW4ID9HICM7fL8PxGAMI/5q/DMvR1lVSMMnwvWlyV3+Bjoqg?= =?utf-8?q?jH6kTL7uAerqHHTIo/+LDR3JtHPJdSB1cFcoFNCLMvAKNwX1hZeYfeDVF09dpcB6k?= =?utf-8?q?BeAX3YbF3AnyWa2C+UasCXeRZNmms+36DZD4RRBx6rx+lYh3RsLbvv7WHafc/K9YL?= =?utf-8?q?WiUI27OE8UTVd+cDeX5NhtOY78Pfq35XUfzINBzPM4j+kFPNzT6jGYe1Pd96igvRn?= =?utf-8?q?nuh9mVkuTLMVVfPy6NclbVg0Ya2CJSVA8ucrIBdnrW9Sa7Y/+I2Rjoo/z/Dey6EM2?= =?utf-8?q?gqeNhRCQMHOys+djiUzRKd9pQhLsftjvwAxn5uZHWryrnkQuoRUYQ7hVe+DIMQ+3Z?= =?utf-8?q?jX8FjgsZc9cgq0CyU/dt4BYYc19YxFK3jdFmLua03PFyxCz1+EF+/iMfM96E57W9g?= =?utf-8?q?6XNFH4KsvfwWGEGmwJSHiAnZCUqX20yYGCBtMOQEQwXPNUL0x/t1oUsnMFR/+5c83?= =?utf-8?q?oWziHmzL07ewy1qa9ZsLd8zW3ZlswGppcngTrJJLg82LRChT0BffPrGTRpqa5Rvxu?= =?utf-8?q?2Dq18/GZL3dsPISSKYOh2k7jx/wBYwlAXSvzKBqIW0Th9KaT7bP1huSe2pK6/xfsK?= =?utf-8?q?mBhGVVPMgnvVm+ikZL+j69IxANa3/3s2d+hMKvIW9eT7/Pg91zfRBfIuu5WCs54BE?= =?utf-8?q?5Iokzn9nnpkKXdoP6YphXtbv5YI4Mh5btSgf4qwt9FVL7PaqD9Ti8yjlEl8dH8GhI?= =?utf-8?q?g8TlVsr6nyva/VVbb23r4hhN7NWIHbEwXyVtGhdT8En8xqwmWc1jrsTDfXhaUpwKf?= =?utf-8?q?lPnwOnCEIe6jFrzw?= Content-ID: <05972F7C98F80B429D4B08D13A95A251@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-4755-11-msonline-outlook-bafef.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: df498a4e-873e-4fb9-f666-08dcb61e5b0e X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Aug 2024 13:47:47.2364 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN0P287MB2100 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 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) },