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

📄 igafb.c

📁 S3C44B0X下的LCD (framebuffer)驱动资料与相关代码
💻 C
📖 第 1 页 / 共 2 页
字号:
static int igafb_get_cmap(struct fb_cmap *cmap, int kspc, int con,                           struct fb_info *fb_info){	struct fb_info_iga *info = (struct fb_info_iga*) fb_info;	        if (con == info->currcon) /* current console? */                return fb_get_cmap(cmap, kspc, iga_getcolreg, &info->fb_info);        else if (fb_display[con].cmap.len) /* non default colormap? */                fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);        else                fb_copy_cmap(fb_default_cmap(info->video_cmap_len),                     cmap, kspc ? 0 : 2);        return 0;}static int igafb_set_cmap(struct fb_cmap *cmap, int kspc, int con,	                  struct fb_info *info){        int err;	struct fb_info_iga *fb = (struct fb_info_iga*) info;        if (!fb_display[con].cmap.len) {        /* no colormap allocated? */                err = fb_alloc_cmap(&fb_display[con].cmap,				    fb->video_cmap_len,0);                if (err)                        return err;        }        if (con == fb->currcon)                     /* current console? */                return fb_set_cmap(cmap, kspc, iga_setcolreg, info);        else                fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);        return 0;}/* * Framebuffer option structure */static struct fb_ops igafb_ops = {	owner:		THIS_MODULE,	fb_get_fix:	igafb_get_fix,	fb_get_var:	igafb_get_var,	fb_set_var:	igafb_set_var,	fb_get_cmap:	igafb_get_cmap,	fb_set_cmap:	igafb_set_cmap,#ifdef __sparc__	fb_mmap:	igafb_mmap,#endif};static void igafb_set_disp(int con, struct fb_info_iga *info){        struct fb_fix_screeninfo fix;        struct display *display;        struct display_switch *sw;        if (con >= 0)                display = &fb_display[con];        else                 display = &info->disp;        /* used during initialization */        igafb_get_fix(&fix, con, &info->fb_info);        memset(display, 0, sizeof(struct display));        display->screen_base = info->frame_buffer;        display->visual = fix.visual;        display->type = fix.type;        display->type_aux = fix.type_aux;        display->ypanstep = fix.ypanstep;        display->ywrapstep = fix.ywrapstep;        display->line_length = fix.line_length;        display->next_line = fix.line_length;        display->can_soft_blank = 0;         display->inverse = 0;        igafb_get_var(&display->var, -1, &info->fb_info);        switch (default_var.bits_per_pixel) {#ifdef FBCON_HAS_CFB8        case 8:                sw = &fbcon_cfb8;                break;#endif#ifdef FBCON_HAS_CFB16        case 15:        case 16:                sw = &fbcon_cfb16;		display->dispsw_data = info->fbcon_cmap.cfb16;                break;#endif#ifdef FBCON_HAS_CFB24	case 24:		sw = &fbcon_cfb24;		display->dispsw_data = info->fbcon_cmap.cfb24;		break;#endif#ifdef FBCON_HAS_CFB32        case 32:                sw = &fbcon_cfb32;		display->dispsw_data = info->fbcon_cmap.cfb32;                break;#endif        default:		printk(KERN_WARNING "igafb_set_disp: unknown resolution %d\n",		    default_var.bits_per_pixel);                return;        }        memcpy(&info->dispsw, sw, sizeof(*sw));        display->dispsw = &info->dispsw;	display->scrollmode = SCROLL_YREDRAW;	info->dispsw.bmove = fbcon_redraw_bmove;}static int igafb_switch(int con, struct fb_info *fb_info){	struct fb_info_iga *info = (struct fb_info_iga*) fb_info;        /* Do we have to save the colormap? */        if (fb_display[info->currcon].cmap.len)                fb_get_cmap(&fb_display[info->currcon].cmap, 1,                            iga_getcolreg, fb_info);	info->currcon = con;	/* Install new colormap */	do_install_cmap(con, fb_info);	igafb_update_var(con, fb_info);        return 1;}/* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */static void igafb_blank(int blank, struct fb_info *info){        /* Not supported */}static int __init iga_init(struct fb_info_iga *info){        char vramsz = iga_inb(info, IGA_EXT_CNTRL, IGA_IDX_EXT_BUS_CNTL) 		                                         & MEM_SIZE_ALIAS;        switch (vramsz) {        case MEM_SIZE_1M:                info->total_vram = 0x100000;                break;        case MEM_SIZE_2M:                info->total_vram = 0x200000;                break;        case MEM_SIZE_4M:        case MEM_SIZE_RESERVED:                info->total_vram = 0x400000;                break;        }        if (default_var.bits_per_pixel > 8) {                info->video_cmap_len = 16;        } else {                info->video_cmap_len = 256;        }	{		int j, k;		for (j = 0; j < 16; j++) {			k = color_table[j];			info->palette[j].red = default_red[k];			info->palette[j].green = default_grn[k];			info->palette[j].blue = default_blu[k];		}	}	strcpy(info->fb_info.modename, igafb_name);	info->fb_info.node = -1;	info->fb_info.fbops = &igafb_ops;	info->fb_info.disp = &info->disp;	strcpy(info->fb_info.fontname, fontname);	info->fb_info.changevar = NULL;	info->fb_info.switch_con = &igafb_switch;	info->fb_info.updatevar = &igafb_update_var;	info->fb_info.blank = &igafb_blank;	info->fb_info.flags=FBINFO_FLAG_DEFAULT;	igafb_set_disp(-1, info);	if (register_framebuffer(&info->fb_info) < 0)		return 0;	printk("fb%d: %s frame buffer device at 0x%08lx [%dMB VRAM]\n",	       GET_FB_IDX(info->fb_info.node), igafb_name, 	       info->frame_buffer_phys, info->total_vram >> 20);	iga_blank_border(info); 	return 1;}int __init igafb_init(void){        struct pci_dev *pdev;        struct fb_info_iga *info;        unsigned long addr;        extern int con_is_present(void);	int iga2000 = 0;        /* Do not attach when we have a serial console. */        if (!con_is_present())                return -ENXIO;        pdev = pci_find_device(PCI_VENDOR_ID_INTERG,                                PCI_DEVICE_ID_INTERG_1682, 0);	if (pdev == NULL) {		/*		 * XXX We tried to use cyber2000fb.c for IGS 2000.		 * But it does not initialize the chip in JavaStation-E, alas.		 */        	pdev = pci_find_device(PCI_VENDOR_ID_INTERG, 0x2000, 0);        	if(pdev == NULL) {        	        return -ENXIO;		}		iga2000 = 1;	}        info = kmalloc(sizeof(struct fb_info_iga), GFP_ATOMIC);        if (!info) {                printk("igafb_init: can't alloc fb_info_iga\n");                return -ENOMEM;        }        memset(info, 0, sizeof(struct fb_info_iga));	if ((addr = pdev->resource[0].start) == 0) {                printk("igafb_init: no memory start\n");		kfree(info);		return -ENXIO;	}	if ((info->frame_buffer = ioremap(addr, 1024*1024*2)) == 0) {                printk("igafb_init: can't remap %lx[2M]\n", addr);		kfree(info);		return -ENXIO;	}	info->frame_buffer_phys = addr & PCI_BASE_ADDRESS_MEM_MASK;#ifdef __sparc__	/*	 * The following is sparc specific and this is why:	 *	 * IGS2000 has its I/O memory mapped and we want	 * to generate memory cycles on PCI, e.g. do ioremap(),	 * then readb/writeb() as in Documentation/IO-mapping.txt.	 *	 * IGS1682 is more traditional, it responds to PCI I/O	 * cycles, so we want to access it with inb()/outb().	 *	 * On sparc, PCIC converts CPU memory access within	 * phys window 0x3000xxxx into PCI I/O cycles. Therefore	 * we may use readb/writeb to access them with IGS1682.	 *	 * We do not take io_base_phys from resource[n].start	 * on IGS1682 because that chip is BROKEN. It does not	 * have a base register for I/O. We just "know" what its	 * I/O addresses are.	 */	if (iga2000) {		info->io_base_phys = info->frame_buffer_phys | 0x00800000;	} else {		info->io_base_phys = 0x30000000;	/* XXX */	}	if ((info->io_base = (int) ioremap(info->io_base_phys, 0x1000)) == 0) {                printk("igafb_init: can't remap %lx[4K]\n", info->io_base_phys);		iounmap((void *)info->frame_buffer);                kfree(info);		return -ENXIO;	}	/*	 * Figure mmap addresses from PCI config space.	 * We need two regions: for video memory and for I/O ports.	 * Later one can add region for video coprocessor registers.	 * However, mmap routine loops until size != 0, so we put	 * one additional region with size == 0. 	 */	info->mmap_map = kmalloc(4 * sizeof(*info->mmap_map), GFP_ATOMIC);	if (!info->mmap_map) {		printk("igafb_init: can't alloc mmap_map\n");		iounmap((void *)info->io_base);		iounmap(info->frame_buffer);                kfree(info);		return -ENOMEM;	}	memset(info->mmap_map, 0, 4 * sizeof(*info->mmap_map));	/*	 * Set default vmode and cmode from PROM properties.	 */	{                struct pcidev_cookie *cookie = pdev->sysdata;                int node = cookie->prom_node;                int width = prom_getintdefault(node, "width", 1024);                int height = prom_getintdefault(node, "height", 768);                int depth = prom_getintdefault(node, "depth", 8);                switch (width) {                    case 1024:                        if (height == 768)                            default_var = default_var_1024x768;                        break;                    case 1152:                        if (height == 900)                            default_var = default_var_1152x900;                        break;                    case 1280:                        if (height == 1024)                            default_var = default_var_1280x1024;                        break;                    default:                        break;                }                switch (depth) {                    case 8:                        default_var.bits_per_pixel = 8;                        break;                    case 16:                        default_var.bits_per_pixel = 16;                        break;                    case 24:                        default_var.bits_per_pixel = 24;                        break;                    case 32:                        default_var.bits_per_pixel = 32;                        break;                    default:                        break;                }            }#endif	if (!iga_init(info)) {		iounmap((void *)info->io_base);		iounmap(info->frame_buffer);		if (info->mmap_map)			kfree(info->mmap_map);		kfree(info);        }#ifdef __sparc__	    /*	     * Add /dev/fb mmap values.	     */	    	    /* First region is for video memory */	    info->mmap_map[0].voff = 0x0;  	    info->mmap_map[0].poff = info->frame_buffer_phys & PAGE_MASK;	    info->mmap_map[0].size = info->total_vram   & PAGE_MASK;	    info->mmap_map[0].prot_mask = SRMMU_CACHE;	    info->mmap_map[0].prot_flag = SRMMU_WRITE;	    /* Second region is for I/O ports */	    info->mmap_map[1].voff = info->frame_buffer_phys & PAGE_MASK;	    info->mmap_map[1].poff = info->io_base_phys & PAGE_MASK;	    info->mmap_map[1].size = PAGE_SIZE * 2; /* X wants 2 pages */	    info->mmap_map[1].prot_mask = SRMMU_CACHE;	    info->mmap_map[1].prot_flag = SRMMU_WRITE;#endif /* __sparc__ */	return 0;}int __init igafb_setup(char *options){    char *this_opt;    if (!options || !*options)        return 0;    while ((this_opt = strsep(&options, ",")) != NULL) {        if (!strncmp(this_opt, "font:", 5)) {                char *p;                int i;                p = this_opt + 5;                for (i = 0; i < sizeof(fontname) - 1; i++)                        if (!*p || *p == ' ' || *p == ',')                                break;                memcpy(fontname, this_opt + 5, i);                fontname[i] = 0;        }    }    return 0;}MODULE_LICENSE("GPL");

⌨️ 快捷键说明

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