⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radeon_driver.c

📁 ati driver
💻 C
📖 第 1 页 / 共 5 页
字号:
	    }	    /* revision 4 has some problem as it appears in RV280, 	       comment it off for new, use default instead */             /*	    else if (RADEON_BIOS8(tmp) == 4) {		int stride = 0;		n = RADEON_BIOS8(tmp + 5) + 1;		if (n > 4) n = 4;		for (i=0; i<n; i++) {		    info->tmds_pll[i].value = RADEON_BIOS32(tmp+stride+0x08);		    info->tmds_pll[i].freq = RADEON_BIOS16(tmp+stride+0x10);		    if (i == 0) stride += 10;		    else stride += 6;		}		return;	    }	    */	}    }    for (i=0; i<4; i++) {	info->tmds_pll[i].value = default_tmds_pll[info->ChipFamily][i].value;	info->tmds_pll[i].freq = default_tmds_pll[info->ChipFamily][i].freq;    }}/* Read PLL parameters from BIOS block.  Default to typical values if * there is no BIOS. */static Bool RADEONGetPLLParameters(ScrnInfoPtr pScrn){    RADEONInfoPtr  info = RADEONPTR(pScrn);    RADEONPLLPtr   pll  = &info->pll;    CARD16         bios_header;    CARD16         pll_info_block;    if (!info->VBIOS) {	pll->min_pll_freq   = 12500;	pll->max_pll_freq   = 35000;		if (!RADEONProbePLLParameters(pScrn)) {	    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,	    	       "Video BIOS not detected, using default PLL parameters!\n");	    switch (info->Chipset) {		case PCI_CHIP_R200_QL:		case PCI_CHIP_R200_QN:		case PCI_CHIP_R200_QO:		case PCI_CHIP_R200_BB:		    pll->reference_freq = 2700;		    pll->reference_div  = 12;		    pll->xclk           = 27500;		    break;		case PCI_CHIP_RV250_Id:		case PCI_CHIP_RV250_Ie:		case PCI_CHIP_RV250_If:		case PCI_CHIP_RV250_Ig:		    pll->reference_freq = 2700;		    pll->reference_div  = 12;		    pll->xclk           = 24975;		    break;		case PCI_CHIP_RV200_QW:		    pll->reference_freq = 2700;		    pll->reference_div  = 12;		    pll->xclk           = 23000;		    break;		default:		    pll->reference_freq = 2700;		    pll->reference_div  = 67;	   	    pll->xclk           = 16615;		    break;	    }        }    } else {	bios_header    = RADEON_BIOS16(0x48);	pll_info_block = RADEON_BIOS16(bios_header + 0x30);	RADEONTRACE(("Header at 0x%04x; PLL Information at 0x%04x\n",		     bios_header, pll_info_block));	pll->reference_freq = RADEON_BIOS16(pll_info_block + 0x0e);	pll->reference_div  = RADEON_BIOS16(pll_info_block + 0x10);	pll->min_pll_freq   = RADEON_BIOS32(pll_info_block + 0x12);	pll->max_pll_freq   = RADEON_BIOS32(pll_info_block + 0x16);	pll->xclk           = RADEON_BIOS16(pll_info_block + 0x08);    }    return TRUE;}/* This is called by RADEONPreInit to set up the default visual */static Bool RADEONPreInitVisual(ScrnInfoPtr pScrn){    RADEONInfoPtr  info = RADEONPTR(pScrn);    if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb))	return FALSE;    switch (pScrn->depth) {    case 8:    case 15:    case 16:    case 24:	break;    default:	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,		   "Given depth (%d) is not supported by %s driver\n",		   pScrn->depth, RADEON_DRIVER_NAME);	return FALSE;    }    xf86PrintDepthBpp(pScrn);    info->fifo_slots                 = 0;    info->pix24bpp                   = xf86GetBppFromDepth(pScrn,							   pScrn->depth);    info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel;    info->CurrentLayout.depth        = pScrn->depth;    info->CurrentLayout.pixel_bytes  = pScrn->bitsPerPixel / 8;    info->CurrentLayout.pixel_code   = (pScrn->bitsPerPixel != 16				       ? pScrn->bitsPerPixel				       : pScrn->depth);    if (info->pix24bpp == 24) {	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,		   "Radeon does NOT support 24bpp\n");	return FALSE;    }    xf86DrvMsg(pScrn->scrnIndex, X_INFO,	       "Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n",	       pScrn->depth,	       info->CurrentLayout.pixel_bytes,	       info->CurrentLayout.pixel_bytes > 1 ? "s" : "",	       info->pix24bpp);    if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE;    if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) {	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,		   "Default visual (%s) is not supported at depth %d\n",		   xf86GetVisualName(pScrn->defaultVisual), pScrn->depth);	return FALSE;    }    return TRUE;}/* This is called by RADEONPreInit to handle all color weight issues */static Bool RADEONPreInitWeight(ScrnInfoPtr pScrn){    RADEONInfoPtr  info = RADEONPTR(pScrn);				/* Save flag for 6 bit DAC to use for				   setting CRTC registers.  Otherwise use				   an 8 bit DAC, even if xf86SetWeight sets				   pScrn->rgbBits to some value other than				   8. */    info->dac6bits = FALSE;    if (pScrn->depth > 8) {	rgb  defaultWeight = { 0, 0, 0 };	if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) return FALSE;    } else {	pScrn->rgbBits = 8;	if (xf86ReturnOptValBool(info->Options, OPTION_DAC_6BIT, FALSE)) {	    pScrn->rgbBits = 6;	    info->dac6bits = TRUE;	}    }    xf86DrvMsg(pScrn->scrnIndex, X_INFO,	       "Using %d bits per RGB (%d bit DAC)\n",	       pScrn->rgbBits, info->dac6bits ? 6 : 8);    return TRUE;}static void RADEONGetVRamType(ScrnInfoPtr pScrn){    RADEONInfoPtr  info   = RADEONPTR(pScrn);    unsigned char *RADEONMMIO = info->MMIO;    CARD32 tmp;     if (info->IsIGP || (info->ChipFamily >= CHIP_FAMILY_R300) ||	(INREG(RADEON_MEM_SDRAM_MODE_REG) & (1<<30))) 	info->IsDDR = TRUE;    else	info->IsDDR = FALSE;    tmp = INREG(RADEON_MEM_CNTL);    if ((info->ChipFamily == CHIP_FAMILY_R300) ||	(info->ChipFamily == CHIP_FAMILY_R350) ||	(info->ChipFamily == CHIP_FAMILY_RV350)) {	tmp &=  R300_MEM_NUM_CHANNELS_MASK;	switch (tmp) {	case 0: info->RamWidth = 64; break;	case 1: info->RamWidth = 128; break;	case 2: info->RamWidth = 256; break;	default: info->RamWidth = 128; break;	}    } else if ((info->ChipFamily == CHIP_FAMILY_RV100) ||	       (info->ChipFamily == CHIP_FAMILY_RS100) ||	       (info->ChipFamily == CHIP_FAMILY_RS200)){	if (tmp & RV100_HALF_MODE) info->RamWidth = 32;	else info->RamWidth = 64;    } else {	if (tmp & RADEON_MEM_NUM_CHANNELS_MASK) info->RamWidth = 128;	else info->RamWidth = 64;    }    /* This may not be correct, as some cards can have half of channel disabled      * ToDo: identify these cases     */}/* This is called by RADEONPreInit to handle config file overrides for * things like chipset and memory regions.  Also determine memory size * and type.  If memory type ever needs an override, put it in this * routine. */static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn){    RADEONInfoPtr  info   = RADEONPTR(pScrn);    EntityInfoPtr  pEnt   = info->pEnt;    GDevPtr        dev    = pEnt->device;    MessageType    from;    unsigned char *RADEONMMIO = info->MMIO;#ifdef XF86DRI    const char *s;#endif				/* Chipset */    from = X_PROBED;    if (dev->chipset && *dev->chipset) {	info->Chipset  = xf86StringToToken(RADEONChipsets, dev->chipset);	from           = X_CONFIG;    } else if (dev->chipID >= 0) {	info->Chipset  = dev->chipID;	from           = X_CONFIG;    } else {	info->Chipset = info->PciInfo->chipType;    }    pScrn->chipset = (char *)xf86TokenToString(RADEONChipsets, info->Chipset);    if (!pScrn->chipset) {	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,		   "ChipID 0x%04x is not recognized\n", info->Chipset);	return FALSE;    }    if (info->Chipset < 0) {	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,		   "Chipset \"%s\" is not recognized\n", pScrn->chipset);	return FALSE;    }    xf86DrvMsg(pScrn->scrnIndex, from,	       "Chipset: \"%s\" (ChipID = 0x%04x)\n",	       pScrn->chipset,	       info->Chipset);    info->HasCRTC2 = TRUE;    info->IsMobility = FALSE;    info->IsIGP = FALSE;    switch (info->Chipset) {    case PCI_CHIP_RADEON_LY:    case PCI_CHIP_RADEON_LZ:	info->IsMobility = TRUE;	info->ChipFamily = CHIP_FAMILY_RV100;	break;    case PCI_CHIP_RV100_QY:    case PCI_CHIP_RV100_QZ:	info->ChipFamily = CHIP_FAMILY_RV100;	break;    case PCI_CHIP_RS100_4336:	info->IsMobility = TRUE;    case PCI_CHIP_RS100_4136:	info->ChipFamily = CHIP_FAMILY_RS100;	info->IsIGP = TRUE;	break;    case PCI_CHIP_RS200_4337:	info->IsMobility = TRUE;    case PCI_CHIP_RS200_4137:	info->ChipFamily = CHIP_FAMILY_RS200;	info->IsIGP = TRUE;	break;    case PCI_CHIP_RS250_4437:	info->IsMobility = TRUE;    case PCI_CHIP_RS250_4237:	info->ChipFamily = CHIP_FAMILY_RS200;	info->IsIGP = TRUE;	break;    case PCI_CHIP_R200_BB:    case PCI_CHIP_R200_BC:    case PCI_CHIP_R200_QH:    case PCI_CHIP_R200_QL:    case PCI_CHIP_R200_QM:	info->ChipFamily = CHIP_FAMILY_R200;	break;    case PCI_CHIP_RADEON_LW:    case PCI_CHIP_RADEON_LX:	info->IsMobility = TRUE;    case PCI_CHIP_RV200_QW: /* RV200 desktop */    case PCI_CHIP_RV200_QX:	info->ChipFamily = CHIP_FAMILY_RV200;	break;    case PCI_CHIP_RV250_Ld:    case PCI_CHIP_RV250_Lf:    case PCI_CHIP_RV250_Lg:	info->IsMobility = TRUE;    case PCI_CHIP_RV250_If:    case PCI_CHIP_RV250_Ig:	info->ChipFamily = CHIP_FAMILY_RV250;	break;    case PCI_CHIP_RS300_5835:	info->IsMobility = TRUE;    case PCI_CHIP_RS300_5834:	info->ChipFamily = CHIP_FAMILY_RS300;	info->IsIGP = TRUE;	break;    case PCI_CHIP_RV280_5C61:    case PCI_CHIP_RV280_5C63:	info->IsMobility = TRUE;    case PCI_CHIP_RV280_5960:    case PCI_CHIP_RV280_5961:    case PCI_CHIP_RV280_5962:    case PCI_CHIP_RV280_5964:	info->ChipFamily = CHIP_FAMILY_RV280;	break;    case PCI_CHIP_R300_AD:    case PCI_CHIP_R300_AE:    case PCI_CHIP_R300_AF:    case PCI_CHIP_R300_AG:    case PCI_CHIP_R300_ND:    case PCI_CHIP_R300_NE:    case PCI_CHIP_R300_NF:    case PCI_CHIP_R300_NG:	info->ChipFamily = CHIP_FAMILY_R300;        break;    case PCI_CHIP_RV350_NP:    case PCI_CHIP_RV350_NQ:    case PCI_CHIP_RV350_NR:    case PCI_CHIP_RV350_NS:    case PCI_CHIP_RV350_NT:    case PCI_CHIP_RV350_NV:	info->IsMobility = TRUE;    case PCI_CHIP_RV350_AP:    case PCI_CHIP_RV350_AQ:    case PCI_CHIP_RV360_AR:    case PCI_CHIP_RV350_AS:    case PCI_CHIP_RV350_AT:    case PCI_CHIP_RV350_AV:	info->ChipFamily = CHIP_FAMILY_RV350;        break;    case PCI_CHIP_R350_AH:    case PCI_CHIP_R350_AI:    case PCI_CHIP_R350_AJ:    case PCI_CHIP_R350_AK:    case PCI_CHIP_R350_NH:    case PCI_CHIP_R350_NI:    case PCI_CHIP_R350_NK:    case PCI_CHIP_R360_NJ:	info->ChipFamily = CHIP_FAMILY_R350;        break;    default:	/* Original Radeon/7200 */	info->ChipFamily = CHIP_FAMILY_RADEON;	info->HasCRTC2 = FALSE;    }				/* Framebuffer */    from               = X_PROBED;    info->LinearAddr   = info->PciInfo->memBase[0] & 0xfe000000;    pScrn->memPhysBase = info->LinearAddr;    if (dev->MemBase) {	xf86DrvMsg(pScrn->scrnIndex, X_INFO,		   "Linear address override, using 0x%08lx instead of 0x%08lx\n",		   dev->MemBase,		   info->LinearAddr);	info->LinearAddr = dev->MemBase;	from             = X_CONFIG;    } else if (!info->LinearAddr) {	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,		   "No valid linear framebuffer address\n");	return FALSE;    }    xf86DrvMsg(pScrn->scrnIndex, from,	       "Linear framebuffer at 0x%08lx\n", info->LinearAddr);				/* BIOS */    from              = X_PROBED;    info->BIOSAddr    = info->PciInfo->biosBase & 0xfffe0000;    if (dev->BiosBase) {	xf86DrvMsg(pScrn->scrnIndex, X_INFO,		   "BIOS address override, using 0x%08lx instead of 0x%08lx\n",		   dev->BiosBase,		   info->BIOSAddr);	info->BIOSAddr = dev->BiosBase;	from           = X_CONFIG;    }    if (info->BIOSAddr) {	xf86DrvMsg(pScrn->scrnIndex, from,		   "BIOS at 0x%08lx\n", info->BIOSAddr);    } 				/* Read registers used to determine options */    from                     = X_PROBED;    if (info->FBDev)	pScrn->videoRam      = fbdevHWGetVidmem(pScrn) / 1024;    else if ((info->ChipFamily == CHIP_FAMILY_RS100) || 	     (info->ChipFamily == CHIP_FAMILY_RS200) ||	     (info->ChipFamily == CHIP_FAMILY_RS300)) {        CARD32 tom = INREG(RADEON_NB_TOM);        pScrn->videoRam = (((tom >> 16) - 			    (tom & 0xffff) + 1) << 6);	OUTREG(RADEON_MC_FB_LOCATION, tom);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -