2 * linux/drivers/video/pmag-ba-fb.c
4 * PMAG-BA 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 * Based on digital document:
10 * "PMAG-BA TURBOchannel Color Frame Buffer
11 * Functional Specification", Revision 1.2, August 27, 1990
13 * DECstation related code Copyright (C) 1999, 2000, 2001 by
14 * Michael Engel <engel@unix-ag.org>,
15 * Karsten Merker <merker@linuxtag.org> and
17 * This file is subject to the terms and conditions of the GNU General
18 * Public License. See the file COPYING in the main directory of this
19 * archive for more details.
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/sched.h>
25 #include <linux/errno.h>
26 #include <linux/string.h>
27 #include <linux/timer.h>
29 #include <linux/tty.h>
30 #include <linux/slab.h>
31 #include <linux/delay.h>
32 #include <linux/init.h>
34 #include <asm/bootinfo.h>
35 #include <asm/dec/machtype.h>
36 #include <asm/dec/tc.h>
37 #include <video/pmag-ba-fb.h>
39 struct pmag_ba_ramdac_regs
{
40 unsigned char addr_low
;
41 unsigned char pad0
[3];
42 unsigned char addr_hi
;
43 unsigned char pad1
[3];
45 unsigned char pad2
[3];
50 * Max 3 TURBOchannel slots -> max 3 PMAG-BA :)
52 static struct fb_info pmagba_fb_info
[3];
54 static struct fb_var_screeninfo pmagbafb_defined
= {
63 .activate
= FB_ACTIVATE_NOW
,
66 .accel
= FB_ACCEL_NONE
,
67 .vmode
= FB_VMODE_NONINTERLACED
,
70 static struct fb_fix_screeninfo pmagbafb_fix
= {
72 .smem_len
= (1024 * 864),
73 .type
= FB_TYPE_PACKED_PIXELS
,
74 .visual
= FB_VISUAL_PSEUDOCOLOR
,
79 * Turn hardware cursor off
81 void pmagbafb_erase_cursor(struct pmag_ba_ramdac_regs
*bt459_regs
)
83 bt459_regs
->addr_low
= 0;
84 bt459_regs
->addr_hi
= 3;
91 static int pmagbafb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
92 unsigned blue
, unsigned transp
,
95 struct pmag_ba_ramdac_regs
*bt459_regs
= (struct pmag_ba_ramdac_regs
*) info
->par
;
97 if (regno
>= info
->cmap
.len
)
100 red
>>= 8; /* The cmap fields are 16 bits */
101 green
>>= 8; /* wide, but the harware colormap */
102 blue
>>= 8; /* registers are only 8 bits wide */
104 bt459_regs
->addr_low
= (__u8
) regno
;
105 bt459_regs
->addr_hi
= 0;
106 bt459_regs
->cmap
= red
;
107 bt459_regs
->cmap
= green
;
108 bt459_regs
->cmap
= blue
;
112 static struct fb_ops pmagbafb_ops
= {
113 .owner
= THIS_MODULE
,
114 .fb_get_fix
= gen_get_fix
,
115 .fb_get_var
= gen_get_var
,
116 .fb_setcolreg
= pmagbafb_setcolreg
,
117 .fb_fillrect
= cfb_fillrect
,
118 .fb_copyarea
= cfb_copyarea
,
119 .fb_imageblit
= cfb_imageblit
,
120 .fb_cursor
= soft_cursor
,
123 int __init
pmagbafb_init_one(int slot
)
125 unsigned long base_addr
= get_tc_base_addr(slot
);
126 struct fb_info
*info
= &pmagba_fb_info
[slot
];
127 struct display
*disp
= &pmagba_disp
[slot
];
129 printk("PMAG-BA framebuffer in slot %d\n", slot
);
131 * Framebuffer display memory base address and friends
133 pmagbafb_fix
.smem_start
= base_addr
+ PMAG_BA_ONBOARD_FBMEM_OFFSET
;
134 info
->par
= (base_addr
+ PMAG_BA_BT459_OFFSET
);
137 * Configure the Bt459 RAM DAC
139 pmagbafb_erase_cursor((struct pmag_ba_ramdac_regs
*) info
->par
);
142 * Let there be consoles..
144 info
->fbops
= &pmagbafb_ops
;
145 info
->var
= pmagbafb_defined
;
146 info
->fix
= pmagbafb_fix
;
147 info
->screen_base
= pmagbafb_fix
.smem_start
;
148 info
->flags
= FBINFO_DEFAULT
;
150 fb_alloc_cmap(&fb_info
.cmap
, 256, 0);
152 if (register_framebuffer(info
) < 0)
158 * Initialise the framebuffer
161 int __init
pmagbafb_init(void)
166 if (fb_get_options("pmagbafb", NULL
))
170 while ((sid
= search_tc_card("PMAG-BA")) >= 0) {
173 pmagbafb_init_one(sid
);
175 return found
? 0 : -ENODEV
;
181 module_init(pmagbafb_init
);
182 MODULE_LICENSE("GPL");