[Comm] Dual head ALD4

Michael Shigorin =?iso-8859-1?q?mike_=CE=C1_osdn=2Eorg=2Eua?=
Пн Сен 17 19:45:03 MSD 2007


On Wed, Sep 12, 2007 at 10:06:32PM +0300, Alexander Yereschenko wrote:
> 1) видюха видится как одно устройство по lspci:
> 01:00.0 VGA compatible controller: ATI Technologies Inc RV280
> [Radeon 9200] (rev 01)
> 
> Во всех примерах (см. ссылки выше) в xorg.conf требуется
> указать разные  BusID для каждого устройства вывода.

А на деле для 9200 нужен _один_ BusID для обоих устройств...
кажется, vsu@ это как-то рассказывал -- что второе там на PCI
в качестве объезда кривизны Windows(TM).

> Видюха ATI 9200 _умеет_ выводить два независимых изображения.
> Как это объяснить X-ам, если BusID у карточки только один?
> Для подробностей - в аттаче - моя заготовка для xorg.conf 
> (может еще какие грабли найдутся, кроме видео)

Эх... за приложенные костыли мне изрядно стыдно (даже в git.alt
не клал в надежде понять текущую схему с автонастройкой, к чему
вот недавно только подошёл по мотивам разборок около fglrx).
Но для случая "завести попавшееся железо в 2D, если это ATI --
с дуалхедом на :0.0 и :0.1" (по условиям задачи) оно работает.

Пояснения:

- xorg.conf.ati9200 -- то, с чем оно по факту работает
  (в болванке vesa)

- /usr/bin/x11updatedrv -- текущая внутренняя версия того,
  что опубликовано здесь:
  http://git.altlinux.org/people/mike/packages/?p=x11updatedrv.git;a=blob;f=x11updatedrv/x11updatedrv.sh;hb=HEAD

- /usr/bin/startxheads -- обёртка вокруг startx, выбирающая
  нужный ServerLayout.

:0 и :1 мне не были нужны, но на этих двух вполне работают
программы от разных пользователей, что и требуется.  Разные
dm, насколько понимаю, не заведутся.

PS: для того, чтобы поднять два монитора, они действительно
должны быть воткнуты при включении, как и упоминали.

-- 
 ---- WBR, Michael Shigorin <mike на altlinux.ru>
  ------ Linux.Kiev http://www.linux.kiev.ua/
----------- следующая часть -----------
#!/bin/sh
# a script to update Driver "..." in xorg.conf as seen on PCI
# by Michael Shigorin <mike на osdn.org.ua>, 2005, 2006
# use and modify freely

# thanks for tips to Sergey Vlasov <vsu на altlinux>
# and Sergey Bolshakov <sbolshakov на altlinux>

# init: avoid vesa but still have it as a fallback
VESA="Generic VESA compatible"
CARD=
DRIVER="vesa"

debug() {
	[ -n "$DEBUG" ] && echo $0: $* >&2
}

error() {
	echo $0: $* >&2; exit 1
}

( which x11createconfig && which x11setupdrv && \
  which x11setupdrv ) >&/dev/null || {
	error "needed utilities missing"
}

# put it to function since |while will go subshell
# and won't influence main process' vars
cards() {
		x11createconfig -c \
		| grep -v "$VESA" \
		| awk -F: '/^card:/ { print $2; }' \
		| while read type; do
			debug "considering non-vesa [$type]"
			[ -n "$type" ] && {
				[ -n "$CARD" ] && { 
				echo "$0: warning, overriding already acquired $CARD!" >&2
			}
			CARD="$type"
			echo "$CARD"
		} || echo "$0: hmm, empty card type in x11createconfig output?" >&2
	done
}

# read bus info for second ATI Radeon head, if any
# note that we drop function and force it to 0
secondary() {
       lspci -d 1002: \
       | grep Secondary \
       | while read bus device function rest; do
               busid="$bus:$device"
       done
       debug "secondary BusID: ${busid:-1:0}:0"
       echo ${busid:-1:0}:0
}


# x11setupdrv -s doesn't support multihead yet
# (actually all of this is a relatively quick hack
# to plug a hole with automatic more-or-less setup
# right at bootup...) -- taking presumably primary
# device available on higher numbered PCI bus
CARD=`cards | tail -1`
debug "card: [$CARD]"

[ -n "$CARD" ] && {
    xdriver=`vcardinfo "$CARD" | awk '/^xdriver\t/ { print $2; exit; }'` || {
    	error "pciscan failed"
    }
    
    # another one for Radeon 9550 and others set up with fglrx	// mike on 20070312
    [ "$xdriver" = "fglrx" ] && {
           debug "WARNING: fixing up preferred ATI driver (fglrx->ati)"
           xdriver="ati"
    }
    
    [ -n "$xdriver" ] && DRIVER="$xdriver"
} || {
	# is it some fancy new card not in hwdatabase yet?
	debug "WARNING: an empty CARD!"
	# NVIDIA might also be onboard
	pciscan -c 003 \
	| grep -q 'nVidia Corporation.*VGA compatible controller' \
	&& {
		debug "WARNING: some unknown NVIDIA videocard found, trying to use nvidia..."
		DRIVER="nvidia"
	}
	# ATI has less chance to be onboard, rather dualhead
	pciscan -c 003 \
	| grep -q 'ATI Technologies Inc.*VGA compatible controller' \
	&& {
		debug "WARNING: some unknown ATI videocard found, trying to use ati..."
		DRIVER="ati"
    }
	# else defaults to vesa
}
debug "driver: [$DRIVER]"

CURRENT=`x11setupdrv -d --nosetup | sed 's/driver name: //'` || {
	error "x11setupdrv failed"
}

debug "current: [$CURRENT]"

[ "$DRIVER" == "$CURRENT" ] && {
	debug "nothing to modify, driver is the same"
	exit 0	# nothing to be done
}

debug ">> setting driver to [$DRIVER]"

x11setupdrv -s "$DRIVER" || {
	error "x11setupdrv failed to modify configuration"
}

busid=`secondary`
[ -n "$busid" ] && subst \
       "s/\\(^[[:space:]]*BusID[[:space:]]*\"PCI:\\)1:0:0\"/\\1$busid\"/" \
       /etc/X11/xorg.conf
----------- следующая часть -----------
#!/bin/sh
# a script to wrap startx with single- or dual-head
# server layout chooser since using generic vesa/vga-based
# xorg.conf fails with dualhead chips (not dual-card setup)
# because vga or vesa grabs the whole chip and e.g. radeon
# configured for Screen1 will bail out taking the whole server
# down; you should have preconfigured ServerLayout "DualHead"
# 
# by Michael Shigorin <mike на osdn.org.ua>, 2006
# use freely

CARDS="`x11createconfig -c | grep ^card: | wc -l`" || {
	echo "$0: x11createconfig failed" >&2
	exit 1
}

case $CARDS in
		2) LAYOUT="-layout DualHead";;
		*) LAYOUT=;;
esac

# try to do plain startx just in case;
# needs fixed startx, see ALT bug #10245
startx -- $LAYOUT || startx
----------- следующая часть -----------
Section "ServerLayout"
	Identifier     "SingleHead"
	Screen         "Screen0" 0 0
	InputDevice    "mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "ServerLayout"
	Identifier     "DualHead"
	Screen      0  "Screen0" 0 0
	Screen      1  "Screen1" 0 0
	InputDevice    "mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
	Option	    "Clone" "off"
EndSection

Section "Files"
	FontPath     "unix/:-1"
EndSection

Section "Module"

	# don't load dri/glx by default: breakable and not crucial
#	Load  "glx"
#	Load  "v4l"
	Load  "dbe"
#	Load  "dri"
	Load  "extmod"
	Load  "type1"
	Load  "freetype"
#	SubSection  "extmod"
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
	Option	    "AutoRepeat" "250 30"
	Option	    "XkbModel" "pc105"
	Option	    "XkbLayout" "us,ru,ua"
	Option	    "XkbVariant" ",winkeys,winkeys"
	Option	    "XkbOptions" "grp:ctrl_shift_toggle,grp_led:scroll"
EndSection

Section "InputDevice"
	Identifier  "mouse0"
	Driver      "mouse"
	Option	    "Device" "/dev/input/mice"
EndSection

Section "Monitor"

	# hardwire DPI near 92 for cashdesk
	# NB: eostapets@ tells it's currently broken in xorg,
	# one needs to pass a server argument
	#DisplaySize  283	212
	Identifier   "Monitor0"
	Option	    "DPMS"
EndSection

Section "Monitor"

	# these are obviously in wrong place according to xorg.conf(5)
	# but ServerLayout is a bit too common between screens
	# so we'll really xset it in ~user/.icewm/startup
	#Option	    "DPMS" "off"
	#Option		"BlankTime" "32768"
	#Option		"StandbyTime" "32768"
	#Option		"SuspendTime" "32768"
	#Option		"OffTime" "32768"
#	HorizSync    31.5 - 48
#	VertRefresh  60.0 - 85.0
	Identifier   "Monitor1"
EndSection

Section "Device"

	# set default to vesa, x11updatedrv will take care at boot
	# NB: vga/vesa grab device in full, dualhead won't work
	Identifier  "Device0"
	Driver      "radeon"
	BusID       "PCI:1:0:0"
EndSection

Section "Device"
	Identifier  "Device1"
	Driver      "ati"
	BusID       "PCI:1:0:0"
	Screen      1
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Device0"
	Monitor    "Monitor0"
	DefaultDepth     16
	SubSection "Display"

		# provide safer fallback mode too
		Depth     16
		Modes    "1024x768" "800x600"
	EndSubSection
EndSection

Section "Screen"
	Identifier "Screen1"
	Device     "Device1"
	Monitor    "Monitor1"
	DefaultDepth     16
	SubSection "Display"
		Depth     16
		Modes    "1024x768"
	EndSubSection
EndSection

Section "DRI"
	Group        "xgrp"
	Mode         0660
EndSection



Подробная информация о списке рассылки community