Running Gentoo on a Sony Vaio PCG-V505BX

Standard Disclaimer: These notes are a work in progress, use them at your own risk ;-)

My old notes on setting up debian woody on this machine are here.

pic of the vaio

Hardware

Function Hardware Comments Status
Processor: Intel P4 2.0Ghz - Mobile Ok
RAM: 512 MB Ok
Display: 12.1in TFT; 1024x768 Nice and small! Ok
Video: ATI Radeon "Mobility" (M6 LY), 16MB Using the vesa driver Ok
Audio: Intel 82801CA/CAM AC'97 Audio Intel ICH (i8xx) Driver Works (CONFIG_SOUND_ICH), ALSA Works Fine Ok
Optical: MATSHITA UJDA745 DVD/CDRW Works Great! Ok
HardDisk: HITACHI_DK23EA-40, ATA DISK drive (40GB) Ok
Ethernet: Integrated Intel Pro Works fine with driver eepro100 Ok
Wifi: Built-in LAN-Express 802.11b Works great with the HostAP driver. Ok
Firewire: Ricoh Co Ltd R5C551 IEEE 1394 Controller A single connection on left side Untested
PCMCIA: Ricoh Co Ltd RL5c475 Use the Yenta driver Ok
USB: USB Controller: NEC Corporation USB Use the OHCI Controller Driver Ok
Media: "MagicSlot" Sony Memory Stick Reader Enable USB Mass Storage and SCSI Disk Support Ok

Configuration

The basics are in the Hardware section above, but let me detail some things below. Note, I (currently) am using kernel 2.6.14.4 with the relevant Software Suspend patch.

Here's my current .config.

Power Management: ACPI

[Update]: Excellent notes on setting up ACPI and other power management ideas are here.

ACPI is a more flexible alternative to APM and it is necessary to get some of the hardware to work. Kernel 2.6.14.4 has full ACPI support, but you need to install and use a user-land daemon. The daemon (acpid) (available in portage) responds to power-management events (hitting the power button, closing/opening the lid, plugging in/out the AC power cable) by running a script of your choosing. For instance, when I unplug the AC power cable, acpid runs my script to dim the LCD and start laptop-mode.

Configure the kernel to run ACPI (CONFIG_ACPI) and use the fan, battery, processor, button, ac and thermal options.

As you will see in the scripts below, I'm making use of the kernel's laptop-mode. This should help save some battery. See Documentation/laptop-mode.txt in your kernel sources for more info and the scripts. I've put the laptop-mode script in /etc/init.d and its config file in /etc/conf.d -- those are not the defaults, so you'll have to modify your scripts if you do the same.

My /etc/acpi/events directory has 4 files:

/etc/acpi/events/battery:

event=battery.*
action=/etc/acpi/battery.sh %e
/etc/acpi/events/ac_adaptor:
event=ac_adapter.*
action=/etc/acpi/ac.sh %e
/etc/acpi/events/lidbtn:
event=button/lid
action=/etc/acpi/lidbtn.sh
/etc/acpi/events/powerbtn:
event=button[ /]power.*
action=/etc/acpi/powerbtn.sh
My /etc/acpi directory holds the 4 scripts called by events:

/etc/acpi/battery:

#! /bin/bash                    
                                
# Modified from /usr/src/linux-2.6.9/Documentation/laptop-mode.txt
# Automatically disable laptop mode when the battery almost runs out.
                                
BATT_INFO=/proc/acpi/battery/$2/state
CONFIG=/etc/conf.d/laptop-mode
                                
if [[ -f /proc/sys/vm/laptop_mode ]]
then                            
   LM=`cat /proc/sys/vm/laptop_mode`
   if [[ $LM -gt 0 ]]           
   then                         
     if [[ -f $BATT_INFO ]]     
     then                       
        # Source the config file only now that we know we need
        if [ -f $CONFIG ] ; then
                . $CONFIG
        fi                      
        MINIMUM_BATTERY_MINUTES=${MINIMUM_BATTERY_MINUTES:-'10'}
                                
        ACTION="`cat $BATT_INFO | grep charging | cut -c 26-`"
        if [[ ACTION -eq "discharging" ]]
        then
           PRESENT_RATE=`cat $BATT_INFO | grep "present rate:" | sed "s/.* \([0-9][0-9]* \).*/\1/" `
           REMAINING=`cat $BATT_INFO | grep "remaining capacity:" | sed "s/.* \([0-9][0-9]* \).*/\1/" `
        fi
        if (($REMAINING * 60 / $PRESENT_RATE < $MINIMUM_BATTERY_MINUTES))
        then
           /sbin/laptop_mode stop
        fi
     else
       logger -p daemon.warning "You are using laptop mode and your battery interface $BATT_INFO is missing.                                  This may lead to loss of data when the battery runs out.  Check kernel ACPI                                  support and /proc/acpi/battery folder, and edit /etc/acpi/battery.sh to set                                  BATT_INFO to the correct path."
     fi
   fi
fi
/etc/acpi/lidbtn.sh:
#!/bin/sh

echo "Suspending to RAM"
echo -n mem > /sys/power/state
/etc/acpi/powerbtn.sh:
#!/bin/sh

# I pressed the power button, so shutdown gracefully

/sbin/init 0
/etc/acpi/ac.sh:
#!/bin/sh

status=`awk '/^state: / { print $2 }' /proc/acpi/ac_adapter/ACAD/state`

case $status in
        "on-line")
                echo "AC Power On-Line"
                
                # set lcd to maximum brightnes
                /usr/bin/spicctrl -b 220

                # let wifi card use full power
                iwconfig wlan0 power off

                # run the laptop-mode script to set CPU frequency 
                # and harddrive spin-down times
                /etc/init.d/laptop-mode stop
                exit 0
        ;;
        "off-line")
                echo "Running on Battery"

                # set lcd to medium brightnes
                /usr/bin/spicctrl -b 100

                # power off wifi card after 3 seconds of inactivity
                iwconfig wlan0 power on power max period 3

                # throttle CPU speed and set harddrive spin-down times
                /etc/init.d/laptop-mode start
                exit 0
        ;;
esac
FYI: You can run the acpid daemon in debug mode to verify it is running your scripts on the proper events.

SonyPI

Enable kernel option CONFIG_SONYPI (Sony Vaio Programmable I/O Control Device Support) as a module under the Character Devices menu. This will allow you to use the 'spicctrl' program to control the backlight of your LCD (very handy if used in conjunction with ACPI; eg. dim the LCD when you remove the AC power cable). spicctrl is available via portage.
> mknod /dev/sonypi c 10 250
You'll also need some module instructions for the kernel. Create /etc/modules.d/sonypi with the following contents:
alias char-major-10-250 sonypi
options sonypi minor=250
Now run modules-update.

Wireless

The hostap driver supports monitoring and scanning modes.

I'm able to run kismet (version 3.0.1c)! My /etc/kismet/kismet.conf has the all important line source=hostap,wlan0,wifi. I also had to set the logtemplate directive to the home dir of the suiduser - otherwise the server tries to write to a directory it cannot access: logtemplate=%h/kismet/%n-%d-%i.%l

GPS

I am able to connect a Garmin Gecko 201 via a Keyspan Serial-to-USB adapter. Make sure you have the Keyspan adapter configured by setting CONFIG_USB_SERIAL_KEYSPAN=m.

GpsDrive is the motivating application here ;-)

CD-ROM

Linux finds the cdrom as "hdc: UJDA745 DVD/CDRW, ATAPI CD/DVD-ROM drive". To use this drive as a CD-R/W you need to have the following kernel setup. Also, add append="hdc=ide-scsi" to your lilo.conf

CONFIG Description State
CONFIG_BLK_DEV_IDESCSI IDE SCSI Emulation M or Y
CONFIG_BLK_DEV_IDECD IDE CDROM Support N
CONFIG_SCSI SCSI Support Y
CONFIG_CHR_DEV_SG Generic SCSI Support M or Y
CONFIG_BLK_DEV_SR SCSI CDROM Support M or Y

USB

Note that this machine's USB Controller uses the OHCI driver, not the UHCI driver. During boot, it will detect 3 USB ports: the 2 USB ports and the Sony Memory Stick slot ("Magic Gate").

I can mount a USB keychain drive via:

mount -t auto /dev/sdb /usbkey

Memstick

The memory stick will be detected as a scsi device if your have SCSI emulation, basic SCSI support, USB Mass Storage (CONFIG_USB_STORAGE) and SCSI Disk (CONFIG_BLK_DEV_SD) in your kernel. Note that this machine's USB Controller uses the OHCI driver not the UHCI driver. Add an entry in /etc/fstab:
/dev/sda1     /memstick    vfat     noauto,rw,user    0     0 
Then do "mount /memstick" or "mount -t vfat /dev/sda1 /memstick".

XFree86

I'm using the standard vesa driver at the moment. Here's my XF86Config.

Software Suspend

The vanilla software suspend patch allows me to hibernate with no problems. Even when running X! This is nice when "Suspend to RAM" (ACPI state S3) isn't enough.

Enjoy!