Linux and the hp ze4145 laptop

Intro

For the impatient: See my files section. I claim no responsibility if you trash your hardware using one of my configuration files.

I bought this laptop in October 2002, after hunting around for a good AMD-based laptop. So far I enjoy it very much, although the lack of linux specific information and drivers due to the novelty of the hardware used has driven me nuts at times.

At the time this page was written Compal no longer manufactured and HP no longer made available this particular laptop model. However, several things described below can be applied to any laptop because they are not model specific, but hardware specific. Examples include configuring X for an external USB mouse, on-demand network configuration, or PCMCIA subsystem setup. So, people might actually find useful stuff in the lines below.

My reason for installing linux on this machine is very simple. I believe that everyone should be able to choose their preferred operating system. In my case, this is linux. I can also get rid of Outlook Express, with its plethora of viruses, for a cleaner, better work environment. So, that's that.

Contents

1. Hewlett-Packard ze4145 hardware specifications

Notes: So far PowerNow! is not supported. Suspend does not work. A dual-head configuration implements only clone-display, so Xinerama is not yet fully supported. TV-Out does not work. If USB Legacy Support is not disabled in the laptop's BIOS, the usb-ohci module locks up the keyboard during boot. Other things work as described below.

2. Partitioning scheme

The laptop came from HP with a choice of Windows XP Home Edition or Professional. The hard drive comes partitioned into a NTFS partition for Windows and a small FAT partition which holds HP's diagnostic tools. In order to install linux, this is how I partitioned the drive:
Table 1. Hard-drive partitioning
DeviceSizeFile systemDescription
/dev/hda220 GBytesNTFSWindows XP
/dev/hda18 GBytesext3linux root
/dev/hda311 GBytesext3/home
/dev/hda41 GByteswaplinux swap

I used PartitionMagic to delete the FAT32 partition and resize the NTFS partition in order to obtain the 19 GBytes of free space needed for linux. Once I had that, I used disk-druid and partitioned this free space as shown above.

3. Operating systems

Due to lack of linux drivers, I needed to keep the Windows XP operating system. For linux, I initially tried RedHat 7, then 7.3 and lastly 8. Finally, I settled for building my own linux system from scratch and I followed the excellent guide written by Gerard Beekmans for Linux From Scratch 4.1 and this is the operating system I currently use. During build, the partitioning scheme described above changed to make room for two linux OS' - RedHat and LFS - at least until the LFS system was ready. After all was done, I just erased RedHat and redeclared its partition as the new /home. This was not the first time I built a LFS system, since my desktop computer is exclusively LFS, albeit v3.2. However, it was really cool to see XFree86 compile in less than thirty minutes, whereas on the desktop system it took almost a full night.

4. Boot loader

The linux from scratch team recommends LiLo over GRUB, one of the reasons being that GRUB is still considered beta software. I initially installed, configured and used lilo-22.2, but I kept forgetting running it between kernel recompilations. I therefore switched to GRUB v.0.91. Let me note that both boot loaders work correctly, it's just a matter of preference. Note that if a CD-ROM is in the drive while the computer boots up, GRUB really wants to read it before entering Stage 1.5, and that just takes some extra time.

4.1. LiLo configuration

Upon standard compilation and installation, LiLo puts its configuration file in /etc/lilo.conf. Keep in mind that boot loaders need to load operating systems or kernel images from the correct partition these were installed on. For example, on this computer, the linux partition resides on /dev/hda1. On another computer it might be different. Check and modify the respective configuration accordingly. Here is how it looks:

# Begin /etc/lilo.conf
boot="/dev/hda"
install=/boot/boot-bmp.b
bitmap=/boot/boot_image.bmp
bmp-colors=14,11,,15,9,0
bmp-table=21,287p,2,4,175p
bmp-timer=73,29,12,8,0
map=/boot/map
prompt
timeout="50"
lba32
default="LFS 4.0"
vga=773

image="/boot/lfs-kernel-2.4.21"
	label="LFS 4.0"
	root="/dev/hda1"
	append="hdc=ide-scsi pci=biosirq idebus=50"

other=/dev/hda2
	optional
	label="Windows XP"
	table=/dev/hda

# End /etc/lilo.conf

Once this file is modified, /sbin/lilo must be run in order to update the hard-drive's MBR with the new configuration. If the kernel file is changed as a result of a new kernel compilation, /sbin/lilo must be run, even if the kernel file name is the same and even if /etc/lilo.conf was not modified, otherwise the machine will not boot.

4.2. GRUB configuration

Life is easier with GRUB, mainly because it automatically adjusts to changes. It is mostly forgiving when it comes to errors and features a command shell similar to bash which can be used to figure out and correct what went wrong. Upon standard installation, its configuration file is /boot/grub/menu.lst. Usually, there is a /boot/grub/grub.conf link pointing to this file. GRUB numbers hard drives and partitions differently than LiLo. Here is a short correspondence between the two:
Table 2. Device numbering in LiLo and GRUB
LiLoGRUBMeaning
fd0(fd0)First floppy drive
hda(hd0)First hard-drive
hda1(hd0,0)First hard-drive, first partition
hda2(hd0,1)First hard-drive, second partition
hdb(hd1)Second hard-drive
hdb1(hd1,0)Second hard-drive, first partition
hdb2(hd1,1)Second hard-drive, second partition

This is how /boot/grub/menu.lst looks like for my laptop:

# Begin /boot/grub/menu.lst

default=0
timeout=3
splashimage=(hd0,0)/boot/grub/lfs-splash.xpm.gz

title Linux From Scratch 4.1
	root (hd0,0)
	kernel /boot/lfs-kernel-2.4.21 ro root=/dev/hda1 vga=773 hdc=ide-scsi

title Windows XP
	rootnoverify (hd0,1)
	chainloader +1

# End /boot/grub/menu.lst

5. Kernel configuration

I tried different kernels, from the stock RedHat 2.4.18 shipped with RedHat 7.0 to 2.4.22. The 2.5 series is also a regular on this laptop, although without too much success. It detects and initialises AMD's PowerNow! but because of changes in the keyboard and mouse interface, XFree86 no longer detects the Synaptics TouchPad.

I currently use the 2.4.22 kernel patched for agp support for the IGP 320M. Its .config file is in the files section. Instructions below refer to the 2.4.21. I built the kernel partly modular, bearing in mind what subsystems (mouse, sound-card, usb) I need and in what runlevel I am most likely to use them. Several init scripts in the relevant /etc/rc.d/rcX.d directory start these subsystems upon bootup as needed.

First, I uncompressed the kernel archive into /usr/src. I then made a 'linux' link to the source code.

cd /usr/src
tar -jxvf <path-to-kernel-archive>/linux-2.4.21.tar.bz2
ln -sf ./linux-2.4.21 linux

5.1. ACPI patch

I patched the kernel with the respective ACPI patch in order to get information about and access to the AC adapter, battery, processor temperature, lid and power switches events and LCD brightness control via fn + f1, f2. Note that this patch is already integrated in 2.4.22.

cd /usr/src/linux
zcat <path-to-acpi-patch>/acpi-20030619-2.4.21.diff.gz | patch -Np1

After rebooting the new kernel, ACPI information will be available in /proc/acpi. For example, cat the following:

5.2. Conexant modem kernel modules

The software modem used in this laptop is supported under linux, although the drivers for it are partly close-source, non-GPL. The version I use is 5.03.27msibeta02122600. This is not a patch but fully functional modules which need to be compiled outside of the kernel tree. The Makefile takes care of these aspects and the compilation and installation process is very simple. Read the included INSTALL file for more details.

cd /usr/src
tar -zxvf <path-to-modem-driver>/hsflinmodem-5.03.27mbsibeta02122600.tar.gz
cd hsflinmodem-5.03.27mbsibeta02122600
make install

5.3. PCMCIA kernel preparation

I disabled all PCMCIA related settings in the kernel in light of compiling and installing the pcmcia-cs-3.2.5 package (see below). These are the most important settings:

The ISA settings are there because, even if the laptop does not have an ISA interface per se, 16-bit PCMCIA cards need these to get an IRQ through a 'serial IRQ'.

5.4. Patch for AGP support

The AGPGart is a kernel module which provides support for the PCI to AGP bridge. This patch makes the kernel recognise and initialise the particular ATI chipset inside this computer. Once this patch is applied, XFree86 can use (some of) the card's accelerated functions. You can download the patch from the files section. Like above:

cd /usr/src/linux
patch -Np1 -i <path-to-AGP-patch>/linux-2.4.22-pre8-ATI-AGP.patch

Then, make menuconfig and go to "Character devices" and enable "/dev/agpgart (AGP Support)" either as a module or built into the kernel. Do not forget to enable support for this particular chipset, by checking "ATI IGP chipset support" further down. Finally, recompile the kernel.

6. Init scripts

Linux from scratch 4.1 uses a Sys-V init type. This means that the first process the kernel starts is /sbin/init which, among other things, runs several scripts. These scripts reside in the /etc/rc.d/init.d directory. Under /etc/rc.d there are several more directories, rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, rc6.d and rcsysinit.d. Historically, some of them are used to start processes (2, 3, 5) while others are used to stop or restart the computer (0, 6). The rcsysinit.d runs before any of the 0-6 ones. Inside these directories, there are user-defined links to the actual scripts in the /etc/rc.d/init.d directory. A link's name contains a letter (S or K), a number and a name. If a link starts with 'S', then the respective service starts. If it starts with 'K', then the service is killed or stopped. The numbers define the order in which the services are executed. The name describes what service the link executes. For more information, see the LFS 4.0 book (page 161) and the From Power Up To Bash Prompt HOWTO. All init scripts used below have as model the /etc/init.d/rc.d/template script Gerard Beekmans so kindly provided exactly for this purpose.

6.1. Common startup services

The /etc/rc.d/rcsysinit.d contains the links to all services started or stopped when the computer boots up, before entering a specific runlevel. Besides the services already existing started by the LFS init scripts, I added the daemons listed below.

6.1.1. ifplugd

ifplugd is a must-use daemon for a portable computer. Its purpose is to automatically configure or unconfigure an ethernet device when its cable is plugged or removed. It can also be used to automatically configure a PCMCIA/Cardbus network device, such as a wireless adapter, upon insertion. Since this laptop has an on-board ethernet controller and it is used daily in different network environments, this little daemon is extremely handy.

To be able to happily surf the net, one needs a DHCP server to configure the computer's IP address and also a DNS Server to resolve Internet addresses. There are two steps to the configuration:

  1. Configure the network for DHCP and DNS
  2. Execute the network configuration script only when a cable is plugged / unplugged

Note that if other network services are running, such as SAMBA or NFS, then there could be a security problem when switching networks. For example, if the home network is made up from mostly trusted computers and SAMBA or NFS export directories with no security level (r/w share available to all users), once the network is switched to school, office or whatever else, these same insecure directories will be available to everyone in that network. To solve this, I created two profiles, home and generic. The computer checks for the MAC address of my DHCP server on my home network. If found, it loads the home profile. If the server's MAC address is different than expected, it loads the generic profile. It could very well completely stop sharing services instead.

To configure the network for DHCP and DNS, please see the LFS 4.1 book and the DHCPCd man page. In short, a configuration like this first looks for a DHCP server on the network; it then automatically configures the IP of the client's computer and assigns the gateway server's address to a preferred network interface (eth0 in my case). There are several configuration files to be modified. For this computer they look like this:

# Begin /etc/sysconfig/network

HOSTNAME="HPLaptop"

# End /etc/sysconfig/network
# Begin /etc/sysconfig/network-devices/ifconfig.eth0

ONBOOT=yes
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
DHCP=yes
DEVICE=eth0
GW=yes

# End /etc/sysconfig/network-devices/ifconfig.eth0
# Begin /etc/resolv.conf

# This file contains a list of DNS Servers for name-address resolutions.
# Good candidates are the servers supplied by your ISP.

nameserver xxx.xxx.xxx.xxx

# End /etc/resolv.conf

Please note that the dhcpc daemon overrides by default /etc/resolv.conf with the server-provided DNS Server. If for some reason this is not desirable, use the -R switch when calling the daemon so that it'll not touch this file. Once the network is usable in this configuration, we can use ifplugd to automatise the process. When ifplugd detects a link, it executes a script, by default in /etc/ifplugd/ifplug.action. This script takes two parametres: the first one is the network device to operate on, and the second is the action to take.

First, create the startup script to run the daemon:

#!/bin/bash
# Begin /etc/rc.d/init.d/ifplugd
source /etc/sysconfig/rc
source $rc_functions

case "$1" in
	start)
		/usr/sbin/ifplugd -b -i eth0 -r /etc/ifplugd/ifplugd.action
		echo "Starting ethernet link sensing daemon..."
		evaluate_retval
		;;

	stop)
		echo "Stopping ethernet link sensing daemon..."
		killproc /usr/sbin/ifplugd
		evaluate_retval
		;;

	restart)
		$0 stop
		sleep 1
		$0 start
		;;
	
	status)
		statusproc ifplugd
		;;

	*)
		echo "Usage: $0 {start|stop|reload|restart|status}"
		exit 1
		;;
esac

# End /etc/rc.d/init.d/ifplugd

Then, create the two parametres action script:

#!/bin/sh
# Begin /etc/ifplugd/ifplugd.action

if [ /etc/sysconfig/network-devices/ifconfig.$1 ]; then
	source $(/bin/ls /etc/sysconfig/network-devices/ifconfig.$1)
else
	exit 0
fi

case "$2" in
	up)
		if [ "$ONBOOT" == "yes" ]; then
			if [ "$DHCP" == "yes" ]; then
				/sbin/dhcpcd -t 3 -dR $1
			else
				/sbin/ifconfig $1 $IP broadcast $BROADCAST netmask $NETMASK
			fi
		fi

		if [ "$GATEWAY" != "" ]; then
			/sbin/route add default gw $GATEWAY dev $GATEWAY_IF
		else
			if [ "$GW" == "yes" ]; then
				source /etc/dhcpc/dhcpcd-$1.info
				# /sbin/route add default gw $DNS dev $1
			fi
		fi
		;;
		
	down)
		if [ "$ONBOOT" == "yes" ]; then
			if [ "$DHCP" == "yes" ]; then
				route del default
				/sbin/dhcpcd -k
				rm -f /etc/dhcpc/dhcpcd-$1.pid
			else
				/sbin/ifconfig $DEVICE down
			fi
		fi
		;;

	*)
		echo "Usage: $0 {interface} {up|down}"
		exit 1
		;;
esac

# End /etc/ifplugd/ifplugd.action

Finally, start the script at boot time and stop it when shutting the computer down:

ln -s ../init.d/ifplugd /etc/rc.d/rcsysinit.d/S85network
for n in 0 6; do
	ln -sf ../init.d/ifplugd /etc/rc.d/rc$n.d/K45network
done
for n in 3 5; do
	rm /etc/rc.d/rc$n.d/S30network
done
6.1.2. ACPId

The ACPI daemon allows the user to configure what happens when different events are triggered. Events are, for instance, closing the lid of the laptop or pressing the power button. Since linux on this computer does not yet support the suspend command, the only thing I use the daemon for is to turn the computer off by pressing the power button. This also saved me from a lot of file system rechecks as I tried to make the PCMCIA and the USB subsystems work and the computer's keyboard locked up.

Upon standard compilation and installation, acpid resides in /usr/sbin. Its configuration files are in /etc/acpi. For each event we want an action for, we create a file in /etc/acpi/events which contains the name of the event and the action to be executed. Thus,

# Begin /etc/acpi/events/power

event=button/power
action=/sbin/shutdown -h now

# End /etc/acpi/events/power

The file above tells the acpi daemon to stop the computer whenever the power button is pressed. If suspend was usable, we could have written another file to make the computer enter the suspend state whenever the lid was closed, like so:

# Begin /etc/acpi/events/lid

event=button/lid
action=/sbin/suspend

# End /etc/acpi/events/lid

In order to find out the name of the button which we want to assign to an event, open a console session and do the following:

  1. With acpid stopped, cat /proc/acpi/event
  2. Press the desired button
  3. This will print two messages, one for each state of the button, for instance:

For more information, please read the acpid man page.

6.1.3. smartd - the S.M.A.R.T. daemon

The S.M.A.R.T. daemon takes advantage of the interface present in most recent hard-drives to automatically repair themselves by marking for nonsafe use a potentially bad disk area. When such an area is found, the daemon can send an e-mail to the system's administrator, informing about the nature and seriousness of the problem. Besides this, there are also several other useful parametres which describe the state of the disk. I believe that on a laptop, the most important is temperature. The IBM hard-drive used in this laptop can monitor itself for temperature. On my computer, it has an average of about 150oC. For now I use the smartd only for this, but a hard-drive plugin for the system's monitor would be nice indeed. Since such plugin is not yet written, I just tail /var/log/syslog every now and then, especially when having the laptop in my lap :-) The system log contains smartd entries of the form:

Usage Attribute: 193 Load_Cycle_Count changed from 95 to 94
Usage Attribute: 194 Temperature_Celsius changed from 177 to 130

To configure the daemon, it suffices to have an /etc/smartd.conf file with the following contents:

# Begin /etc/smartd.conf

# First ATA/IDE hard disk, monitor all attributes
/dev/hda -d ata -a

# End /etc/smartd.conf

Then, create the startup script in /etc/rc.d/init.d which reads:

#!/bin/bash
# Begin /etc/rc.d/init.d/smartd

source /etc/sysconfig/rc
source $rc_functions

case "$1" in
	start)
		echo "Starting S.M.A.R.T. daemon..."
		loadproc /usr/sbin/smartd
		touch /var/lock/subsys/smartd
		evaluate_retval
		;;

	stop)
		echo "Stopping S.M.A.R.T. daemon..."
		killproc smartd
		rm -f /var/lock/subsys/smartd
		evaluate_retval
		echo
		;;

	restart)
		$0 stop
		$0 start
		;;

	status)
		statusproc smartd
		evaluate_retval
		;;

	*)
		echo "Usage: smartd {start|stop|restart|status}"
		exit 1
esac

# End /etc/rc.d/init.d/smartd

Finally, start and stop the script as desired:

ln -s ../init.d/smartd /etc/rc.d/rcsysinit.d/S75smartd
for n in 0 6; do
	ln -s ../init.d/smartd /etc/rc.d/rc$n.d/K65smartd
done
6.1.4. Sound initialisation

The sound system on this laptop is based around the ALi5451 audio core. It is therefore enough to enable support for this chip in the kernel to be able to enjoy "more than an occassional beep". I compiled sound support for this chip as a module. Therefore, the script below is run after the /proc filesystem has been mounted, inserts the module and then does some initialisation stuff as described in the module's kernel help page. If instead you chose to make this module part of the kernel, remove the modprobe and rmmod lines from your startup script.

6.1.5. USB initialisation

USB support is provided by two modules: usbcore.o and usb-ohci.o. The hardware (root hub) supports four ports, but for reasons yet unknown, only two physical ports are provided. They're located in the most accessible place of all: at the back of the laptop :-)

Their placement is awkward too, 'squeezed' between the ethernet port and the power supply connector. It is really a pain to connect or disconnect any USB cabled device (mouse, scanner, etc.) when running on external power and connected to a cabled (ethernet) network. Not to mention that some USB devices (such as a wireless network card or an USB memory stick) are wide enough not to fit in the top connector, due to space limitations. I have good enough dexterity, but I feel more comfortable fiddling around at the back of a blade server than touching this area. This is just poor design at its best, I guess.

Note: It seems there is a bug in the laptop's BIOS. If there's any USB device connected to the laptop when it is scheduled for a restart, it will freeze at the HP logo screen. Remedy: press the power button to turn it off, wait a few seconds and then press it again to turn it back on. This does not happen if there is no USB device connected or when the restart is performed from within Windows.

I decided to upgrade the BIOS to version K.M1.24. This fixes another USB-related bug (and this one too) in a quick and dirty way: when the computer restarts, it actually turns off for a second and then powers back on. Really ugly! (not to mention the stress on components such as hard-drive and the backlight inverter). So don't upgrade to this BIOS!

The simplest way to get USB working correctly on this computer is to use the hotplug management package. Each time the kernel fires an event as the result of the insertion of a new USB device, the hotplug scripts will load the appropriate driver for that particular device (or class of devices). If nothing happens, it may be the case that no driver is available or the kernel was not built with hotplug support. A good place to start debugging is the system log. A tail /var/log/<log-file-name> will reveal the message posted by the kernel and hotplug's answer. Then, search for that particular device's support under linux.

I successfully tested the laptop with a cool Targus laptop optical mouse, iMac's transparent 'burger' mouse and keyboard, a Netgear MA111 wireless network card, a Canon LiDE30 scanner, a Canon PowerShot S330 (Digital Ixus in Europe), and also some other devices.

Hotplug is a service, so that appropriate start-up and shutdown scripts must exist in the relevant directories inside /etc/rc.d. I decided I needed the USB subsystem while mostly in graphical mode (runlevel 5), so the commands below reflect my choice.

mv /etc/init.d/hotplug /etc/rc.d/init.d
rm /etc/init.d

ln -s ../init.d/hotplug /etc/rc.d/rc5.d/S30hotplug
for n in 0 6; do
   ln -s ../init.d/hotplug /etc/rc.d/rc$n.d/K35hotplug
done
6.1.6 PCMCIA controller

Using pcmcia-cs-3.2.5 I was able to have the controller working properly. Thanks goes to David Hinds et all for making this possible. First, compile the kernel with the settings above. Boot the new kernel. Then, untar and compile the pcmcia-cs-3.2.5 package as outlined below. As with any other package, make install must be run as root.

tar -zxvf <path-to-pcmcia-cs-package>/pcmcia-cs-3.2.5.tar.gz
cd pcmcia-cs-3.2.5
yes "" | make config
make all
make install

Next, configure /etc/sysconfig/pcmcia and /etc/pcmcia/config.opts to correctly initialise the CardBus hardware. Finally, create the startup and shutdown links:

cd /etc/sysconfig
sed -i 's/PCIC=yenta_socket/PCIC=\"i82365\"/' pcmcia
sed -i 's/PCIC_OPTS=/PCIC_OPTS=\"irq_list=11\"/' pcmcia
sed -i 's/CARDMGR_OPTS=/CARDMGR_OPTS=\"-q -v\"/' pcmcia

cd /etc/pcmcia
sed -i 's/include memory 0xa0000000-0xa0ffffff, memory 0x60000000-0x60ffffff\
         /include memory 0x80000000-0x80000fff, memory 0xffeff000-0xffefffff,\
                  memory 0xfbeff000-0xffefefff, memory 0x000d7000-0x000dffff/' config.opts
sed -i 's/include port 0x100-0x4ff, port 0x800-0x8ff, port 0xc00-0xcff\
         /include port 0xfd00-0xfdff, port 0xfc00-0xfcff/' config.opts

ln -s ../init.d/pcmcia /etc/rc.d/rcsysinit.d/S82pcmcia
for n in 0 6; do
	ln -s ../init.d/pcmcia /etc/rc.d/rc$n.d/K55pcmcia
done

The above memory settings were set after the Properties page of the Device Manager in Windows XP.
I successfully tested several prism2 based PCMCIA wireless cards, some compact flash cards (PQL 256MBytes didn't work - different protocol?, SanDisk based cards did) and a Conexant hardware modem. I can't get my hands on a CardBus card yet, so I don't know if 32-bit mode works. The above configuration files are in the files section.

6.1.7 CUPSd - linux printing services

The primary reason for choosing CUPS is that I can have ubiquitous network printing (Windows, UNIX or MacOS). Secondly, it's extremely easy to use and set up. Finally, KDE supports it very well.

CUPS' configuration files usually lie in /etc/cups. They are very well documented. If you're curious or you need more detailed configuration, peek in there. CUPS has an extremely simple configuration interface via a web browser. To start it, point your browser to localhost:631. If you use KDE, go to the Control Centre, and under Peripherials select CUPS as the preferred printing method, right-click the list of currently installed printers and select "Add Printer/Class...". Follow the wizard. In both cases, root privileges are needed to install a system-wide printer.
Distribution specific notes: While in RedHat (tested up to 8.0) the above KDE method works just fine, SuSE has its own Control Centre module for adding a printer. It is located under YaST -> Hardware. The setup steps are similar, and in case of Windows printing, even improved upon.
Support notes: Although I am using the CUPS print server, I rely on gimp-print to provide support for the printers I use. This package offers far broader and better support than the "bare" CUPS software does.

6.2 Console services

6.2.1 GPMd - console mouse

It is recommended that this daemon should run in 'console only' mode. The Synaptics touchpad is identified as a synps2 device. First, get the latest and greatest version of the daemon from ftp.linux.it. Then untar, compile and install the package with:

tar -jxfv <path-to-gpm-package>/gpm-1.20.1.tar.bz2
cd gpm-1.20.1
./configure --prefix=/usr --sysconfdir=/etc
export LDFLAGS="-lm"
make
make install
cp conf/gpm-*.conf /etc

Next, create the necessary /etc/rc.d/init.d/gpmd script.

#!/bin/bash
# Begin $rc_base/init.d/gpmd

source /etc/sysconfig/rc
source $rc_functions

case "$1" in
	start)
		echo "Starting console mouse services..."
		loadproc /usr/sbin/gpm -m /dev/psaux -t synps2
		evaluate_retval
		;;

	stop)
		echo "Stopping console mouse services..."
		killproc /usr/sbin/gpm
		evaluate_retval
		;;

	restart)
		$0 stop
		sleep 1
		$0 start
		;;

	status)
		statusproc gpm
		;;
		
	*)
		echo "Usage: $0 {start|stop|restart|status}"
		exit 1
		;;
esac

# End $rc_base/init.d/gpmd

To make an external (USB) mouse work together with the built-in touchpad, gpmd must be used in 'repeater' mode. In this mode, a /dev/gpmdata FIFO node will be created on the fly, which can be referenced by non-X programs as the mouse 'device'. The incantation is as follows:

gpm -m /dev/psaux -t synps2 -M -m /dev/input/mice -t imps2

Finally, create the start and stop links in the respective runlevels:

for n in 1 3 4; do
	ln -s ../init.d/gpmd /etc/rc.d/rc$n.d/S40gpmd
done
for n in 0 5 6; do
	ln -s ../init.d/gpmd /etc/rc.d/rc$n.d/K10gpmd
done

7. XFree86 configuration

The version of XFree I use is 4.3.0. Since the ATI IGP320M is too new for this release of X, I used for a long time the vesa driver, with no acceleration. Patches to enable 2D acceleration for the radeon driver soon appeared. Later on they were followed by 3D acceleration patches for both the kernel's agpgart and XFree's (4.3.99-8) radeon. I took advantage of these patches by applying them to both the kernel and XFree86-4.3.0 source trees. If with the vesa driver things were a bit slow, they improved a lot when using radeon's 2D acceleration, especially for watching DVD movies. As stated above, TV out does not work, probably because of macrovision's patent issues. On the Gatos project there are, however, preliminary plans for tv_output support, currently available from the CVS repository. They do not apply for this card yet. The Windows driver provides support for TV out and has the copy protection enabled by default.

The native resolution for the LCD screen is 1024 x 768. A peculiarity of running resolutions lower than this is that the desktop will no longer occupy the entire area of the display. This is unlike Windows, where the driver will adjust lower resolutions to fully fit the physical display.

The configuration file for X is called XF86Config and usually resides in /etc/X11. All my posted configuration files make use of the patches to the radeon driver, so if you download them, make sure the driver you use supports them.

If at any time you might become lost and have an unusable X configuration, you can rely on readily available tools such as xf86config to create one for you.

7.1. Single-head display

In this configuration, X drives the primary monitor only. Note that if an external monitor is connected before the computer is turned on, the laptop will automatically switch to it before booting. Therefore, please make sure your external monitor supports the horisontal and vertical frequencies and resolutions configured for the internal LCD screen. A working, hand-written, configuration file for this mode is available in the files section.

7.2. Dual-head display

Here, X will drive an external monitor attached to the analogue port provided. I usually connect my laptop to a 17" Sony which supports horisontal frequencies between 31 and 70 Hz. Its vertical frequencies domain is 50 to 150 kHz. If necessary, adjust the configuration file provided to match your monitor, otherwise it can become permanently damaged. Do not use this as an excuse to go out and buy a new monitor. This file is also available in the files section.

7.3. Synaptics TouchPad driver

There is an excellent driver for the touchpad available at tuxmobil.org. This driver also makes use of the handy-dandy on/off button and can have hot-click corner zones, just like in Windows. The scroll areas work as well. Overall, I prefer this driver to its Windows counterpart anytime. Both X configuration files supplied have the device configured as follows:

Here's an example Section "InputDevice" from my XF86Config, which implements the above behaviour:

Section "InputDevice"
   Identifier   "Synaptics PS/2 touchpad"
   Driver       "synaptics"
   Option       "Device"                "/dev/psaux"
   Option       "Edges"                 "1900 5400 1800 3900"
   Option       "Fingers"               "25 30"
   Option       "MaxTapTime"            "20"
   Option       "MaxTapMove"            "220"
   Option       "VertScrollDelta"       "100"
   Option       "MinSpeed"              "0.02"
   Option       "MaxSpeed"              "0.18"
   Option       "AccelFactor"           "0.0005"
   Option       "ZAxisMapping"          "4 5"
   Option       "Emulate3Buttons"       "No"
EndSection

7.4. External USB mouse

To make an external USB mouse work in X, there must be a second Section "InputDevice" dedicated to this USB mouse. This section will contain parametres relevant to this mouse only. Example:

Section "InputDevice"
	Identifier	"Targus USB mouse"
	Driver		"mouse"
	Option		"Device"		"/dev/input/mice"
	Option		"Protocol"		"ImPS/2"
	Option		"ZAxisMapping"		"4 5"
	Option		"Emulate3Buttons"	"No"
EndSection

Then, in the Section "ServerLayout", alongside the existing entry for the primary mouse (the touchpad), there must also be an entry of the form:

InputDevice	"Targus USB mouse"		"SendCoreEvents"

7.5. OneTouch keys configuration

The 'OneTouch' keys are the five keys located at the top of the keyboard. Their obvious (and not so obvious) functionality in Windows was duplicated in some cases by other keys, like fn + f5 for the TV key or the f1 key for the question mark. XFree86 already knows the scan codes generated by these keys and has a predefined keyboard layout to be used in the configuration file. This keyboard model is called ze4xxx. For the curious it is located in the /etc/X11/xkb/symbols/inet file. Once this is set in the XF86Config file, a secondary program or the window manager is used to tie a button to a desired action. In my case, this is handled by the KDE window manager's 'Menu Editor' application (kmenuedit). Once an application is selected in the left pane, the bottom right area of the configuration window allows for selecting a desired shortcut key to launch the application with. Here's the relevant entry in the XF86Config file:

Section "InputDevice"
   Identifier   "ze4145 keyboard"
   Driver       "keyboard"
   Option       "AutoRepeat"            "500 30"
   Option       "XkbRules"              "xfree86"
   Option       "XkbModel"              "ze4xxx"
   Option       "XkbLayout"             "us"
EndSection

This keyboard layout handles not only these five buttons, but also the mute, volume up, and volume down buttons on the left side of the laptop. Just assign them to the master volume slider in kmix.

There is also a kernel module which enables the same buttons and adds some extra functionality and information to the /proc system. It is written by Peter Soos et all and is available from sourceforge.net. An omke.pl PERL script is provided by Pavel Mihaylov, which supports several functions, such as turning on or off the LCD display or enabling / disabling the touchpad.

8. Startup automation

If you always want your computer start in graphical mode each time it boots up (and eat more battery along the way), then this is the place to read on how to do so. As stated above, the first process which is run after the kernel boots is called init. When it is done running all those scripts in /etc/rc.d/rc<runlevel-number>.d, it hands control to another program (this is not exactly true, but for our purposes, it is good enough). Think that in runlevel 3 this program is a text login screen, whereas in runlevel 5, this is a graphical login screen. Therefore, it is enough to place init in runlevel 5 each time the computer boots to get to that desirable, cool-looking graphical login screen. Since I am using KDE, my login screen is provided by <path-to-KDE-exec-directory>/kdm. So:

# Begin /etc/inittab

id:5:initdefault:

si::sysinit:/etc/rc.d/init.d/rc sysinit

l0:0:wait:/etc/rc.d/init.d/rc 0
l1:S1:wait:/etc/rc.d/init.d/rc 1
l2:S2:wait:/etc/rc.d/init.d/rc 2
l3:S3:wait:/etc/rc.d/init.d/rc 3
l4:S4:wait:/etc/rc.d/init.d/rc 4
l5:S5:wait:/etc/rc.d/init.d/rc 5
l6:S6:wait:/etc/rc.d/init.d/rc 6

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

su:S016:once:/sbin/sulogin

1:2345:respawn:/sbin/agetty tty1 9600
2:2345:respawn:/sbin/agetty tty2 9600
3:2345:respawn:/sbin/agetty tty3 9600
4:2345:respawn:/sbin/agetty tty4 9600
5:2345:respawn:/sbin/agetty tty5 9600
6:2345:respawn:/sbin/agetty tty6 9600

# Run kdm in runlevel 5
x:5:respawn:/opt/kde/bin/kdm -nodaemon

# End /etc/inittab

The line id:5:initdefault: makes init run whatever is listed under x:5, in this case /opt/kde/bin/kdm. The option -nodaemon prevents kdm to enter daemon mode and fork in the background. If this poor laptop was serving X over a network to other poor and oppressed X-terminals, then removing this option means that our laptop could run in full text mode, or under a different window manager, whereas whomever requesting an X session from it would be presented with the familiar KDE login screen. Read more about X-servers at the Linux Documentation Project.

9. The End

I sincerely hope that the information presented here has helped solve your particular problem. Or maybe you simply enjoyed reading it. Then again, maybe not. In any case, feel free to drop me a line at virgilg at ev1 dot net. I am open to suggestions, corrections and improvements to this document. Have fun.

Valid HTML code written in vim. Best viewed with a browser.
Page created using 100% recycled bits