xorg: other infinite fixes for nvidia <-> nouveau switch with X -configure getting worse

This commit is contained in:
Silvan Calarco 2015-03-05 19:16:00 +01:00
parent be4dd98c7c
commit e80b4fc1a1

View File

@ -1,6 +1,6 @@
#!/bin/bash
# xorg - xorg plugin for postplug
# Copyright (c) 2004-2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Copyright (c) 2004-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Copyright (c) 2004-2007 by Davide Madrisan <davide.madrisan@gmail.com>
if [ $UID != 0 ]; then
@ -171,8 +171,8 @@ if [ -e $XORGCONF ]; then
rmmod nvidia
echo "blacklist nvidia" > /etc/modprobe.d/postplug-nouveau.conf
VIDEODRIVER=""
elif [ "$VIDEODRIVER" = "nouveau" -a "$NOUVEAU_MODESET" != "1" ]; then
# replace nouveau with nvidia
elif [ "$NOUVEAU_MODESET" = "0" ]; then
# replace nouveau with nvidia (NOUVEAU_MODESET=0 means we have nvidia chip)
mv $XORGCONF $XORGCONF.postplug.nouveau.save
rmmod nouveau
rm -f /etc/modprobe.d/postplug-nouveau.conf
@ -183,7 +183,7 @@ if [ -e $XORGCONF ]; then
rmmod fglrx
echo "blacklist fglrx" > /etc/modprobe.d/postplug-radeon.conf
VIDEODRIVER=""
elif [ "$VIDEODRIVER" = "radeon" -a "$RADEON_MODESET" != "1" ]; then
elif [ "$RADEON_MODESET" = "0" ]; then
# replace radeon with fglrx
#mv $XORGCONF $XORGCONF.postplug.radeon.save
rmmod radeon
@ -214,16 +214,18 @@ if [ ! -e $XORGCONF ]; then
# remove any nvidia driver loaded as they don't load according to PCIID
[ "`/sbin/lsmod 2>/dev/null | grep ^nvidia `" ] && rmmod nvidia
## detect and configure nvidia driver
#[ "$freevideo" ] || nvidia-autoselect-driver
# sync to avoid filesystem corruption in case of system hang on probe
sync
rm -f /tmp/xorg.conf.new
HOME=/tmp Xorg :5 -configure 2>>$logfile
logmsg "$me" "info: running Xorg -configure"
tmpfile=`mktemp`
HOME=/tmp Xorg :5 -configure 2>>$tmpfile
RET=$?
if [ $RET -ne 0 -o ! -e /tmp/xorg.conf.new ]; then
grep "Server terminated with error" $tmpfile >/dev/null && RET=255
logmsg "$me" "info: Xorg -configure return code was $RET"
if [ $RET -ne 0 -a "$NOUVEAU_MODESET" != "0" ]; then
logmsg "$me" "warning: xorg autoprobed configuration failed; using xorg autoconfig"
echo "# Dummy empty xorg.conf file created by postplug" > $XORGCONF
else
@ -481,29 +483,50 @@ EndSection
_EOF
fi
# enable 'Composite' extensions
if [ "$VIDEODRIVER" -a "$VIDEODRIVER" != "mga" -a ! -e /etc/X11/xorg.conf.d/40-extensions.conf ]; then
cat > /etc/X11/xorg.conf.d/40-extensions.conf << _EOF
Section "Extensions"
Option "Composite" "true"
EndSection
_EOF
elif [ "$VIDEODRIVER" != "mga" -a -e /etc/X11/xorg.conf.d/40-extensions.conf ]; then
rm -f /etc/X11/xorg.conf.d/40-extensions.conf
fi
# add 'Section "DRI"'
if [ "$VIDEODRIVER" -a "$VIDEODRIVER" != "mga" -a ! -e /etc/X11/xorg.conf.d/50-dri.conf ]; then
cat > /etc/X11/xorg.conf.d/50-dri.conf << _EOF
Section "DRI"
Mode 0666
EndSection
_EOF
fi
if [ -d /sys/devices/platform/sunxi-rtc -a ! -e /etc/X11/xorg.conf.d/30-serverflags.conf ]; then
# Workaround: disable DPMS on BananaPi
cat > /etc/X11/xorg.conf.d/30-serverflags.conf << _EOF
Section "ServerFlags"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
EndSection
_EOF
fi
# Workaround symlink for libglx.so (or Xorg will choose the wrong one)
if [ -e /usr/lib/xorg/modules/extensions/libglx.so -a ! -e /usr/lib/xorg/modules/libglx.so ]; then
ln -s extensions/libglx.so /usr/lib/xorg/modules/extensions/libglx.so
fi
if [ -e /usr/lib64/xorg/modules/extensions/libglx.so -a ! -e /usr/lib64/xorg/modules/libglx.so ]; then
ln -s extensions/libglx.so /usr/lib64/xorg/modules/libglx.so
fi
[ -e $XORGCONF -a "$VIDEODRIVER" ] || exit 0
# add missing brackets to Xorg.conf device entries
sed -i "s|^[ \t]*Driver[ \t]*\([A-Za-z0-9]*\)[ \t]*$| Driver \"\1\"|g" $XORGCONF
# add 'Section "DRI"' if not present...
if [ "$XORG_ENABLE_DRI" = "on" ]; then
grep -q 'Section "DRI"' $XORGCONF
[ $? -eq 1 ] && echo "
Section \"DRI\"
Mode 0666
EndSection" >> $XORGCONF
fi
# enable 'Composite' extensions if not present...
if [[ "$XORG_ENABLE_COMPOSITE_EXT" = "on" ]]; then
grep -q 'Section "Extensions"' $XORGCONF
[ $? -eq 1 ] && echo "
Section \"Extensions\"
Option \"Composite\" \"true\"
EndSection" >> $XORGCONF
fi
# set alternative configuration for different video drivers
xorg_set_alternatives