1fe5e51b7Smrg/********************************************************************* 2fe5e51b7Smrg* G450: This is for Dual Head. 3fe5e51b7Smrg* Matrox Graphics 4fe5e51b7Smrg* Author : Luugi Marsan 5fe5e51b7Smrg**********************************************************************/ 6fe5e51b7Smrg 7fe5e51b7Smrg#ifdef HAVE_CONFIG_H 8fe5e51b7Smrg#include "config.h" 9fe5e51b7Smrg#endif 10fe5e51b7Smrg 11fe5e51b7Smrg/* All drivers should typically include these */ 12fe5e51b7Smrg#include "xf86.h" 13fe5e51b7Smrg#include "xf86_OSproc.h" 14fe5e51b7Smrg 15fe5e51b7Smrg/* Drivers that need to access the PCI config space directly need this */ 16fe5e51b7Smrg#include "xf86Pci.h" 17fe5e51b7Smrg 18fe5e51b7Smrg#include "mga_reg.h" 19fe5e51b7Smrg#include "mga.h" 20fe5e51b7Smrg 21fe5e51b7Smrg#define MNP_TABLE_SIZE 64 22fe5e51b7Smrg#define CLKSEL_MGA 0x0c 23fe5e51b7Smrg#define PLLLOCK 0x40 24fe5e51b7Smrg 25fe5e51b7Smrg/* Misc field*/ 26fe5e51b7Smrg#define IOADDSEL 0x01 27fe5e51b7Smrg#define RAMMAPEN 0x02 28fe5e51b7Smrg#define CLKSEL_25175 0x00 29fe5e51b7Smrg#define CLKSEL_28322 0x04 30fe5e51b7Smrg#define CLKSEL_MGA 0x0c 31fe5e51b7Smrg#define VIDEODIS 0x10 32fe5e51b7Smrg#define HPGODDEV 0x20 33fe5e51b7Smrg#define HSYNCPOL 0x40 34fe5e51b7Smrg#define VSYNCPOL 0x80 35fe5e51b7Smrg 36fe5e51b7Smrg/* XSYNCCTRL field */ 37fe5e51b7Smrg#define XSYNCCTRL_DAC1HSPOL_SHIFT 2 38fe5e51b7Smrg#define XSYNCCTRL_DAC1HSPOL_MASK (1 << XSYNCCTRL_DAC1HSPOL_SHIFT) 39fe5e51b7Smrg#define XSYNCCTRL_DAC1HSPOL_NEG (1 << XSYNCCTRL_DAC1HSPOL_SHIFT) 40fe5e51b7Smrg#define XSYNCCTRL_DAC1HSPOL_POS 0 41fe5e51b7Smrg#define XSYNCCTRL_DAC1VSPOL_SHIFT 3 42fe5e51b7Smrg#define XSYNCCTRL_DAC1VSPOL_MASK (1 << XSYNCCTRL_DAC1VSPOL_SHIFT) 43fe5e51b7Smrg#define XSYNCCTRL_DAC1VSPOL_NEG (1 << XSYNCCTRL_DAC1VSPOL_SHIFT) 44fe5e51b7Smrg#define XSYNCCTRL_DAC1VSPOL_POS 0 45fe5e51b7Smrg#define XSYNCCTRL_DAC2HSPOL_SHIFT 6 46fe5e51b7Smrg#define XSYNCCTRL_DAC2HSPOL_MASK (1 << XSYNCCTRL_DAC2HSPOL_SHIFT) 47fe5e51b7Smrg#define XSYNCCTRL_DAC2HSPOL_NEG (1 << XSYNCCTRL_DAC2HSPOL_SHIFT) 48fe5e51b7Smrg#define XSYNCCTRL_DAC2HSPOL_POS 0 49fe5e51b7Smrg#define XSYNCCTRL_DAC2VSPOL_SHIFT 7 50fe5e51b7Smrg#define XSYNCCTRL_DAC2VSPOL_MASK (1 << XSYNCCTRL_DAC2VSPOL_SHIFT) 51fe5e51b7Smrg#define XSYNCCTRL_DAC2VSPOL_NEG (1 << XSYNCCTRL_DAC2VSPOL_SHIFT) 52fe5e51b7Smrg#define XSYNCCTRL_DAC2VSPOL_POS 0 53fe5e51b7Smrg#define XSYNCCTRL_DAC1HSOFF_SHIFT 0 54fe5e51b7Smrg#define XSYNCCTRL_DAC1HSOFF_MASK (1 << XSYNCCTRL_DAC1HSOFF_SHIFT) 55fe5e51b7Smrg#define XSYNCCTRL_DAC1HSOFF_OFF (1 << XSYNCCTRL_DAC1HSOFF_SHIFT) 56fe5e51b7Smrg#define XSYNCCTRL_DAC1HSOFF_ON 1 57fe5e51b7Smrg#define XSYNCCTRL_DAC1VSOFF_SHIFT 1 58fe5e51b7Smrg#define XSYNCCTRL_DAC1VSOFF_MASK (1 << XSYNCCTRL_DAC1VSOFF_SHIFT) 59fe5e51b7Smrg#define XSYNCCTRL_DAC1VSOFF_OFF (1 << XSYNCCTRL_DAC1VSOFF_SHIFT) 60fe5e51b7Smrg#define XSYNCCTRL_DAC1VSOFF_ON 0 61fe5e51b7Smrg#define XSYNCCTRL_DAC2HSOFF_SHIFT 4 62fe5e51b7Smrg#define XSYNCCTRL_DAC2HSOFF_MASK (1 << XSYNCCTRL_DAC2HSOFF_SHIFT) 63fe5e51b7Smrg#define XSYNCCTRL_DAC2HSOFF_OFF (1 << XSYNCCTRL_DAC2HSOFF_SHIFT) 64fe5e51b7Smrg#define XSYNCCTRL_DAC2HSOFF_ON 0 65fe5e51b7Smrg#define XSYNCCTRL_DAC2VSOFF_SHIFT 5 66fe5e51b7Smrg#define XSYNCCTRL_DAC2VSOFF_MASK (1 << XSYNCCTRL_DAC2VSOFF_SHIFT) 67fe5e51b7Smrg#define XSYNCCTRL_DAC2VSOFF_OFF (1 << XSYNCCTRL_DAC2VSOFF_SHIFT) 68fe5e51b7Smrg#define XSYNCCTRL_DAC2VSOFF_ON 0 69fe5e51b7Smrg 70fe5e51b7Smrg#define POS_HSYNC 0x00000004 71fe5e51b7Smrg#define POS_VSYNC 0x00000008 72fe5e51b7Smrg 73fe5e51b7Smrg 74fe5e51b7Smrg/* Set CRTC 2*/ 75fe5e51b7Smrg/* Uses the mode given by xfree86 to setup the registry */ 76fe5e51b7Smrg/* Does not write to the hard yet */ 77fe5e51b7Smrgvoid MGACRTC2Get(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo) 78fe5e51b7Smrg{ 79fe5e51b7Smrg 80fe5e51b7Smrg 81fe5e51b7Smrg MGAPtr pMga = MGAPTR(pScrn); 82fe5e51b7Smrg MGARegPtr pReg = &pMga->ModeReg; 83fe5e51b7Smrg 84fe5e51b7Smrg xMODEINFO tmpModeInfo; 85fe5e51b7Smrg CARD32 ulHTotal; 86fe5e51b7Smrg CARD32 ulHDispEnd; 87fe5e51b7Smrg CARD32 ulHBlkStr; 88fe5e51b7Smrg CARD32 ulHSyncStr; 89fe5e51b7Smrg CARD32 ulHSyncEnd; 90fe5e51b7Smrg CARD32 ulVTotal; 91fe5e51b7Smrg CARD32 ulVDispEnd; 92fe5e51b7Smrg CARD32 ulVBlkStr; 93fe5e51b7Smrg CARD32 ulVSyncStr; 94fe5e51b7Smrg CARD32 ulVSyncEnd; 95fe5e51b7Smrg CARD32 ulOffset; 96fe5e51b7Smrg CARD32 ulCtl2; 97fe5e51b7Smrg CARD32 ulDataCtl2; 98fe5e51b7Smrg CARD32 ulDispHeight = pModeInfo->ulDispHeight; 99fe5e51b7Smrg 100fe5e51b7Smrg#ifdef DEBUG 101fe5e51b7Smrg ErrorF("ENTER MGACRTC2Get\n"); 102fe5e51b7Smrg#endif 103fe5e51b7Smrg 104fe5e51b7Smrg tmpModeInfo = *pModeInfo; 105fe5e51b7Smrg 106fe5e51b7Smrg 107fe5e51b7Smrg /* First compute the Values */ 108fe5e51b7Smrg 109fe5e51b7Smrg ulHTotal = tmpModeInfo.ulDispWidth + 110fe5e51b7Smrg tmpModeInfo.ulHFPorch + 111fe5e51b7Smrg tmpModeInfo.ulHBPorch + 112fe5e51b7Smrg tmpModeInfo.ulHSync; 113fe5e51b7Smrg 114fe5e51b7Smrg ulHDispEnd = tmpModeInfo.ulDispWidth; 115fe5e51b7Smrg ulHBlkStr = ulHDispEnd; 116fe5e51b7Smrg ulHSyncStr = ulHBlkStr + tmpModeInfo.ulHFPorch; 117fe5e51b7Smrg ulHSyncEnd = ulHSyncStr + tmpModeInfo.ulHSync; 118fe5e51b7Smrg 119fe5e51b7Smrg ulVTotal = ulDispHeight + 120fe5e51b7Smrg tmpModeInfo.ulVFPorch + 121fe5e51b7Smrg tmpModeInfo.ulVBPorch + 122fe5e51b7Smrg tmpModeInfo.ulVSync; 123fe5e51b7Smrg 124fe5e51b7Smrg 125fe5e51b7Smrg ulVDispEnd = ulDispHeight; 126fe5e51b7Smrg ulVBlkStr = ulVDispEnd; 127fe5e51b7Smrg ulVSyncStr = ulVBlkStr + tmpModeInfo.ulVFPorch; 128fe5e51b7Smrg ulVSyncEnd = ulVSyncStr + tmpModeInfo.ulVSync; 129fe5e51b7Smrg 130fe5e51b7Smrg ulOffset = tmpModeInfo.ulFBPitch; 131fe5e51b7Smrg 132fe5e51b7Smrg 133fe5e51b7Smrg 134fe5e51b7Smrg ulCtl2 = INREG(MGAREG_C2CTL); 135fe5e51b7Smrg ulDataCtl2 = INREG(MGAREG_C2DATACTL); 136fe5e51b7Smrg 137fe5e51b7Smrg ulCtl2 &= 0xFF1FFFFF; 138fe5e51b7Smrg ulDataCtl2 &= 0xFFFFFF00; 139fe5e51b7Smrg 140fe5e51b7Smrg switch (tmpModeInfo.ulBpp) 141fe5e51b7Smrg { 142fe5e51b7Smrg case 15: ulCtl2 |= 0x00200000; 143fe5e51b7Smrg ulOffset <<= 1; 144fe5e51b7Smrg break; 145fe5e51b7Smrg case 16: ulCtl2 |= 0x00400000; 146fe5e51b7Smrg ulOffset <<= 1; 147fe5e51b7Smrg break; 148fe5e51b7Smrg case 32: ulCtl2 |= 0x00800000; 149fe5e51b7Smrg ulOffset <<= 2; 150fe5e51b7Smrg break; 151fe5e51b7Smrg } 152fe5e51b7Smrg 153fe5e51b7Smrg 154fe5e51b7Smrg pReg->crtc2[ MGAREG2_C2CTL ] = ulCtl2; 155fe5e51b7Smrg pReg->crtc2[ MGAREG2_C2DATACTL ] = ulDataCtl2; 156fe5e51b7Smrg 157fe5e51b7Smrg /* Horizontal Value*/ 158fe5e51b7Smrg pReg->crtc2[MGAREG2_C2HPARAM] = (((ulHDispEnd-8) << 16) | (ulHTotal-8)) ; 159fe5e51b7Smrg pReg->crtc2[MGAREG2_C2HSYNC] = (((ulHSyncEnd-8) << 16) | (ulHSyncStr-8)) ; 160fe5e51b7Smrg 161fe5e51b7Smrg 162fe5e51b7Smrg /*Vertical Value*/ 163fe5e51b7Smrg pReg->crtc2[MGAREG2_C2VPARAM] = (((ulVDispEnd-1) << 16) | (ulVTotal-1)) ; 164fe5e51b7Smrg pReg->crtc2[MGAREG2_C2VSYNC] = (((ulVSyncEnd-1) << 16) | (ulVSyncStr-1)) ; 165fe5e51b7Smrg 166fe5e51b7Smrg /** Offset value*/ 167fe5e51b7Smrg 168fe5e51b7Smrg pReg->crtc2[MGAREG2_C2OFFSET] = ulOffset; 169fe5e51b7Smrg 170fe5e51b7Smrg#ifdef DEBUG 171fe5e51b7Smrg ErrorF("EXIT MGACRTC2Get\n"); 172fe5e51b7Smrg#endif 173fe5e51b7Smrg 174fe5e51b7Smrg} 175fe5e51b7Smrg 176fe5e51b7Smrg/* Set CRTC 2*/ 177fe5e51b7Smrg/* Writes to the hardware */ 178fe5e51b7Smrgvoid MGACRTC2Set(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo) 179fe5e51b7Smrg{ 180fe5e51b7Smrg 181fe5e51b7Smrg 182fe5e51b7Smrg MGAPtr pMga = MGAPTR(pScrn); 183fe5e51b7Smrg MGARegPtr pReg = &pMga->ModeReg; 184fe5e51b7Smrg 185fe5e51b7Smrg#ifdef DEBUG 186fe5e51b7Smrg ErrorF("ENTER MGACRTC2Set\n"); 187fe5e51b7Smrg#endif 188fe5e51b7Smrg 189fe5e51b7Smrg 190fe5e51b7Smrg /* This writes to the registers manually */ 191fe5e51b7Smrg OUTREG(MGAREG_C2CTL, pReg->crtc2[MGAREG2_C2CTL]); 192fe5e51b7Smrg OUTREG(MGAREG_C2DATACTL,pReg->crtc2[MGAREG2_C2DATACTL]); 193fe5e51b7Smrg 194fe5e51b7Smrg 195fe5e51b7Smrg /* Horizontal Value*/ 196fe5e51b7Smrg OUTREG(MGAREG_C2HPARAM, pReg->crtc2[MGAREG2_C2HPARAM]); 197fe5e51b7Smrg OUTREG(MGAREG_C2HSYNC, pReg->crtc2[MGAREG2_C2HSYNC]); 198fe5e51b7Smrg 199fe5e51b7Smrg 200fe5e51b7Smrg /*Vertical Value*/ 201fe5e51b7Smrg OUTREG(MGAREG_C2VPARAM, pReg->crtc2[MGAREG2_C2VPARAM]); 202fe5e51b7Smrg OUTREG(MGAREG_C2VSYNC, pReg->crtc2[MGAREG2_C2VSYNC]); 203fe5e51b7Smrg 204fe5e51b7Smrg /** Offset value*/ 205fe5e51b7Smrg 206fe5e51b7Smrg OUTREG(MGAREG_C2OFFSET, pReg->crtc2[MGAREG2_C2OFFSET]); 207fe5e51b7Smrg#ifdef DEBUG 208fe5e51b7Smrg ErrorF("EXIT MGACRTC2Set\n"); 209fe5e51b7Smrg#endif 210fe5e51b7Smrg 211fe5e51b7Smrg} 212fe5e51b7Smrg 213fe5e51b7Smrg 214fe5e51b7Smrg/* Set CRTC2 on the right output */ 215fe5e51b7Smrgvoid MGAEnableSecondOutPut(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo) 216fe5e51b7Smrg{ 217fe5e51b7Smrg CARD8 ucByte, ucXDispCtrl; 218fe5e51b7Smrg CARD32 ulC2CTL; 219fe5e51b7Smrg MGAPtr pMga = MGAPTR(pScrn); 220fe5e51b7Smrg MGARegPtr pReg; 221fe5e51b7Smrg pReg = &pMga->ModeReg; 222fe5e51b7Smrg#ifdef DEBUG 223fe5e51b7Smrg ErrorF("ENTER MGAEnableSecondOutPut\n"); 224fe5e51b7Smrg#endif 225fe5e51b7Smrg 226fe5e51b7Smrg 227fe5e51b7Smrg /* Route Video PLL on second CRTC */ 228fe5e51b7Smrg ulC2CTL = INREG( MGAREG_C2CTL); 229fe5e51b7Smrg 230fe5e51b7Smrg /*--- Disable Pixel clock oscillations On Crtc1 */ 231fe5e51b7Smrg OUTREG( MGAREG_C2CTL, ulC2CTL | MGAREG_C2CTL_PIXCLKDIS_MASK); 232d2b10af6Smrg /*--- Have to wait minimum time (2 access will be ok) */ 233fe5e51b7Smrg (void) INREG( MGAREG_Status); 234fe5e51b7Smrg (void) INREG( MGAREG_Status); 235fe5e51b7Smrg 236fe5e51b7Smrg 237fe5e51b7Smrg ulC2CTL &= ~MGAREG_C2CTL_PIXCLKSEL_MASK; 238fe5e51b7Smrg ulC2CTL &= ~MGAREG_C2CTL_PIXCLKSELH_MASK; 239fe5e51b7Smrg 240fe5e51b7Smrg ulC2CTL |= MGAREG_C2CTL_PIXCLKSEL_VIDEOPLL; 241fe5e51b7Smrg 242fe5e51b7Smrg 243fe5e51b7Smrg OUTREG( MGAREG_C2CTL, ulC2CTL); 244fe5e51b7Smrg 245fe5e51b7Smrg /*--- Enable Pixel clock oscillations on CRTC2*/ 246fe5e51b7Smrg ulC2CTL &= ~MGAREG_C2CTL_PIXCLKDIS_MASK; 247fe5e51b7Smrg OUTREG( MGAREG_C2CTL, ulC2CTL); 248fe5e51b7Smrg 249fe5e51b7Smrg 250fe5e51b7Smrg /* We don't use MISC synch pol, must be 0*/ 251eda3803bSmrg ucByte = INREG8( MGAREG_MEM_MISC_READ); 252fe5e51b7Smrg 253eda3803bSmrg OUTREG8(MGAREG_MEM_MISC_WRITE, (CARD8)(ucByte & ~(HSYNCPOL| VSYNCPOL) )); 254fe5e51b7Smrg 255fe5e51b7Smrg 256fe5e51b7Smrg 257fe5e51b7Smrg 258fe5e51b7Smrg /* Set Rset to 0.7 V*/ 259fe5e51b7Smrg ucByte = inMGAdac(MGA1064_GEN_IO_CTL); 260fe5e51b7Smrg ucByte &= ~0x40; 261fe5e51b7Smrg pReg->DacRegs[MGA1064_GEN_IO_CTL] = ucByte; 262fe5e51b7Smrg outMGAdac (MGA1064_GEN_IO_CTL, ucByte); 263fe5e51b7Smrg 264fe5e51b7Smrg ucByte = inMGAdac( MGA1064_GEN_IO_DATA); 265fe5e51b7Smrg ucByte &= ~0x40; 266fe5e51b7Smrg pReg->DacRegs[MGA1064_GEN_IO_DATA]= ucByte; 267fe5e51b7Smrg outMGAdac (MGA1064_GEN_IO_DATA, ucByte); 268fe5e51b7Smrg 269fe5e51b7Smrg /* Since G550 can swap outputs at BIOS initialisation, we must check which 270fe5e51b7Smrg * DAC is 'logically' used as the secondary (don't assume its DAC2 anymore) */ 271fe5e51b7Smrg 272fe5e51b7Smrg ulC2CTL = INREG(MGAREG_C2CTL); 273fe5e51b7Smrg ucXDispCtrl = inMGAdac(MGA1064_DISP_CTL); 274fe5e51b7Smrg 275fe5e51b7Smrg ucXDispCtrl &= ~MGA1064_DISP_CTL_DAC2OUTSEL_MASK; 276fe5e51b7Smrg 277fe5e51b7Smrg if (!pMga->SecondOutput) { 278fe5e51b7Smrg /* Route Crtc2 on Output1 */ 279fe5e51b7Smrg ucXDispCtrl |= MGA1064_DISP_CTL_DAC2OUTSEL_CRTC1; 280fe5e51b7Smrg ulC2CTL |= MGAREG_C2CTL_CRTCDACSEL_CRTC2; 281fe5e51b7Smrg } 282fe5e51b7Smrg else { 283fe5e51b7Smrg /* Route Crtc2 on Output2*/ 284fe5e51b7Smrg ucXDispCtrl |= MGA1064_DISP_CTL_DAC2OUTSEL_CRTC2; 285fe5e51b7Smrg ulC2CTL &= ~MGAREG_C2CTL_CRTCDACSEL_MASK; 286fe5e51b7Smrg } 287fe5e51b7Smrg 288fe5e51b7Smrg /* Enable CRTC2*/ 289fe5e51b7Smrg ulC2CTL |= MGAREG_C2CTL_C2_EN; 290fe5e51b7Smrg 291fe5e51b7Smrg pReg->dac2[ MGA1064_DISP_CTL - 0x80] = ucXDispCtrl; 292fe5e51b7Smrg 293fe5e51b7Smrg 294fe5e51b7Smrg 295fe5e51b7Smrg OUTREG( MGAREG_C2CTL, ulC2CTL); 296fe5e51b7Smrg 297fe5e51b7Smrg /* Set DAC2 Synch polarity*/ 298fe5e51b7Smrg ucByte = inMGAdac( MGA1064_SYNC_CTL); 299fe5e51b7Smrg ucByte &= ~(XSYNCCTRL_DAC2HSPOL_MASK | XSYNCCTRL_DAC2VSPOL_MASK); 300fe5e51b7Smrg if ( !(pModeInfo->flSignalMode & POS_HSYNC) ) 301fe5e51b7Smrg { 302fe5e51b7Smrg ucByte |= XSYNCCTRL_DAC2HSPOL_NEG; 303fe5e51b7Smrg } 304fe5e51b7Smrg if ( !(pModeInfo->flSignalMode & POS_VSYNC) ) 305fe5e51b7Smrg { 306fe5e51b7Smrg ucByte |= XSYNCCTRL_DAC2VSPOL_NEG; 307fe5e51b7Smrg } 308fe5e51b7Smrg 309fe5e51b7Smrg /* Enable synch output*/ 310fe5e51b7Smrg ucByte &= ~(XSYNCCTRL_DAC2HSOFF_MASK | XSYNCCTRL_DAC2VSOFF_MASK); 311fe5e51b7Smrg pReg->dac2[ MGA1064_SYNC_CTL - 0x80] = ucByte; 312fe5e51b7Smrg 313fe5e51b7Smrg /* Power up DAC2, Fifo. 314fe5e51b7Smrg * The TMDS is powered down here, which is likely wrong. 315fe5e51b7Smrg */ 316fe5e51b7Smrg pReg->dac2[MGA1064_PWR_CTL - 0x80] = 317fe5e51b7Smrg MGA1064_PWR_CTL_DAC2_EN | 318fe5e51b7Smrg MGA1064_PWR_CTL_VID_PLL_EN | 319fe5e51b7Smrg MGA1064_PWR_CTL_RFIFO_EN | 320fe5e51b7Smrg MGA1064_PWR_CTL_CFIFO_EN; 321fe5e51b7Smrg 322fe5e51b7Smrg 323fe5e51b7Smrg#ifdef DEBUG 324fe5e51b7Smrg ErrorF("EXIT MGAEnableSecondOutPut\n"); 325fe5e51b7Smrg#endif 326fe5e51b7Smrg} 327fe5e51b7Smrg 328fe5e51b7Smrg 329fe5e51b7Smrg 330fe5e51b7Smrg 331fe5e51b7Smrg 332fe5e51b7Smrgvoid MGACRTC2GetPitch (ScrnInfoPtr pScrn, xMODEINFO *pModeInfo) 333fe5e51b7Smrg{ 334fe5e51b7Smrg CARD32 ulOffset; 335fe5e51b7Smrg MGAPtr pMga = MGAPTR(pScrn); 336fe5e51b7Smrg MGARegPtr pReg; 337fe5e51b7Smrg 338fe5e51b7Smrg pReg = &pMga->ModeReg; 339fe5e51b7Smrg#ifdef DEBUG 340fe5e51b7Smrg ErrorF("ENTER MGACRTC2GetPitch\n"); 341fe5e51b7Smrg#endif 342fe5e51b7Smrg 343fe5e51b7Smrg 344fe5e51b7Smrg switch(pModeInfo->ulBpp) 345fe5e51b7Smrg { 346fe5e51b7Smrg case 15: 347fe5e51b7Smrg case 16: 348fe5e51b7Smrg ulOffset = pModeInfo->ulFBPitch * 2; 349fe5e51b7Smrg break; 350fe5e51b7Smrg case 32: 351fe5e51b7Smrg ulOffset = pModeInfo->ulFBPitch * 4; 352fe5e51b7Smrg break; 353fe5e51b7Smrg default: /* Muffle compiler */ 354fe5e51b7Smrg ulOffset = pModeInfo->ulFBPitch; 355fe5e51b7Smrg break; 356fe5e51b7Smrg } 357fe5e51b7Smrg 358fe5e51b7Smrg pReg->crtc2[MGAREG2_C2OFFSET] = ulOffset; 359fe5e51b7Smrg 360fe5e51b7Smrg#ifdef DEBUG 361fe5e51b7Smrg ErrorF("EXIT MGACRTC2GetPitch\n"); 362fe5e51b7Smrg#endif 363fe5e51b7Smrg 364fe5e51b7Smrg} 365fe5e51b7Smrg 366fe5e51b7Smrgvoid MGACRTC2SetPitch (ScrnInfoPtr pScrn, xMODEINFO *pModeInfo) 367fe5e51b7Smrg{ 368fe5e51b7Smrg 369fe5e51b7Smrg MGAPtr pMga = MGAPTR(pScrn); 370fe5e51b7Smrg MGARegPtr pReg; 371fe5e51b7Smrg pReg = &pMga->ModeReg; 372fe5e51b7Smrg 373fe5e51b7Smrg#ifdef DEBUG 374fe5e51b7Smrg ErrorF("ENTER CRCT2SetPitch\n"); 375fe5e51b7Smrg#endif 376fe5e51b7Smrg 377fe5e51b7Smrg 378fe5e51b7Smrg OUTREG(MGAREG_C2OFFSET, pReg->crtc2[MGAREG2_C2OFFSET]); 379fe5e51b7Smrg#ifdef DEBUG 380fe5e51b7Smrg ErrorF("EXIT CRCT2SetPitch\n"); 381fe5e51b7Smrg#endif 382fe5e51b7Smrg 383fe5e51b7Smrg} 384fe5e51b7Smrg 385fe5e51b7Smrg 386fe5e51b7Smrg /* Set Display Start*/ 387fe5e51b7Smrg /* base in bytes*/ 388fe5e51b7Smrgvoid MGACRTC2GetDisplayStart (ScrnInfoPtr pScrn, xMODEINFO *pModeInfo, CARD32 base, CARD32 ulX, CARD32 ulY) 389fe5e51b7Smrg{ 390fe5e51b7Smrg 391fe5e51b7Smrg CARD32 ulAddress; 392fe5e51b7Smrg MGAPtr pMga = MGAPTR(pScrn); 393fe5e51b7Smrg MGARegPtr pReg; 394fe5e51b7Smrg pReg = &pMga->ModeReg; 395fe5e51b7Smrg 396fe5e51b7Smrg#ifdef DEBUG 397fe5e51b7Smrg ErrorF("ENTER MGACRTC2GetDisplayStart\n"); 398fe5e51b7Smrg#endif 399fe5e51b7Smrg 400fe5e51b7Smrg 401fe5e51b7Smrg pReg = &pMga->ModeReg; 402fe5e51b7Smrg 403fe5e51b7Smrg ulAddress = (pModeInfo->ulFBPitch * ulY + ulX); 404fe5e51b7Smrg switch(pModeInfo->ulBpp) 405fe5e51b7Smrg { 406fe5e51b7Smrg case 15: 407fe5e51b7Smrg case 16: 408fe5e51b7Smrg ulAddress <<= 1; 409fe5e51b7Smrg break; 410fe5e51b7Smrg case 32: 411fe5e51b7Smrg ulAddress <<= 2; 412fe5e51b7Smrg break; 413fe5e51b7Smrg } 414fe5e51b7Smrg 415fe5e51b7Smrg pReg->crtc2[MGAREG2_C2STARTADD0] = ulAddress + base; 416fe5e51b7Smrg#ifdef DEBUG 417fe5e51b7Smrg ErrorF("EXIT MGACRTC2GetDisplayStart\n"); 418fe5e51b7Smrg#endif 419fe5e51b7Smrg 420fe5e51b7Smrg} 421fe5e51b7Smrg 422fe5e51b7Smrgvoid MGACRTC2SetDisplayStart (ScrnInfoPtr pScrn, xMODEINFO *pModeInfo, CARD32 base, CARD32 ulX, CARD32 ulY) 423fe5e51b7Smrg{ 424fe5e51b7Smrg MGAPtr pMga = MGAPTR(pScrn); 425fe5e51b7Smrg MGARegPtr pReg; 426fe5e51b7Smrg pReg = &pMga->ModeReg; 427fe5e51b7Smrg#ifdef DEBUG 428fe5e51b7Smrg ErrorF("ENTER MGACRTC2SetDisplayStart\n"); 429fe5e51b7Smrg#endif 430fe5e51b7Smrg 431fe5e51b7Smrg OUTREG(MGAREG_C2STARTADD0, pReg->crtc2[MGAREG2_C2STARTADD0]); 432fe5e51b7Smrg#ifdef DEBUG 433fe5e51b7Smrg ErrorF("EXIT MGACRTC2SetDisplayStart\n"); 434fe5e51b7Smrg#endif 435fe5e51b7Smrg 436fe5e51b7Smrg} 437fe5e51b7Smrg 438fe5e51b7Smrg 439fe5e51b7Smrg 440fe5e51b7Smrg 441fe5e51b7Smrg 442fe5e51b7Smrg 443fe5e51b7Smrg 444fe5e51b7Smrg 445fe5e51b7Smrg 446fe5e51b7Smrg 447fe5e51b7Smrg 448