~ubuntu-branches/ubuntu/lucid/xserver-xorg-video-savage/lucid

« back to all changes in this revision

Viewing changes to debian/patches/02_temporary_revert_pciaccess.diff

  • Committer: Bazaar Package Importer
  • Author(s): Brice Goglin
  • Date: 2008-09-05 19:37:51 UTC
  • Revision ID: james.westby@ubuntu.com-20080905193751-p16ylwnxakd1jnes
Tags: 1:2.2.1-2
Reenable 02_temporary_revert_pciaccess.diff and append all recent
pci-rework changes, closes: #483989.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--- b/src/savage_driver.c
 
1
diff --git a/configure.ac b/configure.ac
 
2
index b6d64e4..d88819c 100644
 
3
--- a/configure.ac
 
4
+++ b/configure.ac
 
5
@@ -95,18 +95,6 @@ if test "$DRI" = yes; then
 
6
         AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
 
7
 fi
 
8
 
 
9
-save_CFLAGS="$CFLAGS"
 
10
-CFLAGS="$XORG_CFLAGS"
 
11
-AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
 
12
-              [XSERVER_LIBPCIACCESS=yes], [XSERVER_LIBPCIACCESS=no],
 
13
-              [#include "xorg-server.h"])
 
14
-CFLAGS="$save_CFLAGS"
 
15
-
 
16
-if test "x$XSERVER_LIBPCIACCESS" = xyes; then
 
17
-    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10])
 
18
-fi
 
19
-AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
 
20
-
 
21
 AC_SUBST([DRI_CFLAGS])
 
22
 AC_SUBST([XORG_CFLAGS])
 
23
 AC_SUBST([moduledir])
 
24
diff --git a/src/savage_dga.c b/src/savage_dga.c
 
25
index eb1c5d2..42f4262 100644
 
26
--- a/src/savage_dga.c
 
27
+++ b/src/savage_dga.c
 
28
@@ -390,7 +390,7 @@ Savage_OpenFramebuffer(
 
29
     SavagePtr psav = SAVPTR(pScrn);
 
30
 
 
31
     *name = NULL;       /* no special device */
 
32
-    *mem = (unsigned char*)psav->FbRegion.base;
 
33
+    *mem = (unsigned char*)psav->FrameBufferBase;
 
34
     *size = psav->videoRambytes;
 
35
     *offset = 0;
 
36
     *flags = DGA_NEED_ROOT;
 
37
diff --git a/src/savage_dri.c b/src/savage_dri.c
 
38
index 0d40222..2879f2a 100644
 
39
--- a/src/savage_dri.c
 
40
+++ b/src/savage_dri.c
 
41
@@ -467,8 +467,8 @@ static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen)
 
42
    xf86DrvMsg( pScreen->myNum, X_INFO,
 
43
               "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
 
44
               mode, vendor, device,
 
45
-              VENDOR_ID(psav->PciInfo),
 
46
-              DEVICE_ID(psav->PciInfo));
 
47
+              psav->PciInfo->vendor,
 
48
+              psav->PciInfo->chipType );
 
49
 
 
50
    if ( drmAgpEnable( psav->drmFD, mode ) < 0 ) {
 
51
       xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" );
 
52
@@ -624,7 +624,7 @@ static Bool SAVAGEDRIMapInit( ScreenPtr pScreen )
 
53
    pSAVAGEDRIServer->registers.size = SAVAGEIOMAPSIZE;
 
54
 
 
55
    if ( drmAddMap( psav->drmFD,
 
56
-                  (drm_handle_t)psav->MmioRegion.base,
 
57
+                  (drm_handle_t)psav->MmioBase,
 
58
                   pSAVAGEDRIServer->registers.size,
 
59
                   DRM_REGISTERS,0,
 
60
                   &pSAVAGEDRIServer->registers.handle ) < 0 ) {
 
61
@@ -636,7 +636,7 @@ static Bool SAVAGEDRIMapInit( ScreenPtr pScreen )
 
62
    pSAVAGEDRIServer->aperture.size = 5 * 0x01000000;
 
63
    
 
64
    if ( drmAddMap( psav->drmFD,
 
65
-                  (drm_handle_t)(psav->ApertureRegion.base),
 
66
+                  (drm_handle_t)(psav->ApertureBase),
 
67
                   pSAVAGEDRIServer->aperture.size,
 
68
                   DRM_FRAME_BUFFER,0,
 
69
                   &pSAVAGEDRIServer->aperture.handle ) < 0 ) {
 
70
@@ -882,18 +882,14 @@ Bool SAVAGEDRIScreenInit( ScreenPtr pScreen )
 
71
       sprintf(pDRIInfo->busIdString,
 
72
               "PCI:%d:%d:%d",
 
73
               psav->PciInfo->bus,
 
74
-#ifdef XSERVER_LIBPCIACCESS
 
75
-              psav->PciInfo->dev,
 
76
-#else
 
77
               psav->PciInfo->device,
 
78
-#endif
 
79
               psav->PciInfo->func);
 
80
    }
 
81
    pDRIInfo->ddxDriverMajorVersion = SAVAGE_VERSION_MAJOR;
 
82
    pDRIInfo->ddxDriverMinorVersion = SAVAGE_VERSION_MINOR;
 
83
    pDRIInfo->ddxDriverPatchVersion = SAVAGE_PATCHLEVEL;
 
84
 
 
85
-   pDRIInfo->frameBufferPhysicalAddress = (pointer) psav->FbRegion.base;
 
86
+   pDRIInfo->frameBufferPhysicalAddress = (pointer) psav->FrameBufferBase;
 
87
    pDRIInfo->frameBufferSize = psav->videoRambytes;
 
88
    pDRIInfo->frameBufferStride = pScrn->displayWidth*(pScrn->bitsPerPixel/8);
 
89
    pDRIInfo->ddxDrawableTableEntry = SAVAGE_MAX_DRAWABLES;
 
90
diff --git a/src/savage_driver.c b/src/savage_driver.c
 
91
index 919bd1a..725d1fa 100644
 
92
--- a/src/savage_driver.c
2
93
+++ b/src/savage_driver.c
3
94
@@ -40,7 +40,6 @@
4
95
 #endif
8
99
 
9
100
 #include "xf86RAC.h"
10
101
 #include "shadowfb.h"
11
 
@@ -73,13 +72,7 @@
 
102
@@ -73,13 +72,7 @@ static void SavageDisableMMIO(ScrnInfoPtr pScrn);
12
103
 
13
104
 static const OptionInfoRec * SavageAvailableOptions(int chipid, int busid);
14
105
 static void SavageIdentify(int flags);
22
113
 static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags);
23
114
 
24
115
 static Bool SavageEnterVT(int scrnIndex, int flags);
25
 
@@ -139,38 +132,18 @@
 
116
@@ -139,38 +132,18 @@ extern ScrnInfoPtr gpScrn;
26
117
 
27
118
 int gSavageEntityIndex = -1;
28
119
 
29
 
+_X_EXPORT DriverRec SAVAGE =
30
 
+{
31
 
+    SAVAGE_VERSION,
32
 
+    SAVAGE_DRIVER_NAME,
33
 
+    SavageIdentify,
34
 
+    SavageProbe,
35
 
+    SavageAvailableOptions,
36
 
+    NULL,
37
 
+    0,
38
 
+    NULL
39
 
+};
40
120
-#ifdef XSERVER_LIBPCIACCESS
41
121
-#define SAVAGE_DEVICE_MATCH(d, i) \
42
122
-    { 0x5333, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) }
65
145
-    SAVAGE_DEVICE_MATCH(PCI_CHIP_SUPSAV_IXCDDR,   S3_SUPERSAVAGE),
66
146
-    SAVAGE_DEVICE_MATCH(PCI_CHIP_PROSAVAGE_DDR,   S3_PROSAVAGEDDR),
67
147
-    SAVAGE_DEVICE_MATCH(PCI_CHIP_PROSAVAGE_DDRK,  S3_PROSAVAGEDDR),
68
 
 
 
148
-
69
149
-    { 0, 0, 0 },
70
 
-};
 
150
+_X_EXPORT DriverRec SAVAGE =
 
151
+{
 
152
+    SAVAGE_VERSION,
 
153
+    SAVAGE_DRIVER_NAME,
 
154
+    SavageIdentify,
 
155
+    SavageProbe,
 
156
+    SavageAvailableOptions,
 
157
+    NULL,
 
158
+    0,
 
159
+    NULL
 
160
 };
71
161
-#endif
 
162
+
72
163
 
73
164
 /* Supported chipsets */
74
165
 
75
 
@@ -213,7 +186,6 @@
 
166
@@ -213,7 +186,6 @@ static SymTabRec SavageChipsets[] = {
76
167
     { -1,              NULL }
77
168
 };
78
169
 
80
171
 /* This table maps a PCI device ID to a chipset family identifier. */
81
172
 
82
173
 static PciChipsets SavagePciChipsets[] = {
83
 
@@ -242,7 +214,6 @@
 
174
@@ -242,7 +214,6 @@ static PciChipsets SavagePciChipsets[] = {
84
175
     { S3_SUPERSAVAGE,  PCI_CHIP_SUPSAV_IXCDDR, RES_SHARED_VGA },
85
176
     { -1,              -1,                     RES_UNDEFINED }
86
177
 };
88
179
 
89
180
 typedef enum {
90
181
      OPTION_PCI_BURST
91
 
@@ -314,28 +285,6 @@
 
182
@@ -316,28 +287,6 @@ static const OptionInfoRec SavageOptions[] =
92
183
     { -1,              NULL,           OPTV_NONE,    {0}, FALSE }
93
184
 };
94
185
 
117
208
 
118
209
 static const char *vgaHWSymbols[] = {
119
210
     "vgaHWBlankScreen",
120
 
@@ -839,82 +788,6 @@
 
211
@@ -841,82 +790,6 @@ static void SavageIdentify(int flags)
121
212
 }
122
213
 
123
214
 
200
291
 static Bool SavageProbe(DriverPtr drv, int flags)
201
292
 {
202
293
     int i;
203
 
@@ -953,8 +826,6 @@
 
294
@@ -955,8 +828,6 @@ static Bool SavageProbe(DriverPtr drv, int flags)
204
295
                                                    NULL, NULL, NULL, NULL);
205
296
 
206
297
             if (pScrn != NULL) {
209
300
                pScrn->driverVersion = SAVAGE_VERSION;
210
301
                pScrn->driverName = SAVAGE_DRIVER_NAME;
211
302
                pScrn->name = "SAVAGE";
212
 
@@ -968,23 +839,6 @@
 
303
@@ -970,23 +841,6 @@ static Bool SavageProbe(DriverPtr drv, int flags)
213
304
                pScrn->FreeScreen = NULL;
214
305
                pScrn->ValidMode = SavageValidMode;
215
306
                foundScreen = TRUE;
233
324
            }
234
325
 
235
326
             pEnt = xf86GetEntityInfo(usedChips[i]);
236
 
@@ -1038,7 +892,6 @@
 
327
@@ -1040,7 +894,6 @@ static int LookupChipID( PciChipsets* pset, int ChipID )
237
328
 
238
329
     return -1;
239
330
 }
241
332
 
242
333
 static void SavageDoDDC(ScrnInfoPtr pScrn)
243
334
 {
244
 
@@ -1553,6 +1406,7 @@
 
335
@@ -1581,6 +1434,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
245
336
        psav->pVbe = VBEInit(NULL, pEnt->index);
246
337
     }
247
338
 
249
340
     xf86RegisterResources(pEnt->index, NULL, ResNone);
250
341
     xf86SetOperatingState(resVgaIo, pEnt->index, ResUnusedOpr);
251
342
     xf86SetOperatingState(resVgaMem, pEnt->index, ResDisableOpr);
252
 
@@ -1561,9 +1415,11 @@
 
343
@@ -1589,9 +1443,11 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
253
344
     if (pEnt->device->chipset && *pEnt->device->chipset) {
254
345
        pScrn->chipset = pEnt->device->chipset;
255
346
        psav->ChipId = pEnt->device->chipID;
261
352
        pScrn->chipset = (char *)xf86TokenToString(SavageChipsets,
262
353
                                                   psav->Chipset);
263
354
        from = X_CONFIG;
264
 
@@ -1571,7 +1427,8 @@
 
355
@@ -1599,7 +1455,8 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
265
356
                   pEnt->device->chipID);
266
357
     } else {
267
358
        from = X_PROBED;
 
359
-       psav->ChipId = DEVICE_ID(psav->PciInfo);
268
360
+       psav->ChipId = psav->PciInfo->chipType;
269
361
+       psav->Chipset = LookupChipID(SavagePciChipsets, psav->ChipId);
270
 
-       psav->ChipId = DEVICE_ID(psav->PciInfo);
271
362
        pScrn->chipset = (char *)xf86TokenToString(SavageChipsets,
272
363
                                                   psav->Chipset);
273
364
     }
274
 
@@ -1584,7 +1441,7 @@
 
365
@@ -1612,7 +1469,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
275
366
        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
276
367
                   psav->ChipRev);
277
368
     } else
 
369
-       psav->ChipRev = CHIP_REVISION(psav->PciInfo);
278
370
+       psav->ChipRev = psav->PciInfo->chipRev;
279
 
-       psav->ChipRev = CHIP_REVISION(psav->PciInfo);
280
371
 
281
372
     xf86DrvMsg(pScrn->scrnIndex, from, "Engine: \"%s\"\n", pScrn->chipset);
282
373
 
283
 
@@ -1593,22 +1450,13 @@
 
374
@@ -1621,22 +1478,13 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
284
375
 
285
376
     xfree(pEnt);
286
377
 
303
394
                                /* AGP/PCI (FK: copied from radeon_driver.c) */
304
395
     /* Proper autodetection of an AGP capable device requires examining
305
396
      * PCI config registers to determine if the device implements extended
306
 
@@ -1667,7 +1515,6 @@
 
397
@@ -1695,7 +1543,6 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
307
398
            cap_ptr = (cap_id >> 8) & SAVAGE_CAP_PTR_MASK;
308
399
        }
309
400
     }
311
402
 
312
403
     xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "%s card detected\n",
313
404
               (psav->IsPCI) ? "PCI" : "AGP");
314
 
@@ -3061,132 +2908,97 @@
 
405
@@ -3089,136 +2936,97 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr,
315
406
 static Bool SavageMapMem(ScrnInfoPtr pScrn)
316
407
 {
317
408
     SavagePtr psav = SAVPTR(pScrn);
 
409
-    int err;
318
410
+    int mode;
319
411
+    unsigned i;
320
 
-    int err;
321
412
 
322
413
     TRACE(("SavageMapMem()\n"));
323
414
 
324
415
     if( S3_SAVAGE3D_SERIES(psav->Chipset) ) {
 
416
-#ifdef XSERVER_LIBPCIACCESS
 
417
-        psav->MmioRegion.base = SAVAGE_NEWMMIO_REGBASE_S3
 
418
-            + psav->PciInfo->regions[0].base_addr;
 
419
-        psav->FbRegion.base = psav->PciInfo->regions[0].base_addr;
 
420
-#else
 
421
-        psav->MmioRegion.base = SAVAGE_NEWMMIO_REGBASE_S3
 
422
-            + psav->PciInfo->memBase[0];
 
423
-        psav->FbRegion.base = psav->PciInfo->memBase[0];
 
424
-#endif
325
425
+       psav->MmioRegion.bar = 0;
326
426
+       psav->MmioRegion.offset = SAVAGE_NEWMMIO_REGBASE_S3;
327
427
+
329
429
+       psav->FbRegion.offset = 0;
330
430
+
331
431
+       psav->last_bar = 0;
332
 
-#ifdef XSERVER_LIBPCIACCESS
333
 
-        psav->MmioRegion.base = SAVAGE_NEWMMIO_REGBASE_S3
334
 
-            + psav->PciInfo->regions[0].base_addr;
335
 
-        psav->FbRegion.base = psav->PciInfo->regions[0].base_addr;
336
 
-#else
337
 
-        psav->MmioRegion.base = SAVAGE_NEWMMIO_REGBASE_S3
338
 
-            + psav->PciInfo->memBase[0];
339
 
-        psav->FbRegion.base = psav->PciInfo->memBase[0];
340
 
-#endif
341
432
     } else {
342
 
+       psav->MmioRegion.bar = 0;
343
 
+       psav->MmioRegion.offset = SAVAGE_NEWMMIO_REGBASE_S4;
344
 
+
345
 
+       psav->FbRegion.bar = 1;
346
 
+       psav->FbRegion.offset = 0;
347
 
+
348
 
+       psav->last_bar = 1;
349
433
-#ifdef XSERVER_LIBPCIACCESS
350
434
-        psav->MmioRegion.base = SAVAGE_NEWMMIO_REGBASE_S4
351
435
-            + psav->PciInfo->regions[0].base_addr;
355
439
-            + psav->PciInfo->memBase[0];
356
440
-        psav->FbRegion.base = psav->PciInfo->memBase[1];
357
441
-#endif
358
 
     }
 
442
-    }
 
443
+       psav->MmioRegion.bar = 0;
 
444
+       psav->MmioRegion.offset = SAVAGE_NEWMMIO_REGBASE_S4;
359
445
 
360
446
-    psav->MmioRegion.size = SAVAGE_NEWMMIO_REGSIZE;
361
447
-    psav->FbRegion.size = psav->videoRambytes;
362
 
-
 
448
+       psav->FbRegion.bar = 1;
 
449
+       psav->FbRegion.offset = 0;
 
450
+
 
451
+       psav->last_bar = 1;
 
452
+    }
 
453
 
363
454
     /* On Paramount and Savage 2000, aperture 0 is PCI base 2.  On other
364
455
      * chipsets it's in the same BAR as the framebuffer.
365
456
      */
 
457
-
 
458
-    psav->ApertureRegion.size = (psav->IsPrimary || psav->IsSecondary)
 
459
-        ? (0x01000000 * 2) : (0x01000000 * 5);
 
460
-
366
461
     if ((psav->Chipset == S3_SUPERSAVAGE) 
 
462
-        || (psav->Chipset == S3_SAVAGE2000)) {
 
463
-#ifdef XSERVER_LIBPCIACCESS
 
464
-        psav->ApertureRegion.base = psav->PciInfo->regions[2].base_addr;
 
465
-        if (psav->ApertureRegion.size > psav->PciInfo->regions[2].size)
 
466
-            psav->ApertureRegion.size = psav->PciInfo->regions[2].size;
 
467
-#else
 
468
-        psav->ApertureRegion.base = psav->PciInfo->memBase[2];
 
469
-#endif
367
470
+       || (psav->Chipset == S3_SAVAGE2000)) {
368
471
+       psav->ApertureRegion.bar = 2;
369
472
+       psav->ApertureRegion.offset = 0;
370
473
+
371
474
+       psav->last_bar = 2;
372
 
-        || (psav->Chipset == S3_SAVAGE2000)) {
373
 
-#ifdef XSERVER_LIBPCIACCESS
374
 
-        psav->ApertureRegion.base = psav->PciInfo->regions[2].base_addr;
375
 
-#else
376
 
-        psav->ApertureRegion.base = psav->PciInfo->memBase[2];
377
 
-#endif
378
475
     } else {
 
476
-        psav->ApertureRegion.base = psav->FbRegion.base + 0x02000000;
379
477
+       psav->ApertureRegion.bar = psav->FbRegion.bar;
380
478
+       psav->ApertureRegion.offset = 0x02000000;
381
 
-        psav->ApertureRegion.base = psav->FbRegion.base + 0x02000000;
382
479
     }
383
480
 
384
 
-    psav->ApertureRegion.size = (psav->IsPrimary || psav->IsSecondary)
385
 
-        ? (0x01000000 * 2) : (0x01000000 * 5);
386
481
 
387
482
+    psav->MmioBase = psav->PciInfo->memBase[ psav->MmioRegion.bar ]
388
483
+      + psav->MmioRegion.offset;
389
 
+
390
 
+    psav->FrameBufferBase = psav->PciInfo->memBase[ psav->FbRegion.bar ]
391
 
+      + psav->FbRegion.offset;
392
484
 
393
 
+    psav->ApertureBase = psav->PciInfo->memBase[ psav->FbRegion.bar ]
394
 
+      + psav->ApertureRegion.offset;
395
 
+
396
 
+
397
 
+    /* FIXME: This seems fine even on Savage3D where the same BAR contains the
398
 
+     * FIXME: MMIO space and the framebuffer.  Write-combining gets fixed up
399
 
+     * FIXME: later.  Someone should investigate this, though.  And kick S3
400
 
+     * FIXME: for doing something so silly.
401
 
+     */
402
 
+    mode = VIDMEM_MMIO;
403
 
+    for (i = 0; i <= psav->last_bar; i++) {
404
 
+       psav->bar_mappings[i] = xf86MapPciMem(pScrn->scrnIndex, mode,
405
 
+                                             psav->PciTag,
406
 
+                                             psav->PciInfo->memBase[i],
407
 
+                                             (1U << psav->PciInfo->size[i]));
408
 
+       if (!psav->bar_mappings[i]) {
409
 
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
410
 
+                      "Internal error: cound not map PCI region %u, last BAR = %u\n",
411
 
+                      i, psav->last_bar);
412
 
+           return FALSE;
413
 
+       }
414
 
+
415
 
+       mode = VIDMEM_FRAMEBUFFER;
416
485
-    if (psav->FbRegion.size != 0) {
417
486
-#ifdef XSERVER_LIBPCIACCESS
418
487
-        err = pci_device_map_range(psav->PciInfo, psav->FbRegion.base,
429
498
-#endif
430
499
-        if (err) {
431
500
-            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
432
 
-                       "Internal error: cound not map framebuffer range (%d, %s).\n",
 
501
-                       "Internal error: could not map framebuffer range (%d, %s).\n",
433
502
-                       err, strerror(err));
434
503
-            return FALSE;
435
504
-        }
436
 
-
 
505
+    psav->FrameBufferBase = psav->PciInfo->memBase[ psav->FbRegion.bar ]
 
506
+      + psav->FbRegion.offset;
 
507
 
437
508
-        psav->FBBase = psav->FbRegion.memory;
438
509
-        psav->FBStart = (psav->IsSecondary)
439
510
-            ? psav->FBBase + 0x1000000 : psav->FBBase;
440
 
     }
 
511
-    }
 
512
+    psav->ApertureBase = psav->PciInfo->memBase[ psav->FbRegion.bar ]
 
513
+      + psav->ApertureRegion.offset;
441
514
 
442
 
+    psav->MapBase = psav->bar_mappings[ psav->MmioRegion.bar ]
443
 
+      + psav->MmioRegion.offset;
444
 
+
445
 
+    psav->BciMem = psav->MapBase + 0x10000;
446
 
+
447
 
+    SavageEnableMMIO(pScrn);
448
 
+
449
 
+    psav->FBBase = psav->bar_mappings[ psav->FbRegion.bar ]
450
 
+      + psav->FbRegion.offset;
451
515
-    if (psav->ApertureRegion.memory == NULL) {
452
516
-#ifdef XSERVER_LIBPCIACCESS
453
517
-        err = pci_device_map_range(psav->PciInfo, psav->ApertureRegion.base,
464
528
-#endif
465
529
-        if (err) {
466
530
-            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
467
 
-                       "Internal error: cound not map aperture range (%d, %s).\n",
 
531
-                       "Internal error: could not map aperture range (%d, %s).\n",
468
532
-                       err, strerror(err));
469
533
-            return FALSE;
470
534
-        }
471
 
-
 
535
 
472
536
-        psav->ApertureMap = (psav->IsSecondary)
473
 
-            ? psav->ApertureRegion.memory
474
 
-            : psav->ApertureRegion.memory + 0x1000000;
475
 
-    }
 
537
-            ? psav->ApertureRegion.memory + 0x1000000
 
538
-            : psav->ApertureRegion.memory;
 
539
+    /* FIXME: This seems fine even on Savage3D where the same BAR contains the
 
540
+     * FIXME: MMIO space and the framebuffer.  Write-combining gets fixed up
 
541
+     * FIXME: later.  Someone should investigate this, though.  And kick S3
 
542
+     * FIXME: for doing something so silly.
 
543
+     */
 
544
+    mode = VIDMEM_MMIO;
 
545
+    for (i = 0; i <= psav->last_bar; i++) {
 
546
+       psav->bar_mappings[i] = xf86MapPciMem(pScrn->scrnIndex, mode,
 
547
+                                             psav->PciTag,
 
548
+                                             psav->PciInfo->memBase[i],
 
549
+                                             (1U << psav->PciInfo->size[i]));
 
550
+       if (!psav->bar_mappings[i]) {
 
551
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
552
+                      "Internal error: cound not map PCI region %u, last BAR = %u\n",
 
553
+                      i, psav->last_bar);
 
554
+           return FALSE;
 
555
+       }
 
556
+
 
557
+       mode = VIDMEM_FRAMEBUFFER;
 
558
     }
476
559
 
477
 
+    psav->FBStart = (psav->IsSecondary)
478
 
+      ? psav->FBBase + 0x1000000 : psav->FBBase;
479
560
-    if (psav->MmioRegion.memory == NULL) {
480
561
-#ifdef XSERVER_LIBPCIACCESS
481
562
-        err = pci_device_map_range(psav->PciInfo, psav->MmioRegion.base,
484
565
-                                   & psav->MmioRegion.memory);
485
566
-#else
486
567
-        psav->MmioRegion.memory = 
487
 
-            xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
 
568
-            xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
488
569
-                          psav->PciTag, psav->MmioRegion.base,
489
570
-                          psav->MmioRegion.size);
490
571
-        err = (psav->MmioRegion.memory == NULL) ? errno : 0;
491
572
-#endif
492
573
-        if (err) {
493
574
-            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
494
 
-                       "Internal error: cound not map MMIO range (%d, %s).\n",
 
575
-                       "Internal error: could not map MMIO range (%d, %s).\n",
495
576
-                       err, strerror(err));
496
577
-            return FALSE;
497
578
-        }
 
579
+    psav->MapBase = psav->bar_mappings[ psav->MmioRegion.bar ]
 
580
+      + psav->MmioRegion.offset;
 
581
+
 
582
+    psav->BciMem = psav->MapBase + 0x10000;
 
583
+
 
584
+    SavageEnableMMIO(pScrn);
 
585
+
 
586
+    psav->FBBase = psav->bar_mappings[ psav->FbRegion.bar ]
 
587
+      + psav->FbRegion.offset;
498
588
 
499
 
+    psav->ApertureMap = psav->bar_mappings[ psav->ApertureRegion.bar ]
500
 
+      + psav->ApertureRegion.offset;
501
589
-        psav->MapBase = psav->MmioRegion.memory;
502
590
-        psav->BciMem = psav->MapBase + 0x10000;
 
591
+    psav->FBStart = (psav->IsSecondary)
 
592
+      ? psav->FBBase + 0x1000000 : psav->FBBase;
503
593
 
 
594
-        SavageEnableMMIO(pScrn);
 
595
+    psav->ApertureMap = psav->bar_mappings[ psav->ApertureRegion.bar ]
 
596
+      + psav->ApertureRegion.offset;
 
597
+
504
598
+    if (psav->IsSecondary) {
505
599
+       psav->ApertureMap += 0x1000000;
506
 
-        SavageEnableMMIO(pScrn);
507
600
     }
508
601
 
 
602
-    pScrn->memPhysBase = psav->FbRegion.base;
509
603
+    pScrn->memPhysBase = psav->PciInfo->memBase[0];
510
604
+
511
 
-    pScrn->memPhysBase = psav->FbRegion.base;
512
605
     return TRUE;
513
606
 }
514
607
 
515
 
@@ -3194,55 +3006,30 @@
 
608
@@ -3226,55 +3034,30 @@ static Bool SavageMapMem(ScrnInfoPtr pScrn)
516
609
 static void SavageUnmapMem(ScrnInfoPtr pScrn, int All)
517
610
 {
518
611
     SavagePtr psav = SAVPTR(pScrn);
521
614
     TRACE(("SavageUnmapMem(%x,%x)\n", psav->MapBase, psav->FBBase));
522
615
 
523
616
     if (psav->PrimaryVidMapped) {
 
617
-        vgaHWUnmapMem(pScrn);
 
618
-        psav->PrimaryVidMapped = FALSE;
524
619
+       vgaHWUnmapMem(pScrn);
525
620
+       psav->PrimaryVidMapped = FALSE;
526
 
-        vgaHWUnmapMem(pScrn);
527
 
-        psav->PrimaryVidMapped = FALSE;
528
621
     }
529
622
 
530
623
     SavageDisableMMIO(pScrn);
531
624
 
532
 
+    for (i = (All) ? 0 : 1; i <= psav->last_bar; i++) {
533
 
+       if (psav->bar_mappings[i]) {
534
 
+           xf86UnMapVidMem(pScrn->scrnIndex, psav->bar_mappings[i],
535
 
+                           (1U << psav->PciInfo->size[i]));
536
 
+           psav->bar_mappings[i] = NULL;
537
 
+       }
538
625
-    if (All && (psav->MmioRegion.memory != NULL)) {
539
626
-#ifdef XSERVER_LIBPCIACCESS
540
627
-        pci_device_unmap_range(psav->PciInfo,
559
646
-        xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->FbRegion.base,
560
647
-                        psav->FbRegion.size);
561
648
-#endif
 
649
+    for (i = (All) ? 0 : 1; i <= psav->last_bar; i++) {
 
650
+       if (psav->bar_mappings[i]) {
 
651
+           xf86UnMapVidMem(pScrn->scrnIndex, psav->bar_mappings[i],
 
652
+                           (1U << psav->PciInfo->size[i]));
 
653
+           psav->bar_mappings[i] = NULL;
 
654
+       }
562
655
     }
563
656
 
564
 
+    if (All) {
565
 
+       psav->MapBase = 0;
566
 
+       psav->BciMem = 0;
567
657
-    if (psav->ApertureRegion.memory != NULL) {
568
658
-#ifdef XSERVER_LIBPCIACCESS
569
659
-        pci_device_unmap_range(psav->PciInfo,
573
663
-        xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->ApertureRegion.base,
574
664
-                        psav->ApertureRegion.size);
575
665
-#endif
 
666
+    if (All) {
 
667
+       psav->MapBase = 0;
 
668
+       psav->BciMem = 0;
576
669
     }
577
 
+    
578
670
-
579
671
-    psav->FbRegion.memory = NULL;
580
672
-    psav->ApertureRegion.memory = NULL;
 
673
+    
581
674
     psav->FBBase = 0;
582
675
     psav->FBStart = 0;
583
676
     psav->ApertureMap = 0;
584
 
@@ -3331,7 +3118,7 @@
 
677
@@ -3363,7 +3146,7 @@ static void SavageInitShadowStatus(ScrnInfoPtr pScrn)
585
678
 
586
679
     if( psav->ShadowStatus ) {
587
680
        psav->ShadowPhysical = 
 
681
-           psav->FbRegion.base + psav->CursorKByte*1024 + 4096 - 32;
588
682
+           psav->FrameBufferBase + psav->CursorKByte*1024 + 4096 - 32;
589
 
-           psav->FbRegion.base + psav->CursorKByte*1024 + 4096 - 32;
590
683
        
591
684
        psav->ShadowVirtual = (CARD32 *)
592
685
            (psav->FBBase + psav->CursorKByte*1024 + 4096 - 32);
593
 
--- b/ChangeLog
594
 
+++ a/ChangeLog
595
 
@@ -1,82 +1,3 @@
596
 
-commit 9c959f53ca8376aa136a9d434c3383cdb20487c2
597
 
-Author: Alex Deucher <alex@botch2.(none)>
598
 
-Date:   Fri Sep 14 20:21:12 2007 -0400
599
 
-
600
 
-    fix the build for the non-pci-rework case (compile tested only)
601
 
-
602
 
-commit 846a69f70d189c486448df269a512b8d42fab0c2
603
 
-Author: Alex Deucher <alex@botch2.(none)>
604
 
-Date:   Fri Sep 14 20:13:33 2007 -0400
605
 
-
606
 
-    fix segfault from pScrn->currentMode
607
 
-    
608
 
-    should fix bug 12260
609
 
-
610
 
-commit 53a2088c5590bb96ce9a7ad30d908c7ea1d54027
611
 
-Merge: 7da1a03... 0287432...
612
 
-Author: James Cloos <cloos@jhcloos.com>
613
 
-Date:   Mon Sep 3 06:08:13 2007 -0400
614
 
-
615
 
-    Merge branch 'master' of ssh://git.freedesktop.org/git/xorg/driver/xf86-video-savage
616
 
-
617
 
-commit 7da1a03d4b8b40483001b1f6e56dae655a1797f4
618
 
-Author: James Cloos <cloos@jhcloos.com>
619
 
-Date:   Mon Sep 3 05:52:43 2007 -0400
620
 
-
621
 
-    Add *~ to .gitignore to skip patch/emacs droppings
622
 
-
623
 
-commit 0287432c65231460fadff7d8d7b332208e345a31
624
 
-Author: Ian Romanick <idr@us.ibm.com>
625
 
-Date:   Fri Aug 31 13:07:17 2007 -0700
626
 
-
627
 
-    Fix odd typo.
628
 
-
629
 
-commit 514dc647d108e179965adb1377b1d4c011afa367
630
 
-Author: Ian Romanick <idr@us.ibm.com>
631
 
-Date:   Thu Aug 30 17:53:11 2007 -0700
632
 
-
633
 
-    Update to use new libpciaccess interfaces for mapping with MTRR support.
634
 
-
635
 
-commit 1eec792391d9ce9127817107100a53382f167749
636
 
-Merge: 4a87cab... ffc5ba7...
637
 
-Author: Ian Romanick <idr@us.ibm.com>
638
 
-Date:   Thu Aug 23 18:21:37 2007 -0700
639
 
-
640
 
-    Merge branch 'pci-rework'
641
 
-
642
 
-commit 4a87cab2765df548a3b5d796e19568a2576306b8
643
 
-Author: James Cloos <cloos@jhcloos.com>
644
 
-Date:   Thu Aug 23 19:25:53 2007 -0400
645
 
-
646
 
-    Rename .cvsignore to .gitignore
647
 
-
648
 
-commit ffc5ba7f0b1cdefdcecf6bd47018b6a4924bfc44
649
 
-Author: Ian Romanick <idr@us.ibm.com>
650
 
-Date:   Wed Aug 22 12:38:14 2007 -0700
651
 
-
652
 
-    Merge PCI-rework support and "classic" PCI interface support into one tree
653
 
-    
654
 
-    First pass at merging both trees.  So far, this has only been compile
655
 
-    tested.  I need to dig out a savage card to put in a system for
656
 
-    testing, so it may take another hour or two.
657
 
-
658
 
-commit 68ceead721aeb75b9faed6297407a320a83499e4
659
 
-Merge: da23218... bf5e2a5...
660
 
-Author: Ian Romanick <idr@us.ibm.com>
661
 
-Date:   Wed Aug 22 11:45:43 2007 -0700
662
 
-
663
 
-    Merge branch 'master' into pci-rework
664
 
-    
665
 
-    Conflicts:
666
 
-    
667
 
-       src/savage_driver.h
668
 
-
669
 
-commit da23218b067d9b1808fc1168737c79b3349af09e
670
 
-Author: Ian Romanick <idr@us.ibm.com>
671
 
-Date:   Wed Aug 22 11:42:47 2007 -0700
672
 
-
673
 
-    dos2unix
674
 
-
675
 
 commit bf5e2a5d33fbab07bc3606927c58a3a04a5c9b1e
676
 
 Author: Julien Cristau <jcristau@debian.org>
677
 
 Date:   Fri Aug 17 03:25:48 2007 +0200
678
 
@@ -179,17 +100,6 @@
679
 
     SavageCloseScreen() unmaps memory, but SavageScreenInit()
680
 
     never maps it again.
681
 
 
682
 
-commit 36c444e80324c82f7d02d9d95372123c923336a0
683
 
-Merge: f2191d4... e361a95...
684
 
-Author: Ian Romanick <idr@us.ibm.com>
685
 
-Date:   Mon Dec 11 13:16:53 2006 -0800
686
 
-
687
 
-    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-video-savage into pci-rework
688
 
-    
689
 
-    Conflicts:
690
 
-    
691
 
-       src/savage_driver.c
692
 
-
693
 
 commit 37240b81daa4ed46c27e439d22b6fd9909dac249
694
 
 Author: Alex Deucher <alex@t41p.(none)>
695
 
 Date:   Wed Nov 22 11:56:41 2006 -0500
696
 
@@ -228,12 +138,6 @@
697
 
 
698
 
     re-order SavageMapMem() so that ram detection works again.
699
 
 
700
 
-commit f2191d412832312b494f313841d094f87f64a5ff
701
 
-Author: Ian Romanick <idr@umwelt.(none)>
702
 
-Date:   Tue Aug 8 16:49:51 2006 -0700
703
 
-
704
 
-    Minimal change set to convert driver to the new PCI interfaces.  Enjoy.
705
 
-
706
 
 commit 5108d1dd581a6e649f89812affba8481491e1bd7
707
 
 Author: Ian Romanick <idr@umwelt.(none)>
708
 
 Date:   Tue Aug 8 12:21:11 2006 -0700
709
 
--- b/configure.ac
710
 
+++ a/configure.ac
711
 
@@ -95,18 +95,6 @@
712
 
         AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
713
 
 fi
714
 
 
715
 
-save_CFLAGS="$CFLAGS"
716
 
-CFLAGS="$XORG_CFLAGS"
717
 
-AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
718
 
-              [XSERVER_LIBPCIACCESS=yes], [XSERVER_LIBPCIACCESS=no],
719
 
-              [#include "xorg-server.h"])
720
 
-CFLAGS="$save_CFLAGS"
721
 
-
722
 
-if test "x$XSERVER_LIBPCIACCESS" = xyes; then
723
 
-    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10.0])
724
 
-fi
725
 
-AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
726
 
-
727
 
 AC_SUBST([DRI_CFLAGS])
728
 
 AC_SUBST([XORG_CFLAGS])
729
 
 AC_SUBST([moduledir])
730
 
--- b/src/savage_dga.c
731
 
+++ a/src/savage_dga.c
732
 
@@ -391,7 +391,7 @@
733
 
     SavagePtr psav = SAVPTR(pScrn);
734
 
 
735
 
     *name = NULL;       /* no special device */
736
 
+    *mem = (unsigned char*)psav->FrameBufferBase;
737
 
-    *mem = (unsigned char*)psav->FbRegion.base;
738
 
     *size = psav->videoRambytes;
739
 
     *offset = 0;
740
 
     *flags = DGA_NEED_ROOT;
741
 
--- b/src/savage_dri.c
742
 
+++ a/src/savage_dri.c
743
 
@@ -467,8 +467,8 @@
744
 
    xf86DrvMsg( pScreen->myNum, X_INFO,
745
 
               "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
746
 
               mode, vendor, device,
747
 
+              psav->PciInfo->vendor,
748
 
+              psav->PciInfo->chipType );
749
 
-              VENDOR_ID(psav->PciInfo),
750
 
-              DEVICE_ID(psav->PciInfo));
751
 
 
752
 
    if ( drmAgpEnable( psav->drmFD, mode ) < 0 ) {
753
 
       xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" );
754
 
@@ -624,7 +624,7 @@
755
 
    pSAVAGEDRIServer->registers.size = SAVAGEIOMAPSIZE;
756
 
 
757
 
    if ( drmAddMap( psav->drmFD,
758
 
+                  (drm_handle_t)psav->MmioBase,
759
 
-                  (drm_handle_t)psav->MmioRegion.base,
760
 
                   pSAVAGEDRIServer->registers.size,
761
 
                   DRM_REGISTERS,0,
762
 
                   &pSAVAGEDRIServer->registers.handle ) < 0 ) {
763
 
@@ -636,7 +636,7 @@
764
 
    pSAVAGEDRIServer->aperture.size = 5 * 0x01000000;
765
 
    
766
 
    if ( drmAddMap( psav->drmFD,
767
 
+                  (drm_handle_t)(psav->ApertureBase),
768
 
-                  (drm_handle_t)(psav->ApertureRegion.base),
769
 
                   pSAVAGEDRIServer->aperture.size,
770
 
                   DRM_FRAME_BUFFER,0,
771
 
                   &pSAVAGEDRIServer->aperture.handle ) < 0 ) {
772
 
@@ -882,18 +882,14 @@
773
 
       sprintf(pDRIInfo->busIdString,
774
 
               "PCI:%d:%d:%d",
775
 
               psav->PciInfo->bus,
776
 
-#ifdef XSERVER_LIBPCIACCESS
777
 
-              psav->PciInfo->dev,
778
 
-#else
779
 
               psav->PciInfo->device,
780
 
-#endif
781
 
               psav->PciInfo->func);
782
 
    }
783
 
    pDRIInfo->ddxDriverMajorVersion = SAVAGE_VERSION_MAJOR;
784
 
    pDRIInfo->ddxDriverMinorVersion = SAVAGE_VERSION_MINOR;
785
 
    pDRIInfo->ddxDriverPatchVersion = SAVAGE_PATCHLEVEL;
786
 
 
787
 
+   pDRIInfo->frameBufferPhysicalAddress = (pointer) psav->FrameBufferBase;
788
 
-   pDRIInfo->frameBufferPhysicalAddress = (pointer) psav->FbRegion.base;
789
 
    pDRIInfo->frameBufferSize = psav->videoRambytes;
790
 
    pDRIInfo->frameBufferStride = pScrn->displayWidth*(pScrn->bitsPerPixel/8);
791
 
    pDRIInfo->ddxDrawableTableEntry = SAVAGE_MAX_DRAWABLES;
792
 
--- b/src/savage_driver.h
793
 
+++ a/src/savage_driver.h
 
686
diff --git a/src/savage_driver.h b/src/savage_driver.h
 
687
index b6d1e7a..9faedc4 100644
 
688
--- a/src/savage_driver.h
 
689
+++ b/src/savage_driver.h
794
690
@@ -33,19 +33,6 @@
795
691
 #include <string.h>
796
692
 #include <math.h>
811
707
 #define MODE_24 24
812
708
 
813
709
 #include "compiler.h"
814
 
@@ -280,14 +267,8 @@
 
710
@@ -280,14 +267,8 @@ typedef struct _StatInfo {
815
711
 } StatInfoRec,*StatInfoPtr;
816
712
 
817
713
 struct savage_region {
818
 
+    unsigned        bar;
819
 
+    unsigned long   offset;
820
714
-#ifdef XSERVER_LIBPCIACCESS
821
715
-    pciaddr_t       base;
822
716
-    pciaddr_t       size;
825
719
-    unsigned long   size;
826
720
-#endif
827
721
-    void          * memory;
 
722
+    unsigned        bar;
 
723
+    unsigned long   offset;
828
724
 };
829
725
 
830
726
 typedef struct _Savage {
831
 
@@ -311,12 +292,18 @@
 
727
@@ -311,12 +292,18 @@ typedef struct _Savage {
832
728
     int                        endfb;
833
729
 
834
730
     /* These are physical addresses. */
847
743
 
848
744
     unsigned char*     MapBase;
849
745
     unsigned char*     BciMem;
850
 
@@ -376,12 +363,8 @@
 
746
@@ -377,12 +364,8 @@ typedef struct _Savage {
851
747
     int                        TVSizeY;
852
748
 
853
749
     CloseScreenProcPtr CloseScreen;
860
756
     int                        Chipset;
861
757
     int                        ChipId;
862
758
     int                        ChipRev;
863
 
--- b/src/savage_hwmc.c
864
 
+++ a/src/savage_hwmc.c
865
 
@@ -202,7 +202,7 @@
 
759
diff --git a/src/savage_hwmc.c b/src/savage_hwmc.c
 
760
index 43c9dfd..6a39754 100644
 
761
--- a/src/savage_hwmc.c
 
762
+++ b/src/savage_hwmc.c
 
763
@@ -202,7 +202,7 @@ Bool SAVAGEInitMC(ScreenPtr pScreen)
866
764
     return FALSE;
867
765
   }
868
766
 
 
767
-  offset = pSAVAGE->hwmcOffset + pSAVAGE->FbRegion.base;
869
768
+  offset = pSAVAGE->hwmcOffset + pSAVAGE->FrameBufferBase;
870
 
-  offset = pSAVAGE->hwmcOffset + pSAVAGE->FbRegion.base;
871
769
 
872
770
   if(drmAddMap(pSAVAGE->drmFD, offset, pSAVAGE->hwmcSize,
873
771
                DRM_FRAME_BUFFER, 0, &pSAVAGEDriPriv->xvmcSurfHandle) < 0)