📄 chips.c
字号:
__svgalib_ctSize.HDisplay); /* sync. polarities */ if ((mode->flags & (PHSYNC | NHSYNC)) && (mode->flags & (PVSYNC | NVSYNC))) { if (mode->flags & (PHSYNC | NHSYNC)) { if (mode->flags & PHSYNC) moderegs[HiQVFR08] &= 0xBF; /* Alt. CRT Hsync positive */ else moderegs[HiQVFR08] |= 0x40; /* Alt. CRT Hsync negative */ } if (mode->flags & (PVSYNC | NVSYNC)) { if (mode->flags & PVSYNC) moderegs[HiQVFR08] &= 0x7F; /* Alt. CRT Vsync positive */ else moderegs[HiQVFR08] |= 0x80; /* Alt. CRT Vsync negative */ } } if (modeinfo->bitsPerPixel == 16) { moderegs[HiQVXR81] = (moderegs[HiQVXR81] & 0xF0) | 0x4; /* 15bpp */ moderegs[HiQVFR10] |= 0x0C; /*Colour Panel */ moderegs[HiQVXR20] = 0x10; /*BitBLT Draw Mode for 16 bpp */ if (modeinfo->greenWeight != 5) moderegs[HiQVXR81] |= 0x01; /*16bpp */ } else if (modeinfo->bitsPerPixel == 24) { moderegs[HiQVXR81] = (moderegs[HiQVXR81] & 0xF0) | 0x6; /* 24bpp */ moderegs[HiQVXR20] = 0x20; /*BitBLT Draw Mode for 24 bpp */ } /* STN specific */ if (IS_STN(__svgalib_ctPanelType)) { moderegs[HiQVFR11] &= ~0x03;/* FRC clear */ moderegs[HiQVFR11] &= ~0x8C;/* Dither clear */ moderegs[HiQVFR11] |= 0x01; /* 16 frame FRC */ moderegs[HiQVFR11] |= 0x84; /* Dither */ if (CHIPSchipset == CT_555 || CHIPSchipset == CT_8554 || CHIPSchipset == CT_9000) { moderegs[HiQVFR73] &= 0x4f; moderegs[HiQVFR73] |= 0x80; moderegs[HiQVFR73] |= 0x30; } if (__svgalib_ctPanelType == DD) /* Shift Clock Mask. Use to get */ moderegs[HiQVFR12] |= 0x4;/* rid of line in DSTN screens */ }}/*----------------------------------------------------------------------*//* Check if mode is interlaced *//*----------------------------------------------------------------------*/static int CHIPS_interlaced(int mode){#ifdef DEBUG printf("CHIPS: CHIPS_interlaced(%d)\n",mode);#endif /* This driver does not support interlaced mode */ return FALSE;}/*----------------------------------------------------------------------*//* Set a mode *//*----------------------------------------------------------------------*/static int CHIPS_setmode(int mode, int prv_mode){ unsigned char *regs; ModeInfo *modeinfo; ModeTiming *modetiming;#ifdef DEBUG printf("CHIPS: CHIPS_setmode(%d, %d)\n", mode, prv_mode);#endif if (CHIPSchipset == CT_545 || CHIPSchipset == CT_546 || CHIPSchipset == CT_548 || CHIPSchipset == CT_550 || CHIPSchipset == CT_554 || CHIPSchipset == CT_555 || CHIPSchipset == CT_8554 || CHIPSchipset == CT_9000 || CHIPSchipset == CT_4300) { __svgalib_driverspecs->accelspecs->operations = 0; __svgalib_driverspecs->accelspecs->ropOperations = 0; __svgalib_driverspecs->accelspecs->transparencyOperations = 0; __svgalib_driverspecs->accelspecs->ropModes = 0; __svgalib_driverspecs->accelspecs->transparencyModes = 0; } if (!CHIPS_modeavailable(mode)) { return 1; } if (mode < G640x480x256 || mode == G720x348x2) return (int) (__svgalib_vga_driverspecs.setmode(mode, prv_mode)); modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode); modetiming = malloc(sizeof(ModeTiming)); if (__svgalib_getmodetiming(modetiming, modeinfo, cardspecs)) { free(modetiming); free(modeinfo); return 1; }#ifdef MODELINE_DEBUG /*------------------------------------*/ printf("Modetiming:\n"); printf("pixelclock - %d, HDisplay - %d, HSyncStart - %d, HSyncEnd - %d, HTotal - %d\n", modetiming->pixelClock,modetiming->HDisplay,modetiming->HSyncStart, modetiming->HSyncEnd,modetiming->HTotal); printf("VDisplay - %d, VSyncStart - %d, VSyncEnd - %d, VTotal - %d, flags - %d\n", modetiming->VDisplay,modetiming->VSyncStart,modetiming->VSyncEnd, modetiming->VTotal,modetiming->flags); printf("programmedClock - %d, selectedClockNo - %d, CrtcHDisplay - %d\n", modetiming->programmedClock,modetiming->selectedClockNo,modetiming->CrtcHDisplay); printf("CrtcHSyncStart - %d, CrtcHSyncEnd - %d, CrtcHDisplay - %d, CrtcHTotal - %d\n", modetiming->CrtcHSyncStart,modetiming->CrtcHSyncEnd,modetiming->CrtcHDisplay, modetiming->CrtcHTotal); printf("CrtcVSyncStart - %d, CrtcVSyncEnd - %d, CrtcVTotal - %d\n\n", modetiming->CrtcVSyncStart,modetiming->CrtcVSyncEnd,modetiming->CrtcVTotal); printf("ModeInfo:\n"); printf("width - %d, height - %d, bytesPerPixel - %d, bitsPerPixel - %d\n", (int)modeinfo->width,(int)modeinfo->height,(int)modeinfo->bytesPerPixel, (int)modeinfo->bitsPerPixel); printf("colorBits - %d, redWeight - %d, greenWeight - %d, blueWeight - %d\n", (int)modeinfo->colorBits,(int)modeinfo->redWeight,(int)modeinfo->greenWeight, (int)modeinfo->blueWeight); printf("redOffset - %d, blueOffset - %d, greenOffset - %d\n", (int)modeinfo->redOffset,(int)modeinfo->blueOffset, (int)modeinfo->greenOffset); printf("redMask - %d, blueMask - %d, greenMask - %d, lineWidth - %d\n", (int)modeinfo->redMask,(int)modeinfo->blueMask,(int)modeinfo->greenMask, modeinfo->lineWidth); printf("realWidth - %d, realHeight - %d, flags - %d\n\n", (int)modeinfo->realWidth,(int)modeinfo->realHeight,modeinfo->flags); printf("CardSpecs:\n"); printf("videoMemory - %d, maxPixelClock8bpp - %d, flags - %d\n", cardspecs->videoMemory,cardspecs->maxPixelClock8bpp, cardspecs->flags); printf("nClocks - %d, maxHorizontalCrtc - %d, mapClock - %p\n", cardspecs->nClocks,cardspecs->maxHorizontalCrtc, cardspecs->mapClock); printf("matchProgrammableClock - %p, mapHorizontalCrtc - %p\n", cardspecs->matchProgrammableClock,cardspecs->mapHorizontalCrtc); /*------------------------------------*/#endif regs = malloc(CHIPS_TOTAL_REGS); if (ctisHiQV) { CHIPS_HiQV_initializemode(regs, modetiming, modeinfo); } else { CHIPS_initializemode(regs, modetiming, modeinfo); } free(modetiming); __svgalib_setregs(regs); CHIPS_setregs(regs, mode); if (ctFlagsSet & ctFlags_NoBitBlt) return 0; if (CHIPSchipset == CT_545 || CHIPSchipset == CT_546 || CHIPSchipset == CT_548) { if (PCIcard) { /* We are a PCI machine */ if (__svgalib_modeinfo_linearset & IS_LINEAR) { /* Linear addressing is enabled. So we can use * MMIO with linear addressing. Map the required * memory space */ ctMMIO = TRUE; __svgalib_ctMMIOPage = -1; if (__svgalib_ctMMIOBase == NULL) { __svgalib_ctMMIOBase = MMIO_mem1; } } else { if (CHIPSchipset == CT_545 || CHIPSchipset == CT_546) { /* We are a 65545 or 65546 PCI machine. We only * support acceleration on these machines with MMIO. * Hence we have to use page mode to access the * MMIO registers. */ ctMMIO = TRUE; __svgalib_ctMMIOPage = 32; /* MMIO starts at 2MBytes */ __svgalib_ctMMIOBase = __svgalib_graph_mem; } else { /* Let the register address acceleration handle this */ ctMMIO = FALSE; } } } } if (ctisHiQV) { if (__svgalib_modeinfo_linearset & IS_LINEAR) { /* Linear addressing is enabled. So we can use * MMIO with linear addressing. Map the required * memory space */ ctMMIO = TRUE; __svgalib_ctMMIOPage = -1; if (__svgalib_ctMMIOBase == NULL) { __svgalib_ctMMIOBase=MMIO_mem2; } __svgalib_ctBltDataWindow = __svgalib_ctMMIOBase + 0x10000; } else { /* Use paged addressing mode to program the MMIO registers */ ctMMIO = TRUE; __svgalib_ctMMIOPage = 64; /* MMIO starts at 4MBytes */ __svgalib_ctMMIOBase = __svgalib_graph_mem; __svgalib_ctBltDataWindow = __svgalib_graph_mem; } } if (CHIPSchipset == CT_545 || CHIPSchipset == CT_546 || CHIPSchipset == CT_548 || CHIPSchipset == CT_550 || CHIPSchipset == CT_554 || CHIPSchipset == CT_555 || CHIPSchipset == CT_8554 || CHIPSchipset == CT_9000 || CHIPSchipset == CT_4300) { __svgalib_InitializeAcceleratorInterface(modeinfo); __svgalib_driverspecs->accelspecs->operations = ACCELFLAG_FILLBOX | ACCELFLAG_SETFGCOLOR | ACCELFLAG_SETBGCOLOR | ACCELFLAG_SCREENCOPY | ACCELFLAG_SETRASTEROP | ACCELFLAG_SETTRANSPARENCY | ACCELFLAG_SYNC; __svgalib_driverspecs->accelspecs->ropModes = (1<<ROP_COPY) | (1<<ROP_OR) | (1<<ROP_AND) | (1<<ROP_XOR) | (1<<ROP_INVERT); __svgalib_driverspecs->accelspecs->transparencyModes = (1<<ENABLE_TRANSPARENCY_COLOR) | (1<<ENABLE_BITMAP_TRANSPARENCY); if ((CHIPSchipset == CT_545 || CHIPSchipset == CT_546 || CHIPSchipset == CT_548 || CHIPSchipset == CT_4300) && (modeinfo->bitsPerPixel == 24)) { __svgalib_driverspecs->accelspecs->ropOperations = ACCELFLAG_SCREENCOPY; } else { __svgalib_driverspecs->accelspecs->ropOperations = ACCELFLAG_FILLBOX | ACCELFLAG_SCREENCOPY; } if ((CHIPSchipset == CT_545 || CHIPSchipset == CT_546 || CHIPSchipset == CT_548 || CHIPSchipset == CT_4300) && (modeinfo->bitsPerPixel == 24)) { /* For now PutBitmap is only supported on 6554x's. I * don't have a 65550 machine to debug it on */ __svgalib_driverspecs->accelspecs->operations |= ACCELFLAG_PUTBITMAP; __svgalib_driverspecs->accelspecs->ropOperations |= ACCELFLAG_PUTBITMAP; __svgalib_driverspecs->accelspecs->transparencyOperations |= ACCELFLAG_PUTBITMAP; } /* Set the function pointers; availability is handled by flags. */ __svgalib_driverspecs->accelspecs->SetFGColor = __svgalib_CHIPS_SetFGColor; __svgalib_driverspecs->accelspecs->SetBGColor = __svgalib_CHIPS_SetBGColor; __svgalib_driverspecs->accelspecs->SetRasterOp = __svgalib_CHIPS_SetRasterOp; __svgalib_driverspecs->accelspecs->SetTransparency = __svgalib_CHIPS_SetTransparency; if (ctMMIO) { if (ctisHiQV) { __svgalib_driverspecs->accelspecs->FillBox = __svgalib_CHIPS_hiqv_FillBox; __svgalib_driverspecs->accelspecs->ScreenCopy = CHIPS_hiqv_ScreenCopy; __svgalib_driverspecs->accelspecs->Sync = CHIPS_hiqv_Sync; } else { if (modeinfo->bitsPerPixel == 24) { __svgalib_driverspecs->accelspecs->FillBox = __svgalib_CHIPS_mmio_FillBox24; } else { __svgalib_driverspecs->accelspecs->FillBox = __svgalib_CHIPS_mmio_FillBox; __svgalib_driverspecs->accelspecs->PutBitmap = __svgalib_CHIPS_mmio_PutBitmap; } __svgalib_driverspecs->accelspecs->ScreenCopy = CHIPS_mmio_ScreenCopy; __svgalib_driverspecs->accelspecs->Sync = CHIPS_mmio_Sync; } } else { if (modeinfo->bitsPerPixel == 24) { __svgalib_driverspecs->accelspecs->FillBox = __svgalib_CHIPS_FillBox24; } else { __svgalib_driverspecs->accelspecs->FillBox = __svgalib_CHIPS_FillBox; __svgalib_driverspecs->accelspecs->PutBitmap = __svgalib_CHIPS_PutBitmap; } __svgalib_driverspecs->accelspecs->ScreenCopy = CHIPS_ScreenCopy; __svgalib_driverspecs->accelspecs->Sync = CHIPS_Sync; } } return 0;}/* Enable linear mode (0 to turn off) */static void CHIPS_setlinear(int addr){#ifdef DEBUG printf("CHIPS: CHIPS_setlinear(0x%X)\n", addr);#endif if (ctisHiQV) { outb(0x3D6, 0x0A); if (addr) outb(0x3D7, inb(0x3D7) | 0x02); /* enable linear mode */ else outb(0x3D7, inb(0x3D7) & ~0x02); /* disable linear mode */ } else { outb(0x3D6, 0x0B); if (addr) outb(0x3D7, inb(0x3D7) | 0x10); /* enable linear mode */ else outb(0x3D7, inb(0x3D7) & ~0x10); /* disable linear mode */ }}static int CHIPS_linear(int op, int param){#ifdef DEBUG printf("CHIPS: CHIPS_linear(%d, %d)\n", op, param);#endif if (CHIPSchipset != CT_520) { /* The 65520 doesn't support it */ if (op == LINEAR_ENABLE) { CHIPS_setlinear(1); return 0; } if (op == LINEAR_DISABLE) { CHIPS_setlinear(0); return 0; } if (op == LINEAR_QUERY_BASE) { /* First deal with the user set MEMBASE */ if (ctFlagsSet & ctFlags_SetLinear) { switch (param) { case 0: return __svgalib_CHIPS_LinearBase; break; default: return -1; break; } } __svgalib_CHIPS_LinearBase = -1; if (PCIcard) { if (param == 0) { __svgalib_CHIPS_LinearBase = chips_pcilinearbase;#ifdef DEBUG printf("CHIPS_linear: base = %08X\n",__svgalib_CHIPS_LinearBase);#endif } else { /* As the above PCI membase probing code is new * keep the old code around too as a fallback */ switch (param) { case 1: __svgalib_CHIPS_LinearBase = 0xFE000000; break; case 2: __svgalib_CHIPS_LinearBase = 0xC0000000; break; case 3: __svgalib_CHIPS_LinearBase = 0xFD000000; break; case 4: __svgalib_CHIPS_LinearBase = 0x41000000; break; default: __svgalib_CHIPS_LinearBase = -1; break; } } } else { if (param == 0) { if (ctisHiQV) { outb(0x3D6, 0x6); __svgalib_CHIPS_LinearBase = ((0xFF & inb(0x3D7)) << 24); outb(0x3D6, 0x5); __svgalib_CHIPS_LinearBase |= ((0x80
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -