From patchwork Sat Apr 20 11:22:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10910265 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A9BB17E0 for ; Sat, 20 Apr 2019 11:22:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 493F228D25 for ; Sat, 20 Apr 2019 11:22:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DCEE28D94; Sat, 20 Apr 2019 11:22:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA3DF28D25 for ; Sat, 20 Apr 2019 11:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728112AbfDTLW4 (ORCPT ); Sat, 20 Apr 2019 07:22:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44630 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728105AbfDTLW4 (ORCPT ); Sat, 20 Apr 2019 07:22:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 803323082B15; Sat, 20 Apr 2019 11:22:55 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C68719C5A; Sat, 20 Apr 2019 11:22:54 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , Nestor Lopez Casado , linux-input@vger.kernel.org Subject: [PATCH v3 22/37] HID: logitech-dj: make appending of the HID++ descriptors conditional Date: Sat, 20 Apr 2019 13:22:02 +0200 Message-Id: <20190420112217.27590-23-hdegoede@redhat.com> In-Reply-To: <20190420112217.27590-1-hdegoede@redhat.com> References: <20190420112217.27590-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 20 Apr 2019 11:22:55 +0000 (UTC) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make the appending of the HID++ descriptors in logi_dj_ll_parse conditional. This is a preparation patch for adding support for the Logitech mini Bluetooth receiver in HID proxy mode (its default mode), where some of the paired devices may not be Logitech devices and thus may not be HID++ capable. This uses a fake bit 63 in reports_supported, which is changed from an u32 to an u64 for this. Bits <= 31 are not usable for this because that would cause a behavioral change in logi_dj_recv_forward_null_report. Signed-off-by: Hans de Goede --- drivers/hid/hid-logitech-dj.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c index e30ed320207b..154cc37ed8fd 100644 --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c @@ -100,6 +100,8 @@ #define POWER_KEYS BIT(4) #define MEDIA_CENTER BIT(8) #define KBD_LEDS BIT(14) +/* Fake (bitnr > NUMBER_OF_HID_REPORTS) bit to track HID++ capability */ +#define HIDPP BIT_ULL(63) /* HID++ Device Connected Notification */ #define REPORT_TYPE_NOTIF_DEVICE_CONNECTED 0x41 @@ -162,7 +164,7 @@ struct dj_receiver_dev { struct dj_device { struct hid_device *hdev; struct dj_receiver_dev *dj_receiver_dev; - u32 reports_supported; + u64 reports_supported; u8 device_index; }; @@ -177,7 +179,7 @@ struct dj_workitem { u8 device_type; u8 quad_id_msb; u8 quad_id_lsb; - u32 reports_supported; + u64 reports_supported; }; /* Keyboard descriptor (1) */ @@ -805,6 +807,7 @@ static void logi_dj_recv_queue_notification(struct dj_receiver_dev *djrcv_dev, workitem.reports_supported = get_unaligned_le32( dj_report->report_params + DEVICE_PAIRED_RF_REPORT_TYPE); + workitem.reports_supported |= HIDPP; if (dj_report->report_type == REPORT_TYPE_NOTIF_DEVICE_UNPAIRED) workitem.type = WORKITEM_TYPE_UNPAIRED; break; @@ -828,10 +831,11 @@ static void logi_hidpp_dev_conn_notif_equad(struct hidpp_event *hidpp_report, switch (workitem->device_type) { case REPORT_TYPE_KEYBOARD: workitem->reports_supported |= STD_KEYBOARD | MULTIMEDIA | - POWER_KEYS | MEDIA_CENTER; + POWER_KEYS | MEDIA_CENTER | + HIDPP; break; case REPORT_TYPE_MOUSE: - workitem->reports_supported |= STD_MOUSE; + workitem->reports_supported |= STD_MOUSE | HIDPP; break; } } @@ -846,13 +850,13 @@ static void logi_hidpp_dev_conn_notif_27mhz(struct hid_device *hdev, case 1: /* Index 1 is always a mouse */ case 2: /* Index 2 is always a mouse */ workitem->device_type = HIDPP_DEVICE_TYPE_MOUSE; - workitem->reports_supported |= STD_MOUSE; + workitem->reports_supported |= STD_MOUSE | HIDPP; break; case 3: /* Index 3 is always the keyboard */ case 4: /* Index 4 is used for an optional separate numpad */ workitem->device_type = HIDPP_DEVICE_TYPE_KEYBOARD; workitem->reports_supported |= STD_KEYBOARD | MULTIMEDIA | - POWER_KEYS; + POWER_KEYS | HIDPP; break; default: hid_warn(hdev, "%s: unexpected device-index %d", __func__, @@ -1249,14 +1253,14 @@ static int logi_dj_ll_parse(struct hid_device *hid) return -ENOMEM; if (djdev->reports_supported & STD_KEYBOARD) { - dbg_hid("%s: sending a kbd descriptor, reports_supported: %x\n", + dbg_hid("%s: sending a kbd descriptor, reports_supported: %llx\n", __func__, djdev->reports_supported); rdcat(rdesc, &rsize, kbd_descriptor, sizeof(kbd_descriptor)); } if (djdev->reports_supported & STD_MOUSE) { - dbg_hid("%s: sending a mouse descriptor, reports_supported: " - "%x\n", __func__, djdev->reports_supported); + dbg_hid("%s: sending a mouse descriptor, reports_supported: %llx\n", + __func__, djdev->reports_supported); if (djdev->dj_receiver_dev->type == recvr_type_gaming_hidpp) rdcat(rdesc, &rsize, mse_high_res_descriptor, sizeof(mse_high_res_descriptor)); @@ -1269,29 +1273,32 @@ static int logi_dj_ll_parse(struct hid_device *hid) } if (djdev->reports_supported & MULTIMEDIA) { - dbg_hid("%s: sending a multimedia report descriptor: %x\n", + dbg_hid("%s: sending a multimedia report descriptor: %llx\n", __func__, djdev->reports_supported); rdcat(rdesc, &rsize, consumer_descriptor, sizeof(consumer_descriptor)); } if (djdev->reports_supported & POWER_KEYS) { - dbg_hid("%s: sending a power keys report descriptor: %x\n", + dbg_hid("%s: sending a power keys report descriptor: %llx\n", __func__, djdev->reports_supported); rdcat(rdesc, &rsize, syscontrol_descriptor, sizeof(syscontrol_descriptor)); } if (djdev->reports_supported & MEDIA_CENTER) { - dbg_hid("%s: sending a media center report descriptor: %x\n", + dbg_hid("%s: sending a media center report descriptor: %llx\n", __func__, djdev->reports_supported); rdcat(rdesc, &rsize, media_descriptor, sizeof(media_descriptor)); } if (djdev->reports_supported & KBD_LEDS) { - dbg_hid("%s: need to send kbd leds report descriptor: %x\n", + dbg_hid("%s: need to send kbd leds report descriptor: %llx\n", __func__, djdev->reports_supported); } - rdcat(rdesc, &rsize, hidpp_descriptor, sizeof(hidpp_descriptor)); + if (djdev->reports_supported & HIDPP) { + rdcat(rdesc, &rsize, hidpp_descriptor, + sizeof(hidpp_descriptor)); + } retval = hid_parse_report(hid, rdesc, rsize); kfree(rdesc);