Skip to content

Commit

Permalink
Merge pull request #28 from mariux64/pass-legacy-cards-to-nouveau
Browse files Browse the repository at this point in the history
Pass legacy cards to nouveau
  • Loading branch information
donald authored Feb 22, 2018
2 parents 64d7d3e + f60aab1 commit 5a1d993
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions nvidiactl/nvidiactl
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 5a1d993

Please sign in to comment.