linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Jacek Anaszewski"
	<j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	"Darren Hart" <dvhart-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	"Matthew Garrett" <mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>,
	"Pali Rohár" <pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Henrique de Moraes Holschuh"
	<ibm-acpi-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>,
	"Richard Purdie"
	<rpurdie-Fm38FmjxZ/leoWH0uzbU5w@public.gmane.org>
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	platform-driver-x86-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v5 2/6] leds: triggers: Add a keyboard backlight trigger
Date: Fri, 18 Nov 2016 10:07:29 +0100	[thread overview]
Message-ID: <39fdea9c-b2de-7fb6-3acf-0ea1de73ea75@redhat.com> (raw)
In-Reply-To: <af5a6b68-310d-85ec-16db-5c9036f38ba5-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

Hi,

On 18-11-16 09:55, Jacek Anaszewski wrote:
> Hi Hans,
>
> Thanks for the patch.
>
> I think we need less generic trigger name.
> With present name we pretend that all kbd-backlight controllers
> can change LED brightness autonomously.
>
> How about kbd-backlight-pollable ?

This is a trigger to control kbd-backlights, in the
current use-case the brightness change is already done
by the firmware, hence the set_brightness argument to
ledtrig_kbd_backlight(), so that we can avoid setting
it again.

But I can see future cases where we do want to have some
event (e.g. a wmi hotkey event on a laptop where the firmware
does not do the adjustment automatically) which does
lead to actually updating the brightness.

So I decided to go with a generic kbd-backlight trigger,
which in the future can also be used to directly control
kbd-backlight brightness; and not just to make ot
poll-able.

Regards,

Hans



>
> Best regards,
> Jacek Anaszewski
>
> On 11/17/2016 11:24 PM, Hans de Goede wrote:
>> Add a trigger to control keyboard backlight LED devices. Note that in
>> some cases the keyboard backlight control is hardwired (taken care of
>> in firmware outside of the kernels control), in that case this triggers
>> main purpose is to allow userspace to monitor these changes.
>>
>> The ledtrig_kbd_backlight function has a set_brightness parameter to
>> differentiate between full backlight control through the trigger
>> (set_brightness set to true) or change notification only (false).
>>
>> Note the Kconfig option for this is a bool because the code is so
>> small that it is not worth the overhead of being a module.
>>
>> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>> Changes in v5:
>> -This is a new patch in v5 of this patch-set (replacing earlier attempts
>>  at similar functionality)
>> ---
>>  drivers/leds/trigger/Kconfig                 | 10 ++++++++
>>  drivers/leds/trigger/Makefile                |  1 +
>>  drivers/leds/trigger/ledtrig-kbd-backlight.c | 38 ++++++++++++++++++++++++++++
>>  include/linux/leds.h                         |  8 ++++++
>>  4 files changed, 57 insertions(+)
>>  create mode 100644 drivers/leds/trigger/ledtrig-kbd-backlight.c
>>
>> diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
>> index 3f9ddb9..350e2c7 100644
>> --- a/drivers/leds/trigger/Kconfig
>> +++ b/drivers/leds/trigger/Kconfig
>> @@ -67,6 +67,16 @@ config LEDS_TRIGGER_BACKLIGHT
>>
>>        If unsure, say N.
>>
>> +config LEDS_TRIGGER_KBD_BACKLIGHT
>> +    bool "LED keyboard backlight Trigger"
>> +    depends on LEDS_TRIGGERS
>> +    help
>> +      This trigger can control keyboard backlight LED devices,
>> +      it also allows user-space to monitor keyboard backlight brightness
>> +      changes done through e.g. hotkeys on some laptops.
>> +
>> +      If unsure, say Y.
>> +
>>  config LEDS_TRIGGER_CPU
>>      bool "LED CPU Trigger"
>>      depends on LEDS_TRIGGERS
>> diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
>> index a72c43c..be6b249 100644
>> --- a/drivers/leds/trigger/Makefile
>> +++ b/drivers/leds/trigger/Makefile
>> @@ -4,6 +4,7 @@ obj-$(CONFIG_LEDS_TRIGGER_DISK)        += ledtrig-disk.o
>>  obj-$(CONFIG_LEDS_TRIGGER_MTD)        += ledtrig-mtd.o
>>  obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT)    += ledtrig-heartbeat.o
>>  obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT)    += ledtrig-backlight.o
>> +obj-$(CONFIG_LEDS_TRIGGER_KBD_BACKLIGHT) += ledtrig-kbd-backlight.o
>>  obj-$(CONFIG_LEDS_TRIGGER_GPIO)        += ledtrig-gpio.o
>>  obj-$(CONFIG_LEDS_TRIGGER_CPU)        += ledtrig-cpu.o
>>  obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON)    += ledtrig-default-on.o
>> diff --git a/drivers/leds/trigger/ledtrig-kbd-backlight.c b/drivers/leds/trigger/ledtrig-kbd-backlight.c
>> new file mode 100644
>> index 0000000..353ee92
>> --- /dev/null
>> +++ b/drivers/leds/trigger/ledtrig-kbd-backlight.c
>> @@ -0,0 +1,38 @@
>> +/*
>> + * LED Trigger for keyboard backlight control
>> + *
>> + * Copyright 2016, Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + */
>> +
>> +#include <linux/module.h>
>> +#include <linux/kernel.h>
>> +#include <linux/init.h>
>> +#include <linux/device.h>
>> +#include <linux/leds.h>
>> +#include "../leds.h"
>> +
>> +static struct led_trigger kbd_backlight_trigger = {
>> +    .name     = "kbd-backlight",
>> +    .activate = led_trigger_add_current_brightness,
>> +    .deactivate = led_trigger_remove_current_brightness,
>> +};
>> +
>> +void ledtrig_kbd_backlight(bool set_brightness, enum led_brightness brightness)
>> +{
>> +    if (set_brightness)
>> +        led_trigger_event(&kbd_backlight_trigger, brightness);
>> +
>> +    led_trigger_notify_current_brightness_change(&kbd_backlight_trigger);
>> +}
>> +EXPORT_SYMBOL_GPL(ledtrig_kbd_backlight);
>> +
>> +static int __init kbd_backlight_trig_init(void)
>> +{
>> +    return led_trigger_register(&kbd_backlight_trigger);
>> +}
>> +device_initcall(kbd_backlight_trig_init);
>> diff --git a/include/linux/leds.h b/include/linux/leds.h
>> index d3eb992..870b8c2 100644
>> --- a/include/linux/leds.h
>> +++ b/include/linux/leds.h
>> @@ -353,6 +353,14 @@ static inline void ledtrig_flash_ctrl(bool on) {}
>>  static inline void ledtrig_torch_ctrl(bool on) {}
>>  #endif
>>
>> +#ifdef CONFIG_LEDS_TRIGGER_KBD_BACKLIGHT
>> +extern void ledtrig_kbd_backlight(bool set_brightness,
>> +                  enum led_brightness brightness);
>> +#else
>> +static inline void ledtrig_kbd_backlight(bool set_brightness,
>> +                     enum led_brightness brightness) {}
>> +#endif
>> +
>>  /*
>>   * Generic LED platform data for describing LED names and default triggers.
>>   */
>>
>
>

------------------------------------------------------------------------------

  parent reply	other threads:[~2016-11-18  9:07 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17 22:24 [PATCH v5 1/6] leds: triggers: Add current_brightness trigger parameter Hans de Goede
2016-11-17 22:24 ` [PATCH v5 2/6] leds: triggers: Add a keyboard backlight trigger Hans de Goede
2016-11-18  8:55   ` Jacek Anaszewski
     [not found]     ` <af5a6b68-310d-85ec-16db-5c9036f38ba5-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-11-18  9:07       ` Hans de Goede [this message]
2016-11-18 16:03         ` Jacek Anaszewski
2016-11-18 18:47           ` Hans de Goede
2016-11-19 15:44             ` Jacek Anaszewski
2016-11-20 15:05               ` Pali Rohár
2016-11-20 16:21                 ` Pavel Machek
2016-11-20 18:48                   ` Hans de Goede
     [not found]                     ` <acd1691b-56be-c902-feff-7ecf38ea102a-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-11-20 19:45                       ` Pali Rohár
2016-11-21 10:24                   ` Jacek Anaszewski
2016-11-21 10:42                     ` Hans de Goede
2016-11-21 11:24                       ` Jacek Anaszewski
2016-11-21 11:56                         ` Hans de Goede
2016-11-21 13:29                           ` Jacek Anaszewski
2016-11-22 14:58                             ` Pali Rohár
2016-11-22 15:20                               ` [ibm-acpi-devel] " Glenn Golden
2016-11-23 11:01                               ` Jacek Anaszewski
2016-11-24  9:15                                 ` Pali Rohár
2016-11-24  9:21                                   ` Hans de Goede
2016-11-24 14:21                                   ` Jacek Anaszewski
2016-11-24 14:26                                     ` Pali Rohár
2016-11-24 15:32                                       ` Jacek Anaszewski
     [not found]                                         ` <50225a88-b928-c61b-bf6f-6c85fb6a9082-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-11-24 15:36                                           ` Pali Rohár
2016-11-24 16:21                                             ` Jacek Anaszewski
2016-11-24 16:51                                               ` Pali Rohár
2016-11-24 21:35                                                 ` Jacek Anaszewski
     [not found]                                                   ` <5238be1f-d669-07e6-c796-5bc0126cb456-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-24 21:45                                                     ` Pali Rohár
2016-11-25  8:33                                                       ` Jacek Anaszewski
2016-11-25 10:01                                                         ` Pavel Machek
2016-11-25 10:25                                                           ` Jacek Anaszewski
     [not found]                                                             ` <e32e3d6c-5d6d-c882-21d9-8028c8311b0b-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-11-25 11:05                                                               ` Pavel Machek
2016-11-25 11:19                                                                 ` Jacek Anaszewski
     [not found]                                                                   ` <2367b9a7-68f7-2038-0d3a-a9561055b4f6-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-11-25 14:49                                                                     ` Pavel Machek
2016-11-25 15:55                                                                       ` Jacek Anaszewski
2016-11-25 20:40                                                                         ` Pavel Machek
2016-11-25 22:28                                                                           ` Jacek Anaszewski
2016-12-21 18:49                                                                             ` Pavel Machek
2016-12-23 21:55                                                                               ` Jacek Anaszewski
2017-01-13 19:17                                                                                 ` Darren Hart
2017-01-15 10:54                                                                                   ` Hans de Goede
2017-01-15 12:25                                                                                     ` Henrique de Moraes Holschuh
2017-01-15 15:05                                                                                       ` Hans de Goede
2017-01-24 12:32                                                                                 ` Pavel Machek
2017-01-24 22:56                                                                                   ` Jacek Anaszewski
2017-01-25 13:12                                                                                     ` Hans de Goede
2016-11-25 11:14                                                           ` Hans de Goede
2016-11-25 11:26                                                             ` Pali Rohár
2016-11-25 12:05                                                               ` Pavel Machek
2016-11-25 15:46                                                               ` Jacek Anaszewski
2016-12-01 14:08                                                             ` Jacek Anaszewski
2016-11-25  9:56                                             ` Pavel Machek
2016-11-25  9:51                                   ` Pavel Machek
2016-11-21 11:41                     ` Pavel Machek
2016-11-21 13:29                       ` Jacek Anaszewski
2016-11-25  9:29                         ` Pavel Machek
2016-11-21  8:35                 ` Jacek Anaszewski
2016-11-21  9:31                   ` Hans de Goede
2016-11-21 10:12                     ` Pali Rohár
2016-11-21 10:16                       ` Hans de Goede
2016-11-25 10:07                     ` Pavel Machek
2016-11-17 22:24 ` [PATCH v5 3/6] leds: triggers: Add support for read-only triggers Hans de Goede
2016-11-18  8:52   ` Jacek Anaszewski
2016-11-18  9:04     ` Hans de Goede
2016-11-18 10:49       ` Jacek Anaszewski
2016-11-18 11:01         ` Hans de Goede
2016-11-17 22:24 ` [PATCH v5 4/6] platform: x86: thinkpad: Call led kbd_backlight trigger on kbd brightness change Hans de Goede
2016-11-17 22:24 ` [PATCH v5 5/6] platform: x86: dell-laptop: Set keyboard backlight led device default trigger Hans de Goede
2016-11-17 22:24 ` [PATCH v5 6/6] platform: x86: dell-wmi: Call led kbd_backlight trigger on kbd brightness change Hans de Goede
2016-11-20 14:59 ` [PATCH v5 1/6] leds: triggers: Add current_brightness trigger parameter Pali Rohár
2016-11-20 18:45   ` Hans de Goede
2016-11-20 19:40     ` Pali Rohár
2016-11-20 22:12       ` Pavel Machek
2016-11-20 23:07 ` Pali Rohár
2016-11-20 23:48   ` Pavel Machek
2016-11-21 10:02     ` Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39fdea9c-b2de-7fb6-3acf-0ea1de73ea75@redhat.com \
    --to=hdegoede-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dvhart-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=ibm-acpi-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org \
    --cc=ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mjg59-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org \
    --cc=pali.rohar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=platform-driver-x86-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rpurdie-Fm38FmjxZ/leoWH0uzbU5w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).