The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    Ambient Light Sensor ALS

    Discussion in 'Linux Compatibility and Software' started by oled, Jan 27, 2014.

  1. oled

    oled Notebook Evangelist

    Reputations:
    221
    Messages:
    587
    Likes Received:
    33
    Trophy Points:
    41
    Quite a few notebooks come with a 'standard' ACPI ambient light sensor. However in my case my kernel did not provide the appropriate driver module. Here is a brief documentation on how I made the ALS sensor work on a Samsung Series 9 running kernel-3.12

    Check whether your kernel is aware of the sensor:
    Code:
    me@nbr:~$ find /sys | grep ACPI0008
    /sys/bus/acpi/devices/ACPI0008:00
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/hid
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/path
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/control
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/async
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/runtime_enabled
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/runtime_active_kids
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/runtime_active_time
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/autosuspend_delay_ms
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/runtime_status
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/runtime_usage
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/power/runtime_suspended_time
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/modalias
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/subsystem
    /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/PNP0C09:00/ACPI0008:00/uevent
    Download the driver source from: https://github.com/victorenator/als/archive/master.zip. It is originally written for the sensor in the Asus Zenbook, but I suspect it to work with a variety of ACPI0008 sensors. It does work on my Samsung Series 9.

    To be able to compile the module make sure you have the linux-headers installed matching your running kernel.
    Now unpack the downloaded archive, change into its directory and compile the driver:
    Code:
    me@nbr:~/als-master$ make
    Your freshly built module is now ready to be inserted into the kernel:
    Code:
    me@nbr:~/als-master$ sudo insmod als.ko
    That's it! The driver then provides a new attribute 'ali' which holds the current measured light value:
    Code:
    me@nbr:~$ cat /sys/bus/acpi/devices/ACPI0008:00/ali
    5
    In my case valid values are between 1 - 3230



    Alternatively you can monitor sensor changes and have the value sent by a simple udev rule:
    Code:
    me@nbr:~$ sudo echo 'ACTION=="change", KERNEL=="ACPI0008:00", RUN+="/path/to/als_script.sh $attr{ali}"' > /etc/udev/rules.d/60-als.rules
    me@nbr:~$ sudo chmod +x /etc/udev/rules.d/60-als.rules
    me@nbr:~$ sudo udevadm control --reload-rules


    I'm a bit disappointed though. While the sensor is very sensitive on strong light (eg shining torch light at it) it has very poor performance at low light. So the lowest value '1' gets already reached in modest low light surroundings, leaving no more room for further adjustment in dark environments. I have no idea if the hardware, BIOS or driver is to blame for that.


    Useful links:
    Asus Zenbook ALS Controller | Github
    ALS for ASUS Zenbook Prime | infty.nl
    Camera Light Sensor | Calise
    Avoiding Eye Strain | Linux Magazine
     
    ALLurGroceries likes this.
  2. oled

    oled Notebook Evangelist

    Reputations:
    221
    Messages:
    587
    Likes Received:
    33
    Trophy Points:
    41
    Suitable driver found. Updated OP...
     
  3. lviggiani

    lviggiani Newbie

    Reputations:
    0
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    5
    Hi, thanks for your post!

    I'm trying to build it on arch linux but I get the following error:

    make -C /lib/modules/3.13.6-1-ARCH/build M=/home/luca/Scaricati/als-master modules
    make[1]: Entering directory '/usr/lib/modules/3.13.6-1-ARCH/build'
    make[1]: *** No rule to make target 'modules'. Stop.
    make[1]: Leaving directory '/usr/lib/modules/3.13.6-1-ARCH/build'
    Makefile:4: recipe for target 'all' failed
    make: *** [all] Error 2

    Can you help me out to find what I do miss?
    Thanks!

    Shame on me! ...I forgot to install linux-headers package... :eek:
     
  4. oled

    oled Notebook Evangelist

    Reputations:
    221
    Messages:
    587
    Likes Received:
    33
    Trophy Points:
    41
    I see, so your kernel was still a virgin :)
    Fixed the OP.

    Could you please give some feedback if everything went smooth?
    What manufacturer / model is your notebook?
    How does your sensor perform in dark environments?
     
  5. bfvogel

    bfvogel Newbie

    Reputations:
    11
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    5
    I've been searching for a modules for the ALS on the Series 9 for some time now and thanks to you we finally have it.

    Kernel: 3.14.4-200
    Platform: Fedora 20

    Didn't need to do anything special to get it to build.

    I'm seeing the same results as the OP. The sensor is not very dynamic in Mid-Low light. I find it amusing the the max value is so high as under outdoor sunlight the sensor float around 200-250 for me and is under 10 for low light but still usable without keyboard backlight room. I wrote a quick script to modify the Screen and Keyboard backlight in respect to the ALS sensor but an actively modifying Lightum ( https://github.com/poliva/lightum) to work with the Samsung Series 9 devices.

    Thanks for tracking this down.