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

📄 i830_driver.c

📁 是由intel提供的针对intel显卡915以上系列的linux驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
	 memsize = MB(1) - KB(range);	 break;      case I855_GMCH_GMS_STOLEN_4M:	 memsize = MB(4) - KB(range);	 break;      case I855_GMCH_GMS_STOLEN_8M:	 memsize = MB(8) - KB(range);	 break;      case I855_GMCH_GMS_STOLEN_16M:	 memsize = MB(16) - KB(range);	 break;      case I855_GMCH_GMS_STOLEN_32M:	 memsize = MB(32) - KB(range);	 break;      case I915G_GMCH_GMS_STOLEN_48M:	 if (IS_I9XX(pI830))	    memsize = MB(48) - KB(range);	 break;      case I915G_GMCH_GMS_STOLEN_64M:	 if (IS_I9XX(pI830))	    memsize = MB(64) - KB(range);	 break;      }   } else {      switch (gmch_ctrl & I830_GMCH_GMS_MASK) {      case I830_GMCH_GMS_STOLEN_512:	 memsize = KB(512) - KB(range);	 break;      case I830_GMCH_GMS_STOLEN_1024:	 memsize = MB(1) - KB(range);	 break;      case I830_GMCH_GMS_STOLEN_8192:	 memsize = MB(8) - KB(range);	 break;      case I830_GMCH_GMS_LOCAL:	 memsize = 0;	 xf86DrvMsg(pScrn->scrnIndex, X_WARNING,		    "Local memory found, but won't be used.\n");	 break;      }   }   if (memsize > 0) {      xf86DrvMsg(pScrn->scrnIndex, X_INFO,		 "detected %d kB stolen memory.\n", memsize / 1024);   } else {      xf86DrvMsg(pScrn->scrnIndex, X_INFO, "no video memory detected.\n");   }   return memsize;}static BoolI830MapMMIO(ScrnInfoPtr pScrn){   int mmioFlags;   I830Ptr pI830 = I830PTR(pScrn);#if !defined(__alpha__)   mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT;#else   mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT | VIDMEM_SPARSE;#endif   pI830->MMIOBase = xf86MapPciMem(pScrn->scrnIndex, mmioFlags,				   pI830->PciTag,				   pI830->MMIOAddr, I810_REG_SIZE);   if (!pI830->MMIOBase)      return FALSE;   return TRUE;}static BoolI830MapMem(ScrnInfoPtr pScrn){   I830Ptr pI830 = I830PTR(pScrn);   long i;   for (i = 2; i < pI830->FbMapSize; i <<= 1) ;   pI830->FbMapSize = i;   if (!I830MapMMIO(pScrn))      return FALSE;   pI830->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,				 pI830->PciTag,				 pI830->LinearAddr, pI830->FbMapSize);   if (!pI830->FbBase)      return FALSE;   if (I830IsPrimary(pScrn))   pI830->LpRing->virtual_start = pI830->FbBase + pI830->LpRing->mem.Start;   return TRUE;}static voidI830UnmapMMIO(ScrnInfoPtr pScrn){   I830Ptr pI830 = I830PTR(pScrn);   xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pI830->MMIOBase,		   I810_REG_SIZE);   pI830->MMIOBase = 0;}static BoolI830UnmapMem(ScrnInfoPtr pScrn){   I830Ptr pI830 = I830PTR(pScrn);   xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pI830->FbBase,		   pI830->FbMapSize);   pI830->FbBase = 0;   I830UnmapMMIO(pScrn);   return TRUE;}#ifndef HAVE_GET_PUT_BIOSMEMSIZE#define HAVE_GET_PUT_BIOSMEMSIZE 1#endif#if HAVE_GET_PUT_BIOSMEMSIZE/* * Tell the BIOS how much video memory is available.  The BIOS call used * here won't always be available. */static BoolPutBIOSMemSize(ScrnInfoPtr pScrn, int memSize){   vbeInfoPtr pVbe = I830PTR(pScrn)->pVbe;   DPRINTF(PFX, "PutBIOSMemSize: %d kB\n", memSize / 1024);   pVbe->pInt10->num = 0x10;   pVbe->pInt10->ax = 0x5f11;   pVbe->pInt10->bx = 0;   pVbe->pInt10->cx = memSize / GTT_PAGE_SIZE;   xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn);   return Check5fStatus(pScrn, 0x5f11, pVbe->pInt10->ax);}/* * This reports what the previous VBEGetVBEInfo() found.  Be sure to call * VBEGetVBEInfo() after changing the BIOS memory size view.  If * a separate BIOS call is added for this, it can be put here.  Only * return a valid value if the funtionality for PutBIOSMemSize() * is available. */static intGetBIOSMemSize(ScrnInfoPtr pScrn){   I830Ptr pI830 = I830PTR(pScrn);   int memSize = KB(pI830->vbeInfo->TotalMemory * 64);   DPRINTF(PFX, "GetBIOSMemSize\n");   if (PutBIOSMemSize(pScrn, memSize))      return memSize;   else      return -1;}#endif/* * These three functions allow the video BIOS's view of the available video * memory to be changed.  This is currently implemented only for the 830 * and 845G, which can do this via a BIOS scratch register that holds the * BIOS's view of the (pre-reserved) memory size.  If another mechanism * is available in the future, it can be plugged in here.   * * The mapping used for the 830/845G scratch register's low 4 bits is: * *             320k => 0 *             832k => 1 *            8000k => 8 * * The "unusual" values are the 512k, 1M, 8M pre-reserved memory, less * overhead, rounded down to the BIOS-reported 64k granularity. */static BoolSaveBIOSMemSize(ScrnInfoPtr pScrn){   I830Ptr pI830 = I830PTR(pScrn);   DPRINTF(PFX, "SaveBIOSMemSize\n");   pI830->useSWF1 = FALSE;#if HAVE_GET_PUT_BIOSMEMSIZE   if ((pI830->saveBIOSMemSize = GetBIOSMemSize(pScrn)) != -1)      return TRUE;#endif   if (IS_I830(pI830) || IS_845G(pI830)) {      pI830->useSWF1 = TRUE;      pI830->saveSWF1 = INREG(SWF1) & 0x0f;      /*       * This is for sample purposes only.  pI830->saveBIOSMemSize isn't used       * when pI830->useSWF1 is TRUE.       */      switch (pI830->saveSWF1) {      case 0:	 pI830->saveBIOSMemSize = KB(320);	 break;      case 1:	 pI830->saveBIOSMemSize = KB(832);	 break;      case 8:	 pI830->saveBIOSMemSize = KB(8000);	 break;      default:	 pI830->saveBIOSMemSize = 0;	 break;      }      return TRUE;   }   return FALSE;}/* * TweakMemorySize() tweaks the BIOS image to set the correct size. * Original implementation by Christian Zietz in a stand-alone tool. */static CARD32TweakMemorySize(ScrnInfoPtr pScrn, CARD32 newsize, Bool preinit){#define SIZE 0x10000#define _855_IDOFFSET (-23)#define _845_IDOFFSET (-19)        const char *MAGICstring = "Total time for VGA POST:";    const int len = strlen(MAGICstring);    I830Ptr pI830 = I830PTR(pScrn);    volatile char *position;    char *biosAddr;    CARD32 oldsize;    CARD32 oldpermission;    CARD32 ret = 0;    int i,j = 0;    int reg = (IS_845G(pI830) || IS_I865G(pI830)) ? _845_DRAM_RW_CONTROL	: _855_DRAM_RW_CONTROL;        PCITAG tag =pciTag(0,0,0);    if(!pI830->PciInfo        || !(IS_845G(pI830) || IS_I85X(pI830) || IS_I865G(pI830)))	return 0;    if (!pI830->pVbe)	return 0;    biosAddr = xf86int10Addr(pI830->pVbe->pInt10, 				    pI830->pVbe->pInt10->BIOSseg << 4);    if (!pI830->BIOSMemSizeLoc) {	if (!preinit)	    return 0;	/* Search for MAGIC string */	for (i = 0; i < SIZE; i++) {	    if (biosAddr[i] == MAGICstring[j]) {		if (++j == len)		    break;	    } else {		i -= j;		j = 0;	    }	}	if (j < len) return 0;	pI830->BIOSMemSizeLoc =  (i - j + 1 + (IS_845G(pI830)					    ? _845_IDOFFSET : _855_IDOFFSET));    }        position = biosAddr + pI830->BIOSMemSizeLoc;    oldsize = *(CARD32 *)position;    ret = oldsize - 0x21000;        /* verify that register really contains current size */    if (preinit && ((ret >> 16) !=  pI830->vbeInfo->TotalMemory))	return 0;    oldpermission = pciReadLong(tag, reg);    pciWriteLong(tag, reg, DRAM_WRITE | (oldpermission & 0xffff));         *(CARD32 *)position = newsize + 0x21000;    if (preinit) {	/* reinitialize VBE for new size */	VBEFreeVBEInfo(pI830->vbeInfo);	vbeFree(pI830->pVbe);	pI830->pVbe = VBEInit(NULL, pI830->pEnt->index);	pI830->vbeInfo = VBEGetVBEInfo(pI830->pVbe);		/* verify that change was successful */	if (pI830->vbeInfo->TotalMemory != (newsize >> 16)){	    ret = 0;	    *(CARD32 *)position = oldsize;	} else {	    pI830->BIOSMemorySize = KB(pI830->vbeInfo->TotalMemory * 64);	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 		       "Tweak BIOS image to %d kB VideoRAM\n",		       (int)(pI830->BIOSMemorySize / 1024));	}    }    pciWriteLong(tag, reg, oldpermission);     return ret;}static voidRestoreBIOSMemSize(ScrnInfoPtr pScrn){   I830Ptr pI830 = I830PTR(pScrn);   CARD32 swf1;   DPRINTF(PFX, "RestoreBIOSMemSize\n");   if (TweakMemorySize(pScrn, pI830->saveBIOSMemSize,FALSE))       return;   if (!pI830->overrideBIOSMemSize)      return;#if HAVE_GET_PUT_BIOSMEMSIZE   if (!pI830->useSWF1) {      PutBIOSMemSize(pScrn, pI830->saveBIOSMemSize);      return;   }#endif   if ((IS_I830(pI830) || IS_845G(pI830)) && pI830->useSWF1) {      swf1 = INREG(SWF1);      swf1 &= ~0x0f;      swf1 |= (pI830->saveSWF1 & 0x0f);      OUTREG(SWF1, swf1);   }}static voidSetBIOSMemSize(ScrnInfoPtr pScrn, int newSize){   I830Ptr pI830 = I830PTR(pScrn);   unsigned long swf1;   Bool mapped;   DPRINTF(PFX, "SetBIOSMemSize: %d kB\n", newSize / 1024);   if (!pI830->overrideBIOSMemSize)      return;#if HAVE_GET_PUT_BIOSMEMSIZE   if (!pI830->useSWF1) {      PutBIOSMemSize(pScrn, newSize);      return;   }#endif   if ((IS_I830(pI830) || IS_845G(pI830)) && pI830->useSWF1) {      unsigned long newSWF1;      /* Need MMIO access here. */      mapped = (pI830->MMIOBase != NULL);      if (!mapped)	 I830MapMMIO(pScrn);      if (newSize <= KB(832))	 newSWF1 = 1;      else	 newSWF1 = 8;      swf1 = INREG(SWF1);      xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Before: SWF1 is 0x%08lx\n", swf1);      swf1 &= ~0x0f;      swf1 |= (newSWF1 & 0x0f);      xf86DrvMsg(pScrn->scrnIndex, X_INFO, "After: SWF1 is 0x%08lx\n", swf1);      OUTREG(SWF1, swf1);      if (!mapped)	 I830UnmapMMIO(pScrn);   }}static CARD32 val8[256];static voidI830LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,		LOCO * colors, VisualPtr pVisual){   I830Ptr pI830;   int i,j, index;   unsigned char r, g, b;   CARD32 val, temp;   int palreg;   int dspreg, dspbase;   DPRINTF(PFX, "I830LoadPalette: numColors: %d\n", numColors);   pI830 = I830PTR(pScrn);   if (pI830->pipe == 0) {      palreg = PALETTE_A;      dspreg = DSPACNTR;      dspbase = DSPABASE;   } else {      palreg = PALETTE_B;      dspreg = DSPBCNTR;      dspbase = DSPBBASE;   }   /* To ensure gamma is enabled we need to turn off and on the plane */   temp = INREG(dspreg);   OUTREG(dspreg, temp & ~(1<<31));   OUTREG(dspbase, INREG(dspbase));   OUTREG(dspreg, temp | DISPPLANE_GAMMA_ENABLE);   OUTREG(dspbase, INREG(dspbase));   /* It seems that an initial read is needed. */   temp = INREG(palreg);   switch(pScrn->depth) {   case 15:      for (i = 0; i < numColors; i++) {         index = indices[i];         r = colors[index].red;         g = colors[index].green;         b = colors[index].blue;	 val = (r << 16) | (g << 8) | b;         for (j = 0; j < 8; j++) {	    OUTREG(palreg + index * 32 + (j * 4), val);         }      }      break;   case 16:      for (i = 0; i < numColors; i++) {         index = indices[i];	 r   = colors[index / 2].red;	 g   = colors[index].green;	 b   = colors[index / 2].blue;	 val = (r << 16) | (g << 8) | b;	 OUTREG(palreg + index * 16, val);	 OUTREG(palreg + index * 16 + 4, val);	 OUTREG(palreg + index * 16 + 8, val);	 OUTREG(palreg + index * 16 + 12, val);   	 if (index <= 31) {            r   = colors[index].red;	    g   = colors[(index * 2) + 1].green;	    b   = colors[index].blue;	    val = (r << 16) | (g << 8) | b;	    OUTREG(palreg + index * 32, val);	    OUTREG(palreg + index * 32 + 4, val);	    OUTREG(palreg + index * 32 + 8, val);	    OUTREG(palreg + index * 32 + 12, val);	 }      }      break;   default:#if 1      /* Dual head 8bpp modes seem to squish the primary's cmap - reload */      if (I830IsPrimary(pScrn) && xf86IsEntityShared(pScrn->entityList[0]) &&          pScrn->depth == 8) {         for(i = 0; i < numColors; i++) {	    index = indices[i];	    r = colors[index].red;	    g = colors[index].green;	    b = colors[index].blue;	    val8[index] = (r << 16) | (g << 8) | b;        }      }

⌨️ 快捷键说明

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