sync hh.org
[hh.org.git] / drivers / video / vsfb.c
blob903a4db4d142c996819698a6e2b719af4823ed01
1 /*
2 * linux/drivers/video/vsfb.c
4 * Copyright (C) 2003 Ian Molton
6 * Based on acornfb by Russell King
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * Frame buffer code for Simple platforms
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
19 #include <linux/errno.h>
20 #include <linux/string.h>
21 #include <linux/ctype.h>
22 #include <linux/mm.h>
23 #include <linux/tty.h>
24 #include <linux/slab.h>
25 #include <linux/init.h>
26 #include <linux/fb.h>
27 #include <linux/vsfb.h>
28 #include <linux/ioport.h>
29 #include <linux/platform_device.h>
31 #include <asm/hardware.h>
32 #include <asm/io.h>
33 #include <asm/irq.h>
34 #include <asm/mach-types.h>
35 #include <asm/uaccess.h>
37 static struct fb_info fb_info;
38 static u32 colreg[17]; // Copied from other driver - but is 17 correct?
41 static int
42 vsfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
43 u_int trans, struct fb_info *info)
45 if (regno > 16)
46 return 1;
48 ((u32 *)(info->pseudo_palette))[regno] = (red & 0xf800) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11);
50 return 0;
53 static struct fb_ops vsfb_ops = {
54 .owner = THIS_MODULE,
55 .fb_setcolreg = vsfb_setcolreg,
56 .fb_fillrect = cfb_fillrect,
57 .fb_copyarea = cfb_copyarea,
58 .fb_imageblit = cfb_imageblit,
61 static int vsfb_probe(struct platform_device *pdev) {
62 struct vsfb_deviceinfo *vsfb;
64 vsfb = pdev->dev.platform_data;
65 if(!vsfb)
66 return -ENODEV;
68 memcpy (&fb_info.fix, vsfb->fix, sizeof(struct fb_fix_screeninfo));
69 memcpy (&fb_info.var, vsfb->var, sizeof(struct fb_var_screeninfo));
71 fb_info.fbops = &vsfb_ops;
72 fb_info.flags = FBINFO_FLAG_DEFAULT;
73 fb_info.pseudo_palette = colreg;
74 fb_alloc_cmap(&fb_info.cmap, 16, 0); //FIXME - needs to work for all depths
76 /* Try to grab our phys memory space... */
77 if (!(request_mem_region(fb_info.fix.smem_start, fb_info.fix.smem_len, "vsfb"))){
78 return -ENOMEM;
81 /* Try to map this so we can access it */
82 fb_info.screen_base = ioremap(fb_info.fix.smem_start, fb_info.fix.smem_len);
83 if (!fb_info.screen_base) {
84 release_mem_region(fb_info.fix.smem_start, fb_info.fix.smem_len);
85 return -EIO;
88 printk(KERN_INFO "vsfb: framebuffer at 0x%lx, mapped to 0x%p, size %dk\n", fb_info.fix.smem_start, fb_info.screen_base, fb_info.fix.smem_len/1024);
90 if (register_framebuffer(&fb_info) < 0){
91 iounmap(fb_info.screen_base);
92 release_mem_region(fb_info.fix.smem_start, fb_info.fix.smem_len);
94 return -EINVAL;
97 return 0;
100 struct platform_driver vsfb_driver = {
101 .driver = {
102 .name = "vsfb",
104 .probe = vsfb_probe,
105 // .remove = vsfb_remove,
108 static int __init vsfb_init(void)
110 return platform_driver_register (&vsfb_driver);
111 return 0;
114 #if 0
115 static void __exit tmio_mmc_exit(void)
117 return platform_driver_unregister (&tmio_mmc_driver);
119 #endif
121 module_init(vsfb_init);
123 MODULE_AUTHOR("Ian Molton (based on acornfb by RMK and parts of anakinfb)");
124 MODULE_DESCRIPTION("Very Simple framebuffer driver");
125 MODULE_LICENSE("GPL");