0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <linux/kernel.h>
0014 #include <linux/errno.h>
0015 #include <linux/string.h>
0016 #include <linux/mm.h>
0017 #include <linux/delay.h>
0018 #include <linux/interrupt.h>
0019 #include <linux/platform_device.h>
0020
0021 #include <linux/uaccess.h>
0022 #include <asm/setup.h>
0023 #include <asm/q40_master.h>
0024 #include <linux/fb.h>
0025 #include <linux/module.h>
0026
0027 #define Q40_PHYS_SCREEN_ADDR 0xFE800000
0028
0029 static struct fb_fix_screeninfo q40fb_fix = {
0030 .id = "Q40",
0031 .smem_len = 1024*1024,
0032 .type = FB_TYPE_PACKED_PIXELS,
0033 .visual = FB_VISUAL_TRUECOLOR,
0034 .line_length = 1024*2,
0035 .accel = FB_ACCEL_NONE,
0036 };
0037
0038 static const struct fb_var_screeninfo q40fb_var = {
0039 .xres = 1024,
0040 .yres = 512,
0041 .xres_virtual = 1024,
0042 .yres_virtual = 512,
0043 .bits_per_pixel = 16,
0044 .red = {6, 5, 0},
0045 .green = {11, 5, 0},
0046 .blue = {0, 6, 0},
0047 .activate = FB_ACTIVATE_NOW,
0048 .height = 230,
0049 .width = 300,
0050 .vmode = FB_VMODE_NONINTERLACED,
0051 };
0052
0053 static int q40fb_setcolreg(unsigned regno, unsigned red, unsigned green,
0054 unsigned blue, unsigned transp,
0055 struct fb_info *info)
0056 {
0057
0058
0059
0060
0061
0062
0063 if (regno > 255)
0064 return 1;
0065 red>>=11;
0066 green>>=11;
0067 blue>>=10;
0068
0069 if (regno < 16) {
0070 ((u32 *)info->pseudo_palette)[regno] = ((red & 31) <<6) |
0071 ((green & 31) << 11) |
0072 (blue & 63);
0073 }
0074 return 0;
0075 }
0076
0077 static const struct fb_ops q40fb_ops = {
0078 .owner = THIS_MODULE,
0079 .fb_setcolreg = q40fb_setcolreg,
0080 .fb_fillrect = cfb_fillrect,
0081 .fb_copyarea = cfb_copyarea,
0082 .fb_imageblit = cfb_imageblit,
0083 };
0084
0085 static int q40fb_probe(struct platform_device *dev)
0086 {
0087 struct fb_info *info;
0088
0089 if (!MACH_IS_Q40)
0090 return -ENXIO;
0091
0092
0093 q40fb_fix.smem_start = Q40_PHYS_SCREEN_ADDR;
0094
0095 info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
0096 if (!info)
0097 return -ENOMEM;
0098
0099 info->var = q40fb_var;
0100 info->fix = q40fb_fix;
0101 info->fbops = &q40fb_ops;
0102 info->flags = FBINFO_DEFAULT;
0103 info->pseudo_palette = info->par;
0104 info->par = NULL;
0105 info->screen_base = (char *) q40fb_fix.smem_start;
0106
0107 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
0108 framebuffer_release(info);
0109 return -ENOMEM;
0110 }
0111
0112 master_outb(3, DISPLAY_CONTROL_REG);
0113
0114 if (register_framebuffer(info) < 0) {
0115 printk(KERN_ERR "Unable to register Q40 frame buffer\n");
0116 fb_dealloc_cmap(&info->cmap);
0117 framebuffer_release(info);
0118 return -EINVAL;
0119 }
0120
0121 fb_info(info, "Q40 frame buffer alive and kicking !\n");
0122 return 0;
0123 }
0124
0125 static struct platform_driver q40fb_driver = {
0126 .probe = q40fb_probe,
0127 .driver = {
0128 .name = "q40fb",
0129 },
0130 };
0131
0132 static struct platform_device q40fb_device = {
0133 .name = "q40fb",
0134 };
0135
0136 static int __init q40fb_init(void)
0137 {
0138 int ret = 0;
0139
0140 if (fb_get_options("q40fb", NULL))
0141 return -ENODEV;
0142
0143 ret = platform_driver_register(&q40fb_driver);
0144
0145 if (!ret) {
0146 ret = platform_device_register(&q40fb_device);
0147 if (ret)
0148 platform_driver_unregister(&q40fb_driver);
0149 }
0150 return ret;
0151 }
0152
0153 module_init(q40fb_init);
0154 MODULE_LICENSE("GPL");