diff options
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers/ati')
57 files changed, 3767 insertions, 1643 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile index 79bdb9fb3..305988042 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile,v 1.15 2000/06/19 15:00:55 tsi Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile,v 1.17 2000/08/04 21:07:12 tsi Exp $ XCOMM XCOMM Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca XCOMM @@ -33,17 +33,59 @@ ATIMODSRC = atimodule.c ATIMODOBJ = atimodule.o #endif -SRCS = ati.c atiadapter.c atiadjust.c atibank.c atibios.c atibus.c atichip.c \ - aticlock.c aticonsole.c atidac.c atidga.c atidsp.c atiident.c atiio.c \ - atilock.c atimach64.c $(ATIMODSRC) atioption.c atipreinit.c atiprint.c \ - atiprobe.c atiscreen.c atiutil.c ativalid.c ativga.c atividmem.c \ - atiwonder.c +/* + * The following configuration logic is only meant as a first cut, and is + * therefore incomplete. ...And, no, you do NOT have permission to move this + * into xfree86.cf... + * + * Currently, ATIAvoidCPIO >MUST< be #define'd as YES for those platforms + * (architecture/OS combinations) that neither provide nor emulate a + * little-endian undirected PIO address space of at least 64 kB in size. + * + * "Undirected" means the driver does not need to determine the identity nor + * location of the responding adapter before accessing a particular location in + * the PIO address space. + * + * #define'ing ATIAvoidCPIO to YES generates a driver that will only support + * PCI/AGP Mach64 adapters using a linear aperture and the accelerator CRTC. + * The resulting driver will also require the same of the environment on server + * entry. + * + * For testing purposes, #define'ing ATIAvoidCPIO as YES is also supported on + * platforms that do, in fact, provide or emulate a PIO address space as + * described above, but this should not be the default driver configuration. + */ +#if defined(i386Architecture) || defined(ia64Architecture) +# ifndef ATIAvoidCPIO +# define ATIAvoidCPIO NO +# endif +#else +# undef ATIAvoidCPIO /* Clobber any previous setting */ +# define ATIAvoidCPIO YES +#endif + +#if !ATIAvoidCPIO + +CPIOSRCS = atibank.c atibios.c atiio.c ativga.c atiwonder.c +CPIOOBJS = atibank.o atibios.o atiio.o ativga.o atiwonder.o + +#else + +DEFINES = -DAVOID_CPIO + +#endif + +SRCS = ati.c atiadapter.c atiadjust.c atibus.c atichip.c aticlock.c \ + aticonsole.c atidac.c atidga.c atidsp.c atiident.c atilock.c \ + atimach64.c atimach64io.c $(ATIMODSRC) atioption.c atipreinit.c \ + atiprint.c atiprobe.c atiscreen.c atiutil.c ativalid.c atividmem.c \ + $(CPIOSRCS) -OBJS = ati.o atiadapter.o atiadjust.o atibank.o atibios.o atibus.o atichip.o \ - aticlock.o aticonsole.o atidac.o atidga.o atidsp.o atiident.o atiio.o \ - atilock.o atimach64.o $(ATIMODOBJ) atioption.o atipreinit.o atiprint.o \ - atiprobe.o atiscreen.o atiutil.o ativalid.o ativga.o atividmem.o \ - atiwonder.o +OBJS = ati.o atiadapter.o atiadjust.o atibus.o atichip.o aticlock.o \ + aticonsole.o atidac.o atidga.o atidsp.o atiident.o atilock.o \ + atimach64.o atimach64io.o $(ATIMODOBJ) atioption.o atipreinit.o \ + atiprint.o atiprobe.o atiscreen.o atiutil.o ativalid.o atividmem.o \ + $(CPIOOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -109,6 +151,8 @@ InstallDriverSDKNonExecFile(atilock.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atilock.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimach64.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimach64.h,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimach64io.c,$(DRIVERSDKDIR)/drivers/ati) +InstallDriverSDKNonExecFile(atimach64io.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimodule.c,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimodule.h,$(DRIVERSDKDIR)/drivers/ati) InstallDriverSDKNonExecFile(atimono.h,$(DRIVERSDKDIR)/drivers/ati) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c index ed9c0315c..d655859d3 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c,v 1.12 2000/05/11 18:14:29 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c,v 1.13 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -60,6 +60,11 @@ * Mark Vojkovich, mvojkovich@valinux.com * Huw D M Davies, h.davies1@physics.ox.ac.uk * Andrew C Aitchison, A.C.Aitchison@dpmms.cam.ac.uk + * Ani Joshi, ajoshi@shell.unixbox.com + * Kostas Gewrgiou, gewrgiou@imbc.gr + * Jakub Jelinek, jakub@redhat.com + * David S. Miller, davem@redhat.com + * A E Lawrence, adrian.lawrence@computing-services.oxford.ac.uk * * ... and, many, many others from around the world. * diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h index ce4264699..3959dcf24 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h,v 1.5 2000/02/18 12:19:11 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.h,v 1.6 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -32,8 +32,6 @@ #include "xf86_ansic.h" #include "xf86_OSproc.h" -#define ATI_README "\n See README.ati for details.\n" - extern DriverRec ATI; #endif /* ___ATI_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c index 64a104356..3540c74f1 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c,v 1.12 2000/06/19 15:00:55 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c,v 1.13 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,8 +26,8 @@ #include "atichip.h" #include "atidac.h" #include "atidsp.h" -#include "atiio.h" #include "atimach64.h" +#include "atimach64io.h" #include "atiprint.h" #include "ativga.h" #include "atiwonder.h" @@ -38,6 +38,9 @@ const char *ATIAdapterNames[] = { "Unknown", + +#ifndef AVOID_CPIO + "ATI EGA Wonder800", "ATI EGA Wonder800+", "IBM VGA or compatible", @@ -51,10 +54,16 @@ const char *ATIAdapterNames[] = "IBM 8514/A or compatible", "ATI Mach8", "ATI Mach32", + +#endif /* AVOID_CPIO */ + "ATI Mach64", - "ATI Rage128" + "ATI Rage128", + "ATI Radeon" }; +#ifndef AVOID_CPIO + /* * ATICopyVGAMemory -- * @@ -89,10 +98,10 @@ ATICopyVGAMemory static void ATISwap ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI, - ATIHWPtr pATIHW, - Bool ToFB + int iScreen, + ATIPtr pATI, + ATIHWPtr pATIHW, + Bool ToFB ) { pointer save, *from, *to; @@ -125,7 +134,7 @@ ATISwap (pointer)xalloc(pATIHW->nBank * pATIHW->nPlane * 0x00010000U); if (!pATIHW->frame_buffer) { - xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + xf86DrvMsg(iScreen, X_WARNING, "Temporary frame buffer could not be allocated.\n"); return; } @@ -245,6 +254,8 @@ ATISwap } } +#endif /* AVOID_CPIO */ + /* * ATIAdapterPreInit -- * @@ -262,6 +273,8 @@ ATIAdapterPreInit CARD32 lcd_index; int HDisplay, VDisplay; +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { /* Fill in VGA data */ @@ -274,7 +287,12 @@ ATIAdapterPreInit /* Fill in Mach64 data */ if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + + { ATIMach64PreInit(pScreenInfo, pATI, pATIHW); + } if (pATI->Chip >= ATI_CHIP_264CT) { @@ -301,24 +319,24 @@ ATIAdapterPreInit { if (pATI->Chip == ATI_CHIP_264LT) { - pATIHW->horz_stretching = inl(pATI->CPIO_HORZ_STRETCHING); - pATIHW->vert_stretching = inl(pATI->CPIO_VERT_STRETCHING); - pATIHW->lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + pATIHW->horz_stretching = inr(HORZ_STRETCHING); + pATIHW->vert_stretching = inr(VERT_STRETCHING); + pATIHW->lcd_gen_ctrl = inr(LCD_GEN_CTRL); } else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - lcd_index = inl(pATI->CPIO_LCD_INDEX); + lcd_index = inr(LCD_INDEX); pATIHW->lcd_index = (lcd_index & ~(LCD_REG_INDEX | LCD_DISPLAY_DIS | LCD_SRC_SEL)) | (LCD_SRC_SEL_CRTC1 | LCD_CRTC2_DISPLAY_DIS); pATIHW->config_panel = - ATIGetLTProLCDReg(LCD_CONFIG_PANEL) | DONT_SHADOW_HEND; - pATIHW->lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); - pATIHW->horz_stretching = ATIGetLTProLCDReg(LCD_HORZ_STRETCHING); - pATIHW->vert_stretching = ATIGetLTProLCDReg(LCD_VERT_STRETCHING); - outl(pATI->CPIO_LCD_INDEX, lcd_index); + ATIGetMach64LCDReg(LCD_CONFIG_PANEL) | DONT_SHADOW_HEND; + pATIHW->lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); + pATIHW->horz_stretching = ATIGetMach64LCDReg(LCD_HORZ_STRETCHING); + pATIHW->vert_stretching = ATIGetMach64LCDReg(LCD_VERT_STRETCHING); + outr(LCD_INDEX, lcd_index); } pATIHW->lcd_gen_ctrl &= @@ -347,16 +365,18 @@ ATIAdapterPreInit * the registers read here are not the ones actually in use by the * panel. */ - if (inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN) + +#ifndef AVOID_CPIO + + if (pATI->LockData.crtc_gen_cntl & CRTC_EXT_DISP_EN) + +#endif /* AVOID_CPIO */ + { - pATIHW->crtc_h_total_disp = - inl(pATI->CPIO_CRTC_H_TOTAL_DISP); - pATIHW->crtc_h_sync_strt_wid = - inl(pATI->CPIO_CRTC_H_SYNC_STRT_WID); - pATIHW->crtc_v_total_disp = - inl(pATI->CPIO_CRTC_V_TOTAL_DISP); - pATIHW->crtc_v_sync_strt_wid = - inl(pATI->CPIO_CRTC_V_SYNC_STRT_WID); + pATIHW->crtc_h_total_disp = inr(CRTC_H_TOTAL_DISP); + pATIHW->crtc_h_sync_strt_wid = inr(CRTC_H_SYNC_STRT_WID); + pATIHW->crtc_v_total_disp = inr(CRTC_V_TOTAL_DISP); + pATIHW->crtc_v_sync_strt_wid = inr(CRTC_V_SYNC_STRT_WID); HDisplay = GetBits(pATIHW->crtc_h_total_disp, CRTC_H_DISP); VDisplay = GetBits(pATIHW->crtc_v_total_disp, CRTC_V_DISP); @@ -370,15 +390,20 @@ ATIAdapterPreInit pATI->LCDHSyncWidth = GetBits(pATIHW->crtc_h_sync_strt_wid, CRTC_H_SYNC_WID); pATI->LCDHBlankWidth = - GetBits(pATIHW->crtc_h_total_disp, CRTC_H_TOTAL) - HDisplay; + GetBits(pATIHW->crtc_h_total_disp, CRTC_H_TOTAL) - + HDisplay; pATI->LCDVSyncStart = GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_STRT) - VDisplay; pATI->LCDVSyncWidth = GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_WID); pATI->LCDVBlankWidth = - GetBits(pATIHW->crtc_v_total_disp, CRTC_V_TOTAL) - VDisplay; + GetBits(pATIHW->crtc_v_total_disp, CRTC_V_TOTAL) - + VDisplay; } + +#ifndef AVOID_CPIO + else { pATIHW->crt[0] = GetReg(CRTX(pATI->CPIO_VGABase), 0x00U); @@ -397,7 +422,8 @@ ATIAdapterPreInit pATIHW->crt[18]) + 1; pATI->LCDHSyncStart = pATIHW->crt[4] - HDisplay; - pATI->LCDHSyncWidth = (pATIHW->crt[5] - pATIHW->crt[4]) & 0x1FU; + pATI->LCDHSyncWidth = + (pATIHW->crt[5] - pATIHW->crt[4]) & 0x1FU; pATI->LCDHBlankWidth = pATIHW->crt[0] + 5 - HDisplay; pATI->LCDVSyncStart = (((pATIHW->crt[7] << 2) & 0x0200U) | ((pATIHW->crt[7] << 6) & 0x0100U) | @@ -409,6 +435,8 @@ ATIAdapterPreInit pATIHW->crt[6]) + 2 - VDisplay; } +#endif /* AVOID_CPIO */ + HDisplay <<= 3; pATI->LCDHSyncStart <<= 3; pATI->LCDHSyncWidth <<= 3; @@ -456,11 +484,16 @@ ATIAdapterSave ATIHWPtr pATIHW ) { + +#ifndef AVOID_CPIO + int Index; /* Get bank to bank 0 */ (*pATIHW->SetBank)(pATI, 0); +#endif /* AVOID_CPIO */ + /* Save clock data */ ATIClockSave(pScreenInfo, pATI, pATIHW); @@ -483,31 +516,34 @@ ATIAdapterSave { if (pATI->Chip == ATI_CHIP_264LT) { - pATIHW->horz_stretching = inl(pATI->CPIO_HORZ_STRETCHING); - pATIHW->vert_stretching = inl(pATI->CPIO_VERT_STRETCHING); - pATIHW->lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + pATIHW->horz_stretching = inr(HORZ_STRETCHING); + pATIHW->vert_stretching = inr(VERT_STRETCHING); + pATIHW->lcd_gen_ctrl = inr(LCD_GEN_CTRL); /* Set up to save non-shadow registers */ - outl(pATI->CPIO_LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl & + outr(LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); } else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - pATIHW->lcd_index = inl(pATI->CPIO_LCD_INDEX); - pATIHW->config_panel = ATIGetLTProLCDReg(LCD_CONFIG_PANEL); - pATIHW->lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); - pATIHW->horz_stretching = ATIGetLTProLCDReg(LCD_HORZ_STRETCHING); - pATIHW->vert_stretching = ATIGetLTProLCDReg(LCD_VERT_STRETCHING); - pATIHW->ext_vert_stretch = ATIGetLTProLCDReg(LCD_EXT_VERT_STRETCH); + pATIHW->lcd_index = inr(LCD_INDEX); + pATIHW->config_panel = ATIGetMach64LCDReg(LCD_CONFIG_PANEL); + pATIHW->lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); + pATIHW->horz_stretching = ATIGetMach64LCDReg(LCD_HORZ_STRETCHING); + pATIHW->vert_stretching = ATIGetMach64LCDReg(LCD_VERT_STRETCHING); + pATIHW->ext_vert_stretch = + ATIGetMach64LCDReg(LCD_EXT_VERT_STRETCH); /* Set up to save non-shadow registers */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl & + ATIPutMach64LCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); } } +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { /* Save VGA data */ @@ -520,10 +556,15 @@ ATIAdapterSave /* Save Mach64 data */ if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + + { ATIMach64Save(pATI, pATIHW); + } /* Save DSP data */ - if ((pATI->Chip >= ATI_CHIP_264VTB) && (pATI->CPIODecoding == BLOCK_IO)) + if (pATI->Chip >= ATI_CHIP_264VTB) ATIDSPSave(pATI, pATIHW); if (pATI->LCDPanelID >= 0) @@ -532,42 +573,45 @@ ATIAdapterSave { /* Switch to shadow registers */ if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, - (pATIHW->lcd_gen_ctrl & ~CRTC_RW_SELECT) | + outr(LCD_GEN_CTRL, (pATIHW->lcd_gen_ctrl & ~CRTC_RW_SELECT) | (SHADOW_EN | SHADOW_RW_EN)); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, (pATIHW->lcd_gen_ctrl & ~CRTC_RW_SELECT) | (SHADOW_EN | SHADOW_RW_EN)); +#ifndef AVOID_CPIO + /* Save shadow VGA CRTC registers */ for (Index = 0; Index < NumberOf(pATIHW->shadow_vga); Index++) pATIHW->shadow_vga[Index] = GetReg(CRTX(pATI->CPIO_VGABase), Index); +#endif /* AVOID_CPIO */ + /* Save shadow Mach64 CRTC registers */ - pATIHW->shadow_h_total_disp = inl(pATI->CPIO_CRTC_H_TOTAL_DISP); - pATIHW->shadow_h_sync_strt_wid = - inl(pATI->CPIO_CRTC_H_SYNC_STRT_WID); - pATIHW->shadow_v_total_disp = inl(pATI->CPIO_CRTC_V_TOTAL_DISP); - pATIHW->shadow_v_sync_strt_wid = - inl(pATI->CPIO_CRTC_V_SYNC_STRT_WID); + pATIHW->shadow_h_total_disp = inr(CRTC_H_TOTAL_DISP); + pATIHW->shadow_h_sync_strt_wid = inr(CRTC_H_SYNC_STRT_WID); + pATIHW->shadow_v_total_disp = inr(CRTC_V_TOTAL_DISP); + pATIHW->shadow_v_sync_strt_wid = inr(CRTC_V_SYNC_STRT_WID); } /* Restore CRTC selection and shadow state */ if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl); + outr(LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - ATIPutLTProLCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl); - outl(pATI->CPIO_LCD_INDEX, pATIHW->lcd_index); + ATIPutMach64LCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl); + outr(LCD_INDEX, pATIHW->lcd_index); } } +#ifndef AVOID_CPIO + /* * For some unknown reason, CLKDIV2 needs to be turned off to save the * DAC's LUT reliably on VGA Wonder VLB adapters. @@ -575,12 +619,18 @@ ATIAdapterSave if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (pATIHW->seq[1] & 0x08U)) PutReg(SEQX, 0x01U, pATIHW->seq[1] & ~0x08U); +#endif /* AVOID_CPIO */ + /* Save RAMDAC state */ ATIDACSave(pATI, pATIHW); +#ifndef AVOID_CPIO + if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (pATIHW->seq[1] & 0x08U)) PutReg(SEQX, 0x01U, pATIHW->seq[1]); +#endif /* AVOID_CPIO */ + /* * The server has already saved video memory contents when switching out of * its virtual console, so don't do it again. @@ -589,11 +639,22 @@ ATIAdapterSave { pATIHW->FeedbackDivider = 0; /* Don't programme clock */ - ATISwap(pScreenInfo, pATI, pATIHW, FALSE); /* Save video memory */ +#ifndef AVOID_CPIO + + /* Save video memory */ + ATISwap(pScreenInfo->scrnIndex, pATI, pATIHW, FALSE); + +#endif /* AVOID_CPIO */ + } +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) ATIVGASaveScreen(pATI, SCREEN_SAVER_OFF); /* Turn on screen */ + +#endif /* AVOID_CPIO */ + } /* @@ -606,7 +667,7 @@ ATIAdapterSave Bool ATIAdapterCalculate ( - ScrnInfoPtr pScreenInfo, + int iScreen, ATIPtr pATI, ATIHWPtr pATIHW, DisplayModePtr pMode @@ -632,12 +693,17 @@ ATIAdapterCalculate VScan = pATI->LCDVertical / pMode->VDisplay; switch (pATIHW->crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: if (VScan > 64) VScan = 64; pMode->VScan = VScan; break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: pMode->VScan = 0; if (VScan <= 1) @@ -664,6 +730,9 @@ ATIAdapterCalculate switch (pATIHW->crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: /* Fill in VGA data */ ATIVGACalculate(pATI, pATIHW, pMode); @@ -702,7 +771,7 @@ ATIAdapterCalculate pATIHW->crtc_v_sync_strt_wid |= CRTC_V_SYNC_POL; } - pATIHW->crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL) & + pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL) & ~(CRTC_DBL_SCAN_EN | CRTC_INTERLACE_EN | CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_CSYNC_EN | CRTC_PIX_BY_2_EN | CRTC_DISPLAY_DIS | @@ -728,6 +797,8 @@ ATIAdapterCalculate } break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: /* Fill in Mach64 data */ ATIMach64Calculate(pATI, pATIHW, pMode); @@ -750,15 +821,15 @@ ATIAdapterCalculate VDisplay >>= 1; if (pATI->Chip == ATI_CHIP_264LT) - pATIHW->horz_stretching = inl(pATI->CPIO_HORZ_STRETCHING); + pATIHW->horz_stretching = inr(HORZ_STRETCHING); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - pATIHW->horz_stretching = ATIGetLTProLCDReg(LCD_HORZ_STRETCHING); + lcd_index = inr(LCD_INDEX); + pATIHW->horz_stretching = ATIGetMach64LCDReg(LCD_HORZ_STRETCHING); pATIHW->ext_vert_stretch = - ATIGetLTProLCDReg(LCD_EXT_VERT_STRETCH) & + ATIGetMach64LCDReg(LCD_EXT_VERT_STRETCH) & ~(AUTO_VERT_RATIO | VERT_STRETCH_MODE); /* @@ -770,7 +841,7 @@ ATIAdapterCalculate (VDisplay < pATI->LCDVertical)) pATIHW->ext_vert_stretch |= VERT_STRETCH_MODE; - outl(pATI->CPIO_LCD_INDEX, lcd_index); + outr(LCD_INDEX, lcd_index); } pATIHW->horz_stretching &= @@ -793,10 +864,15 @@ ATIAdapterCalculate if (!pATI->OptionCRT) { + +#ifndef AVOID_CPIO + /* Copy non-shadow CRTC register values to the shadow set */ for (Index = 0; Index < NumberOf(pATIHW->shadow_vga); Index++) pATIHW->shadow_vga[Index] = pATIHW->crt[Index]; +#endif /* AVOID_CPIO */ + pATIHW->shadow_h_total_disp = pATIHW->crtc_h_total_disp; pATIHW->shadow_h_sync_strt_wid = pATIHW->crtc_h_sync_strt_wid; pATIHW->shadow_v_total_disp = pATIHW->crtc_v_total_disp; @@ -805,7 +881,7 @@ ATIAdapterCalculate } /* Fill in clock data */ - if (!ATIClockCalculate(pScreenInfo, pATI, pATIHW, pMode)) + if (!ATIClockCalculate(iScreen, pATI, pATIHW, pMode)) return FALSE; /* Setup ECP clock divider */ @@ -836,11 +912,16 @@ ATIAdapterSet ATIHWPtr pATIHW ) { + +#ifndef AVOID_CPIO + int Index; /* Get back to bank 0 */ (*pATIHW->SetBank)(pATI, 0); +#endif /* AVOID_CPIO */ + if (pATI->Chip >= ATI_CHIP_264CT) { ATIPutMach64PLLReg(PLL_VCLK_CNTL, pATIHW->pll_vclk_cntl); @@ -860,20 +941,20 @@ ATIAdapterSet if (pATI->LCDPanelID >= 0) { /* Stop CRTC */ - outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & ~(CRTC_EXT_DISP_EN | CRTC_EN)); if (pATI->Chip == ATI_CHIP_264LT) { /* Update non-shadow registers first */ - outl(pATI->CPIO_LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl & + outr(LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl & ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); /* Temporarily disable stretching */ - outl(pATI->CPIO_HORZ_STRETCHING, pATIHW->horz_stretching & + outr(HORZ_STRETCHING, pATIHW->horz_stretching & ~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN)); - outl(pATI->CPIO_VERT_STRETCHING, pATIHW->vert_stretching & + outr(VERT_STRETCHING, pATIHW->vert_stretching & ~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 | VERT_STRETCH_USE0 | VERT_STRETCH_EN)); } @@ -882,15 +963,15 @@ ATIAdapterSet (pATI->Chip == ATI_CHIP_MOBILITY)) */ { /* Update non-shadow registers first */ - ATIPutLTProLCDReg(LCD_CONFIG_PANEL, pATIHW->config_panel); - ATIPutLTProLCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl & + ATIPutMach64LCDReg(LCD_CONFIG_PANEL, pATIHW->config_panel); + ATIPutMach64LCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl & ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); /* Temporarily disable stretching */ - ATIPutLTProLCDReg(LCD_HORZ_STRETCHING, pATIHW->horz_stretching & + ATIPutMach64LCDReg(LCD_HORZ_STRETCHING, pATIHW->horz_stretching & ~(HORZ_STRETCH_MODE | HORZ_STRETCH_EN)); - ATIPutLTProLCDReg(LCD_VERT_STRETCHING, pATIHW->vert_stretching & + ATIPutMach64LCDReg(LCD_VERT_STRETCHING, pATIHW->vert_stretching & ~(VERT_STRETCH_RATIO1 | VERT_STRETCH_RATIO2 | VERT_STRETCH_USE0 | VERT_STRETCH_EN)); } @@ -898,18 +979,20 @@ ATIAdapterSet switch (pATIHW->crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: /* Stop CRTC */ if (pATI->Chip >= ATI_CHIP_88800GXC) - outl(pATI->CPIO_CRTC_GEN_CNTL, - pATIHW->crtc_gen_cntl & ~CRTC_EN); + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & ~CRTC_EN); /* Start sequencer reset */ PutReg(SEQX, 0x00U, 0x00U); /* Set pixel clock */ if ((pATIHW->FeedbackDivider > 0) && - (pATI->ProgrammableClock != ATI_CLOCK_FIXED)) + (pATI->ProgrammableClock > ATI_CLOCK_FIXED)) ATIClockSet(pATI, pATIHW); /* Load VGA Wonder */ @@ -922,32 +1005,32 @@ ATIAdapterSet /* Load Mach64 registers */ if (pATI->Chip >= ATI_CHIP_88800GXC) { - outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl); - outl(pATI->CPIO_MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel); - outl(pATI->CPIO_MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel); - outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl); + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl); + outr(MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel); + outr(MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel); + outr(CONFIG_CNTL, pATIHW->config_cntl); if (pATI->Chip >= ATI_CHIP_264CT) { - outl(pATI->CPIO_CRTC_H_TOTAL_DISP, - pATIHW->crtc_h_total_disp); - outl(pATI->CPIO_CRTC_H_SYNC_STRT_WID, - pATIHW->crtc_h_sync_strt_wid); - outl(pATI->CPIO_CRTC_V_TOTAL_DISP, - pATIHW->crtc_v_total_disp); - outl(pATI->CPIO_CRTC_V_SYNC_STRT_WID, - pATIHW->crtc_v_sync_strt_wid); - outl(pATI->CPIO_CRTC_OFF_PITCH, pATIHW->crtc_off_pitch); - outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl); - outl(pATI->CPIO_DAC_CNTL, pATIHW->dac_cntl); + outr(CRTC_H_TOTAL_DISP, pATIHW->crtc_h_total_disp); + outr(CRTC_H_SYNC_STRT_WID, pATIHW->crtc_h_sync_strt_wid); + outr(CRTC_V_TOTAL_DISP, pATIHW->crtc_v_total_disp); + outr(CRTC_V_SYNC_STRT_WID, pATIHW->crtc_v_sync_strt_wid); + outr(CRTC_OFF_PITCH, pATIHW->crtc_off_pitch); + outr(BUS_CNTL, pATIHW->bus_cntl); + outr(DAC_CNTL, pATIHW->dac_cntl); } } break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: /* Load Mach64 CRTC registers */ ATIMach64Set(pATI, pATIHW); +#ifndef AVOID_CPIO + if (pATI->UseSmallApertures) { /* Oddly enough, these need to be set also, maybe others */ @@ -958,6 +1041,8 @@ ATIAdapterSet ATIModifyExtReg(pATI, 0xB6U, -1, 0x00U, pATIHW->b6); } +#endif /* AVOID_CPIO */ + break; default: @@ -971,14 +1056,13 @@ ATIAdapterSet { /* Switch to shadow registers */ if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, - (pATIHW->lcd_gen_ctrl & + outr(LCD_GEN_CTRL, (pATIHW->lcd_gen_ctrl & ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT)) | (SHADOW_EN | SHADOW_RW_EN)); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, (pATIHW->lcd_gen_ctrl & ~(DISABLE_PCLK_RESET | CRTC_RW_SELECT)) | (SHADOW_EN | SHADOW_RW_EN)); @@ -986,6 +1070,9 @@ ATIAdapterSet /* Restore shadow registers */ switch (pATIHW->crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: for (Index = 0; Index < NumberOf(pATIHW->shadow_vga); @@ -994,15 +1081,13 @@ ATIAdapterSet pATIHW->shadow_vga[Index]); /* Fall through */ +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: - outl(pATI->CPIO_CRTC_H_TOTAL_DISP, - pATIHW->shadow_h_total_disp); - outl(pATI->CPIO_CRTC_H_SYNC_STRT_WID, - pATIHW->shadow_h_sync_strt_wid); - outl(pATI->CPIO_CRTC_V_TOTAL_DISP, - pATIHW->shadow_v_total_disp); - outl(pATI->CPIO_CRTC_V_SYNC_STRT_WID, - pATIHW->shadow_v_sync_strt_wid); + outr(CRTC_H_TOTAL_DISP, pATIHW->shadow_h_total_disp); + outr(CRTC_H_SYNC_STRT_WID, pATIHW->shadow_h_sync_strt_wid); + outr(CRTC_V_TOTAL_DISP, pATIHW->shadow_v_total_disp); + outr(CRTC_V_SYNC_STRT_WID, pATIHW->shadow_v_sync_strt_wid); break; default: @@ -1013,19 +1098,19 @@ ATIAdapterSet /* Restore CRTC selection & shadow state and enable stretching */ if (pATI->Chip == ATI_CHIP_264LT) { - outl(pATI->CPIO_LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl); - outl(pATI->CPIO_HORZ_STRETCHING, pATIHW->horz_stretching); - outl(pATI->CPIO_VERT_STRETCHING, pATIHW->vert_stretching); + outr(LCD_GEN_CTRL, pATIHW->lcd_gen_ctrl); + outr(HORZ_STRETCHING, pATIHW->horz_stretching); + outr(VERT_STRETCHING, pATIHW->vert_stretching); } else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - ATIPutLTProLCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl); - ATIPutLTProLCDReg(LCD_HORZ_STRETCHING, pATIHW->horz_stretching); - ATIPutLTProLCDReg(LCD_VERT_STRETCHING, pATIHW->vert_stretching); - ATIPutLTProLCDReg(LCD_EXT_VERT_STRETCH, pATIHW->ext_vert_stretch); - outl(pATI->CPIO_LCD_INDEX, pATIHW->lcd_index); + ATIPutMach64LCDReg(LCD_GEN_CNTL, pATIHW->lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_HORZ_STRETCHING, pATIHW->horz_stretching); + ATIPutMach64LCDReg(LCD_VERT_STRETCHING, pATIHW->vert_stretching); + ATIPutMach64LCDReg(LCD_EXT_VERT_STRETCH, pATIHW->ext_vert_stretch); + outr(LCD_INDEX, pATIHW->lcd_index); } } @@ -1033,18 +1118,22 @@ ATIAdapterSet * Set DSP registers. Note that, for some reason, sequencer resets clear * the DSP_CONFIG register on early integrated controllers. */ - if ((pATI->Chip >= ATI_CHIP_264VTB) && (pATI->CPIODecoding == BLOCK_IO)) + if (pATI->Chip >= ATI_CHIP_264VTB) ATIDSPSet(pATI, pATIHW); /* Load RAMDAC */ ATIDACSet(pATI, pATIHW); +#ifndef AVOID_CPIO + /* Restore video memory */ - ATISwap(pScreenInfo, pATI, pATIHW, TRUE); + ATISwap(pScreenInfo->scrnIndex, pATI, pATIHW, TRUE); if (pATI->VGAAdapter != ATI_ADAPTER_NONE) ATIVGASaveScreen(pATI, SCREEN_SAVER_OFF); /* Turn on screen */ +#endif /* AVOID_CPIO */ + if ((xf86GetVerbosity() > 3) && (pATIHW == &pATI->NewHW)) { xf86ErrorFVerb(4, "\n After setting mode \"%s\":\n\n", diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h index f616c35e4..e206c2a88 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h,v 1.5 2000/02/18 12:19:12 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.h,v 1.6 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" /* @@ -34,6 +35,9 @@ typedef enum { ATI_ADAPTER_NONE = 0, + +#ifndef AVOID_CPIO + ATI_ADAPTER_EGA, ATI_ADAPTER_EGA_PLUS, ATI_ADAPTER_VGA, @@ -47,8 +51,12 @@ typedef enum ATI_ADAPTER_8514A, ATI_ADAPTER_MACH8, ATI_ADAPTER_MACH32, + +#endif /* AVOID_CPIO */ + ATI_ADAPTER_MACH64, ATI_ADAPTER_RAGE128, + ATI_ADAPTER_RADEON, ATI_ADAPTER_MAX /* Must be last */ } ATIAdapterType; @@ -58,8 +66,8 @@ extern void ATIAdapterPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); extern void ATIAdapterSave FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); -extern Bool ATIAdapterCalculate FunctionPrototype((ScrnInfoPtr, ATIPtr, - ATIHWPtr, DisplayModePtr)); +extern Bool ATIAdapterCalculate FunctionPrototype((int, ATIPtr, ATIHWPtr, + DisplayModePtr)); extern void ATIAdapterSet FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c index 5b94998a0..78b199bfb 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c,v 1.6 2000/06/19 15:00:55 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c,v 1.8 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,12 +21,12 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atiadjust.h" #include "atichip.h" #include "aticrtc.h" -#include "atiio.h" #include "atilock.h" -#include "xf86.h" +#include "atimach64io.h" /* * The display start address is expressed in units of 32-bit (VGA) or 64-bit @@ -50,6 +50,8 @@ ATIAdjustPreInit { unsigned long MaxBase; +#ifndef AVOID_CPIO + if ((pATI->CPIO_VGAWonder) && (pATI->Chip <= ATI_CHIP_18800_1) && (pATI->VideoRAM == 256) && @@ -60,6 +62,9 @@ ATIAdjustPreInit pATI->AdjustMask = (unsigned long)(-32); } else + +#endif /* AVOID_CPIO */ + { pATI->AdjustDepth = (pATI->bitsPerPixel + 7) >> 3; @@ -73,6 +78,9 @@ ATIAdjustPreInit switch (pATI->NewHW.crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: if (pATI->Chip >= ATI_CHIP_264CT) { @@ -88,6 +96,8 @@ ATIAdjustPreInit pATI->AdjustMaxBase = 0x0FFFFFU << 3; break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: pATI->AdjustMaxBase = MaxBits(CRTC_OFFSET) << 3; break; @@ -141,6 +151,8 @@ ATIAdjustFrame /* Unlock registers */ ATIUnlock(pATI); +#ifndef AVOID_CPIO + if ((pATI->NewHW.crtc == ATI_CRTC_VGA) && (pATI->Chip < ATI_CHIP_264CT)) { PutReg(CRTX(pATI->CPIO_VGABase), 0x0CU, GetByte(Base, 1)); @@ -165,6 +177,9 @@ ATIAdjustFrame } } else + +#endif /* AVOID_CPIO */ + { /* * On integrated controllers, there is only one set of CRTC control @@ -173,19 +188,29 @@ ATIAdjustFrame * setting the CRTC's offset register to more than 256k needs to be * done through the accelerator port. */ + +#ifndef AVOID_CPIO + if (pATI->depth <= 4) { - outl(pATI->CPIO_CRTC_OFF_PITCH, - SetBits(pATI->displayWidth >> 4, CRTC_PITCH) | - SetBits(Base, CRTC_OFFSET)); + outr(CRTC_OFF_PITCH, SetBits(pATI->displayWidth >> 4, CRTC_PITCH) | + SetBits(Base, CRTC_OFFSET)); } else + +#endif /* AVOID_CPIO */ + { + +#ifndef AVOID_CPIO + if (pATI->NewHW.crtc == ATI_CRTC_VGA) Base <<= 1; /* LSBit must be zero */ - outl(pATI->CPIO_CRTC_OFF_PITCH, - SetBits(pATI->displayWidth >> 3, CRTC_PITCH) | - SetBits(Base, CRTC_OFFSET)); + +#endif /* AVOID_CPIO */ + + outr(CRTC_OFF_PITCH, SetBits(pATI->displayWidth >> 3, CRTC_PITCH) | + SetBits(Base, CRTC_OFFSET)); } } } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c index 64d175c11..9ba4c2832 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c,v 1.6 2000/03/22 03:08:09 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c,v 1.8 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,9 +21,11 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atibank.h" -#include "atiio.h" -#include "xf86.h" +#include "atimach64io.h" + +#ifndef AVOID_CPIO /* * ATI VGA Wonder V3 adapters use an ATI 18800 chip and are single-banked. @@ -266,8 +268,9 @@ ATIMach64SetBankPacked ) { CARD32 tmp = ATIMach64MassagePackedBankNumber(iBank); - outl(pATI->CPIO_MEM_VGA_RP_SEL, tmp); - outl(pATI->CPIO_MEM_VGA_WP_SEL, tmp); + + outr(MEM_VGA_RP_SEL, tmp); + outr(MEM_VGA_WP_SEL, tmp); } /* @@ -282,8 +285,9 @@ ATIMach64SetReadPacked unsigned int iBank ) { - outl(ATIPTR(XF86SCRNINFO(pScreen))->CPIO_MEM_VGA_RP_SEL, - ATIMach64MassagePackedBankNumber(iBank)); + ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); + + outr(MEM_VGA_RP_SEL, ATIMach64MassagePackedBankNumber(iBank)); return 0; } @@ -299,8 +303,9 @@ ATIMach64SetWritePacked unsigned int iBank ) { - outl(ATIPTR(XF86SCRNINFO(pScreen))->CPIO_MEM_VGA_WP_SEL, - ATIMach64MassagePackedBankNumber(iBank)); + ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); + + outr(MEM_VGA_WP_SEL, ATIMach64MassagePackedBankNumber(iBank)); return 0; } @@ -343,8 +348,9 @@ ATIMach64SetBankPlanar ) { CARD32 tmp = ATIMach64MassagePlanarBankNumber(iBank); - outl(pATI->CPIO_MEM_VGA_RP_SEL, tmp); - outl(pATI->CPIO_MEM_VGA_WP_SEL, tmp); + + outr(MEM_VGA_RP_SEL, tmp); + outr(MEM_VGA_WP_SEL, tmp); } /* @@ -359,8 +365,9 @@ ATIMach64SetReadPlanar unsigned int iBank ) { - outl(ATIPTR(XF86SCRNINFO(pScreen))->CPIO_MEM_VGA_RP_SEL, - ATIMach64MassagePlanarBankNumber(iBank)); + ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); + + outr(MEM_VGA_RP_SEL, ATIMach64MassagePlanarBankNumber(iBank)); return 0; } @@ -376,8 +383,9 @@ ATIMach64SetWritePlanar unsigned int iBank ) { - outl(ATIPTR(XF86SCRNINFO(pScreen))->CPIO_MEM_VGA_WP_SEL, - ATIMach64MassagePlanarBankNumber(iBank)); + ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen)); + + outr(MEM_VGA_WP_SEL, ATIMach64MassagePlanarBankNumber(iBank)); return 0; } @@ -396,3 +404,5 @@ ATIMach64SetReadWritePlanar ATIMach64SetBankPlanar(ATIPTR(XF86SCRNINFO(pScreen)), iBank); return 0; } + +#endif /* AVOID_CPIO */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h index 1473c31bb..5922386ab 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h,v 1.4 2000/02/18 12:19:13 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.h,v 1.5 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,8 +26,11 @@ #include "atipriv.h" #include "atiproto.h" + #include "mibank.h" +#ifndef AVOID_CPIO + /* * Banking definitions. */ @@ -80,4 +83,6 @@ extern ATIBankProc ATIV3SetBank, ATIMach64SetBankPacked, ATIMach64SetBankPlanar; +#endif /* AVOID_CPIO */ + #endif /* ___ATIBANK_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c index 3ca1adc95..c543d519b 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c,v 1.5 2000/02/18 12:19:14 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.c,v 1.6 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,8 @@ #include "atibios.h" #include "atistruct.h" +#ifndef AVOID_CPIO + /* * ATIReadBIOS -- * @@ -47,7 +49,7 @@ ATIReadBIOS * disabled on server entry. */ if ((pVideo = pATI->PCIInfo) && - (((pPCI = (pciConfigPtr)(pVideo->thisCard))->pci_command & + (((pPCI = pVideo->thisCard)->pci_command & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)) != (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE))) @@ -61,3 +63,5 @@ ATIReadBIOS pATI->BIOSBase = 0x000C0000U; return xf86ReadBIOS(pATI->BIOSBase, Offset, Buffer, Length); } + +#endif /* AVOID_CPIO */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h index 43fd902ac..24f6b0d2b 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h,v 1.2 2000/02/18 12:19:14 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibios.h,v 1.3 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,9 +26,14 @@ #include "atipriv.h" #include "atiproto.h" + #include "Xmd.h" +#ifndef AVOID_CPIO + extern int ATIReadBIOS FunctionPrototype((ATIPtr, pointer, unsigned long, int)); +#endif /* AVOID_CPIO */ + #endif /* ___ATIBIOS_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c index 0d44a5c0d..93fcd7b14 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c,v 1.8 2000/05/03 00:44:03 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c,v 1.9 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -46,6 +46,28 @@ const char *ATIBusNames[] = }; /* + * ATIRefreshPCIBases -- + * + * This function ensures the common layer's view of an adapter's PCI resources + * is up-to-date. This should eventually be moved into the common layer. + */ +void +ATIRefreshPCIBases +( + pciVideoPtr pVideo, + pciConfigPtr pPCI +) +{ + pPCI->pci_base0 = pciReadLong(pPCI->tag, PCI_CMD_BASE_REG + 0); + pPCI->pci_base1 = pciReadLong(pPCI->tag, PCI_CMD_BASE_REG + 4); + pPCI->pci_base2 = pciReadLong(pPCI->tag, PCI_CMD_BASE_REG + 8); + + pVideo->memBase[0] = PCIGETMEMORY(pPCI->pci_base0); + pVideo->ioBase[1] = PCIGETIO(pPCI->pci_base1); + pVideo->memBase[2] = PCIGETMEMORY(pPCI->pci_base2); +} + +/* * ATIClaimResources -- * * This function registers most of the bus resources used by an adapter. The @@ -62,6 +84,9 @@ ATIClaimResources ) { resPtr pResources; + +#ifndef AVOID_CPIO + resRange Resources[2] = {{0, 0, 0}, _END}; /* Claim VGA and VGAWonder resources */ @@ -98,8 +123,13 @@ ATIClaimResources } } +#endif /* AVOID_CPIO */ + if (Active || !pATI->SharedAccelerator) { + +#ifndef AVOID_CPIO + /* Claim 8514/A resources */ if (pATI->ChipHasSUBSYS_CNTL) xf86ClaimFixedResources( @@ -120,6 +150,8 @@ ATIClaimResources xf86ClaimFixedResources(Resources, pATI->iEntity); } +#endif /* AVOID_CPIO */ + /* Register relocatable resources for inactive adapters */ if (!Active) { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h index a5b1bdd9e..84b46e7a4 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h,v 1.5 2000/02/18 12:19:15 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.h,v 1.6 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -22,10 +22,17 @@ */ #ifndef ___ATIBUS_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error missing #include "ati.h" before #include "atibus.h" +# undef XFree86Module +#endif + #define ___ATIBUS_H___ 1 #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" /* @@ -46,7 +53,8 @@ typedef enum extern const char *ATIBusNames[]; -extern int ATIClaimBusSlot FunctionPrototype((DriverPtr, int, GDevPtr, Bool, - ATIPtr)); +extern void ATIRefreshPCIBases FunctionPrototype((pciVideoPtr, pciConfigPtr)); +extern int ATIClaimBusSlot FunctionPrototype((DriverPtr, int, GDevPtr, + Bool, ATIPtr)); #endif /* ___ATIBUS_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c index c50cf1641..397e0bcaa 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c,v 1.11 2000/04/20 21:28:28 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c,v 1.12 2000/08/04 21:07:12 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,7 +24,7 @@ #include "ati.h" #include "atibus.h" #include "atichip.h" -#include "atiio.h" +#include "atimach64io.h" #include "ativersion.h" /* @@ -33,6 +33,9 @@ const char *ATIChipNames[] = { "Unknown", + +#ifndef AVOID_CPIO + "IBM VGA or compatible", "ATI 18800", "ATI 18800-1", @@ -48,6 +51,9 @@ const char *ATIChipNames[] = "ATI 68800-6", "ATI 68800LX", "ATI 68800AX", + +#endif /* AVOID_CPIO */ + "ATI 88800GX-C", "ATI 88800GX-D", "ATI 88800GX-E", @@ -79,6 +85,8 @@ const char *ATIChipNames[] = const char *ATIFoundryNames[] = { "SGS", "NEC", "KCS", "UMC", "TSMC", "5", "6", "UMC" }; +#ifndef AVOID_CPIO + /* * ATIMach32ChipID -- * @@ -121,6 +129,8 @@ ATIMach32ChipID } } +#endif /* AVOID_CPIO */ + /* * ATIMach64ChipID -- * @@ -134,13 +144,13 @@ ATIMach64ChipID const CARD16 ExpectedChipType ) { - CARD32 IOValue = inl(ATIIOPort(CONFIG_CHIP_ID)); - pATI->ChipType = GetBits(IOValue, 0xFFFFU); - pATI->ChipClass = GetBits(IOValue, CFG_CHIP_CLASS); - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REV); - pATI->ChipVersion = GetBits(IOValue, CFG_CHIP_VERSION); - pATI->ChipFoundry = GetBits(IOValue, CFG_CHIP_FOUNDRY); - pATI->ChipRev = pATI->ChipRevision; + pATI->config_chip_id = inr(CONFIG_CHIP_ID); + pATI->ChipType = GetBits(pATI->config_chip_id, 0xFFFFU); + pATI->ChipClass = GetBits(pATI->config_chip_id, CFG_CHIP_CLASS); + pATI->ChipRevision = GetBits(pATI->config_chip_id, CFG_CHIP_REV); + pATI->ChipVersion = GetBits(pATI->config_chip_id, CFG_CHIP_VERSION); + pATI->ChipFoundry = GetBits(pATI->config_chip_id, CFG_CHIP_FOUNDRY); + pATI->ChipRev = pATI->ChipRevision; switch (pATI->ChipType) { case OldChipID('G', 'X'): @@ -179,7 +189,8 @@ ATIMach64ChipID case OldChipID('C', 'T'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('C', 'T'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264CT; pATI->BusType = ATI_BUS_PCI; break; @@ -187,7 +198,8 @@ ATIMach64ChipID case OldChipID('E', 'T'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('E', 'T'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264ET; pATI->BusType = ATI_BUS_PCI; break; @@ -195,7 +207,8 @@ ATIMach64ChipID case OldChipID('V', 'T'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('V', 'T'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264VT; pATI->BusType = ATI_BUS_PCI; /* Some early GT's are detected as VT's */ @@ -216,7 +229,8 @@ ATIMach64ChipID case OldChipID('G', 'T'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'T'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->BusType = ATI_BUS_PCI; if (!pATI->ChipVersion) pATI->Chip = ATI_CHIP_264GT; @@ -227,7 +241,8 @@ ATIMach64ChipID case OldChipID('V', 'U'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('V', 'U'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264VT3; pATI->BusType = ATI_BUS_PCI; break; @@ -235,7 +250,8 @@ ATIMach64ChipID case OldChipID('G', 'U'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'U'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GTDVD; pATI->BusType = ATI_BUS_PCI; break; @@ -243,7 +259,8 @@ ATIMach64ChipID case OldChipID('L', 'G'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'G'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264LT; pATI->BusType = ATI_BUS_PCI; break; @@ -251,7 +268,8 @@ ATIMach64ChipID case OldChipID('V', 'V'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('V', 'V'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264VT4; pATI->BusType = ATI_BUS_PCI; break; @@ -259,7 +277,8 @@ ATIMach64ChipID case OldChipID('G', 'V'): pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'V'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GT2C; pATI->BusType = ATI_BUS_PCI; break; @@ -269,7 +288,8 @@ ATIMach64ChipID pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'W'): case NewChipID('G', 'Z'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GT2C; pATI->BusType = ATI_BUS_AGP; break; @@ -281,7 +301,8 @@ ATIMach64ChipID case NewChipID('G', 'I'): case NewChipID('G', 'P'): case NewChipID('G', 'Q'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GTPRO; pATI->BusType = ATI_BUS_PCI; break; @@ -291,7 +312,8 @@ ATIMach64ChipID pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'B'): case NewChipID('G', 'D'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264GTPRO; pATI->BusType = ATI_BUS_AGP; break; @@ -301,7 +323,8 @@ ATIMach64ChipID pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'I'): case NewChipID('L', 'P'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264LTPRO; pATI->BusType = ATI_BUS_PCI; pATI->LCDVBlendFIFOSize = 800; @@ -312,7 +335,8 @@ ATIMach64ChipID pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'B'): case NewChipID('L', 'D'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264LTPRO; pATI->BusType = ATI_BUS_AGP; pATI->LCDVBlendFIFOSize = 800; @@ -327,7 +351,8 @@ ATIMach64ChipID case NewChipID('G', 'O'): case NewChipID('G', 'R'): case NewChipID('G', 'S'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264XL; pATI->BusType = ATI_BUS_PCI; pATI->LCDVBlendFIFOSize = 1024; @@ -338,7 +363,8 @@ ATIMach64ChipID pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('G', 'M'): case NewChipID('G', 'N'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_264XL; pATI->BusType = ATI_BUS_AGP; pATI->LCDVBlendFIFOSize = 1024; @@ -349,7 +375,8 @@ ATIMach64ChipID pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'R'): case NewChipID('L', 'S'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_MOBILITY; pATI->BusType = ATI_BUS_PCI; pATI->LCDVBlendFIFOSize = 1024; @@ -360,7 +387,8 @@ ATIMach64ChipID pATI->ChipType = OldToNewChipID(pATI->ChipType); case NewChipID('L', 'M'): case NewChipID('L', 'N'): - pATI->ChipRevision = GetBits(IOValue, CFG_CHIP_REVISION); + pATI->ChipRevision = + GetBits(pATI->config_chip_id, CFG_CHIP_REVISION); pATI->Chip = ATI_CHIP_MOBILITY; pATI->BusType = ATI_BUS_AGP; pATI->LCDVBlendFIFOSize = 1024; @@ -373,7 +401,7 @@ ATIMach64ChipID } /* - * ATIPCIChip -- + * ATIChipID -- * * This returns the ATI_CHIP_* value (generally) associated with a particular * ChipID/ChipRev combination. @@ -387,6 +415,9 @@ ATIChipID { switch (ChipID) { + +#ifndef AVOID_CPIO + case OldChipID('A', 'A'): case NewChipID('A', 'A'): return ATI_CHIP_68800_3; @@ -399,6 +430,8 @@ ATIChipID case OldChipID('A', 'X'): case NewChipID('A', 'X'): return ATI_CHIP_68800AX; +#endif /* AVOID_CPIO */ + case OldChipID('G', 'X'): case NewChipID('G', 'X'): switch (ChipRev) { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h index 395602062..e548aa6a5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h,v 1.10 2000/03/30 15:41:17 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h,v 1.11 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiregs.h" + #include "Xmd.h" /* @@ -34,6 +35,9 @@ typedef enum { ATI_CHIP_NONE = 0, + +#ifndef AVOID_CPIO + ATI_CHIP_VGA, /* Generic VGA */ ATI_CHIP_18800, ATI_CHIP_18800_1, @@ -49,6 +53,9 @@ typedef enum ATI_CHIP_68800_6, /* Mach32 */ ATI_CHIP_68800LX, /* Mach32 */ ATI_CHIP_68800AX, /* Mach32 */ + +#endif /* AVOID_CPIO */ + ATI_CHIP_88800GXC, /* Mach64 */ ATI_CHIP_88800GXD, /* Mach64 */ ATI_CHIP_88800GXE, /* Mach64 */ @@ -96,7 +103,12 @@ typedef enum extern const char *ATIFoundryNames[]; +#ifndef AVOID_CPIO + extern void ATIMach32ChipID FunctionPrototype((ATIPtr)); + +#endif /* AVOID_CPIO */ + extern void ATIMach64ChipID FunctionPrototype((ATIPtr, const CARD16)); extern ATIChipType ATIChipID FunctionPrototype((const CARD16, const CARD8)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c index 5cd0604c2..23e682d3f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c,v 1.10 2000/06/19 15:00:55 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c,v 1.11 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -197,6 +197,7 @@ #include "atichip.h" #include "atidac.h" #include "atidsp.h" +#include "atimach64io.h" /* * Definitions related to non-programmable clock generators. @@ -241,7 +242,7 @@ ClockRec ATIClockDescriptors[] = "SGS-Thompson 1703 or similar" }, { - 8, 263, 8, 8, 9, + 16, 263, 8, 8, 9, 4, 12, 2, 4, ATIPostDividers, "Chrontel 8398 or similar" @@ -268,7 +269,7 @@ ClockRec ATIClockDescriptors[] = /* * XF86Config clocks line that start with the following will either be rejected - * for ATI boards, or accepted for non-ATI boards. + * for ATI adapters, or accepted for non-ATI adapters. */ static const int ATIVGAClocks[] = @@ -422,113 +423,6 @@ static const CARD8 ClockMaps[][4] = ((_Index) & ~0x0CU)) /* - * ATIClockSelect -- - * - * This function sets clock select bits in various registers to a specified - * value. - */ -static Bool -ATIClockSelect -( - ScrnInfoPtr pScreenInfo, - int Index -) -{ - ATIPtr pATI = ATIPTR(pScreenInfo); - CARD8 genmo; - - switch (Index) - { - case CLK_REG_SAVE: - if (pATI->CPIO_VGAWonder && (pATI->OldHW.crtc == ATI_CRTC_VGA)) - ATIModifyExtReg(pATI, 0xB5U, pATI->OldHW.b5, 0x7FU, 0x00U); - break; - - case CLK_REG_RESTORE: - break; - - default: - /* Remap clock number */ - Index = MapClockIndex(pATI->OldHW.ClockMap, Index); - - switch (pATI->OldHW.crtc) - { - case ATI_CRTC_VGA: - /* Get generic two low-order bits */ - genmo = (inb(R_GENMO) & 0xF3U) | ((Index << 2) & 0x0CU); - - if (pATI->CPIO_VGAWonder) - { - /* - * On adapters with crystals, switching to one of the - * spare assignments doesn't do anything (i.e. the - * previous setting remains in effect). So, disable - * their selection. - */ - if (((Index & 0x03U) == 0x02U) && - ((pATI->Chip <= ATI_CHIP_18800) || - (pATI->Adapter == ATI_ADAPTER_V4))) - return FALSE; - - /* Start sequencer reset */ - PutReg(SEQX, 0x00U, 0x00U); - - /* Set high-order bits */ - if (pATI->Chip <= ATI_CHIP_18800) - ATIModifyExtReg(pATI, 0xB2U, -1, 0xBFU, - Index << 4); - else - { - ATIModifyExtReg(pATI, 0xBEU, -1, 0xEFU, - Index << 2); - if (pATI->Adapter != ATI_ADAPTER_V4) - { - Index >>= 1; - ATIModifyExtReg(pATI, 0xB9U, -1, 0xFDU, - Index >> 1); - } - } - - /* Set clock divider bits */ - ATIModifyExtReg(pATI, 0xB8U, -1, 0x00U, - (Index << 3) & 0xC0U); - } - else - { - /* - * Reject clocks that cannot be selected. - */ - if (Index & ~0x03U) - return FALSE; - - /* Start sequencer reset */ - PutReg(SEQX, 0x00U, 0x00U); - } - - /* Must set miscellaneous output register last */ - outb(GENMO, genmo); - - /* End sequencer reset */ - PutReg(SEQX, 0x00U, 0x03U); - - break; - - case ATI_CRTC_MACH64: - outl(pATI->CPIO_CLOCK_CNTL, CLOCK_STROBE | - SetBits(Index, CLOCK_SELECT | CLOCK_DIVIDER)); - break; - - default: - return FALSE; - } - - break; - } - - return TRUE; -} - -/* * ATIMatchClockLine -- * * This function tries to match the XF86Config clocks to one of an array of @@ -550,9 +444,18 @@ ATIMatchClockLine int MinimumGap = CLOCK_TOLERANCE + 1; /* For ATI adapters, reject generic VGA clocks */ - if ((pATI->Adapter != ATI_ADAPTER_VGA) && - (ClockLine == SpecificationClockLine)) - ClockChipIndex++; + +#ifndef AVOID_CPIO + + if (pATI->Adapter != ATI_ADAPTER_VGA) + +#endif /* AVOID_CPIO */ + + { + if (ClockLine == SpecificationClockLine) + ClockChipIndex++; + } + /* If checking for XF86Config clock order, skip crystals */ if (ClockMap) ClockChipIndex++; @@ -561,11 +464,15 @@ ATIMatchClockLine { int MaximumGap = 0, ClockCount = 0, ClockIndex = 0; +#ifndef AVOID_CPIO + /* Only Mach64's and Rage128's can have programmable clocks */ if ((ClockChipIndex >= ATI_CLOCK_MACH64A) && (pATI->Adapter < ATI_ADAPTER_MACH64)) break; +#endif /* AVOID_CPIO */ + for (; ClockIndex < NumberOfClocks; ClockIndex++) { int Gap, XF86ConfigClock, SpecificationClock; @@ -601,10 +508,16 @@ ATIMatchClockLine if (!(MinimumGap = MaximumGap)) break; -SkipThisClockGenerator: +SkipThisClockGenerator:; + +#ifndef AVOID_CPIO + /* For non-ATI adapters, only normalise standard VGA clocks */ if (pATI->Adapter == ATI_ADAPTER_VGA) break; + +#endif /* AVOID_CPIO */ + } return ClockChip; @@ -625,12 +538,18 @@ ATIClockPreInit ClockRangePtr pRange ) { + double ScaleFactor; unsigned short int NumberOfUndividedClocks; unsigned short int NumberOfDividers, NumberOfClocks; int CalibrationClockNumber, CalibrationClockValue; - int ClockIndex, SpecificationClock, ClockMap = 0; - CARD16 VSyncRegister = GENS1(pATI->CPIO_VGABase); - CARD8 VSyncBit = 0x08U; + int ClockIndex, SpecificationClock, ClockMap = 0, Index; + CARD8 CanDisableInterrupts; + +#ifndef AVOID_CPIO + + CARD8 genmo; + +#endif /* AVOID_CPIO */ /* * Decide what to do about the XF86Config clocks for programmable clock @@ -639,7 +558,8 @@ ATIClockPreInit if (pATI->ProgrammableClock != ATI_CLOCK_FIXED) { /* Check for those that are not (yet) handled */ - if (pATI->ProgrammableClock > NumberOf(ATIClockDescriptors)) + if ((pATI->ProgrammableClock == ATI_CLOCK_UNKNOWN) || + (pATI->ProgrammableClock > NumberOf(ATIClockDescriptors))) xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, "Unknown programmable clock generator type (0x%02X)" " detected.\n", pATI->ProgrammableClock); @@ -658,12 +578,18 @@ ATIClockPreInit pScreenInfo->progClock = TRUE; /* Set internal clock ordering */ + +#ifndef AVOID_CPIO + if (pATI->NewHW.crtc == ATI_CRTC_VGA) { pATI->NewHW.ClockMap = ATIVGAProgrammableClockMap; pATI->NewHW.ClockUnmap = ATIVGAProgrammableClockUnmap; } else + +#endif /* AVOID_CPIO */ + { pATI->NewHW.ClockMap = ATIProgrammableClockMap; pATI->NewHW.ClockUnmap = ATIProgrammableClockUnmap; @@ -706,15 +632,22 @@ ATIClockPreInit } } +#ifndef AVOID_CPIO + /* Set default clock maps */ pATI->NewHW.ClockMap = ATIVGAWonderClockMap; pATI->NewHW.ClockUnmap = ATIVGAWonderClockUnmap; +#endif /* AVOID_CPIO */ + /* * Determine the number of clock values the adapter should be able to * generate and the dot clock to use for probe calibration. */ ProbeClocks: + +#ifndef AVOID_CPIO + if (pATI->Adapter == ATI_ADAPTER_VGA) { NumberOfDividers = 1; @@ -723,7 +656,13 @@ ProbeClocks: CalibrationClockValue = 28322; } else + +#endif /* AVOID_CPIO */ + { + +#ifndef AVOID_CPIO + NumberOfDividers = 4; if ((pATI->Chip <= ATI_CHIP_18800) || (pATI->Adapter == ATI_ADAPTER_V4)) @@ -734,11 +673,20 @@ ProbeClocks: CalibrationClockValue = 56644; } else + +#endif /* AVOID_CPIO */ + { NumberOfUndividedClocks = 16; + +#ifndef AVOID_CPIO + CalibrationClockNumber = 7; CalibrationClockValue = 36000; if (pATI->Chip >= ATI_CHIP_68800) + +#endif /* AVOID_CPIO */ + { NumberOfDividers = 2; if (pATI->Chip >= ATI_CHIP_264CT) @@ -748,7 +696,14 @@ ProbeClocks: CalibrationClockNumber = 1; CalibrationClockValue = 28322; } - else if (pATI->Adapter >= ATI_ADAPTER_MACH64) + else + +#ifndef AVOID_CPIO + + if (pATI->Adapter >= ATI_ADAPTER_MACH64) + +#endif /* AVOID_CPIO */ + { CalibrationClockNumber = 10 /* or 11 */; CalibrationClockValue = 75000 /* or 65000 */; @@ -758,12 +713,18 @@ ProbeClocks: * When selecting clocks, all ATI accelerators use a different * clock ordering. */ + +#ifndef AVOID_CPIO + if (pATI->NewHW.crtc == ATI_CRTC_VGA) { pATI->NewHW.ClockMap = ATIMachVGAClockMap; pATI->NewHW.ClockUnmap = ATIMachVGAClockUnmap; } else + +#endif /* AVOID_CPIO */ + { pATI->NewHW.ClockMap = ATIAcceleratorClockMap; pATI->NewHW.ClockUnmap = ATIAcceleratorClockUnmap; @@ -806,6 +767,8 @@ ProbeClocks: CalibrationClockValue *= 10; } +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { /* @@ -816,27 +779,208 @@ ProbeClocks: * greater than what the adapter can handle. */ ATIAdapterSave(pScreenInfo, pATI, &pATI->OldHW); + + /* Ensure clock select pins are not OR'ed with anything */ + if (pATI->CPIO_VGAWonder && (pATI->OldHW.crtc == ATI_CRTC_VGA)) + ATIModifyExtReg(pATI, 0xB5, pATI->OldHW.b5, 0x7FU, 0x00U); } - switch (pATI->OldHW.crtc) +#endif /* AVOID_CPIO */ + + /* + * Probe the adapter for clock values. The following is essentially + * the common layer's xf86GetClocks() reworked to fit. One difference + * is the ability to monitor a VSync bit in MMIO space. + */ + CanDisableInterrupts = TRUE; /* An assumption verified below */ + + for (ClockIndex = 0; ClockIndex < NumberOfClocks; ClockIndex++) { - case ATI_CRTC_VGA: - /* Already set */ - break; + pScreenInfo->clock[ClockIndex] = 0; - case ATI_CRTC_MACH64: - VSyncRegister = pATI->CPIO_CRTC_INT_CNTL; - VSyncBit = GetByte(CRTC_VBLANK, 0); - break; + /* Remap clock number */ + Index = MapClockIndex(pATI->OldHW.ClockMap, ClockIndex); - default: - break; + /* Select the clock */ + switch (pATI->OldHW.crtc) + { + +#ifndef AVOID_CPIO + + case ATI_CRTC_VGA: + /* Get generic two low-order bits */ + genmo = (inb(R_GENMO) & 0xF3U) | ((Index << 2) & 0x0CU); + + if (pATI->CPIO_VGAWonder) + { + /* + * On adapters with crystals, switching to one of the + * spare assignments doesn't do anything (i.e. the + * previous setting remains in effect). So, disable + * their selection. + */ + if (((Index & 0x03U) == 0x02U) && + ((pATI->Chip <= ATI_CHIP_18800) || + (pATI->Adapter == ATI_ADAPTER_V4))) + continue; + + /* Start sequencer reset */ + PutReg(SEQX, 0x00U, 0x00U); + + /* Set high-order bits */ + if (pATI->Chip <= ATI_CHIP_18800) + ATIModifyExtReg(pATI, 0xB2U, -1, 0xBFU, + Index << 4); + else + { + ATIModifyExtReg(pATI, 0xBEU, -1, 0xEFU, + Index << 2); + if (pATI->Adapter != ATI_ADAPTER_V4) + { + Index >>= 1; + ATIModifyExtReg(pATI, 0xB9U, -1, 0xFDU, + Index >> 1); + } + } + + /* Set clock divider bits */ + ATIModifyExtReg(pATI, 0xB8U, -1, 0x00U, + (Index << 3) & 0xC0U); + } + else + { + /* + * Reject clocks that cannot be selected. + */ + if (Index & ~0x03U) + continue; + + /* Start sequencer reset */ + PutReg(SEQX, 0x00U, 0x00U); + } + + /* Must set miscellaneous output register last */ + outb(GENMO, genmo); + + /* End sequencer reset */ + PutReg(SEQX, 0x00U, 0x03U); + + break; + +#endif /* AVOID_CPIO */ + + case ATI_CRTC_MACH64: + out8(CLOCK_CNTL, CLOCK_STROBE | + SetBits(Index, CLOCK_SELECT | CLOCK_DIVIDER)); + break; + + default: + continue; + } + + usleep(50000); /* Let clock stabilise */ + + xf86SetPriority(TRUE); + + /* Try to disable interrupts */ + if (CanDisableInterrupts && !xf86DisableInterrupts()) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to disable interrupts; Clock probe will not be as" + " accurate.\n"); + CanDisableInterrupts = FALSE; + } + + /* + * Generate a count while monitoring the vertical sync or blanking + * pulse. This is dependent on the CRTC used by the mode on server + * entry. + */ + switch (pATI->OldHW.crtc) + { + +#ifndef AVOID_CPIO + + case ATI_CRTC_VGA: + /* Verify vertical sync pulses are in fact occurring */ + Index = 1 << 19; + while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) + if (Index-- <= 0) + goto EnableInterrupts; + Index = 1 << 19; + while (inb(GENS1(pATI->CPIO_VGABase)) & 0x08U) + if (Index-- <= 0) + goto EnableInterrupts; + Index = 1 << 19; + while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) + if (Index-- <= 0) + goto EnableInterrupts; + + /* Generate the count */ + for (Index = 0; Index < 8; Index++) + { + while (inb(GENS1(pATI->CPIO_VGABase)) & 0x08U) + pScreenInfo->clock[ClockIndex]++; + while (!(inb(GENS1(pATI->CPIO_VGABase)) & 0x08U)) + pScreenInfo->clock[ClockIndex]++; + } + break; + +#endif /* AVOID_CPIO */ + + case ATI_CRTC_MACH64: + /* Verify vertical blanking pulses are in fact occurring */ + Index = 1 << 19; + while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) + if (Index-- <= 0) + goto EnableInterrupts; + Index = 1 << 19; + while (inr(CRTC_INT_CNTL) & CRTC_VBLANK) + if (Index-- <= 0) + goto EnableInterrupts; + Index = 1 << 19; + while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) + if (Index-- <= 0) + goto EnableInterrupts; + + /* Generate the count */ + for (Index = 0; Index < 4; Index++) + { + while (inr(CRTC_INT_CNTL) & CRTC_VBLANK) + pScreenInfo->clock[ClockIndex]++; + while (!(inr(CRTC_INT_CNTL) & CRTC_VBLANK)) + pScreenInfo->clock[ClockIndex]++; + } + break; + + default: + break; + } + + EnableInterrupts: + if (CanDisableInterrupts) + xf86EnableInterrupts(); + + xf86SetPriority(FALSE); } - /* Probe the adapter for clock values */ - xf86GetClocks(pScreenInfo, NumberOfClocks, ATIClockSelect, - NULL, NULL, VSyncRegister, VSyncBit, - CalibrationClockNumber, CalibrationClockValue); + ScaleFactor = (double)CalibrationClockValue * + (double)pScreenInfo->clock[CalibrationClockNumber]; + + /* Scale the clocks from counts to kHz */ + for (ClockIndex = 0; ClockIndex < NumberOfClocks; ClockIndex++) + { + if (ClockIndex == CalibrationClockNumber) + pScreenInfo->clock[ClockIndex] = CalibrationClockValue; + else /* Round to the nearest 10 kHz */ + pScreenInfo->clock[ClockIndex] = + (((ScaleFactor / (double)pScreenInfo->clock[ClockIndex]) + + 5) / 10) * 10; + } + + pScreenInfo->numClocks = NumberOfClocks; + +#ifndef AVOID_CPIO if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { @@ -846,6 +990,8 @@ ProbeClocks: pATI->OldHW.frame_buffer = NULL; } +#endif /* AVOID_CPIO */ + /* Tell user clocks were probed, instead of supplied */ pATI->OptionProbeClocks = TRUE; @@ -854,6 +1000,8 @@ ProbeClocks: SpecificationClockLine, NumberOfUndividedClocks, CalibrationClockNumber, 0); +#ifndef AVOID_CPIO + if ((pATI->Chip <= ATI_CHIP_18800) || (pATI->Adapter == ATI_ADAPTER_V4)) { @@ -862,6 +1010,8 @@ ProbeClocks: pATI->Clock = ATI_CLOCK_NONE; } else + +#endif /* AVOID_CPIO */ { /* All others don't have crystals */ if (pATI->Clock == ATI_CLOCK_CRYSTALS) @@ -890,21 +1040,32 @@ ProbeClocks: pATI->Clock = ATIMatchClockLine(pScreenInfo, pATI, SpecificationClockLine, NumberOfUndividedClocks, -1, 0); +#ifndef AVOID_CPIO + if (pATI->Adapter != ATI_ADAPTER_VGA) + +#endif /* AVOID_CPIO */ + { if (pATI->Clock == ATI_CLOCK_NONE) { /* * Reject certain clock lines that are obviously wrong. This - * includes the standard VGA clocks for non-ATI adapters, and - * clock lines that could have been used with the pre-2.1.1 - * driver. + * includes the standard VGA clocks for ATI adapters, and clock + * lines that could have been used with the pre-2.1.1 driver. */ if (ATIMatchClockLine(pScreenInfo, pATI, InvalidClockLine, NumberOfClocks, -1, 0)) pATI->OptionProbeClocks = TRUE; - else if ((pATI->Chip >= ATI_CHIP_18800) && - (pATI->Adapter != ATI_ADAPTER_V4)) + else + +#ifndef AVOID_CPIO + + if ((pATI->Chip >= ATI_CHIP_18800) && + (pATI->Adapter != ATI_ADAPTER_V4)) + +#endif /* AVOID_CPIO */ + { /* * Check for clocks that are specified in the wrong order. @@ -921,7 +1082,7 @@ ProbeClocks: xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, "XF86Config clock ordering incorrect. Clocks" - " will be reordered." ATI_README); + " will be reordered.\n"); break; } } @@ -929,6 +1090,9 @@ ProbeClocks: } else /* Ensure crystals are not matched to clock chips, and vice versa */ + +#ifndef AVOID_CPIO + if ((pATI->Chip <= ATI_CHIP_18800) || (pATI->Adapter == ATI_ADAPTER_V4)) { @@ -936,6 +1100,9 @@ ProbeClocks: pATI->OptionProbeClocks = TRUE; } else + +#endif /* AVOID_CPIO */ + { if (pATI->Clock == ATI_CLOCK_CRYSTALS) pATI->OptionProbeClocks = TRUE; @@ -945,7 +1112,7 @@ ProbeClocks: { xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, "Invalid or obsolete XF86Config clocks line rejected.\n" - " Clocks will be probed." ATI_README); + " Clocks will be probed.\n"); goto ProbeClocks; } } @@ -956,12 +1123,21 @@ ProbeClocks: else if (pATI->Clock == ATI_CLOCK_NONE) xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_WARNING, 0, "Unknown clock generator detected.\n"); - else if (pATI->Clock == ATI_CLOCK_CRYSTALS) + else + +#ifndef AVOID_CPIO + + if (pATI->Clock == ATI_CLOCK_CRYSTALS) xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "This adapter uses crystals to generate clock frequencies.\n"); else if (pATI->Clock != ATI_CLOCK_VGA) + +#endif /* AVOID_CPIO */ + + { xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s clock chip detected.\n", ATIClockNames[pATI->Clock]); + } if (pATI->Clock != ATI_CLOCK_NONE) { @@ -1037,14 +1213,20 @@ ATIClockSave ATIHWPtr pATIHW ) { - if (pScreenInfo->vtSema && (pATI->ProgrammableClock != ATI_CLOCK_FIXED)) + if (pScreenInfo->vtSema && (pATI->ProgrammableClock > ATI_CLOCK_FIXED)) { + +#ifndef AVOID_CPIO + if (pATIHW->crtc == ATI_CRTC_VGA) { pATIHW->ClockMap = ATIVGAProgrammableClockMap; pATIHW->ClockUnmap = ATIVGAProgrammableClockUnmap; } else + +#endif /* AVOID_CPIO */ + { pATIHW->ClockMap = ATIProgrammableClockMap; pATIHW->ClockUnmap = ATIProgrammableClockUnmap; @@ -1052,11 +1234,20 @@ ATIClockSave } else { + +#ifndef AVOID_CPIO + if (pATIHW->crtc != ATI_CRTC_VGA) + +#endif /* AVOID_CPIO */ + { pATIHW->ClockMap = ATIAcceleratorClockMap; pATIHW->ClockUnmap = ATIAcceleratorClockUnmap; } + +#ifndef AVOID_CPIO + else if (pATI->Chip < ATI_CHIP_68800) { pATIHW->ClockMap = ATIVGAWonderClockMap; @@ -1067,6 +1258,9 @@ ATIClockSave pATIHW->ClockMap = ATIMachVGAClockMap; pATIHW->ClockUnmap = ATIMachVGAClockUnmap; } + +#endif /* AVOID_CPIO */ + } } @@ -1079,7 +1273,7 @@ ATIClockSave Bool ATIClockCalculate ( - ScrnInfoPtr pScreenInfo, + int iScreen, ATIPtr pATI, ATIHWPtr pATIHW, DisplayModePtr pMode @@ -1092,7 +1286,7 @@ ATIClockCalculate /* Set default values */ pATIHW->FeedbackDivider = pATIHW->ReferenceDivider = pATIHW->PostDivider = 0; - if ((pATI->ProgrammableClock == ATI_CLOCK_FIXED) || + if ((pATI->ProgrammableClock <= ATI_CLOCK_FIXED) || ((pATI->ProgrammableClock == ATI_CLOCK_CH8398) && (pMode->ClockIndex < 2))) { @@ -1162,7 +1356,7 @@ ATIClockCalculate Frequency = ATIDivide(Frequency, Multiple, 0, 0); if (abs(Frequency - pMode->Clock) > CLOCK_TOLERANCE) { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + xf86DrvMsg(iScreen, X_ERROR, "Unable to programme clock %.3fMHz for mode %s.\n", (double)(pMode->Clock) / 1000.0, pMode->name); return FALSE; @@ -1177,8 +1371,7 @@ ATIClockCalculate pATIHW->FeedbackDivider, pATIHW->ReferenceDivider, pATIHW->PostDivider); - if ((pATI->Chip >= ATI_CHIP_264VTB) && - (pATI->CPIODecoding == BLOCK_IO)) + if (pATI->Chip >= ATI_CHIP_264VTB) ATIDSPCalculate(pATI, pATIHW, pMode); } @@ -1188,6 +1381,9 @@ ATIClockCalculate switch (pATIHW->crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: pATIHW->genmo = (pATIHW->genmo & 0xF3U) | ((ClockSelect << 2) & 0x0CU); @@ -1216,6 +1412,8 @@ ATIClockCalculate } break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: pATIHW->clock_cntl = CLOCK_STROBE | SetBits(ClockSelect, CLOCK_SELECT | CLOCK_DIVIDER); @@ -1240,24 +1438,22 @@ ATIClockSet ATIHWPtr pATIHW ) { - CARD8 clock_cntl0, crtc_gen_cntl3; - CARD8 tmp, tmp2; + CARD32 crtc_gen_cntl, tmp; + CARD8 clock_cntl0; + CARD8 tmp2; unsigned int Programme; int N = pATIHW->FeedbackDivider - pATI->ClockDescriptor.NAdjust; int M = pATIHW->ReferenceDivider - pATI->ClockDescriptor.MAdjust; int D = pATIHW->PostDivider; /* Temporarily switch to accelerator mode */ - crtc_gen_cntl3 = inb(pATI->CPIO_CRTC_GEN_CNTL + 3); - outb(pATI->CPIO_CRTC_GEN_CNTL + 3, - crtc_gen_cntl3 | GetByte(CRTC_EXT_DISP_EN, 3)); - - ATISetDACIOPorts(pATI, ATI_CRTC_MACH64); + crtc_gen_cntl = inr(CRTC_GEN_CNTL); + outr(CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_EXT_DISP_EN); switch (pATI->ProgrammableClock) { case ATI_CLOCK_ICS2595: - clock_cntl0 = inb(pATI->CPIO_CLOCK_CNTL); + clock_cntl0 = in8(CLOCK_CNTL); Programme = (SetBits(pATIHW->clock, ICS2595_CLOCK) | SetBits(N, ICS2595_FB_DIV) | SetBits(D, ICS2595_POST_DIV)) ^ @@ -1271,9 +1467,9 @@ ATIClockSet while (Programme >= CLOCK_BIT) { tmp = (Programme & CLOCK_BIT) | CLOCK_STROBE; - outb(pATI->CPIO_CLOCK_CNTL, tmp); + out8(CLOCK_CNTL, tmp); ATIDelay(26); /* 26 microseconds */ - outb(pATI->CPIO_CLOCK_CNTL, tmp | CLOCK_PULSE); + out8(CLOCK_CNTL, tmp | CLOCK_PULSE); ATIDelay(26); /* 26 microseconds */ Programme >>= 1; } @@ -1281,26 +1477,29 @@ ATIClockSet xf86EnableInterrupts(); /* Restore register */ - outb(pATI->CPIO_CLOCK_CNTL, clock_cntl0 | CLOCK_STROBE); + out8(CLOCK_CNTL, clock_cntl0 | CLOCK_STROBE); break; case ATI_CLOCK_STG1703: (void)ATIGetDACCmdReg(pATI); - (void)inb(pATI->CPIO_DAC_MASK); - outb(pATI->CPIO_DAC_MASK, (pATIHW->clock << 1) + 0x20U); - outb(pATI->CPIO_DAC_MASK, 0); - outb(pATI->CPIO_DAC_MASK, SetBits(N, 0xFFU)); - outb(pATI->CPIO_DAC_MASK, SetBits(M, 0x1FU) | SetBits(D, 0xE0U)); + (void)in8(M64_DAC_MASK); + out8(M64_DAC_MASK, (pATIHW->clock << 1) + 0x20U); + out8(M64_DAC_MASK, 0); + out8(M64_DAC_MASK, SetBits(N, 0xFFU)); + out8(M64_DAC_MASK, SetBits(M, 0x1FU) | SetBits(D, 0xE0U)); break; case ATI_CLOCK_CH8398: - tmp = inb(pATI->CPIO_DAC_CNTL); - outb(pATI->CPIO_DAC_CNTL, - tmp | (DAC_EXT_SEL_RS2 | DAC_EXT_SEL_RS3)); - outb(pATI->CPIO_DAC_WRITE, pATIHW->clock); - outb(pATI->CPIO_DAC_DATA, SetBits(N, 0xFFU)); - outb(pATI->CPIO_DAC_DATA, SetBits(M, 0x3FU) | SetBits(D, 0xC0U)); - outb(pATI->CPIO_DAC_CNTL, tmp); + tmp = inr(DAC_CNTL) | (DAC_EXT_SEL_RS2 | DAC_EXT_SEL_RS3); + outr(DAC_CNTL, tmp); + out8(M64_DAC_WRITE, pATIHW->clock); + out8(M64_DAC_DATA, SetBits(N, 0xFFU)); + out8(M64_DAC_DATA, SetBits(M, 0x3FU) | SetBits(D, 0xC0U)); + out8(M64_DAC_MASK, 0x04U); + outr(DAC_CNTL, tmp & ~(DAC_EXT_SEL_RS2 | DAC_EXT_SEL_RS3)); + tmp2 = in8(M64_DAC_WRITE); + out8(M64_DAC_WRITE, (tmp2 & 0x70U) | 0x80U); + outr(DAC_CNTL, tmp & ~DAC_EXT_SEL_RS2); break; case ATI_CLOCK_INTERNAL: @@ -1334,45 +1533,44 @@ ATIClockSet case ATI_CLOCK_ATT20C408: (void)ATIGetDACCmdReg(pATI); - tmp = inb(pATI->CPIO_DAC_MASK); + tmp = in8(M64_DAC_MASK); (void)ATIGetDACCmdReg(pATI); - outb(pATI->CPIO_DAC_MASK, tmp | 1); - outb(pATI->CPIO_DAC_WRITE, 1); - outb(pATI->CPIO_DAC_MASK, tmp | 9); + out8(M64_DAC_MASK, tmp | 1); + out8(M64_DAC_WRITE, 1); + out8(M64_DAC_MASK, tmp | 9); ATIDelay(400); /* 400 microseconds */ tmp2 = (pATIHW->clock << 2) + 0x40U; - outb(pATI->CPIO_DAC_WRITE, tmp2); - outb(pATI->CPIO_DAC_MASK, SetBits(N, 0xFFU)); - outb(pATI->CPIO_DAC_WRITE, ++tmp2); - outb(pATI->CPIO_DAC_MASK, SetBits(M, 0x3FU) | SetBits(D, 0xC0U)); - outb(pATI->CPIO_DAC_WRITE, ++tmp2); - outb(pATI->CPIO_DAC_MASK, 0x77U); + out8(M64_DAC_WRITE, tmp2); + out8(M64_DAC_MASK, SetBits(N, 0xFFU)); + out8(M64_DAC_WRITE, ++tmp2); + out8(M64_DAC_MASK, SetBits(M, 0x3FU) | SetBits(D, 0xC0U)); + out8(M64_DAC_WRITE, ++tmp2); + out8(M64_DAC_MASK, 0x77U); ATIDelay(400); /* 400 microseconds */ - outb(pATI->CPIO_DAC_WRITE, 1); - outb(pATI->CPIO_DAC_MASK, tmp); + out8(M64_DAC_WRITE, 1); + out8(M64_DAC_MASK, tmp); break; case ATI_CLOCK_IBMRGB514: - tmp = inb(pATI->CPIO_DAC_CNTL); - outb(pATI->CPIO_DAC_CNTL, - (tmp & ~DAC_EXT_SEL_RS3) | DAC_EXT_SEL_RS2); + tmp = inr(DAC_CNTL); + outr(DAC_CNTL, (tmp & ~DAC_EXT_SEL_RS3) | DAC_EXT_SEL_RS2); tmp2 = (pATIHW->clock << 1) + 0x20U; - outb(pATI->CPIO_DAC_WRITE, tmp2); - outb(pATI->CPIO_DAC_DATA, 0); - outb(pATI->CPIO_DAC_MASK, + out8(M64_DAC_WRITE, tmp2); + out8(M64_DAC_DATA, 0); + out8(M64_DAC_MASK, (SetBits(N, 0x3FU) | SetBits(D, 0xC0U)) ^ 0xC0U); - outb(pATI->CPIO_DAC_WRITE, tmp2 + 1); - outb(pATI->CPIO_DAC_DATA, 0); - outb(pATI->CPIO_DAC_MASK, SetBits(M, 0x3FU)); - outb(pATI->CPIO_DAC_CNTL, tmp); + out8(M64_DAC_WRITE, tmp2 + 1); + out8(M64_DAC_DATA, 0); + out8(M64_DAC_MASK, SetBits(M, 0x3FU)); + outr(DAC_CNTL, tmp); break; default: break; } - (void)inb(pATI->CPIO_DAC_WRITE); /* Clear DAC counter */ + (void)in8(M64_DAC_WRITE); /* Clear DAC counter */ /* Restore register */ - outb(pATI->CPIO_CRTC_GEN_CNTL + 3, crtc_gen_cntl3); + outr(CRTC_GEN_CNTL, crtc_gen_cntl); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h index 7378afa83..8c4485ad3 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h,v 1.4 2000/02/18 12:19:18 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.h,v 1.5 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" /* @@ -51,6 +52,7 @@ extern const char *ATIClockNames[]; */ typedef enum { + ATI_CLOCK_UNKNOWN = -1, ATI_CLOCK_FIXED = 0, /* Further described by ATIClockType */ ATI_CLOCK_ICS2595, ATI_CLOCK_STG1703, @@ -77,8 +79,8 @@ extern void ATIClockPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, GDevPtr, ClockRangePtr)); extern void ATIClockSave FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); -extern Bool ATIClockCalculate FunctionPrototype((ScrnInfoPtr, ATIPtr, - ATIHWPtr, DisplayModePtr)); +extern Bool ATIClockCalculate FunctionPrototype((int, ATIPtr, ATIHWPtr, + DisplayModePtr)); extern void ATIClockSet FunctionPrototype((ATIPtr, ATIHWPtr)); #endif /* ___ATICLOCK_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c index c0682036f..82e0a24a1 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c,v 1.12 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c,v 1.13 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -29,6 +29,7 @@ #include "atistruct.h" #include "ativga.h" #include "atividmem.h" + #include "xf86.h" /* @@ -59,10 +60,15 @@ ATISaveScreen pATI = ATIPTR(pScreenInfo); switch (pATI->NewHW.crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: ATIVGASaveScreen(pATI, Mode); break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: ATIMach64SaveScreen(pATI, Mode); break; @@ -101,13 +107,23 @@ ATISetDPMSMode ATIMach64SetDPMSMode(pATI, DPMSMode); break; +#ifndef AVOID_CPIO + case ATI_ADAPTER_NONE: case ATI_ADAPTER_8514A: case ATI_ADAPTER_MACH8: break; +#endif /* AVOID_CPIO */ + default: /* Assume EGA/VGA */ + +#ifndef AVOID_CPIO + ATIVGASetDPMSMode(pATI, DPMSMode); + +#endif /* AVOID_CPIO */ + break; } } @@ -126,7 +142,7 @@ ATIEnterGraphics ) { /* Map apertures */ - if (!ATIMapApertures(pScreenInfo, pATI)) + if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI)) return FALSE; /* Unlock device */ @@ -134,7 +150,7 @@ ATIEnterGraphics /* Calculate hardware data */ if (pScreen && - !ATIAdapterCalculate(pScreenInfo, pATI, &pATI->NewHW, + !ATIAdapterCalculate(pScreenInfo->scrnIndex, pATI, &pATI->NewHW, pScreenInfo->currentMode)) return FALSE; @@ -188,7 +204,7 @@ ATILeaveGraphics /* Unmap apertures */ if (!pATI->Closeable || !pATI->nDGAMode) - ATIUnmapApertures(pScreenInfo, pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); SetTimeSinceLastInputEvent(); } @@ -210,7 +226,7 @@ ATISwitchMode ATIPtr pATI = ATIPTR(pScreenInfo); /* Calculate new hardware data */ - if (!ATIAdapterCalculate(pScreenInfo, pATI, &pATI->NewHW, pMode)) + if (!ATIAdapterCalculate(iScreen, pATI, &pATI->NewHW, pMode)) return FALSE; /* Set new hardware state */ @@ -251,10 +267,14 @@ ATIEnterVT if (pATI->OptionShadowFB) return TRUE; +#ifndef AVOID_CPIO + /* If used, modify banking interface */ if (!miModifyBanking(pScreen, &pATI->BankInfo)) return FALSE; +#endif /* AVOID_CPIO */ + pScreenPixmap = (*pScreen->GetScreenPixmap)(pScreen); PixmapPrivate = pScreenPixmap->devPrivate; if (!PixmapPrivate.ptr) @@ -312,9 +332,13 @@ ATIFreeScreen ATILeaveGraphics(pScreenInfo, pATI); +#ifndef AVOID_CPIO + xfree(pATI->OldHW.frame_buffer); xfree(pATI->NewHW.frame_buffer); +#endif /* AVOID_CPIO */ + xfree(pATI->pShadow); xfree(pATI->pDGAMode); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h index 11d6e96c7..fb33e324c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h,v 1.5 2000/03/22 03:08:11 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h,v 1.6 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" extern Bool ATISaveScreen FunctionPrototype((ScreenPtr, int)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h index 218bb80e2..b6d91e9df 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h,v 1.4 2000/02/18 12:19:20 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticrtc.h,v 1.5 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -29,8 +29,14 @@ */ typedef enum { + +#ifndef AVOID_CPIO + ATI_CRTC_VGA, /* Use VGA CRTC */ ATI_CRTC_8514, /* Use 8514/Mach8/Mach32 accelerator CRTC */ + +#endif /* AVOID_CPIO */ + ATI_CRTC_MACH64 /* Use Mach64 accelerator CRTC */ } ATICRTCType; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c index aaf65b95f..68a32983e 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c,v 1.8 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c,v 1.9 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,7 +21,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atidac.h" +#include "atimach64io.h" #include "atimono.h" /* @@ -55,6 +57,8 @@ const DACRec ATIDACDescriptors[] = {ATI_DAC_UNKNOWN, "Unknown"} /* Must be last */ }; +#ifndef AVOID_CPIO + /* * ATISetDACIOPorts -- * @@ -77,17 +81,17 @@ ATISetDACIOPorts break; case ATI_CRTC_8514: - pATI->CPIO_DAC_DATA = DAC_DATA; - pATI->CPIO_DAC_MASK = DAC_MASK; - pATI->CPIO_DAC_READ = DAC_R_INDEX; - pATI->CPIO_DAC_WRITE = DAC_W_INDEX; + pATI->CPIO_DAC_DATA = IBM_DAC_DATA; + pATI->CPIO_DAC_MASK = IBM_DAC_MASK; + pATI->CPIO_DAC_READ = IBM_DAC_READ; + pATI->CPIO_DAC_WRITE = IBM_DAC_WRITE; break; case ATI_CRTC_MACH64: - pATI->CPIO_DAC_DATA = pATI->CPIO_DAC_REGS + 1; - pATI->CPIO_DAC_MASK = pATI->CPIO_DAC_REGS + 2; - pATI->CPIO_DAC_READ = pATI->CPIO_DAC_REGS + 3; - pATI->CPIO_DAC_WRITE = pATI->CPIO_DAC_REGS + 0; + pATI->CPIO_DAC_DATA = ATIIOPort(DAC_REGS) + 1; + pATI->CPIO_DAC_MASK = ATIIOPort(DAC_REGS) + 2; + pATI->CPIO_DAC_READ = ATIIOPort(DAC_REGS) + 3; + pATI->CPIO_DAC_WRITE = ATIIOPort(DAC_REGS) + 0; break; default: @@ -95,6 +99,8 @@ ATISetDACIOPorts } } +#endif /* AVOID_CPIO */ + /* * ATIGetDACCmdReg -- * @@ -106,11 +112,25 @@ ATIGetDACCmdReg ATIPtr pATI ) { + +#ifdef AVOID_CPIO + + (void)in8(M64_DAC_WRITE); /* Reset to PEL mode */ + (void)in8(M64_DAC_MASK); + (void)in8(M64_DAC_MASK); + (void)in8(M64_DAC_MASK); + return in8(M64_DAC_MASK); + +#else /* AVOID_CPIO */ + (void)inb(pATI->CPIO_DAC_WRITE); /* Reset to PEL mode */ (void)inb(pATI->CPIO_DAC_MASK); (void)inb(pATI->CPIO_DAC_MASK); (void)inb(pATI->CPIO_DAC_MASK); return inb(pATI->CPIO_DAC_MASK); + +#endif /* AVOID_CPIO */ + } /* @@ -159,6 +179,8 @@ ATIDACPreInit pATIHW->lut[Index2 + 2] = maxColour; } +#ifndef AVOID_CPIO + if (pATI->depth == 1) { rgb blackColour = pScreenInfo->display->whiteColour, @@ -186,6 +208,9 @@ ATIDACPreInit pATIHW->lut[Index + 1] = pATIHW->lut[Index + 2] = 0x00U; } + +#endif /* AVOID_CPIO */ + } } @@ -204,6 +229,33 @@ ATIDACSave { int Index; +#ifdef AVOID_CPIO + + pATIHW->dac_read = in8(M64_DAC_READ); + DACDelay; + pATIHW->dac_write = in8(M64_DAC_WRITE); + DACDelay; + pATIHW->dac_mask = in8(M64_DAC_MASK); + DACDelay; + + /* Save DAC's colour lookup table */ + out8(M64_DAC_MASK, 0xFFU); + DACDelay; + out8(M64_DAC_READ, 0x00U); + DACDelay; + for (Index = 0; Index < NumberOf(pATIHW->lut); Index++) + { + pATIHW->lut[Index] = in8(M64_DAC_DATA); + DACDelay; + } + + out8(M64_DAC_MASK, pATIHW->dac_mask); + DACDelay; + out8(M64_DAC_READ, pATIHW->dac_read); + DACDelay; + +#else /* AVOID_CPIO */ + ATISetDACIOPorts(pATI, pATIHW->crtc); pATIHW->dac_read = inb(pATI->CPIO_DAC_READ); @@ -228,6 +280,9 @@ ATIDACSave DACDelay; outb(pATI->CPIO_DAC_READ, pATIHW->dac_read); DACDelay; + +#endif /* AVOID_CPIO */ + } /* @@ -244,6 +299,28 @@ ATIDACSet { int Index; +#ifdef AVOID_CPIO + + /* Load DAC's colour lookup table */ + out8(M64_DAC_MASK, 0xFFU); + DACDelay; + out8(M64_DAC_WRITE, 0x00U); + DACDelay; + for (Index = 0; Index < NumberOf(pATIHW->lut); Index++) + { + out8(M64_DAC_DATA, pATIHW->lut[Index]); + DACDelay; + } + + out8(M64_DAC_MASK, pATIHW->dac_mask); + DACDelay; + out8(M64_DAC_READ, pATIHW->dac_read); + DACDelay; + out8(M64_DAC_WRITE, pATIHW->dac_write); + DACDelay; + +#else /* AVOID_CPIO */ + ATISetDACIOPorts(pATI, pATIHW->crtc); /* Load DAC's colour lookup table */ @@ -263,6 +340,9 @@ ATIDACSet DACDelay; outb(pATI->CPIO_DAC_WRITE, pATIHW->dac_write); DACDelay; + +#endif /* AVOID_CPIO */ + } /* @@ -334,6 +414,20 @@ ATILoadPalette Index < (SizeOf(pATI->NewHW.lut) / 3); Index += i, LUTEntry += i * 3) { + +#ifdef AVOID_CPIO + + out8(M64_DAC_WRITE, Index); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[0]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[1]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[2]); + DACDelay; + +#else /* AVOID_CPIO */ + outb(pATI->CPIO_DAC_WRITE, Index); DACDelay; outb(pATI->CPIO_DAC_DATA, LUTEntry[0]); @@ -342,6 +436,9 @@ ATILoadPalette DACDelay; outb(pATI->CPIO_DAC_DATA, LUTEntry[2]); DACDelay; + +#endif /* AVOID_CPIO */ + } } } @@ -360,6 +457,20 @@ ATILoadPalette if (pScreenInfo->vtSema || pATI->currentMode) { + +#ifdef AVOID_CPIO + + out8(M64_DAC_WRITE, Index); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[0]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[1]); + DACDelay; + out8(M64_DAC_DATA, LUTEntry[2]); + DACDelay; + +#else /* AVOID_CPIO */ + outb(pATI->CPIO_DAC_WRITE, Index); DACDelay; outb(pATI->CPIO_DAC_DATA, LUTEntry[0]); @@ -368,6 +479,9 @@ ATILoadPalette DACDelay; outb(pATI->CPIO_DAC_DATA, LUTEntry[2]); DACDelay; + +#endif /* AVOID_CPIO */ + } } } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h index 868dbd502..56556d013 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h,v 1.6 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h,v 1.8 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -22,10 +22,18 @@ */ #ifndef ___ATIDAC_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error missing #include "ati.h" before #include "atidac.h" +# undef XFree86Module +#endif + #define ___ATIDAC_H___ 1 +#include "ati.h" #include "aticrtc.h" #include "atiio.h" + #include "colormapst.h" /* @@ -68,21 +76,30 @@ typedef struct } DACRec; extern const DACRec ATIDACDescriptors[]; -#define DACDelay \ - do \ - { \ - (void)inb(GENS1(pATI->CPIO_VGABase)); \ - (void)inb(GENS1(pATI->CPIO_VGABase)); \ - } while (0) +#ifdef AVOID_CPIO + +# define DACDelay /* Nothing */ + +#else /* AVOID_CPIO */ + +# define DACDelay \ + do \ + { \ + (void)inb(GENS1(pATI->CPIO_VGABase)); \ + (void)inb(GENS1(pATI->CPIO_VGABase)); \ + } while (0) + + extern void ATISetDACIOPorts FunctionPrototype((ATIPtr, ATICRTCType)); + +#endif /* AVOID_CPIO */ -extern void ATISetDACIOPorts FunctionPrototype((ATIPtr, ATICRTCType)); -extern CARD8 ATIGetDACCmdReg FunctionPrototype((ATIPtr)); +extern CARD8 ATIGetDACCmdReg FunctionPrototype((ATIPtr)); -extern void ATIDACPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); -extern void ATIDACSave FunctionPrototype((ATIPtr, ATIHWPtr)); -extern void ATIDACSet FunctionPrototype((ATIPtr, ATIHWPtr)); +extern void ATIDACPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr)); +extern void ATIDACSave FunctionPrototype((ATIPtr, ATIHWPtr)); +extern void ATIDACSet FunctionPrototype((ATIPtr, ATIHWPtr)); -extern void ATILoadPalette FunctionPrototype((ScrnInfoPtr, int, int *, LOCO *, - VisualPtr)); +extern void ATILoadPalette FunctionPrototype((ScrnInfoPtr, int, int *, LOCO *, + VisualPtr)); #endif /* ___ATIDAC_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c index 9e8f91c48..a2c5acd04 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c,v 1.1 2000/06/19 15:02:24 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c,v 1.3 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,8 +24,11 @@ #include "ati.h" #include "atiadapter.h" #include "atiadjust.h" +#include "atichip.h" #include "atidac.h" #include "atidga.h" +#include "atiident.h" + #include "dgaproc.h" /* @@ -233,10 +236,14 @@ ATIDGAAddModes /* Fill in the mode structure */ pDGAMode->mode = pMode; + pDGAMode->flags = DGA_CONCURRENT_ACCESS; if (bitsPerPixel == pScreenInfo->bitsPerPixel) { pDGAMode->flags |= DGA_PIXMAP_AVAILABLE; pDGAMode->address = pATI->pMemory; + + if (pATI->OptionAccel) + pDGAMode->flags &= ~DGA_CONCURRENT_ACCESS; } if ((pMode->Flags & V_DBLSCAN) || (pMode->VScan > 1)) pDGAMode->flags |= DGA_DOUBLESCAN; @@ -299,6 +306,9 @@ ATIDGAInit { if (!pATI->nDGAMode) { + +#ifndef AVOID_CPIO + /* * Contrary to previous extension versions, DGA 2 does not support * banked framebuffers. Also, disable DGA when non-DGA server modes @@ -307,34 +317,40 @@ ATIDGAInit if (pATI->BankInfo.BankSize || (pScreenInfo->depth <= 4)) return FALSE; +#endif /* AVOID_CPIO */ + ATIDGAAddModes(pScreenInfo, pATI, 8, 8, 0, 0, 0, PseudoColor); - ATIDGAAddModes(pScreenInfo, pATI, - 15, 16, 0x7C00U, 0x03E0U, 0x001FU, TrueColor); + if ((pATI->Chip >= ATI_CHIP_264CT) && + (pATI->Chipset == ATI_CHIPSET_ATI)) + { + ATIDGAAddModes(pScreenInfo, pATI, 15, 16, + 0x7C00U, 0x03E0U, 0x001FU, TrueColor); - ATIDGAAddModes(pScreenInfo, pATI, - 16, 16, 0xF800U, 0x07E0U, 0x001FU, TrueColor); + ATIDGAAddModes(pScreenInfo, pATI, 16, 16, + 0xF800U, 0x07E0U, 0x001FU, TrueColor); - ATIDGAAddModes(pScreenInfo, pATI, - 24, 24, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor); + ATIDGAAddModes(pScreenInfo, pATI, 24, 24, + 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor); - ATIDGAAddModes(pScreenInfo, pATI, - 24, 32, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor); + ATIDGAAddModes(pScreenInfo, pATI, 24, 32, + 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor); - if (pATI->DAC != ATI_DAC_INTERNAL) /* Not first revision */ - { - ATIDGAAddModes(pScreenInfo, pATI, - 15, 16, 0x7C00U, 0x03E0U, 0x001FU, DirectColor); + if (pATI->DAC != ATI_DAC_INTERNAL) /* Not first revision */ + { + ATIDGAAddModes(pScreenInfo, pATI, 15, 16, + 0x7C00U, 0x03E0U, 0x001FU, DirectColor); - ATIDGAAddModes(pScreenInfo, pATI, - 16, 16, 0xF800U, 0x07E0U, 0x001FU, DirectColor); + ATIDGAAddModes(pScreenInfo, pATI, 16, 16, + 0xF800U, 0x07E0U, 0x001FU, DirectColor); - ATIDGAAddModes(pScreenInfo, pATI, - 24, 24, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor); + ATIDGAAddModes(pScreenInfo, pATI, 24, 24, + 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor); - ATIDGAAddModes(pScreenInfo, pATI, - 24, 32, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor); + ATIDGAAddModes(pScreenInfo, pATI, 24, 32, + 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor); + } } } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h index b84b1aaba..7340def10 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h,v 1.1 2000/06/19 15:02:24 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h,v 1.2 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" extern Bool ATIDGAInit FunctionPrototype((ScrnInfoPtr, ScreenPtr, ATIPtr)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c index ba121f99e..53c34388f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c,v 1.10 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c,v 1.12 2000/08/04 21:07:13 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,12 +21,12 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atichip.h" #include "aticrtc.h" #include "atidsp.h" -#include "atiio.h" +#include "atimach64io.h" #include "atividmem.h" -#include "xf86.h" /* * ATIDSPPreInit -- @@ -37,17 +37,13 @@ Bool ATIDSPPreInit ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { CARD32 IOValue, dsp_config, dsp_on_off, vga_dsp_config, vga_dsp_on_off; int trp; - /* Set DSP register port numbers */ - pATI->CPIO_DSP_CONFIG = ATIIOPort(DSP_CONFIG); - pATI->CPIO_DSP_ON_OFF = ATIIOPort(DSP_ON_OFF); - /* * VT-B's and later have additional post-dividers that are not powers of * two. @@ -69,7 +65,7 @@ ATIDSPPreInit break; default: - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + xf86DrvMsg(iScreen, X_ERROR, "Unsupported XCLK source: %d.\n", pATI->XCLKPostDivider); return FALSE; } @@ -78,11 +74,11 @@ ATIDSPPreInit pATI->XCLKFeedbackDivider = ATIGetMach64PLLReg(PLL_MCLK_FB_DIV); /* Compute maximum RAS delay and friends */ - IOValue = inl(pATI->CPIO_MEM_INFO); - trp = GetBits(IOValue, CTL_MEM_TRP); - pATI->XCLKPageFaultDelay = GetBits(IOValue, CTL_MEM_TRCD) + - GetBits(IOValue, CTL_MEM_TCRD) + trp + 2; - pATI->XCLKMaxRASDelay = GetBits(IOValue, CTL_MEM_TRAS) + trp + 2; + trp = GetBits(pATI->LockData.mem_cntl, CTL_MEM_TRP); + pATI->XCLKPageFaultDelay = GetBits(pATI->LockData.mem_cntl, CTL_MEM_TRCD) + + GetBits(pATI->LockData.mem_cntl, CTL_MEM_TCRD) + trp + 2; + pATI->XCLKMaxRASDelay = GetBits(pATI->LockData.mem_cntl, CTL_MEM_TRAS) + + trp + 2; pATI->DisplayFIFODepth = 32; if (pATI->Chip < ATI_CHIP_264VT4) @@ -140,15 +136,15 @@ ATIDSPPreInit pATI->XCLKMaxRASDelay = pATI->XCLKPageFaultDelay + 1; /* Allow BIOS to override */ - dsp_config = inl(pATI->CPIO_DSP_CONFIG); - dsp_on_off = inl(pATI->CPIO_DSP_ON_OFF); - vga_dsp_config = inl(ATIIOPort(VGA_DSP_CONFIG)); - vga_dsp_on_off = inl(ATIIOPort(VGA_DSP_ON_OFF)); + dsp_config = inr(DSP_CONFIG); + dsp_on_off = inr(DSP_ON_OFF); + vga_dsp_config = inr(VGA_DSP_CONFIG); + vga_dsp_on_off = inr(VGA_DSP_ON_OFF); if (dsp_config) pATI->DisplayLoopLatency = GetBits(dsp_config, DSP_LOOP_LATENCY); - if (!dsp_on_off || + if ((!dsp_on_off && (pATI->Chip < ATI_CHIP_264GTPRO)) || ((dsp_on_off == vga_dsp_on_off) && (!dsp_config || !((dsp_config ^ vga_dsp_config) & DSP_XCLKS_PER_QW)))) { @@ -175,8 +171,8 @@ ATIDSPSave ATIHWPtr pATIHW ) { - pATIHW->dsp_on_off = inl(pATI->CPIO_DSP_ON_OFF); - pATIHW->dsp_config = inl(pATI->CPIO_DSP_CONFIG); + pATIHW->dsp_on_off = inr(DSP_ON_OFF); + pATIHW->dsp_config = inr(DSP_CONFIG); } @@ -209,12 +205,26 @@ ATIDSPCalculate Multiplier = pATI->XCLKFeedbackDivider * pATI->ClockDescriptor.PostDividers[pATIHW->PostDivider]; Divider = pATIHW->FeedbackDivider * pATI->XCLKReferenceDivider; + +#ifndef AVOID_CPIO + if (pATI->depth >= 8) + +#endif /* AVOID_CPIO */ + + { Divider *= pATI->bitsPerPixel / 4; - /* Start by assuming a display FIFO width of 32 bits */ - vshift = (5 - 2) - pATI->XCLKPostDivider; - if (pATIHW->crtc != ATI_CRTC_VGA) - vshift++; /* Nope, it's 64 bits wide */ + } + + /* Start by assuming a display FIFO width of 64 bits */ + vshift = (6 - 2) - pATI->XCLKPostDivider; + +#ifndef AVOID_CPIO + + if (pATIHW->crtc == ATI_CRTC_VGA) + vshift--; /* Nope, it's 32 bits wide */ + +#endif /* AVOID_CPIO */ if (!pATI->OptionCRT && (pATI->LCDPanelID >= 0)) { @@ -243,6 +253,9 @@ ATIDSPCalculate vshift, -1) - ATIDivide(1, 1, vshift - xshift, 1); /* Next is dsp_on */ + +#ifndef AVOID_CPIO + if ((pATIHW->crtc == ATI_CRTC_VGA) /* && (dsp_precision < 3) */) { /* @@ -252,6 +265,9 @@ ATIDSPCalculate dsp_on = ATIDivide(Multiplier * 5, Divider, vshift + 2, 1); } else + +#endif /* AVOID_CPIO */ + { dsp_on = ATIDivide(Multiplier, Divider, vshift, 1); tmp = ATIDivide(RASMultiplier, RASDivider, xshift, 1); @@ -261,8 +277,15 @@ ATIDSPCalculate ATIDivide(pATI->XCLKPageFaultDelay, 1, xshift, 1); } - if (dsp_on >= dsp_off) + /* Calculate rounding factor and apply it to dsp_on */ + tmp = ((1 << (Maximum_DSP_PRECISION - dsp_precision)) - 1) >> 1; + dsp_on = ((dsp_on + tmp) / (tmp + 1)) * (tmp + 1); + + if (dsp_on >= ((dsp_off / (tmp + 1)) * (tmp + 1))) + { dsp_on = dsp_off - ATIDivide(Multiplier, Divider, vshift, -1); + dsp_on = (dsp_on / (tmp + 1)) * (tmp + 1); + } /* Last but not least: dsp_xclks */ dsp_xclks = ATIDivide(Multiplier, Divider, vshift + 5, 1); @@ -287,6 +310,6 @@ ATIDSPSet ATIHWPtr pATIHW ) { - outl(pATI->CPIO_DSP_ON_OFF, pATIHW->dsp_on_off); - outl(pATI->CPIO_DSP_CONFIG, pATIHW->dsp_config); + outr(DSP_ON_OFF, pATIHW->dsp_on_off); + outr(DSP_CONFIG, pATIHW->dsp_config); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h index 4cbbb6ad0..c940de14d 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h,v 1.6 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h,v 1.7 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,9 +26,10 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" -extern Bool ATIDSPPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr)); +extern Bool ATIDSPPreInit FunctionPrototype((int, ATIPtr)); extern void ATIDSPSave FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIDSPCalculate FunctionPrototype((ATIPtr, ATIHWPtr, DisplayModePtr)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c index 03fc99102..d0f334fce 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c,v 1.5 2000/02/18 12:19:22 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.c,v 1.6 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -28,18 +28,29 @@ const char *ATIChipsetNames[] = { "ati", + +#ifndef AVOID_CPIO + "ativga", "ibmvga", "ibm8514", "vgawonder", "mach8", "mach32", - "mach64" + +#endif /* AVOID_CPIO */ + + "mach64", + "rage128", + "radeon" }; static SymTabRec ATIPublicChipsetNames[] = { {ATI_CHIPSET_ATI, "ati"}, + +#ifndef AVOID_CPIO + {ATI_CHIPSET_ATIVGA, "ativga"}, #ifdef __MAYBE_NOT__ {ATI_CHIPSET_IBMVGA, "ibmvga"}, @@ -47,6 +58,9 @@ static SymTabRec ATIPublicChipsetNames[] = #ifdef __NOT_YET__ {ATI_CHIPSET_IBM8514, "ibm8514"}, #endif + +#endif /* AVOID_CPIO */ + {-1, NULL} }; @@ -82,13 +96,20 @@ ATIIdentProbe static SymTabRec SpecificNames[] = { + +#ifndef AVOID_CPIO + {ATI_CHIPSET_VGAWONDER, "vgawonder"}, #ifdef __NOT_YET__ {ATI_CHIPSET_MACH8, "mach8"}, #endif {ATI_CHIPSET_MACH32, "mach32"}, + +#endif /* AVOID_CPIO */ + {ATI_CHIPSET_MACH64, "mach64"}, {ATI_CHIPSET_RAGE128, "rage128"}, + {ATI_CHIPSET_RADEON, "radeon"}, {-1, NULL} }; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h index a8f1075dc..c46c9ed08 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h,v 1.6 2000/02/18 12:19:23 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiident.h,v 1.7 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -29,14 +29,21 @@ typedef enum { ATI_CHIPSET_ATI, + +#ifndef AVOID_CPIO + ATI_CHIPSET_ATIVGA, ATI_CHIPSET_IBMVGA, ATI_CHIPSET_IBM8514, ATI_CHIPSET_VGAWONDER, ATI_CHIPSET_MACH8, ATI_CHIPSET_MACH32, + +#endif /* AVOID_CPIO */ + ATI_CHIPSET_MACH64, ATI_CHIPSET_RAGE128, + ATI_CHIPSET_RADEON, ATI_CHIPSET_MAX /* Must be last */ } ATIChipsetType; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c index a4dd66ba5..d87670b4f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c,v 1.4 2000/02/18 12:19:23 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.c,v 1.6 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,9 +21,12 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "ati.h" #include "atichip.h" #include "atiio.h" +#ifndef AVOID_CPIO + /* * ATISetVGAIOBase -- * @@ -96,24 +99,4 @@ ATIModifyExtReg ATIPutExtReg(Index, NewValue); } -/* - * ATIAccessMach64PLLReg -- - * - * This function sets up the addressing required to access, for read or write, - * a 264xT's PLL registers. - */ -void -ATIAccessMach64PLLReg -( - ATIPtr pATI, - const CARD8 Index, - const Bool Write -) -{ - CARD8 clock_cntl1 = inb(pATI->CPIO_CLOCK_CNTL + 1) & - ~GetByte(PLL_WR_EN | PLL_ADDR, 1); - - /* Set PLL register to be read or written */ - outb(pATI->CPIO_CLOCK_CNTL + 1, clock_cntl1 | - GetByte(SetBits(Index, PLL_ADDR) | SetBits(Write, PLL_WR_EN), 1)); -} +#endif /* AVOID_CPIO */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h index 4c09b8dec..1c66c010f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h,v 1.7 2000/03/30 15:41:17 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h,v 1.8 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -22,13 +22,19 @@ */ #ifndef ___ATIIO_H___ -#define ___ATIIO_H___ 1 -#ifndef NO_COMPILER_H_EXTRAS -#define NO_COMPILER_H_EXTRAS +#if !defined(___ATI_H___) && defined(XFree86Module) +# error missing #include "ati.h" before #include "atiio.h" +# undef XFree86Module #endif +#define ___ATIIO_H___ 1 + #include "atistruct.h" + +#ifndef NO_COMPILER_H_EXTRAS +# define NO_COMPILER_H_EXTRAS +#endif #include "compiler.h" /* I/O decoding definitions */ @@ -38,16 +44,14 @@ typedef enum BLOCK_IO } ATIIODecodingType; -#define ATIIOPort(_PortTag) \ - (((pATI->CPIODecoding == SPARSE_IO) ? \ - (((_PortTag) & SPARSE_IO_SELECT) | ((_PortTag) & IO_BYTE_SELECT)) : \ - (((_PortTag) & BLOCK_IO_SELECT) | ((_PortTag) & IO_BYTE_SELECT))) | \ - pATI->CPIOBase) +#ifndef AVOID_CPIO extern void ATISetVGAIOBase FunctionPrototype((ATIPtr, const CARD8)); extern void ATIModifyExtReg FunctionPrototype((ATIPtr, const CARD8, int, const CARD8, CARD8)); +#endif /* AVOID_CPIO */ + /* Odds and ends to ease reading and writting of registers */ #define GetReg(_Register, _Index) \ ( \ @@ -65,42 +69,6 @@ extern void ATIModifyExtReg FunctionPrototype((ATIPtr, const CARD8, int, #define ATIPutExtReg(_Index, _Value) \ PutReg(pATI->CPIO_VGAWonder, _Index, _Value) -extern void ATIAccessMach64PLLReg FunctionPrototype((ATIPtr, const CARD8, - const Bool)); - -#define ATIGetMach64PLLReg(_Index) \ - ( \ - ATIAccessMach64PLLReg(pATI, _Index, FALSE), \ - inb(pATI->CPIO_CLOCK_CNTL + 2) \ - ) -#define ATIPutMach64PLLReg(_Index, _Value) \ - ( \ - ATIAccessMach64PLLReg(pATI, _Index, TRUE), \ - outb(pATI->CPIO_CLOCK_CNTL + 2, _Value) \ - ) - -#define ATIGetLTProLCDReg(_Index) \ - ( \ - outb(pATI->CPIO_LCD_INDEX, SetBits((_Index), LCD_REG_INDEX)), \ - inl(pATI->CPIO_LCD_DATA) \ - ) -#define ATIPutLTProLCDReg(_Index, _Value) \ - ( \ - outb(pATI->CPIO_LCD_INDEX, SetBits((_Index), LCD_REG_INDEX)), \ - outl(pATI->CPIO_LCD_DATA, (_Value)) \ - ) - -#define ATIGetLTProTVReg(_Index) \ - ( \ - outb(pATI->CPIO_TV_OUT_INDEX, SetBits((_Index), TV_REG_INDEX)), \ - inl(pATI->CPIO_TV_OUT_DATA) \ - ) -#define ATIPutLTProTVReg(_Index, _Value) \ - ( \ - outb(pATI->CPIO_TV_OUT_INDEX, SetBits((_Index), TV_REG_INDEX)), \ - outl(pATI->CPIO_TV_OUT_DATA, (_Value)) \ - ) - /* Wait until "n" queue entries are free */ #define ibm8514WaitQueue(_n) \ { \ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c index 75c0e0485..c0083abb3 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c,v 1.6 2000/03/22 03:08:13 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c,v 1.7 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -24,8 +24,8 @@ #include "ati.h" #include "atiadapter.h" #include "atichip.h" -#include "atiio.h" #include "atilock.h" +#include "atimach64io.h" /* * ATIUnlock -- @@ -39,12 +39,20 @@ ATIUnlock ATIPtr pATI ) { - CARD32 tmp, saved_lcd_gen_ctrl = 0, lcd_gen_ctrl = 0; + CARD32 tmp; + +#ifndef AVOID_CPIO + + CARD32 saved_lcd_gen_ctrl = 0, lcd_gen_ctrl = 0; + +#endif /* AVOID_CPIO */ if (pATI->Unlocked) return; pATI->Unlocked = TRUE; +#ifndef AVOID_CPIO + if (pATI->ChipHasSUBSYS_CNTL) { /* Save register values to be modified */ @@ -83,15 +91,13 @@ ATIUnlock ProbeWaitIdleEmpty(); } else if (pATI->Chip >= ATI_CHIP_88800GXC) - { - /* Save register values to be modified */ - pATI->LockData.config_cntl = inl(pATI->CPIO_CONFIG_CNTL); - pATI->LockData.dac_cntl = inl(pATI->CPIO_DAC_CNTL); +#endif /* AVOID_CPIO */ + + { /* Reset everything */ pATI->LockData.bus_cntl = - (inl(pATI->CPIO_BUS_CNTL) & ~BUS_HOST_ERR_INT_EN) | - BUS_HOST_ERR_INT; + (inr(BUS_CNTL) & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT; if (pATI->Chip < ATI_CHIP_264VTB) pATI->LockData.bus_cntl = (pATI->LockData.bus_cntl & ~BUS_FIFO_ERR_INT_EN) | @@ -100,44 +106,55 @@ ATIUnlock SetBits(15, BUS_FIFO_WS); if (pATI->Chip >= ATI_CHIP_264VT) tmp |= BUS_EXT_REG_EN; /* Enable Block 1 */ - outl(pATI->CPIO_BUS_CNTL, tmp); - pATI->LockData.crtc_int_cntl = inl(pATI->CPIO_CRTC_INT_CNTL); - outl(pATI->CPIO_CRTC_INT_CNTL, - (pATI->LockData.crtc_int_cntl & ~CRTC_INT_ENS) | CRTC_INT_ACKS); - pATI->LockData.gen_test_cntl = inl(pATI->CPIO_GEN_TEST_CNTL) & + outr(BUS_CNTL, tmp); + pATI->LockData.crtc_int_cntl = inr(CRTC_INT_CNTL); + outr(CRTC_INT_CNTL, (pATI->LockData.crtc_int_cntl & ~CRTC_INT_ENS) | + CRTC_INT_ACKS); + pATI->LockData.gen_test_cntl = inr(GEN_TEST_CNTL) & (GEN_OVR_OUTPUT_EN | GEN_OVR_POLARITY | GEN_CUR_EN | GEN_BLOCK_WR_EN); tmp = pATI->LockData.gen_test_cntl & ~GEN_CUR_EN; - outl(pATI->CPIO_GEN_TEST_CNTL, tmp | GEN_GUI_EN); - outl(pATI->CPIO_GEN_TEST_CNTL, tmp); - outl(pATI->CPIO_GEN_TEST_CNTL, tmp | GEN_GUI_EN); - tmp = pATI->LockData.crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL) & + outr(GEN_TEST_CNTL, tmp | GEN_GUI_EN); + outr(GEN_TEST_CNTL, tmp); + outr(GEN_TEST_CNTL, tmp | GEN_GUI_EN); + tmp = pATI->LockData.crtc_gen_cntl = inr(CRTC_GEN_CNTL) & ~(CRTC_EN | CRTC_LOCK_REGS); if (pATI->Chip >= ATI_CHIP_264XL) tmp = (tmp & ~CRTC_INT_ENS_X) | CRTC_INT_ACKS_X; - outl(pATI->CPIO_CRTC_GEN_CNTL, tmp | CRTC_EN); - outl(pATI->CPIO_CRTC_GEN_CNTL, tmp); - outl(pATI->CPIO_CRTC_GEN_CNTL, tmp | CRTC_EN); + outr(CRTC_GEN_CNTL, tmp | CRTC_EN); + outr(CRTC_GEN_CNTL, tmp); + outr(CRTC_GEN_CNTL, tmp | CRTC_EN); if ((pATI->LCDPanelID >= 0) && (pATI->Chip != ATI_CHIP_264LT)) { - pATI->LockData.lcd_index = inl(pATI->CPIO_LCD_INDEX); + pATI->LockData.lcd_index = inr(LCD_INDEX); if (pATI->Chip >= ATI_CHIP_264XL) - outl(pATI->CPIO_LCD_INDEX, pATI->LockData.lcd_index & + outr(LCD_INDEX, pATI->LockData.lcd_index & ~(LCD_MONDET_INT_EN | LCD_MONDET_INT)); } +#ifndef AVOID_CPIO + /* Ensure VGA aperture is enabled */ - outl(pATI->CPIO_DAC_CNTL, pATI->LockData.dac_cntl | DAC_VGA_ADR_EN); - outl(pATI->CPIO_CONFIG_CNTL, - pATI->LockData.config_cntl & ~CFG_VGA_DIS); + pATI->LockData.config_cntl = inr(CONFIG_CNTL); + pATI->LockData.dac_cntl = inr(DAC_CNTL); + outr(DAC_CNTL, pATI->LockData.dac_cntl | DAC_VGA_ADR_EN); + outr(CONFIG_CNTL, pATI->LockData.config_cntl & ~CFG_VGA_DIS); + +#endif /* AVOID_CPIO */ + + pATI->LockData.mem_cntl = inr(MEM_CNTL); if (pATI->Chip < ATI_CHIP_264CT) - { - pATI->LockData.mem_info = inl(pATI->CPIO_MEM_INFO); - outl(pATI->CPIO_MEM_INFO, pATI->LockData.mem_info & + outr(MEM_CNTL, pATI->LockData.mem_cntl & ~(CTL_MEM_BNDRY | CTL_MEM_BNDRY_EN)); - } + else if (pATI->Chip >= ATI_CHIP_264VTB) + outr(MEM_CNTL, (pATI->LockData.mem_cntl & + ~(CTL_MEM_LOWER_APER_ENDIAN | CTL_MEM_UPPER_APER_ENDIAN)) | + (SetBits(CTL_MEM_APER_BYTE_ENDIAN, CTL_MEM_LOWER_APER_ENDIAN) | + SetBits(CTL_MEM_APER_LONG_ENDIAN, CTL_MEM_UPPER_APER_ENDIAN))); } +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { if (pATI->CPIO_VGAWonder) @@ -178,23 +195,23 @@ ATIUnlock { if (pATI->Chip == ATI_CHIP_264LT) { - saved_lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + saved_lcd_gen_ctrl = inr(LCD_GEN_CTRL); /* Setup to unlock non-shadow registers */ lcd_gen_ctrl = saved_lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); } else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - saved_lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + saved_lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); /* Setup to unlock non-shadow registers */ lcd_gen_ctrl = saved_lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); } } @@ -256,11 +273,11 @@ ATIUnlock lcd_gen_ctrl |= SHADOW_EN | SHADOW_RW_EN; if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); /* Unlock shadow registers */ ATISetVGAIOBase(pATI, inb(R_GENMO)); @@ -276,6 +293,11 @@ ATIUnlock GetReg(CRTX(pATI->CPIO_VGABase), 0x11U); if (tmp & 0x80U) /* Unprotect CRTC[0-7] */ outb(CRTD(pATI->CPIO_VGABase), tmp & 0x7FU); + else if (!tmp && pATI->LockData.crt11) + { + pATI->LockData.shadow_crt11 = tmp = pATI->LockData.crt11; + outb(CRTD(pATI->CPIO_VGABase), tmp & 0x7FU); + } } else { @@ -312,19 +334,21 @@ ATIUnlock /* Restore selection */ if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, saved_lcd_gen_ctrl); + outr(LCD_GEN_CTRL, saved_lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - ATIPutLTProLCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); /* Restore LCD index */ - outb(pATI->CPIO_LCD_INDEX, - GetByte(pATI->LockData.lcd_index, 0)); + out8(LCD_INDEX, GetByte(pATI->LockData.lcd_index, 0)); } } } + +#endif /* AVOID_CPIO */ + } /* @@ -338,35 +362,42 @@ ATILock ATIPtr pATI ) { + +#ifndef AVOID_CPIO + CARD32 tmp, saved_lcd_gen_ctrl = 0, lcd_gen_ctrl = 0; +#endif /* AVOID_CPIO */ + if (!pATI->Unlocked) return; pATI->Unlocked = FALSE; +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { if (pATI->LCDPanelID >= 0) { if (pATI->Chip == ATI_CHIP_264LT) { - saved_lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + saved_lcd_gen_ctrl = inr(LCD_GEN_CTRL); /* Setup to lock non-shadow registers */ lcd_gen_ctrl = saved_lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); } else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - saved_lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + saved_lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); /* Setup to lock non-shadow registers */ lcd_gen_ctrl = saved_lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); } } @@ -382,11 +413,11 @@ ATILock lcd_gen_ctrl |= SHADOW_EN | SHADOW_RW_EN; if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); /* Lock shadow registers */ ATISetVGAIOBase(pATI, inb(R_GENMO)); @@ -398,11 +429,11 @@ ATILock /* Restore selection */ if (pATI->Chip == ATI_CHIP_264LT) - outl(pATI->CPIO_LCD_GEN_CTRL, saved_lcd_gen_ctrl); + outr(LCD_GEN_CTRL, saved_lcd_gen_ctrl); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ - ATIPutLTProLCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); } if (pATI->CPIO_VGAWonder) @@ -452,30 +483,32 @@ ATILock ProbeWaitIdleEmpty(); } else if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + { /* Reset everything */ - outl(pATI->CPIO_BUS_CNTL, pATI->LockData.bus_cntl); + outr(BUS_CNTL, pATI->LockData.bus_cntl); - outl(pATI->CPIO_CRTC_INT_CNTL, pATI->LockData.crtc_int_cntl); + outr(CRTC_INT_CNTL, pATI->LockData.crtc_int_cntl); - outl(pATI->CPIO_GEN_TEST_CNTL, - pATI->LockData.gen_test_cntl | GEN_GUI_EN); - outl(pATI->CPIO_GEN_TEST_CNTL, pATI->LockData.gen_test_cntl); - outl(pATI->CPIO_GEN_TEST_CNTL, - pATI->LockData.gen_test_cntl | GEN_GUI_EN); + outr(GEN_TEST_CNTL, pATI->LockData.gen_test_cntl | GEN_GUI_EN); + outr(GEN_TEST_CNTL, pATI->LockData.gen_test_cntl); + outr(GEN_TEST_CNTL, pATI->LockData.gen_test_cntl | GEN_GUI_EN); - outl(pATI->CPIO_CRTC_GEN_CNTL, - pATI->LockData.crtc_gen_cntl | CRTC_EN); - outl(pATI->CPIO_CRTC_GEN_CNTL, pATI->LockData.crtc_gen_cntl); - outl(pATI->CPIO_CRTC_GEN_CNTL, - pATI->LockData.crtc_gen_cntl | CRTC_EN); + outr(CRTC_GEN_CNTL, pATI->LockData.crtc_gen_cntl | CRTC_EN); + outr(CRTC_GEN_CNTL, pATI->LockData.crtc_gen_cntl); + outr(CRTC_GEN_CNTL, pATI->LockData.crtc_gen_cntl | CRTC_EN); - /* Restore registers */ - outl(pATI->CPIO_CONFIG_CNTL, pATI->LockData.config_cntl); - outl(pATI->CPIO_DAC_CNTL, pATI->LockData.dac_cntl); - if (pATI->Chip < ATI_CHIP_264CT) - outl(pATI->CPIO_MEM_INFO, pATI->LockData.mem_info); - else if ((pATI->LCDPanelID >= 0) && (pATI->Chip != ATI_CHIP_264LT)) - outl(pATI->CPIO_LCD_INDEX, pATI->LockData.lcd_index); +#ifndef AVOID_CPIO + + outr(CONFIG_CNTL, pATI->LockData.config_cntl); + outr(DAC_CNTL, pATI->LockData.dac_cntl); + +#endif /* AVOID_CPIO */ + + outr(MEM_CNTL, pATI->LockData.mem_cntl); + if ((pATI->LCDPanelID >= 0) && (pATI->Chip != ATI_CHIP_264LT)) + outr(LCD_INDEX, pATI->LockData.lcd_index); } } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c index 2d53d1629..b0b3caf96 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c,v 1.21 2000/06/19 15:00:56 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c,v 1.23 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -47,116 +47,17 @@ #include "ati.h" #include "atibus.h" #include "atichip.h" -#include "atiio.h" #include "atimach64.h" +#include "atimach64io.h" + #include "miline.h" -#define DPMS_SERVER +#ifndef DPMS_SERVER +# define DPMS_SERVER +#endif #include "extensions/dpms.h" /* - * Note: Only 32-bit MMIO is needed here. - */ - -#define inm(_Register) \ - MMIO_IN32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ - (_Register) & MM_IO_SELECT) - -/* - * ATIMach64PollEngineStatus -- - * - * This function refreshes the driver's view of the draw engine's status. - */ -static void -ATIMach64PollEngineStatus -( - ATIPtr pATI -) -{ - CARD32 IOValue; - int Count; - - if (pATI->Chip < ATI_CHIP_264VTB) - { - /* - * TODO: Deal with locked engines. - */ - IOValue = inm(FIFO_STAT); - pATI->EngineIsLocked = GetBits(IOValue, FIFO_ERR); - - /* - * The following counts the number of bits in FIFO_STAT_BITS, and is - * derived from miSetVisualTypes() (formerly cfbSetVisualTypes()). - */ - IOValue = GetBits(IOValue, FIFO_STAT_BITS); - Count = (IOValue >> 1) & 0x36DBU; - Count = IOValue - Count - ((Count >> 1) & 0x36DBU); - Count = ((Count + (Count >> 3)) & 0x71C7U) % 0x3FU; - Count = pATI->nFIFOEntries - Count; - if (Count > pATI->nAvailableFIFOEntries) - pATI->nAvailableFIFOEntries = Count; - - /* - * If the command FIFO is non-empty, then the engine isn't idle. - */ - if (pATI->nAvailableFIFOEntries < pATI->nFIFOEntries) - { - pATI->EngineIsBusy = TRUE; - return; - } - } - - IOValue = inm(GUI_STAT); - pATI->EngineIsBusy = GetBits(IOValue, GUI_ACTIVE); - Count = GetBits(IOValue, GUI_FIFO); - if (Count > pATI->nAvailableFIFOEntries) - pATI->nAvailableFIFOEntries = Count; -} - -/* - * MMIO cache definitions. - */ -#define CacheByte(___Register) pATI->MMIOCached[CacheSlotOf(___Register) >> 3] -#define CacheBit(___Register) (0x80U >> (CacheSlotOf(___Register) & 0x07U)) - -#define RegisterIsCached(__Register) \ - (CacheByte(__Register) & CacheBit(__Register)) -#define CacheRegister(__Register) \ - CacheByte(__Register) |= CacheBit(__Register) -#define UncacheRegister(__Register) \ - CacheByte(__Register) &= ~CacheBit(__Register) - -#define CacheSlot(__Register) pATI->MMIOCache[CacheSlotOf(__Register)] - -/* This would be quite a bit slower as a function */ -#define outm(_Register, _Value) \ - do \ - { \ - CARD32 _IOValue = (_Value); \ - \ - if (!RegisterIsCached(_Register) || \ - (_IOValue != CacheSlot(_Register))) \ - { \ - while (!pATI->nAvailableFIFOEntries--) \ - ATIMach64PollEngineStatus(pATI); \ - MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ - (_Register) & MM_IO_SELECT, _IOValue); \ - CacheSlot(_Register) = _IOValue; \ - pATI->EngineIsBusy = TRUE; \ - } \ - } while (0) - -/* This is no longer as critical, especially for _n == 1 */ -#define ATIMach64WaitForFIFO(_n) \ - while ((pATI->nAvailableFIFOEntries < (_n)) && \ - (pATI->nAvailableFIFOEntries < pATI->nFIFOEntries)) \ - ATIMach64PollEngineStatus(pATI) - -#define ATIMach64WaitForIdle() \ - while (pATI->EngineIsBusy) \ - ATIMach64PollEngineStatus(pATI) - -/* * X-to-Mach64 mix translation table. */ static CARD8 ATIMach64ALU[16] = @@ -196,12 +97,19 @@ ATIMach64PreInit CARD32 bus_cntl, config_cntl; int tmp; +#ifndef AVOID_CPIO + if (pATI->depth <= 4) pATIHW->crtc_off_pitch = SetBits(pATI->displayWidth >> 4, CRTC_PITCH); else + +#endif /* AVOID_CPIO */ + + { pATIHW->crtc_off_pitch = SetBits(pATI->displayWidth >> 3, CRTC_PITCH); + } - bus_cntl = inl(pATI->CPIO_BUS_CNTL); + bus_cntl = inr(BUS_CNTL); pATIHW->bus_cntl = (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT; if (pATI->Chip < ATI_CHIP_264VTB) { @@ -213,26 +121,42 @@ ATIMach64PreInit if (pATI->Chip >= ATI_CHIP_264VT) pATIHW->bus_cntl |= BUS_EXT_REG_EN; /* Enable Block 1 */ - pATIHW->mem_vga_wp_sel = - /* SetBits(0, MEM_VGA_WPS0) | */ +#ifdef AVOID_CPIO + + pATIHW->mem_vga_wp_sel = SetBits(0, MEM_VGA_WPS0) | + SetBits(1, MEM_VGA_WPS1); + pATIHW->mem_vga_rp_sel = SetBits(0, MEM_VGA_RPS0) | + SetBits(1, MEM_VGA_RPS1); + +#else /* AVOID_CPIO */ + + pATIHW->mem_vga_wp_sel = SetBits(0, MEM_VGA_WPS0) | SetBits(pATIHW->nPlane, MEM_VGA_WPS1); - pATIHW->mem_vga_rp_sel = - /* SetBits(0, MEM_VGA_RPS0) | */ + pATIHW->mem_vga_rp_sel = SetBits(0, MEM_VGA_RPS0) | SetBits(pATIHW->nPlane, MEM_VGA_RPS1); - pATIHW->dac_cntl = inl(pATI->CPIO_DAC_CNTL) & +#endif /* AVOID_CPIO */ + + pATIHW->dac_cntl = inr(DAC_CNTL) & ~(DAC1_CLK_SEL | DAC_PALETTE_ACCESS_CNTL | DAC_8BIT_EN); if ((pATI->depth > 8) || (pScreenInfo->rgbBits == 8)) pATIHW->dac_cntl |= DAC_8BIT_EN; - pATIHW->config_cntl = config_cntl = inl(pATI->CPIO_CONFIG_CNTL); + pATIHW->config_cntl = config_cntl = inr(CONFIG_CNTL); + +#ifndef AVOID_CPIO + if (pATI->UseSmallApertures) pATIHW->config_cntl |= CFG_MEM_VGA_AP_EN; else + +#endif /* AVOID_CPIO */ + + { pATIHW->config_cntl &= ~CFG_MEM_VGA_AP_EN; - if (pATI->LinearBase && - ((pATI->Chip < ATI_CHIP_264CT) || - ((pATI->BusType != ATI_BUS_PCI) && (pATI->BusType != ATI_BUS_AGP)))) + } + + if (pATI->LinearBase && (pATI->Chip < ATI_CHIP_264CT)) { /* Replace linear aperture size and address */ pATIHW->config_cntl &= ~(CFG_MEM_AP_LOC | CFG_MEM_AP_SIZE); @@ -247,8 +171,8 @@ ATIMach64PreInit if (pATI->OptionAccel) { /* Ensure apertures are enabled */ - outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl); + outr(BUS_CNTL, pATIHW->bus_cntl); + outr(CONFIG_CNTL, pATIHW->config_cntl); /* * When possible, max out command FIFO size. @@ -283,7 +207,7 @@ ATIMach64PreInit { case 8: pATIHW->dp_chain_mask = DP_CHAIN_8BPP; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -291,7 +215,7 @@ ATIMach64PreInit case 15: pATIHW->dp_chain_mask = DP_CHAIN_15BPP_1555; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_15BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_15BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -299,7 +223,7 @@ ATIMach64PreInit case 16: pATIHW->dp_chain_mask = DP_CHAIN_16BPP_565; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_16BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_16BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -309,7 +233,7 @@ ATIMach64PreInit if (pATI->bitsPerPixel == 24) { pATIHW->dp_chain_mask = DP_CHAIN_24BPP_888; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -317,7 +241,7 @@ ATIMach64PreInit else { pATIHW->dp_chain_mask = DP_CHAIN_32BPP_8888; - pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */ + pATIHW->dp_pix_width = DP_BYTE_PIX_ORDER | SetBits(PIX_WIDTH_32BPP, DP_DST_PIX_WIDTH) | SetBits(PIX_WIDTH_32BPP, DP_SRC_PIX_WIDTH) | SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH); @@ -337,8 +261,8 @@ ATIMach64PreInit pATIHW->clr_cmp_msk = (CARD32)(-1); /* Restore aperture enablement */ - outl(pATI->CPIO_BUS_CNTL, bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, config_cntl); + outr(BUS_CNTL, bus_cntl); + outr(CONFIG_CNTL, config_cntl); } } @@ -355,38 +279,38 @@ ATIMach64Save ATIHWPtr pATIHW ) { - pATIHW->crtc_h_total_disp = inl(pATI->CPIO_CRTC_H_TOTAL_DISP); - pATIHW->crtc_h_sync_strt_wid = inl(pATI->CPIO_CRTC_H_SYNC_STRT_WID); - pATIHW->crtc_v_total_disp = inl(pATI->CPIO_CRTC_V_TOTAL_DISP); - pATIHW->crtc_v_sync_strt_wid = inl(pATI->CPIO_CRTC_V_SYNC_STRT_WID); + pATIHW->crtc_h_total_disp = inr(CRTC_H_TOTAL_DISP); + pATIHW->crtc_h_sync_strt_wid = inr(CRTC_H_SYNC_STRT_WID); + pATIHW->crtc_v_total_disp = inr(CRTC_V_TOTAL_DISP); + pATIHW->crtc_v_sync_strt_wid = inr(CRTC_V_SYNC_STRT_WID); - pATIHW->crtc_off_pitch = inl(pATI->CPIO_CRTC_OFF_PITCH); + pATIHW->crtc_off_pitch = inr(CRTC_OFF_PITCH); - pATIHW->crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL); + pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL); - pATIHW->ovr_clr = inl(pATI->CPIO_OVR_CLR); - pATIHW->ovr_wid_left_right = inl(pATI->CPIO_OVR_WID_LEFT_RIGHT); - pATIHW->ovr_wid_top_bottom = inl(pATI->CPIO_OVR_WID_TOP_BOTTOM); + pATIHW->ovr_clr = inr(OVR_CLR); + pATIHW->ovr_wid_left_right = inr(OVR_WID_LEFT_RIGHT); + pATIHW->ovr_wid_top_bottom = inr(OVR_WID_TOP_BOTTOM); - pATIHW->clock_cntl = inl(pATI->CPIO_CLOCK_CNTL); + pATIHW->clock_cntl = inr(CLOCK_CNTL); - pATIHW->bus_cntl = inl(pATI->CPIO_BUS_CNTL); + pATIHW->bus_cntl = inr(BUS_CNTL); - pATIHW->mem_vga_wp_sel = inl(pATI->CPIO_MEM_VGA_WP_SEL); - pATIHW->mem_vga_rp_sel = inl(pATI->CPIO_MEM_VGA_RP_SEL); + pATIHW->mem_vga_wp_sel = inr(MEM_VGA_WP_SEL); + pATIHW->mem_vga_rp_sel = inr(MEM_VGA_RP_SEL); - pATIHW->dac_cntl = inl(pATI->CPIO_DAC_CNTL); + pATIHW->dac_cntl = inr(DAC_CNTL); - pATIHW->config_cntl = inl(pATI->CPIO_CONFIG_CNTL); + pATIHW->config_cntl = inr(CONFIG_CNTL); /* Save draw engine state */ if (pATI->OptionAccel && (pATIHW == &pATI->OldHW)) { /* Ensure apertures are enabled */ - outl(pATI->CPIO_BUS_CNTL, pATI->NewHW.bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATI->NewHW.config_cntl); + outr(BUS_CNTL, pATI->NewHW.bus_cntl); + outr(CONFIG_CNTL, pATI->NewHW.config_cntl); - ATIMach64WaitForIdle(); + ATIMach64WaitForIdle(pATI); /* Save FIFO size */ if (pATI->Chip >= ATI_CHIP_264VT4) @@ -423,10 +347,10 @@ ATIMach64Save pATIHW->pat_cntl = inm(PAT_CNTL); /* Save scissor registers */ - pATIHW->sc_left = inm(SC_LEFT); - pATIHW->sc_right = inm(SC_RIGHT); - pATIHW->sc_top = inm(SC_TOP); - pATIHW->sc_bottom = inm(SC_BOTTOM); + pATIHW->sc_left = pATI->sc_left = inm(SC_LEFT); + pATIHW->sc_right = pATI->sc_right = inm(SC_RIGHT); + pATIHW->sc_top = pATI->sc_top = inm(SC_TOP); + pATIHW->sc_bottom = pATI->sc_bottom = inm(SC_BOTTOM); /* Save data path registers */ pATIHW->dp_bkgd_clr = inm(DP_BKGD_CLR); @@ -446,8 +370,8 @@ ATIMach64Save pATIHW->context_mask = inm(CONTEXT_MASK); /* Restore aperture enablement */ - outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl); + outr(BUS_CNTL, pATIHW->bus_cntl); + outr(CONFIG_CNTL, pATIHW->config_cntl); } } @@ -565,7 +489,7 @@ ATIMach64Calculate if (pMode->Flags & V_NVSYNC) pATIHW->crtc_v_sync_strt_wid |= CRTC_V_SYNC_POL; - pATIHW->crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL) & + pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL) & ~(CRTC_DBL_SCAN_EN | CRTC_INTERLACE_EN | CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_CSYNC_EN | CRTC_PIX_BY_2_EN | CRTC_DISPLAY_DIS | CRTC_VGA_XOVERSCAN | @@ -578,21 +502,31 @@ ATIMach64Calculate CRTC_EXT_DISP_EN | CRTC_EN | CRTC_VGA_LINEAR | CRTC_CNT_EN; switch (pATI->depth) { + +#ifndef AVOID_CPIO + case 1: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_1BPP, CRTC_PIX_WIDTH); break; + case 4: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_4BPP, CRTC_PIX_WIDTH); break; + +#endif /* AVOID_CPIO */ + case 8: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_8BPP, CRTC_PIX_WIDTH); break; + case 15: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_15BPP, CRTC_PIX_WIDTH); break; + case 16: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_16BPP, CRTC_PIX_WIDTH); break; + case 24: if (pATI->bitsPerPixel == 24) { @@ -603,9 +537,11 @@ ATIMach64Calculate if (pATI->bitsPerPixel != 32) break; /* Fall through */ + case 32: pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_32BPP, CRTC_PIX_WIDTH); break; + default: break; } @@ -633,30 +569,30 @@ ATIMach64Set ) { /* First, turn off the display */ - outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & ~CRTC_EN); + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl & ~CRTC_EN); if ((pATIHW->FeedbackDivider > 0) && (pATI->ProgrammableClock != ATI_CLOCK_NONE)) ATIClockSet(pATI, pATIHW); /* Programme clock */ /* Load Mach64 CRTC registers */ - outl(pATI->CPIO_CRTC_H_TOTAL_DISP, pATIHW->crtc_h_total_disp); - outl(pATI->CPIO_CRTC_H_SYNC_STRT_WID, pATIHW->crtc_h_sync_strt_wid); - outl(pATI->CPIO_CRTC_V_TOTAL_DISP, pATIHW->crtc_v_total_disp); - outl(pATI->CPIO_CRTC_V_SYNC_STRT_WID, pATIHW->crtc_v_sync_strt_wid); + outr(CRTC_H_TOTAL_DISP, pATIHW->crtc_h_total_disp); + outr(CRTC_H_SYNC_STRT_WID, pATIHW->crtc_h_sync_strt_wid); + outr(CRTC_V_TOTAL_DISP, pATIHW->crtc_v_total_disp); + outr(CRTC_V_SYNC_STRT_WID, pATIHW->crtc_v_sync_strt_wid); - outl(pATI->CPIO_CRTC_OFF_PITCH, pATIHW->crtc_off_pitch); + outr(CRTC_OFF_PITCH, pATIHW->crtc_off_pitch); /* Set pixel clock */ - outl(pATI->CPIO_CLOCK_CNTL, pATIHW->clock_cntl | CLOCK_STROBE); + outr(CLOCK_CNTL, pATIHW->clock_cntl | CLOCK_STROBE); /* Load overscan registers */ - outl(pATI->CPIO_OVR_CLR, pATIHW->ovr_clr); - outl(pATI->CPIO_OVR_WID_LEFT_RIGHT, pATIHW->ovr_wid_left_right); - outl(pATI->CPIO_OVR_WID_TOP_BOTTOM, pATIHW->ovr_wid_top_bottom); + outr(OVR_CLR, pATIHW->ovr_clr); + outr(OVR_WID_LEFT_RIGHT, pATIHW->ovr_wid_left_right); + outr(OVR_WID_TOP_BOTTOM, pATIHW->ovr_wid_top_bottom); /* Finalise CRTC setup and turn on the screen */ - outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl); + outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl); /* Load draw engine */ if (pATI->OptionAccel) @@ -665,11 +601,11 @@ ATIMach64Set (void)memset(pATI->MMIOCached, 0, SizeOf(pATI->MMIOCached)); /* Ensure apertures are enabled */ - outl(pATI->CPIO_BUS_CNTL, pATI->NewHW.bus_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATI->NewHW.config_cntl); + outr(BUS_CNTL, pATI->NewHW.bus_cntl); + outr(CONFIG_CNTL, pATI->NewHW.config_cntl); pATI->EngineIsBusy = TRUE; /* Force engine poll */ - ATIMach64WaitForIdle(); + ATIMach64WaitForIdle(pATI); /* Load FIFO size */ if (pATI->Chip >= ATI_CHIP_264VT4) @@ -683,65 +619,77 @@ ATIMach64Set pATI->nFIFOEntries = pATI->nAvailableFIFOEntries; /* Load destination registers */ - ATIMach64WaitForFIFO(7); - outm(DST_OFF_PITCH, pATIHW->dst_off_pitch); - outm(DST_Y_X, SetWord(pATIHW->dst_x, 1) | SetWord(pATIHW->dst_y, 0)); - outm(DST_HEIGHT, pATIHW->dst_height); - outm(DST_BRES_ERR, pATIHW->dst_bres_err); - outm(DST_BRES_INC, pATIHW->dst_bres_inc); - outm(DST_BRES_DEC, pATIHW->dst_bres_dec); - outm(DST_CNTL, pATIHW->dst_cntl); + ATIMach64WaitForFIFO(pATI, 7); + outf(DST_OFF_PITCH, pATIHW->dst_off_pitch); + outf(DST_Y_X, SetWord(pATIHW->dst_x, 1) | SetWord(pATIHW->dst_y, 0)); + outf(DST_HEIGHT, pATIHW->dst_height); + outf(DST_BRES_ERR, pATIHW->dst_bres_err); + outf(DST_BRES_INC, pATIHW->dst_bres_inc); + outf(DST_BRES_DEC, pATIHW->dst_bres_dec); + outf(DST_CNTL, pATIHW->dst_cntl); /* Load source registers */ - ATIMach64WaitForFIFO(6); - outm(SRC_OFF_PITCH, pATIHW->src_off_pitch); - outm(SRC_Y_X, SetWord(pATIHW->src_x, 1) | SetWord(pATIHW->src_y, 0)); - outm(SRC_HEIGHT1_WIDTH1, + ATIMach64WaitForFIFO(pATI, 6); + outf(SRC_OFF_PITCH, pATIHW->src_off_pitch); + outf(SRC_Y_X, SetWord(pATIHW->src_x, 1) | SetWord(pATIHW->src_y, 0)); + outf(SRC_HEIGHT1_WIDTH1, SetWord(pATIHW->src_width1, 1) | SetWord(pATIHW->src_height1, 0)); - outm(SRC_Y_X_START, + outf(SRC_Y_X_START, SetWord(pATIHW->src_x_start, 1) | SetWord(pATIHW->src_y_start, 0)); - outm(SRC_HEIGHT2_WIDTH2, + outf(SRC_HEIGHT2_WIDTH2, SetWord(pATIHW->src_width2, 1) | SetWord(pATIHW->src_height2, 0)); - outm(SRC_CNTL, pATIHW->src_cntl); + outf(SRC_CNTL, pATIHW->src_cntl); /* Load host data register */ - ATIMach64WaitForFIFO(1); - outm(HOST_CNTL, pATIHW->host_cntl); + ATIMach64WaitForFIFO(pATI, 1); + outf(HOST_CNTL, pATIHW->host_cntl); + + /* Set host transfer window address and size clamp */ + pATI->pHOST_DATA = + (CARD8 *)pATI->pBlock[GetBits(HOST_DATA_0, BLOCK_SELECT)] + + (HOST_DATA_0 & MM_IO_SELECT); + pATI->nHostFIFOEntries = pATI->nFIFOEntries >> 1; + if (pATI->nHostFIFOEntries > 16) + pATI->nHostFIFOEntries = 16; /* Load pattern registers */ - ATIMach64WaitForFIFO(3); - outm(PAT_REG0, pATIHW->pat_reg0); - outm(PAT_REG1, pATIHW->pat_reg1); - outm(PAT_CNTL, pATIHW->pat_cntl); + ATIMach64WaitForFIFO(pATI, 3); + outf(PAT_REG0, pATIHW->pat_reg0); + outf(PAT_REG1, pATIHW->pat_reg1); + outf(PAT_CNTL, pATIHW->pat_cntl); /* Load scissor registers */ - ATIMach64WaitForFIFO(2); - outm(SC_LEFT_RIGHT, + ATIMach64WaitForFIFO(pATI, 2); + outf(SC_LEFT_RIGHT, SetWord(pATIHW->sc_right, 1) | SetWord(pATIHW->sc_left, 0)); - outm(SC_TOP_BOTTOM, + outf(SC_TOP_BOTTOM, SetWord(pATIHW->sc_bottom, 1) | SetWord(pATIHW->sc_top, 0)); + pATI->sc_left = pATIHW->sc_left; + pATI->sc_right = pATIHW->sc_right; + pATI->sc_top = pATIHW->sc_top; + pATI->sc_bottom = pATIHW->sc_bottom; /* Load data path registers */ - ATIMach64WaitForFIFO(7); - outm(DP_BKGD_CLR, pATIHW->dp_bkgd_clr); - outm(DP_FRGD_CLR, pATIHW->dp_frgd_clr); - outm(DP_WRITE_MASK, pATIHW->dp_write_mask); - outm(DP_CHAIN_MASK, pATIHW->dp_chain_mask); - outm(DP_PIX_WIDTH, pATIHW->dp_pix_width); - outm(DP_MIX, pATIHW->dp_mix); - outm(DP_SRC, pATIHW->dp_src); + ATIMach64WaitForFIFO(pATI, 7); + outf(DP_BKGD_CLR, pATIHW->dp_bkgd_clr); + outf(DP_FRGD_CLR, pATIHW->dp_frgd_clr); + outf(DP_WRITE_MASK, pATIHW->dp_write_mask); + outf(DP_CHAIN_MASK, pATIHW->dp_chain_mask); + outf(DP_PIX_WIDTH, pATIHW->dp_pix_width); + outf(DP_MIX, pATIHW->dp_mix); + outf(DP_SRC, pATIHW->dp_src); /* Load colour compare registers */ - ATIMach64WaitForFIFO(3); - outm(CLR_CMP_CLR, pATIHW->clr_cmp_clr); - outm(CLR_CMP_MSK, pATIHW->clr_cmp_msk); - outm(CLR_CMP_CNTL, pATIHW->clr_cmp_cntl); + ATIMach64WaitForFIFO(pATI, 3); + outf(CLR_CMP_CLR, pATIHW->clr_cmp_clr); + outf(CLR_CMP_MSK, pATIHW->clr_cmp_msk); + outf(CLR_CMP_CNTL, pATIHW->clr_cmp_cntl); /* Load context mask */ - ATIMach64WaitForFIFO(1); - outm(CONTEXT_MASK, pATIHW->context_mask); + ATIMach64WaitForFIFO(pATI, 1); + outf(CONTEXT_MASK, pATIHW->context_mask); - ATIMach64WaitForIdle(); + ATIMach64WaitForIdle(pATI); if (pATI->OptionMMIOCache) { @@ -774,14 +722,13 @@ ATIMach64Set } /* Aperture setup */ - outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl); - - outl(pATI->CPIO_MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel); - outl(pATI->CPIO_MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel); + outr(MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel); + outr(MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel); - outl(pATI->CPIO_DAC_CNTL, pATIHW->dac_cntl); + outr(DAC_CNTL, pATIHW->dac_cntl); - outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl); + outr(CONFIG_CNTL, pATIHW->config_cntl); + outr(BUS_CNTL, pATIHW->bus_cntl); } /* @@ -796,18 +743,18 @@ ATIMach64SaveScreen int Mode ) { - CARD32 crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL); + CARD32 crtc_gen_cntl = inr(CRTC_GEN_CNTL); switch (Mode) { case SCREEN_SAVER_OFF: case SCREEN_SAVER_FORCER: - outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl & ~CRTC_DISPLAY_DIS); + outr(CRTC_GEN_CNTL, crtc_gen_cntl & ~CRTC_DISPLAY_DIS); break; case SCREEN_SAVER_ON: case SCREEN_SAVER_CYCLE: - outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_DISPLAY_DIS); + outr(CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_DISPLAY_DIS); break; default: @@ -828,7 +775,7 @@ ATIMach64SetDPMSMode ) { CARD32 crtc_gen_cntl = - inl(pATI->CPIO_CRTC_GEN_CNTL) & ~(CRTC_HSYNC_DIS | CRTC_VSYNC_DIS); + inr(CRTC_GEN_CNTL) & ~(CRTC_HSYNC_DIS | CRTC_VSYNC_DIS); switch (DPMSMode) { @@ -851,20 +798,20 @@ ATIMach64SetDPMSMode return; } - outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl); + outr(CRTC_GEN_CNTL, crtc_gen_cntl); if ((pATI->LCDPanelID >= 0) && !pATI->OptionCRT) { CARD32 lcd_index = 0, power_management; if (pATI->Chip == ATI_CHIP_264LT) - power_management = inl(pATI->CPIO_POWER_MANAGEMENT); + power_management = inr(POWER_MANAGEMENT); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - power_management = ATIGetLTProLCDReg(LCD_POWER_MANAGEMENT); + lcd_index = inr(LCD_INDEX); + power_management = ATIGetMach64LCDReg(LCD_POWER_MANAGEMENT); } power_management &= ~(STANDBY_NOW | SUSPEND_NOW); @@ -891,18 +838,51 @@ ATIMach64SetDPMSMode } if (pATI->Chip == ATI_CHIP_264LT) - outl(POWER_MANAGEMENT, power_management); + outr(POWER_MANAGEMENT, power_management); else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) */ { - ATIPutLTProLCDReg(LCD_POWER_MANAGEMENT, power_management); - outl(pATI->CPIO_LCD_INDEX, lcd_index); + ATIPutMach64LCDReg(LCD_POWER_MANAGEMENT, power_management); + outr(LCD_INDEX, lcd_index); } } } /* + * ATIMach64ValidateClip -- + * + * This function ensures the current scissor settings do not interfere with + * the current draw request. + */ +static void +ATIMach64ValidateClip +( + ATIPtr pATI, + CARD16 sc_left, + CARD16 sc_right, + CARD16 sc_top, + CARD16 sc_bottom +) +{ + if ((sc_left < pATI->sc_left) || (sc_right > pATI->sc_right)) + { + outf(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) | + SetWord(pATI->NewHW.sc_left, 0)); + pATI->sc_left = pATI->NewHW.sc_left; + pATI->sc_right = pATI->NewHW.sc_right; + } + + if ((sc_top < pATI->sc_top) || (sc_bottom > pATI->sc_bottom)) + { + outf(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) | + SetWord(pATI->NewHW.sc_top, 0)); + pATI->sc_top = pATI->NewHW.sc_top; + pATI->sc_bottom = pATI->NewHW.sc_bottom; + } +} + +/* * ATIMach64Sync -- * * This is called to wait for the draw engine to become idle. @@ -915,7 +895,7 @@ ATIMach64Sync { ATIPtr pATI = ATIPTR(pScreenInfo); - ATIMach64WaitForIdle(); + ATIMach64WaitForIdle(pATI); if (pATI->OptionMMIOCache) { @@ -1075,14 +1055,14 @@ ATIMach64SetupForScreenToScreenCopy pATI->dst_cntl |= DST_X_DIR; if (pATI->XModifier == 1) - outm(DST_CNTL, pATI->dst_cntl); + outf(DST_CNTL, pATI->dst_cntl); else pATI->dst_cntl |= DST_24_ROT_EN; - ATIMach64WaitForFIFO(3); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_ALLONES | + ATIMach64WaitForFIFO(pATI, 3); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_ALLONES | SetBits(SRC_BLIT, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); } @@ -1110,14 +1090,7 @@ ATIMach64SubsequentScreenToScreenCopy w *= pATI->XModifier; /* Disable clipping if it gets in the way */ - if ((xDst < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) || - ((xDst + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1))) - outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) | - SetWord(pATI->NewHW.sc_left, 0)); - if ((yDst < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) || - ((yDst + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1))) - outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) | - SetWord(pATI->NewHW.sc_top, 0)); + ATIMach64ValidateClip(pATI, xDst, xDst + w - 1, yDst, yDst + h - 1); if (!(pATI->dst_cntl & DST_X_DIR)) { @@ -1132,13 +1105,13 @@ ATIMach64SubsequentScreenToScreenCopy } if (pATI->XModifier != 1) - outm(DST_CNTL, pATI->dst_cntl | SetBits((xDst / 4) % 6, DST_24_ROT)); + outf(DST_CNTL, pATI->dst_cntl | SetBits((xDst / 4) % 6, DST_24_ROT)); - ATIMach64WaitForFIFO(4); - outm(SRC_Y_X, SetWord(xSrc, 1) | SetWord(ySrc, 0)); - outm(SRC_WIDTH1, w); - outm(DST_Y_X, SetWord(xDst, 1) | SetWord(yDst, 0)); - outm(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); + ATIMach64WaitForFIFO(pATI, 4); + outf(SRC_Y_X, SetWord(xSrc, 1) | SetWord(ySrc, 0)); + outf(SRC_WIDTH1, w); + outf(DST_Y_X, SetWord(xDst, 1) | SetWord(yDst, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); } /* @@ -1158,14 +1131,14 @@ ATIMach64SetupForSolidFill ATIPtr pATI = ATIPTR(pScreenInfo); if (pATI->XModifier == 1) - outm(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); - ATIMach64WaitForFIFO(4); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_ALLONES | + ATIMach64WaitForFIFO(pATI, 4); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_ALLONES | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); - outm(DP_FRGD_CLR, colour); + outf(DP_FRGD_CLR, colour); } /* @@ -1190,23 +1163,16 @@ ATIMach64SubsequentSolidFillRect x *= pATI->XModifier; w *= pATI->XModifier; - outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | + outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN)); } /* Disable clipping if it gets in the way */ - if ((x < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) || - ((x + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1))) - outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) | - SetWord(pATI->NewHW.sc_left, 0)); - if ((y < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) || - ((y + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1))) - outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) | - SetWord(pATI->NewHW.sc_top, 0)); + ATIMach64ValidateClip(pATI, x, x + w - 1, y, y + h - 1); - ATIMach64WaitForFIFO(2); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); - outm(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); + ATIMach64WaitForFIFO(pATI, 2); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); } /* @@ -1226,17 +1192,15 @@ ATIMach64SetupForSolidLine { ATIPtr pATI = ATIPTR(pScreenInfo); - ATIMach64WaitForFIFO(6); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_ALLONES | + ATIMach64WaitForFIFO(pATI, 4); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX)); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_ALLONES | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); - outm(DP_FRGD_CLR, colour); + outf(DP_FRGD_CLR, colour); - outm(SC_LEFT_RIGHT, - SetWord(pATI->NewHW.sc_right, 1) | SetWord(pATI->NewHW.sc_left, 0)); - outm(SC_TOP_BOTTOM, - SetWord(pATI->NewHW.sc_bottom, 1) | SetWord(pATI->NewHW.sc_top, 0)); + ATIMach64ValidateClip(pATI, pATI->NewHW.sc_left, pATI->NewHW.sc_right, + pATI->NewHW.sc_top, pATI->NewHW.sc_bottom); } /* @@ -1257,14 +1221,14 @@ ATIMach64SubsequentSolidHorVertLine { ATIPtr pATI = ATIPTR(pScreenInfo); - ATIMach64WaitForFIFO(3); - outm(DST_CNTL, DST_X_DIR | DST_Y_DIR); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + ATIMach64WaitForFIFO(pATI, 3); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); if (dir == DEGREES_0) - outm(DST_HEIGHT_WIDTH, SetWord(len, 1) | SetWord(1, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(len, 1) | SetWord(1, 0)); else /* if (dir == DEGREES_270) */ - outm(DST_HEIGHT_WIDTH, SetWord(1, 1) | SetWord(len, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(1, 1) | SetWord(len, 0)); } /* @@ -1297,13 +1261,13 @@ ATIMach64SubsequentSolidBresenhamLine if (!(octant & YDECREASING)) dst_cntl |= DST_Y_DIR; - ATIMach64WaitForFIFO(6); - outm(DST_CNTL, dst_cntl); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); - outm(DST_BRES_ERR, minor + err); - outm(DST_BRES_INC, minor); - outm(DST_BRES_DEC, minor - major); - outm(DST_BRES_LNTH, len); + ATIMach64WaitForFIFO(pATI, 6); + outf(DST_CNTL, dst_cntl); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_BRES_ERR, minor + err); + outf(DST_BRES_INC, minor); + outf(DST_BRES_DEC, minor - major); + outf(DST_BRES_LNTH, len); } /* @@ -1327,28 +1291,28 @@ ATIMach64SetupForMono8x8PatternFill ATIPtr pATI = ATIPTR(pScreenInfo); if (pATI->XModifier == 1) - outm(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); if (bg == -1) - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | SetBits(MIX_DST, DP_BKGD_MIX)); else { - ATIMach64WaitForFIFO(2); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | + ATIMach64WaitForFIFO(pATI, 2); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | SetBits(ATIMach64ALU[rop], DP_BKGD_MIX)); - outm(DP_BKGD_CLR, bg); + outf(DP_BKGD_CLR, bg); } - ATIMach64WaitForFIFO(6); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_PATTERN | + ATIMach64WaitForFIFO(pATI, 6); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_PATTERN | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); - outm(DP_FRGD_CLR, fg); + outf(DP_FRGD_CLR, fg); - outm(PAT_REG0, patx); - outm(PAT_REG1, paty); - outm(PAT_CNTL, PAT_MONO_EN); + outf(PAT_REG0, patx); + outf(PAT_REG1, paty); + outf(PAT_CNTL, PAT_MONO_EN); } /* @@ -1375,23 +1339,16 @@ ATIMach64SubsequentMono8x8PatternFillRect x *= pATI->XModifier; w *= pATI->XModifier; - outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | + outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN)); } /* Disable clipping if it gets in the way */ - if ((x < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) || - ((x + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1))) - outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) | - SetWord(pATI->NewHW.sc_left, 0)); - if ((y < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) || - ((y + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1))) - outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) | - SetWord(pATI->NewHW.sc_top, 0)); + ATIMach64ValidateClip(pATI, x, x + w - 1, y, y + h - 1); - ATIMach64WaitForFIFO(2); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); - outm(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); + ATIMach64WaitForFIFO(pATI, 2); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); } /* @@ -1412,24 +1369,24 @@ ATIMach64SetupForScanlineCPUToScreenColorExpandFill ATIPtr pATI = ATIPTR(pScreenInfo); if (pATI->XModifier == 1) - outm(DST_CNTL, DST_X_DIR | DST_Y_DIR); + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); if (bg == -1) - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | SetBits(MIX_DST, DP_BKGD_MIX)); else { - ATIMach64WaitForFIFO(2); - outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | + ATIMach64WaitForFIFO(pATI, 2); + outf(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) | SetBits(ATIMach64ALU[rop], DP_BKGD_MIX)); - outm(DP_BKGD_CLR, bg); + outf(DP_BKGD_CLR, bg); } - ATIMach64WaitForFIFO(3); - outm(DP_WRITE_MASK, planemask); - outm(DP_SRC, DP_MONO_SRC_HOST | + ATIMach64WaitForFIFO(pATI, 3); + outf(DP_WRITE_MASK, planemask); + outf(DP_SRC, DP_MONO_SRC_HOST | SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); - outm(DP_FRGD_CLR, fg); + outf(DP_FRGD_CLR, fg); } /* @@ -1456,16 +1413,19 @@ ATIMach64SubsequentScanlineCPUToScreenColorExpandFill w *= pATI->XModifier; skipleft *= pATI->XModifier; - outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | + outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN)); } pATI->ExpansionBitmapWidth = (w + 31) / 32; - ATIMach64WaitForFIFO(3); - outm(SC_LEFT_RIGHT, SetWord(x + w - 1, 1) | SetWord(x + skipleft, 0)); - outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); - outm(DST_HEIGHT_WIDTH, + ATIMach64WaitForFIFO(pATI, 3); + pATI->sc_left = x + skipleft; + pATI->sc_right = x + w - 1; + outf(SC_LEFT_RIGHT, + SetWord(pATI->sc_right, 1) | SetWord(pATI->sc_left, 0)); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(pATI->ExpansionBitmapWidth * 32, 1) | SetWord(h, 0)); } @@ -1473,7 +1433,8 @@ ATIMach64SubsequentScanlineCPUToScreenColorExpandFill * ATIMach64SubsequentColorExpandScanline -- * * This function feeds a bitmap scanline to the engine for a colour expansion - * fill. + * fill. This is written to do burst transfers for those platforms that can do + * them, and to improve CPU/engine concurrency. */ static void ATIMach64SubsequentColorExpandScanline @@ -1482,22 +1443,69 @@ ATIMach64SubsequentColorExpandScanline int iBuffer ) { - ATIPtr pATI = ATIPTR(pScreenInfo); - CARD32 *pBitmapData = pATI->ExpansionBitmapScanline; - int w = pATI->ExpansionBitmapWidth; - int nFIFOEntries = pATI->nFIFOEntries; + ATIPtr pATI = ATIPTR(pScreenInfo); + CARD32 *pBitmapData = pATI->ExpansionBitmapScanlinePtr[iBuffer]; + CARD32 *pDst, *pSrc; + int w = pATI->ExpansionBitmapWidth; + int nDWord; + unsigned int iDWord; + + while (w > 0) + { + /* + * Transfers are done in chunks of up to 64 bytes in length (32 on + * earlier controllers). + */ + nDWord = w; + if (nDWord > pATI->nHostFIFOEntries) + nDWord = pATI->nHostFIFOEntries; - pATI->nFIFOEntries >>= 1; + /* Make enough FIFO slots available */ + ATIMach64WaitForFIFO(pATI, nDWord); - for (; w > 0; w--, pBitmapData++) - { - if (!pATI->nAvailableFIFOEntries && (w > 1)) - ATIMach64WaitForFIFO(w); + /* + * Always start transfers on a chuck-sized boundary. Note that + * HOST_DATA_0 is actually on a 512-byte boundary, but *pBitmapData can + * only be guaranteed to be on a chunk-sized boundary. + */ + iDWord = 16 - nDWord; + pDst = (CARD32 *)pATI->pHOST_DATA - iDWord; + pSrc = pBitmapData - iDWord; - outm(HOST_DATA_0, *pBitmapData); + /* + * Transfer current chunk. With any luck, the compiler won't mangle + * this too badly... + */ + switch (iDWord) + { + case 0: MMIO_OUT32(pDst + 0, 0, *(pSrc + 0)); + case 1: MMIO_OUT32(pDst + 1, 0, *(pSrc + 1)); + case 2: MMIO_OUT32(pDst + 2, 0, *(pSrc + 2)); + case 3: MMIO_OUT32(pDst + 3, 0, *(pSrc + 3)); + case 4: MMIO_OUT32(pDst + 4, 0, *(pSrc + 4)); + case 5: MMIO_OUT32(pDst + 5, 0, *(pSrc + 5)); + case 6: MMIO_OUT32(pDst + 6, 0, *(pSrc + 6)); + case 7: MMIO_OUT32(pDst + 7, 0, *(pSrc + 7)); + case 8: MMIO_OUT32(pDst + 8, 0, *(pSrc + 8)); + case 9: MMIO_OUT32(pDst + 9, 0, *(pSrc + 9)); + case 10: MMIO_OUT32(pDst + 10, 0, *(pSrc + 10)); + case 11: MMIO_OUT32(pDst + 11, 0, *(pSrc + 11)); + case 12: MMIO_OUT32(pDst + 12, 0, *(pSrc + 12)); + case 13: MMIO_OUT32(pDst + 13, 0, *(pSrc + 13)); + case 14: MMIO_OUT32(pDst + 14, 0, *(pSrc + 14)); + case 15: MMIO_OUT32(pDst + 15, 0, *(pSrc + 15)); + + default: /* Muffle compiler */ + break; + } + + /* Step to next chunk */ + pBitmapData += nDWord; + w -= nDWord; + pATI->nAvailableFIFOEntries -= nDWord; } - pATI->nFIFOEntries = nFIFOEntries; + pATI->EngineIsBusy = TRUE; } /* @@ -1517,8 +1525,16 @@ ATIMach64AccelInit if (pATI->XModifier == 1) { pXAAInfo->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS; + +#ifndef AVOID_CPIO + if (!pATI->BankInfo.BankSize) + +#endif /* AVOID_CPIO */ + + { pXAAInfo->Flags |= LINEAR_FRAMEBUFFER; + } } /* Sync */ @@ -1535,8 +1551,8 @@ ATIMach64AccelInit pXAAInfo->SubsequentSolidFillRect = ATIMach64SubsequentSolidFillRect; /* 8x8 mono pattern fills */ - pXAAInfo->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_SCREEN_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST; + pXAAInfo->Mono8x8PatternFillFlags = + HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN; pXAAInfo->SetupForMono8x8PatternFill = ATIMach64SetupForMono8x8PatternFill; pXAAInfo->SubsequentMono8x8PatternFillRect = ATIMach64SubsequentMono8x8PatternFillRect; @@ -1547,14 +1563,21 @@ ATIMach64AccelInit */ pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags = LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X | - BIT_ORDER_IN_BYTE_MSBFIRST | CPU_TRANSFER_PAD_DWORD | - SCANLINE_PAD_DWORD; + CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD; if (pATI->XModifier != 1) pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags |= TRIPLE_BITS_24BPP; pXAAInfo->NumScanlineColorExpandBuffers = 1; - pATI->ExpansionBitmapScanlinePtr = pATI->ExpansionBitmapScanline; + + /* Align bitmap data on a 64-byte boundary */ + pATI->ExpansionBitmapWidth = /* DWord size in bits */ + ((pATI->displayWidth * pATI->XModifier) + 31) & ~31U; + pATI->ExpansionBitmapScanlinePtr[1] = + (CARD32 *)xnfalloc((pATI->ExpansionBitmapWidth >> 3) + 63); + pATI->ExpansionBitmapScanlinePtr[0] = + (pointer)(((unsigned long)pATI->ExpansionBitmapScanlinePtr[1] + 63) & + ~63UL); pXAAInfo->ScanlineColorExpandBuffers = - (CARD8 **)&pATI->ExpansionBitmapScanlinePtr; + (CARD8 **)pATI->ExpansionBitmapScanlinePtr; pXAAInfo->SetupForScanlineCPUToScreenColorExpandFill = ATIMach64SetupForScanlineCPUToScreenColorExpandFill; pXAAInfo->SubsequentScanlineCPUToScreenColorExpandFill = diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h index 0cfa6e92b..8e53f2183 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h,v 1.8 2000/06/19 15:00:57 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h,v 1.9 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xaa.h" #define ATIMach64MaxX 8191 diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.c new file mode 100644 index 000000000..723e93a7d --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.c @@ -0,0 +1,100 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.c,v 1.2 2000/08/04 21:07:14 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ati.h" +#include "atichip.h" +#include "atimach64io.h" + +/* + * ATIAccessMach64PLLReg -- + * + * This function sets up the addressing required to access, for read or write, + * a 264xT's PLL registers. + */ +void +ATIAccessMach64PLLReg +( + ATIPtr pATI, + const CARD8 Index, + const Bool Write +) +{ + CARD8 clock_cntl1 = in8(CLOCK_CNTL + 1) & + ~GetByte(PLL_WR_EN | PLL_ADDR, 1); + + /* Set PLL register to be read or written */ + out8(CLOCK_CNTL + 1, clock_cntl1 | + GetByte(SetBits(Index, PLL_ADDR) | SetBits(Write, PLL_WR_EN), 1)); +} + +/* + * ATIMach64PollEngineStatus -- + * + * This function refreshes the driver's view of the draw engine's status. This + * has been moved into a separate compilation unit to prevent inlining. + */ +void +ATIMach64PollEngineStatus +( + ATIPtr pATI +) +{ + CARD32 IOValue; + int Count; + + if (pATI->Chip < ATI_CHIP_264VTB) + { + /* + * TODO: Deal with locked engines. + */ + IOValue = inm(FIFO_STAT); + pATI->EngineIsLocked = GetBits(IOValue, FIFO_ERR); + + /* + * The following counts the number of bits in FIFO_STAT_BITS, and is + * derived from miSetVisualTypes() (formerly cfbSetVisualTypes()). + */ + IOValue = GetBits(IOValue, FIFO_STAT_BITS); + Count = (IOValue >> 1) & 0x36DBU; + Count = IOValue - Count - ((Count >> 1) & 0x36DBU); + Count = ((Count + (Count >> 3)) & 0x71C7U) % 0x3FU; + Count = pATI->nFIFOEntries - Count; + if (Count > pATI->nAvailableFIFOEntries) + pATI->nAvailableFIFOEntries = Count; + + /* + * If the command FIFO is non-empty, then the engine isn't idle. + */ + if (pATI->nAvailableFIFOEntries < pATI->nFIFOEntries) + { + pATI->EngineIsBusy = TRUE; + return; + } + } + + IOValue = inm(GUI_STAT); + pATI->EngineIsBusy = GetBits(IOValue, GUI_ACTIVE); + Count = GetBits(IOValue, GUI_FIFO); + if (Count > pATI->nAvailableFIFOEntries) + pATI->nAvailableFIFOEntries = Count; +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.h new file mode 100644 index 000000000..70e27ee8e --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.h @@ -0,0 +1,210 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64io.h,v 1.2 2000/08/04 21:07:14 tsi Exp $ */ +/* + * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef ___ATIMACH64IO_H___ + +#if !defined(___ATI_H___) && defined(XFree86Module) +# error Missing #include "ati.h" before #include "atimach64io.h" +# undef XFree86Module +#endif + +#define ___ATIMACH64IO_H___ 1 + +#include "atiio.h" + +/* + * A few important notes on some of the I/O statements provided: + * + * inl/outl 32-bit R/W through PIO space. The register is specified as the + * actual PIO address. These are actually defined in compiler.h. + * + * inw/outw 16-bit counterparts to inl/outl. Not used for Mach64 support. + * + * inb/outb 8-bit counterparts to inl/outl. + * + * inm/outm 32-bit R/W through MMIO space. The register is specified as + * the actual MMIO offset (with Block 1 following Block 0), which, + * in this case, is equivalent to the register's IOPortTag from + * atiregs.h. Can only be used for those few non-FIFO'ed + * registers outside of Block 0's first 256 bytes. pATI->pBlock + * array elements must have been previously set up by + * ATIMapApertures(). + * + * outf 32-bit write through MMIO cache. Identical to outm() but + * intended for FIFO'ed registers. There is no inf() provided. + * + * inr/outr 32-bit R/W through PIO or MMIO. Which one depends on the + * machine architecture. The register is specified as a IOPortTag + * from atiregs.h. Can only be used for registers in the first + * 256 bytes of MMIO space (in Block 0). Note that all of these + * registers are non-FIFO'ed. + * + * in8/out8 8-bit counterparts to inr/outr. + */ + +/* + * Cave canem (or it WILL bite you): All Mach64 non-VGA registers are + * ================================ little-endian, no matter how they are + * accessed (nor by what). + */ + +#define inm(_Register) \ + MMIO_IN32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ + (_Register) & MM_IO_SELECT) +#define outm(_Register, _Value) \ + MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ + (_Register) & MM_IO_SELECT, _Value) + +#ifdef AVOID_CPIO + +# define inr(_Register) \ + MMIO_IN32(pATI->pBlock[0], (_Register) & MM_IO_SELECT) +# define outr(_Register, _Value) \ + MMIO_OUT32(pATI->pBlock[0], (_Register) & MM_IO_SELECT, _Value) + +# define in8(_Register) \ + MMIO_IN8(pATI->pBlock[0], \ + (_Register) & (MM_IO_SELECT | IO_BYTE_SELECT)) +# define out8(_Register, _Value) \ + MMIO_OUT8(pATI->pBlock[0], \ + (_Register) & (MM_IO_SELECT | IO_BYTE_SELECT), _Value) + +/* Cause a cpp syntax error if any of these are used */ +#undef inb +#undef inw +#undef inl +#undef outb +#undef outw +#undef outl + +#define inb() /* Nothing */ +#define inw() /* Nothing */ +#define inl() /* Nothing */ +#define outb() /* Nothing */ +#define outw() /* Nothing */ +#define outl() /* Nothing */ + +#else /* AVOID_CPIO */ + +# define ATIIOPort(_PortTag) \ + (((pATI->CPIODecoding == SPARSE_IO) ? \ + ((_PortTag) & (SPARSE_IO_SELECT | IO_BYTE_SELECT)) : \ + ((_PortTag) & (BLOCK_IO_SELECT | IO_BYTE_SELECT))) | \ + pATI->CPIOBase) + +# define inr(_Register) \ + inl(ATIIOPort(_Register)) +# define outr(_Register, _Value) \ + outl(ATIIOPort(_Register), _Value) + +# define in8(_Register) \ + inb(ATIIOPort(_Register)) +# define out8(_Register, _Value) \ + outb(ATIIOPort(_Register), _Value) + +#endif /* AVOID_CPIO */ + +extern void ATIMach64PollEngineStatus FunctionPrototype((ATIPtr)); + +/* + * MMIO cache definitions + */ +#define CacheByte(___Register) pATI->MMIOCached[CacheSlotOf(___Register >> 3)] +#define CacheBit(___Register) (0x80U >> (CacheSlotOf(___Register) & 0x07U)) + +#define RegisterIsCached(__Register) \ + (CacheByte(__Register) & CacheBit(__Register)) +#define CacheSlot(__Register) pATI->MMIOCache[CacheSlotOf(__Register)] + +#define CacheRegister(__Register) \ + CacheByte(__Register) |= CacheBit(__Register) +#define UncacheRegister(__Register) \ + CacheByte(__Register) &= ~CacheBit(__Register) + +/* This would be quite a bit slower as a function */ +#define outf(_Register, _Value) \ + do \ + { \ + CARD32 _IOValue = (_Value); \ + \ + if (!RegisterIsCached(_Register) || \ + (_IOValue != CacheSlot(_Register))) \ + { \ + while (!pATI->nAvailableFIFOEntries--) \ + ATIMach64PollEngineStatus(pATI); \ + MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \ + (_Register) & MM_IO_SELECT, _IOValue); \ + CacheSlot(_Register) = _IOValue; \ + pATI->EngineIsBusy = TRUE; \ + } \ + } while (0) + +/* + * This is no longer as critical, especially for _n == 1. However, + * there is still a need to ensure _n <= pATI-<nFIFOEntries. + */ +#define ATIMach64WaitForFIFO(_pATI, _n) \ + while (pATI->nAvailableFIFOEntries < (_n)) \ + ATIMach64PollEngineStatus(pATI); + +#define ATIMach64WaitForIdle(_pATI) \ + while (pATI->EngineIsBusy) \ + ATIMach64PollEngineStatus(pATI); + +extern void ATIAccessMach64PLLReg FunctionPrototype((ATIPtr, const CARD8, + const Bool)); + +#define ATIGetMach64PLLReg(_Index) \ + ( \ + ATIAccessMach64PLLReg(pATI, _Index, FALSE), \ + in8(CLOCK_CNTL + 2) \ + ) +#define ATIPutMach64PLLReg(_Index, _Value) \ + ( \ + ATIAccessMach64PLLReg(pATI, _Index, TRUE), \ + out8(CLOCK_CNTL + 2, _Value) \ + ) + +#define ATIGetMach64LCDReg(_Index) \ + ( \ + out8(LCD_INDEX, SetBits((_Index), LCD_REG_INDEX)), \ + inr(LCD_DATA) \ + ) +#define ATIPutMach64LCDReg(_Index, _Value) \ + ( \ + out8(LCD_INDEX, SetBits((_Index), LCD_REG_INDEX)), \ + outr(LCD_DATA, (_Value)) \ + ) + +#define ATIGetMach64TVReg(_Index) \ + ( \ + out8(TV_OUT_INDEX, SetBits((_Index), TV_REG_INDEX)), \ + inr(TV_OUT_DATA) \ + ) +#define ATIPutMach64TVReg(_Index, _Value) \ + ( \ + out8(TV_OUT_INDEX, SetBits((_Index), TV_REG_INDEX)), \ + outr(TV_OUT_DATA, (_Value)) \ + ) + +#endif /* ___ATIMACH64IO_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c index a334861f6..75e50abfc 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c,v 1.6 2000/06/19 15:00:57 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c,v 1.7 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -70,8 +70,14 @@ ATISetup * refer to. */ LoaderRefSymbols( + +#ifndef AVOID_CPIO + "xf1bppScreenInit", "xf4bppScreenInit", + +#endif /* AVOID_CPIO */ + "cfbScreenInit", "cfb16ScreenInit", "cfb24ScreenInit", @@ -149,12 +155,17 @@ ATILoadModules /* Load depth-specific entry points */ switch (pATI->bitsPerPixel) { + +#ifndef AVOID_CPIO + case 1: return ATILoadModule(pScreenInfo, "xf1bpp", "xf1bppScreenInit"); case 4: return ATILoadModule(pScreenInfo, "xf4bpp", "xf4bppScreenInit"); +#endif /* AVOID_CPIO */ + case 8: return ATILoadModule(pScreenInfo, "cfb", "cfbScreenInit"); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h index 05e3f4472..f09f04a78 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h,v 1.3 2000/02/18 12:19:26 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.h,v 1.4 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -21,13 +21,14 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#if defined(XFree86LOADER) && !defined(___ATI_MODULE_H___) -#define ___ATI_MODULE_H___ 1 +#if defined(XFree86LOADER) && !defined(___ATIMODULE_H___) +#define ___ATIMODULE_H___ 1 #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" extern Bool ATILoadModules FunctionPrototype((ScrnInfoPtr, ATIPtr)); -#endif +#endif /* ___ATIMODULE_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c index 8b30b41a0..0d9649dde 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c,v 1.8 2000/05/03 00:44:06 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c,v 1.9 2000/08/04 21:07:14 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -38,6 +38,7 @@ typedef enum ATI_OPTION_LINEAR, ATI_OPTION_MMIO_CACHE, ATI_OPTION_PROBE_CLOCKS, + ATI_OPTION_REFERENCE_CLOCK, ATI_OPTION_SHADOW_FB } ATIPublicOptionType; @@ -49,14 +50,69 @@ typedef enum static OptionInfoRec ATIPublicOptions[] = { - {ATI_OPTION_ACCEL, "accel", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_CRT, "crt_screen", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_CSYNC, "composite_sync", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_LINEAR, "linear", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_MMIO_CACHE, "mmio_cache", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_PROBE_CLOCKS, "probe_clocks", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_SHADOW_FB, "shadow_fb", OPTV_BOOLEAN, {0, }, FALSE}, - {-1, NULL, OPTV_NONE , {0, }, FALSE} + { + ATI_OPTION_ACCEL, + "accel", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_CRT, + "crt_screen", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_CSYNC, + "composite_sync", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_LINEAR, + "linear", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_MMIO_CACHE, + "mmio_cache", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_PROBE_CLOCKS, + "probe_clocks", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_REFERENCE_CLOCK, + "reference_clock", + OPTV_FREQ, + {0, }, + FALSE + }, + { + ATI_OPTION_SHADOW_FB, + "shadow_fb", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + -1, + NULL, + OPTV_NONE, + {0, }, + FALSE + } }; /* @@ -90,9 +146,27 @@ ATIProcessOptions OptionInfoRec PublicOption[NumberOf(ATIPublicOptions)]; OptionInfoRec PrivateOption[] = { - {ATI_OPTION_DEVEL, "tsi", OPTV_BOOLEAN, {0, }, FALSE}, - {ATI_OPTION_SYNC, "lcdsync", OPTV_BOOLEAN, {0, }, FALSE}, - {-1, NULL, OPTV_NONE , {0, }, FALSE} + { + ATI_OPTION_DEVEL, + "tsi", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + ATI_OPTION_SYNC, + "lcdsync", + OPTV_BOOLEAN, + {0, }, + FALSE + }, + { + -1, + NULL, + OPTV_NONE, + {0, }, + FALSE + } }; (void)memcpy(PublicOption, ATIPublicOptions, SizeOf(ATIPublicOptions)); @@ -107,14 +181,36 @@ ATIProcessOptions # define ShadowFB PublicOption[ATI_OPTION_SHADOW_FB].value.bool # define Sync PrivateOption[ATI_OPTION_SYNC].value.bool +# define ReferenceClock \ + PublicOption[ATI_OPTION_REFERENCE_CLOCK].value.freq.freq + /* Pick up XF86Config options */ xf86CollectOptions(pScreenInfo, NULL); /* Set non-zero defaults */ + +#ifndef AVOID_CPIO + if (pATI->Adapter >= ATI_ADAPTER_MACH64) + +#endif /* AVOID_CPIO */ + + { Accel = Linear = CacheMMIO = TRUE; + } + + ReferenceClock = ((double)157500000.0) / ((double)11.0); + +#ifndef AVOID_CPIO + if (pATI->BusType >= ATI_BUS_PCI) + +#endif /* AVOID_CPIO */ + + { ShadowFB = TRUE; + } + Sync = TRUE; xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options, @@ -141,4 +237,27 @@ ATIProcessOptions pATI->OptionProbeClocks = ProbeClocks; pATI->OptionShadowFB = ShadowFB; pATI->OptionSync = Sync; + + /* Only set the reference clock if it hasn't already been determined */ + if (!pATI->ReferenceNumerator || !pATI->ReferenceDenominator) + { + switch ((int)(ReferenceClock / ((double)100000.0))) + { + case 143: + pATI->ReferenceNumerator = 157500; + pATI->ReferenceDenominator = 11; + break; + + case 286: + pATI->ReferenceNumerator = 315000; + pATI->ReferenceDenominator = 11; + break; + + default: + pATI->ReferenceNumerator = + (int)(ReferenceClock / ((double)1000.0)); + pATI->ReferenceDenominator = 1; + break; + } + } } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h index a0fd69992..99189bfca 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h,v 1.2 2000/02/18 12:19:27 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.h,v 1.3 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" extern OptionInfoPtr ATIAvailableOptions FunctionPrototype((int, int)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c index 73d5dc9dc..a3651de33 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c,v 1.26 2000/06/19 15:00:57 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c,v 1.28 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -31,14 +31,18 @@ #include "atiident.h" #include "atilock.h" #include "atimach64.h" +#include "atimach64io.h" #include "atimodule.h" #include "atioption.h" #include "atipreinit.h" #include "atiprint.h" #include "atividmem.h" + #include "vbe.h" #include "xf86RAC.h" +#ifndef AVOID_CPIO + typedef CARD16 Colour; /* The correct spelling should be OK :-) */ /* @@ -277,6 +281,8 @@ ATIMach32videoRam return Test_Case[Case_Number].videoRamSize; } +#endif /* AVOID_CPIO */ + /* * ATIReportMemory -- * @@ -295,6 +301,9 @@ ATIReportMemory Message = Buffer + snprintf(Buffer, SizeOf(Buffer), "%d kB of %s detected", pATI->VideoRAM, MemoryTypeName); + +#ifndef AVOID_CPIO + if (pATI->depth == 1) { /* 1bpp only uses one plane of four */ @@ -302,7 +311,11 @@ ATIReportMemory Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, " (using %d kB)", pScreenInfo->videoRam); } - else if (pATI->VideoRAM > pScreenInfo->videoRam) + else + +#endif /* AVOID_CPIO */ + + if (pATI->VideoRAM > pScreenInfo->videoRam) Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, " (using %d kB)", pScreenInfo->videoRam); xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s.\n", Buffer); @@ -314,6 +327,24 @@ static const rgb defaultWeight = {0, 0, 0}; static const Gamma defaultGamma = {0.0, 0.0, 0.0}; /* + * ATIMapMach64 -- + * + * This function attempts to mmap() a Mach64's MMIO aperture. + */ +static void +ATIMapMach64 +( + int iScreen, + ATIPtr pATI +) +{ + (void)ATIMapApertures(iScreen, pATI); + if (!pATI->pBlock[0] || + (pATI->config_chip_id != inr(CONFIG_CHIP_ID))) + ATIUnmapApertures(iScreen, pATI); +} + +/* * ATIPreInit -- * * This function is only called once per screen at the start of the first @@ -327,11 +358,11 @@ ATIPreInit ) { # define BIOS_SIZE 0x00010000U /* 64kB */ - CARD8 BIOS[BIOS_SIZE], *pBIOS; + CARD8 BIOS[BIOS_SIZE]; # define BIOSByte(_n) (*((CARD8 *)(BIOS + (_n)))) # define BIOSWord(_n) (*((CARD16 *)(BIOS + (_n)))) # define BIOSLong(_n) (*((CARD32 *)(BIOS + (_n)))) - unsigned int BIOSSize; + unsigned int BIOSSize = 0; unsigned int ROMTable = 0, ClockTable = 0, FrequencyTable = 0; unsigned int LCDTable = 0, LCDPanelInfo = 0; @@ -340,21 +371,27 @@ ATIPreInit GDevPtr pGDev; EntityInfoPtr pEntity; resPtr pResources; + pciVideoPtr pVideo; DisplayModePtr pMode; - xf86Int10InfoPtr pInt10Info; + xf86Int10InfoPtr pInt10Info = NULL; vbeInfoPtr pVBE; - xf86MonPtr pMonitor = NULL; - pointer pInt10Module, pDDCModule, pVBEModule = NULL; - Bool AllowCRT = TRUE; - CARD32 IOValue1, IOValue2 = 0; - int i, j, AcceleratorVideoRAM = 0, VGAVideoRAM = 0; + pointer pInt10Module, pDDCModule = NULL, pVBEModule = NULL; + CARD32 IOValue1, IOValue2 = 0, IOValue3 = 0, IOValue4 = 0; + int i, j, AcceleratorVideoRAM = 0; int Numerator, Denominator; int MinX, MinY; - resRange Resources[2] = {{0, 0, 0}, _END}; ClockRange ATIClockRange = {NULL, 0, 80000, 0, TRUE, TRUE, 1, 1, 0}; int minPitch, maxPitch = 0xFFU, maxHeight = 0; + int ApertureSize = 0x00010000U; LookupModeFlags Strategy = LOOKUP_CLOSEST_CLOCK; +#ifndef AVOID_CPIO + + int VGAVideoRAM = 0; + resRange Resources[2] = {{0, 0, 0}, _END}; + +#endif /* AVOID_CPIO */ + if (pScreenInfo->numEntities != 1) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, @@ -371,57 +408,70 @@ ATIPreInit return FALSE; } - /* - * Get adapter BIOS, after ensuring its initialisation entry point has been - * executed. - */ - if (!(pInt10Module = xf86LoadSubModule(pScreenInfo, "int10"))) + /* Register resources */ + pEntity = xf86GetEntityInfo(pScreenInfo->entityList[0]); + pGDev = pEntity->device; + pResources = pEntity->resources; + xfree(pEntity); + if (!pResources) + pResources = xf86RegisterResources(pATI->iEntity, NULL, + pATI->SharedAccelerator ? ResShared : ResExclusive); + if (pResources) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to load int10 module.\n"); + "Unable to register the following bus resources:\n"); + xf86PrintResList(0, pResources); + xf86FreeResList(pResources); return FALSE; } - if (!(pInt10Info = xf86InitInt10(pATI->iEntity))) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to initialise int10 interface.\n"); - xf86UnloadSubModule(pInt10Module); - return FALSE; - } + ConfiguredMonitor = NULL; - if (!(pDDCModule = xf86LoadSubModule(pScreenInfo, "ddc"))) + /* + * If there is an ix86-style BIOS, ensure its initialisation entry point + * has been executed, and retrieve DDC and VBE information from it. + */ + (void)memset(BIOS, 0, SizeOf(BIOS)); + if (!(pInt10Module = xf86LoadSubModule(pScreenInfo, "int10"))) xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Unable to load ddc module.\n"); - else if (!(pVBEModule = xf86LoadSubModule(pScreenInfo, "vbe"))) + "Unable to load int10 module.\n"); + else if (!(pInt10Info = xf86InitInt10(pATI->iEntity))) xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, - "Unable to load vbe module.\n"); + "Unable to initialise int10 interface.\n"); else { - if ((pVBE = VBEInit(pInt10Info, pATI->iEntity))) - pMonitor = vbeDoEDID(pVBE, pDDCModule); - vbeFree(pVBE); - xf86UnloadSubModule(pVBEModule); - } + if (!(pDDCModule = xf86LoadSubModule(pScreenInfo, "ddc"))) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to load ddc module.\n"); + else if (!(pVBEModule = xf86LoadSubModule(pScreenInfo, "vbe"))) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to load vbe module.\n"); + else + { + if ((pVBE = VBEInit(pInt10Info, pATI->iEntity))) + { + ConfiguredMonitor = vbeDoEDID(pVBE, pDDCModule); + vbeFree(pVBE); + } + xf86UnloadSubModule(pVBEModule); + } - /* - * Validate, then make a private copy of, the initialised BIOS. This - * allows de-activating int10 early. - */ - pBIOS = xf86int10Addr(pInt10Info, pInt10Info->BIOSseg << 4); - if ((pBIOS[0] != 0x55U) || (pBIOS[1] != 0xAAU) || !pBIOS[2]) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to correctly retrieve adapter BIOS.\n"); - xf86FreeInt10(pInt10Info); - xf86UnloadSubModule(pInt10Module); - return FALSE; - } + if (!(flags & PROBE_DETECT)) + { + /* Validate, then make a private copy of, the initialised BIOS */ + CARD8 *pBIOS = xf86int10Addr(pInt10Info, pInt10Info->BIOSseg << 4); - BIOSSize = pBIOS[2] << 9; - (void)memcpy(BIOS, pBIOS, BIOSSize); - if (BIOSSize < SizeOf(BIOS)) - (void)memset(BIOS + BIOSSize, 0, SizeOf(BIOS) - BIOSSize); + if ((pBIOS[0] != 0x55U) || (pBIOS[1] != 0xAAU) || + !pBIOS[2] || (pBIOS[2] > 0x80U)) + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Unable to correctly retrieve adapter BIOS.\n"); + else + { + BIOSSize = pBIOS[2] << 9; + (void)memcpy(BIOS, pBIOS, BIOSSize); + } + } + } /* De-activate int10 */ xf86FreeInt10(pInt10Info); @@ -429,42 +479,33 @@ ATIPreInit if (flags & PROBE_DETECT) { - ConfiguredMonitor = pMonitor; xf86UnloadSubModule(pDDCModule); return TRUE; } - /* Register resources */ - pEntity = xf86GetEntityInfo(pScreenInfo->entityList[0]); - pGDev = pEntity->device; - pResources = pEntity->resources; - xfree(pEntity); - if (!pResources) - pResources = xf86RegisterResources(pATI->iEntity, NULL, - pATI->SharedAccelerator ? ResShared : ResExclusive); - if (pResources) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to register the following bus resources:\n"); - xf86PrintResList(0, pResources); - xf86FreeResList(pResources); - return FALSE; - } - - pScreenInfo->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_VIEWPORT; - pScreenInfo->racMemFlags = RAC_FB; - /* Set monitor */ pScreenInfo->monitor = pScreenInfo->confScreen->monitor; + xf86PrintEDID(ConfiguredMonitor); + xf86SetDDCproperties(pScreenInfo, ConfiguredMonitor); + + /* DDC module is no longer needed at this point */ + xf86UnloadSubModule(pDDCModule); - if (pMonitor) + pATI->Block0Base = 0; /* Might no longer be valid */ + if ((pVideo = pATI->PCIInfo)) { - xf86PrintEDID(pMonitor); - xf86SetDDCproperties(pScreenInfo, pMonitor); + ATIRefreshPCIBases(pVideo, pVideo->thisCard); + + if (pATI->CPIODecoding == BLOCK_IO) + pATI->CPIOBase = pVideo->ioBase[1]; + + /* Set MMIO address from PCI configuration space, if available */ + if ((pATI->Block0Base = pVideo->memBase[2])) + pATI->Block0Base += 0x0400U; } - /* DDC module is no longer needed at this point */ - xf86UnloadSubModule(pDDCModule); + pScreenInfo->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_VIEWPORT; + pScreenInfo->racMemFlags = RAC_FB; /* Deal with ChipID & ChipRev overrides */ if (pGDev->chipID >= 0) @@ -501,19 +542,26 @@ ATIPreInit /* Finish private area initialisation */ pATI->DAC = ATI_DAC_GENERIC; + +#ifndef AVOID_CPIO + pATI->NewHW.SetBank = ATIx8800SetBank; pATI->BankInfo.SetSourceBank = ATIx8800SetRead; pATI->BankInfo.SetDestinationBank = ATIx8800SetWrite; pATI->BankInfo.SetSourceAndDestinationBanks = ATIx8800SetReadWrite; pATI->BankInfo.BankSize = 0x00010000U; /* 64kB */ - pATI->ApertureBase = 0x000A0000U; - pATI->ApertureSize = 0x00010000U; + +#endif /* AVOID_CPIO */ + pATI->LCDPanelID = -1; pATI->nFIFOEntries = 16; /* For now */ /* Finish probing the adapter */ switch (pATI->Adapter) { + +#ifndef AVOID_CPIO + case ATI_ADAPTER_NONE: case ATI_ADAPTER_EGA: case ATI_ADAPTER_EGA_PLUS: @@ -573,25 +621,73 @@ ATIPreInit break; +#endif /* AVOID_CPIO */ + case ATI_ADAPTER_MACH64: - /* Set I/O port addresses */ - pATI->CPIO_CRTC_H_TOTAL_DISP = ATIIOPort(CRTC_H_TOTAL_DISP); - pATI->CPIO_CRTC_H_SYNC_STRT_WID = ATIIOPort(CRTC_H_SYNC_STRT_WID); - pATI->CPIO_CRTC_V_TOTAL_DISP = ATIIOPort(CRTC_V_TOTAL_DISP); - pATI->CPIO_CRTC_V_SYNC_STRT_WID = ATIIOPort(CRTC_V_SYNC_STRT_WID); - pATI->CPIO_CRTC_OFF_PITCH = ATIIOPort(CRTC_OFF_PITCH); - pATI->CPIO_CRTC_INT_CNTL = ATIIOPort(CRTC_INT_CNTL); - pATI->CPIO_CRTC_GEN_CNTL = ATIIOPort(CRTC_GEN_CNTL); - pATI->CPIO_OVR_CLR = ATIIOPort(OVR_CLR); - pATI->CPIO_OVR_WID_LEFT_RIGHT = ATIIOPort(OVR_WID_LEFT_RIGHT); - pATI->CPIO_OVR_WID_TOP_BOTTOM = ATIIOPort(OVR_WID_TOP_BOTTOM); - pATI->CPIO_CLOCK_CNTL = ATIIOPort(CLOCK_CNTL); - pATI->CPIO_MEM_INFO = ATIIOPort(MEM_INFO); - pATI->CPIO_DAC_REGS = ATIIOPort(DAC_REGS); - pATI->CPIO_DAC_CNTL = ATIIOPort(DAC_CNTL); - pATI->CPIO_CONFIG_CNTL = ATIIOPort(CONFIG_CNTL); - - IOValue1 = inl(pATI->CPIO_MEM_INFO); + /* Find and mmap() MMIO area */ + do + { + /* Only allow auxiliary aperture if it exists */ + if (!pATI->Block0Base) + { + if (pVideo) + { + /* Check tail end of linear (8MB or 4MB) aperture */ + if ((pATI->Block0Base = pVideo->memBase[0])) + { + pATI->Block0Base += 0x007FFC00U; + ATIMapMach64(pScreenInfo->scrnIndex, pATI); + if (pATI->pBlock[0]) + break; + + pATI->Block0Base -= 0x00400000U; + ATIMapMach64(pScreenInfo->scrnIndex, pATI); + if (pATI->pBlock[0]) + break; + } + } + + /* Check VGA MMIO aperture */ + pATI->Block0Base = 0x000BFC00U; + } + + ATIMapMach64(pScreenInfo->scrnIndex, pATI); + } while(0); + +#ifdef AVOID_CPIO + + if (!pATI->pBlock[0]) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Unable to mmap() adapter registers.\n"); + return FALSE; + } + +#endif /* AVOID_CPIO */ + + IOValue1 = inr(CRTC_GEN_CNTL); + if (!(IOValue1 & CRTC_EN)) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Adapter has not been initialised.\n"); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } + +#ifdef AVOID_CPIO + + if (!(IOValue1 & CRTC_EXT_DISP_EN)) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Adapters found to be in VGA mode on server entry are not" + " supported by the MMIO-only version of this driver.\n"); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } + +#endif /* AVOID_CPIO */ + + IOValue1 = inr(MEM_CNTL); if (pATI->Chip < ATI_CHIP_264VTB) pATI->VideoRAM = videoRamSizes[GetBits(IOValue1, CTL_MEM_SIZE) + 2]; @@ -609,9 +705,9 @@ ATIPreInit pATI->VideoRAM = (IOValue1 - 7) * 2048; } - pATI->DAC = GetBits(inl(pATI->CPIO_DAC_CNTL), DAC_TYPE); + pATI->DAC = GetBits(inr(DAC_CNTL), DAC_TYPE); - IOValue1 = inl(ATIIOPort(CONFIG_STATUS64_0)); + IOValue1 = inr(CONFIG_STATUS64_0); if (pATI->Chip >= ATI_CHIP_264CT) { pATI->MemoryType = GetBits(IOValue1, CFG_MEM_TYPE_T); @@ -621,12 +717,9 @@ ATIPreInit { pATI->LCDPanelID = GetBits(IOValue1, CFG_PANEL_ID); - pATI->CPIO_HORZ_STRETCHING = ATIIOPort(HORZ_STRETCHING); - pATI->CPIO_VERT_STRETCHING = ATIIOPort(VERT_STRETCHING); - pATI->CPIO_LCD_GEN_CTRL = ATIIOPort(LCD_GEN_CTRL); - pATI->CPIO_POWER_MANAGEMENT = ATIIOPort(POWER_MANAGEMENT); - - IOValue2 = inl(pATI->CPIO_LCD_GEN_CTRL); + IOValue2 = inr(HORZ_STRETCHING); + IOValue3 = inr(VERT_STRETCHING); + IOValue4 = inr(LCD_GEN_CTRL); } else if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || @@ -634,40 +727,42 @@ ATIPreInit { pATI->LCDPanelID = GetBits(IOValue1, CFG_PANEL_ID); - pATI->CPIO_TV_OUT_INDEX = ATIIOPort(TV_OUT_INDEX); - pATI->CPIO_TV_OUT_DATA = ATIIOPort(TV_OUT_DATA); - pATI->CPIO_LCD_INDEX = ATIIOPort(LCD_INDEX); - pATI->CPIO_LCD_DATA = ATIIOPort(LCD_DATA); - - IOValue1 = inl(pATI->CPIO_LCD_INDEX); - IOValue2 = ATIGetLTProLCDReg(LCD_HORZ_STRETCHING); -#if 0 - if (IOValue2 & AUTO_HORZ_RATIO) -#endif - pATI->LCDHorizontal = - (GetBits(IOValue2, HORZ_PANEL_SIZE) + 1) << 3; - IOValue2 = ATIGetLTProLCDReg(LCD_EXT_VERT_STRETCH); -#if 0 - if (IOValue2 & AUTO_VERT_RATIO) -#endif - pATI->LCDVertical = - GetBits(IOValue2, VERT_PANEL_SIZE) + 1; - IOValue2 = ATIGetLTProLCDReg(LCD_GEN_CNTL); - outl(pATI->CPIO_LCD_INDEX, IOValue1); + IOValue1 = inr(LCD_INDEX); + IOValue2 = ATIGetMach64LCDReg(LCD_HORZ_STRETCHING); + pATI->LCDHorizontal = GetBits(IOValue2, HORZ_PANEL_SIZE); + if (pATI->LCDHorizontal) + { + if (pATI->LCDHorizontal == MaxBits(HORZ_PANEL_SIZE)) + pATI->LCDHorizontal = 0; + else + pATI->LCDHorizontal = + (pATI->LCDHorizontal + 1) << 3; + } + IOValue3 = ATIGetMach64LCDReg(LCD_EXT_VERT_STRETCH); + pATI->LCDVertical = GetBits(IOValue3, VERT_PANEL_SIZE); + if (pATI->LCDVertical) + { + if (pATI->LCDVertical == MaxBits(VERT_PANEL_SIZE)) + pATI->LCDVertical = 0; + else + pATI->LCDVertical++; + } + IOValue3 = ATIGetMach64LCDReg(LCD_VERT_STRETCHING); + IOValue4 = ATIGetMach64LCDReg(LCD_GEN_CNTL); + outr(LCD_INDEX, IOValue1); } - if (pATI->LCDPanelID >= 0) - { - /* - * Don't bother with panel support if it's not enabled by - * BIOS initialisation. Also, remember if the BIOS knows - * about the CRT. - */ - if (!(IOValue2 & LCD_ON)) + /* + * Don't bother with panel support if it hasn't been previously + * enabled. + */ + if ((pATI->LCDPanelID >= 0) && + !pATI->LCDHorizontal && + !pATI->LCDVertical && + !(IOValue2 & HORZ_STRETCH_EN) && + !(IOValue3 & VERT_STRETCH_EN) && + !(IOValue4 & LCD_ON)) pATI->LCDPanelID = -1; - else if (!(IOValue2 & CRT_ON)) - AllowCRT = FALSE; - } } else { @@ -675,8 +770,7 @@ ATIPreInit /* Factor in what the BIOS says the DAC is */ pATI->DAC = ATI_DAC(pATI->DAC, - GetBits(inl(ATIIOPort(SCRATCH_REG1)), - BIOS_INIT_DAC_SUBTYPE)); + GetBits(inr(SCRATCH_REG1), BIOS_INIT_DAC_SUBTYPE)); } /* @@ -696,7 +790,13 @@ ATIPreInit * For Mach64 adapters, pick up, from the BIOS, the type of programmable * clock generator (if any), and various information about it. */ + +#ifndef AVOID_CPIO + if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + { CARD16 ClockDac; @@ -724,9 +824,6 @@ ATIPreInit pATI->BIOSClocks[i] = (&BIOSWord(FrequencyTable))[i]; pATI->ProgrammableClock = BIOSByte(ClockTable); pATI->ClockNumberToProgramme = BIOSByte(ClockTable + 0x06U); - if (pATI->ProgrammableClock < ATI_CLOCK_MAX) - pATI->ClockDescriptor = - ATIClockDescriptors[pATI->ProgrammableClock]; switch (BIOSWord(ClockTable + 0x08U) / 10) { case 143: @@ -746,6 +843,45 @@ ATIPreInit break; } } + else + { + /* + * Compensate for BIOS absence. Note that the reference + * frequency will be set later by option processing. + */ + if ((pATI->DAC & 0x0FU) == ATI_DAC_INTERNAL) + pATI->ProgrammableClock = ATI_CLOCK_INTERNAL; + else switch (pATI->DAC) + { + case ATI_DAC_STG1703: + pATI->ProgrammableClock = ATI_CLOCK_STG1703; + break; + + case ATI_DAC_CH8398: + pATI->ProgrammableClock = ATI_CLOCK_CH8398; + break; + + case ATI_DAC_ATT20C408: + pATI->ProgrammableClock = ATI_CLOCK_ATT20C408; + break; + + case ATI_DAC_IBMRGB514: + pATI->ProgrammableClock = ATI_CLOCK_IBMRGB514; + break; + + default: /* Provisional */ + pATI->ProgrammableClock = ATI_CLOCK_ICS2595; + break; + } + + /* This should be safe for all generators except IBM's RGB514 */ + pATI->ClockNumberToProgramme = 3; + } + + if ((pATI->ProgrammableClock > ATI_CLOCK_FIXED) && + (pATI->ProgrammableClock < ATI_CLOCK_MAX)) + pATI->ClockDescriptor = + ATIClockDescriptors[pATI->ProgrammableClock]; ClockDac = pATI->DAC; switch (pATI->ProgrammableClock) @@ -756,8 +892,17 @@ ATIPreInit * revision level. */ if (ClockTable > 0) - pATI->ClockDescriptor.MinM = pATI->ClockDescriptor.MaxM = - BIOSWord(ClockTable + 0x0AU); + pATI->ClockDescriptor.MinM = + pATI->ClockDescriptor.MaxM = + BIOSWord(ClockTable + 0x0AU); + else if (!xf86NameCmp(pGDev->clockchip, "ATI 18818-0")) + pATI->ClockDescriptor.MinM = + pATI->ClockDescriptor.MaxM = 43; + else if (!xf86NameCmp(pGDev->clockchip, "ATI 18818-1")) + pATI->ClockDescriptor.MinM = + pATI->ClockDescriptor.MaxM = 46; + else + pATI->ProgrammableClock = ATI_CLOCK_UNKNOWN; break; case ATI_CLOCK_STG1703: @@ -869,15 +1014,12 @@ ATIPreInit } /* ... verify panel width ... */ - if ((pATI->LCDHorizontal > 8) && - (pATI->LCDHorizontal <= - (int)(MaxBits(HORZ_PANEL_SIZE) << 3)) && + if (pATI->LCDHorizontal && (pATI->LCDHorizontal != BIOSWord(i + 0x19U))) continue; /* ... and verify panel height */ - if ((pATI->LCDVertical > 1) && - (pATI->LCDVertical <= (int)MaxBits(VERT_PANEL_SIZE)) && + if (pATI->LCDVertical && (pATI->LCDVertical != BIOSWord(i + 0x1BU))) continue; @@ -903,42 +1045,17 @@ ATIPreInit if (LCDPanelInfo > 0) { - CARD8 ClockMask, PostMask; - pATI->LCDPanelID = BIOSByte(LCDPanelInfo); pATI->LCDHorizontal = BIOSWord(LCDPanelInfo + 0x19U); pATI->LCDVertical = BIOSWord(LCDPanelInfo + 0x1BU); - - /* Get clock number */ - if (inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN) - i = inl(pATI->CPIO_CLOCK_CNTL) & 0x03U; - else - i = (inb(R_GENMO) & 0x0CU) >> 2; - - /* - * Get post divider. A GCC bug has caused the following - * expression to be broken down into its individual - * components. - */ - ClockMask = PLL_VCLK0_XDIV << i; - PostMask = PLL_VCLK0_POST_DIV << (i * 2); - j = GetBits(ATIGetMach64PLLReg(PLL_XCLK_CNTL), ClockMask); - j *= MaxBits(PLL_VCLK0_POST_DIV) + 1; - j |= GetBits(ATIGetMach64PLLReg(PLL_VCLK_POST_DIV), PostMask); - - /* Calculate clock of mode on entry */ - Numerator = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV + i) * - pATI->ReferenceNumerator; - Denominator = pATI->ClockDescriptor.MinM * - pATI->ReferenceDenominator * - pATI->ClockDescriptor.PostDividers[j]; - pATI->LCDClock = ATIDivide(Numerator, Denominator, 1, 0); } } } ATIUnlock(pATI); /* Unlock registers */ +#ifndef AVOID_CPIO + /* Sometimes, the BIOS lies about the chip */ if ((pATI->Chip >= ATI_CHIP_28800_4) && (pATI->Chip <= ATI_CHIP_28800_6)) { @@ -948,6 +1065,8 @@ ATIPreInit pATI->Chip = IOValue1; } +#endif /* AVOID_CPIO */ + /* Report what was found */ xf86DrvMsg(pScreenInfo->scrnIndex, pATI->Chipset ? X_CONFIG : X_DEFAULT, "Chipset: \"%s\".\n", ATIChipsetNames[pATI->Chipset]); @@ -955,7 +1074,12 @@ ATIPreInit xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s graphics controller detected.\n", ATIChipNames[pATI->Chip]); +#ifndef AVOID_CPIO + if ((pATI->Chip >= ATI_CHIP_68800) && (pATI->Chip != ATI_CHIP_68800_3)) + +#endif /* AVOID_CPIO */ + { Message = Buffer + snprintf(Buffer, SizeOf(Buffer), "Chip type %04X", pATI->ChipType); @@ -977,18 +1101,34 @@ ATIPreInit Buffer, pATI->ChipClass, pATI->ChipRevision); } +#ifndef AVOID_CPIO + if (pATI->Adapter >= ATI_ADAPTER_MACH8) + +#endif /* AVOID_CPIO */ + { Message = Buffer + snprintf(Buffer, SizeOf(Buffer), "%s bus interface detected", ATIBusNames[pATI->BusType]); + +#ifndef AVOID_CPIO + if (pATI->Adapter >= ATI_ADAPTER_MACH64) + +#endif /* AVOID_CPIO */ + + { Message += snprintf(Message, Buffer + SizeOf(Buffer) - Message, "; %s I/O base is 0x%04X", (pATI->CPIODecoding == SPARSE_IO) ? "sparse" : "block", pATI->CPIOBase); + } + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s.\n", Buffer); } +#ifndef AVOID_CPIO + if (pATI->CPIO_VGAWonder) xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "VGA Wonder registers at I/O port 0x%04X.\n", @@ -1000,6 +1140,8 @@ ATIPreInit " memory.\n", ATIChipNames[pATI->Coprocessor], pATI->VideoRAM); +#endif /* AVOID_CPIO */ + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "%s adapter detected.\n", ATIAdapterNames[pATI->Adapter]); @@ -1028,37 +1170,12 @@ ATIPreInit } } - if (pATI->LCDPanelID >= 0) - { - if (LCDPanelInfo <= 0) - { - xf86DrvMsgVerb(pScreenInfo->scrnIndex, X_ERROR, 0, - "Unable to determine dimensions of panel (ID %d).\n", - pATI->LCDPanelID); - ATILock(pATI); - return FALSE; - } - - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "%dx%d panel (ID %d) detected.\n", - pATI->LCDHorizontal, pATI->LCDVertical, pATI->LCDPanelID); - for (i = 0; i < 24; i++) - Buffer[i] = BIOSByte(LCDPanelInfo + 1 + i); - for (i = 24; --i >= 0; ) - if (Buffer[i] != ' ') - { - Buffer[i + 1] = '\0'; - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "Panel model %s.\n", Buffer); - break; - } - xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "Panel clock is %.3f MHz.\n", (double)(pATI->LCDClock) / 1000.0); - } - /* Promote chipset specification */ switch (pATI->Chipset) { + +#ifndef AVOID_CPIO + case ATI_CHIPSET_IBMVGA: if (pATI->Adapter == ATI_ADAPTER_VGA) break; /* XXX */ @@ -1075,6 +1192,9 @@ ATIPreInit case ATI_CHIPSET_MACH8: case ATI_CHIPSET_MACH32: + +#endif /* AVOID_CPIO */ + case ATI_CHIPSET_MACH64: case ATI_CHIPSET_RAGE128: pATI->Chipset = ATI_CHIPSET_ATI; @@ -1093,11 +1213,22 @@ ATIPreInit else i = Support24bppFb | Support32bppFb; if (!xf86SetDepthBpp(pScreenInfo, 8, 8, 8, i)) + { + ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; + } switch (pScreenInfo->depth) { - case 1: case 4: case 8: case 15: case 16: case 24: + +#ifndef AVOID_CPIO + + case 1: case 4: + +#endif /* AVOID_CPIO */ + + case 8: case 15: case 16: case 24: break; default: @@ -1105,6 +1236,7 @@ ATIPreInit "Driver does not support depth %d.\n", pScreenInfo->depth); ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1116,6 +1248,7 @@ ATIPreInit "Depth %d is not supported through this adapter.\n", pScreenInfo->depth); ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1125,6 +1258,19 @@ ATIPreInit ATIProcessOptions(pScreenInfo, pATI); +#ifdef AVOID_CPIO + + if (!pATI->OptionLinear) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "A linear aperture is not available in this configuration.\n"); + ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } + +#endif /* AVOID_CPIO */ + /* * Set colour weights. */ @@ -1137,6 +1283,7 @@ ATIPreInit if (!xf86SetWeight(pScreenInfo, defaultWeight, defaultWeight)) { ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1152,6 +1299,7 @@ ATIPreInit pScreenInfo->weight.red, pScreenInfo->weight.green, pScreenInfo->weight.blue, pScreenInfo->depth); ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1162,6 +1310,7 @@ ATIPreInit if (!xf86SetDefaultVisual(pScreenInfo, -1)) { ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1175,6 +1324,7 @@ ATIPreInit xf86GetVisualName(pScreenInfo->defaultVisual), pScreenInfo->depth); ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1182,10 +1332,19 @@ ATIPreInit * Set colour gamma. */ - if ((pScreenInfo->depth > 1) && !xf86SetGamma(pScreenInfo, defaultGamma)) +#ifndef AVOID_CPIO + + if (pScreenInfo->depth > 1) + +#endif /* AVOID_CPIO */ + { - ATILock(pATI); - return FALSE; + if (!xf86SetGamma(pScreenInfo, defaultGamma)) + { + ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } } pATI->depth = pScreenInfo->depth; @@ -1197,15 +1356,22 @@ ATIPreInit * Determine which CRT controller to use for video modes. */ +#ifndef AVOID_CPIO + if ((pATI->Chip >= ATI_CHIP_88800GXC) && (pATI->depth >= 8) && (pATI->Chipset == ATI_CHIPSET_ATI)) + +#endif /* AVOID_CPIO */ + { pATI->NewHW.crtc = ATI_CRTC_MACH64; xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Using Mach64 accelerator CRTC.\n"); +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { /* @@ -1234,7 +1400,13 @@ ATIPreInit } } } + +#endif /* AVOID_CPIO */ + } + +#ifndef AVOID_CPIO + else { pATI->NewHW.crtc = ATI_CRTC_VGA; @@ -1252,6 +1424,7 @@ ATIPreInit xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "VGA is not available through this adapter.\n"); ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1265,27 +1438,106 @@ ATIPreInit } } +#endif /* AVOID_CPIO */ + /* * Decide between the CRT and the panel. */ if (pATI->LCDPanelID >= 0) { - if (pATI->OptionCRT && AllowCRT) + CARD8 ClockMask, PostMask; + + if (!pATI->LCDHorizontal || !pATI->LCDVertical) + { + if (pATI->LCDPanelID || (pATI->Chip <= ATI_CHIP_264LTPRO)) + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Unable to determine dimensions of panel (ID %d).\n", + pATI->LCDPanelID); + else + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Unable to determine dimensions of panel.\n"); + + ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } + + if (pATI->LCDPanelID || (pATI->Chip <= ATI_CHIP_264LTPRO)) + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, + "%dx%d panel (ID %d) detected.\n", + pATI->LCDHorizontal, pATI->LCDVertical, pATI->LCDPanelID); + else + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, + "%dx%d panel detected.\n", + pATI->LCDHorizontal, pATI->LCDVertical); + + if (LCDPanelInfo) + { + for (i = 0; i < 24; i++) + Buffer[i] = BIOSByte(LCDPanelInfo + 1 + i); + for (; --i >= 0; ) + if (Buffer[i] && Buffer[i] != ' ') + { + Buffer[i + 1] = '\0'; + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, + "Panel model %s.\n", Buffer); + break; + } + } + + /* + * Determine panel clock. This must be done after option processing so + * that the adapter's reference frequency is always available. + */ + +#ifndef AVOID_CPIO + + if (!(pATI->LockData.crtc_gen_cntl & CRTC_EXT_DISP_EN)) + i = (inb(R_GENMO) & 0x0CU) >> 2; + else + +#endif /* AVOID_CPIO */ + + { + i = inr(CLOCK_CNTL) & 0x03U; + } + + /* + * Get post divider. A GCC bug has caused the following expression to + * be broken down into its individual components. + */ + ClockMask = PLL_VCLK0_XDIV << i; + PostMask = PLL_VCLK0_POST_DIV << (i * 2); + j = GetBits(ATIGetMach64PLLReg(PLL_XCLK_CNTL), ClockMask); + j *= MaxBits(PLL_VCLK0_POST_DIV) + 1; + j |= GetBits(ATIGetMach64PLLReg(PLL_VCLK_POST_DIV), PostMask); + + /* Calculate clock of mode on entry */ + Numerator = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV + i) * + pATI->ReferenceNumerator; + Denominator = pATI->ClockDescriptor.MinM * pATI->ReferenceDenominator * + pATI->ClockDescriptor.PostDividers[j]; + pATI->LCDClock = ATIDivide(Numerator, Denominator, 1, 0); + + xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, + "Panel clock is %.3f MHz.\n", (double)(pATI->LCDClock) / 1000.0); + + if (pATI->OptionCRT) xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, "Using CRT interface and disabling digital flat panel.\n"); - else if (pATI->OptionCRT || AllowCRT) - { - pATI->OptionCRT = FALSE; + else xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Using digital flat panel interface.\n"); - } } /* * Finish detecting video RAM size. */ + pScreenInfo->videoRam = pATI->VideoRAM; - AcceleratorVideoRAM = pScreenInfo->videoRam = pATI->VideoRAM; +#ifndef AVOID_CPIO + + AcceleratorVideoRAM = pScreenInfo->videoRam; if (pATI->Chip == ATI_CHIP_VGA) { if (pATI->depth <= 4) @@ -1341,33 +1593,43 @@ ATIPreInit { xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, "Virtual resolutions requiring more than %s kB\n of video" - " memory might not function properly." ATI_README, + " memory might not function properly.\n", (pATI->depth == 1) ? "64" : "256"); } else { xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "VideoRAM reduced to 256 kB due to hardware limitations." - ATI_README); + "VideoRAM reduced to 256 kB due to hardware" + " limitations.\n"); pScreenInfo->videoRam = 256; } } } else if ((pATI->NewHW.crtc == ATI_CRTC_MACH64) || (pATI->Chip >= ATI_CHIP_264CT)) + +#endif /* AVOID_CPIO */ + { + +#ifndef AVOID_CPIO + if (pATI->depth >= 8) - { - /* Set MMIO address from PCI configuration space, if available */ - if (pATI->PCIInfo && - (pATI->Block0Base = pATI->PCIInfo->memBase[2])) - pATI->Block0Base += 0x0400U; +#endif /* AVOID_CPIO */ + + { /* Possibly set up for linear aperture */ + +#ifndef AVOID_CPIO + if (pATI->OptionLinear) + +#endif /* AVOID_CPIO */ + { /* Get adapter's linear aperture configuration */ - IOValue1 = inl(pATI->CPIO_CONFIG_CNTL); + IOValue1 = inr(CONFIG_CNTL); pATI->LinearBase = GetBits(IOValue1, CFG_MEM_AP_LOC) << 22; if ((IOValue1 & CFG_MEM_AP_SIZE) != CFG_MEM_AP_SIZE) { @@ -1387,9 +1649,10 @@ ATIPreInit } } +#ifndef AVOID_CPIO + /* Except for PCI & AGP, allow for user override */ - if ((pATI->BusType != ATI_BUS_PCI) && - (pATI->BusType != ATI_BUS_AGP)) + if (pATI->BusType < ATI_BUS_PCI) { if (pATI->Chip == ATI_CHIP_88800CX) IOValue2 = ~((unsigned long)((1 << 23) - 1)); @@ -1433,19 +1696,33 @@ ATIPreInit } } +#endif /* AVOID_CPIO */ + if (!pATI->LinearBase || !pATI->LinearSize) { + +#ifndef AVOID_CPIO + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + +#endif /* AVOID_CPIO */ + { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "A linear aperture is not available through this" " adapter.\n"); ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } +#ifndef AVOID_CPIO + /* Insurance */ pATI->LinearBase = pATI->LinearSize = 0; + +#endif /* AVOID_CPIO */ + } else { @@ -1457,37 +1734,32 @@ ATIPreInit pATI->Block0Base = pATI->LinearBase + pATI->LinearSize - 0x00000400U; - AcceleratorVideoRAM = (pATI->LinearSize >> 10) - 2; /* 4? */ + AcceleratorVideoRAM = pATI->LinearSize >> 10; + +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + + /* Account for MMIO area, if it cannot be disabled */ + if (pATI->Chip < ATI_CHIP_264VTB) + { + AcceleratorVideoRAM--; + if (pATI->Chip >= ATI_CHIP_264VT) + AcceleratorVideoRAM--; + } + +#else /* if X_BYTE_ORDER == X_BIG_ENDIAN */ + + /* Big-endian aperture is 8 MB higher */ + pATI->LinearBase += 0x00800000U; + +#endif /* X_BYTE_ORDER */ + if (AcceleratorVideoRAM < pATI->VideoRAM) { - if (pATI->Chip < ATI_CHIP_264VTB) - { - /* - * Don't allow virtual resolution to overlay - * register aperture(s). - */ - pScreenInfo->videoRam = AcceleratorVideoRAM; - xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "Virtual resolutions will be limited to %d kB" - " to account for\n accelerator register" - " aperture.\n", - AcceleratorVideoRAM); - } - else - { - /* - * On VTB's and later, ATIInit disables the primary - * register aperture. This is done so the driver - * can get at the frame buffer memory behind it. - * For MMIO purposes, the auxillary register - * aperture will be used instead. Also, ignore the - * CONFIG_CNTL register's indication of linear - * aperture size, as it is insufficient for - * adapters with more than 8MB of video memory. - */ - if (pATI->VideoRAM > (8 * 1024)) - pATI->LinearSize = 16 * 1024 * 1024; - } + pScreenInfo->videoRam = AcceleratorVideoRAM; + xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, + "Virtual resolutions will be limited to %d kB due" + " to linear aperture size.\n", + AcceleratorVideoRAM); } xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, @@ -1495,21 +1767,18 @@ ATIPreInit pATI->LinearSize >> 20, pATI->LinearBase); /* Only mmap what is needed */ - pATI->ApertureSize = pATI->LinearSize = - pATI->VideoRAM * 1024; + ApertureSize = pATI->LinearSize = pATI->VideoRAM * 1024; } } } +#ifndef AVOID_CPIO + /* Set up for a banked aperture */ if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { pATI->UseSmallApertures = TRUE; - /* Set banking port numbers */ - pATI->CPIO_MEM_VGA_RP_SEL = ATIIOPort(MEM_VGA_RP_SEL); - pATI->CPIO_MEM_VGA_WP_SEL = ATIIOPort(MEM_VGA_WP_SEL); - /* Set banking functions */ if (pATI->depth <= 4) { @@ -1540,11 +1809,10 @@ ATIPreInit pATI->Block0Base = 0x000BFC00U; } +#endif /* AVOID_CPIO */ + if (pATI->Block0Base) { - pATI->PageSize = getpagesize(); - pATI->MMIOBase = pATI->Block0Base & ~(pATI->PageSize - 1); - xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Using Block 0 MMIO aperture at 0x%08X.\n", pATI->Block0Base); @@ -1558,12 +1826,15 @@ ATIPreInit } } } + +#ifndef AVOID_CPIO + else /* * After BIOS initialisation, the accelerator (if any) and the VGA won't * necessarily agree on the amount of video memory, depending on whether or * where the memory boundary is configured. Any discrepancy will be - * resolved by ATIInit. + * resolved by ATIAdapterPreInit(). * * However, it's possible that there is more video memory than VGA Wonder * can architecturally handle. @@ -1584,8 +1855,8 @@ ATIPreInit else { xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE, - "VideoRAM reduced to %d kB due to hardware limitations." - ATI_README, AcceleratorVideoRAM); + "VideoRAM reduced to %d kB due to hardware limitations.\n", + AcceleratorVideoRAM); pScreenInfo->videoRam = AcceleratorVideoRAM; } @@ -1620,8 +1891,24 @@ ATIPreInit } } +#endif /* AVOID_CPIO */ + + /* + * Remap apertures. Must lock and re-unlock around this in case the + * remapping fails. + */ + ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI)) + return FALSE; + + ATIUnlock(pATI); + if (pATI->OptionAccel) { + +#ifndef AVOID_CPIO + if (!pATI->Block0Base || (pATI->NewHW.crtc == ATI_CRTC_VGA)) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, @@ -1629,12 +1916,22 @@ ATIPreInit pATI->OptionAccel = FALSE; } else + +#endif /* AVOID_CPIO */ + + { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "MMIO write caching %sabled.\n", pATI->OptionMMIOCache ? "en" : "dis"); + } } +#ifndef AVOID_CPIO + if (pATI->Adapter >= ATI_ADAPTER_MACH32) + +#endif /* AVOID_CPIO */ + { if (pATI->Chip >= ATI_CHIP_264CT) ATIReportMemory(pScreenInfo, pATI, @@ -1646,22 +1943,42 @@ ATIPreInit ATIReportMemory(pScreenInfo, pATI, ATIMemoryTypeNames_Mach[pATI->MemoryType]); } + +#ifndef AVOID_CPIO + else if (pATI->Adapter >= ATI_ADAPTER_V3) ATIReportMemory(pScreenInfo, pATI, (ATIGetExtReg(0xB7U) & 0x04U) ? "DRAM" : "VRAM"); else ATIReportMemory(pScreenInfo, pATI, "video memory"); +#endif /* AVOID_CPIO */ + /* * Finish banking setup. This needs to be fixed to not assume the mode on * entry is a VGA mode. XXX */ + +#ifndef AVOID_CPIO + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + +#endif /* AVOID_CPIO */ + { pATI->OldHW.crtc = pATI->NewHW.crtc; + +#ifndef AVOID_CPIO + pATI->OldHW.SetBank = (ATIBankProcPtr)NoopDDA; pATI->BankInfo.BankSize = 0; /* No banking */ + +#endif /* AVOID_CPIO */ + } + +#ifndef AVOID_CPIO + else { pATI->OldHW.crtc = ATI_CRTC_VGA; @@ -1672,7 +1989,7 @@ ATIPreInit else #endif if ((pATI->Chip >= ATI_CHIP_88800GXC) && - (inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN)) + (pATI->LockData.crtc_gen_cntl & CRTC_EXT_DISP_EN)) pATI->OldHW.crtc = ATI_CRTC_MACH64; if (pATI->depth <= 4) @@ -1706,7 +2023,7 @@ ATIPreInit else if (!pATI->UseSmallApertures) pATI->OldHW.SetBank = pATI->NewHW.SetBank; else if ((pATI->OldHW.crtc == ATI_CRTC_VGA) && - !(inl(pATI->CPIO_CONFIG_CNTL) & CFG_MEM_VGA_AP_EN)) + !(pATI->LockData.config_cntl & CFG_MEM_VGA_AP_EN)) { pATI->OldHW.SetBank = (ATIBankProcPtr)NoopDDA; pATI->OldHW.nBank = 1; @@ -1716,15 +2033,19 @@ ATIPreInit else pATI->OldHW.SetBank = ATIMach64SetBankPlanar; - if (((pATI->ApertureSize * pATI->depth) / - pATI->BankInfo.nBankDepth) >= + if (((ApertureSize * pATI->depth) / pATI->BankInfo.nBankDepth) >= (unsigned)(pScreenInfo->videoRam * 1024)) pATI->BankInfo.BankSize = 0; /* No banking */ } +#endif /* AVOID_CPIO */ + if (pATI->OptionShadowFB) { /* Until ShadowFB becomes a true screen wrapper... */ + +#ifndef AVOID_CPIO + if (pATI->BankInfo.BankSize) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, @@ -1737,7 +2058,11 @@ ATIPreInit "Cannot shadow a planar frame buffer.\n"); pATI->OptionShadowFB = FALSE; } - else if (pATI->OptionAccel) + else + +#endif /* AVOID_CPIO */ + + if (pATI->OptionAccel) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Cannot shadow an accelerated frame buffer.\n"); @@ -1749,10 +2074,11 @@ ATIPreInit } /* 264VT-B's and later have DSP registers */ - if ((pATI->Chip >= ATI_CHIP_264VTB) && (pATI->CPIODecoding == BLOCK_IO) && - !ATIDSPPreInit(pScreenInfo, pATI)) + if ((pATI->Chip >= ATI_CHIP_264VTB) && + !ATIDSPPreInit(pScreenInfo->scrnIndex, pATI)) { ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -1794,12 +2120,24 @@ ATIPreInit Denominator = pATI->ClockDescriptor.MinM * pATI->XCLKReferenceDivider * pATI->ReferenceDenominator; +#ifndef AVOID_CPIO + if (pATI->depth >= 8) + +#endif /* AVOID_CPIO */ + + { Denominator *= pATI->bitsPerPixel / 4; + } + + i = (6 - 2) - pATI->XCLKPostDivider; - i = (5 - 2) - pATI->XCLKPostDivider; - if (pATI->NewHW.crtc != ATI_CRTC_VGA) - i++; +#ifndef AVOID_CPIO + + if (pATI->NewHW.crtc == ATI_CRTC_VGA) + i--; + +#endif /* AVOID_CPIO */ i = (ATIDivide(Numerator, Denominator, i, -1) / 1000) * 1000; if (i < ATIClockRange.maxClock) @@ -1869,6 +2207,9 @@ ATIPreInit break; default: + +#ifndef AVOID_CPIO + /* * 80 MHz is too high in some cases. Limit 18800-x's to 40 MHz. * Don't exceed the memory clock on VGA Wonder capables with less @@ -1883,7 +2224,13 @@ ATIPreInit ATIClockRange.maxClock = (GetBits(BIOSByte(0x44U), 0x04U) * 5000) + 40000; else + +#endif /* AVOID_CPIO */ + + { ATIClockRange.maxClock = 80000; + } + break; } if (pATI->ClockDescriptor.MaxN <= 0) @@ -1891,22 +2238,25 @@ ATIPreInit "Maximum pixel clock: %.3f MHz.\n", (double)ATIClockRange.maxClock / 1000.0); - /* Map MMIO areas */ - if (!ATIMapApertures(pScreenInfo, pATI)) - return FALSE; - /* * Determine available pixel clock frequencies. */ ATIClockPreInit(pScreenInfo, pATI, pGDev, &ATIClockRange); - if (pATI->ProgrammableClock != ATI_CLOCK_FIXED) + if (pATI->ProgrammableClock > ATI_CLOCK_FIXED) Strategy = LOOKUP_BEST_REFRESH; /* * Mode validation. */ +#ifdef AVOID_CPIO + + if (pATI->Chip >= ATI_CHIP_264CT) + minPitch = 8; + +#else /* AVOID_CPIO */ + if ((pATI->depth >= 8) && (pATI->Chip >= ATI_CHIP_264CT)) minPitch = 8; else if (pATI->CPIO_VGAWonder && @@ -1917,15 +2267,29 @@ ATIPreInit minPitch = 32; /* Very strange, but true */ maxPitch = 0x3FU; } + +#endif /* AVOID_CPIO */ + else minPitch = 16; pATI->pitchInc = minPitch; + +#ifndef AVOID_CPIO + if (pATI->depth >= 8) + +#endif /* AVOID_CPIO */ + + { pATI->pitchInc *= pATI->bitsPerPixel; + } switch (pATI->NewHW.crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: /* * IBM's VGA doesn't allow for interlaced modes. @@ -1967,6 +2331,8 @@ ATIPreInit break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: pScreenInfo->maxHValue = (MaxBits(CRTC_H_TOTAL) + 1) << 3; @@ -2077,11 +2443,11 @@ ATIPreInit &ATIClockRange, NULL, minPitch, maxPitch, pATI->pitchInc, 0, maxHeight, pScreenInfo->display->virtualX, pScreenInfo->display->virtualY, - pATI->ApertureSize, Strategy); + ApertureSize, Strategy); if (i <= 0) { - ATIUnmapApertures(pScreenInfo, pATI); ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } @@ -2101,8 +2467,8 @@ ATIPreInit /* Load required modules */ if (!ATILoadModules(pScreenInfo, pATI)) { - ATIUnmapApertures(pScreenInfo, pATI); ATILock(pATI); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); return FALSE; } #endif @@ -2138,7 +2504,6 @@ ATIPreInit ATIAdapterPreInit(pScreenInfo, pATI, &pATI->NewHW); /* Relock registers */ - ATIUnmapApertures(pScreenInfo, pATI); ATILock(pATI); if (!pScreenInfo->chipset || !*pScreenInfo->chipset) @@ -2147,10 +2512,13 @@ ATIPreInit /* Generate noise if requested */ if (xf86GetVerbosity() > 3) { - ATIPrintBIOS(BIOS, 0, BIOSSize); + if (BIOSSize > 0) + ATIPrintBIOS(BIOS, 0, BIOSSize); xf86ErrorFVerb(4, "\n On server entry:\n"); ATIPrintRegisters(pATI); } + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return TRUE; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h index d15d45a93..de23e9435 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h,v 1.2 2000/02/18 12:19:30 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.h,v 1.3 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #define ___ATIPREINIT_H___ 1 #include "atiproto.h" + #include "xf86str.h" extern Bool ATIPreInit FunctionPrototype((ScrnInfoPtr, int)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c index d00909198..da308550a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c,v 1.13 2000/06/19 15:00:58 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c,v 1.14 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #include "atiadapter.h" #include "atichip.h" #include "atidac.h" +#include "atimach64io.h" #include "atiprint.h" /* @@ -82,6 +83,8 @@ ATIPrintBIOS xf86ErrorFVerb(5, " |%s|\n", Printable); } +#ifndef AVOID_CPIO + /* * ATIPrintIndexedRegisters -- * @@ -100,7 +103,7 @@ ATIPrintIndexedRegisters { int Index; - xf86ErrorFVerb(4, "\n\n %s register values:", Name); + xf86ErrorFVerb(4, "\n %s register values:", Name); for (Index = StartIndex; Index < EndIndex; Index++) { if (!(Index & (4U - 1U))) @@ -119,8 +122,12 @@ ATIPrintIndexedRegisters (void)inb(GenS1); /* Reset flip-flop */ outb(ATTRX, 0x20U); /* Turn on PAS bit */ } + + xf86ErrorFVerb(4, "\n"); } +#endif /* AVOID_CPIO */ + /* * ATIPrintMach64Registers -- * @@ -135,47 +142,102 @@ ATIPrintMach64Registers const char *Description ) { - int Index, Step, Limit; CARD32 IOValue; CARD8 dac_read, dac_mask, dac_data, dac_write; + int Index, Limit; + +#ifndef AVOID_CPIO + + int Step; + +#endif /* AVOID_CPIO */ + + xf86ErrorFVerb(4, "\n Mach64 %s register values:", Description); + +#ifdef AVOID_CPIO + + if (pATI->Chip < ATI_CHIP_264VT) + Limit = MM_IO_SELECT; + else + Limit = DWORD_SELECT; + + for (Index = 0; Index <= Limit; Index += UnitOf(MM_IO_SELECT)) + { + if (!(Index & SetBits(3, MM_IO_SELECT))) + xf86ErrorFVerb(4, "\n 0x%04X: ", Index); + if (Index == (DAC_REGS & DWORD_SELECT)) + { + dac_read = in8(DAC_REGS + 3); + DACDelay; + dac_mask = in8(DAC_REGS + 2); + DACDelay; + dac_data = in8(DAC_REGS + 1); + DACDelay; + dac_write = in8(DAC_REGS + 0); + DACDelay; + + xf86ErrorFVerb(4, " %02X%02X%02X%02X", + dac_read, dac_mask, dac_data, dac_write); + + out8(DAC_REGS + 2, dac_mask); + DACDelay; + out8(DAC_REGS + 3, dac_read); + DACDelay; + } + else + { + IOValue = inm(Index); + + if ((Index == (CRTC_GEN_CNTL & DWORD_SELECT)) && + (IOValue & CRTC_EXT_DISP_EN)) + *crtc = ATI_CRTC_MACH64; + + xf86ErrorFVerb(4, " %08X", IOValue); + } + } + +#else /* AVOID_CPIO */ - xf86ErrorFVerb(4, "\n\n Mach64 %s register values:", Description); Limit = ATIIOPort(IOPortTag(0x1FU, 0x3FU)); Step = ATIIOPort(IOPortTag(0x01U, 0x01U)) - pATI->CPIOBase; for (Index = pATI->CPIOBase; Index <= Limit; Index += Step) { if (!(((Index - pATI->CPIOBase) / Step) & 0x03U)) xf86ErrorFVerb(4, "\n 0x%04X: ", Index); - if (Index == pATI->CPIO_DAC_REGS) + if (Index == (int)ATIIOPort(DAC_REGS)) { - dac_read = inb(pATI->CPIO_DAC_REGS + 3); + dac_read = in8(DAC_REGS + 3); DACDelay; - dac_mask = inb(pATI->CPIO_DAC_REGS + 2); + dac_mask = in8(DAC_REGS + 2); DACDelay; - dac_data = inb(pATI->CPIO_DAC_REGS + 1); + dac_data = in8(DAC_REGS + 1); DACDelay; - dac_write = inb(pATI->CPIO_DAC_REGS); + dac_write = in8(DAC_REGS + 0); DACDelay; xf86ErrorFVerb(4, " %02X%02X%02X%02X", dac_read, dac_mask, dac_data, dac_write); - outb(pATI->CPIO_DAC_REGS + 2, dac_mask); + out8(DAC_REGS + 2, dac_mask); DACDelay; - outb(pATI->CPIO_DAC_REGS + 3, dac_read); + out8(DAC_REGS + 3, dac_read); DACDelay; } else { IOValue = inl(Index); - if ((Index == pATI->CPIO_CRTC_GEN_CNTL) && + if ((Index == (int)ATIIOPort(CRTC_GEN_CNTL)) && (IOValue & CRTC_EXT_DISP_EN)) *crtc = ATI_CRTC_MACH64; xf86ErrorFVerb(4, " %08X", IOValue); } } + +#endif /* AVOID_CPIO */ + + xf86ErrorFVerb(4, "\n"); } /* @@ -190,10 +252,22 @@ ATIPrintMach64PLLRegisters ATIPtr pATI ) { - int Index; - - xf86ErrorFVerb(4, "\n\n Mach64 PLL register values:"); - for (Index = 0; Index < 64; Index++) + int Index, Limit; + CARD8 PLLReg[MaxBits(PLL_ADDR) + 1]; + + for (Limit = 0; Limit < SizeOf(PLLReg); Limit++) + PLLReg[Limit] = ATIGetMach64PLLReg(Limit); + + /* Determine how many PLL registers there really are */ + while ((Limit = Limit >> 1)) + for (Index = 0; Index < Limit; Index++) + if (PLLReg[Index] != PLLReg[Index + Limit]) + goto FoundLimit; +FoundLimit: + Limit <<= 1; + + xf86ErrorFVerb(4, "\n Mach64 PLL register values:"); + for (Index = 0; Index < Limit; Index++) { if (!(Index & 3)) { @@ -201,8 +275,10 @@ ATIPrintMach64PLLRegisters xf86ErrorFVerb(4, "\n 0x%02X: ", Index); xf86ErrorFVerb(4, " "); } - xf86ErrorFVerb(4, "%02X", ATIGetMach64PLLReg(Index)); + xf86ErrorFVerb(4, "%02X", PLLReg[Index]); } + + xf86ErrorFVerb(4, "\n"); } /* @@ -220,9 +296,14 @@ ATIPrintRegisters pciConfigPtr pPCI; int Index; CARD32 lcd_index, tv_out_index, lcd_gen_ctrl; - CARD8 genmo, seq1 = 0; CARD8 dac_read, dac_mask, dac_write; - CARD8 crtc = ATI_CRTC_VGA; + CARD8 crtc; + +#ifndef AVOID_CPIO + + CARD8 genmo, seq1 = 0; + + crtc = ATI_CRTC_VGA; if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { @@ -233,39 +314,37 @@ ATIPrintRegisters { if (pATI->Chip == ATI_CHIP_264LT) { - lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + lcd_gen_ctrl = inr(LCD_GEN_CTRL); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, "Non-shadow colour CRT controller", 0); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, "Shadow colour CRT controller", 0); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); } else if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + lcd_index = inr(LCD_INDEX); + lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, "Non-shadow colour CRT controller", 0); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, "Shadow colour CRT controller", 0); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); - outl(pATI->CPIO_LCD_INDEX, lcd_index); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + outr(LCD_INDEX, lcd_index); } else ATIPrintIndexedRegisters(CRTX(ColourIOBase), 0, 64, @@ -277,39 +356,37 @@ ATIPrintRegisters { if (pATI->Chip == ATI_CHIP_264LT) { - lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + lcd_gen_ctrl = inr(LCD_GEN_CTRL); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, "Non-shadow monochrome CRT controller", 0); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, "Shadow monochrome CRT controller", 0); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); } else if ((pATI->Chip == ATI_CHIP_264LTPRO) || (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + lcd_index = inr(LCD_INDEX); + lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl & ~(SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, "Non-shadow monochrome CRT controller", 0); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, "Shadow monochrome CRT controller", 0); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); - outl(pATI->CPIO_LCD_INDEX, lcd_index); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + outr(LCD_INDEX, lcd_index); } else ATIPrintIndexedRegisters(CRTX(MonochromeIOBase), 0, 64, @@ -329,7 +406,7 @@ ATIPrintRegisters if (pATI->ChipHasSUBSYS_CNTL) { - xf86ErrorFVerb(4, "\n\n 8514/A register values:"); + xf86ErrorFVerb(4, "\n 8514/A register values:"); for (Index = 0x02E8U; Index <= 0x0FEE8; Index += 0x0400U) { if (!((Index - 0x02E8U) & 0x0C00U)) @@ -347,20 +424,26 @@ ATIPrintRegisters xf86ErrorFVerb(4, " %04X", inw(Index)); } } + + xf86ErrorFVerb(4, "\n"); } - else if (pATI->Chip == ATI_CHIP_264LT) + else + +#endif /* AVOID_CPIO */ + + if (pATI->Chip == ATI_CHIP_264LT) { - lcd_gen_ctrl = inl(pATI->CPIO_LCD_GEN_CTRL); + lcd_gen_ctrl = inr(LCD_GEN_CTRL); - outl(pATI->CPIO_LCD_GEN_CTRL, - lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, lcd_gen_ctrl & + ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); ATIPrintMach64Registers(pATI, &crtc, "non-shadow"); - outl(pATI->CPIO_LCD_GEN_CTRL, - (lcd_gen_ctrl & ~CRTC_RW_SELECT) | (SHADOW_EN | SHADOW_RW_EN)); + outr(LCD_GEN_CTRL, (lcd_gen_ctrl & ~CRTC_RW_SELECT) | + (SHADOW_EN | SHADOW_RW_EN)); ATIPrintMach64Registers(pATI, &crtc, "shadow"); - outl(pATI->CPIO_LCD_GEN_CTRL, lcd_gen_ctrl); + outr(LCD_GEN_CTRL, lcd_gen_ctrl); ATIPrintMach64PLLRegisters(pATI); } @@ -368,55 +451,113 @@ ATIPrintRegisters (pATI->Chip == ATI_CHIP_264XL) || (pATI->Chip == ATI_CHIP_MOBILITY)) { - lcd_index = inl(pATI->CPIO_LCD_INDEX); - lcd_gen_ctrl = ATIGetLTProLCDReg(LCD_GEN_CNTL); + lcd_index = inr(LCD_INDEX); + lcd_gen_ctrl = ATIGetMach64LCDReg(LCD_GEN_CNTL); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl & ~(CRTC_RW_SELECT | SHADOW_EN | SHADOW_RW_EN)); ATIPrintMach64Registers(pATI, &crtc, "non-shadow"); - ATIPutLTProLCDReg(LCD_GEN_CNTL, + ATIPutMach64LCDReg(LCD_GEN_CNTL, (lcd_gen_ctrl & ~CRTC_RW_SELECT) | (SHADOW_EN | SHADOW_RW_EN)); ATIPrintMach64Registers(pATI, &crtc, "shadow"); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl | CRTC_RW_SELECT); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl | CRTC_RW_SELECT); ATIPrintMach64Registers(pATI, &crtc, "secondary"); - ATIPutLTProLCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); + ATIPutMach64LCDReg(LCD_GEN_CNTL, lcd_gen_ctrl); ATIPrintMach64PLLRegisters(pATI); - xf86ErrorFVerb(4, "\n\n LCD register values:"); + xf86ErrorFVerb(4, "\n LCD register values:"); for (Index = 0; Index < 64; Index++) { if (!(Index & 3)) xf86ErrorFVerb(4, "\n 0x%02X: ", Index); - xf86ErrorFVerb(4, " %08X", ATIGetLTProLCDReg(Index)); + xf86ErrorFVerb(4, " %08X", ATIGetMach64LCDReg(Index)); } - outl(pATI->CPIO_LCD_INDEX, lcd_index); + outr(LCD_INDEX, lcd_index); - tv_out_index = inl(pATI->CPIO_TV_OUT_INDEX); + tv_out_index = inr(TV_OUT_INDEX); xf86ErrorFVerb(4, "\n\n TV_OUT register values:"); for (Index = 0; Index < 256; Index++) { if (!(Index & 3)) xf86ErrorFVerb(4, "\n 0x%02X: ", Index); - xf86ErrorFVerb(4, " %08X", ATIGetLTProTVReg(Index)); + xf86ErrorFVerb(4, " %08X", ATIGetMach64TVReg(Index)); } - outl(pATI->CPIO_TV_OUT_INDEX, tv_out_index); + outr(TV_OUT_INDEX, tv_out_index); + + xf86ErrorFVerb(4, "\n"); } - else if (pATI->Chip >= ATI_CHIP_88800GXC) + else + +#ifndef AVOID_CPIO + + if (pATI->Chip >= ATI_CHIP_88800GXC) + +#endif /* AVOID_CPIO */ + { + +#ifdef AVOID_CPIO + + ATIPrintMach64Registers(pATI, &crtc, "MMIO"); + +#else /* AVOID_CPIO */ + ATIPrintMach64Registers(pATI, &crtc, (pATI->CPIODecoding == SPARSE_IO) ? "sparse" : "block"); +#endif /* AVOID_CPIO */ + if (pATI->Chip >= ATI_CHIP_264CT) ATIPrintMach64PLLRegisters(pATI); } +#ifdef AVOID_CPIO + + dac_read = in8(M64_DAC_READ); + DACDelay; + dac_write = in8(M64_DAC_WRITE); + DACDelay; + dac_mask = in8(M64_DAC_MASK); + DACDelay; + + xf86ErrorFVerb(4, "\n" + " DAC read index: 0x%02X\n" + " DAC write index: 0x%02X\n" + " DAC mask: 0x%02X\n\n" + " DAC colour lookup table:", + dac_read, dac_write, dac_mask); + + out8(M64_DAC_MASK, 0xFFU); + DACDelay; + out8(M64_DAC_READ, 0x00U); + DACDelay; + + for (Index = 0; Index < 256; Index++) + { + if (!(Index & 3)) + xf86ErrorFVerb(4, "\n 0x%02X:", Index); + xf86ErrorFVerb(4, " %02X", in8(M64_DAC_DATA)); + DACDelay; + xf86ErrorFVerb(4, " %02X", in8(M64_DAC_DATA)); + DACDelay; + xf86ErrorFVerb(4, " %02X", in8(M64_DAC_DATA)); + DACDelay; + } + + out8(M64_DAC_MASK, dac_mask); + DACDelay; + out8(M64_DAC_READ, dac_read); + DACDelay; + +#else /* AVOID_CPIO */ + ATISetDACIOPorts(pATI, crtc); /* Temporarily turn off CLKDIV2 while reading DAC's LUT */ @@ -434,7 +575,7 @@ ATIPrintRegisters dac_mask = inb(pATI->CPIO_DAC_MASK); DACDelay; - xf86ErrorFVerb(4, "\n\n" + xf86ErrorFVerb(4, "\n" " DAC read index: 0x%02X\n" " DAC write index: 0x%02X\n" " DAC mask: 0x%02X\n\n" @@ -466,9 +607,11 @@ ATIPrintRegisters if ((pATI->Adapter == ATI_ADAPTER_NONISA) && (seq1 & 0x08U)) PutReg(SEQX, 0x01U, seq1); +#endif /* AVOID_CPIO */ + if ((pVideo = pATI->PCIInfo)) { - pPCI = (pciConfigPtr)(pVideo->thisCard); + pPCI = pVideo->thisCard; xf86ErrorFVerb(4, "\n\n PCI configuration register values:"); for (Index = 0; Index < 256; Index+= 4) { @@ -478,21 +621,30 @@ ATIPrintRegisters } } + xf86ErrorFVerb(4, "\n"); + +#ifndef AVOID_CPIO + if (pATI->pBank) - xf86ErrorFVerb(4, "\n\n Banked aperture at 0x%08X.\n", + xf86ErrorFVerb(4, "\n Banked aperture at 0x%08X.", pATI->pBank); else - xf86ErrorFVerb(4, "\n\n No banked aperture.\n"); + xf86ErrorFVerb(4, "\n No banked aperture."); - if (pATI->pMemory != pATI->pBank) - xf86ErrorFVerb(4, " Linear aperture at 0x%08X.\n", pATI->pMemory); + if (pATI->pMemory == pATI->pBank) + xf86ErrorFVerb(4, "\n No linear aperture.\n"); else - xf86ErrorFVerb(4, " No linear aperture.\n"); + +#endif /* AVOID_CPIO */ + + { + xf86ErrorFVerb(4, "\n Linear aperture at 0x%08X.\n", pATI->pMemory); + } if (pATI->pBlock[0]) { xf86ErrorFVerb(4, " Block 0 aperture at 0x%08X.\n", pATI->pBlock[0]); - if (inl(pATI->CPIOBase) == MMIO_IN32(pATI->pBlock[0], 0)) + if (inr(CONFIG_CHIP_ID) == pATI->config_chip_id) xf86ErrorFVerb(4, " MMIO registers are correctly mapped.\n"); else xf86ErrorFVerb(4, " MMIO mapping is in error!\n"); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h index ce6c40273..cb0067377 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h,v 1.5 2000/04/20 21:28:31 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h,v 1.6 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" extern void ATIPrintBIOS FunctionPrototype((const CARD8 *, diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c index b8228f2f5..527b780f7 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.22 2000/06/19 15:00:58 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.25 2000/08/11 16:50:33 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -29,12 +29,13 @@ #include "atichip.h" #include "aticonsole.h" #include "atiident.h" -#include "atiio.h" +#include "atimach64io.h" #include "atipreinit.h" #include "atiprobe.h" #include "atiscreen.h" #include "ativalid.h" #include "ativersion.h" +#include "atividmem.h" /* * NOTES: @@ -51,6 +52,19 @@ */ /* + * An internal structure definition to facilitate the matching of detected + * adapters to XF86Config Device sections. + */ +typedef struct _ATIGDev +{ + GDevPtr pGDev; + int iATIPtr; + CARD8 Chipset; +} ATIGDev, *ATIGDevPtr; + +#ifndef AVOID_CPIO + +/* * Definitions for I/O conflict avoidance. */ #define LongPort(_Port) GetBits((_Port), PCIGETIO(SPARSE_IO_BASE)) @@ -67,17 +81,6 @@ typedef struct } PortRec, *PortPtr; /* - * An internal structure definition to facilitate the matching of detected - * adapters to XF86Config Device sections. - */ -typedef struct _ATIGDev -{ - GDevPtr pGDev; - int iATIPtr; - CARD8 Chipset; -} ATIGDev, *ATIGDevPtr; - -/* * ATIScanPCIBases -- * * This function loops though a device's PCI registered bases and accumulates @@ -139,33 +142,39 @@ ATIScanPCIBases static CARD8 ATICheckSparseIOBases ( + pciVideoPtr pVideo, CARD8 *ProbeFlags, const CARD16 IOBase, const int Count, const Bool Override ) { - CARD32 FirstPort = LongPort(IOBase), - LastPort = LongPort(IOBase + Count - 1); + CARD32 FirstPort, LastPort; - for (; FirstPort <= LastPort; FirstPort++) + if (!pVideo || !xf86IsPrimaryPci(pVideo)) { - CARD8 ProbeFlag = ProbeFlags[FirstPort]; + FirstPort = LongPort(IOBase); + LastPort = LongPort(IOBase + Count - 1); - if (ProbeFlag & DoProbe) - continue; + for (; FirstPort <= LastPort; FirstPort++) + { + CARD8 ProbeFlag = ProbeFlags[FirstPort]; - if (!(ProbeFlag & Allowed)) - return ProbeFlag; + if (ProbeFlag & DoProbe) + continue; - if (Override) - continue; + if (!(ProbeFlag & Allowed)) + return ProbeFlag; + + if (Override) + continue; - /* User might wish to override this decision */ - xf86Msg(X_WARNING, - ATI_NAME ": Sparse I/O base 0x%04X not probed." ATI_README, - IOBase); - return Allowed; + /* User might wish to override this decision */ + xf86Msg(X_WARNING, + ATI_NAME ": Sparse I/O base 0x%04X not probed.\n", + IOBase); + return Allowed; + } } return DoProbe; @@ -251,20 +260,22 @@ ATIVGAProbe static void ATIVGAWonderProbe ( - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags + pciVideoPtr pVideo, + ATIPtr pATI, + ATIPtr p8514, + CARD8 *ProbeFlags ) { CARD8 IOValue1, IOValue2, IOValue3, IOValue4, IOValue5, IOValue6; - switch (ATICheckSparseIOBases(ProbeFlags, pATI->CPIO_VGAWonder, 2, TRUE)) + switch (ATICheckSparseIOBases(pVideo, ProbeFlags, + pATI->CPIO_VGAWonder, 2, TRUE)) { case 0: xf86Msg(X_WARNING, ATI_NAME ": Expected VGA Wonder capability could not be" " detected at I/O port 0x%04X because it would conflict with" - " a non-video PCI device." ATI_README, pATI->CPIO_VGAWonder); + " a non-video PCI device.\n", pATI->CPIO_VGAWonder); pATI->CPIO_VGAWonder = 0; break; @@ -272,7 +283,7 @@ ATIVGAWonderProbe xf86Msg(X_WARNING, ATI_NAME ": Expected VGA Wonder capability could not be" " detected at I/O port 0x%04X because it would conflict with" - " a %s %s." ATI_README, pATI->CPIO_VGAWonder, + " a %s %s.\n", pATI->CPIO_VGAWonder, ATIBusNames[p8514->BusType], ATIAdapterNames[p8514->Adapter]); pATI->CPIO_VGAWonder = 0; break; @@ -281,7 +292,7 @@ ATIVGAWonderProbe xf86Msg(X_WARNING, ATI_NAME ": Expected VGA Wonder capability could not be" " detected at I/O port 0x%04X because it would conflict with" - " a Mach64." ATI_README, pATI->CPIO_VGAWonder); + " a Mach64.\n", pATI->CPIO_VGAWonder); pATI->CPIO_VGAWonder = 0; break; @@ -313,7 +324,7 @@ ATIVGAWonderProbe xf86Msg(X_WARNING, ATI_NAME ": Expected VGA Wonder capability at I/O port 0x%04X" - " was not detected." ATI_README); + " was not detected.\n"); pATI->CPIO_VGAWonder = 0; break; } @@ -461,91 +472,216 @@ ATI8514Probe return pATI; } +#endif /* AVOID_CPIO */ + /* - * ATIMach64Probe -- + * ATIDetectMach64 -- * - * This function looks for a Mach64 at a particular I/O base address and - * returns an ATIRec if one is found. + * This function determines if a Mach64 is detectable at a particular base + * address. */ -static ATIPtr -ATIMach64Probe +static Bool +ATIDetectMach64 ( - const CARD16 IOBase, - const CARD8 IODecoding, + ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip ) { - ATIPtr pATI; CARD32 IOValue, bus_cntl, gen_test_cntl; - CARD16 IOPort; - pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - pATI->CPIOBase = IOBase; - pATI->CPIODecoding = IODecoding; + (void)ATIMapApertures(-1, pATI); /* Ignore errors */ + +#ifdef AVOID_CPIO + + if (!pATI->pBlock[0]) + { + ATIUnmapApertures(-1, pATI); + return FALSE; + } + +#endif /* AVOID_CPIO */ /* Make sure any Mach64 is not in some weird state */ - pATI->CPIO_BUS_CNTL = ATIIOPort(BUS_CNTL); - bus_cntl = inl(pATI->CPIO_BUS_CNTL); + bus_cntl = inr(BUS_CNTL); if (Chip < ATI_CHIP_264VTB) - outl(pATI->CPIO_BUS_CNTL, + outr(BUS_CNTL, (bus_cntl & ~(BUS_HOST_ERR_INT_EN | BUS_FIFO_ERR_INT_EN)) | (BUS_HOST_ERR_INT | BUS_FIFO_ERR_INT)); else - outl(pATI->CPIO_BUS_CNTL, (bus_cntl & ~BUS_HOST_ERR_INT_EN) | - BUS_HOST_ERR_INT); + outr(BUS_CNTL, (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT); - pATI->CPIO_GEN_TEST_CNTL = ATIIOPort(GEN_TEST_CNTL); - gen_test_cntl = inl(pATI->CPIO_GEN_TEST_CNTL); + gen_test_cntl = inr(GEN_TEST_CNTL); IOValue = gen_test_cntl & (GEN_OVR_OUTPUT_EN | GEN_OVR_POLARITY | GEN_CUR_EN | GEN_BLOCK_WR_EN); - outl(pATI->CPIO_GEN_TEST_CNTL, IOValue | GEN_GUI_EN); - outl(pATI->CPIO_GEN_TEST_CNTL, IOValue); - outl(pATI->CPIO_GEN_TEST_CNTL, IOValue | GEN_GUI_EN); + outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN); + outr(GEN_TEST_CNTL, IOValue); + outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN); /* See if a Mach64 answers */ - IOPort = ATIIOPort(SCRATCH_REG0); - IOValue = inl(IOPort); + IOValue = inr(SCRATCH_REG0); /* Test odd bits */ - outl(IOPort, 0x55555555U); - if (inl(IOPort) == 0x55555555U) + outr(SCRATCH_REG0, 0x55555555U); + if (inr(SCRATCH_REG0) == 0x55555555U) { /* Test even bits */ - outl(IOPort, 0xAAAAAAAAU); - if (inl(IOPort) == 0xAAAAAAAAU) + outr(SCRATCH_REG0, 0xAAAAAAAAU); + if (inr(SCRATCH_REG0) == 0xAAAAAAAAU) { /* - * *Something* has a R/W 32-bit register at this I/O address. Try - * to make sure it's a Mach64. The following assumes that ATI will + * *Something* has a R/W 32-bit register at this address. Try to + * make sure it's a Mach64. The following assumes that ATI will * not be producing any more adapters that do not register * themselves in PCI configuration space. */ ATIMach64ChipID(pATI, ChipType); - if ((pATI->Chip != ATI_CHIP_Mach64) || (IODecoding == BLOCK_IO)) + if ((pATI->Chip != ATI_CHIP_Mach64) || + (pATI->CPIODecoding == BLOCK_IO)) pATI->Adapter = ATI_ADAPTER_MACH64; } } /* Restore clobbered register value */ - outl(IOPort, IOValue); + outr(SCRATCH_REG0, IOValue); /* If no Mach64 was detected, return now */ if (pATI->Adapter != ATI_ADAPTER_MACH64) { - outl(pATI->CPIO_GEN_TEST_CNTL, gen_test_cntl); - outl(pATI->CPIO_BUS_CNTL, bus_cntl); - xfree(pATI); - return NULL; + outr(GEN_TEST_CNTL, gen_test_cntl); + outr(BUS_CNTL, bus_cntl); + ATIUnmapApertures(-1, pATI); + return FALSE; } /* Determine legacy BIOS address */ pATI->BIOSBase = 0x000C0000U + - (GetBits(inl(ATIIOPort(SCRATCH_REG1)), BIOS_BASE_SEGMENT) << 11); + (GetBits(inr(SCRATCH_REG1), BIOS_BASE_SEGMENT) << 11); + + ATIUnmapApertures(-1, pATI); + pATI->PCIInfo = NULL; + return TRUE; +} + +#ifdef AVOID_CPIO + +/* + * ATIMach64Probe -- + * + * This function looks for a Mach64 at a particular MMIO address and returns an + * ATIRec if one is found. + */ +static ATIPtr +ATIMach64Probe +( + pciVideoPtr pVideo, + const CARD16 IOBase, + const CARD8 IODecoding, + const ATIChipType Chip +) +{ + ATIPtr pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); + CARD16 ChipType = 0; + + pATI->CPIOBase = IOBase; + pATI->CPIODecoding = IODecoding; + + if (pVideo) + { + pATI->PCIInfo = pVideo; + ChipType = pVideo->chipType; + + /* + * Probe through auxiliary MMIO aperture if one exists. Because such + * apertures can be enabled/disabled only through PCI, this probes no + * further. + */ + if ((pVideo->size[2] >= 12) && (pATI->Block0Base = pVideo->memBase[2])) + { + pATI->Block0Base += 0x00000400U; + goto LastProbe; + } + + /* + * Probe through the primary MMIO aperture that exists at the tail end + * of the linear aperture. Test for both 8MB and 4MB linear apertures. + */ + if ((pVideo->size[0] >= 22) && (pATI->Block0Base = pVideo->memBase[0])) + { + pATI->Block0Base += 0x007FFC00U; + if ((pVideo->size[0] >= 23) && + ATIDetectMach64(pATI, ChipType, Chip)) + return pATI; + + pATI->Block0Base -= 0x00400000U; + if (ATIDetectMach64(pATI, ChipType, Chip)) + return pATI; + } + } + + /* + * A last, perhaps desparate, probe attempt. Note that if this succeeds, + * there's a VGA in the system and it's likely the PIO version of the + * driver should be used instead. + */ + pATI->Block0Base = 0x000BFC00; + +LastProbe: + if (ATIDetectMach64(pATI, ChipType, Chip)) + return pATI; + + xfree(pATI); + return NULL; +} + +#else /* AVOID_CPIO */ + +/* + * ATIMach64Probe -- + * + * This function looks for a Mach64 at a particular PIO address and returns an + * ATIRec if one is found. + */ +static ATIPtr +ATIMach64Probe +( + pciVideoPtr pVideo, + const CARD16 IOBase, + const CARD8 IODecoding, + const ATIChipType Chip +) +{ + ATIPtr pATI; + CARD32 IOValue; + CARD16 ChipType = 0; + + if (pVideo) + { + if ((IODecoding == BLOCK_IO) && (pVideo->size[1] < 8)) + return NULL; + + ChipType = pVideo->chipType; + } + + pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); + pATI->CPIOBase = IOBase; + pATI->CPIODecoding = IODecoding; + pATI->PCIInfo = pVideo; + + if (!ATIDetectMach64(pATI, ChipType, Chip)) + { + xfree(pATI); + return NULL; + } - /* Determine VGA capability */ - IOValue = inl(ATIIOPort(CONFIG_STATUS64_0)); - if (pATI->Chip < ATI_CHIP_264CT) + /* + * Determine VGA capability. VGA can always be enabled on integrated + * controllers. For the GX/CX, it's a board strap. + */ + IOValue = inr(CONFIG_STATUS64_0); + if (pATI->Chip >= ATI_CHIP_264CT) + pATI->VGAAdapter = ATI_ADAPTER_MACH64; + else { pATI->BusType = GetBits(IOValue, CFG_BUS_TYPE); IOValue &= (CFG_VGA_EN | CFG_CHIP_EN); @@ -558,11 +694,6 @@ ATIMach64Probe pATI->VGAOffset = 0x80U; } } - else - { - if ((pATI->Chip < ATI_CHIP_264VT) || (IOValue & CFG_VGA_EN_T)) - pATI->VGAAdapter = ATI_ADAPTER_MACH64; - } return pATI; } @@ -579,10 +710,11 @@ ATIMach64Probe static void ATIAssignVGA ( - ATIPtr *ppVGA, - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags + pciVideoPtr pVideo, + ATIPtr *ppVGA, + ATIPtr pATI, + ATIPtr p8514, + CARD8 *ProbeFlags ) { ATIPtr pVGA = *ppVGA; @@ -605,10 +737,10 @@ ATIAssignVGA */ OldDACMask = inb(VGA_DAC_MASK); - if (inb(DAC_MASK) == OldDACMask) + if (inb(IBM_DAC_MASK) == OldDACMask) { outb(VGA_DAC_MASK, 0xA5U); - if (inb(DAC_MASK) == 0xA5U) + if (inb(IBM_DAC_MASK) == 0xA5U) pATI->VGAAdapter = ATI_ADAPTER_VGA; } @@ -627,10 +759,10 @@ ATIAssignVGA OldDACMask = inb(VGA_DAC_MASK); - if (inb(DAC_MASK) == OldDACMask) + if (inb(IBM_DAC_MASK) == OldDACMask) { outb(VGA_DAC_MASK, 0xA5U); - if (inb(DAC_MASK) == 0xA5U) + if (inb(IBM_DAC_MASK) == 0xA5U) pATI->VGAAdapter = ATI_ADAPTER_VGA; } @@ -656,10 +788,10 @@ ATIAssignVGA OldDACMask = inb(VGA_DAC_MASK); - if (inb(DAC_MASK) == OldDACMask) + if (inb(IBM_DAC_MASK) == OldDACMask) { outb(VGA_DAC_MASK, 0xA5U); - if (inb(DAC_MASK) == 0xA5U) + if (inb(IBM_DAC_MASK) == 0xA5U) pATI->VGAAdapter = ATI_ADAPTER_MACH32; } @@ -674,26 +806,24 @@ ATIAssignVGA case ATI_ADAPTER_MACH64: { - CARD16 DACMaskPort = ATIIOPort(DAC_REGS) + 2, - DACCntlPort = ATIIOPort(DAC_CNTL); - CARD32 DACCntl = inl(DACCntlPort); + CARD32 DACCntl = inr(DAC_CNTL); if (!(DACCntl & DAC_VGA_ADR_EN)) - outl(DACCntlPort, DACCntl | DAC_VGA_ADR_EN); + outr(DAC_CNTL, DACCntl | DAC_VGA_ADR_EN); OldDACMask = inb(VGA_DAC_MASK); - if (inb(DACMaskPort) == OldDACMask) + if (in8(M64_DAC_MASK) == OldDACMask) { outb(VGA_DAC_MASK, 0xA5U); - if (inb(DACMaskPort) == 0xA5U) + if (in8(M64_DAC_MASK) == 0xA5U) pATI->VGAAdapter = ATI_ADAPTER_MACH64; } outb(VGA_DAC_MASK, OldDACMask); if (!(DACCntl & DAC_VGA_ADR_EN)) - outl(DACCntlPort, DACCntl); + outr(DAC_CNTL, DACCntl); } break; @@ -709,7 +839,7 @@ ATIAssignVGA if (pATI->CPIO_VGAWonder) { - ATIVGAWonderProbe(pATI, p8514, ProbeFlags); + ATIVGAWonderProbe(pVideo, pATI, p8514, ProbeFlags); if (!pATI->CPIO_VGAWonder) { /* @@ -719,7 +849,7 @@ ATIAssignVGA * of I/O through the bus tree. */ pATI->CPIO_VGAWonder = GRAX; - ATIVGAWonderProbe(pATI, p8514, ProbeFlags); + ATIVGAWonderProbe(pVideo, pATI, p8514, ProbeFlags); } } @@ -743,14 +873,15 @@ ATIAssignVGA static void ATIClaimVGA ( - ATIPtr *ppVGA, - ATIPtr pATI, - ATIPtr p8514, - CARD8 *ProbeFlags, - int Detected + pciVideoPtr pVideo, + ATIPtr *ppVGA, + ATIPtr pATI, + ATIPtr p8514, + CARD8 *ProbeFlags, + int Detected ) { - ATIAssignVGA(ppVGA, pATI, p8514, ProbeFlags); + ATIAssignVGA(pVideo, ppVGA, pATI, p8514, ProbeFlags); if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { ATIClaimSparseIOBases(ProbeFlags, MonochromeIOBase, 48, Detected); @@ -769,24 +900,27 @@ ATIClaimVGA static void ATIFindVGA ( - ATIPtr *ppVGA, - ATIPtr *ppATI, - ATIPtr p8514, - CARD8 *ProbeFlags + pciVideoPtr pVideo, + ATIPtr *ppVGA, + ATIPtr *ppATI, + ATIPtr p8514, + CARD8 *ProbeFlags ) { ATIPtr pATI = *ppATI; if (*ppVGA) - ATIAssignVGA(ppVGA, pATI, p8514, ProbeFlags); + ATIAssignVGA(pVideo, ppVGA, pATI, p8514, ProbeFlags); else { pATI = ATIVGAProbe(pATI); if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIAssignVGA(ppATI, pATI, p8514, ProbeFlags); + ATIAssignVGA(pVideo, ppATI, pATI, p8514, ProbeFlags); } } +#endif /* AVOID_CPIO */ + /* * ATIProbe -- * @@ -800,21 +934,27 @@ ATIProbe int flags ) { - ATIPtr pATI, *ATIPtrs = NULL, pVGA = NULL, p8514 = NULL; - ATIPtr pMach64[3] = {NULL, NULL, NULL}; + ATIPtr pATI, *ATIPtrs = NULL; GDevPtr *GDevs, pGDev; pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo(); - pciConfigPtr pPCI, *xf86PciInfo = xf86GetPciConfigInfo(); + pciConfigPtr pPCI; ATIGDev *ATIGDevs = NULL, *pATIGDev; ScrnInfoPtr pScreenInfo; - PortPtr PCIPorts = NULL; CARD32 PciReg; int i, j, k; - int nGDev, nATIGDev = 0, nATIPtr = 0, nPCIPort = 0; + int nGDev, nATIGDev = 0, nATIPtr = 0; int nAdapter = 0; int Chipset; - CARD8 fChipsets[ATI_CHIPSET_MAX]; ATIChipType Chip; + +#ifndef AVOID_CPIO + + ATIPtr pVGA = NULL, p8514 = NULL; + ATIPtr pMach64[3] = {NULL, NULL, NULL}; + pciConfigPtr *xf86PciInfo = xf86GetPciConfigInfo(); + PortPtr PCIPorts = NULL; + int nPCIPort = 0; + CARD8 fChipsets[ATI_CHIPSET_MAX]; static const CARD16 Mach64SparseIOBases[] = {0x02ECU, 0x01CCU, 0x01C8U}; CARD8 ProbeFlags[LongPort(SPARSE_IO_BASE) + 1]; @@ -826,6 +966,8 @@ ATIProbe CARD8 BIOS[PrefixSize]; # define BIOSWord(_n) (*((CARD16 *)(BIOS + (_n)))) +#endif /* AVOID_CPIO */ + # define AddAdapter(_p) \ do \ { \ @@ -848,8 +990,13 @@ ATIProbe return FALSE; ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev)); + +#ifndef AVOID_CPIO + (void)memset(fChipsets, FALSE, SizeOf(fChipsets)); +#endif /* AVOID_CPIO */ + for (i = 0, pATIGDev = ATIGDevs; i < nGDev; i++) { pGDev = GDevs[i]; @@ -876,7 +1023,13 @@ ATIProbe pATIGDev->Chipset = Chipset; nATIGDev++; pATIGDev++; + +#ifndef AVOID_CPIO + fChipsets[Chipset] = TRUE; + +#endif /* AVOID_CPIO */ + } xfree(GDevs); @@ -889,6 +1042,8 @@ ATIProbe } } +#ifndef AVOID_CPIO + /* * Collect hardware information. This must be done with care to avoid * lockups due to overlapping I/O port assignments. @@ -917,39 +1072,15 @@ ATIProbe if (xf86PciVideoInfo) for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { - pPCI = (pciConfigPtr)(pVideo->thisCard); + pPCI = pVideo->thisCard; if (pVideo->vendor == PCI_VENDOR_ATI) - { - if (pVideo->chipType == PCI_CHIP_MACH32) - continue; - - /* - * Some PCI Mach64's are not properly configured for sparse or - * block I/O. Correct PCI's USERCONFIG register, if necessary. - */ - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); - if (IsATIBlockIOBase(pVideo->ioBase[1])) - { - /* This is block I/O */ - if (!(PciReg & 0x00000004U)) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg | 0x00000004U); - } - else - { - /* This is sparse I/O */ - if (PciReg & 0x00000004U) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, - PciReg & ~0x00000004U); - } - continue; - } - - ATIScanPCIBases(&PCIPorts, &nPCIPort, - &pPCI->pci_base0, pVideo->size, - (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & - PCI_CMD_IO_ENABLE) ? 0 : Allowed); + ATIRefreshPCIBases(pVideo, pPCI); + else + ATIScanPCIBases(&PCIPorts, &nPCIPort, + &pPCI->pci_base0, pVideo->size, + (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) & + PCI_CMD_IO_ENABLE) ? 0 : Allowed); } /* Check non-video PCI devices for I/O bases */ @@ -1006,7 +1137,7 @@ ATIProbe * failed to be detected the first time around. Each such device is probed * for again, this time with I/O temporarily enabled through PCI. */ - if (ATICheckSparseIOBases(ProbeFlags, ATTRX, 16, TRUE) == DoProbe) + if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == DoProbe) { pVGA = ATIVGAProbe(NULL); if (pVGA->Adapter == ATI_ADAPTER_NONE) @@ -1025,7 +1156,7 @@ ATIProbe } } - if ((ATICheckSparseIOBases(ProbeFlags, 0x02E8U, 8, + if ((ATICheckSparseIOBases(NULL, ProbeFlags, 0x02E8U, 8, fChipsets[ATI_CHIPSET_IBM8514] || fChipsets[ATI_CHIPSET_MACH8] || fChipsets[ATI_CHIPSET_MACH32]) == DoProbe) && @@ -1035,31 +1166,66 @@ ATIProbe if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || (pATI->Coprocessor != ATI_CHIP_NONE)) - ATIClaimVGA(&pVGA, pATI, p8514, ProbeFlags, Detected8514A); + ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, Detected8514A); ATIClaimSparseIOBases(ProbeFlags, 0x02E8U, 8, Detected8514A); } for (i = 0; i < NumberOf(Mach64SparseIOBases); i++) { - if (ATICheckSparseIOBases(ProbeFlags, Mach64SparseIOBases[i], 4, + if (ATICheckSparseIOBases(NULL, ProbeFlags, Mach64SparseIOBases[i], 4, fChipsets[ATI_CHIPSET_MACH64]) != DoProbe) continue; - if (!(pATI = ATIMach64Probe(Mach64SparseIOBases[i], SPARSE_IO, 0, 0))) + pATI = ATIMach64Probe(NULL, Mach64SparseIOBases[i], SPARSE_IO, 0); + if (!pATI) continue; AddAdapter(pMach64[i] = pATI); if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIClaimVGA(&pVGA, pATI, p8514, ProbeFlags, DetectedMach64); + ATIClaimVGA(NULL, &pVGA, pATI, p8514, ProbeFlags, DetectedMach64); ATIClaimSparseIOBases(ProbeFlags, Mach64SparseIOBases[i], 4, DetectedMach64); } +#endif /* AVOID_CPIO */ + if (xf86PciVideoInfo) { + +#ifdef AVOID_CPIO + + /* PCI Sparse I/O adapters can still be used through MMIO */ + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + IsATIBlockIOBase(pVideo->ioBase[1])) + continue; + + pPCI = pVideo->thisCard; + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004U) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg & ~0x00000004U); + + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + + /* The CPIO base used by the adapter is of little concern here */ + pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); + if (!pATI) + continue; + + AddAdapter(pATI); + pATI->PCIInfo = pVideo; + } + +#endif /* AVOID_CPIO */ + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { if ((pVideo->vendor != PCI_VENDOR_ATI) || @@ -1072,18 +1238,33 @@ ATIProbe if (Chip > ATI_CHIP_Mach64) continue; - pATI = ATIMach64Probe(pVideo->ioBase[1], BLOCK_IO, - pVideo->chipType, Chip); + pPCI = pVideo->thisCard; + + /* Possibly fix block I/O indicator in PCI configuration space */ + PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + if (!(PciReg & 0x00000004U)) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg | 0x00000004U); + + pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip); if (!pATI) continue; AddAdapter(pATI); +#ifndef AVOID_CPIO + /* This is probably not necessary */ if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIClaimVGA(&pVGA, pATI, p8514, ProbeFlags, DetectedMach64); + ATIClaimVGA(pVideo, &pVGA, pATI, p8514, + ProbeFlags, DetectedMach64); + +#endif /* AVOID_CPIO */ + } +#ifndef AVOID_CPIO + /* * This is the second pass through PCI configuration space. Much of * this is verbiage to deal with potential situations that are very @@ -1092,7 +1273,7 @@ ATIProbe * First, look for non-ATI shareable VGA's. For now, these must the * primary device. */ - if (ATICheckSparseIOBases(ProbeFlags, ATTRX, 16, TRUE) == DoProbe) + if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) == DoProbe) { for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { @@ -1105,7 +1286,7 @@ ATIProbe pVideo->func)) continue; - xf86SetPciVideo(pVideo, IO); + xf86SetPciVideo(pVideo, MEM_IO); pATI = ATIVGAProbe(NULL); if (pATI->Adapter == ATI_ADAPTER_NONE) @@ -1113,7 +1294,7 @@ ATIProbe xfree(pATI); xf86Msg(X_WARNING, ATI_NAME ": PCI/AGP VGA-compatible in slot" - " %d:%d:%d could not be detected!" ATI_README, + " %d:%d:%d could not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); } else @@ -1135,13 +1316,14 @@ ATIProbe (pVideo->chipType != PCI_CHIP_MACH32)) continue; - switch (ATICheckSparseIOBases(ProbeFlags, 0x02E8U, 8, TRUE)) + switch (ATICheckSparseIOBases(pVideo, ProbeFlags, + 0x02E8U, 8, TRUE)) { case 0: xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not" " be enabled\n because it conflicts with a" - " non-video PCI device." ATI_README, + " non-video PCI device.\n", pVideo->bus, pVideo->device, pVideo->func); break; @@ -1152,7 +1334,7 @@ ATIProbe xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will" " not be enabled\n because it conflicts with" - " another %s %s." ATI_README, + " another %s %s.\n", pVideo->bus, pVideo->device, pVideo->func, ATIBusNames[p8514->BusType], ATIAdapterNames[p8514->Adapter]); @@ -1162,8 +1344,7 @@ ATIProbe xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not" " be enabled\n because it conflicts with a" - " Mach64 at I/O base 0x02EC." - ATI_README, + " Mach64 at I/O base 0x02EC.\n", pVideo->bus, pVideo->device, pVideo->func); break; @@ -1173,20 +1354,19 @@ ATIProbe pVideo->func)) continue; - xf86SetPciVideo(pVideo, IO); + xf86SetPciVideo(pVideo, MEM_IO); if (!(pATI = ATI8514Probe(pVideo))) xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d could" - " not be detected!" ATI_README, + " not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); else { if (pATI->Adapter != ATI_ADAPTER_MACH32) xf86Msg(X_WARNING, ATI_NAME ": PCI Mach32 in slot %d:%d:%d" - " could only be detected as an %s!" - ATI_README, + " could only be detected as an %s!\n", pVideo->bus, pVideo->device, pVideo->func, ATIAdapterNames[pATI->Adapter]); @@ -1195,7 +1375,8 @@ ATIProbe if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) || (pATI->Coprocessor != ATI_CHIP_NONE)) - ATIFindVGA(&pVGA, &pATI, p8514, ProbeFlags); + ATIFindVGA(pVideo, &pVGA, &pATI, p8514, + ProbeFlags); } xf86SetPciVideo(NULL, NONE); @@ -1211,31 +1392,30 @@ ATIProbe IsATIBlockIOBase(pVideo->ioBase[1])) continue; - pPCI = (pciConfigPtr)(pVideo->thisCard); + pPCI = pVideo->thisCard; PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); j = PciReg & 0x03U; if (j == 0x03U) xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d cannot be" " enabled\n because it has neither a block, nor a" - " sparse, I/O base." ATI_README, + " sparse, I/O base.\n", pVideo->bus, pVideo->device, pVideo->func); - else switch(ATICheckSparseIOBases(ProbeFlags, + else switch(ATICheckSparseIOBases(pVideo, ProbeFlags, Mach64SparseIOBases[j], 4, TRUE)) { case 0: xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not" " be enabled\n because it conflicts with another" - " non-video PCI device." ATI_README, + " non-video PCI device.\n", pVideo->bus, pVideo->device, pVideo->func); break; case Detected8514A: xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not" - " be enabled\n because it conflicts with an %s." - ATI_README, + " be enabled\n because it conflicts with an %s.\n", pVideo->bus, pVideo->device, pVideo->func, ATIAdapterNames[p8514->Adapter]); break; @@ -1248,8 +1428,8 @@ ATIProbe xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d will" " not be enabled\n because it conflicts with" - " another %s Mach64 at sparse I/O base 0x%04X." - ATI_README, + " another %s Mach64 at sparse I/O base" + " 0x%04X.\n", pVideo->bus, pVideo->device, pVideo->func, ATIBusNames[pATI->BusType], Mach64SparseIOBases[j]); @@ -1261,15 +1441,20 @@ ATIProbe pVideo->func)) continue; - xf86SetPciVideo(pVideo, IO); + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004U) + pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, + PciReg & ~0x00000004U); + + xf86SetPciVideo(pVideo, MEM_IO); - pATI = ATIMach64Probe(Mach64SparseIOBases[j], SPARSE_IO, - pVideo->chipType, - ATIChipID(pVideo->chipType, pVideo->chipRev)); + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j], + SPARSE_IO, Chip); if (!pATI) xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d could" - " not be detected!" ATI_README, + " not be detected!\n", pVideo->bus, pVideo->device, pVideo->func); else { @@ -1278,7 +1463,8 @@ ATIProbe pATI->PCIInfo = pVideo; if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIFindVGA(&pVGA, &pATI, p8514, ProbeFlags); + ATIFindVGA(pVideo, &pVGA, &pATI, p8514, + ProbeFlags); } xf86SetPciVideo(NULL, NONE); @@ -1286,6 +1472,52 @@ ATIProbe } } +#else /* AVOID_CPIO */ + + for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) + { + if ((pVideo->vendor != PCI_VENDOR_ATI) || + (pVideo->chipType == PCI_CHIP_MACH32) || + IsATIBlockIOBase(pVideo->ioBase[1])) + continue; + + /* Check if this one has already been detected */ + for (j = 0; j < nATIPtr; j++) + { + pATI = ATIPtrs[j]; + if (pATI->PCIInfo == pVideo) + goto SkipThisSlot; + } + + if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func)) + continue; + + xf86SetPciVideo(pVideo, MEM_IO); + + Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); + + /* The adapter's CPIO base is of little concern here */ + pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip); + if (pATI) + { + AddAdapter(pATI); + pATI->SharedAccelerator = TRUE; + pATI->PCIInfo = pVideo; + } + + xf86SetPciVideo(NULL, NONE); + + if (!pATI) + xf86Msg(X_WARNING, + ATI_NAME ": PCI Mach64 in slot %d:%d:%d could not be" + " detected!\n", + pVideo->bus, pVideo->device, pVideo->func); + + SkipThisSlot:; + } + +#endif /* AVOID_CPIO */ + /* Lastly, look for block I/O devices */ for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) { @@ -1311,17 +1543,21 @@ ATIProbe continue; /* Probe for it */ - xf86SetPciVideo(pVideo, IO); + xf86SetPciVideo(pVideo, MEM_IO); - pATI = ATIMach64Probe(pVideo->ioBase[1], BLOCK_IO, - pVideo->chipType, Chip); + pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip); if (pATI) { AddAdapter(pATI); pATI->SharedAccelerator = TRUE; +#ifndef AVOID_CPIO + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIFindVGA(&pVGA, &pATI, p8514, ProbeFlags); + ATIFindVGA(pVideo, &pVGA, &pATI, p8514, ProbeFlags); + +#endif /* AVOID_CPIO */ + } xf86SetPciVideo(NULL, NONE); @@ -1330,7 +1566,7 @@ ATIProbe { xf86Msg(X_WARNING, ATI_NAME ": PCI Mach64 in slot %d:%d:%d could not be" - " detected!" ATI_README, + " detected!\n", pVideo->bus, pVideo->device, pVideo->func); continue; } @@ -1340,6 +1576,8 @@ ATIProbe } } +#ifndef AVOID_CPIO + /* * At this point, if there's a non-shareable VGA with its own framebuffer, * find out if it's an ATI VGA Wonder. @@ -1476,7 +1714,7 @@ ATIProbe if (!pVGA->CPIO_VGAWonder) pVGA->CPIO_VGAWonder = 0x01CEU; - ATIVGAWonderProbe(pVGA, p8514, ProbeFlags); + ATIVGAWonderProbe(NULL, pVGA, p8514, ProbeFlags); break; #if 0 case '2': @@ -1504,6 +1742,8 @@ ATIProbe NoVGAWonder:; } while (0); +#endif /* AVOID_CPIO */ + /* If no appropriate adapters have been detected, return now */ if (!nATIPtr) { @@ -1521,10 +1761,15 @@ NoVGAWonder:; { pATI = ATIPtrs[i]; +#ifndef AVOID_CPIO + if ((pATI->Adapter != ATI_ADAPTER_VGA) && ((pATI->Adapter != ATI_ADAPTER_8514A) || ((pATI->VGAAdapter != ATI_ADAPTER_VGA) && (pATI->VGAAdapter != ATI_ADAPTER_NONE)))) + +#endif /* AVOID_CPIO */ + { nAdapter++; pGDev = xf86AddDeviceToConfigure(ATI_DRIVER_NAME, @@ -1590,6 +1835,9 @@ NoVGAWonder:; switch (pATIGDev->Chipset) { case ATI_CHIPSET_ATI: + +#ifndef AVOID_CPIO + if (pATI->Adapter == ATI_ADAPTER_VGA) continue; if (pATI->Adapter != ATI_ADAPTER_8514A) @@ -1626,6 +1874,8 @@ NoVGAWonder:; break; continue; +#endif /* AVOID_CPIO */ + case ATI_CHIPSET_MACH64: if (pATI->Adapter == ATI_ADAPTER_MACH64) break; @@ -1639,7 +1889,7 @@ NoVGAWonder:; * The ChipID and ChipRev specifications are compared next. First, * require these to be unspecified for anything other than Mach32 * or Mach64 adapters. ChipRev is also required to be unspecified - * for Mach32's. ChipID is optional for for Mach32's, and both + * for Mach32's. ChipID is optional for Mach32's, and both * specifications are optional for Mach64's. Lastly, allow both * specifications to override their detected value in the case of * Mach64 adapters whose ChipID is unrecognised. @@ -1706,8 +1956,15 @@ NoVGAWonder:; */ if (pGDev->busID && pGDev->busID[0]) { - if (!(pVideo = pATI->PCIInfo)) + pVideo = pATI->PCIInfo; + +#ifndef AVOID_CPIO + + if (!pVideo) continue; + +#endif /* AVOID_CPIO */ + if (!xf86ComparePciBusString(pGDev->busID, pVideo->bus, pVideo->device, pVideo->func)) continue; @@ -1724,7 +1981,7 @@ NoVGAWonder:; xf86Msg(X_ERROR, ATI_NAME ": XF86Config Device section \"%s\" may not" - " be assigned to more than one adapter." ATI_README, + " be assigned to more than one adapter.\n", pGDev->identifier); pATIGDev->iATIPtr = -1; break; @@ -1760,9 +2017,8 @@ NoVGAWonder:; { xf86Msg(X_ERROR, ATI_NAME ": XF86Config Device sections \"%s\" and" - " \"%s\" may not be assigned to the same adapter." - ATI_README, pGDev->identifier, - ATIGDevs[k].pGDev->identifier); + " \"%s\" may not be assigned to the same adapter.\n", + pGDev->identifier, ATIGDevs[k].pGDev->identifier); pATIGDev->iATIPtr = ATIGDevs[k].iATIPtr = -1; } } @@ -1819,8 +2075,17 @@ NoVGAWonder:; if (!(pATI = ATIPtrs[i])) continue; - if ((pATI->Adapter > ATI_ADAPTER_VGA) && (pATI->iEntity < 0)) - (void)ATIClaimBusSlot(pDriver, 0, NULL, FALSE, pATI); +#ifndef AVOID_CPIO + + if (pATI->Adapter > ATI_ADAPTER_VGA) + +#endif /* AVOID_CPIO */ + + { + if (pATI->iEntity < 0) + (void)ATIClaimBusSlot(pDriver, 0, NULL, FALSE, pATI); + } + xfree(pATI); } xfree(ATIPtrs); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h index bde7d2fd7..b26bc7d83 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h,v 1.4 2000/02/18 12:19:34 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h,v 1.5 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #define ___ATIPROBE_H___ 1 #include "atiproto.h" + #include "xf86str.h" extern Bool ATIProbe FunctionPrototype((DriverPtr, int)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h index 6b8d93209..b306808eb 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h,v 1.10 2000/03/30 15:41:20 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h,v 1.11 2000/08/04 21:07:15 tsi Exp $ */ /* * Copyright 1994 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -124,10 +124,10 @@ #define VBLANK 0x0002u #define HORTOG 0x0004u #define H_TOTAL 0x02e8u /* Write */ -#define DAC_MASK 0x02eau -#define DAC_R_INDEX 0x02ebu -#define DAC_W_INDEX 0x02ecu -#define DAC_DATA 0x02edu +#define IBM_DAC_MASK 0x02eau +#define IBM_DAC_READ 0x02ebu +#define IBM_DAC_WRITE 0x02ecu +#define IBM_DAC_DATA 0x02edu #define H_DISP 0x06e8u /* Write */ #define H_SYNC_STRT 0x0ae8u /* Write */ #define H_SYNC_WID 0x0ee8u /* Write */ @@ -273,7 +273,7 @@ #define SCISSORS_L 0x2000u #define SCISSORS_B 0x3000u #define SCISSORS_R 0x4000u -#define MEM_CNTL 0x5000u +#define M32_MEM_CNTL 0x5000u #define HORCFG_4 0x0000u #define HORCFG_5 0x0001u #define HORCFG_8 0x0002u @@ -949,7 +949,7 @@ #define HFB_PITCH_ADDR BlockIOTag(0x2au) /* LT */ #define LCD_DATA BlockIOTag(0x2au) /* LTPro */ #define EXT_MEM_CNTL BlockIOTag(0x2bu) /* VTB/GTB/LT */ -#define MEM_INFO IOPortTag(0x14u, 0x2cu) /* Renamed MEM_CNTL */ +#define MEM_CNTL IOPortTag(0x14u, 0x2cu) #define CTL_MEM_SIZE 0x00000007ul /* ? 0x00000008ul */ #define CTL_MEM_REFRESH 0x00000078ul /* VT/GT */ @@ -993,7 +993,7 @@ #define CTL_MEM_PIX_WIDTH 0x07000000ul #define CTL_MEM_LOWER_APER_ENDIAN 0x03000000ul /* VTB/GTB/LT */ #define CTL_MEM_OE_SELECT 0x18000000ul /* VT/GT */ -#define CTL_MEM_UPPER_APER_ENDIAN 0c0c000000ul /* VTB/GTB/LT */ +#define CTL_MEM_UPPER_APER_ENDIAN 0x0c000000ul /* VTB/GTB/LT */ /* ? 0xe0000000ul */ #define CTL_MEM_PAGE_SIZE 0x30000000ul /* VTB/GTB/LT */ #define MEM_VGA_WP_SEL IOPortTag(0x15u, 0x2du) @@ -1005,6 +1005,10 @@ #define LT_GIO BlockIOTag(0x2fu) /* LT */ #define I2C_CNTL_1 BlockIOTag(0x2fu) /* GTPro */ #define DAC_REGS IOPortTag(0x17u, 0x30u) /* 4 separate bytes */ +#define M64_DAC_WRITE (DAC_REGS + 0) +#define M64_DAC_DATA (DAC_REGS + 1) +#define M64_DAC_MASK (DAC_REGS + 2) +#define M64_DAC_READ (DAC_REGS + 3) #define DAC_CNTL IOPortTag(0x18u, 0x31u) #define DAC_EXT_SEL 0x00000003ul #define DAC_EXT_SEL_RS2 0x000000001ul @@ -1861,6 +1865,12 @@ /* ? BlockIOTag(0x1feu) */ /* ? BlockIOTag(0x1ffu) */ +/* Definitions for MEM_CNTL's CTL_MEM_?????_APER_ENDIAN fields */ +#define CTL_MEM_APER_BYTE_ENDIAN 0x00u +#define CTL_MEM_APER_WORD_ENDIAN 0x01u +#define CTL_MEM_APER_LONG_ENDIAN 0x02u +/* ? 0x03u */ + /* Definitions for an ICS2595's programme word */ #define ICS2595_CLOCK 0x000001f0ul #define ICS2595_FB_DIV 0x0001fe00ul /* Feedback divider */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c index 85d650d89..706ee1b25 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c,v 1.9 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c,v 1.11 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -136,6 +136,9 @@ ATIScreenInit /* Initialise framebuffer layer */ switch (pATI->bitsPerPixel) { + +#ifndef AVOID_CPIO + case 1: pATI->Closeable = xf1bppScreenInit(pScreen, pFB, pScreenInfo->virtualX, pScreenInfo->virtualY, @@ -148,6 +151,8 @@ ATIScreenInit pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth); break; +#endif /* AVOID_CPIO */ + case 8: pATI->Closeable = cfbScreenInit(pScreen, pFB, pScreenInfo->virtualX, pScreenInfo->virtualY, @@ -201,12 +206,16 @@ ATIScreenInit xf86SetBlackWhitePixels(pScreen); +#ifndef AVOID_CPIO + /* Initialise banking if needed */ if (!miInitializeBanking(pScreen, pScreenInfo->virtualX, pScreenInfo->virtualY, pATI->displayWidth, &pATI->BankInfo)) return FALSE; +#endif /* AVOID_CPIO */ + /* Initialise DGA support */ (void)ATIDGAInit(pScreenInfo, pScreen, pATI); @@ -225,6 +234,16 @@ ATIScreenInit if (!miCreateDefColormap(pScreen)) return FALSE; +#ifdef AVOID_CPIO + + if (!xf86HandleColormaps(pScreen, 256, pScreenInfo->rgbBits, + ATILoadPalette, NULL, + CMAP_PALETTED_TRUECOLOR | + CMAP_LOAD_EVEN_IF_OFFSCREEN)) + return FALSE; + +#else /* AVOID_CPIO */ + if (pATI->depth > 1) if (!xf86HandleColormaps(pScreen, (pATI->depth == 4) ? 16 : 256, pScreenInfo->rgbBits, ATILoadPalette, NULL, @@ -232,6 +251,8 @@ ATIScreenInit CMAP_LOAD_EVEN_IF_OFFSCREEN)) return FALSE; +#endif /* AVOID_CPIO */ + /* Initialise shadow framebuffer */ if (pATI->OptionShadowFB && !ShadowFBInit(pScreen, ATIRefreshArea)) @@ -283,6 +304,10 @@ ATICloseScreen ATILeaveGraphics(pScreenInfo, pATI); + xfree(pATI->ExpansionBitmapScanlinePtr[1]); + pATI->ExpansionBitmapScanlinePtr[0] = + pATI->ExpansionBitmapScanlinePtr[1] = NULL; + xfree(pATI->pShadow); pATI->pShadow = NULL; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h index f2c1883d8..ba662df3a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h,v 1.2 2000/02/18 12:19:40 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.h,v 1.3 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #define ___ATISCREEN_H___ 1 #include "atiproto.h" + #include "screenint.h" extern Bool ATIScreenInit FunctionPrototype((int, ScreenPtr, int, char **)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h index c75b44baf..7bce0c90a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h,v 1.18 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h,v 1.20 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -27,6 +27,7 @@ #include "atibank.h" #include "aticlock.h" #include "atiregs.h" + #include "xf86Resources.h" #include "xaa.h" @@ -51,16 +52,26 @@ typedef struct _ATIHWRec /* The CRTC used to drive the screen (VGA, 8514, Mach64) */ CARD8 crtc; - /* VGA registers */ - CARD8 genmo, crt[25], seq[5], gra[9], attr[21], lut[256 * 3]; + /* Colour lookup table */ + CARD8 lut[256 * 3]; - /* Generic DAC registers */ - CARD8 dac_read, dac_write, dac_mask; +#ifndef AVOID_CPIO + + /* VGA registers */ + CARD8 genmo, crt[25], seq[5], gra[9], attr[21]; /* VGA Wonder registers */ CARD8 a3, a6, a7, ab, ac, ad, ae, b0, b1, b2, b3, b5, b6, b8, b9, ba, bd, be, bf; + /* Shadow VGA CRTC registers */ + CARD8 shadow_vga[25]; + +#endif /* AVOID_CPIO */ + + /* Generic DAC registers */ + CARD8 dac_read, dac_write, dac_mask; + /* Mach64 PLL registers */ CARD8 pll_vclk_cntl, pll_vclk_post_div, pll_vclk0_fb_div, pll_vclk1_fb_div, @@ -79,9 +90,6 @@ typedef struct _ATIHWRec CARD32 lcd_index, config_panel, lcd_gen_ctrl, horz_stretching, vert_stretching, ext_vert_stretch; - /* Shadow VGA CRTC registers */ - CARD8 shadow_vga[25]; - /* Shadow Mach64 CRTC registers */ CARD32 shadow_h_total_disp, shadow_h_sync_strt_wid, shadow_v_total_disp, shadow_v_sync_strt_wid; @@ -111,10 +119,15 @@ typedef struct _ATIHWRec /* Clock programming data */ int FeedbackDivider, ReferenceDivider, PostDivider; +#ifndef AVOID_CPIO + /* This is used by ATISwap() */ pointer frame_buffer; ATIBankProcPtr SetBank; unsigned int nBank, nPlane; + +#endif /* AVOID_CPIO */ + } ATIHWRec; /* @@ -130,15 +143,27 @@ typedef struct _ATIRec /* * Adapter-related definitions. */ - CARD8 Adapter, VGAAdapter; + CARD8 Adapter; + +#ifndef AVOID_CPIO + + CARD8 VGAAdapter; + +#endif /* AVOID_CPIO */ /* * Chip-related definitions. */ - CARD8 Chip, Coprocessor; + CARD32 config_chip_id; CARD16 ChipType; + CARD8 Chip; CARD8 ChipClass, ChipRevision, ChipRev, ChipVersion, ChipFoundry; - CARD8 ChipHasSUBSYS_CNTL; + +#ifndef AVOID_CPIO + + CARD8 Coprocessor, ChipHasSUBSYS_CNTL; + +#endif /* AVOID_CPIO */ /* * Processor I/O decoding definitions. @@ -146,6 +171,8 @@ typedef struct _ATIRec CARD8 CPIODecoding; CARD16 CPIOBase; +#ifndef AVOID_CPIO + /* * Processor I/O port definition for VGA. */ @@ -158,36 +185,34 @@ typedef struct _ATIRec CARD8 B2Reg; /* The B2 mirror */ CARD8 VGAOffset; /* Low index for CPIO_VGAWonder */ - /* - * Processor I/O port definitions for Mach64. - */ - CARD16 CPIO_CRTC_H_TOTAL_DISP, CPIO_CRTC_H_SYNC_STRT_WID, - CPIO_CRTC_V_TOTAL_DISP, CPIO_CRTC_V_SYNC_STRT_WID, - CPIO_CRTC_OFF_PITCH, CPIO_CRTC_INT_CNTL, CPIO_CRTC_GEN_CNTL, - CPIO_DSP_CONFIG, CPIO_DSP_ON_OFF, CPIO_OVR_CLR, - CPIO_OVR_WID_LEFT_RIGHT, CPIO_OVR_WID_TOP_BOTTOM, - CPIO_TV_OUT_INDEX, CPIO_CLOCK_CNTL, CPIO_TV_OUT_DATA, - CPIO_BUS_CNTL, CPIO_LCD_INDEX, CPIO_LCD_DATA, CPIO_MEM_INFO, - CPIO_MEM_VGA_WP_SEL, CPIO_MEM_VGA_RP_SEL, - CPIO_DAC_REGS, CPIO_DAC_CNTL, - CPIO_HORZ_STRETCHING, CPIO_VERT_STRETCHING, - CPIO_GEN_TEST_CNTL, CPIO_LCD_GEN_CTRL, - CPIO_POWER_MANAGEMENT, CPIO_CONFIG_CNTL; +#endif /* AVOID_CPIO */ /* * DAC-related definitions. */ - CARD16 DAC; + +#ifndef AVOID_CPIO + CARD16 CPIO_DAC_MASK, CPIO_DAC_DATA, CPIO_DAC_READ, CPIO_DAC_WRITE; + +#endif /* AVOID_CPIO */ + + CARD16 DAC; CARD8 rgbBits; /* * Definitions related to system bus interface. */ pciVideoPtr PCIInfo; - resRange VGAWonderResources[2]; CARD8 BusType; - CARD8 SharedVGA, SharedAccelerator; + CARD8 SharedAccelerator; + +#ifndef AVOID_CPIO + + CARD8 SharedVGA; + resRange VGAWonderResources[2]; + +#endif /* AVOID_CPIO */ /* * Definitions related to video memory. @@ -203,32 +228,42 @@ typedef struct _ATIRec /* * Definitions related to video memory apertures. */ - pointer pBank, pMemory, pShadow; - unsigned long LinearBase, ApertureBase; - int LinearSize, ApertureSize, FBPitch, FBBytesPerPixel; + pointer pMemory, pShadow; + unsigned long LinearBase; + int LinearSize, FBPitch, FBBytesPerPixel; + +#ifndef AVOID_CPIO + + pointer pBank; CARD8 UseSmallApertures; +#endif /* AVOID_CPIO */ + /* * Definitions related to MMIO register apertures. */ pointer pMMIO, pBlock[2]; - unsigned long PageSize, MMIOBase; unsigned long Block0Base, Block1Base; +#ifndef AVOID_CPIO + /* * Banking interface. */ miBankInfoRec BankInfo; +#endif /* AVOID_CPIO */ + /* * XAA interface. */ XAAInfoRecPtr pXAAInfo; - int nAvailableFIFOEntries, nFIFOEntries; + int nAvailableFIFOEntries, nFIFOEntries, nHostFIFOEntries; CARD8 EngineIsBusy, EngineIsLocked, XModifier; CARD32 dst_cntl; /* For SetupFor/Subsequent communication */ - CARD32 ExpansionBitmapScanline[256]; - CARD32 *ExpansionBitmapScanlinePtr; + CARD16 sc_left, sc_right, sc_top, sc_bottom; /* Current scissors */ + pointer pHOST_DATA; /* Current HOST_DATA_* transfer window address */ + CARD32 *ExpansionBitmapScanlinePtr[2]; int ExpansionBitmapWidth; /* @@ -241,9 +276,10 @@ typedef struct _ATIRec * Clock-related definitions. */ int ClockNumberToProgramme, ReferenceNumerator, ReferenceDenominator; + int ProgrammableClock; ClockRec ClockDescriptor; CARD16 BIOSClocks[16]; - CARD8 Clock, ProgrammableClock; + CARD8 Clock; /* * DSP register data. @@ -286,21 +322,28 @@ typedef struct _ATIRec */ struct { + /* Mach64 registers */ + CARD32 bus_cntl, crtc_gen_cntl, mem_cntl, gen_test_cntl, crtc_int_cntl, + lcd_index; + +#ifndef AVOID_CPIO + + CARD32 config_cntl, dac_cntl; + + /* Mach8/Mach32 registers */ + CARD16 clock_sel, misc_options, mem_bndry, mem_cfg; + + /* VGA Wonder registers */ + CARD8 a6, ab, b1, b4, b5, b6, b8, b9, be; + /* VGA registers */ CARD8 crt03, crt11; /* VGA shadow registers */ CARD8 shadow_crt03, shadow_crt11; - /* VGA Wonder registers */ - CARD8 a6, ab, b1, b4, b5, b6, b8, b9, be; +#endif /* AVOID_CPIO */ - /* Mach8/Mach32 registers */ - CARD16 clock_sel, misc_options, mem_bndry, mem_cfg; - - /* Mach64 registers */ - CARD32 bus_cntl, config_cntl, crtc_gen_cntl, mem_info, gen_test_cntl, - dac_cntl, crtc_int_cntl, lcd_index; } LockData; /* Mode data */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c index 44109758c..c6f49f260 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c,v 1.10 2000/04/12 14:44:40 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c,v 1.11 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,6 +26,7 @@ #include "aticrtc.h" #include "atistruct.h" #include "ativalid.h" + #include "xf86.h" /* @@ -45,8 +46,13 @@ ATIValidMode ScrnInfoPtr pScreenInfo = xf86Screens[iScreen]; ATIPtr pATI = ATIPTR(pScreenInfo); Bool InterlacedSeen; - int VDisplay, VTotal, HBlankWidth; - int HAdjust, VScan, VInterlace; + int HBlankWidth, HAdjust, VScan, VInterlace; + +#ifndef AVOID_CPIO + + int VDisplay, VTotal; + +#endif /* AVOID_CPIO */ if (flags & MODECHECK_FINAL) { @@ -170,7 +176,7 @@ ATIValidMode pMode->VTotal = ATIReverseVertical(CrtcVTotal); # undef ATIReverseHorizontal -# undef ATIReverVertical +# undef ATIReverseVertical } HBlankWidth = (pMode->HTotal >> 3) - (pMode->HDisplay >> 3); @@ -179,6 +185,9 @@ ATIValidMode switch (pATI->NewHW.crtc) { + +#ifndef AVOID_CPIO + case ATI_CRTC_VGA: /* Prevent overscans */ if (HBlankWidth > 63) @@ -210,6 +219,8 @@ ATIValidMode break; +#endif /* AVOID_CPIO */ + case ATI_CRTC_MACH64: if (VScan > 2) return MODE_NO_VSCAN; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h index 09881d94e..51daa8ee8 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h,v 1.4 2000/02/18 12:19:42 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.h,v 1.5 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -25,6 +25,7 @@ #define ___ATIVALID_H___ 1 #include "atiproto.h" + #include "xf86str.h" extern int ATIValidMode FunctionPrototype((int, DisplayModePtr, Bool, int)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h index d96b5fbd2..cd3bdefb1 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h,v 1.16 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h,v 1.18 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -27,11 +27,11 @@ #define ATI_NAME "ATI" #define ATI_DRIVER_NAME "ati" -#define ATI_VERSION_NAME "5.3.5" +#define ATI_VERSION_NAME "6.0.0" -#define ATI_VERSION_MAJOR 5 -#define ATI_VERSION_MINOR 3 -#define ATI_VERSION_PATCH 5 +#define ATI_VERSION_MAJOR 6 +#define ATI_VERSION_MINOR 0 +#define ATI_VERSION_PATCH 0 #define ATI_VERSION_CURRENT \ ((ATI_VERSION_MAJOR << 20) | (ATI_VERSION_MINOR << 10) | ATI_VERSION_PATCH) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c index ab5c10032..5d1d26a9a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c,v 1.11 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c,v 1.12 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -27,11 +27,16 @@ #include "atiio.h" #include "atimono.h" #include "ativga.h" + #include "xf86.h" -#define DPMS_SERVER +#ifndef DPMS_SERVER +# define DPMS_SERVER +#endif #include "extensions/dpms.h" +#ifndef AVOID_CPIO + /* * ATIVGAPreInit -- * @@ -496,3 +501,5 @@ ATIVGASetDPMSMode PutReg(CRTX(pATI->CPIO_VGABase), 0x17U, crt17); PutReg(SEQX, 0x01U, 0x03U); /* End synchonous reset */ } + +#endif /* AVOID_CPIO */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h index bda485384..8661c8c05 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h,v 1.6 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h,v 1.7 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,8 +26,11 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" +#ifndef AVOID_CPIO + extern void ATIVGAPreInit FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGASave FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGACalculate FunctionPrototype((ATIPtr, ATIHWPtr, @@ -37,4 +40,6 @@ extern void ATIVGASet FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGASaveScreen FunctionPrototype((ATIPtr, int)); extern void ATIVGASetDPMSMode FunctionPrototype((ATIPtr, int)); +#endif /* AVOID_CPIO */ + #endif /* ___ATIVGA_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c index 45e6a1bd9..ac25c450b 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c,v 1.8 2000/02/18 12:19:44 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.c,v 1.9 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -65,6 +65,8 @@ const char *ATIMemoryTypeNames_264xT[] = "Unknown video memory type" }; +#ifndef AVOID_CPIO + /* * ATIUnmapVGA -- * @@ -73,18 +75,20 @@ const char *ATIMemoryTypeNames_264xT[] = static void ATIUnmapVGA ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { if (!pATI->pBank) return; - xf86UnMapVidMem(pScreenInfo->scrnIndex, pATI->pBank, 0x00010000U); + xf86UnMapVidMem(iScreen, pATI->pBank, 0x00010000U); pATI->pBank = pATI->BankInfo.pBankA = pATI->BankInfo.pBankB = NULL; } +#endif /* AVOID_CPIO */ + /* * ATIUnmapLinear -- * @@ -93,13 +97,33 @@ ATIUnmapVGA static void ATIUnmapLinear ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { + unsigned long PageSize; + int LinearSize; + +#ifdef AVOID_CPIO + + if (!pATI->pMemory) + return; + +#else /* AVOID_CPIO */ + if (pATI->pMemory != pATI->pBank) - xf86UnMapVidMem(pScreenInfo->scrnIndex, pATI->pMemory, - pATI->LinearSize); + +#endif /* AVOID_CPIO */ + + { + PageSize = getpagesize(); + LinearSize = pATI->LinearSize; + if (((pATI->Block0Base | (PageSize - 1)) + 1) == + (pATI->LinearBase + LinearSize)) + LinearSize -= PageSize; + + xf86UnMapVidMem(iScreen, pATI->pMemory, LinearSize); + } pATI->pMemory = NULL; } @@ -112,12 +136,12 @@ ATIUnmapLinear static void ATIUnmapMMIO ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { if (pATI->pMMIO) - xf86UnMapVidMem(pScreenInfo->scrnIndex, pATI->pMMIO, pATI->PageSize); + xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize()); pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL; } @@ -130,15 +154,42 @@ ATIUnmapMMIO Bool ATIMapApertures ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { - pciVideoPtr pVideo; + pciVideoPtr pVideo; + PCITAG Tag; + unsigned long PageSize, MMIOBase; + int LinearSize; if (pATI->Mapped) return TRUE; +#ifndef AVOID_CPIO + + if (pATI->VGAAdapter == ATI_ADAPTER_NONE) + +#endif /* AVOID_CPIO */ + + { + if (!pATI->LinearBase && !pATI->Block0Base) + return FALSE; + } + + PageSize = getpagesize(); + MMIOBase = pATI->Block0Base & ~(PageSize - 1); + LinearSize = pATI->LinearSize; + if ((MMIOBase + PageSize) == (pATI->LinearBase + LinearSize)) + LinearSize -= PageSize; + + if ((pVideo = pATI->PCIInfo)) + Tag = ((pciConfigPtr)(pVideo->thisCard))->tag; + else + Tag = 0; + +#ifndef AVOID_CPIO + /* Map VGA aperture */ if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { @@ -146,8 +197,12 @@ ATIMapApertures * No relocation, resizing, caching or write-combining of this * aperture is supported. Hence, the hard-coded values here... */ - pATI->pBank = xf86MapVidMem(pScreenInfo->scrnIndex, VIDMEM_MMIO, - 0x000A0000U, 0x00010000U); + if (pVideo) + pATI->pBank = xf86MapPciMem(iScreen, VIDMEM_MMIO, + Tag, 0x000A0000U, 0x00010000U); + else + pATI->pBank = xf86MapVidMem(iScreen, VIDMEM_MMIO, + 0x000A0000U, 0x00010000U); if (!pATI->pBank) return FALSE; @@ -155,66 +210,71 @@ ATIMapApertures pATI->pMemory = pATI->BankInfo.pBankA = pATI->BankInfo.pBankB = pATI->pBank; + + pATI->Mapped = TRUE; } - pVideo = pATI->PCIInfo; +#endif /* AVOID_CPIO */ /* Map linear aperture */ if (pATI->LinearBase) { if (pVideo) - pATI->pMemory = xf86MapPciMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, ((pciConfigPtr)(pVideo->thisCard))->tag, - pATI->LinearBase, pATI->LinearSize); + pATI->pMemory = xf86MapPciMem(iScreen, VIDMEM_FRAMEBUFFER, + Tag, pATI->LinearBase, LinearSize); else - pATI->pMemory = xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_FRAMEBUFFER, pATI->LinearBase, pATI->LinearSize); + pATI->pMemory = xf86MapVidMem(iScreen, VIDMEM_FRAMEBUFFER, + pATI->LinearBase, LinearSize); if (!pATI->pMemory) { - ATIUnmapVGA(pScreenInfo, pATI); + +#ifndef AVOID_CPIO + + ATIUnmapVGA(iScreen, pATI); + +#endif /* AVOID_CPIO */ + + pATI->Mapped = FALSE; return FALSE; } + + pATI->Mapped = TRUE; } /* Map MMIO aperture */ if (pATI->Block0Base) { - if ((pATI->Block0Base >= pATI->LinearBase) && - ((pATI->Block0Base + 0x00000400U) <= - (pATI->LinearBase + pATI->LinearSize))) - { - pATI->pBlock[0] = (char *)pATI->pMemory + - (pATI->Block0Base - pATI->LinearBase); - } + if (pVideo) + pATI->pMMIO = xf86MapPciMem(iScreen, VIDMEM_MMIO, + Tag, MMIOBase, PageSize); else + pATI->pMMIO = xf86MapVidMem(iScreen, VIDMEM_MMIO, + MMIOBase, PageSize); + + if (!pATI->pMMIO) { - if (pVideo && - ((pATI->Block0Base < 0x000A0000U) || - (pATI->Block0Base > (0x000B0000U - 0x00000400U)))) - pATI->pMMIO = xf86MapPciMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, ((pciConfigPtr)(pVideo->thisCard))->tag, - pATI->MMIOBase, pATI->PageSize); - else - pATI->pMMIO = xf86MapVidMem(pScreenInfo->scrnIndex, - VIDMEM_MMIO, pATI->MMIOBase, pATI->PageSize); - - if (!pATI->pMMIO) - { - ATIUnmapLinear(pScreenInfo, pATI); - ATIUnmapVGA(pScreenInfo, pATI); - return FALSE; - } - - pATI->pBlock[0] = (char *)pATI->pMMIO + - (pATI->Block0Base - pATI->MMIOBase); + ATIUnmapLinear(iScreen, pATI); + +#ifndef AVOID_CPIO + + ATIUnmapVGA(iScreen, pATI); + +#endif /* AVOID_CPIO */ + + pATI->Mapped = FALSE; + return FALSE; } + pATI->Mapped = TRUE; + + pATI->pBlock[0] = (char *)pATI->pMMIO + + (pATI->Block0Base - MMIOBase); + if (pATI->Block1Base) pATI->pBlock[1] = (char *)pATI->pBlock[0] - 0x00000400U; } - pATI->Mapped = TRUE; return TRUE; } @@ -226,8 +286,8 @@ ATIMapApertures void ATIUnmapApertures ( - ScrnInfoPtr pScreenInfo, - ATIPtr pATI + int iScreen, + ATIPtr pATI ) { if (!pATI->Mapped) @@ -235,11 +295,16 @@ ATIUnmapApertures pATI->Mapped = FALSE; /* Unmap MMIO area */ - ATIUnmapMMIO(pScreenInfo, pATI); + ATIUnmapMMIO(iScreen, pATI); /* Unmap linear aperture */ - ATIUnmapLinear(pScreenInfo, pATI); + ATIUnmapLinear(iScreen, pATI); + +#ifndef AVOID_CPIO /* Unmap VGA aperture */ - ATIUnmapVGA(pScreenInfo, pATI); + ATIUnmapVGA(iScreen, pATI); + +#endif /* AVOID_CPIO */ + } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h index 3aa90311b..51ef6f299 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h,v 1.5 2000/02/18 12:19:45 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atividmem.h,v 1.6 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,7 +26,6 @@ #include "atiproto.h" #include "atipriv.h" -#include "xf86str.h" /* Memory types for 68800's and 88800GX's */ typedef enum @@ -70,7 +69,7 @@ typedef enum } ATI264MemoryType; extern const char *ATIMemoryTypeNames_264xT[]; -extern Bool ATIMapApertures FunctionPrototype((ScrnInfoPtr, ATIPtr)); -extern void ATIUnmapApertures FunctionPrototype((ScrnInfoPtr, ATIPtr)); +extern Bool ATIMapApertures FunctionPrototype((int, ATIPtr)); +extern void ATIUnmapApertures FunctionPrototype((int, ATIPtr)); #endif /* ___ATIVIDMEM_H___ */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c index ad55dc846..c6aeecb3a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c,v 1.8 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c,v 1.10 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -50,10 +50,13 @@ * accessed at indices 0xB0 through 0xBF on all chipsets. */ +#include "ati.h" #include "atichip.h" #include "atiio.h" #include "atiwonder.h" +#ifndef AVOID_CPIO + /* * ATIVGAWonderPreInit -- * @@ -296,3 +299,5 @@ ATIVGAWonderSet ATIModifyExtReg(pATI, 0xBAU, -1, 0x00U, pATIHW->ba); ATIModifyExtReg(pATI, 0xBDU, -1, 0x00U, pATIHW->bd); } + +#endif /* AVOID_CPIO */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h index dcf390c04..04299eb36 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h,v 1.5 2000/06/19 15:00:59 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h,v 1.6 2000/08/04 21:07:16 tsi Exp $ */ /* * Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca * @@ -26,12 +26,17 @@ #include "atipriv.h" #include "atiproto.h" + #include "xf86str.h" +#ifndef AVOID_CPIO + extern void ATIVGAWonderPreInit FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGAWonderSave FunctionPrototype((ATIPtr, ATIHWPtr)); extern void ATIVGAWonderCalculate FunctionPrototype((ATIPtr, ATIHWPtr, DisplayModePtr)); extern void ATIVGAWonderSet FunctionPrototype((ATIPtr, ATIHWPtr)); +#endif /* AVOID_CPIO */ + #endif /* ___ATIWONDER_H___ */ |