From patchwork Fri Apr 16 13:13:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 422935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80F1DC433ED for ; Fri, 16 Apr 2021 13:13:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B93A611BF for ; Fri, 16 Apr 2021 13:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235631AbhDPNN7 (ORCPT ); Fri, 16 Apr 2021 09:13:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58209 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235252AbhDPNN7 (ORCPT ); Fri, 16 Apr 2021 09:13:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618578814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k/EGcJH1KjzRFMCyD+pA4YdYmrTeRipoXkRuJQYvFZM=; b=Bs5kM+QArt3y3OEfZUxbZw8tup8cNT6D9vwswziFK1Hht0Fv6s2ManV1ZVzhrsOFBjiUJH sSngK5uhgosghkQZdhGhsJjlfE+Rm8MkP5xlfOxraKDCrsja9PJsV0IXeRT3PFwWoeBxot rpXkZH4sxJ/ENkfytjXhyWbb+gNw9fQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-494-buoBHjTtPBGHZzVnjfF3gw-1; Fri, 16 Apr 2021 09:13:32 -0400 X-MC-Unique: buoBHjTtPBGHZzVnjfF3gw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E23C102CB77; Fri, 16 Apr 2021 13:13:30 +0000 (UTC) Received: from x1.localdomain (ovpn-113-102.ams2.redhat.com [10.36.113.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D0865C3F8; Fri, 16 Apr 2021 13:13:29 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , Peter Hoeg , linux-input@vger.kernel.org Subject: [PATCH 1/6] HID: lg-g15: Remove unused size argument from lg_*_event() functions Date: Fri, 16 Apr 2021 15:13:18 +0200 Message-Id: <20210416131323.233184-2-hdegoede@redhat.com> In-Reply-To: <20210416131323.233184-1-hdegoede@redhat.com> References: <20210416131323.233184-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The report-size is already checked in lg_g15_raw_event() before calling the lg_*_event() functions and these functions don't use the passed in size at all, drop the unused parameter. Signed-off-by: Hans de Goede --- drivers/hid/hid-lg-g15.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-lg-g15.c b/drivers/hid/hid-lg-g15.c index bfbba0d41933..b887af72957c 100644 --- a/drivers/hid/hid-lg-g15.c +++ b/drivers/hid/hid-lg-g15.c @@ -464,7 +464,7 @@ static int lg_g15_get_initial_led_brightness(struct lg_g15_data *g15) /******** Input functions ********/ /* On the G15 Mark I Logitech has been quite creative with which bit is what */ -static int lg_g15_event(struct lg_g15_data *g15, u8 *data, int size) +static int lg_g15_event(struct lg_g15_data *g15, u8 *data) { int i, val; @@ -510,7 +510,7 @@ static int lg_g15_event(struct lg_g15_data *g15, u8 *data, int size) return 0; } -static int lg_g15_v2_event(struct lg_g15_data *g15, u8 *data, int size) +static int lg_g15_v2_event(struct lg_g15_data *g15, u8 *data) { int i, val; @@ -542,7 +542,7 @@ static int lg_g15_v2_event(struct lg_g15_data *g15, u8 *data, int size) return 0; } -static int lg_g510_event(struct lg_g15_data *g15, u8 *data, int size) +static int lg_g510_event(struct lg_g15_data *g15, u8 *data) { bool game_mode_enabled; int i, val; @@ -586,7 +586,7 @@ static int lg_g510_event(struct lg_g15_data *g15, u8 *data, int size) return 0; } -static int lg_g510_leds_event(struct lg_g15_data *g15, u8 *data, int size) +static int lg_g510_leds_event(struct lg_g15_data *g15, u8 *data) { bool backlight_disabled; @@ -613,18 +613,18 @@ static int lg_g15_raw_event(struct hid_device *hdev, struct hid_report *report, switch (g15->model) { case LG_G15: if (data[0] == 0x02 && size == 9) - return lg_g15_event(g15, data, size); + return lg_g15_event(g15, data); break; case LG_G15_V2: if (data[0] == 0x02 && size == 5) - return lg_g15_v2_event(g15, data, size); + return lg_g15_v2_event(g15, data); break; case LG_G510: case LG_G510_USB_AUDIO: if (data[0] == 0x03 && size == 5) - return lg_g510_event(g15, data, size); + return lg_g510_event(g15, data); if (data[0] == 0x04 && size == 2) - return lg_g510_leds_event(g15, data, size); + return lg_g510_leds_event(g15, data); break; } From patchwork Fri Apr 16 13:13:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 422934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52B19C43460 for ; Fri, 16 Apr 2021 13:13:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 337546121E for ; Fri, 16 Apr 2021 13:13:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235575AbhDPNOA (ORCPT ); Fri, 16 Apr 2021 09:14:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26514 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235252AbhDPNN7 (ORCPT ); Fri, 16 Apr 2021 09:13:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618578814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uPniQ55/p3S2h23mtw/MqnwWJYYEEkCWf3qP1ZgqZ3E=; b=f93NZsiFYsR2ee263oJbRoINZAb9RdDbgg6gSlfUUwu7cnfC+51uio2OxuPdf8allzf8YU 8Kn0rnTe9lqQz68M3d10AqcJdy8fBtZMhlN+JnuegFgaNQGRCKBDQ9uK1KqwE/mL0DN8VQ +cjltFB2a4VDFE3IWO1gBl93Y6WkAak= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-314-pC4PdPj6MvyTT91c0gWhug-1; Fri, 16 Apr 2021 09:13:32 -0400 X-MC-Unique: pC4PdPj6MvyTT91c0gWhug-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06C9081425A; Fri, 16 Apr 2021 13:13:32 +0000 (UTC) Received: from x1.localdomain (ovpn-113-102.ams2.redhat.com [10.36.113.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAEB55C266; Fri, 16 Apr 2021 13:13:30 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , Peter Hoeg , linux-input@vger.kernel.org Subject: [PATCH 2/6] HID: lg-g15: Add a lg_g15_handle_lcd_menu_keys() helper function Date: Fri, 16 Apr 2021 15:13:19 +0200 Message-Id: <20210416131323.233184-3-hdegoede@redhat.com> In-Reply-To: <20210416131323.233184-1-hdegoede@redhat.com> References: <20210416131323.233184-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Factor out the handling of the G15 LCD menu keys out of lg_g15_event() into a new lg_g15_handle_lcd_menu_keys() helper function. This is a preparation patch for adding support for the LCD menu keys on the Logitech Z-10 speakers (with LCD) which use the same funky HID report format. Signed-off-by: Hans de Goede --- drivers/hid/hid-lg-g15.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-lg-g15.c b/drivers/hid/hid-lg-g15.c index b887af72957c..75a27b48d9c9 100644 --- a/drivers/hid/hid-lg-g15.c +++ b/drivers/hid/hid-lg-g15.c @@ -464,6 +464,19 @@ static int lg_g15_get_initial_led_brightness(struct lg_g15_data *g15) /******** Input functions ********/ /* On the G15 Mark I Logitech has been quite creative with which bit is what */ +static void lg_g15_handle_lcd_menu_keys(struct lg_g15_data *g15, u8 *data) +{ + int i, val; + + /* Most left (round/display) button below the LCD */ + input_report_key(g15->input, KEY_KBD_LCD_MENU1, data[8] & 0x80); + /* 4 other buttons below the LCD */ + for (i = 0; i < 4; i++) { + val = data[i + 2] & 0x80; + input_report_key(g15->input, KEY_KBD_LCD_MENU2 + i, val); + } +} + static int lg_g15_event(struct lg_g15_data *g15, u8 *data) { int i, val; @@ -494,13 +507,7 @@ static int lg_g15_event(struct lg_g15_data *g15, u8 *data) /* MR */ input_report_key(g15->input, KEY_MACRO_RECORD_START, data[7] & 0x40); - /* Most left (round) button below the LCD */ - input_report_key(g15->input, KEY_KBD_LCD_MENU1, data[8] & 0x80); - /* 4 other buttons below the LCD */ - for (i = 0; i < 4; i++) { - val = data[i + 2] & 0x80; - input_report_key(g15->input, KEY_KBD_LCD_MENU2 + i, val); - } + lg_g15_handle_lcd_menu_keys(g15, data); /* Backlight cycle button pressed? */ if (data[1] & 0x80) From patchwork Fri Apr 16 13:13:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 423609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8D08C433ED for ; Fri, 16 Apr 2021 13:13:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90892611AC for ; Fri, 16 Apr 2021 13:13:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243396AbhDPNOD (ORCPT ); Fri, 16 Apr 2021 09:14:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28364 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235252AbhDPNOC (ORCPT ); Fri, 16 Apr 2021 09:14:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618578817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jb8oIHg0iOx0tAJaAZIEhtCOW5fT/J+mpZA59jYafeg=; b=JJseE6BD/pkhZeOKuzo3pY3e/iFqq0sFLOLo5To29YP82B+nYZ5x+x3heh9UyMeQpmLq0O cb4MxQZJxlHD/AXeSfoz1b5cyV0WGjb6P9/SQjSbTT2xF+l0QhzQl3hzxeGcCkOymgXYz7 qJrYOhORRWjM212sHM9n4SaD+m8x0sY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-581-M0HI8CrbPue5HUuaD1C-JQ-1; Fri, 16 Apr 2021 09:13:34 -0400 X-MC-Unique: M0HI8CrbPue5HUuaD1C-JQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5EC52107ACCA; Fri, 16 Apr 2021 13:13:33 +0000 (UTC) Received: from x1.localdomain (ovpn-113-102.ams2.redhat.com [10.36.113.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A8E15C257; Fri, 16 Apr 2021 13:13:32 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , Peter Hoeg , linux-input@vger.kernel.org Subject: [PATCH 3/6] HID: lg-g15: Add a lg_g15_init_input_dev() helper function Date: Fri, 16 Apr 2021 15:13:20 +0200 Message-Id: <20210416131323.233184-4-hdegoede@redhat.com> In-Reply-To: <20210416131323.233184-1-hdegoede@redhat.com> References: <20210416131323.233184-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Factor the input-device setup + KEY_KBD_LCD_MENU capability setting out of lg_g15_probe() into a new lg_g15_init_input_dev() helper function. This is a preparation patch for adding support for the LCD menu keys + LCD brightness control on the Logitech Z-10 speakers (with LCD) which use the same protocol as the G15 keyboards. Signed-off-by: Hans de Goede --- drivers/hid/hid-lg-g15.c | 42 ++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/hid/hid-lg-g15.c b/drivers/hid/hid-lg-g15.c index 75a27b48d9c9..eff8c51a8dce 100644 --- a/drivers/hid/hid-lg-g15.c +++ b/drivers/hid/hid-lg-g15.c @@ -709,6 +709,28 @@ static int lg_g15_register_led(struct lg_g15_data *g15, int i) return devm_led_classdev_register(&g15->hdev->dev, &g15->leds[i].cdev); } +/* Common input device init code shared between keyboards and Z-10 speaker handling */ +static void lg_g15_init_input_dev(struct hid_device *hdev, struct input_dev *input, + const char *name) +{ + int i; + + input->name = name; + input->phys = hdev->phys; + input->uniq = hdev->uniq; + input->id.bustype = hdev->bus; + input->id.vendor = hdev->vendor; + input->id.product = hdev->product; + input->id.version = hdev->version; + input->dev.parent = &hdev->dev; + input->open = lg_g15_input_open; + input->close = lg_g15_input_close; + + /* Keys below the LCD, intended for controlling a menu on the LCD */ + for (i = 0; i < 5; i++) + input_set_capability(input, EV_KEY, KEY_KBD_LCD_MENU1 + i); +} + static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) { u8 gkeys_settings_output_report = 0; @@ -751,6 +773,8 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) g15->hdev = hdev; g15->model = id->driver_data; + g15->input = input; + input_set_drvdata(input, hdev); hid_set_drvdata(hdev, (void *)g15); switch (g15->model) { @@ -822,16 +846,7 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) goto error_hw_stop; /* Setup and register input device */ - input->name = "Logitech Gaming Keyboard Gaming Keys"; - input->phys = hdev->phys; - input->uniq = hdev->uniq; - input->id.bustype = hdev->bus; - input->id.vendor = hdev->vendor; - input->id.product = hdev->product; - input->id.version = hdev->version; - input->dev.parent = &hdev->dev; - input->open = lg_g15_input_open; - input->close = lg_g15_input_close; + lg_g15_init_input_dev(hdev, input, "Logitech Gaming Keyboard Gaming Keys"); /* G-keys */ for (i = 0; i < gkeys; i++) @@ -842,10 +857,6 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) input_set_capability(input, EV_KEY, KEY_MACRO_PRESET1 + i); input_set_capability(input, EV_KEY, KEY_MACRO_RECORD_START); - /* Keys below the LCD, intended for controlling a menu on the LCD */ - for (i = 0; i < 5; i++) - input_set_capability(input, EV_KEY, KEY_KBD_LCD_MENU1 + i); - /* * On the G510 only report headphone and mic mute keys when *not* using * the builtin USB audio device. When the builtin audio is used these @@ -857,9 +868,6 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) input_set_capability(input, EV_KEY, KEY_F20); } - g15->input = input; - input_set_drvdata(input, hdev); - ret = input_register_device(input); if (ret) goto error_hw_stop; From patchwork Fri Apr 16 13:13:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 422933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14625C433B4 for ; Fri, 16 Apr 2021 13:13:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD44761153 for ; Fri, 16 Apr 2021 13:13:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235252AbhDPNOD (ORCPT ); Fri, 16 Apr 2021 09:14:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35606 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240600AbhDPNOD (ORCPT ); Fri, 16 Apr 2021 09:14:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618578818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yQ4Hhxf1k99HBMnRXN2PzEc7pNk8TxZV85xgcJZ/lvg=; b=I1eRMOubFf2J+MuG5AKzZmdjyIbcHXcCUxE5HD3wnxt/QAIPUvOhgdqkRiUjom4pNYjptA RUZ19hq5rfB8oaoaa8fjjQQiiCFG8mGIsaSZTb/oSPx7sFux+le2z46MKH1JQD9jJEyGVo tkEIK9ga9YjMHsg9S8T9ydy9pK2s4DY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-580-oPY4KSuoO7Wwol1TvFhysA-1; Fri, 16 Apr 2021 09:13:36 -0400 X-MC-Unique: oPY4KSuoO7Wwol1TvFhysA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B79C21B2C983; Fri, 16 Apr 2021 13:13:34 +0000 (UTC) Received: from x1.localdomain (ovpn-113-102.ams2.redhat.com [10.36.113.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5F305C257; Fri, 16 Apr 2021 13:13:33 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , Peter Hoeg , linux-input@vger.kernel.org Subject: [PATCH 4/6] HID: lg-g15: Make the LED-name used by lg_g15_register_led() a parameter Date: Fri, 16 Apr 2021 15:13:21 +0200 Message-Id: <20210416131323.233184-5-hdegoede@redhat.com> In-Reply-To: <20210416131323.233184-1-hdegoede@redhat.com> References: <20210416131323.233184-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Make the LED-name used by lg_g15_register_led() a parameter. This is a preparation patch for adding support for the LCD menu keys + LCD brightness control on the Logitech Z-10 speakers (with LCD) which use the same protocol as the G15 keyboards. Signed-off-by: Hans de Goede --- drivers/hid/hid-lg-g15.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/hid/hid-lg-g15.c b/drivers/hid/hid-lg-g15.c index eff8c51a8dce..b76988c19f84 100644 --- a/drivers/hid/hid-lg-g15.c +++ b/drivers/hid/hid-lg-g15.c @@ -652,19 +652,10 @@ static void lg_g15_input_close(struct input_dev *dev) hid_hw_close(hdev); } -static int lg_g15_register_led(struct lg_g15_data *g15, int i) +static int lg_g15_register_led(struct lg_g15_data *g15, int i, const char *name) { - static const char * const led_names[] = { - "g15::kbd_backlight", - "g15::lcd_backlight", - "g15::macro_preset1", - "g15::macro_preset2", - "g15::macro_preset3", - "g15::macro_record", - }; - g15->leds[i].led = i; - g15->leds[i].cdev.name = led_names[i]; + g15->leds[i].cdev.name = name; switch (g15->model) { case LG_G15: @@ -733,6 +724,14 @@ static void lg_g15_init_input_dev(struct hid_device *hdev, struct input_dev *inp static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) { + static const char * const led_names[] = { + "g15::kbd_backlight", + "g15::lcd_backlight", + "g15::macro_preset1", + "g15::macro_preset2", + "g15::macro_preset3", + "g15::macro_record", + }; u8 gkeys_settings_output_report = 0; u8 gkeys_settings_feature_report = 0; struct hid_report_enum *rep_enum; @@ -874,7 +873,7 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) /* Register LED devices */ for (i = 0; i < LG_G15_LED_MAX; i++) { - ret = lg_g15_register_led(g15, i); + ret = lg_g15_register_led(g15, i, led_names[i]); if (ret) goto error_hw_stop; } From patchwork Fri Apr 16 13:13:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 423608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F272AC43461 for ; Fri, 16 Apr 2021 13:13:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEC57611ED for ; Fri, 16 Apr 2021 13:13:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243509AbhDPNOE (ORCPT ); Fri, 16 Apr 2021 09:14:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28854 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240600AbhDPNOE (ORCPT ); Fri, 16 Apr 2021 09:14:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618578819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=doZCo40olfiy9h3AlVaue7bjTd7SfvhJo1kUvyxuRFc=; b=hWuRsF2x2Efn89I5mEMUKNpPQnE0aoDGQFZTjLOhaP2I0odNRYAe2VQAAUkbwFzZtw5kfM pyy8UgP0aV1bm3H5p4N6cBibldI7sTlNLnqeSBqSb4N+GaT8ldKRizIPOeNVuifmIlkmZ+ /AYpw5ePhIuGljkRnlrBr6XheeCeBnI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-yDRdTJJqN6u5nBBbB3iE3g-1; Fri, 16 Apr 2021 09:13:37 -0400 X-MC-Unique: yDRdTJJqN6u5nBBbB3iE3g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4196F10054F6; Fri, 16 Apr 2021 13:13:36 +0000 (UTC) Received: from x1.localdomain (ovpn-113-102.ams2.redhat.com [10.36.113.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07E145C257; Fri, 16 Apr 2021 13:13:34 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , Peter Hoeg , linux-input@vger.kernel.org Subject: [PATCH 5/6] HID: lg-g15: Add support for the Logitech Z-10 speakers Date: Fri, 16 Apr 2021 15:13:22 +0200 Message-Id: <20210416131323.233184-6-hdegoede@redhat.com> In-Reply-To: <20210416131323.233184-1-hdegoede@redhat.com> References: <20210416131323.233184-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add support to hid-lg-g15 for the Logitech Z-10 speakers. This adds support for the LCD menu keys found on these speakers, as well as support for controlling the LCD's brightness through a LED classdev. Signed-off-by: Hans de Goede --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-lg-g15.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index df78b1a11fb5..5a3d2e5a3b3a 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -759,6 +759,7 @@ #define I2C_DEVICE_ID_LG_7010 0x7010 #define USB_VENDOR_ID_LOGITECH 0x046d +#define USB_DEVICE_ID_LOGITECH_Z_10_SPK 0x0a07 #define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e #define USB_DEVICE_ID_LOGITECH_T651 0xb00c #define USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD 0xb309 diff --git a/drivers/hid/hid-lg-g15.c b/drivers/hid/hid-lg-g15.c index b76988c19f84..701ddb98e7d2 100644 --- a/drivers/hid/hid-lg-g15.c +++ b/drivers/hid/hid-lg-g15.c @@ -28,6 +28,7 @@ enum lg_g15_model { LG_G15_V2, LG_G510, LG_G510_USB_AUDIO, + LG_Z10, }; enum lg_g15_led_type { @@ -457,6 +458,13 @@ static int lg_g15_get_initial_led_brightness(struct lg_g15_data *g15) return ret; return lg_g510_update_mkey_led_brightness(g15); + case LG_Z10: + /* + * Getting the LCD backlight brightness is not supported. + * Reading Feature(2) fails with -EPIPE and this crashes + * the LCD and touch keys part of the speakers. + */ + return 0; } return -EINVAL; /* Never reached */ } @@ -626,6 +634,12 @@ static int lg_g15_raw_event(struct hid_device *hdev, struct hid_report *report, if (data[0] == 0x02 && size == 5) return lg_g15_v2_event(g15, data); break; + case LG_Z10: + if (data[0] == 0x02 && size == 9) { + lg_g15_handle_lcd_menu_keys(g15, data); + input_sync(g15->input); + } + break; case LG_G510: case LG_G510_USB_AUDIO: if (data[0] == 0x03 && size == 5) @@ -660,8 +674,10 @@ static int lg_g15_register_led(struct lg_g15_data *g15, int i, const char *name) switch (g15->model) { case LG_G15: case LG_G15_V2: - g15->leds[i].cdev.brightness_set_blocking = lg_g15_led_set; g15->leds[i].cdev.brightness_get = lg_g15_led_get; + fallthrough; + case LG_Z10: + g15->leds[i].cdev.brightness_set_blocking = lg_g15_led_set; if (i < LG_G15_BRIGHTNESS_MAX) { g15->leds[i].cdev.flags = LED_BRIGHT_HW_CHANGED; g15->leds[i].cdev.max_brightness = 2; @@ -802,6 +818,9 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) gkeys_settings_feature_report = 0x01; gkeys = 18; break; + case LG_Z10: + connect_mask = HID_CONNECT_HIDRAW; + break; } ret = hid_hw_start(hdev, connect_mask); @@ -844,6 +863,19 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id) if (ret) goto error_hw_stop; + if (g15->model == LG_Z10) { + lg_g15_init_input_dev(hdev, g15->input, "Logitech Z-10 LCD Menu Keys"); + ret = input_register_device(g15->input); + if (ret) + goto error_hw_stop; + + ret = lg_g15_register_led(g15, 1, "z-10::lcd_backlight"); + if (ret) + goto error_hw_stop; + + return 0; /* All done */ + } + /* Setup and register input device */ lg_g15_init_input_dev(hdev, input, "Logitech Gaming Keyboard Gaming Keys"); @@ -904,6 +936,10 @@ static const struct hid_device_id lg_g15_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G510_USB_AUDIO), .driver_data = LG_G510_USB_AUDIO }, + /* Z-10 speakers */ + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, + USB_DEVICE_ID_LOGITECH_Z_10_SPK), + .driver_data = LG_Z10 }, { } }; MODULE_DEVICE_TABLE(hid, lg_g15_devices); From patchwork Fri Apr 16 13:13:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 422932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6EDEC433B4 for ; Fri, 16 Apr 2021 13:13:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8248611BF for ; Fri, 16 Apr 2021 13:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243526AbhDPNOG (ORCPT ); Fri, 16 Apr 2021 09:14:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40563 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240600AbhDPNOG (ORCPT ); Fri, 16 Apr 2021 09:14:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618578821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e4rWDrDfwyLsDweYXZDDicczuMT9JBPonwOXgMZ3Nl8=; b=TNDXG9wbYMSpu7Pq65j/cwlk1gN4t0pHUW1eyVhDJf88qDsz5IZZiLe3upbxyowlWJ5xYJ LEj6VVaFM4m3BVx35lCwJgZraDT/aJDLW9iyt9NJtx0H31ZQFA61jYUALkOssTPykRx3qh sWu528Q+20nboQhl3sIubqXRV6otd7w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-566-Ms3Fs5yXO_qKlNvY_Tc65A-1; Fri, 16 Apr 2021 09:13:38 -0400 X-MC-Unique: Ms3Fs5yXO_qKlNvY_Tc65A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7548C87A83E; Fri, 16 Apr 2021 13:13:37 +0000 (UTC) Received: from x1.localdomain (ovpn-113-102.ams2.redhat.com [10.36.113.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CA0B5C626; Fri, 16 Apr 2021 13:13:36 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , Peter Hoeg , linux-input@vger.kernel.org Subject: [PATCH 6/6] HID: lg-g15 + ite: Add MODULE_AUTHOR Date: Fri, 16 Apr 2021 15:13:23 +0200 Message-Id: <20210416131323.233184-7-hdegoede@redhat.com> In-Reply-To: <20210416131323.233184-1-hdegoede@redhat.com> References: <20210416131323.233184-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org I noticed that the 2 HID drivers which I've written and maintain were missing a MODULE_AUTHOR tag, add this so that people can easily figure out who to email with questions. Signed-off-by: Hans de Goede --- drivers/hid/hid-ite.c | 1 + drivers/hid/hid-lg-g15.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/hid/hid-ite.c b/drivers/hid/hid-ite.c index 14fc068affad..430fa4f52ed3 100644 --- a/drivers/hid/hid-ite.c +++ b/drivers/hid/hid-ite.c @@ -135,4 +135,5 @@ static struct hid_driver ite_driver = { }; module_hid_driver(ite_driver); +MODULE_AUTHOR("Hans de Goede "); MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-lg-g15.c b/drivers/hid/hid-lg-g15.c index 701ddb98e7d2..b2a08233f8d5 100644 --- a/drivers/hid/hid-lg-g15.c +++ b/drivers/hid/hid-lg-g15.c @@ -952,4 +952,5 @@ static struct hid_driver lg_g15_driver = { }; module_hid_driver(lg_g15_driver); +MODULE_AUTHOR("Hans de Goede "); MODULE_LICENSE("GPL");