radeon-gallium: Support new info ioctls in addition to classic getparams.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 11 May 2009 16:04:15 +0000 (09:04 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 11 May 2009 16:05:33 +0000 (09:05 -0700)
This makes non-hybrid kernels like newttm from drm-next-radeon work
while avoiding breakage with Fedora/Ubuntu/etc.

src/gallium/winsys/drm/radeon/core/radeon_r300.c
src/gallium/winsys/drm/radeon/core/radeon_r300.h

index be70ead68d01377059a26ef2528bd08b41f2b1bb..56b0d00842622821a286472f544ce8d68c2c5000 100644 (file)
@@ -152,44 +152,62 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys)
 /* Helper function to do the ioctls needed for setup and init. */
 static void do_ioctls(struct r300_winsys* winsys, int fd)
 {
-    struct drm_radeon_gem_info info = {0};
+    struct drm_radeon_gem_info gem_info = {0};
     drm_radeon_getparam_t gp = {0};
+    struct drm_radeon_info info = {0};
     int target = 0;
     int retval;
 
+    info.value = &target;
     gp.value = &target;
 
     /* First, get the number of pixel pipes */
-    gp.param = RADEON_PARAM_NUM_GB_PIPES;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
+    info.request = RADEON_INFO_NUM_GB_PIPES;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
     if (retval) {
-        fprintf(stderr, "%s: Failed to get GB pipe count, error number %d\n",
+        fprintf(stderr, "%s: New ioctl for GB pipe count failed "
+                "(error number %d), trying classic ioctl...\n",
                 __FUNCTION__, retval);
-        exit(1);
+        gp.param = RADEON_PARAM_NUM_GB_PIPES;
+        retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp,
+                sizeof(gp));
+        if (retval) {
+            fprintf(stderr, "%s: Failed to get GB pipe count, "
+                    "error number %d\n", __FUNCTION__, retval);
+            exit(1);
+        }
     }
     winsys->gb_pipes = target;
 
     /* Then, get PCI ID */
-    gp.param = RADEON_PARAM_DEVICE_ID;
-    retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
+    info.request = RADEON_INFO_DEVICE_ID;
+    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
     if (retval) {
-        fprintf(stderr, "%s: Failed to get PCI ID, error number %d\n",
+        fprintf(stderr, "%s: New ioctl for PCI ID failed "
+                "(error number %d), trying classic ioctl...\n",
                 __FUNCTION__, retval);
-        exit(1);
+        gp.param = RADEON_PARAM_DEVICE_ID;
+        retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp,
+                sizeof(gp));
+        if (retval) {
+            fprintf(stderr, "%s: Failed to get PCI ID, "
+                    "error number %d\n", __FUNCTION__, retval);
+            exit(1);
+        }
     }
     winsys->pci_id = target;
 
     /* Finally, retrieve MM info */
     retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO,
-            &info, sizeof(info));
+            &gem_info, sizeof(gem_info));
     if (retval) {
         fprintf(stderr, "%s: Failed to get MM info, error number %d\n",
                 __FUNCTION__, retval);
         exit(1);
     }
-    winsys->gart_size = info.gart_size;
+    winsys->gart_size = gem_info.gart_size;
     /* XXX */
-    winsys->vram_size = info.vram_visible;
+    winsys->vram_size = gem_info.vram_visible;
 }
 
 struct r300_winsys*
index 5c373cd0848594bbfda16133bbb0a33e8491a74d..98586746cd49999d29d71d5e58910f495981b5ba 100644 (file)
 
 #include "radeon_buffer.h"
 
+/* protect us from bonghits */
+#ifndef RADEON_INFO_NUM_GB_PIPES
+#define RADEON_INFO_NUM_GB_PIPES 0
+#endif
+#ifndef RADEON_INFO_DEVICE_ID
+#define RADEON_INFO_DEVICE_ID 0
+#endif
+#ifndef DRM_RADEON_INFO
+#define DRM_RADEON_INFO 0x1
+#endif
+
 struct r300_winsys*
 radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys);