aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/pmag-ba-fb.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/video/pmag-ba-fb.c
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/video/pmag-ba-fb.c')
-rw-r--r--drivers/video/pmag-ba-fb.c182
1 files changed, 182 insertions, 0 deletions
diff --git a/drivers/video/pmag-ba-fb.c b/drivers/video/pmag-ba-fb.c
new file mode 100644
index 000000000000..f8095588e99d
--- /dev/null
+++ b/drivers/video/pmag-ba-fb.c
@@ -0,0 +1,182 @@
1/*
2 * linux/drivers/video/pmag-ba-fb.c
3 *
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.
8 *
9 * Based on digital document:
10 * "PMAG-BA TURBOchannel Color Frame Buffer
11 * Functional Specification", Revision 1.2, August 27, 1990
12 *
13 * DECstation related code Copyright (C) 1999, 2000, 2001 by
14 * Michael Engel <engel@unix-ag.org>,
15 * Karsten Merker <merker@linuxtag.org> and
16 * Harald Koerfgen.
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.
20 *
21 */
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>
28#include <linux/mm.h>
29#include <linux/tty.h>
30#include <linux/slab.h>
31#include <linux/delay.h>
32#include <linux/init.h>
33#include <linux/fb.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>
38
39struct pmag_ba_ramdac_regs {
40 unsigned char addr_low;
41 unsigned char pad0[3];
42 unsigned char addr_hi;
43 unsigned char pad1[3];
44 unsigned char data;
45 unsigned char pad2[3];
46 unsigned char cmap;
47};
48
49/*
50 * Max 3 TURBOchannel slots -> max 3 PMAG-BA :)
51 */
52static struct fb_info pmagba_fb_info[3];
53
54static struct fb_var_screeninfo pmagbafb_defined = {
55 .xres = 1024,
56 .yres = 864,
57 .xres_virtual = 1024,
58 .yres_virtual = 864,
59 .bits_per_pixel = 8,
60 .red.length = 8,
61 .green.length = 8,
62 .blue.length = 8,
63 .activate = FB_ACTIVATE_NOW,
64 .height = 274,
65 .width = 195,
66 .accel = FB_ACCEL_NONE,
67 .vmode = FB_VMODE_NONINTERLACED,
68};
69
70static struct fb_fix_screeninfo pmagbafb_fix = {
71 .id = "PMAG-BA",
72 .smem_len = (1024 * 864),
73 .type = FB_TYPE_PACKED_PIXELS,
74 .visual = FB_VISUAL_PSEUDOCOLOR,
75 .line_length = 1024,
76};
77
78/*
79 * Turn hardware cursor off
80 */
81void pmagbafb_erase_cursor(struct pmag_ba_ramdac_regs *bt459_regs)
82{
83 bt459_regs->addr_low = 0;
84 bt459_regs->addr_hi = 3;
85 bt459_regs->data = 0;
86}
87
88/*
89 * Set the palette.
90 */
91static int pmagbafb_setcolreg(unsigned regno, unsigned red, unsigned green,
92 unsigned blue, unsigned transp,
93 struct fb_info *info)
94{
95 struct pmag_ba_ramdac_regs *bt459_regs = (struct pmag_ba_ramdac_regs *) info->par;
96
97 if (regno >= info->cmap.len)
98 return 1;
99
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 */
103
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;
109 return 0;
110}
111
112static 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,
121};
122
123int __init pmagbafb_init_one(int slot)
124{
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];
128
129 printk("PMAG-BA framebuffer in slot %d\n", slot);
130 /*
131 * Framebuffer display memory base address and friends
132 */
133 pmagbafb_fix.smem_start = base_addr + PMAG_BA_ONBOARD_FBMEM_OFFSET;
134 info->par = (base_addr + PMAG_BA_BT459_OFFSET);
135
136 /*
137 * Configure the Bt459 RAM DAC
138 */
139 pmagbafb_erase_cursor((struct pmag_ba_ramdac_regs *) info->par);
140
141 /*
142 * Let there be consoles..
143 */
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;
149
150 fb_alloc_cmap(&fb_info.cmap, 256, 0);
151
152 if (register_framebuffer(info) < 0)
153 return 1;
154 return 0;
155}
156
157/*
158 * Initialise the framebuffer
159 */
160
161int __init pmagbafb_init(void)
162{
163 int sid;
164 int found = 0;
165
166 if (fb_get_options("pmagbafb", NULL))
167 return -ENODEV;
168
169 if (TURBOCHANNEL) {
170 while ((sid = search_tc_card("PMAG-BA")) >= 0) {
171 found = 1;
172 claim_tc_card(sid);
173 pmagbafb_init_one(sid);
174 }
175 return found ? 0 : -ENODEV;
176 } else {
177 return -ENODEV;
178 }
179}
180
181module_init(pmagbafb_init);
182MODULE_LICENSE("GPL");