Add support for toggling the BIOS POST sound on some ASUS laptops.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
.../ABI/testing/sysfs-platform-asus-wmi | 9 ++++
drivers/platform/x86/asus-wmi.c | 51 +++++++++++++++++++
include/linux/platform_data/x86/asus-wmi.h | 3 ++
3 files changed, 63 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
index 61a745d2476f..5645dbac4ce8 100644
--- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
+++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
@@ -194,3 +194,12 @@ Contact: "Luke Jones" <luke@ljones.dev>
Description:
Set the target temperature limit of the Nvidia dGPU:
* min=75, max=87
+
+What: /sys/devices/platform/<platform>/boot_sound
+Date: Jun 2023
+KernelVersion: 6.10
+Contact: "Luke Jones" <luke@ljones.dev>
+Description:
+ Set if the BIOS POST sound is played on boot.
+ * 0 - False,
+ * 1 - True
\ No newline at end of file
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 094a93f24667..6cac9c3eb8b2 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -2106,6 +2106,54 @@ static ssize_t panel_od_store(struct device *dev,
}
static DEVICE_ATTR_RW(panel_od);
+/* Bootup sound ***************************************************************/
+
+static ssize_t boot_sound_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_BOOT_SOUND);
+ if (result < 0)
+ return result;
+
+ return sysfs_emit(buf, "%d\n", result);
+}
+
+static ssize_t boot_sound_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int result, err;
+ u32 snd;
+
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ result = kstrtou32(buf, 10, &snd);
+ if (result)
+ return result;
+
+ if (snd > 1)
+ return -EINVAL;
+
+ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BOOT_SOUND, snd, &result);
+ if (err) {
+ pr_warn("Failed to set boot sound: %d\n", err);
+ return err;
+ }
+
+ if (result > 1) {
+ pr_warn("Failed to set panel boot sound (result): 0x%x\n", result);
+ return -EIO;
+ }
+
+ sysfs_notify(&asus->platform_device->dev.kobj, NULL, "boot_sound");
+
+ return count;
+}
+static DEVICE_ATTR_RW(boot_sound);
+
/* Mini-LED mode **************************************************************/
static ssize_t mini_led_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -4227,6 +4275,7 @@ static struct attribute *platform_attributes[] = {
&dev_attr_ppt_platform_sppt.attr,
&dev_attr_nv_dynamic_boost.attr,
&dev_attr_nv_temp_target.attr,
+ &dev_attr_boot_sound.attr,
&dev_attr_panel_od.attr,
&dev_attr_mini_led_mode.attr,
&dev_attr_available_mini_led_mode.attr,
@@ -4279,6 +4328,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
ok = asus->nv_dyn_boost_available;
else if (attr == &dev_attr_nv_temp_target.attr)
ok = asus->nv_temp_tgt_available;
+ else if (attr == &dev_attr_boot_sound.attr)
+ devid = ASUS_WMI_DEVID_BOOT_SOUND;
else if (attr == &dev_attr_panel_od.attr)
ok = asus->panel_overdrive_available;
else if (attr == &dev_attr_mini_led_mode.attr)
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 3e9a01467c67..3eb5cd6773ad 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -137,6 +137,9 @@
/* TUF laptop RGB power/state */
#define ASUS_WMI_DEVID_TUF_RGB_STATE 0x00100057
+/* Bootup sound control */
+#define ASUS_WMI_DEVID_BOOT_SOUND 0x00130022
+
/* DSTS masks */
#define ASUS_WMI_DSTS_STATUS_BIT 0x00000001
#define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002
--
2.44.0
On Mon, 25 Mar 2024, Luke D. Jones wrote:
> Add support for toggling the BIOS POST sound on some ASUS laptops.
>
> Signed-off-by: Luke D. Jones <luke@ljones.dev>
> ---
> .../ABI/testing/sysfs-platform-asus-wmi | 9 ++++
> drivers/platform/x86/asus-wmi.c | 51 +++++++++++++++++++
> include/linux/platform_data/x86/asus-wmi.h | 3 ++
> 3 files changed, 63 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> index 61a745d2476f..5645dbac4ce8 100644
> --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
> +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> @@ -194,3 +194,12 @@ Contact: "Luke Jones" <luke@ljones.dev>
> Description:
> Set the target temperature limit of the Nvidia dGPU:
> * min=75, max=87
> +
> +What: /sys/devices/platform/<platform>/boot_sound
> +Date: Jun 2023
> +KernelVersion: 6.10
> +Contact: "Luke Jones" <luke@ljones.dev>
> +Description:
> + Set if the BIOS POST sound is played on boot.
> + * 0 - False,
> + * 1 - True
> \ No newline at end of file
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 094a93f24667..6cac9c3eb8b2 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -2106,6 +2106,54 @@ static ssize_t panel_od_store(struct device *dev,
> }
> static DEVICE_ATTR_RW(panel_od);
>
> +/* Bootup sound ***************************************************************/
> +
> +static ssize_t boot_sound_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_BOOT_SOUND);
> + if (result < 0)
> + return result;
> +
> + return sysfs_emit(buf, "%d\n", result);
> +}
> +
> +static ssize_t boot_sound_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + int result, err;
> + u32 snd;
> +
> + struct asus_wmi *asus = dev_get_drvdata(dev);
> +
> + result = kstrtou32(buf, 10, &snd);
> + if (result)
> + return result;
> +
> + if (snd > 1)
> + return -EINVAL;
> +
> + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BOOT_SOUND, snd, &result);
> + if (err) {
> + pr_warn("Failed to set boot sound: %d\n", err);
> + return err;
> + }
> +
> + if (result > 1) {
> + pr_warn("Failed to set panel boot sound (result): 0x%x\n", result);
> + return -EIO;
> + }
> +
> + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "boot_sound");
> +
> + return count;
> +}
> +static DEVICE_ATTR_RW(boot_sound);
I started to think that perhaps these would be a way to create helper for
these sysfs functions to call as they are quite similar, only the wmi id,
strings and the range check change (the GPU functions do a few extra
checks and could remain standalone functions but the rest look very
similar to each other).
--
i.
On Tue, 26 Mar 2024, at 3:02 AM, Ilpo Järvinen wrote:
> On Mon, 25 Mar 2024, Luke D. Jones wrote:
>
> > Add support for toggling the BIOS POST sound on some ASUS laptops.
> >
> > Signed-off-by: Luke D. Jones <luke@ljones.dev>
> > ---
> > .../ABI/testing/sysfs-platform-asus-wmi | 9 ++++
> > drivers/platform/x86/asus-wmi.c | 51 +++++++++++++++++++
> > include/linux/platform_data/x86/asus-wmi.h | 3 ++
> > 3 files changed, 63 insertions(+)
> >
> > diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> > index 61a745d2476f..5645dbac4ce8 100644
> > --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
> > +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> > @@ -194,3 +194,12 @@ Contact: "Luke Jones" <luke@ljones.dev>
> > Description:
> > Set the target temperature limit of the Nvidia dGPU:
> > * min=75, max=87
> > +
> > +What: /sys/devices/platform/<platform>/boot_sound
> > +Date: Jun 2023
> > +KernelVersion: 6.10
> > +Contact: "Luke Jones" <luke@ljones.dev>
> > +Description:
> > + Set if the BIOS POST sound is played on boot.
> > + * 0 - False,
> > + * 1 - True
> > \ No newline at end of file
> > diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> > index 094a93f24667..6cac9c3eb8b2 100644
> > --- a/drivers/platform/x86/asus-wmi.c
> > +++ b/drivers/platform/x86/asus-wmi.c
> > @@ -2106,6 +2106,54 @@ static ssize_t panel_od_store(struct device *dev,
> > }
> > static DEVICE_ATTR_RW(panel_od);
> >
> > +/* Bootup sound ***************************************************************/
> > +
> > +static ssize_t boot_sound_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_BOOT_SOUND);
> > + if (result < 0)
> > + return result;
> > +
> > + return sysfs_emit(buf, "%d\n", result);
> > +}
> > +
> > +static ssize_t boot_sound_store(struct device *dev,
> > + struct device_attribute *attr,
> > + const char *buf, size_t count)
> > +{
> > + int result, err;
> > + u32 snd;
> > +
> > + struct asus_wmi *asus = dev_get_drvdata(dev);
> > +
> > + result = kstrtou32(buf, 10, &snd);
> > + if (result)
> > + return result;
> > +
> > + if (snd > 1)
> > + return -EINVAL;
> > +
> > + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BOOT_SOUND, snd, &result);
> > + if (err) {
> > + pr_warn("Failed to set boot sound: %d\n", err);
> > + return err;
> > + }
> > +
> > + if (result > 1) {
> > + pr_warn("Failed to set panel boot sound (result): 0x%x\n", result);
> > + return -EIO;
> > + }
> > +
> > + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "boot_sound");
> > +
> > + return count;
> > +}
> > +static DEVICE_ATTR_RW(boot_sound);
>
> I started to think that perhaps these would be a way to create helper for
> these sysfs functions to call as they are quite similar, only the wmi id,
> strings and the range check change (the GPU functions do a few extra
> checks and could remain standalone functions but the rest look very
> similar to each other).
I absolutely agree. In rust I would have written function or macro by now. I'm working on this but won't submit until we've been through the existing chain and applied.
Looks like the entire asus-wmi could use some maintenance tbh, I'll do what I can.
Cheers,
Luke.
On Mon, 25 Mar 2024, Luke D. Jones wrote: > Add support for toggling the BIOS POST sound on some ASUS laptops. > > Signed-off-by: Luke D. Jones <luke@ljones.dev> > --- > .../ABI/testing/sysfs-platform-asus-wmi | 9 ++++ > drivers/platform/x86/asus-wmi.c | 51 +++++++++++++++++++ > include/linux/platform_data/x86/asus-wmi.h | 3 ++ > 3 files changed, 63 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi > index 61a745d2476f..5645dbac4ce8 100644 > --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi > +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi > @@ -194,3 +194,12 @@ Contact: "Luke Jones" <luke@ljones.dev> > Description: > Set the target temperature limit of the Nvidia dGPU: > * min=75, max=87 > + > +What: /sys/devices/platform/<platform>/boot_sound > +Date: Jun 2023 2024? :-) > +KernelVersion: 6.10 > +Contact: "Luke Jones" <luke@ljones.dev> > +Description: > + Set if the BIOS POST sound is played on boot. > + * 0 - False, > + * 1 - True > \ No newline at end of file Please add the new line. Once those are fixed: Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> -- i.
© 2016 - 2026 Red Hat, Inc.