2 * linux/drivers/video/q40fb.c -- Q40 frame buffer device
6 * Richard Zidlicky <rz@linux-m68k.org>
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
13 #include <linux/kernel.h>
14 #include <linux/errno.h>
15 #include <linux/string.h>
17 #include <linux/delay.h>
18 #include <linux/interrupt.h>
19 #include <linux/platform_device.h>
21 #include <asm/uaccess.h>
22 #include <asm/setup.h>
23 #include <asm/system.h>
24 #include <asm/q40_master.h>
26 #include <linux/module.h>
27 #include <asm/pgtable.h>
29 #define Q40_PHYS_SCREEN_ADDR 0xFE800000
31 static struct fb_fix_screeninfo q40fb_fix __initdata = {
33 .smem_len = 1024*1024,
34 .type = FB_TYPE_PACKED_PIXELS,
35 .visual = FB_VISUAL_TRUECOLOR,
36 .line_length = 1024*2,
37 .accel = FB_ACCEL_NONE,
40 static struct fb_var_screeninfo q40fb_var __initdata = {
49 .activate = FB_ACTIVATE_NOW,
52 .vmode = FB_VMODE_NONINTERLACED,
55 static int q40fb_setcolreg(unsigned regno, unsigned red, unsigned green,
56 unsigned blue, unsigned transp,
60 * Set a single color register. The values supplied have a 16 bit
62 * Return != 0 for invalid regno.
72 ((u32 *)info->pseudo_palette)[regno] = ((red & 31) <<6) |
73 ((green & 31) << 11) |
79 static struct fb_ops q40fb_ops = {
81 .fb_setcolreg = q40fb_setcolreg,
82 .fb_fillrect = cfb_fillrect,
83 .fb_copyarea = cfb_copyarea,
84 .fb_imageblit = cfb_imageblit,
87 static int __devinit q40fb_probe(struct platform_device *dev)
94 /* mapped in q40/config.c */
95 q40fb_fix.smem_start = Q40_PHYS_SCREEN_ADDR;
97 info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
101 info->var = q40fb_var;
102 info->fix = q40fb_fix;
103 info->fbops = &q40fb_ops;
104 info->flags = FBINFO_DEFAULT; /* not as module for now */
105 info->pseudo_palette = info->par;
107 info->screen_base = (char *) q40fb_fix.smem_start;
109 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
110 framebuffer_release(info);
114 master_outb(3, DISPLAY_CONTROL_REG);
116 if (register_framebuffer(info) < 0) {
117 printk(KERN_ERR "Unable to register Q40 frame buffer\n");
118 fb_dealloc_cmap(&info->cmap);
119 framebuffer_release(info);
123 printk(KERN_INFO "fb%d: Q40 frame buffer alive and kicking !\n",
128 static struct platform_driver q40fb_driver = {
129 .probe = q40fb_probe,
135 static struct platform_device q40fb_device = {
139 int __init q40fb_init(void)
143 if (fb_get_options("q40fb", NULL))
146 ret = platform_driver_register(&q40fb_driver);
149 ret = platform_device_register(&q40fb_device);
151 platform_driver_unregister(&q40fb_driver);
156 module_init(q40fb_init);
157 MODULE_LICENSE("GPL");