[PATCH 06/10] radeontool, avivotool: remove unnecessary region autodetection magic

Jonathan Nieder jrnieder at gmail.com
Fri Feb 24 19:55:44 PST 2012


Trying to guess which region is which based on size is needlessly
error-prone and complicated.

Region 0 is always the frame buffer and region 2 is always mmio.
radeonreg already hard-codes the appropriate region numbers.  This
patch teaches radeontool and avivotool to do the same.

Suggested-by: Alex Deucher <alexdeucher at gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
---
 avivotool.c  |   14 +++-----------
 radeontool.c |   18 ++----------------
 2 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/avivotool.c b/avivotool.c
index 9c35fc79..bc827b37 100644
--- a/avivotool.c
+++ b/avivotool.c
@@ -1857,17 +1857,9 @@ static int map_radeon_mem(void)
         printf("cannot find Radeon device\n");
         return -1;
     }
-      
-    for (i = 0; i < 6; i++) {
-        if (device->regions[i].size == 64 * 1024)
-            ctrl_region = i;
-        else if (device->regions[i].size == 128 * 1024)
-            ctrl_region = i;
-        else if (device->regions[i].size == 256 * 1024)
-            ctrl_region = i;
-        else if (device->regions[i].size >= 128 * 1024 * 1024)
-            fb_region = i;
-    }
+
+    fb_region = 0;
+    ctrl_region = 2;
     avivo_device = device;
 
     if (pci_device_map_region(avivo_device, ctrl_region, 1) != 0) {
diff --git a/radeontool.c b/radeontool.c
index 9ed92c24..cb0d12d2 100644
--- a/radeontool.c
+++ b/radeontool.c
@@ -948,22 +948,8 @@ static void map_radeon_cntl_mem(void)
     if (!device)
         die("cannot find Radeon device");
 
-    for (i = 0; i < 6; i++) {
-        if (device->regions[i].size >= 16 * 1024 &&
-            device->regions[i].size <= 64 * 1024) {
-            if (ctrl_region != -1)
-                die("cannot distinguish ctrl region");
-            ctrl_region = i;
-        } else if (device->regions[i].size >= 64 * 1024 * 1024) {
-            if (fb_region != -1)
-                die("cannot distinguish fb region");
-            fb_region = i;
-        }
-    }
-    if (ctrl_region == -1)
-        die("cannot find ctrl region");
-    if (fb_region == -1)
-        die("cannot find fb region");
+    fb_region = 0;
+    ctrl_region = 2;
     avivo_device = device;
 
     if (pci_device_map_region(avivo_device, ctrl_region, 1) != 0)
-- 
1.7.9.2



More information about the xorg-driver-ati mailing list