Skip to content
Commit f3f837e5 authored by Bill Richardson's avatar Bill Richardson Committed by Olof Johansson
Browse files

platform/chrome: Expose Chrome OS Lightbar to users



This adds some sysfs entries to provide userspace control of the
four-element LED "lightbar" on the Chromebook Pixel. This only instantiates
the lightbar controls if the device actually exists.

To prevent DoS attacks, this interface is limited to 20 accesses/second,
although that rate can be adjusted by a privileged user.

On Chromebooks without a lightbar, this should have no effect. On the
Chromebook Pixel, you should be able to do things like this:

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo 0x80 > brightness
    $ echo 255 > brightness
    $
    $ cat sequence
    S0
    $ echo konami > sequence
    $ cat sequence
    KONAMI
    $
    $ cat sequence
    S0

And

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo stop > sequence
    $ echo "4 255 255 255" > led_rgb
    $ echo "0 255 0 0  1 0 255 0  2 0 0 255  3 255 255 0" > led_rgb
    $ echo run  > sequence

Test the DoS prevention with this:

    $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar
    $ echo 500 > interval_msec
    $ time (cat version version version version version version version)

Signed-off-by: default avatarBill Richardson <wfrichar@chromium.org>
Reviewed-by: default avatarOlof Johansson <olofj@chromium.org>
Tested-by: default avatarDoug Anderson <dianders@chromium.org>
Reviewed-by: default avatarBenson Leung <bleung@chromium.org>
Signed-off-by: default avatarJavier Martinez Canillas <javier.martinez@collabora.co.uk>
Tested-by: default avatarGwendal Grignou <gwendal@chromium.org>
Reviewed-by: default avatarGwendal Grignou <gwendal@chromium.org>
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parent 71af4b52
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment