📄 cyberfb.c
字号:
yres = (video_mode->yres + 1) / 2; vfront = (video_mode->lower_margin + 1) / 2; vsync = (video_mode->vsync_len + 1) / 2; vback = (video_mode->upper_margin + 1) / 2; LACE = 1; } else { yres = video_mode->yres; vfront = video_mode->lower_margin; vsync = video_mode->vsync_len; vback = video_mode->upper_margin; } /* ARB Dropping custom setup method from cvision.c */#if 0 if (cvision_custom_mode) { HBS = hbs / 8 * hmul; HBE = hbe / 8 * hmul; HSS = hss / 8 * hmul; HSE = hse / 8 * hmul; HT = ht / 8 * hmul - 5; VBS = vbs - 1; VSS = vss; VSE = vse; VBE = vbe; VT = vt - 2; } else {#else {#endif HBS = hmul * (xres / 8); HBE = hmul * ((xres/8) + (hfront/8) + (hsync/8) + (hback/8) - 2); HSS = hmul * ((xres/8) + (hfront/8) + 2); HSE = hmul * ((xres/8) + (hfront/8) + (hsync/8) + 1); HT = hmul * ((xres/8) + (hfront/8) + (hsync/8) + (hback/8)); VBS = yres; VBE = yres + vfront + vsync + vback - 2; VSS = yres + vfront - 1; VSE = yres + vfront + vsync - 1; VT = yres + vfront + vsync + vback - 2; } wb_64 (regs, ECR_ADV_FUNC_CNTL, (TEXT ? 0x00 : 0x31)); if (TEXT) HDE = ((video_mode->xres + fx - 1) / fx) - 1; else HDE = (video_mode->xres + 3) * hmul / 8 - 1; VDE = video_mode->yres - 1; WCrt (regs, CRT_ID_HWGC_MODE, 0x00); WCrt (regs, CRT_ID_EXT_DAC_CNTL, 0x00); WSeq (regs, SEQ_ID_MEMORY_MODE, (TEXT || (video_mode->bits_per_pixel == 1)) ? 0x06 : 0x0e); WGfx (regs, GCT_ID_READ_MAP_SELECT, 0x00); WSeq (regs, SEQ_ID_MAP_MASK, (video_mode->bits_per_pixel == 1) ? 0x01 : 0xFF); WSeq (regs, SEQ_ID_CHAR_MAP_SELECT, 0x00); /* cv64_compute_clock accepts arguments in Hz */ /* pixclock is in ps ... convert to Hz */ #if 0 freq_f = (1.0 / (float) video_mode->pixclock) * 1000000000; freq = ((long) freq_f) * 1000;#else/* freq = (long) ((long long)1000000000000 / (long long) video_mode->pixclock); */ freq = (1000000000 / video_mode->pixclock) * 1000;#endif mnr = cv64_compute_clock (freq); WSeq (regs, SEQ_ID_DCLK_HI, ((mnr & 0xFF00) >> 8)); WSeq (regs, SEQ_ID_DCLK_LO, (mnr & 0xFF)); /* Load display parameters into board */ WCrt (regs, CRT_ID_EXT_HOR_OVF, ((HT & 0x100) ? 0x01 : 0x00) | ((HDE & 0x100) ? 0x02 : 0x00) | ((HBS & 0x100) ? 0x04 : 0x00) | /* ((HBE & 0x40) ? 0x08 : 0x00) | */ ((HSS & 0x100) ? 0x10 : 0x00) | /* ((HSE & 0x20) ? 0x20 : 0x00) | */ (((HT-5) & 0x100) ? 0x40 : 0x00) ); WCrt (regs, CRT_ID_EXT_VER_OVF, 0x40 | ((VT & 0x400) ? 0x01 : 0x00) | ((VDE & 0x400) ? 0x02 : 0x00) | ((VBS & 0x400) ? 0x04 : 0x00) | ((VSS & 0x400) ? 0x10 : 0x00) ); WCrt (regs, CRT_ID_HOR_TOTAL, HT); WCrt (regs, CRT_ID_DISPLAY_FIFO, HT - 5); WCrt (regs, CRT_ID_HOR_DISP_ENA_END, ((HDE >= HBS) ? (HBS - 1) : HDE)); WCrt (regs, CRT_ID_START_HOR_BLANK, HBS); WCrt (regs, CRT_ID_END_HOR_BLANK, ((HBE & 0x1F) | 0x80)); WCrt (regs, CRT_ID_START_HOR_RETR, HSS); WCrt (regs, CRT_ID_END_HOR_RETR, (HSE & 0x1F) | ((HBE & 0x20) ? 0x80 : 0x00) ); WCrt (regs, CRT_ID_VER_TOTAL, VT); WCrt (regs, CRT_ID_OVERFLOW, 0x10 | ((VT & 0x100) ? 0x01 : 0x00) | ((VDE & 0x100) ? 0x02 : 0x00) | ((VSS & 0x100) ? 0x04 : 0x00) | ((VBS & 0x100) ? 0x08 : 0x00) | ((VT & 0x200) ? 0x20 : 0x00) | ((VDE & 0x200) ? 0x40 : 0x00) | ((VSS & 0x200) ? 0x80 : 0x00) ); WCrt (regs, CRT_ID_MAX_SCAN_LINE, 0x40 | (DBLSCAN ? 0x80 : 0x00) | ((VBS & 0x200) ? 0x20 : 0x00) | (TEXT ? ((fy - 1) & 0x1F) : 0x00) ); WCrt (regs, CRT_ID_MODE_CONTROL, 0xE3); /* Text cursor */ if (TEXT) {#if 1 WCrt (regs, CRT_ID_CURSOR_START, (fy & 0x1f) - 2); WCrt (regs, CRT_ID_CURSOR_END, (fy & 0x1F) - 1);#else WCrt (regs, CRT_ID_CURSOR_START, 0x00); WCrt (regs, CRT_ID_CURSOR_END, fy & 0x1F);#endif WCrt (regs, CRT_ID_UNDERLINE_LOC, (fy - 1) & 0x1F); WCrt (regs, CRT_ID_CURSOR_LOC_HIGH, 0x00); WCrt (regs, CRT_ID_CURSOR_LOC_LOW, 0x00); } WCrt (regs, CRT_ID_START_ADDR_HIGH, 0x00); WCrt (regs, CRT_ID_START_ADDR_LOW, 0x00); WCrt (regs, CRT_ID_START_VER_RETR, VSS); WCrt (regs, CRT_ID_END_VER_RETR, (VSE & 0x0F)); WCrt (regs, CRT_ID_VER_DISP_ENA_END, VDE); WCrt (regs, CRT_ID_START_VER_BLANK, VBS); WCrt (regs, CRT_ID_END_VER_BLANK, VBE); WCrt (regs, CRT_ID_LINE_COMPARE, 0xFF); WCrt (regs, CRT_ID_LACE_RETR_START, HT / 2); WCrt (regs, CRT_ID_LACE_CONTROL, (LACE ? 0x20 : 0x00)); WGfx (regs, GCT_ID_GRAPHICS_MODE, ((TEXT || (video_mode->bits_per_pixel == 1)) ? 0x00 : 0x40)); WGfx (regs, GCT_ID_MISC, (TEXT ? 0x04 : 0x01)); WSeq (regs, SEQ_ID_MEMORY_MODE, ((TEXT || (video_mode->bits_per_pixel == 1)) ? 0x06 : 0x02)); wb_64 (regs, VDAC_MASK, 0xFF); /* Blank border */ test = RCrt (regs, CRT_ID_BACKWAD_COMP_2); WCrt (regs, CRT_ID_BACKWAD_COMP_2, (test | 0x20)); sr15 = RSeq (regs, SEQ_ID_CLKSYN_CNTL_2); sr15 &= 0xEF; sr18 = RSeq (regs, SEQ_ID_RAMDAC_CNTL); sr18 &= 0x7F; clock_mode = 0x00; cr50 = 0x00; test = RCrt (regs, CRT_ID_EXT_MISC_CNTL_2); test &= 0xD; /* Clear roxxler byte-swapping... */ cv64_write_port (0x0040, CyberBase); cv64_write_port (0x0020, CyberBase); switch (video_mode->bits_per_pixel) { case 1: case 4: /* text */ HDE = video_mode->xres / 16; break; case 8: if (freq > 80000000) { clock_mode = 0x10 | 0x02; sr15 |= 0x10; sr18 |= 0x80; } HDE = video_mode->xres / 8; cr50 |= 0x00; break; case 15: cv64_write_port (0x8020, CyberBase); clock_mode = 0x30; HDE = video_mode->xres / 4; cr50 |= 0x10; break; case 16: cv64_write_port (0x8020, CyberBase); clock_mode = 0x50; HDE = video_mode->xres / 4; cr50 |= 0x10; break; case 24: case 32: cv64_write_port (0x8040, CyberBase); clock_mode = 0xD0; HDE = video_mode->xres / 2; cr50 |= 0x30; break; } WCrt (regs, CRT_ID_EXT_MISC_CNTL_2, clock_mode | test); WSeq (regs, SEQ_ID_CLKSYN_CNTL_2, sr15); WSeq (regs, SEQ_ID_RAMDAC_CNTL, sr18); WCrt (regs, CRT_ID_SCREEN_OFFSET, HDE); WCrt (regs, CRT_ID_MISC_1, (TEXT ? 0x05 : 0x35)); test = RCrt (regs, CRT_ID_EXT_SYS_CNTL_2); test &= ~0x30; test |= (HDE >> 4) & 0x30; WCrt (regs, CRT_ID_EXT_SYS_CNTL_2, test); /* Set up graphics engine */ switch (video_mode->xres) { case 1024: cr50 |= 0x00; break; case 640: cr50 |= 0x40; break; case 800: cr50 |= 0x80; break; case 1280: cr50 |= 0xC0; break; case 1152: cr50 |= 0x01; break; case 1600: cr50 |= 0x81; break; default: /* XXX */ break; } WCrt (regs, CRT_ID_EXT_SYS_CNTL_1, cr50); udelay(100); WAttr (regs, ACT_ID_ATTR_MODE_CNTL, (TEXT ? 0x08 : 0x41)); udelay(100); WAttr (regs, ACT_ID_COLOR_PLANE_ENA, (video_mode->bits_per_pixel == 1) ? 0x01 : 0x0F); udelay(100); tfillm = (96 * (cv64_memclk / 1000)) / 240000; switch (video_mode->bits_per_pixel) { case 32: case 24: temptym = (24 * (cv64_memclk / 1000)) / (freq / 1000); break; case 15: case 16: temptym = (48 * (cv64_memclk / 1000)) / (freq / 1000); break; case 4: temptym = (192 * (cv64_memclk / 1000)) / (freq / 1000); break; default: temptym = (96 * (cv64_memclk / 1000)) / (freq / 1000); break; } m = (temptym - tfillm - 9) / 2; if (m < 0) m = 0; m = (m & 0x1F) << 3; if (m < 0x18) m = 0x18; n = 0xFF; WCrt (regs, CRT_ID_EXT_MEM_CNTL_2, m); WCrt (regs, CRT_ID_EXT_MEM_CNTL_3, n); udelay(10); /* Text initialization */ if (TEXT) { /* Do text initialization here ! */ } if (CONSOLE) { int i; wb_64 (regs, VDAC_ADDRESS_W, 0); for (i = 0; i < 4; i++) { wb_64 (regs, VDAC_DATA, cvconscolors [i][0]); wb_64 (regs, VDAC_DATA, cvconscolors [i][1]); wb_64 (regs, VDAC_DATA, cvconscolors [i][2]); } } WAttr (regs, 0x33, 0); /* Turn gfx on again */ gfx_on_off (0, (volatile unsigned char *) regs); /* Pass-through */ cvscreen (0, CyberBase);DPRINTK("EXIT\n");}void cvision_bitblt (u_short sx, u_short sy, u_short dx, u_short dy, u_short w, u_short h){ volatile unsigned char *regs = CyberRegs; unsigned short drawdir = 0; DPRINTK("ENTER\n"); if (sx > dx) { drawdir |= 1 << 5; } else { sx += w - 1; dx += w - 1; } if (sy > dy) { drawdir |= 1 << 7; } else { sy += h - 1; dy += h - 1; } Cyber_WaitBlit(); vgaw16 (regs, ECR_READ_REG_DATA, 0xA000); vgaw16 (regs, ECR_BKGD_MIX, 0x7); vgaw16 (regs, ECR_FRGD_MIX, 0x67); vgaw16 (regs, ECR_BKGD_COLOR, 0x0); vgaw16 (regs, ECR_FRGD_COLOR, 0x1); vgaw16 (regs, ECR_BITPLANE_READ_MASK, 0x1); vgaw16 (regs, ECR_BITPLANE_WRITE_MASK, 0xFFF); vgaw16 (regs, ECR_CURRENT_Y_POS, sy); vgaw16 (regs, ECR_CURRENT_X_POS, sx); vgaw16 (regs, ECR_DEST_Y__AX_STEP, dy); vgaw16 (regs, ECR_DEST_X__DIA_STEP, dx); vgaw16 (regs, ECR_READ_REG_DATA, h - 1); vgaw16 (regs, ECR_MAJ_AXIS_PIX_CNT, w - 1); vgaw16 (regs, ECR_DRAW_CMD, 0xC051 | drawdir); DPRINTK("EXIT\n");}void cvision_clear (u_short dx, u_short dy, u_short w, u_short h, u_short bg){ volatile unsigned char *regs = CyberRegs; DPRINTK("ENTER\n"); Cyber_WaitBlit(); vgaw16 (regs, ECR_FRGD_MIX, 0x0027); vgaw16 (regs, ECR_FRGD_COLOR, bg); vgaw16 (regs, ECR_READ_REG_DATA, 0xA000); vgaw16 (regs, ECR_CURRENT_Y_POS, dy); vgaw16 (regs, ECR_CURRENT_X_POS, dx); vgaw16 (regs, ECR_READ_REG_DATA, h - 1); vgaw16 (regs, ECR_MAJ_AXIS_PIX_CNT, w - 1); vgaw16 (regs, ECR_DRAW_CMD, 0x40B1); DPRINTK("EXIT\n");}#ifdef CYBERFBDEBUG/* * Dump internal settings of CyberVision board */static void cv64_dump (void){ volatile unsigned char *regs = CyberRegs; DPRINTK("ENTER\n"); /* Dump the VGA setup values */ *(regs + S3_CRTC_ADR) = 0x00; DPRINTK("CR00 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x01; DPRINTK("CR01 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x02; DPRINTK("CR02 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x03; DPRINTK("CR03 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x04; DPRINTK("CR04 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x05; DPRINTK("CR05 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x06; DPRINTK("CR06 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x07; DPRINTK("CR07 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x08; DPRINTK("CR08 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x09; DPRINTK("CR09 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x10; DPRINTK("CR10 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x11; DPRINTK("CR11 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x12; DPRINTK("CR12 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x13; DPRINTK("CR13 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x15; DPRINTK("CR15 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x16; DPRINTK("CR16 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x36; DPRINTK("CR36 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x37; DPRINTK("CR37 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x42; DPRINTK("CR42 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x43; DPRINTK("CR43 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x50; DPRINTK("CR50 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x51; DPRINTK("CR51 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x53; DPRINTK("CR53 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x58; DPRINTK("CR58 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x59; DPRINTK("CR59 = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x5A; DPRINTK("CR5A = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x5D; DPRINTK("CR5D = %x\n", *(regs + S3_CRTC_DATA)); *(regs + S3_CRTC_ADR) = 0x5E; DPRINTK("CR5E = %x\n", *(regs + S3_CRTC_DATA)); DPRINTK("MISC = %x\n", *(regs + GREG_MISC_OUTPUT_R)); *(regs + SEQ_ADDRESS) = 0x01; DPRINTK("SR01 = %x\n", *(regs + SEQ_ADDRESS_R)); *(regs + SEQ_ADDRESS) = 0x02; DPRINTK("SR02 = %x\n", *(regs + SEQ_ADDRESS_R)); *(regs + SEQ_ADDRESS) = 0x03; DPRINTK("SR03 = %x\n", *(regs + SEQ_ADDRESS_R)); *(regs + SEQ_ADDRESS) = 0x09; DPRINTK("SR09 = %x\n", *(regs + SEQ_ADDRESS_R)); *(regs + SEQ_ADDRESS) = 0x10; DPRINTK("SR10 = %x\n", *(regs + SEQ_ADDRESS_R)); *(regs + SEQ_ADDRESS) = 0x11; DPRINTK("SR11 = %x\n", *(regs + SEQ_ADDRESS_R)); *(regs + SEQ_ADDRESS) = 0x12; DPRINTK("SR12 = %x\n", *(regs + SEQ_ADDRESS_R)); *(regs + SEQ_ADDRESS) = 0x13; DPRINTK("SR13 = %x\n", *(regs + SEQ_ADDRESS_R)); *(regs + SEQ_ADDRESS) = 0x15; DPRINTK("SR15 = %x\n", *(regs + SEQ_ADDRESS_R)); return;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -