* [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros
@ 2025-03-10 9:10 Aditya Garg
2025-03-10 9:12 ` [PATCH RESEND 1/5] HID: multitouch: Get the contact ID from HID_DG_TRANSDUCER_INDEX fields in case of Apple Touch Bar Aditya Garg
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Aditya Garg @ 2025-03-10 9:10 UTC (permalink / raw)
To: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, bentiss
Cc: Kerem Karabay, Orlando Chamberlain, Aun-Ali Zaidi,
Linux Kernel Mailing List, linux-input
Hi all!
This patch series aims to improve the Touch Bar support for x86 Macs.
Recently, the hid-appletb-kbd and hid-appletb-bl drivers were upstreamed
into the Linux kernel [1]. They enabled the Touch Bar to display a
predefined set of media and function keys, exactly the same it does on
Windows Bootcamp.
Now we are about to get support added for the DRM mode of the Touch Bar
as well [2].
The DRM mode enables the Touch Bar to act as a second display,
just like macOS. So now you can add a widget, put a clock or anything
else on the Touch Bar as long as you can develop a daemon.
Now via these patches, in the DRM mode, we can use the Touch Bar as a
touch screen. The Touch Bar seems to be not compliant with the HID spec,
thus via these patches several tweaks have been done under the cover of
a single quirk, MT_QUIRK_APPLE_TOUCHBAR.
For the case of T2 Macs, apple-bce [3], the driver for the T2 Security
Chip is also needed for all the peripherals, including the Touch Bar
to work. It is still WIP, and will be subsequently sent later to the
appropriate tree. Till then, I'll suggest for get the driver from [3],
or more preferably, get Linux support from https://t2linux.org/.
Cheers
Aditya
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/log/?h=for-6.15/apple
[2]: https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/0670c2f56e45b3f4541985a9ebe06d04308e43b0
[3]: https://github.com/t2linux/apple-bce-drv
Kerem Karabay (5):
HID: multitouch: Get the contact ID from HID_DG_TRANSDUCER_INDEX
fields in case of Apple Touch Bar
HID: multitouch: support getting the tip state from HID_DG_TOUCH
fields in Apple Touch Bar
HID: multitouch: take cls->maxcontacts into account for Apple Touch
Bar even without a HID_DG_CONTACTMAX field
HID: multitouch: specify that Apple Touch Bar is direct
HID: multitouch: add device ID for Apple Touch Bar
drivers/hid/Kconfig | 1 +
drivers/hid/hid-multitouch.c | 70 +++++++++++++++++++++++++++++++-----
2 files changed, 62 insertions(+), 9 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH RESEND 1/5] HID: multitouch: Get the contact ID from HID_DG_TRANSDUCER_INDEX fields in case of Apple Touch Bar
2025-03-10 9:10 [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Aditya Garg
@ 2025-03-10 9:12 ` Aditya Garg
2025-03-10 9:12 ` [PATCH RESEND 2/5] HID: multitouch: support getting the tip state from HID_DG_TOUCH fields in " Aditya Garg
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Aditya Garg @ 2025-03-10 9:12 UTC (permalink / raw)
To: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, bentiss
Cc: Kerem Karabay, Orlando Chamberlain, Aun-Ali Zaidi,
Linux Kernel Mailing List, linux-input
From: Kerem Karabay <kekrby@gmail.com>
In Apple Touch Bar, the contact ID is contained in fields with the
HID_DG_TRANSDUCER_INDEX usage rather than HID_DG_CONTACTID, thus differing
from the HID spec. Add a quirk for the same.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Co-developed-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/hid/hid-multitouch.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index e50887a6d..6e7f34a47 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -73,6 +73,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_APPLE_TOUCHBAR BIT(23)
#define MT_INPUTMODE_TOUCHSCREEN 0x02
#define MT_INPUTMODE_TOUCHPAD 0x03
@@ -625,6 +626,7 @@ static struct mt_application *mt_find_application(struct mt_device *td,
static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
struct hid_report *report)
{
+ struct mt_class *cls = &td->mtclass;
struct mt_report_data *rdata;
struct hid_field *field;
int r, n;
@@ -649,7 +651,11 @@ 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 ||
+ (cls->quirks & MT_QUIRK_APPLE_TOUCHBAR &&
+ hid == HID_DG_TRANSDUCER_INDEX)) {
rdata->is_mt_collection = true;
break;
}
@@ -827,6 +833,14 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
EV_KEY, BTN_TOUCH);
MT_STORE_FIELD(tip_state);
return 1;
+ case HID_DG_TRANSDUCER_INDEX:
+ /*
+ * Contact ID in case of Apple Touch Bars is contained
+ * in fields with HID_DG_TRANSDUCER_INDEX usage.
+ */
+ if (!(cls->quirks & MT_QUIRK_APPLE_TOUCHBAR))
+ return 0;
+ fallthrough;
case HID_DG_CONTACTID:
MT_STORE_FIELD(contactid);
app->touches_by_report++;
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH RESEND 2/5] HID: multitouch: support getting the tip state from HID_DG_TOUCH fields in Apple Touch Bar
2025-03-10 9:10 [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Aditya Garg
2025-03-10 9:12 ` [PATCH RESEND 1/5] HID: multitouch: Get the contact ID from HID_DG_TRANSDUCER_INDEX fields in case of Apple Touch Bar Aditya Garg
@ 2025-03-10 9:12 ` Aditya Garg
2025-03-10 9:13 ` [PATCH RESEND 3/5] HID: multitouch: take cls->maxcontacts into account for Apple Touch Bar even without a HID_DG_CONTACTMAX field Aditya Garg
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Aditya Garg @ 2025-03-10 9:12 UTC (permalink / raw)
To: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, bentiss
Cc: Kerem Karabay, Orlando Chamberlain, Aun-Ali Zaidi,
Linux Kernel Mailing List, linux-input
From: Kerem Karabay <kekrby@gmail.com>
In Apple Touch Bar, 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 <kekrby@gmail.com>
Co-developed-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/hid/hid-multitouch.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 6e7f34a47..70fdd8cf9 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -827,6 +827,17 @@ 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.
+ * One special case here is of the Apple Touch Bars.
+ * In these devices, the tip state is contained in
+ * fields with the HID_DG_TOUCH usage.
+ * Let's just ignore this field for other devices.
+ */
+ if (!(cls->quirks & MT_QUIRK_APPLE_TOUCHBAR))
+ return -1;
+ fallthrough;
case HID_DG_TIPSWITCH:
if (field->application != HID_GD_SYSTEM_MULTIAXIS)
input_set_capability(hi->input,
@@ -897,10 +908,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;
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH RESEND 3/5] HID: multitouch: take cls->maxcontacts into account for Apple Touch Bar even without a HID_DG_CONTACTMAX field
2025-03-10 9:10 [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Aditya Garg
2025-03-10 9:12 ` [PATCH RESEND 1/5] HID: multitouch: Get the contact ID from HID_DG_TRANSDUCER_INDEX fields in case of Apple Touch Bar Aditya Garg
2025-03-10 9:12 ` [PATCH RESEND 2/5] HID: multitouch: support getting the tip state from HID_DG_TOUCH fields in " Aditya Garg
@ 2025-03-10 9:13 ` Aditya Garg
2025-03-10 9:13 ` [PATCH RESEND 4/5] HID: multitouch: specify that Apple Touch Bar is direct Aditya Garg
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Aditya Garg @ 2025-03-10 9:13 UTC (permalink / raw)
To: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, bentiss
Cc: Kerem Karabay, Orlando Chamberlain, Aun-Ali Zaidi,
Linux Kernel Mailing List, linux-input
From: Kerem Karabay <kekrby@gmail.com>
In Apple Touch Bar, the HID_DG_CONTACTMAX is not present, but the maximum
contact count is still greater than the default. Add quirks for the same.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Co-developed-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/hid/hid-multitouch.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 70fdd8cf9..f7fe6aab8 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1335,6 +1335,13 @@ static int mt_touch_input_configured(struct hid_device *hdev,
struct input_dev *input = hi->input;
int ret;
+ /*
+ * HID_DG_CONTACTMAX field is not present on Apple Touch Bars,
+ * but the maximum contact count is greater than the default.
+ */
+ if (cls->quirks & MT_QUIRK_APPLE_TOUCHBAR && cls->maxcontacts)
+ td->maxcontacts = cls->maxcontacts;
+
if (!td->maxcontacts)
td->maxcontacts = MT_DEFAULT_MAXCONTACT;
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH RESEND 4/5] HID: multitouch: specify that Apple Touch Bar is direct
2025-03-10 9:10 [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Aditya Garg
` (2 preceding siblings ...)
2025-03-10 9:13 ` [PATCH RESEND 3/5] HID: multitouch: take cls->maxcontacts into account for Apple Touch Bar even without a HID_DG_CONTACTMAX field Aditya Garg
@ 2025-03-10 9:13 ` Aditya Garg
2025-03-10 9:14 ` [PATCH RESEND 5/5] HID: multitouch: add device ID for Apple Touch Bar Aditya Garg
2025-03-25 12:52 ` [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Jiri Kosina
5 siblings, 0 replies; 11+ messages in thread
From: Aditya Garg @ 2025-03-10 9:13 UTC (permalink / raw)
To: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, bentiss
Cc: Kerem Karabay, Orlando Chamberlain, Aun-Ali Zaidi,
Linux Kernel Mailing List, linux-input
From: Kerem Karabay <kekrby@gmail.com>
Currently the driver determines the device type based on the
application, but this value is not reliable on Apple Touch Bar, where
the application is HID_DG_TOUCHPAD even though this device is direct,
so add a quirk for the same.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Co-developed-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/hid/hid-multitouch.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index f7fe6aab8..66e33a482 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1349,6 +1349,13 @@ static int mt_touch_input_configured(struct hid_device *hdev,
if (td->serial_maybe)
mt_post_parse_default_settings(td, app);
+ /*
+ * The application for Apple Touch Bars is HID_DG_TOUCHPAD,
+ * but these devices are direct.
+ */
+ if (cls->quirks & MT_QUIRK_APPLE_TOUCHBAR)
+ app->mt_flags |= INPUT_MT_DIRECT;
+
if (cls->is_indirect)
app->mt_flags |= INPUT_MT_POINTER;
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH RESEND 5/5] HID: multitouch: add device ID for Apple Touch Bar
2025-03-10 9:10 [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Aditya Garg
` (3 preceding siblings ...)
2025-03-10 9:13 ` [PATCH RESEND 4/5] HID: multitouch: specify that Apple Touch Bar is direct Aditya Garg
@ 2025-03-10 9:14 ` Aditya Garg
2025-03-25 13:13 ` Benjamin Tissoires
2025-03-25 12:52 ` [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Jiri Kosina
5 siblings, 1 reply; 11+ messages in thread
From: Aditya Garg @ 2025-03-10 9:14 UTC (permalink / raw)
To: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, bentiss
Cc: Kerem Karabay, Orlando Chamberlain, Aun-Ali Zaidi,
Linux Kernel Mailing List, linux-input
From: Kerem Karabay <kekrby@gmail.com>
This patch adds the device ID of Apple Touch Bar found on x86 MacBook Pros
to the hid-multitouch driver.
Note that this is device ID is for T2 Macs. Testing on T1 Macs would be
appreciated.
Signed-off-by: Kerem Karabay <kekrby@gmail.com>
Co-developed-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/hid/Kconfig | 1 +
drivers/hid/hid-multitouch.c | 25 +++++++++++++++++++++----
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index dfc245867..727a2ed0d 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -743,6 +743,7 @@ config HID_MULTITOUCH
Say Y here if you have one of the following devices:
- 3M PCT touch screens
- ActionStar dual touch panels
+ - Apple Touch Bar 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 66e33a482..078ceef62 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -221,6 +221,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_CLS_SIS 0x0457
#define MT_DEFAULT_MAXCONTACT 10
@@ -406,6 +407,12 @@ 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_SLOT_IS_CONTACTID_MINUS_ONE |
+ MT_QUIRK_APPLE_TOUCHBAR,
+ .maxcontacts = 11,
+ },
{ .name = MT_CLS_SIS,
.quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
MT_QUIRK_ALWAYS_VALID |
@@ -1807,6 +1814,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");
@@ -1854,10 +1870,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);
@@ -2339,6 +2351,11 @@ static const struct hid_device_id mt_devices[] = {
MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
USB_DEVICE_ID_XIROKU_CSR2) },
+ /* Apple Touch Bar */
+ { .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,
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros
2025-03-10 9:10 [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Aditya Garg
` (4 preceding siblings ...)
2025-03-10 9:14 ` [PATCH RESEND 5/5] HID: multitouch: add device ID for Apple Touch Bar Aditya Garg
@ 2025-03-25 12:52 ` Jiri Kosina
2025-03-25 13:13 ` Benjamin Tissoires
5 siblings, 1 reply; 11+ messages in thread
From: Jiri Kosina @ 2025-03-25 12:52 UTC (permalink / raw)
To: Aditya Garg, Benjamin Tissoires
Cc: bentiss, Kerem Karabay, Orlando Chamberlain, Aun-Ali Zaidi,
Linux Kernel Mailing List, linux-input
On Mon, 10 Mar 2025, Aditya Garg wrote:
> Hi all!
>
> This patch series aims to improve the Touch Bar support for x86 Macs.
>
> Recently, the hid-appletb-kbd and hid-appletb-bl drivers were upstreamed
> into the Linux kernel [1]. They enabled the Touch Bar to display a
> predefined set of media and function keys, exactly the same it does on
> Windows Bootcamp.
>
> Now we are about to get support added for the DRM mode of the Touch Bar
> as well [2].
>
> The DRM mode enables the Touch Bar to act as a second display,
> just like macOS. So now you can add a widget, put a clock or anything
> else on the Touch Bar as long as you can develop a daemon.
>
> Now via these patches, in the DRM mode, we can use the Touch Bar as a
> touch screen. The Touch Bar seems to be not compliant with the HID spec,
> thus via these patches several tweaks have been done under the cover of
> a single quirk, MT_QUIRK_APPLE_TOUCHBAR.
>
> For the case of T2 Macs, apple-bce [3], the driver for the T2 Security
> Chip is also needed for all the peripherals, including the Touch Bar
> to work. It is still WIP, and will be subsequently sent later to the
> appropriate tree. Till then, I'll suggest for get the driver from [3],
> or more preferably, get Linux support from https://t2linux.org/.
Benjamin, could you please Ack this series?
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND 5/5] HID: multitouch: add device ID for Apple Touch Bar
2025-03-10 9:14 ` [PATCH RESEND 5/5] HID: multitouch: add device ID for Apple Touch Bar Aditya Garg
@ 2025-03-25 13:13 ` Benjamin Tissoires
2025-03-25 13:38 ` Aditya Garg
0 siblings, 1 reply; 11+ messages in thread
From: Benjamin Tissoires @ 2025-03-25 13:13 UTC (permalink / raw)
To: Aditya Garg
Cc: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, Kerem Karabay,
Orlando Chamberlain, Aun-Ali Zaidi, Linux Kernel Mailing List,
linux-input
On Mar 10 2025, Aditya Garg wrote:
> From: Kerem Karabay <kekrby@gmail.com>
>
> This patch adds the device ID of Apple Touch Bar found on x86 MacBook Pros
> to the hid-multitouch driver.
>
> Note that this is device ID is for T2 Macs. Testing on T1 Macs would be
> appreciated.
>
> Signed-off-by: Kerem Karabay <kekrby@gmail.com>
> Co-developed-by: Aditya Garg <gargaditya08@live.com>
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> ---
> drivers/hid/Kconfig | 1 +
> drivers/hid/hid-multitouch.c | 25 +++++++++++++++++++++----
> 2 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index dfc245867..727a2ed0d 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -743,6 +743,7 @@ config HID_MULTITOUCH
> Say Y here if you have one of the following devices:
> - 3M PCT touch screens
> - ActionStar dual touch panels
> + - Apple Touch Bar 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 66e33a482..078ceef62 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -221,6 +221,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_CLS_SIS 0x0457
>
> #define MT_DEFAULT_MAXCONTACT 10
> @@ -406,6 +407,12 @@ 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_SLOT_IS_CONTACTID_MINUS_ONE |
> + MT_QUIRK_APPLE_TOUCHBAR,
> + .maxcontacts = 11,
> + },
> { .name = MT_CLS_SIS,
> .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
> MT_QUIRK_ALWAYS_VALID |
> @@ -1807,6 +1814,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;
> +
That hunk and the one below make me very nervous. Is there any reason
preventing you to keep hid_parse() at the same place?
The rest of the series looks fine as everything seems properly guarded
by MT_CLS_APPLE_TOUCHBAR.
Cheers,
Benjamin
> td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL);
> if (!td) {
> dev_err(&hdev->dev, "cannot allocate multitouch data\n");
> @@ -1854,10 +1870,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);
>
> @@ -2339,6 +2351,11 @@ static const struct hid_device_id mt_devices[] = {
> MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
> USB_DEVICE_ID_XIROKU_CSR2) },
>
> + /* Apple Touch Bar */
> + { .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,
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros
2025-03-25 12:52 ` [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Jiri Kosina
@ 2025-03-25 13:13 ` Benjamin Tissoires
0 siblings, 0 replies; 11+ messages in thread
From: Benjamin Tissoires @ 2025-03-25 13:13 UTC (permalink / raw)
To: Jiri Kosina
Cc: Aditya Garg, Benjamin Tissoires, Kerem Karabay,
Orlando Chamberlain, Aun-Ali Zaidi, Linux Kernel Mailing List,
linux-input
On Mar 25 2025, Jiri Kosina wrote:
> On Mon, 10 Mar 2025, Aditya Garg wrote:
>
> > Hi all!
> >
> > This patch series aims to improve the Touch Bar support for x86 Macs.
> >
> > Recently, the hid-appletb-kbd and hid-appletb-bl drivers were upstreamed
> > into the Linux kernel [1]. They enabled the Touch Bar to display a
> > predefined set of media and function keys, exactly the same it does on
> > Windows Bootcamp.
> >
> > Now we are about to get support added for the DRM mode of the Touch Bar
> > as well [2].
> >
> > The DRM mode enables the Touch Bar to act as a second display,
> > just like macOS. So now you can add a widget, put a clock or anything
> > else on the Touch Bar as long as you can develop a daemon.
> >
> > Now via these patches, in the DRM mode, we can use the Touch Bar as a
> > touch screen. The Touch Bar seems to be not compliant with the HID spec,
> > thus via these patches several tweaks have been done under the cover of
> > a single quirk, MT_QUIRK_APPLE_TOUCHBAR.
> >
> > For the case of T2 Macs, apple-bce [3], the driver for the T2 Security
> > Chip is also needed for all the peripherals, including the Touch Bar
> > to work. It is still WIP, and will be subsequently sent later to the
> > appropriate tree. Till then, I'll suggest for get the driver from [3],
> > or more preferably, get Linux support from https://t2linux.org/.
>
> Benjamin, could you please Ack this series?
Nitpick on patch 5.
Patches 1-4 are:
Acked-by: Benjamin Tissoires <bentiss@kernel.org>
Cheers,
Benjamin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND 5/5] HID: multitouch: add device ID for Apple Touch Bar
2025-03-25 13:13 ` Benjamin Tissoires
@ 2025-03-25 13:38 ` Aditya Garg
2025-03-25 16:11 ` Benjamin Tissoires
0 siblings, 1 reply; 11+ messages in thread
From: Aditya Garg @ 2025-03-25 13:38 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, Kerem Karabay,
Orlando Chamberlain, Aun-Ali Zaidi, Linux Kernel Mailing List,
linux-input
> On 25 Mar 2025, at 6:43 PM, Benjamin Tissoires <bentiss@kernel.org> wrote:
>
> On Mar 10 2025, Aditya Garg wrote:
>> From: Kerem Karabay <kekrby@gmail.com>
>>
>> This patch adds the device ID of Apple Touch Bar found on x86 MacBook Pros
>> to the hid-multitouch driver.
>>
>> Note that this is device ID is for T2 Macs. Testing on T1 Macs would be
>> appreciated.
>>
>> Signed-off-by: Kerem Karabay <kekrby@gmail.com>
>> Co-developed-by: Aditya Garg <gargaditya08@live.com>
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> ---
>> drivers/hid/Kconfig | 1 +
>> drivers/hid/hid-multitouch.c | 25 +++++++++++++++++++++----
>> 2 files changed, 22 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
>> index dfc245867..727a2ed0d 100644
>> --- a/drivers/hid/Kconfig
>> +++ b/drivers/hid/Kconfig
>> @@ -743,6 +743,7 @@ config HID_MULTITOUCH
>> Say Y here if you have one of the following devices:
>> - 3M PCT touch screens
>> - ActionStar dual touch panels
>> + - Apple Touch Bar 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 66e33a482..078ceef62 100644
>> --- a/drivers/hid/hid-multitouch.c
>> +++ b/drivers/hid/hid-multitouch.c
>> @@ -221,6 +221,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_CLS_SIS 0x0457
>>
>> #define MT_DEFAULT_MAXCONTACT 10
>> @@ -406,6 +407,12 @@ 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_SLOT_IS_CONTACTID_MINUS_ONE |
>> + MT_QUIRK_APPLE_TOUCHBAR,
>> + .maxcontacts = 11,
>> + },
>> { .name = MT_CLS_SIS,
>> .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
>> MT_QUIRK_ALWAYS_VALID |
>> @@ -1807,6 +1814,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;
>> +
>
> That hunk and the one below make me very nervous. Is there any reason
> preventing you to keep hid_parse() at the same place?
>
Wouldn't we need to parse in order to do hid_find_field? Although I haven't tried putting it at the same place tbh.
> The rest of the series looks fine as everything seems properly guarded
> by MT_CLS_APPLE_TOUCHBAR.
>
> Cheers,
> Benjamin
>
>> td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL);
>> if (!td) {
>> dev_err(&hdev->dev, "cannot allocate multitouch data\n");
>> @@ -1854,10 +1870,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);
>>
>> @@ -2339,6 +2351,11 @@ static const struct hid_device_id mt_devices[] = {
>> MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
>> USB_DEVICE_ID_XIROKU_CSR2) },
>>
>> + /* Apple Touch Bar */
>> + { .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,
>> --
>> 2.43.0
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND 5/5] HID: multitouch: add device ID for Apple Touch Bar
2025-03-25 13:38 ` Aditya Garg
@ 2025-03-25 16:11 ` Benjamin Tissoires
0 siblings, 0 replies; 11+ messages in thread
From: Benjamin Tissoires @ 2025-03-25 16:11 UTC (permalink / raw)
To: Aditya Garg
Cc: Jiri Kosina, Jiri Kosina, Benjamin Tissoires, Kerem Karabay,
Orlando Chamberlain, Aun-Ali Zaidi, Linux Kernel Mailing List,
linux-input
On Mar 25 2025, Aditya Garg wrote:
>
>
> > On 25 Mar 2025, at 6:43 PM, Benjamin Tissoires <bentiss@kernel.org> wrote:
> >
> > On Mar 10 2025, Aditya Garg wrote:
> >> From: Kerem Karabay <kekrby@gmail.com>
> >>
> >> This patch adds the device ID of Apple Touch Bar found on x86 MacBook Pros
> >> to the hid-multitouch driver.
> >>
> >> Note that this is device ID is for T2 Macs. Testing on T1 Macs would be
> >> appreciated.
> >>
> >> Signed-off-by: Kerem Karabay <kekrby@gmail.com>
> >> Co-developed-by: Aditya Garg <gargaditya08@live.com>
> >> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> >> ---
> >> drivers/hid/Kconfig | 1 +
> >> drivers/hid/hid-multitouch.c | 25 +++++++++++++++++++++----
> >> 2 files changed, 22 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> >> index dfc245867..727a2ed0d 100644
> >> --- a/drivers/hid/Kconfig
> >> +++ b/drivers/hid/Kconfig
> >> @@ -743,6 +743,7 @@ config HID_MULTITOUCH
> >> Say Y here if you have one of the following devices:
> >> - 3M PCT touch screens
> >> - ActionStar dual touch panels
> >> + - Apple Touch Bar 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 66e33a482..078ceef62 100644
> >> --- a/drivers/hid/hid-multitouch.c
> >> +++ b/drivers/hid/hid-multitouch.c
> >> @@ -221,6 +221,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_CLS_SIS 0x0457
> >>
> >> #define MT_DEFAULT_MAXCONTACT 10
> >> @@ -406,6 +407,12 @@ 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_SLOT_IS_CONTACTID_MINUS_ONE |
> >> + MT_QUIRK_APPLE_TOUCHBAR,
> >> + .maxcontacts = 11,
> >> + },
> >> { .name = MT_CLS_SIS,
> >> .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
> >> MT_QUIRK_ALWAYS_VALID |
> >> @@ -1807,6 +1814,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;
> >> +
> >
> > That hunk and the one below make me very nervous. Is there any reason
> > preventing you to keep hid_parse() at the same place?
> >
> Wouldn't we need to parse in order to do hid_find_field? Although I haven't tried putting it at the same place tbh.
Yes, you need hid_parse() to be able to call hid_find_field(). But you
can put hid_find_field() after hid_parse() at the original location, no?
Cheers,
Benjamin
>
> > The rest of the series looks fine as everything seems properly guarded
> > by MT_CLS_APPLE_TOUCHBAR.
> >
> > Cheers,
> > Benjamin
> >
> >> td = devm_kzalloc(&hdev->dev, sizeof(struct mt_device), GFP_KERNEL);
> >> if (!td) {
> >> dev_err(&hdev->dev, "cannot allocate multitouch data\n");
> >> @@ -1854,10 +1870,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);
> >>
> >> @@ -2339,6 +2351,11 @@ static const struct hid_device_id mt_devices[] = {
> >> MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
> >> USB_DEVICE_ID_XIROKU_CSR2) },
> >>
> >> + /* Apple Touch Bar */
> >> + { .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,
> >> --
> >> 2.43.0
> >>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-03-25 16:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-10 9:10 [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Aditya Garg
2025-03-10 9:12 ` [PATCH RESEND 1/5] HID: multitouch: Get the contact ID from HID_DG_TRANSDUCER_INDEX fields in case of Apple Touch Bar Aditya Garg
2025-03-10 9:12 ` [PATCH RESEND 2/5] HID: multitouch: support getting the tip state from HID_DG_TOUCH fields in " Aditya Garg
2025-03-10 9:13 ` [PATCH RESEND 3/5] HID: multitouch: take cls->maxcontacts into account for Apple Touch Bar even without a HID_DG_CONTACTMAX field Aditya Garg
2025-03-10 9:13 ` [PATCH RESEND 4/5] HID: multitouch: specify that Apple Touch Bar is direct Aditya Garg
2025-03-10 9:14 ` [PATCH RESEND 5/5] HID: multitouch: add device ID for Apple Touch Bar Aditya Garg
2025-03-25 13:13 ` Benjamin Tissoires
2025-03-25 13:38 ` Aditya Garg
2025-03-25 16:11 ` Benjamin Tissoires
2025-03-25 12:52 ` [PATCH RESEND 0/5] HID: multitouch: Add support for Touch Bars on x86 MacBook Pros Jiri Kosina
2025-03-25 13:13 ` Benjamin Tissoires
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®