Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > 26764e702e441b473525f6a16ac25557 > files > 40

hal-0.5.8.1-59.el5.src.rpm

--- hald/linux/osspec.c.orig	2007-07-03 19:09:11.000000000 -0400
+++ hald/linux/osspec.c	2007-07-03 19:13:11.000000000 -0400
@@ -561,6 +561,38 @@
 	detect_openfirmware_formfactor(root);
 }
 
+static void
+get_primary_videocard (HalDevice *d)
+{
+        GDir *dir;
+        const char *name;
+
+        dir = g_dir_open ("/sys/bus/pci/devices", 0, NULL);
+        if (dir == NULL)
+                goto out;
+        while ((name = g_dir_read_name (dir)) != NULL) {
+                int class;
+                char *path;
+                path = g_strdup_printf ("/sys/bus/pci/devices/%s", name);
+                if (hal_util_get_int_from_file (path, "class", &class, 0) && (class&0xffff00) == 0x030000 ) {
+                        int vendor, device;
+                        if (hal_util_get_int_from_file (path, "vendor", &vendor, 0) &&
+                            hal_util_get_int_from_file (path, "device", &device, 0)) {
+                                HAL_INFO (("got %x:%x as primary videocard", vendor, device));
+                                hal_device_property_set_int (d, "system.hardware.primary_video.vendor", vendor);
+                                hal_device_property_set_int (d, "system.hardware.primary_video.product", device);
+                                g_free (path);
+                                g_dir_close (dir);
+                                goto out;
+			}
+		}
+                g_free (path);
+	}
+        g_dir_close (dir);
+out:
+        ;
+}
+
 
 void 
 osspec_probe (void)
@@ -615,6 +647,9 @@
 	 */
 	set_suspend_hibernate_keys (root);
 
+        /* set the vendor/product of primary video card */
+        get_primary_videocard (root);
+
 	if (should_decode_dmi) {
 		hald_runner_run (root, "hald-probe-smbios", NULL, HAL_HELPER_TIMEOUT,
         	                 computer_probing_pcbios_helper_done, NULL, NULL);