7 Nov 2005 19:18
Re: Added support for binary only Matrox driver (Dual Head with MGA G400)
Hello,
The very short HowTo:
1) cd ThinStation-2.1/packages ; cp xorg6-mga xorg6-mgahal ; cd .. (the
additional file from Matrox has the name mga_hal_drv.o)
2) tar xzf mgadriver-4.1.tar.gz (which is available on the Matrox
support pages)
3) cp mgadriver-4.1/xfree86/6.8.1/*
packages/xorg6-mgahal/lib/X11/modules/drivers
4) created xorg6-mgahal/lib/X11/XF86Config-mgahal.tpl (see attachment)
5) modified packages/x-common/etc/init.d/x (see attachment) We have to
bypass the Xorg autoconfiguration when mgahal is installed and add
support for the three new config params (see 7)
6) added xorg6-mgahal package in build.conf
7) There are three new parameters for thinstation.conf:
# Necessary for Dual-Head with MGA G400 cards: Use PCI:1:0:0 for AGP
and PCI:2:0:0 for PCI type cards
X_DRIVER_BUSID="PCI:2:0:0"
# The layout
X_DRIVER_LAYOUT1="\"Screen 1\" 0 0"
X_DRIVER_LAYOUT2="\"Screen 2\" LeftOf \"Screen 1\""
Reagrds
Flori
#! /bin/sh
. $TS_GLOBAL
HOME=/tmp
X_PATH=/usr/X11R6
X_OPTIONS=/tmp/x_options
X_PORT=/tmp/x_port
X_AUTO=$HOME/xorg.conf.new
build_command ()
{
X_CMD="$X_SERVER :$DISPLAY_NUMBER"
if [ -e /tmp/X_TERMINATE ] ; then
X_CMD="$X_CMD -terminate"
fi
X_FONT="$X_PATH/lib/X11/fonts"
if [ -n "$SCREEN_X_FONT_SERVER" ]; then
if [ "$X_SERVER" != "Xvesa" ]; then
X_CMD="$X_CMD -fp $X_FONT/misc,tcp/$SCREEN_X_FONT_SERVER"
else
X_CMD="$X_CMD -fp tcp/$SCREEN_X_FONT_SERVER"
fi
else
X_CMD="$X_CMD -fp $X_FONT/misc"
[ -e $X_FONT/75dpi/fonts.dir ] && X_CMD="$X_CMD,$X_FONT/75dpi"
[ -e $X_FONT/100dpi/fonts.dir ] && X_CMD="$X_CMD,$X_FONT/100dpi"
fi
[ "$X_SERVER" = "Xorg" ] && X_CMD="$X_CMD -depth $SCREEN_COLOR_DEPTH \
-xkbmap $KEYBOARD_MAP \
-xf86config $X_PATH/etc/X11/XF86Config-$DISPLAY_NUMBER"
[ "$X_SERVER" != "Xorg" ] && [ "$X_SERVER" != "Xvesa" ] && \
X_CMD="$X_CMD -bpp $SCREEN_COLOR_DEPTH -xkbmap $KEYBOARD_MAP \
-xf86config $X_PATH/etc/X11/XF86Config-$DISPLAY_NUMBER"
[ "$X_SERVER" = "Xvesa" ] && X_CMD="$X_CMD -screen $SCREEN_RESOLUTION"x"$SCREEN_COLOR_DEPTH"
if [ -n "$DUALHEAD" ] ; then
# The keybdev driver can interfer with dual head support and needs to be removed
if lsmod | grep keybdev > /dev/null 2>&1 ; then
rmmod keybdev
fi
# The apm module causes the second screen to crash when using dual head
if lsmod | grep apm > /dev/null 2>&1 ; then
rmmod apm
fi
if [ "$X_SERVER" = "Xorg" ] && [ "$POSITION" -ge 2 ] ; then
X_CMD="$X_CMD -novtswitch -sharevts"
fi
fi
}
parse_xconfig ()
{
X_CONFIG=$X_PATH/etc/X11/XF86Config-$DISPLAY_NUMBER
echo s/\$SCREEN_RESOLUTION/$SCREEN_RESOLUTION/g > /tmp/script$DISPLAY_NUMBER
echo s/\$SCREEN_HORIZSYNC/$SCREEN_HORIZSYNC/g >> /tmp/script$DISPLAY_NUMBER
echo s/\$SCREEN_VERTREFRESH/$SCREEN_VERTREFRESH/g >> /tmp/script$DISPLAY_NUMBER
echo s/\$SCREEN_BLANK_TIME/$SCREEN_BLANK_TIME/g >> /tmp/script$DISPLAY_NUMBER
echo s/\$SCREEN_STANDBY_TIME/$SCREEN_STANDBY_TIME/g >> /tmp/script$DISPLAY_NUMBER
echo s/\$SCREEN_SUSPEND_TIME/$SCREEN_SUSPEND_TIME/g >> /tmp/script$DISPLAY_NUMBER
echo s/\$SCREEN_OFF_TIME/$SCREEN_OFF_TIME/g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$MOUSE_PROTOCOL <at> $MOUSE_PROTOCOL <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$MOUSE_DEVICE <at> $MOUSE_DEVICE <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$KEYBOARD_DEVICE <at> $KEYBOARD_DEVICE <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$MOUSE_RESOLUTION <at> $MOUSE_RESOLUTION <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$X_DRIVER_BUSID <at> $X_DRIVER_BUSID <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$X_DRIVER_LAYOUT1 <at> $X_DRIVER_LAYOUT1 <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$X_DRIVER_LAYOUT2 <at> $X_DRIVER_LAYOUT2 <at> g >> /tmp/script$DISPLAY_NUMBER
echo s/\$DISPLAY_NUMBER/$DISPLAY_NUMBER/g >> /tmp/script$DISPLAY_NUMBER
cat $X_PATH/lib/X11/XF86Config-$1.tpl | sed -f /tmp/script$DISPLAY_NUMBER > $X_CONFIG
rm /tmp/script$DISPLAY_NUMBER
return 0
}
xorg_options ()
{
if [ -n "$1" ] ; then
(echo $1) |
while read name option
do
echo -e "\tOption \"$name\" \"$option\"" >> $X_OPTIONS
done
fi
}
xorg_autoconfig ()
{
if [ ! -e $X_AUTO ] ; then
Xorg -modulepath $X_PATH/lib/X11/modules -configure >/var/log/x.config.log 2>&1
fi
awk '{print $0; if ($1=="InputDevice" && $2=="\"Mouse0\"") print " InputDevice \"Mouse2\""}' <
$X_AUTO > $X_AUTO.tmp
cp -f $X_AUTO.tmp $X_AUTO
X_CONFIG=$X_PATH/etc/X11/XF86Config-$DISPLAY_NUMBER
# Extra options for X Device
cat /dev/null > $X_OPTIONS
xorg_options "$X_DRIVER_OPTION1"
xorg_options "$X_DRIVER_OPTION2"
xorg_options "$X_DRIVER_OPTION3"
xorg_options "$X_DRIVER_OPTION4"
xorg_options "$X_DRIVER_OPTION5"
if [ -e $X_PATH/lib/X11/vnc_device.tpl ] ; then
VNC_PATH=$X_PATH/lib/X11
cat $VNC_PATH/vnc_device.tpl >> $X_OPTIONS
fi
# Manual Settings override autoconfig, however, if manual settings for
# driver name are wrong, it will drop back to autoconfig
if [ -e $X_AUTO ] ; then
let x=-1
if [ ! -e $X_PORT ] ; then
echo $x > $X_PORT
fi
awk "/Section \"Screen\"/,/EndSection/" $X_AUTO | \
awk '{print $0; if ( /Viewport/ ) print "\t\tModes \"'$SCREEN_RESOLUTION'\""}' \
>> $X_CONFIG
awk "/Section \"Monitor\"/,/EndSection/" $X_AUTO | \
awk '{print $0; if ( /ModelName/ ) { if ( "'$SCREEN_HORIZSYNC'" ) \
{ print "\tHorizSync '$SCREEN_HORIZSYNC'" } if ( "'$SCREEN_VERTREFRESH'" ) \
{ print "\tVertRefresh '$SCREEN_VERTREFRESH'"}}}' >> $X_CONFIG
if [ -e "$X_PATH/lib/X11/modules/drivers/$X_DRIVER_NAME"_drv.o ] ; then
echo "Section \"Device\"" >> $X_CONFIG
echo "Driver \"$X_DRIVER_NAME\"" >> $X_CONFIG
echo "Identifier \"Card0\"" >> $X_CONFIG
if [ -n "$X_DRIVER_BUSID" ] ; then
echo "BusID \"$X_DRIVER_BUSID\"" >> $X_CONFIG
fi
cat $X_OPTIONS >> $X_CONFIG
echo "EndSection" >> $X_CONFIG
else
awk "/Section \"Device\"/,/EndSection/" $X_AUTO | \
awk '{print $0; if ( /Section \"Device\"/ ) system("cat '$X_OPTIONS'")}' | \
awk 'BEGIN {x='`cat $X_PORT`'} {print $0 ; if ( /httpdir/ ) { y=y+1; \
print "\tOption \"httpport\" \""y+x+5800"\"" }} END { print y+x > "'$X_PORT'"}' >> $X_CONFIG
fi
# Checks for and configures dual head support
if [ "$DUALHEAD" = "ENABLED" ] ; then
# Auto configures keyboard/mouse support
if [ -z "$DUAL_KEYBOARD" ] && [ -z "$DUAL_MOUSE" ] ; then
ls /dev/input/event* > /tmp/devices
if [ -s /tmp/devices ] ; then
(cat /tmp/devices) |
while read device
do
devicetype=`evdev $device 2>&1`
if [ -z "$DUAL_KEYBOARD" ] ; then
if echo $devicetype | grep Keyboard > /dev/null ; then
DUAL_KEYBOARD=$device
echo "DUAL_KEYBOARD=$device" >> $TS_RUNTIME
fi
fi
if [ -z "$DUAL_MOUSE" ] ; then
if echo $devicetype | grep Mouse > /dev/null ; then
DUAL_MOUSE=$device
echo "DUAL_MOUSE=$device" >> $TS_RUNTIME
fi
fi
done
fi
rm /tmp/devices
fi
. $TS_RUNTIME
if [ -z "$DUAL_MOUSE" ] ; then
echo_log "Dual Head session aborted, no 2nd USB mouse found"
DUALHEAD=""
fi
if [ -z "$DUAL_KEYBOARD" ] ; then
echo_log "Dual Head session aborted, no 2nd USB keyboard found"
DUALHEAD=""
fi
if [ -n "$DUALHEAD" ] ; then
if [ "$POSITION" -ge "2" ] ; then
CONFIGFILE=$X_PATH/lib/X11/XF86Config-Xorg_Head2.tpl
CONFIGSERVER=$CONFIGFILE
MOUSE_DEVICE=$DUAL_MOUSE
KEYBOARD_DEVICE=$DUAL_KEYBOARD
else
CONFIGFILE=$X_PATH/lib/X11/XF86Config-Xorg_Head1.tpl
CONFIGSERVER=$CONFIGFILE
fi
else
CONFIGFILE=$X_PATH/lib/X11/XF86Config-Xorg_Dual.tpl
CONFIGSERVER=$X_AUTO
fi
else
CONFIGFILE=$X_PATH/lib/X11/XF86Config-Xorg_Dual.tpl
CONFIGSERVER=$X_AUTO
fi
if [ -n "$VNC_PATH" ] ; then
awk "/Section \"ServerLayout\"/,/EndSection/" $CONFIGSERVER | \
awk '{print $0; if ( /Identifier/ ) system("cat '$VNC_PATH/vnc_input.tpl'")}' >> $X_CONFIG
awk "/Section \"Module\"/,/EndSection/" $CONFIGFILE | \
awk '{print $0; if ( /Module/ ) print "\tLoad \"vnc\""}' >> $X_CONFIG
cat $VNC_PATH/vnc_keyboard.tpl >> $X_CONFIG
else
awk "/Section \"ServerLayout\"/,/EndSection/" $CONFIGSERVER >> $X_CONFIG
awk "/Section \"Module\"/,/EndSection/" $CONFIGFILE >> $X_CONFIG
fi
# Some model names are causing a config file to be corrupted, ModelName isn't required so we are deleting it
sed -i /ModelName/d $X_CONFIG
echo s\ <at> \$MOUSE_PROTOCOL <at> $MOUSE_PROTOCOL <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$MOUSE_DEVICE <at> $MOUSE_DEVICE <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$MOUSE_RESOLUTION <at> $MOUSE_RESOLUTION <at> g >> /tmp/script$DISPLAY_NUMBER
echo s\ <at> \$KEYBOARD_DEVICE <at> $KEYBOARD_DEVICE <at> g >> /tmp/script$DISPLAY_NUMBER
echo s/\$DISPLAY_NUMBER/$DISPLAY_NUMBER/g >> /tmp/script$DISPLAY_NUMBER
cat $CONFIGFILE | sed -f /tmp/script$DISPLAY_NUMBER | awk "/Section \"InputDevice\"/,/EndSection/"
>> $X_CONFIG
rm /tmp/script$DISPLAY_NUMBER
rm $X_OPTIONS
return 0;
else
echo -e "\n\nError, Configuration for Xorg has failed!!!!!" >> $LOGFILE
echo "Check /var/log/x.config.log for details" >> $LOGFILE
sleep 2
echo -e "\nTail of log file is:" >> $LOGFILE
tail /var/log/x.config.log >> $LOGFILE
echo -e "\n" >> $LOGFILE
sleep 2
return 1;
fi
}
build_config()
{
X_CONFIG=$X_PATH/etc/X11/XF86Config-$DISPLAY_NUMBER
if [ ! -e $X_CONFIG ] ; then
# Automagically detect what X server to use
echo debug_1
if pkg_is_executable Xorg ; then
echo debug_2
if [ -e $X_PATH/lib/X11/XF86Config-mgahal.tpl ] ; then
# Hook for xorg-mgahal (Dual Head with MGA400)
echo debug_3
if parse_xconfig mgahal ; then
echo debug_4
X_SERVER=Xorg
fi
else
echo debug_5
if parse_xconfig Xorg && xorg_autoconfig ; then
echo debug_6
X_SERVER=Xorg
fi
fi
elif pkg_is_executable XF86_S3 && parse_xconfig XF86_S3 \
&& ! XF86_S3 -probeonly 2>&1 | \
grep "None of the configured devices"; then
X_SERVER=XF86_S3
elif pkg_is_executable XF86_SVGA && parse_xconfig XF86_SVGA \
&& ! XF86_SVGA -probeonly 2>&1 | \
grep "None of the configured devices"; then
X_SERVER=XF86_SVGA
elif pkg_is_executable Xvesa; then
X_SERVER=Xvesa
else
"Can't autodetect your video card!!! Do you have one? ;)"
sleep 2
fi
echo "X_SERVER=$X_SERVER" >> $TS_RUNTIME
fi
}
case "$1" in
init)
if ! pkg_initialized $PACKAGE; then
if pkg_is_loaded mdetect && ! pkg_initialized mdetect; then
pkg init mdetect
. $TS_GLOBAL
fi
if [ ! -e $X_PATH ] ; then
ln -s $ROOT $X_PATH
fi
if [ ! -e /tmp/parsed/app-defaults ] ; then
mkdir /tmp/parsed/app-defaults
fi
if [ ! -e /tmp/parsed/extensions ] ; then
mkdir /tmp/parsed/extensions
fi
for filename in `ls /lib/X11/app-defaults.tmp/* /usr/lib/X11/app-defaults.tmp/* 2>/dev/null`
do
ln -s $filename /usr/X11R6/lib/X11/app-defaults
done
for filename in `ls /lib/X11/modules/extensions.tmp/* /usr/lib/X11/modules/extensions.tmp/* 2>/dev/null`
do
ln -s $filename /usr/X11R6/lib/X11/modules/extensions
done
pkg_set_init_flag $PACKAGE
fi
;;
start)
if [ ! -e /tmp/.X$DISPLAY_NUMBER-lock ]; then
echo "Starting $0 server" >> $LOGFILE
if [ -e /bin/mkfontdir ] || [ -e /usr/bin/mkfontdir ] ; then
if [ -e /usr/X11R6/lib/X11/fonts/75dpi ] ; then
mkfontdir /usr/X11R6/lib/X11/fonts/75dpi
fi
fi
build_config
echo X_SERVER:$X_SERVER
if [ -n "$X_SERVER" ]; then
build_command
# Delay needed for dual head support
if [ "$X_SERVER" = "Xorg" ] && [ "$POSITION" -ge 2 ] ; then
sleep 6
fi
X_CMD="$X_CMD -nolisten tcp"
echo $X_CMD >> $LOGFILE
$X_CMD >> $LOGFILE 2>&1 &
sleep 1
if [ "$X_SERVER" = "Xvesa" ]; then
touch /tmp/.X$DISPLAY_NUMBER-lock
fi
else
echo "XSERVER variable is not defined, error!!!"
echo "X aborted, starting shell instead."
ash
fi
fi
;;
stop)
if [ -e /tmp/.X$DISPLAY_NUMBER-lock ]; then
echo "Stoping $0 server" >> $LOGFILE
kill $(cat /tmp/.X$DISPLAY_NUMBER-lock)
fi
;;
console|menu)
if [ ! -e /tmp/.X$DISPLAY_NUMBER-lock ]; then
echo "Starting $0 server" >> $LOGFILE
build_config
echo console:X_SERVER:$X_SERVER
if [ -n "$X_SERVER" ]; then
build_command
if [ "$2" = "" ] ; then
X_CMD="$X_CMD -broadcast"
elif [ "$3" = "" ] ; then
X_CMD="$X_CMD -query $2"
else
X_CMD="$X_CMD $3 $2"
fi
echo $X_CMD >> $LOGFILE
exec $X_CMD >> $LOGFILE 2>&1
if [ $X_SERVER = "Xvesa" ]; then
touch /tmp/.X$DISPLAY_NUMBER-lock
fi
else
echo "XSERVER variable is not defined, error!!!"
echo "X aborted, starting shell instead."
ash
fi
fi
;;
help)
echo "Usage: $0 {init|start|stop|console|menu}"
;;
*)
exit 1
;;
esac
exit 0
Section "ServerLayout"
Identifier "Simple Layout"
Screen $X_DRIVER_LAYOUT1
Screen $X_DRIVER_LAYOUT2
InputDevice "Mouse1" "CorePointer"
InputDevice "Keyboard1" "CoreKeyboard"
EndSection
Section "ServerFlags"
Option "Xinerama"
Option "blank time" "$SCREEN_BLANK_TIME"
Option "standby time" "$SCREEN_STANDBY_TIME"
Option "suspend time" "$SCREEN_SUSPEND_TIME"
Option "off time" "$SCREEN_OFF_TIME"
EndSection
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
ModulePath "/usr/X11R6/lib/X11/modules"
EndSection
Section "Module"
Load "dbe"
Load "extmod"
Load "glx"
EndSection
Section "InputDevice"
Identifier "Keyboard1"
Driver "kbd"
EndSection
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Protocol" "$MOUSE_PROTOCOL"
Option "Device" "$MOUSE_DEVICE"
Option "ZAxisMapping" "4 5"
EndSection
Section "Monitor"
Identifier "My Monitor 1"
HorizSync $SCREEN_HORIZSYNC
VertRefresh $SCREEN_VERTREFRESH
EndSection
Section "Monitor"
Identifier "My Monitor 2"
HorizSync 31.5 - 95.0
VertRefresh 50.0 - 85.0
EndSection
Section "Device"
Identifier "MGA CARD 1"
Driver "mga"
BusID "$X_DRIVER_BUSID"
Option "HWcursor" "off"
Screen 0
EndSection
Section "Device"
Identifier "MGA CARD 2"
Driver "mga"
BusID "$X_DRIVER_BUSID"
Option "HWcursor" "off"
Screen 1
EndSection
Section "Screen"
Identifier "Screen 1"
Device "MGA CARD 1"
Monitor "My Monitor 1"
DefaultDepth 16
SubSection "Display"
Depth 8
Modes "$SCREEN_RESOLUTION"
EndSubSection
SubSection "Display"
Depth 16
Modes "$SCREEN_RESOLUTION"
EndSubSection
SubSection "Display"
Depth 24
Modes "$SCREEN_RESOLUTION"
EndSubSection
EndSection
Section "Screen"
Identifier "Screen 2"
Device "MGA CARD 2"
Monitor "My Monitor 2"
DefaultDepth 16
SubSection "Display"
Depth 8
Modes "$SCREEN_RESOLUTION"
EndSubSection
SubSection "Display"
Depth 16
Modes "$SCREEN_RESOLUTION"
EndSubSection
SubSection "Display"
Depth 24
Modes "$SCREEN_RESOLUTION"
EndSubSection
EndSection
RSS Feed