Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4220201rwe; Tue, 30 Aug 2022 06:41:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR5AIw1z0ySCSWs3HX1VeXAdCnk4nFxSHQIrAzqfzqEuTF0v+1vA3tJSLKcE0BqBfEEnWdHf X-Received: by 2002:a17:907:75d2:b0:741:6a6f:eaaa with SMTP id jl18-20020a17090775d200b007416a6feaaamr8592172ejc.163.1661866879977; Tue, 30 Aug 2022 06:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661866879; cv=none; d=google.com; s=arc-20160816; b=MqoD6pCPgm/8uvQaYwCpUy2FZhv9E/TZLsg8RVqwtb7atSiix9CBOZ68LvcGLg7aOk JHrhaL1p0HJuGVMFEoVF1UMVPABEzDcDJxGMJWnMbTVCVJXE6AjkKl/nlcTyQT2SavwX 2GxQZ//ROoIs2pEV/zjvMCFgqlPDiE7rl1Q+XVU7EhseYQkqo/Do38Yowbr00JchQHWq L8/GwZVGbiFHc9u3c82LQskL9NJKBZtaKt2e1mOr6Dvd1Kg/ja6h4+pKZ5yn/DGLcp4g 91e1MfFFiXRh/HnaKaZ877lAHA/y3GMw3aHxH2X744zbe7BEwvxX8n/pUBFR48T/5gx4 FMdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fa8NYtBuI++vlrGsJ+lFwNKTQMI3heFLTPEgbNSes+A=; b=UHtG6MFfk4CJFgPOhb7PwmdfwPK60kKdb39ESOOWcUunsObRv5PGiDM6Qr6iaA0lKU rhLX1X2bROULI2X2maOe7Uwd8cufApw9Kir/5VqBP5q0qTJ/ZkIHk7XOJbhqnUdMxOBI fo3yFZJOkTvPHaP2ldunFCDlhiwIu0/Sl+B8S4sqFWZCDlYY5eaPaPJZFH/M6VfL58zF loGtGL80efnZwvHqHrmwKXpr8DCXolc2CtTanmbvbdYgGwvsZnef8iFyIFl06s35+4YR 6HaHuTdWvEWAPaOtOy0IJ/OnL1CLaOgVep/WDGSAy1+ChLFAtNuWcxiCK0CT3KHHh9Tj UcpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a50eb06000000b00447d5ed04afsi8026256edp.446.2022.08.30.06.40.54; Tue, 30 Aug 2022 06:41:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230187AbiH3N0F (ORCPT + 99 others); Tue, 30 Aug 2022 09:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbiH3NZ4 (ORCPT ); Tue, 30 Aug 2022 09:25:56 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12DAB6B175; Tue, 30 Aug 2022 06:25:54 -0700 (PDT) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id 0251B2000E; Tue, 30 Aug 2022 13:25:51 +0000 (UTC) From: Bastien Nocera To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , "Peter F . Patel-Schneider" , =?UTF-8?q?Filipe=20La=C3=ADns?= , Nestor Lopez Casado Subject: [v4 2/5] HID: logitech-hidpp: Enable HID++ for all the Logitech Bluetooth devices Date: Tue, 30 Aug 2022 15:25:46 +0200 Message-Id: <20220830132549.7240-2-hadess@hadess.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220830132549.7240-1-hadess@hadess.net> References: <20220830132549.7240-1-hadess@hadess.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Probe for HID++ support over Bluetooth for all the Logitech Bluetooth devices. As Logitech doesn't have a list of Bluetooth devices that support HID++ over Bluetooth, probe every device. The HID++ driver will fall back to plain HID if the device does not support HID++, or to a another device-specific driver if it is part of the unhandled_hidpp_devices array, used in the match function. Note that this change might cause upower to export 2 batteries for certain Bluetooth LE devices which export their battery information through the Bluetooth BATT profile. This particular bug is tracked at: https://gitlab.freedesktop.org/upower/upower/-/issues/166 Tested with a Logitech Signature M650 mouse, over Bluetooth Signed-off-by: Bastien Nocera --- drivers/hid/hid-logitech-hidpp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 68f9e9d207f4..641c897bf714 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -4219,6 +4219,21 @@ static void hidpp_remove(struct hid_device *hdev) mutex_destroy(&hidpp->send_mutex); } +static const struct hid_device_id unhandled_hidpp_devices[] = { + /* Logitech Harmony Adapter for PS3, handled in hid-sony */ + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) }, + /* Handled in hid-generic */ + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD) }, + {} +}; + +static bool hidpp_match(struct hid_device *hdev, + bool ignore_special_driver) +{ + /* Refuse to handle devices handled by other HID drivers */ + return !hid_match_id(hdev, unhandled_hidpp_devices); +} + #define LDJ_DEVICE(product) \ HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, \ USB_VENDOR_ID_LOGITECH, (product)) @@ -4347,6 +4362,9 @@ static const struct hid_device_id hidpp_devices[] = { { /* MX Master 3 mouse over Bluetooth */ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb023), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + + { /* And try to enable HID++ for all the Logitech Bluetooth devices */ + HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_ANY, USB_VENDOR_ID_LOGITECH, HID_ANY_ID) }, {} }; @@ -4360,6 +4378,7 @@ static const struct hid_usage_id hidpp_usages[] = { static struct hid_driver hidpp_driver = { .name = "logitech-hidpp-device", .id_table = hidpp_devices, + .match = hidpp_match, .report_fixup = hidpp_report_fixup, .probe = hidpp_probe, .remove = hidpp_remove, -- 2.37.2