sparc.patch revision 1333
1265N/Adiff --git a/src/mga.h b/src/mga.h
1265N/Aindex 77406f1..25dcf53 100644
1265N/A--- a/src/mga.h
1265N/A+++ b/src/mga.h
1265N/A@@ -46,6 +46,10 @@
1265N/A #include "mga_dri.h"
1244N/A #endif
1244N/A
1244N/A+#ifdef __sparc__
1244N/A+#include <sys/visual_io.h>
1244N/A+#endif
1244N/A+
1244N/A typedef enum {
1244N/A OPTION_SW_CURSOR,
1244N/A OPTION_HW_CURSOR,
1265N/A@@ -200,6 +204,28 @@ void MGAdbg_outreg32(ScrnInfoPtr, int,int, char*);
1244N/A #define MGA_MODULE_DATA mgaModuleData
1244N/A #define MGA_DRIVER_NAME "mga"
1244N/A
1244N/A+#ifdef __sparc__
1244N/A+#ifndef VIS_GETPCICONFIG
1244N/A+
1244N/A+/*
1244N/A+ * These definitions will be removed when they are included in the
1244N/A+ * visual_io.h
1244N/A+ */
1244N/A+#define VIS_GETVIDEOMODENAME (VIOC | 12)
1244N/A+#define VIS_STOREVIDEOMODENAME (VIOC | 13)
1244N/A+#define VIS_MAX_VMODE_LEN 48
1244N/A+
1244N/A+typedef struct vis_video_mode {
1244N/A+ char mode_name[VIS_MAX_VMODE_LEN];
1244N/A+ uint32_t vRefresh;
1244N/A+ char pad[96];
1244N/A+} vis_video_mode_t;
1244N/A+
1244N/A+
1244N/A+#define VIS_GETPCICONFIG (VIOC | 14)
1244N/A+#endif
1244N/A+#endif
1244N/A+
1244N/A typedef struct {
1244N/A unsigned char ExtVga[6];
1244N/A unsigned char DacClk[6];
1265N/A@@ -667,6 +693,9 @@ typedef struct {
1244N/A if in merged mode */
1244N/A /* End of Merged Framebuffer Data */
1244N/A int HALGranularityOffX, HALGranularityOffY;
1244N/A+#ifdef __sparc__
1244N/A+ int fd;
1244N/A+#endif
1244N/A } MGARec, *MGAPtr;
1244N/A
1244N/A extern CARD32 MGAAtype[16];
1265N/Adiff --git a/src/mga_dacG.c b/src/mga_dacG.c
1265N/Aindex b489dea..e549f6c 100644
1265N/A--- a/src/mga_dacG.c
1265N/A+++ b/src/mga_dacG.c
1265N/A@@ -1711,11 +1711,35 @@ MGAGLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
1244N/A MGAPtr pMga = MGAPTR(pScrn);
1244N/A CARD32 *dst = (CARD32*)(pMga->FbBase + pMga->FbCursorOffset);
1244N/A int i = 128;
1244N/A-
1244N/A- /* swap bytes in each line */
1244N/A+#ifdef X_BYTE_ORDER != X_LITTLE_ENDIAN
1244N/A+ MGAFBLayout *pLayout = &pMga->CurrentLayout;
1244N/A+#endif
1244N/A+
1244N/A+ /*
1244N/A+ * HW cursor expects image that is both bytes and words swapped
1244N/A+ * see DAC Registers section of the manual
1244N/A+ */
1244N/A while( i-- ) {
1244N/A+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1244N/A+ /* swap bytes in each line, byte swap happens during explict byte shift */
1244N/A *dst++ = (src[4] << 24) | (src[5] << 16) | (src[6] << 8) | src[7];
1244N/A *dst++ = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];
1244N/A+#else
1244N/A+ if (pLayout->depth == 8) {
1244N/A+ /* byte swap happens during assembly of word, no explict byte shift */
1244N/A+ *dst++ = (src[7] << 24) | (src[6] << 16) | (src[5] << 8) | src[4];
1244N/A+ *dst++ = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0];
1244N/A+ } else if (pLayout->depth == 16) {
1244N/A+ /* byte swap happens during assembly of word, partial byte shift to
1244N/A+ offset effects from HW cursor's double bytes reading */
1244N/A+ *dst++ = (src[6] << 24) | (src[7] << 16) | (src[4] << 8) | src[5];
1244N/A+ *dst++ = (src[2] << 24) | (src[3] << 16) | (src[0] << 8) | src[1];
1244N/A+ } else {
1244N/A+ /* depth = 32. no byte swap needed, HW cursor's word reading does swap */
1244N/A+ *dst++ = ((CARD32 *)src)[1];
1244N/A+ *dst++ = ((CARD32 *)src)[0];
1244N/A+ }
1244N/A+#endif
1244N/A src += 8;
1244N/A }
1244N/A }
1265N/Adiff --git a/src/mga_driver.c b/src/mga_driver.c
1265N/Aindex af005f1..ae4a005 100644
1265N/A--- a/src/mga_driver.c
1265N/A+++ b/src/mga_driver.c
1265N/A@@ -107,6 +107,11 @@
1244N/A
1244N/A #include <unistd.h>
1244N/A
1244N/A+#ifdef __sparc__
1244N/A+#include <stdio.h>
1244N/A+#include <fcntl.h>
1244N/A+#endif
1244N/A+
1244N/A /*
1244N/A * Forward definitions for the functions that make up the driver.
1244N/A */
1265N/A@@ -156,6 +161,10 @@ static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
1244N/A static void MGABlockHandler(int, pointer, pointer, pointer);
1244N/A static void MGAG100BlackMagic(ScrnInfoPtr pScrn);
1244N/A
1244N/A+#ifdef __sparc__
1244N/A+static void MGANotifyModeChanged(ScrnInfoPtr pScrn);
1244N/A+#endif
1244N/A+
1244N/A static int MGAEntityIndex = -1;
1244N/A
1244N/A #include "mga_merge.h"
1265N/A@@ -455,6 +464,15 @@ static const struct pci_id_match mga_device_match[] = {
1244N/A
1244N/A { 0, 0, 0 },
1244N/A };
1244N/A+
1244N/A+#ifdef __sparc__
1244N/A+/* mimic pci_device_private struct so that define of DEV_PATH becomes valid */
1244N/A+static struct mga_device_private {
1244N/A+ struct pci_device base;
1244N/A+ const char * device_string;
1244N/A+};
1244N/A+#define DEV_PATH(dev) (((struct mga_device_private *) (dev))->device_string)
1265N/A+#endif
1244N/A #endif
1244N/A
1244N/A /* Supported chipsets */
1265N/A@@ -1296,9 +1314,11 @@ MGAdoDDC(ScrnInfoPtr pScrn)
1244N/A
1244N/A /* Map the VGA memory when the primary video */
1244N/A if (pMga->Primary) {
1244N/A+#if !defined(__sparc__)
1244N/A hwp->MapSize = 0x10000;
1244N/A if (!vgaHWMapMem(pScrn))
1244N/A return NULL;
1244N/A+#endif
1244N/A } else {
1244N/A /* XXX Need to write an MGA mode ddc1SetSpeed */
1244N/A if (pMga->DDC1SetSpeed == vgaHWddc1SetSpeedWeak()) {
1265N/A@@ -1341,6 +1361,7 @@ MGAdoDDC(ScrnInfoPtr pScrn)
1244N/A pMga->ddc1Read ) ;
1244N/A from = "DDC1";
1244N/A }
1244N/A+#if !defined(__sparc__)
1244N/A if (!MonInfo){
1244N/A vbeInfoPtr pVbe;
1244N/A if (xf86LoadSubModule(pScrn, "vbe")) {
1265N/A@@ -1350,6 +1371,7 @@ MGAdoDDC(ScrnInfoPtr pScrn)
1244N/A from = "VBE";
1244N/A }
1244N/A }
1244N/A+#endif
1244N/A }
1244N/A
1244N/A if (MonInfo) {
1265N/A@@ -1571,6 +1593,20 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
1244N/A pMga->PciInfo = xf86GetPciInfoForEntity(pMga->pEnt->index);
1244N/A pMga->PciTag = pciTag(pMga->PciInfo->bus, pMga->PciInfo->device,
1244N/A pMga->PciInfo->func);
1244N/A+#else
1244N/A+#ifdef __sparc__
1244N/A+ {
1244N/A+ char dev[128];
1244N/A+ if (DEV_PATH(pMga->PciInfo))
1244N/A+ snprintf(dev, sizeof (dev), "%s%s", "/devices",
1244N/A+ DEV_PATH(pMga->PciInfo));
1244N/A+ else
1244N/A+ strcpy (dev, "/dev/fb0");
1244N/A+
1244N/A+ if ((pMga->fd = open(dev, O_RDWR)) < 0)
1244N/A+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot open device %s\n", dev);
1244N/A+ }
1265N/A+#endif
1244N/A #endif
1244N/A
1244N/A pMga->Primary = xf86IsPrimaryPci(pMga->PciInfo);
1265N/A@@ -1922,7 +1958,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
1244N/A xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Enabling KVM\n");
1244N/A }
1244N/A
1244N/A-#if !defined(__powerpc__)
1244N/A+#if (!defined(__powerpc__) && !defined(__sparc__))
1244N/A pMga->softbooted = FALSE;
1244N/A Default = (pMga->chip_attribs->dual_head_possible
1244N/A && !pMga->Primary && !pMga->SecondCrtc);
1265N/A@@ -2838,7 +2874,11 @@ MGASave(ScrnInfoPtr pScrn)
1244N/A /* Could call it dac2Saved */
1244N/A
1244N/A /* Only save text mode fonts/text for the primary card */
1244N/A+#ifdef __sparc__
1244N/A+ (*pMga->Save)(pScrn, vgaReg, mgaReg, FALSE);
1244N/A+#else
1244N/A (*pMga->Save)(pScrn, vgaReg, mgaReg, pMga->Primary);
1244N/A+#endif
1244N/A }
1244N/A
1265N/A /*
1265N/A@@ -2996,6 +3036,10 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
1244N/A #ifdef DEBUG
1244N/A MGAG450PrintPLL(pScrn);
1244N/A #endif
1244N/A+
1244N/A+#ifdef __sparc__
1244N/A+ MGANotifyModeChanged(pScrn);
1244N/A+#endif
1244N/A return TRUE;
1244N/A }
1244N/A
1265N/A@@ -3085,7 +3129,11 @@ MGARestore(ScrnInfoPtr pScrn)
1265N/A vgaHWProtect(pScrn, TRUE);
1265N/A }
1265N/A if (pMga->Primary) {
1244N/A+#ifdef __sparc__
1265N/A+ (*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE);
1244N/A+#else
1244N/A (*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE);
1244N/A+#endif
1244N/A } else {
1244N/A vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
1244N/A }
1265N/A@@ -3215,9 +3263,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
1244N/A /* Map the VGA memory when the primary video */
1244N/A if (!pMga->FBDev) {
1244N/A if (pMga->Primary) {
1244N/A+#if !defined(__sparc__)
1244N/A hwp->MapSize = 0x10000;
1244N/A if (!vgaHWMapMem(pScrn))
1244N/A return FALSE;
1244N/A+#endif
1244N/A }
1244N/A
1244N/A /* Save the current state */
1265N/A@@ -3473,6 +3523,10 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
1244N/A
1244N/A MGAInitVideo(pScreen);
1244N/A
1244N/A+#ifdef __sparc__
1244N/A+ MGANotifyModeChanged(pScrn);
1244N/A+#endif
1244N/A+
1265N/A #ifdef MGADRI
1244N/A if (pMga->directRenderingEnabled) {
1244N/A /* Now that mi, drm and others have done their thing,
1265N/A@@ -3792,6 +3846,13 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
1265N/A free(pMga->portPrivate);
1265N/A free(pMga->ScratchBuffer);
1244N/A
1244N/A+#ifdef __sparc__
1265N/A+ MGANotifyModeChanged(pScrn);
1265N/A+
1244N/A+ if (pMga->fd)
1244N/A+ close(pMga->fd);
1244N/A+#endif
1244N/A+
1244N/A pScrn->vtSema = FALSE;
1244N/A
1265N/A xf86ClearPrimInitDone(pScrn->entityList[0]);
1265N/Adiff --git a/src/mga_storm.c b/src/mga_storm.c
1265N/Aindex 96bb6b9..57fdba5 100644
1265N/A--- a/src/mga_storm.c
1265N/A+++ b/src/mga_storm.c
1329N/A@@ -97,6 +97,7 @@
1329N/A static void mgaSubsequentSolidTwoPointLine( ScrnInfoPtr pScrn, int x1, int y1,
1329N/A int x2, int y2, int flags );
1329N/A
1329N/A+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A static void mgaSetupForMono8x8PatternFill( ScrnInfoPtr pScrn,
1329N/A int patx, int paty, int fg, int bg, int rop, unsigned int planemask );
1329N/A
1329N/A@@ -109,6 +110,7 @@
1329N/A static void mgaSubsequentMono8x8PatternFillTrap( ScrnInfoPtr pScrn,
1329N/A int patx, int paty, int y, int h, int left, int dxL, int dyL, int eL,
1329N/A int right, int dxR, int dyR, int eR );
1329N/A+#endif
1329N/A
1329N/A static void mgaSetupForScanlineImageWrite( ScrnInfoPtr pScrn, int rop,
1329N/A unsigned int planemask, int transparency_color, int bpp, int depth );
1329N/A@@ -148,10 +150,12 @@
1329N/A static void MGAFillSolidSpansDMA(ScrnInfoPtr pScrn, int fg, int rop,
1329N/A unsigned int planemask, int n, DDXPointPtr ppt,
1329N/A int *pwidth, int fSorted);
1329N/A+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A static void MGAFillMono8x8PatternRectsTwoPass(ScrnInfoPtr pScrn, int fg, int bg,
1329N/A int rop, unsigned int planemask, int nBox,
1329N/A BoxPtr pBox, int pattern0, int pattern1,
1329N/A int xorigin, int yorigin);
1329N/A+#endif
1329N/A static void MGAValidatePolyArc(GCPtr, unsigned long, DrawablePtr);
1329N/A static void MGAValidatePolyPoint(GCPtr, unsigned long, DrawablePtr);
1329N/A static void MGAFillCacheBltRects(ScrnInfoPtr, int, unsigned int, int, BoxPtr,
1329N/A@@ -623,7 +627,9 @@
1329N/A /* fill out infoPtr here */
1329N/A infoPtr->Flags = PIXMAP_CACHE |
1329N/A OFFSCREEN_PIXMAPS |
1329N/A+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A LINEAR_FRAMEBUFFER |
1329N/A+#endif
1329N/A MICROSOFT_ZERO_LINE_BIAS;
1329N/A
1329N/A /* sync */
1329N/A@@ -652,18 +658,20 @@
1329N/A /* clipping */
1329N/A infoPtr->SetClippingRectangle = MGASetClippingRectangle;
1329N/A infoPtr->DisableClipping = MGADisableClipping;
1329N/A+#if X_BYTE_ORDER == X_BIG_ENDIAN
1329N/A infoPtr->ClippingFlags = HARDWARE_CLIP_SOLID_LINE |
1329N/A+ HARDWARE_CLIP_SOLID_FILL;
1329N/A+#else
1329N/A+ infoPtr->ClippingFlags = HARDWARE_CLIP_SOLID_LINE |
1329N/A HARDWARE_CLIP_DASHED_LINE |
1329N/A HARDWARE_CLIP_SOLID_FILL |
1329N/A HARDWARE_CLIP_MONO_8x8_FILL;
1329N/A
1329N/A-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A /* dashed lines */
1329N/A infoPtr->DashedLineFlags = LINE_PATTERN_MSBFIRST_LSBJUSTIFIED;
1329N/A infoPtr->SetupForDashedLine = mgaSetupForDashedLine;
1329N/A infoPtr->SubsequentDashedTwoPointLine = mgaSubsequentDashedTwoPointLine;
1329N/A infoPtr->DashPatternMaxLength = 128;
1329N/A-#endif
1329N/A
1329N/A /* 8x8 mono patterns */
1329N/A infoPtr->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_BITS |
1329N/A@@ -675,6 +683,7 @@
1329N/A mgaSubsequentMono8x8PatternFillRect;
1329N/A infoPtr->SubsequentMono8x8PatternFillTrap =
1329N/A mgaSubsequentMono8x8PatternFillTrap;
1329N/A+#endif
1329N/A
1329N/A /* cpu to screen color expansion */
1329N/A infoPtr->ScanlineCPUToScreenColorExpandFillFlags =
1329N/A@@ -748,11 +757,13 @@
1329N/A infoPtr->FillSolidSpans = MGAFillSolidSpansDMA;
1329N/A }
1329N/A
1329N/A+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A if(pMga->AccelFlags & TWO_PASS_COLOR_EXPAND) {
1329N/A if(infoPtr->SetupForMono8x8PatternFill)
1329N/A infoPtr->FillMono8x8PatternRects =
1329N/A MGAFillMono8x8PatternRectsTwoPass;
1329N/A }
1329N/A+#endif
1329N/A
1329N/A if(infoPtr->SetupForSolidFill) {
1329N/A infoPtr->ValidatePolyArc = MGAValidatePolyArc;
1329N/A@@ -769,12 +780,14 @@
1329N/A infoPtr->SolidLineFlags |= NO_PLANEMASK;
1329N/A #if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A infoPtr->DashedLineFlags |= NO_PLANEMASK;
1329N/A-#endif
1329N/A infoPtr->Mono8x8PatternFillFlags |= NO_PLANEMASK;
1329N/A+#endif
1329N/A infoPtr->ScreenToScreenColorExpandFillFlags |= NO_PLANEMASK;
1329N/A infoPtr->FillSolidRectsFlags |= NO_PLANEMASK;
1329N/A infoPtr->FillSolidSpansFlags |= NO_PLANEMASK;
1329N/A+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A infoPtr->FillMono8x8PatternRectsFlags |= NO_PLANEMASK;
1329N/A+#endif
1329N/A infoPtr->FillCacheBltRectsFlags |= NO_PLANEMASK;
1329N/A }
1329N/A
1329N/A@@ -989,7 +1002,12 @@
1244N/A #if X_BYTE_ORDER == X_LITTLE_ENDIAN
1244N/A OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT );
1244N/A #else
1244N/A- OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | 0x10000);
1244N/A+ if (pLayout->depth == 8)
1244N/A+ OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT);
1244N/A+ else if (pLayout->depth == 16)
1244N/A+ OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | 0x10000);
1244N/A+ else
1244N/A+ OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | 0x20000);
1244N/A #endif
1244N/A OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */
1244N/A OUTREG(MGAREG_YTOP, 0x00000000); /* minPixelPointer */
1329N/A@@ -1077,9 +1095,9 @@
1244N/A maccess |= (1 << 31);
1244N/A }
1244N/A
1244N/A- opmode |= opmode_table[ pLayout->bitsPerPixel / 8 ];
1244N/A-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1244N/A opmode &= ~0x30000;
1244N/A+#if X_BYTE_ORDER == X_BIG_ENDIAN
1244N/A+ opmode |= opmode_table[ pLayout->bitsPerPixel / 8 ];
1244N/A #endif
1244N/A
1244N/A pMga->SetupForSolidFill = mgaSetupForSolidFill;
1329N/A@@ -1601,6 +1619,7 @@
1329N/A OUTREG(MGAREG_DWGCTL, pMga->FilledRectCMD);
1329N/A }
1329N/A
1329N/A+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A
1329N/A /***************************\
1329N/A | 8x8 Mono Pattern Fills |
1329N/A@@ -1689,6 +1708,7 @@
1329N/A OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (y << 16) | h);
1329N/A OUTREG(MGAREG_DWGCTL, pMga->PatternRectCMD);
1329N/A }
1329N/A+#endif /* X_BYTE_ORDER == X_LITTLE_ENDIAN */
1329N/A
1329N/A /***********************\
1329N/A | Color Expand Rect |
1329N/A@@ -2280,6 +2300,8 @@
1329N/A }
1329N/A
1329N/A
1329N/A+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
1329N/A+
1329N/A static void
1329N/A MGAFillMono8x8PatternRectsTwoPass(
1329N/A ScrnInfoPtr pScrn,
1329N/A@@ -2331,6 +2353,7 @@
1329N/A
1329N/A SET_SYNC_FLAG(infoRec);
1329N/A }
1329N/A+#endif /* X_BYTE_ORDER == X_LITTLE_ENDIAN */
1329N/A
1329N/A
1329N/A static void
1333N/A--- a/src/mga_driver.c Thu Oct 18 14:08:08 2012
1333N/A+++ b/src/mga_driver.c Thu Oct 18 14:11:07 2012
1333N/A@@ -2890,6 +2890,25 @@
1333N/A #endif
1333N/A }
1333N/A
1333N/A+#ifdef __sparc__
1333N/A+static void
1333N/A+MGANotifyModeChanged(ScrnInfoPtr pScrn)
1333N/A+{
1333N/A+ struct vis_video_mode mode;
1333N/A+ MGAPtr pMga = MGAPTR(pScrn);
1333N/A+
1333N/A+ if (pScrn->currentMode->name != NULL) {
1333N/A+ strlcpy(mode.mode_name, pScrn->currentMode->name, VIS_MAX_VMODE_LEN);
1333N/A+ } else {
1333N/A+ strlcpy(mode.mode_name, " ", VIS_MAX_VMODE_LEN);
1333N/A+ }
1333N/A+ mode.vRefresh = pScrn->currentMode->VRefresh;
1333N/A+
1333N/A+ ioctl(pMga->fd, VIS_STOREVIDEOMODENAME, &mode);
1333N/A+
1333N/A+}
1333N/A+#endif
1333N/A+
1333N/A /*
1333N/A * Initialise a new mode. This is currently still using the old
1333N/A * "initialise struct, restore/write struct to HW" model. That could