1
--- b/src/savage_driver.c
1
diff --git a/configure.ac b/configure.ac
2
index b6d64e4..d88819c 100644
5
@@ -95,18 +95,6 @@ if test "$DRI" = yes; then
6
AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
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"
16
-if test "x$XSERVER_LIBPCIACCESS" = xyes; then
17
- PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10])
19
-AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
21
AC_SUBST([DRI_CFLAGS])
22
AC_SUBST([XORG_CFLAGS])
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);
31
*name = NULL; /* no special device */
32
- *mem = (unsigned char*)psav->FbRegion.base;
33
+ *mem = (unsigned char*)psav->FrameBufferBase;
34
*size = psav->videoRambytes;
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",
45
- VENDOR_ID(psav->PciInfo),
46
- DEVICE_ID(psav->PciInfo));
47
+ psav->PciInfo->vendor,
48
+ psav->PciInfo->chipType );
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;
55
if ( drmAddMap( psav->drmFD,
56
- (drm_handle_t)psav->MmioRegion.base,
57
+ (drm_handle_t)psav->MmioBase,
58
pSAVAGEDRIServer->registers.size,
60
&pSAVAGEDRIServer->registers.handle ) < 0 ) {
61
@@ -636,7 +636,7 @@ static Bool SAVAGEDRIMapInit( ScreenPtr pScreen )
62
pSAVAGEDRIServer->aperture.size = 5 * 0x01000000;
64
if ( drmAddMap( psav->drmFD,
65
- (drm_handle_t)(psav->ApertureRegion.base),
66
+ (drm_handle_t)(psav->ApertureBase),
67
pSAVAGEDRIServer->aperture.size,
69
&pSAVAGEDRIServer->aperture.handle ) < 0 ) {
70
@@ -882,18 +882,14 @@ Bool SAVAGEDRIScreenInit( ScreenPtr pScreen )
71
sprintf(pDRIInfo->busIdString,
74
-#ifdef XSERVER_LIBPCIACCESS
77
psav->PciInfo->device,
81
pDRIInfo->ddxDriverMajorVersion = SAVAGE_VERSION_MAJOR;
82
pDRIInfo->ddxDriverMinorVersion = SAVAGE_VERSION_MINOR;
83
pDRIInfo->ddxDriverPatchVersion = SAVAGE_PATCHLEVEL;
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
355
439
- + psav->PciInfo->memBase[0];
356
440
- psav->FbRegion.base = psav->PciInfo->memBase[1];
443
+ psav->MmioRegion.bar = 0;
444
+ psav->MmioRegion.offset = SAVAGE_NEWMMIO_REGBASE_S4;
360
446
- psav->MmioRegion.size = SAVAGE_NEWMMIO_REGSIZE;
361
447
- psav->FbRegion.size = psav->videoRambytes;
448
+ psav->FbRegion.bar = 1;
449
+ psav->FbRegion.offset = 0;
451
+ psav->last_bar = 1;
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.
458
- psav->ApertureRegion.size = (psav->IsPrimary || psav->IsSecondary)
459
- ? (0x01000000 * 2) : (0x01000000 * 5);
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;
468
- psav->ApertureRegion.base = psav->PciInfo->memBase[2];
367
470
+ || (psav->Chipset == S3_SAVAGE2000)) {
368
471
+ psav->ApertureRegion.bar = 2;
369
472
+ psav->ApertureRegion.offset = 0;
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;
376
- psav->ApertureRegion.base = psav->PciInfo->memBase[2];
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;
384
- psav->ApertureRegion.size = (psav->IsPrimary || psav->IsSecondary)
385
- ? (0x01000000 * 2) : (0x01000000 * 5);
387
482
+ psav->MmioBase = psav->PciInfo->memBase[ psav->MmioRegion.bar ]
388
483
+ + psav->MmioRegion.offset;
390
+ psav->FrameBufferBase = psav->PciInfo->memBase[ psav->FbRegion.bar ]
391
+ + psav->FbRegion.offset;
393
+ psav->ApertureBase = psav->PciInfo->memBase[ psav->FbRegion.bar ]
394
+ + psav->ApertureRegion.offset;
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.
402
+ mode = VIDMEM_MMIO;
403
+ for (i = 0; i <= psav->last_bar; i++) {
404
+ psav->bar_mappings[i] = xf86MapPciMem(pScrn->scrnIndex, mode,
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);
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,
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));
472
536
- psav->ApertureMap = (psav->IsSecondary)
473
- ? psav->ApertureRegion.memory
474
- : psav->ApertureRegion.memory + 0x1000000;
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.
544
+ mode = VIDMEM_MMIO;
545
+ for (i = 0; i <= psav->last_bar; i++) {
546
+ psav->bar_mappings[i] = xf86MapPciMem(pScrn->scrnIndex, mode,
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);
557
+ mode = VIDMEM_FRAMEBUFFER;
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);
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;
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));
579
+ psav->MapBase = psav->bar_mappings[ psav->MmioRegion.bar ]
580
+ + psav->MmioRegion.offset;
582
+ psav->BciMem = psav->MapBase + 0x10000;
584
+ SavageEnableMMIO(pScrn);
586
+ psav->FBBase = psav->bar_mappings[ psav->FbRegion.bar ]
587
+ + psav->FbRegion.offset;
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;
594
- SavageEnableMMIO(pScrn);
595
+ psav->ApertureMap = psav->bar_mappings[ psav->ApertureRegion.bar ]
596
+ + psav->ApertureRegion.offset;
504
598
+ if (psav->IsSecondary) {
505
599
+ psav->ApertureMap += 0x1000000;
506
- SavageEnableMMIO(pScrn);
602
- pScrn->memPhysBase = psav->FbRegion.base;
509
603
+ pScrn->memPhysBase = psav->PciInfo->memBase[0];
511
- pScrn->memPhysBase = psav->FbRegion.base;
515
@@ -3194,55 +3006,30 @@
608
@@ -3226,55 +3034,30 @@ static Bool SavageMapMem(ScrnInfoPtr pScrn)
516
609
static void SavageUnmapMem(ScrnInfoPtr pScrn, int All)
518
611
SavagePtr psav = SAVPTR(pScrn);
573
663
- xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->ApertureRegion.base,
574
664
- psav->ApertureRegion.size);
579
671
- psav->FbRegion.memory = NULL;
580
672
- psav->ApertureRegion.memory = NULL;
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)
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;
591
684
psav->ShadowVirtual = (CARD32 *)
592
685
(psav->FBBase + psav->CursorKByte*1024 + 4096 - 32);
596
-commit 9c959f53ca8376aa136a9d434c3383cdb20487c2
597
-Author: Alex Deucher <alex@botch2.(none)>
598
-Date: Fri Sep 14 20:21:12 2007 -0400
600
- fix the build for the non-pci-rework case (compile tested only)
602
-commit 846a69f70d189c486448df269a512b8d42fab0c2
603
-Author: Alex Deucher <alex@botch2.(none)>
604
-Date: Fri Sep 14 20:13:33 2007 -0400
606
- fix segfault from pScrn->currentMode
608
- should fix bug 12260
610
-commit 53a2088c5590bb96ce9a7ad30d908c7ea1d54027
611
-Merge: 7da1a03... 0287432...
612
-Author: James Cloos <cloos@jhcloos.com>
613
-Date: Mon Sep 3 06:08:13 2007 -0400
615
- Merge branch 'master' of ssh://git.freedesktop.org/git/xorg/driver/xf86-video-savage
617
-commit 7da1a03d4b8b40483001b1f6e56dae655a1797f4
618
-Author: James Cloos <cloos@jhcloos.com>
619
-Date: Mon Sep 3 05:52:43 2007 -0400
621
- Add *~ to .gitignore to skip patch/emacs droppings
623
-commit 0287432c65231460fadff7d8d7b332208e345a31
624
-Author: Ian Romanick <idr@us.ibm.com>
625
-Date: Fri Aug 31 13:07:17 2007 -0700
629
-commit 514dc647d108e179965adb1377b1d4c011afa367
630
-Author: Ian Romanick <idr@us.ibm.com>
631
-Date: Thu Aug 30 17:53:11 2007 -0700
633
- Update to use new libpciaccess interfaces for mapping with MTRR support.
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
640
- Merge branch 'pci-rework'
642
-commit 4a87cab2765df548a3b5d796e19568a2576306b8
643
-Author: James Cloos <cloos@jhcloos.com>
644
-Date: Thu Aug 23 19:25:53 2007 -0400
646
- Rename .cvsignore to .gitignore
648
-commit ffc5ba7f0b1cdefdcecf6bd47018b6a4924bfc44
649
-Author: Ian Romanick <idr@us.ibm.com>
650
-Date: Wed Aug 22 12:38:14 2007 -0700
652
- Merge PCI-rework support and "classic" PCI interface support into one tree
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.
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
663
- Merge branch 'master' into pci-rework
667
- src/savage_driver.h
669
-commit da23218b067d9b1808fc1168737c79b3349af09e
670
-Author: Ian Romanick <idr@us.ibm.com>
671
-Date: Wed Aug 22 11:42:47 2007 -0700
675
commit bf5e2a5d33fbab07bc3606927c58a3a04a5c9b1e
676
Author: Julien Cristau <jcristau@debian.org>
677
Date: Fri Aug 17 03:25:48 2007 +0200
679
SavageCloseScreen() unmaps memory, but SavageScreenInit()
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
687
- Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-video-savage into pci-rework
691
- src/savage_driver.c
693
commit 37240b81daa4ed46c27e439d22b6fd9909dac249
694
Author: Alex Deucher <alex@t41p.(none)>
695
Date: Wed Nov 22 11:56:41 2006 -0500
698
re-order SavageMapMem() so that ram detection works again.
700
-commit f2191d412832312b494f313841d094f87f64a5ff
701
-Author: Ian Romanick <idr@umwelt.(none)>
702
-Date: Tue Aug 8 16:49:51 2006 -0700
704
- Minimal change set to convert driver to the new PCI interfaces. Enjoy.
706
commit 5108d1dd581a6e649f89812affba8481491e1bd7
707
Author: Ian Romanick <idr@umwelt.(none)>
708
Date: Tue Aug 8 12:21:11 2006 -0700
712
AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
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"
722
-if test "x$XSERVER_LIBPCIACCESS" = xyes; then
723
- PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10.0])
725
-AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
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
733
SavagePtr psav = SAVPTR(pScrn);
735
*name = NULL; /* no special device */
736
+ *mem = (unsigned char*)psav->FrameBufferBase;
737
- *mem = (unsigned char*)psav->FbRegion.base;
738
*size = psav->videoRambytes;
740
*flags = DGA_NEED_ROOT;
741
--- b/src/savage_dri.c
742
+++ a/src/savage_dri.c
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));
752
if ( drmAgpEnable( psav->drmFD, mode ) < 0 ) {
753
xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" );
755
pSAVAGEDRIServer->registers.size = SAVAGEIOMAPSIZE;
757
if ( drmAddMap( psav->drmFD,
758
+ (drm_handle_t)psav->MmioBase,
759
- (drm_handle_t)psav->MmioRegion.base,
760
pSAVAGEDRIServer->registers.size,
762
&pSAVAGEDRIServer->registers.handle ) < 0 ) {
764
pSAVAGEDRIServer->aperture.size = 5 * 0x01000000;
766
if ( drmAddMap( psav->drmFD,
767
+ (drm_handle_t)(psav->ApertureBase),
768
- (drm_handle_t)(psav->ApertureRegion.base),
769
pSAVAGEDRIServer->aperture.size,
771
&pSAVAGEDRIServer->aperture.handle ) < 0 ) {
772
@@ -882,18 +882,14 @@
773
sprintf(pDRIInfo->busIdString,
776
-#ifdef XSERVER_LIBPCIACCESS
777
- psav->PciInfo->dev,
779
psav->PciInfo->device,
781
psav->PciInfo->func);
783
pDRIInfo->ddxDriverMajorVersion = SAVAGE_VERSION_MAJOR;
784
pDRIInfo->ddxDriverMinorVersion = SAVAGE_VERSION_MINOR;
785
pDRIInfo->ddxDriverPatchVersion = SAVAGE_PATCHLEVEL;
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>