desktop-base-openmamba/mambabase/nvidia-autoselect-driver

92 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
#
# nVidia legacy test script
#
# Copyright (c) 2007-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Released under the GNU GPL v.3 license
#
[ "$1" = "-i" ] && DO_INSTALL=1
PCIID=`/usr/sbin/lspci -n | grep " 0300: 10de:" | awk '{ print $3 }'`
[ "$PCIID" ] || {
echo "No NVIDIA PCI device found!" >&2
exit 1
}
DEVID=`echo ${PCIID/*:/} | tr '[:lower:]' '[:upper:]'`
case $DEVID in
0191|0193|0194|0197|019D|019E|0400|0401|0402|0403|\
0404|0405|0406|0407|0408|0409|040A|040B|040C|040D|\
040E|040F|0410|0420|0421|0422|0423|0424|0425|0426|\
0427|0428|0429|042A|042B|042C|042D|042E|042F|05E0|\
05E1|05E2|05E3|05E6|05E7|05EA|05EB|05ED|05F8|05F9|\
05FD|05FE|05FF|0600|0601|0602|0603|0604|0605|0606|\
0607|0608|0609|060A|060B|060C|060D|060F|0610|0611|\
0612|0613|0614|0615|0617|0618|0619|061A|061B|061C|\
061D|061E|061F|0621|0622|0623|0625|0626|0627|0628|\
062A|062B|062C|062D|062E|0630|0631|0632|0635|0637|\
0638|063A|0640|0641|0643|0644|0645|0646|0647|0648|\
0649|064A|064B|064C|0651|0652|0653|0654|0655|0656|\
0658|0659|065A|065B|065C|06E0|06E1|06E2|06E3|06E4|\
06E5|06E6|06E7|06E8|06E9|06EA|06EB|06EC|06EF|06F1|\
06F8|06F9|06FA|06FB|06FD|06FF|0840|0844|0845|0846|\
0847|0848|0849|084A|084B|084C|084D|084F|0860|0861|\
0862|0863|0864|0865|0866|0867|0868|0869|086A|086C|\
086D|086E|086F|0870|0871|0872|0873|0874|0876|087A|\
087D|087E|087F|08A0|08A2|08A3|08A4|08A5|0A20|0A22|\
0A23|0A26|0A27|0A28|0A29|0A2A|0A2B|0A2C|0A2D|0A32|\
0A34|0A35|0A38|0A3C|0A60|0A62|0A63|0A64|0A65|0A66|\
0A67|0A68|0A69|0A6A|0A6C|0A6E|0A6F|0A70|0A71|0A72|\
0A73|0A74|0A75|0A76|0A78|0A7A|0A7C|0CA0|0CA2|0CA3|\
0CA4|0CA5|0CA7|0CA8|0CA9|0CAC|0CAF|0CB0|0CB1|0CBC|\
10C0|10C3|10C5|10D8) ALT_SUFFIX='340' ;;
0040|0041|0042|0043|0044|0045|0046|0047|0048|004E|\
0090|0091|0092|0093|0095|0098|0099|009D|00C0|00C1|\
00C2|00C3|00C8|00C9|00CC|00CD|00CE|00F1|00F2|00F3|\
00F4|00F5|00F6|00F8|00F9|0140|0141|0142|0143|0144|\
0145|0146|0147|0148|0149|014A|014C|014D|014E|014F|\
0160|0161|0162|0163|0164|0165|0166|0167|0168|0169|\
016A|01D0|01D1|01D2|01D3|01D6|01D7|01D8|01DA|01DB|\
01DC|01DD|01DE|01DF|0211|0212|0215|0218|0221|0222|\
0240|0241|0242|0244|0245|0247|0290|0291|0292|0293|\
0294|0295|0297|0298|0299|029A|029B|029C|029D|029E|\
029F|02E0|02E1|02E2|02E3|02E4|038B|0390|0391|0392|\
0393|0394|0395|0397|0398|0399|039C|039E|03D0|03D1|\
03D2|03D5|03D6|0531|0533|053A|053B|053E|07E0|07E1|\
07E2|07E3|07E5) ALT_SUFFIX='304' ;;
00FA|00FB|00FC|00FD|00FE|0301|0302|0308|0309|0311|\
0312|0314|031A|031B|031C|0320|0321|0322|0323|0324|\
0325|0326|0327|0328|032A|032B|032C|032D|0330|0331|\
0332|0333|0334|0338|033F|0341|0342|0343|0344|0347|\
0348|034C|034E) ALT_SUFFIX='173' ;;
0110|0111|0112|0113|0170|0171|0172|0173|0174|0175|\
0176|0177|0178|0179|017A|017C|017D|0181|0182|0183|\
0185|0188|018A|018B|018C|01A0|01F0|0200|0201|0202|\
0203|0250|0251|0253|0258|0259|025B|0280|0281|0282|\
0286|0288|0289|028C) ALT_SUFFIX='96' ;;
0020|0028|0029|002C|002D|00A0|0100|0101|0103|0150|\
0151|0152|0153) ALT_SUFFIX='71' ;;
*) ALT_SUFFIX='' ;;
esac
case $ALT_SUFFIX in
340) REC_DRIVER='xorg-drv-video-nvidia_340' ;;
304) REC_DRIVER='xorg-drv-video-nvidia_304' ;;
173|96|71) REC_DRIVER='nouveau' ;;
*) REC_DRIVER='xorg-drv-video-nvidia' ;;
esac
echo "NVIDIA recommended driver is $REC_DRIVER" >&2
if [ "$DO_INSTALL" = "1" ]; then
rpm -q $REC_DRIVER || pkcon install -y $REC_DRIVER
fi