[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZzDHrOr43KO+CtuL@visitorckw-System-Product-Name>
Date: Sun, 10 Nov 2024 22:48:12 +0800
From: Kuan-Wei Chiu <visitorckw@...il.com>
To: Callahan Kovacs <callahankovacs@...il.com>
Cc: jikos@...nel.org, bentiss@...nel.org, linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org, jose.exposito89@...il.com
Subject: Re: [PATCH] HID: magicmouse: Apple Magic Trackpad 2 USB-C driver
support
Hi Callahan,
On Sat, Nov 09, 2024 at 06:25:56PM -0600, Callahan Kovacs wrote:
> Adds driver support for the USB-C model of Apple's Magic Trackpad 2.
>
> The 2024 USB-C model is compatible with the existing Magic Trackpad 2
> driver but has a different hardware ID.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=219470
Thanks for your patch. However, all kernel patches require the author
to add a Signed-off-by tag at the end of the commit message. Could you
please resend the patch with this correction?
See: https://www.kernel.org/doc/html/v6.11/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin
Regards,
Kuan-Wei
> ---
> drivers/hid/hid-ids.h | 1 +
> drivers/hid/hid-magicmouse.c | 56 ++++++++++++++++++++++++++----------
> 2 files changed, 42 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> index 92cff3f2658c..0f23be98c56e 100644
> --- a/drivers/hid/hid-ids.h
> +++ b/drivers/hid/hid-ids.h
> @@ -94,6 +94,7 @@
> #define USB_DEVICE_ID_APPLE_MAGICMOUSE2 0x0269
> #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e
> #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 0x0265
> +#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC 0x0324
> #define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e
> #define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f
> #define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
> diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
> index 8a73b59e0827..ec110dea8772 100644
> --- a/drivers/hid/hid-magicmouse.c
> +++ b/drivers/hid/hid-magicmouse.c
> @@ -227,7 +227,9 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
> touch_minor = tdata[4];
> state = tdata[7] & TOUCH_STATE_MASK;
> down = state != TOUCH_STATE_NONE;
> - } else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) {
> + } else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + input->id.product ==
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) {
> id = tdata[8] & 0xf;
> x = (tdata[1] << 27 | tdata[0] << 19) >> 19;
> y = -((tdata[3] << 30 | tdata[2] << 22 | tdata[1] << 14) >> 19);
> @@ -259,8 +261,9 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
> /* If requested, emulate a scroll wheel by detecting small
> * vertical touch motions.
> */
> - if (emulate_scroll_wheel && (input->id.product !=
> - USB_DEVICE_ID_APPLE_MAGICTRACKPAD2)) {
> + if (emulate_scroll_wheel &&
> + input->id.product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
> + input->id.product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) {
> unsigned long now = jiffies;
> int step_x = msc->touches[id].scroll_x - x;
> int step_y = msc->touches[id].scroll_y - y;
> @@ -359,7 +362,9 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
> input_report_abs(input, ABS_MT_POSITION_X, x);
> input_report_abs(input, ABS_MT_POSITION_Y, y);
>
> - if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2)
> + if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + input->id.product ==
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC)
> input_report_abs(input, ABS_MT_PRESSURE, pressure);
>
> if (report_undeciphered) {
> @@ -367,7 +372,9 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
> input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2)
> input_event(input, EV_MSC, MSC_RAW, tdata[7]);
> else if (input->id.product !=
> - USB_DEVICE_ID_APPLE_MAGICTRACKPAD2)
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
> + input->id.product !=
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC)
> input_event(input, EV_MSC, MSC_RAW, tdata[8]);
> }
> }
> @@ -493,7 +500,9 @@ static int magicmouse_raw_event(struct hid_device *hdev,
> magicmouse_emit_buttons(msc, clicks & 3);
> input_report_rel(input, REL_X, x);
> input_report_rel(input, REL_Y, y);
> - } else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) {
> + } else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + input->id.product ==
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) {
> input_mt_sync_frame(input);
> input_report_key(input, BTN_MOUSE, clicks & 1);
> } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
> @@ -545,7 +554,9 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
> __set_bit(REL_WHEEL_HI_RES, input->relbit);
> __set_bit(REL_HWHEEL_HI_RES, input->relbit);
> }
> - } else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) {
> + } else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + input->id.product ==
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) {
> /* If the trackpad has been connected to a Mac, the name is
> * automatically personalized, e.g., "José Expósito's Trackpad".
> * When connected through Bluetooth, the personalized name is
> @@ -621,7 +632,9 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
> MOUSE_RES_X);
> input_abs_set_res(input, ABS_MT_POSITION_Y,
> MOUSE_RES_Y);
> - } else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) {
> + } else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + input->id.product ==
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) {
> input_set_abs_params(input, ABS_MT_PRESSURE, 0, 253, 0, 0);
> input_set_abs_params(input, ABS_PRESSURE, 0, 253, 0, 0);
> input_set_abs_params(input, ABS_MT_ORIENTATION, -3, 4, 0, 0);
> @@ -660,7 +673,8 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
> input_set_events_per_packet(input, 60);
>
> if (report_undeciphered &&
> - input->id.product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) {
> + input->id.product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
> + input->id.product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) {
> __set_bit(EV_MSC, input->evbit);
> __set_bit(MSC_RAW, input->mscbit);
> }
> @@ -685,7 +699,9 @@ static int magicmouse_input_mapping(struct hid_device *hdev,
>
> /* Magic Trackpad does not give relative data after switching to MT */
> if ((hi->input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD ||
> - hi->input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) &&
> + hi->input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + hi->input->id.product ==
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) &&
> field->flags & HID_MAIN_ITEM_RELATIVE)
> return -1;
>
> @@ -721,7 +737,8 @@ static int magicmouse_enable_multitouch(struct hid_device *hdev)
> int ret;
> int feature_size;
>
> - if (hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) {
> + if (hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) {
> if (hdev->vendor == BT_VENDOR_ID_APPLE) {
> feature_size = sizeof(feature_mt_trackpad2_bt);
> feature = feature_mt_trackpad2_bt;
> @@ -766,7 +783,8 @@ static int magicmouse_fetch_battery(struct hid_device *hdev)
>
> if (!hdev->battery || hdev->vendor != USB_VENDOR_ID_APPLE ||
> (hdev->product != USB_DEVICE_ID_APPLE_MAGICMOUSE2 &&
> - hdev->product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2))
> + hdev->product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
> + hdev->product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC))
> return -1;
>
> report_enum = &hdev->report_enum[hdev->battery_report_type];
> @@ -835,7 +853,9 @@ static int magicmouse_probe(struct hid_device *hdev,
>
> if (id->vendor == USB_VENDOR_ID_APPLE &&
> (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
> - (id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 && hdev->type != HID_TYPE_USBMOUSE)))
> + ((id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) &&
> + hdev->type != HID_TYPE_USBMOUSE)))
> return 0;
>
> if (!msc->input) {
> @@ -850,7 +870,8 @@ static int magicmouse_probe(struct hid_device *hdev,
> else if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2)
> report = hid_register_report(hdev, HID_INPUT_REPORT,
> MOUSE2_REPORT_ID, 0);
> - else if (id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) {
> + else if (id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) {
> if (id->vendor == BT_VENDOR_ID_APPLE)
> report = hid_register_report(hdev, HID_INPUT_REPORT,
> TRACKPAD2_BT_REPORT_ID, 0);
> @@ -920,7 +941,8 @@ static const __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
> */
> if (hdev->vendor == USB_VENDOR_ID_APPLE &&
> (hdev->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
> - hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) &&
> + hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
> + hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) &&
> *rsize == 83 && rdesc[46] == 0x84 && rdesc[58] == 0x85) {
> hid_info(hdev,
> "fixing up magicmouse battery report descriptor\n");
> @@ -951,6 +973,10 @@ static const struct hid_device_id magic_mice[] = {
> USB_DEVICE_ID_APPLE_MAGICTRACKPAD2), .driver_data = 0 },
> { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
> USB_DEVICE_ID_APPLE_MAGICTRACKPAD2), .driver_data = 0 },
> + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE,
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC), .driver_data = 0 },
> + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
> + USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC), .driver_data = 0 },
> { }
> };
> MODULE_DEVICE_TABLE(hid, magic_mice);
> --
> 2.45.2
>
>
Powered by blists - more mailing lists