Search code examples
linux-kernellinux-device-driverasus-wmi

How to enable Asus WMI LED manually in terminal by ID found in asus-wmi.h


How I can in the Linux terminal turn on or off LED when I know its id e.g. 0x00050031, 0x00050032, 0x00060078 from file asus-wmi.h.

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __PLATFORM_DATA_X86_ASUS_WMI_H_EXT
#define __PLATFORM_DATA_X86_ASUS_WMI_H_EXT

#define ASUS_WMI_DEVID_SCREENPAD    0x00050031
#define ASUS_WMI_DEVID_SCREENPAD_LIGHT  0x00050032
#define ASUS_WMI_DEVID_CAMERA_LED_ON_KEYBOARD 0x00060078

#endif  /* __PLATFORM_DATA_X86_ASUS_WMI_H_EXT */

Solution

  • @IanAbbott: I think that once the asus-nb-wmi module is loaded, you could send arbitrary WMI commands via the debugfs file system. In "/sys/kernel/debug/asus-nb-wmi/", write values to the "dev_id", "ctrl_param" and "method_id" files, then read the "devs" file to set the device state, or read the "dsts" file to get the device state, or read the "call" file to evaluate the method on the device.

    Script what I wrote for brute forcing (check is done by eyes):

    # Script try read and write range of devids defined in cycle below via /sys/kernel/debug/asus-nb-wmi/
    
    for CURRENT_DEVID in 0x000{60079..60079}
    do
        echo "${CURRENT_DEVID}" > "/sys/kernel/debug/asus-nb-wmi/dev_id"
    
        CURRENT_VALUE=$(cat "/sys/kernel/debug/asus-nb-wmi/dsts")
    
        # test read value
        if [[ $? != 0 ]]
        then
            echo "-- Current devid: ${CURRENT_DEVID} (no dsts)"
        fi
    
        # test write value
        echo $(echo "${CURRENT_VALUE}" | rev | cut -d' ' -f1 | rev) > "/sys/kernel/debug/asus-nb-wmi/ctrl_param"
        cat "/sys/kernel/debug/asus-nb-wmi/devs"
    
        if [[ $? != 0 ]]
        then
            echo "-- Current devid: ${CURRENT_DEVID} (current value ${CURRENT_VALUE} but no devs)"
        else
            echo "0x00000001" > "/sys/kernel/debug/asus-nb-wmi/ctrl_param"
            cat "/sys/kernel/debug/asus-nb-wmi/devs"
            echo "-- Current devid: ${CURRENT_DEVID} (current value ${CURRENT_VALUE} changed on 1s to \"0x00000001\")"
            sleep 1
            echo $(echo "${CURRENT_VALUE}" | rev | cut -d' ' -f1 | rev) > "/sys/kernel/debug/asus-nb-wmi/ctrl_param"
            cat "/sys/kernel/debug/asus-nb-wmi/devs"
        fi
    done