📄 ark.c
字号:
modeinfo->bitsPerPixel, __svgalib_colorbits_to_colormode(modeinfo->bitsPerPixel, modeinfo->colorBits), modetiming->pixelClock); }}/* Set a mode */static void init_acceleration_specs_for_mode(AccelSpecs * accelspecs, int bpp, int width_in_pixels);static void arkaccel_init(AccelSpecs * accelspecs, int bpp, int width_in_pixels);static int ark_setmode(int mode, int prv_mode){ ModeInfo *modeinfo; ModeTiming *modetiming; unsigned char *moderegs;#ifdef SVGA_STYLE_320x200x256 if ((mode < G640x480x256 || mode == G720x348x2) && mode != G320x200x256)#else if (mode < G640x480x256 || mode == G720x348x2)#endif /* Let the standard VGA driver set standard VGA modes. */ return __svgalib_vga_driverspecs.setmode(mode, prv_mode); if (!ark_modeavailable(mode)) return 1; modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode); modetiming = malloc(sizeof(ModeTiming)); if (__svgalib_getmodetiming(modetiming, modeinfo, cardspecs)) { free(modetiming); free(modeinfo); return 1; } moderegs = malloc(ARK_TOTAL_REGS); ark_initializemode(moderegs, modetiming, modeinfo); free(modetiming); ark_setregs(moderegs, mode); /* Set extended regs. */ __svgalib_setregs(moderegs); /* Set standard regs. */ free(moderegs); __svgalib_InitializeAcceleratorInterface(modeinfo); init_acceleration_specs_for_mode(__svgalib_driverspecs->accelspecs, modeinfo->bitsPerPixel, modeinfo->lineWidth / modeinfo->bytesPerPixel); arkaccel_init(__svgalib_driverspecs->accelspecs, modeinfo->bitsPerPixel, modeinfo->lineWidth / modeinfo->bytesPerPixel); free(modeinfo); return 0;}/* Indentify chipset; return non-zero if detected */static int ark_test(void){ if (ark_init(0, 0, 0)) return 0; return 1;}/* Bank switching function - set 64K bank number */static void ark_setpage(int page){ outw(SEQ_I, 0x15 + (page << 8)); /* Aperture Write index. */ outw(SEQ_I, 0x16 + (page << 8)); /* Aperture Read index. */}/* Set display start address (not for 16 color modes) */static void ark_setdisplaystart(int address){ outw(CRT_IC, 0x0d + ((address >> 2) & 0x00ff) * 256); /* sa2-sa9 */ outw(CRT_IC, 0x0c + ((address >> 2) & 0xff00)); /* sa10-sa17 */ inb(0x3da); /* set ATC to addressing mode */ outb(ATT_IW, 0x13 + 0x20); /* select ATC reg 0x13 */ outb(ATT_IW, (inb(ATT_R) & 0xf0) | ((address & 3) << 1)); /* write sa0-1 to bits 1-2 */ outb(__svgalib_CRT_I, 0x40); outb(__svgalib_CRT_D, (address & 0x1C0000) >> 18); /* sa18-sa20 */}/* Set logical scanline length (usually multiple of 8) *//* Multiples of 8 to 2040 */static void ark_setlogicalwidth(int width){ outw(CRT_IC, 0x13 + (width >> 3) * 256); /* lw3-lw11 */ outb(__svgalib_CRT_I, 0x41); outb(__svgalib_CRT_D, (inb(__svgalib_CRT_D) & ~0x08) | ((width >> 3) & 0x100));}static int ark_linear(int op, int param){ if (op == LINEAR_ENABLE) { int size; __svgalib_outSR(0x13, param >> 16); __svgalib_outSR(0x14, param >> 24); switch (ark_memory) { case 1024: size = 1; break; case 2048: size = 2; break; case 4096: default: size = 3; } __svgalib_outSR(0x12, (__svgalib_inSR(0x12) & ~0x03) | size); return 0; } if (op == LINEAR_DISABLE) { __svgalib_outSR(0x12, __svgalib_inSR(0x12) & ~0x03); /* 64K map. */ __svgalib_outSR(0x13, 0xA0); /* Revert to 0xA0000. */ __svgalib_outSR(0x14, 0x00); return 0; } if (op == LINEAR_QUERY_BASE) { if (ark_bus == PCI && param == 0) /* Return PCI base address. */ return ark_baseaddress; if (ark_bus == VL) { if (param == 0) return 0x08000000; /* 128MB */ if (param == 1) return 0x04000000; /* 64MB */ if (param == 2) return 0x80000000; /* 2048MB */ if (param == 3) return 0x02000000; /* 32MB */ } return -1; } if (op == LINEAR_QUERY_RANGE || op == LINEAR_QUERY_GRANULARITY) return 0; /* No granularity or range. */ else return -1; /* Unknown function. */}/* Function table (exported) */DriverSpecs __svgalib_ark_driverspecs ={ ark_saveregs, /* saveregs */ ark_setregs, /* setregs */ ark_unlock, /* unlock */ nothing, /* lock */ ark_test, ark_init, ark_setpage, (void (*)(int)) nothing, (void (*)(int)) nothing, ark_setmode, ark_modeavailable, ark_setdisplaystart, ark_setlogicalwidth, ark_getmodeinfo, 0, /* bitblt */ 0, /* imageblt */ 0, /* fillblt */ 0, /* hlinelistblt */ 0, /* bltwait */ 0, /* extset */ 0, ark_linear, NULL, /* accelspecs */ NULL, /* Emulation */};/* ARK-specific config file options. *//* * Currently this only handles Clocks. It would a good idea to have * higher-level code process options like Clocks that are valid for * more than one driver driver (with better error detection etc.). */static char *ark_config_options[] ={ "clocks", "ramdac", "dacspeed", NULL};static char *ark_process_option(int option, int mode){/* * option is the number of the option string in ark_config_options, * mode seems to be a security indicator. */ if (option == 0) { /* "Clocks" */ /* Process at most 16 specified clocks. */ cardspecs->clocks = malloc(sizeof(int) * 16); /* cardspecs->nClocks should already be 0. */ for (;;) { char *ptr; int freq; ptr = strtok(NULL, " "); if (ptr == NULL) break; /* * This doesn't protect against bad characters * (atof() doesn't detect errors). */ freq = atof(ptr) * 1000; cardspecs->clocks[cardspecs->nClocks] = freq; cardspecs->nClocks++; if (cardspecs->nClocks == 16) break; } } if (option == 1) { /* "Ramdac" */ char *ptr; DacMethods *old_dac_used; ptr = strtok(NULL, " "); old_dac_used = dac_used;#ifdef INCLUDE_SIERRA_DAC if (strcasecmp(ptr, "Sierra32K") == 0) dac_used = &__svgalib_Sierra_32K_methods;#endif#ifdef INCLUDE_ATT20C490_DAC if (strcasecmp(ptr, "ATT20C490") == 0) dac_used = &__svgalib_ATT20C490_methods;#endif#ifdef INCLUDE_ATT20C498_DAC if (strcasecmp(ptr, "ATT20C498") == 0) dac_used = &__svgalib_ATT20C498_methods;#endif#ifdef INCLUDE_NORMAL_DAC if (strcasecmp(ptr, "Normal") == 0) /* force normal VGA dac */ dac_used = &__svgalib_normal_dac_methods;#endif if (old_dac_used != dac_used) dac_used->initialize(); } if (option == 2) { /* "Dacspeed" */ char *ptr; ptr = strtok(NULL, " "); /* * This doesn't protect against bad characters * (atoi() doesn't detect errors). */ dac_speed = atoi(ptr) * 1000; } return strtok(NULL, " ");}/* Initialize driver (called after detection) */static char *ark_chipname[] ={"ARK1000PV", "ARK2000PV"};static int ark_init(int force, int par1, int par2){ ark_unlock(); if (force) { ark_chip = par1; /* we already know the type */ ark_memory = par2; } else { unsigned char id, val; id = __svgalib_inCR(0x50) >> 3; if (id == 0x12) ark_chip = ARK1000PV; else if ((id == 0x13) || (id == 0x14) || (id == 0x20)) ark_chip = ARK2000PV; else { printf("svgalib: ark: Unknown chiptype %d.\n", id); return -1; } val = __svgalib_inSR(0x10); if (ark_chip == ARK1000PV) if ((val & 0x40) == 0) ark_memory = 1024; else ark_memory = 2048; else if ((val & 0xC0) == 0) ark_memory = 1024; else if ((val & 0xC0) == 0x40) ark_memory = 2048; else ark_memory = 4096; }/* begin: Initialize cardspecs. */ cardspecs = malloc(sizeof(CardSpecs)); cardspecs->videoMemory = ark_memory; cardspecs->maxHorizontalCrtc = 4088; cardspecs->nClocks = 0; cardspecs->flags = INTERLACE_DIVIDE_VERT; /* Process ARK-specific config file options. */ __svgalib_read_options(ark_config_options, ark_process_option); if (dac_used == NULL) { /* Not supported. */ printf("svgalib: ark: Assuming normal VGA DAC.\n");#ifdef INCLUDE_NORMAL_DAC dac_used = &__svgalib_normal_dac_methods;#else printf("svgalib: Alas, normal VGA DAC support is not compiled in, goodbye.\n"); return 1;#endif } dac_used->qualifyCardSpecs(cardspecs, dac_speed); /* Initialize standard clocks for unknown clock device. */ if (!(dac_used->flags & CLOCK_PROGRAMMABLE) && cardspecs->nClocks == 0) {#ifdef INCLUDE_HALVED_CLOCKS int i; cardspecs->nClocks = 32; cardspecs->clocks = malloc(sizeof(int) * 32);#else cardspecs->nClocks = 2; cardspecs->clocks = malloc(sizeof(int) * 2);#endif cardspecs->clocks[0] = 25175; cardspecs->clocks[1] = 28322;#ifdef INCLUDE_HALVED_CLOCKS for (i = 2; i < 16; i++) cardspecs->clocks[i] = 0; for (i = 16; i < 32; i++) cardspecs->clocks[i] = cardspecs->clocks[i - 16] / 2;#endif } /* Limit pixel clocks according to chip specifications. */ if (ark_chip == ARK1000PV) { /* Limit max clocks according to 120 MHz DCLK spec. */ /* 8-bit DAC. */ LIMIT(cardspecs->maxPixelClock4bpp, 120000); LIMIT(cardspecs->maxPixelClock8bpp, 120000); LIMIT(cardspecs->maxPixelClock16bpp, 120000 / 2); LIMIT(cardspecs->maxPixelClock24bpp, 120000 / 3); LIMIT(cardspecs->maxPixelClock32bpp, 120000 / 4); } if (ark_chip == ARK2000PV) { /* Limit max clocks according to 120 MHz DCLK spec. */ /* Assume 16-bit DAC. */ LIMIT(cardspecs->maxPixelClock4bpp, 120000); LIMIT(cardspecs->maxPixelClock8bpp, 120000 * 2); LIMIT(cardspecs->maxPixelClock16bpp, 120000); LIMIT(cardspecs->maxPixelClock24bpp, 120000 / 3); LIMIT(cardspecs->maxPixelClock32bpp, 120000 / 2); } cardspecs->maxPixelClock4bpp = 0; /* 16-color modes don't work. *//* end: Initialize cardspecs. *//* Initialize accelspecs structure. */ __svgalib_ark_driverspecs.accelspecs = malloc(sizeof(AccelSpecs)); __svgalib_clear_accelspecs(__svgalib_ark_driverspecs.accelspecs); __svgalib_ark_driverspecs.accelspecs->flags = ACCELERATE_ANY_LINEWIDTH; /* Map memory-mapped I/O register space. */ if (__svgalib_driver_report) { char *bustype; if (__svgalib_inSR(0x19) & 0x80) { ark_bus = VL; bustype = "VL bus"; } else { ark_bus = PCI; bustype = "PCI"; ark_baseaddress = (__svgalib_inSR(0x13) << 16) + (__svgalib_inSR(0x14) << 24); } printf("svgalib: Using ARK driver (%s, %dK, %s).", ark_chipname[ark_chip], ark_memory, bustype); if (ark_bus == PCI) printf(" Base address = 0x%08X.", ark_baseaddress); printf("\n"); } __svgalib_driverspecs = &__svgalib_ark_driverspecs; __svgalib_mmio_base = 0xb80000; __svgalib_mmio_size = 4096; __svgalib_banked_mem_base=0xa0000; __svgalib_banked_mem_size=0x10000; if (ark_bus == PCI)__svgalib_linear_mem_base=ark_baseaddress; __svgalib_linear_mem_size=ark_memory*0x400; return 0;}/* ARK Logic acceleration functions implementation. *//* We use linear COP addresses (no coordinates) to allow acceleration *//* in any linewidth. *//* Macros for memory-mapped I/O COP register access. *//* MMIO addresses (offset from 0xb8000). */#define BACKGROUNDCOLOR 0x00#define FOREGROUNDCOLOR 0x02#define COLORMIXSELECT 0x18#define WRITEPLANEMASK 0x1A#define STENCILPITCH 0x60
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -