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

📄 macfb.c

📁 linux下的VIDEO接口驱动程序
💻 C
📖 第 1 页 / 共 3 页
字号:
		fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);	return 0;}static struct fb_ops macfb_ops = {	owner:		THIS_MODULE,	fb_get_fix:	macfb_get_fix,	fb_get_var:	macfb_get_var,	fb_set_var:	macfb_set_var,	fb_get_cmap:	macfb_get_cmap,	fb_set_cmap:	macfb_set_cmap,};void __init macfb_setup(char *options, int *ints){	char *this_opt;		fb_info.fontname[0] = '\0';		if (!options || !*options)		return;		while ((this_opt = strsep(&options, ",")) != NULL) {		if (!*this_opt) continue;				if (! strcmp(this_opt, "inverse"))			inverse=1;		else if (!strncmp(this_opt, "font:", 5))			strcpy(fb_info.fontname, this_opt+5);		/* This means "turn on experimental CLUT code" */		else if (!strcmp(this_opt, "vidtest"))			vidtest=1;	}}static int macfb_switch(int con, struct fb_info *info){	/* Do we have to save the colormap? */	if (fb_display[currcon].cmap.len)		fb_get_cmap(&fb_display[currcon].cmap, 1, macfb_getcolreg,			    info);		currcon = con;	/* Install new colormap */	do_install_cmap(con, info);	macfb_update_var(con, info);	return 1;}static void macfb_blank(int blank, struct fb_info *info){	/* Not supported */}void __init macfb_init(void){	struct nubus_dev* ndev = NULL;	int video_is_nubus = 0;	if (!MACH_IS_MAC) 		return;	/* There can only be one internal video controller anyway so	   we're not too worried about this */	video_width      = mac_bi_data.dimensions & 0xFFFF;	video_height     = mac_bi_data.dimensions >> 16;	video_bpp        = mac_bi_data.videodepth;	video_linelength = mac_bi_data.videorow;	video_size       = video_linelength * video_height;	/* Note: physical address (since 2.1.127) */	video_base       = (void*) mac_bi_data.videoaddr;	/* This is actually redundant with the initial mappings.	   However, there are some non-obvious aspects to the way	   those mappings are set up, so this is in fact the safest	   way to ensure that this driver will work on every possible	   Mac */	video_vbase	 = ioremap(mac_bi_data.videoaddr, video_size);		printk("macfb: framebuffer at 0x%p, mapped to 0x%p, size %dk\n",	       video_base, video_vbase, video_size/1024);	printk("macfb: mode is %dx%dx%d, linelength=%d\n",	       video_width, video_height, video_bpp, video_linelength);		/*	 *	Fill in the available video resolution	 */	 	macfb_defined.xres           = video_width;	macfb_defined.yres           = video_height;	macfb_defined.xres_virtual   = video_width;	macfb_defined.yres_virtual   = video_height;	macfb_defined.bits_per_pixel = video_bpp;	macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres);	macfb_defined.width  = PIXEL_TO_MM(macfb_defined.xres);	 	printk("macfb: scrolling: redraw\n");	macfb_defined.yres_virtual = video_height;	/* some dummy values for timing to make fbset happy */	macfb_defined.pixclock     = 10000000 / video_width * 1000 / video_height;	macfb_defined.left_margin  = (video_width / 8) & 0xf8;	macfb_defined.right_margin = 32;	macfb_defined.upper_margin = 16;	macfb_defined.lower_margin = 4;	macfb_defined.hsync_len    = (video_width / 8) & 0xf8;	macfb_defined.vsync_len    = 4;	switch (video_bpp) {	case 1:		/* XXX: I think this will catch any program that tries		   to do FBIO_PUTCMAP when the visual is monochrome */		video_cmap_len = 0;		video_visual = FB_VISUAL_MONO01;		break;	case 2:	case 4:	case 8:		macfb_defined.red.length = video_bpp;		macfb_defined.green.length = video_bpp;		macfb_defined.blue.length = video_bpp;		video_cmap_len = 1 << video_bpp;		video_visual = FB_VISUAL_PSEUDOCOLOR;		break;	case 16:		macfb_defined.transp.offset = 15;		macfb_defined.transp.length = 1;		macfb_defined.red.offset = 10;		macfb_defined.red.length = 5;		macfb_defined.green.offset = 5;		macfb_defined.green.length = 5;		macfb_defined.blue.offset = 0;		macfb_defined.blue.length = 5;		printk("macfb: directcolor: "		       "size=1:5:5:5, shift=15:10:5:0\n");		video_cmap_len = 16;		/* Should actually be FB_VISUAL_DIRECTCOLOR, but this		   works too */		video_visual = FB_VISUAL_TRUECOLOR;		break;	case 24:	case 32:		/* XXX: have to test these... can any 68k Macs		   actually do this on internal video? */		macfb_defined.red.offset = 16;		macfb_defined.red.length = 8;		macfb_defined.green.offset = 8;		macfb_defined.green.length = 8;		macfb_defined.blue.offset = 0;		macfb_defined.blue.length = 8;		printk("macfb: truecolor: "		       "size=0:8:8:8, shift=0:16:8:0\n");		video_cmap_len = 16;		video_visual = FB_VISUAL_TRUECOLOR;	default:		video_cmap_len = 0;		video_visual = FB_VISUAL_MONO01;		printk("macfb: unknown or unsupported bit depth: %d\n", video_bpp);		break;	}		/* Hardware dependent stuff */	/*  We take a wild guess that if the video physical address is	 *  in nubus slot space, that the nubus card is driving video.	 *  Penguin really ought to tell us whether we are using internal	 *  video or not.	 */	/* Hopefully we only find one of them.  Otherwise our NuBus           code is really broken :-) */	while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY, NUBUS_TYPE_VIDEO, ndev))		!= NULL)	{		if (!(mac_bi_data.videoaddr >= ndev->board->slot_addr		      && (mac_bi_data.videoaddr <			  (unsigned long)nubus_slot_addr(ndev->board->slot+1))))			continue;		video_is_nubus = 1;		/* We should probably just use the slot address... */		video_slot = ndev->board->slot;		switch(ndev->dr_hw) {		case NUBUS_DRHW_APPLE_MDC:			strcpy( fb_info.modename, "Macintosh Display Card" );			macfb_setpalette = mdc_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			break;		case NUBUS_DRHW_APPLE_TFB:			strcpy( fb_info.modename, "Toby" );			macfb_setpalette = toby_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			break;		case NUBUS_DRHW_APPLE_JET:			strcpy(fb_info.modename, "Jet");			macfb_setpalette = jet_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			break;					default:			strcpy( fb_info.modename, "Generic NuBus" );			break;		}	}	/* If it's not a NuBus card, it must be internal video */	/* FIXME: this function is getting way too big.  (this driver           is too...) */	if (!video_is_nubus)		switch( mac_bi_data.id )		{			/* These don't have onboard video.  Eventually, we may			   be able to write separate framebuffer drivers for			   them (tobyfb.c, hiresfb.c, etc, etc) */		case MAC_MODEL_II:		case MAC_MODEL_IIX:		case MAC_MODEL_IICX:		case MAC_MODEL_IIFX:			strcpy( fb_info.modename, "Generic NuBus" );			break;			/* Valkyrie Quadras */		case MAC_MODEL_Q630:			/* I'm not sure about this one */		case MAC_MODEL_P588:			strcpy( fb_info.modename, "Valkyrie built-in" );			macfb_setpalette = valkyrie_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			valkyrie_cmap_regs = ioremap(DAC_BASE, 0x1000);			break;			/* DAFB Quadras */			/* Note: these first four have the v7 DAFB, which is			   known to be rather unlike the ones used in the			   other models */		case MAC_MODEL_P475:		case MAC_MODEL_P475F:		case MAC_MODEL_P575:		case MAC_MODEL_Q605:			case MAC_MODEL_Q800:		case MAC_MODEL_Q650:		case MAC_MODEL_Q610:		case MAC_MODEL_C650:		case MAC_MODEL_C610:		case MAC_MODEL_Q700:		case MAC_MODEL_Q900:		case MAC_MODEL_Q950:			strcpy( fb_info.modename, "DAFB built-in" );			macfb_setpalette = dafb_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000);			break;			/* LC II uses the V8 framebuffer */		case MAC_MODEL_LCII:			strcpy( fb_info.modename, "V8 built-in" );			macfb_setpalette = v8_brazil_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);			break;					/* IIvi, IIvx use the "Brazil" framebuffer (which is			   very much like the V8, it seems, and probably uses			   the same DAC) */		case MAC_MODEL_IIVI:		case MAC_MODEL_IIVX:		case MAC_MODEL_P600:			strcpy( fb_info.modename, "Brazil built-in" );			macfb_setpalette = v8_brazil_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);			break;					/* LC III (and friends) use the Sonora framebuffer */			/* Incidentally this is also used in the non-AV models			   of the x100 PowerMacs */			/* These do in fact seem to use the same DAC interface			   as the LC II. */		case MAC_MODEL_LCIII:		case MAC_MODEL_P520:		case MAC_MODEL_P550:		case MAC_MODEL_P460:			macfb_setpalette = v8_brazil_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			strcpy( fb_info.modename, "Sonora built-in" );			v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);			break;			/* IIci and IIsi use the infamous RBV chip                           (the IIsi is just a rebadged and crippled                           IIci in a different case, BTW) */		case MAC_MODEL_IICI:		case MAC_MODEL_IISI:			macfb_setpalette = rbv_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			strcpy( fb_info.modename, "RBV built-in" );			rbv_cmap_regs = ioremap(DAC_BASE, 0x1000);			break;			/* AVs use the Civic framebuffer */		case MAC_MODEL_Q840:		case MAC_MODEL_C660:			macfb_setpalette = civic_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			strcpy( fb_info.modename, "Civic built-in" );			civic_cmap_regs = ioremap(CIVIC_BASE, 0x1000);			break;					/* Write a setpalette function for your machine, then			   you can add something similar here.  These are			   grouped by classes of video chipsets.  Some of this			   information is from the VideoToolbox "Bugs" web			   page at			   http://rajsky.psych.nyu.edu/Tips/VideoBugs.html */			/* Assorted weirdos */			/* We think this may be like the LC II */		case MAC_MODEL_LC:			if (vidtest) {				macfb_setpalette = v8_brazil_setpalette;				macfb_defined.activate = FB_ACTIVATE_NOW;				v8_brazil_cmap_regs =					ioremap(DAC_BASE, 0x1000);			}			strcpy( fb_info.modename, "LC built-in" );			break;			/* We think this may be like the LC II */		case MAC_MODEL_CCL:			if (vidtest) {				macfb_setpalette = v8_brazil_setpalette;				macfb_defined.activate = FB_ACTIVATE_NOW;				v8_brazil_cmap_regs =					ioremap(DAC_BASE, 0x1000);			}			strcpy( fb_info.modename, "Color Classic built-in" );			break;			/* And we *do* mean "weirdos" */		case MAC_MODEL_TV:			strcpy( fb_info.modename, "Mac TV built-in" );			break;			/* These don't have colour, so no need to worry */		case MAC_MODEL_SE30:		case MAC_MODEL_CLII:			strcpy( fb_info.modename, "Monochrome built-in" );			break;			/* Powerbooks are particularly difficult.  Many of			   them have separate framebuffers for external and			   internal video, which is admittedly pretty cool,			   but will be a bit of a headache to support here.			   Also, many of them are grayscale, and we don't			   really support that. */		case MAC_MODEL_PB140:		case MAC_MODEL_PB145:		case MAC_MODEL_PB170:			strcpy( fb_info.modename, "DDC built-in" );			break;			/* Internal is GSC, External (if present) is ViSC */		case MAC_MODEL_PB150:	/* no external video */		case MAC_MODEL_PB160:		case MAC_MODEL_PB165:		case MAC_MODEL_PB180:		case MAC_MODEL_PB210:		case MAC_MODEL_PB230:			strcpy( fb_info.modename, "GSC built-in" );			break;			/* Internal is TIM, External is ViSC */		case MAC_MODEL_PB165C:		case MAC_MODEL_PB180C:			strcpy( fb_info.modename, "TIM built-in" );			break;			/* Internal is CSC, External is Keystone+Ariel. */		case MAC_MODEL_PB190:	/* external video is optional */		case MAC_MODEL_PB520:		case MAC_MODEL_PB250:		case MAC_MODEL_PB270C:		case MAC_MODEL_PB280:		case MAC_MODEL_PB280C:			macfb_setpalette = csc_setpalette;			macfb_defined.activate = FB_ACTIVATE_NOW;			strcpy( fb_info.modename, "CSC built-in" );			csc_cmap_regs = ioremap(CSC_BASE, 0x1000);			break;				default:			strcpy( fb_info.modename, "Unknown/Unsupported built-in" );			break;		}		fb_info.changevar  = NULL;	fb_info.node       = -1;	fb_info.fbops      = &macfb_ops;	fb_info.disp       = &disp;	fb_info.switch_con = &macfb_switch;	fb_info.updatevar  = &macfb_update_var;	fb_info.blank      = &macfb_blank;	fb_info.flags      = FBINFO_FLAG_DEFAULT;	macfb_set_disp(-1);	do_install_cmap(0, &fb_info);		if (register_framebuffer(&fb_info) < 0)		return;	printk("fb%d: %s frame buffer device\n",	       GET_FB_IDX(fb_info.node), fb_info.modename);}MODULE_LICENSE("GPL");

⌨️ 快捷键说明

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