diff --git a/nvidiactl/nvidiactl b/nvidiactl/nvidiactl index 2ea5265..2d6f3f5 100755 --- a/nvidiactl/nvidiactl +++ b/nvidiactl/nvidiactl @@ -1,5 +1,17 @@ #!/bin/bash +set_generic_mxgfx_link () { + rm -f /node/usr_share_mxgfx + ln -sf /usr/share/mxgfx-generic /node/usr_share_mxgfx +} + + +if [ -d /sys/module/nouveau ] ; then + echo >&2 "NOTE: nouveau driver loaded already, using 'mxgfx-generic'." + set_generic_mxgfx_link + exit 0 +fi + PCIIDHINT_DIR=/usr/share/nvidia/pciidhints kver=$(uname -r) @@ -8,41 +20,37 @@ nvidiacards=( $(lspci -n | grep " 0300: 10de:" | cut -d ' ' -f 3) ) nvver=${nvidiacards[0]} - if [ -z ${nvver} ] ; then - echo >&2 "WARNING: no nvidia card found.." - rm -f /node/usr_share_mxgfx - ln -sf /usr/share/mxgfx-generic /node/usr_share_mxgfx - exit 0 + echo >&2 "WARNING: no nvidia card found.." + set_generic_mxgfx_link + exit 0 fi pciids="${PCIIDHINT_DIR}/${kver}-${nvver} ${PCIIDHINT_DIR}/${nvver}" - -leglvl="current" - for leglvlhint in ${pciids} ; do - if [ -h "${leglvlhint}" ] ; then - leglvl=$(readlink ${leglvlhint}) - break - fi + if [ -h "${leglvlhint}" ] ; then + set_generic_mxgfx_link + test -e /lib/modules/${kver}/kernel/drivers/gpu/drm/nouveau/nouveau.ko && \ + echo >&2 "NOTE: legacy nvidia card found, loading nouveau .." && \ + modprobe nouveau && \ + exit 0 + + echo >&2 "ERROR: nouveau module not available, choose a newer kernel!" + exit 1 + fi done -nvlink=/usr/share/nvidia/kernel/${kver}/${leglvl} +nvlink=/usr/share/nvidia/kernel/${kver}/current if [ ! -h ${nvlink} ] ; then - echo >&2 "WARNING: ${nvlink} is not a link (to nvversion) trying current.." - nvlink=/usr/share/nvidia/kernel/${kver}/current -fi - -if [ ! -h ${nvlink} ] ; then - echo >&2 "WARNING: ${nvlink} is not a link (to nvversion) .." - exit 1 + echo >&2 "WARNING: ${nvlink} is not a link (to nvversion) .." + exit 1 fi nvver=$(readlink ${nvlink}) -#echo "kver=${kver} leglvl=${leglvl} nvver=${nvver}" +#echo "kver=${kver} nvver=${nvver}" # lrwxrwxrwx 1 root system 27 Feb 11 15:39 /node/usr_share_mxgfx -> /usr/share/nvidia/260.19.21 @@ -77,4 +85,5 @@ if [ ! -z $N ]; then test -e ${nvlink}/nvidia-modeset.ko && insmod ${nvlink}/nvidia-modeset.ko test -e ${nvlink}/nvidia-drm.ko && insmod ${nvlink}/nvidia-drm.ko fi + exit 0