📄 i830_driver.c
字号:
pipe = 0;#if 0 ErrorF("PIPE %d\n",pipe);#endif } switch ((VODA & 0x00000F00) >> 8) { case 0x0: case 0x1: /* CRT */ devices |= PIPE_CRT << (pipe == 1 ? 8 : 0); break; case 0x2: /* TV/HDTV */ devices |= PIPE_TV << (pipe == 1 ? 8 : 0); break; case 0x3: /* DFP */ devices |= PIPE_DFP << (pipe == 1 ? 8 : 0); break; case 0x4: /* LFP */ devices |= PIPE_LFP << (pipe == 1 ? 8 : 0); break; } } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ACPI Toggle devices 0x%x\n", devices); return devices;}static intGetAttachableDisplayDeviceList(ScrnInfoPtr pScrn){ vbeInfoPtr pVbe = I830PTR(pScrn)->pVbe; int i; DPRINTF(PFX, "GetAttachableDisplayDeviceList\n"); pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f64; pVbe->pInt10->bx = 0x900; pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base); pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base); xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (!Check5fStatus(pScrn, 0x5f64, pVbe->pInt10->ax)) return 0; for (i=0; i<(pVbe->pInt10->cx & 0xff); i++) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Attachable device 0x%lx.\n", ((CARD32*)pVbe->memory)[i]); return pVbe->pInt10->cx & 0xffff;}static intBitToRefresh(int bits){ int i; for (i = 0; i < nrefreshes; i++) if (bits & (1 << i)) return i830refreshes[i]; return 0;}static intGetRefreshRate(ScrnInfoPtr pScrn, int mode, int *availRefresh){ vbeInfoPtr pVbe = I830PTR(pScrn)->pVbe; DPRINTF(PFX, "GetRefreshRate\n"); /* Only 8-bit mode numbers are supported. */ if (mode & 0x100) return 0; pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f05; pVbe->pInt10->bx = (mode & 0xff) | 0x100; xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (Check5fStatus(pScrn, 0x5f05, pVbe->pInt10->ax)) { if (availRefresh) *availRefresh = pVbe->pInt10->bx; return BitToRefresh(pVbe->pInt10->cx); } else return 0;}struct panelid { short hsize; short vsize; short fptype; char redbpp; char greenbpp; char bluebpp; char reservedbpp; int rsvdoffscrnmemsize; int rsvdoffscrnmemptr; char reserved[14];};static voidI830InterpretPanelID(int scrnIndex, unsigned char *tmp){ ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; struct panelid *block = (struct panelid *)tmp;#define PANEL_DEFAULT_HZ 60 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PanelID returned panel resolution : %dx%d\n", block->hsize, block->vsize); /* If we get bogus values from this, don't accept it */ if (block->hsize == 0 || block->vsize == 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Bad Panel resolution - ignoring panelID\n"); return; } /* If we have monitor timings then don't overwrite them */ if (pScrn->monitor->nHsync > 0 && pScrn->monitor->nVrefresh > 0) return; /* With panels, we're always assuming a refresh of 60Hz */ pScrn->monitor->nHsync = 1; pScrn->monitor->nVrefresh = 1; /* Give a little tolerance for the selected panel */ pScrn->monitor->hsync[0].lo = (float)((PANEL_DEFAULT_HZ/1.05)*block->vsize)/1000; pScrn->monitor->hsync[0].hi = (float)((PANEL_DEFAULT_HZ/0.95)*block->vsize)/1000; pScrn->monitor->vrefresh[0].lo = (float)PANEL_DEFAULT_HZ; pScrn->monitor->vrefresh[0].hi = (float)PANEL_DEFAULT_HZ;}/* This should probably go into the VBE layer */static unsigned char *vbeReadPanelID(vbeInfoPtr pVbe){ int RealOff = pVbe->real_mode_base; pointer page = pVbe->memory; unsigned char *tmp = NULL; int screen = pVbe->pInt10->scrnIndex; pVbe->pInt10->ax = 0x4F11; pVbe->pInt10->bx = 0x01; pVbe->pInt10->cx = 0; pVbe->pInt10->dx = 0; pVbe->pInt10->es = SEG_ADDR(RealOff); pVbe->pInt10->di = SEG_OFF(RealOff); pVbe->pInt10->num = 0x10; xf86ExecX86int10(pVbe->pInt10); if ((pVbe->pInt10->ax & 0xff) != 0x4f) { xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID invalid\n"); goto error; } switch (pVbe->pInt10->ax & 0xff00) { case 0x0: xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read successfully\n"); tmp = (unsigned char *)xnfalloc(32); memcpy(tmp,page,32); break; case 0x100: xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read failed\n"); break; default: xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID unknown failure %i\n", pVbe->pInt10->ax & 0xff00); break; } error: return tmp;}static voidvbeDoPanelID(vbeInfoPtr pVbe){ unsigned char *PanelID_data; if (!pVbe) return; PanelID_data = vbeReadPanelID(pVbe); if (!PanelID_data) return; I830InterpretPanelID(pVbe->pInt10->scrnIndex, PanelID_data);}int I830GetBestRefresh(ScrnInfoPtr pScrn, int refresh){ int i; for (i = nrefreshes - 1; i >= 0; i--) { /* * Look for the highest value that the requested (refresh + 2) is * greater than or equal to. */ if (i830refreshes[i] <= (refresh + 2)) break; } /* i can be 0 if the requested refresh was higher than the max. */ if (i == 0) { if (refresh >= i830refreshes[nrefreshes - 1]) i = nrefreshes - 1; } return i;}static intSetRefreshRate(ScrnInfoPtr pScrn, int mode, int refresh){ vbeInfoPtr pVbe = I830PTR(pScrn)->pVbe; int i = I830GetBestRefresh(pScrn, refresh); DPRINTF(PFX, "SetRefreshRate: mode 0x%x, refresh: %d\n", mode, refresh); DPRINTF(PFX, "Setting refresh rate to %dHz for mode 0x%02x\n", i830refreshes[i], mode & 0xff); /* Only 8-bit mode numbers are supported. */ if (mode & 0x100) return 0; pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f05; pVbe->pInt10->bx = mode & 0xff; pVbe->pInt10->cx = 1 << i; xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (Check5fStatus(pScrn, 0x5f05, pVbe->pInt10->ax)) return i830refreshes[i]; else return 0;}#if 0static BoolSetPowerStatus(ScrnInfoPtr pScrn, int mode){ vbeInfoPtr pVbe = I830PTR(pScrn)->pVbe; pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f64; pVbe->pInt10->bx = 0x0800 | mode; pVbe->pInt10->cx = 0x0000; xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (Check5fStatus(pScrn, 0x5f64, pVbe->pInt10->ax)) return TRUE; return FALSE;}#endifstatic BoolGetModeSupport(ScrnInfoPtr pScrn, int modePipeA, int modePipeB, int devicesPipeA, int devicesPipeB, int *maxBandwidth, int *bandwidthPipeA, int *bandwidthPipeB){ vbeInfoPtr pVbe = I830PTR(pScrn)->pVbe; DPRINTF(PFX, "GetModeSupport: modes 0x%x, 0x%x, devices: 0x%x, 0x%x\n", modePipeA, modePipeB, devicesPipeA, devicesPipeB); /* Only 8-bit mode numbers are supported. */ if ((modePipeA & 0x100) || (modePipeB & 0x100)) return FALSE; pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f28; pVbe->pInt10->bx = (modePipeA & 0xff) | ((modePipeB & 0xff) << 8); if ((devicesPipeA & 0x80) || (devicesPipeB & 0x80)) pVbe->pInt10->cx = 0x8000; else pVbe->pInt10->cx = (devicesPipeA & 0xff) | ((devicesPipeB & 0xff) << 8); xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (Check5fStatus(pScrn, 0x5f28, pVbe->pInt10->ax)) { if (maxBandwidth) *maxBandwidth = pVbe->pInt10->cx; if (bandwidthPipeA) *bandwidthPipeA = pVbe->pInt10->dx & 0xffff; /* XXX For XFree86 4.2.0 and earlier, ->dx is truncated to 16 bits. */ if (bandwidthPipeB) *bandwidthPipeB = (pVbe->pInt10->dx >> 16) & 0xffff; return TRUE; } else return FALSE;}#if 0static intGetLFPCompMode(ScrnInfoPtr pScrn){ vbeInfoPtr pVbe = I830PTR(pScrn)->pVbe; DPRINTF(PFX, "GetLFPCompMode\n"); pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f61; pVbe->pInt10->bx = 0x100; xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (Check5fStatus(pScrn, 0x5f61, pVbe->pInt10->ax)) return pVbe->pInt10->cx & 0xffff; else return -1;}static BoolSetLFPCompMode(ScrnInfoPtr pScrn, int compMode){ vbeInfoPtr pVbe = I830PTR(pScrn)->pVbe; DPRINTF(PFX, "SetLFPCompMode: compMode %d\n", compMode); pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f61; pVbe->pInt10->bx = 0; pVbe->pInt10->cx = compMode; xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); return Check5fStatus(pScrn, 0x5f61, pVbe->pInt10->ax);}#endifstatic intGetDisplayDevices(ScrnInfoPtr pScrn){ I830Ptr pI830 = I830PTR(pScrn); vbeInfoPtr pVbe = pI830->pVbe; DPRINTF(PFX, "GetDisplayDevices\n");#if 0 { CARD32 temp; ErrorF("ADPA is 0x%08x\n", INREG(ADPA)); ErrorF("DVOA is 0x%08x\n", INREG(DVOA)); ErrorF("DVOB is 0x%08x\n", INREG(DVOB)); ErrorF("DVOC is 0x%08x\n", INREG(DVOC)); ErrorF("LVDS is 0x%08x\n", INREG(LVDS)); temp = INREG(DVOA_SRCDIM); ErrorF("DVOA_SRCDIM is 0x%08x (%d x %d)\n", temp, (temp >> 12) & 0xfff, temp & 0xfff); temp = INREG(DVOB_SRCDIM); ErrorF("DVOB_SRCDIM is 0x%08x (%d x %d)\n", temp, (temp >> 12) & 0xfff, temp & 0xfff); temp = INREG(DVOC_SRCDIM); ErrorF("DVOC_SRCDIM is 0x%08x (%d x %d)\n", temp, (temp >> 12) & 0xfff, temp & 0xfff); ErrorF("SWF0 is 0x%08x\n", INREG(SWF0)); ErrorF("SWF4 is 0x%08x\n", INREG(SWF4)); }#endif pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f64; pVbe->pInt10->bx = 0x100; xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (Check5fStatus(pScrn, 0x5f64, pVbe->pInt10->ax)) { return pVbe->pInt10->cx & 0xffff; } else { if (pI830->PciInfo->chipType == PCI_CHIP_E7221_G) /* FIXED CONFIG */ return PIPE_CRT; else return -1; }}static intGetBIOSPipe(ScrnInfoPtr pScrn){ I830Ptr pI830 = I830PTR(pScrn); vbeInfoPtr pVbe = pI830->pVbe; int pipe; DPRINTF(PFX, "GetBIOSPipe:\n"); /* single pipe machines should always return Pipe A */ if (pI830->availablePipes == 1) return 0; pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f1c; pVbe->pInt10->bx = 0x100; xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (Check5fStatus(pScrn, 0x5f1c, pVbe->pInt10->ax)) { if (pI830->newPipeSwitch) { pipe = ((pVbe->pInt10->bx & 0x0001)); } else { pipe = ((pVbe->pInt10->cx & 0x0100) >> 8); } return pipe; } /* failed, assume pipe A */ return 0;}static BoolSetBIOSPipe(ScrnInfoPtr pScrn, int pipe){ I830Ptr pI830 = I830PTR(pScrn); vbeInfoPtr pVbe = pI830->pVbe; DPRINTF(PFX, "SetBIOSPipe: pipe 0x%x\n", pipe); /* single pipe machines should always return TRUE */ if (pI830->availablePipes == 1) return TRUE; pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0x5f1c; if (pI830->newPipeSwitch) { pVbe->pInt10->bx = pipe; pVbe->pInt10->cx = 0; } else { pVbe->pInt10->bx = 0x0; pVbe->pInt10->cx = pipe << 8; } xf86ExecX86int10_wrapper(pVbe->pInt10, pScrn); if (Check5fStatus(pScrn, 0x5f1c, pVbe->pInt10->ax)) { return TRUE; } return FALSE;}static BoolSetPipeAccess(ScrnInfoPtr pScrn){ I830Ptr pI830 = I830PTR(pScrn); /* Don't try messing with the pipe, unless we're dual head */ if (xf86IsEntityShared(pScrn->entityList[0]) || pI830->Clone || pI830->origPipe != pI830->pipe) { if (!SetBIOSPipe(pScrn, pI830->pipe)) return FALSE; } return TRUE;}static BoolI830Set640x480(ScrnInfoPtr pScrn){ I830Ptr pI830 = I830PTR(pScrn); int m = 0x30; /* 640x480 8bpp */ switch (pScrn->depth) { case 15: m = 0x40; break; case 16: m = 0x41; break; case 24: m = 0x50; break; } m |= (1 << 15) | (1 << 14); return VBESetVBEMode(pI830->pVbe, m, NULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -