sparc-ast.patch revision 1265
1265N/Adiff --git a/src/Makefile.am b/src/Makefile.am
1265N/Aindex 4cd7075..58274df 100644
1265N/A--- a/src/Makefile.am
1265N/A+++ b/src/Makefile.am
705N/A@@ -42,4 +42,5 @@ ast_drv_la_SOURCES = \
691N/A ast_pcirename.h \
691N/A ast_tool.c \
691N/A ast_vgatool.c \
691N/A- ast_vgatool.h
691N/A+ ast_vgatool.h \
691N/A+ ast_sparc_driver.c
1265N/Adiff --git a/src/ast.h b/src/ast.h
1265N/Aindex 7ceee31..a6af228 100644
1265N/A--- a/src/ast.h
1265N/A+++ b/src/ast.h
705N/A@@ -20,8 +20,17 @@
705N/A * PERFORMANCE OF THIS SOFTWARE.
705N/A */
705N/A
705N/A+#ifndef AST_H
705N/A+#define AST_H
705N/A+
705N/A #include <string.h>
705N/A #include <stdlib.h>
705N/A+#include <sys/visual_io.h>
705N/A+
705N/A+#ifdef __sparc
705N/A+#define __sparc__ 1
705N/A+#endif
705N/A+
705N/A
705N/A #include "ast_pcirename.h"
705N/A
1265N/A@@ -90,6 +99,15 @@ typedef CARD32 ULONG;
705N/A typedef struct _ASTRegRec {
705N/A UCHAR ExtCRTC[0x50];
1265N/A ULONG GFX[12];
1265N/A+
705N/A+#if (defined(__sparc__))
705N/A+ UCHAR MISC;
705N/A+ UCHAR SEQ[4];
705N/A+ UCHAR CRTC[25];
705N/A+ UCHAR AR[20];
705N/A+ UCHAR GR[9];
705N/A+ UCHAR DAC[256][3];
705N/A+#endif
705N/A } ASTRegRec, *ASTRegPtr;
705N/A
705N/A typedef struct _VIDEOMODE {
1265N/A@@ -249,12 +267,94 @@ typedef struct _ASTRec {
1265N/A Atom xvGammaRed, xvGammaGreen, xvGammaBlue;
1265N/A #endif
1265N/A
705N/A+#if defined(__sparc__)
705N/A+ char *deviceName;
705N/A+ int fd;
705N/A+#endif /* __sparc__ */
705N/A+
1265N/A } ASTRec, *ASTRecPtr, *ASTPtr;
1265N/A
705N/A #define ASTPTR(p) ((ASTRecPtr)((p)->driverPrivate))
705N/A
705N/A+#if defined(__sparc__)
705N/A+#ifndef VIS_GETPCICONFIG
705N/A+
705N/A+/*
705N/A+ * These definitions will be removed when they are included in the
705N/A+ * visual_io.h
705N/A+ */
705N/A+#define VIS_GETVIDEOMODENAME (VIOC | 12)
705N/A+#define VIS_STOREVIDEOMODENAME (VIOC | 13)
705N/A+#define VIS_MAX_VMODE_LEN 48
705N/A+
705N/A+typedef struct vis_video_mode {
705N/A+ char mode_name[VIS_MAX_VMODE_LEN];
705N/A+ uint32_t vRefresh;
705N/A+ char pad[96];
705N/A+} vis_video_mode_t;
705N/A+
705N/A+
705N/A+#define VIS_GETPCICONFIG (VIOC | 14)
705N/A+
705N/A+typedef struct vis_pci_cfg {
705N/A+ uint16_t VendorID;
705N/A+ uint16_t DeviceID;
705N/A+ uint16_t Command;
705N/A+ uint16_t Status;
705N/A+ uint8_t RevisionID;
705N/A+ uint8_t ProgIF;
705N/A+ uint8_t SubClass;
705N/A+ uint8_t BaseClass;
705N/A+
705N/A+ uint8_t CacheLineSize;
705N/A+ uint8_t LatencyTimer;
705N/A+ uint8_t HeaderType;
705N/A+ uint8_t BIST;
705N/A+
705N/A+ uint32_t bar[6];
705N/A+ uint32_t CIS;
705N/A+ uint16_t SubVendorID;
705N/A+ uint16_t SubSystemID;
705N/A+ uint32_t ROMBaseAddress;
705N/A+
705N/A+ uint8_t CapabilitiesPtr;
705N/A+ uint8_t Reserved_1[3];
705N/A+ uint32_t Reserved_2;
705N/A+
705N/A+ uint8_t InterruptLine;
705N/A+ uint8_t InterruptPin;
705N/A+ uint8_t MinimumGrant;
705N/A+ uint8_t MaximumLatency;
705N/A+
705N/A+ uint8_t pad[100];
705N/A+} vis_pci_cfg_t;
705N/A+
705N/A+
705N/A+#define VIS_SETIOREG (VIOC | 17)
705N/A+#define VIS_GETIOREG (VIOC | 18)
705N/A+
705N/A+typedef struct vis_io_reg {
705N/A+ uchar_t offset;
705N/A+ uchar_t value;
705N/A+} vis_io_reg_t;
705N/A+#endif
705N/A+
705N/A+
705N/A+extern struct pci_device *ASTGetPciInfo(ASTRecPtr);
705N/A+extern ScrnInfoPtr ASTAllocScreen(DriverPtr, GDevPtr);
705N/A+extern pointer ASTMapVidMem(ScrnInfoPtr, unsigned int, PCITAG,
705N/A+ unsigned long, unsigned long);
705N/A+extern void ASTUnmapVidMem(ScrnInfoPtr, pointer, unsigned long);
705N/A+extern void ASTNotifyModeChanged(ScrnInfoPtr);
705N/A+extern void ASTSaveHW(ScrnInfoPtr);
705N/A+extern void ASTRestoreHW(ScrnInfoPtr);
705N/A+
705N/A+#endif
705N/A+
705N/A /* Include Files */
705N/A #include "ast_mode.h"
705N/A #include "ast_vgatool.h"
705N/A #include "ast_2dtool.h"
705N/A #include "ast_cursor.h"
705N/A+
705N/A+#endif /* AST_H */
1265N/Adiff --git a/src/ast_accel.c b/src/ast_accel.c
1265N/Aindex 2d3dab3..74ca45d 100644
1265N/A--- a/src/ast_accel.c
1265N/A+++ b/src/ast_accel.c
999N/A@@ -189,7 +189,12 @@ ASTAccelInit(ScreenPtr pScreen)
691N/A {
691N/A infoPtr->SetupForSolidFill = ASTSetupForSolidFill;
691N/A infoPtr->SubsequentSolidFillRect = ASTSubsequentSolidFillRect;
691N/A+
691N/A+#if defined(__sparc__)
691N/A+ infoPtr->SolidFillFlags = NO_PLANEMASK | BIT_ORDER_IN_BYTE_MSBFIRST;
691N/A+#else
691N/A infoPtr->SolidFillFlags = NO_PLANEMASK;
691N/A+#endif /* __sparc__ */
691N/A }
691N/A
691N/A /* Solid Lines */
1265N/Adiff --git a/src/ast_cursor.c b/src/ast_cursor.c
1265N/Aindex b3f2061..9b7f1c8 100644
1265N/A--- a/src/ast_cursor.c
1265N/A+++ b/src/ast_cursor.c
1265N/A@@ -87,7 +87,11 @@ ASTCursorInit(ScreenPtr pScreen)
691N/A
691N/A infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
691N/A HARDWARE_CURSOR_INVERT_MASK |
1265N/A+#if !defined(__sparc__)
691N/A HARDWARE_CURSOR_BIT_ORDER_MSBFIRST;
691N/A+#else
1265N/A+ 0;
691N/A+#endif
691N/A
691N/A infoPtr->MaxWidth = MAX_HWC_WIDTH;
691N/A infoPtr->MaxHeight = MAX_HWC_HEIGHT;
1265N/Adiff --git a/src/ast_driver.c b/src/ast_driver.c
1265N/Aindex 896f22c..c4afa21 100644
1265N/A--- a/src/ast_driver.c
1265N/A+++ b/src/ast_driver.c
1265N/A@@ -106,7 +106,7 @@ static void ASTFreeScreen(int scrnIndex, int flags);
691N/A static ModeStatus ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags);
691N/A
691N/A /* Internally used functions */
691N/A-static Bool ASTGetRec(ScrnInfoPtr pScrn);
691N/A+extern Bool ASTGetRec(ScrnInfoPtr pScrn);
691N/A static void ASTFreeRec(ScrnInfoPtr pScrn);
691N/A static Bool ASTSaveScreen(ScreenPtr pScreen, Bool unblack);
691N/A static Bool ASTCloseScreen(int scrnIndex, ScreenPtr pScreen);
1265N/A@@ -270,7 +270,7 @@ ASTProbe(DriverPtr drv, int flags)
691N/A return FALSE;
691N/A }
691N/A
691N/A-#ifndef XSERVER_LIBPCIACCESS
691N/A+#if !defined(XSERVER_LIBPCIACCESS) && !defined(__sparc__)
691N/A /*
691N/A * This probing is just checking the PCI data the server already
691N/A * collected.
1265N/A@@ -280,6 +280,7 @@ ASTProbe(DriverPtr drv, int flags)
691N/A }
691N/A #endif
691N/A
691N/A+#if !defined(__sparc__)
691N/A numUsed = xf86MatchPciInstances(AST_NAME, PCI_VENDOR_AST,
691N/A ASTChipsets, ASTPciChipsets,
691N/A devSections, numDevSections,
1265N/A@@ -323,6 +324,37 @@ ASTProbe(DriverPtr drv, int flags)
691N/A } /* end of if flags */
691N/A
1265N/A free(usedChips);
691N/A+#else
705N/A+
1265N/A+ if (flags & PROBE_DETECT) {
1265N/A+ foundScreen = TRUE;
1265N/A+ } else {
1265N/A+ for (i = 0; i < numDevSections; i++) {
1265N/A+
1265N/A+ ScrnInfoPtr pScrn = NULL;
1265N/A+
1265N/A+ /* Allocate new ScrnInfoRec and claim the slot */
1265N/A+ if (pScrn = ASTAllocScreen(drv, devSections[i])) {
1265N/A+ pScrn->driverVersion = AST_VERSION;
1265N/A+ pScrn->driverName = AST_DRIVER_NAME;
1265N/A+ pScrn->name = AST_NAME;
691N/A+
1265N/A+ pScrn->Probe = ASTProbe;
1265N/A+ pScrn->PreInit = ASTPreInit;
1265N/A+ pScrn->ScreenInit = ASTScreenInit;
1265N/A+ pScrn->SwitchMode = ASTSwitchMode;
1265N/A+ pScrn->AdjustFrame = ASTAdjustFrame;
1265N/A+ pScrn->EnterVT = ASTEnterVT;
1265N/A+ pScrn->LeaveVT = ASTLeaveVT;
1265N/A+ pScrn->FreeScreen = ASTFreeScreen;
1265N/A+ pScrn->ValidMode = ASTValidMode;
1265N/A+
1265N/A+ foundScreen = TRUE;
1265N/A+ }
691N/A+ }
691N/A+ }
1265N/A+ free(devSections);
691N/A+#endif
705N/A
691N/A return foundScreen;
691N/A }
1265N/A@@ -338,7 +370,9 @@ static Bool
691N/A ASTPreInit(ScrnInfoPtr pScrn, int flags)
691N/A {
691N/A EntityInfoPtr pEnt;
691N/A+#if !defined(__sparc__)
691N/A vgaHWPtr hwp;
691N/A+#endif
691N/A int flags24;
691N/A rgb defaultWeight = { 0, 0, 0 };
691N/A
1265N/A@@ -355,6 +389,10 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
691N/A
691N/A pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
691N/A
691N/A+#if defined(__sparc__)
691N/A+ pEnt->location.type = BUS_PCI;
691N/A+#endif /* __sparc__ */
691N/A+
691N/A if (flags & PROBE_DETECT) {
691N/A ASTProbeDDC(pScrn, pEnt->index);
691N/A return TRUE;
1265N/A@@ -368,19 +406,23 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
691N/A return FALSE;
999N/A #endif
691N/A
1265N/A+#if !(defined(__sparc__))
691N/A /* The vgahw module should be loaded here when needed */
691N/A if (!xf86LoadSubModule(pScrn, "vgahw"))
691N/A return FALSE;
691N/A+#endif
691N/A
691N/A /* The fb module should be loaded here when needed */
691N/A if (!xf86LoadSubModule(pScrn, "fb"))
691N/A return FALSE;
705N/A
1265N/A+#if !(defined(__sparc__))
691N/A /* Allocate a vgaHWRec */
691N/A if (!vgaHWGetHWRec(pScrn))
691N/A return FALSE;
691N/A hwp = VGAHWPTR(pScrn);
1265N/A vgaHWSetStdFuncs(hwp);
691N/A+#endif
705N/A
691N/A /* Color Depth Check */
691N/A flags24 = Support32bppFb;
1265N/A@@ -453,7 +495,12 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
691N/A /* Fill AST Info */
691N/A pAST = ASTPTR(pScrn);
691N/A pAST->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
691N/A+#if !defined(__sparc__)
691N/A pAST->PciInfo = xf86GetPciInfoForEntity(pAST->pEnt->index);
691N/A+#else
1265N/A+ pAST->PciInfo = ASTGetPciInfo(pAST);
691N/A+#endif
691N/A+
691N/A #ifndef XSERVER_LIBPCIACCESS
691N/A pAST->PciTag = pciTag(pAST->PciInfo->bus, pAST->PciInfo->device,
691N/A pAST->PciInfo->func);
1265N/A@@ -508,11 +555,13 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
691N/A * the vgaHW module to use our relocated i/o ports.
691N/A */
1265N/A
1265N/A+#if !(defined(__sparc__))
1265N/A #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
1265N/A VGAHWPTR(pScrn)->PIOOffset = /* ... */
1265N/A #endif
1265N/A pAST->PIOOffset =
1265N/A pAST->IODBase + PCI_REGION_BASE(pAST->PciInfo, 2, REGION_IO) - 0x380;
691N/A+#endif
691N/A
691N/A pAST->RelocateIO = (IOADDRESS)(PCI_REGION_BASE(pAST->PciInfo, 2, REGION_IO) + pAST->IODBase);
691N/A
1265N/A@@ -757,7 +806,9 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
691N/A {
691N/A ScrnInfoPtr pScrn;
691N/A ASTRecPtr pAST;
1265N/A+#if (!defined(__sparc__))
1265N/A vgaHWPtr hwp;
1265N/A+#endif
691N/A VisualPtr visual;
691N/A
691N/A /* for FB Manager */
1265N/A@@ -766,7 +817,9 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
691N/A
691N/A pScrn = xf86Screens[pScreen->myNum];
691N/A pAST = ASTPTR(pScrn);
1265N/A+#if (!defined(__sparc__))
1265N/A hwp = VGAHWPTR(pScrn);
1265N/A+#endif
691N/A
705N/A if (!ASTMapMem(pScrn)) {
705N/A xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map FB Memory Failed \n");
1265N/A@@ -795,7 +848,9 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
691N/A
691N/A }
705N/A
691N/A+#if (!defined(__sparc__))
1265N/A vgaHWGetIOBase(hwp);
691N/A+#endif
705N/A
691N/A vFillASTModeInfo (pScrn);
691N/A
1265N/A@@ -836,6 +891,10 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
691N/A
691N/A }
691N/A
691N/A+#if (defined(__sparc__))
691N/A+ ASTNotifyModeChanged(pScrn);
691N/A+#endif
691N/A+
691N/A if (pScrn->bitsPerPixel > 8) {
691N/A /* Fixup RGB ordering */
691N/A visual = pScreen->visuals + pScreen->numVisuals;
1265N/A@@ -999,7 +1058,9 @@ ASTLeaveVT(int scrnIndex, int flags)
691N/A
691N/A ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
691N/A ASTRecPtr pAST = ASTPTR(pScrn);
1265N/A+#if (!defined(__sparc__))
1265N/A vgaHWPtr hwp = VGAHWPTR(pScrn);
691N/A+#endif
691N/A
691N/A #ifdef HWC
691N/A if (pAST->pHWCPtr) {
1265N/A@@ -1022,7 +1083,9 @@ ASTLeaveVT(int scrnIndex, int flags)
1265N/A if (pAST->jChipType == AST1180)
1265N/A ASTBlankScreen(pScrn, 0);
1265N/A
1265N/A+#if (!defined(__sparc__))
691N/A vgaHWLock(hwp);
691N/A+#endif
691N/A
691N/A }
691N/A
1265N/A@@ -1030,8 +1093,11 @@ static void
691N/A ASTFreeScreen(int scrnIndex, int flags)
691N/A {
691N/A ASTFreeRec(xf86Screens[scrnIndex]);
691N/A+
1265N/A+#if (!defined(__sparc__))
691N/A if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
691N/A vgaHWFreeHWRec(xf86Screens[scrnIndex]);
1265N/A+#endif
691N/A }
691N/A
1265N/A static ModeStatus
1265N/A@@ -1122,7 +1188,6 @@ ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
1265N/A return Flags;
1265N/A }
691N/A
691N/A-/* Internal used modules */
691N/A /*
691N/A * ASTGetRec and ASTFreeRec --
691N/A *
1265N/A@@ -1130,7 +1195,7 @@ ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
691N/A * These two functions create and destroy that private data.
691N/A *
691N/A */
691N/A-static Bool
691N/A+Bool
691N/A ASTGetRec(ScrnInfoPtr pScrn)
691N/A {
691N/A if (pScrn->driverPrivate)
1265N/A@@ -1140,6 +1205,8 @@ ASTGetRec(ScrnInfoPtr pScrn)
691N/A return TRUE;
691N/A }
691N/A
691N/A+/* Internal used modules */
691N/A+
691N/A static void
691N/A ASTFreeRec(ScrnInfoPtr pScrn)
691N/A {
1265N/A@@ -1171,7 +1238,9 @@ static Bool
691N/A ASTCloseScreen(int scrnIndex, ScreenPtr pScreen)
691N/A {
691N/A ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
1265N/A+#if (!defined(__sparc__))
999N/A vgaHWPtr hwp = VGAHWPTR(pScrn);
1265N/A+#endif
691N/A ASTRecPtr pAST = ASTPTR(pScrn);
691N/A
691N/A if (pScrn->vtSema == TRUE)
1265N/A@@ -1197,11 +1266,15 @@ ASTCloseScreen(int scrnIndex, ScreenPtr pScreen)
1265N/A if (pAST->jChipType == AST1180)
1265N/A ASTBlankScreen(pScrn, 0);
1265N/A
1265N/A+#if (!defined(__sparc__))
691N/A vgaHWLock(hwp);
1265N/A+#endif
691N/A }
691N/A
691N/A ASTUnmapMem(pScrn);
691N/A+#if (!defined(__sparc__))
691N/A vgaHWUnmapMem(pScrn);
691N/A+#endif
691N/A
691N/A if(pAST->AccelInfoPtr) {
691N/A XAADestroyInfoRec(pAST->AccelInfoPtr);
1265N/A@@ -1222,12 +1295,13 @@ static void
691N/A ASTSave(ScrnInfoPtr pScrn)
691N/A {
1265N/A ASTRecPtr pAST;
691N/A- vgaRegPtr vgaReg;
691N/A ASTRegPtr astReg;
691N/A int i, icount=0;
1265N/A ULONG ulData;
691N/A
1265N/A pAST = ASTPTR(pScrn);
691N/A+#if !defined(__sparc__)
691N/A+ vgaRegPtr vgaReg;
691N/A vgaReg = &VGAHWPTR(pScrn)->SavedReg;
691N/A astReg = &pAST->SavedReg;
705N/A
1265N/A@@ -1238,6 +1312,10 @@ ASTSave(ScrnInfoPtr pScrn)
691N/A else {
691N/A vgaHWSave(pScrn, vgaReg, VGA_SR_MODE);
691N/A }
691N/A+#else
691N/A+ astReg = &pAST->SavedReg;
691N/A+ ASTSaveHW(pScrn);
691N/A+#endif
691N/A
691N/A /* Ext. Save */
1265N/A if (pAST->jChipType == AST1180)
1265N/A@@ -1266,12 +1344,13 @@ static void
691N/A ASTRestore(ScrnInfoPtr pScrn)
691N/A {
1265N/A ASTRecPtr pAST;
691N/A- vgaRegPtr vgaReg;
691N/A ASTRegPtr astReg;
691N/A int i, icount=0;
1265N/A ULONG ulData;
691N/A
1265N/A pAST = ASTPTR(pScrn);
691N/A+#if !defined(__sparc__)
691N/A+ vgaRegPtr vgaReg;
691N/A vgaReg = &VGAHWPTR(pScrn)->SavedReg;
691N/A astReg = &pAST->SavedReg;
691N/A
1265N/A@@ -1303,18 +1382,21 @@ ASTRestore(ScrnInfoPtr pScrn)
1265N/A SetIndexReg(CRTC_PORT, (UCHAR) (i), astReg->ExtCRTC[icount++]);
1265N/A SetIndexReg(CRTC_PORT, (UCHAR) (0xBB), astReg->ExtCRTC[icount]);
1265N/A }
1265N/A-
1265N/A+#endif /* __sparc__ */
999N/A }
999N/A
691N/A static void
691N/A ASTProbeDDC(ScrnInfoPtr pScrn, int index)
691N/A {
1265N/A- vbeInfoPtr pVbe;
1265N/A ASTRecPtr pAST = ASTPTR(pScrn);
1265N/A unsigned char DDC_data[128];
1265N/A Bool Flags;
1265N/A
691N/A+#if defined(__sparc__)
1265N/A+ if (xf86LoadSubModule(pScrn, "ddc"))
1265N/A+#else
1265N/A if ( (pAST->jChipType == AST1180) || (!xf86IsPrimaryPci(pAST->PciInfo)) )
1265N/A+#endif
1265N/A {
1265N/A if (pAST->jChipType == AST1180)
1265N/A Flags = GetVGA2EDID(pScrn, DDC_data);
1265N/A@@ -1328,14 +1410,16 @@ ASTProbeDDC(ScrnInfoPtr pScrn, int index)
1265N/A else
1265N/A xf86DrvMsg(pScrn->scrnIndex, X_INFO,"[ASTProbeDDC] Can't Get EDID Properly \n");
1265N/A }
1265N/A+#if !defined(__sparc__)
1265N/A else
1265N/A {
1265N/A if (xf86LoadSubModule(pScrn, "vbe")) {
1265N/A- pVbe = VBEInit(NULL, index);
1265N/A+ vbeInfoPtr pVbe = VBEInit(NULL, index);
1265N/A ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
1265N/A vbeFree(pVbe);
1265N/A }
691N/A }
691N/A+#endif
691N/A }
691N/A
691N/A #define SkipDT 0x00
1265N/A@@ -1345,6 +1429,7 @@ ASTProbeDDC(ScrnInfoPtr pScrn, int index)
691N/A static xf86MonPtr
691N/A ASTDoDDC(ScrnInfoPtr pScrn, int index)
691N/A {
691N/A+#if !defined(__sparc__)
691N/A vbeInfoPtr pVbe;
1265N/A xf86MonPtr MonInfo = NULL, MonInfo1 = NULL, MonInfo2 = NULL;
1265N/A ASTRecPtr pAST = ASTPTR(pScrn);
1265N/A@@ -1539,6 +1624,30 @@ ASTDoDDC(ScrnInfoPtr pScrn, int index)
1265N/A }
691N/A
1265N/A } /* AST1180 */
1265N/A+#else /* __sparc__ */
691N/A+
691N/A+ xf86MonPtr MonInfo = NULL;
691N/A+ ASTRecPtr pAST = ASTPTR(pScrn);
691N/A+ unsigned char DDC_data[128];
691N/A+
691N/A+ /* Honour Option "noDDC" */
691N/A+ if (xf86ReturnOptValBool(pAST->Options, OPTION_NO_DDC, FALSE)) {
691N/A+ return MonInfo;
691N/A+ }
691N/A+
691N/A+ if ((xf86LoadSubModule(pScrn, "ddc")) && (GetVGAEDID(pScrn, DDC_data) == TRUE))
691N/A+ {
691N/A+ MonInfo = xf86InterpretEDID(pScrn->scrnIndex, DDC_data);
691N/A+
691N/A+ xf86PrintEDID(MonInfo);
691N/A+ xf86SetDDCproperties(pScrn, MonInfo);
691N/A+ }
691N/A+ else
691N/A+ {
691N/A+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,"[ASTDoDDC] Can't Load DDC Sub-Modules or Read EDID Failed \n");
691N/A+ }
691N/A+
691N/A+#endif
1265N/A
691N/A return MonInfo;
691N/A }
1265N/A@@ -1564,9 +1673,14 @@ ASTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
691N/A vgaHWPtr hwp;
691N/A ASTRecPtr pAST;
691N/A
691N/A- hwp = VGAHWPTR(pScrn);
691N/A pAST = ASTPTR(pScrn);
691N/A
691N/A+ pScrn->vtSema = TRUE;
691N/A+ pAST->ModePtr = mode;
1265N/A+
691N/A+#if !defined(__sparc__)
691N/A+ hwp = VGAHWPTR(pScrn);
691N/A+
691N/A vgaHWUnlock(hwp);
691N/A
691N/A if (!vgaHWInit(pScrn, mode))
1265N/A@@ -1579,6 +1693,10 @@ ASTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
691N/A return FALSE;
691N/A
691N/A vgaHWProtect(pScrn, FALSE);
691N/A+#else
691N/A+ if (!ASTSetMode(pScrn, mode))
1265N/A+ return FALSE;
691N/A+#endif
691N/A
691N/A return TRUE;
691N/A }
1265N/Adiff --git a/src/ast_mode.c b/src/ast_mode.c
1265N/Aindex b58916f..3ea5089 100644
1265N/A--- a/src/ast_mode.c
1265N/A+++ b/src/ast_mode.c
1265N/A@@ -798,6 +798,16 @@ void vSetExtReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAMod
691N/A SetIndexRegMask(CRTC_PORT,0xA3, 0xF0, (UCHAR) jRegA3);
691N/A SetIndexRegMask(CRTC_PORT,0xA8, 0xFD, (UCHAR) jRegA8);
691N/A
691N/A+#if defined(__sparc__)
1265N/A+ UCHAR jRegA2 = 0x00;
1265N/A+
691N/A+ if ((pScrn->bitsPerPixel == 15) || (pScrn->bitsPerPixel == 16) )
691N/A+ jRegA2 |= 0xC0;
691N/A+ else if (pScrn->bitsPerPixel == 32)
691N/A+ jRegA2 |= 0x80;
691N/A+ SetIndexRegMask(CRTC_PORT,0xA2, 0x3F, (UCHAR) jRegA2);
691N/A+#endif
691N/A+
691N/A /* Set Threshold */
999N/A if (pAST->jChipType == AST2300)
691N/A {
1265N/Adiff --git a/src/ast_tool.c b/src/ast_tool.c
1265N/Aindex 1dd87f0..7d9ed0d 100644
1265N/A--- a/src/ast_tool.c
1265N/A+++ b/src/ast_tool.c
999N/A@@ -60,16 +60,29 @@ Bool ASTUnmapMem(ScrnInfoPtr pScrn);
691N/A Bool ASTMapMMIO(ScrnInfoPtr pScrn);
691N/A void ASTUnmapMMIO(ScrnInfoPtr pScrn);
691N/A
691N/A+#if defined(__sparc__)
691N/A+extern pointer ASTMapVidMem(ScrnInfoPtr, unsigned int, PCITAG,
691N/A+ unsigned long, unsigned long);
691N/A+extern void ASTUnmapVidMem(ScrnInfoPtr, pointer, unsigned long);
691N/A+#endif /* __sparc__ */
691N/A+
691N/A+
691N/A Bool
691N/A ASTMapMem(ScrnInfoPtr pScrn)
691N/A {
691N/A ASTRecPtr pAST = ASTPTR(pScrn);
691N/A
691N/A-#ifndef XSERVER_LIBPCIACCESS
691N/A+#if !defined(XSERVER_LIBPCIACCESS) || defined(__sparc__)
691N/A+#if !defined(__sparc__)
691N/A pAST->FBVirtualAddr = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
691N/A pAST->PciTag,
691N/A pAST->FBPhysAddr, pAST->FbMapSize);
691N/A #else
691N/A+ pAST->FBVirtualAddr = ASTMapVidMem(pScrn, VIDMEM_FRAMEBUFFER, NULL,
691N/A+ pAST->FBPhysAddr, pAST->FbMapSize);
691N/A+#endif /* sparc */
691N/A+
691N/A+#else
691N/A {
691N/A void** result = (void**)&pAST->FBVirtualAddr;
691N/A int err = pci_device_map_range(pAST->PciInfo,
999N/A@@ -95,10 +108,14 @@ ASTUnmapMem(ScrnInfoPtr pScrn)
691N/A {
691N/A ASTRecPtr pAST = ASTPTR(pScrn);
691N/A
691N/A-#ifndef XSERVER_LIBPCIACCESS
691N/A+#if !defined(XSERVER_LIBPCIACCESS) || defined(__sparc__)
691N/A+#if !defined(__sparc__)
691N/A xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pAST->FBVirtualAddr,
691N/A pAST->FbMapSize);
691N/A #else
1265N/A+ ASTUnmapVidMem(pScrn, (pointer)pAST->FBVirtualAddr, pAST->FbMapSize);
691N/A+#endif
691N/A+#else
691N/A pci_device_unmap_range(pAST->PciInfo, pAST->FBVirtualAddr, pAST->FbMapSize);
691N/A #endif
691N/A
999N/A@@ -111,7 +128,7 @@ Bool
691N/A ASTMapMMIO(ScrnInfoPtr pScrn)
691N/A {
691N/A ASTRecPtr pAST = ASTPTR(pScrn);
691N/A-#ifndef XSERVER_LIBPCIACCESS
691N/A+#if !defined(XSERVER_LIBPCIACCESS) || defined(__sparc__)
691N/A int mmioFlags;
691N/A
691N/A #if !defined(__alpha__)
999N/A@@ -121,9 +138,15 @@ ASTMapMMIO(ScrnInfoPtr pScrn)
691N/A #endif
691N/A
705N/A
691N/A+#if !defined(__sparc__)
691N/A pAST->MMIOVirtualAddr = xf86MapPciMem(pScrn->scrnIndex, mmioFlags,
691N/A pAST->PciTag,
691N/A pAST->MMIOPhysAddr, pAST->MMIOMapSize);
691N/A+#else
691N/A+ pAST->MMIOVirtualAddr = ASTMapVidMem(pScrn,
691N/A+ VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, NULL,
691N/A+ pAST->MMIOPhysAddr, pAST->MMIOMapSize);
691N/A+#endif
691N/A
691N/A #else
691N/A {
999N/A@@ -150,10 +173,14 @@ ASTUnmapMMIO(ScrnInfoPtr pScrn)
691N/A {
691N/A ASTRecPtr pAST = ASTPTR(pScrn);
691N/A
691N/A-#ifndef XSERVER_LIBPCIACCESS
691N/A+#if !defined(XSERVER_LIBPCIACCESS) || defined(__sparc__)
691N/A+#if !defined(__sparc__)
691N/A xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pAST->MMIOVirtualAddr,
691N/A pAST->MMIOMapSize);
691N/A #else
691N/A+ ASTUnmapVidMem(pScrn, (pointer)pAST->MMIOVirtualAddr, pAST->MMIOMapSize);
691N/A+#endif
691N/A+#else
691N/A pci_device_unmap_range(pAST->PciInfo, pAST->MMIOVirtualAddr, pAST->MMIOMapSize);
691N/A #endif
691N/A pAST->MMIOVirtualAddr = 0;
1265N/Adiff --git a/src/ast_vgatool.c b/src/ast_vgatool.c
1265N/Aindex 4a90dd4..fa0722c 100644
1265N/A--- a/src/ast_vgatool.c
1265N/A+++ b/src/ast_vgatool.c
1265N/A@@ -95,6 +95,27 @@ bASTRegInit(ScrnInfoPtr pScrn)
691N/A /* Enable MMIO */
691N/A SetIndexRegMask(CRTC_PORT,0xA1, 0xFF, 0x04);
691N/A
691N/A+ /* Enable Big-Endian */
691N/A+#if defined(__sparc__)
1265N/A+ UCHAR jReg = 0x00;
1265N/A+
691N/A+ switch (pScrn->bitsPerPixel)
691N/A+ {
691N/A+ case 8:
691N/A+ jReg = 0x00;
691N/A+ break;
691N/A+ case 15:
691N/A+ case 16:
691N/A+ jReg = 0xC0;
691N/A+ break;
691N/A+ case 24:
691N/A+ case 32:
691N/A+ jReg = 0x80;
691N/A+ break;
691N/A+ }
691N/A+ SetIndexRegMask(CRTC_PORT,0xA2, 0x3F, jReg);
691N/A+#endif
691N/A+
691N/A return (TRUE);
691N/A
691N/A }
1265N/A@@ -445,6 +466,7 @@ vASTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
691N/A void
691N/A ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
691N/A {
1265N/A+#if !defined(__sparc__)
1265N/A ASTRecPtr pAST;
691N/A UCHAR SEQ01, CRB6;
1265N/A ULONG ulData, ulTemp;
1265N/A@@ -494,6 +516,7 @@ ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int fla
1265N/A SetIndexRegMask(SEQ_PORT,0x01, 0xDF, SEQ01);
1265N/A SetIndexRegMask(CRTC_PORT,0xB6, 0xFC, CRB6);
1265N/A }
691N/A+#endif
691N/A
691N/A }
999N/A
1265N/A@@ -985,7 +1008,7 @@ AST_DRAMStruct AST1100DRAMTableData[] = {
691N/A { 0x0030, 0x00000040 },
691N/A { 0x0028, 0x00000003 },
691N/A { 0x000C, 0x00005a21 },
691N/A- { 0x0034, 0x00007c03 },
691N/A+ { 0x0034, 0x00007c43 },
691N/A { 0x0120, 0x00004c41 },
691N/A { 0xffff, 0xffffffff },
691N/A };
1265N/A@@ -1038,7 +1061,7 @@ AST_DRAMStruct AST2100DRAMTableData[] = {
691N/A { 0x0030, 0x00000040 },
691N/A { 0x0028, 0x00000003 },
691N/A { 0x000C, 0x00005a21 },
691N/A- { 0x0034, 0x00007c03 },
691N/A+ { 0x0034, 0x00007c43 },
691N/A { 0x0120, 0x00005061 },
691N/A { 0xffff, 0xffffffff },
691N/A };
1265N/A@@ -2654,9 +2677,11 @@ Bool InitVGA(ScrnInfoPtr pScrn, ULONG Flags)
691N/A
999N/A {
999N/A /* Enable PCI */
999N/A+#if !defined(__sparc__)
999N/A PCI_READ_LONG(pAST->PciInfo, &ulData, 0x04);
999N/A ulData |= 0x03;
999N/A PCI_WRITE_LONG(pAST->PciInfo, ulData, 0x04);
999N/A+#endif
999N/A
999N/A /* Enable VGA */
999N/A vEnableVGA(pScrn);
1265N/Adiff --git a/src/ast_vgatool.h b/src/ast_vgatool.h
1265N/Aindex 53cb4c7..9f5fa50 100644
1265N/A--- a/src/ast_vgatool.h
1265N/A+++ b/src/ast_vgatool.h
691N/A@@ -20,6 +20,12 @@
691N/A * PERFORMANCE OF THIS SOFTWARE.
691N/A */
691N/A
691N/A+#ifndef ASTVGATOOL_H
691N/A+#define ASTVGATOOL_H
691N/A+
691N/A+#include <unistd.h>
691N/A+#include <stropts.h>
691N/A+
691N/A /* VRAM Size Definition */
691N/A #define VIDEOMEM_SIZE_08M 0x00800000
691N/A #define VIDEOMEM_SIZE_16M 0x01000000
1265N/A@@ -40,6 +46,95 @@
1265N/A #define DRAMTYPE_2Gx16 6
1265N/A #define DRAMTYPE_4Gx16 7
691N/A
691N/A+#if defined(__sparc__)
691N/A+
691N/A+#define SET_IO_REG 0x1000
691N/A+#define GET_IO_REG 0x1001
691N/A+
691N/A+#define AR_PORT_WRITE 0x40
691N/A+#define MISC_PORT_WRITE 0x42
691N/A+#define SEQ_PORT 0x44
691N/A+#define DAC_INDEX_READ 0x47
691N/A+#define DAC_INDEX_WRITE 0x48
691N/A+#define DAC_DATA 0x49
691N/A+#define GR_PORT 0x4E
691N/A+#define CRTC_PORT 0x54
691N/A+#define INPUT_STATUS1_READ 0x5A
691N/A+#define MISC_PORT_READ 0x4C
691N/A+
1265N/A+static inline uchar_t
1265N/A+_GetRegFromFd(uchar_t off, int fd)
1265N/A+{
1265N/A+ struct vis_io_reg io_reg = {
1265N/A+ .offset = off
1265N/A+ };
1265N/A+ ioctl(fd, VIS_GETIOREG, &io_reg);
1265N/A+ return io_reg.value;
1265N/A+}
1265N/A+
1265N/A+#define GetReg(off) _GetRegFromFd(off, pAST->fd)
691N/A+
1265N/A+#define SetReg(off, val) do { \
1265N/A+ struct vis_io_reg io_reg = { \
1265N/A+ .offset = off, \
1265N/A+ .value = val \
1265N/A+ }; \
1265N/A+ ioctl(pAST->fd, VIS_SETIOREG, &io_reg); \
1265N/A+ } while (0)
691N/A+
1265N/A+#define GetIndexReg(off, index, val) do { \
1265N/A+ struct vis_io_reg io_reg = { \
1265N/A+ .offset = off, \
1265N/A+ .value = index \
1265N/A+ }; \
1265N/A+ ioctl(pAST->fd, VIS_SETIOREG, &io_reg); \
691N/A+ io_reg.offset = off+1; \
1265N/A+ ioctl(pAST->fd, VIS_GETIOREG, &io_reg); \
691N/A+ val = io_reg.value; \
1265N/A+ } while (0)
691N/A+
1265N/A+#define SetIndexReg(off, index, val) do { \
1265N/A+ struct vis_io_reg io_reg = { \
1265N/A+ .offset = off, \
1265N/A+ .value = index \
1265N/A+ }; \
1265N/A+ ioctl(pAST->fd, VIS_SETIOREG, &io_reg); \
1265N/A+ io_reg.offset = off+1; \
691N/A+ io_reg.value = val; \
1265N/A+ ioctl(pAST->fd, VIS_SETIOREG, &io_reg); \
1265N/A+ } while (0)
691N/A+
1265N/A+#define GetIndexRegMask(off, index, and, val) do { \
1265N/A+ struct vis_io_reg io_reg = { \
1265N/A+ .offset = off, \
1265N/A+ .value = index \
1265N/A+ }; \
1265N/A+ ioctl(pAST->fd, VIS_SETIOREG, &io_reg); \
691N/A+ io_reg.offset = off+1; \
1265N/A+ ioctl(pAST->fd, VIS_GETIOREG, &io_reg); \
691N/A+ val = io_reg.value & and; \
1265N/A+ } while (0)
691N/A+
1265N/A+#define SetIndexRegMask(off, index, and, val) do { \
1265N/A+ UCHAR __Temp; \
1265N/A+ struct vis_io_reg io_reg = { \
1265N/A+ .offset = off, \
1265N/A+ .value = index \
1265N/A+ }; \
1265N/A+ ioctl(pAST->fd, VIS_SETIOREG, &io_reg); \
691N/A+ io_reg.offset = off + 1; \
1265N/A+ ioctl(pAST->fd, VIS_GETIOREG, &io_reg); \
691N/A+ __Temp = (io_reg.value & and) | val; \
691N/A+ io_reg.offset = off; \
691N/A+ io_reg.value = index; \
1265N/A+ ioctl(pAST->fd, VIS_SETIOREG, &io_reg); \
1265N/A+ io_reg.offset = off+1; \
691N/A+ io_reg.value = __Temp; \
1265N/A+ ioctl(pAST->fd, VIS_SETIOREG, &io_reg); \
1265N/A+ } while (0)
691N/A+
1265N/A+#else /* !__sparc__ */
691N/A+
691N/A #define AR_PORT_WRITE (pAST->RelocateIO + 0x40)
691N/A #define MISC_PORT_WRITE (pAST->RelocateIO + 0x42)
691N/A #define SEQ_PORT (pAST->RelocateIO + 0x44)
1265N/A@@ -71,6 +166,8 @@
691N/A SetIndexReg(base,index,__Temp); \
691N/A } while (0)
691N/A
1265N/A+#endif /* __sparc__ */
691N/A+
1265N/A #define VGA_GET_PALETTE_INDEX(index, red, green, blue) \
691N/A { \
691N/A UCHAR __junk; \
1265N/A@@ -162,3 +259,5 @@
1265N/A *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x1; \
1265N/A *(ULONG *) (pAST->MMIOVirtualAddr + 0x10000 + ((addr) & 0x0000FFFF)) = (data); \
691N/A }
691N/A+
691N/A+#endif /* ASTVGATOOL_H */
1265N/A--- a/src/ast_vgatool.c Wed Mar 28 14:37:44 2012
1265N/A+++ b/src/ast_vgatool.c Wed Mar 28 14:39:46 2012
1265N/A@@ -2974,9 +2974,11 @@
1265N/A pAST = ASTPTR(pScrn);
1265N/A
1265N/A /* Enable PCI */
1265N/A+#if !defined(__sparc__)
1265N/A PCI_READ_LONG(pAST->PciInfo, &ulData, 0x04);
1265N/A ulData |= 0x03;
1265N/A PCI_WRITE_LONG(pAST->PciInfo, ulData, 0x04);
1265N/A+#endif
1265N/A
1265N/A /* init DRAM if no F/W */
1265N/A /* TODO */