Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4109536rwe; Tue, 30 Aug 2022 04:59:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR54UCTbS0yEml1v9iW7evAUynb1l/IJFhfYE+B6bEAbigBnPmMBU+uZOLrS1p74TFiDfYCJ X-Received: by 2002:a63:804a:0:b0:42b:8b81:72b8 with SMTP id j71-20020a63804a000000b0042b8b8172b8mr14964477pgd.218.1661860794946; Tue, 30 Aug 2022 04:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661860794; cv=none; d=google.com; s=arc-20160816; b=VICEGFS30n9c7MZ3ZQRcSZvVRVY0/vUgH29eMhtz7GzUEeivUnIlxBtxcCYprZAaaw z3X8WSm9o/96ld3f3ZiySYysA5CiGKN2TpuiyAghDsIhdraznFJPGCP0S60Uy1HcNcx3 9UFvEc1R0rOfnkx7cKo2FW71KWb6L7g1pROGPO8KDGTpYGmHS6qS7BjfOkiE79rPCQfF GR5a+jGbgqd5sPJS9XmL9SMX8slnYFDvQGvelWFO5nyVUHGpqZnpiEUy7vKFrQMv2OZ3 uSCU+PBB5krc0S2Nxiae9/g3EZyRUeX7+KVnyH/5gmzIdKrXeSjYE07fEHY2w3ug7exa U7vQ== 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=Me5q82mlE+b+OqY9CLUyy1hNUzvApbM9SytHrQ+cpTFq4Q0VXEISEhiKaANPt7xo8S PF5QDYzTRXGM1Em0Re4TOr6tybwW6HndxNVzmSGZIzpMXt1f935DOFpYoVv4/J7WGjOj sgbwedbiOB3Quqphul8ZY9qsgAh56qfNjjxhWrvC/4gjlCpcxqKTfXlWJOXEvpJ/Ccec LZ15aq3EmxVpxFdFSjaOyLMRa5FCYvGgYpwkIspi0mK6frf2vNBRUL3nCk2MKDbW4kRa 1vFxuwVTcsufB3qHnNilFfKmTduhSMqKjUxF/W+mphYdzyd/ocxsfGpIWHOZb2JoY9G9 lqjA== 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 q5-20020a656245000000b0042b4018450dsi1902011pgv.742.2022.08.30.04.59.43; Tue, 30 Aug 2022 04:59:54 -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 S230286AbiH3Lia (ORCPT + 99 others); Tue, 30 Aug 2022 07:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbiH3Lhs (ORCPT ); Tue, 30 Aug 2022 07:37:48 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF654FCA1D; Tue, 30 Aug 2022 04:36:21 -0700 (PDT) Received: (Authenticated sender: hadess@hadess.net) by mail.gandi.net (Postfix) with ESMTPSA id 2A1F14000A; Tue, 30 Aug 2022 11:36:18 +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: [v2 2/5] HID: logitech-hidpp: Enable HID++ for all the Logitech Bluetooth devices Date: Tue, 30 Aug 2022 13:36:12 +0200 Message-Id: <20220830113615.4414-2-hadess@hadess.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220830113615.4414-1-hadess@hadess.net> References: <20220830113615.4414-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