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

📄 xcfb.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
	/* spec sez: */	wptr = regs + 0xa0000 + (regno << 4);	*((volatile u_int *)(regs)) = (val >> 8) & 0xff00;	*((volatile u_short *)(wptr)) = val;}#define	assert_ims332_reset_bit(r)	*r &= ~0x40#define	deassert_ims332_reset_bit(r)	*r |=  0x40/* * Color map */static voidxcfbLoadColorMap(ptr)	ColorMap *ptr;{	register int i;	if (ptr->index > 256)		return;	ims332_load_colormap_entry(ptr->index, ptr);}static voidims332_load_colormap_entry(entry, map)	ColorMap *map;{	/* ?? stop VTG */	ims332_write_register(IMS332_REG_LUT_BASE + (entry & 0xff),			      (map->Entry.blue << 16) |			      (map->Entry.green << 8) |			      (map->Entry.red));}static voidxcfbInitColorMap(){	register int i;	ColorMap m;	m.Entry.red = m.Entry.green = m.Entry.blue = 0;	ims332_load_colormap_entry(0, &m);	m.Entry.red = m.Entry.green = m.Entry.blue = 0xff;	for (i = 1; i < 256; i++)		ims332_load_colormap_entry(i, &m);	for (i = 0; i < 3; i++) {		cursor_RGB[i] = 0x00;		cursor_RGB[i + 3] = 0xff;	}	xcfbRestoreCursorColor();}/* * Video on/off * * It is unfortunate that X11 goes backward with white@0 * and black@1.  So we must stash away the zero-th entry * and fix it while screen is off.  Also must remember * it, sigh. */static struct {	u_int	save;	int	off;} xcfb_vstate;static voidims332_video_off(){	register u_int csr;	if (xcfb_vstate.off)		return;	xcfb_vstate.save = ims332_read_register(IMS332_REG_LUT_BASE);	ims332_write_register(IMS332_REG_LUT_BASE, 0);	ims332_write_register(IMS332_REG_COLOR_MASK, 0);	/* cursor now */	csr = ims332_read_register(IMS332_REG_CSR_A);	csr |= IMS332_CSR_A_DISABLE_CURSOR;	ims332_write_register(IMS332_REG_CSR_A, csr);	xcfb_vstate.off = 1;}static voidims332_video_on(){	register u_int csr;	if (!xcfb_vstate.off)		return;	ims332_write_register(IMS332_REG_LUT_BASE, xcfb_vstate.save);	ims332_write_register(IMS332_REG_COLOR_MASK, 0xffffffff);	/* cursor now */	csr = ims332_read_register(IMS332_REG_CSR_A);	csr &= ~IMS332_CSR_A_DISABLE_CURSOR;	ims332_write_register(IMS332_REG_CSR_A, csr);	xcfb_vstate.off = 0;}/* * Cursor */voidxcfbPosCursor(x, y)	register int x, y;{	register struct pmax_fb *fp = &xcfbfb;	if (y < fp->fbu->scrInfo.min_cur_y || y > fp->fbu->scrInfo.max_cur_y)		y = fp->fbu->scrInfo.max_cur_y;	if (x < fp->fbu->scrInfo.min_cur_x || x > fp->fbu->scrInfo.max_cur_x)		x = fp->fbu->scrInfo.max_cur_x;	fp->fbu->scrInfo.cursor.x = x;		/* keep track of real cursor */	fp->fbu->scrInfo.cursor.y = y;		/* position, indep. of mouse */	ims332_write_register(IMS332_REG_CURSOR_LOC,		((x & 0xfff) << 12) | (y & 0xfff));}/* * xcfbRestoreCursorColor */static voidxcfbRestoreCursorColor(){	/* Bg is color[0], Fg is color[1] */	ims332_write_register(IMS332_REG_CURSOR_LUT_0,			      (cursor_RGB[2] << 16) |			      (cursor_RGB[1] << 8) |			      (cursor_RGB[0]));	ims332_write_register(IMS332_REG_CURSOR_LUT_1, 0x7f0000);	ims332_write_register(IMS332_REG_CURSOR_LUT_2,			      (cursor_RGB[5] << 16) |			      (cursor_RGB[4] << 8) |			      (cursor_RGB[3]));}/* * ---------------------------------------------------------------------------- * * xcfbCursorColor -- * *	Set the color of the cursor. * * Results: *	None. * * Side effects: *	None. * * ---------------------------------------------------------------------------- */static voidxcfbCursorColor(color)	unsigned int color[];{	register int i, j;	for (i = 0; i < 6; i++)		cursor_RGB[i] = (u_char)(color[i] >> 8);	xcfbRestoreCursorColor();}static voidxcfbLoadCursor(cursor)	u_short *cursor;{	register int i, j, k, pos;	register u_short ap, bp, out;	/*	 * Fill in the cursor sprite using the A and B planes, as provided	 * for the pmax.	 * XXX This will have to change when the X server knows that this	 * is not a pmax display.	 */	pos = 0;	for (k = 0; k < 16; k++) {		ap = *cursor;		bp = *(cursor + 16);		j = 0;		while (j < 2) {			out = 0;			for (i = 0; i < 8; i++) {				out = ((out >> 2) & 0x3fff) |					((ap & 0x1) << 15) |					((bp & 0x1) << 14);				ap >>= 1;				bp >>= 1;			}			ims332_write_register(IMS332_REG_CURSOR_RAM + pos, out);			pos++;			j++;		}		while (j < 8) {			ims332_write_register(IMS332_REG_CURSOR_RAM + pos, 0);			pos++;			j++;		}		cursor++;	}	while (pos < 512) {		ims332_write_register(IMS332_REG_CURSOR_RAM + pos, 0);		pos++;	}}/* * Initialization */intxcfbinit(){	register u_int *reset = (u_int *)IMS332_RESET_ADDRESS;	register struct pmax_fb *fp = &xcfbfb;	fp->isMono = 0;	/*	 * Or Cached? A comment in the Mach driver suggests that the X server	 * runs faster in cached address space, but the X server is going	 * to blow away the data cache whenever it updates the screen, so..	 */	fp->fr_addr = (char *)		MACH_PHYS_TO_UNCACHED(XINE_PHYS_CFB_START + VRAM_OFFSET);	fp->fr_size = 0x100000;	/*	 * Must be in Uncached space since the fbuaccess structure is	 * mapped into the user's address space uncached.	 */	fp->fbu = (struct fbuaccess *)		MACH_PHYS_TO_UNCACHED(MACH_CACHED_TO_PHYS(&xcfbu));	fp->posCursor = xcfbPosCursor;	fp->KBDPutc = dtopKBDPutc;	fp->kbddev = makedev(DTOPDEV, DTOPKBD_PORT);	/*	 * Initialize the screen.	 */#ifdef notdef	assert_ims332_reset_bit(reset);	DELAY(1);	/* specs sez 50ns.. */	deassert_ims332_reset_bit(reset);	/* CLOCKIN appears to receive a 6.25 Mhz clock --> PLL 12 for 75Mhz monitor */	ims332_write_register(IMS332_REG_BOOT, 12 | IMS332_BOOT_CLOCK_PLL);	/* initialize VTG */	ims332_write_register(IMS332_REG_CSR_A,				IMS332_BPP_8 | IMS332_CSR_A_DISABLE_CURSOR);	DELAY(50);	/* spec does not say */	/* datapath registers (values taken from prom's settings) */	ims332_write_register(IMS332_REG_HALF_SYNCH, 0x10);	ims332_write_register(IMS332_REG_BACK_PORCH, 0x21);	ims332_write_register(IMS332_REG_DISPLAY, 0x100);	ims332_write_register(IMS332_REG_SHORT_DIS, 0x5d);	ims332_write_register(IMS332_REG_BROAD_PULSE, 0x9f);	ims332_write_register(IMS332_REG_V_SYNC, 0xc);	ims332_write_register(IMS332_REG_V_PRE_EQUALIZE, 2);	ims332_write_register(IMS332_REG_V_POST_EQUALIZE, 2);	ims332_write_register(IMS332_REG_V_BLANK, 0x2a);	ims332_write_register(IMS332_REG_V_DISPLAY, 0x600);	ims332_write_register(IMS332_REG_LINE_TIME, 0x146);	ims332_write_register(IMS332_REG_LINE_START, 0x10);	ims332_write_register(IMS332_REG_MEM_INIT, 0xa);	ims332_write_register(IMS332_REG_XFER_DELAY, 0xa);	ims332_write_register(IMS332_REG_COLOR_MASK, 0xffffff);#endif	/*	 * Initialize screen info.	 */	fp->fbu->scrInfo.max_row = 50;	fp->fbu->scrInfo.max_col = 80;	fp->fbu->scrInfo.max_x = 1024;	fp->fbu->scrInfo.max_y = 768;	fp->fbu->scrInfo.max_cur_x = 1008;	fp->fbu->scrInfo.max_cur_y = 752;	fp->fbu->scrInfo.version = 11;	fp->fbu->scrInfo.mthreshold = 4;		fp->fbu->scrInfo.mscale = 2;	fp->fbu->scrInfo.min_cur_x = -15;	fp->fbu->scrInfo.min_cur_y = -15;	fp->fbu->scrInfo.qe.timestamp_ms = TO_MS(time);	fp->fbu->scrInfo.qe.eSize = PM_MAXEVQ;	fp->fbu->scrInfo.qe.eHead = fp->fbu->scrInfo.qe.eTail = 0;	fp->fbu->scrInfo.qe.tcSize = MOTION_BUFFER_SIZE;	fp->fbu->scrInfo.qe.tcNext = 0;	xcfbInitColorMap();	ims332_write_register(IMS332_REG_CSR_A,		IMS332_BPP_8 | IMS332_CSR_A_DMA_DISABLE | IMS332_CSR_A_VTG_ENABLE);	xcfbScreenInit();	fbScroll(fp);	fp->initialized = 1;	if (cn_tab.cn_fb == (struct pmax_fb *)0)		cn_tab.cn_fb = fp;	return (1);}/* * ---------------------------------------------------------------------------- * * xcfbScreenInit -- * *	Initialize the screen. * * Results: *	None. * * Side effects: *	The screen is initialized. * * ---------------------------------------------------------------------------- */static voidxcfbScreenInit(){	register struct pmax_fb *fp = &xcfbfb;	/*	 * Home the cursor.	 * We want an LSI terminal emulation.  We want the graphics	 * terminal to scroll from the bottom. So start at the bottom.	 */	fp->row = 49;	fp->col = 0;	/*	 * Load the cursor with the default values	 *	 */	xcfbLoadCursor(defCursor);}/* * xcfb keyboard and mouse input. Just punt to the generic ones in fb.c */voidxcfbKbdEvent(ch)	int ch;{	fbKbdEvent(ch, &xcfbfb);}voidxcfbMouseEvent(newRepPtr)	MouseReport *newRepPtr;{	fbMouseEvent(newRepPtr, &xcfbfb);}voidxcfbMouseButtons(newRepPtr)	MouseReport *newRepPtr;{	fbMouseButtons(newRepPtr, &xcfbfb);}#endif /* NDTOP */#endif /* NXCFB */

⌨️ 快捷键说明

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