Reverse-Engineer Driver for Multi-colored Backlit Keyboard on Clevo Laptops

Here's my situation:

I recently purchased a Sager NP9170 (same as the Clevo P170EM) and it has a multi-colored, backlit keyboard. Under Windows 7, you can launch an app that allows you to change the color of the backlighting to any of a handful of colors (blue, green, red, etc).

I want that same functionality under Linux. I haven't been able to find any software that does this, so I guess I'm going to have to write it myself. I'm a programmer by trade, but I've haven't done much low level programming, and I've certainly never written a device driver, so I was wondering if anyone could answer these two questions:

1) Is there any software already out there that does this sort of thing? I've looked fairly thoroughly but haven't found anything applicable.

2) Where would I start in trying to reverse engineer this sort of thing? Any useful articles, tutorials, books that might help?

And just to clarify: The backlighting already works, that's not the problem. I just want to be able to change the color of the backlighting. This functionality is supported by the hardware. The laptop came with windows software that does this and I want the same functionality in Linux. I am willing to write this software myself, I just want to know the best way to go about it.

Thanks!


Solution 1:

Well, as it turns out, someone else actually figured it out. A huge "Thank You" to "klystron34" over in the notebookreview.com forums. Check out the forum thread for more information.

Note: As far as I know, this will work for many/most laptops based on the stock Clevo P150EM and the P170EM. This was personally verified by me on a Sager NP9170 on Ubuntu 12.04. Proceed at your own risk. I'm not responsible for any damage you might cause doing this, and any other standard internet disclaimers. Proceed at your own risk. Now, onto the good stuff:

First, you need to be able to compile a kernel module, so update your repositories:

sudo apt-get update

Now, install git, the build tools and the kernel source:

sudo apt-get install git build-essential linux-source

Now create a working directory. I prefer to use a "dev" folder located in my home directory:

cd ˜
mkdir dev
cd dev

Now, download the source for the kernel module:

git clone git://git.code.sf.net/p/clevo-wmi/code clevo-wmi-code

Go into the directory with the source code:

cd clevo-wmi-code

"Make" the kernel module:

make

You should now have a file called clevo_wmi.ko

Now, let's test and see if the module actually works by loading the module:

sudo insmod /home/<your-username-here>/dev/clevo-wmi-code/clevo_wmi.ko

If it worked, you should now have a new directory called:

/sys/devices/platform/clevo_wmi/kbled

Change over to that directory:

cd /sys/devices/platform/clevo_wmi/kbled

You should now be able to change the colour of the middle section of your keyboard by executing the following command:

sudo su -c 'echo 100 > middle'

The middle section of your keyboard should now be green. Replace middle with left or right to change the corresponding section of the keyboard. Here's a list of the color codes:

GRB (Green-Red-Blue)
000 - Off
111 - White
100 - Green
010 - Red
001 - Blue
110 - Yellow
011 - Purple
101 - Aqua

To install this kernel module permanently, copy it into the same location as the rest of your kernel modules (NOTE: You will probably have to perform this step and the next step anytime you change your kernel):

sudo cp ~/dev/clevo-wmi-code/clevo_wmi.ko /lib/modules/`uname -r`/kernel/drivers/platform/x86/

Next, do this (I think rebuilds the list of kernel modules):

sudo depmod -a

Then edit your /etc/modules file and add this line to the end of the file:

clevo_wmi

Save your changes to /etc/modules.

Now, whenever you reboot, the module should be loaded and you can then change the colour of the backlight on your keyboard. Figuring out how to have it change colours on reboot and remembering your last colour setting is an exercise left up to the reader. Check the docs directory in the sourcecode for instructions on how to use the dynamic colour changing features.

Thanks agin to the developer(s) that worked hard on writing this kernel module!