Skip to contentSkip to conversation

platform/x86: Add wmi driver for Casper Excalibur laptops

PATCH Superseded mustafa 4 participants 10 messages Mar 24, 2024 – Apr 8, 2024

Subsystems (3)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

mustafa

author
#0 lore raw

v5 cover platform/x86: Add wmi driver for Casper Excalibur laptops

From: Mustafa Ekşi <[email protected]>

Hi,
I want to note that moving mutex_init to the bottom of the function crashes the driver when mutex_lock is called. I didn't investigate it further but I wanted to say that since Ai Chao also did it like that.

Driver sets all leds to white on start. Before that, when a led's brightness is changed, that led's color gets set to white but others keep their old colors which creates a bad user experience (at least for me). Please inform me if this is a bad approach.
Also, this driver still lacks support for changing modes and I seek advise for that.

Mustafa Ekşi (1):
platform/x86: Add wmi driver for Casper Excalibur laptops

 MAINTAINERS                       |   6 +
 drivers/platform/x86/Kconfig      |  14 +
 drivers/platform/x86/Makefile     |   1 +
 drivers/platform/x86/casper-wmi.c | 641 ++++++++++++++++++++++++++++++
 4 files changed, 662 insertions(+)
 create mode 100644 drivers/platform/x86/casper-wmi.c
Signature · 1 line
2.44.0
author
#1 lore raw

PATCH v5 1/1 platform/x86: Add wmi driver for Casper Excalibur laptops

From: Mustafa Ekşi <[email protected]>

This wmi driver supports Casper Excalibur laptops' changing keyboard backlight, reading fan speeds and changing power profiles. Multicolor led device is used for backlight, platform_profile for power management and hwmon for fan speeds. It supports both old (10th gen or older) and new (11th gen or newer) laptops. It uses x86_match_cpu to check if the laptop is old or new.
This driver's Multicolor keyboard backlight API is very similar to Rishit Bansal's proposed API.

---
Changes in v5:
- Added mutex_destroy to casper_wmi_probe error handling
- casper_multicolor_register now sets all leds to CASPER_DEFAULT_COLOR
- Some minor changes
Changes in v4:
- Renamed casper_driver to casper_drv
- Moved all global variables to casper_drv struct. Devices access casper_drv via wdev's driver_data.
- Removed struct led_cache, because only its u32 array was used. It is replaced with color_cache.
- Added mutex_locks in casper_set and casper_query, so they now accept casper_drv instead of wmi_device as argument.
- Changed endianess conversion in hwmon_read to something sparse doesn't complain about.
- Moved registrations of multicolor leds and platform profile to their own functions. This makes casper_wmi_probe more readable.
- Added .no_singleton to wmi_device.
- Some minor changes.
Changes in v3:
- Replaced led_control attribute with multicolor led interface.
- Added struct led_cache, instead of storing only last color change.
- Added dmi list to prevent registering platform_profile driver in models that doesn't have this feature.
- Added a x86_cpu_id to differentiate older laptops that are reporting fan speeds in big-endian. Also newer laptops have a different power profile scheme. I'm using x86_cpu_id because they don't have a difference in model names, only in cpu generations (the official driver download page makes you select your cpu's generation too).
- Removed hwmon_pwm device in favor of platform_profile driver. It indirectly affects fans' speed but they also affect frequency and power consumption as well.
- Replaced handwritten masks with GENMASK equivalents.
- Replaced led_classdev_register with devm_led_classdev_multicolor_register. This should solve the bug where led_classdev remains registered even if casper_wmi_probe returns -ENODEV.
- Removed select NEW_LEDS and LEDS_CLASS, because it creates recursive dependencies.
- And some minor changes.
Changes in v2:
- Added masks for
- Changed casper_set and casper_query returns Linux error code rather than acpi_status.
- replaced complicated bit operations with FIELD_GET.
- Fixed some indentation and spacing.
- Broke fan speeds further.
- Moved module metadata to the end of the file.

---
 MAINTAINERS                       |   6 +
 drivers/platform/x86/Kconfig      |  14 +
 drivers/platform/x86/Makefile     |   1 +
 drivers/platform/x86/casper-wmi.c | 641 ++++++++++++++++++++++++++++++
 4 files changed, 662 insertions(+)
 create mode 100644 drivers/platform/x86/casper-wmi.c
MAINTAINERS +6 -0
index aa3b947fb08..78f908449ea 100644
@@ -4761,6 +4761,12 @@ S:	Maintained
 W:	https://wireless.wiki.kernel.org/en/users/Drivers/carl9170
 F:	drivers/net/wireless/ath/carl9170/
 
+CASPER EXCALIBUR WMI DRIVER
+M:	Mustafa Ekşi <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/casper-wmi.c
+
 CAVIUM I2C DRIVER
 M:	Robert Richter <[email protected]>
 S:	Odd Fixes
drivers/platform/x86/Kconfig +14 -0
index 7e9251fc334..e671ccbf23a 100644
@@ -1122,6 +1122,20 @@ config SEL3350_PLATFORM
 	  To compile this driver as a module, choose M here: the module
 	  will be called sel3350-platform.
 
+config CASPER_WMI
+	tristate "Casper Excalibur Laptop WMI driver"
+	depends on ACPI_WMI
+	depends on HWMON
+	depends on LEDS_CLASS_MULTICOLOR
+	select ACPI_PLATFORM_PROFILE
+	help
+	  Say Y here if you want to support WMI-based fan speed reporting,
+	  power management and keyboard backlight support on Casper Excalibur
+	  Laptops.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called casper-wmi.
+
 endif # X86_PLATFORM_DEVICES
 
 config P2SB
drivers/platform/x86/Makefile +1 -0
index 1de432e8861..4b527dd44ad 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_MXM_WMI)			+= mxm-wmi.o
 obj-$(CONFIG_NVIDIA_WMI_EC_BACKLIGHT)	+= nvidia-wmi-ec-backlight.o
 obj-$(CONFIG_XIAOMI_WMI)		+= xiaomi-wmi.o
 obj-$(CONFIG_GIGABYTE_WMI)		+= gigabyte-wmi.o
+obj-$(CONFIG_CASPER_WMI)		+= casper-wmi.o
 
 # Acer
 obj-$(CONFIG_ACERHDF)		+= acerhdf.o
drivers/platform/x86/casper-wmi.c new file +641 -0

641 lines not on this page · raw message

Signature · 1 line
2.44.0
#2 lore raw

Hi Mustafa,

Quoted 11 lines · mustafa

From: Mustafa Ekşi <[email protected]>

This wmi driver supports Casper Excalibur laptops' changing keyboard backlight, reading fan speeds and changing power profiles. Multicolor led device is used for backlight, platform_profile for power management and hwmon for fan speeds. It supports both old (10th gen or older) and new (11th gen or newer) laptops. It uses x86_match_cpu to check if the laptop is old or new.
This driver's Multicolor keyboard backlight API is very similar to Rishit Bansal's proposed API.

Quoted 1 line

Thank you for your patch.

Overall this looks pretty good I have one important remark about the LED names and some small remarks inline.

After those are addressed I believe this is ready for merging.

<snip>

drivers/platform/x86/casper-wmi.c line 47

Quoted 8 lines
drivers/platform/x86/casper-wmi.c new file +8 -0
+#define CASPER_LED_COUNT 4
+
+static const char * const zone_names[CASPER_LED_COUNT] = {
+	"casper::kbd_zoned_backlight-right",
+	"casper::kbd_zoned_backlight-middle",
+	"casper::kbd_zoned_backlight-left",
+	"casper::kbd_zoned_backlight-corners",
+};

So these names should be:

static const char * const zone_names[CASPER_LED_COUNT] = {
"casper:rgb:kbd_zoned_backlight-right", "casper:rgb:kbd_zoned_backlight-middle", "casper:rgb:kbd_zoned_backlight-left", "casper:rgb:kbd_zoned_backlight-corners",
};

with that change I think this is fine, but we really need to get an ack for this from the LED subsys maintainers.

Please add a second patch to this patch-serieas adding some documentation about the use of these names for zoned RGB backlit kbds in a new paragraph / subsection of the "LED Device Naming" section of:

Documentation/leds/leds-class.rst

It seems there are 2 possible sets which we should probably document in one go:

The set of 4 zones from this patch:

:rgb:kbd_zoned_backlight-right
:rgb:kbd_zoned_backlight-middle
:rgb:kbd_zoned_backlight-left
:rgb:kbd_zoned_backlight-corners

As well as:

:rgb:kbd_zoned_backlight-main
:rgb:kbd_zoned_backlight-wasd
:rgb:kbd_zoned_backlight-cursor
:rgb:kbd_zoned_backlight-numpad

Maybe with a comment that in the future different
zone names are possible if keyboards with
a different zoning scheme show up.

drivers/platform/x86/casper-wmi.c line 105

Quoted 5 lines
drivers/platform/x86/casper-wmi.c new file +5 -0
+static int casper_set(struct casper_drv *drv, u16 a1, u8 led_id, u32 data)
+{
+	acpi_status ret = 0;
+	struct casper_wmi_args wmi_args;
+	struct acpi_buffer input;

Please use a separate acpi_status and ret variables here with the correct types:

	struct casper_wmi_args wmi_args;
	struct acpi_buffer input;
	acpi_status status;
	int ret = 0;
Quoted 5 lines
drivers/platform/x86/casper-wmi.c new file +5 -0
+
+	wmi_args = (struct casper_wmi_args) {
+		.a0 = CASPER_WRITE,
+		.a1 = a1,
+		.a2 = led_id,

drivers/platform/x86/casper-wmi.c line 120

Quoted 10 lines
drivers/platform/x86/casper-wmi.c new file +10 -0
+		.a3 = data
+	};
+
+	input = (struct acpi_buffer) {
+		(acpi_size) sizeof(struct casper_wmi_args),
+		&wmi_args
+	};
+
+	mutex_lock(&drv->casper_mutex);
+

And then here:

	status = wmidev_block_set(drv->wdev, 0, &input);
	if (ACPI_FAILURE(status))
		ret = -EIO;

drivers/platform/x86/casper-wmi.c line 131

Quoted 8 lines
drivers/platform/x86/casper-wmi.c new file +8 -0
+
+	mutex_unlock(&drv->casper_mutex);
+	return ret;
+}
+
+static int casper_query(struct casper_drv *drv, u16 a1,
+			struct casper_wmi_args *out)
+{

Same here, also please sort variable declarations in reverse christmas tree order, so longest lines first:

	struct casper_wmi_args wmi_args;
	struct acpi_buffer input;
	union acpi_object *obj;
	acpi_status status;
	int ret = 0;

drivers/platform/x86/casper-wmi.c line 147

Quoted 11 lines
drivers/platform/x86/casper-wmi.c new file +11 -0
+	wmi_args = (struct casper_wmi_args) {
+		.a0 = CASPER_READ,
+		.a1 = a1
+	};
+	input = (struct acpi_buffer) {
+		(acpi_size) sizeof(struct casper_wmi_args),
+		&wmi_args
+	};
+
+	mutex_lock(&drv->casper_mutex);
+

And use status here to store the acpi_status type
returned by wmidev_block_set().

Quoted 19 lines
drivers/platform/x86/casper-wmi.c new file +19 -0
+	ret = wmidev_block_set(drv->wdev, 0, &input);
+	if (ACPI_FAILURE(ret)) {
+		ret = -EIO;
+		goto unlock;
+	}
+
+	obj = wmidev_block_query(drv->wdev, 0);
+	if (!obj) {
+		ret = -EIO;
+		goto unlock;
+	}
+
+	if (obj->type != ACPI_TYPE_BUFFER) { // obj will be 0x10 on failure
+		ret = -EINVAL;
+		goto freeobj;
+	}
+	if (obj->buffer.length != sizeof(struct casper_wmi_args)) {
+		ret = -EIO;
+		goto freeobj;

drivers/platform/x86/casper-wmi.c line 176

Quoted 10 lines
drivers/platform/x86/casper-wmi.c new file +10 -0
+	}
+
+	memcpy(out, obj->buffer.pointer, sizeof(struct casper_wmi_args));
+
+freeobj:
+	kfree(obj);
+unlock:
+	mutex_unlock(&drv->casper_mutex);
+	return ret;
+}

<snip>

The MODULE_DEVICE_TABLE() line should be directly below the declaration of the table like this:

static const struct wmi_device_id casper_wmi_id_table[] = {
	{ CASPER_WMI_GUID, NULL },
	{ }
};

MODULE_DEVICE_TABLE(wmi, casper_wmi_id_table);

Regards,

Hans

#3 lore raw
In reply to mustafa

Am 24.03.24 um 19:12 schrieb mustafa:

Quoted 6 lines

From: Mustafa Ekşi <[email protected]>

Hi,
I want to note that moving mutex_init to the bottom of the function crashes the driver when mutex_lock is called. I didn't investigate it further but I wanted to say that since Ai Chao also did it like that.

You mean like the lenovo-wmi-camera driver? In this case, the driver was only using the mutex inside the WMI notify callback, which can only run once the driver has finished probing.

In your case however, the mutex can already be used while the driver is still probing, because it registers callbacks with other subsystems.
The subsystem (maybe led?) assumes that the device is already fully operational and will begin calling the callbacks immediately, causing a crash.

Looking at the code, it seems that you are not calling mutex_destroy() in casper_wmi_remove(). I suggest to use devm_add_action_or_reset() for handling this.

Thanks,
Armin Wolf

Quoted 17 lines

Driver sets all leds to white on start. Before that, when a led's brightness is changed, that led's color gets set to white but others keep their old colors which creates a bad user experience (at least for me). Please inform me if this is a bad approach.
Also, this driver still lacks support for changing modes and I seek advise for that.

Mustafa Ekşi (1):
platform/x86: Add wmi driver for Casper Excalibur laptops

  MAINTAINERS                       |   6 +
  drivers/platform/x86/Kconfig      |  14 +
  drivers/platform/x86/Makefile     |   1 +
  drivers/platform/x86/casper-wmi.c | 641 ++++++++++++++++++++++++++++++
  4 files changed, 662 insertions(+)

create mode 100644 drivers/platform/x86/casper-wmi.c

#4 lore raw

v5 cover platform/x86: Add wmi driver for Casper Excalibur laptops

In reply to mustafa
Quoted 17 lines

From: Mustafa Ekşi <[email protected]>

Hi,
I want to note that moving mutex_init to the bottom of the function crashes the driver when mutex_lock is called. I didn't investigate it further but I wanted to say that since Ai Chao also did it like that.

Driver sets all leds to white on start. Before that, when a led's brightness is changed, that led's color gets set to white but others keep their old colors which creates a bad user experience (at least for me). Please inform me if this is a bad approach.
Also, this driver still lacks support for changing modes and I seek advise for that.

Mustafa Ekşi (1):
platform/x86: Add wmi driver for Casper Excalibur laptops

Quoted 7 lines
  MAINTAINERS                       |   6 +
  drivers/platform/x86/Kconfig      |  14 +
  drivers/platform/x86/Makefile     |   1 +
  drivers/platform/x86/casper-wmi.c | 641 ++++++++++++++++++++++++++++++
  4 files changed, 662 insertions(+)

create mode 100644 drivers/platform/x86/casper-wmi.c

Hi there,

I just wanted to pitch in by testing the driver on the kernel I use on my Arch install on an Excalibur G770.1245, namely xdevs23's linux-nitrous (https://gitlab.com/xdevs23/linux-nitrous), but trying to compile the driver using LLVM, which is the default compilation behavior in this kernel's AUR package, spits out the following error;

```
drivers/platform/x86/casper-wmi.c:633:3: error: field designator 'no_singleton' does not refer to any field in type 'struct wmi_driver'
  633 |         .no_singleton = true,
      |         ~^~~~~~~~~~~~~~~~~~~
1 error generated.
make[5]: *** [scripts/Makefile.build:243: drivers/platform/x86/casper-wmi.o] Error 1
make[4]: *** [scripts/Makefile.build:481: drivers/platform/x86] Error 2
make[3]: *** [scripts/Makefile.build:481: drivers/platform] Error 2
make[2]: *** [scripts/Makefile.build:481: drivers] Error 2
make[1]: *** [/home/stella/.cache/yay/linux-nitrous/src/linux-nitrous/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
```

I want to help debug this somehow, but I'm more of an Android custom ROM developer than a Linux kernel maintainer, so my knowledge on the programming and build system languages other than Java, Makefile, Bash, etc is pretty much limited if not outright non-existent.

I would *love* to see this driver actually hit mainline repos, and eventually the upcoming kernel releases, given how much I need to use this laptop of mine as a computer engineering student.

Asking just for the case I manage to get this driver up and going on my end somehow: Is there a tool made for controlling the LED colors yet? I can still use CLI tools much like on ASUS ROG series laptops, but it would be much easier and more appreciated to have a GUI provided Excalibur series laptops' LED lights can virtually take any color in the RGB space - At least that's how I interpreted with the configurations I used to do on mine using Excalibur Control Center on Windows 10/11.

And as for the profiles, let me make sure we're talking about the same thing in this term: You're talking about the "Office", "Gaming" and "High Performance" modes as seen in Excalibur Control Center, right? If so, can this be somehow integrated into power-profiles-daemon SystemD service for easier controlling with GNOME and other DEs that use it? It's fine if it can't be, this was just a thought struck on my mind for whatever reason.

Please do CC me and the people I've added to the CC list with this email of mine on the upcoming revisions, if any. We would love to keep track of this driver and I personally would love to contribute into testing as a power user.

Cc Alviro Iskandar Setiawan <[email protected]>
Cc Ammar Faizi <[email protected]>
Cc GNU/Weeb Mailing List <[email protected]>

Also adding my organizational and school email addresses to the CC list so I can still be notified while I stay offline on this email address. GNOME Evolution doesn't run in the background and periodically check for emails sadly, and I switch ROMs every now and then on my phone as a source maintainer of 3 different custom ROMs. :/

Cc Stella Bloom <[email protected]>
Cc Bedirhan KURT <[email protected]>

--
Stella Bloom

#5 lore raw
Quoted 44 lines · Stella Bloom
Quoted 17 lines

From: Mustafa Ekşi <[email protected]>

Hi,
I want to note that moving mutex_init to the bottom of the function crashes the driver when mutex_lock is called. I didn't investigate it further but I wanted to say that since Ai Chao also did it like that.

Driver sets all leds to white on start. Before that, when a led's brightness is changed, that led's color gets set to white but others keep their old colors which creates a bad user experience (at least for me). Please inform me if this is a bad approach.
Also, this driver still lacks support for changing modes and I seek advise for that.

Mustafa Ekşi (1):
platform/x86: Add wmi driver for Casper Excalibur laptops

Quoted 7 lines
  MAINTAINERS                       |   6 +
  drivers/platform/x86/Kconfig      |  14 +
  drivers/platform/x86/Makefile     |   1 +
  drivers/platform/x86/casper-wmi.c | 641 ++++++++++++++++++++++++++++++
  4 files changed, 662 insertions(+)

create mode 100644 drivers/platform/x86/casper-wmi.c

Hi there,

I just wanted to pitch in by testing the driver on the kernel I use on my Arch install on an Excalibur G770.1245, namely xdevs23's linux-nitrous (https://gitlab.com/xdevs23/linux-nitrous), but trying to compile the driver using LLVM, which is the default compilation behavior in this kernel's AUR package, spits out the following error;

```
drivers/platform/x86/casper-wmi.c:633:3: error: field designator 'no_singleton' does not refer to any field in type 'struct wmi_driver'
  633 |         .no_singleton = true,
      |         ~^~~~~~~~~~~~~~~~~~~
1 error generated.
make[5]: *** [scripts/Makefile.build:243: drivers/platform/x86/casper-wmi.o] Error 1
make[4]: *** [scripts/Makefile.build:481: drivers/platform/x86] Error 2
make[3]: *** [scripts/Makefile.build:481: drivers/platform] Error 2
make[2]: *** [scripts/Makefile.build:481: drivers] Error 2
make[1]: *** [/home/stella/.cache/yay/linux-nitrous/src/linux-nitrous/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
```
Quoted 4 lines

I want to help debug this somehow, but I'm more of an Android custom ROM developer than a Linux kernel maintainer, so my knowledge on the programming and build system languages other than Java, Makefile, Bash, etc is pretty much limited if not outright non-existent.

Hi,
This is because of a newly merged patch from Armin Wolf:
https://lore.kernel.org/platform-driver-x86/[email protected]/
You can comment that line or apply that patch to your tree to make it compile. Also, you'll probablyneed to change the call to wmidev_block_set in casper_query function with wmi_set_block (which is now deprecated).

Quoted 4 lines

I would *love* to see this driver actually hit mainline repos, and eventually the upcoming kernel releases, given how much I need to use this laptop of mine as a computer engineering student.

Quoted 8 lines

Asking just for the case I manage to get this driver up and going on my end somehow: Is there a tool made for controlling the LED colors yet? I can still use CLI tools much like on ASUS ROG series laptops, but it would be much easier and more appreciated to have a GUI provided Excalibur series laptops' LED lights can virtually take any color in the RGB space - At least that's how I interpreted with the configurations I used to do on mine using Excalibur Control Center on Windows 10/11.

No, there isn't a tool yet but controlling leds via sysfs ispretty easy. For example, if you wanted to change the left led zone's color to red:

```
# echo 0xff0000 > /sys/class/leds/casper\:\:kbd_zoned_backlight-left/multi_intensity
```

And don't forget that all leds' initial brightnesses are 0. Also, I'm planning to add support for this API in OpenRGB.

Quoted 3 lines

And as for the profiles, let me make sure we're talking about the same thing in this term: You're talking about the "Office", "Gaming" and "High Performance" modes as seen in Excalibur Control Center, right?

For laptops with 11th gen processors or newer: yes.
For laptops with 10th gen processors or older: no, there are 4 power profiles for these laptops (High Performance, Gaming, Text Mode andPower save).

Quoted 4 lines

If so, can this be somehow integrated into power-profiles-daemon SystemD service for easier controlling with GNOME and other DEs that use it? It's fine if it can't be, this was just a thought struck on my mind for whatever reason.

Yes, power-profiles-daemon is already integrated with platform_profile.

Quoted 15 lines

Please do CC me and the people I've added to the CC list with this email of mine on the upcoming revisions, if any. We would love to keep track of this driver and I personally would love to contribute into testing as a power user.

Cc Alviro Iskandar Setiawan <[email protected]>
Cc Ammar Faizi <[email protected]>
Cc GNU/Weeb Mailing List <[email protected]>

Also adding my organizational and school email addresses to the CC list so I can still be notified while I stay offline on this email address. GNOME Evolution doesn't run in the background and periodically check for emails sadly, and I switch ROMs every now and then on my phone as a source maintainer of 3 different custom ROMs. :/

Quoted 5 lines
Cc Stella Bloom <[email protected]>
Cc Bedirhan KURT <[email protected]>

--
Stella Bloom

Thanks for your interest,
Mustafa Ekşi

#7 lore raw
In reply to Mustafa Ekşi
Quoted 49 lines · Mustafa Ekşi
Quoted 44 lines · Stella Bloom
Quoted 17 lines

From: Mustafa Ekşi <[email protected]>

Hi,
I want to note that moving mutex_init to the bottom of the function crashes the driver when mutex_lock is called. I didn't investigate it further but I wanted to say that since Ai Chao also did it like that.

Driver sets all leds to white on start. Before that, when a led's brightness is changed, that led's color gets set to white but others keep their old colors which creates a bad user experience (at least for me). Please inform me if this is a bad approach.
Also, this driver still lacks support for changing modes and I seek advise for that.

Mustafa Ekşi (1):
platform/x86: Add wmi driver for Casper Excalibur laptops

Quoted 7 lines
  MAINTAINERS                       |   6 +
  drivers/platform/x86/Kconfig      |  14 +
  drivers/platform/x86/Makefile     |   1 +
  drivers/platform/x86/casper-wmi.c | 641 ++++++++++++++++++++++++++++++
  4 files changed, 662 insertions(+)

create mode 100644 drivers/platform/x86/casper-wmi.c

Hi there,

I just wanted to pitch in by testing the driver on the kernel I use on my Arch install on an Excalibur G770.1245, namely xdevs23's linux-nitrous (https://gitlab.com/xdevs23/linux-nitrous), but trying to compile the driver using LLVM, which is the default compilation behavior in this kernel's AUR package, spits out the following error;

```
drivers/platform/x86/casper-wmi.c:633:3: error: field designator 'no_singleton' does not refer to any field in type 'struct wmi_driver'
  633 |         .no_singleton = true,
      |         ~^~~~~~~~~~~~~~~~~~~
1 error generated.
make[5]: *** [scripts/Makefile.build:243: drivers/platform/x86/casper-wmi.o] Error 1
make[4]: *** [scripts/Makefile.build:481: drivers/platform/x86] Error 2
make[3]: *** [scripts/Makefile.build:481: drivers/platform] Error 2
make[2]: *** [scripts/Makefile.build:481: drivers] Error 2
make[1]: *** [/home/stella/.cache/yay/linux-nitrous/src/linux-nitrous/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
```
Quoted 4 lines

I want to help debug this somehow, but I'm more of an Android custom ROM developer than a Linux kernel maintainer, so my knowledge on the programming and build system languages other than Java, Makefile, Bash, etc is pretty much limited if not outright non-existent.

Quoted 6 lines

Hi,
This is because of a newly merged patch from Armin Wolf:
https://lore.kernel.org/platform-driver-x86/[email protected]/
You can comment that line or apply that patch to your tree to make it compile. Also, you'll probablyneed to change the call to wmidev_block_set in casper_query function with wmi_set_block (which is now deprecated).

Well, I prefer not to touch the driver itself, so I already resorted to picking the patch over the latest RC, which is v6.9-rc2 as of now, and got onto compiling linux-mainline AUR package with it. It will be kind of a hassle considering how I have to write systemd-boot entries after the installation to get the kernel to appear (one for normal initramfs and the other for fallback one) and sign the kernel image using sbctl so I don't fail secure boot, but I'm willing to go through it just for the sake of seeing this driver in action without bugs related to the "backport" modifications I would do to it.

Quoted 12 lines
Quoted 4 lines

I would *love* to see this driver actually hit mainline repos, and eventually the upcoming kernel releases, given how much I need to use this laptop of mine as a computer engineering student.

Quoted 8 lines

Asking just for the case I manage to get this driver up and going on my end somehow: Is there a tool made for controlling the LED colors yet? I can still use CLI tools much like on ASUS ROG series laptops, but it would be much easier and more appreciated to have a GUI provided Excalibur series laptops' LED lights can virtually take any color in the RGB space - At least that's how I interpreted with the configurations I used to do on mine using Excalibur Control Center on Windows 10/11.

Quoted 5 lines

No, there isn't a tool yet but controlling leds via sysfs ispretty easy. For example, if you wanted to change the left led zone's color to red:

```
# echo 0xff0000 > /sys/class/leds/casper\:\:kbd_zoned_backlight-left/multi_intensity
```

Oh so the LED zones are in different sysfs directories, that's pretty good. I might code a simple Bash script to make things easier later down the road.

Quoted 1 line

And don't forget that all leds' initial brightnesses are 0.

Yeah I think I read that somewhere in the initial message. Can't I change the brightness of the LEDs using Fn+Space anyway if I can't find the sysfs entries for that? At least it works just fine on the latest stable release - v6.8.4.

Quoted 1 line

Also, I'm planning to add support for this API in OpenRGB.

That's pretty nice to hear! If you need someone to test it out on a 12th gen G770, I'm more than willing to do so!

Quoted 7 lines
Quoted 3 lines

And as for the profiles, let me make sure we're talking about the same thing in this term: You're talking about the "Office", "Gaming" and "High Performance" modes as seen in Excalibur Control Center, right?

For laptops with 11th gen processors or newer: yes.
For laptops with 10th gen processors or older: no, there are 4 power profiles for these laptops (High Performance, Gaming, Text Mode andPower save).

Oh so that's a yes in my case as my laptop has a 12th gen processor. Glad to know.

Quoted 5 lines
Quoted 4 lines

If so, can this be somehow integrated into power-profiles-daemon SystemD service for easier controlling with GNOME and other DEs that use it? It's fine if it can't be, this was just a thought struck on my mind for whatever reason.

Yes, power-profiles-daemon is already integrated with platform_profile.

Now that's exciting to hear. I haven't seen a laptop that has its power profiles integrated into the system with a driver in terms of Linux... At least on the Monster and ASUS laptops I've tried Ubuntu on IIRC.

Quoted 15 lines
Quoted 15 lines

Please do CC me and the people I've added to the CC list with this email of mine on the upcoming revisions, if any. We would love to keep track of this driver and I personally would love to contribute into testing as a power user.

Cc Alviro Iskandar Setiawan <[email protected]>
Cc Ammar Faizi <[email protected]>
Cc GNU/Weeb Mailing List <[email protected]>

Also adding my organizational and school email addresses to the CC list so I can still be notified while I stay offline on this email address. GNOME Evolution doesn't run in the background and periodically check for emails sadly, and I switch ROMs every now and then on my phone as a source maintainer of 3 different custom ROMs. :/

Quoted 7 lines
Quoted 5 lines
Cc Stella Bloom <[email protected]>
Cc Bedirhan KURT <[email protected]>

--
Stella Bloom

Thanks for your interest,
Mustafa Ekşi

Also I apologize for the previous (empty) email. I forgot to put one newline after the "Subject" line, which caused git-send-email to not pick up the email content.

--
Stella Bloom

#8 lore raw

Am 08.04.24 um 18:13 schrieb Stella Bloom:

Quoted 56 lines · Mustafa Ekşi
Quoted 49 lines · Stella Bloom
Quoted 44 lines
Quoted 17 lines

From: Mustafa Ekşi <[email protected]>

Hi,
I want to note that moving mutex_init to the bottom of the function crashes the driver when mutex_lock is called. I didn't investigate it further but I wanted to say that since Ai Chao also did it like that.

Driver sets all leds to white on start. Before that, when a led's brightness is changed, that led's color gets set to white but others keep their old colors which creates a bad user experience (at least for me). Please inform me if this is a bad approach.
Also, this driver still lacks support for changing modes and I seek advise for that.

Mustafa Ekşi (1):
platform/x86: Add wmi driver for Casper Excalibur laptops

Quoted 7 lines
   MAINTAINERS                       |   6 +
   drivers/platform/x86/Kconfig      |  14 +
   drivers/platform/x86/Makefile     |   1 +
   drivers/platform/x86/casper-wmi.c | 641 ++++++++++++++++++++++++++++++
   4 files changed, 662 insertions(+)

create mode 100644 drivers/platform/x86/casper-wmi.c

Hi there,

I just wanted to pitch in by testing the driver on the kernel I use on my Arch install on an Excalibur G770.1245, namely xdevs23's linux-nitrous (https://gitlab.com/xdevs23/linux-nitrous), but trying to compile the driver using LLVM, which is the default compilation behavior in this kernel's AUR package, spits out the following error;

```
drivers/platform/x86/casper-wmi.c:633:3: error: field designator 'no_singleton' does not refer to any field in type 'struct wmi_driver'
   633 |         .no_singleton = true,
       |         ~^~~~~~~~~~~~~~~~~~~
1 error generated.
make[5]: *** [scripts/Makefile.build:243: drivers/platform/x86/casper-wmi.o] Error 1
make[4]: *** [scripts/Makefile.build:481: drivers/platform/x86] Error 2
make[3]: *** [scripts/Makefile.build:481: drivers/platform] Error 2
make[2]: *** [scripts/Makefile.build:481: drivers] Error 2
make[1]: *** [/home/stella/.cache/yay/linux-nitrous/src/linux-nitrous/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
```
Quoted 4 lines

I want to help debug this somehow, but I'm more of an Android custom ROM developer than a Linux kernel maintainer, so my knowledge on the programming and build system languages other than Java, Makefile, Bash, etc is pretty much limited if not outright non-existent.

Quoted 6 lines

Hi,
This is because of a newly merged patch from Armin Wolf:
https://lore.kernel.org/platform-driver-x86/[email protected]/
You can comment that line or apply that patch to your tree to make it compile. Also, you'll probablyneed to change the call to wmidev_block_set in casper_query function with wmi_set_block (which is now deprecated).

Quoted 9 lines

Well, I prefer not to touch the driver itself, so I already resorted to picking the patch over the latest RC, which is v6.9-rc2 as of now, and got onto compiling linux-mainline AUR package with it. It will be kind of a hassle considering how I have to write systemd-boot entries after the installation to get the kernel to appear (one for normal initramfs and the other for fallback one) and sign the kernel image using sbctl so I don't fail secure boot, but I'm willing to go through it just for the sake of seeing this driver in action without bugs related to the "backport" modifications I would do to it.

Hi,

if you use kernel 6.9-rc2, then wmidev_block_set() is already available, so you do not have to change that.

You just have to comment out the line with the no_singleton flag, then the driver should work.

Thanks,
Armin Wolf

Quoted 74 lines
Quoted 12 lines
Quoted 4 lines

I would *love* to see this driver actually hit mainline repos, and eventually the upcoming kernel releases, given how much I need to use this laptop of mine as a computer engineering student.

Quoted 8 lines

Asking just for the case I manage to get this driver up and going on my end somehow: Is there a tool made for controlling the LED colors yet? I can still use CLI tools much like on ASUS ROG series laptops, but it would be much easier and more appreciated to have a GUI provided Excalibur series laptops' LED lights can virtually take any color in the RGB space - At least that's how I interpreted with the configurations I used to do on mine using Excalibur Control Center on Windows 10/11.

Quoted 5 lines

No, there isn't a tool yet but controlling leds via sysfs ispretty easy. For example, if you wanted to change the left led zone's color to red:

```
# echo 0xff0000 > /sys/class/leds/casper\:\:kbd_zoned_backlight-left/multi_intensity
```

Oh so the LED zones are in different sysfs directories, that's pretty good. I might code a simple Bash script to make things easier later down the road.

Quoted 1 line

And don't forget that all leds' initial brightnesses are 0.

Yeah I think I read that somewhere in the initial message. Can't I change the brightness of the LEDs using Fn+Space anyway if I can't find the sysfs entries for that? At least it works just fine on the latest stable release - v6.8.4.

Quoted 1 line

Also, I'm planning to add support for this API in OpenRGB.

That's pretty nice to hear! If you need someone to test it out on a 12th gen G770, I'm more than willing to do so!

Quoted 7 lines
Quoted 3 lines

And as for the profiles, let me make sure we're talking about the same thing in this term: You're talking about the "Office", "Gaming" and "High Performance" modes as seen in Excalibur Control Center, right?

For laptops with 11th gen processors or newer: yes.
For laptops with 10th gen processors or older: no, there are 4 power profiles for these laptops (High Performance, Gaming, Text Mode andPower save).

Oh so that's a yes in my case as my laptop has a 12th gen processor. Glad to know.

Quoted 5 lines
Quoted 4 lines

If so, can this be somehow integrated into power-profiles-daemon SystemD service for easier controlling with GNOME and other DEs that use it? It's fine if it can't be, this was just a thought struck on my mind for whatever reason.

Yes, power-profiles-daemon is already integrated with platform_profile.

Now that's exciting to hear. I haven't seen a laptop that has its power profiles integrated into the system with a driver in terms of Linux... At least on the Monster and ASUS laptops I've tried Ubuntu on IIRC.

Quoted 15 lines
Quoted 15 lines

Please do CC me and the people I've added to the CC list with this email of mine on the upcoming revisions, if any. We would love to keep track of this driver and I personally would love to contribute into testing as a power user.

Cc Alviro Iskandar Setiawan <[email protected]>
Cc Ammar Faizi <[email protected]>
Cc GNU/Weeb Mailing List <[email protected]>

Also adding my organizational and school email addresses to the CC list so I can still be notified while I stay offline on this email address. GNOME Evolution doesn't run in the background and periodically check for emails sadly, and I switch ROMs every now and then on my phone as a source maintainer of 3 different custom ROMs. :/

Quoted 7 lines
Quoted 5 lines
Cc Stella Bloom <[email protected]>
Cc Bedirhan KURT <[email protected]>

--
Stella Bloom

Thanks for your interest,
Mustafa Ekşi

Also I apologize for the previous (empty) email. I forgot to put one newline after the "Subject" line, which caused git-send-email to not pick up the email content.

--
Stella Bloom

#9 lore raw
Quoted 68 lines

Am 08.04.24 um 18:13 schrieb Stella Bloom:

Quoted 56 lines · Mustafa Ekşi
Quoted 49 lines · Stella Bloom
Quoted 44 lines
Quoted 17 lines

From: Mustafa Ekşi <[email protected]>

Hi,
I want to note that moving mutex_init to the bottom of the function crashes the driver when mutex_lock is called. I didn't investigate it further but I wanted to say that since Ai Chao also did it like that.

Driver sets all leds to white on start. Before that, when a led's brightness is changed, that led's color gets set to white but others keep their old colors which creates a bad user experience (at least for me). Please inform me if this is a bad approach.
Also, this driver still lacks support for changing modes and I seek advise for that.

Mustafa Ekşi (1):
platform/x86: Add wmi driver for Casper Excalibur laptops

Quoted 7 lines
   MAINTAINERS                       |   6 +
   drivers/platform/x86/Kconfig      |  14 +
   drivers/platform/x86/Makefile     |   1 +
   drivers/platform/x86/casper-wmi.c | 641 ++++++++++++++++++++++++++++++
   4 files changed, 662 insertions(+)

create mode 100644 drivers/platform/x86/casper-wmi.c

Hi there,

I just wanted to pitch in by testing the driver on the kernel I use on my Arch install on an Excalibur G770.1245, namely xdevs23's linux-nitrous (https://gitlab.com/xdevs23/linux-nitrous), but trying to compile the driver using LLVM, which is the default compilation behavior in this kernel's AUR package, spits out the following error;

```
drivers/platform/x86/casper-wmi.c:633:3: error: field designator 'no_singleton' does not refer to any field in type 'struct wmi_driver'
   633 |         .no_singleton = true,
       |         ~^~~~~~~~~~~~~~~~~~~
1 error generated.
make[5]: *** [scripts/Makefile.build:243: drivers/platform/x86/casper-wmi.o] Error 1
make[4]: *** [scripts/Makefile.build:481: drivers/platform/x86] Error 2
make[3]: *** [scripts/Makefile.build:481: drivers/platform] Error 2
make[2]: *** [scripts/Makefile.build:481: drivers] Error 2
make[1]: *** [/home/stella/.cache/yay/linux-nitrous/src/linux-nitrous/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
```
Quoted 4 lines

I want to help debug this somehow, but I'm more of an Android custom ROM developer than a Linux kernel maintainer, so my knowledge on the programming and build system languages other than Java, Makefile, Bash, etc is pretty much limited if not outright non-existent.

Quoted 6 lines

Hi,
This is because of a newly merged patch from Armin Wolf:
https://lore.kernel.org/platform-driver-x86/[email protected]/
You can comment that line or apply that patch to your tree to make it compile. Also, you'll probablyneed to change the call to wmidev_block_set in casper_query function with wmi_set_block (which is now deprecated).

Quoted 9 lines

Well, I prefer not to touch the driver itself, so I already resorted to picking the patch over the latest RC, which is v6.9-rc2 as of now, and got onto compiling linux-mainline AUR package with it. It will be kind of a hassle considering how I have to write systemd-boot entries after the installation to get the kernel to appear (one for normal initramfs and the other for fallback one) and sign the kernel image using sbctl so I don't fail secure boot, but I'm willing to go through it just for the sake of seeing this driver in action without bugs related to the "backport" modifications I would do to it.

Quoted 7 lines

Hi,

if you use kernel 6.9-rc2, then wmidev_block_set() is already available, so you do not have to change that.

You just have to comment out the line with the no_singleton flag, then the driver should work.

Hi,

Thanks for letting me know of that. I'm doing the change locally right away.

Quoted 76 lines

Thanks,
Armin Wolf

Quoted 73 lines
Quoted 12 lines
Quoted 4 lines

I would *love* to see this driver actually hit mainline repos, and eventually the upcoming kernel releases, given how much I need to use this laptop of mine as a computer engineering student.

Quoted 8 lines

Asking just for the case I manage to get this driver up and going on my end somehow: Is there a tool made for controlling the LED colors yet? I can still use CLI tools much like on ASUS ROG series laptops, but it would be much easier and more appreciated to have a GUI provided Excalibur series laptops' LED lights can virtually take any color in the RGB space - At least that's how I interpreted with the configurations I used to do on mine using Excalibur Control Center on Windows 10/11.

Quoted 5 lines

No, there isn't a tool yet but controlling leds via sysfs ispretty easy. For example, if you wanted to change the left led zone's color to red:

```
# echo 0xff0000 > /sys/class/leds/casper\:\:kbd_zoned_backlight-left/multi_intensity
```

Oh so the LED zones are in different sysfs directories, that's pretty good. I might code a simple Bash script to make things easier later down the road.

Quoted 1 line

And don't forget that all leds' initial brightnesses are 0.

Yeah I think I read that somewhere in the initial message. Can't I change the brightness of the LEDs using Fn+Space anyway if I can't find the sysfs entries for that? At least it works just fine on the latest stable release - v6.8.4.

Quoted 1 line

Also, I'm planning to add support for this API in OpenRGB.

That's pretty nice to hear! If you need someone to test it out on a 12th gen G770, I'm more than willing to do so!

Quoted 7 lines
Quoted 3 lines

And as for the profiles, let me make sure we're talking about the same thing in this term: You're talking about the "Office", "Gaming" and "High Performance" modes as seen in Excalibur Control Center, right?

For laptops with 11th gen processors or newer: yes.
For laptops with 10th gen processors or older: no, there are 4 power profiles for these laptops (High Performance, Gaming, Text Mode andPower save).

Oh so that's a yes in my case as my laptop has a 12th gen processor. Glad to know.

Quoted 5 lines
Quoted 4 lines

If so, can this be somehow integrated into power-profiles-daemon SystemD service for easier controlling with GNOME and other DEs that use it? It's fine if it can't be, this was just a thought struck on my mind for whatever reason.

Yes, power-profiles-daemon is already integrated with platform_profile.

Now that's exciting to hear. I haven't seen a laptop that has its power profiles integrated into the system with a driver in terms of Linux... At least on the Monster and ASUS laptops I've tried Ubuntu on IIRC.

Quoted 15 lines
Quoted 15 lines

Please do CC me and the people I've added to the CC list with this email of mine on the upcoming revisions, if any. We would love to keep track of this driver and I personally would love to contribute into testing as a power user.

Cc Alviro Iskandar Setiawan <[email protected]>
Cc Ammar Faizi <[email protected]>
Cc GNU/Weeb Mailing List <[email protected]>

Also adding my organizational and school email addresses to the CC list so I can still be notified while I stay offline on this email address. GNOME Evolution doesn't run in the background and periodically check for emails sadly, and I switch ROMs every now and then on my phone as a source maintainer of 3 different custom ROMs. :/

Quoted 7 lines
Quoted 5 lines
Cc Stella Bloom <[email protected]>
Cc Bedirhan KURT <[email protected]>
Signature · 1 line
Stella Bloom

Thanks for your interest,
Mustafa Ekşi

Also I apologize for the previous (empty) email. I forgot to put one newline after the "Subject" line, which caused git-send-email to not pick up the email content.

Signature · 1 line
Stella Bloom

--
Stella Bloom