From patchwork Mon Mar 31 07:36:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 14033193 X-Patchwork-Delegate: jikos@jikos.cz Received: from MA0PR01CU012.outbound.protection.outlook.com (mail-southindiaazolkn19011026.outbound.protection.outlook.com [52.103.67.26]) (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 7701C198A2F; Mon, 31 Mar 2025 07:36:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.103.67.26 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743406615; cv=fail; b=HFZ6Zbbm4LzZgDeRVgYs9PaSmAR+o6jr3/IP25QmokbvyAaMq4AHnkL/KMz5Un2g40k4EhOTG5ysqO6wKZ62hajVoKvb4jkRJdBKbBs2f+r7OCTixavGcru5pJjHJD9Cf436rd0/tCesQIkeQQ+A0UNl0qPmwCHAcKCAhSkIuyk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743406615; c=relaxed/simple; bh=qyHPhdxuTXVmRk6F4TT+jNTVTxBiNq8j+KSo981uBMo=; h=Message-ID:Date:To:Cc:From:Subject:Content-Type:MIME-Version; b=XakEOUcEoYefpO6yoeNpfj99MnHTmdbR2bLVLD9GcdBx1snyQebz2zI6l067EyMNnJh2hikmKN07FE0OXmzjEDFFdxFEb8SUG1JvnjlNYK8z4E9r2t63b0BQmMosN0bidvBbsbhTCVKhWd3KTiar+R+sx78fSauUQQbAvkfEZMM= 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=RFzLZijn; arc=fail smtp.client-ip=52.103.67.26 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="RFzLZijn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W1coPgtVrpDurUhtsES2fjrqcIfCyUOXeANSKziuqrkfWDqetZui4267giMsEHqkyn2fJxaiU54eWQniAzY8VqsJL6n2p1cJxlrXvTHPfUtZEBDD9T8ra78HsKhxk2LFsuBhF62grR6UYpD25DSXe/LIZHgd1Y/lUHGmF9tMIEFeF/pzA+ebK1pwdt5aGUAXGLQNMHNDEFu6YLkgPTmpXK33a5MJshDhu5eYBIl8mueqko1MdcwTEVRxhQMxz4KzFy4LNeWTc7JWiQ9bq1ctBgSFNvsdMJEZBLEIn7wx8urkKolKspbY+k7W/ltOsmhksLAlEFobK5LzaelqC6JR+w== 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=6d5TPBGzPVuv8dhuiBtkCWJeSbJvSiPEpNg9Ibr2w/s=; b=f/x/4OxImMxBUQhYdzWBbDiZI5baKD3PWCvwelD2kUDyxEIkwwY96HeM2yGnnKAretLBwLJYHy2pnvPYH6FcZRAA4HY8q2liR250R9qbxtLdEBmxIF+DvfWRQFd3tgzd5NX5HvNo6yQeMStrfgIHD4KySaVQSHCpyxTezZIiE48OhrjtIbhLo2mNrVBl4xwVebn1azfGueXcrwEtOT6a0nlg5vDJAGcBMBDrEGM1N82RfFB3HIo6//41X7zFTwnaNIxrQXHUuViJRtRhzjXx6opo9QyRUJzg/i8JJtXWb6o5TV1KpjSkIekBTsVSL6HeYn4bLFAddzQBxaoGFYVOSw== 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=6d5TPBGzPVuv8dhuiBtkCWJeSbJvSiPEpNg9Ibr2w/s=; b=RFzLZijnYhU/eMRZd9mQFNaCTe/PIKtLMnWKYIR9YgQydljySwMth2tW6jWQKiVS7gpiktgKYYX6ytCE5zg0lbtczNc1NWNcj3KB6z5g1XLaTsCleLVpDA+T7JqxnHitKRTIpdjC7OV3lXKpftOM69OBkez54GRxKUfN8ZWn2pjRTY39jQFWETWuHN6yC1nHAyQ/gsCVK2aDeqMYWOwGQCN3xKcRYU3pJNiqiQRc4cCTj2Xdk/ObVfqwceNaYfuiaVn7ASYF71P1sLIpqDKoJ66ue/EtwaeKBPHqcMB2lTPyScjgbec/+VIIHNceREA3JKjO3CHU9lzi5UuMEKxJwQ== Received: from PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:f7::14) by PN3PR01MB10322.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:1e2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8583.38; Mon, 31 Mar 2025 07:36:49 +0000 Received: from PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM ([fe80::324:c085:10c8:4e77]) by PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM ([fe80::324:c085:10c8:4e77%7]) with mapi id 15.20.8583.033; Mon, 31 Mar 2025 07:36:49 +0000 Message-ID: Date: Mon, 31 Mar 2025 13:06:47 +0530 User-Agent: Mozilla Thunderbird Content-Language: en-US To: jikos@kernel.org, jkosina@suse.com, bentiss@kernel.org, benjamin.tissoires@redhat.com Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org From: Aditya Garg Subject: [PATCH] HID: magicmouse: Apple Magic Mouse 2 USB-C support X-ClientProxiedBy: PN3PR01CA0144.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:bf::11) To PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:f7::14) X-Microsoft-Original-Message-ID: Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PR01MB9597:EE_|PN3PR01MB10322:EE_ X-MS-Office365-Filtering-Correlation-Id: 387602c3-2b2c-4cc3-a634-08dd7026cc0d X-Microsoft-Antispam: BCL:0;ARA:14566002|15080799006|8060799006|7092599003|6090799003|19110799003|5072599009|461199028|5062599005|440099028|3412199025|41001999003; X-Microsoft-Antispam-Message-Info: =?utf-8?q?B79Xnx4j+XFvDtNn74IiZLq3M3tzrpr?= =?utf-8?q?Uco+NDWAv84zdqyhONVoYUpoBMiExv7kT9q725XErsqnGIUWAmR5a3qSr7ydQ2no8?= =?utf-8?q?afRYM5UIZKAyiwwxV1HvzWp6pybkbynVJ0O1PTJW3ayHGs1P7J6RN5AKWHcCucy0R?= =?utf-8?q?Kj5IeL4wsL8+RusWVJo+SNhj+YdFbX4LXgKuXaNc0IwPsPCp9o8iQKtaWpE0lAlM7?= =?utf-8?q?no4VPw1Hthe1cLhowguTLjD3howCL8OFTFd9ySIpY3Q7cknR0VAisZY8MNpaECPoD?= =?utf-8?q?d4+WW4TBGo3D3Whir1TInwasnhJCqVkdhvCLaPVxqIsoEfPsEJMHgwKdrhCwT+dv3?= =?utf-8?q?FXBkos09xXBTGpCEx4Gr4U6yHaGAEWujBf6glYXG4gh3jenbY6Xx9IRYNZV8toING?= =?utf-8?q?1TgVHe+Y4VT93pACrLu7OSpZjDsJflrOnYnFg6D88PD4uZcBNHK9LE/YQyWwSfOLq?= =?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O0XUWohT3mUAr3D391G7E0tefjBzXBXAcg+2LTx6+RNxbzU2mBxu?= =?utf-8?q?CIBYsEyVwt5Dz1VaUjYTG3rT5+AYmJ2Dgzx8YR/WAYhts6rfhDCB0lJ77YB0jkxag?= =?utf-8?q?W1qm3qEGTMnnPJECEkM3tlDdts+IJGowu4N0RNra8rMGtZGC2Qola/PE53Ot1I8X4?= =?utf-8?q?ztvfdEe6FfKncuO4DGJiX+vtifjBJp1iRZPPxkJh4GBNDkXFsdr7yg7Hk7/FQNUdz?= =?utf-8?q?QxB4oJlaX4ITdCHeASuwLlaQzGaKEjclpEy4LT0AAYNSea1y+Z9R3TXilWkLHjNPD?= =?utf-8?q?Oyd62FJYQntdpcUS?= X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-ae5c4.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 387602c3-2b2c-4cc3-a634-08dd7026cc0d X-MS-Exchange-CrossTenant-AuthSource: PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 07:36:49.3488 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN3PR01MB10322 From: Aditya Garg This patch adds support for USB-C model of Apple Magic Mouse 2. Except for the hardware ID, it should resemble the existing configuration for the older Magic Mouse 2. Signed-off-by: Aditya Garg --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-magicmouse.c | 74 ++++++++++++++++++++++++------------ 2 files changed, 51 insertions(+), 24 deletions(-) y = -((tdata[2] << 24 | tdata[1] << 16) >> 20); @@ -370,7 +371,8 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda if (report_undeciphered) { if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) input_event(input, EV_MSC, MSC_RAW, tdata[7]); else if (input->id.product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 && @@ -497,7 +499,8 @@ static int magicmouse_raw_event(struct hid_device *hdev, } if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) { magicmouse_emit_buttons(msc, clicks & 3); input_report_rel(input, REL_X, x); input_report_rel(input, REL_Y, y); @@ -519,7 +522,8 @@ static int magicmouse_event(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value) { struct magicmouse_sc *msc = hid_get_drvdata(hdev); - if (msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 && + if ((msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) && field->report->id == MOUSE2_REPORT_ID) { /* * magic_mouse_raw_event has done all the work. Skip hidinput. @@ -540,7 +544,8 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd __set_bit(EV_KEY, input->evbit); if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) { __set_bit(BTN_LEFT, input->keybit); __set_bit(BTN_RIGHT, input->keybit); if (emulate_3button) @@ -625,7 +630,8 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd * inverse of the reported Y. */ if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) { input_set_abs_params(input, ABS_MT_ORIENTATION, -31, 32, 1, 0); input_set_abs_params(input, ABS_MT_POSITION_X, MOUSE_MIN_X, MOUSE_MAX_X, 4, 0); @@ -741,19 +747,25 @@ static int magicmouse_enable_multitouch(struct hid_device *hdev) int ret; int feature_size; - if (hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 || - hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) { - if (hdev->vendor == BT_VENDOR_ID_APPLE) { + switch (hdev->product) { + case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2: + case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC: + switch (hdev->vendor) { + case BT_VENDOR_ID_APPLE: feature_size = sizeof(feature_mt_trackpad2_bt); feature = feature_mt_trackpad2_bt; - } else { /* USB_VENDOR_ID_APPLE */ + break; + default: /* USB_VENDOR_ID_APPLE */ feature_size = sizeof(feature_mt_trackpad2_usb); feature = feature_mt_trackpad2_usb; } - } else if (hdev->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + break; + case USB_DEVICE_ID_APPLE_MAGICMOUSE2: + case USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC: feature_size = sizeof(feature_mt_mouse2); feature = feature_mt_mouse2; - } else { + break; + default: feature_size = sizeof(feature_mt); feature = feature_mt; } @@ -787,6 +799,7 @@ 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_MAGICMOUSE2_USBC && hdev->product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 && hdev->product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC)) return -1; @@ -857,6 +870,7 @@ 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_MAGICMOUSE2_USBC || ((id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 || id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) && hdev->type != HID_TYPE_USBMOUSE))) @@ -868,21 +882,27 @@ static int magicmouse_probe(struct hid_device *hdev, goto err_stop_hw; } - if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE) - report = hid_register_report(hdev, HID_INPUT_REPORT, - MOUSE_REPORT_ID, 0); - 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 || - id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) { - if (id->vendor == BT_VENDOR_ID_APPLE) + switch (id->product) { + case USB_DEVICE_ID_APPLE_MAGICMOUSE: + report = hid_register_report(hdev, HID_INPUT_REPORT, MOUSE_REPORT_ID, 0); + break; + case USB_DEVICE_ID_APPLE_MAGICMOUSE2: + case USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC: + report = hid_register_report(hdev, HID_INPUT_REPORT, MOUSE2_REPORT_ID, 0); + break; + case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2: + case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC: + switch (id->vendor) { + case BT_VENDOR_ID_APPLE: report = hid_register_report(hdev, HID_INPUT_REPORT, TRACKPAD2_BT_REPORT_ID, 0); - else /* USB_VENDOR_ID_APPLE */ + break; + default: report = hid_register_report(hdev, HID_INPUT_REPORT, TRACKPAD2_USB_REPORT_ID, 0); - } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */ + } + break; + default: /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */ report = hid_register_report(hdev, HID_INPUT_REPORT, TRACKPAD_REPORT_ID, 0); report = hid_register_report(hdev, HID_INPUT_REPORT, @@ -909,7 +929,8 @@ static int magicmouse_probe(struct hid_device *hdev, hid_err(hdev, "unable to request touch data (%d)\n", ret); goto err_stop_hw; } - if (ret == -EIO && id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + if (ret == -EIO && (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC)) { schedule_delayed_work(&msc->work, msecs_to_jiffies(500)); } @@ -945,6 +966,7 @@ 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_MAGICMOUSE2_USBC || hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 || hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) && *rsize == 83 && rdesc[46] == 0x84 && rdesc[58] == 0x85) { @@ -971,6 +993,10 @@ static const struct hid_device_id magic_mice[] = { USB_DEVICE_ID_APPLE_MAGICMOUSE2), .driver_data = 0 }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE2), .driver_data = 0 }, + { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, + USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC), .driver_data = 0 }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, + USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC), .driver_data = 0 }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD), .driver_data = 0 }, { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 288a2b864..2d3f96af6 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -92,6 +92,7 @@ #define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 #define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d #define USB_DEVICE_ID_APPLE_MAGICMOUSE2 0x0269 +#define USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC 0x0323 #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 0x0265 #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC 0x0324 diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index a76f17158..423d50702 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -218,7 +218,8 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda int pressure = 0; if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) { id = (tdata[6] << 2 | tdata[5] >> 6) & 0xf; x = (tdata[1] << 28 | tdata[0] << 20) >> 20;