linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Luke D. Jones" <luke@ljones.dev>, jikos@kernel.org
Cc: ilpo.jarvinen@linux.intel.com, corentin.chary@gmail.com,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	bentiss@kernel.org
Subject: Re: [PATCH v1 2/2] hid-asus: change the report_id used for HID LED control
Date: Wed, 29 May 2024 10:25:57 +0200	[thread overview]
Message-ID: <ea85df16-53b4-4e25-b7c7-3f74486cdcf9@redhat.com> (raw)
In-Reply-To: <20240529012827.146005-3-luke@ljones.dev>

Hi,

On 5/29/24 3:28 AM, Luke D. Jones wrote:
> On some laptops the report_id used for LED brightness control must be
> 0x5D instead of 0x5A.
> 
> Signed-off-by: Luke D. Jones <luke@ljones.dev>
> ---
>  drivers/hid/hid-asus.c | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 4cba8e143031..ec3556cc4eef 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
> @@ -94,6 +94,8 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
>  
>  #define TRKID_SGN       ((TRKID_MAX + 1) >> 1)
>  
> +static const char * const use_alt_led_report_id[] = { "GU605", "GA403" };
> +
>  struct asus_kbd_leds {
>  	struct led_classdev cdev;
>  	struct hid_device *hdev;
> @@ -101,6 +103,7 @@ struct asus_kbd_leds {
>  	unsigned int brightness;
>  	spinlock_t lock;
>  	bool removed;
> +	int report_id;
>  };
>  
>  struct asus_touchpad_info {
> @@ -473,7 +476,7 @@ static enum led_brightness asus_kbd_backlight_get(struct led_classdev *led_cdev)
>  static void asus_kbd_backlight_work(struct work_struct *work)
>  {
>  	struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
> -	u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
> +	u8 buf[] = { led->report_id, 0xba, 0xc5, 0xc4, 0x00 };
>  	int ret;
>  	unsigned long flags;
>  
> @@ -513,6 +516,23 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
>  	return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT);
>  }
>  
> +static bool asus_kbd_is_input_led(void)
> +{
> +	const char *product;
> +	int i;
> +
> +	product = dmi_get_system_info(DMI_PRODUCT_NAME);
> +	if (!product)
> +		return false;
> +
> +	for (i = 0; i < ARRAY_SIZE(use_alt_led_report_id); i++) {
> +		if (strstr(product, use_alt_led_report_id[i]))
> +			return true;
> +	}
> +
> +	return false;
> +}
> +


This again feels like you are re-inventing dmi_check_system() please
change use_alt_led_report_id to a dmi_system_id array and drop this
function (you can directly call dmi_check_system(use_alt_led_report_id)
instead).


>  static int asus_kbd_register_leds(struct hid_device *hdev)
>  {
>  	struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
> @@ -555,6 +575,10 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
>  	if (!drvdata->kbd_backlight)
>  		return -ENOMEM;
>  
> +	drvdata->kbd_backlight->report_id = FEATURE_KBD_REPORT_ID;
> +	if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD && asus_kbd_is_input_led())
> +		drvdata->kbd_backlight->report_id = FEATURE_KBD_LED_REPORT_ID1;
> +
>  	drvdata->kbd_backlight->removed = false;
>  	drvdata->kbd_backlight->brightness = 0;
>  	drvdata->kbd_backlight->hdev = hdev;

Regards,

Hans



  reply	other threads:[~2024-05-29  8:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29  1:28 [PATCH v1 0/2] asus wmi and hid: use HID LED for brightness Luke D. Jones
2024-05-29  1:28 ` [PATCH v1 1/2] hid-asus: use hid for brightness control on keyboard Luke D. Jones
2024-05-29  8:21   ` Hans de Goede
2024-05-29  1:28 ` [PATCH v1 2/2] hid-asus: change the report_id used for HID LED control Luke D. Jones
2024-05-29  8:25   ` Hans de Goede [this message]
2024-05-29  9:27     ` Luke Jones
2024-05-29 15:28 ` [PATCH v1 0/2] asus wmi and hid: use HID LED for brightness Hans de Goede
2024-06-06  8:49   ` Benjamin Tissoires
2024-06-06  9:53     ` Hans de Goede
2024-06-06 21:02       ` Luke Jones
  -- strict thread matches above, loose matches on Subject: below --
2024-05-29  1:24 [PATCH v1 1/2] hid-asus: use hid for brightness control on keyboard Luke D. Jones
2024-05-29  1:24 ` [PATCH v1 2/2] hid-asus: change the report_id used for HID LED control Luke D. Jones
2024-05-29  1:30   ` Luke Jones

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=ea85df16-53b4-4e25-b7c7-3f74486cdcf9@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=bentiss@kernel.org \
    --cc=corentin.chary@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luke@ljones.dev \
    --cc=platform-driver-x86@vger.kernel.org \
    /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).