Ubuntu On Sony Vaio FW Series

Tips & Tricks related to Sony Vaio FW series laptops

AV Mode media key patch for 9.10 (Karmic Koala)

with 6 comments

I have made a patch for latest sony-laptop module in 2.6.31 kernel to fix broken AV Mode key handling.

If you want to apply this patch please follow fourth step in Finally a brightness How To post but apply this new patch instead of old one.

From: Anton Veretenenko <anton@veretenenko.ru>
Subject: [PATCH] UBUNTU: sony-laptop: Sony Vaio FW series media keys: AV Mode key support broken

Bug: #502751

AV Mode media key support broken on sony-laptop kernel module.

Signed-off-by: Anton Veretenenko <anton@veretenenko.ru>
---
 drivers/platform/x86/sony-laptop.c |    2 ++
 1 file changed, 2 insertions(+)
--- /usr/src/linux-2.6.31/drivers/platform/x86/sony-laptop.c	2010-01-03 23:21:05.000000000 +0500
+++ drivers/platform/x86/sony-laptop.c	2010-01-04 03:32:20.000000000 +0500
@@ -868,6 +868,8 @@ static struct sony_nc_event sony_100_eve
 	{ 0x10, SONYPI_EVENT_ANYBUTTON_RELEASED },
 	{ 0x91, SONYPI_EVENT_PKEY_P2 },
 	{ 0x11, SONYPI_EVENT_ANYBUTTON_RELEASED },
+	{ 0xA1, SONYPI_EVENT_PKEY_P3 },
+	{ 0x21, SONYPI_EVENT_ANYBUTTON_RELEASED },
 	{ 0x81, SONYPI_EVENT_FNKEY_F1 },
 	{ 0x01, SONYPI_EVENT_FNKEY_RELEASED },
 	{ 0x82, SONYPI_EVENT_FNKEY_F2 },

Bugreport on lanuchpad.net.

Written by egaistek

January 22, 2010 at 14:29

Posted in Vaio

Tagged with , , , ,

HDMI/VGA display detection solution

with 2 comments

Here is my solution about second display detection before login screen. First of all I configured xorg for one screen only with Catalyst Control Center (CCC) and saved xorg.conf as xorg.conf.mono in /etc/X11. Then I connect second monitor to HDMI and reconfigures xorg for double screen with Xinerama enabled and saved xorg.conf as xorg.conf.dual in /etc/X11.

The only way I’ve found to detect another display on HDMI/VGA port is by reading xorg log file after it loads (/var/log/Xorg.0.log). If display connected through HDMI there is “DFP1 connected” line present and “DFP1 disconnected” if not. The same is for VGA except that DFP1 should be changed to CRT1 I guess.

Ok, I need system to load xorg then read log file then select right config file (xorg.conf.mono/xorg.conf.dual) and put it as /etc/xorg.conf and restart xorg. This actions needs to be done before GDM loads because I don’t need any screen flickering with login screen 🙂

There is such script (/etc/gdm/Init/Default) which GDM runs before loading for initializing. I wrote a little script for actions I need and put it on top of just before <code>PATH=/usr/bin:$PATH</code> line /etc/gdm/Init/Default.

Here it is:

ISMULTI=`/bin/cat /var/log/Xorg.0.log | /bin/grep -c 'DFP1 connected'`
ISMULTI_MUTEX=/etc/X11/fglrx-multi-xorg-killed

if [ "$ISMULTI" != "1" ] ; then
    /bin/cp /etc/X11/xorg.conf.mono /etc/X11/xorg.conf
    if [ ! -f "$ISMULTI_MUTEX" ] ; then
        /usr/bin/touch "$ISMULTI_MUTEX"
        /usr/bin/killall Xorg
    else
        /bin/rm "$ISMULTI_MUTEX"
    fi
else
    /bin/cp /etc/X11/xorg.conf.dual /etc/X11/xorg.conf
    if [ ! -f "$ISMULTI_MUTEX" ] ; then
        /usr/bin/touch "$ISMULTI_MUTEX"
        /usr/bin/killall Xorg
    else
        /bin/rm "$ISMULTI_MUTEX"
    fi
fi

Now when booting with second display connected, I got two enabled displays on login screen ready and vise versa.

Written by egaistek

December 6, 2009 at 20:19

Posted in Vaio

HDMI/VGA display detection

with one comment

Does anybody knows how to detect second display before Xorg or GDM loads? I’m always moving between home with second display (through hdmi) and another places with just my laptop screen 🙂

Why am I asking. Ok I can enable second display in Catalyst Control Center (CCC), but for applying changes I need to re-login. Next I need to enable Xinerama and re-login again. Now I have two working displays. Next I move somewhere without additional display, boot my laptop. It boots to login screen with wrong resolution (1280), I login, disable Xinerama, re-login, disable second display, change resolution back (without re-login). That’s too m uch moves to enable/disable second display. Oh I forgot to mention, it’s all about FGLRX of course. XrandR does not work with Xinerama enabled. I guess radeonhd should work ok, but I need performance.

Here is what I want. Just before login screen appears system should check if second display connected and load appropriate configuration for Xorg.

I know how to detect it after GDM loads Xorg, and I’ll post a solution soon when I test it. But I want a better way out.

Stay tuned.

Written by egaistek

November 28, 2009 at 18:47

Posted in Vaio

Tagged with , , , , , , ,

Sony finally unlock Intel Virtualization

with 15 comments

As I saw on Bernhard Froemel‘s blog, Sony plans to make bios updates with enabled VT. Sony decides to enable it after people complain about non working XP Mode in Windows 7.

I see people confirming it in comments, but I still can not find any update for my model on sony-europe.com

Written by egaistek

October 26, 2009 at 02:06

Posted in Vaio

Tagged with ,

Ubuntu 9.10 Karmic Koala beta

with 47 comments

I just want to inform you, if you have not tried it yet. Brightness control works out of the box. S1 key works, AV key does not. Headphones jack detection works. Built-in microphone does not. Web camera works in Skype.

Dmesg output when using AV key:


sony-laptop: Unknown event: 0x100 0xa1
sony-laptop: Unknown event: 0x100 0x21

I guess sony-laptop module is without our patch or just a new one. I’ll check sources when I have time.

Stay tuned.

Written by egaistek

October 3, 2009 at 08:49

Brightness patch for FW4x models

with 31 comments

Thanks to Olivier Grégoire for supplying DSDT.aml for FW4 model. I have updated quick brightness guide post with new patch links, take a look.

Written by egaistek

July 20, 2009 at 23:22

Posted in Vaio

Tagged with , , , ,

HDMI sound output switcher for PulseAudio

with 9 comments

Here is another script which you can link for example to AV Mode button, to switch sound output to HDMI and back. First I thought I can use Alsa, but it works only with one application, other application can not play sound while another one is playing. So then I did it with PulseAudio which works correctly. This switcher works for all native Gnome/gstreamer sound applications, and some applications e.g. SMplayer refuse to switch their sound regardles what default output set in PulseAudio. If you have playing sound and then switched to HDMI, it will still play through old way and you need to restart your sound e.g. push stop/play button to point sound through new way.

First of all you need to prepare PulseAudio configuration. For some point PA does not add HDMI output to devices itself. We should add it and rename internal sound card to something readable. Open /etc/pulse/defauld.pa in editor with root privileges (e.g. sudo nano /etc/pulse/default.pa in terminal) locate line “#load-module module-pipe-sink” there. Open terminal and run this command there: aplay -l | grep -o -e "card [0-9]:.*[0-9]:" | sed -e "s/card \([0-9]\): \(.*\) \[.*device \([0-9]\).*/load-module module-alsa-sink device=hw:\1,\3 sink_name=\2/"

Command returns two lines which we need to add to default.pa file after that line you located earlier. In my case this lines look like:


#load-module module-null-sink
#load-module module-pipe-sink
load-module module-alsa-sink device=hw:0,0 sink_name=Intel
load-module module-alsa-sink device=hw:1,3 sink_name=HDMI

### Automatically load driver modules depending on the hardware available

Then you should restart PulseAudio (sudo /etc/init.d/pulseaudio restart) to changes make effect. You can check that devices added correctly by running pacmd list-sinks in terminal, you should see “name: <HDMI>” and “name <Intel>” if you have got the same names as in my case, theese names must be the same as after “sink_name” in lines you added to default.pa.

Ok, now to switcher:


#!/bin/bash
#
# Sound output switcher using Gnome,gconf,PulseAudio,Alsa,libnotify
#
# by Anton Veretenenko <anton&#91;email sign&#93;veretenenko.ru>

notify_show=1
notify_delay=500
hdmi_card_num=1
internal_card_name=Intel
hdmi_card_name=HDMI

is_hdmi_on=`amixer -c $hdmi_card_num cget numid=4,iface=MIXER,name='IEC958 Playback Switch' | grep -i -c -P -e "values=on"`

if [ "$is_hdmi_on" == "1" ]
then
 amixer -c $hdmi_card_num cset numid=4,iface=MIXER,name='IEC958 Playback Switch' off > /dev/null
 gconftool --set "/system/gstreamer/0.10/default/musicaudiosink" --type=string "pulsesink device=\"$internal_card_name\""
 gconftool --set "/system/gstreamer/0.10/default/audiosink" --type=string "pulsesink device=\"$internal_card_name\""
 gconftool --set "/system/gstreamer/0.10/default/chataudiosink" --type=string "pulsesink device=\"$internal_card_name\""
 pacmd "set-default-sink "$internal_card_name""
 if [ $notify_show -eq 1 ]
 then
  notify-send -u normal -t $notify_delay -i gnome-sound-properties "HDMI Off" "Sound output switched to $internal_card_name"
 fi
else
 amixer -c $hdmi_card_num cset numid=4,iface=MIXER,name='IEC958 Playback Switch' on > /dev/null
 gconftool --set "/system/gstreamer/0.10/default/musicaudiosink" --type=string "pulsesink device=\"$hdmi_card_name\""
 gconftool --set "/system/gstreamer/0.10/default/audiosink" --type=string "pulsesink device=\"$hdmi_card_name\""
 gconftool --set "/system/gstreamer/0.10/default/chataudiosink" --type=string "pulsesink device=\"$hdmi_card_name\""
 pacmd "set-default-sink "$hdmi_card_name""
 if [ $notify_show -eq 1 ]
 then
  notify-send -u normal -t $notify_delay -i gnome-sound-properties "HDMI On" "Sound output switched to $hdmi_card_name"
 fi
fi

Here you need to change hdmi_card_num to number of your HDMI sound card (you can get it by aplay -l in terminal) and internal_card_name to name you found earlier and hdmi_card_name to hdmi card name which you saw after “sink_name” parameter.

This switcher will show a popup notification, like you see when changing brightness 🙂

P.S. How to link this script to AV Mode button (XF86Launch2) read in post about headphones switcher script.


Written by egaistek

July 8, 2009 at 13:22

Posted in Vaio

Tagged with , , , , , , ,

Headphones/Front switch script

with 4 comments

I’m not defining a “hippo” model for “snd-hda-intel” to make headphones detection about we talk earlier. Because I’m using my headphones plug very rarely, I decided to write a shell script to switch sound to headphone and back and link it to to S1 button. This information could help you if you want to make S1 button to do something else too.

Here is a switch script, when you run it, it detects if headphones are switched on then it switch it off and vice-versa. Front mixer channel will be switched off if headphones switched on and vice-versa.


#!/bin/bash
# by Anton Veretenenko <anton&#91;email sign&#93;veretenenko.ru>

is_front_on=`amixer -c 0 cget numid=2,iface=MIXER,name='Front Playback Switch' | grep -i -c -P -e "values=on,on"`

if [ "$is_front_on" == "1" ]
then
 amixer -c 0 cset numid=2,iface=MIXER,name='Front Playback Switch' off
 amixer -c 0 cset numid=3,iface=MIXER,name='Headphone Playback Switch' on
else
 amixer -c 0 cset numid=2,iface=MIXER,name='Front Playback Switch' on
 amixer -c 0 cset numid=3,iface=MIXER,name='Headphone Playback Switch' off
fi

To link S1 button to this script (make a shortcut) you need to delete shortcut from System->Preferences->Keyboard Shortcuts for this button, if you have it. I guess you saw that S1 button named as “XF86Launch1” in keyboard shortcuts, you need this name later.

Open gconf-editor (Alt+F2, type gconf-editor, Run). On the left tree select apps->metacity->global_keybindings the on the right you should see a list of keys, select one you like (I choose “run_command_1”) and edit it (right click, Edit Key), enter name of S1 button (“XF86Launch1”) into value field. Then select “keybinding_commands”  on the left.

Edit “command_1” key, into value field you should enter path to the script, in my case it is “/home/egaistek/scripts/alsa-front-mute”. That’s all, it should work now.

P.S. Do not forget to add executable permissions to a script file (chmod +x in terminal or File->Properties, Permissions tab, set “Allow executing file as program” in Nautilus/File Explorer)

P.P.S. This works only for Gnome without Compiz running. If you want to add shortcuts with Compiz, use Compiz configuration tools.

Written by egaistek

July 7, 2009 at 07:49

Posted in Vaio

Tagged with , , , , ,

Quick brightness guide for Jaunty

with 62 comments

This little guide is faster an easier version of previous brightness how to. Since Jaunty already have sony-laptop patch included, we need to patch our DSDT bios table only and override default one with patched, while kernel is loading. I saw many people have problems with DSDT compiling, so I removed dsdt-error.patch patches from pack, and changed it with another line in terminal.

I have made a script which will make all what needed, you just need to select right patch for your model. Download new patches pack. Unpack it, then pop up your terminal and go into that directory, where you’ve unpacked it. There is 3 patches included dsdt-ati-fix-fw1x.patch, dsdt-ati-fix-fw2x.patch, dsdt-ati-fix-fw3x.patch. If you have FW3x(x) model, then use dsdt-ati-fix-fw3x.patch and so on for FW1x(x)/FW2x(x). Ok, you’ve made your choice, now just type this in terminal:

Ok, I have changed script and make him choose the right patch for you, just type this in terminal then:

sudo ./dsdt-patch

That’s all 🙂

Here is a source code of that script, for those who interested:

#!/bin/bash
# by Anton Veretenenko
# version: 0.2

patch_temp_dir=vaio_fw_patch
isroot=`whoami`

if [ ! $# -eq 0 ]
then
echo “Use: sudo ./dsdt-patch”
exit
fi

if [ ! “$isroot” == “root” ]
then
echo “Error: Make sure you run this script with sudo”
exit
fi

echo “Creating temp directory”
mkdir “/tmp/$patch_temp_dir”

if [ ! -x /usr/sbin/dmidecode ]
then
# if dmidecode isn’t found, let’s install it too
echo “Installing dmidecode”
apt-get install dmidecode
else
echo “dmidecode found”
fi

isfw1=`dmidecode –type system | grep -i -c -P -e “Product Name: VGN-FW(1).*”`
isfw2=`dmidecode –type system | grep -i -c -P -e “Product Name: VGN-FW(2).*”`
isfw3=`dmidecode –type system | grep -i -c -P -e “Product Name: VGN-FW(3).*”`
isfw4=`dmidecode –type system | grep -i -c -P -e “Product Name: VGN-FW(4).*”`
if [ “$isfw1” == “1” ]
then
patch_file=dsdt-ati-fix-fw1x.patch
elif [ “$isfw2” == “1” ]
then
patch_file=dsdt-ati-fix-fw2x.patch
elif [ “$isfw3” == “1” ]
then
patch_file=dsdt-ati-fix-fw3x.patch
elif [ “$isfw4” == “1” ]
then
patch_file=dsdt-ati-fix-fw4x.patch
else
echo “Could not select the right patch for you, does it FW model? Contact me.”
rm -rfd “/tmp/$patch_temp_dir/”
exit
fi

if [ ! -r “$patch_file” ]
then
echo “Error: Could not read $patch_file file”
rm -rfd “/tmp/$patch_temp_dir/”
exit
else
echo “Selected $patch_file patch for you”
fi

cp “$patch_file” “/tmp/$patch_temp_dir/”
cd “/tmp/$patch_temp_dir”

if [ ! -x /usr/bin/iasl ]
then
# if iasl isn’t found, let’s install it
echo “Installing iasl”
apt-get install iasl
else
echo “iasl found”
fi

if [ ! -x /usr/bin/acpidump ]
then
# if acpidump isn’t found, let’s install it too
echo “Installing acpidump”
apt-get install acpidump
else
echo “acpidump found”
fi

if [ ! -x /usr/bin/patch ]
then
echo “Installing patch command”
apt-get install patch
else
echo “patch command found”
fi

echo “Dumping DSDT table to DSDT.aml”
acpidump -b -t DSDT -o DSDT.aml
if [ ! $? -eq 0 ]
then
# if acpidump failed, show error
echo “acpidump failed”
rm -rfd “/tmp/$patch_temp_dir/”
exit
fi

echo “Decompiling DSDT.aml to DSDT.dsl”
iasl -d DSDT.aml
rm DSDT.aml
if [ ! $? -eq 0 ]
then
# if iasl failed, show error
echo “iasl failed”
rm -rfd “/tmp/$patch_temp_dir/”
exit
fi

echo “Patching DSDT.dsl with $patch_file”
patch < "$patch_file" if [ ! $? -eq 0 ] then # if patching failed, show error echo "$patch_file patch failed" rm -rfd "/tmp/$patch_temp_dir/" exit fi echo "Fixing _T_0 errors in DSDT.dsl" sed -i 's/_T_0/T_0/g' DSDT.dsl if [ ! $? -eq 0 ] then # if sed failed, show error echo "_T_0 fixing failed" rm -rfd "/tmp/$patch_temp_dir/" exit fi echo "Compiling patched DSDT" iasl DSDT.dsl if [ -f DSDT.aml ] then echo "Compilation successfull, updating initramfs" cp DSDT.aml /etc/initramfs-tools/ dpkg-reconfigure linux-image-`uname -r` else echo "Error: DSDT compilation error" fi # deleting temp dir rm -rfd "/tmp/$patch_temp_dir/" if [ -f /etc/initramfs-tools/DSDT.aml ] then echo "DSDT patch applied, you should reboot your system now" fi [/sourcecode]

Written by egaistek

May 28, 2009 at 03:54

Posted in Vaio

Tagged with , , , , , ,

On Jaunty

with 47 comments

Just updated.
Brightness works out of the box if you have patched dsdt in initramfs =)
Sound works and not integrated mic.
Video/3D works with fglrx.
S1/AV and fn keys works.
I saw that usb flash/hdd drives are fast now but system load too much.

I guess I have problems with wireless, poor performance. I’ve noticed it because I’m using NFS shares through wifi, e.g. watching movies. And on Jaunty nautilus and player hangs more of a time. Something wrong there. Do you have such problems?

Written by egaistek

April 27, 2009 at 17:02

Posted in Vaio

Tagged with , , ,