From 33d617f3ae12e8f063fc46103ab79fa13810e1f1 Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Mon, 25 Oct 2010 20:48:08 +0200 Subject: [PATCH] xorg-server: rework detection of graphic card Signed-off-by: Stephan Raue --- .../x11/xserver/xorg-server/init.d/15_xorg | 31 +------- .../xorg-server/profile.d/display.conf | 78 +++++++++++++++++-- 2 files changed, 73 insertions(+), 36 deletions(-) diff --git a/packages/x11/xserver/xorg-server/init.d/15_xorg b/packages/x11/xserver/xorg-server/init.d/15_xorg index 3b8d002af4..62122c95b6 100755 --- a/packages/x11/xserver/xorg-server/init.d/15_xorg +++ b/packages/x11/xserver/xorg-server/init.d/15_xorg @@ -26,26 +26,11 @@ . /etc/profile -( - XORG_DEFAULT_CONF="/etc/X11/xorg.conf" - XORG_NVIDIA_CONF="/etc/X11/xorg-nvidia.conf" - XORG_NVIDIA_CHD_CONF="/etc/X11/xorg-nvidia-chd.conf" - XORG_USER_CONF="/storage/.config/xorg.conf" XORG_ARGS="-s 0 -nr -noreset -allowMouseOpenFail -nocursor -nolisten tcp" [ "$DEBUG" = yes ] && XORG_ARGS="$XORG_ARGS -logverbose 6 -verbose 6" - # find used graphic driver - if [ -d /sys/module/i915 ]; then - DRIVER="intel" - elif [ -d /sys/module/nouveau ]; then - DRIVER="nouveau" - elif [ -d /sys/module/nvidia ]; then - DRIVER="nvidia" - else - DRIVER="other" - fi - +( progress "creating directories needed for Xorg" mkdir -p /var/cache/xkb @@ -53,27 +38,15 @@ mkdir -m 1777 -p /tmp/.ICE-unix chown root:root /tmp/.ICE-unix - # test if nvidia kernel driver is loaded, - if [ "$DRIVER" = "nvidia" ]; then + if [ "$GPUTYPE" = "NVIDIA" ]; then ln -sf /usr/lib/libGL_nvidia.so.1 /var/lib/libGL.so ln -sf /usr/lib/xorg/modules/extensions/libglx_nvidia.so /var/lib/libglx.so XORG_ARGS="$XORG_ARGS -ignoreABI" - - # check if we have an Broadcom CrystalHD card installed, so we can disable - # the use of shared memory - if lspci -n | grep 0480 | grep -q 14e4; then - XORG_CONF="$XORG_NVIDIA_CHD_CONF" - else - XORG_CONF="$XORG_NVIDIA_CONF" - fi else ln -sf /usr/lib/libGL_mesa.so.1 /var/lib/libGL.so ln -sf /usr/lib/xorg/modules/extensions/libglx_mesa.so /var/lib/libglx.so - XORG_CONF="$XORG_DEFAULT_CONF" fi - [ -f $XORG_USER_CONF ] && XORG_CONF="$XORG_USER_CONF" - progress "starting xorg" XORG_ARGS="$XORG_ARGS -config $XORG_CONF" diff --git a/packages/x11/xserver/xorg-server/profile.d/display.conf b/packages/x11/xserver/xorg-server/profile.d/display.conf index 51b7873c0b..02f34d9ba9 100644 --- a/packages/x11/xserver/xorg-server/profile.d/display.conf +++ b/packages/x11/xserver/xorg-server/profile.d/display.conf @@ -5,12 +5,76 @@ # evironment variables that are not user defined. ################################################################################ -DISPLAY=":0.0" +################################################################################ +# setup $DISPLAY variable +################################################################################ -export DISPLAY + DISPLAY=":0.0" + export DISPLAY -wait_for_xorg () { - while [ ! -f /tmp/.X0-lock ]; do - usleep 200000 - done -} +################################################################################ +# setup xorg.conf paths +################################################################################ + + XORG_CONF_DEFAULT="/etc/X11/xorg.conf" + XORG_CONF_INTEL="/etc/X11/xorg-intel.conf" + XORG_CONF_NVIDIA="/etc/X11/xorg-nvidia.conf" + XORG_CONF_NVIDIA_CHD="/etc/X11/xorg-nvidia-chd.conf" + XORG_CONF_NOUVEAU="/etc/X11/xorg-nouveau.conf" + XORG_CONF_RADEON="/etc/X11/xorg-radeon.conf" + XORG_CONF_USER="/storage/.config/xorg.conf" + +################################################################################ +# setup driver paths +################################################################################ + + XORG_DRIVER_INTEL="/usr/lib/xorg/modules/drivers/intel_drv.so" + XORG_DRIVER_NVIDIA="/usr/lib/xorg/modules/drivers/nvidia_drv.so" + XORG_DRIVER_NOUVEAU="/usr/lib/xorg/modules/drivers/nouveau_drv.so" + XORG_DRIVER_RADEON="/usr/lib/xorg/modules/drivers/radeon_drv.so" + +################################################################################ +# Identify GPU, other by default +################################################################################ + + GPUDEVICE=$(lspci -n | grep 0300) + GPUTYPE="OTHER" + [ "$(echo $GPUDEVICE | grep 8086)" -a -f "$XORG_DRIVER_INTEL" ] && GPUTYPE="INTEL" # 8086 == INTEL + [ "$(echo $GPUDEVICE | grep 10de)" -a -f "$XORG_DRIVER_NVIDIA" ] && GPUTYPE="NVIDIA" # 10de == NVIDIA + [ "$(echo $GPUDEVICE | grep 10de)" -a -f "$XORG_DRIVER_NOUVEAU" ] && GPUTYPE="NOUVEAU" # 10de == NVIDIA + [ "$(echo $GPUDEVICE | grep 1002)" -a -f "$XORG_DRIVER_RADEON" ] && GPUTYPE="AMD" # 1002 == AMD + +################################################################################ +# Identify any Mediadevice, like Broadcom's CrystalHD cards +################################################################################ + + MEDIADEVICE=$(lspci -n | grep 0480) + MEDIATYPE="NO" + [ "$(echo $MEDIADEVICE | grep 14e4)" ] && MEDIATYPE="CRYSTALHD" # 14e4 == BROADCOM + +################################################################################ +# setup xorg.conf +################################################################################ + + [ "$GPUTYPE" = "INTEL" ] && XORG_CONF="$XORG_CONF_INTEL" + [ "$GPUTYPE" = "NVIDIA" ] && XORG_CONF="$XORG_CONF_NVIDIA" + [ "$GPUTYPE" = "NOUVEAU" ] && XORG_CONF="$XORG_CONF_NOUVEAU" + [ "$GPUTYPE" = "RADEON" ] && XORG_CONF="$XORG_CONF_RADEON" + [ "$GPUTYPE" = "OTHER" ] && XORG_CONF="$XORG_CONF_DEFAULT" + + # check if we have an Broadcom CrystalHD card installed, so we can disable + # the use of shared memory + [ "$GPUTYPE" = "NVIDIA" -a "$MEDIATYPE" = "CRYSTALHD" ] && XORG_CONF="$XORG_CONF_NVIDIA_CHD" + + # load user defined xorg.conf, if exist + [ -f "$XORG_CONF_USER" ] && XORG_CONF="$XORG_CONF_USER" + +################################################################################ +# setup functions +################################################################################ + + wait_for_xorg () { + while [ ! -f /tmp/.X0-lock ]; do + usleep 200000 + done + }