From: Evan McClain <aeroevan@gmail.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>,
Jingoo Han <jingoohan1@gmail.com>,
Lee Jones <lee.jones@linaro.org>
Cc: Linux LED Subsystem <linux-leds@vger.kernel.org>,
Simon Que <sque@chromium.org>,
Duncan Laurie <dlaurie@chromium.org>,
Richard Purdie <rpurdie@rpsys.net>,
Olof Johansson <olof@lixom.net>
Subject: Re: [PATCH v4] leds: Add Chrome OS keyboard LEDs driver
Date: Tue, 23 Feb 2016 10:40:11 -0500 [thread overview]
Message-ID: <1456242011.3234.3.camel@gmail.com> (raw)
In-Reply-To: <56CC73D0.80106@samsung.com>
[-- Attachment #1: Type: text/plain, Size: 6871 bytes --]
It looks like most keyboard backlight drivers currently live in
drivers/platform, with a few exceptions.
Moving this driver to platform/chrome should be easy enough if that is
the proper location.
Thanks,
Evan McClain
On Tue, 2016-02-23 at 15:59 +0100, Jacek Anaszewski wrote:
> Hi Jingoo, Lee,
>
> I have my doubts if this driver wouldn't better fit for
> backlight subsystem. Actually the two are very similar
> and I wonder what are the criteria to follow when deciding
> if a driver should belong to one or to the other. Is the
> advertised purpose of the hardware the only one?
>
> Best regards,
> Jacek Anaszewski
>
> On 02/23/2016 02:01 PM, Evan McClain wrote:
> > From: Simon Que <sque@chromium.org>
> >
> > Some Chrome OS devices use ACPI-based keyboard backlight LEDs.
> >
> > Enable with menuconfig option under Device Drivers -> LED Support.
> >
> > Signed-off-by: Simon Que <sque@chromium.org>
> > Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
> > Signed-off-by: Evan McClain <aeroevan@gmail.com>
> > ---
> > drivers/leds/Kconfig | 7 +++
> > drivers/leds/Makefile | 1 +
> > drivers/leds/leds-chromeos-keyboard.c | 110
> > ++++++++++++++++++++++++++++++++++
> > 3 files changed, 118 insertions(+)
> > create mode 100644 drivers/leds/leds-chromeos-keyboard.c
> >
> > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> > index 1034696..89c81b6 100644
> > --- a/drivers/leds/Kconfig
> > +++ b/drivers/leds/Kconfig
> > @@ -619,6 +619,13 @@ config LEDS_VERSATILE
> > This option enabled support for the LEDs on the ARM
> > Versatile
> > and RealView boards. Say Y to enabled these.
> >
> > +config LEDS_CHROMEOS_KEYBOARD
> > + tristate "LED support for Chrome OS keyboards"
> > + depends on LEDS_CLASS && ACPI
> > + help
> > + This option enables support for the LEDs on Chrome OS
> > keyboards.
> > + Say Y to enable keyboard LEDs on Chrome OS systems.
> > +
> > comment "LED Triggers"
> > source "drivers/leds/trigger/Kconfig"
> >
> > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> > index 89c9b6f..5b96d15 100644
> > --- a/drivers/leds/Makefile
> > +++ b/drivers/leds/Makefile
> > @@ -67,6 +67,7 @@ obj-$(CONFIG_LEDS_KTD2692) +=
> > leds-ktd2692.o
> > obj-$(CONFIG_LEDS_POWERNV) += leds-powernv.o
> > obj-$(CONFIG_LEDS_SEAD3) += leds-sead3.o
> > obj-$(CONFIG_LEDS_SN3218) += leds-sn3218.o
> > +obj-$(CONFIG_LEDS_CHROMEOS_KEYBOARD) += leds-chromeos-
> > keyboard.o
> >
> > # LED SPI Drivers
> > obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
> > diff --git a/drivers/leds/leds-chromeos-keyboard.c
> > b/drivers/leds/leds-chromeos-keyboard.c
> > new file mode 100644
> > index 0000000..4611fae
> > --- /dev/null
> > +++ b/drivers/leds/leds-chromeos-keyboard.c
> > @@ -0,0 +1,110 @@
> > +/*
> > + * LED driver for Chrome OS keyboard backlight
> > + *
> > + * Copyright (C) 2012 Google, Inc.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > modify
> > + * it under the terms of the GNU General Public License as
> > published by
> > + * the Free Software Foundation; either version 2 of the License,
> > or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be
> > useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <linux/acpi.h>
> > +#include <linux/delay.h>
> > +#include <linux/err.h>
> > +#include <linux/init.h>
> > +#include <linux/kernel.h>
> > +#include <linux/leds.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/slab.h>
> > +
> > +/* Keyboard LED ACPI Device must be defined in firmware */
> > +#define ACPI_KEYBOARD_BACKLIGHT_DEVICE "\\_SB.KBLT"
> > +#define ACPI_KEYBOARD_BACKLIGHT_READ ACPI_KEYBOARD_BACKLIGH
> > T_DEVICE ".KBQC"
> > +#define ACPI_KEYBOARD_BACKLIGHT_WRITE ACPI_KEYBOARD_BACKLIG
> > HT_DEVICE ".KBCM"
> > +
> > +#define ACPI_KEYBOARD_BACKLIGHT_MAX 100
> > +
> > +static void keyboard_led_set_brightness(struct led_classdev *cdev,
> > + enum led_brightness
> > brightness)
> > +{
> > + union acpi_object param;
> > + struct acpi_object_list input;
> > + acpi_status status;
> > +
> > + if (!(cdev->flags & LED_SUSPENDED))
> > + cdev->brightness = brightness;
> > +
> > + param.type = ACPI_TYPE_INTEGER;
> > + param.integer.value = brightness;
> > + input.count = 1;
> > + input.pointer = ¶m;
> > +
> > + status = acpi_evaluate_object(NULL,
> > ACPI_KEYBOARD_BACKLIGHT_WRITE,
> > + &input, NULL);
> > + if (ACPI_FAILURE(status))
> > + dev_err(cdev->dev, "Error setting keyboard LED
> > value");
> > +}
> > +
> > +static int keyboard_led_probe(struct platform_device *pdev)
> > +{
> > + struct led_classdev *cdev;
> > + acpi_handle handle;
> > + acpi_status status;
> > + int ret;
> > +
> > + /* Look for the keyboard LED ACPI Device */
> > + status = acpi_get_handle(ACPI_ROOT_OBJECT,
> > + ACPI_KEYBOARD_BACKLIGHT_DEVICE,
> > + &handle);
> > + if (ACPI_FAILURE(status)) {
> > + dev_err(&pdev->dev, "Unable fo find ACPI device
> > %s\n",
> > + ACPI_KEYBOARD_BACKLIGHT_DEVICE);
> > + return -ENODEV;
> > + }
> > +
> > + cdev = devm_kzalloc(&pdev->dev, sizeof(struct
> > led_classdev), GFP_KERNEL);
> > + if (!cdev)
> > + return -ENOMEM;
> > +
> > + cdev->name = "chromeos::kbd_backlight";
> > + cdev->brightness_set = keyboard_led_set_brightness;
> > + cdev->max_brightness = ACPI_KEYBOARD_BACKLIGHT_MAX;
> > + cdev->flags |= LED_CORE_SUSPENDRESUME;
> > +
> > + ret = devm_led_classdev_register(&pdev->dev, cdev);
> > + if (ret)
> > + return ret;
> > +
> > + platform_set_drvdata(pdev, cdev);
> > +
> > + return 0;
> > +}
> > +
> > +static const struct acpi_device_id keyboard_led_id[] = {
> > + { "GOOG0002", 0 },
> > + { }
> > +};
> > +MODULE_DEVICE_TABLE(acpi, keyboard_led_id);
> > +
> > +static struct platform_driver keyboard_led_driver = {
> > + .driver = {
> > + .name = "chromeos-keyboard-leds",
> > + .owner = THIS_MODULE,
> > + .acpi_match_table = ACPI_PTR(keyboard_led_id),
> > + },
> > + .probe = keyboard_led_probe,
> > +};
> > +
> > +module_platform_driver(keyboard_led_driver);
> > +
> > +MODULE_AUTHOR("Simon Que <sque@chromium.org>");
> > +MODULE_DESCRIPTION("ChromeOS Keyboard LED Driver");
> > +MODULE_LICENSE("GPL v2");
> > +MODULE_ALIAS("platform:chromeos-keyboard-leds");
> >
>
--
Evan McClain
https://keybase.io/aeroevan
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
prev parent reply other threads:[~2016-02-23 15:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-23 13:01 [PATCH v4] leds: Add Chrome OS keyboard LEDs driver Evan McClain
2016-02-23 14:59 ` Jacek Anaszewski
2016-02-23 15:40 ` Evan McClain [this message]
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=1456242011.3234.3.camel@gmail.com \
--to=aeroevan@gmail.com \
--cc=dlaurie@chromium.org \
--cc=j.anaszewski@samsung.com \
--cc=jingoohan1@gmail.com \
--cc=lee.jones@linaro.org \
--cc=linux-leds@vger.kernel.org \
--cc=olof@lixom.net \
--cc=rpurdie@rpsys.net \
--cc=sque@chromium.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).