linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Alexander Kobel <a-kobel@a-kobel.de>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
	"Pavel Machek" <pavel@ucw.cz>, "Marek Behún" <kabel@kernel.org>,
	linux-input@vger.kernel.org, linux-leds@vger.kernel.org
Subject: [PATCH v2 resend 8/9] HID: lenovo: Rework how the tp10ubkbd code decides which USB interface to use
Date: Sun,  4 Apr 2021 10:04:31 +0200	[thread overview]
Message-ID: <20210404080432.4322-9-hdegoede@redhat.com> (raw)
In-Reply-To: <20210404080432.4322-1-hdegoede@redhat.com>

Instead of looking for a hdev with a type of HID_TYPE_USBMOUSE find
the interface for the mute/mic-mute/fn-lock LEDs by checking for the
output-report which is used to set them.

This is a preparation patch for adding support for the LEDs on the
X1 tablet thin keyboard which uses the same output-report, but has
a separate (third) USB interface for the touchpad/mouse functionality.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/hid/hid-lenovo.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 2287142116b9..a33de5022ec3 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -959,11 +959,24 @@ static const struct attribute_group lenovo_attr_group_tp10ubkbd = {
 
 static int lenovo_probe_tp10ubkbd(struct hid_device *hdev)
 {
+	struct hid_report_enum *rep_enum;
 	struct lenovo_drvdata *data;
+	struct hid_report *rep;
+	bool found;
 	int ret;
 
-	/* All the custom action happens on the USBMOUSE device for USB */
-	if (hdev->type != HID_TYPE_USBMOUSE)
+	/*
+	 * The LEDs and the Fn-lock functionality use output report 9,
+	 * with an application of 0xffa0001, add the LEDs on the interface
+	 * with this output report.
+	 */
+	found = false;
+	rep_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
+	list_for_each_entry(rep, &rep_enum->report_list, list) {
+		if (rep->application == 0xffa00001)
+			found = true;
+	}
+	if (!found)
 		return 0;
 
 	data = devm_kzalloc(&hdev->dev, sizeof(*data), GFP_KERNEL);
-- 
2.30.2


  parent reply	other threads:[~2021-04-04  8:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-04  8:04 [PATCH v2 resend 0/9] HID: lenovo: LED fixes and Thinkpad X1 Tablet kbd support Hans de Goede
2021-04-04  8:04 ` [PATCH v2 resend 1/9] HID: lenovo: Use brightness_set_blocking callback for setting LEDs brightness Hans de Goede
2021-04-04  8:04 ` [PATCH v2 resend 2/9] HID: lenovo: Fix lenovo_led_set_tp10ubkbd() error handling Hans de Goede
2021-04-04  8:04 ` [PATCH v2 resend 3/9] HID: lenovo: Check hid_get_drvdata() returns non NULL in lenovo_event() Hans de Goede
2021-04-04  8:04 ` [PATCH v2 resend 4/9] HID: lenovo: Remove lenovo_led_brightness_get() Hans de Goede
2021-04-04  8:04 ` [PATCH v2 resend 5/9] HID: lenovo: Set LEDs max_brightness value Hans de Goede
2021-04-04  8:04 ` [PATCH v2 resend 6/9] HID: lenovo: Map mic-mute button to KEY_F20 instead of KEY_MICMUTE Hans de Goede
2021-04-04  8:04 ` [PATCH v2 resend 7/9] HID: lenovo: Set default_triggers for the mute and micmute LEDs Hans de Goede
2021-04-04  8:04 ` Hans de Goede [this message]
2021-04-04  8:04 ` [PATCH v2 resend 9/9] HID: lenovo: Add support for Thinkpad X1 Tablet Thin keyboard Hans de Goede
2021-04-07 12:56 ` [PATCH v2 resend 0/9] HID: lenovo: LED fixes and Thinkpad X1 Tablet kbd support Jiri Kosina
2021-04-07 13:42   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210404080432.4322-9-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=a-kobel@a-kobel.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=kabel@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).