Lenovo thinkpad t61 / t61p


Docking station support

Advanced Mini Dock

At moosy we have a T61p with the Lenovo Advanced Mini Dock.
For more information on this, see
Linux features a "dock" kernel module which offers rudimentary support for this.
On openSUSE 11, hot docking and undocking works out-of-the-box for things like HID devices (mouse, keyboard) and network.

While trying this, dmesg and /var/log/messages showed docking/undocking events:
kernel: ACPI: \_SB_.GDCK - docking
kernel: ACPI: \_SB_.GDCK - undocking

If there is an event, it can be detected and used as a trigger!
The primary goal of this exercise is to automatically switch the graphical display between the internal LCD and the external monitor connected to the dock.

Sysfs dock information

When looking in sysfs (/sys) there is quite a lot of information available regarding the dock.
Detect docked state:
# cat /sys/bus/platform/devices/dock.0/docked

View uevent alias:
# cat /sys/devices/platform/dock.0/uevent

Udev dock events

Linux offers a very nice system event interface with udev. This can be used to trigger on a certain event, and run a script, for example.
First we need to obtain information about the hardware we want to monitor. The system command udevinfo can be used to list attributes of our dock device:
# udevinfo -a -p /sys/devices/platform/dock.0

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/platform/dock.0':

  looking at parent device '/devices/platform':

This tells us, that the dock module maintains an attribute "docked" which contains the state. Useful, and we will trigger on this changing attribute.

Write udev rules

See for a complete description of the possibilities with udev rules.
For now, we will focus on the dock, triggering on docked / undocked state changes.

# Rules for docking / undocking

KERNEL=="dock.0", ATTR{docked}=="1", RUN+="/sbin/ 1"
KERNEL=="dock.0", ATTR{docked}=="0", RUN+="/sbin/ 0"

For some reason (timing, probably) only the first rule ever gets triggered. This means that our script will always get "1" as the state and will need to do its own detection.
STATE=$(/usr/bin/udevinfo -a -p /sys/devices/platform/dock.0 | grep docked | awk -F= {'print $3'} | sed s/\"//g)

Changing the X output

Display connected monitors:
# xrandr -q | grep ^[VDL] | awk -F\  {'print $1": "$2'}
VGA1: disconnected
DVI1: connected
LVDS: connected
In script, change monitor with xrandr:
# xrandr -d :0.0 -s 1680x1050
# xrandr -d :0.0 -s 1920x1200


Nothing much specific for the T61p, but need to place it somewhere:

CASA on openSUSE 11.0

Enable in YaST
/usr/bin/micasad-init /usr/bin/micasad.exe
mono /usr/bin/micasad.exe