Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/drivers/video/maxinefb.c | |
3 | * | |
4 | * DECstation 5000/xx onboard framebuffer 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 | * DECstation related code Copyright (C) 1999,2000,2001 by | |
10 | * Michael Engel <engel@unix-ag.org> and | |
11 | * Karsten Merker <merker@linuxtag.org>. | |
12 | * This file is subject to the terms and conditions of the GNU General | |
13 | * Public License. See the file COPYING in the main directory of this | |
14 | * archive for more details. | |
15 | * | |
16 | */ | |
17 | ||
18 | /* | |
19 | * Changes: | |
20 | * 2001/01/27 removed debugging and testing code, fixed fb_ops | |
21 | * initialization which had caused a crash before, | |
22 | * general cleanup, first official release (KM) | |
23 | * | |
24 | */ | |
25 | ||
26 | #include <linux/module.h> | |
27 | #include <linux/kernel.h> | |
28 | #include <linux/sched.h> | |
29 | #include <linux/errno.h> | |
30 | #include <linux/string.h> | |
31 | #include <linux/mm.h> | |
1da177e4 LT |
32 | #include <linux/slab.h> |
33 | #include <linux/delay.h> | |
34 | #include <linux/init.h> | |
35 | #include <linux/fb.h> | |
36 | #include <video/maxinefb.h> | |
37 | ||
38 | /* bootinfo.h defines the machine type values, needed when checking */ | |
39 | /* whether are really running on a maxine, KM */ | |
40 | #include <asm/bootinfo.h> | |
41 | ||
42 | static struct fb_info fb_info; | |
43 | ||
44 | static struct fb_var_screeninfo maxinefb_defined = { | |
45 | .xres = 1024, | |
46 | .yres = 768, | |
47 | .xres_virtual = 1024, | |
48 | .yres_virtual = 768, | |
49 | .bits_per_pixel =8, | |
50 | .activate = FB_ACTIVATE_NOW, | |
51 | .height = -1, | |
52 | .width = -1, | |
53 | .vmode = FB_VMODE_NONINTERLACED, | |
54 | }; | |
55 | ||
56 | static struct fb_fix_screeninfo maxinefb_fix = { | |
8fd66ab8 | 57 | .id = "Maxine", |
1da177e4 LT |
58 | .smem_len = (1024*768), |
59 | .type = FB_TYPE_PACKED_PIXELS, | |
60 | .visual = FB_VISUAL_PSEUDOCOLOR, | |
61 | .line_length = 1024, | |
62 | }; | |
63 | ||
64 | /* Handle the funny Inmos RamDAC/video controller ... */ | |
65 | ||
66 | void maxinefb_ims332_write_register(int regno, register unsigned int val) | |
67 | { | |
68 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS; | |
69 | unsigned char *wptr; | |
70 | ||
71 | wptr = regs + 0xa0000 + (regno << 4); | |
72 | *((volatile unsigned int *) (regs)) = (val >> 8) & 0xff00; | |
73 | *((volatile unsigned short *) (wptr)) = val; | |
74 | } | |
75 | ||
76 | unsigned int maxinefb_ims332_read_register(int regno) | |
77 | { | |
78 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS; | |
79 | unsigned char *rptr; | |
80 | register unsigned int j, k; | |
81 | ||
82 | rptr = regs + 0x80000 + (regno << 4); | |
83 | j = *((volatile unsigned short *) rptr); | |
84 | k = *((volatile unsigned short *) regs); | |
85 | ||
86 | return (j & 0xffff) | ((k & 0xff00) << 8); | |
87 | } | |
88 | ||
89 | /* Set the palette */ | |
90 | static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green, | |
91 | unsigned blue, unsigned transp, struct fb_info *info) | |
92 | { | |
93 | /* value to be written into the palette reg. */ | |
94 | unsigned long hw_colorvalue = 0; | |
95 | ||
96 | red >>= 8; /* The cmap fields are 16 bits */ | |
97 | green >>= 8; /* wide, but the harware colormap */ | |
98 | blue >>= 8; /* registers are only 8 bits wide */ | |
99 | ||
100 | hw_colorvalue = (blue << 16) + (green << 8) + (red); | |
101 | ||
102 | maxinefb_ims332_write_register(IMS332_REG_COLOR_PALETTE + regno, | |
103 | hw_colorvalue); | |
104 | return 0; | |
105 | } | |
106 | ||
107 | static struct fb_ops maxinefb_ops = { | |
108 | .owner = THIS_MODULE, | |
1da177e4 LT |
109 | .fb_setcolreg = maxinefb_setcolreg, |
110 | .fb_fillrect = cfb_fillrect, | |
111 | .fb_copyarea = cfb_copyarea, | |
112 | .fb_imageblit = cfb_imageblit, | |
1da177e4 LT |
113 | }; |
114 | ||
115 | int __init maxinefb_init(void) | |
116 | { | |
117 | unsigned long fboff; | |
118 | unsigned long fb_start; | |
119 | int i; | |
120 | ||
121 | if (fb_get_options("maxinefb", NULL)) | |
122 | return -ENODEV; | |
123 | ||
124 | /* Validate we're on the proper machine type */ | |
125 | if (mips_machtype != MACH_DS5000_XX) { | |
126 | return -EINVAL; | |
127 | } | |
128 | ||
129 | printk(KERN_INFO "Maxinefb: Personal DECstation detected\n"); | |
130 | printk(KERN_INFO "Maxinefb: initializing onboard framebuffer\n"); | |
131 | ||
132 | /* Framebuffer display memory base address */ | |
133 | fb_start = DS5000_xx_ONBOARD_FBMEM_START; | |
134 | ||
135 | /* Clear screen */ | |
136 | for (fboff = fb_start; fboff < fb_start + 0x1ffff; fboff++) | |
137 | *(volatile unsigned char *)fboff = 0x0; | |
138 | ||
139 | maxinefb_fix.smem_start = fb_start; | |
140 | ||
141 | /* erase hardware cursor */ | |
142 | for (i = 0; i < 512; i++) { | |
143 | maxinefb_ims332_write_register(IMS332_REG_CURSOR_RAM + i, | |
144 | 0); | |
145 | /* | |
146 | if (i&0x8 == 0) | |
147 | maxinefb_ims332_write_register (IMS332_REG_CURSOR_RAM + i, 0x0f); | |
148 | else | |
149 | maxinefb_ims332_write_register (IMS332_REG_CURSOR_RAM + i, 0xf0); | |
150 | */ | |
151 | } | |
152 | ||
153 | fb_info.fbops = &maxinefb_ops; | |
154 | fb_info.screen_base = (char *)maxinefb_fix.smem_start; | |
155 | fb_info.var = maxinefb_defined; | |
156 | fb_info.fix = maxinefb_fix; | |
157 | fb_info.flags = FBINFO_DEFAULT; | |
158 | ||
159 | fb_alloc_cmap(&fb_info.cmap, 256, 0); | |
160 | ||
161 | if (register_framebuffer(&fb_info) < 0) | |
162 | return 1; | |
163 | return 0; | |
164 | } | |
165 | ||
166 | static void __exit maxinefb_exit(void) | |
167 | { | |
168 | unregister_framebuffer(&fb_info); | |
169 | } | |
170 | ||
171 | #ifdef MODULE | |
172 | MODULE_LICENSE("GPL"); | |
173 | #endif | |
174 | module_init(maxinefb_init); | |
175 | module_exit(maxinefb_exit); | |
176 |