platform/x86: panasonic-laptop: Add sysfs attributes for firmware brightness registers
authorKenneth Chan <kenneth.t.chan@gmail.com>
Fri, 21 Aug 2020 18:14:33 +0000 (02:14 +0800)
committerHans de Goede <hdegoede@redhat.com>
Tue, 10 Nov 2020 13:49:50 +0000 (14:49 +0100)
commit25dd390c6206c3e0f9e0551fca030a5f909564eb
tree2ca05dd84ac89324ae7c61b8c4ff4bce8b1ffa2d
parent468f96bfa3a045450f54c96e63db786b0b5fcab2
platform/x86: panasonic-laptop: Add sysfs attributes for firmware brightness registers

Panasonic laptops (at least from CF-W4 onwards) have dedicated firmware
registers for saving ac/dc and current brightness. They are a bit confusing
so here's some explanations:

AC_MIN_BRIGHT, AC_MAX_BRIGHT, DC_MIN_BRIGHT, DC_MAX_BRIGHT:
Read-only. Values: 0x01 and 0x15 respectively.

AC_CUR_BRIGHT, DC_CUR_BRIGHT:
Read-Write. 0x00-0xFF. Store user-defined AC/DC brightness. However,
they do not represent current brightness so they should be named AC_BRIGHT
and DC_BRIGHT instead.

CUR_BRIGHT (present since CF-W4):
Read-Write. 0x00-0xFF. It sets the current brightness. It won't update
itself if brightness is changed via other means, e.g. acpi_video0.

Another CUR_BRIGHT (added since CF-W5):
Read-Write. 0x01-0x15. Its value always synchronizes with current
brightness. Not implemented in this version.

Currently the backlight API interacts with AC_CUR_BRIGHT (probably because
it's the only bl register available in earlier models?). This patch adds
sysfs attributes for AC_CUR_BRIGHT, DC_CUR_BRIGHT and CUR_BRIGHT.

It also fixes the error of https://lkml.org/lkml/2020/8/19/1264.

PS: I think the backlight API should interact with CUR_BRIGHT instead of
AC_CUR_BRIGHT. But it involves complications like mapping between 0x01-0x15
or 0x00-0x14 (the backlight API) and 0x00-0xFF (CUR_BRIGHT). I'll leave the
discussion for a later version.

Signed-off-by: Kenneth Chan <kenneth.t.chan@gmail.com>
Link: https://lore.kernel.org/r/20200821181433.17653-10-kenneth.t.chan@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/panasonic-laptop.c