summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2006-12-13 16:03:36 -0700
committerJordan Crouse <jordan.crouse@amd.com>2006-12-14 17:33:48 -0700
commita38f40687c00f35d2e6529c3cfb894ee29cdea66 (patch)
tree730bec5184acc5a42f06c3e2f02e547afd5c7082
parentedd326cc9ba5b9f46ca7a4516806a5b7fd3605f0 (diff)
Clean up whitespace and other code style issues
-rw-r--r--src/amd_gx_dcon.c159
-rw-r--r--src/amd_gx_driver.c2190
-rw-r--r--src/amd_gx_randr.c424
-rw-r--r--src/amd_gx_rotate.c199
4 files changed, 1494 insertions, 1478 deletions
diff --git a/src/amd_gx_dcon.c b/src/amd_gx_dcon.c
index 034f835..4bf4c8e 100644
--- a/src/amd_gx_dcon.c
+++ b/src/amd_gx_dcon.c
@@ -57,100 +57,117 @@ extern unsigned long gfx_gamma_ram_redcloud[];
embedded controller
*/
-static int eccmd(ScrnInfoPtr pScrni, unsigned char cmd) {
-
- unsigned char ret;
- int i;
-
- ret = inb(0x6c);
-
- if (ret & 1)
- ret = inb(0x68);
-
- /* Write the command */
- outb(0x6C, cmd);
-
- /* Wait for the 2 response */
- for(i = 0; i < 1000; i++) {
- ret = inb(0x6C);
- if ((ret & 3) == 1)
- break;
- }
-
- if (i == 100) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "Error waiting for the EC command (%x)\n", ret);
- ret = -1;
- goto eread;
- }
+static int
+eccmd(ScrnInfoPtr pScrni, unsigned char cmd)
+{
+
+ unsigned char ret;
+ int i;
- /* get the response */
+ ret = inb(0x6c);
+
+ if (ret & 1)
ret = inb(0x68);
- eread:
- /* Clear the "ownership flag" */
- outb(0x6C, 0xFF);
- return ret;
+ /* Write the command */
+ outb(0x6C, cmd);
+
+ /* Wait for the 2 response */
+ for (i = 0; i < 1000; i++) {
+ ret = inb(0x6C);
+ if ((ret & 3) == 1)
+ break;
+ }
+
+ if (i == 100) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Error waiting for the EC command (%x)\n", ret);
+ ret = -1;
+ goto eread;
+ }
+
+ /* get the response */
+ ret = inb(0x68);
+
+ eread:
+ /* Clear the "ownership flag" */
+ outb(0x6C, 0xFF);
+ return ret;
}
-static int boardrev(ScrnInfoPtr pScrni) {
- int i, ret;
+static int
+boardrev(ScrnInfoPtr pScrni)
+{
+ int i, ret;
- ret = eccmd(pScrni, 0x09);
+ ret = eccmd(pScrni, 0x09);
- if (ret == -1)
- return -1;
+ if (ret == -1)
+ return -1;
- return ret == TESTA_REVISION ? REV_TESTA : REV_TESTB;
+ return ret == TESTA_REVISION ? REV_TESTA : REV_TESTB;
}
#define RTC_BASE_PORT 0x70
#define RTC_PORT(x) (RTC_BASE_PORT + (x))
-static inline char cmos_read(unsigned char addr) {
- outb(RTC_PORT(0), addr);
- return inb(RTC_PORT(1));
+static inline char
+cmos_read(unsigned char addr)
+{
+ outb(RTC_PORT(0), addr);
+ return inb(RTC_PORT(1));
}
-static inline void cmos_write(unsigned char val, unsigned char addr) {
- outb(RTC_PORT(0), addr);
- outb(RTC_PORT(1), val);
+static inline void
+cmos_write(unsigned char val, unsigned char addr)
+{
+ outb(RTC_PORT(0), addr);
+ outb(RTC_PORT(1), val);
}
-
-static int dcon_avail(void) {
- return cmos_read(440 / 8) & 1;
+
+static int
+dcon_avail(void)
+{
+ return cmos_read(440 / 8) & 1;
}
-void gx_dcon_init(ScrnInfoPtr pScrni) {
+void
+gx_dcon_init(ScrnInfoPtr pScrni)
+{
- int rev = boardrev(pScrni);
- int i;
+ int rev = boardrev(pScrni);
+ int i;
- if (rev == -1) {
- xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT, "This is not an OLPC board\n");
- return;
- }
- if (dcon_avail() == 0) {
- xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT, "No DCON is present\n");
- return;
- }
+ if (rev == -1) {
+ xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT,
+ "This is not an OLPC board\n");
+ return;
+ }
+ if (dcon_avail() == 0) {
+ xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT, "No DCON is present\n");
+ return;
+ }
+
+ xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT, "OLPC board revision %s\n",
+ rev == REV_TESTB ? "testB" : "testA");
+ xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT, "DCON detected.\n");
+
+ /* FIXME: Panel setup should go here */
+ /* FIXME: Mode setup should go here */
+ /* FIXME: Controller setup should go here */
- xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT, "OLPC board revision %s\n", rev == REV_TESTB ? "testB" : "testA");
- xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT, "DCON detected.\n");
+ /* Update the Xv map on a rev-b board */
- /* FIXME: Panel setup should go here */
- /* FIXME: Mode setup should go here */
- /* FIXME: Controller setup should go here */
-
- /* Update the Xv map on a rev-b board */
+ if (rev == REV_TESTB) {
+ for (i = 0; i < 256; i++) {
+ unsigned char r, g, b;
- if (rev == REV_TESTB) {
- for(i = 0; i < 256; i++) {
- unsigned char r, g, b;
- r = (gfx_gamma_ram_redcloud[i] >> 16) & 0xFF;
- g = (gfx_gamma_ram_redcloud[i] >> 8) & 0xFF;
- b = gfx_gamma_ram_redcloud[i] & 0xFF;
+ r = (gfx_gamma_ram_redcloud[i] >> 16) & 0xFF;
+ g = (gfx_gamma_ram_redcloud[i] >> 8) & 0xFF;
+ b = gfx_gamma_ram_redcloud[i] & 0xFF;
- gfx_gamma_ram_redcloud[i] = ((r >> 2) << 16) | ((g >> 1) << 8) | (b >> 2);
- }
+ gfx_gamma_ram_redcloud[i] =
+ ((r >> 2) << 16) | ((g >> 1) << 8) | (b >> 2);
}
+ }
}
diff --git a/src/amd_gx_driver.c b/src/amd_gx_driver.c
index 13fedf7..aeda9ae 100644
--- a/src/amd_gx_driver.c
+++ b/src/amd_gx_driver.c
@@ -27,7 +27,6 @@
#include "config.h"
#endif
-
#include <stdio.h>
#include "xf86.h"
@@ -83,34 +82,36 @@ extern const char *amdRamdacSymbols[];
unsigned char *XpressROMPtr;
const char *gxShadowSymbols[] = {
- "ShadowInit",
- "ShadowSetup",
- "ShadowAdd",
- NULL
+ "ShadowInit",
+ "ShadowSetup",
+ "ShadowAdd",
+ NULL
};
static inline void
gx_enable_dac_power(void)
{
- gfx_write_vid32(RCDF_VID_MISC,
- gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH);
+ gfx_write_vid32(RCDF_VID_MISC,
+ gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH);
}
static inline void
gx_disable_dac_power(void)
{
- gfx_write_vid32(RCDF_VID_MISC,
- RCDF_DAC_POWER_DOWN | RCDF_ANALOG_POWER_DOWN |
- (gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH));
+ gfx_write_vid32(RCDF_VID_MISC,
+ RCDF_DAC_POWER_DOWN | RCDF_ANALOG_POWER_DOWN |
+ (gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH));
}
/* Parser for the flatpanel info */
static inline int
-GXGetFPInfo(const char *str, int *width, int *height) {
+GXGetFPInfo(const char *str, int *width, int *height)
+{
- int ret = sscanf(str, "%dx%d", width, height);
- return (ret == 2) ? 0 : 1;
+ int ret = sscanf(str, "%dx%d", width, height);
+
+ return (ret == 2) ? 0 : 1;
}
/* I borrowed this function from the i830 driver - its much better
@@ -118,276 +119,279 @@ GXGetFPInfo(const char *str, int *width, int *height) {
*/
static int
-GXGetRefreshRate(DisplayModePtr pMode)
+GXGetRefreshRate(DisplayModePtr pMode)
{
- if (pMode->VRefresh)
- return (int) (pMode->VRefresh + 0.5);
-
- return (int) (pMode->Clock * 1000.0 / pMode->HTotal / pMode->VTotal + 0.5);
+ if (pMode->VRefresh)
+ return (int)(pMode->VRefresh + 0.5);
+
+ return (int)(pMode->Clock * 1000.0 / pMode->HTotal / pMode->VTotal + 0.5);
}
static int
-GXCalculatePitchBytes(unsigned int width, unsigned int bpp) {
+GXCalculatePitchBytes(unsigned int width, unsigned int bpp)
+{
- int delta = width * (bpp >> 3);
+ int delta = width * (bpp >> 3);
- /* Less then 640 has doubling enabled */
+ /* Less then 640 has doubling enabled */
- if (width < 640)
- delta <<= 1;
+ if (width < 640)
+ delta <<= 1;
- /* Calculate the pitch (compression rquires a power of 2) */
+ /* Calculate the pitch (compression rquires a power of 2) */
- if (delta > 4096)
- delta = 8192;
- else if (delta > 2048)
- delta = 4096;
- else if (delta > 1024)
- delta = 2048;
- else
- delta = 1024;
+ if (delta > 4096)
+ delta = 8192;
+ else if (delta > 2048)
+ delta = 4096;
+ else if (delta > 1024)
+ delta = 2048;
+ else
+ delta = 1024;
- return delta;
+ return delta;
}
static void
GXFreeRec(ScrnInfoPtr pScrni)
{
- if (pScrni->driverPrivate != NULL) {
- xfree(pScrni->driverPrivate);
- pScrni->driverPrivate = NULL;
- }
+ if (pScrni->driverPrivate != NULL) {
+ xfree(pScrni->driverPrivate);
+ pScrni->driverPrivate = NULL;
+ }
}
static void
-GXInitEXAMemory(ScrnInfoPtr pScrni, unsigned int *offset, unsigned int *avail)
+GXInitEXAMemory(ScrnInfoPtr pScrni, unsigned int *offset, unsigned int *avail)
{
- GeodePtr pGeode = GEODEPTR(pScrni);
+ GeodePtr pGeode = GEODEPTR(pScrni);
- if (pGeode->exaBfrSz > 0 && pGeode->exaBfrSz <= *avail) {
- pGeode->exaBfrOffset = *offset;
- *offset += pGeode->exaBfrOffset;
- *avail -= pGeode->exaBfrOffset;
- }
+ if (pGeode->exaBfrSz > 0 && pGeode->exaBfrSz <= *avail) {
+ pGeode->exaBfrOffset = *offset;
+ *offset += pGeode->exaBfrOffset;
+ *avail -= pGeode->exaBfrOffset;
+ }
}
static void
-GXInitXAAMemory(ScrnInfoPtr pScrni, unsigned int *offset, unsigned int *avail)
+GXInitXAAMemory(ScrnInfoPtr pScrni, unsigned int *offset, unsigned int *avail)
{
- GeodePtr pGeode = GEODEPTR(pScrni);
- unsigned int size, i, pitch;
-
- /* XXX - FIXME - What if we are out of room? Then what? */
- /* For now, we NULL them all out. */
-
- if (pGeode->NoOfImgBuffers > 0) {
- size = pGeode->displayPitch * pGeode->NoOfImgBuffers;
- if (size <= *avail) {
- for(i = 0; i < pGeode->NoOfImgBuffers; i++) {
- pGeode->AccelImageWriteBuffers[i] = pGeode->FBBase + *offset;
- *offset += pGeode->displayPitch;
- *avail -= pGeode->displayPitch;
- }
- }
- else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for image write buffers.\n");
-
- for(i = 0; i < pGeode->NoOfImgBuffers; i++)
- pGeode->AccelImageWriteBuffers[i] = NULL;
- }
- }
-
- if (pGeode->NoOfColorExpandLines > 0) {
- pitch = ((pGeode->displayPitch + 31) >> 5) << 2;
- size = pitch * pGeode->NoOfColorExpandLines;
-
- if (size <= *avail) {
- for(i = 0; i < pGeode->NoOfColorExpandLines; i++) {
- pGeode->AccelColorExpandBuffers[i] = pGeode->FBBase + *offset;
- *offset += pitch;
- *avail -= pitch;
- }
+ GeodePtr pGeode = GEODEPTR(pScrni);
+ unsigned int size, i, pitch;
+
+ /* XXX - FIXME - What if we are out of room? Then what? */
+ /* For now, we NULL them all out. */
+
+ if (pGeode->NoOfImgBuffers > 0) {
+ size = pGeode->displayPitch * pGeode->NoOfImgBuffers;
+ if (size <= *avail) {
+ for (i = 0; i < pGeode->NoOfImgBuffers; i++) {
+ pGeode->AccelImageWriteBuffers[i] = pGeode->FBBase + *offset;
+ *offset += pGeode->displayPitch;
+ *avail -= pGeode->displayPitch;
+ }
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for image write buffers.\n");
+
+ for (i = 0; i < pGeode->NoOfImgBuffers; i++)
+ pGeode->AccelImageWriteBuffers[i] = NULL;
+ }
}
- else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for color expansion buffers.\n");
- for(i = 0; i < pGeode->NoOfImgBuffers; i++)
- pGeode->AccelColorExpandBuffers[i] = NULL;
+ if (pGeode->NoOfColorExpandLines > 0) {
+ pitch = ((pGeode->displayPitch + 31) >> 5) << 2;
+ size = pitch * pGeode->NoOfColorExpandLines;
+
+ if (size <= *avail) {
+ for (i = 0; i < pGeode->NoOfColorExpandLines; i++) {
+ pGeode->AccelColorExpandBuffers[i] = pGeode->FBBase + *offset;
+ *offset += pitch;
+ *avail -= pitch;
+ }
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for color expansion buffers.\n");
+
+ for (i = 0; i < pGeode->NoOfImgBuffers; i++)
+ pGeode->AccelColorExpandBuffers[i] = NULL;
+ }
}
- }
}
-static
-Bool GXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate) {
- GeodePtr pGeode = GEODEPTR(pScrni);
+static Bool
+GXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate)
+{
+ GeodePtr pGeode = GEODEPTR(pScrni);
- unsigned int fboffset, fbavail;
- unsigned int size;
- unsigned int bytpp = (pScrni->bitsPerPixel + 7) / 8;
- BOOL ret = TRUE;
+ unsigned int fboffset, fbavail;
+ unsigned int size;
+ unsigned int bytpp = (pScrni->bitsPerPixel + 7) / 8;
+ BOOL ret = TRUE;
- if (pGeode->tryCompression)
- pGeode->displayPitch = GXCalculatePitchBytes(pScrni->virtualX, pScrni->bitsPerPixel);
- else
- pGeode->displayPitch = ((pScrni->virtualX + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
+ if (pGeode->tryCompression)
+ pGeode->displayPitch =
+ GXCalculatePitchBytes(pScrni->virtualX, pScrni->bitsPerPixel);
+ else
+ pGeode->displayPitch =
+ ((pScrni->virtualX + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
- pGeode->Pitch = pGeode->displayPitch;
- pGeode->displayWidth = pGeode->displayPitch / bytpp;
- pScrni->displayWidth = pGeode->displayWidth;
+ pGeode->Pitch = pGeode->displayPitch;
+ pGeode->displayWidth = pGeode->displayPitch / bytpp;
+ pScrni->displayWidth = pGeode->displayWidth;
- fbavail = pGeode->FBAvail - 0x4000;
+ fbavail = pGeode->FBAvail - 0x4000;
- pGeode->displayOffset = fboffset = 0;
- pGeode->displaySize = pScrni->virtualY * pGeode->displayPitch;
+ pGeode->displayOffset = fboffset = 0;
+ pGeode->displaySize = pScrni->virtualY * pGeode->displayPitch;
- fbavail -= pGeode->displaySize;
- fboffset += pGeode->displaySize;
+ fbavail -= pGeode->displaySize;
+ fboffset += pGeode->displaySize;
- if (pGeode->tryCompression) {
- size = pScrni->virtualY * GX_CB_PITCH;
+ if (pGeode->tryCompression) {
+ size = pScrni->virtualY * GX_CB_PITCH;
- if (size <= fbavail) {
- pGeode->CBOffset = fboffset;
+ if (size <= fbavail) {
+ pGeode->CBOffset = fboffset;
- fboffset += size;
- fbavail -= size;
+ fboffset += size;
+ fbavail -= size;
- pGeode->Compression = TRUE;
- }
- else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for compression\n");
- pGeode->Compression = FALSE;
+ pGeode->Compression = TRUE;
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for compression\n");
+ pGeode->Compression = FALSE;
+ }
}
- }
- if (pGeode->tryHWCursor) {
- pGeode->CursorSize = 1024;
-
- if (pGeode->CursorSize <= fbavail) {
- pGeode->CursorStartOffset = fboffset;
- fboffset += pGeode->CursorSize;
- fbavail -= pGeode->CursorSize;
- pGeode->HWCursor = TRUE;
- }
- else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for the hardware cursor\n");
- pGeode->HWCursor = FALSE;
+ if (pGeode->tryHWCursor) {
+ pGeode->CursorSize = 1024;
+
+ if (pGeode->CursorSize <= fbavail) {
+ pGeode->CursorStartOffset = fboffset;
+ fboffset += pGeode->CursorSize;
+ fbavail -= pGeode->CursorSize;
+ pGeode->HWCursor = TRUE;
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for the hardware cursor\n");
+ pGeode->HWCursor = FALSE;
+ }
}
- }
- if (!pGeode->NoAccel) {
- if (pGeode->useEXA)
- GXInitEXAMemory(pScrni, &fboffset, &fbavail);
- else
- GXInitXAAMemory(pScrni, &fboffset, &fbavail);
- }
+ if (!pGeode->NoAccel) {
+ if (pGeode->useEXA)
+ GXInitEXAMemory(pScrni, &fboffset, &fbavail);
+ else
+ GXInitXAAMemory(pScrni, &fboffset, &fbavail);
+ }
- pGeode->shadowSize = 0;
+ pGeode->shadowSize = 0;
- if (rotate != RR_Rotate_0) {
- if (rotate & (RR_Rotate_90 | RR_Rotate_270))
- size = pGeode->displayPitch * pScrni->virtualX;
- else
- size = pGeode->displayPitch * pScrni->virtualY;
-
- if (size <= fbavail) {
- pGeode->shadowOffset = fboffset;
- pGeode->shadowSize = size;
-
- fboffset += size;
- fbavail -= size;
- }
- else {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Not enough memory for the shadow framebuffer\n");
- ret = FALSE;
+ if (rotate != RR_Rotate_0) {
+ if (rotate & (RR_Rotate_90 | RR_Rotate_270))
+ size = pGeode->displayPitch * pScrni->virtualX;
+ else
+ size = pGeode->displayPitch * pScrni->virtualY;
+
+ if (size <= fbavail) {
+ pGeode->shadowOffset = fboffset;
+ pGeode->shadowSize = size;
+
+ fboffset += size;
+ fbavail -= size;
+ } else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for the shadow framebuffer\n");
+ ret = FALSE;
+ }
}
- }
- /* Set the memory available for the offscreen pixmaps */
+ /* Set the memory available for the offscreen pixmaps */
- if (!pGeode->NoAccel) {
+ if (!pGeode->NoAccel) {
- if (pGeode->useEXA && pGeode->pExa) {
- ExaDriverPtr pExa = pGeode->pExa;
- pExa->offScreenBase = fboffset;
- pExa->memorySize = fboffset + fbavail;
- }
+ if (pGeode->useEXA && pGeode->pExa) {
+ ExaDriverPtr pExa = pGeode->pExa;
- /* XXX - We don't use XAA if we are rotated, so this should be fine. Changing the
- resolution will hurt us though */
+ pExa->offScreenBase = fboffset;
+ pExa->memorySize = fboffset + fbavail;
+ }
- if (!pGeode->useEXA) {
+ /* XXX - We don't use XAA if we are rotated, so this should be fine. Changing the
+ * resolution will hurt us though */
- if (!xf86FBManagerRunning(pScrn)) {
+ if (!pGeode->useEXA) {
- unsigned int offset = fboffset;
- unsigned int avail = fbavail;
- RegionRec OffscreenRegion;
- BoxRec AvailBox;
+ if (!xf86FBManagerRunning(pScrn)) {
- /* We only get one shot at allocating offscreen memory for XAA */
- /* That means if the mode changes with RandR, we'll probably be out of luck.
- we can compensate for rotation by offsetting the start of offscreen memory to account
- for the shadow framebuffer even if we're not using it right now
- */
+ unsigned int offset = fboffset;
+ unsigned int avail = fbavail;
+ RegionRec OffscreenRegion;
+ BoxRec AvailBox;
- if (pGeode->shadowSize == 0) {
- size = (pScrn->width * bytpp) * pScrni->virtualX;
-
- offset += size;
- avail -= size;
- }
+ /* We only get one shot at allocating offscreen memory for XAA */
+ /* That means if the mode changes with RandR, we'll probably be out of luck.
+ * we can compensate for rotation by offsetting the start of offscreen memory to account
+ * for the shadow framebuffer even if we're not using it right now
+ */
- AvailBox.x1 = 0;
- AvailBox.y1 = (offset + pGeode->displayPitch - 1) / pGeode->displayPitch;
+ if (pGeode->shadowSize == 0) {
+ size = (pScrn->width * bytpp) * pScrni->virtualX;
- AvailBox.x2 = pGeode->displayWidth;
- AvailBox.y2 = (offset + avail) / pGeode->displayPitch;
+ offset += size;
+ avail -= size;
+ }
- if (AvailBox.y1 < AvailBox.y2) {
- REGION_INIT(pScrn, &OffscreenRegion, &AvailBox, 2);
+ AvailBox.x1 = 0;
+ AvailBox.y1 =
+ (offset + pGeode->displayPitch -
+ 1) / pGeode->displayPitch;
- if (!xf86InitFBManagerRegion(pScrn, &OffscreenRegion))
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "Memory manager initialization failed.\n");
+ AvailBox.x2 = pGeode->displayWidth;
+ AvailBox.y2 = (offset + avail) / pGeode->displayPitch;
- REGION_UNINIT(pScrn, &OffscreenRegion);
+ if (AvailBox.y1 < AvailBox.y2) {
+ REGION_INIT(pScrn, &OffscreenRegion, &AvailBox, 2);
+
+ if (!xf86InitFBManagerRegion(pScrn, &OffscreenRegion))
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Memory manager initialization failed.\n");
+
+ REGION_UNINIT(pScrn, &OffscreenRegion);
+ } else
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO,
+ "Cache disabled - no offscreen memory available.\n");
+ } else
+ xf86DrvMsgp(pScrni->scrnIndex, X_INFO,
+ "XAA offscreen memory has already been allocated.\n");
}
- else
- xf86DrvMsg(pScrni->scrnIndex, X_INFO, "Cache disabled - no offscreen memory available.\n");
- }
- else
- xf86DrvMsgp(pScrni->scrnIndex, X_INFO, "XAA offscreen memory has already been allocated.\n");
}
- }
}
static Bool
GXSaveScreen(ScreenPtr pScrn, int mode)
{
- ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
- GeodePtr pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
+ GeodePtr pGeode = GEODEPTR(pScrni);
- if (pGeode->useVGA && !pScrni->vtSema)
- return vgaHWSaveScreen(pScrn, mode);
+ if (pGeode->useVGA && !pScrni->vtSema)
+ return vgaHWSaveScreen(pScrn, mode);
- return TRUE;
+ return TRUE;
}
static void
GXProbeDDC(ScrnInfoPtr pScrni, int index)
{
- vbeInfoPtr pVbe;
+ vbeInfoPtr pVbe;
- if (xf86LoadSubModule(pScrni, "vbe")) {
- pVbe = VBEInit(NULL, index);
- ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
- vbeFree(pVbe);
- }
+ if (xf86LoadSubModule(pScrni, "vbe")) {
+ pVbe = VBEInit(NULL, index);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+ vbeFree(pVbe);
+ }
}
/* From the Intel driver */
@@ -395,433 +399,435 @@ GXProbeDDC(ScrnInfoPtr pScrni, int index)
static xf86MonPtr
GXDoDDC(ScrnInfoPtr pScrni, int index)
{
- vbeInfoPtr pVbe;
- xf86MonPtr info = NULL;
-
- if (xf86LoadSubModule(pScrni, "vbe")) {
- xf86LoaderReqSymLists(amdVbeSymbols, NULL);
- info = vbeDoEDID(pVbe, NULL);
- xf86PrintEDID(info);
- xf86SetDDCproperties(pScrni, info);
- vbeFree(pVbe);
- }
- else
- xf86DrvMsg(pScrni->scrnIndex, X_INFO, "We cannot do DDC without VBE.\n");
-
- return info;
+ vbeInfoPtr pVbe;
+ xf86MonPtr info = NULL;
+
+ if (xf86LoadSubModule(pScrni, "vbe")) {
+ xf86LoaderReqSymLists(amdVbeSymbols, NULL);
+ info = vbeDoEDID(pVbe, NULL);
+ xf86PrintEDID(info);
+ xf86SetDDCproperties(pScrni, info);
+ vbeFree(pVbe);
+ } else
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO,
+ "We cannot do DDC without VBE.\n");
+
+ return info;
}
static Bool
-GXMapMem(ScrnInfoPtr pScrni)
+GXMapMem(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int index = pScrni->scrnIndex;
-
- gfx_virt_regptr = (unsigned char *) xf86MapVidMem(index, VIDMEM_MMIO,
- gfx_get_cpu_register_base(),
- pGeode->cpu_reg_size);
-
- if (pGeode->DetectedChipSet & GX)
- gfx_virt_gpptr = (unsigned char *) xf86MapVidMem(index, VIDMEM_MMIO,
- gfx_get_graphics_register_base(),
- pGeode->gp_reg_size);
- else
- gfx_virt_spptr = gfx_virt_regptr;
-
- gfx_virt_vidptr = (unsigned char *) xf86MapVidMem(index, VIDMEM_MMIO,
- gfx_get_vid_register_base(),
- pGeode->vid_reg_size);
-
- gfx_virt_fbptr = (unsigned char *) xf86MapVidMem(index, VIDMEM_FRAMEBUFFER,
- pGeode->FBLinearAddr,
- pGeode->FBAvail);
-
- XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
-
- pGeode->FBBase = gfx_virt_fbptr;
-
- if ((!gfx_virt_regptr) || (!gfx_virt_gpptr) ||
- (!gfx_virt_vidptr) || (!gfx_virt_fbptr))
- return FALSE;
-
- xf86DrvMsg(index, X_INFO, "Found Geode %lx %lx %lx %p\n",
- pGeode->cpu_version, pGeode->vid_version,
- pGeode->FBAvail, pGeode->FBBase);
-
- return TRUE;
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int index = pScrni->scrnIndex;
+
+ gfx_virt_regptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
+ gfx_get_cpu_register_base(), pGeode->cpu_reg_size);
+
+ if (pGeode->DetectedChipSet & GX)
+ gfx_virt_gpptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
+ gfx_get_graphics_register_base(), pGeode->gp_reg_size);
+ else
+ gfx_virt_spptr = gfx_virt_regptr;
+
+ gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO,
+ gfx_get_vid_register_base(), pGeode->vid_reg_size);
+
+ gfx_virt_fbptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_FRAMEBUFFER,
+ pGeode->FBLinearAddr, pGeode->FBAvail);
+
+ XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
+
+ pGeode->FBBase = gfx_virt_fbptr;
+
+ if ((!gfx_virt_regptr) || (!gfx_virt_gpptr) ||
+ (!gfx_virt_vidptr) || (!gfx_virt_fbptr))
+ return FALSE;
+
+ xf86DrvMsg(index, X_INFO, "Found Geode %lx %lx %lx %p\n",
+ pGeode->cpu_version, pGeode->vid_version,
+ pGeode->FBAvail, pGeode->FBBase);
+
+ return TRUE;
}
static Bool
-GXPreInit(ScrnInfoPtr pScrni, int flags)
+GXPreInit(ScrnInfoPtr pScrni, int flags)
{
- GeodePtr pGeode;
- ClockRangePtr GeodeClockRange;
- OptionInfoRec *GeodeOptions = &GX_GeodeOptions[0];
+ GeodePtr pGeode;
+ ClockRangePtr GeodeClockRange;
+ OptionInfoRec *GeodeOptions = &GX_GeodeOptions[0];
- rgb defaultWeight = { 0, 0, 0 };
- int ret, modecnt;
- int maj, min;
- char *s, *panelgeo;
- char **modes;
+ rgb defaultWeight = { 0, 0, 0 };
+ int ret, modecnt;
+ int maj, min;
+ char *s, *panelgeo;
+ char **modes;
- pGeode = pScrni->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1);
+ pGeode = pScrni->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1);
- if (pGeode == NULL)
- return FALSE;
+ if (pGeode == NULL)
+ return FALSE;
#if INT10_SUPPORT
- pGeode->vesa = xcalloc(sizeof(VESARec), 1);
+ pGeode->vesa = xcalloc(sizeof(VESARec), 1);
#endif
- if (pScrni->numEntities != 1)
- return FALSE;
+ if (pScrni->numEntities != 1)
+ return FALSE;
- pGeode->pEnt = xf86GetEntityInfo(pScrni->entityList[0]);
+ pGeode->pEnt = xf86GetEntityInfo(pScrni->entityList[0]);
- if (pGeode->pEnt->resources)
- return FALSE;
+ if (pGeode->pEnt->resources)
+ return FALSE;
- /* ISSUE - this won't work without VGA, but its too early to know if we can use VGA or not */
+ /* ISSUE - this won't work without VGA, but its too early to know if we can use VGA or not */
- if (flags & PROBE_DETECT) {
- GXProbeDDC(pScrni, pGeode->pEnt->index);
- return TRUE;
- }
+ if (flags & PROBE_DETECT) {
+ GXProbeDDC(pScrni, pGeode->pEnt->index);
+ return TRUE;
+ }
- pGeode->cpu_version = gfx_detect_cpu();
+ pGeode->cpu_version = gfx_detect_cpu();
- if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) {
- int ret;
- QQ_WORD msrValue;
+ if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) {
+ int ret;
+ QQ_WORD msrValue;
- pGeode->DetectedChipSet = GX_CRT;
+ pGeode->DetectedChipSet = GX_CRT;
- ret = gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue);
+ ret = gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue);
- if (!ret)
- pGeode->DetectedChipSet =
- ((msrValue.low & RCDF_CONFIG_FMT_MASK) == RCDF_CONFIG_FMT_FP) ? GX_TFT : GX_CRT;
- }
- else
- pGeode->DetectedChipSet = GX1;
-
- pGeode->vid_version = gfx_detect_video();
- pGeode->FBLinearAddr = gfx_get_frame_buffer_base();
-
- if (pGeode->DetectedChipSet & GX) {
- pGeode->cpu_reg_size = 0x4000;
- pGeode->gp_reg_size = 0x4000;
- pGeode->vid_reg_size = 0x4000;
- } else {
- pGeode->cpu_reg_size = 0x9000;
- pGeode->vid_reg_size = 0x1000;
- }
-
- /* Fill in the monitor information */
- pScrni->monitor = pScrni->confScreen->monitor;
-
- if (!xf86SetDepthBpp(pScrni, 8, 8, 8, Support24bppFb | Support32bppFb))
- return FALSE;
-
- switch(pScrni->depth) {
- case 8:
- pScrni->rgbBits = 8;
- case 16:
- case 24:
- case 32:
- break;
- default:
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "The driver does not support %d as a depth.\n", pScrni->depth);
- return FALSE;
- }
-
- xf86PrintDepthBpp(pScrni);
-
- if (!xf86SetWeight(pScrni, defaultWeight, defaultWeight))
- return FALSE;
-
- if (!xf86SetDefaultVisual(pScrni, -1))
- return FALSE;
-
- pScrni->progClock = TRUE;
- xf86CollectOptions(pScrni, NULL);
- xf86ProcessOptions(pScrni->scrnIndex, pScrni->options, GeodeOptions);
-
- /* Set up our various options that may get reversed as we go on */
- pGeode->useVGA = TRUE;
- pGeode->FBVGAActive = FALSE;
-
- pGeode->tryHWCursor = TRUE;
- pGeode->tryCompression = TRUE;
-
- pGeode->NoAccel = FALSE;
- pGeode->CustomMode = FALSE;
- pGeode->useEXA = FALSE;
-
- if (pGeode->DetectedChipSet == GX_TFT)
- pGeode->Panel = TRUE;
- else if (pGeode->DetectedChipSet == GX_CRT)
- pGeode->Panel = FALSE;
-
- pGeode->NoOfImgBuffers = DEFAULT_IMG_LINE_BUFS;
- pGeode->NoOfColorExpandLines = DEFAULT_CLR_LINE_BUFS;
- pGeode->exaBfrSz = DEFAULT_EXA_SCRATCH_BFRSZ;
-
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOVGA, FALSE))
- pGeode->useVGA = FALSE;
-
- xf86GetOptValBool(GeodeOptions, GX_OPTION_HW_CURSOR, &pGeode->tryHWCursor);
-
- /* For compatability - allow SWCursor too */
-
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_SW_CURSOR, FALSE))
- pGeode->tryHWCursor = FALSE;
-
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOCOMPRESSION, FALSE))
- pGeode->tryCompression = FALSE;
-
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOACCEL, FALSE))
- pGeode->NoAccel = TRUE;
-
- xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_IMG_BUFS, &(pGeode->NoOfImgBuffers));
-
- if (pGeode->NoOfImgBuffers <= 0)
- pGeode->NoOfImgBuffers = 0;
-
- xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS, &(pGeode->NoOfColorExpandLines));
-
- if (pGeode->NoOfColorExpandLines <= 0)
- pGeode->NoOfColorExpandLines = 0;
-
- xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS, &(pGeode->exaBfrSz));
-
- if (pGeode->exaBfrSz <= 0)
- pGeode->exaBfrSz = 0;
-
- /* We are going to see if we can get rid of this option */
-
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_CUSTOM_MODE, FALSE))
- pGeode->CustomMode = TRUE;
+ if (!ret)
+ pGeode->DetectedChipSet =
+ ((msrValue.low & RCDF_CONFIG_FMT_MASK) ==
+ RCDF_CONFIG_FMT_FP) ? GX_TFT : GX_CRT;
+ } else
+ pGeode->DetectedChipSet = GX1;
+
+ pGeode->vid_version = gfx_detect_video();
+ pGeode->FBLinearAddr = gfx_get_frame_buffer_base();
- if (pGeode->Panel == TRUE) {
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOPANEL, FALSE))
- pGeode->Panel = FALSE;
- }
+ if (pGeode->DetectedChipSet & GX) {
+ pGeode->cpu_reg_size = 0x4000;
+ pGeode->gp_reg_size = 0x4000;
+ pGeode->vid_reg_size = 0x4000;
+ } else {
+ pGeode->cpu_reg_size = 0x9000;
+ pGeode->vid_reg_size = 0x1000;
+ }
- panelgeo = xf86GetOptValString(GeodeOptions, GX_OPTION_PANEL_GEOMETRY);
+ /* Fill in the monitor information */
+ pScrni->monitor = pScrni->confScreen->monitor;
+
+ if (!xf86SetDepthBpp(pScrni, 8, 8, 8, Support24bppFb | Support32bppFb))
+ return FALSE;
+
+ switch (pScrni->depth) {
+ case 8:
+ pScrni->rgbBits = 8;
+ case 16:
+ case 24:
+ case 32:
+ break;
+ default:
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "The driver does not support %d as a depth.\n", pScrni->depth);
+ return FALSE;
+ }
- if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ACCEL_METHOD))) {
- if (!xf86NameCmp(s, "EXA"))
- pGeode->useEXA = TRUE;
- }
+ xf86PrintDepthBpp(pScrni);
+ if (!xf86SetWeight(pScrni, defaultWeight, defaultWeight))
+ return FALSE;
- xf86DrvMsg(pScrni->scrnIndex, X_INFO, "Using %s acceleration architecture\n",
- pGeode->useEXA ? "EXA" : "XAA");
+ if (!xf86SetDefaultVisual(pScrni, -1))
+ return FALSE;
- /* Set up the panel */
+ pScrni->progClock = TRUE;
+ xf86CollectOptions(pScrni, NULL);
+ xf86ProcessOptions(pScrni->scrnIndex, pScrni->options, GeodeOptions);
- if (pGeode->Panel) {
- if (panelgeo != NULL) {
- if (GXGetFPInfo(panelgeo, &pGeode->FPBX, &pGeode->FPBY))
+ /* Set up our various options that may get reversed as we go on */
+ pGeode->useVGA = TRUE;
+ pGeode->FBVGAActive = FALSE;
+
+ pGeode->tryHWCursor = TRUE;
+ pGeode->tryCompression = TRUE;
+
+ pGeode->NoAccel = FALSE;
+ pGeode->CustomMode = FALSE;
+ pGeode->useEXA = FALSE;
+
+ if (pGeode->DetectedChipSet == GX_TFT)
+ pGeode->Panel = TRUE;
+ else if (pGeode->DetectedChipSet == GX_CRT)
pGeode->Panel = FALSE;
+
+ pGeode->NoOfImgBuffers = DEFAULT_IMG_LINE_BUFS;
+ pGeode->NoOfColorExpandLines = DEFAULT_CLR_LINE_BUFS;
+ pGeode->exaBfrSz = DEFAULT_EXA_SCRATCH_BFRSZ;
+
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOVGA, FALSE))
+ pGeode->useVGA = FALSE;
+
+ xf86GetOptValBool(GeodeOptions, GX_OPTION_HW_CURSOR,
+ &pGeode->tryHWCursor);
+
+ /* For compatability - allow SWCursor too */
+
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_SW_CURSOR, FALSE))
+ pGeode->tryHWCursor = FALSE;
+
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOCOMPRESSION, FALSE))
+ pGeode->tryCompression = FALSE;
+
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOACCEL, FALSE))
+ pGeode->NoAccel = TRUE;
+
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_IMG_BUFS,
+ &(pGeode->NoOfImgBuffers));
+
+ if (pGeode->NoOfImgBuffers <= 0)
+ pGeode->NoOfImgBuffers = 0;
+
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS,
+ &(pGeode->NoOfColorExpandLines));
+
+ if (pGeode->NoOfColorExpandLines <= 0)
+ pGeode->NoOfColorExpandLines = 0;
+
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS,
+ &(pGeode->exaBfrSz));
+
+ if (pGeode->exaBfrSz <= 0)
+ pGeode->exaBfrSz = 0;
+
+ /* We are going to see if we can get rid of this option */
+
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_CUSTOM_MODE, FALSE))
+ pGeode->CustomMode = TRUE;
+
+ if (pGeode->Panel == TRUE) {
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOPANEL, FALSE))
+ pGeode->Panel = FALSE;
}
-#ifdef PNL_SUP
- else {
- int b, f;
-
- /* The bitdepth and refresh isn't used anywhere else in the driver */
-
- if ((pGeode->Panel = Pnl_IsPanelEnabledInBIOS()))
- Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY, &b, &f);
+
+ panelgeo = xf86GetOptValString(GeodeOptions, GX_OPTION_PANEL_GEOMETRY);
+
+ if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ACCEL_METHOD))) {
+ if (!xf86NameCmp(s, "EXA"))
+ pGeode->useEXA = TRUE;
}
+
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO,
+ "Using %s acceleration architecture\n",
+ pGeode->useEXA ? "EXA" : "XAA");
+
+ /* Set up the panel */
+
+ if (pGeode->Panel) {
+ if (panelgeo != NULL) {
+ if (GXGetFPInfo(panelgeo, &pGeode->FPBX, &pGeode->FPBY))
+ pGeode->Panel = FALSE;
+ }
+#ifdef PNL_SUP
+ else {
+ int b, f;
+
+ /* The bitdepth and refresh isn't used anywhere else in the driver */
+
+ if ((pGeode->Panel = Pnl_IsPanelEnabledInBIOS()))
+ Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY, &b,
+ &f);
+ }
#endif
- }
+ }
- /* Set up the VGA */
+ /* Set up the VGA */
- if (pGeode->useVGA) {
+ if (pGeode->useVGA) {
#if INT10_SUPPORT
- VESARec *pVesa;
-
- if (!xf86LoadSubModule(pScrni, "int10"))
- return FALSE;
- xf86LoaderReqSymLists(amdInt10Symbols, NULL);
-
- pVesa = pGeode->vesa;
-
- if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,"Unable to initialize 1NT10 support\n");
- pGeode->useVGA = FALSE;
- }
+ VESARec *pVesa;
+
+ if (!xf86LoadSubModule(pScrni, "int10"))
+ return FALSE;
+ xf86LoaderReqSymLists(amdInt10Symbols, NULL);
+
+ pVesa = pGeode->vesa;
+
+ if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Unable to initialize 1NT10 support\n");
+ pGeode->useVGA = FALSE;
+ }
#endif
-
- if (!xf86LoadSubModule(pScrni, "vgahw"))
- return FALSE;
-
- xf86LoaderReqSymLists(amdVgahwSymbols, NULL);
- pGeode->FBVGAActive = gu2_get_vga_active();
- }
-
- pGeode->FBAvail = gfx_get_frame_buffer_size();
-
- if (pScrni->memPhysBase == 0)
- pScrni->memPhysBase = gfx_get_frame_buffer_base();
-
- pScrni->fbOffset = 0;
-
- if (pGeode->pEnt->device->videoRam == 0)
- pScrni->videoRam = pGeode->FBAvail / 1024;
- else
- pScrni->videoRam = pGeode->pEnt->device->videoRam;
-
- if (!GXMapMem(pScrni))
- return FALSE;
-
- pGeode->maxWidth = GX_MAX_WIDTH;
- pGeode->maxHeight = GX_MAX_HEIGHT;
-
- GeodeClockRange = (ClockRangePtr) xnfcalloc(sizeof(ClockRange), 1);
- GeodeClockRange->next = NULL;
- GeodeClockRange->minClock = 25175;
- GeodeClockRange->maxClock = 229500;
- GeodeClockRange->clockIndex = -1;
- GeodeClockRange->interlaceAllowed = TRUE;
- GeodeClockRange->doubleScanAllowed = FALSE;
-
- if (pGeode->useVGA)
- pScrni->monitor->DDC = GXDoDDC(pScrni, pGeode->pEnt->index);
- else
- pScrni->monitor->DDC = NULL;
-
- /* I'm still not 100% sure this uses the right values */
-
- modecnt = xf86ValidateModes(pScrni,
- pScrni->monitor->Modes,
- pScrni->display->modes,
- GeodeClockRange,
- NULL, GX_MIN_PITCH, GX_MAX_PITCH,
- 32, GX_MIN_HEIGHT, GX_MAX_HEIGHT,
- pScrni->display->virtualX,
- pScrni->display->virtualY, pGeode->FBAvail, LOOKUP_BEST_REFRESH);
-
- if (modecnt <= 0) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
- GXFreeRec(pScrni);
- return FALSE;
- }
-
- xf86PruneDriverModes(pScrni);
-
- if (pScrni->modes == NULL) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
- GXFreeRec(pScrni);
- return FALSE;
- }
-
- xf86SetCrtcForModes(pScrni, 0);
- pScrni->currentMode = pScrni->modes;
-
- xf86PrintModes(pScrni);
- xf86SetDpi(pScrni, 0, 0);
-
- /* Load the modules we'll need */
-
- if (xf86LoadSubModule(pScrni, "fb") == NULL) {
- GXFreeRec(pScrni);
- return FALSE;
- }
-
- xf86LoaderReqSymLists(amdFbSymbols, NULL);
-
- if (pGeode->NoAccel == FALSE) {
- const char *module = "xaa";
- const char **symbols = &amdXaaSymbols[0];
-
-
- if (pGeode->useEXA) {
- module = "exa";
- symbols = &amdExaSymbols[0];
+
+ if (!xf86LoadSubModule(pScrni, "vgahw"))
+ return FALSE;
+
+ xf86LoaderReqSymLists(amdVgahwSymbols, NULL);
+ pGeode->FBVGAActive = gu2_get_vga_active();
+ }
+
+ pGeode->FBAvail = gfx_get_frame_buffer_size();
+
+ if (pScrni->memPhysBase == 0)
+ pScrni->memPhysBase = gfx_get_frame_buffer_base();
+
+ pScrni->fbOffset = 0;
+
+ if (pGeode->pEnt->device->videoRam == 0)
+ pScrni->videoRam = pGeode->FBAvail / 1024;
+ else
+ pScrni->videoRam = pGeode->pEnt->device->videoRam;
+
+ if (!GXMapMem(pScrni))
+ return FALSE;
+
+ pGeode->maxWidth = GX_MAX_WIDTH;
+ pGeode->maxHeight = GX_MAX_HEIGHT;
+
+ GeodeClockRange = (ClockRangePtr) xnfcalloc(sizeof(ClockRange), 1);
+ GeodeClockRange->next = NULL;
+ GeodeClockRange->minClock = 25175;
+ GeodeClockRange->maxClock = 229500;
+ GeodeClockRange->clockIndex = -1;
+ GeodeClockRange->interlaceAllowed = TRUE;
+ GeodeClockRange->doubleScanAllowed = FALSE;
+
+ if (pGeode->useVGA)
+ pScrni->monitor->DDC = GXDoDDC(pScrni, pGeode->pEnt->index);
+ else
+ pScrni->monitor->DDC = NULL;
+
+ /* I'm still not 100% sure this uses the right values */
+
+ modecnt = xf86ValidateModes(pScrni,
+ pScrni->monitor->Modes,
+ pScrni->display->modes,
+ GeodeClockRange,
+ NULL, GX_MIN_PITCH, GX_MAX_PITCH,
+ 32, GX_MIN_HEIGHT, GX_MAX_HEIGHT,
+ pScrni->display->virtualX,
+ pScrni->display->virtualY, pGeode->FBAvail, LOOKUP_BEST_REFRESH);
+
+ if (modecnt <= 0) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
+ GXFreeRec(pScrni);
+ return FALSE;
+ }
+
+ xf86PruneDriverModes(pScrni);
+
+ if (pScrni->modes == NULL) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
+ GXFreeRec(pScrni);
+ return FALSE;
}
- if (!xf86LoadSubModule(pScrni, module)) {
- GXFreeRec(pScrni);
- return FALSE;
+ xf86SetCrtcForModes(pScrni, 0);
+ pScrni->currentMode = pScrni->modes;
+
+ xf86PrintModes(pScrni);
+ xf86SetDpi(pScrni, 0, 0);
+
+ /* Load the modules we'll need */
+
+ if (xf86LoadSubModule(pScrni, "fb") == NULL) {
+ GXFreeRec(pScrni);
+ return FALSE;
}
- xf86LoaderReqSymLists(symbols, NULL);
- }
+ xf86LoaderReqSymLists(amdFbSymbols, NULL);
+
+ if (pGeode->NoAccel == FALSE) {
+ const char *module = "xaa";
+ const char **symbols = &amdXaaSymbols[0];
+
+ if (pGeode->useEXA) {
+ module = "exa";
+ symbols = &amdExaSymbols[0];
+ }
- if (pGeode->tryHWCursor == TRUE) {
- if (!xf86LoadSubModule(pScrni, "ramdac")) {
- GXFreeRec(pScrni);
- return FALSE;
+ if (!xf86LoadSubModule(pScrni, module)) {
+ GXFreeRec(pScrni);
+ return FALSE;
+ }
+
+ xf86LoaderReqSymLists(symbols, NULL);
}
- xf86LoaderReqSymLists(amdRamdacSymbols, NULL);
- }
+ if (pGeode->tryHWCursor == TRUE) {
+ if (!xf86LoadSubModule(pScrni, "ramdac")) {
+ GXFreeRec(pScrni);
+ return FALSE;
+ }
- if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Couldn't register the resources.\n");
- GXFreeRec(pScrni);
- return FALSE;
- }
+ xf86LoaderReqSymLists(amdRamdacSymbols, NULL);
+ }
- return TRUE;
+ if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Couldn't register the resources.\n");
+ GXFreeRec(pScrni);
+ return FALSE;
+ }
+
+ return TRUE;
}
static void
GXRestore(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (pGeode->useVGA && pGeode->FBVGAActive) {
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
+ if (pGeode->useVGA && pGeode->FBVGAActive) {
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- vgaHWProtect(pScrni, TRUE);
- vgaHWRestore(pScrni, &pvgaHW->SavedReg, VGA_SR_ALL);
- vgaHWProtect(pScrni, FALSE);
- }
+ vgaHWProtect(pScrni, TRUE);
+ vgaHWRestore(pScrni, &pvgaHW->SavedReg, VGA_SR_ALL);
+ vgaHWProtect(pScrni, FALSE);
+ }
}
-
+
static Bool
GXUnmapMem(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- /* unmap all the memory map's */
+ /* unmap all the memory map's */
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_regptr, pGeode->cpu_reg_size);
+ xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_regptr, pGeode->cpu_reg_size);
- if (pGeode->DetectedChipSet & GX) {
- xf86UnMapVidMem(pScrni->scrnIndex,
- gfx_virt_gpptr, pGeode->gp_reg_size);
- }
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_vidptr, pGeode->vid_reg_size);
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_fbptr, pGeode->FBAvail);
- return TRUE;
+ if (pGeode->DetectedChipSet & GX) {
+ xf86UnMapVidMem(pScrni->scrnIndex,
+ gfx_virt_gpptr, pGeode->gp_reg_size);
+ }
+ xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_vidptr, pGeode->vid_reg_size);
+ xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_fbptr, pGeode->FBAvail);
+ return TRUE;
}
static void
GXSetDvLineSize(unsigned int pitch)
{
- unsigned long temp, dv_size = MDC_DV_LINE_SIZE_1024;
-
- if (pitch > 1024) {
- dv_size = MDC_DV_LINE_SIZE_2048;
- }
- if (pitch > 2048) {
- dv_size = MDC_DV_LINE_SIZE_4096;
- }
- if (pitch > 4096) {
- dv_size = MDC_DV_LINE_SIZE_8192;
- }
-
- /* WRITE DIRTY/VALID CONTROL WITH LINE LENGTH */
-
- temp = READ_REG32(MDC_DV_CTL);
- WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size);
+ unsigned long temp, dv_size = MDC_DV_LINE_SIZE_1024;
+
+ if (pitch > 1024) {
+ dv_size = MDC_DV_LINE_SIZE_2048;
+ }
+ if (pitch > 2048) {
+ dv_size = MDC_DV_LINE_SIZE_4096;
+ }
+ if (pitch > 4096) {
+ dv_size = MDC_DV_LINE_SIZE_8192;
+ }
+
+ /* WRITE DIRTY/VALID CONTROL WITH LINE LENGTH */
+
+ temp = READ_REG32(MDC_DV_CTL);
+ WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size);
}
/* XXX - this is nothing like the original function - not sure exactly what the purpose is for this quite yet */
@@ -834,7 +840,8 @@ GXAdjustFrame(int scrnIndex, int x, int y, int flags)
unsigned long offset;
offset =
- pGeode->FBOffset + y * pGeode->Pitch + x * (pScrni->bitsPerPixel >> 3);
+ pGeode->FBOffset + y * pGeode->Pitch +
+ x * (pScrni->bitsPerPixel >> 3);
gfx_set_display_offset(offset);
}
@@ -842,311 +849,308 @@ GXAdjustFrame(int scrnIndex, int x, int y, int flags)
static Bool
GXSetVideoMode(ScrnInfoPtr pScrni, DisplayModePtr pMode)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int flags;
-
- pScrni->vtSema = TRUE;
-
- gx_disable_dac_power();
-
- if (pMode->Flags & V_NHSYNC)
- flags |= 1;
- if (pMode->Flags & V_NVSYNC)
- flags |= 2;
-
- /* XXX Fixme - for now, we'll use the fixed settings for panel - but I would
- like to see these go away too
- */
-
- /* XXX Question - why even use set_display_mode at all - shouldn't the
- mode timings be the same that we advertise? */
-
- if (pGeode->Panel) {
- GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY,
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel));
- }
- else {
- GFX(set_display_timings(pScrni->bitsPerPixel, flags,
- pMode->CrtcHDisplay, pMode->CrtcHBlankStart,
- pMode->CrtcHSyncStart, pMode->CrtcHSyncEnd,
- pMode->CrtcHBlankEnd, pMode->CrtcHTotal,
- pMode->CrtcVDisplay, pMode->CrtcVBlankStart,
- pMode->CrtcVSyncStart, pMode->CrtcVSyncEnd,
- pMode->CrtcVBlankEnd, pMode->CrtcVTotal,
- (int)((pMode->SynthClock / 1000.0) * 0x10000)));
- }
-
- GFX(set_crt_enable(CRT_ENABLE));
- GFX(set_display_pitch(pGeode->displayPitch));
- GFX(set_display_offset(0L));
- GFX(wait_vertical_blank());
-
- if (pGeode->Compression) {
- GXSetDvLineSize(pGeode->Pitch);
-
- gfx_set_compression_offset(pGeode->CBOffset);
- gfx_set_compression_pitch(GX_CB_PITCH);
- gfx_set_compression_size(GX_CB_SIZE);
-
- gfx_set_compression_enable(1);
- }
-
- if (pGeode->HWCursor && !(pMode->Flags & V_DBLSCAN)) {
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int flags;
+
+ pScrni->vtSema = TRUE;
+
+ gx_disable_dac_power();
+
+ if (pMode->Flags & V_NHSYNC)
+ flags |= 1;
+ if (pMode->Flags & V_NVSYNC)
+ flags |= 2;
+
+ /* XXX Fixme - for now, we'll use the fixed settings for panel - but I would
+ * like to see these go away too
+ */
+
+ /* XXX Question - why even use set_display_mode at all - shouldn't the
+ * mode timings be the same that we advertise? */
+
+ if (pGeode->Panel) {
+ GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY,
+ pMode->CrtcHDisplay, pMode->CrtcVDisplay,
+ pScrni->bitsPerPixel));
+ } else {
+ GFX(set_display_timings(pScrni->bitsPerPixel, flags,
+ pMode->CrtcHDisplay, pMode->CrtcHBlankStart,
+ pMode->CrtcHSyncStart, pMode->CrtcHSyncEnd,
+ pMode->CrtcHBlankEnd, pMode->CrtcHTotal,
+ pMode->CrtcVDisplay, pMode->CrtcVBlankStart,
+ pMode->CrtcVSyncStart, pMode->CrtcVSyncEnd,
+ pMode->CrtcVBlankEnd, pMode->CrtcVTotal,
+ (int)((pMode->SynthClock / 1000.0) * 0x10000)));
+ }
+
+ GFX(set_crt_enable(CRT_ENABLE));
+ GFX(set_display_pitch(pGeode->displayPitch));
+ GFX(set_display_offset(0L));
+ GFX(wait_vertical_blank());
+
+ if (pGeode->Compression) {
+ GXSetDvLineSize(pGeode->Pitch);
+
+ gfx_set_compression_offset(pGeode->CBOffset);
+ gfx_set_compression_pitch(GX_CB_PITCH);
+ gfx_set_compression_size(GX_CB_SIZE);
+
+ gfx_set_compression_enable(1);
+ }
+
+ if (pGeode->HWCursor && !(pMode->Flags & V_DBLSCAN)) {
GXLoadCursorImage(pScrni, NULL);
GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0));
- GXShowCursor(pScrni);
- }
- else {
+ GXShowCursor(pScrni);
+ } else {
GFX(set_cursor_enable(0));
pGeode->HWCursor = FALSE;
- }
+ }
- GXAdjustFrame(pScrni->scrnIndex, pScrni->frameX0, pScrni->frameY0, 0);
- gx_enable_dac_power();
+ GXAdjustFrame(pScrni->scrnIndex, pScrni->frameX0, pScrni->frameY0, 0);
+ gx_enable_dac_power();
- return TRUE;
+ return TRUE;
}
static Bool
GXSwitchMode(int index, DisplayModePtr pMode, int flags)
{
- ScrnInfoPtr pScrni = xf86Screens[index];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int ret = TRUE;
- int rotate;
+ ScrnInfoPtr pScrni = xf86Screens[index];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int ret = TRUE;
+ int rotate;
+
+ /* Syn the engine and shutdown the DAC momentarily */
- /* Syn the engine and shutdown the DAC momentarily */
+ gfx_wait_until_idle();
- gfx_wait_until_idle();
+ /* Set up the memory for the new mode */
+ rotate = GXGetRotation(pScrni->pScreen);
+ ret = GXAllocateMemory(pScrni->pScreen, pScrni, rotate);
- /* Set up the memory for the new mode */
- rotate = GXGetRotation(pScrni->pScreen);
- ret = GXAllocateMemory(pScrni->pScreen, pScrni, rotate);
+ if (ret) {
+ if (pGeode->curMode != pMode)
+ ret = GXSetVideoMode(pScrni, pMode);
+ }
- if (ret) {
- if (pGeode->curMode != pMode)
- ret = GXSetVideoMode(pScrni, pMode);
- }
+ if (ret)
+ ret = GXRotate(pScrni, pMode);
- if (ret)
- ret = GXRotate(pScrni, pMode);
+ /* Go back the way it was */
- /* Go back the way it was */
+ if (ret == FALSE) {
+ if (!GXSetVideoMode(pScrni, pGeode->curMode))
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Could not restore the previous mode\n");
+ } else
+ pGeode->curMode = pMode;
- if (ret == FALSE) {
- if (!GXSetVideoMode(pScrni, pGeode->curMode))
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "Could not restore the previous mode\n");
- }
- else
- pGeode->curMode = pMode;
-
- return ret;
+ return ret;
}
static void
GXLeaveGraphics(ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- gfx_wait_until_idle();
-
- /* Restore VG registers */
- gfx_set_display_timings(pGeode->FBgfxdisplaytiming.wBpp,
- pGeode->FBgfxdisplaytiming.wPolarity,
- pGeode->FBgfxdisplaytiming.wHActive,
- pGeode->FBgfxdisplaytiming.wHBlankStart,
- pGeode->FBgfxdisplaytiming.wHSyncStart,
- pGeode->FBgfxdisplaytiming.wHSyncEnd,
- pGeode->FBgfxdisplaytiming.wHBlankEnd,
- pGeode->FBgfxdisplaytiming.wHTotal,
- pGeode->FBgfxdisplaytiming.wVActive,
- pGeode->FBgfxdisplaytiming.wVBlankStart,
- pGeode->FBgfxdisplaytiming.wVSyncStart,
- pGeode->FBgfxdisplaytiming.wVSyncEnd,
- pGeode->FBgfxdisplaytiming.wVBlankEnd,
- pGeode->FBgfxdisplaytiming.wVTotal,
- pGeode->FBgfxdisplaytiming.dwDotClock);
-
- gfx_set_compression_enable(0);
-
- /* Restore the previous Compression state */
- if (pGeode->FBCompressionEnable) {
- gfx_set_compression_offset(pGeode->FBCompressionOffset);
- gfx_set_compression_pitch(pGeode->FBCompressionPitch);
- gfx_set_compression_size(pGeode->FBCompressionSize);
- gfx_set_compression_enable(1);
- }
-
- gfx_set_display_pitch(pGeode->FBgfxdisplaytiming.wPitch);
-
- gfx_set_display_offset(pGeode->FBDisplayOffset);
-
- /* Restore Cursor */
- gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0);
-
- if (pGeode->useVGA) {
- pGeode->vesa->pInt->num = 0x10;
- pGeode->vesa->pInt->ax = 0x0 | pGeode->FBBIOSMode;
- pGeode->vesa->pInt->bx = 0;
- xf86ExecX86int10(pGeode->vesa->pInt);
- gfx_delay_milliseconds(3);
- }
-
- GXRestore(pScrni);
-
- gx_enable_dac_power();
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ gfx_wait_until_idle();
+
+ /* Restore VG registers */
+ gfx_set_display_timings(pGeode->FBgfxdisplaytiming.wBpp,
+ pGeode->FBgfxdisplaytiming.wPolarity,
+ pGeode->FBgfxdisplaytiming.wHActive,
+ pGeode->FBgfxdisplaytiming.wHBlankStart,
+ pGeode->FBgfxdisplaytiming.wHSyncStart,
+ pGeode->FBgfxdisplaytiming.wHSyncEnd,
+ pGeode->FBgfxdisplaytiming.wHBlankEnd,
+ pGeode->FBgfxdisplaytiming.wHTotal,
+ pGeode->FBgfxdisplaytiming.wVActive,
+ pGeode->FBgfxdisplaytiming.wVBlankStart,
+ pGeode->FBgfxdisplaytiming.wVSyncStart,
+ pGeode->FBgfxdisplaytiming.wVSyncEnd,
+ pGeode->FBgfxdisplaytiming.wVBlankEnd,
+ pGeode->FBgfxdisplaytiming.wVTotal,
+ pGeode->FBgfxdisplaytiming.dwDotClock);
+
+ gfx_set_compression_enable(0);
+
+ /* Restore the previous Compression state */
+ if (pGeode->FBCompressionEnable) {
+ gfx_set_compression_offset(pGeode->FBCompressionOffset);
+ gfx_set_compression_pitch(pGeode->FBCompressionPitch);
+ gfx_set_compression_size(pGeode->FBCompressionSize);
+ gfx_set_compression_enable(1);
+ }
+
+ gfx_set_display_pitch(pGeode->FBgfxdisplaytiming.wPitch);
+
+ gfx_set_display_offset(pGeode->FBDisplayOffset);
+
+ /* Restore Cursor */
+ gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0);
+
+ if (pGeode->useVGA) {
+ pGeode->vesa->pInt->num = 0x10;
+ pGeode->vesa->pInt->ax = 0x0 | pGeode->FBBIOSMode;
+ pGeode->vesa->pInt->bx = 0;
+ xf86ExecX86int10(pGeode->vesa->pInt);
+ gfx_delay_milliseconds(3);
+ }
+
+ GXRestore(pScrni);
+
+ gx_enable_dac_power();
}
static Bool
-GXCloseScreen(int scrnIndex, ScreenPtr pScrn)
+GXCloseScreen(int scrnIndex, ScreenPtr pScrn)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- if (pScrni->vtSema)
- GXLeaveGraphics(pScrni);
-
- if (pGeode->AccelInfoRec)
- XAADestroyInfoRec(pGeode->AccelInfoRec);
-
- if (pGeode->AccelImageWriteBuffers) {
- xfree(pGeode->AccelImageWriteBuffers[0]);
- xfree(pGeode->AccelImageWriteBuffers);
- pGeode->AccelImageWriteBuffers = NULL;
- }
-
- if (pGeode->AccelColorExpandBuffers) {
- xfree(pGeode->AccelColorExpandBuffers);
- pGeode->AccelColorExpandBuffers = NULL;
- }
-
- if (pGeode->pExa) {
- exaDriverFini(pScrn);
- xfree(pGeode->pExa);
- pGeode->pExa = NULL;
- }
-
- pScrni->vtSema = FALSE;
-
- GXUnmapMem(pScrni);
-
- if (pGeode && (pScrn->CloseScreen = pGeode->CloseScreen)) {
- pGeode->CloseScreen = NULL;
- return ((*pScrn->CloseScreen) (scrnIndex, pScrn));
- }
-
- return TRUE;
-}
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ if (pScrni->vtSema)
+ GXLeaveGraphics(pScrni);
+
+ if (pGeode->AccelInfoRec)
+ XAADestroyInfoRec(pGeode->AccelInfoRec);
+
+ if (pGeode->AccelImageWriteBuffers) {
+ xfree(pGeode->AccelImageWriteBuffers[0]);
+ xfree(pGeode->AccelImageWriteBuffers);
+ pGeode->AccelImageWriteBuffers = NULL;
+ }
+
+ if (pGeode->AccelColorExpandBuffers) {
+ xfree(pGeode->AccelColorExpandBuffers);
+ pGeode->AccelColorExpandBuffers = NULL;
+ }
+ if (pGeode->pExa) {
+ exaDriverFini(pScrn);
+ xfree(pGeode->pExa);
+ pGeode->pExa = NULL;
+ }
+ pScrni->vtSema = FALSE;
+
+ GXUnmapMem(pScrni);
+
+ if (pGeode && (pScrn->CloseScreen = pGeode->CloseScreen)) {
+ pGeode->CloseScreen = NULL;
+ return ((*pScrn->CloseScreen) (scrnIndex, pScrn));
+ }
+
+ return TRUE;
+}
static Bool
-GXEnterGraphics(ScreenPtr pScrn, ScrnInfoPtr pScrni)
+GXEnterGraphics(ScreenPtr pScrn, ScrnInfoPtr pScrni)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- gfx_wait_until_idle();
-
- /* Save off the current state (should this be somewhere else)? */
-
- pGeode->FBgfxdisplaytiming.dwDotClock = gfx_get_clock_frequency();
- pGeode->FBgfxdisplaytiming.wPitch = gfx_get_display_pitch();
- pGeode->FBgfxdisplaytiming.wBpp = gfx_get_display_bpp();
- pGeode->FBgfxdisplaytiming.wHTotal = gfx_get_htotal();
- pGeode->FBgfxdisplaytiming.wHActive = gfx_get_hactive();
- pGeode->FBgfxdisplaytiming.wHSyncStart = gfx_get_hsync_start();
- pGeode->FBgfxdisplaytiming.wHSyncEnd = gfx_get_hsync_end();
- pGeode->FBgfxdisplaytiming.wHBlankStart = gfx_get_hblank_start();
- pGeode->FBgfxdisplaytiming.wHBlankEnd = gfx_get_hblank_end();
- pGeode->FBgfxdisplaytiming.wVTotal = gfx_get_vtotal();
- pGeode->FBgfxdisplaytiming.wVActive = gfx_get_vactive();
- pGeode->FBgfxdisplaytiming.wVSyncStart = gfx_get_vsync_start();
- pGeode->FBgfxdisplaytiming.wVSyncEnd = gfx_get_vsync_end();
- pGeode->FBgfxdisplaytiming.wVBlankStart = gfx_get_vblank_start();
- pGeode->FBgfxdisplaytiming.wVBlankEnd = gfx_get_vblank_end();
- pGeode->FBgfxdisplaytiming.wPolarity = gfx_get_sync_polarities();
-
- pGeode->FBDisplayOffset = gfx_get_display_offset();
-
- if (pGeode->useVGA) {
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- pGeode->FBBIOSMode = pvgaHW->readCrtc(pvgaHW, 0x040);
- }
-
- pGeode->FBCompressionEnable = gfx_get_compression_enable();
- pGeode->FBCompressionOffset = gfx_get_compression_offset();
- pGeode->FBCompressionPitch = gfx_get_compression_pitch();
- pGeode->FBCompressionSize = gfx_get_compression_size();
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ gfx_wait_until_idle();
+
+ /* Save off the current state (should this be somewhere else)? */
+
+ pGeode->FBgfxdisplaytiming.dwDotClock = gfx_get_clock_frequency();
+ pGeode->FBgfxdisplaytiming.wPitch = gfx_get_display_pitch();
+ pGeode->FBgfxdisplaytiming.wBpp = gfx_get_display_bpp();
+ pGeode->FBgfxdisplaytiming.wHTotal = gfx_get_htotal();
+ pGeode->FBgfxdisplaytiming.wHActive = gfx_get_hactive();
+ pGeode->FBgfxdisplaytiming.wHSyncStart = gfx_get_hsync_start();
+ pGeode->FBgfxdisplaytiming.wHSyncEnd = gfx_get_hsync_end();
+ pGeode->FBgfxdisplaytiming.wHBlankStart = gfx_get_hblank_start();
+ pGeode->FBgfxdisplaytiming.wHBlankEnd = gfx_get_hblank_end();
+ pGeode->FBgfxdisplaytiming.wVTotal = gfx_get_vtotal();
+ pGeode->FBgfxdisplaytiming.wVActive = gfx_get_vactive();
+ pGeode->FBgfxdisplaytiming.wVSyncStart = gfx_get_vsync_start();
+ pGeode->FBgfxdisplaytiming.wVSyncEnd = gfx_get_vsync_end();
+ pGeode->FBgfxdisplaytiming.wVBlankStart = gfx_get_vblank_start();
+ pGeode->FBgfxdisplaytiming.wVBlankEnd = gfx_get_vblank_end();
+ pGeode->FBgfxdisplaytiming.wPolarity = gfx_get_sync_polarities();
+
+ pGeode->FBDisplayOffset = gfx_get_display_offset();
+
+ if (pGeode->useVGA) {
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
+
+ pGeode->FBBIOSMode = pvgaHW->readCrtc(pvgaHW, 0x040);
+ }
+
+ pGeode->FBCompressionEnable = gfx_get_compression_enable();
+ pGeode->FBCompressionOffset = gfx_get_compression_offset();
+ pGeode->FBCompressionPitch = gfx_get_compression_pitch();
+ pGeode->FBCompressionSize = gfx_get_compression_size();
#ifdef PNL_SUP
- Pnl_SavePanelState();
+ Pnl_SavePanelState();
#endif
- /* Turn off the VGA */
+ /* Turn off the VGA */
- if (pGeode->useVGA && pGeode->FBVGAActive) {
- unsigned short sequencer;
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
+ if (pGeode->useVGA && pGeode->FBVGAActive) {
+ unsigned short sequencer;
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- /* Map VGA aperture */
- if (!vgaHWMapMem(pScrni))
- return FALSE;
+ /* Map VGA aperture */
+ if (!vgaHWMapMem(pScrni))
+ return FALSE;
- /* Unlock VGA registers */
- vgaHWUnlock(pvgaHW);
+ /* Unlock VGA registers */
+ vgaHWUnlock(pvgaHW);
- /* Save the current state and setup the current mode */
- vgaHWSave(pScrni, &VGAHWPTR(pScrni)->SavedReg, VGA_SR_ALL);
+ /* Save the current state and setup the current mode */
+ vgaHWSave(pScrni, &VGAHWPTR(pScrni)->SavedReg, VGA_SR_ALL);
- /* DISABLE VGA SEQUENCER */
- /* This allows the VGA state machine to terminate. We must delay */
- /* such that there are no pending MBUS requests. */
+ /* DISABLE VGA SEQUENCER */
+ /* This allows the VGA state machine to terminate. We must delay */
+ /* such that there are no pending MBUS requests. */
- gfx_outb(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_CLK_MODE);
- sequencer = gfx_inb(MDC_SEQUENCER_DATA);
- sequencer |= MDC_CLK_MODE_SCREEN_OFF;
- gfx_outb(MDC_SEQUENCER_DATA, sequencer);
+ gfx_outb(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_CLK_MODE);
+ sequencer = gfx_inb(MDC_SEQUENCER_DATA);
+ sequencer |= MDC_CLK_MODE_SCREEN_OFF;
+ gfx_outb(MDC_SEQUENCER_DATA, sequencer);
- gfx_delay_milliseconds(1);
+ gfx_delay_milliseconds(1);
- /* BLANK THE VGA DISPLAY */
- gfx_outw(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_RESET);
- sequencer = gfx_inb(MDC_SEQUENCER_DATA);
- sequencer &= ~MDC_RESET_VGA_DISP_ENABLE;
- gfx_outb(MDC_SEQUENCER_DATA, sequencer);
+ /* BLANK THE VGA DISPLAY */
+ gfx_outw(MDC_SEQUENCER_INDEX, MDC_SEQUENCER_RESET);
+ sequencer = gfx_inb(MDC_SEQUENCER_DATA);
+ sequencer &= ~MDC_RESET_VGA_DISP_ENABLE;
+ gfx_outb(MDC_SEQUENCER_DATA, sequencer);
- gfx_delay_milliseconds(1);
- }
+ gfx_delay_milliseconds(1);
+ }
- /* Set up the memory */
- /* XXX - FIXME - when we alow inital rotation, it should be here */
- GXAllocateMemory(pScrn, pScrni, RR_Rotate_0);
+ /* Set up the memory */
+ /* XXX - FIXME - when we alow inital rotation, it should be here */
+ GXAllocateMemory(pScrn, pScrni, RR_Rotate_0);
- /* Clear the framebuffer */
- memset(pGeode->FBBase + pGeode->displayOffset, 0, pGeode->displaySize);
+ /* Clear the framebuffer */
+ memset(pGeode->FBBase + pGeode->displayOffset, 0, pGeode->displaySize);
- /* Set up the video mode */
- GXSetVideoMode(pScrni, pScrni->currentMode);
- pGeode->curMode = pScrni->currentMode;
+ /* Set up the video mode */
+ GXSetVideoMode(pScrni, pScrni->currentMode);
+ pGeode->curMode = pScrni->currentMode;
- return TRUE;
+ return TRUE;
}
static void
GXLoadPalette(ScrnInfoPtr pScrni,
- int numColors, int *indizes, LOCO * colors, VisualPtr pVisual)
+ int numColors, int *indizes, LOCO * colors, VisualPtr pVisual)
{
- int i, index, color;
+ int i, index, color;
- for (i = 0; i < numColors; i++) {
- index = indizes[i] & 0xFF;
- color = (((unsigned long)(colors[index].red & 0xFF)) << 16) |
- (((unsigned long)(colors[index].green & 0xFF)) << 8) |
- ((unsigned long)(colors[index].blue & 0xFF));
+ for (i = 0; i < numColors; i++) {
+ index = indizes[i] & 0xFF;
+ color = (((unsigned long)(colors[index].red & 0xFF)) << 16) |
+ (((unsigned long)(colors[index].green & 0xFF)) << 8) |
+ ((unsigned long)(colors[index].blue & 0xFF));
- GFX(set_display_palette_entry(index, color));
- }
+ GFX(set_display_palette_entry(index, color));
+ }
}
#ifdef DPMSExtension
@@ -1156,9 +1160,9 @@ GXPanelPower(int enable)
unsigned long power = READ_VID32(RCDF_POWER_MANAGEMENT);
if (enable != 0)
- power |= RCDF_PM_PANEL_POWER_ON;
+ power |= RCDF_PM_PANEL_POWER_ON;
else
- power &= ~RCDF_PM_PANEL_POWER_ON;
+ power &= ~RCDF_PM_PANEL_POWER_ON;
WRITE_VID32(RCDF_POWER_MANAGEMENT, power);
}
@@ -1170,54 +1174,53 @@ GXDPMSSet(ScrnInfoPtr pScrni, int mode, int flags)
pGeode = GEODEPTR(pScrni);
-
- if (!pScrni->vtSema)
- return;
+ if (!pScrni->vtSema)
+ return;
switch (mode) {
case DPMSModeOn:
- /* Screen: On; HSync: On; VSync: On */
- GFX(set_crt_enable(CRT_ENABLE));
+ /* Screen: On; HSync: On; VSync: On */
+ GFX(set_crt_enable(CRT_ENABLE));
#if defined(PNL_SUP)
- if (pGeode->Panel) {
- Pnl_PowerUp();
- GXPanelPower(1);
- }
+ if (pGeode->Panel) {
+ Pnl_PowerUp();
+ GXPanelPower(1);
+ }
#endif
- break;
+ break;
case DPMSModeStandby:
- /* Screen: Off; HSync: Off; VSync: On */
- GFX(set_crt_enable(CRT_STANDBY));
+ /* Screen: Off; HSync: Off; VSync: On */
+ GFX(set_crt_enable(CRT_STANDBY));
#if defined(PNL_SUP)
- if (pGeode->Panel) {
- Pnl_PowerDown();
- GXPanelPower(0);
- }
+ if (pGeode->Panel) {
+ Pnl_PowerDown();
+ GXPanelPower(0);
+ }
#endif
- break;
+ break;
case DPMSModeSuspend:
- /* Screen: Off; HSync: On; VSync: Off */
- GFX(set_crt_enable(CRT_SUSPEND));
+ /* Screen: Off; HSync: On; VSync: Off */
+ GFX(set_crt_enable(CRT_SUSPEND));
#if defined(PNL_SUP)
- if (pGeode->Panel) {
- Pnl_PowerDown();
- GXPanelPower(0);
- }
+ if (pGeode->Panel) {
+ Pnl_PowerDown();
+ GXPanelPower(0);
+ }
#endif
- break;
+ break;
case DPMSModeOff:
- /* Screen: Off; HSync: Off; VSync: Off */
- GFX(set_crt_enable(CRT_DISABLE));
+ /* Screen: Off; HSync: Off; VSync: Off */
+ GFX(set_crt_enable(CRT_DISABLE));
#if defined(PNL_SUP)
- if (pGeode->Panel) {
- Pnl_PowerDown();
- GXPanelPower(0);
- }
+ if (pGeode->Panel) {
+ Pnl_PowerDown();
+ GXPanelPower(0);
+ }
#endif
- break;
+ break;
}
}
#endif
@@ -1225,315 +1228,318 @@ GXDPMSSet(ScrnInfoPtr pScrni, int mode, int flags)
static Bool
GXCreateScreenResources(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- pScreen->CreateScreenResources = pGeode->CreateScreenResources;
- if (!(*pScreen->CreateScreenResources)(pScreen))
- return FALSE;
+ pScreen->CreateScreenResources = pGeode->CreateScreenResources;
+ if (!(*pScreen->CreateScreenResources) (pScreen))
+ return FALSE;
- if (xf86LoaderCheckSymbol("GXRandRSetConfig") && pGeode->rotation != RR_Rotate_0) {
- Rotation (*GXRandRSetConfig)(ScreenPtr pScreen, Rotation rr, int rate, RRScreenSizePtr pSize) = NULL;
- RRScreenSize p;
- Rotation requestedRotation = pGeode->rotation;
+ if (xf86LoaderCheckSymbol("GXRandRSetConfig")
+ && pGeode->rotation != RR_Rotate_0) {
+ Rotation(*GXRandRSetConfig) (ScreenPtr pScreen, Rotation rr, int rate,
+ RRScreenSizePtr pSize) = NULL;
+ RRScreenSize p;
+ Rotation requestedRotation = pGeode->rotation;
- pGeode->rotation = RR_Rotate_0;
+ pGeode->rotation = RR_Rotate_0;
- /* Just setup enough for an initial rotate */
+ /* Just setup enough for an initial rotate */
- p.width = pScreen->width;
- p.height = pScreen->height;
- p.mmWidth = pScreen->mmWidth;
- p.mmHeight = pScreen->mmHeight;
+ p.width = pScreen->width;
+ p.height = pScreen->height;
+ p.mmWidth = pScreen->mmWidth;
+ p.mmHeight = pScreen->mmHeight;
- GXRandRSetConfig = LoaderSymbol("GXRandRSetConfig");
- if (GXRandRSetConfig) {
- pGeode->starting = TRUE;
- (*GXRandRSetConfig) (pScreen, requestedRotation, 0, &p);
- pGeode->starting = FALSE;
+ GXRandRSetConfig = LoaderSymbol("GXRandRSetConfig");
+ if (GXRandRSetConfig) {
+ pGeode->starting = TRUE;
+ (*GXRandRSetConfig) (pScreen, requestedRotation, 0, &p);
+ pGeode->starting = FALSE;
+ }
}
- }
- return TRUE;
+ return TRUE;
}
static Bool
-GXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
+GXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- XF86ModReqInfo shadowReq;
- int maj, min ,ret, rotate;
- BOOL shadowfb = TRUE;
-
- /* FIXME: VGA stuff - what does this do? */
-
- /*
- if (pGeode->useVGA) {
- if (!vgaHWGetHWRec(pScrni))
- return FALSE;
- if (!vgaHWMapMem(pScrni))
- return FALSE;
-
- vgaHWGetIOBase(VGAHWPTR(pScrni));
- }
- */
-
- pGeode->starting = TRUE;
-
- if (!pGeode->NoAccel) {
-
- if (pGeode->useEXA) {
-
- if (!(pGeode->pExa = xnfcalloc(sizeof(ExaDriverRec), 1))) {
- xf86DrvMsg(scrnIndex, X_ERROR, "Couldn't allocate the EXA structure.\n");
- pGeode->NoAccel = TRUE;
- }
- else {
- ExaDriverPtr pExa = pGeode->pExa;
- pExa->memoryBase = pGeode->FBBase;
-
- /* This is set in GXAllocateMemory */
- pExa->memorySize = 0;
-
- pExa->pixmapOffsetAlign = 32;
- pExa->pixmapPitchAlign = 32;
- pExa->flags = EXA_OFFSCREEN_PIXMAPS;
- pExa->maxX = pGeode->maxWidth - 1;
- pExa->maxY = pGeode->maxHeight - 1;
- }
- }
- else {
- pGeode->AccelImageWriteBuffers = xcalloc(sizeof(pGeode->AccelImageWriteBuffers[0]), pGeode->NoOfImgBuffers);
- pGeode->AccelColorExpandBuffers = xcalloc(sizeof(pGeode->AccelColorExpandBuffers[0]), pGeode->NoOfColorExpandLines);
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ XF86ModReqInfo shadowReq;
+ int maj, min, ret, rotate;
+ BOOL shadowfb = TRUE;
+
+ /* FIXME: VGA stuff - what does this do? */
+
+ /*
+ * if (pGeode->useVGA) {
+ * if (!vgaHWGetHWRec(pScrni))
+ * return FALSE;
+ * if (!vgaHWMapMem(pScrni))
+ * return FALSE;
+ *
+ * vgaHWGetIOBase(VGAHWPTR(pScrni));
+ * }
+ */
+
+ pGeode->starting = TRUE;
+
+ if (!pGeode->NoAccel) {
+
+ if (pGeode->useEXA) {
+
+ if (!(pGeode->pExa = xnfcalloc(sizeof(ExaDriverRec), 1))) {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Couldn't allocate the EXA structure.\n");
+ pGeode->NoAccel = TRUE;
+ } else {
+ ExaDriverPtr pExa = pGeode->pExa;
+
+ pExa->memoryBase = pGeode->FBBase;
+
+ /* This is set in GXAllocateMemory */
+ pExa->memorySize = 0;
+
+ pExa->pixmapOffsetAlign = 32;
+ pExa->pixmapPitchAlign = 32;
+ pExa->flags = EXA_OFFSCREEN_PIXMAPS;
+ pExa->maxX = pGeode->maxWidth - 1;
+ pExa->maxY = pGeode->maxHeight - 1;
+ }
+ } else {
+ pGeode->AccelImageWriteBuffers =
+ xcalloc(sizeof(pGeode->AccelImageWriteBuffers[0]),
+ pGeode->NoOfImgBuffers);
+ pGeode->AccelColorExpandBuffers =
+ xcalloc(sizeof(pGeode->AccelColorExpandBuffers[0]),
+ pGeode->NoOfColorExpandLines);
+ }
}
- }
- /* XXX FIXME - Take down any of the structures on failure? */
+ /* XXX FIXME - Take down any of the structures on failure? */
- if (!GXEnterGraphics(pScrn, pScrni))
- return FALSE;
+ if (!GXEnterGraphics(pScrn, pScrni))
+ return FALSE;
- miClearVisualTypes();
+ miClearVisualTypes();
- /* XXX Again - take down anything? */
+ /* XXX Again - take down anything? */
- if (pScrni->bitsPerPixel > 8) {
- if (!miSetVisualTypes(pScrni->depth,
- TrueColorMask, pScrni->rgbBits, pScrni->defaultVisual)) {
- return FALSE;
- }
- } else {
- if (!miSetVisualTypes(pScrni->depth,
- miGetDefaultVisualMask(pScrni->depth),
- pScrni->rgbBits, pScrni->defaultVisual)) {
- return FALSE;
+ if (pScrni->bitsPerPixel > 8) {
+ if (!miSetVisualTypes(pScrni->depth,
+ TrueColorMask, pScrni->rgbBits, pScrni->defaultVisual)) {
+ return FALSE;
+ }
+ } else {
+ if (!miSetVisualTypes(pScrni->depth,
+ miGetDefaultVisualMask(pScrni->depth),
+ pScrni->rgbBits, pScrni->defaultVisual)) {
+ return FALSE;
+ }
}
- }
- miSetPixmapDepths();
+ miSetPixmapDepths();
- /* Point at the visible area to start */
+ /* Point at the visible area to start */
- ret = fbScreenInit(pScrn, pGeode->FBBase + pGeode->displayOffset,
- pScrni->virtualX, pScrni->virtualY,
- pScrni->xDpi, pScrni->yDpi, pGeode->displayWidth,
- pScrni->bitsPerPixel);
+ ret = fbScreenInit(pScrn, pGeode->FBBase + pGeode->displayOffset,
+ pScrni->virtualX, pScrni->virtualY,
+ pScrni->xDpi, pScrni->yDpi, pGeode->displayWidth,
+ pScrni->bitsPerPixel);
- if (!ret)
- return FALSE;
+ if (!ret)
+ return FALSE;
+
+ xf86SetBlackWhitePixels(pScrn);
- xf86SetBlackWhitePixels(pScrn);
+ /* Set up the color ordering */
- /* Set up the color ordering */
+ if (pScrni->bitsPerPixel > 8) {
+ VisualPtr visual = pScrn->visuals + pScrn->numVisuals;
- if (pScrni->bitsPerPixel > 8) {
- VisualPtr visual = pScrn->visuals + pScrn->numVisuals;
- while (--visual >= pScrn->visuals) {
- if ((visual->class | DynamicClass) == DirectColor) {
- visual->offsetRed = pScrni->offset.red;
- visual->offsetGreen = pScrni->offset.green;
- visual->offsetBlue = pScrni->offset.blue;
- visual->redMask = pScrni->mask.red;
- visual->greenMask = pScrni->mask.green;
- visual->blueMask = pScrni->mask.blue;
- }
+ while (--visual >= pScrn->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = pScrni->offset.red;
+ visual->offsetGreen = pScrni->offset.green;
+ visual->offsetBlue = pScrni->offset.blue;
+ visual->redMask = pScrni->mask.red;
+ visual->greenMask = pScrni->mask.green;
+ visual->blueMask = pScrni->mask.blue;
+ }
+ }
}
- }
- /* Must follow the color ordering */
- fbPictureInit(pScrn, 0, 0);
+ /* Must follow the color ordering */
+ fbPictureInit(pScrn, 0, 0);
- if (!pGeode->NoAccel)
- GXAccelInit(pScrn);
+ if (!pGeode->NoAccel)
+ GXAccelInit(pScrn);
- miInitializeBackingStore(pScrn);
- xf86SetBackingStore(pScrn);
+ miInitializeBackingStore(pScrn);
+ xf86SetBackingStore(pScrn);
- /* Set up the soft cursor */
- miDCInitialize(pScrn, xf86GetPointerScreenFuncs());
+ /* Set up the soft cursor */
+ miDCInitialize(pScrn, xf86GetPointerScreenFuncs());
- /* Set up the HW cursor - must follow the soft cursor init */
+ /* Set up the HW cursor - must follow the soft cursor init */
- if (pGeode->tryHWCursor) {
- if (!GXHWCursorInit(pScrn))
- xf86DrvMsg(scrnIndex, X_ERROR, "Hardware cursor initialization failed.\n");
- }
+ if (pGeode->tryHWCursor) {
+ if (!GXHWCursorInit(pScrn))
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Hardware cursor initialization failed.\n");
+ }
- /* Set up the color map */
+ /* Set up the color map */
- if (!miCreateDefColormap(pScrn))
- return FALSE;
+ if (!miCreateDefColormap(pScrn))
+ return FALSE;
- if (pScrni->bitsPerPixel == 8) {
- /* Must follow initialization of the default colormap */
+ if (pScrni->bitsPerPixel == 8) {
+ /* Must follow initialization of the default colormap */
- if (!xf86HandleColormaps(pScrn, 256, 8,
- GXLoadPalette, NULL,
- CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) {
- return FALSE;
+ if (!xf86HandleColormaps(pScrn, 256, 8,
+ GXLoadPalette, NULL,
+ CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) {
+ return FALSE;
+ }
}
- }
-
#ifdef DPMSExtension
- xf86DPMSInit(pScrn, GXDPMSSet, 0);
+ xf86DPMSInit(pScrn, GXDPMSSet, 0);
#endif
- GXInitVideo(pScrn);
+ GXInitVideo(pScrn);
- /* Set up RandR */
+ /* Set up RandR */
- xf86DisableRandR(); /* We provide our own RandR goodness */
+ xf86DisableRandR(); /* We provide our own RandR goodness */
- /* Try to set up the shadow FB for rotation */
+ /* Try to set up the shadow FB for rotation */
- memset(&shadowReq, 0, sizeof(shadowReq));
- shadowReq.majorversion = 1;
- shadowReq.minorversion = 1;
+ memset(&shadowReq, 0, sizeof(shadowReq));
+ shadowReq.majorversion = 1;
+ shadowReq.minorversion = 1;
- rotate = RR_Rotate_0;
+ rotate = RR_Rotate_0;
- if (LoadSubModule(pScrni->module, "shadow",
- NULL, NULL, NULL, &shadowReq, &maj, &min)) {
+ if (LoadSubModule(pScrni->module, "shadow",
+ NULL, NULL, NULL, &shadowReq, &maj, &min)) {
- rotate = RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270;
- shadowSetup(pScrn);
- }
- else {
- LoaderErrorMsg(NULL, "shadow", maj, min);
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "Error loading shadow - rotation not available.\n");
- }
-
- GXRandRInit(pScrn, rotate);
+ rotate = RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270;
+ shadowSetup(pScrn);
+ } else {
+ LoaderErrorMsg(NULL, "shadow", maj, min);
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Error loading shadow - rotation not available.\n");
+ }
- pGeode->PointerMoved = pScrni->PointerMoved;
- pScrni->PointerMoved = GXPointerMoved;
- pGeode->CreateScreenResources = pScrn->CreateScreenResources;
- pScrn->CreateScreenResources = GXCreateScreenResources;
+ GXRandRInit(pScrn, rotate);
- /* XXX - Allow user to specify initial rotation */
- pGeode->rotation = RR_Rotate_0;
+ pGeode->PointerMoved = pScrni->PointerMoved;
+ pScrni->PointerMoved = GXPointerMoved;
+ pGeode->CreateScreenResources = pScrn->CreateScreenResources;
+ pScrn->CreateScreenResources = GXCreateScreenResources;
- pGeode->CloseScreen = pScrn->CloseScreen;
- pScrn->CloseScreen = GXCloseScreen;
- pScrn->SaveScreen = GXSaveScreen;
+ /* XXX - Allow user to specify initial rotation */
+ pGeode->rotation = RR_Rotate_0;
+ pGeode->CloseScreen = pScrn->CloseScreen;
+ pScrn->CloseScreen = GXCloseScreen;
+ pScrn->SaveScreen = GXSaveScreen;
- if (serverGeneration == 1)
- xf86ShowUnusedOptions(pScrni->scrnIndex, pScrni->options);
+ if (serverGeneration == 1)
+ xf86ShowUnusedOptions(pScrni->scrnIndex, pScrni->options);
- pGeode->starting = FALSE;
+ pGeode->starting = FALSE;
- return TRUE;
+ return TRUE;
}
-
static int
-GXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags)
+GXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int p, ret;
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int p, ret;
- if (pMode->type != M_T_USERDEF) {
-
- if (pGeode->Panel) {
- if (pMode->CrtcHDisplay > pGeode->FPBX ||
- pMode->CrtcVDisplay > pGeode->FPBY ||
- gfx_is_panel_mode_supported(pGeode->FPBX, pGeode->FPBY,
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel) < 0) {
-
- return MODE_BAD;
- }
- }
-
- ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay,
- pMode->CrtcVDisplay,
- pScrni->bitsPerPixel, GXGetRefreshRate(pMode));
- if (ret < 0) {
- return MODE_BAD;
- }
- }
+ if (pMode->type != M_T_USERDEF) {
+
+ if (pGeode->Panel) {
+ if (pMode->CrtcHDisplay > pGeode->FPBX ||
+ pMode->CrtcVDisplay > pGeode->FPBY ||
+ gfx_is_panel_mode_supported(pGeode->FPBX, pGeode->FPBY,
+ pMode->CrtcHDisplay, pMode->CrtcVDisplay,
+ pScrni->bitsPerPixel) < 0) {
+
+ return MODE_BAD;
+ }
+ }
- if (pMode->Flags & V_INTERLACE)
- return MODE_NO_INTERLACE;
+ ret = gfx_is_display_mode_supported(pMode->CrtcHDisplay,
+ pMode->CrtcVDisplay,
+ pScrni->bitsPerPixel, GXGetRefreshRate(pMode));
+ if (ret < 0) {
+ return MODE_BAD;
+ }
+ }
+ if (pMode->Flags & V_INTERLACE)
+ return MODE_NO_INTERLACE;
- if (pGeode->tryCompression)
- p = GXCalculatePitchBytes(pMode->CrtcHDisplay, pScrni->bitsPerPixel);
- else
- p = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
+ if (pGeode->tryCompression)
+ p = GXCalculatePitchBytes(pMode->CrtcHDisplay, pScrni->bitsPerPixel);
+ else
+ p = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
- if (p * pMode->CrtcVDisplay > pGeode->FBAvail)
- return MODE_MEM;
+ if (p * pMode->CrtcVDisplay > pGeode->FBAvail)
+ return MODE_MEM;
- return MODE_OK;
+ return MODE_OK;
}
-
/* XXX - Way more to do here */
static Bool
GXEnterVT(int scrnIndex, int flags)
{
- return GXEnterGraphics(NULL, xf86Screens[scrnIndex]);
+ return GXEnterGraphics(NULL, xf86Screens[scrnIndex]);
}
static void
GXLeaveVT(int scrnIndex, int flags)
{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- pGeode->PrevDisplayOffset = gfx_get_display_offset();
- GXLeaveGraphics(xf86Screens[scrnIndex]);
+ pGeode->PrevDisplayOffset = gfx_get_display_offset();
+ GXLeaveGraphics(xf86Screens[scrnIndex]);
}
static void
GXFreeScreen(int scrnIndex, int flags)
{
- GeodeRec *pGeode = GEODEPTR(xf86Screens[scrnIndex]);
-
- if (pGeode->useVGA) {
- if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
- vgaHWFreeHWRec(xf86Screens[scrnIndex]);
- }
-
- GXFreeRec(xf86Screens[scrnIndex]);
+ GeodeRec *pGeode = GEODEPTR(xf86Screens[scrnIndex]);
+
+ if (pGeode->useVGA) {
+ if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
+ vgaHWFreeHWRec(xf86Screens[scrnIndex]);
+ }
+
+ GXFreeRec(xf86Screens[scrnIndex]);
}
void
-GXSetupChipsetFPtr(ScrnInfoPtr pScrn)
+GXSetupChipsetFPtr(ScrnInfoPtr pScrn)
{
- pScrn->PreInit = GXPreInit;
- pScrn->ScreenInit = GXScreenInit;
- pScrn->SwitchMode = GXSwitchMode;
- pScrn->AdjustFrame = GXAdjustFrame;
- pScrn->EnterVT = GXEnterVT;
- pScrn->LeaveVT = GXLeaveVT;
- pScrn->FreeScreen = GXFreeScreen;
- pScrn->ValidMode = GXValidMode;
+ pScrn->PreInit = GXPreInit;
+ pScrn->ScreenInit = GXScreenInit;
+ pScrn->SwitchMode = GXSwitchMode;
+ pScrn->AdjustFrame = GXAdjustFrame;
+ pScrn->EnterVT = GXEnterVT;
+ pScrn->LeaveVT = GXLeaveVT;
+ pScrn->FreeScreen = GXFreeScreen;
+ pScrn->ValidMode = GXValidMode;
}
/* STUPID STUFF */
@@ -1546,42 +1552,40 @@ GXPointerMoved(int index, int x, int y)
Bool frameChanged = FALSE;
if (x < 0)
- x = 0;
+ x = 0;
else if (x >= pScrni->virtualX)
- x = pScrni->virtualX - 1;
+ x = pScrni->virtualX - 1;
if (y < 0)
- y = 0;
+ y = 0;
else if (y >= pScrni->virtualY)
- y = pScrni->virtualY - 1;
+ y = pScrni->virtualY - 1;
if (pScrni->frameX0 > x) {
- pScrni->frameX0 = x;
- pScrni->frameX1 = x + pGeode->HDisplay - 1;
- frameChanged = TRUE;
+ pScrni->frameX0 = x;
+ pScrni->frameX1 = x + pGeode->HDisplay - 1;
+ frameChanged = TRUE;
}
if (pScrni->frameX1 < x) {
- pScrni->frameX1 = x + 1;
- pScrni->frameX0 = x - pGeode->HDisplay + 1;
- frameChanged = TRUE;
+ pScrni->frameX1 = x + 1;
+ pScrni->frameX0 = x - pGeode->HDisplay + 1;
+ frameChanged = TRUE;
}
if (pScrni->frameY0 > y) {
- pScrni->frameY0 = y;
- pScrni->frameY1 = y + pGeode->VDisplay - 1;
- frameChanged = TRUE;
+ pScrni->frameY0 = y;
+ pScrni->frameY1 = y + pGeode->VDisplay - 1;
+ frameChanged = TRUE;
}
if (pScrni->frameY1 < y) {
- pScrni->frameY1 = y;
- pScrni->frameY0 = y - pGeode->VDisplay + 1;
- frameChanged = TRUE;
+ pScrni->frameY1 = y;
+ pScrni->frameY0 = y - pGeode->VDisplay + 1;
+ frameChanged = TRUE;
}
if (frameChanged && pScrni->AdjustFrame != NULL)
- pScrni->AdjustFrame(pScrni->scrnIndex, pScrni->frameX0,
- pScrni->frameY0, 0);
+ pScrni->AdjustFrame(pScrni->scrnIndex, pScrni->frameX0,
+ pScrni->frameY0, 0);
}
-
-
diff --git a/src/amd_gx_randr.c b/src/amd_gx_randr.c
index 6e1505b..bdda3d6 100644
--- a/src/amd_gx_randr.c
+++ b/src/amd_gx_randr.c
@@ -40,300 +40,292 @@
#include "amd.h"
-static int GXRandRIndex;
-static int GXRandRGeneration;
-
-typedef struct _GXRandRInfo {
- int virtualX;
- int virtualY;
- int mmWidth;
- int mmHeight;
- int maxX;
- int maxY;
- Rotation rotation; /* current mode */
- Rotation supported_rotations; /* driver supported */
+static int GXRandRIndex;
+static int GXRandRGeneration;
+
+typedef struct _GXRandRInfo
+{
+ int virtualX;
+ int virtualY;
+ int mmWidth;
+ int mmHeight;
+ int maxX;
+ int maxY;
+ Rotation rotation; /* current mode */
+ Rotation supported_rotations; /* driver supported */
} XF86RandRInfoRec, *XF86RandRInfoPtr;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[GXRandRIndex].ptr)
static int
-GXRandRModeRefresh (DisplayModePtr mode)
+GXRandRModeRefresh(DisplayModePtr mode)
{
if (mode->VRefresh)
- return (int) (mode->VRefresh + 0.5);
+ return (int)(mode->VRefresh + 0.5);
else
- return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);}
+ return (int)(mode->Clock * 1000.0 / mode->HTotal / mode->VTotal +
+ 0.5);
+}
static Bool
-GXRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+GXRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
{
- RRScreenSizePtr pSize;
- ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int refresh0 = 60;
- int maxX = 0, maxY = 0;
+ RRScreenSizePtr pSize;
+ ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int refresh0 = 60;
+ int maxX = 0, maxY = 0;
*rotations = pRandr->supported_rotations;
if (pRandr->virtualX == -1 || pRandr->virtualY == -1) {
- pRandr->virtualX = pScrni->virtualX;
- pRandr->virtualY = pScrni->virtualY;
+ pRandr->virtualX = pScrni->virtualX;
+ pRandr->virtualY = pScrni->virtualY;
}
- for (mode = pScrni->modes; ; mode = mode->next) {
- int refresh = GXRandRModeRefresh (mode);
- if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
-
- if (mode == pScrni->modes)
- refresh0 = refresh;
-
- pSize = RRRegisterSize (pScreen,
- mode->HDisplay, mode->VDisplay,
- pRandr->mmWidth, pRandr->mmHeight);
- if (!pSize)
- return FALSE;
+ for (mode = pScrni->modes;; mode = mode->next) {
+ int refresh = GXRandRModeRefresh(mode);
+
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+
+ if (mode == pScrni->modes)
+ refresh0 = refresh;
+
+ pSize = RRRegisterSize(pScreen,
+ mode->HDisplay, mode->VDisplay,
+ pRandr->mmWidth, pRandr->mmHeight);
+ if (!pSize)
+ return FALSE;
- RRRegisterRate (pScreen, pSize, refresh);
+ RRRegisterRate(pScreen, pSize, refresh);
- if (mode == pScrni->currentMode &&
- mode->HDisplay == pScrni->virtualX && mode->VDisplay == pScrni->virtualY)
- RRSetCurrentConfig (pScreen, pRandr->rotation, refresh, pSize);
- if (mode->next == pScrni->modes)
- break;
+ if (mode == pScrni->currentMode &&
+ mode->HDisplay == pScrni->virtualX
+ && mode->VDisplay == pScrni->virtualY)
+ RRSetCurrentConfig(pScreen, pRandr->rotation, refresh, pSize);
+ if (mode->next == pScrni->modes)
+ break;
}
- if (pRandr->maxX == 0 || pRandr->maxY == 0)
- {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
}
if (pScrni->currentMode->HDisplay != pScrni->virtualX ||
- pScrni->currentMode->VDisplay != pScrni->virtualY) {
-
- mode = pScrni->modes;
- pSize = RRRegisterSize (pScreen,
- pRandr->virtualX, pRandr->virtualY,
- pRandr->mmWidth,
- pRandr->mmHeight);
- if (!pSize)
- return FALSE;
-
- RRRegisterRate (pScreen, pSize, refresh0);
- if (pScrni->virtualX == pRandr->virtualX &&
- pScrni->virtualY == pRandr->virtualY)
- {
- RRSetCurrentConfig (pScreen, pRandr->rotation, refresh0, pSize);
- }
+ pScrni->currentMode->VDisplay != pScrni->virtualY) {
+
+ mode = pScrni->modes;
+ pSize = RRRegisterSize(pScreen,
+ pRandr->virtualX, pRandr->virtualY,
+ pRandr->mmWidth, pRandr->mmHeight);
+ if (!pSize)
+ return FALSE;
+
+ RRRegisterRate(pScreen, pSize, refresh0);
+ if (pScrni->virtualX == pRandr->virtualX &&
+ pScrni->virtualY == pRandr->virtualY) {
+ RRSetCurrentConfig(pScreen, pRandr->rotation, refresh0, pSize);
+ }
}
return TRUE;
}
+static Bool
+GXRandRSetMode(ScreenPtr pScreen,
+ DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight)
+{
+ ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
+
+ int oldWidth = pScreen->width;
+ int oldHeight = pScreen->height;
+ int oldmmWidth = pScreen->mmWidth;
+ int oldmmHeight = pScreen->mmHeight;
+ WindowPtr pRoot = WindowTable[pScreen->myNum];
+ DisplayModePtr currentMode = NULL;
+ Bool ret = TRUE;
+ PixmapPtr pspix = NULL;
+ if (pRoot)
+ (*pScrni->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+
+ if (useVirtual) {
+ pScrni->virtualX = pRandr->virtualX;
+ pScrni->virtualY = pRandr->virtualY;
+ } else {
+ pScrni->virtualX = mode->HDisplay;
+ pScrni->virtualY = mode->VDisplay;
+ }
+ if (pRandr->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
+ pScreen->width = pScrni->virtualY;
+ pScreen->height = pScrni->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
+ } else {
+ pScreen->width = pScrni->virtualX;
+ pScreen->height = pScrni->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
+ }
-static Bool
-GXRandRSetMode (ScreenPtr pScreen,
- DisplayModePtr mode,
- Bool useVirtual,
- int mmWidth,
- int mmHeight)
-{
- ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
-
- int oldWidth = pScreen->width;
- int oldHeight = pScreen->height;
- int oldmmWidth = pScreen->mmWidth;
- int oldmmHeight = pScreen->mmHeight;
- WindowPtr pRoot = WindowTable[pScreen->myNum];
- DisplayModePtr currentMode = NULL;
- Bool ret = TRUE;
- PixmapPtr pspix = NULL;
-
- if (pRoot)
- (*pScrni->EnableDisableFBAccess) (pScreen->myNum, FALSE);
-
- if (useVirtual) {
- pScrni->virtualX = pRandr->virtualX;
- pScrni->virtualY = pRandr->virtualY;
- } else {
- pScrni->virtualX = mode->HDisplay;
- pScrni->virtualY = mode->VDisplay;
- }
-
- if(pRandr->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
- pScreen->width = pScrni->virtualY;
- pScreen->height = pScrni->virtualX;
- pScreen->mmWidth = mmHeight;
- pScreen->mmHeight = mmWidth;
- }
- else {
- pScreen->width = pScrni->virtualX;
- pScreen->height = pScrni->virtualY;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
- }
-
- if (pScrni->currentMode == mode) {
- currentMode = pScrni->currentMode;
- pScrni->currentMode = NULL;
- }
-
- if (!xf86SwitchMode (pScreen, mode))
- {
- ret = FALSE;
- pScrni->virtualX = pScreen->width = oldWidth;
- pScrni->virtualY = pScreen->height = oldHeight;
- pScreen->mmWidth = oldmmWidth;
- pScreen->mmHeight = oldmmHeight;
- pScrni->currentMode = currentMode;
+ if (pScrni->currentMode == mode) {
+ currentMode = pScrni->currentMode;
+ pScrni->currentMode = NULL;
+ }
+
+ if (!xf86SwitchMode(pScreen, mode)) {
+ ret = FALSE;
+ pScrni->virtualX = pScreen->width = oldWidth;
+ pScrni->virtualY = pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
+ pScrni->currentMode = currentMode;
}
/*
* Get the new Screen pixmap ptr as SwitchMode might have called
* ModifyPixmapHeader and xf86EnableDisableFBAccess will put it back...
* Unfortunately.
-
- */
+
+ */
pspix = (*pScreen->GetScreenPixmap) (pScreen);
if (pspix->devPrivate.ptr)
- pScrni->pixmapPrivate = pspix->devPrivate;
+ pScrni->pixmapPrivate = pspix->devPrivate;
xf86ReconfigureLayout();
- xf86SetViewport (pScreen, pScreen->width, pScreen->height);
- xf86SetViewport (pScreen, 0, 0);
+ xf86SetViewport(pScreen, pScreen->width, pScreen->height);
+ xf86SetViewport(pScreen, 0, 0);
if (pRoot)
- (*pScrni->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ (*pScrni->EnableDisableFBAccess) (pScreen->myNum, TRUE);
return ret;
}
-
Bool
-GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize)
+GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation,
+ int rate, RRScreenSizePtr pSize)
{
- ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
-
- DisplayModePtr mode;
- int px, py;
- Bool useVirtual = FALSE;
- int maxX = 0, maxY = 0;
- Rotation oldRotation = pRandr->rotation;
-
- pRandr->rotation = rotation;
-
- if (pRandr->virtualX == -1 || pRandr->virtualY == -1) {
- pRandr->virtualX = pScrni->virtualX;
- pRandr->virtualY = pScrni->virtualY;
- }
-
- miPointerPosition(&px, &py);
-
- for (mode = pScrni->modes; ; mode = mode->next)
- {
- if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
- if (mode->HDisplay == pSize->width &&
- mode->VDisplay == pSize->height &&
- (rate == 0 || GXRandRModeRefresh (mode) == rate))
- break;
- if (mode->next == pScrni->modes) {
- if (pSize->width == pRandr->virtualX &&
- pSize->height == pRandr->virtualY) {
- mode = pScrni->modes;
- useVirtual = TRUE;
- break;
- }
+ ScrnInfoPtr pScrni = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
+
+ DisplayModePtr mode;
+ int px, py;
+ Bool useVirtual = FALSE;
+ int maxX = 0, maxY = 0;
+ Rotation oldRotation = pRandr->rotation;
+
+ pRandr->rotation = rotation;
+
+ if (pRandr->virtualX == -1 || pRandr->virtualY == -1) {
+ pRandr->virtualX = pScrni->virtualX;
+ pRandr->virtualY = pScrni->virtualY;
+ }
+
+ miPointerPosition(&px, &py);
+
+ for (mode = pScrni->modes;; mode = mode->next) {
if (pRandr->maxX == 0 || pRandr->maxY == 0) {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+ if (mode->HDisplay == pSize->width &&
+ mode->VDisplay == pSize->height &&
+ (rate == 0 || GXRandRModeRefresh(mode) == rate))
+ break;
+ if (mode->next == pScrni->modes) {
+ if (pSize->width == pRandr->virtualX &&
+ pSize->height == pRandr->virtualY) {
+ mode = pScrni->modes;
+ useVirtual = TRUE;
+ break;
+ }
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
+ }
+ return FALSE;
}
- return FALSE;
- }
}
- if (pRandr->maxX == 0 || pRandr->maxY == 0)
- {
- pRandr->maxX = maxX;
- pRandr->maxY = maxY;
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
}
- if (!GXRandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) {
- pRandr->rotation = oldRotation;
- return FALSE;
- }
+ if (!GXRandRSetMode(pScreen, mode, useVirtual, pSize->mmWidth,
+ pSize->mmHeight)) {
+ pRandr->rotation = oldRotation;
+ return FALSE;
+ }
- if (pScreen == miPointerCurrentScreen ()) {
- px = (px >= pScreen->width ? (pScreen->width - 1) : px);
- py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+ if (pScreen == miPointerCurrentScreen()) {
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
- xf86SetViewport(pScreen, px, py);
+ xf86SetViewport(pScreen, px, py);
- (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE);
- }
+ (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE);
+ }
- return TRUE;
+ return TRUE;
}
Rotation
GXGetRotation(ScreenPtr pScreen)
{
- XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
- return pRandr->rotation;
+ XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
+
+ return pRandr->rotation;
}
Bool
GXRandRInit(ScreenPtr pScreen, int rotation)
{
- XF86RandRInfoPtr pRandr;
- rrScrPrivPtr rp;
+ XF86RandRInfoPtr pRandr;
+ rrScrPrivPtr rp;
- if (GXRandRGeneration != serverGeneration) {
- GXRandRIndex = AllocateScreenPrivateIndex();
- GXRandRGeneration = serverGeneration;
- }
+ if (GXRandRGeneration != serverGeneration) {
+ GXRandRIndex = AllocateScreenPrivateIndex();
+ GXRandRGeneration = serverGeneration;
+ }
- pRandr = xalloc(sizeof(XF86RandRInfoRec));
- if (pRandr == NULL)
- return FALSE;
+ pRandr = xalloc(sizeof(XF86RandRInfoRec));
+ if (pRandr == NULL)
+ return FALSE;
- if (!RRScreenInit(pScreen)) {
- xfree(pRandr);
- return FALSE;
- }
+ if (!RRScreenInit(pScreen)) {
+ xfree(pRandr);
+ return FALSE;
+ }
- rp = rrGetScrPriv(pScreen);
- rp->rrGetInfo = GXRandRGetInfo;
- rp->rrSetConfig = GXRandRSetConfig;
+ rp = rrGetScrPriv(pScreen);
+ rp->rrGetInfo = GXRandRGetInfo;
+ rp->rrSetConfig = GXRandRSetConfig;
- pRandr->virtualX = -1;
- pRandr->virtualY = -1;
+ pRandr->virtualX = -1;
+ pRandr->virtualY = -1;
- pRandr->mmWidth = pScreen->mmWidth;
- pRandr->mmHeight = pScreen->mmHeight;
+ pRandr->mmWidth = pScreen->mmWidth;
+ pRandr->mmHeight = pScreen->mmHeight;
- pRandr->rotation = RR_Rotate_0;
- pRandr->supported_rotations = rotation;
- pRandr->maxX = pRandr->maxY = 0;
+ pRandr->rotation = RR_Rotate_0;
+ pRandr->supported_rotations = rotation;
+ pRandr->maxX = pRandr->maxY = 0;
- pScreen->devPrivates[GXRandRIndex].ptr = pRandr;
- return TRUE;
+ pScreen->devPrivates[GXRandRIndex].ptr = pRandr;
+ return TRUE;
}
-
-
diff --git a/src/amd_gx_rotate.c b/src/amd_gx_rotate.c
index c9b813a..c5ae30a 100644
--- a/src/amd_gx_rotate.c
+++ b/src/amd_gx_rotate.c
@@ -32,124 +32,127 @@
#include "amd.h"
void *
-GXWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, CARD32 *size, void *closure)
+GXWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode,
+ CARD32 * size, void *closure)
{
- ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- *size = pGeode->displayPitch;
+ *size = pGeode->displayPitch;
- return (pGeode->FBBase + pGeode->displayOffset) +
- row * pGeode->displayPitch + offset;
+ return (pGeode->FBBase + pGeode->displayOffset) +
+ row * pGeode->displayPitch + offset;
}
-static
-void GXGetUpdateFunc(ScrnInfoPtr pScrni, int rotate, ShadowUpdateProc *update)
+static void
+GXGetUpdateFunc(ScrnInfoPtr pScrni, int rotate, ShadowUpdateProc * update)
{
- *update = NULL;
+ *update = NULL;
- switch(rotate) {
- case RR_Rotate_90:
+ switch (rotate) {
+ case RR_Rotate_90:
- if (pScrni->bitsPerPixel == 8)
- *update = shadowUpdateRotate8_90;
- else if (pScrni->bitsPerPixel == 16)
- *update = shadowUpdateRotate16_90;
- else
- *update = shadowUpdateRotate32_90;
+ if (pScrni->bitsPerPixel == 8)
+ *update = shadowUpdateRotate8_90;
+ else if (pScrni->bitsPerPixel == 16)
+ *update = shadowUpdateRotate16_90;
+ else
+ *update = shadowUpdateRotate32_90;
- break;
+ break;
- case RR_Rotate_180:
+ case RR_Rotate_180:
- if (pScrni->bitsPerPixel == 8)
- *update = shadowUpdateRotate8_180;
- else if (pScrni->bitsPerPixel == 16)
- *update = shadowUpdateRotate16_180;
- else
- *update = shadowUpdateRotate32_180;
+ if (pScrni->bitsPerPixel == 8)
+ *update = shadowUpdateRotate8_180;
+ else if (pScrni->bitsPerPixel == 16)
+ *update = shadowUpdateRotate16_180;
+ else
+ *update = shadowUpdateRotate32_180;
- break;
+ break;
- case RR_Rotate_270:
- if (pScrni->bitsPerPixel == 8)
- *update = shadowUpdateRotate8_270;
- else if (pScrni->bitsPerPixel == 16)
- *update = shadowUpdateRotate16_270;
- else
- *update = shadowUpdateRotate32_270;
+ case RR_Rotate_270:
+ if (pScrni->bitsPerPixel == 8)
+ *update = shadowUpdateRotate8_270;
+ else if (pScrni->bitsPerPixel == 16)
+ *update = shadowUpdateRotate16_270;
+ else
+ *update = shadowUpdateRotate32_270;
- break;
- }
+ break;
+ }
}
Bool
GXRotate(ScrnInfoPtr pScrni, DisplayModePtr mode)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
- ShadowUpdateProc update;
- Rotation curr = pGeode->rotation;
- unsigned int pitch, dw;
- PixmapPtr pPixmap;
- BOOL ret;
-
- pPixmap = pScrni->pScreen->GetScreenPixmap(pScrni->pScreen);
- pGeode->rotation = GXGetRotation(pScrni->pScreen);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ ShadowUpdateProc update;
+ Rotation curr = pGeode->rotation;
+ unsigned int pitch, dw;
+ PixmapPtr pPixmap;
+ BOOL ret;
+
+ pPixmap = pScrni->pScreen->GetScreenPixmap(pScrni->pScreen);
+ pGeode->rotation = GXGetRotation(pScrni->pScreen);
+
+ /* Leave if we have nothing to do */
+
+ if (pGeode->rotation == curr && pGeode->curMode == mode) {
+ return TRUE;
+ }
+
+ shadowRemove(pScrni->pScreen, NULL);
+
+ switch (pGeode->rotation) {
+ case RR_Rotate_0:
+ ErrorF("Rotate to 0 degrees\n");
+ pScrni->displayWidth = pGeode->displayWidth;
+ pGeode->Pitch = pGeode->displayPitch;
+ break;
+
+ case RR_Rotate_90:
+ ErrorF("Rotate to 90 degrees\n");
+ pScrni->displayWidth = pScrni->pScreen->width;
+ break;
+
+ case RR_Rotate_180:
+ ErrorF("Rotate to 180 degrees\n");
+ pScrni->displayWidth = pGeode->displayWidth;
+ break;
+
+ case RR_Rotate_270:
+ ErrorF("Rotate to 270 degrees\n");
+ pScrni->displayWidth = pScrni->pScreen->width;
+ break;
+ }
+
+ if (pGeode->rotation != RR_Rotate_0) {
+
+ GXGetUpdateFunc(pScrni, pGeode->rotation, &update);
+ ret =
+ shadowAdd(pScrni->pScreen, pPixmap, update, GXWindowLinear,
+ pGeode->rotation, NULL);
+
+ /* XXX - FIXME - bail gracefully */
+
+ if (!ret)
+ ErrorF("shadowAdd failed\n");
+ }
+
+ if (pGeode->rotation == RR_Rotate_0)
+ pScrni->fbOffset = pGeode->displayOffset;
+ else
+ pScrni->fbOffset = pGeode->shadowOffset;
- /* Leave if we have nothing to do */
+ pScrni->pScreen->ModifyPixmapHeader(pPixmap,
+ pScrni->pScreen->width,
+ pScrni->pScreen->height,
+ pScrni->pScreen->rootDepth,
+ pScrni->bitsPerPixel,
+ PixmapBytePad(pScrni->displayWidth, pScrni->pScreen->rootDepth),
+ (pointer) (pGeode->FBBase + pScrni->fbOffset));
- if (pGeode->rotation == curr && pGeode->curMode == mode) {
return TRUE;
- }
-
- shadowRemove(pScrni->pScreen, NULL);
-
- switch(pGeode->rotation) {
- case RR_Rotate_0:
- ErrorF("Rotate to 0 degrees\n");
- pScrni->displayWidth = pGeode->displayWidth;
- pGeode->Pitch = pGeode->displayPitch;
- break;
-
- case RR_Rotate_90:
- ErrorF("Rotate to 90 degrees\n");
- pScrni->displayWidth = pScrni->pScreen->width;
- break;
-
- case RR_Rotate_180:
- ErrorF("Rotate to 180 degrees\n");
- pScrni->displayWidth = pGeode->displayWidth;
- break;
-
- case RR_Rotate_270:
- ErrorF("Rotate to 270 degrees\n");
- pScrni->displayWidth = pScrni->pScreen->width;
- break;
- }
-
- if (pGeode->rotation != RR_Rotate_0) {
-
- GXGetUpdateFunc(pScrni, pGeode->rotation, &update);
- ret = shadowAdd(pScrni->pScreen, pPixmap, update, GXWindowLinear, pGeode->rotation, NULL);
-
- /* XXX - FIXME - bail gracefully */
-
- if (!ret)
- ErrorF("shadowAdd failed\n");
- }
-
- if (pGeode->rotation == RR_Rotate_0)
- pScrni->fbOffset = pGeode->displayOffset;
- else
- pScrni->fbOffset = pGeode->shadowOffset;
-
- pScrni->pScreen->ModifyPixmapHeader(pPixmap,
- pScrni->pScreen->width,
- pScrni->pScreen->height,
- pScrni->pScreen->rootDepth,
- pScrni->bitsPerPixel,
- PixmapBytePad(pScrni->displayWidth, pScrni->pScreen->rootDepth),
- (pointer)(pGeode->FBBase + pScrni->fbOffset));
-
- return TRUE;
}