Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759546AbcCDJjo (ORCPT ); Fri, 4 Mar 2016 04:39:44 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:30311 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759428AbcCDJi3 (ORCPT ); Fri, 4 Mar 2016 04:38:29 -0500 X-AuditID: cbfec7f5-f79b16d000005389-5c-56d95791df48 Message-id: <56D95790.9080301@samsung.com> Date: Fri, 04 Mar 2016 10:38:24 +0100 From: Jacek Anaszewski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-version: 1.0 To: Dmitry Torokhov Cc: Richard Purdie , Bryan Wu , Simon Que , Olof Johansson , Duncan Laurie , Guenter Roeck , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [PATCH] leds: Add Chrome OS keyboard backlight LEDs driver References: <20160303234646.GA17641@dtor-ws> In-reply-to: <20160303234646.GA17641@dtor-ws> Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHLMWRmVeSWpSXmKPExsVy+t/xy7oTw2+GGfRd47Q4unMik8W1qW2M FocXvWC0OPVqGbPF5V1z2Cy2vlnHaPF1y25Gi927nrJaXNle78DpMbvhIovHzll32T32zP/B 6vF5k1wASxSXTUpqTmZZapG+XQJXxpRzeQUd+hWNax+zNTDOVuti5OSQEDCRuL5uLyOELSZx 4d56ti5GLg4hgaWMEm3LTkI5zxglOs/MZe1i5ODgFdCS+DdVHKSBRUBVYvOzVrBmNgFDiZ8v XjOB2KICERJ/Tu9jBbF5BQQlfky+xwJiiwjoS2yf/YsRZCazwBQmiXnH7oAlhAXcJd79WADW LCSgI7Fy8R4mkF2cAroS10+ngYSZBawlVk7axghhy0tsXvOWeQKjwCwkK2YhKZuFpGwBI/Mq RtHU0uSC4qT0XCO94sTc4tK8dL3k/NxNjJBQ/7qDcekxq0OMAhyMSjy8NxquhwmxJpYVV+Ye YpTgYFYS4Z3tdjNMiDclsbIqtSg/vqg0J7X4EKM0B4uSOO/MXe9DhATSE0tSs1NTC1KLYLJM HJxSDYyiSy4GrpLirHr8b/bEpf8+PzBd9Yknw7WGW+LHw+5tGVyT9m6ZFu+62HjrIVOZ/qdp +1X1t200C/j7KDH6oSDfoui6njyHJXFLry20llrnaGm+TeTRKqY6jnkGoZ6p5r+ntHnsWmy+ evbMgA81W1YzzGLJZphwK9th1V0BrYQtxwolWTyeuicrsRRnJBpqMRcVJwIAvXE17HECAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5847 Lines: 175 Hi Dmitry, Thanks for the patch. There's already other pending version [1], still to be decided where it should live. [1] http://comments.gmane.org/gmane.linux.leds/4523 Best regards, Jacek Anaszewski On 03/04/2016 12:46 AM, Dmitry Torokhov wrote: > From: Simon Que > > This is a driver for ACPI-based keyboard backlight LEDs found on > Chromebooks. The driver locates \\_SB.KBLT ACPI device and exports > backlight as "chromeos::kbd_backlight" LED class device in sysfs. > > Signed-off-by: Simon Que > Signed-off-by: Duncan Laurie > Signed-off-by: Dmitry Torokhov > --- > drivers/leds/Kconfig | 11 ++++ > drivers/leds/Makefile | 1 + > drivers/leds/leds-chromeos-keyboard.c | 106 ++++++++++++++++++++++++++++++++++ > 3 files changed, 118 insertions(+) > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > index f86527cf..02aaaf1 100644 > --- a/drivers/leds/Kconfig > +++ b/drivers/leds/Kconfig > @@ -581,6 +581,17 @@ config LEDS_SN3218 > This driver can also be built as a module. If so the module > will be called leds-sn3218. > > +config LEDS_CHROMEOS_KEYBOARD > + tristate "LED backlight support for Chrome OS keyboards" > + depends on LEDS_CLASS && ACPI > + depends on CHROME_PLATFORMS || COMPILE_TEST > + help > + This option enables support for the keyboard backlight LEDs on > + select Chrome OS systems. > + > + This driver can also be built as a module. If so the module > + will be called leds-chromeos-keyboard. > + > comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" > > config LEDS_BLINKM > 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..3592f09 > --- /dev/null > +++ b/drivers/leds/leds-chromeos-keyboard.c > @@ -0,0 +1,106 @@ > +/* > + * Keyboard backlight LED driver for Chrome OS. > + * > + * 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* Keyboard LED ACPI Device must be defined in firmware */ > +#define ACPI_KEYBOARD_BACKLIGHT_DEVICE "\\_SB.KBLT" > +#define ACPI_KEYBOARD_BACKLIGHT_READ ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBQC" > +#define ACPI_KEYBOARD_BACKLIGHT_WRITE ACPI_KEYBOARD_BACKLIGHT_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; > + > + 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: %d\n", > + status); > +} > + > +static int keyboard_led_probe(struct platform_device *pdev) > +{ > + struct led_classdev *cdev; > + acpi_handle handle; > + acpi_status status; > + int error; > + > + /* 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 to find ACPI device %s: %d\n", > + ACPI_KEYBOARD_BACKLIGHT_DEVICE, status); > + return -ENXIO; > + } > + > + cdev = devm_kzalloc(&pdev->dev, sizeof(*cdev), 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->brightness = cdev->max_brightness; > + cdev->flags |= LED_CORE_SUSPENDRESUME; > + > + error = devm_led_classdev_register(&pdev->dev, cdev); > + if (error) > + return error; > + > + 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", > + .acpi_match_table = ACPI_PTR(keyboard_led_id), > + }, > + .probe = keyboard_led_probe, > +}; > +module_platform_driver(keyboard_led_driver); > + > +MODULE_AUTHOR("Simon Que "); > +MODULE_DESCRIPTION("ChromeOS Keyboard backlight LED Driver"); > +MODULE_LICENSE("GPL"); > +MODULE_ALIAS("platform:chromeos-keyboard-leds"); >