diff options
| -rwxr-xr-x | archsetup | 54 |
1 files changed, 44 insertions, 10 deletions
@@ -446,26 +446,60 @@ install_gpu_drivers() { display "subtitle" "GPU Drivers" - # Detect GPU vendors via lspci - gpu_info=$(lspci 2>/dev/null | grep -E "VGA|3D") + # Detect GPU vendors using modalias (more reliable than parsing lspci) + # Modalias is the kernel's hardware identification system used by drivers + # Vendor IDs: 1002=AMD, 8086=Intel, 10DE=NVIDIA + local detected_intel=false + local detected_amd=false + local detected_nvidia=false + + # Primary detection: check modalias from DRM subsystem + for modalias_file in /sys/class/drm/card*/device/modalias; do + if [[ -r "$modalias_file" ]]; then + modalias=$(cat "$modalias_file" 2>/dev/null) + case "$modalias" in + *v00008086*) detected_intel=true ;; + *v00001002*) detected_amd=true ;; + *v000010DE*|*v000010de*) detected_nvidia=true ;; + esac + fi + done + + # Fallback: check PCI bus modalias if DRM not available (early boot/chroot) + if ! $detected_intel && ! $detected_amd && ! $detected_nvidia; then + for modalias_file in /sys/bus/pci/devices/*/modalias; do + if [[ -r "$modalias_file" ]]; then + modalias=$(cat "$modalias_file" 2>/dev/null) + # Only check display class devices (bc03 = display controller) + if [[ "$modalias" == *bc03* ]]; then + case "$modalias" in + *v00008086*) detected_intel=true ;; + *v00001002*) detected_amd=true ;; + *v000010DE*|*v000010de*) detected_nvidia=true ;; + esac + fi + fi + done + fi - if echo "$gpu_info" | grep -qi "intel"; then - display "task" "Intel GPU detected - installing drivers" + # Install drivers based on detected hardware + if $detected_intel; then + display "task" "Intel GPU detected (via modalias) - installing drivers" pacman_install mesa pacman_install intel-media-driver # hardware video acceleration pacman_install vulkan-intel # Vulkan support fi - if echo "$gpu_info" | grep -qi "amd\|radeon"; then - display "task" "AMD GPU detected - installing drivers" + if $detected_amd; then + display "task" "AMD GPU detected (via modalias) - installing drivers" pacman_install mesa pacman_install xf86-video-amdgpu pacman_install vulkan-radeon pacman_install libva-mesa-driver # hardware video acceleration fi - if echo "$gpu_info" | grep -qi "nvidia"; then - display "task" "NVIDIA GPU detected - installing drivers" + if $detected_nvidia; then + display "task" "NVIDIA GPU detected (via modalias) - installing drivers" pacman_install nvidia-dkms # DKMS version for kernel flexibility pacman_install nvidia-utils pacman_install nvidia-settings @@ -473,8 +507,8 @@ install_gpu_drivers() { fi # Fallback for VMs or unknown hardware - if ! echo "$gpu_info" | grep -qiE "intel|amd|radeon|nvidia"; then - display "task" "No discrete GPU detected - installing generic drivers" + if ! $detected_intel && ! $detected_amd && ! $detected_nvidia; then + display "task" "No GPU detected via modalias - installing generic drivers" pacman_install mesa pacman_install xf86-video-vesa fi |
