Skip to content

Commit

Permalink
nvidiactl: Refactor
Browse files Browse the repository at this point in the history
Refactor fallback to nouveau driver into function.
  • Loading branch information
donald committed Dec 16, 2019
1 parent 46309d7 commit ab1a0f9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions nvidiactl/nvidiactl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ set_generic_mxgfx_link () {
ln -sf /usr/share/mxgfx-generic /node/usr_share_mxgfx
}

use_nouveau () {
set_generic_mxgfx_link
test -e /lib/modules/${kver}/kernel/drivers/gpu/drm/nouveau/nouveau.ko && \
echo >&2 "NOTE: using nouveau.." && \
modprobe nouveau && \
exit 0

echo >&2 "ERROR: nouveau module not available."
exit 1
}

if [ -d /sys/module/nouveau ] ; then
echo >&2 "NOTE: nouveau driver loaded already, using 'mxgfx-generic'."
Expand All @@ -30,14 +40,8 @@ pciids="${PCIIDHINT_DIR}/${kver}-${nvver} ${PCIIDHINT_DIR}/${nvver}"

for leglvlhint in ${pciids} ; do
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
echo >&2 "NOTE: legacy nvidia card found.."
use_nouveau
fi
done

Expand Down

0 comments on commit ab1a0f9

Please sign in to comment.