mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Luke D. Jones" <luke@ljones.dev>
Cc: corentin.chary@gmail.com, acpi4asus-user@lists.sourceforge.net,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org,
	markgross@kernel.org, jdelvare@suse.com, linux@roeck-us.net
Subject: Re: [PATCH v2 7/8] platform/x86: asus-wmi: support setting mini-LED mode
Date: Wed, 12 Jul 2023 16:48:23 +0200	[thread overview]
Message-ID: <43985ad2-401c-3632-c045-90049d600217@redhat.com> (raw)
In-Reply-To: <20230630053552.976579-8-luke@ljones.dev>

Hi,

On 6/30/23 07:35, Luke D. Jones wrote:
> Support changing the mini-LED mode on some of the newer ASUS laptops.
> 
> Signed-off-by: Luke D. Jones <luke@ljones.dev>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  .../ABI/testing/sysfs-platform-asus-wmi       |  9 ++++
>  drivers/platform/x86/asus-wmi.c               | 53 +++++++++++++++++++
>  include/linux/platform_data/x86/asus-wmi.h    |  1 +
>  3 files changed, 63 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> index 878daf7c2036..5624bdef49cb 100644
> --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
> +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> @@ -117,3 +117,12 @@ Description:
>  		Show if the egpu (XG Mobile) is correctly connected:
>  			* 0 - False,
>  			* 1 - True
> +
> +What:		/sys/devices/platform/<platform>/mini_led_mode
> +Date:		Jun 2023
> +KernelVersion:	6.5
> +Contact:	"Luke Jones" <luke@ljones.dev>
> +Description:
> +		Change the mini-LED mode:
> +			* 0 - Single-zone,
> +			* 1 - Multi-zone
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 602426a7fb41..1fc9e8afc2f3 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -265,6 +265,7 @@ struct asus_wmi {
>  	bool battery_rsoc_available;
>  
>  	bool panel_overdrive_available;
> +	bool mini_led_mode_available;
>  
>  	struct hotplug_slot hotplug_slot;
>  	struct mutex hotplug_lock;
> @@ -1820,6 +1821,54 @@ static ssize_t panel_od_store(struct device *dev,
>  }
>  static DEVICE_ATTR_RW(panel_od);
>  
> +/* Mini-LED mode **************************************************************/
> +static ssize_t mini_led_mode_show(struct device *dev,
> +				   struct device_attribute *attr, char *buf)
> +{
> +	struct asus_wmi *asus = dev_get_drvdata(dev);
> +	int result;
> +
> +	result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MINI_LED_MODE);
> +	if (result < 0)
> +		return result;
> +
> +	return sysfs_emit(buf, "%d\n", result);
> +}
> +
> +static ssize_t mini_led_mode_store(struct device *dev,
> +				    struct device_attribute *attr,
> +				    const char *buf, size_t count)
> +{
> +	int result, err;
> +	u32 mode;
> +
> +	struct asus_wmi *asus = dev_get_drvdata(dev);
> +
> +	result = kstrtou32(buf, 10, &mode);
> +	if (result)
> +		return result;
> +
> +	if (mode > 1)
> +		return -EINVAL;
> +
> +	err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MINI_LED_MODE, mode, &result);
> +
> +	if (err) {
> +		pr_warn("Failed to set mini-LED: %d\n", err);
> +		return err;
> +	}
> +
> +	if (result > 1) {
> +		pr_warn("Failed to set mini-LED mode (result): 0x%x\n", result);
> +		return -EIO;
> +	}
> +
> +	sysfs_notify(&asus->platform_device->dev.kobj, NULL, "mini_led_mode");
> +
> +	return count;
> +}
> +static DEVICE_ATTR_RW(mini_led_mode);
> +
>  /* Quirks *********************************************************************/
>  
>  static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
> @@ -3727,6 +3776,7 @@ static struct attribute *platform_attributes[] = {
>  	&dev_attr_fan_boost_mode.attr,
>  	&dev_attr_throttle_thermal_policy.attr,
>  	&dev_attr_panel_od.attr,
> +	&dev_attr_mini_led_mode.attr,
>  	NULL
>  };
>  
> @@ -3764,6 +3814,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
>  		ok = asus->throttle_thermal_policy_available;
>  	else if (attr == &dev_attr_panel_od.attr)
>  		ok = asus->panel_overdrive_available;
> +	else if (attr == &dev_attr_mini_led_mode.attr)
> +		ok = asus->mini_led_mode_available;
>  
>  	if (devid != -1)
>  		ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
> @@ -4026,6 +4078,7 @@ static int asus_wmi_add(struct platform_device *pdev)
>  	asus->kbd_rgb_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE);
>  	asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE);
>  	asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD);
> +	asus->mini_led_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE);
>  
>  	err = fan_boost_mode_check_present(asus);
>  	if (err)
> diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
> index 2034648f8cdf..ea80361ac6c7 100644
> --- a/include/linux/platform_data/x86/asus-wmi.h
> +++ b/include/linux/platform_data/x86/asus-wmi.h
> @@ -66,6 +66,7 @@
>  #define ASUS_WMI_DEVID_CAMERA		0x00060013
>  #define ASUS_WMI_DEVID_LID_FLIP		0x00060062
>  #define ASUS_WMI_DEVID_LID_FLIP_ROG	0x00060077
> +#define ASUS_WMI_DEVID_MINI_LED_MODE	0x0005001E
>  
>  /* Storage */
>  #define ASUS_WMI_DEVID_CARDREADER	0x00080013


  reply	other threads:[~2023-07-12 14:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-30  5:35 [PATCH v2 0/8] platform/x86: asus-wmi: Luke D. Jones
2023-06-30  5:35 ` [PATCH v2 1/8] platform/x86: asus-wmi: add support for showing charger mode Luke D. Jones
2023-07-04 11:33   ` Hans de Goede
2023-06-30  5:35 ` [PATCH v2 2/8] platform/x86: asus-wmi: add support for showing middle fan RPM Luke D. Jones
2023-07-04 11:33   ` Hans de Goede
2023-06-30  5:35 ` [PATCH v2 3/8] platform/x86: asus-wmi: support middle fan custom curves Luke D. Jones
2023-07-04 11:34   ` Hans de Goede
2023-06-30  5:35 ` [PATCH v2 4/8] platform/x86: asus-wmi: add WMI method to show if egpu connected Luke D. Jones
2023-07-12 14:43   ` Hans de Goede
2023-06-30  5:35 ` [PATCH v2 5/8] platform/x86: asus-wmi: don't allow eGPU switching if eGPU not connected Luke D. Jones
2023-07-12 14:43   ` Hans de Goede
2023-06-30  5:35 ` [PATCH v2 6/8] platform/x86: asus-wmi: add safety checks to gpu switching Luke D. Jones
2023-07-12 14:47   ` Hans de Goede
2023-06-30  5:35 ` [PATCH v2 7/8] platform/x86: asus-wmi: support setting mini-LED mode Luke D. Jones
2023-07-12 14:48   ` Hans de Goede [this message]
2023-06-30  5:35 ` [PATCH v2 8/8] platform/x86: asus-wmi: expose dGPU and CPU tunables for ROG Luke D. Jones
2023-07-11  9:55   ` kernel test robot
2023-07-12 14:57   ` Hans de Goede
2023-07-12 15:18 ` [PATCH v2 0/8] platform/x86: asus-wmi: 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=43985ad2-401c-3632-c045-90049d600217@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=acpi4asus-user@lists.sourceforge.net \
    --cc=corentin.chary@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=luke@ljones.dev \
    --cc=markgross@kernel.org \
    --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

all inboxes | Powered by JetHome®