diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/amd_gx_dga.c | 393 | ||||
-rw-r--r-- | src/amd_gx_driver.c | 57 | ||||
-rw-r--r-- | src/durango.c | 6 |
4 files changed, 22 insertions, 435 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e6d1d32..8a50018 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,7 +43,6 @@ amd_drv_la_SOURCES = \ amd_gx_driver.c\ amd_gx_accel.c \ amd_gx_cursor.c \ - amd_gx_dga.c \ amd_gx_video.c \ amd_gx_regacc.c \ amd_gx_rotate.c \ diff --git a/src/amd_gx_dga.c b/src/amd_gx_dga.c deleted file mode 100644 index 2212962..0000000 --- a/src/amd_gx_dga.c +++ /dev/null @@ -1,393 +0,0 @@ -/* Copyright (c) 2003-2005 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. - * */ - -/* - * File contents: DGA(Direct Acess Graphics mode) is feature of XFree86 that - * allows the program to access directly to video memory on - * the graphics card.DGA supports the double flickering. This - * file has the functions to support the DGA modes. - * - * Project: Geode Xfree Frame buffer device driver. - * */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86_ansic.h" -#include "xf86Pci.h" -#include "xf86PciInfo.h" -#include "xaa.h" -#include "xaalocal.h" -#include "amd.h" -#include "dgaproc.h" - -/* forward declarations */ -Bool GXDGAInit(ScreenPtr pScrn); -static Bool GX_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, - int *, int *, int *); -static void GX_CloseFramebuffer(ScrnInfoPtr pScrn); -static Bool GX_SetMode(ScrnInfoPtr, DGAModePtr); -static int GX_GetViewport(ScrnInfoPtr); -static void GX_SetViewport(ScrnInfoPtr, int, int, int); -static void GX_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); -static void GX_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); - -extern void GXAdjustFrame(int, int, int, int); -extern Bool GXSwitchMode(int, DisplayModePtr, int); -extern void GXAccelSync(ScrnInfoPtr pScrni); - -static DGAFunctionRec GXDGAFuncs = { - GX_OpenFramebuffer, - GX_CloseFramebuffer, - GX_SetMode, - GX_SetViewport, - GX_GetViewport, - GXAccelSync, - GX_FillRect, - GX_BlitRect, - NULL -}; - -/*---------------------------------------------------------------------------- - * GXDGAInit. - * - * Description :This function is used to intiallize the DGA modes and sets - * the viewport based on the screen mode. - * - * Parameters. - * pScreeen :Pointer to screen info structure. - * - * Returns :TRUE on success and FALSE on failure. - * - * Comments :This function prepares the DGA mode settings for - * other func reference. - * - *---------------------------------------------------------------------------- - */ - -Bool -GXDGAInit(ScreenPtr pScrn) -{ - ScrnInfoPtr pScrni = xf86Screens[pScrn->myNum]; - GeodeRec *pGeode = GEODEPTR(pScrni); - DGAModePtr modes = NULL, newmodes = NULL, currentMode; - DisplayModePtr pMode, firstMode; - int Bpp = pScrni->bitsPerPixel >> 3; - int num = 0; - Bool oneMore; - - pMode = firstMode = pScrni->modes; - DEBUGMSG(0, (0, X_NONE, "GXDGAInit %d\n", Bpp)); - while (pMode) { - /* one record is allocated here */ - newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); - oneMore = FALSE; - if (!newmodes) { - xfree(modes); - return FALSE; - } - - modes = newmodes; - - SECOND_PASS: /* DGA mode flgas and viewport parametrs are set here. */ - currentMode = modes + num; - num++; - currentMode->mode = pMode; - currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; - currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; - if (pMode->Flags & V_DBLSCAN) - currentMode->flags |= DGA_DOUBLESCAN; - if (pMode->Flags & V_INTERLACE) - currentMode->flags |= DGA_INTERLACED; - currentMode->byteOrder = pScrni->imageByteOrder; - currentMode->depth = pScrni->depth; - currentMode->bitsPerPixel = pScrni->bitsPerPixel; - currentMode->red_mask = pScrni->mask.red; - currentMode->green_mask = pScrni->mask.green; - currentMode->blue_mask = pScrni->mask.blue; - currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; - currentMode->viewportWidth = pMode->HDisplay; - currentMode->viewportHeight = pMode->VDisplay; - currentMode->xViewportStep = 1; - currentMode->yViewportStep = 1; - currentMode->viewportFlags = DGA_FLIP_RETRACE; - currentMode->offset = 0; - currentMode->address = pGeode->FBBase; - if (oneMore) { /* first one is narrow width */ - currentMode->bytesPerScanline = - ((pMode->HDisplay * Bpp) + 3) & ~3L; - currentMode->imageWidth = pMode->HDisplay; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - oneMore = FALSE; - goto SECOND_PASS; - } else { - currentMode->bytesPerScanline = - ((pScrni->displayWidth * Bpp) + 3) & ~3L; - currentMode->imageWidth = pScrni->displayWidth; - currentMode->imageHeight = pMode->VDisplay; - currentMode->pixmapWidth = currentMode->imageWidth; - currentMode->pixmapHeight = currentMode->imageHeight; - currentMode->maxViewportX = currentMode->imageWidth - - currentMode->viewportWidth; - /* this might need to get clamped to some maximum */ - currentMode->maxViewportY = currentMode->imageHeight - - currentMode->viewportHeight; - } - - pMode = pMode->next; - if (pMode == firstMode) - break; - } - pGeode->numDGAModes = num; - pGeode->DGAModes = modes; - return DGAInit(pScrn, &GXDGAFuncs, modes, num); -} - -/*---------------------------------------------------------------------------- - * GX_SetMode. - * - * Description :This function is sets into the DGA mode. - *. - * Parameters. - * pScreeen :Pointer to screen info structure. - * pMode :Points to the DGAmode ptr data - * - * Returns :TRUE on success and FALSE on failure. - * - * Comments :none. - *---------------------------------------------------------------------------- - */ -static Bool -GX_SetMode(ScrnInfoPtr pScrni, DGAModePtr pMode) -{ - static int OldDisplayWidth[MAXSCREENS]; - int index = pScrni->pScreen->myNum; - GeodeRec *pGeode = GEODEPTR(pScrni); - - DEBUGMSG(0, (0, X_NONE, "GX_SetMode\n")); - - if (!pMode) { - /* restore the original mode put the ScreenParameters back - */ - pScrni->displayWidth = OldDisplayWidth[index]; - DEBUGMSG(0, - (0, X_NONE, "GX_SetMode !pMode %d\n", pScrni->displayWidth)); - GXSwitchMode(index, pScrni->currentMode, 0); - pGeode->DGAactive = FALSE; - } else { - if (!pGeode->DGAactive) { /* save the old parameters */ - OldDisplayWidth[index] = pScrni->displayWidth; - pGeode->DGAactive = TRUE; - DEBUGMSG(0, - (0, X_NONE, "GX_SetMode pMode+ NA %d\n", - pScrni->displayWidth)); - } -#if defined(STB_X) - Gal_get_display_offset(&pGeode->PrevDisplayOffset); -#else - pGeode->PrevDisplayOffset = gfx_get_display_offset(); -#endif - pScrni->displayWidth = pMode->bytesPerScanline / - (pMode->bitsPerPixel >> 3); - DEBUGMSG(0, - (0, X_NONE, "GX_SetMode pMode+ %d\n", pScrni->displayWidth)); - GXSwitchMode(index, pMode->mode, 0); - } - /* enable/disable Compression */ - if (pGeode->Compression) { - GFX(set_compression_enable(!pGeode->DGAactive)); - } - - /* enable/disable cursor */ - if (pGeode->HWCursor) { - GFX(set_cursor_enable(!pGeode->DGAactive)); - } - - return TRUE; -} - -/*---------------------------------------------------------------------------- - * GX_GetViewPort. - * - * Description :This function is Gets the viewport window memory. - *. - * Parameters. - * pScrni :Pointer to screen info structure. - * - * Returns :returns the viewport status. - * - * Comments :none. - *---------------------------------------------------------------------------- - */ -static int -GX_GetViewport(ScrnInfoPtr pScrni) -{ - GeodeRec *pGeode = GEODEPTR(pScrni); - - return pGeode->DGAViewportStatus; -} - -/*---------------------------------------------------------------------------- - * GX_SetViewPort. - * - * Description :This function is Gets the viewport window memory. - * - * Parameters. - * pScrn :Pointer to screen info structure. - x :x-cordinate of viewport window - * y :y-codinate of the viewport window. - * flags :indicates the viewport to be flipped or not. - * - * Returns :returns the viewport status as zero. - * - * Comments :none. - *---------------------------------------------------------------------------- - */ -static void -GX_SetViewport(ScrnInfoPtr pScrni, int x, int y, int flags) -{ - GeodeRec *pGeode = GEODEPTR(pScrni); - - GXAdjustFrame(pScrni->pScreen->myNum, x, y, flags); - pGeode->DGAViewportStatus = 0; /*GXAdjustFrame loops until finished */ -} - -/*---------------------------------------------------------------------------- - * GX_FillRect. - * - * Description :This function is Gets the viewport window memory. - *. - * Parameters. - * pScrn :Pointer to screen info structure. - * x :x-cordinate of viewport window - * y :y-codinate of the viewport window. - * w :width of the rectangle - * h :height of the rectangle. - * color :color to be filled in rectangle. - * - * Returns :returns the viewport status as zero. - * - * Comments :This function is implemented by solidfill routines.. - *---------------------------------------------------------------------------- - */ -static void -GX_FillRect(ScrnInfoPtr pScrn, int x, int y, - int w, int h, unsigned long color) -{ - GeodeRec *pGeode = GEODEPTR(pScrn); - - if (pGeode->AccelInfoRec) { - (*pGeode->AccelInfoRec->SetupForSolidFill) (pScrn, color, GXcopy, ~0); - (*pGeode->AccelInfoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); - SET_SYNC_FLAG(pGeode->AccelInfoRec); - } -} - -/*---------------------------------------------------------------------------- - * GX_BlitRect. - * - * Description :This function implementing Blit and it moves a - * Rectangular block of data from one location to other - * Location. - * - * Parameters. - * pScrni :Pointer to screen info structure. - * srcx :x-cordinate of the src rectangle - * srcy :y-codinate of src rectangle. - * w :width of the rectangle - * h :height of the rectangle. - * dstx :x-cordinate of the dst rectangle. - * dsty :y -coordinates of the dst rectangle. - * Returns :none. - * - * Comments :none - *---------------------------------------------------------------------------- - */ -static void -GX_BlitRect(ScrnInfoPtr pScrni, - int srcx, int srcy, int w, int h, int dstx, int dsty) -{ - GeodeRec *pGeode = GEODEPTR(pScrni); - - if (pGeode->AccelInfoRec) { - int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; - int ydir = (srcy < dsty) ? -1 : 1; - - (*pGeode->AccelInfoRec->SetupForScreenToScreenCopy) - (pScrni, xdir, ydir, GXcopy, ~0, -1); - (*pGeode->AccelInfoRec->SubsequentScreenToScreenCopy) (pScrni, srcx, - srcy, dstx, dsty, w, h); - SET_SYNC_FLAG(pGeode->AccelInfoRec); - } -} - -/*---------------------------------------------------------------------------- - * GX_OpenFramebuffer. - * - * Description :This function open the framebuffer driver for DGA. - * - * Parameters. - * pScrni :Pointer to screen info structure. - * srcx :x-cordinate of the src rectangle - * srcy :y-codinate of src rectangle. - * w :width of the rectangle - * h :height of the rectangle. - * dstx :x-cordinate of the dst rectangle. - * dsty :y -coordinates of the dst rectangle. - * Returns :none. - * - * Comments :none - *---------------------------------------------------------------------------- - */ -static Bool -GX_OpenFramebuffer(ScrnInfoPtr pScrni, - char **name, unsigned char **mem, int *size, int *offset, int *flags) -{ - GeodeRec *pGeode = GEODEPTR(pScrni); - - *name = NULL; /* no special device */ - *mem = (unsigned char *)pGeode->FBLinearAddr; - *size = pGeode->FBSize; - *offset = 0; - *flags = DGA_NEED_ROOT; - return TRUE; -} - -static void -GX_CloseFramebuffer(ScrnInfoPtr pScrni) -{ -} - -/* end of file */ diff --git a/src/amd_gx_driver.c b/src/amd_gx_driver.c index 7448494..df919ed 100644 --- a/src/amd_gx_driver.c +++ b/src/amd_gx_driver.c @@ -57,7 +57,6 @@ /* Chipset types */ -#define GX1 0x1 #define GX 0x2 #define GX_CRT 0x04 | GX @@ -413,26 +412,29 @@ GXDoDDC(ScrnInfoPtr pScrni, int index) return info; } +extern unsigned long gfx_gx2_scratch_base; + static Bool GXMapMem(ScrnInfoPtr pScrni) { GeodeRec *pGeode = GEODEPTR(pScrni); int index = pScrni->scrnIndex; + pciVideoRec *pci = xf86GetPciInfoForEntity(pGeode->pEnt->index); + gfx_virt_regptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO, - gfx_get_cpu_register_base(), pGeode->cpu_reg_size); + pci->memBase[2], pci->size[2]); - if (pGeode->DetectedChipSet & GX) - gfx_virt_gpptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO, - gfx_get_graphics_register_base(), pGeode->gp_reg_size); - else - gfx_virt_spptr = gfx_virt_regptr; + gfx_virt_gpptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO, + pci->memBase[1], pci->size[1]); gfx_virt_vidptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_MMIO, - gfx_get_vid_register_base(), pGeode->vid_reg_size); + pci->memBase[3], pci->size[3]); gfx_virt_fbptr = (unsigned char *)xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, - pGeode->FBLinearAddr, pGeode->FBAvail); + pci->memBase[0], pGeode->FBAvail); + + gfx_gx2_scratch_base = pGeode->FBAvail - 0x4000; XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000); @@ -442,8 +444,7 @@ GXMapMem(ScrnInfoPtr pScrni) (!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, + xf86DrvMsg(index, X_INFO, "Found Geode %lx %p\n", pGeode->FBAvail, pGeode->FBBase); return TRUE; @@ -475,9 +476,10 @@ GXPreInit(ScrnInfoPtr pScrni, int flags) GeodePtr pGeode; ClockRangePtr GeodeClockRange; OptionInfoRec *GeodeOptions = &GX_GeodeOptions[0]; - + int ret; + QQ_WORD msrValue; rgb defaultWeight = { 0, 0, 0 }; - int ret, modecnt; + int modecnt; int maj, min; char *s, *panelgeo; char **modes; @@ -516,34 +518,17 @@ GXPreInit(ScrnInfoPtr pScrni, int flags) return TRUE; } - pGeode->cpu_version = gfx_detect_cpu(); - - if ((pGeode->cpu_version & 0xFF) == GFX_CPU_REDCLOUD) { - int ret; - QQ_WORD msrValue; + gfx_msr_init(); - pGeode->DetectedChipSet = GX_CRT; + /* Note that we assume that we are on a GX */ - ret = gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue); + pGeode->DetectedChipSet = GX_CRT; + ret = gfx_msr_read(RC_ID_DF, MBD_MSR_CONFIG, &msrValue); - if (!ret) - pGeode->DetectedChipSet = + if (!ret) + pGeode->DetectedChipSet = ((msrValue.low & RCDF_CONFIG_FMT_MASK) == RCDF_CONFIG_FMT_FP) ? GX_TFT : GX_CRT; - } else - pGeode->DetectedChipSet = GX1; - - pGeode->vid_version = gfx_detect_video(); - pGeode->FBLinearAddr = gfx_get_frame_buffer_base(); - - if (pGeode->DetectedChipSet & GX) { - pGeode->cpu_reg_size = 0x4000; - pGeode->gp_reg_size = 0x4000; - pGeode->vid_reg_size = 0x4000; - } else { - pGeode->cpu_reg_size = 0x9000; - pGeode->vid_reg_size = 0x1000; - } /* Fill in the monitor information */ pScrni->monitor = pScrni->confScreen->monitor; diff --git a/src/durango.c b/src/durango.c index 9f8efb7..527e02b 100644 --- a/src/durango.c +++ b/src/durango.c @@ -49,7 +49,7 @@ #define GFX_INIT_GU1 0 /* SC1200/GX1 */ #define GFX_INIT_GU2 1 /* GX */ -#define GFX_MSR_DYNAMIC 1 /* runtime selection */ +#define GFX_MSR_DYNAMIC 0 /* runtime selection */ #define GFX_MSR_REDCLOUD 1 /* GX */ #define GFX_2DACCEL_DYNAMIC 0 /* runtime selection */ @@ -89,10 +89,6 @@ #include "gfx_regs.h" #include "gfx_defs.h" -#if GFX_MSR_DYNAMIC -int gfx_msr_type = 0; -#endif - unsigned char *gfx_virt_regptr = (unsigned char *)0x40000000; unsigned char *gfx_virt_fbptr = (unsigned char *)0x40800000; unsigned char *gfx_virt_vidptr = (unsigned char *)0x40010000; |