summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2006-12-12 17:31:48 -0700
committerJordan Crouse <jordan.crouse@amd.com>2006-12-12 17:34:05 -0700
commitedd326cc9ba5b9f46ca7a4516806a5b7fd3605f0 (patch)
tree5486a7c7b7805d6dfd3fd1c51cf4898b70211cd4
parent98aad0c298e59b6336e9219cc37294644d2d9e95 (diff)
First attempt at adding dynamic rotation (just RandR 1.1 for now)
-rw-r--r--src/Makefile.am3
-rw-r--r--src/amd.h28
-rw-r--r--src/amd_driver.c6
-rw-r--r--src/amd_gx_accel.c149
-rw-r--r--src/amd_gx_cursor.c47
-rw-r--r--src/amd_gx_driver.c3277
-rw-r--r--src/amd_gx_randr.c339
-rw-r--r--src/amd_gx_rotate.c155
-rw-r--r--src/amd_gx_vga.c3
-rw-r--r--src/amd_gx_video.c3
-rw-r--r--src/amd_lx_accel.c2
11 files changed, 1782 insertions, 2230 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index db8c264..e6d1d32 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,9 +45,10 @@ amd_drv_la_SOURCES = \
amd_gx_cursor.c \
amd_gx_dga.c \
amd_gx_video.c \
- amd_gx_shadow.c \
amd_gx_regacc.c \
+ amd_gx_rotate.c \
amd_gx_dcon.c \
+ amd_gx_randr.c \
durango.c \
panel.c \
amd_lx_driver.c \
diff --git a/src/amd.h b/src/amd.h
index 17463c2..d0ff619 100644
--- a/src/amd.h
+++ b/src/amd.h
@@ -236,7 +236,7 @@ VESARec;
#define LX_OT_VOP 0x0004
#define LX_OT_DRGB 0x0008
-typedef struct
+typedef struct _geodeRec
{
/* Private struct for the server */
unsigned long cpu_version;
@@ -270,6 +270,13 @@ typedef struct
#endif
int Pitch; /* display FB pitch */
int AccelPitch; /* accel pitch (may be ShadowPitch) */
+
+ /** new **/
+ int displayPitch; /* The pitch ofthe visible area */
+ int shadowPitch; /* The pitch of the shadow area */
+ int displayOffset; /* The offset of the visible area */
+ int displaySize; /* The size of the visibile area */
+
Bool HWCursor;
Bool NoAccel;
Bool CustomMode;
@@ -300,7 +307,6 @@ typedef struct
Bool TV_Overscan_On;
Bool Panel;
- Bool dconPanel;
/* Flatpanel support from Bios */
int FPBX; /* xres */
@@ -320,10 +326,13 @@ typedef struct
#endif
Bool ShadowFB;
+
+#ifdef HAVE_LX
unsigned char *ShadowPtr;
int ShadowSize;
int ShadowPitch;
int ShadowInFBMem;
+#endif
int orig_virtX; /* original */
int orig_virtY;
@@ -429,6 +438,17 @@ typedef struct
unsigned int cmpSrcFmt, cmpDstFmt;
int cmpOp;
#endif
+
+ DisplayModePtr curMode;
+ int rotation;
+ int displayWidth;
+ Bool starting;
+ Bool tryCompression;
+ Bool tryHWCursor;
+ unsigned int shadowSize;
+ unsigned int shadowOffset;
+
+ Bool (*CreateScreenResources)(ScreenPtr);
}
GeodeRec, *GeodePtr;
@@ -476,7 +496,7 @@ enum
GX_OPTION_TV_OVERSCAN,
GX_OPTION_SHADOW_FB,
GX_OPTION_ROTATE,
- GX_OPTION_FLATPANEL,
+ GX_OPTION_NOPANEL,
GX_OPTION_FLATPANEL_INFO,
GX_OPTION_FLATPANEL_IN_BIOS,
GX_OPTION_COLOR_KEY,
@@ -486,7 +506,7 @@ enum
GX_OPTION_CUSTOM_MODE,
GX_OPTION_FBSIZE,
GX_OPTION_NOVGA,
- GX_OPTION_DCONPANEL,
+ GX_OPTION_PANEL_GEOMETRY,
GX_OPTION_DONT_PROGRAM
}
GX_GeodeOpts;
diff --git a/src/amd_driver.c b/src/amd_driver.c
index 5f6c3d0..b5eab54 100644
--- a/src/amd_driver.c
+++ b/src/amd_driver.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Advanced Micro Devices, Inc.
+ * Copyright (c) 2006 Avanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -204,14 +204,14 @@ OptionInfoRec GX_GeodeOptions[] = {
{GX_OPTION_TV_OVERSCAN, "TVOverscan", OPTV_ANYSTR, {0}, FALSE},
{GX_OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE},
{GX_OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE},
- {GX_OPTION_FLATPANEL, "FlatPanel", OPTV_BOOLEAN, {0}, FALSE},
+ {GX_OPTION_NOPANEL, "NoPanel", OPTV_BOOLEAN, {0}, FALSE},
{GX_OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, FALSE},
{GX_OPTION_OSM_IMG_BUFS, "OSMImageBuffers", OPTV_INTEGER, {0}, FALSE},
{GX_OPTION_OSM_CLR_BUFS, "OSMColorExpBuffers", OPTV_INTEGER, {0}, FALSE},
{GX_OPTION_CUSTOM_MODE, "CustomMode", OPTV_BOOLEAN, {0}, FALSE},
{GX_OPTION_FBSIZE, "FBSize", OPTV_INTEGER, {0}, FALSE },
{GX_OPTION_NOVGA, "NoVGA", OPTV_BOOLEAN, {0}, FALSE },
- {GX_OPTION_DCONPANEL, "DconPanel", OPTV_BOOLEAN, {0}, FALSE },
+ {GX_OPTION_PANEL_GEOMETRY, "PanelGeometry", OPTV_STRING, {0}, FALSE },
{-1, NULL, OPTV_NONE, {0}, FALSE}
};
#endif
diff --git a/src/amd_gx_accel.c b/src/amd_gx_accel.c
index 20c79ef..a179fa5 100644
--- a/src/amd_gx_accel.c
+++ b/src/amd_gx_accel.c
@@ -68,47 +68,6 @@ typedef unsigned short ushort;
#undef uchar
typedef unsigned char uchar;
-#if DEBUGLVL>0
-extern FILE *zdfp;
-
-#if DEBUGTIM>0
-#ifdef NO_RDTSC
-#define DBLOG(n,s...) \
- do { \
- if((DEBUGLVL)>=(n)) { \
- long secs,usecs; \
- getsecs(&secs,&usecs); \
- fprintf(zdfp,"%d,%d ",secs,usecs); \
- fprintf(zdfp,s); \
- } \
- } while(0)
-#else /* ifdef No_RDTSC */
-#define tsc(n) __asm__ __volatile__ ( \
- " rdtsc" \
- : "=a" (((int*)(&(n)))[0]), "=d" (((int*)(&(n)))[1]) \
- : )
-#define DBLOG(n,s...) \
- do { \
- if((DEBUGLVL)>=(n)) { \
- long long t; \
- tsc(t); \
- fprintf(zdfp,"%lld ",t); \
- fprintf(zdfp,s); \
- } \
- } while(0)
-#endif /* ifdef No_RDTSC */
-#else /* if DEBUFTIM */
-#define DBLOG(n,s...) \
- do { \
- if((DEBUGLVL)>=(n)) \
- fprintf(zdfp,s); \
- } while(0)
-#endif /* if DEBUGTIM */
-#else /* if DEBUGLVL > 0 */
-#define DBLOG(n,s...) \
- do {} while(0)
-#endif /* if DEBUGLVL > 0 */
-
#define CALC_FBOFFSET(x, y) \
(((ulong)(y) * gu2_pitch) + ((ulong)(x) << gu2_xshift))
@@ -133,6 +92,8 @@ unsigned int ACCEL_STRIDE;
#define HOOK(fn) localRecPtr->fn = GX##fn
+#define DLOG(l, fmt, args...) ErrorF(fmt, ##args)
+
/* static storage declarations */
typedef struct sGBltBox
@@ -289,7 +250,7 @@ amd_memory_to_screen_blt(unsigned long src, unsigned long dst,
void
GXAccelSync(ScrnInfoPtr pScrni)
{
- DBLOG(3, "GXAccelSync()\n");
+ //ErrorF("GXAccelSync()\n");
#ifndef OPT_ACCEL
gfx_wait_until_idle();
#else
@@ -318,7 +279,7 @@ static void
GXSetupForSolidFill(ScrnInfoPtr pScrni,
int color, int rop, unsigned int planemask)
{
- DBLOG(2, "GXSetupForSolidFill(%#x,%#x,%#x)\n", color, rop, planemask);
+ //ErrorF("GXSetupForSolidFill(%#x,%#x,%#x)\n", color, rop, planemask);
rop &= 0x0F;
#ifndef OPT_ACCEL
gfx_set_solid_pattern(planemask);
@@ -365,7 +326,7 @@ GXSetupForSolidFill(ScrnInfoPtr pScrni,
static void
GXSubsequentSolidFillRect(ScrnInfoPtr pScrni, int x, int y, int w, int h)
{
- DBLOG(2, "GXSubsequentSolidFillRect() at %d,%d %dx%d\n", x, y, w, h);
+ //ErrorF("GXSubsequentSolidFillRect() at %d,%d %dx%d\n", x, y, w, h);
#ifndef OPT_ACCEL
gfx_pattern_fill(x, y, w, h);
#else
@@ -412,16 +373,16 @@ GXSetupForColor8x8PatternFill(ScrnInfoPtr pScrni, int patx, int paty, int rop,
{
GeodeRec *pGeode = GEODEPTR(pScrni);
- DBLOG(2, "GXSetupForColor8x8PatternFill() pat %#x,%#x rop %#x %#x %#x\n",
- patx, paty, rop, planemask, trans_color);
+ //ErrorF("GXSetupForColor8x8PatternFill() pat %#x,%#x rop %#x %#x %#x\n",
+ // patx, paty, rop, planemask, trans_color);
rop &= 0x0F;
gc8x8p = (unsigned long *)FBADDR(patx, paty);
/* gfx_set_solid_pattern is needed to clear src/pat transparency */
gfx_set_solid_pattern(0);
gfx_set_raster_operation(planemask == ~0U ? PDfn[rop] :
(gfx_set_solid_source(planemask), PDfn_SM[rop]));
- gfx2_set_source_stride(pGeode->AccelPitch);
- gfx2_set_destination_stride(pGeode->AccelPitch);
+ gfx2_set_source_stride(pGeode->Pitch);
+ gfx2_set_destination_stride(pGeode->Pitch);
if (trans_color == -1)
gfx2_set_source_transparency(0, 0);
else
@@ -453,9 +414,9 @@ static void
GXSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrni, int patx, int paty,
int x, int y, int w, int h)
{
- DBLOG(2,
- "GXSubsequentColor8x8PatternFillRect() patxy %d,%d at %d,%d %dsx%d\n",
- patx, paty, x, y, w, h);
+ //ErrorF(
+ // "GXSubsequentColor8x8PatternFillRect() patxy %d,%d at %d,%d %dsx%d\n",
+ // patx, paty, x, y, w, h);
gfx2_set_pattern_origin(patx, paty);
gfx2_color_pattern_fill(CALC_FBOFFSET(x, y), w, h, gc8x8p);
}
@@ -491,9 +452,9 @@ static void
GXSetupForMono8x8PatternFill(ScrnInfoPtr pScrni, int patx, int paty,
int fg, int bg, int rop, uint planemask)
{
- DBLOG(2,
- "GXSetupForMono8x8PatternFill() pat %#x,%#x fg %#x bg %#x %#x %#x\n",
- patx, paty, fg, bg, rop, planemask);
+ //ErrorF(
+ //"GXSetupForMono8x8PatternFill() pat %#x,%#x fg %#x bg %#x %#x %#x\n",
+ //patx, paty, fg, bg, rop, planemask);
rop &= 0x0F;
#ifndef OPT_ACCEL
gfx_set_mono_pattern(bg, fg, patx, paty, bg == -1 ? 1 : 0);
@@ -603,8 +564,8 @@ GXSetupForScreenToScreenCopy(ScrnInfoPtr pScrni, int xdir, int ydir, int rop,
else
gfx2_set_source_transparency(trans_color, ~0);
gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- gfx2_set_source_stride(pGeode->AccelPitch);
- gfx2_set_destination_stride(pGeode->AccelPitch);
+ gfx2_set_source_stride(pGeode->Pitch);
+ gfx2_set_destination_stride(pGeode->Pitch);
}
#else
{
@@ -678,7 +639,7 @@ GXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrni,
blt_mode |= MGP_BM_NEG_XDIR;
}
if (y2 > y1) {
- int n = (h - 1) * pGeode->AccelPitch;
+ int n = (h - 1) * pGeode->Pitch;
src += n;
dst += n;
@@ -735,8 +696,8 @@ GXSetupForScanlineImageWrite(ScrnInfoPtr pScrni, int rop, uint planemask,
else
gfx2_set_source_transparency(trans_color, ~0);
gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- gfx2_set_source_stride(pGeode->AccelPitch);
- gfx2_set_destination_stride(pGeode->AccelPitch);
+ gfx2_set_source_stride(pGeode->Pitch);
+ gfx2_set_destination_stride(pGeode->Pitch);
}
/*----------------------------------------------------------------------------
@@ -805,7 +766,7 @@ GXSubsequentImageWriteScanline(ScrnInfoPtr pScrni, int bufno)
1, 0);
#else /* if !GX_USE_OFFSCRN_MEM */
gfx2_color_bitmap_to_screen_blt(0, 0, CALC_FBOFFSET(giwr.x, giwr.y),
- giwr.w, 1, pGeode->AccelImageWriteBuffers[bufno], pGeode->AccelPitch);
+ giwr.w, 1, pGeode->AccelImageWriteBuffers[bufno], pGeode->Pitch);
#endif /* if !GX_USE_OFFSCRN_MEM */
++giwr.y;
#else /* if GX_ONE_LINE_AT_A_TIME */
@@ -825,7 +786,7 @@ GXSubsequentImageWriteScanline(ScrnInfoPtr pScrni, int bufno)
#else /* if !GX_USE_OFFSCRN_MEM */
gfx2_color_bitmap_to_screen_blt(0, 0, CALC_FBOFFSET(giwr.x, giwr.y),
giwr.w, blt_height, pGeode->AccelImageWriteBuffers[0],
- pGeode->AccelPitch);
+ pGeode->Pitch);
#endif /* if !GX_USE_OFFSCRN_MEM */
giwr.h -= blt_height;
giwr.y += blt_height;
@@ -863,16 +824,16 @@ GXSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrni,
"GXSetupForScanlineCPUToScreenColorExpandFill() fg %#x bg %#x "
"rop %#x %#x\n", fg, bg, rop, planemask);
rop &= 0x0F;
- srcpitch = ((pGeode->AccelPitch + 31) >> 5) << 2;
+ srcpitch = ((pGeode->Pitch + 31) >> 5) << 2;
#ifndef OPT_ACCEL
gfx_set_solid_pattern(planemask);
gfx_set_mono_source(bg, fg, bg == -1 ? 1 : 0);
gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
gfx2_set_source_stride(srcpitch);
- gfx2_set_destination_stride(pGeode->AccelPitch);
+ gfx2_set_destination_stride(pGeode->Pitch);
#else
{
- unsigned int stride = (srcpitch << 16) | pGeode->AccelPitch;
+ unsigned int stride = (srcpitch << 16) | pGeode->Pitch;
unsigned int ROP =
BPP | (planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
if (bg == -1)
@@ -971,7 +932,7 @@ GXSubsequentColorExpandScanline(ScrnInfoPtr pScrni, int bufno)
return;
/* convert from bits to dwords */
- srcpitch = ((pGeode->AccelPitch + 31) >> 5) << 2;
+ srcpitch = ((pGeode->Pitch + 31) >> 5) << 2;
gfx2_mono_bitmap_to_screen_blt(0, 0, CALC_FBOFFSET(gc2s.x, gc2s.y),
gc2s.w, blt_height, pGeode->AccelColorExpandBuffers[0], srcpitch);
gc2s.h -= blt_height;
@@ -1047,8 +1008,8 @@ GXSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrni, int fg, int bg,
gfx_set_solid_pattern(planemask);
gfx_set_mono_source(bg, fg, bg == -1 ? 1 : 0);
gfx_set_raster_operation(planemask == ~0U ? SDfn[rop] : SDfn_PM[rop]);
- gfx2_set_source_stride(pGeode->AccelPitch);
- gfx2_set_destination_stride(pGeode->AccelPitch);
+ gfx2_set_source_stride(pGeode->Pitch);
+ gfx2_set_destination_stride(pGeode->Pitch);
}
#else
{
@@ -1430,8 +1391,9 @@ GXSubsequentDashedBresenhamLine(ScrnInfoPtr pScrni,
int trans = (gdln.bg == -1);
unsigned long pat8x8[2];
- DEBUGMSG(0, (0, 0, "BLine %d, %d, %d, %d, %d, %d, %d\n",
- x1, y1, absmaj, absmin, err, len, octant));
+ //ErrorF("BLine %d, %d, %d, %d, %d, %d, %d\n" x1, y1, absmaj, absmin,
+ //err, len, octant);
+
i = phase >= 32 ? (phase -= 32, 1) : 0;
n = 32 - phase;
pat8x8[0] =
@@ -1471,8 +1433,8 @@ GXSubsequentDashedTwoPointLine(ScrnInfoPtr pScrni, int x0, int y0,
long dx, dy, dmaj, dmin, octant, bias;
long axial, diagn, err, len, pat8x8[2];
- DBLOG(2, "GXSubsequentDashedTwoPointLine() %d,%d %d,%d, %#x %d\n",
- x0, y0, x1, y1, flags, phase);
+ //ErrorF("GXSubsequentDashedTwoPointLine() %d,%d %d,%d, %#x %d\n",
+ // x0, y0, x1, y1, flags, phase);
i = phase >= 32 ? (phase -= 32, 1) : 0;
n = 32 - phase;
@@ -1524,14 +1486,15 @@ GXWritePixmap(ScrnInfoPtr pScrni, int x, int y, int w, int h,
{
GeodeRec *pGeode = GEODEPTR(pScrni);
- DBLOG(2, "GXWritePixmap() %d,%d %dx%d, s%#x sp%d %#x %#x %#x %d %d\n",
- x, y, w, h, src, srcwidth, rop, planemask, trans, bpp, depth);
+ //ErrorF("GXWritePixmap() %d,%d %dx%d, s%#x sp%d %#x %#x %#x %d %d\n",
+ // x, y, w, h, src, srcwidth, rop, planemask, trans, bpp, depth);
+
if (bpp == pScrni->bitsPerPixel) {
rop &= 0x0F;
if (rop == GXcopy && trans == -1) {
gfx_wait_until_idle();
amd_memory_to_screen_blt((unsigned long)src,
- (unsigned long)FBADDR(x, y), srcwidth, pGeode->AccelPitch, w,
+ (unsigned long)FBADDR(x, y), srcwidth, pGeode->Pitch, w,
h, bpp);
} else {
gfx_set_solid_pattern(planemask);
@@ -1605,10 +1568,12 @@ amd_gx_exa_DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,
static Bool
amd_gx_exa_PrepareSolid(PixmapPtr pxMap, int alu, Pixel planemask, Pixel fg)
{
- DBLOG(2, "amd_gx_exa_PrepareSolid(%#x,%#x,%#x)\n", alu, planemask, fg);
+
int dstPitch = exaGetPixmapPitch(pxMap);
unsigned int ROP = BPP | (planemask == ~0U ? SDfn[alu] : SDfn_PM[alu]);
+ //ErrorF("amd_gx_exa_PrepareSolid(%#x,%#x,%#x)\n", alu, planemask, fg);
+
BLT_MODE = ((ROP ^ (ROP >> 2)) & 0x33) == 0 ? MGP_BM_SRC_MONO : 0;
if (((ROP ^ (ROP >> 1)) & 0x55) != 0)
BLT_MODE |= MGP_BM_DST_REQ;
@@ -1623,12 +1588,13 @@ amd_gx_exa_PrepareSolid(PixmapPtr pxMap, int alu, Pixel planemask, Pixel fg)
static void
amd_gx_exa_Solid(PixmapPtr pxMap, int x1, int y1, int x2, int y2)
{
- DBLOG(2, "amd_gx_exa_Solid() at %d,%d %d,%d\n", x1, y1, x2, y2);
int bpp = (pxMap->drawable.bitsPerPixel + 7) / 8;
int pitch = exaGetPixmapPitch(pxMap);
unsigned int offset = exaGetPixmapOffset(pxMap) + pitch * y1 + bpp * x1;
unsigned int size = ((x2 - x1) << 16) | (y2 - y1);
+ //ErrorF("amd_gx_exa_Solid() at %d,%d %d,%d\n", x1, y1, x2, y2);
+
GU2_WAIT_PENDING;
WRITE_GP32(MGP_DST_OFFSET, offset);
WRITE_GP32(MGP_WID_HEIGHT, size);
@@ -1641,11 +1607,12 @@ static Bool
amd_gx_exa_PrepareCopy(PixmapPtr pxSrc, PixmapPtr pxDst, int dx, int dy,
int alu, Pixel planemask)
{
- DBLOG(2, "amd_gx_exa_PrepareCopy() dx%d dy%d alu %#x %#x\n",
- dx, dy, alu, planemask);
GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst);
int dstPitch = exaGetPixmapPitch(pxDst);
+ //ErrorF("amd_gx_exa_PrepareCopy() dx%d dy%d alu %#x %#x\n",
+ // dx, dy, alu, planemask);
+
pGeode->cpySrcOffset = exaGetPixmapOffset(pxSrc);
pGeode->cpySrcPitch = exaGetPixmapPitch(pxSrc);
pGeode->cpySrcBpp = (pxSrc->drawable.bitsPerPixel + 7) / 8;
@@ -1668,8 +1635,6 @@ static void
amd_gx_exa_Copy(PixmapPtr pxDst, int srcX, int srcY, int dstX, int dstY,
int w, int h)
{
- DBLOG(2, "amd_gx_exa_Copy() from %d,%d to %d,%d %dx%d\n", srcX, srcY,
- dstX, dstY, w, h);
GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst);
int dstBpp = (pxDst->drawable.bitsPerPixel + 7) / 8;
int dstPitch = exaGetPixmapPitch(pxDst);
@@ -1681,6 +1646,9 @@ amd_gx_exa_Copy(PixmapPtr pxDst, int srcX, int srcY, int dstX, int dstY,
unsigned int size = (w << 16) | h;
unsigned int blt_mode = BLT_MODE;
+ //ErrorF("amd_gx_exa_Copy() from %d,%d to %d,%d %dx%d\n", srcX, srcY,
+ // dstX, dstY, w, h);
+
if (pGeode->cpyDx < 0) {
srcOffset += w * pGeode->cpySrcBpp - 1;
dstOffset += w * dstBpp - 1;
@@ -1863,10 +1831,11 @@ amd_gx_exa_PrepareComposite(int op, PicturePtr pSrc, PicturePtr pMsk,
{
int srcPitch;
- DBLOG(2, "amd_gx_exa_PrepareComposite()\n");
GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst);
amd_gx_exa_fmt_t *sfp, *dfp;
+ //ErrorF("amd_gx_exa_PrepareComposite()\n");
+
if ((sfp = amd_gx_exa_check_format(pSrc)) == NULL)
return FALSE;
if (sfp->alpha_bits == 0 && usesSrcAlpha(op))
@@ -1900,8 +1869,8 @@ amd_gx_exa_Composite(PixmapPtr pxDst, int srcX, int srcY, int maskX,
unsigned int sizes, strides, blt_mode, rop, pitch;
GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst);
- DBLOG(2, "amd_gx_exa_Composite() from %d,%d to %d,%d %dx%d\n",
- srcX, srcY, dstX, dstY, width, height);
+ //ErrorF("amd_gx_exa_Composite() from %d,%d to %d,%d %dx%d\n",
+ // srcX, srcY, dstX, dstY, width, height);
op = pGeode->cmpOp;
if (usesPasses(op)) {
@@ -2029,10 +1998,15 @@ GXAccelInit(ScreenPtr pScrn)
ExaDriverPtr pExa = pGeode->pExa;
#endif
+ ErrorF("ACCELINIT START\n");;
+
gu2_xshift = pScrni->bitsPerPixel >> 4;
- gu2_pitch = pGeode->AccelPitch;
- switch (pGeode->AccelPitch) {
+ /* XXX - fixme - this will change - we'll need to update it */
+
+ gu2_pitch = pGeode->Pitch;
+
+ switch (pGeode->Pitch) {
case 1024:
gu2_yshift = 10;
break;
@@ -2049,7 +2023,7 @@ GXAccelInit(ScreenPtr pScrn)
#ifdef OPT_ACCEL
- ACCEL_STRIDE = (pGeode->AccelPitch << 16) | pGeode->AccelPitch;
+ ACCEL_STRIDE = (pGeode->Pitch << 16) | pGeode->Pitch;
switch (pScrni->bitsPerPixel) {
case 16:
BPP = MGP_RM_BPPFMT_565;
@@ -2065,8 +2039,7 @@ GXAccelInit(ScreenPtr pScrn)
#if XF86EXA
if (pExa && pGeode->useEXA) {
-
- xf86DrvMsg(pScrni->scrnIndex, X_INFO, "Init EXA\n");
+ ErrorF("Init EXA\n");
pExa->exa_major = EXA_VERSION_MAJOR;
pExa->exa_minor = EXA_VERSION_MINOR;
diff --git a/src/amd_gx_cursor.c b/src/amd_gx_cursor.c
index 3630482..87dba0c 100644
--- a/src/amd_gx_cursor.c
+++ b/src/amd_gx_cursor.c
@@ -140,11 +140,40 @@ GXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y)
{
static unsigned long panOffset = 0;
GeodeRec *pGeode = GEODEPTR(pScrni);
+ int savex, savey;
int newX, newY;
- (*pGeode->Rotation) (x, y, pGeode->HDisplay, pGeode->VDisplay, &newX,
- &newY);
- (*pGeode->RBltXlat) (newX, newY, 32, 32, &newX, &newY);
+ /* Adjust xf86HWCursor messing about */
+
+ savex = x + pScrni->frameX0;
+ savey = y + pScrni->frameY0;
+
+ switch(pGeode->rotation) {
+ case RR_Rotate_0:
+ newX = savex; newY = savey;
+ break;
+
+ case RR_Rotate_90:
+ newX = savey;
+ newY = pScrni->pScreen->width - savex;
+ break;
+
+ case RR_Rotate_180:
+ newX = pScrni->pScreen->width - savex;
+ newY = pScrni->pScreen->height - savey;
+ break;
+
+ case RR_Rotate_270:
+ newX = pScrni->pScreen->height - savey;
+ newY = savex;
+ break;
+ }
+
+ newX += pScrni->frameX0;
+ newY += pScrni->frameY0;
+
+ //ErrorF("Turned (%d,%d) into (%d,%d)\n", x,y,newX, newY);
+
if (newX < -31)
newX = -31;
if (newY < -31)
@@ -204,7 +233,10 @@ GXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src)
++rowp;
++mskp;
}
- (*pGeode->Rotation) (x, y, 32, 32, &newX, &newY);
+ //(*pGeode->Rotation) (x, y, 32, 32, &newX, &newY);
+ newX = x;
+ newY = y;
+
i = 7 - i;
n = 31 - newX;
andMask[newY] |= (((mskb >> i) & 1) << n);
@@ -281,10 +313,7 @@ static Bool
GXUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs)
{
ScrnInfoPtr pScrni = XF86SCRNINFO(pScrn);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (pScrni->currentMode->Flags & V_DBLSCAN)
- return FALSE;
- return TRUE;
+ return pGeode->HWCursor;
}
-
-/* End of File */
diff --git a/src/amd_gx_driver.c b/src/amd_gx_driver.c
index 5fc19f1..13fedf7 100644
--- a/src/amd_gx_driver.c
+++ b/src/amd_gx_driver.c
@@ -21,1603 +21,1132 @@
* Neither the name of the Advanced Micro Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
- * */
-
-/*
- * File Contents: This is the main module configures the interfacing with
- * the X server. The individual modules will be loaded based
- * upon the options selected from the XF86Config. This file
- * also has modules for finding supported modes, turning on
- * the modes based on options.
- *
- * Project: Geode Xfree Frame buffer device driver.
- * */
+ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-/* Includes that are used by all drivers */
+
+#include <stdio.h>
+
#include "xf86.h"
#include "xf86_OSproc.h"
-#include "xf86_ansic.h"
-#include "xf86_libc.h"
#include "xf86Resources.h"
-
-/* We may want inb() and outb() */
-#include "compiler.h"
-
-/* We may want to access the PCI config space */
-#include "xf86PciInfo.h"
-#include "xf86Pci.h"
-
-/* Colormap handling stuff */
#include "xf86cmap.h"
-
-#define RC_MAX_DEPTH 24
+#include "compiler.h"
+#include "mipointer.h"
+#include <X11/extensions/randr.h>
+#include "fb.h"
+#include "miscstruct.h"
+#include "micmap.h"
+#include "vbe.h"
+#include "fb.h"
+#include "randrstr.h"
#include "amd.h"
#include "gfx_defs.h"
#include "gfx_regs.h"
#include "panel.h"
-/* Frame buffer stuff */
-#if CFB
-/*
- * If using cfb, cfb.h is required. Select the others for the bpp values
- * the driver supports.
- */
-#define PSZ 8 /* needed for cfb.h */
-#include "cfb.h"
-#undef PSZ
-#include "cfb16.h"
-#include "cfb24.h"
-#include "cfb32.h"
-#else
-#include "fb.h"
-#endif
+/* Bring in VGA functions */
+#include "amd_gx_vga.c"
-#include "shadowfb.h"
+/* Chipset types */
-/* Machine independent stuff */
-#include "mipointer.h"
-#include "mibank.h"
-#include "micmap.h"
-/* All drivers implementing backing store need this */
-#include "mibstore.h"
-#include "vgaHW.h"
-#include "vbe.h"
+#define GX1 0x1
+#define GX 0x2
-/* Check for some extensions */
-#ifdef XFreeXDGA
-#define _XF86_DGA_SERVER_
-#include <X11/extensions/xf86dgastr.h>
-#endif /* XFreeXDGA */
+#define GX_CRT 0x04 | GX
+#define GX_TFT 0x08 | GX
-#ifdef DPMSExtension
-#include "globals.h"
-#include "opaque.h"
-#define DPMS_SERVER
-#include <X11/extensions/dpms.h>
-#endif /* DPMSExtension */
+#define GX_MIN_PITCH 1024
+#define GX_MAX_PITCH 8192
+#define GX_MAX_WIDTH 1600
+#define GX_MIN_HEIGHT 400
+#define GX_MAX_HEIGHT 1200
+#define GX_CB_PITCH 544
+#define GX_CB_SIZE 544
-#include "amd_gx_vga.c"
+static void GXPointerMoved(int index, int x, int y);
-extern SymTabRec GeodeChipsets[];
extern OptionInfoRec GX_GeodeOptions[];
-/* Forward definitions */
-static Bool GXPreInit(ScrnInfoPtr, int);
-static Bool GXScreenInit(int, ScreenPtr, int, char **);
-static Bool GXEnterVT(int, int);
-static void GXLeaveVT(int, int);
-static void GXFreeScreen(int, int);
-void GXAdjustFrame(int, int, int, int);
-Bool GXSwitchMode(int, DisplayModePtr, int);
-static int GXValidMode(int, DisplayModePtr, Bool, int);
-static void GXLoadPalette(ScrnInfoPtr pScrni,
- int numColors, int *indizes, LOCO * colors, VisualPtr pVisual);
-static Bool GXMapMem(ScrnInfoPtr);
-static Bool GXUnmapMem(ScrnInfoPtr);
-static void gx_set_DvLineSize(unsigned int pitch);
-
-extern Bool GXAccelInit(ScreenPtr pScrn);
-extern Bool GXHWCursorInit(ScreenPtr pScrn);
-extern void GXHideCursor(ScrnInfoPtr pScrni);
-extern void GXShowCursor(ScrnInfoPtr pScrni);
-extern void GXPointerMoved(int index, int x, int y);
-extern void GXRotationInit(ScrnInfoPtr pScrni);
-extern void GXShadowFBInit(ScreenPtr pScrn, GeodeRec *pGeode, int bytpp);
-extern void GXInitVideo(ScreenPtr pScrn);
-extern Bool GXDGAInit(ScreenPtr pScrn);
-extern void GXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src);
-
-unsigned char *XpressROMPtr;
-unsigned long fb;
-
-/* Existing Processor Models */
-#define GX1 0x1
-#define GX 0x2
-#define GX_CRT 0x6
-#define GX_TFT 0xA
-
-/* List of symbols from other modules that this module references.The purpose
- * is that to avoid unresolved symbol warnings
- */
extern const char *amdVgahwSymbols[];
extern const char *amdVbeSymbols[];
extern const char *amdInt10Symbols[];
-
-#if CFB
-extern const char *amdCfbSymbols[];
-#else
extern const char *amdFbSymbols[];
-#endif
extern const char *amdXaaSymbols[];
extern const char *amdExaSymbols[];
extern const char *amdRamdacSymbols[];
-extern const char *amdShadowSymbols[];
-
-void GXSetupChipsetFPtr(ScrnInfoPtr pScrn);
-GeodeRec *GXGetRec(ScrnInfoPtr pScrni);
-void get_flatpanel_info(const char *options, int *W, int *H,
- int *D, int *C, int *T);
-void gx_clear_screen(ScrnInfoPtr pScrni, int width, int height, int bpp);
-void gx_enable_dac_power(ScrnInfoPtr pScrni);
-void gx_disable_dac_power(ScrnInfoPtr pScrni);
-
-#if DEBUGLVL>0
-FILE *zdfp = NULL;
-#endif
-void
-GXSetupChipsetFPtr(ScrnInfoPtr pScrn)
+unsigned char *XpressROMPtr;
+
+const char *gxShadowSymbols[] = {
+ "ShadowInit",
+ "ShadowSetup",
+ "ShadowAdd",
+ NULL
+};
+
+static inline void
+gx_enable_dac_power(void)
{
-#if DEBUGLVL>0
- if (zdfp == NULL) {
- zdfp = fopen("/tmp/xwin.log", "w");
-#if DEBUGTIM==0
- setbuf(zdfp, NULL);
-#endif
- }
-#endif
- DEBUGMSG(1, (0, X_INFO, "GXSetupChipsetFPtr!\n"));
- pScrn->PreInit = GXPreInit;
- pScrn->ScreenInit = GXScreenInit;
- pScrn->SwitchMode = GXSwitchMode;
- pScrn->AdjustFrame = GXAdjustFrame;
- pScrn->EnterVT = GXEnterVT;
- pScrn->LeaveVT = GXLeaveVT;
- pScrn->FreeScreen = GXFreeScreen;
- pScrn->ValidMode = GXValidMode;
+ gfx_write_vid32(RCDF_VID_MISC,
+ gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH);
}
-/*----------------------------------------------------------------------------
- * GXGetRec.
- *
- * Description :This function allocates a GeodeRec and hooks into pScrni
- * struct's driverPrivate member of ScreeenInfo structure.
- *
- * Parameters.
- * pScrni :Pointer handle to the screenonfo structure.
- *
- * Returns :allocated pScrninfo structure.
- *
- * Comments :none
- *
- *----------------------------------------------------------------------------
- */
-GeodeRec *
-GXGetRec(ScrnInfoPtr pScrni)
+static inline void
+gx_disable_dac_power(void)
{
- if (!pScrni->driverPrivate) {
- GeodeRec *pGeode;
+ gfx_write_vid32(RCDF_VID_MISC,
+ RCDF_DAC_POWER_DOWN | RCDF_ANALOG_POWER_DOWN |
+ (gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH));
+}
- pGeode = pScrni->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1);
-#if INT10_SUPPORT
- pGeode->vesa = xcalloc(sizeof(VESARec), 1);
-#endif
- }
- return GEODEPTR(pScrni);
+/* Parser for the flatpanel info */
+
+static inline int
+GXGetFPInfo(const char *str, int *width, int *height) {
+
+ int ret = sscanf(str, "%dx%d", width, height);
+ return (ret == 2) ? 0 : 1;
}
-/*----------------------------------------------------------------------------
- * GXFreeRec.
- *
- * Description :This function deallocates and disconnect the GeodeRec from
- * the pScrni struct's driverPrivate member.
- *
- * Parameters.
- * pScrni :Pointer handle to the screenonfo structure.
- *
- * Returns :none
- *
- * Comments :none
- *
- *----------------------------------------------------------------------------
- */
-static void
-GXFreeRec(ScrnInfoPtr pScrni)
+/* I borrowed this function from the i830 driver - its much better
+ then what we had before
+*/
+
+static int
+GXGetRefreshRate(DisplayModePtr pMode)
{
- if (pScrni->driverPrivate == NULL) {
- return;
- }
- xfree(pScrni->driverPrivate);
- pScrni->driverPrivate = NULL;
+ if (pMode->VRefresh)
+ return (int) (pMode->VRefresh + 0.5);
+
+ return (int) (pMode->Clock * 1000.0 / pMode->HTotal / pMode->VTotal + 0.5);
}
-/*----------------------------------------------------------------------------
- * GXSaveScreen.
- *
- * Description :This is todo the screen blanking
- *
- * Parameters.
- * pScrn :Handle to ScreenPtr structure.
- * mode :mode is used by vgaHWSaveScren to check blnak os on.
- *
- * Returns :TRUE on success and FALSE on failure.
- *
- * Comments :none
- *----------------------------------------------------------------------------
- */
-static Bool
-GXSaveScreen(ScreenPtr pScrn, int mode)
-{
- ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
- GeodePtr pGeode = GEODEPTR(pScrni);
+static int
+GXCalculatePitchBytes(unsigned int width, unsigned int bpp) {
- if (pGeode->useVGA && !pScrni->vtSema)
- return vgaHWSaveScreen(pScrn, mode);
- return TRUE;
-}
+ int delta = width * (bpp >> 3);
-/*----------------------------------------------------------------------------
- * get_flatpanel_info.
- *
- * Description: This gets the parameter values of the flatpanel attached.
- *
- * Parameters:
- * options: Pointer to the display options.
- * W: Pointer to the width of the panel
- * H: Pointer to the height of the panel
- * D: Pointer to the depth of the panel.
- * C: Pointer to the color of the panel.
- * T: Pointer to the type of the panel.
- *
- * Returns: none.
- *
- * Comments: none
- *------------------------------------------------------------------------
- */
-void
-get_flatpanel_info(const char *options, int *W, int *H,
- int *D, int *C, int *T)
-{
- char *pnl_opt;
-
- pnl_opt = strtok((char *)options, ":");
- *W = strtoul(pnl_opt, NULL, 0);
- pnl_opt = strtok(NULL, ":");
- *H = strtoul(pnl_opt, NULL, 0);
- pnl_opt = strtok(NULL, ":");
- *D = strtoul(pnl_opt, NULL, 0);
- pnl_opt = strtok(NULL, ":");
- *C = strtoul(pnl_opt, NULL, 0);
- pnl_opt = strtok(NULL, ":");
- *T = strtoul(pnl_opt, NULL, 0);
-
- *C = (*C) ? PNL_COLOR_PANEL : PNL_MONO_PANEL;
-
- switch (*T) {
- case 0:
- *T = PNL_SSTN;
- break;
- case 1:
- *T = PNL_DSTN;
- break;
- case 2:
- default:
- *T = PNL_TFT;
- break;
- }
+ /* Less then 640 has doubling enabled */
- if ((*W != 640) && (*W != 800) && (*W != 1024))
- *W = 640;
+ if (width < 640)
+ delta <<= 1;
- if ((*H != 480) && (*H != 600) && (*H != 768))
- *H = 480;
-}
+ /* Calculate the pitch (compression rquires a power of 2) */
-static xf86MonPtr
-GXProbeDDC(ScrnInfoPtr pScrni, int index)
-{
- vbeInfoPtr pVbe;
- xf86MonPtr ddc = NULL;
+ if (delta > 4096)
+ delta = 8192;
+ else if (delta > 2048)
+ delta = 4096;
+ else if (delta > 1024)
+ delta = 2048;
+ else
+ delta = 1024;
- if (xf86LoadSubModule(pScrni, "vbe")) {
- pVbe = VBEInit(NULL, index);
- ddc = vbeDoEDID(pVbe, NULL);
- vbeFree(pVbe);
- }
- return ddc;
+ return delta;
}
static void
-GXDecodeDDC(ScrnInfoPtr pScrni, xf86MonPtr ddc)
+GXFreeRec(ScrnInfoPtr pScrni)
{
- int i;
-
- DEBUGMSG(1, (0, X_INFO,
- "Detected monitor DDC (%4s) id %d serno %d week %d year %d "
- "nsects %d\n",
- &ddc->vendor.name[0], ddc->vendor.prod_id, ddc->vendor.serial,
- ddc->vendor.week, ddc->vendor.year, ddc->no_sections));
- for (i = 0; i < DET_TIMINGS; ++i) {
- struct detailed_monitor_section *dp = &ddc->det_mon[i];
-
- switch (dp->type) {
- case DT:
- {
- struct detailed_timings *r = &dp->section.d_timings;
-
- DEBUGMSG(1, (0, X_INFO, " mon det timing %0.3f %dx%d\n",
- r->clock / 1000000.0, r->h_active, r->v_active));
- DEBUGMSG(1, (0, X_INFO,
- " mon border %d,%d laced %d stereo %d sync %d, misc"
- " %d\n",
- r->h_border, r->v_border, r->interlaced, r->stereo,
- r->sync, r->misc));
- }
- break;
- case DS_SERIAL:
- {
- char *serial_no = (char *)&dp->section.serial[0];
-
- DEBUGMSG(1, (0, X_INFO, " mon serial %13s\n", serial_no));
- }
- break;
- case DS_ASCII_STR:
- {
- char *ascii = (char *)&dp->section.ascii_data[0];
-
- DEBUGMSG(1, (0, X_INFO, " mon ascii_str %13s\n", ascii));
- }
- break;
- case DS_NAME:
- {
- char *name = (char *)&dp->section.name[0];
-
- DEBUGMSG(1, (0, X_INFO, " mon name %13s\n", name));
- }
- break;
- case DS_RANGES:
- {
- struct monitor_ranges *r = &dp->section.ranges;
-
- DEBUGMSG(1, (0, X_INFO,
- " mon ranges v %d-%d h %d-%d clk %d\n", r->min_v,
- r->max_v, r->min_h, r->max_h, r->max_clock));
- }
- break;
- case DS_WHITE_P:
- {
- struct whitePoints *wp = &dp->section.wp[0];
-
- DEBUGMSG(1, (0, X_INFO,
- " mon whitept %f,%f %f,%f idx %d,%d gamma %f,%f\n",
- wp[1].white_x, wp[1].white_y, wp[2].white_x,
- wp[2].white_y, wp[1].index, wp[2].index,
- wp[1].white_gamma, wp[2].white_gamma));
- }
- break;
- case DS_STD_TIMINGS:
- {
- struct std_timings *t = &dp->section.std_t[0];
-
- DEBUGMSG(1, (0, X_INFO,
- " mon std_timing no size @rate, id\n"));
- for (i = 0; i < 5; ++i)
- DEBUGMSG(1, (0, X_INFO,
- " %d %5dx%-5d @%-4d %d\n", i,
- t[i].hsize, t[i].vsize, t[i].refresh, t[i].id));
- }
- break;
- }
- }
+ if (pScrni->driverPrivate != NULL) {
+ xfree(pScrni->driverPrivate);
+ pScrni->driverPrivate = NULL;
+ }
}
-/*----------------------------------------------------------------------------
- * GXPreInit.
- *
- * Description :This function is called only once ate teh server startup
- *
- * Parameters.
- * pScrni :Handle to ScreenPtr structure.
- * flags :flags may be used to check the probeed one with config.
- *
- * Returns :TRUE on success and FALSE on failure.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-static Bool
-GXPreInit(ScrnInfoPtr pScrni, int flags)
+static void
+GXInitEXAMemory(ScrnInfoPtr pScrni, unsigned int *offset, unsigned int *avail)
{
- ClockRangePtr GeodeClockRange;
- MessageType from;
- int i = 0;
- GeodeRec *pGeode;
- char *mod = NULL;
- xf86MonPtr ddc = NULL;
- OptionInfoRec *GeodeOptions = &GX_GeodeOptions[0];
+ GeodePtr pGeode = GEODEPTR(pScrni);
-#if CFB
- char *reqSymbol = NULL;
-#endif /* CFB */
-#if INT10_SUPPORT
- VESARec *pVesa;
-#endif
- unsigned int PitchInc = 0, minPitch = 0, maxPitch = 0;
- unsigned int minHeight = 0, maxHeight = 0, maxWidth = 0;
- unsigned int SupportFlags;
- const char *s;
- char **modes;
-
- /*
- * Setup the ClockRanges, which describe what clock ranges are
- * available, and what sort of modes they can be used for.
- */
- GeodeClockRange = (ClockRangePtr) xnfcalloc(sizeof(ClockRange), 1);
- GeodeClockRange->next = NULL;
- GeodeClockRange->minClock = 25175;
- GeodeClockRange->maxClock = 229500;
- GeodeClockRange->clockIndex = -1; /* programmable */
- GeodeClockRange->interlaceAllowed = TRUE;
- GeodeClockRange->doubleScanAllowed = FALSE; /* XXX check this */
-
- DEBUGMSG(1, (0, X_INFO, "GXPreInit!\n"));
- /* Allocate driver private structure */
- if (!(pGeode = GXGetRec(pScrni)))
- return FALSE;
-
- if (pScrni->numEntities != 1)
- return FALSE;
-
- pGeode->pEnt = xf86GetEntityInfo(pScrni->entityList[i]);
- if (pGeode->pEnt->resources)
- return FALSE;
- pGeode->Chipset = pGeode->pEnt->chipset;
- pScrni->chipset = (char *)xf86TokenToString(GeodeChipsets,
- pGeode->pEnt->chipset);
+ 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)
+{
+ GeodePtr pGeode = GEODEPTR(pScrni);
+ unsigned int size, i, pitch;
- /* DEBUGMSG(1, (pScrni->scrnIndex, X_ERROR, "PROBEDDC\n")); */
+ /* XXX - FIXME - What if we are out of room? Then what? */
+ /* For now, we NULL them all out. */
- /* Note that we can't do this without VGA */
+ 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");
- if (flags & PROBE_DETECT != 0) {
- ConfiguredMonitor = GXProbeDDC(pScrni, pGeode->pEnt->index);
- return TRUE;
+ for(i = 0; i < pGeode->NoOfImgBuffers; i++)
+ pGeode->AccelImageWriteBuffers[i] = NULL;
}
+ }
- /* Hardware detection */
+ if (pGeode->NoOfColorExpandLines > 0) {
+ pitch = ((pGeode->displayPitch + 31) >> 5) << 2;
+ size = pitch * pGeode->NoOfColorExpandLines;
- pGeode->cpu_version = gfx_detect_cpu();
+ 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");
- if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) {
- int ret;
- Q_WORD msrValue;
- pGeode->DetectedChipSet = GX;
+ for(i = 0; i < pGeode->NoOfImgBuffers; i++)
+ pGeode->AccelColorExpandBuffers[i] = NULL;
+ }
+ }
+}
- /* See if this a CRT or TFT part */
+static
+Bool GXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate) {
+ GeodePtr pGeode = GEODEPTR(pScrni);
- ret = gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue);
+ unsigned int fboffset, fbavail;
+ unsigned int size;
+ unsigned int bytpp = (pScrni->bitsPerPixel + 7) / 8;
+ BOOL ret = TRUE;
- /* We depend heavily on the MSR working, so if it doesn't, there
- * isn't much we can do but complain and move on
- */
+ if (pGeode->tryCompression)
+ pGeode->displayPitch = GXCalculatePitchBytes(pScrni->virtualX, pScrni->bitsPerPixel);
+ else
+ pGeode->displayPitch = ((pScrni->virtualX + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
- if (ret != 0) {
- DEBUGMSG(1, (pScrni->scrnIndex, X_ERROR,
- "MSR read failed (ret=%d)\n", ret));
- }
+ pGeode->Pitch = pGeode->displayPitch;
+ pGeode->displayWidth = pGeode->displayPitch / bytpp;
+ pScrni->displayWidth = pGeode->displayWidth;
- pGeode->DetectedChipSet =
- ((msrValue.low & RCDF_CONFIG_FMT_MASK) ==
- RCDF_CONFIG_FMT_FP) ? GX_TFT : GX_CRT;
+ fbavail = pGeode->FBAvail - 0x4000;
- }
+ pGeode->displayOffset = fboffset = 0;
+ pGeode->displaySize = pScrni->virtualY * pGeode->displayPitch;
- pGeode->vid_version = gfx_detect_video();
- pGeode->FBLinearAddr = gfx_get_frame_buffer_base();
+ fbavail -= pGeode->displaySize;
+ fboffset += pGeode->displaySize;
- /* update the max clock from the one system suports */
- GeodeClockRange->maxClock = gfx_get_max_supported_pixel_clock();
+ if (pGeode->tryCompression) {
+ size = pScrni->virtualY * GX_CB_PITCH;
+ if (size <= fbavail) {
+ pGeode->CBOffset = fboffset;
- /* Set Durango register pointers */
+ fboffset += size;
+ fbavail -= size;
- 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;
+ pGeode->Compression = TRUE;
}
+ else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for compression\n");
+ pGeode->Compression = FALSE;
+ }
+ }
+ if (pGeode->tryHWCursor) {
+ pGeode->CursorSize = 1024;
- pGeode->FBVGAActive = 0;
-
- /* Fill in the monitor field */
- pScrni->monitor = pScrni->confScreen->monitor;
-
- SupportFlags = Support24bppFb | Support32bppFb;
-
- if (!xf86SetDepthBpp(pScrni, 8, 8, 8, SupportFlags)) {
- return FALSE;
- } else {
- if (!((pScrni->depth == 8) ||
- (pScrni->depth == 16) ||
- (pScrni->depth == 24) || (pScrni->depth == 32))) {
- DEBUGMSG(1, (pScrni->scrnIndex, X_ERROR,
- "Given depth (%d bpp) is not supported by this driver\n",
- pScrni->depth));
- return FALSE;
- }
+ 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;
+ }
+ }
- /*This must happen after pScrni->display has been set
- * * because xf86SetWeight references it.
- */
- if (pScrni->depth > 8) {
-
- rgb BitsPerComponent = { 0, 0, 0 };
- rgb BitMask = { 0, 0, 0 };
+ if (!pGeode->NoAccel) {
+ if (pGeode->useEXA)
+ GXInitEXAMemory(pScrni, &fboffset, &fbavail);
+ else
+ GXInitXAAMemory(pScrni, &fboffset, &fbavail);
+ }
- if (pScrni->depth > 16) {
+ pGeode->shadowSize = 0;
- BitsPerComponent.red = 8;
- BitsPerComponent.green = 8;
- BitsPerComponent.blue = 8;
+ 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;
- BitMask.red = 0xFF0000;
- BitMask.green = 0x00FF00;
- BitMask.blue = 0x0000FF;
- }
- if (!xf86SetWeight(pScrni, BitsPerComponent, BitMask)) {
- return FALSE;
- } else {
- /* XXX Check if the returned weight is supported */
- }
+ fboffset += size;
+ fbavail -= size;
}
+ else {
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
+ "Not enough memory for the shadow framebuffer\n");
+ ret = FALSE;
+ }
+ }
- xf86PrintDepthBpp(pScrni);
-
- if (!xf86SetDefaultVisual(pScrni, -1))
- return FALSE;
+ /* Set the memory available for the offscreen pixmaps */
- if (pScrni->depth > 1) {
- Gamma zeros = { 0.0, 0.0, 0.0 };
+ if (!pGeode->NoAccel) {
- if (!xf86SetGamma(pScrni, zeros)) {
- return FALSE;
- }
+ if (pGeode->useEXA && pGeode->pExa) {
+ ExaDriverPtr pExa = pGeode->pExa;
+ pExa->offScreenBase = fboffset;
+ pExa->memorySize = fboffset + fbavail;
}
- /* We use a programmable clock */
- pScrni->progClock = TRUE;
+ /* XXX - We don't use XAA if we are rotated, so this should be fine. Changing the
+ resolution will hurt us though */
- xf86CollectOptions(pScrni, NULL);
+ if (!pGeode->useEXA) {
- xf86ProcessOptions(pScrni->scrnIndex, pScrni->options,
- GeodeOptions);
+ if (!xf86FBManagerRunning(pScrn)) {
- pGeode->useVGA = TRUE;
+ unsigned int offset = fboffset;
+ unsigned int avail = fbavail;
+ RegionRec OffscreenRegion;
+ BoxRec AvailBox;
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOVGA, FALSE))
- pGeode->useVGA = FALSE;
+ /* 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
+ */
- xf86DrvMsg(pScrni->scrnIndex, X_DEFAULT,
- "useVGA=%d\n", pGeode->useVGA);
+ if (pGeode->shadowSize == 0) {
+ size = (pScrn->width * bytpp) * pScrni->virtualX;
+
+ offset += size;
+ avail -= size;
+ }
+ AvailBox.x1 = 0;
+ AvailBox.y1 = (offset + pGeode->displayPitch - 1) / pGeode->displayPitch;
- if (pGeode->useVGA) {
-#if INT10_SUPPORT
- if (!xf86LoadSubModule(pScrni, "int10"))
- return FALSE;
- xf86LoaderReqSymLists(amdInt10Symbols, NULL);
+ AvailBox.x2 = pGeode->displayWidth;
+ AvailBox.y2 = (offset + avail) / pGeode->displayPitch;
- pVesa = pGeode->vesa;
+ if (AvailBox.y1 < AvailBox.y2) {
+ REGION_INIT(pScrn, &OffscreenRegion, &AvailBox, 2);
- if ((pVesa->pInt = xf86InitInt10(pGeode->pEnt->index)) == NULL) {
- DEBUGMSG(1, (pScrni->scrnIndex, X_ERROR,
- "Unable to initialize INT10 support\n"));
- return FALSE;
- }
-#endif
+ if (!xf86InitFBManagerRegion(pScrn, &OffscreenRegion))
+ xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "Memory manager initialization failed.\n");
- if (!xf86LoadSubModule(pScrni, "vgahw"))
- return FALSE;
+ 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");
+ }
+ }
+}
- xf86LoaderReqSymLists(amdVgahwSymbols, NULL);
+static Bool
+GXSaveScreen(ScreenPtr pScrn, int mode)
+{
+ ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
+ GeodePtr pGeode = GEODEPTR(pScrni);
- pGeode->FBAvail = gfx_get_frame_buffer_size();
- }
- else {
- if (!xf86GetOptValInteger(GeodeOptions, GX_OPTION_FBSIZE,
- &(pGeode->FBAvail)))
- pGeode->FBAvail = 0x800000;
- }
+ if (pGeode->useVGA && !pScrni->vtSema)
+ return vgaHWSaveScreen(pScrn, mode);
- if (!GXMapMem(pScrni))
- return FALSE;
+ return TRUE;
+}
- pGeode->FBVGAActive = FALSE;
+static void
+GXProbeDDC(ScrnInfoPtr pScrni, int index)
+{
+ vbeInfoPtr pVbe;
- if (pGeode->useVGA)
- pGeode->FBVGAActive = gu2_get_vga_active();
+ if (xf86LoadSubModule(pScrni, "vbe")) {
+ pVbe = VBEInit(NULL, index);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+ vbeFree(pVbe);
+ }
+}
- /*Set the bits per RGB for 8bpp mode */
+/* From the Intel driver */
- if (pScrni->depth == 8)
- pScrni->rgbBits = 8;
+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;
+}
- from = X_DEFAULT;
+static Bool
+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);
- /*
- * *The preferred method is to use the "hw cursor" option as a tri-state
- * *option, with the default set above.
- */
- pGeode->HWCursor = TRUE;
+ 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;
- if (xf86GetOptValBool(GeodeOptions, GX_OPTION_HW_CURSOR, &pGeode->HWCursor)) {
- from = X_CONFIG;
- }
- /* For compatibility, accept this too (as an override) */
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_SW_CURSOR, FALSE)) {
- from = X_CONFIG;
- pGeode->HWCursor = FALSE;
- }
+ gfx_virt_vidptr = (unsigned char *) xf86MapVidMem(index, VIDMEM_MMIO,
+ gfx_get_vid_register_base(),
+ pGeode->vid_reg_size);
- pGeode->Compression = TRUE;
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOCOMPRESSION, FALSE)) {
- pGeode->Compression = FALSE;
- }
+ gfx_virt_fbptr = (unsigned char *) xf86MapVidMem(index, VIDMEM_FRAMEBUFFER,
+ pGeode->FBLinearAddr,
+ pGeode->FBAvail);
- pGeode->NoAccel = FALSE;
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOACCEL, FALSE)) {
- pGeode->NoAccel = TRUE;
- }
+ XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
- if (!xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_IMG_BUFS,
- &(pGeode->NoOfImgBuffers)))
- pGeode->NoOfImgBuffers = DEFAULT_IMG_LINE_BUFS;
+ pGeode->FBBase = gfx_virt_fbptr;
- if (pGeode->NoOfImgBuffers <= 0)
- pGeode->NoOfImgBuffers = 0;
+ 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;
+}
- if (!xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS,
- &(pGeode->NoOfColorExpandLines)))
- pGeode->NoOfColorExpandLines = DEFAULT_CLR_LINE_BUFS;
+static Bool
+GXPreInit(ScrnInfoPtr pScrni, int flags)
+{
+ GeodePtr pGeode;
+ ClockRangePtr GeodeClockRange;
+ OptionInfoRec *GeodeOptions = &GX_GeodeOptions[0];
- if (pGeode->NoOfColorExpandLines <= 0)
- pGeode->NoOfColorExpandLines = 0;
+ rgb defaultWeight = { 0, 0, 0 };
+ int ret, modecnt;
+ int maj, min;
+ char *s, *panelgeo;
+ char **modes;
+ pGeode = pScrni->driverPrivate = xnfcalloc(sizeof(GeodeRec), 1);
-#ifdef XF86EXA
- if (!xf86GetOptValInteger(GeodeOptions, GX_OPTION_EXA_SCRATCH_BFRSZ,
- &(pGeode->exaBfrSz)))
- pGeode->exaBfrSz = DEFAULT_EXA_SCRATCH_BFRSZ;
+ if (pGeode == NULL)
+ return FALSE;
- if (pGeode->exaBfrSz <= 0)
- pGeode->exaBfrSz = 0;
+#if INT10_SUPPORT
+ pGeode->vesa = xcalloc(sizeof(VESARec), 1);
#endif
-
+ if (pScrni->numEntities != 1)
+ return FALSE;
- pGeode->CustomMode = FALSE;
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_CUSTOM_MODE, FALSE)) {
- pGeode->CustomMode = TRUE;
- }
+ pGeode->pEnt = xf86GetEntityInfo(pScrni->entityList[0]);
- pGeode->Panel = FALSE;
+ if (pGeode->pEnt->resources)
+ return FALSE;
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_FLATPANEL, FALSE)) {
- pGeode->Panel = TRUE;
- }
+ /* ISSUE - this won't work without VGA, but its too early to know if we can use VGA or not */
- if (pGeode->DetectedChipSet == GX_TFT) {
- pGeode->Panel = TRUE;
- }
+ if (flags & PROBE_DETECT) {
+ GXProbeDDC(pScrni, pGeode->pEnt->index);
+ return TRUE;
+ }
- pGeode->dconPanel = FALSE;
+ pGeode->cpu_version = gfx_detect_cpu();
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_DCONPANEL, FALSE)) {
- pGeode->dconPanel = TRUE;
- gx_dcon_init();
- }
+ if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) {
+ int ret;
+ QQ_WORD msrValue;
- /* Force the Panel on if on a GX TFT part, no CRT support anyway */
+ pGeode->DetectedChipSet = GX_CRT;
- if (pGeode->DetectedChipSet == GX_TFT) {
- pGeode->Panel = TRUE;
- }
+ ret = gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue);
- /* If on a CRT and Panel flag set, disable Panel */
- if ((pGeode->DetectedChipSet == GX_CRT) && (pGeode->Panel)) {
- pGeode->dconPanel = FALSE;
- pGeode->Panel = FALSE;
- }
-
-#if defined(PNL_SUP)
- /* If dconPanel is selected - then hard wire the settings */
- /* Otherwise, suck the timings out of the BIOS */
-
- if (pGeode->dconPanel) {
- pGeode->FPBX = DCON_DEFAULT_XRES;
- pGeode->FPBY = DCON_DEFAULT_YRES;
- pGeode->FPBB = DCON_DEFAULT_BPP;
- pGeode->FPBF = DCON_DEFAULT_REFRESH;
- DEBUGMSG(1, (pScrni->scrnIndex, X_ERROR, "DCON!\n"));
- } else if (pGeode->Panel) {
- if ((pGeode->Panel = Pnl_IsPanelEnabledInBIOS()))
- Pnl_GetPanelInfoFromBIOS(&pGeode->FPBX, &pGeode->FPBY,
- &pGeode->FPBB, &pGeode->FPBF);
- }
+ if (!ret)
+ pGeode->DetectedChipSet =
+ ((msrValue.low & RCDF_CONFIG_FMT_MASK) == RCDF_CONFIG_FMT_FP) ? GX_TFT : GX_CRT;
+ }
+ else
+ pGeode->DetectedChipSet = GX1;
- if (pGeode->Panel)
- Pnl_PowerUp();
- else
- Pnl_PowerDown();
-#endif
+ pGeode->vid_version = gfx_detect_video();
+ pGeode->FBLinearAddr = gfx_get_frame_buffer_base();
- pGeode->useEXA = FALSE;
- from = X_DEFAULT;
- if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ACCEL_METHOD))) {
- if (!xf86NameCmp(s, "XAA")) {
- from = X_CONFIG;
- pGeode->useEXA = FALSE;
-#if XF86EXA
- } else if (!xf86NameCmp(s, "EXA")) {
- from = X_CONFIG;
- pGeode->useEXA = TRUE;
-#endif
- } else
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Unknown acceleration architecture - %s\n", s);
- }
+ 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;
+ }
- xf86DrvMsg(pScrni->scrnIndex, from,
- "Using %s acceleration architecture\n",
- pGeode->useEXA ? "EXA" : "XAA");
+ /* Fill in the monitor information */
+ pScrni->monitor = pScrni->confScreen->monitor;
- pGeode->ShadowFB = FALSE;
- if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_SHADOW_FB, FALSE)) {
- pGeode->ShadowFB = TRUE;
- pGeode->NoAccel = TRUE;
- }
+ 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;
+ }
- pGeode->Rotate = 0;
- if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ROTATE))) {
+ xf86PrintDepthBpp(pScrni);
- if (!xf86NameCmp(s, "CW"))
- pGeode->Rotate = 1;
- else if (!xf86NameCmp(s, "INVERT"))
- pGeode->Rotate = 2;
- else if (!xf86NameCmp(s, "CCW"))
- pGeode->Rotate = 3;
+ if (!xf86SetWeight(pScrni, defaultWeight, defaultWeight))
+ return FALSE;
+ if (!xf86SetDefaultVisual(pScrni, -1))
+ return FALSE;
- if (pGeode->Rotate == 0) {
- DEBUGMSG(1, (pScrni->scrnIndex, X_CONFIG,
- "\"%s\" is not a valid value for Option \"Rotate\"\n",
- s));
- DEBUGMSG(1, (pScrni->scrnIndex, X_INFO,
- "Valid options are \"CW\", \"INVERT\" or \"CCW\"\n"));
- }
- }
+ pScrni->progClock = TRUE;
+ xf86CollectOptions(pScrni, NULL);
+ xf86ProcessOptions(pScrni->scrnIndex, pScrni->options, GeodeOptions);
- if (pGeode->Rotate == 1)
- xf86DrvMsg(pScrni->scrnIndex, X_CONFIG, "Rotating screen clockwise\n");
- else if (pGeode->Rotate == 2)
- xf86DrvMsg(pScrni->scrnIndex, X_CONFIG, "Rotating screen 180 degrees\n");
- else if (pGeode->Rotate == 3)
- xf86DrvMsg(pScrni->scrnIndex, X_CONFIG, "Rotating screen 180 counter clockwise\n");
-
- if (pGeode->Rotate != 0) {
- xf86DrvMsg(pScrni->scrnIndex, X_CONFIG, "Option 'Rotate' will disable acceleration and enable shadow\n");
- pGeode->NoAccel = TRUE;
- pGeode->ShadowFB = TRUE;
- }
+ /* Set up our various options that may get reversed as we go on */
+ pGeode->useVGA = TRUE;
+ pGeode->FBVGAActive = FALSE;
- /* XXX Init further private data here */
+ pGeode->tryHWCursor = TRUE;
+ pGeode->tryCompression = TRUE;
- /*
- * * This shouldn't happen because such problems should be caught in
- * * GeodeProbe(), but check it just in case.
- */
- if (pScrni->chipset == NULL) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "ChipID 0x%04X is not recognised\n", pGeode->Chipset);
- return FALSE;
- }
+ pGeode->NoAccel = FALSE;
+ pGeode->CustomMode = FALSE;
+ pGeode->useEXA = FALSE;
- if (pGeode->Chipset < 0) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "Chipset %s is not recognised\n", pScrni->chipset);
- return FALSE;
- }
+ if (pGeode->DetectedChipSet == GX_TFT)
+ pGeode->Panel = TRUE;
+ else if (pGeode->DetectedChipSet == GX_CRT)
+ pGeode->Panel = FALSE;
- if (pScrni->memPhysBase == 0) {
- from = X_PROBED;
- pScrni->memPhysBase = gfx_get_frame_buffer_base();
- }
+ pGeode->NoOfImgBuffers = DEFAULT_IMG_LINE_BUFS;
+ pGeode->NoOfColorExpandLines = DEFAULT_CLR_LINE_BUFS;
+ pGeode->exaBfrSz = DEFAULT_EXA_SCRATCH_BFRSZ;
- pScrni->fbOffset = 0;
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOVGA, FALSE))
+ pGeode->useVGA = FALSE;
- if (pGeode->pEnt->device->videoRam == 0) {
- from = X_PROBED;
- pScrni->videoRam = pGeode->FBAvail / 1024;
- } else {
- pScrni->videoRam = pGeode->pEnt->device->videoRam;
- from = X_CONFIG;
- }
+ xf86GetOptValBool(GeodeOptions, GX_OPTION_HW_CURSOR, &pGeode->tryHWCursor);
+
+ /* For compatability - allow SWCursor too */
- /*
- * * xf86ValidateModes will check that the mode HTotal and VTotal values
- * * don't exceed the chipset's limit if pScrni->maxHValue adn
- * * pScrni->maxVValue are set. Since our GXValidMode()
- * * already takes care of this, we don't worry about setting them here.
- */
- /* Select valid modes from those available */
-
- /*
- * * min pitch 1024, max 2048 (Pixel count)
- * * min height 480, max 1024 (Pixel count)
- */
-
- minPitch = 1024;
- maxPitch = 8192; /* Can support upto 1600x1200 32Bpp */
- maxWidth = 1600;
- minHeight = 400;
- maxHeight = 1200; /* Can support upto 1600x1200 32Bpp */
-
-
- if (pGeode->Compression) {
- if (pScrni->depth > 16) {
- PitchInc = 4096;
- } else if (pScrni->depth == 16) {
- PitchInc = 2048;
- } else {
- PitchInc = 1024;
- }
- }
- else {
- /* When compression is off - use a linear pitch */
- if (pScrni->depth < 16)
- PitchInc = 1600;
- else if (pScrni->depth == 16)
- PitchInc = 3200;
- else
- PitchInc = 6400;
- }
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_SW_CURSOR, FALSE))
+ pGeode->tryHWCursor = FALSE;
+
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOCOMPRESSION, FALSE))
+ pGeode->tryCompression = FALSE;
- PitchInc <<= 3; /* in bits */
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOACCEL, FALSE))
+ pGeode->NoAccel = TRUE;
- pGeode->maxWidth = maxWidth;
- pGeode->maxHeight = maxHeight;
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_IMG_BUFS, &(pGeode->NoOfImgBuffers));
- /* by default use what user sets in the XF86Config file */
- modes = pScrni->display->modes;
+ if (pGeode->NoOfImgBuffers <= 0)
+ pGeode->NoOfImgBuffers = 0;
- if (ddc != NULL && pScrni->monitor != NULL
- && pScrni->monitor->DDC == NULL) {
- pScrni->monitor->DDC = ddc;
- GXDecodeDDC(pScrni, ddc);
- }
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS, &(pGeode->NoOfColorExpandLines));
- i = xf86ValidateModes(pScrni,
- pScrni->monitor->Modes,
- modes, GeodeClockRange,
- NULL, minPitch, maxPitch,
- PitchInc, minHeight, maxHeight,
- pScrni->display->virtualX,
- pScrni->display->virtualY, pGeode->FBAvail, LOOKUP_BEST_REFRESH);
-
- if (i == -1) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
- GXFreeRec(pScrni);
- return FALSE;
- }
+ if (pGeode->NoOfColorExpandLines <= 0)
+ pGeode->NoOfColorExpandLines = 0;
+
+ xf86GetOptValInteger(GeodeOptions, GX_OPTION_OSM_CLR_BUFS, &(pGeode->exaBfrSz));
- /* Prune the modes marked as invalid */
- xf86PruneDriverModes(pScrni);
+ if (pGeode->exaBfrSz <= 0)
+ pGeode->exaBfrSz = 0;
+
+ /* We are going to see if we can get rid of this option */
- if (i == 0 || pScrni->modes == NULL) {
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No valid modes were found\n");
- GXFreeRec(pScrni);
- return FALSE;
- }
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_CUSTOM_MODE, FALSE))
+ pGeode->CustomMode = TRUE;
- xf86SetCrtcForModes(pScrni, 0);
+ if (pGeode->Panel == TRUE) {
+ if (xf86ReturnOptValBool(GeodeOptions, GX_OPTION_NOPANEL, FALSE))
+ pGeode->Panel = FALSE;
+ }
- /* Set the current mode to the first in the list */
- pScrni->currentMode = pScrni->modes;
- DEBUGMSG(1, (0, X_INFO, "GXPreInit(12)!\n"));
+ panelgeo = xf86GetOptValString(GeodeOptions, GX_OPTION_PANEL_GEOMETRY);
- /* Print the list of modes being used */
- xf86PrintModes(pScrni);
+ if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ACCEL_METHOD))) {
+ if (!xf86NameCmp(s, "EXA"))
+ pGeode->useEXA = TRUE;
+ }
- /* Set the display resolution */
- xf86SetDpi(pScrni, 0, 0);
- /* Load bpp-specific modules */
- mod = NULL;
+ xf86DrvMsg(pScrni->scrnIndex, X_INFO, "Using %s acceleration architecture\n",
+ pGeode->useEXA ? "EXA" : "XAA");
-#if CFB
- /* Load bpp-specific modules */
- switch (pScrni->bitsPerPixel) {
- case 8:
- mod = "cfb";
- reqSymbol = "cfbScreenInit";
- break;
- case 16:
- mod = "cfb16";
- reqSymbol = "cfb16ScreenInit";
- break;
- case 24:
- mod = "cfb24";
- reqSymbol = "cfb24ScreenInit";
- break;
- case 32:
- mod = "cfb32";
- reqSymbol = "cfb32ScreenInit";
- break;
- default:
- return FALSE;
- }
+ /* Set up the panel */
- if (mod && xf86LoadSubModule(pScrni, mod) == NULL) {
- GXFreeRec(pScrni);
- return FALSE;
+ if (pGeode->Panel) {
+ if (panelgeo != NULL) {
+ if (GXGetFPInfo(panelgeo, &pGeode->FPBX, &pGeode->FPBY))
+ pGeode->Panel = FALSE;
}
-
- xf86LoaderReqSymbols(reqSymbol, NULL);
-#else
- if (xf86LoadSubModule(pScrni, "fb") == NULL) {
- GXFreeRec(pScrni);
- return 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);
}
-
- xf86LoaderReqSymLists(amdFbSymbols, NULL);
#endif
+ }
- if (pGeode->NoAccel == FALSE) {
- const char *module = "xaa";
- const char **symbols = &amdXaaSymbols[0];
+ /* Set up the VGA */
-#if XF86EXA
- if (pGeode->useEXA) {
- module = "exa";
- symbols = &amdExaSymbols[0];
- }
-#endif
- if (!xf86LoadSubModule(pScrni, module)) {
- GXFreeRec(pScrni);
- return FALSE;
- }
+ if (pGeode->useVGA) {
+#if INT10_SUPPORT
+ VESARec *pVesa;
- xf86LoaderReqSymLists(symbols, NULL);
+ 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;
}
-
- if (pGeode->HWCursor == TRUE) {
- if (!xf86LoadSubModule(pScrni, "ramdac")) {
- GXFreeRec(pScrni);
- return FALSE;
- }
-
- xf86LoaderReqSymLists(amdRamdacSymbols, NULL);
+#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, module)) {
+ GXFreeRec(pScrni);
+ return FALSE;
}
- /* Load shadowfb if needed */
- if (pGeode->ShadowFB) {
- if (!xf86LoadSubModule(pScrni, "shadowfb")) {
- GXFreeRec(pScrni);
- return FALSE;
- }
+ xf86LoaderReqSymLists(symbols, NULL);
+ }
- xf86LoaderReqSymLists(amdShadowSymbols, NULL);
+ if (pGeode->tryHWCursor == TRUE) {
+ if (!xf86LoadSubModule(pScrni, "ramdac")) {
+ GXFreeRec(pScrni);
+ return FALSE;
}
- if (xf86RegisterResources(pGeode->pEnt->index, NULL, ResExclusive)) {
- DEBUGMSG(1, (pScrni->scrnIndex, X_ERROR,
- "xf86RegisterResources() found resource conflicts\n"));
- GXFreeRec(pScrni);
- return FALSE;
- }
+ xf86LoaderReqSymLists(amdRamdacSymbols, NULL);
+ }
- GXUnmapMem(pScrni);
- 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;
}
-/*----------------------------------------------------------------------------
- * GXRestore.
- *
- * Description :This function restores the mode that was saved on server
- entry
- * Parameters.
- * pScrni :Handle to ScreenPtr structure.
- * Pmode :poits to screen mode
- *
- * Returns :none.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
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);
+ }
}
-
-/*----------------------------------------------------------------------------
- * GXCalculatePitchBytes.
- *
- * Description :This function restores the mode that was saved on server
- *
- * Parameters.
- * pScrni :Handle to ScreenPtr structure.
- * Pmode :Points to screenmode
- *
- * Returns :none.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-static int
-GXCalculatePitchBytes(unsigned int width, unsigned int bpp)
+
+static Bool
+GXUnmapMem(ScrnInfoPtr pScrni)
{
- int lineDelta = width * (bpp >> 3);
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- if (width < 640) {
- /* low resolutions have both pixel and line doubling */
- DEBUGMSG(1, (0, X_PROBED, "lower resolution %d %d\n",
- width, lineDelta));
- lineDelta <<= 1;
- }
- /* needed in Rotate mode when in accel is turned off */
- if (1) { /*!pGeode->NoAccel */
- if (lineDelta > 4096)
- lineDelta = 8192;
- else if (lineDelta > 2048)
- lineDelta = 4096;
- else if (lineDelta > 1024)
- lineDelta = 2048;
- else
- lineDelta = 1024;
- }
+ /* unmap all the memory map's */
- DEBUGMSG(1, (0, X_PROBED, "pitch %d %d\n", width, lineDelta));
+ xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_regptr, pGeode->cpu_reg_size);
- return lineDelta;
+ 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;
}
-/*----------------------------------------------------------------------------
- * GXGetRefreshRate.
- *
- * Description :This function restores the mode that saved on server
- *
- * Parameters.
- * Pmode :Pointer to the screen modes
- *
- * Returns :It returns the selected refresh rate.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-static int
-GXGetRefreshRate(DisplayModePtr pMode)
+static void
+GXSetDvLineSize(unsigned int pitch)
{
-#define THRESHOLD 2
- unsigned int i;
- static int validRates[] = { 56, 60, 70, 72, 75, 85, 90, 100 }; /* Hz */
- unsigned long dotClock;
- int refreshRate;
- int selectedRate;
-
- dotClock = pMode->SynthClock * 1000;
- refreshRate = dotClock / pMode->CrtcHTotal / pMode->CrtcVTotal;
-
- if ((pMode->CrtcHTotal < 640) && (pMode->CrtcVTotal < 480))
- refreshRate >>= 2; /* double pixel and double scan */
-
- DEBUGMSG(1, (0, X_PROBED, "dotclock %lu %d\n", dotClock, refreshRate));
-
- selectedRate = validRates[0];
-
- for (i = 0; i < (sizeof(validRates) / sizeof(validRates[0])); i++) {
- if (validRates[i] < (refreshRate + THRESHOLD)) {
- selectedRate = validRates[i];
- }
- }
-
- return selectedRate;
+ 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);
}
-void
-gx_clear_screen(ScrnInfoPtr pScrni, int width, int height, int bpp)
-{
- /* no accels, mode is not yet set */
- GeodeRec *pGeode = GEODEPTR(pScrni);
- unsigned long offset = gfx_get_display_offset();
- unsigned long pitch = gfx_get_display_pitch();
- unsigned long n = width * ((bpp + 7) >> 3);
-
- DEBUGMSG(1, (0, X_PROBED, "clear screen %lx %d %d %d %ld %ld\n", offset,
- width, height, bpp, pitch, n));
- while (height > 0) {
- memset(pGeode->FBBase + offset, 0, n);
- offset += pitch;
- --height;
- }
-}
+/* XXX - this is nothing like the original function - not sure exactly what the purpose is for this quite yet */
-void
-gx_clear_fb(ScrnInfoPtr pScrni)
+static void
+GXAdjustFrame(int scrnIndex, int x, int y, int flags)
{
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
GeodeRec *pGeode = GEODEPTR(pScrni);
- unsigned char *fb = pGeode->FBBase + pGeode->FBOffset;
-
- memset(fb, 0, pGeode->FBSize);
- if (pGeode->ShadowPtr != NULL && pGeode->ShadowPtr != fb)
- memset(pGeode->ShadowPtr, 0, pGeode->ShadowSize);
-}
-
-void
-gx_set_DvLineSize(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;
- }
+ unsigned long offset;
- /* WRITE DIRTY/VALID CONTROL WITH LINE LENGTH */
+ offset =
+ pGeode->FBOffset + y * pGeode->Pitch + x * (pScrni->bitsPerPixel >> 3);
- temp = READ_REG32(MDC_DV_CTL);
- WRITE_REG32(MDC_DV_CTL, (temp & ~MDC_DV_LINE_SIZE_MASK) | dv_size);
+ gfx_set_display_offset(offset);
}
-/*----------------------------------------------------------------------------
- * GXSetMode.
- *
- * Description :This function sets parametrs for screen mode
- *
- * Parameters.
- * pScrni :Pointer to the screenInfo structure.
- * Pmode :Pointer to the screen modes
- *
- * Returns :TRUE on success and FALSE on Failure.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-
static Bool
-GXSetMode(ScrnInfoPtr pScrni, DisplayModePtr pMode)
+GXSetVideoMode(ScrnInfoPtr pScrni, DisplayModePtr pMode)
{
- int flags;
- static char *quals[4] = {
- " +hsync +vsync", " -hsync +vsync", " +hsync -vsync", " -hsync -vsync"
- };
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ 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());
- gfx_wait_until_idle();
- /* disable video */
- gx_disable_dac_power(pScrni);
-
- /* unsigned int compOffset, compPitch, compSize; */
- DEBUGMSG(1, (0, X_INFO, "GXSetMode %p %p %p %p %p\n",
- gfx_virt_regptr, gfx_virt_gpptr,
- gfx_virt_spptr, gfx_virt_vidptr, gfx_virt_fbptr));
-
- /* Set the VT semaphore */
- pScrni->vtSema = TRUE;
-
- /* The timing will be adjusted later */
- flags = 0;
- if ((pMode->Flags & V_NHSYNC) != 0)
- flags |= 1;
-
- if ((pMode->Flags & V_NVSYNC) != 0)
- flags |= 2;
-
- DEBUGMSG(1, (0, X_PROBED,
- "Setting mode %dx%d %0.3f %d %d %d %d %d %d %d %d%s\n",
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pMode->SynthClock / 1000.0, pMode->CrtcHDisplay,
- pMode->CrtcHSyncStart, pMode->CrtcHSyncEnd, pMode->CrtcHTotal,
- pMode->CrtcVDisplay, pMode->CrtcVSyncStart, pMode->CrtcVSyncEnd,
- pMode->CrtcVTotal, quals[flags]));
- DEBUGMSG(1, (0, X_INFO, "Set display mode: %dHz Pitch %d\n",
- GXGetRefreshRate(pMode), pGeode->Pitch));
-
- /* TV not selected */
- DEBUGMSG(1, (0, X_PROBED, "Setting Display for CRT or TFT\n"));
- if (pGeode->CustomMode != 0) {
- DEBUGMSG(1, (0, X_PROBED, "Setting Custom mode\n"));
- 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)));
- } else if (pGeode->Panel != 0) {
- DEBUGMSG(0, (0, X_PROBED, "Setting Display for TFT\n"));
- DEBUGMSG(1, (0, X_PROBED, "Restore Panel %d %d %d %d %d\n",
- pGeode->FPBX, pGeode->FPBY,
- pMode->CrtcHDisplay,
- pMode->CrtcVDisplay, pScrni->bitsPerPixel));
-
- DEBUGMSG(1, (pScrni->scrnIndex, X_CONFIG, "FP Bios %d\n",
- pGeode->Panel));
- GFX(set_fixed_timings(pGeode->FPBX, pGeode->FPBY,
- pMode->CrtcHDisplay,
- pMode->CrtcVDisplay, pScrni->bitsPerPixel));
- } else {
- /* display is crt */
- DEBUGMSG(1, (0, X_PROBED,
- "Setting Display for CRT %dx%d-%d@%d\n",
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel, GXGetRefreshRate(pMode)));
- GFX(set_display_mode(pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel, GXGetRefreshRate(pMode)));
-
- /* adjust the pitch */
- }
+ if (pGeode->Compression) {
+ GXSetDvLineSize(pGeode->Pitch);
- /* enable crt */
- GFX(set_crt_enable(CRT_ENABLE));
- GFX(set_display_pitch(pGeode->Pitch));
- GFX(set_display_offset(0L));
- GFX(wait_vertical_blank());
-
- DEBUGMSG(1, (0, X_PROBED, "Display mode set\n"));
- /* enable compression if option selected */
- if (pGeode->Compression) {
- DEBUGMSG(1, (0, X_PROBED, "Compression mode set %d\n",
- pGeode->Compression));
- /* set the compression parameters,and it will be turned on later. */
- gx_set_DvLineSize(pGeode->Pitch);
-
- gfx_set_compression_offset(pGeode->CBOffset);
- gfx_set_compression_pitch(pGeode->CBPitch);
- gfx_set_compression_size(pGeode->CBSize);
-
- /* set the compression buffer, all parameters already set */
- gfx_set_compression_enable(1);
- }
+ gfx_set_compression_offset(pGeode->CBOffset);
+ gfx_set_compression_pitch(GX_CB_PITCH);
+ gfx_set_compression_size(GX_CB_SIZE);
- if (pGeode->HWCursor) {
- /* Load blank cursor */
- GXLoadCursorImage(pScrni, NULL);
- GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0));
- GFX(set_cursor_enable(1));
- } else {
- DEBUGMSG(1,(0, X_INFO, "GXRestore ... "));
- GXRestore(pScrni);
- DEBUGMSG(1,(0, X_INFO, "done.\n"));
- }
+ gfx_set_compression_enable(1);
+ }
- DEBUGMSG(1, (0, X_INFO, "done.\n"));
- /* Reenable the hardware cursor after the mode switch */
- if (pGeode->HWCursor == TRUE) {
- DEBUGMSG(1, (0, X_INFO, "GXShowCursor ... "));
+ if (pGeode->HWCursor && !(pMode->Flags & V_DBLSCAN)) {
+ GXLoadCursorImage(pScrni, NULL);
+ GFX(set_cursor_position(pGeode->CursorStartOffset, 0, 0, 0, 0));
GXShowCursor(pScrni);
- DEBUGMSG(1, (0, X_INFO, "done.\n"));
}
+ else {
+ GFX(set_cursor_enable(0));
+ pGeode->HWCursor = FALSE;
+ }
- if (!pGeode->Panel)
- GFX(set_display_offset(pGeode->PrevDisplayOffset));
+ GXAdjustFrame(pScrni->scrnIndex, pScrni->frameX0, pScrni->frameY0, 0);
+ gx_enable_dac_power();
- /* Restore the contents in the screen info */
- DEBUGMSG(1, (0, X_INFO, "After setting the mode\n"));
- switch (pGeode->Rotate) {
- case 1:
- case 3:
- pGeode->HDisplay = pMode->VDisplay;
- pGeode->VDisplay = pMode->HDisplay;
- break;
- default:
- pGeode->HDisplay = pMode->HDisplay;
- pGeode->VDisplay = pMode->VDisplay;
- break;
- }
- gx_enable_dac_power(pScrni);
- return TRUE;
+ return TRUE;
}
-/*----------------------------------------------------------------------------
- * GXEnterGraphics.
- *
- * Description :This function will intiallize the displaytiming
- structure for nextmode and switch to VGA mode.
- *
- * Parameters.
- * pScrn :Screen information will be stored in this structure.
- * pScrni :Pointer to the screenInfo structure.
- *
- * Returns :TRUE on success and FALSE on Failure.
- *
- * Comments :gfx_vga_mode_switch() will start and end the
- * switching based on the arguments 0 or 1.soft_vga
- * is disabled in this function.
- *----------------------------------------------------------------------------
- */
static Bool
-GXEnterGraphics(ScreenPtr pScrn, ScrnInfoPtr pScrni)
+GXSwitchMode(int index, DisplayModePtr pMode, int flags)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- gfx_wait_until_idle();
-
- DEBUGMSG(1, (0, X_INFO, "GXEnterGraphics(1)!\n"));
-
- /* Save CRT State */
- 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();
-
- /* Save Display offset */
- pGeode->FBDisplayOffset = gfx_get_display_offset();
-
- DEBUGMSG(1, (0, X_INFO, "GXEnterGraphics(2)!\n"));
-
- if (pGeode->useVGA) {
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- pGeode->FBBIOSMode = pvgaHW->readCrtc(pvgaHW, 0x040);
- }
-
- /* Save the current Compression state */
- pGeode->FBCompressionEnable = gfx_get_compression_enable();
- pGeode->FBCompressionOffset = gfx_get_compression_offset();
- pGeode->FBCompressionPitch = gfx_get_compression_pitch();
- pGeode->FBCompressionSize = gfx_get_compression_size();
-
- /* Save Cursor offset */
- pGeode->FBCursorOffset = gfx_get_cursor_offset();
-
-#if defined(PNL_SUP)
- /* Save the Panel state */
- DEBUGMSG(1, (0, X_INFO, "GXEnterGraphics(3)!\n"));
- Pnl_SavePanelState();
-#endif
-
- /* only if comming from VGA */
- if (pGeode->useVGA && pGeode->FBVGAActive) {
- unsigned short sequencer;
- vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
-
- /* Map VGA aperture */
- if (!vgaHWMapMem(pScrni))
- return FALSE;
+ ScrnInfoPtr pScrni = xf86Screens[index];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int ret = TRUE;
+ int rotate;
- /* Unlock VGA registers */
- vgaHWUnlock(pvgaHW);
+ /* Syn the engine and shutdown the DAC momentarily */
- /* Save the current state and setup the current mode */
- vgaHWSave(pScrni, &VGAHWPTR(pScrni)->SavedReg, VGA_SR_ALL);
+ gfx_wait_until_idle();
- /* DISABLE VGA SEQUENCER */
- /* This allows the VGA state machine to terminate. We must delay */
- /* such that there are no pending MBUS requests. */
+ /* Set up the memory for the new mode */
+ rotate = GXGetRotation(pScrni->pScreen);
+ ret = GXAllocateMemory(pScrni->pScreen, pScrni, rotate);
- 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);
+ if (ret) {
+ if (pGeode->curMode != pMode)
+ ret = GXSetVideoMode(pScrni, pMode);
+ }
- gfx_delay_milliseconds(1);
+ if (ret)
+ ret = GXRotate(pScrni, pMode);
- /* 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);
+ /* Go back the way it was */
- gfx_delay_milliseconds(1);
- }
+ 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;
+}
- gx_clear_fb(pScrni);
+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);
+ }
- if (!GXSetMode(pScrni, pScrni->currentMode)) {
- return FALSE;
- }
+ GXRestore(pScrni);
- gx_enable_dac_power(pScrni);
- DEBUGMSG(1, (0, X_INFO, "GXEnterGraphics(4)!\n"));
- return TRUE;
+ gx_enable_dac_power();
}
-void
-gx_enable_dac_power(ScrnInfoPtr pScrni)
+static Bool
+GXCloseScreen(int scrnIndex, ScreenPtr pScrn)
{
- /* enable the DAC POWER */
- gfx_write_vid32(RCDF_VID_MISC,
- gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH);
+ 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;
}
-void
-gx_disable_dac_power(ScrnInfoPtr pScrni)
-{
- /* disable the DAC POWER */
- gfx_write_vid32(RCDF_VID_MISC,
- RCDF_DAC_POWER_DOWN | RCDF_ANALOG_POWER_DOWN |
- (gfx_read_vid32(RCDF_VID_MISC) & RCDF_GAMMA_BYPASS_BOTH));
-}
-/*----------------------------------------------------------------------------
- * GXLeaveGraphics:
- *
- * Description :This function will restore the displaymode parameters
- * and switches the VGA mode
- *
- * Parameters.
- * pScrn :Screen information will be stored in this structure.
- * pScrni :Pointer to the screenInfo structure.
- *
- * Returns :none.
- *
- * Comments : gfx_vga_mode_switch() will start and end the switching
- * based on the arguments 0 or 1.soft_vga is disabled in
- * this function.
- *----------------------------------------------------------------------------
- */
-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);
- }
+static Bool
+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();
+
+#ifdef PNL_SUP
+ Pnl_SavePanelState();
+#endif
- gfx_set_display_pitch(pGeode->FBgfxdisplaytiming.wPitch);
+ /* Turn off the VGA */
- gfx_set_display_offset(pGeode->FBDisplayOffset);
+ if (pGeode->useVGA && pGeode->FBVGAActive) {
+ unsigned short sequencer;
+ vgaHWPtr pvgaHW = VGAHWPTR(pScrni);
- /* Restore Cursor */
- gfx_set_cursor_position(pGeode->FBCursorOffset, 0, 0, 0, 0);
+ /* Map VGA aperture */
+ if (!vgaHWMapMem(pScrni))
+ return FALSE;
- 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);
- }
+ /* Unlock VGA registers */
+ vgaHWUnlock(pvgaHW);
- GXRestore(pScrni);
+ /* Save the current state and setup the current mode */
+ vgaHWSave(pScrni, &VGAHWPTR(pScrni)->SavedReg, VGA_SR_ALL);
- gx_enable_dac_power(pScrni);
-}
+ /* DISABLE VGA SEQUENCER */
+ /* This allows the VGA state machine to terminate. We must delay */
+ /* such that there are no pending MBUS requests. */
-/*----------------------------------------------------------------------------
- * GXCloseScreen.
- *
- * Description :This function will restore the original mode
- * and also it unmap video memory
- *
- * Parameters.
- * ScrnIndex :Screen index value of the screen will be closed.
- * pScrn :Pointer to the screen structure.
- *
- *
- * Returns :TRUE on success and FALSE on Failure.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-static Bool
-GXCloseScreen(int scrnIndex, ScreenPtr pScrn)
-{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ 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);
- if (pGeode->ShadowPtr)
- xfree(pGeode->ShadowPtr);
+ gfx_delay_milliseconds(1);
- DEBUGMSG(0, (scrnIndex, X_PROBED, "GXCloseScreen %d\n", pScrni->vtSema));
- if (pScrni->vtSema)
- GXLeaveGraphics(pScrni);
+ /* 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);
- if (pGeode->AccelInfoRec)
- XAADestroyInfoRec(pGeode->AccelInfoRec);
+ gfx_delay_milliseconds(1);
+ }
- if (pGeode->AccelImageWriteBuffers) {
-#if GX_USE_OFFSCRN_MEM
- xfree(pGeode->AccelImageWriteBuffers[0]);
-#endif
- xfree(pGeode->AccelImageWriteBuffers);
- pGeode->AccelImageWriteBuffers = NULL;
- }
+ /* Set up the memory */
+ /* XXX - FIXME - when we alow inital rotation, it should be here */
+ GXAllocateMemory(pScrn, pScrni, RR_Rotate_0);
- if (pGeode->AccelColorExpandBuffers) {
- xfree(pGeode->AccelColorExpandBuffers);
- pGeode->AccelColorExpandBuffers = NULL;
- }
+ /* Clear the framebuffer */
+ memset(pGeode->FBBase + pGeode->displayOffset, 0, pGeode->displaySize);
-#ifdef XF86EXA
- if (pGeode->pExa) {
- exaDriverFini(pScrn);
- xfree(pGeode->pExa);
- pGeode->pExa = NULL;
- }
-#endif
+ /* Set up the video mode */
+ GXSetVideoMode(pScrni, pScrni->currentMode);
+ pGeode->curMode = pScrni->currentMode;
- pScrni->vtSema = FALSE;
+ return TRUE;
+}
- GXUnmapMem(pScrni);
+static void
+GXLoadPalette(ScrnInfoPtr pScrni,
+ int numColors, int *indizes, LOCO * colors, VisualPtr pVisual)
+{
+ int i, index, color;
- if (pGeode && (pScrn->CloseScreen = pGeode->CloseScreen)) {
- pGeode->CloseScreen = NULL;
- return ((*pScrn->CloseScreen) (scrnIndex, pScrn));
- }
+ 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));
- return TRUE;
+ GFX(set_display_palette_entry(index, color));
+ }
}
#ifdef DPMSExtension
@@ -1634,21 +1163,6 @@ GXPanelPower(int enable)
WRITE_VID32(RCDF_POWER_MANAGEMENT, power);
}
-/*----------------------------------------------------------------------------
- * GXDPMSSet.
- *
- * Description :This function sets geode into Power Management
- * Signalling mode.
- *
- * Parameters.
- * pScrni :Pointer to screen info strucrure.
- * mode :Specifies the power management mode.
- *
- * Returns :none.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
static void
GXDPMSSet(ScrnInfoPtr pScrni, int mode, int flags)
{
@@ -1656,13 +1170,9 @@ GXDPMSSet(ScrnInfoPtr pScrni, int mode, int flags)
pGeode = GEODEPTR(pScrni);
- DEBUGMSG(1, (0, X_INFO, "GXDPMSSet! %d %d\n", mode, flags));
- /* Check if we are actively controlling the display */
- if (!pScrni->vtSema) {
- ErrorF("GXDPMSSet called when we not controlling the VT!\n");
- return;
- }
+ if (!pScrni->vtSema)
+ return;
switch (mode) {
case DPMSModeOn:
@@ -1712,849 +1222,366 @@ GXDPMSSet(ScrnInfoPtr pScrni, int mode, int flags)
}
#endif
-/*----------------------------------------------------------------------------
- * GXScreenInit.
- *
- * Description :This function will be called at the each ofserver
- * generation.
- *
- * Parameters.
- * scrnIndex :Specfies the screenindex value during generation.
- * pScrn :Pointer to screen info strucrure.
- * argc :parameters for command line arguments count
- * argv :command line arguments if any it is not used.
- *
- * Returns :none.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
static Bool
-GXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
+GXCreateScreenResources(ScreenPtr pScreen)
{
- int i, l, bytpp, size, fbsize, fboffset, fbavail;
- int pitch, displayWidth, virtualX, virtualY;
- int HDisplay, VDisplay, maxHDisplay, maxVDisplay, maxX, maxY;
- unsigned char *FBStart;
- unsigned char **ap, *bp;
- DisplayModePtr p;
- GeodeRec *pGeode;
- VisualPtr visual;
- BoxRec AvailBox;
- RegionRec OffscreenRegion;
- ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum];
- Bool Inited = FALSE;
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- pGeode = GXGetRec(pScrni);
+ pScreen->CreateScreenResources = pGeode->CreateScreenResources;
+ if (!(*pScreen->CreateScreenResources)(pScreen))
+ return FALSE;
- if (pGeode->useVGA) {
- if (!vgaHWGetHWRec(pScrni))
- return FALSE;
- if (!vgaHWMapMem(pScrni))
- 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;
- vgaHWGetIOBase(VGAHWPTR(pScrni));
- }
-
- if (!GXMapMem(pScrni))
- return FALSE;
+ pGeode->rotation = RR_Rotate_0;
- /* If compression is not turned on - adjust the pitch to be linear */
- if (pGeode->Compression)
- pGeode->Pitch = GXCalculatePitchBytes(pScrni->virtualX, pScrni->bitsPerPixel);
- else
- pGeode->Pitch = ((pScrni->virtualX + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
+ /* Just setup enough for an initial rotate */
- pGeode->AccelPitch = pGeode->Pitch;
- bytpp = (pScrni->bitsPerPixel + 7) / 8;
+ p.width = pScreen->width;
+ p.height = pScreen->height;
+ p.mmWidth = pScreen->mmWidth;
+ p.mmHeight = pScreen->mmHeight;
- /* start of framebuffer for accels */
- fboffset = 0;
- /* 0x4000 for gfx_gu2_scratch_buffer */
- fbavail = pGeode->FBAvail - 0x4000;
+ GXRandRSetConfig = LoaderSymbol("GXRandRSetConfig");
+ if (GXRandRSetConfig) {
+ pGeode->starting = TRUE;
+ (*GXRandRSetConfig) (pScreen, requestedRotation, 0, &p);
+ pGeode->starting = FALSE;
+ }
+ }
-#ifdef V4L2_VIDEO_BFR_SZ
- fbavail -= V4L2_VIDEO_BFR_SZ;
-#endif
+ return TRUE;
+}
- /* allocate display frame buffer at zero offset */
- fbsize = pScrni->virtualY * pGeode->Pitch;
- pGeode->FBSize = fbsize;
+static Bool
+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;
- pGeode->CursorSize = 16 * 64; /* 64x64 */
- pGeode->CursorStartOffset = 0;
+ /* FIXME: VGA stuff - what does this do? */
- DEBUGMSG(1, (scrnIndex, X_PROBED, "%d %d %d\n",
- pScrni->virtualX, pScrni->bitsPerPixel, pGeode->Pitch));
+ /*
+ if (pGeode->useVGA) {
+ if (!vgaHWGetHWRec(pScrni))
+ return FALSE;
+ if (!vgaHWMapMem(pScrni))
+ return FALSE;
- HDisplay = pScrni->currentMode->HDisplay;
- VDisplay = pScrni->currentMode->VDisplay;
- pGeode->orig_virtX = pScrni->virtualX;
- pGeode->orig_virtY = pScrni->virtualY;
+ vgaHWGetIOBase(VGAHWPTR(pScrni));
+ }
+ */
- p = pScrni->modes;
- maxHDisplay = p->HDisplay;
- maxVDisplay = p->VDisplay;
- while ((p = p->next) != pScrni->modes) {
- if (maxHDisplay < p->HDisplay)
- maxHDisplay = p->HDisplay;
+ pGeode->starting = TRUE;
- if (maxVDisplay < p->VDisplay)
- maxVDisplay = p->VDisplay;
- }
+ if (!pGeode->NoAccel) {
- DEBUGMSG(1, (scrnIndex, X_PROBED, "maxHDisplay %d maxVDisplay %d\n",
- maxHDisplay, maxVDisplay));
-
- switch (pGeode->Rotate) {
- case 1:
- case 3:
- pGeode->HDisplay = VDisplay;
- pGeode->VDisplay = HDisplay;
- virtualX = pScrni->virtualY;
- virtualY = pScrni->virtualX;
- maxX = maxVDisplay;
- maxY = maxHDisplay;
- break;
- default:
- pGeode->HDisplay = HDisplay;
- pGeode->VDisplay = VDisplay;
- virtualX = pScrni->virtualX;
- virtualY = pScrni->virtualY;
- maxX = maxHDisplay;
- maxY = maxVDisplay;
- break;
- }
+ if (pGeode->useEXA) {
- /* shadow may be first in FB, since accels render there */
+ 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;
- pGeode->ShadowPtr = NULL;
- if (pGeode->ShadowFB) {
- if (!pGeode->PointerMoved) {
- pGeode->PointerMoved = pScrni->PointerMoved;
- pScrni->PointerMoved = GXPointerMoved;
- }
+ /* This is set in GXAllocateMemory */
+ pExa->memorySize = 0;
- if (pGeode->ShadowPtr == NULL) {
- pGeode->ShadowPitch =
- BitmapBytePad(pScrni->bitsPerPixel * virtualX);
- size = pGeode->ShadowPitch * virtualY;
- pGeode->ShadowPtr = xalloc(size);
- if (pGeode->ShadowPtr != NULL) {
- pGeode->ShadowSize = size;
- if (!pGeode->NoAccel) {
- pGeode->NoAccel = TRUE;
- pGeode->HWCursor = FALSE;
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Shadow FB offscreen, All Accels disabled\n");
- }
-
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Shadow FB, No offscreen Memory, disabled\n");
- pGeode->ShadowFB = FALSE;
- pGeode->Rotate = 0;
- pGeode->HDisplay = HDisplay;
- pGeode->VDisplay = VDisplay;
- virtualX = pScrni->virtualX;
- virtualY = pScrni->virtualY;
- }
- }
+ pExa->pixmapOffsetAlign = 32;
+ pExa->pixmapPitchAlign = 32;
+ pExa->flags = EXA_OFFSCREEN_PIXMAPS;
+ pExa->maxX = pGeode->maxWidth - 1;
+ pExa->maxY = pGeode->maxHeight - 1;
+ }
}
-
- if (pGeode->ShadowPtr != NULL) {
- displayWidth = pGeode->ShadowPitch / bytpp;
- FBStart = pGeode->ShadowPtr;
- DEBUGMSG(1, (0, X_PROBED, "Shadow %p \n", FBStart));
- } else {
- displayWidth = pGeode->Pitch / bytpp;
- FBStart = pGeode->FBBase;
- DEBUGMSG(1, (0, X_PROBED, "FBStart %p \n", FBStart));
+ else {
+ pGeode->AccelImageWriteBuffers = xcalloc(sizeof(pGeode->AccelImageWriteBuffers[0]), pGeode->NoOfImgBuffers);
+ pGeode->AccelColorExpandBuffers = xcalloc(sizeof(pGeode->AccelColorExpandBuffers[0]), pGeode->NoOfColorExpandLines);
}
+ }
- DEBUGMSG(1, (0, X_PROBED, "FB display %X size %X \n", fboffset, fbsize));
- pGeode->FBOffset = fboffset; /* offset of display framebuffer */
- pScrni->fbOffset = fboffset;
- fboffset += fbsize;
- fbavail -= fbsize;
-
- if (pGeode->Compression) { /* Compression enabled */
- pGeode->CBPitch = 512 + 32;
- pGeode->CBSize = 512 + 32;
- size = maxY * pGeode->CBPitch;
- DEBUGMSG(1, (0, X_PROBED, "CB %#x size %#x (%d*%d)\n", fboffset, size,
- maxY, pGeode->CBPitch));
- if (size <= fbavail) {
- pGeode->CBOffset = fboffset;
- fboffset += size;
- fbavail -= size;
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Compression, No FB Memory, disabled\n");
- pGeode->Compression = FALSE;
- }
- }
+ /* XXX FIXME - Take down any of the structures on failure? */
- if (pGeode->HWCursor) { /* HWCursor enabled */
- size = pGeode->CursorSize;
- if (size <= fbavail) {
- pGeode->CursorStartOffset = fboffset;
- fboffset += size;
- fbavail -= size;
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "HWCursor, No FB Memory, disabled\n");
- pGeode->HWCursor = FALSE;
- }
- }
-#if XF86EXA
- if (!pGeode->NoAccel && pGeode->useEXA) { /* exa acceleration enabled */
- if (!(pGeode->pExa = xnfcalloc(sizeof(ExaDriverRec), 1))) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "No ExaDriverRec Memory, disabled\n");
- pGeode->NoAccel = TRUE;
- } else {
- if ((size = pGeode->exaBfrSz) > 0 && size <= fbavail) {
- pGeode->exaBfrOffset = fboffset;
- fboffset += size;
- fbavail -= size;
- }
- }
- }
-#endif
+ if (!GXEnterGraphics(pScrn, pScrni))
+ return FALSE;
- if (!pGeode->NoAccel && !pGeode->useEXA) { /* xaa acceleration enabled */
- if (pGeode->NoOfImgBuffers > 0) {
- pGeode->AccelImageWriteBuffers = NULL;
- pitch = pGeode->AccelPitch;
- size = pitch * pGeode->NoOfImgBuffers;
-#if !GX_USE_OFFSCRN_MEM
- if (size <= fbavail) {
- bp = (unsigned char *)pGeode->FBBase + fboffset;
- l = sizeof(pGeode->AccelImageWriteBuffers[0]) *
- pGeode->NoOfImgBuffers;
- ap = (unsigned char **)xalloc(l);
- if (ap != NULL) {
- for (i = 0; i < pGeode->NoOfImgBuffers; ++i) {
- ap[i] = bp;
- DEBUGMSG(1, (scrnIndex, X_PROBED, "img line %d %p\n",
- i, ap[i]));
- bp += pitch;
- }
- pGeode->AccelImageWriteBuffers = ap;
- fboffset += size;
- fbavail -= size;
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Image Write, No Memory\n");
- }
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR, "Image Write, No FB Memory\n");
- }
-#else
- if ((bp = (unsigned char *)xalloc(size)) != NULL) {
- ap = xalloc(sizeof(pGeode->AccelImageWriteBuffers[0]) *
- pGeode->NoOfImgBuffers);
- if (ap != NULL) {
- for (i = 0; i < pGeode->NoOfImgBuffers; ++i) {
- ap[i] = bp;
- DEBUGMSG(1, (scrnIndex, X_PROBED, "img line %d %x\n",
- i, ap[i]));
- bp += pitch;
- }
- pGeode->AccelImageWriteBuffers = ap;
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Image Write, No Memory\n");
- }
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Image Write, No offscreen Memory\n");
- }
-#endif
- if (pGeode->AccelImageWriteBuffers == NULL) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Accel Image Write disabled\n");
- pGeode->NoOfImgBuffers = 0;
- }
- }
+ miClearVisualTypes();
- if (pGeode->NoOfColorExpandLines > 0) {
- pGeode->AccelColorExpandBuffers = NULL;
- pitch = ((pGeode->AccelPitch + 31) >> 5) << 2;
- size = pitch * pGeode->NoOfColorExpandLines;
- if (size <= fbavail) {
- bp = (unsigned char *)pGeode->FBBase + fboffset;
- l = sizeof(pGeode->AccelColorExpandBuffers[0]) *
- pGeode->NoOfColorExpandLines;
- ap = (unsigned char **)xalloc(l);
- if (ap != NULL) {
- for (i = 0; i < pGeode->NoOfColorExpandLines; ++i) {
- ap[i] = bp;
- DEBUGMSG(1, (scrnIndex, X_PROBED, "clr line %d %p\n",
- i, ap[i]));
- bp += pitch;
- }
- pGeode->AccelColorExpandBuffers = ap;
- fboffset += size;
- fbavail -= size;
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Color Expansion, No Memory\n");
- }
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Color Expansion, No offscreen Memory\n");
- }
- if (pGeode->AccelColorExpandBuffers == NULL) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Accel Color Expansion disabled\n");
- pGeode->NoOfColorExpandLines = 0;
- }
- }
- } else {
- pGeode->NoOfImgBuffers = 0;
- pGeode->AccelImageWriteBuffers = NULL;
- pGeode->NoOfColorExpandLines = 0;
- pGeode->AccelColorExpandBuffers = NULL;
+ /* 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;
+ }
+ }
- /* Initialise graphics mode */
- if (!GXEnterGraphics(pScrn, pScrni))
- return FALSE;
+ miSetPixmapDepths();
- pScrni->virtualX = virtualX;
- pScrni->virtualY = virtualY;
+ /* Point at the visible area to start */
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(1)!\n"));
+ ret = fbScreenInit(pScrn, pGeode->FBBase + pGeode->displayOffset,
+ pScrni->virtualX, pScrni->virtualY,
+ pScrni->xDpi, pScrni->yDpi, pGeode->displayWidth,
+ pScrni->bitsPerPixel);
- /* Reset visual list */
- miClearVisualTypes();
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(2)!\n"));
+ if (!ret)
+ return FALSE;
- /* Setup the visual we support */
- if (pScrni->bitsPerPixel > 8) {
- DEBUGMSG(1, (scrnIndex, X_PROBED,
- "miSetVisualTypes %d %X %X %X\n",
- pScrni->depth, TrueColorMask,
- pScrni->rgbBits, pScrni->defaultVisual));
+ xf86SetBlackWhitePixels(pScrn);
- 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;
- }
- }
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(3)!\n"));
-
- /* Set for RENDER extensions */
- miSetPixmapDepths();
-
- /* Call the framebuffer layer's ScreenInit function, and fill in other
- * * pScrn fields.
- */
- switch (pScrni->bitsPerPixel) {
-#if CFB
- case 8:
- Inited = cfbScreenInit(pScrn, FBStart, virtualX, virtualY,
- pScrni->xDpi, pScrni->yDpi, displayWidth);
- break;
- case 16:
- Inited = cfb16ScreenInit(pScrn, FBStart, virtualX, virtualY,
- pScrni->xDpi, pScrni->yDpi, displayWidth);
- break;
- case 24:
- case 32:
- Inited = cfb32ScreenInit(pScrn, FBStart, virtualX, virtualY,
- pScrni->xDpi, pScrni->yDpi, displayWidth);
- break;
-#else
- case 8:
- case 16:
- case 24:
- case 32:
- Inited = fbScreenInit(pScrn, FBStart, virtualX, virtualY,
- pScrni->xDpi, pScrni->yDpi, displayWidth, pScrni->bitsPerPixel);
- break;
-#endif
- default:
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Internal error: invalid bpp (%d) in ScreenInit\n",
- pScrni->bitsPerPixel);
- Inited = FALSE;
- break;
- }
+ /* Set up the color ordering */
- if (!Inited)
- return FALSE;
-
- GXRotationInit(pScrni);
- GXAdjustFrame(scrnIndex, pScrni->frameX0, pScrni->frameY0, 0);
-
- if (!pGeode->NoAccel) {
- if (!pGeode->useEXA) {
- AvailBox.x1 = 0; /* SET UP GRAPHICS MEMORY AVAILABLE FOR PIXMAP CACHE */
- AvailBox.y1 =
- (fboffset + pGeode->AccelPitch - 1) / pGeode->AccelPitch;
- AvailBox.x2 = displayWidth;
- AvailBox.y2 = (fboffset + fbavail) / pGeode->AccelPitch;
-
- DEBUGMSG(1, (scrnIndex, X_PROBED,
- "Memory manager initialized to (%d,%d) (%d,%d)\n",
- AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2));
-
- if (AvailBox.y1 < AvailBox.y2) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Initializing Memory manager to (%d,%d) (%d,%d)\n",
- AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2);
- REGION_INIT(pScrn, &OffscreenRegion, &AvailBox, 2);
- if (!xf86InitFBManagerRegion(pScrn, &OffscreenRegion)) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Memory manager initialization failed, Cache Diabled\n");
- }
- REGION_UNINIT(pScrn, &OffscreenRegion);
- } else {
- xf86DrvMsg(scrnIndex, X_INFO,
- "No Off Screen Memory, Cache Disabled (%d,%d) (%d,%d)\n",
- AvailBox.x1, AvailBox.y1, AvailBox.x2, AvailBox.y2);
- }
- }
-#if XF86EXA
- else if (pGeode->pExa) {
- ExaDriverPtr pExa = pGeode->pExa;
-
- pExa->memoryBase = pGeode->FBBase;
- pExa->offScreenBase = fboffset;
- pExa->memorySize = fboffset + fbavail;
- pExa->pixmapOffsetAlign = 32;
- pExa->pixmapPitchAlign = 32;
- pExa->flags = EXA_OFFSCREEN_PIXMAPS;
- pExa->maxX = pGeode->maxWidth - 1;
- pExa->maxY = pGeode->maxHeight - 1;
- }
-#endif
+ 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;
+ }
}
+ }
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(4)!\n"));
- xf86SetBlackWhitePixels(pScrn);
+ /* Must follow the color ordering */
+ fbPictureInit(pScrn, 0, 0);
- if (!pGeode->ShadowFB) {
- GXDGAInit(pScrn);
- }
+ if (!pGeode->NoAccel)
+ GXAccelInit(pScrn);
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(5)!\n"));
- if (pScrni->bitsPerPixel > 8) {
- /* Fixup RGB ordering */
- 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;
- }
- }
- }
-#if CFB
-#else
- /* must be after RGB ordering fixed */
- fbPictureInit(pScrn, 0, 0);
-#endif
+ miInitializeBackingStore(pScrn);
+ xf86SetBackingStore(pScrn);
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(6)!\n"));
- if (!pGeode->NoAccel) {
- GXAccelInit(pScrn);
- }
+ /* Set up the soft cursor */
+ miDCInitialize(pScrn, xf86GetPointerScreenFuncs());
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(7)!\n"));
- miInitializeBackingStore(pScrn);
- xf86SetBackingStore(pScrn);
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(8)!\n"));
- /* Initialise software cursor */
- miDCInitialize(pScrn, xf86GetPointerScreenFuncs());
- /* Initialize HW cursor layer.
- * * Must follow software cursor initialization
- */
- if (pGeode->HWCursor) {
- if (!GXHWCursorInit(pScrn))
- xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
- "Hardware cursor initialization failed\n");
- }
+ /* Set up the HW cursor - must follow the soft cursor init */
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(9)!\n"));
- /* Setup default colourmap */
- if (!miCreateDefColormap(pScrn)) {
- return FALSE;
- }
+ if (pGeode->tryHWCursor) {
+ if (!GXHWCursorInit(pScrn))
+ xf86DrvMsg(scrnIndex, X_ERROR, "Hardware cursor initialization failed.\n");
+ }
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(10)!\n"));
- if (pScrni->bitsPerPixel == 8) {
- /* Initialize colormap layer.
- * * Must follow initialization of the default colormap
- */
- if (!xf86HandleColormaps(pScrn, 256, 8,
- GXLoadPalette, NULL,
- CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) {
- return FALSE;
- }
- }
+ /* Set up the color map */
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(11)!\n"));
+ if (!miCreateDefColormap(pScrn))
+ return FALSE;
- if (pGeode->ShadowFB) {
- DEBUGMSG(1, (0, X_INFO, "Shadowed, Rotate=%d, NoAccel=%d\n",
- pGeode->Rotate, pGeode->NoAccel));
- GXShadowFBInit(pScrn, pGeode, bytpp);
+ 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;
}
+ }
+
#ifdef DPMSExtension
- xf86DPMSInit(pScrn, GXDPMSSet, 0);
+ xf86DPMSInit(pScrn, GXDPMSSet, 0);
#endif
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(12)!\n"));
-
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(13)!\n"));
- GXInitVideo(pScrn); /* needed for video */
- /* Wrap the screen's CloseScreen vector and set its
- * SaveScreen vector
- */
- pGeode->CloseScreen = pScrn->CloseScreen;
- pScrn->CloseScreen = GXCloseScreen;
-
- pScrn->SaveScreen = GXSaveScreen;
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(14)!\n"));
-
- /* Report any unused options */
- if (serverGeneration == 1) {
- xf86ShowUnusedOptions(pScrni->scrnIndex, pScrni->options);
- }
- DEBUGMSG(1, (0, X_INFO, "GXScreenInit(15)!\n"));
- return TRUE;
-}
+ GXInitVideo(pScrn);
-/*----------------------------------------------------------------------------
- * GXSwitchMode.
- *
- * Description :This function will switches the screen mode
- *
- * Parameters:
- * scrnIndex :Specfies the screen index value.
- * pMode :pointer to the mode structure.
- * flags :may be used for status check?.
- *
- * Returns :Returns TRUE on success and FALSE on failure.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-Bool
-GXSwitchMode(int scrnIndex, DisplayModePtr pMode, int flags)
-{
- DEBUGMSG(1, (0, X_INFO, "GXSwitchMode!\n"));
- return GXSetMode(xf86Screens[scrnIndex], pMode);
-}
+ /* Set up RandR */
-/*----------------------------------------------------------------------------
- * GXAdjustFrame.
- *
- * Description :This function is used to intiallize the start
- * address of the memory.
- * Parameters.
- * scrnIndex :Specfies the screen index value.
- * x :x co-ordinate value interms of pixels.
- * y :y co-ordinate value interms of pixels.
- *
- * Returns :none.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-void
-GXAdjustFrame(int scrnIndex, int x, int y, int flags)
-{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ xf86DisableRandR(); /* We provide our own RandR goodness */
- GeodeRec *pGeode = GEODEPTR(pScrni);
- int newX, newY;
- unsigned long offset;
+ /* Try to set up the shadow FB for rotation */
- if (x + pGeode->HDisplay >= pScrni->virtualX)
- x = pScrni->virtualX - pGeode->HDisplay;
+ memset(&shadowReq, 0, sizeof(shadowReq));
+ shadowReq.majorversion = 1;
+ shadowReq.minorversion = 1;
- if (x < 0)
- x = 0;
+ rotate = RR_Rotate_0;
- if (y + pGeode->VDisplay >= pScrni->virtualY)
- y = pScrni->virtualY - pGeode->VDisplay;
+ if (LoadSubModule(pScrni->module, "shadow",
+ NULL, NULL, NULL, &shadowReq, &maj, &min)) {
- if (y < 0)
- y = 0;
+ 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");
+ }
- pScrni->frameX0 = x;
- pScrni->frameY0 = y;
- pScrni->frameX1 = x + pGeode->HDisplay - 1;
- pScrni->frameY1 = y + pGeode->VDisplay - 1;
- (*pGeode->Rotation) (x, y, pScrni->virtualX, pScrni->virtualY, &newX,
- &newY);
- (*pGeode->RBltXlat) (newX, newY, pGeode->HDisplay, pGeode->VDisplay,
- &newX, &newY);
- offset =
- pGeode->FBOffset + newY * pGeode->Pitch +
- newX * (pScrni->bitsPerPixel >> 3);
- gfx_set_display_offset(offset);
-}
+ GXRandRInit(pScrn, rotate);
-/*----------------------------------------------------------------------------
- * GXEnterVT.
- *
- * Description :This is called when VT switching back to the X server
- *
- * Parameters.
- * scrnIndex :Specfies the screen index value.
- * flags :Not used inside the function.
- *
- * Returns :none.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-static Bool
-GXEnterVT(int scrnIndex, int flags)
-{
- DEBUGMSG(1, (0, X_INFO, "GXEnterVT!\n"));
- return GXEnterGraphics(NULL, xf86Screens[scrnIndex]);
-}
+ pGeode->PointerMoved = pScrni->PointerMoved;
+ pScrni->PointerMoved = GXPointerMoved;
+ pGeode->CreateScreenResources = pScrn->CreateScreenResources;
+ pScrn->CreateScreenResources = GXCreateScreenResources;
-/*----------------------------------------------------------------------------
- * GXLeaveVT.
- *
- * Description :This is called when VT switching X server text mode.
- *
- * Parameters.
- * scrnIndex :Specfies the screen index value.
- * flags :Not used inside the function.
- *
- * Returns :none.
- *
- * Comments :none.
- *----------------------------------------------------------------------------
- */
-static void
-GXLeaveVT(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ /* XXX - Allow user to specify initial rotation */
+ pGeode->rotation = RR_Rotate_0;
- pGeode->PrevDisplayOffset = gfx_get_display_offset();
- DEBUGMSG(1, (0, X_INFO, "GXLeaveVT!\n"));
- GXLeaveGraphics(xf86Screens[scrnIndex]);
-}
+ pGeode->CloseScreen = pScrn->CloseScreen;
+ pScrn->CloseScreen = GXCloseScreen;
+ pScrn->SaveScreen = GXSaveScreen;
-/*----------------------------------------------------------------------------
- * GXFreeScreen.
- *
- * Description :This is called to free any persistent data structures.
- *
- * Parameters.
- * scrnIndex :Specfies the screen index value.
- * flags :Not used inside the function.
- *
- * Returns :none.
- *
- * Comments :This will be called only when screen being deleted..
- *----------------------------------------------------------------------------
- */
-static void
-GXFreeScreen(int scrnIndex, int flags)
-{
- DEBUGMSG(1, (0, X_INFO, "GXFreeScreen!\n"));
- if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
- vgaHWFreeHWRec(xf86Screens[scrnIndex]);
- GXFreeRec(xf86Screens[scrnIndex]);
+ if (serverGeneration == 1)
+ xf86ShowUnusedOptions(pScrni->scrnIndex, pScrni->options);
+
+ pGeode->starting = FALSE;
+
+ return TRUE;
}
-/*----------------------------------------------------------------------------
- * GXValidMode.
- *
- * Description :This function checks if a mode is suitable for selected
- * chipset.
- * Parameters.
- * scrnIndex :Specfies the screen index value.
- * pMode :Pointer to the screen mode structure..
- * verbose :not used for implementation.
- * flags :not used for implementation
- *
- * Returns :MODE_OK if the specified mode is supported or
- * MODE_NO_INTERLACE.
- * Comments :none.
- *----------------------------------------------------------------------------
- */
+
static int
-GXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags)
+GXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags)
{
- unsigned int total_memory_required;
- ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
- int ret = -1;
- unsigned int ptch;
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ int p, ret;
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ 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) {
- DEBUGMSG(1, (0, X_NONE, "GeodeValidateMode: %dx%d %d %d\n",
- pMode->CrtcHDisplay, pMode->CrtcVDisplay,
- pScrni->bitsPerPixel, GXGetRefreshRate(pMode)));
- if (pGeode->CustomMode == 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 defined(PNL_SUP)
- if (pGeode->Panel != 0) {
- DEBUGMSG(1, (0, X_NONE, "crtcH = %d, FPBX=%d, CrtcV=%d FPBY=%d\n",
- pMode->CrtcHDisplay, pGeode->FPBX,
- pMode->CrtcVDisplay, pGeode->FPBY));
- 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_NOMODE;
- }
-#endif /* PNL_SUP */
+ if (pMode->Flags & V_INTERLACE)
+ return MODE_NO_INTERLACE;
- DEBUGMSG(1, (0, X_NONE, "CRT mode\n"));
- 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_NOMODE;
- }
+ if (pGeode->tryCompression)
+ p = GXCalculatePitchBytes(pMode->CrtcHDisplay, pScrni->bitsPerPixel);
+ else
+ p = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
- if (pGeode->Compression)
- ptch = GXCalculatePitchBytes(pMode->CrtcHDisplay, pScrni->bitsPerPixel);
- else
- ptch = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3);
+ if (p * pMode->CrtcVDisplay > pGeode->FBAvail)
+ return MODE_MEM;
- total_memory_required = ptch * pMode->CrtcVDisplay;
+ return MODE_OK;
+}
- DEBUGMSG(1, (0, X_NONE, "Total Mem %X %lX\n",
- total_memory_required, pGeode->FBAvail));
- if (total_memory_required > pGeode->FBAvail)
- return MODE_MEM;
+/* XXX - Way more to do here */
- return MODE_OK;
+static Bool
+GXEnterVT(int scrnIndex, int flags)
+{
+ return GXEnterGraphics(NULL, xf86Screens[scrnIndex]);
}
-/*----------------------------------------------------------------------------
- * GXLoadPalette.
- *
- * Description: This function sets the palette entry used for graphics
- * data
- *
- * Parameters.
- * pScrni: Points the screeninfo structure.
- * numColors: Specifies the no of colors it supported.
- * indizes: This is used get index value .
- * LOCO: to be added.
- * pVisual: to be added.
- *
- * Returns: MODE_OK if the specified mode is supported or
- * MODE_NO_INTERLACE.
- *
- * Comments: none.
- *----------------------------------------------------------------------------
- */
static void
-GXLoadPalette(ScrnInfoPtr pScrni,
- int numColors, int *indizes, LOCO * colors, VisualPtr pVisual)
+GXLeaveVT(int scrnIndex, int flags)
{
- 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));
- DEBUGMSG(0, (0, X_NONE, "GXLoadPalette: %d %d %X\n",
- numColors, index, color));
+ ScrnInfoPtr pScrni = xf86Screens[scrnIndex];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
- GFX(set_display_palette_entry(index, color));
- }
+ pGeode->PrevDisplayOffset = gfx_get_display_offset();
+ GXLeaveGraphics(xf86Screens[scrnIndex]);
}
-static Bool
-GXMapMem(ScrnInfoPtr pScrni)
+static void
+GXFreeScreen(int scrnIndex, int flags)
{
- GeodeRec *pGeode = GEODEPTR(pScrni);
-
- gfx_virt_regptr = (unsigned char *)xf86MapVidMem(pScrni->scrnIndex,
- VIDMEM_MMIO, (unsigned int)
- gfx_get_cpu_register_base(), pGeode->cpu_reg_size);
+ GeodeRec *pGeode = GEODEPTR(xf86Screens[scrnIndex]);
+
+ if (pGeode->useVGA) {
+ if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
+ vgaHWFreeHWRec(xf86Screens[scrnIndex]);
+ }
- if (pGeode->DetectedChipSet & GX) {
- gfx_virt_gpptr = (unsigned char *)xf86MapVidMem(pScrni->scrnIndex,
- VIDMEM_MMIO, (unsigned int)
- gfx_get_graphics_register_base(), pGeode->gp_reg_size);
- } else {
- gfx_virt_spptr = gfx_virt_regptr;
- }
+ GXFreeRec(xf86Screens[scrnIndex]);
+}
- gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(pScrni->scrnIndex,
- VIDMEM_MMIO, (unsigned int)
- gfx_get_vid_register_base(), pGeode->vid_reg_size);
+void
+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;
+}
- gfx_virt_fbptr = (unsigned char *)xf86MapVidMem(pScrni->scrnIndex,
- VIDMEM_FRAMEBUFFER, pGeode->FBLinearAddr, pGeode->FBAvail);
+/* STUPID STUFF */
- XpressROMPtr = (unsigned char *)xf86MapVidMem(pScrni->scrnIndex,
- VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
+static void
+GXPointerMoved(int index, int x, int y)
+{
+ ScrnInfoPtr pScrni = xf86Screens[index];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+ Bool frameChanged = FALSE;
- pGeode->FBBase = gfx_virt_fbptr;
+ if (x < 0)
+ x = 0;
+ else if (x >= pScrni->virtualX)
+ x = pScrni->virtualX - 1;
- DEBUGMSG(1, (0, X_NONE, "Set mode %p %p %p %p %p\n",
- gfx_virt_regptr,
- gfx_virt_gpptr, gfx_virt_spptr, gfx_virt_vidptr, gfx_virt_fbptr));
+ if (y < 0)
+ y = 0;
+ else if (y >= pScrni->virtualY)
+ y = pScrni->virtualY - 1;
- /* CHECK IF REGISTERS WERE MAPPED SUCCESSFULLY */
- if ((!gfx_virt_regptr) ||
- (!gfx_virt_gpptr) || (!gfx_virt_vidptr) || (!gfx_virt_fbptr)) {
- DEBUGMSG(1, (0, X_NONE, "Could not map hardware registers.\n"));
- return (FALSE);
+ if (pScrni->frameX0 > x) {
+ pScrni->frameX0 = x;
+ pScrni->frameX1 = x + pGeode->HDisplay - 1;
+ frameChanged = TRUE;
}
- DEBUGMSG(1, (0, X_NONE, "adapter info %lx %lx %lx %p\n",
- pGeode->cpu_version,
- pGeode->vid_version,
- pGeode->FBAvail, pGeode->FBBase));
-
- return TRUE;
-}
-
-/*
- * Unmap the framebuffer and MMIO memory.
- */
+ if (pScrni->frameX1 < x) {
+ pScrni->frameX1 = x + 1;
+ pScrni->frameX0 = x - pGeode->HDisplay + 1;
+ frameChanged = TRUE;
+ }
-static Bool
-GXUnmapMem(ScrnInfoPtr pScrni)
-{
- GeodeRec *pGeode = GEODEPTR(pScrni);
+ if (pScrni->frameY0 > y) {
+ pScrni->frameY0 = y;
+ pScrni->frameY1 = y + pGeode->VDisplay - 1;
+ frameChanged = TRUE;
+ }
- /* unmap all the memory map's */
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_regptr, pGeode->cpu_reg_size);
- if (pGeode->DetectedChipSet & GX) {
- xf86UnMapVidMem(pScrni->scrnIndex,
- gfx_virt_gpptr, pGeode->gp_reg_size);
+ if (pScrni->frameY1 < y) {
+ pScrni->frameY1 = y;
+ pScrni->frameY0 = y - pGeode->VDisplay + 1;
+ frameChanged = TRUE;
}
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_vidptr, pGeode->vid_reg_size);
- xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_fbptr, pGeode->FBAvail);
- return TRUE;
+
+ if (frameChanged && pScrni->AdjustFrame != NULL)
+ pScrni->AdjustFrame(pScrni->scrnIndex, pScrni->frameX0,
+ pScrni->frameY0, 0);
}
-/* End of file */
+
diff --git a/src/amd_gx_randr.c b/src/amd_gx_randr.c
new file mode 100644
index 0000000..6e1505b
--- /dev/null
+++ b/src/amd_gx_randr.c
@@ -0,0 +1,339 @@
+/* Originally derived from the Intel example
+ * Copyright (C) 2002 Keith Packard, member of The XFree86 Project, Inc.
+
+ * Copyright (c) 2006 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Neither the name of the Advanced Micro Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ */
+
+#include "xf86.h"
+#include "os.h"
+#include "mibank.h"
+#include "globals.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86DDC.h"
+#include "mipointer.h"
+#include "windowstr.h"
+#include <X11/extensions/randr.h>
+#include <randrstr.h>
+
+#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 */
+} XF86RandRInfoRec, *XF86RandRInfoPtr;
+
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[GXRandRIndex].ptr)
+
+static int
+GXRandRModeRefresh (DisplayModePtr mode)
+{
+ if (mode->VRefresh)
+ return (int) (mode->VRefresh + 0.5);
+ else
+ return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);}
+
+static Bool
+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;
+
+ *rotations = pRandr->supported_rotations;
+
+ if (pRandr->virtualX == -1 || pRandr->virtualY == -1) {
+ 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;
+
+ 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 (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);
+ }
+ }
+
+ 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;
+ }
+
+ 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;
+
+ xf86ReconfigureLayout();
+
+ xf86SetViewport (pScreen, pScreen->width, pScreen->height);
+ xf86SetViewport (pScreen, 0, 0);
+
+ if (pRoot)
+ (*pScrni->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+
+ return ret;
+}
+
+
+Bool
+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;
+ }
+ if (pRandr->maxX == 0 || pRandr->maxY == 0) {
+ pRandr->maxX = maxX;
+ pRandr->maxY = maxY;
+ }
+ return FALSE;
+ }
+ }
+
+ 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 (pScreen == miPointerCurrentScreen ()) {
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+
+ xf86SetViewport(pScreen, px, py);
+
+ (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE);
+ }
+
+ return TRUE;
+}
+
+Rotation
+GXGetRotation(ScreenPtr pScreen)
+{
+ XF86RandRInfoPtr pRandr = XF86RANDRINFO(pScreen);
+ return pRandr->rotation;
+}
+
+Bool
+GXRandRInit(ScreenPtr pScreen, int rotation)
+{
+ XF86RandRInfoPtr pRandr;
+ rrScrPrivPtr rp;
+
+ if (GXRandRGeneration != serverGeneration) {
+ GXRandRIndex = AllocateScreenPrivateIndex();
+ GXRandRGeneration = serverGeneration;
+ }
+
+ pRandr = xalloc(sizeof(XF86RandRInfoRec));
+ if (pRandr == NULL)
+ return FALSE;
+
+ if (!RRScreenInit(pScreen)) {
+ xfree(pRandr);
+ return FALSE;
+ }
+
+ rp = rrGetScrPriv(pScreen);
+ rp->rrGetInfo = GXRandRGetInfo;
+ rp->rrSetConfig = GXRandRSetConfig;
+
+ pRandr->virtualX = -1;
+ pRandr->virtualY = -1;
+
+ pRandr->mmWidth = pScreen->mmWidth;
+ pRandr->mmHeight = pScreen->mmHeight;
+
+ pRandr->rotation = RR_Rotate_0;
+ pRandr->supported_rotations = rotation;
+ pRandr->maxX = pRandr->maxY = 0;
+
+ pScreen->devPrivates[GXRandRIndex].ptr = pRandr;
+ return TRUE;
+}
+
+
diff --git a/src/amd_gx_rotate.c b/src/amd_gx_rotate.c
new file mode 100644
index 0000000..c9b813a
--- /dev/null
+++ b/src/amd_gx_rotate.c
@@ -0,0 +1,155 @@
+/* Copyrightg (c) 2006 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Neither the name of the Advanced Micro Devices, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xf86.h"
+#include "shadow.h"
+#include "amd.h"
+
+void *
+GXWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, CARD32 *size, void *closure)
+{
+ ScrnInfoPtr pScrni = xf86Screens[pScreen->myNum];
+ GeodeRec *pGeode = GEODEPTR(pScrni);
+
+ *size = pGeode->displayPitch;
+
+ return (pGeode->FBBase + pGeode->displayOffset) +
+ row * pGeode->displayPitch + offset;
+}
+
+static
+void GXGetUpdateFunc(ScrnInfoPtr pScrni, int rotate, ShadowUpdateProc *update)
+{
+ *update = NULL;
+
+ 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;
+
+ break;
+
+ case RR_Rotate_180:
+
+ if (pScrni->bitsPerPixel == 8)
+ *update = shadowUpdateRotate8_180;
+ else if (pScrni->bitsPerPixel == 16)
+ *update = shadowUpdateRotate16_180;
+ else
+ *update = shadowUpdateRotate32_180;
+
+ break;
+
+ case RR_Rotate_270:
+ if (pScrni->bitsPerPixel == 8)
+ *update = shadowUpdateRotate8_270;
+ else if (pScrni->bitsPerPixel == 16)
+ *update = shadowUpdateRotate16_270;
+ else
+ *update = shadowUpdateRotate32_270;
+
+ 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);
+
+ /* 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;
+
+ 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;
+}
diff --git a/src/amd_gx_vga.c b/src/amd_gx_vga.c
index 2fbe2de..b46675a 100644
--- a/src/amd_gx_vga.c
+++ b/src/amd_gx_vga.c
@@ -33,6 +33,9 @@
#include "config.h"
#endif
+#include <stdlib.h>
+#include <string.h>
+
/* VGA STRUCTURE */
#define GU2_STD_CRTC_REGS 25
diff --git a/src/amd_gx_video.c b/src/amd_gx_video.c
index c3c5344..5ec27ae 100644
--- a/src/amd_gx_video.c
+++ b/src/amd_gx_video.c
@@ -40,6 +40,9 @@
#include "config.h"
#endif
+#include <stdlib.h>
+#include <string.h>
+
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86Resources.h"
diff --git a/src/amd_lx_accel.c b/src/amd_lx_accel.c
index 3b65136..37b04a3 100644
--- a/src/amd_lx_accel.c
+++ b/src/amd_lx_accel.c
@@ -48,6 +48,8 @@
#include "amd.h"
typedef unsigned char uchar;
+typedef unsigned int uint;
+typedef unsigned short ushort;
#if DEBUGLVL>0
extern FILE *zdfp;