General TC > Programming & Scripting - Unofficial
Check VGA card and load respective driver.
(1/1)
Misalf:
For my USB install of Tiny Core I'm not using the default xvesa but xorg which needs a graphics driver depending on the graphics card. Not always knowing the hardware of the boxes, I came up with this code which resides in /op/bootsync.sh .
Depends on pci-utils.tcz .
--- Code: ---## Check VGA card and load respective driver.
[ -d /etc/X11 ] || mkdir -p /etc/X11
if [ $(which lspci) ]; then
echo -en "\033[1;30m:: \033[1;34mVGA\033[1;30m: "
VGA="$(lspci | grep -m1 -E "VGA|3D")"
VGA_VENDOR="$(echo "$VGA" | grep -m1 -i -o -E "intel|nvidia|radeon" )"
if [ -n "$VGA_VENDOR" ]; then
VGA_MODEL="$(lspci | grep -m1 -e VGA -e 3D | sed 's/^.*VGA compatible controller: //;s/ Corporation//;s/ Mobile//;s/ Express//;s/ Integrated Graphics Controller//;s/ (rev .*//' | sed "s:$VGA_VENDOR ::I")"
echo -en "\033[1;33m$VGA_VENDOR \033[1;32m$VGA_MODEL\033[1;30m ...\033[1;33m"
TCUSER="$(cat /etc/sysconfig/tcuser)"
KERNEL="$(uname -r)"
VGA_VENDOR="$(echo "$VGA_VENDOR" | tr '[:upper:]' '[:lower:]')"
case $VGA_VENDOR in
intel)
su "$TCUSER" -c "tce-load -i xf86-video-intel" >/dev/null &
rotdash $!
echo -e "\033[1;30mDone\033[0;39m"
;;
nvidia)
if [ -e "/etc/sysconfig/tcedir/optional/nvidia-304.125-$KERNEL.tcz" ]; then
su "$TCUSER" -c "tce-load -i nvidia-304.125-$KERNEL" >/dev/null &
rotdash $!
[ -e /etc/X11/xorg.conf ] || nvidia-xconfig >/dev/null 2>&1
else
su "$TCUSER" -c "tce-load -i xf86-video-nouveau" >/dev/null &
rotdash $!
fi
echo -e "\033[1;30mDone\033[0;39m"
;;
radeon)
su "$TCUSER" -c "tce-load -i firmware-radeon xf86-video-ati" >/dev/null &
rotdash $!
echo -e "\033[1;30mDone\033[0;39m"
;;
*) echo -e "\033[1;30mUnknown\033[0;39m" ;;
esac
else
echo -e "\033[1;31mFailed\033[1;34m to determine driver\033[1;30m.\033[0;39m"
fi
#VGA_PCI="$(echo "$VGA" | awk '{printf "%s" $1}')"
#VGA_RAM="$(sudo lspci -v -s "$VGA_PCI" | grep -m1 ", prefetchable)" | awk '{printf "%s" $6}' | awk 'BEGIN {FS = "="} {if ($1 == "[size") { RAM = $2 }} END {print RAM}' | sed 's:]$:B:')"
#echo "Video RAM: $VGA_RAM"
fi
--- End code ---
Works for Intel and NVidia cards as long as the extensions are available on the boot media.
ATI cards have not been tested.
curaga:
Nice, the lazy user would just load them all and have Xorg detect it based on the PCI id.
Misalf:
The proprietary nvidia drivers, compared to other drivers, seem to need a lot of RAM even if unused. Not sure if it would make much of a difference since it's just cached or buffered stuff that would probably get unloaded if more RAM is needed. But anyway, loading less is always good I think and speeds up boot time.
Added check for Xorg .
Added displaying of Video RAM because reasons.
Moved creation of /etc/X11 directory.
--- Code: ---## Check VGA card and load respective driver.
if [ $(which lspci) ] && [ $(which Xorg) ]; then
echo -en "\033[1;30m:: \033[1;34mVGA\033[1;30m: "
VGA="$(lspci | grep -m1 -E "VGA|3D")"
VGA_VENDOR="$(echo "$VGA" | grep -m1 -i -o -E "intel|nvidia|radeon" )"
if [ -n "$VGA_VENDOR" ]; then
[ -d /etc/X11 ] || mkdir -p /etc/X11
VGA_MODEL="$(lspci | grep -m1 -e VGA -e 3D | sed 's/^.*VGA compatible controller: //;s/ Corporation//;s/ Mobile//;s/ Express//;s/ Integrated Graphics Controller//;s/ (rev .*//' | sed "s:$VGA_VENDOR ::I")"
VGA_PCI="$(echo "$VGA" | awk '{printf "%s" $1}')"
VGA_RAM="$(lspci -v -s "$VGA_PCI" | grep -m1 ", prefetchable)" | awk '{printf "%s" $6}' | awk 'BEGIN {FS = "="} {if ($1 == "[size") { RAM = $2 }} END {print RAM}' | sed 's:]$:B:')"
echo -en "\033[1;33m$VGA_VENDOR \033[1;32m$VGA_MODEL \033[0;32m($VGA_RAM)\033[1;30m ...\033[1;33m"
TCUSER="$(cat /etc/sysconfig/tcuser)"
KERNEL="$(uname -r)"
VGA_VENDOR="$(echo "$VGA_VENDOR" | tr '[:upper:]' '[:lower:]')"
case $VGA_VENDOR in
intel)
su "$TCUSER" -c "tce-load -i xf86-video-intel" >/dev/null &
rotdash $!
echo -e "\033[1;30mDone\033[0;39m"
;;
nvidia)
if [ -e "/etc/sysconfig/tcedir/optional/nvidia-304.125-$KERNEL.tcz" ]; then
su "$TCUSER" -c "tce-load -i nvidia-304.125-$KERNEL" >/dev/null &
rotdash $!
[ -e /etc/X11/xorg.conf ] || nvidia-xconfig >/dev/null 2>&1
else
su "$TCUSER" -c "tce-load -i xf86-video-nouveau" >/dev/null &
rotdash $!
fi
echo -e "\033[1;30mDone\033[0;39m"
;;
radeon)
su "$TCUSER" -c "tce-load -i firmware-radeon xf86-video-ati" >/dev/null &
rotdash $!
echo -e "\033[1;30mDone\033[0;39m"
;;
*) echo -e "\033[1;30mUnknown\033[0;39m" ;;
esac
else
echo -e "\033[1;31mFailed\033[1;34m to determine driver\033[1;30m.\033[0;39m"
fi
fi
--- End code ---
Misalf:
Well, checking the VRAM via lspci seems to be relatively useless as it cannot see more than 256 MB.
So I removed it. Also removed one redundant lspci.
--- Code: ---## Check VGA card and load respective driver.
if [ $(which lspci) ] && [ $(which Xorg) ]; then
echo -en "\033[1;30m:: \033[1;34mVGA\033[1;30m: "
VGA="$(lspci | grep -m1 -E "VGA|3D")"
VGA_VENDOR="$(echo "$VGA" | grep -m1 -i -o -E "intel|nvidia|radeon" )"
if [ -n "$VGA_VENDOR" ]; then
[ -d /etc/X11 ] || mkdir -p /etc/X11
VGA_MODEL="$(echo "$VGA" | sed 's/^.*VGA compatible controller: //;s/ Corporation//;s/ Mobile//;s/ Express//;s/ Integrated Graphics Controller//;s/ (rev .*//' | sed "s:$VGA_VENDOR ::I")"
echo -en "\033[1;33m$VGA_VENDOR \033[1;32m$VGA_MODEL\033[1;30m ...\033[1;33m"
TCUSER="$(cat /etc/sysconfig/tcuser)"
KERNEL="$(uname -r)"
VGA_VENDOR="$(echo "$VGA_VENDOR" | tr '[:upper:]' '[:lower:]')"
case $VGA_VENDOR in
intel)
su "$TCUSER" -c "tce-load -i xf86-video-intel" >/dev/null &
rotdash $!
echo -e "\033[1;30mDone\033[0;39m"
;;
nvidia)
if [ -e "/etc/sysconfig/tcedir/optional/nvidia-304.125-$KERNEL.tcz" ]; then
su "$TCUSER" -c "tce-load -i nvidia-304.125-$KERNEL" >/dev/null &
rotdash $!
[ -e /etc/X11/xorg.conf ] || nvidia-xconfig >/dev/null 2>&1
else
su "$TCUSER" -c "tce-load -i xf86-video-nouveau" >/dev/null &
rotdash $!
fi
echo -e "\033[1;30mDone\033[0;39m"
;;
radeon)
su "$TCUSER" -c "tce-load -i firmware-radeon xf86-video-ati" >/dev/null &
rotdash $!
echo -e "\033[1;30mDone\033[0;39m"
;;
*) echo -e "\033[1;30mUnknown\033[0;39m" ;;
esac
else
echo -e "\033[1;31mFailed\033[1;34m to determine driver\033[1;30m.\033[0;39m"
fi
fi
--- End code ---
If anyone with an ATI / Radeon card would like to try this code in /opt/bootsync.sh , I'd like to hear if it works or if additional extensions are needed.
Also I have no idea about geode , mach64 , neomagic , openchrome and vmware .
Feel free to feed me with the output of
--- Code: ---lspci | grep -m1 -E "VGA|3D"
--- End code ---
Navigation
[0] Message Index
Go to full version