Sony Vaio PCG-C1VRX/K and Debian Linux Sarge

Kernel 2.6.11 Custom built for special needs, details later

Here I will try to explain as best as I can how I got Debian Sarge working on my Sony PCG-C1VRX/K laptop.
A lot of things are not obvious about the installation, so I will try to get to the details as much as necessary, so that it can be understood. I am still updating the site frequently, as I discover new things all the time.

Some things are very straight forward, so I wont go into them. What I will focus on, is:

Install Debian Sarge
X-Windows and 1024x480 Resolution
Optimized 2.6.11 Kernel
ACPI Power Management (Suspend to RAM & Power Savings on Battery)
Camera - Motioneye
JogDial
Capture Button

Bluetooth
Extra Features (Gnomemeeting; Nokia 6630; Japanese Input)



Install Debian Sarge:

It wasnt a very easy task but also wasnt very hard (
like the Libretto L1 ) ,andI am done after all. What I had to do as I have no USB CD drives, I used a USB Floppy drive. I grabbed Debian`s latest Floppy Images from here and made the 3 necessary boot floppies for the install, which are BOOT ROOT and NET drivers. I booted with the 3 floppies, and it luckily recognized my Network Card, which is aNetgear MA401. It uses the Orinoco driver. You may use any older type of PCMCIAcards, that the 2.4.27 kernel supports, because at the time of writing that is the kernel that comes on the floppy. It was pretty straight forward from then on, as the Net was recognized, so I could attach to the Mirror`s and start downloading the distribution. First it installes the Partitioner and other things, thenasks 10000 questions, and shortly after that you are on your way for getting about 500 or so MBs from on of the mirrors, and installes your full distribution.

Few notes:

If you have an internet connectivity issue even after the PCMCIA network card was recognized, you can change console ALT CTRL (F1-F6). Your install is at F1 soyou can change to F2, press enter, and you get a blinking cursor. At this pointyou dont have a lot of power, as most commonly used commangs are unavailable, as they dont fit on the floppy. You can use cat for editing and viewing. Most importantly you can restart PCMCIA services if there is a problem, by typing

/etc/init.d/pcmcia

X-Windows and 1024x480 Resolution

This was a challenging one. Debian Sarge at time of writing (2005 May 6th) comes with Xfree86 4.3 which is a pretty stable X , but not good for the ATI Rage Mobility P/M Mach64 that this laptop has. I read many pages, and many people has it working, but nobody with 4.3. Usually 4.2 or earlier, as this laptop isnt new anymore. I suffered and sweat a lot until I realized this. I tried at least 100 different XF86Config-4 configuration, but it was always the same. GRAYISH SCREEN FILLS UP THE LCD. Darn. Well, what I learned in the 2 days that I tried to fix it was that 4.3`s ati driver is not good for this laptop when displaying 1024x480, only in 8bit (unacceptable) or 640x480 (way unaccaptable).

I went and grabbed the
Xfree 4.5 which is the newest one available. I also tried 4.4, with no luck. So here we go how to make X work for this beautiful laptop.If you want to give it a shot without all the hassle to get 4.5 going, just copy my XF86Config-4 file from below, and use it. If it wont give you the greyish screen, you are in luck. If it will, then keep reading on.

Go to here and download the files necessary. Please read that page carefuly, as I dont include step by step install on X. I could do it by reading the manual, and it didnt take long, so I am sure you can manage as well. What is compilcated (or what was for me) is the messed up font. I will get into that in detail shortly. You will see on X`s site, that you need 13 mandatory files to be downloaded. There are also a good 10 or so files that are extra files, and not necessary. I have chosen a few of those too, and downloaded them, like the 100dpi fonts, and the X headed files for future compilings that might take place. When you compile for X something, it needs the headers, and since this X didnt come from Debian, you cannot just apt-get for the header files, so include them if you need them. That file is called Xprog.tgz .

Another important thing that you will see on that site, is to check for what version you exactly need. There is a script to be downloaded from them in advanced, to check what version of X you will need, so you can make sure to download theright one.

That script is called Xinstall.sh and you need to run

sh Xinstall.sh -check

this will show you what version to download. From here on I trust you can get a working X going. Now for me what happened, is that when I started X for the first time (I have KDM start it for me) my fonts were all messed up. I couldnt see anything except squares instead of letter. Any font that was present on my window was a square. It was terrible. It took me days to find out why, and finally I found this site that explained what might have happened to me. It was written for Suse linux, but it sure worked for me. What I had to do is to make sure I donthave absolete entries in my

/etc/fonts/fonts.conf

file. Now my font.conf looks like this. Its a bit different from what that gentleman describes on his site, but when I did his way, my X was way too slow. He puts every font directory as a new entry, and instead of that, I just inserted one link to a directory called FONTS that includes all the subdirectories with all the fonts. Now I also did what he describes in his "3rd step", which was to copy the fonts.dir files over the fonts.scale files in every directory where the fonts.scale file was empty. Anyways, after doing all this, my X is working like a charm in 24bit 1024x480 and with beautiful fonts.

Here is the top part of my /etc/fonts/fonts.conf file

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts.conf file to configure system font access -->
<fontconfig>

<!--
        The intent of this standard configuration file is to be adequate for
        most environments.  If you have a reasonably normal environment and
        have found problems with this configuration, they are probably
        things that others will also want fixed.  Please send any suggested
        changes to fonts@xfree86.org so that future releases can include
        such changes.

        Note that the normal 'make install' procedure for XFree86 is to
        replace any existing fonts.conf file with the new version.  Place
        any local customizations in local.conf which this file references.

        Keith Packard
-->

<!-- Font directory list configured on Wed Mar 16 18:25:30 EST 2005 -->

        <dir>/usr/X11R6/lib/X11/fonts</dir>

I only touched the very last line, and some other lines that were just like that, except obsolete, so I removed them. And VOILA, my X works great.

Now the main part, the XF86Config-4 file. Without that all you get is a 640x480screen, that is stretched across the LCD. You need to specify a ModeLine for the 1024x480 to work. I found way too many on the net when i thought that was the reason my X didnt work. What I have now is pretty much what I found last and tried last before I realized that my problem was very different from having a wrong ModeLine. If you want to tweak it more, just search for it. I am sure you find it.

/etc/X11/XF86Config-4

# XF86Config-4 (XFree86 X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the XF86Config-4 manual page.
# (Type "man XF86Config-4" at the shell prompt.)
#
# This file is automatically updated on xserver-xfree86 package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xfree86
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following commands as root:
#
#   cp /etc/X11/XF86Config-4 /etc/X11/XF86Config-4.custom
#   md5sum /etc/X11/XF86Config-4 >/var/lib/xfree86/XF86Config-4.md5sum
#   dpkg-reconfigure xserver-xfree86

Section "Files"
        FontPath        "/usr/X11R6/lib/X11/fonts/misc"
        FontPath        "/usr/X11R6/lib/X11/fonts/OTF"
        FontPath        "/usr/X11R6/lib/X11/fonts/TTF"
        FontPath        "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
        FontPath        "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
        FontPath        "/usr/X11R6/lib/X11/fonts/Type1"
        FontPath        "/usr/X11R6/lib/X11/fonts/CID"
        FontPath        "/usr/X11R6/lib/X11/fonts/Speedo"
        FontPath        "/usr/X11R6/lib/X11/fonts/100dpi"
        FontPath        "/usr/X11R6/lib/X11/fonts/75dpi"
        FontPath        "/usr/share/fonts/truetype/sazanami"
EndSection

Section "Module"
        Load    "GLcore"
        Load    "bitmap"
        Load    "dbe"
        Load    "ddc"
        Load    "dri"
        Load    "extmod"
        Load    "freetype"
        Load    "glx"
        Load    "int10"
        Load    "record"
        Load    "speedo"
        Load    "type1"
        Load    "vbe"
EndSection

Section "InputDevice"
        Identifier      "Generic Keyboard"
        Driver          "keyboard"
        Option          "CoreKeyboard"
        Option          "XkbRules"      "xfree86"
        Option          "XkbModel"      "jp106"
        Option          "XkbLayout"     "jp"
EndSection

Section "InputDevice"
        Identifier      "Configured Mouse"
        Driver          "mouse"
        Option          "CorePointer"
        Option          "Device"                "/dev/psaux"
        Option          "Protocol"              "PS/2"
        Option          "Emulate3Buttons"       "true"
        Option          "ZAxisMapping"          "4 5"
EndSection
Section "InputDevice"
        Identifier      "Generic Mouse"
        Driver          "mouse"
        Option          "SendCoreEvents"        "true"
        Option          "Device"                "/dev/input/mice"
        Option          "Protocol"              "ImPS/2"
        Option          "Emulate3Buttons"       "true"
        Option          "ZAxisMapping"          "4 5"
EndSection

Section "Device"
        Identifier      "Generic Video Card"
        Driver          "ati"
EndSection

Section "Monitor"
        Identifier      "DXS:1313"
        #HorizSync      28-50
        #VertRefresh    43-75
        #Option         "DPMS"
        Modeline "1024x480" 29.5 1024 1032 1176 1344 480 491 493 525 -hsync -vsync
EndSection

Section "Screen"
        Identifier      "Default Screen"
        Device          "Generic Video Card"
        Monitor         "DXS:1313"
        DefaultDepth    24
        SubSection "Display"
                Depth           1
                Modes           "800x600" "640x480"
        EndSubSection
        SubSection "Display"
                Depth           4
                Modes           "800x600" "640x480"
        EndSubSection
        SubSection "Display"
                Depth           8
                Modes           "1024x480" "640x480"
        EndSubSection
        SubSection "Display"
                Depth           15
                Modes           "800x600" "640x480"
        EndSubSection
        SubSection "Display"
                Depth           16
                Modes           "1024x480" "640x480"
        EndSubSection
        SubSection "Display"
                Depth           24
                Modes           "1024x480" "640x480"
        EndSubSection
EndSection

Section "ServerLayout"
        Identifier      "Default Layout"
        Screen          "Default Screen"
        InputDevice     "Generic Keyboard"
        InputDevice     "Configured Mouse"
        InputDevice     "Generic Mouse"
EndSection

Section "DRI"
        Mode    0666
EndSection


I can use the 1024x480 resoltuion and my JogDial works as a mousewheel by usingthis config file. (UPDATE: I recently read, that Jogdial works out of the box if you have a kernel 2.6.9 or higher.) That is all I care about. I also tried to make DRI/DRM support to work, and got 80% complete, but never finished it. I will include info about what I did to get that far.


Optimized 2.6.11 Kernel

I have downloaded the sources from here and installed it on my laptop. I also have a Dell 700m with a beefy CPU Centrino 1.6, and a compile takes about 25 -30 minutes. Given that, I compiled at least 20 kernels until I arrived to this stage of having one that I like and keep, and suggest to other people. If you are bored with my talk, and details, grab the kernel config file from here (FIXME broken link) and compile your kernel. If you need the details, read on. What I included in the kernel are the following mandatory things. I compiled in CPU MSR and CPUID support, which is needed for the Longrun. I also included Longrun support, and have choosen CRUSOE as the type of CPU. Other than this, I made sure the kernel has adequate PCMCIA support, Sound support, USB Blueetooth, Wireless (For wireless PCMCIA) and  the SONY spcific things, like the Jogdial and the Camera onboard. Other things I might have forgotten to mention, but to emphasize the point, EVERYTHING works on the laptop, so the kernel should be right. This kernel is a regular Debian kernel, which needs INITRD support. I am sure you are aware of that if you are an oldtimer Debian fellow.

Here is my /boot/grub/menu.lst portion that is for the new compiled kernel. It was created automatically when I installed the kernel, except for that little ACPI parameter which I included and which is VERY necessary for ACPI suspend, but more on that later. Just make sure you have that.

title           Debian GNU/Linux, kernel 2.6.11
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.11 root=/dev/hda2 ro acpi_sleep=s3_bios
initrd          /boot/initrd.img-2.6.11
savedefault
boot


And here is my /etc/modprobe.conf file that I created to load the Camera and Sony drivers as they need to be loaded. This was a battle also, as many people have wrong info on their sites, or just their laptop behaves differently, but for me this works only. WHat is different from others` site is that they use 250 for the sonypi minor and I use 63. This I got by inserting sonypi when I didnt have this modprobe.conf file in place, and I did a "dmesg | grep sonypi" which showed me the right minor was 63 for sonypi on my laptop. When I had 250 before that, my camera misbehaved badly, and I couldnt get the FN keys to work. Beaware.

/etc/modprobe.conf

alias char-major-10-63 sonypi
options sonypi minor=63 camera=1 fnkeyinit=0
alias char-major-81 videodev
alias char-major-81-0 meye
options meye gbuffers=32 video_nr=0
include /etc/modprobe.d/


Here the last line makes sure the rest of the modules wont get ignored. Must Have.

Thats all about the kernel I can think of. If I know more, I post more.

ACPI Power Management (Suspend to RAM & Power Savings on Battery)


This is a tricky part. This Sony VAIO does not like to Come back (resume) from suspend. What I could achieve, is that with kernel 2.6.11, and a boot parameter passed by Grub, the system is suspendable and resumeable, if there is no current Network traffic going on with the PCMCIA network card. IF there is, the PCMCIA cannot be ejected, and it will halt the process. I made a script, that will get triggered when I close the lid and suspend. When I open the lid, I have to press a key to wake up. What you need the most is the 2.6.11 kernel, and the acpid package (apt-get install acpid). That has to be running, so that the laptop will pay attention to when the LID is closed.

Here is my /etc/acpi/lidbtn.sh script

#!/bin/bash

killall cardmgr
sleep 3

cardctl eject

rmmod usb_storage
rmmod uhci_hcd
rmmod usbcore

echo "Oyasumi..."
sleep 2

echo "mem" > /sys/power/state

cardctl insert
sleep 3
cardmgr


modprobe usb_storage
modprobe uhci_hcd
modprobe usbcore

#Personal Modifications

/etc/acpi/ac.sh
/etc/init.d/laptop-mode restart

For this of course you need another script, which tells acpid to run this previous script upon the LID event. And that is /etc/acpi/events/lidbtn

It looks like this

event=button/lid
action=/etc/acpi/lidbtn.sh


Now you should be able to suspend and come out, given if you pass the following little boot parameter into Grub`s menu.lst file. The parameter is this

acpi_sleep=s3_bios

And the way it looks when inserted into the menu.lst file:

title           Debian GNU/Linux, kernel 2.6.11
root            (hd0,1)
kernel          /boot/vmlinuz-2.6.11 root=/dev/hda2 ro acpi_sleep=s3_bios
initrd          /boot/initrd.img-2.6.11
savedefault
boot


Now reboot, and you are ready to go. Try it, close the lid, and open it. It will resume after you hit a key. Now I will explain what my script exactly means, step by step.

#!/bin/bash

killall cardmgr
sleep 3

This stops the PCMCIA card manager. Without this, we cannot remove the modules cleanly. Also it waits 3 seconds, to give time for it to halt.

cardctl eject

This immitates as if we ejected the PCMCIA card by hand. It`s also needed for the module removal. These were all tested by me, and I had a hard time to get to this point, believe me.

rmmod usb_storage
rmmod uhci_hcd
rmmod usbcore

Removal of modules.

echo "Oyasumi..."
sleep 2

Say something nice (Japanese Good night) and wait 2 seconds.

echo "mem" > /sys/power/state

This actually suspends the machine, finally.

cardctl insert

From here these are the steps to get back to life. This emulates as if we put the PCMCIA card in by hand. And a short sleep, so that it can take it`s time.

sleep 3

cardmgr

Now start the card manager.


modprobe usb_storage
modprobe uhci_hcd
modprobe usbcore

And load the modules. Now we have the system working again.

#Personal Modifications

stepThese are what I set for my needs. It restarts the laptop-mode as I need it for powersavings, and it isnt working after the suspend. Also it runs a script, that checks if the machine is on AC or battery, so it can set the energy consumption and brightness. More on that later

/etc/acpi/ac.sh
/etc/init.d/laptop-mode restart


Camera - Motioneye

Pleae read the whole document, specially the Kernel specific topic, as you need a specially built kernel. THings to look out for is to have the SONYPI enabled as a MODULE and not compiled in, as you need to pass options when loaded as module. Compiled in things wont let you modify options unles you mess with your grub, and that is ugly. Other than that you need Linux Video and the Sony Video Inteface (MEYE) enabled also as a module. This is what is needed for the Camera. Now use my modprobe.conf file from above (Kernel Seciton) and put it in /etc/modprobe.conf . Do an "update-modules" to register the changes, and do a reboot or if not, just insert the modules

modprobe sonypi
modprobe videodev
modprobe meye

This should load the modules. Now when you look at dmesg like this "dmesg | grep sony" and "dmesg | grep meye" you should get this

FIXME INCLUDE LINES FROM DMESG FOR REFERENCE

Now we need programs that drive the camera. The best working one is motioneye. You can install it with apt-get as it is a debian package.

apt-get install motioneye

This program was written specifically for this camera, and can use the builtin compressor for the video, so that it wont be as huge as recorded with other devices. Read the man page for it for details. You can take snapshots and movies with it, in 320x240 and 640x480. The pity is that it only allows you do do one thing at a time, and when you record for example, you cannot watch what is being recorded. When you have a nice display and can see what the camera sees on the screen, you cannot record. What a shame.

To view the camera do "motioneye -d". Its pretty fun.

There is also xawtv, but it wont work for me. I posted messages on the video4linux message list, but they didnt have a solution for me.

UPDATE: I have it working now. The /etc/modprobe.conf needs a little modification, so that it can force the V4L1 to be used instead of the V4L2, and then it will work. Change one line of the /etc/modprobe.conf to look like this

options meye gbuffers=32 video_nr=0 forcev4l1=1

And then run

xawtv -c /dev/video0 -geometry 320x240

Another nice and fun app is effect. You can also get it from debian with apt-get.

apt-get effectv

This lets you view the camera in full screen and lets you add real time effects to it. WHen I saw it first, I almost fall back with my chair. Its pretty amazing. Just run it like this

effectv -fullscreen

And then keep pressing the UP arrow, and it changes the effects. Amazing truly.

JogDial, Capture Button

For Jogdial and Capture button, visit the site I created, as it happened to be way complex, so I have included all my success and other trials as well on the site. Check it and check the main site for more Linux Tricks. I made another page that you can access from there about how to run linux on slow laptops, might come in handy.

http://celifornia.com/linux/article.php?story=20050629121445911

http://celifornia.com/linux  and this is for the main site.

Bluetooth


Extra Features (Gnomemeeting, Japanese Input, Nokia 6630)

To get Gnomemeeting to work with the Motioneye camera, you need to force the MEYE module to be loaded with V4L1 support, and not V4L2, as that is buggy still, being fairly new. And just to let you know, everything will still work, even though we use the V4L1 instead of the V4L2, and to top that, even Xawtv will work like this, as that uses V4L1 as well. So we need to change a few things, firstly the

/etc/modprobe.conf

needs to be modified, only the line that calls for the Meye driver. Here is how it should look now:

options meye gbuffers=32 video_nr=0 forcev4l1=1

Now remove the meye module, update the modules and insert the module. This goes like this:

rmmod meye
update-modules
modprobe meye

At this point we need to install gnomemeeting and another package that will let us use the correct V4L1 in Gnomemeeting. Do an:

apt-get install gnomemeeting libpt-plugins-v4l

Now we can start gnomemeeting and set it up the way you want it, just when you get to the video settings, make sure you choose the V4L as the Video source, and at the next step, choose MEYE. After this, there is a button to test settings. If it comes back with no error, you are good to go.

To get Gnomemeeting going with Netmeeting, you need to make sure that all ports are open that need to be open. 1503 and 1720 ports need to point to the machine with Gnomemeeting. This is of course if you are behind a firewall. On the Netmeeting side, you also need the ports open. Look out for Windows XP Service Pack 2 machines, as they tend to have a built in firewall, that also needs to be opened. After this, you are good to go, but one more thing before you start chatting, disable the H.245 Tunneling in the Gnomemeeting preferences. Now your Gnomemeeting is ready to speak with a Netmeeting.

To get Japanese support, you need to install a few packages, and include Japanese in your locales. For that run

dpgk-reconfigure locales

Now choose the Japanese locale as well, but keep your own one as default. You will be promted for that when you say OK after choosing locales.

Now install a few packages

apt-get install canna kinput2-common kinput2-canna ttf-sazanami-mincho ttf-sazanami-gothic libcanna1g-dev libcanna1g canna-utils

This installes the character conversion as well as the Japanese fonts. Now, we need to modify the Xsession file. I am a single user of this laptop, so I modified the default Xsession file, but you are welcome to create on ein your path as ~/.Xsession and then only your session will be modified.

I use KDM as my X loader, so I had to modify KDM`s Xsession file, that is under
/etc/kde3/kdm/Xsession

My file looks like this

#! /bin/sh
# Xsession - run as user

export LANGUAGE=en
export LINGUAS=en
export LC_CTYPE=ja_JP    # May break certain things like window maker; untested
export LC_TIME=C         # Format time as English
export LC_NUMERIC=C      # Format numbers as English
export LC_MESSAGES=C     # Output messages in English
export LC_COLLATE=ja_JP  # Do sorting and collating of characters as Japanese
export LANG=ja_JP        # Use Japanese for all others

export XMODIFIERS="@im=kinput2"
kinput2 -canna &

#Uncomment the following line to let other key change to Japanese as well.
#xmodmap -e 'keycode 49 = Kanji'



# invoke global X session script
. /etc/X11/Xsession

Now when you restart X you should have an English Debian System with the ability to type and read in Japanese. Just press SHIFT + SPACE and you are into typing some Japanese. Pretty nice.

I dont like the SHIFT+SPACE combination, I hit it way too many times when I shouldnt have hit it, and it makes me angry, as Japanese characters start showing up when they shouldnt. Annoying. So I took on another day-journey into GOOGLE`s deep jungle, and finally found the solution on a Japanese site (no I dont read Japanese that well, but I use worldlingo.com`s translator). What you need to do is to reassaign the default keybindings. This is done in a file called

/usr/X11R6/lib/X11/app-defaults/Kinput2

Here you need to fine a line toward the bottom that is similar to mine. Of course mine is already replaced with my desired KEY.

*ConversionStartKeys: \
        <Key>Zenkaku_Hankaku \n\
        <Key>Kanji

This makes my real JAPANESE-ENGLISH selection key work, that is included in every Japanese keyboard, and called Zenkaku_Hankaku. If you wonder what keys your keyboard contain, and what is their real name, just pass the following command.

xmodmap -pke

Also if you want to keep the SHIFT+SPACE and also allow another key to do the job, you can add an additional line to the Xsession file. In my Xsession file it is already included, just commented out. There you need to give the number of the KEY given by the xmodmap command, and restart X.

Another annoying thing is that after we start to use this Japanese capability, man pages will not work anymore. It will show an error like this, when you try to see a man page:

ben@vaio:~$ man man
Reformatting man(1), please wait...
invalid charset name
man: command exited with status 256: /usr/bin/zsoelim /tmp/zmanfSRURp
| /usr/bin/tbl | /usr/bin/nroff -mandoc -Tascii8 | iconv -c -f ISO-8859-1 -t
EUC-JP | exec /usr/bin/pager -s

To correct this, we need to write up a little script, that will overwrite the locale settings for MAN. I named this "mannew" and I put it in /usr/bin/

SO here is how my /usr/bin/mannew looks like

#!/bin/sh

unset LANG=ja_JP
unset LC_CTYPE="ja_JP"
unset LC_NUMERIC=C
unset LC_TIME=C
unset LC_COLLATE=ja_JP
unset LC_MONETARY="ja_JP"
unset LC_MESSAGES=C
unset LC_PAPER="ja_JP"
unset LC_NAME="ja_JP"
unset LC_ADDRESS="ja_JP"
unset LC_TELEPHONE="ja_JP"
unset LC_MEASUREMENT="ja_JP"
unset LC_IDENTIFICATION="ja_JP"

export LANG=C
export LANGUAGE=C

/usr/bin/man "$@"


After this script is in place, make sure you have execution rights set with chmod. Now, you should see a regular man page, like this

mannew manpage

Where manpage is the actual man page you are looking for.