Giter VIP home page Giter VIP logo

ayaneo-platform's Introduction

Platform driver for AYANEO x86 handhelds

This driver provides a sysfs interface for RGB control.

Supported devices include:

  • AIR
  • AIR Pro
  • AIR Plus
  • AIR 1s
  • 2
  • 2S
  • GEEK
  • GEEK 1S
  • KUN
  • Slide

Build

If you only want to build and test the module (you need headers for your kernel):

$ git clone https://github.com/ShadowBlip/ayaneo-platform.git
$ cd ayaneo-platform
$ make

Then insert the module and check dmesg:

# insmod ayaneo-platform.ko

Install

You'll need appropriate headers for your kernel and dkms package from your distribution.

$ git clone https://github.com/ShadowBlip/ayaneo-platform.git
$ cd ayaneo-platform
$ make
# make dkms

Usage

RGB Control

LED color and brightness can be controlled via sysfs.

On most systems this will be mounted at /sys/class/leds/multicolor:chassis/ and provides the following files:

brightness

Read/write.

Gets or sets the overall brightness of the LEDs. Accepts a value between 0 and max_brightness.

Defaults to 0.

max_brightness

Read only.

Gets the maximum brightness supported by the LEDs. On most systems this value is 255.

multi_index

Read only.

Gets the names of each of the channels supported by multi_intensity. On most systems this value will be "red green blue".

multi_intensity

Read/write.

Gets or sets the intensity of each of the channels. The expected value is list of numbers between 0 and 255 for each of the channels listed in multi_index.

Default is "0 0 0".

suspend_mode

Read/write.

Controls how the LEDs should behave during suspend. When reading, the currently selected option will be wrapped in square brackets [ ].

Value Description
oem The LEDs retain OEM behavior.On most devices, they will breathe white during suspend and breathe red when charging.
off The LEDs are turned off during suspend. They do not respond to charging.
keep The LEDs retain their current color during suspend. They do not respond to charging.

Default is "oem".

Identifying and Setting Color Values

The current brightness and color can be retrieved as follows:

$ cat /sys/class/leds/multicolor:chassis/brightness
0
$ cat /sys/class/leds/multicolor:chassis/multi_intensity
0 0 0

New values can be set as follows:

$ echo "255" | sudo tee /sys/class/leds/multicolor:chassis/brightness
255
$ echo "255 0 128" | sudo tee /sys/class/leds/multicolor:chassis/multi_intensity
255 0 128

Changing Startup Defaults

The platform driver is fully exposed over systemd udev. This can be used to write udev rules that set attributes at startup.

Udev Attributes Tree

$ udevadm info --attribute-walk /sys/class/leds/multicolor:chassis

  looking at device '/devices/platform/ayaneo-platform/leds/multicolor:chassis':
    KERNEL=="multicolor:chassis"
    SUBSYSTEM=="leds"
    DRIVER==""
    ATTR{brightness}=="0"
    ATTR{max_brightness}=="255"
    ATTR{multi_index}=="red green blue"
    ATTR{multi_intensity}=="0 0 0"
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"
    ATTR{suspend_mode}=="[oem] keep off"
    ATTR{trigger}=="[none] usb-gadget usb-host rc-feedback kbd-scrolllock kbd-numlock kbd-capslo>

  looking at parent device '/devices/platform/ayaneo-platform':
    KERNELS=="ayaneo-platform"
    SUBSYSTEMS=="platform"
    DRIVERS=="ayaneo-platform"
    ATTRS{driver_override}=="(null)"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

Creating a rule

You can store a udev rule as /etc/udev/rules.d/##-rule_name.rules

All rules will start like this: ACTION=="add|change", KERNEL=="multicolor:chassis", SUBSYSTEM=="leds"

To define a default, add the attribute in the format ATTR{name}=value Valid attributes are:

ATTR{brightness}=="[0-255]"
ATTR{multi_intensity}=="[0-255] [0-255] [0-255]"
ATTR{suspend_mode}=="[oem|keep|off]"

As en example, to set suspend_modeto off: ACTION=="add|change", KERNEL=="multicolor:chassis", SUBSYSTEM=="leds", ATTR{suspend_mode}="off"

to create the rule in one line:

$ echo 'ACTION=="add|change", KERNEL=="multicolor:chassis", SUBSYSTEM=="leds", ATTR{suspend_mode}="off"' | sudo tee /etc/udev/rules.d/99-led_suspend_mode.rules

ayaneo-platform's People

Contributors

pastaq avatar sythezn avatar pull[bot] avatar kylegospo avatar fewtarius avatar honjow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.