From patchwork Sat Apr 20 11:22:00 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: 10910261 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 1C95E17E0 for ; Sat, 20 Apr 2019 11:22:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CB3B28D25 for ; Sat, 20 Apr 2019 11:22:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 003FB28D94; Sat, 20 Apr 2019 11:22:53 +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 9326528D25 for ; Sat, 20 Apr 2019 11:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728107AbfDTLWx (ORCPT ); Sat, 20 Apr 2019 07:22:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46774 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728105AbfDTLWx (ORCPT ); Sat, 20 Apr 2019 07:22:53 -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 C401E307CB52; Sat, 20 Apr 2019 11:22:52 +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 A868519C5A; Sat, 20 Apr 2019 11:22:51 +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 20/37] HID: logitech-dj: pick a better name for non-unifying receivers Date: Sat, 20 Apr 2019 13:22:00 +0200 Message-Id: <20190420112217.27590-21-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.42]); Sat, 20 Apr 2019 11:22:52 +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 hidpp_unifying_get_name() does not work for devices attached to non-unifying receivers. Since we do get a device-type in the device- connection report, we can pick a better name for these devices in hid-logitech-dj.c . Signed-off-by: Hans de Goede --- drivers/hid/hid-logitech-dj.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c index 5f06b80bb404..1488b18266cf 100644 --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c @@ -111,6 +111,9 @@ #define HIDPP_DEVICE_TYPE_MASK GENMASK(3, 0) #define HIDPP_LINK_STATUS_MASK BIT(6) +#define HIDPP_DEVICE_TYPE_KEYBOARD 1 +#define HIDPP_DEVICE_TYPE_MOUSE 2 + #define HIDPP_SET_REGISTER 0x80 #define HIDPP_GET_LONG_REGISTER 0x83 #define HIDPP_REG_CONNECTION_STATE 0x02 @@ -171,6 +174,7 @@ struct dj_device { struct dj_workitem { u8 type; /* WORKITEM_TYPE_* */ u8 device_index; + u8 device_type; u8 quad_id_msb; u8 quad_id_lsb; u32 reports_supported; @@ -632,9 +636,26 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev, dj_hiddev->vendor = djrcv_hdev->vendor; dj_hiddev->product = (workitem->quad_id_msb << 8) | workitem->quad_id_lsb; - snprintf(dj_hiddev->name, sizeof(dj_hiddev->name), - "Logitech Unifying Device. Wireless PID:%04x", - dj_hiddev->product); + if (workitem->device_type) { + const char *type_str = "Device"; + + switch (workitem->device_type) { + case 0x01: type_str = "Keyboard"; break; + case 0x02: type_str = "Mouse"; break; + case 0x03: type_str = "Numpad"; break; + case 0x04: type_str = "Presenter"; break; + case 0x07: type_str = "Remote Control"; break; + case 0x08: type_str = "Trackball"; break; + case 0x09: type_str = "Touchpad"; break; + } + snprintf(dj_hiddev->name, sizeof(dj_hiddev->name), + "Logitech Wireless %s PID:%04x", + type_str, dj_hiddev->product); + } else { + snprintf(dj_hiddev->name, sizeof(dj_hiddev->name), + "Logitech Unifying Device. Wireless PID:%04x", + dj_hiddev->product); + } if (djrcv_dev->type == recvr_type_27mhz) dj_hiddev->group = HID_GROUP_LOGITECH_27MHZ_DEVICE; @@ -809,10 +830,11 @@ static void logi_hidpp_dev_conn_notif_equad(struct hidpp_event *hidpp_report, struct dj_workitem *workitem) { workitem->type = WORKITEM_TYPE_PAIRED; + workitem->device_type = hidpp_report->params[HIDPP_PARAM_DEVICE_INFO] & + HIDPP_DEVICE_TYPE_MASK; workitem->quad_id_msb = hidpp_report->params[HIDPP_PARAM_EQUAD_MSB]; workitem->quad_id_lsb = hidpp_report->params[HIDPP_PARAM_EQUAD_LSB]; - switch (hidpp_report->params[HIDPP_PARAM_DEVICE_INFO] & - HIDPP_DEVICE_TYPE_MASK) { + switch (workitem->device_type) { case REPORT_TYPE_KEYBOARD: workitem->reports_supported |= STD_KEYBOARD | MULTIMEDIA | POWER_KEYS | MEDIA_CENTER; @@ -832,10 +854,12 @@ static void logi_hidpp_dev_conn_notif_27mhz(struct hid_device *hdev, switch (hidpp_report->device_index) { 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; 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; break;