From 614b30d3bbd438870283454a64da7caf81e29275 Mon Sep 17 00:00:00 2001 From: Vasiliy Stelmachenok Date: Fri, 7 Jun 2024 20:48:12 +0300 Subject: [PATCH 1/4] profiles/graphic_drivers: Separate nvidia profiles for PRIME and desktop cards --- profiles/pci/graphic_drivers/profiles.toml | 75 +++++++++++++++++----- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/profiles/pci/graphic_drivers/profiles.toml b/profiles/pci/graphic_drivers/profiles.toml index 07d2b8f..f33b79e 100644 --- a/profiles/pci/graphic_drivers/profiles.toml +++ b/profiles/pci/graphic_drivers/profiles.toml @@ -1,20 +1,8 @@ -# VENDOR AMD=1002 INTEL=8086 NVIDIA=10de -# CLASSID 03=Display controller -# 00=VGA compatible controller 02=3D controller 80=Display controller - -# NVIDIA cards -#CLASSIDS="0300 0302" -#VENDORIDS="10de" -#DEVICEIDS=">/var/lib/mhwd/ids/pci/nvidia.ids" - -# Intel Or Amd cards -#CLASSIDS="0300" -#VENDORIDS="8086 1002" -#DEVICEIDS="*" -#CONKMOD="nvidia-dkms" - [nvidia-dkms.40xxcards] desc = 'Closed source NVIDIA drivers(40xx series) for Linux (Latest)' +nonfree = true +class_ids = "0300" +vendor_ids = "10de" priority = 9 packages = 'nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader' conditional_packages = """ @@ -50,7 +38,7 @@ device_name_pattern = '(AD)\w+' [nvidia-dkms] desc = 'Closed source NVIDIA drivers for Linux (Latest)' nonfree = true -class_ids = "0300 0380 0302" +class_ids = "0300" vendor_ids = "10de" priority = 8 packages = 'nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader' @@ -84,12 +72,65 @@ post_remove = """ """ device_ids = '*' +[nvidia-dkms-prime] +desc = 'Closed source NVIDIA drivers for Linux (Latest)' +nonfree = true +class_ids = "0302" +vendor_ids = "10de" +priority = 10 +packages = 'nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader nvidia-prime switcheroo-control' +conditional_packages = """ + kernels="$(pacman -Qqs "^linux-cachyos")" + modules="" + + for kernel in $kernels; do + case "$kernel" in + *-headers|*-zfs);; + *-nvidia) modules+=" ${kernel}";; + *) modules+=" ${kernel}-nvidia";; + esac + done + + # Fallback if there are no kernels with pre-built modules + [ -z "$modules" ] && modules="nvidia-dkms" + + echo "$modules" +""" +post_install = """ + cat </etc/mkinitcpio.conf.d/10-chwd.conf +# This file is automatically generated by chwd. PLEASE DO NOT EDIT IT. +MODULES+=(nvidia nvidia_modeset nvidia_uvm nvidia_drm) +EOF + mkinitcpio -P + systemctl enable switcheroo-control +""" +post_remove = """ + rm -f /etc/mkinitcpio.conf.d/10-chwd.conf + mkinitcpio -P +""" +device_ids = '*' + [nvidia-dkms.470xx] desc = 'Closed source NVIDIA drivers for Linux (470xx branch, only for Kepler GPUs)' -priority = 9 +class_ids = "0300" +vendor_ids = "10de" +priority = 8 +nonfree = true packages = 'nvidia-470xx-dkms nvidia-470xx-utils nvidia-470xx-settings opencl-nvidia-470xx vulkan-icd-loader lib32-nvidia-470xx-utils lib32-opencl-nvidia-470xx lib32-vulkan-icd-loader libva-nvidia-driver' device_name_pattern = '(GK)\w+' +[nvidia-dkms-prime.470xx] +desc = 'Closed source NVIDIA drivers for Linux (470xx branch, only for Kepler GPUs)' +class_ids = "0302" +vendor_ids = "10de" +nonfree = true +priority = 9 +packages = 'nvidia-470xx-dkms nvidia-470xx-utils nvidia-470xx-settings opencl-nvidia-470xx vulkan-icd-loader lib32-nvidia-470xx-utils lib32-opencl-nvidia-470xx lib32-vulkan-icd-loader libva-nvidia-driver switcheroo-control nvidia-prime' +device_name_pattern = '(GK)\w+' +post_install = """ + systemctl enable switcheroo-control +""" + [nvidia-dkms.390xx] desc = 'Closed source NVIDIA drivers for Linux (390xx branch, only for Fermi GPUs)' priority = 10 From 86cecc3bad129699f6f56b3226f1d8ffe9131405 Mon Sep 17 00:00:00 2001 From: Vasiliy Stelmachenok Date: Fri, 7 Jun 2024 20:51:08 +0300 Subject: [PATCH 2/4] profiles/graphic_drivers: Return class id for display controllers --- profiles/pci/graphic_drivers/profiles.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/profiles/pci/graphic_drivers/profiles.toml b/profiles/pci/graphic_drivers/profiles.toml index f33b79e..288f1b5 100644 --- a/profiles/pci/graphic_drivers/profiles.toml +++ b/profiles/pci/graphic_drivers/profiles.toml @@ -1,7 +1,7 @@ [nvidia-dkms.40xxcards] desc = 'Closed source NVIDIA drivers(40xx series) for Linux (Latest)' nonfree = true -class_ids = "0300" +class_ids = "0300 0380" vendor_ids = "10de" priority = 9 packages = 'nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader' @@ -38,7 +38,7 @@ device_name_pattern = '(AD)\w+' [nvidia-dkms] desc = 'Closed source NVIDIA drivers for Linux (Latest)' nonfree = true -class_ids = "0300" +class_ids = "0300 0380" vendor_ids = "10de" priority = 8 packages = 'nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader' @@ -112,7 +112,7 @@ device_ids = '*' [nvidia-dkms.470xx] desc = 'Closed source NVIDIA drivers for Linux (470xx branch, only for Kepler GPUs)' -class_ids = "0300" +class_ids = "0300 0380" vendor_ids = "10de" priority = 8 nonfree = true From 13f8168351eb817db65acf86f65d56d387573497 Mon Sep 17 00:00:00 2001 From: Vasiliy Stelmachenok Date: Fri, 7 Jun 2024 21:18:17 +0300 Subject: [PATCH 3/4] profiles/graphic_drivers: Remove inherited values --- profiles/pci/graphic_drivers/profiles.toml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/profiles/pci/graphic_drivers/profiles.toml b/profiles/pci/graphic_drivers/profiles.toml index 288f1b5..cfa05f6 100644 --- a/profiles/pci/graphic_drivers/profiles.toml +++ b/profiles/pci/graphic_drivers/profiles.toml @@ -1,8 +1,5 @@ [nvidia-dkms.40xxcards] desc = 'Closed source NVIDIA drivers(40xx series) for Linux (Latest)' -nonfree = true -class_ids = "0300 0380" -vendor_ids = "10de" priority = 9 packages = 'nvidia-utils egl-wayland nvidia-settings opencl-nvidia lib32-opencl-nvidia lib32-nvidia-utils libva-nvidia-driver vulkan-icd-loader lib32-vulkan-icd-loader' conditional_packages = """ @@ -112,18 +109,12 @@ device_ids = '*' [nvidia-dkms.470xx] desc = 'Closed source NVIDIA drivers for Linux (470xx branch, only for Kepler GPUs)' -class_ids = "0300 0380" -vendor_ids = "10de" priority = 8 -nonfree = true packages = 'nvidia-470xx-dkms nvidia-470xx-utils nvidia-470xx-settings opencl-nvidia-470xx vulkan-icd-loader lib32-nvidia-470xx-utils lib32-opencl-nvidia-470xx lib32-vulkan-icd-loader libva-nvidia-driver' device_name_pattern = '(GK)\w+' [nvidia-dkms-prime.470xx] desc = 'Closed source NVIDIA drivers for Linux (470xx branch, only for Kepler GPUs)' -class_ids = "0302" -vendor_ids = "10de" -nonfree = true priority = 9 packages = 'nvidia-470xx-dkms nvidia-470xx-utils nvidia-470xx-settings opencl-nvidia-470xx vulkan-icd-loader lib32-nvidia-470xx-utils lib32-opencl-nvidia-470xx lib32-vulkan-icd-loader libva-nvidia-driver switcheroo-control nvidia-prime' device_name_pattern = '(GK)\w+' From 20adfb317d533a84ccee0e4a1d774b7d5d6034a4 Mon Sep 17 00:00:00 2001 From: Vasiliy Stelmachenok Date: Fri, 7 Jun 2024 22:52:03 +0300 Subject: [PATCH 4/4] profiles/graphic_drivers: Update comments of the main values for profiles --- profiles/pci/graphic_drivers/profiles.toml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/profiles/pci/graphic_drivers/profiles.toml b/profiles/pci/graphic_drivers/profiles.toml index cfa05f6..d3de27d 100644 --- a/profiles/pci/graphic_drivers/profiles.toml +++ b/profiles/pci/graphic_drivers/profiles.toml @@ -1,3 +1,21 @@ +# chwd has a sequential search for the desired profile. First it goes through +# all class_ids that indicate a device type, like GPU or network adapter. Then +# the profile specifies which manufacturer's driver we need via vendor_id, +# after which chwd select specific device in device_id or device_pattern, which +# is how much wider and includes devices of the same generation. For example: +# +# Searched for 3D controllers +# class_ids = "0302" +# +# Filters only NVIDIA GPUs +# vendor_ids = "10de" +# +# A certain device or set of ids: +# device_ids = "25a2" +# +# Or set of devices depending on the generation: +# device_name_pattern = '(AD)\w+' + [nvidia-dkms.40xxcards] desc = 'Closed source NVIDIA drivers(40xx series) for Linux (Latest)' priority = 9