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

📄 viafbdev.c

📁 via framebuffer driver
💻 C
📖 第 1 页 / 共 5 页
字号:
		outb(0x1B, 0x3C4);		/* Second Display Engine colck always on */		outb(sr1b | 0x80, 0x3C5);		outb(0x67, 0x3D4);		/* Second Display Color Depth 8 */		outb(cr67 & 0x3F, 0x3D5);		outb(0x6A, 0x3D4);		/* Second Display Channel Reset CR6A[6]) */		outb(cr6a & 0xBF, 0x3D5);		/* Second Display Channel Enable CR6A[7] */		outb(cr6a | 0x80, 0x3D5);		/* Second Display Channel stop reset) */		outb(cr6a | 0xC0, 0x3D5);		/* Bit mask of palette */		outb(0xFF, 0x3c6);		outb(0x00, 0x3C8);		if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&			rev >= 15) {			shift = 8;			viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);			viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);		} else {			shift = 10;			viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);			viafb_write_reg_mask(SR15, VIASR, 0, BIT7);		}		for (i = 0; i < len; i++) {			outb((*(pred + i)) >> shift, 0x3C9);			outb((*(pgreen + i)) >> shift, 0x3C9);			outb((*(pblue + i)) >> shift, 0x3C9);		}		outb(0x1A, 0x3C4);		/* Map the 3C6/7/8/9 to the IGA1 */		outb(sr1a & 0xFE, 0x3C5);		/* Bit mask of palette */		outb(0xFF, 0x3c6);		outb(0x00, 0x3C8);		for (i = 0; i < len; i++) {			outb((*(pred + i)) >> shift, 0x3C9);			outb((*(pgreen + i)) >> shift, 0x3C9);			outb((*(pblue + i)) >> shift, 0x3C9);		}		outb(0x1A, 0x3C4);		outb(sr1a, 0x3C5);		outb(0x1B, 0x3C4);		outb(sr1b, 0x3C5);		outb(0x67, 0x3D4);		outb(cr67, 0x3D5);		outb(0x6A, 0x3D4);		outb(cr6a, 0x3D5);		break;	case 16:		if (len > 17)			return 0;	/* Because static u32 pseudo_pal[17]; */		for (i = 0; i < len; i++)			((u32 *) info->pseudo_palette)[i] =			    (*(pred + i) & 0xF800) |			    ((*(pgreen + i) & 0xFC00) >> 5) |			    ((*(pblue + i) & 0xF800) >> 11);		break;	case 32:		if (len > 17)			return 0;		if (ptransp) {			for (i = 0; i < len; i++)				((u32 *) info->pseudo_palette)[i] =				    ((*(ptransp + i) & 0xFF00) << 16) |				    ((*(pred + i) & 0xFF00) << 8) |				    ((*(pgreen + i) & 0xFF00)) |				    ((*(pblue + i) & 0xFF00) >> 8);		} else {			for (i = 0; i < len; i++)				((u32 *) info->pseudo_palette)[i] =				    0x00000000 |				    ((*(pred + i) & 0xFF00) << 8) |				    ((*(pgreen + i) & 0xFF00)) |				    ((*(pblue + i) & 0xFF00) >> 8);		}		break;	}	return 0;}static int viafb_pan_display(struct fb_var_screeninfo *var,	struct fb_info *info){	unsigned int offset = 0;	DEBUG_MSG(KERN_INFO "viafb_pan_display!\n");	offset = (var->xoffset + (var->yoffset * var->xres)) *	    var->bits_per_pixel / 16;	DEBUG_MSG(KERN_INFO "\nviafb_pan_display,offset =%d ", offset);	viafb_write_reg_mask(0x48, 0x3d4, ((offset >> 24) & 0x3), 0x3);	viafb_write_reg_mask(0x34, 0x3d4, ((offset >> 16) & 0xff), 0xff);	viafb_write_reg_mask(0x0c, 0x3d4, ((offset >> 8) & 0xff), 0xff);	viafb_write_reg_mask(0x0d, 0x3d4, (offset & 0xff), 0xff);	return 0;}static int viafb_blank(int blank_mode, struct fb_info *info){	DEBUG_MSG(KERN_INFO "viafb_blank!\n");	/* clear DPMS setting */	switch (blank_mode) {	case FB_BLANK_UNBLANK:		/* Screen: On, HSync: On, VSync: On */		/* control CRT monitor power management */		viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);		break;	case FB_BLANK_HSYNC_SUSPEND:		/* Screen: Off, HSync: Off, VSync: On */		/* control CRT monitor power management */		viafb_write_reg_mask(CR36, VIACR, 0x10, BIT4 + BIT5);		break;	case FB_BLANK_VSYNC_SUSPEND:		/* Screen: Off, HSync: On, VSync: Off */		/* control CRT monitor power management */		viafb_write_reg_mask(CR36, VIACR, 0x20, BIT4 + BIT5);		break;	case FB_BLANK_POWERDOWN:		/* Screen: Off, HSync: Off, VSync: Off */		/* control CRT monitor power management */		viafb_write_reg_mask(CR36, VIACR, 0x30, BIT4 + BIT5);		break;	}	return 0;}static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg){	struct viafb_ioctl_info viainfo;	struct viafb_ioctl_mode viamode;	struct viafb_ioctl_samm viasamm;	struct viafb_driver_version driver_version;	struct fb_var_screeninfo sec_var;	struct _panel_size_pos_info panel_pos_size_para;	u32 state_info = 0;	u32 viafb_gamma_table[256];	char driver_name[10] = "viafb\0";	u32 __user *argp = (u32 __user *) arg;	u32 gpu32 = 0, ss;	u32 video_dev_info = 0;	struct viafb_ioctl_setting viafb_setting;	struct device_t active_dev;	ss = sizeof(active_dev);	memset(&active_dev, 0, ss);	memset(&viafb_setting, 0, sizeof(viafb_setting));	DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);	switch (cmd) {	case VIAFB_GET_CHIP_INFO:	/*struct chip_information chip_info ; */	if (copy_to_user((void __user *)arg, viaparinfo->chip_info,		sizeof(struct chip_information)))		return -EFAULT;		break;	case VIAFB_GET_INFO_SIZE:		return put_user(sizeof(viainfo), argp);	case VIAFB_GET_INFO:		return viafb_ioctl_get_viafb_info(arg);	case VIAFB_HOTPLUG:		return put_user((u32)				viafb_ioctl_hotplug(info->var.xres,					      info->var.yres,					      info->var.bits_per_pixel), argp);		break;	case VIAFB_SET_HOTPLUG_FLAG:		if (copy_from_user(&gpu32, argp, sizeof(gpu32)))			return -EFAULT;		via_fb_hotplug = (gpu32) ? 1 : 0;		break;	case VIAFB_GET_RESOLUTION:		viamode.xres = (u32) via_fb_hotplug_Xres;		viamode.yres = (u32) via_fb_hotplug_Yres;		viamode.refresh = (u32) via_fb_hotplug_refresh;		viamode.bpp = (u32) via_fb_hotplug_bpp;		if (viafb_SAMM_ON == 1) {			viamode.xres_sec = viafb_second_xres;			viamode.yres_sec = viafb_second_yres;			viamode.virtual_xres_sec = viafb_second_virtual_xres;			viamode.virtual_yres_sec = viafb_second_virtual_yres;			viamode.refresh_sec = viafb_refresh1;			viamode.bpp_sec = via_fb_bpp1;		} else {			viamode.xres_sec = 0;			viamode.yres_sec = 0;			viamode.virtual_xres_sec = 0;			viamode.virtual_yres_sec = 0;			viamode.refresh_sec = 0;			viamode.bpp_sec = 0;		}		if (copy_to_user((void __user *)arg,			&viamode, sizeof(viamode)))			return -EFAULT;		break;	case VIAFB_GET_SAMM_INFO:		viasamm.samm_status = viafb_SAMM_ON;		if (viafb_SAMM_ON == 1) {			if (viafb_dual_fb) {				viasamm.size_prim = viaparinfo->fbmem_free;				viasamm.size_sec = viaparinfo1->fbmem_free;			} else {				if (viafb_second_size) {					viasamm.size_prim =					    viaparinfo->fbmem_free -					    viafb_second_size * 1024 * 1024;					viasamm.size_sec =					    viafb_second_size * 1024 * 1024;				} else {					viasamm.size_prim =					    viaparinfo->fbmem_free >> 1;					viasamm.size_sec =					    (viaparinfo->fbmem_free >> 1);				}			}			viasamm.mem_base = viaparinfo->fbmem;			viasamm.offset_sec = viafb_second_offset;		} else {			viasamm.size_prim =			    viaparinfo->memsize - viaparinfo->fbmem_used;			viasamm.size_sec = 0;			viasamm.mem_base = viaparinfo->fbmem;			viasamm.offset_sec = 0;		}		if (copy_to_user((void __user *)arg,			&viasamm, sizeof(viasamm)))			return -EFAULT;		break;	case VIAFB_TURN_ON_OUTPUT_DEVICE:		if (copy_from_user(&gpu32, argp, sizeof(gpu32)))			return -EFAULT;		if (gpu32 & CRT_Device)			viafb_crt_enable();		if (gpu32 & DVI_Device)			viafb_dvi_enable();		if (gpu32 & LCD_Device)			viafb_lcd_enable();		break;	case VIAFB_TURN_OFF_OUTPUT_DEVICE:		if (copy_from_user(&gpu32, argp, sizeof(gpu32)))			return -EFAULT;		if (gpu32 & CRT_Device)			viafb_crt_disable();		if (gpu32 & DVI_Device)			viafb_dvi_disable();		if (gpu32 & LCD_Device)			viafb_lcd_disable();		break;	case VIAFB_SET_DEVICE:		if (copy_from_user(&active_dev, (void *)argp, ss))			return -EFAULT;		viafb_set_device(active_dev);		viafb_set_par(info);		break;	case VIAFB_GET_DEVICE:		active_dev.crt = viafb_CRT_ON;		active_dev.dvi = viafb_DVI_ON;		active_dev.lcd = viafb_LCD_ON;		active_dev.samm = viafb_SAMM_ON;		active_dev.primary_dev = viafb_primary_dev;		active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;		active_dev.lcd_panel_id = viafb_lcd_panel_id;		active_dev.lcd_mode = viafb_lcd_mode;		active_dev.xres = via_fb_hotplug_Xres;		active_dev.yres = via_fb_hotplug_Yres;		active_dev.xres1 = viafb_second_xres;		active_dev.yres1 = viafb_second_yres;		active_dev.bpp = via_fb_bpp;		active_dev.bpp1 = via_fb_bpp1;		active_dev.refresh = viafb_refresh;		active_dev.refresh1 = viafb_refresh1;		active_dev.epia_dvi = viafb_platform_epia_dvi;		active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;		active_dev.bus_width = via_bus_width;		if (copy_to_user((void __user *)arg, &active_dev, ss))			return -EFAULT;		break;	case VIAFB_GET_DRIVER_VERSION:		driver_version.iMajorNum = VERSION_MAJOR;		driver_version.iKernelNum = VERSION_KERNEL;		driver_version.iOSNum = VERSION_OS;		driver_version.iMinorNum = VERSION_MINOR;		if (copy_to_user		    ((void __user *)arg, &driver_version,		     sizeof(driver_version)))			return -EFAULT;		break;	case VIAFB_SET_DEVICE_INFO:		if (copy_from_user		    (&viafb_setting, (void *)argp, sizeof(viafb_setting)))			return -EFAULT;		if (apply_device_setting(viafb_setting, info) < 0)			return -EINVAL;		break;	case VIAFB_SET_SECOND_MODE:		if (copy_from_user(&sec_var, (void *)argp, sizeof(sec_var)))			return -EFAULT;		apply_second_mode_setting(&sec_var);		break;	case VIAFB_GET_DEVICE_INFO:		retrieve_device_setting(&viafb_setting);		if (copy_to_user		    ((void __user *)arg, &viafb_setting,		     sizeof(viafb_setting)))			return -EFAULT;		break;	case VIAFB_GET_DEVICE_SUPPORT:		get_device_support_state(&state_info);		if (put_user(state_info, argp))			return -EFAULT;		break;	case VIAFB_GET_DEVICE_CONNECT:		get_device_connect_state(&state_info);		if (put_user(state_info, argp))			return -EFAULT;		break;	case VIAFB_GET_PANEL_SUPPORT_EXPAND:		state_info =		    lcd_get_support_expand_state(info->var.xres,						 info->var.yres);		if (put_user(state_info, argp))			return -EFAULT;		break;	case VIAFB_GET_DRIVER_NAME:		if (copy_to_user		    ((void __user *)arg, driver_name, sizeof(driver_name)))			return -EFAULT;		break;	case VIAFB_SET_GAMMA_LUT:		if (copy_from_user		    (viafb_gamma_table, argp, sizeof(viafb_gamma_table)))			return -EFAULT;		set_gamma_table(via_fb_bpp, viafb_gamma_table);		break;	case VIAFB_GET_GAMMA_LUT:		get_gamma_table(viafb_gamma_table);		if (copy_to_user		    ((void __user *)arg, viafb_gamma_table,		     sizeof(viafb_gamma_table)))			return -EFAULT;		break;	case VIAFB_GET_GAMMA_SUPPORT_STATE:		get_gamma_support_state(via_fb_bpp, &state_info);		if (put_user(state_info, argp))			return -EFAULT;		break;	case VIAFB_SET_VIDEO_DEVICE:		get_user(video_dev_info, argp);		viafb_set_video_device(video_dev_info);		break;	case VIAFB_GET_VIDEO_DEVICE:		viafb_get_video_device(&video_dev_info);		if (put_user(video_dev_info, argp))			return -EFAULT;		break;	case VIAFB_SYNC_SURFACE:		DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");		break;	case VIAFB_GET_DRIVER_CAPS:		break;	case VIAFB_GET_PANEL_MAX_SIZE:		if (copy_from_user		    (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))			return -EFAULT;		get_panel_max_scal_size(&panel_pos_size_para);		if (copy_to_user		    ((void __user *)arg, &panel_pos_size_para,		     sizeof(panel_pos_size_para)))			return -EFAULT;		break;	case VIAFB_GET_PANEL_MAX_POSITION:		if (copy_from_user		    (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))			return -EFAULT;		get_panel_max_scal_pos(&panel_pos_size_para);		if (copy_to_user		    ((void __user *)arg, &panel_pos_size_para,		     sizeof(panel_pos_size_para)))			return -EFAULT;		break;	case VIAFB_GET_PANEL_POSITION:		if (copy_from_user		    (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))			return -EFAULT;		get_panel_scal_pos(&panel_pos_size_para);		if (copy_to_user		    ((void __user *)arg, &panel_pos_size_para,		     sizeof(panel_pos_size_para)))			return -EFAULT;		break;	case VIAFB_GET_PANEL_SIZE:		if (copy_from_user		    (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))			return -EFAULT;		get_panel_scal_size(&panel_pos_size_para);		if (copy_to_user		    ((void __user *)arg, &panel_pos_size_para,		     sizeof(panel_pos_size_para)))			return -EFAULT;		break;	case VIAFB_SET_PANEL_POSITION:		if (copy_from_user		    (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))			return -EFAULT;		set_panel_scal_pos(&panel_pos_size_para);		break;	case VIAFB_SET_PANEL_SIZE:		if (copy_from_user		    (&panel_pos_size_para, argp, sizeof(panel_pos_size_para)))			return -EFAULT;		set_panel_scal_size(&panel_pos_size_para);		break;	default:		return -EINVAL;	}	return 0;}static void viafb_fillrect(struct fb_info *info,	const struct fb_fillrect *rect){	u32 col = 0, rop = 0;	int pitch;	if (!via_fb_accel)		return cfb_fillrect(info, rect);	if (!rect->width || !rect->height)		return;	switch (rect->rop) {	case ROP_XOR:

⌨️ 快捷键说明

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