Author: Benjamin Smee "strerror at disciplina.net"

Date: 20/5/2005

This page is here mainly to help me remember all the steps that I have gone through to get my laptop functioning the way I want it to. Hopefully though some of this information will be useful for other people as well and so I include it all and welcome any feedback / corrections. My current "laptop" is a Fujitsu P7010D and so while all of the following information is specific to it, most of it will be applicable to other laptop models as well. The same applies to the fact that I am using Gentoo, again it is not distro specific but my examples might be.


Powersaving

Notebook users are well aware that one of the main issues when using a notebook is power, thus powersaving and efficient use of your power is key. Linux has a number of facilities available to it to manage power but of the two, ACPI and APM, I will only talk about ACPI as I never had anything but trouble with APM and it's all but deprecated as far as I can work out.

The first thing that I looked at was the CPU. The CPU is the second biggest consumer of power on a given laptop and with modern chipsets that are able to speedstep they are an obvious choice for optimisation. After reviewing some of the tools around to do this I ended up choosing cpufreqd as it seems like it is the most mature and well supported as well as being very flexible. After installing it (gentoo users : emerge cpufreqd cpufrequtils) and ensuring that I had built in the right support in my kernel (Powermanagement -> CPU Frequency Scaling) I didn't like the default config that it came with and started to play with the config files until I saw that Brix (http://dev.gentoo.org/~brix) had pretty much the same idea that I did about config and so I stole his and did a few minor tweaks. My config can be found http://www.disciplina.net/howto/cpufreqd.conf. I then looked at the largest power consumer, the display, and made sure that I included some options in my xorg.conf that turned off the display in a reasonable timeframe (see the xwin section for example config). One thing I did note was a thread at leog.net (http://www.leog.net/fujp_forum/topic.asp?TOPIC_ID=7792) that seemed to indicate a patch for controlling screen brightness and other things, but I havn't had time to check this out yet, please let me know if you do and what successes you have.

I also took the chance to write a few scripts to automatically suspend the fuji if the lid was closed and it was not on ac power. The scripts can be found HERE. Please read the suspend section for more details on that though. In order to use these scripts you will need to install acpid (gentoo users: emerge acpid && rc-update add acpid default) and create a battery runlevel. Information on this can be found in the gentoo howto. Suffice it to say that acpid is the interface that you are looking for if you want to do a lot of work around how your computer functions at different power states.

Finally for managing HD usage I used laptop-mode scripts (gentoo users: emerge laptop-mode-tools). My configuration for this can be found http://www.disciplina.net/howto/laptop-mode.conf.

Links:

http://www.gentoo.org/doc/en/power-management-guide.xml - great, uptodate guide

http://www.xs4all.nl/~bsamwel/laptop_mode/tools/ - nice script for managing a lot of power related things


Networking - gentoo specific

Wireless networking is traditionally a pain with linux but things are getting better. In gentoo we have a few ways to manage wireless networks, one being the /etc/conf.d/wireless file in a ~x86 baselayout or the other is via wpa_supplicant. It is wpa_supplicant that I chose as my solution. The "HOWTO" at the wiki has limited information about wpa_supplicant basically saying the documentation in the configuration file is enough, which while true, can lead to some confusion as to how it integrates with the Gentoo networking.

Wpa_supplicant was my choice because of two key things, firstly as I understand it wpa_supplicant allows you to use some of the more advanced forms of wireless connections, eg wpa / wpa 2. As a security geek this was of big interest. The other, and more generally pertinant reason I chose it was that it has a nice design that allows you to support effectively profiles. What I mean by that is that you can set wpa_supplicant up to initially look for your home network, if it can't find that, your work network, and if it can't find that attach to whatever local ones it can see, while maintaining the particular connection requirements for each of them. This is what I personally needed and so I set about configuring it. Do note though that as I use madwifi for my driver I had to 'echo "net-wireless/madwifi-driver ~x86" >> /etc/portage/package.keywords ; emerge madwifi-driver'

The pain I alluded to before can best be summed in the following manner:

If you are going to run baselayout > 1.11 then you can IGNORE /etc/conf.d/wpa_supplicant file for configuration and /etc/conf.d/wireless. Instead you should put something like this into your /etc/conf.d/net


wpa_supplicant_ath0="-Dmadwifi"

modules=( "wpa_supplicant" )

wpa_timeout_ath0=60


On the other hand if you are using baselayout < 1.11 then you should set the equivalent options in /etc/conf.d/wpa_suuplicant. eg:


INTERFACES="ath0"

ARGS="-w"

ARGS_ath0="-Dmadwifi"


Finally if you have further problems then make sure that you reload the modules, or, if you have done what the ebuild suggested for madwifi and put them into the /etc/modules.autoload.d/kernel-2.6, reboot. It's important that in future if you upgrade your kernel you reemerge the madwifi-driver package, I suggest looking into using the package "module-rebuild" to automate this for you.


Mouse

The fujitsu comes with a synaptics touchpad which at first I thought was effectively just a normal mouse replacement. What I did not realise about the synaptic mouse pad was that it is actually very programmable, for example you can create “soft” mouse button areas or you can configure it so that moving your finger along a border will scroll the window you are in. This is very handy functionality to have on a laptop so I was very interested in getting it working fully. A quick search of some of the links I used for getting information on touchpads, will show that, supposedly, there are a lot of patches required to get it working as well as some differences between the normal synaptics and the alps versions. I am pleased to say that using kernel 2.6.11.8+ and xorg 6.8.2+ (almost definitely earlier, but not sure how much earlier) it will work without too much effort. Firstly make sure that your kernel is built with CONFIG_MOUSE_PS2 and CONFIG_INPUT_EVDEV. Then you need to get the driver from : http://w1.894.telia.com/~u89404340/touchpad/ (gentoo users simply emerge synaptics) and after building cp it to your module path, normally /usr/X11R6/lib/modules/input/ but will vary from distro to distro. One last thing that needs to be done, at least for the fuji, is to add the text "i8042.nomux" to your grub.conf and reboot. Then add


Section "Module"

...

  Load "synaptics"

...

EndSection


to your module section of xorg.conf and



Section "InputDevice"

  Identifier    "Synaptics Touchpad"

  Driver        "synaptics"

  Option        "Device"        "/dev/psaux"

  Option        "Protocol"      "auto-dev"

  Option        "LeftEdge"      "1700"

  Option        "RightEdge"     "5300"

  Option        "TopEdge"       "1700"

  Option        "BottomEdge"    "4200"

  Option        "FingerLow"     "25"

  Option        "FingerHigh"    "30"

  Option        "MaxTapTime"    "180"

  Option        "MaxTAPMove"    "220"

  Option        "VertScrollDelta" "100"

  Option        "MinSpeed"      "0.09"

  Option        "MaxSpeed"      "0.18"

  Option        "AccelFactor"   "0.0015"

  Option        "SHMConfig"     "on"

Option "ZAxisMapping" "4 5"

Option "InputFashion" "Mouse"

Option "Name" "ALPS;Touchpad"

EndSection


To the inputdevice section. Note the SHMConfig parameter allows you to change the mouse settings on the fly but is also a semi security hole as ANY local user will be able to do this.


This will allow you to use the synaptics as a mouse, to use the scroll function on the right hand side and to use the bottom edge as forward and back in a browser for example. You can adjust this to your needs, read the dox that came with the driver.


Most new synaptic touchpads have the so called "palm detection" and “multi finger detection”, the fuji is no exception. That said due to its size I found that hitting the touchpad with palm was not a problem, the issue was more my thumb when hitting space, as the palm detection didn't really seem to help. Instead for those of you who also suffer from unwanted mouse input while typing I recommend you enable syndaemon that comes with the driver (gentoo users just set the options in /etc/conf.d/syndaemon, personally I use "-d -i 1").

Finally I will quote verbatim from the synaptic dox for those of us who might want to use more then one mouse at a time:

--

   Note! You can not have more than one core pointer, so if you want

   to use an external mouse too, you have to set all mouse input

   devices except one to "AlwaysCore" instead of "CorePointer". For

   example:


      Section "ServerLayout"

      ...

              InputDevice    "Mouse0" "CorePointer"

              InputDevice    "Synaptics Mouse" "AlwaysCore"

      ...

      Section "InputDevice"

      ...

              Identifier  "Mouse0"

              Option      "Device" "/dev/input/mice"

      ...


   This also applies if you are using a 2.6 linux kernel and the

   touchpad contains a "pass through" device. Usually a pass through

   device is a touch stick located in the middle of the keyboard, but

   it can also be a separate set of buttons located next to the

   touchpad. If you want the pass through device to be enabled in X,

   the second InputDevice is needed. If there is a line in

   /proc/bus/input/devices that begins with "P: Phys=synaptics-pt" it

   means that the kernel has found a pass through device.

--


Links:

http://w1.894.telia.com/~u89404340/touchpad/



Xwindows

This wasn't anywhere near as hard as I thought it would be to get working. Effectively, it's a simple matter of ensuring that you have built the right kernel drivers for your graphic card (generically as simple as lspci, and then matching the name of your graphics card to a driver in the kernel config). For the fuji this meant the i810 and the i855gm drivers. Once this is done and the latest xorg has been installed I was able to get xwindows running in 1024x768 with no problem using a normal config. Of course there is a small issue here and that is that the fuji's resolution is actually 1280x768 so in order to get that working I had to find a patch. Luckilly due to the good people on leog.net (fantastic resource for those with a passion for laptop tech and a general resource for fuji's) I was able to find one. I have hosted it locally (various other links to it were dead) and it can be found http://www.disciplina.net/howto/1280patch-845g-855gm-865g.c. What this patch does is after compiling it, you should run it with a command line like:

./1280patch 38 1280 768

The 38 represents the bios register that the resolution will be mapped to (don't worry it's not overwriting one that we can use at that spot. It is worth noting that you could theoretically set it to any bios setting but this is the only register I know that it will NOT be overwritting a resolution that you might otherwise want to use). Now a restart of x with resolution changes in the config meant x was working with full 1280x768 resolution. It should be noted that the patch needs to be run everytime you reboot OR suspend, so gentoo users I recommend putting it in /etc/conf.d/local.start and for suspend I will get to that later.

Of course this is just the internel LCD and the fuji also has a monitor out and a svideo out as well. In order to make that more usable I have borrowed from a setup I came across during my research and came up with the following script that can be found HERE, with these other FILES required. Basically what this script does is probe to find out what monitors are attached and when it finds a tv, crt or another lcd it adds the appropriate serverlayout to the xorg.conf so that it will use anything that is attached (that the probe can find).


Links:

http://www.leog.net/fujp_forum/topic.asp?TOPIC_ID=5371 - the main thread about the patch



Framebuffer

The fuji has a very small screen (10.6") and as such using the console in its default configuration is not much fun. Instead I wanted a nice framebuffer so that I had a higher res and maybe a bit of eye candy as well. To this end I rebuilt my kernel enabling CONFIG_FB_VESA and then trying CONFIG_FB_I810. Unfortunately despite my best efforts I couldn't get either of them working. I then found spocks great work (http://dev.gentoo.org/~spock) and downloaded the latest vesafb-tng. With that patch applied to the latest kernel (at time of writing 2.6.12rc1) I was able to get framebuffer working with no problems. It was this of course that lead me to the next stage, suspending.


Links:

http://gentoo-wiki.com/HOWTO_fbsplash

http://gentoo-wiki.com/HOWTO_Design_your_own_Framebuffer_Splash - useful once you have a working framebuffer for your own customizations


Suspend

One of the most frustrating things about running linux on the laptop for me personally over the years was the difficulty in getting suspension working. Well I am glad to say that things are remarkably better now then ever before. Firstly it's worth recapping the types of suspension. Currently we have two main power interfaces in Linux, ACPI and APM. I am not going to touch on APM as I never really liked it and I don't use it, pretty much everything these days uses ACPI anyway so that is what I will talk about. Using ACPI there are 3 (possibly more not sure) different levels of "suspension" of which only 2 seem to do anything.. In particular they are disk and mem, which the first suspending to disk and the second just suspending to ram. Now suspending to ram seems to be problematic for many hardware setups, but I have to say that it works FLAWLESSLY for me with the fuji, both from the command line AND from xwindows. The only thing that I needed to do to get suspend to ram worki

 ng was add the following to my grub.conf:

"acpi_sleep=s3_bios"

While it is possibly to suspend to ram by simply issuing a command like: echo -n "mem" > /sys/power/state it is advisable to use a series of scripts called "hibernate" that can better manage loading / unloading of modules as required as some modules are still problematic with suspendt to ram. In particular usb and firewire still have problems so I highly suggest you compile these as modules so that they can be inserted and removed as needed, otherwise, if you have them builtin and suspend to ram there is a high probabilty that it will kernel oops the system on reactivation. Suspending to disk is a whole different story and is thankfully made a lot easier with suspend2 (http://www.suspend2.net). These guys are very active devs and Neil (primary coder) combined with Bernard (author of the "hibernate" scripts) have a great product. Now precisely how you will do is VERY dependant on your own personal setup, in particular things that matter are:

* Do you use raw partitions for your swap? eg /dev/hda1

* do you use lvm/evms paritions for your swap? eg /dev/vg0/swap

* Do you use dm-crypt for your swap? eg /dev/mapper/dm-crypt


In my case I use lvm + dm-crypt so getting it working was so complicated that I have decided to break that section off and have written a separate howto on how to do this. If you are running a more "normal" configuration then the documentation at suspend2.net is probably more then sufficient to get it working for you. On the other hand if you are running into problems or want to have a laptop that can suspend to fully encrypted partitions then check out my HOWTO http://wiki.suspend2.net/DistroAndHardwareSetup/LvmDmcryptHOWTO.


Whichever way you go gentoo users I recommend that you use Brix's great suspend2-sources that can be found at http://dev.gentoo.org/~brix/files/overlay/sys-kernel/suspend2-sources/


Links:

http://www.suspend2.net

http://developer.berlios.de/projects/softwaresuspend/

http://gentoo-wiki.com/HOWTO_Software_Suspend_v2

http://wiki.suspend2.net/DistroAndHardwareSetup/DebianInitrd