Skip to content

7.3: leds: macsmc: use kbd_backlight name and blocking brightness_set - #17

Open
smilegagarins-debug wants to merge 1 commit into
CachyOS:7.3/t2from
smilegagarins-debug:7.3/macsmc-kbd-backlight
Open

smilegagarins-debug wants to merge 1 commit into
CachyOS:7.3/t2from
smilegagarins-debug:7.3/macsmc-kbd-backlight

Conversation

@smilegagarins-debug

Copy link
Copy Markdown

The Intel macsmc series (Atharva Tiwari, "[RFC PATCH 00/14] Add macsmc support for Intel Macs, replacing applesmc", carried in 7.3/t2) registers the keyboard backlight as macsmc-led.

  • LED name: userspace finds keyboard backlights by the :kbd_backlight suffix required by Documentation/leds/leds-class.rst. With macsmc-led UPower reports max brightness 0, and the brightness controls in GNOME/KDE/COSMIC show NaN. Renamed to macsmc::kbd_backlight, like applesmc's smc::kbd_backlight.
  • Sleeping in brightness_set: apple_smc_write() takes the SMC mutex and the port backend polls, so it can sleep. Switched to brightness_set_blocking.
  • Error handling: the write result was ignored. It is now propagated, and the cached value only changes on success. The ACPI backend returns the byte count on success, so only ret < 0 counts as an error.

Tested on a MacBookAir7,2 with 7.3.0-4-cachyos. UPower now exposes the backlight (max 255), sysfs and UPower writes are applied, and the COSMIC battery applet slider works.

The same fix is being sent upstream as a review reply to RFC patch 06/14.

🤖 Generated with Claude Code

The keyboard backlight LED is registered as "macsmc-led". Userspace
(UPower, and through it GNOME, KDE and COSMIC) finds keyboard backlights
by the ":kbd_backlight" suffix required by
Documentation/leds/leds-class.rst, so the backlight is invisible to it:
UPower reports a maximum brightness of 0 and desktop applets show NaN.
Name the device "macsmc::kbd_backlight", as the old applesmc driver did
with "smc::kbd_backlight".

apple_smc_write() takes the SMC mutex and the port I/O backend polls the
status register, so it may sleep. It is called from the brightness_set
callback, which must not sleep. Use brightness_set_blocking instead and
propagate write errors, only updating the cached value on success. The
ACPI backend returns the number of bytes written on success, so treat
only negative values as errors.

Tested on MacBookAir7,2: UPower now exposes the backlight (max 255) and
brightness writes are applied.

Signed-off-by: 0fx0 <smilegagarins@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant