[PATCH] aic7xxx_osm build fix
[cris-mirror.git] / drivers / video / pmagb-b-fb.c
blobd14eaee91cfffd63d9ddd171e4f466a4a4d5640e
1 /*
2 * linux/drivers/video/pmagb-b-fb.c
4 * PMAGB-B TurboChannel framebuffer card support ... derived from:
5 * "HP300 Topcat framebuffer support (derived from macfb of all things)
6 * Phil Blundell <philb@gnu.org> 1998", the original code can be
7 * found in the file hpfb.c in the same directory.
9 * DECstation related code Copyright (C) 1999, 2000, 2001 by
10 * Michael Engel <engel@unix-ag.org>,
11 * Karsten Merker <merker@linuxtag.org> and
12 * Harald Koerfgen.
13 * This file is subject to the terms and conditions of the GNU General
14 * Public License. See the file COPYING in the main directory of this
15 * archive for more details.
20 * We currently only support the PMAGB-B in high resolution mode
21 * as I know of no way to detect low resolution mode set via jumper.
22 * KM, 2001/01/07
25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/sched.h>
28 #include <linux/errno.h>
29 #include <linux/string.h>
30 #include <linux/timer.h>
31 #include <linux/mm.h>
32 #include <linux/tty.h>
33 #include <linux/slab.h>
34 #include <linux/delay.h>
35 #include <linux/init.h>
36 #include <linux/fb.h>
37 #include <asm/bootinfo.h>
38 #include <asm/dec/machtype.h>
39 #include <asm/dec/tc.h>
40 #include <video/pmagb-b-fb.h>
42 struct pmagb_b_ramdac_regs {
43 unsigned char addr_low;
44 unsigned char pad0[3];
45 unsigned char addr_hi;
46 unsigned char pad1[3];
47 unsigned char data;
48 unsigned char pad2[3];
49 unsigned char cmap;
53 * Max 3 TURBOchannel slots -> max 3 PMAGB-B :)
55 static struct fb_info pmagbb_fb_info[3];
57 static struct fb_var_screeninfo pmagbbfb_defined = {
58 .xres = 1280,
59 .yres = 1024,
60 .xres_virtual = 1280,
61 .yres_virtual = 1024,
62 .bits_per_pixel = 8,
63 .red.length = 8,
64 .green.length = 8,
65 .blue.length = 8,
66 .activate = FB_ACTIVATE_NOW,
67 .height = 274,
68 .width = 195,
69 .accel_flags = FB_ACCEL_NONE,
70 .vmode = FB_VMODE_NONINTERLACED,
73 static struct fb_fix_screeninfo pmagbafb_fix = {
74 .id = "PMAGB-BA",
75 .smem_len = (1280 * 1024),
76 .type = FB_TYPE_PACKED_PIXELS,
77 .visual = FB_VISUAL_PSEUDOCOLOR,
78 .line_length = 1280,
82 * Turn hardware cursor off
84 void pmagbbfb_erase_cursor(struct pmagb_b_ramdac_regs *bt459_regs)
86 bt459_regs->addr_low = 0;
87 bt459_regs->addr_hi = 3;
88 bt459_regs->data = 0;
92 * Set the palette.
94 static int pmagbbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
95 unsigned blue, unsigned transp,
96 struct fb_info *info)
98 struct pmagb_b_ramdac_regs *bt459_regs = (struct pmagb_b_ramdac_regs *) info->par;
100 if (regno >= info->cmap.len)
101 return 1;
103 red >>= 8; /* The cmap fields are 16 bits */
104 green >>= 8; /* wide, but the harware colormap */
105 blue >>= 8; /* registers are only 8 bits wide */
107 bt459_regs->addr_low = (__u8) regno;
108 bt459_regs->addr_hi = 0;
109 bt459_regs->cmap = red;
110 bt459_regs->cmap = green;
111 bt459_regs->cmap = blue;
112 return 0;
115 static struct fb_ops pmagbbfb_ops = {
116 .owner = THIS_MODULE,
117 .fb_setcolreg = pmagbbfb_setcolreg,
118 .fb_fillrect = cfb_fillrect,
119 .fb_copyarea = cfb_copyarea,
120 .fb_imageblit = cfb_imageblit,
121 .fb_cursor = soft_cursor,
124 int __init pmagbbfb_init_one(int slot)
126 unsigned long base_addr = get_tc_base_addr(slot);
127 struct fb_info *info = &pmagbb_fb_info[slot];
129 printk("PMAGB-BA framebuffer in slot %d\n", slot);
131 * Framebuffer display memory base address and friends
133 pmagbbfb_fix.smem_start = base_addr + PMAGB_B_ONBOARD_FBMEM_OFFSET;
134 info->par = (base_addr + PMAGB_B_BT459_OFFSET);
137 * Configure the Bt459 RAM DAC
139 pmagbbfb_erase_cursor((struct pmagb_b_ramdac_regs *) info->par);
142 * Let there be consoles..
144 info->fbops = &pmagbbfb_ops;
145 info->var = pmagbbfb_defined;
146 info->fix = pmagbbfb_fix;
147 info->screen_base = pmagbbfb_fix.smem_start;
148 info->flags = FBINFO_DEFAULT;
150 fb_alloc_cmap(&fb_info.cmap, 256, 0);
152 if (register_framebuffer(info) < 0)
153 return 1;
154 return 0;
158 * Initialise the framebuffer
161 int __init pmagbbfb_init(void)
163 int sid;
164 int found = 0;
166 if (fb_get_options("pmagbbfb", NULL))
167 return -ENODEV;
169 if (TURBOCHANNEL) {
170 while ((sid = search_tc_card("PMAGB-BA")) >= 0) {
171 found = 1;
172 claim_tc_card(sid);
173 pmagbbfb_init_one(sid);
175 return found ? 0 : -ENODEV;
176 } else {
177 return -ENODEV;
181 module_init(pmagbbfb_init);
182 MODULE_LICENSE("GPL");