diff options
-rw-r--r-- | src/smi.h | 8 | ||||
-rw-r--r-- | src/smi_501.c | 69 | ||||
-rw-r--r-- | src/smi_501.h | 52 | ||||
-rw-r--r-- | src/smi_driver.c | 68 | ||||
-rw-r--r-- | src/smi_exa.c | 7 | ||||
-rw-r--r-- | src/smi_hwcurs.c | 4 | ||||
-rw-r--r-- | src/smi_pcirename.h | 6 | ||||
-rw-r--r-- | src/smi_video.c | 22 |
8 files changed, 106 insertions, 130 deletions
@@ -350,8 +350,6 @@ void SMI_CommonCalcClock(int scrnIndex, long freq, int min_m, int min_n1, Bool SMI_I2CInit(ScrnInfoPtr pScrn); /* smi_accel.c */ -Bool SMI_XAAInit(ScreenPtr pScrn); -Bool SMI_EXAInit(ScreenPtr pScrn); void SMI_AccelSync(ScrnInfoPtr pScrn); void SMI_GEReset(ScrnInfoPtr pScrn, int from_timeout, int line, char *file); void SMI_EngineReset(ScrnInfoPtr); @@ -359,6 +357,12 @@ void SMI_SetClippingRectangle(ScrnInfoPtr, int, int, int, int); void SMI_DisableClipping(ScrnInfoPtr); CARD32 SMI_DEDataFormat(int bpp); +/* smi_xaa.c */ +Bool SMI_XAAInit(ScreenPtr pScrn); + +/* smi_exa.c */ +Bool SMI_EXAInit(ScreenPtr pScrn); + /* smi_hwcurs.c */ Bool SMI_HWCursorInit(ScreenPtr pScrn); diff --git a/src/smi_501.c b/src/smi_501.c index e41ab84..c8ae99f 100644 --- a/src/smi_501.c +++ b/src/smi_501.c @@ -51,7 +51,30 @@ authorization from The XFree86 Project or Silicon Motion. /* * Forward definitions for the functions that make up the driver. */ -static void panelPowerSequence(SMIPtr pSmi, panel_state_t on_off, int vsync_delay); +static int roundDiv(int num, int denom); +static int findClock(int requested_clock, clock_select_t *clock, + display_t display); +static mode_table_t *findMode(mode_table_t *mode_table, int width, int height, + int refresh_rate); +static void adjustMode(mode_table_t *vesaMode, mode_table_t *mode, + display_t display); +static void setModeRegisters(reg_table_t *register_table, mode_table_t *mode, + display_t display, int bpp, int fbPitch); +static void programMode(SMIPtr pSmi, reg_table_t *register_table); +static void SetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, + unsigned int fMode, unsigned int nHertz, display_t display, + int fbPitch, int bpp); +static void panelSetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, + unsigned int fMode, unsigned int nHertz, int fbPitch, + int bpp); +static void crtSetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, + unsigned int fMode, unsigned int nHertz, int fbPitch, + int bpp); +static void setPower(SMIPtr pSmi, unsigned int nGates, unsigned int Clock); +static void panelWaitVSync(SMIPtr pSmi, int vsync_count); +static void panelPowerSequence(SMIPtr pSmi, panel_state_t on_off, + int vsync_delay); +static void panelUseCRT(SMIPtr pSmi, BOOL bEnable); /* * Add comment here about this module. @@ -89,6 +112,28 @@ mode_table_t mode_table[] = { }; +Bool +SMI501_SetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + SMIPtr pSmi = SMIPTR(pScrn); + + ENTER_PROC("SMI501_SetMode"); + + /* FIXME */ + mode->VRefresh = 60; + + if (pSmi->IsSecondary) + crtSetMode(pSmi, mode->HDisplay, mode->VDisplay, 0, mode->VRefresh, pSmi->Stride, pScrn->depth); + else + panelSetMode(pSmi, mode->HDisplay, mode->VDisplay, 0, mode->VRefresh, pSmi->Stride, pScrn->depth); + + panelUseCRT(pSmi, TRUE); /* Enable both outputs simultaneously */ + LEAVE_PROC("SMI501_SetMode"); + + return TRUE; + +} + /********************************************************************** * regRead32 * Read the value of the 32-bit register specified by nOffset @@ -116,7 +161,7 @@ regWrite32(SMIPtr pSmi, unsigned int nOffset, unsigned int nData) /* Perform a rounded division. */ -int +static int roundDiv(int num, int denom) { /* n / d + 1 / 2 = (2n + d) / 2d */ @@ -124,7 +169,7 @@ roundDiv(int num, int denom) } /* Finds clock closest to the requested. */ -int +static int findClock(int requested_clock, clock_select_t *clock, display_t display) { int mclk; @@ -162,7 +207,7 @@ findClock(int requested_clock, clock_select_t *clock, display_t display) /* Finds the requested mode in the mode table. */ -mode_table_t * +static mode_table_t * findMode(mode_table_t *mode_table, int width, int height, int refresh_rate) { /* Walk the entire mode table. */ @@ -182,7 +227,7 @@ findMode(mode_table_t *mode_table, int width, int height, int refresh_rate) } /* Converts the VESA timing into Voyager timing. */ -void +static void adjustMode(mode_table_t *vesaMode, mode_table_t *mode, display_t display) { int blank_width, sync_start, sync_width; @@ -226,7 +271,7 @@ adjustMode(mode_table_t *vesaMode, mode_table_t *mode, display_t display) } /* Fill the register structure. */ -void +static void setModeRegisters(reg_table_t *register_table, mode_table_t *mode, display_t display, int bpp, int fbPitch) { @@ -357,7 +402,7 @@ setModeRegisters(reg_table_t *register_table, mode_table_t *mode, } /* Program the mode with the registers specified. */ -void +static void programMode(SMIPtr pSmi, reg_table_t *register_table) { unsigned int value, gate, clock; @@ -590,7 +635,7 @@ programMode(SMIPtr pSmi, reg_table_t *register_table) } } -void +static void SetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, unsigned int fMode, unsigned int nHertz, display_t display, int fbPitch, int bpp) @@ -614,7 +659,7 @@ SetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, } } -void +static void panelSetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, unsigned int fMode, unsigned int nHertz, int fbPitch, int bpp) { @@ -622,7 +667,7 @@ panelSetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, fbPitch, bpp); } -void +static void crtSetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, unsigned int fMode, unsigned int nHertz, int fbPitch, int bpp) { @@ -638,7 +683,7 @@ crtSetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, * */ /* Program new power mode. */ -void +static void setPower(SMIPtr pSmi, unsigned int nGates, unsigned int Clock) { unsigned int gate_reg, clock_reg; @@ -856,7 +901,7 @@ panelPowerSequence(SMIPtr pSmi, panel_state_t on_off, int vsync_delay) * Nothing * **********************************************************************/ -void +static void panelUseCRT(SMIPtr pSmi, BOOL bEnable) { unsigned int panel_ctrl = 0; diff --git a/src/smi_501.h b/src/smi_501.h index 5f4809e..6002fae 100644 --- a/src/smi_501.h +++ b/src/smi_501.h @@ -215,8 +215,6 @@ typedef enum _panel_state_t { /****************************************************************************** * F U N C T I O N P R O T O T Y P E S ******************************************************************************/ -/* Set gate and power mode. */ -void setPower(SMIPtr pSmi, unsigned int nGates, unsigned int nClock); /* Set DPMS state. */ void setDPMS(SMIPtr pSmi, DPMS_t state); /* Calculate memory clock settings of input clock. */ @@ -308,46 +306,16 @@ void setDPMS(SMIPtr pSmi, DPMS_t state); ) /* Sets the same mode both on panel and crt */ -void SetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, - unsigned int fMode, unsigned int nHertz, display_t display, - int fbPitch, int bpp); -/* Initialize the panel hardware module */ - -/* Initialize the CRT hardware module */ -void crtInit(pinit_crt init); -/* Enable CRT gamma control (RGB 5:6:5 and RGB 8:8:8 modes only) */ -void crtSetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, - unsigned int fMode, unsigned int nHertz, int fbPitch, int bpp); -/* Get and/or set CRT DPMS.*/ -unsigned int crtDPMS(int nDPMS); -/* Set CRT frame buffer pointer. */ -void crtSetTiming(unsigned int nHDisplay, unsigned int nHTotal, - unsigned int nHSyncStart, unsigned int nHSyncEnd, - unsigned int nVDisplay, unsigned int nVTotal, - unsigned int nVSyncStart, unsigned int nVSyncEnd, - unsigned int nPixelClock, unsigned int nHPolarity, - unsigned int nVPolarity); -/* Get CRT LUT palette. */ -void crtHwcInit(pinit_crt_hwc init); -/* Enable CRT hardware cursor */ -void crtHwcEnable(void); -/* Disable CRT hardware cursor */ -void crtHwcDisable(void); -/* Set CRT pointer shape and/or colors. */ -void crtPointerShape(unsigned char *pShape, int nWidth, int nHeight, - int nHotX, int nHotY, RGB rgbColor[3]); -/* Set CRT cursor on-screen position. */ -void crtPointerPosition(int nX, int nY, int nTopSelect, int nLeftSelect); -/* Set CRT cursor on-screen position. */ -void crtHwcSetPosition(int nX, int nY, int nTopSelect, int nLeftSelect); -/* Set CRT cursor colors */ -void crtHwcSetColors(RGB rgbColor[HWC_NUM_COLORS]); - -/* Route Panel data to CRT for Simultaneous mode */ -void panelUseCRT(SMIPtr pSmi, BOOL bEnable); - -void panelSetMode(SMIPtr pSmi, unsigned int nWidth, unsigned int nHeight, - unsigned int fMode, unsigned int nHertz, int fbPitch, int bpp); +Bool SMI501_SetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); + +unsigned int regRead32(SMIPtr pSmi, unsigned int nOffset); +void regWrite32(SMIPtr pSmi, unsigned int nOffset, unsigned int nData); + + +/* FIXME does something use it? */ +void DisableOverlay(SMIPtr pSmi); +void EnableOverlay(SMIPtr pSmi); + /* REGISTER DEFINITIONS */ diff --git a/src/smi_driver.c b/src/smi_driver.c index 6fb106b..b14f178 100644 --- a/src/smi_driver.c +++ b/src/smi_driver.c @@ -89,9 +89,6 @@ static void SMI_ProbeDDC(ScrnInfoPtr pScrn, int index); static void SMI_DetectPanelSize(ScrnInfoPtr pScrn); static Bool SMI_DriverFunc(ScrnInfoPtr pScrn , xorgDriverFuncOp op,pointer ptr); -static Bool SMI_MSOCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); - - /* * xf86VDrvMsgVerb prints up to 14 characters prefix, where prefix has the * format "%s(%d): " so, use name "SMI" instead of "Silicon Motion" @@ -394,17 +391,6 @@ siliconmotionSetup(pointer module, pointer opts, int *errmaj, int *errmin) #endif /* XFree86LOADER */ -static SMIRegPtr -SMIEntPriv(ScrnInfoPtr pScrn) -{ - DevUnion *pPriv; - SMIPtr pSmi = SMIPTR(pScrn); - - pPriv = xf86GetEntityPrivate(pSmi->pEnt->index, gSMIEntityIndex); - - return pPriv->ptr; -} - static Bool SMI_GetRec(ScrnInfoPtr pScrn) { @@ -965,8 +951,6 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) pSmi->pEnt = xf86GetEntityInfo(pScrn->entityList[pScrn->numEntities - 1]); if (xf86IsEntityShared(pSmi->pEnt->index)) { - SMIRegPtr pSMIEnt = SMIEntPriv(pScrn); - pSmi->Dualhead = TRUE; if (xf86IsPrimInitDone(pSmi->pEnt->index)) pSmi->IsSecondary = TRUE; @@ -1172,10 +1156,11 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) } if (!pSmi->NoAccel) { - from = X_DEFAULT; char *strptr; - - if ((strptr = (char *)xf86GetOptValString(pSmi->Options, OPTION_ACCELMETHOD))) { + + from = X_DEFAULT; + if ((strptr = (char *)xf86GetOptValString(pSmi->Options, + OPTION_ACCELMETHOD))) { if (!xf86NameCmp(strptr,"XAA")) { from = X_CONFIG; pSmi->useEXA = FALSE; @@ -2080,7 +2065,6 @@ SMI_MapMem(ScrnInfoPtr pScrn) { SMIPtr pSmi = SMIPTR(pScrn); vgaHWPtr hwp; - CARD32 memBase; ENTER_PROC("SMI_MapMem"); @@ -2227,7 +2211,7 @@ SMI_UnmapMem(ScrnInfoPtr pScrn) if (pSmi->FBBase) { xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pSmi->FBBase, pSmi->videoRAMBytes); - pSmi->FBBase != NULL; + pSmi->FBBase = NULL; } LEAVE_PROC("SMI_UnmapMem"); @@ -2688,7 +2672,7 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pSmi->Stride = (pSmi->width * pSmi->Bpp + 15) & ~15; } - SMI_MSOCSetMode(pScrn, mode); + SMI501_SetMode(pScrn, mode); SMI_AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); @@ -2993,6 +2977,12 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) /* dualhead */ if (pSmi->Dualhead) { + /* TFT panel uses FIFO1, DSTN panel uses FIFO1 for upper panel and + * FIFO2 for lower panel. I don't have a DSTN panel, so it's untested. + * -- AGD + */ + CARD32 fifo1_readoffset, fifo2_readoffset, fifo_writeoffset; + /* PLL controls */ /* set LCD to vclk2 */ new->SR69 = 0x04; @@ -3023,12 +3013,6 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) new->SR6F = 0x89; } - /* TFT panel uses FIFO1, DSTN panel uses FIFO1 for upper panel and - * FIFO2 for lower panel. I don't have a DSTN panel, so it's untested. - * -- AGD - */ - CARD32 fifo1_readoffset, fifo2_readoffset, fifo_writeoffset; - /* setting SR21 bit 2 disables ZV circuitry, * if ZV is needed, SR21 = 0x20 */ @@ -3759,8 +3743,10 @@ static void SMI_SetShadowDimensions(ScrnInfoPtr pScrn,int width,int height){ } static Bool -SMI_DriverFunc(ScrnInfoPtr pScrn , xorgDriverFuncOp op,pointer ptr){ - SMIPtr pSmi = SMIPTR(pScrn); +SMI_DriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) +{ + xorgRRConfig rconf = ((xorgRRRotation*)ptr)->RRConfig; + SMIPtr pSmi = SMIPTR(pScrn); ENTER_PROC("SMI_DriverFunc"); if(op==RR_GET_INFO){ @@ -3775,7 +3761,6 @@ SMI_DriverFunc(ScrnInfoPtr pScrn , xorgDriverFuncOp op,pointer ptr){ return FALSE; } - xorgRRConfig rconf= ((xorgRRRotation*)ptr)->RRConfig; if(rconf.rotation==RR_Rotate_0){ if(pSmi->rotate!=0){ if(pSmi->PointerMoved != NULL){ @@ -3811,24 +3796,3 @@ SMI_DriverFunc(ScrnInfoPtr pScrn , xorgDriverFuncOp op,pointer ptr){ LEAVE_PROC("SMI_DriverFunc"); return TRUE; } - -static Bool -SMI_MSOCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) -{ - SMIPtr pSmi = SMIPTR(pScrn); - - ENTER_PROC("SMI_MSOCSetMode"); - - mode->VRefresh = 60; - - if (pSmi->IsSecondary) - crtSetMode(pSmi, mode->HDisplay, mode->VDisplay, 0, mode->VRefresh, pSmi->Stride, pScrn->depth); - else - panelSetMode(pSmi, mode->HDisplay, mode->VDisplay, 0, mode->VRefresh, pSmi->Stride, pScrn->depth); - - panelUseCRT(pSmi, TRUE); /* Enable both outputs simultaneously */ - LEAVE_PROC("SMI_MSOCSetMode"); - - return TRUE; - -} diff --git a/src/smi_exa.c b/src/smi_exa.c index 06bad95..01b9017 100644 --- a/src/smi_exa.c +++ b/src/smi_exa.c @@ -422,16 +422,13 @@ Bool SMI_DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch) { - ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; - SMIPtr pSmi = SMIPTR(pScrn); + unsigned char *src = pSrc->devPrivate.ptr; + int src_pitch = exaGetPixmapPitch(pSrc); ENTER_PROC("SMI_DownloadFromScreen"); DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d dst=%d dst_pitch=%d\n", x, y, w, h, dst, dst_pitch)); - unsigned char *src = pSrc->devPrivate.ptr; - int src_pitch = exaGetPixmapPitch(pSrc); - exaWaitSync(pSrc->drawable.pScreen); src += (y * src_pitch) + (x * pSrc->drawable.bitsPerPixel/8); diff --git a/src/smi_hwcurs.c b/src/smi_hwcurs.c index 4432287..a2a81ff 100644 --- a/src/smi_hwcurs.c +++ b/src/smi_hwcurs.c @@ -351,14 +351,14 @@ SMI_LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) WRITE_DCR(pSmi, DCRF0, pSmi->FBCursorOffset); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, "Primary FBCursorOffset at 0x%08X\n", - pSmi->FBCursorOffset); + (unsigned int)pSmi->FBCursorOffset); } else { /* CRT HWC Addr */ WRITE_DCR(pSmi, DCR230, pSmi->videoRAMBytes + pSmi->FBCursorOffset); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, "Secondary FBCursorOffset at 0x%08X\n", - pSmi->FBCursorOffset); + (unsigned int)pSmi->FBCursorOffset); } } else { diff --git a/src/smi_pcirename.h b/src/smi_pcirename.h index 9321046..64f52f3 100644 --- a/src/smi_pcirename.h +++ b/src/smi_pcirename.h @@ -26,8 +26,8 @@ * library. The main purpose being to facilitate source code compatibility. */ -#ifndef S3PCIRENAME_H -#define S3PCIRENAME_H +#ifndef SMIPCIRENAME_H +#define SMIPCIRENAME_H enum region_type { REGION_MEM, @@ -119,4 +119,4 @@ typedef struct pci_device *pciVideoPtr; #endif /* XSERVER_LIBPCIACCESS */ -#endif /* CIRPCIRENAME_H */ +#endif /* SMIPCIRENAME_H */ diff --git a/src/smi_video.c b/src/smi_video.c index c669d6f..9ed36d9 100644 --- a/src/smi_video.c +++ b/src/smi_video.c @@ -1818,25 +1818,23 @@ SMI_ClipVideo( INT32 height ) { - ScreenPtr pScreen = pScrn->pScreen; SMIPtr pSmi = SMIPTR(pScrn); INT32 vscale, hscale; int diff; + RegionRec VPReg; + BoxRec VPBox = { pScrn->frameX0 , pScrn->frameY0, + pScrn->frameX1 + 1 , pScrn->frameY1 + 1}; + BoxPtr extents = REGION_EXTENTS(pScrn->pScreen, reg); ENTER_PROC("SMI_ClipVideo"); - DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); /* Rotate the viewport before clipping */ - RegionRec VPReg; - BoxRec VPBox = { pScrn->frameX0 , pScrn->frameY0, - pScrn->frameX1 + 1 , pScrn->frameY1 + 1}; if(pSmi->rotate) ROTATE_BOX(VPBox); - REGION_INIT(pScreen, &VPReg, &VPBox, 1); - REGION_INTERSECT(pScreen, reg, reg, &VPReg); - REGION_UNINIT(pScreen, &VPReg); - BoxPtr extents = REGION_EXTENTS(pScreen, reg); + REGION_INIT(pScrn->pScreen, &VPReg, &VPBox, 1); + REGION_INTERSECT(pScrn->pScreen, reg, reg, &VPReg); + REGION_UNINIT(pScrn->pScreen, &VPReg); /* PDR#941 */ extents->x1 = max(extents->x1, VPBox.x1); @@ -1918,9 +1916,9 @@ SMI_ClipVideo( if ((dst->x1 != extents->x1) || (dst->y1 != extents->y1) || (dst->x2 != extents->x2) || (dst->y2 != extents->y2)) { RegionRec clipReg; - REGION_INIT(pScreen, &clipReg, dst, 1); - REGION_INTERSECT(pScreen, reg, reg, &clipReg); - REGION_UNINIT(pScreen, &clipReg); + REGION_INIT(pScrn->pScreen, &clipReg, dst, 1); + REGION_INTERSECT(pScrn->pScreen, reg, reg, &clipReg); + REGION_UNINIT(pScrn->pScreen, &clipReg); } DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); |