From 9ed33791f018bfeb37d907941fe014109b75a687 Mon Sep 17 00:00:00 2001 From: stsdc <6031763+stsdc@users.noreply.github.com> Date: Mon, 24 Nov 2025 19:56:30 +0100 Subject: [PATCH] Add driver_name property to GPU classes with a new get_string_property in PCI vapi --- src/Resources/GPU/GPUAmd.vala | 3 +++ src/Resources/GPU/GPUIntel.vala | 4 ++++ src/Resources/GPU/GPUNvidia.vala | 3 +++ src/Resources/GPU/IGPU.vala | 2 ++ src/Resources/Resources.vala | 2 +- vapi/pci.vapi | 3 +++ 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Resources/GPU/GPUAmd.vala b/src/Resources/GPU/GPUAmd.vala index 0a458d066..32db2cbc3 100644 --- a/src/Resources/GPU/GPUAmd.vala +++ b/src/Resources/GPU/GPUAmd.vala @@ -9,6 +9,8 @@ public class Monitor.GPUAmd : IGPU, Object { public string hwmon_module_name { get; set; } + public string driver_name { get; set; } + public string name { get; set; } public int percentage { get; protected set; } @@ -28,6 +30,7 @@ public class Monitor.GPUAmd : IGPU, Object { name = "AMD® " + name; sysfs_path = pci_parse_sysfs_path (pci_access, pci_device); + driver_name = pci_device.get_string_property (Pci.FILL_DRIVER); } private void update_temperature () { diff --git a/src/Resources/GPU/GPUIntel.vala b/src/Resources/GPU/GPUIntel.vala index dd3bd0cbe..5ee3dd2dd 100644 --- a/src/Resources/GPU/GPUIntel.vala +++ b/src/Resources/GPU/GPUIntel.vala @@ -9,6 +9,8 @@ public class Monitor.GPUIntel : IGPU, Object { public string hwmon_module_name { get; set; } + public string driver_name { get; set; } + public string name { get; set; } public int percentage { get; protected set; } @@ -28,6 +30,8 @@ public class Monitor.GPUIntel : IGPU, Object { name = "Intel® " + name; sysfs_path = pci_parse_sysfs_path (pci_access, pci_device); + driver_name = pci_device.get_string_property (Pci.FILL_DRIVER); + } private void update_temperature () { diff --git a/src/Resources/GPU/GPUNvidia.vala b/src/Resources/GPU/GPUNvidia.vala index 0f1042413..6515afc71 100644 --- a/src/Resources/GPU/GPUNvidia.vala +++ b/src/Resources/GPU/GPUNvidia.vala @@ -9,6 +9,8 @@ public class Monitor.GPUNvidia : IGPU, Object { public string hwmon_module_name { get; set; } + public string driver_name { get; set; } + public string name { get; set; } public int percentage { get; protected set; } @@ -54,6 +56,7 @@ public class Monitor.GPUNvidia : IGPU, Object { name = "nVidia® " + name; sysfs_path = pci_parse_sysfs_path (pci_access, pci_device); + driver_name = pci_device.get_string_property (Pci.FILL_DRIVER); } construct { diff --git a/src/Resources/GPU/IGPU.vala b/src/Resources/GPU/IGPU.vala index 2b9a2c32b..3e5558cf9 100644 --- a/src/Resources/GPU/IGPU.vala +++ b/src/Resources/GPU/IGPU.vala @@ -9,6 +9,8 @@ public interface Monitor.IGPU : Object { public abstract string hwmon_module_name { get; protected set; } + public abstract string driver_name { get; protected set; } + public abstract string name { get; protected set; } public abstract int percentage { get; protected set; } diff --git a/src/Resources/Resources.vala b/src/Resources/Resources.vala index 1925a944f..4cf3f3516 100644 --- a/src/Resources/Resources.vala +++ b/src/Resources/Resources.vala @@ -54,7 +54,7 @@ public class Monitor.Resources : Object { char namebuf[1024]; for (unowned Pci.Dev pci_device = pci_access.devices; pci_device != null; pci_device = pci_device.next) { - pci_device.fill_info (Pci.FILL_IDENT | Pci.FILL_BASES | Pci.FILL_CLASS_EXT | Pci.FILL_LABEL | Pci.FILL_CLASS); + pci_device.fill_info (Pci.FILL_IDENT | Pci.FILL_BASES | Pci.FILL_CLASS_EXT | Pci.FILL_LABEL | Pci.FILL_CLASS | Pci.FILL_DRIVER); string name = pci_access.lookup_name (namebuf, Pci.LookupMode.DEVICE, pci_device.vendor_id, pci_device.device_id); // Looking for a specific PCI device class diff --git a/vapi/pci.vapi b/vapi/pci.vapi index 8953ba21b..50cac6d90 100644 --- a/vapi/pci.vapi +++ b/vapi/pci.vapi @@ -165,6 +165,9 @@ namespace Pci { [CCode (cname = "pci_fill_info")] public int fill_info (int flags); + [CCode (cname = "pci_get_string_property")] + public unowned string ? get_string_property (int flag); + private Dev (); }