I am owner of my new Sony Vaio laptop. My model is not any highend thing, but i am happy with that. This page is about my experience with Linux working on this laptop. I wanted to have all useful features working in preinstalled Windows Vista Home Premium to work also in Linux. I made wiki page for me, but it is in Czech. If you speak Czech, you might look there.
I choosed distribution Ubuntu to have there, dual boot with original Windows. I like Debian, and Ubuntu is well prepared debian for desktop (in my opinion). Well it has great web and forums and users and that, but it has apt-get, that is important. I am running last stable version to this date, Ubuntu Hardy Heron (version 8.04).
I have found several ways to setup special buttons to work. Get it working is a mess, there is that many ways. Problem is also that Sony Vaios have different way of handling special keys in different models. Sony does not provide any information, what is on what model and how should it be handled. But thanks to some great guys, we have some basic support in Linux. Following tutorial should work on any recent Sony Vaio.
Note this article is not about way to make your backlight work. It does explain one part: how to map your FN+F5 key to some action. But what action can dim your panel, is not solved here.
At first let look at buttons i have there. Blue symbols are symbol pressed
when you press FN key and that button. Round button is media button, which
work without any configuration on my model using standard multimedia symbols.
Back to hotkeys. We have about three basic way, how to get special keys do something. First way is handling raw acpi events, using acpid daemon and scripts called for configured events. Second way is using input subsystem and events made by sony-laptop module. For my model FZ, it is available from 2.6.23 kernel, so it did not work with gutsy kernel. Third way is using daemon written for some vaio model, called fzfs.
You need: acpid. ACPI enabled kernel and computer, every recent PC is.
In /etc/acpi are scripts, which are run after configured event. Configured events are in /etc/acpi/events. They consinst of event name and action script. Example:
# /etc/acpi/events/sony-brightness-up event=sony/hotkey (SPIC|SNC) 00000001 00000011 action=/etc/acpi/xbacklight.sh upThis script does run on event sony/hotkey SNC 00000001 00000011 script /etc/acpi/xbacklight.sh up. Note that these scripts are run with root privileges and without access to X server. You can use regular expressions for event matching, as in example.
This method is considered deprecated. It has some problems, but it is most easy to setup, if you dont need access to X server. It can be used to control backlight in some cases, but running firefox on special keys would be difficult.
You need: Xorg, udev, sony-laptop module and manual configuration of /etc/X11/xorg.conf. For my model, i also needed kernel 2.6.23 or higher. I tested 24 and 25.
You have to modify xorg.conf. It depends on what distribution you have got. In Ubuntu Gutsy it worked only with parameter Option "Name" "Sony Vaio Keys". But it crashed xorg if you used that, when you have that name present two times in system. And ubuntu had load both sonypi and sony-laptop, where both have such device. In Ubuntu hardy, option Name is not supported and you have to use Device Option instead. Problem is, sony-laptop might have more or less random number in /etc/input/eventX device path.
For me, path changed when i had mouse plugged into usb port or not at boot. That is unacceptable for me, so i wrote script to create symlink using udev. Place script into /etc/udev/rules.d. After reboot, there should be symlink at /dev/input/by-id/acpi-sony_laptop-event-kbd.
When you have stable symlink, you can edit config file /etc/X11/xorg.conf. Add these somewhere following configuration, but do not replace your normal keyboard configuration.
Section "InputDevice"
Identifier "Sony Vaio Keys"
Driver "evdev"
Option "Device" "/dev/input/by-id/acpi-sony_laptop-event-kbd"
Option "Name" "Sony Vaio Keys"
Option "XkbLayout" "evdev"
Option "XkbModel" "evdev"
EndSection
Section "InputDevice"
Identifier "Sony Vaio Jogdial"
Driver "evdev"
Option "Device" "/dev/input/by-id/acpi-sony_laptop-event-mouse"
Option "Name" "Sony Vaio Jogdial"
EndSection
You have to add these devices to ServerLayout section also. Your ServerLayout might look like this for example:
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "Sony Vaio Keys" "SendCoreEvents"
InputDevice "Sony Vaio Jogdial" "SendCoreEvents"
InputDevice "Synaptics Touchpad"
EndSection
After restart X, xev should start report also special keys. But there is problem with current sony-laptop module, so FN+F5 keys for example are not seen in X. They are reported, but have keycode higher than 255, and evdev does allow only keycodes from 8 to 255. On my model, only S1 and AV-MODE keys are reported.
You need: hal
When you have keys working, you might want keys mapped to correct functions. That means for example FN+F5 will become from FN+F5 symbol to BrightnessLower symbol. It is smart way and might get you functioning keys without any configuring, if distribution is prepared for that.
You need recent hal to get it work, hal quirk site says you need 0.5.10 or newer. If your model is not supported already, you have to try some mapping. For Sony Vaios i found codes pretty stable, as sony-laptop does it report same for every supported model. Basically you have to choose, if you have volume up and down on FN+F3 keys or have media key. On my model, i have volume working by default, as events are reported through normal keyboard driver and no extra support is needed (vise choice Sony, thanks!).
You can skip following guide to fill-in your laptop id and install recent fdi/information/10freedesktop/30-keymap-module-sony-laptop.fdi file from hal-info GIT. Replace with that file in /usr/share/hal/fdi/information/10freedesktop/30-keymap-module-sony-laptop.fdi. I have also local copy here, but it might get outdated. New file is universal for any laptop using sony-laptop module and should work out of the box. After you have replaced local file, continue to hal restart.
First get version of your laptop that HAL see. Get that using command lshal | grep 'system.hardware.product' It should be the same as you see on display or bottom of laptop. Copy text in quotes.
Visit /usr/share/hal/fdi/information/10freedesktop/30-keymap-module-sony-laptop.fdi. If you don't find your model in any match, add your model version after semicolor to right list. In my file they were two, one with volume keys, second with zoom and without. Second was my choice. Just add your model identifier into contains_outof parameter after semicolon to match, that has all your special keys. I suggest you dont put there S1, S2 or AV-MODE there, because they have not single meaning and should be left as user configurable via Keyboard shortcuts or similar tools. My part of config follows, with my model at the end.
<match key="/org/freedesktop/Hal/devices/computer:system.hardware.product"
contains_outof="VGN-FS790B;VGN-TZ11;VGN-TZ16;VGN-FZ210CE">
<append key="input.keymap.data" type="strlist">0x06:mute</append> <!-- Fn+F2 mute -->
<append key="input.keymap.data" type="strlist">0x07:volumedown</append> <!-- Fn+F3 mixer down -->
<append key="input.keymap.data" type="strlist">0x08:volumeup</append> <!-- Fn+F4 mixer up -->
<append key="input.keymap.data" type="strlist">0x09:brightnessdown</append> <!-- Fn+F5 brightness up -->
<append key="input.keymap.data" type="strlist">0x0a:brightnessup</append> <!-- Fn+F6 brightness down -->
<append key="input.keymap.data" type="strlist">0x0b:switchvideomode</append> <!-- Fn+F7 switch crt/lcd -->
<append key="input.keymap.data" type="strlist">0x0e:zoom</append> <!-- Fn+F10 zoom -->
<append key="input.keymap.data" type="strlist">0x10:suspend</append> <!-- Fn+F12 hibernate -->
<append key="info.capabilities" type="strlist">input.keymap</append>
</match>
Restart hal using sudo /etc/init.d/hal restart. It should remap known keys for your laptop. You can check that using command lshal | grep keymap. You should see sony-laptop somewhere in its output. Now if you have backlight system supported by gnome-power-manager, it should react to lower and raise brighntess keys. If you have slider in power options with brightness, you have backlight control supported.
Now you should have mapped function keys to right keycodes. As it does map FN+FX keys with icons on keyboard to keycodes lower than 255, that FN keys should be available to bind some fuction on them. If your desktop support it, they might work out of the box. You can try assign them some functionality keyboard shortcuts panel in Gnome, or try xev command from terminal.
You might want to use xinput also. It will test, if your X server does receive really events. With command xinput test "Sony Vaio Keys" you can test mapped keys. You should see something like: key press 235, if your keys are working. Note you will not see any key without mapped by HAL, because keycodes emitted are higher than 256 and are ignored by X server (or i think so).
If your model was missing and after modification does work, please report changes to that file to hal developers. Instructions are at hal keymap quirks.
Author: Petr Mensik alias "Pihhan". Last modification 2008-09-27.