diff mbox

[v6,2/4] platform/x86/thinkpad: Call led_classdev_notify_brightness_hw_changed on kbd brightness change

Message ID 20170125161130.5424-3-hdegoede@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Andy Shevchenko
Headers show

Commit Message

Hans de Goede Jan. 25, 2017, 4:11 p.m. UTC
Make thinkpad_acpi call led_classdev_notify_brightness_hw_changed on the
kbd_led led_classdev registered by thinkpad_acpi when the kbd backlight
brightness is changed through the hotkey.

This will allow userspace to monitor (poll) for brightness changes on
these LEDs caused by the hotkey.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v3:
-This is a new patch in v3 of this patch-set
Changes in v4:
-No changes
Changes in v5:
-Switch to new led-trigger based API for notifying userspace about
 keyboard backlight brightness changes.
-Also call ledtrig_kbd_backlight() for laptops with a thinklight
-Rename the hotkey defines from THINKLIGHT to KBD_LIGHT since they
 are shared between the thinklight and the keyboard backlight
Changes in v6:
-Switch to new brightness_hw_changed LED class API
---
 drivers/platform/x86/thinkpad_acpi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Andy Shevchenko Jan. 28, 2017, 1:36 p.m. UTC | #1
On Wed, Jan 25, 2017 at 6:11 PM, Hans de Goede <hdegoede@redhat.com> wrote:
> Make thinkpad_acpi call led_classdev_notify_brightness_hw_changed on the
> kbd_led led_classdev registered by thinkpad_acpi when the kbd backlight
> brightness is changed through the hotkey.
>
> This will allow userspace to monitor (poll) for brightness changes on
> these LEDs caused by the hotkey.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

I didn't see v7 of this and consequent patches. What's going on?

> ---
> Changes in v3:
> -This is a new patch in v3 of this patch-set
> Changes in v4:
> -No changes
> Changes in v5:
> -Switch to new led-trigger based API for notifying userspace about
>  keyboard backlight brightness changes.
> -Also call ledtrig_kbd_backlight() for laptops with a thinklight
> -Rename the hotkey defines from THINKLIGHT to KBD_LIGHT since they
>  are shared between the thinklight and the keyboard backlight
> Changes in v6:
> -Switch to new brightness_hw_changed LED class API
> ---
>  drivers/platform/x86/thinkpad_acpi.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index cacb43f..6249292 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -163,6 +163,7 @@ enum tpacpi_hkey_event_t {
>         TP_HKEY_EV_HOTKEY_BASE          = 0x1001, /* first hotkey (FN+F1) */
>         TP_HKEY_EV_BRGHT_UP             = 0x1010, /* Brightness up */
>         TP_HKEY_EV_BRGHT_DOWN           = 0x1011, /* Brightness down */
> +       TP_HKEY_EV_KBD_LIGHT            = 0x1012, /* Thinklight/kbd backlight */
>         TP_HKEY_EV_VOL_UP               = 0x1015, /* Volume up or unmute */
>         TP_HKEY_EV_VOL_DOWN             = 0x1016, /* Volume down or unmute */
>         TP_HKEY_EV_VOL_MUTE             = 0x1017, /* Mixer output mute */
> @@ -1959,7 +1960,7 @@ enum {    /* Positions of some of the keys in hotkey masks */
>         TP_ACPI_HKEY_HIBERNATE_MASK     = 1 << TP_ACPI_HOTKEYSCAN_FNF12,
>         TP_ACPI_HKEY_BRGHTUP_MASK       = 1 << TP_ACPI_HOTKEYSCAN_FNHOME,
>         TP_ACPI_HKEY_BRGHTDWN_MASK      = 1 << TP_ACPI_HOTKEYSCAN_FNEND,
> -       TP_ACPI_HKEY_THNKLGHT_MASK      = 1 << TP_ACPI_HOTKEYSCAN_FNPAGEUP,
> +       TP_ACPI_HKEY_KBD_LIGHT_MASK     = 1 << TP_ACPI_HOTKEYSCAN_FNPAGEUP,
>         TP_ACPI_HKEY_ZOOM_MASK          = 1 << TP_ACPI_HOTKEYSCAN_FNSPACE,
>         TP_ACPI_HKEY_VOLUP_MASK         = 1 << TP_ACPI_HOTKEYSCAN_VOLUMEUP,
>         TP_ACPI_HKEY_VOLDWN_MASK        = 1 << TP_ACPI_HOTKEYSCAN_VOLUMEDOWN,
> @@ -2344,7 +2345,7 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
>                 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY);
>                 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE);
>         }
> -       if (m & TP_ACPI_HKEY_THNKLGHT_MASK) {
> +       if (m & TP_ACPI_HKEY_KBD_LIGHT_MASK) {
>                 d = nvram_read_byte(TP_NVRAM_ADDR_THINKLIGHT);
>                 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT);
>         }
> @@ -5193,6 +5194,7 @@ static struct tpacpi_led_classdev tpacpi_led_kbdlight = {
>         .led_classdev = {
>                 .name           = "tpacpi::kbd_backlight",
>                 .max_brightness = 2,
> +               .flags          = LED_BRIGHT_HW_CHANGED,
>                 .brightness_set = &kbdlight_sysfs_set,
>                 .brightness_get = &kbdlight_sysfs_get,
>         }
> @@ -5222,6 +5224,8 @@ static int __init kbdlight_init(struct ibm_init_struct *iibm)
>                 return rc;
>         }
>
> +       tpacpi_hotkey_driver_mask_set(hotkey_driver_mask |
> +                                     TP_ACPI_HKEY_KBD_LIGHT_MASK);
>         return 0;
>  }
>
> @@ -9169,6 +9173,10 @@ static void tpacpi_driver_event(const unsigned int hkey_event)
>                         volume_alsa_notify_change();
>                 }
>         }
> +       if (tp_features.kbdlight && hkey_event == TP_HKEY_EV_KBD_LIGHT)
> +               led_classdev_notify_brightness_hw_changed(
> +                       &tpacpi_led_kbdlight.led_classdev,
> +                       kbdlight_sysfs_get(NULL));
>  }
>
>  static void hotkey_driver_event(const unsigned int scancode)
> --
> 2.9.3
>
Hans de Goede Jan. 28, 2017, 3:34 p.m. UTC | #2
Hi,

On 01/28/2017 02:36 PM, Andy Shevchenko wrote:
> On Wed, Jan 25, 2017 at 6:11 PM, Hans de Goede <hdegoede@redhat.com> wrote:
>> Make thinkpad_acpi call led_classdev_notify_brightness_hw_changed on the
>> kbd_led led_classdev registered by thinkpad_acpi when the kbd backlight
>> brightness is changed through the hotkey.
>>
>> This will allow userspace to monitor (poll) for brightness changes on
>> these LEDs caused by the hotkey.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>
> I didn't see v7 of this and consequent patches. What's going on?

As I said in the cover-letter of v6 the platform patches were mainly
there to document the usage of the new LED api. Since there were no
changes to the api I did not post a v7 of the platform/x86 patches,
also I've not yet tested the thinkpad changes as adjusted for the
new LED api.

Once the LED side is merged, I'll re-post the platform patches.

Regards,

Hans




>
>> ---
>> Changes in v3:
>> -This is a new patch in v3 of this patch-set
>> Changes in v4:
>> -No changes
>> Changes in v5:
>> -Switch to new led-trigger based API for notifying userspace about
>>  keyboard backlight brightness changes.
>> -Also call ledtrig_kbd_backlight() for laptops with a thinklight
>> -Rename the hotkey defines from THINKLIGHT to KBD_LIGHT since they
>>  are shared between the thinklight and the keyboard backlight
>> Changes in v6:
>> -Switch to new brightness_hw_changed LED class API
>> ---
>>  drivers/platform/x86/thinkpad_acpi.c | 12 ++++++++++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
>> index cacb43f..6249292 100644
>> --- a/drivers/platform/x86/thinkpad_acpi.c
>> +++ b/drivers/platform/x86/thinkpad_acpi.c
>> @@ -163,6 +163,7 @@ enum tpacpi_hkey_event_t {
>>         TP_HKEY_EV_HOTKEY_BASE          = 0x1001, /* first hotkey (FN+F1) */
>>         TP_HKEY_EV_BRGHT_UP             = 0x1010, /* Brightness up */
>>         TP_HKEY_EV_BRGHT_DOWN           = 0x1011, /* Brightness down */
>> +       TP_HKEY_EV_KBD_LIGHT            = 0x1012, /* Thinklight/kbd backlight */
>>         TP_HKEY_EV_VOL_UP               = 0x1015, /* Volume up or unmute */
>>         TP_HKEY_EV_VOL_DOWN             = 0x1016, /* Volume down or unmute */
>>         TP_HKEY_EV_VOL_MUTE             = 0x1017, /* Mixer output mute */
>> @@ -1959,7 +1960,7 @@ enum {    /* Positions of some of the keys in hotkey masks */
>>         TP_ACPI_HKEY_HIBERNATE_MASK     = 1 << TP_ACPI_HOTKEYSCAN_FNF12,
>>         TP_ACPI_HKEY_BRGHTUP_MASK       = 1 << TP_ACPI_HOTKEYSCAN_FNHOME,
>>         TP_ACPI_HKEY_BRGHTDWN_MASK      = 1 << TP_ACPI_HOTKEYSCAN_FNEND,
>> -       TP_ACPI_HKEY_THNKLGHT_MASK      = 1 << TP_ACPI_HOTKEYSCAN_FNPAGEUP,
>> +       TP_ACPI_HKEY_KBD_LIGHT_MASK     = 1 << TP_ACPI_HOTKEYSCAN_FNPAGEUP,
>>         TP_ACPI_HKEY_ZOOM_MASK          = 1 << TP_ACPI_HOTKEYSCAN_FNSPACE,
>>         TP_ACPI_HKEY_VOLUP_MASK         = 1 << TP_ACPI_HOTKEYSCAN_VOLUMEUP,
>>         TP_ACPI_HKEY_VOLDWN_MASK        = 1 << TP_ACPI_HOTKEYSCAN_VOLUMEDOWN,
>> @@ -2344,7 +2345,7 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
>>                 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY);
>>                 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE);
>>         }
>> -       if (m & TP_ACPI_HKEY_THNKLGHT_MASK) {
>> +       if (m & TP_ACPI_HKEY_KBD_LIGHT_MASK) {
>>                 d = nvram_read_byte(TP_NVRAM_ADDR_THINKLIGHT);
>>                 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT);
>>         }
>> @@ -5193,6 +5194,7 @@ static struct tpacpi_led_classdev tpacpi_led_kbdlight = {
>>         .led_classdev = {
>>                 .name           = "tpacpi::kbd_backlight",
>>                 .max_brightness = 2,
>> +               .flags          = LED_BRIGHT_HW_CHANGED,
>>                 .brightness_set = &kbdlight_sysfs_set,
>>                 .brightness_get = &kbdlight_sysfs_get,
>>         }
>> @@ -5222,6 +5224,8 @@ static int __init kbdlight_init(struct ibm_init_struct *iibm)
>>                 return rc;
>>         }
>>
>> +       tpacpi_hotkey_driver_mask_set(hotkey_driver_mask |
>> +                                     TP_ACPI_HKEY_KBD_LIGHT_MASK);
>>         return 0;
>>  }
>>
>> @@ -9169,6 +9173,10 @@ static void tpacpi_driver_event(const unsigned int hkey_event)
>>                         volume_alsa_notify_change();
>>                 }
>>         }
>> +       if (tp_features.kbdlight && hkey_event == TP_HKEY_EV_KBD_LIGHT)
>> +               led_classdev_notify_brightness_hw_changed(
>> +                       &tpacpi_led_kbdlight.led_classdev,
>> +                       kbdlight_sysfs_get(NULL));
>>  }
>>
>>  static void hotkey_driver_event(const unsigned int scancode)
>> --
>> 2.9.3
>>
>
>
>
diff mbox

Patch

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index cacb43f..6249292 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -163,6 +163,7 @@  enum tpacpi_hkey_event_t {
 	TP_HKEY_EV_HOTKEY_BASE		= 0x1001, /* first hotkey (FN+F1) */
 	TP_HKEY_EV_BRGHT_UP		= 0x1010, /* Brightness up */
 	TP_HKEY_EV_BRGHT_DOWN		= 0x1011, /* Brightness down */
+	TP_HKEY_EV_KBD_LIGHT		= 0x1012, /* Thinklight/kbd backlight */
 	TP_HKEY_EV_VOL_UP		= 0x1015, /* Volume up or unmute */
 	TP_HKEY_EV_VOL_DOWN		= 0x1016, /* Volume down or unmute */
 	TP_HKEY_EV_VOL_MUTE		= 0x1017, /* Mixer output mute */
@@ -1959,7 +1960,7 @@  enum {	/* Positions of some of the keys in hotkey masks */
 	TP_ACPI_HKEY_HIBERNATE_MASK	= 1 << TP_ACPI_HOTKEYSCAN_FNF12,
 	TP_ACPI_HKEY_BRGHTUP_MASK	= 1 << TP_ACPI_HOTKEYSCAN_FNHOME,
 	TP_ACPI_HKEY_BRGHTDWN_MASK	= 1 << TP_ACPI_HOTKEYSCAN_FNEND,
-	TP_ACPI_HKEY_THNKLGHT_MASK	= 1 << TP_ACPI_HOTKEYSCAN_FNPAGEUP,
+	TP_ACPI_HKEY_KBD_LIGHT_MASK	= 1 << TP_ACPI_HOTKEYSCAN_FNPAGEUP,
 	TP_ACPI_HKEY_ZOOM_MASK		= 1 << TP_ACPI_HOTKEYSCAN_FNSPACE,
 	TP_ACPI_HKEY_VOLUP_MASK		= 1 << TP_ACPI_HOTKEYSCAN_VOLUMEUP,
 	TP_ACPI_HKEY_VOLDWN_MASK	= 1 << TP_ACPI_HOTKEYSCAN_VOLUMEDOWN,
@@ -2344,7 +2345,7 @@  static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
 		n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY);
 		n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE);
 	}
-	if (m & TP_ACPI_HKEY_THNKLGHT_MASK) {
+	if (m & TP_ACPI_HKEY_KBD_LIGHT_MASK) {
 		d = nvram_read_byte(TP_NVRAM_ADDR_THINKLIGHT);
 		n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT);
 	}
@@ -5193,6 +5194,7 @@  static struct tpacpi_led_classdev tpacpi_led_kbdlight = {
 	.led_classdev = {
 		.name		= "tpacpi::kbd_backlight",
 		.max_brightness	= 2,
+		.flags		= LED_BRIGHT_HW_CHANGED,
 		.brightness_set	= &kbdlight_sysfs_set,
 		.brightness_get	= &kbdlight_sysfs_get,
 	}
@@ -5222,6 +5224,8 @@  static int __init kbdlight_init(struct ibm_init_struct *iibm)
 		return rc;
 	}
 
+	tpacpi_hotkey_driver_mask_set(hotkey_driver_mask |
+				      TP_ACPI_HKEY_KBD_LIGHT_MASK);
 	return 0;
 }
 
@@ -9169,6 +9173,10 @@  static void tpacpi_driver_event(const unsigned int hkey_event)
 			volume_alsa_notify_change();
 		}
 	}
+	if (tp_features.kbdlight && hkey_event == TP_HKEY_EV_KBD_LIGHT)
+		led_classdev_notify_brightness_hw_changed(
+			&tpacpi_led_kbdlight.led_classdev,
+			kbdlight_sysfs_get(NULL));
 }
 
 static void hotkey_driver_event(const unsigned int scancode)