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/tty.h>
18 #include <linux/slab.h>
19 #include <linux/delay.h>
20 #include <linux/interrupt.h>
22 #include <asm/uaccess.h>
23 #include <asm/setup.h>
24 #include <asm/system.h>
25 #include <asm/q40_master.h>
27 #include <linux/module.h>
28 #include <asm/pgtable.h>
30 #define Q40_PHYS_SCREEN_ADDR 0xFE800000
32 static struct fb_fix_screeninfo q40fb_fix __initdata = {
34 .smem_len = 1024*1024,
35 .type = FB_TYPE_PACKED_PIXELS,
36 .visual = FB_VISUAL_TRUECOLOR,
37 .line_length = 1024*2,
38 .accel = FB_ACCEL_NONE,
41 static struct fb_var_screeninfo q40fb_var __initdata = {
50 .activate = FB_ACTIVATE_NOW,
53 .vmode = FB_VMODE_NONINTERLACED,
56 static int q40fb_setcolreg(unsigned regno, unsigned red, unsigned green,
57 unsigned blue, unsigned transp,
61 * Set a single color register. The values supplied have a 16 bit
63 * Return != 0 for invalid regno.
73 ((u32 *)info->pseudo_palette)[regno] = ((red & 31) <<6) |
74 ((green & 31) << 11) |
80 static struct fb_ops q40fb_ops = {
82 .fb_setcolreg = q40fb_setcolreg,
83 .fb_fillrect = cfb_fillrect,
84 .fb_copyarea = cfb_copyarea,
85 .fb_imageblit = cfb_imageblit,
86 .fb_cursor = soft_cursor,
89 static int __init q40fb_probe(struct device *device)
91 struct platform_device *dev = to_platform_device(device);
97 /* mapped in q40/config.c */
98 q40fb_fix.smem_start = Q40_PHYS_SCREEN_ADDR;
100 info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
104 info->var = q40fb_var;
105 info->fix = q40fb_fix;
106 info->fbops = &q40fb_ops;
107 info->flags = FBINFO_DEFAULT; /* not as module for now */
108 info->pseudo_palette = info->par;
110 info->screen_base = (char *) q40fb_fix.smem_start;
112 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
113 framebuffer_release(info);
117 master_outb(3, DISPLAY_CONTROL_REG);
119 if (register_framebuffer(info) < 0) {
120 printk(KERN_ERR "Unable to register Q40 frame buffer\n");
121 fb_dealloc_cmap(&info->cmap);
122 framebuffer_release(info);
126 printk(KERN_INFO "fb%d: Q40 frame buffer alive and kicking !\n",
131 static struct device_driver q40fb_driver = {
133 .bus = &platform_bus_type,
134 .probe = q40fb_probe,
137 static struct platform_device q40fb_device = {
141 int __init q40fb_init(void)
145 if (fb_get_options("q40fb", NULL))
148 ret = driver_register(&q40fb_driver);
151 ret = platform_device_register(&q40fb_device);
153 driver_unregister(&q40fb_driver);
158 module_init(q40fb_init);
159 MODULE_LICENSE("GPL");