Skip to contentSkip to conversation

platform/x86/tuxedo: Add virtual LampArray for TUXEDO NB04 devices

PATCH In review Werner Sembach 3 participants 8 messages Apr 25, 2025 – May 7, 2025

Subsystems (3)
lore
Share & tools
lore

Werner Sembach

author maintainer
#0 lore raw

v9 cover platform/x86/tuxedo: Add virtual LampArray for TUXEDO NB04 devices

Note that I'm away from my work PC for the next week so expect my next response the monday after.

v2: - Integrated Armins feedback and fixed kernel test robot warnings.
v3: - Fixed borked subject line of v2.
v4: - Remove unrequired WMI mutex.
- Move device checking from probe to init.
- Fix device checking working exactly reverse as it should.
- Fix null pointer dereference because,
hdev->driver_data != hdev->dev.driver_data.
v5: - Move everything to subfolder nb04 in preparation for the eventual
upstreaming of other tuxedo-driver parts.
- Integrated Ilpos coding style feedback.
- Use dev_set/get_drvdata() based on Armins feedback.
v6: - Integrated more of Ilpo coding style feedback from a different LKML
patch-thread (less files, local functions prefixed with a short string).
v7: - Integrated more of Ilpos feedback e.g.:
- Use cleanup.h
- replace some if cases with a pointer in driver_data
- coding style oversights
v8: - Integrated more of Ilpos feedback
- Typo fix spotted by Alok
v9: - Introduce lamp_rgbi_tuple_t to group some values
- Introduce LAMP_MULTI_UPDATE_REPORT_LAMP_COUNT_MAX to not manually set a fixed number at multiple places
- Move lamp_multi_update_report initialization in handle_lamp_range_update_report out of the loop again as a small performance optimization as the unused entries do not actually be zeroed (I mixed up the spec of this devices wmi interface and the HID spec)

Werner Sembach (1):
platform/x86/tuxedo: Add virtual LampArray for TUXEDO NB04 devices

 MAINTAINERS                                 |   6 +
 drivers/platform/x86/Kconfig                |   2 +
 drivers/platform/x86/Makefile               |   3 +
 drivers/platform/x86/tuxedo/Kconfig         |   8 +
 drivers/platform/x86/tuxedo/Makefile        |   8 +
 drivers/platform/x86/tuxedo/nb04/Kconfig    |  15 +
 drivers/platform/x86/tuxedo/nb04/Makefile   |  10 +
 drivers/platform/x86/tuxedo/nb04/wmi_ab.c   | 923 ++++++++++++++++++++
 drivers/platform/x86/tuxedo/nb04/wmi_util.c |  91 ++
 drivers/platform/x86/tuxedo/nb04/wmi_util.h | 109 +++
 10 files changed, 1175 insertions(+)
 create mode 100644 drivers/platform/x86/tuxedo/Kconfig
 create mode 100644 drivers/platform/x86/tuxedo/Makefile
 create mode 100644 drivers/platform/x86/tuxedo/nb04/Kconfig
 create mode 100644 drivers/platform/x86/tuxedo/nb04/Makefile
 create mode 100644 drivers/platform/x86/tuxedo/nb04/wmi_ab.c
 create mode 100644 drivers/platform/x86/tuxedo/nb04/wmi_util.c
 create mode 100644 drivers/platform/x86/tuxedo/nb04/wmi_util.h
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v9 1/1 platform/x86/tuxedo: Add virtual LampArray for TUXEDO NB04 devices

The TUXEDO Sirius 16 Gen1 and TUXEDO Sirius 16 Gen2 devices have a per-key controllable RGB keyboard backlight. The firmware API for it is implemented via WMI.

To make the backlight userspace configurable this driver emulates a LampArray HID device and translates the input from hidraw to the corresponding WMI calls. This is a new approach as the leds subsystem lacks a suitable UAPI for per-key keyboard backlights, and like this no new UAPI needs to be established.

The handle_* functions an corresponding structs are named based on the HID
spec: HID Usage Tables 1.6 -> 26 Lighting And Illumination Page (0x59)

---
 MAINTAINERS                                 |   6 +
 drivers/platform/x86/Kconfig                |   2 +
 drivers/platform/x86/Makefile               |   3 +
 drivers/platform/x86/tuxedo/Kconfig         |   8 +
 drivers/platform/x86/tuxedo/Makefile        |   8 +
 drivers/platform/x86/tuxedo/nb04/Kconfig    |  15 +
 drivers/platform/x86/tuxedo/nb04/Makefile   |  10 +
 drivers/platform/x86/tuxedo/nb04/wmi_ab.c   | 923 ++++++++++++++++++++
 drivers/platform/x86/tuxedo/nb04/wmi_util.c |  91 ++
 drivers/platform/x86/tuxedo/nb04/wmi_util.h | 109 +++
 10 files changed, 1175 insertions(+)
 create mode 100644 drivers/platform/x86/tuxedo/Kconfig
 create mode 100644 drivers/platform/x86/tuxedo/Makefile
 create mode 100644 drivers/platform/x86/tuxedo/nb04/Kconfig
 create mode 100644 drivers/platform/x86/tuxedo/nb04/Makefile
 create mode 100644 drivers/platform/x86/tuxedo/nb04/wmi_ab.c
 create mode 100644 drivers/platform/x86/tuxedo/nb04/wmi_util.c
 create mode 100644 drivers/platform/x86/tuxedo/nb04/wmi_util.h
MAINTAINERS +6 -0
index 00e94bec401e1..c1f7460c246ad 100644
@@ -24217,6 +24217,12 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git turbostat
 F:	tools/power/x86/turbostat/
 F:	tools/testing/selftests/turbostat/
 
+TUXEDO DRIVERS
+M:	Werner Sembach <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/platform/x86/tuxedo/
+
 TW5864 VIDEO4LINUX DRIVER
 M:	Bluecherry Maintainers <[email protected]>
 M:	Andrey Utkin <[email protected]>
drivers/platform/x86/Kconfig +2 -0
index 0258dd879d64b..58b258cde4fdb 100644
@@ -1186,6 +1186,8 @@ config SEL3350_PLATFORM
 	  To compile this driver as a module, choose M here: the module
 	  will be called sel3350-platform.
 
+source "drivers/platform/x86/tuxedo/Kconfig"
+
 endif # X86_PLATFORM_DEVICES
 
 config P2SB
drivers/platform/x86/Makefile +3 -0
index e1b1429470674..1562dcd7ad9a5 100644
@@ -153,3 +153,6 @@ obj-$(CONFIG_WINMATE_FM07_KEYS)		+= winmate-fm07-keys.o
 
 # SEL
 obj-$(CONFIG_SEL3350_PLATFORM)		+= sel3350-platform.o
+
+# TUXEDO
+obj-y					+= tuxedo/
drivers/platform/x86/tuxedo/Kconfig new file +8 -0
new file mode 100644
index 0000000000000..80be0947dddc4
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2024-2025 Werner Sembach [email protected]
+#
+# TUXEDO X86 Platform Specific Drivers
+#
+
+source "drivers/platform/x86/tuxedo/nb04/Kconfig"
drivers/platform/x86/tuxedo/Makefile new file +8 -0
new file mode 100644
index 0000000000000..0afe0d0f455e7
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2024-2025 Werner Sembach [email protected]
+#
+# TUXEDO X86 Platform Specific Drivers
+#
+
+obj-y	+= nb04/
drivers/platform/x86/tuxedo/nb04/Kconfig new file +15 -0
new file mode 100644
index 0000000000000..411c46c9a1cf0
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2024-2025 Werner Sembach [email protected]
+#
+# TUXEDO X86 Platform Specific Drivers
+#
+
+config TUXEDO_NB04_WMI_AB
+	tristate "TUXEDO NB04 WMI AB Platform Driver"
+	help
+	  This driver implements the WMI AB device found on TUXEDO notebooks
+	  with board vendor NB04. This enables keyboard backlight control via a
+	  virtual HID LampArray device.
+
+	  When compiled as a module it will be called tuxedo_nb04_wmi_ab.
drivers/platform/x86/tuxedo/nb04/Makefile new file +10 -0
new file mode 100644
index 0000000000000..c963e0d605057
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2024-2025 Werner Sembach [email protected]
+#
+# TUXEDO X86 Platform Specific Drivers
+#
+
+tuxedo_nb04_wmi_ab-y			:= wmi_ab.o
+tuxedo_nb04_wmi_ab-y			+= wmi_util.o
+obj-$(CONFIG_TUXEDO_NB04_WMI_AB)	+= tuxedo_nb04_wmi_ab.o
drivers/platform/x86/tuxedo/nb04/wmi_ab.c new file +923 -0

923 lines not on this page · raw message

drivers/platform/x86/tuxedo/nb04/wmi_util.c new file +91 -0

91 lines not on this page · raw message

drivers/platform/x86/tuxedo/nb04/wmi_util.h new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw
In reply to Werner Sembach
Quoted 2 lines · Werner Sembach

Note that I'm away from my work PC for the next week so expect my next response the monday after.

Forgot to cc LED lists. NAK.
Pavel

Signature · 2 lines
I don't work for Nazis and criminals, and neither should you.
Boycott Putin, Trump, and Musk!
author maintainer
#3 lore raw

Hi,

Am 26.04.25 um 10:21 schrieb Pavel Machek:

Quoted 5 lines · Werner Sembach
Quoted 2 lines

Note that I'm away from my work PC for the next week so expect my next response the monday after.

Forgot to cc LED lists. NAK.
Pavel

This patch does not touch the led subsystem in any way. It implements a part of the HID standard only.

Best regards,

Werner

maintainer
#4 lore raw
In reply to Werner Sembach
Quoted 32 lines · Werner Sembach

Note that I'm away from my work PC for the next week so expect my next response the monday after.

v2: - Integrated Armins feedback and fixed kernel test robot warnings.
v3: - Fixed borked subject line of v2.
v4: - Remove unrequired WMI mutex.
- Move device checking from probe to init.
- Fix device checking working exactly reverse as it should.
- Fix null pointer dereference because,
hdev->driver_data != hdev->dev.driver_data.
v5: - Move everything to subfolder nb04 in preparation for the eventual
upstreaming of other tuxedo-driver parts.
- Integrated Ilpos coding style feedback.
- Use dev_set/get_drvdata() based on Armins feedback.
v6: - Integrated more of Ilpo coding style feedback from a different LKML
patch-thread (less files, local functions prefixed with a short string).
v7: - Integrated more of Ilpos feedback e.g.:
- Use cleanup.h
- replace some if cases with a pointer in driver_data
- coding style oversights
v8: - Integrated more of Ilpos feedback
- Typo fix spotted by Alok
v9: - Introduce lamp_rgbi_tuple_t to group some values
- Introduce LAMP_MULTI_UPDATE_REPORT_LAMP_COUNT_MAX to not manually set a fixed number at multiple places
- Move lamp_multi_update_report initialization in handle_lamp_range_update_report out of the loop again as a small performance optimization as the unused entries do not actually be zeroed (I mixed up the spec of this devices wmi interface and the HID spec)

Quoted 1 line

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86/tuxedo: Add virtual LampArray for TUXEDO NB04 devices

      commit: d430124bac586f9d4302ebf6a3146635539325d1

--
i.

#5 lore raw

Hi!

Quoted 4 lines

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

Can I ask you to Cc me with the pull request when you'll send the patch upstream?

Thank you,
Pavel

Signature · 2 lines
I don't work for Nazis and criminals, and neither should you.
Boycott Putin, Trump, and Musk!
maintainer
#6 lore raw
Quoted 7 lines · Pavel Machek
Quoted 4 lines

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

Can I ask you to Cc me with the pull request when you'll send the patch upstream?

Hi Pavel,

To not forget your request, I've temporarily added you to the Cc list of any PRs I'm sending towards Linus.

This means you'll be Cc'ed the unrelated fixes PRs too but there shouldn't be that many of those until the next merge window (I'm sorry about the extra noise but I'd likely forget it otherwise). And if I forget to remove you afterwards the CC list and you keep getting PRs Cc'ed, please just sent me a note then.

Signature · 1 line
 i.
#7 lore raw

Hi!

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

Can I ask you to Cc me with the pull request when you'll send the patch upstream?

Hi Pavel,

Quoted 8 lines

To not forget your request, I've temporarily added you to the Cc list of any PRs I'm sending towards Linus.

This means you'll be Cc'ed the unrelated fixes PRs too but there shouldn't be that many of those until the next merge window (I'm sorry about the extra noise but I'd likely forget it otherwise). And if I forget to remove you afterwards the CC list and you keep getting PRs Cc'ed, please just sent me a note then.

That works for me. Thank you!

Best regards,
Pavel

Signature · 2 lines
I don't work for Nazis and criminals, and neither should you.
Boycott Putin, Trump, and Musk!