sparc.patch revision 1244
diff -ur old/src/mga.h new/src/mga.h
--- src/mga.h Wed Jan 4 18:11:17 2012
+++ src/mga.h Wed Jan 4 18:12:40 2012
@@ -47,6 +47,10 @@
#include "client.h"
#endif
+#ifdef __sparc__
+#include <sys/visual_io.h>
+#endif
+
typedef enum {
OPTION_SW_CURSOR,
OPTION_HW_CURSOR,
@@ -201,6 +205,28 @@
#define MGA_MODULE_DATA mgaModuleData
#define MGA_DRIVER_NAME "mga"
+#ifdef __sparc__
+#ifndef VIS_GETPCICONFIG
+
+/*
+ * These definitions will be removed when they are included in the
+ * visual_io.h
+ */
+#define VIS_GETVIDEOMODENAME (VIOC | 12)
+#define VIS_STOREVIDEOMODENAME (VIOC | 13)
+#define VIS_MAX_VMODE_LEN 48
+
+typedef struct vis_video_mode {
+ char mode_name[VIS_MAX_VMODE_LEN];
+ uint32_t vRefresh;
+ char pad[96];
+} vis_video_mode_t;
+
+
+#define VIS_GETPCICONFIG (VIOC | 14)
+#endif
+#endif
+
typedef struct {
unsigned char ExtVga[6];
unsigned char DacClk[6];
@@ -682,6 +708,9 @@
if in merged mode */
/* End of Merged Framebuffer Data */
int HALGranularityOffX, HALGranularityOffY;
+#ifdef __sparc__
+ int fd;
+#endif
} MGARec, *MGAPtr;
extern CARD32 MGAAtype[16];
diff -ur old/src/mga_dacG.c new/src/mga_dacG.c
--- src/mga_dacG.c Wed Jan 4 18:11:17 2012
+++ src/mga_dacG.c Thu Jan 19 11:54:04 2012
@@ -1753,11 +1753,35 @@
MGAPtr pMga = MGAPTR(pScrn);
CARD32 *dst = (CARD32*)(pMga->FbBase + pMga->FbCursorOffset);
int i = 128;
-
- /* swap bytes in each line */
+#ifdef X_BYTE_ORDER != X_LITTLE_ENDIAN
+ MGAFBLayout *pLayout = &pMga->CurrentLayout;
+#endif
+
+ /*
+ * HW cursor expects image that is both bytes and words swapped
+ * see DAC Registers section of the manual
+ */
while( i-- ) {
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ /* swap bytes in each line, byte swap happens during explict byte shift */
*dst++ = (src[4] << 24) | (src[5] << 16) | (src[6] << 8) | src[7];
*dst++ = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3];
+#else
+ if (pLayout->depth == 8) {
+ /* byte swap happens during assembly of word, no explict byte shift */
+ *dst++ = (src[7] << 24) | (src[6] << 16) | (src[5] << 8) | src[4];
+ *dst++ = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0];
+ } else if (pLayout->depth == 16) {
+ /* byte swap happens during assembly of word, partial byte shift to
+ offset effects from HW cursor's double bytes reading */
+ *dst++ = (src[6] << 24) | (src[7] << 16) | (src[4] << 8) | src[5];
+ *dst++ = (src[2] << 24) | (src[3] << 16) | (src[0] << 8) | src[1];
+ } else {
+ /* depth = 32. no byte swap needed, HW cursor's word reading does swap */
+ *dst++ = ((CARD32 *)src)[1];
+ *dst++ = ((CARD32 *)src)[0];
+ }
+#endif
src += 8;
}
}
diff -ur old/src/mga_driver.c new/src/mga_driver.c
--- src/mga_driver.c Wed Jan 4 18:11:17 2012
+++ src/mga_driver.c Wed Jan 11 12:45:12 2012
@@ -104,6 +104,11 @@
#include <unistd.h>
+#ifdef __sparc__
+#include <stdio.h>
+#include <fcntl.h>
+#endif
+
/*
* Forward definitions for the functions that make up the driver.
*/
@@ -153,6 +158,10 @@
static void MGABlockHandler(int, pointer, pointer, pointer);
static void MGAG100BlackMagic(ScrnInfoPtr pScrn);
+#ifdef __sparc__
+static void MGANotifyModeChanged(ScrnInfoPtr pScrn);
+#endif
+
static int MGAEntityIndex = -1;
#include "mga_merge.h"
@@ -452,7 +461,16 @@
{ 0, 0, 0 },
};
+
+#ifdef __sparc__
+/* mimic pci_device_private struct so that define of DEV_PATH becomes valid */
+static struct mga_device_private {
+ struct pci_device base;
+ const char * device_string;
+};
+#define DEV_PATH(dev) (((struct mga_device_private *) (dev))->device_string)
#endif
+#endif
/* Supported chipsets */
static SymTabRec MGAChipsets[] = {
@@ -1295,9 +1316,11 @@
/* Map the VGA memory when the primary video */
if (pMga->Primary) {
+#if !defined(__sparc__)
hwp->MapSize = 0x10000;
if (!vgaHWMapMem(pScrn))
return NULL;
+#endif
} else {
/* XXX Need to write an MGA mode ddc1SetSpeed */
if (pMga->DDC1SetSpeed == vgaHWddc1SetSpeedWeak()) {
@@ -1340,6 +1363,7 @@
pMga->ddc1Read ) ;
from = "DDC1";
}
+#if !defined(__sparc__)
if (!MonInfo){
vbeInfoPtr pVbe;
if (xf86LoadSubModule(pScrn, "vbe")) {
@@ -1349,6 +1373,7 @@
from = "VBE";
}
}
+#endif
}
if (MonInfo) {
@@ -1574,7 +1599,21 @@
pMga->PciInfo = xf86GetPciInfoForEntity(pMga->pEnt->index);
pMga->PciTag = pciTag(pMga->PciInfo->bus, pMga->PciInfo->device,
pMga->PciInfo->func);
+#else
+#ifdef __sparc__
+ {
+ char dev[128];
+ if (DEV_PATH(pMga->PciInfo))
+ snprintf(dev, sizeof (dev), "%s%s", "/devices",
+ DEV_PATH(pMga->PciInfo));
+ else
+ strcpy (dev, "/dev/fb0");
+
+ if ((pMga->fd = open(dev, O_RDWR)) < 0)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot open device %s\n", dev);
+ }
#endif
+#endif
pMga->Primary = xf86IsPrimaryPci(pMga->PciInfo);
@@ -1960,7 +1999,7 @@
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Enabling KVM\n");
}
-#if !defined(__powerpc__)
+#if (!defined(__powerpc__) && !defined(__sparc__))
pMga->softbooted = FALSE;
Default = (pMga->chip_attribs->dual_head_possible
&& !pMga->Primary && !pMga->SecondCrtc);
@@ -3012,7 +3051,11 @@
/* Could call it dac2Saved */
/* Only save text mode fonts/text for the primary card */
+#ifdef __sparc__
+ (*pMga->Save)(pScrn, vgaReg, mgaReg, FALSE);
+#else
(*pMga->Save)(pScrn, vgaReg, mgaReg, pMga->Primary);
+#endif
}
#ifdef USEMGAHAL
@@ -3370,6 +3413,10 @@
#ifdef DEBUG
MGAG450PrintPLL(pScrn);
#endif
+
+#ifdef __sparc__
+ MGANotifyModeChanged(pScrn);
+#endif
return TRUE;
}
@@ -3467,7 +3514,11 @@
}
); /* MGA_HAL */
#endif
+#ifdef __sparc__
+ (*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE);
+#else
(*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE);
+#endif
} else {
vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
}
@@ -3658,9 +3709,11 @@
/* Map the VGA memory when the primary video */
if (!pMga->FBDev) {
if (pMga->Primary) {
+#if !defined(__sparc__)
hwp->MapSize = 0x10000;
if (!vgaHWMapMem(pScrn))
return FALSE;
+#endif
}
/* Save the current state */
@@ -3916,6 +3969,10 @@
MGAInitVideo(pScreen);
+#ifdef __sparc__
+ MGANotifyModeChanged(pScrn);
+#endif
+
#ifdef XF86DRI
if (pMga->directRenderingEnabled) {
/* Now that mi, drm and others have done their thing,
@@ -4352,6 +4409,11 @@
if (pMga->ScratchBuffer)
xfree(pMga->ScratchBuffer);
+#ifdef __sparc__
+ if (pMga->fd)
+ close(pMga->fd);
+#endif
+
pScrn->vtSema = FALSE;
if (xf86IsPc98())
@@ -4757,3 +4819,21 @@
usleep(10);
}
+#ifdef __sparc__
+static void
+MGANotifyModeChanged(ScrnInfoPtr pScrn)
+{
+ struct vis_video_mode mode;
+ MGAPtr pMga = MGAPTR(pScrn);
+
+ if (pScrn->currentMode->name != NULL) {
+ strlcpy(mode.mode_name, pScrn->currentMode->name, VIS_MAX_VMODE_LEN);
+ } else {
+ strlcpy(mode.mode_name, " ", VIS_MAX_VMODE_LEN);
+ }
+ mode.vRefresh = pScrn->currentMode->VRefresh;
+
+ ioctl(pMga->fd, VIS_STOREVIDEOMODENAME, &mode);
+
+}
+#endif
diff -ur old/src/mga_storm.c new/src/mga_storm.c
--- src/mga_storm.c Wed Jan 4 18:11:17 2012
+++ src/mga_storm.c Wed Jan 11 12:41:33 2012
@@ -989,7 +989,12 @@
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT );
#else
- OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | 0x10000);
+ if (pLayout->depth == 8)
+ OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT);
+ else if (pLayout->depth == 16)
+ OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | 0x10000);
+ else
+ OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | 0x20000);
#endif
OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */
OUTREG(MGAREG_YTOP, 0x00000000); /* minPixelPointer */
@@ -1077,9 +1082,9 @@
maccess |= (1 << 31);
}
- opmode |= opmode_table[ pLayout->bitsPerPixel / 8 ];
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
opmode &= ~0x30000;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ opmode |= opmode_table[ pLayout->bitsPerPixel / 8 ];
#endif
pMga->SetupForSolidFill = mgaSetupForSolidFill;