1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/module.h>
18#include <linux/mm.h>
19#include <linux/fb.h>
20#include <linux/init.h>
21#include <linux/zorro.h>
22#include <asm/io.h>
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120#define FRAMEMASTER_SIZE 0x200000
121#define FRAMEMASTER_REG 0x1ffff8
122
123#define FRAMEMASTER_NOLACE 1
124#define FRAMEMASTER_ENABLE 2
125#define FRAMEMASTER_COMPL 4
126#define FRAMEMASTER_ROM 8
127
128static volatile unsigned char *fm2fb_reg;
129
130static struct fb_fix_screeninfo fb_fix __devinitdata = {
131 .smem_len = FRAMEMASTER_REG,
132 .type = FB_TYPE_PACKED_PIXELS,
133 .visual = FB_VISUAL_TRUECOLOR,
134 .line_length = (768 << 2),
135 .mmio_len = (8),
136 .accel = FB_ACCEL_NONE,
137};
138
139static int fm2fb_mode __devinitdata = -1;
140
141#define FM2FB_MODE_PAL 0
142#define FM2FB_MODE_NTSC 1
143
144static struct fb_var_screeninfo fb_var_modes[] __devinitdata = {
145 {
146
147 768, 576, 768, 576, 0, 0, 32, 0,
148 { 16, 8, 0 }, { 8, 8, 0 }, { 0, 8, 0 }, { 24, 8, 0 },
149 0, FB_ACTIVATE_NOW, -1, -1, FB_ACCEL_NONE,
150 33333, 10, 102, 10, 5, 80, 34, FB_SYNC_COMP_HIGH_ACT, 0
151 }, {
152
153 768, 480, 768, 480, 0, 0, 32, 0,
154 { 16, 8, 0 }, { 8, 8, 0 }, { 0, 8, 0 }, { 24, 8, 0 },
155 0, FB_ACTIVATE_NOW, -1, -1, FB_ACCEL_NONE,
156 33333, 10, 102, 10, 5, 80, 34, FB_SYNC_COMP_HIGH_ACT, 0
157 }
158};
159
160
161
162
163
164static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
165 u_int transp, struct fb_info *info);
166static int fm2fb_blank(int blank, struct fb_info *info);
167
168static struct fb_ops fm2fb_ops = {
169 .owner = THIS_MODULE,
170 .fb_setcolreg = fm2fb_setcolreg,
171 .fb_blank = fm2fb_blank,
172 .fb_fillrect = cfb_fillrect,
173 .fb_copyarea = cfb_copyarea,
174 .fb_imageblit = cfb_imageblit,
175};
176
177
178
179
180static int fm2fb_blank(int blank, struct fb_info *info)
181{
182 unsigned char t = FRAMEMASTER_ROM;
183
184 if (!blank)
185 t |= FRAMEMASTER_ENABLE | FRAMEMASTER_NOLACE;
186 fm2fb_reg[0] = t;
187 return 0;
188}
189
190
191
192
193
194
195static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
196 u_int transp, struct fb_info *info)
197{
198 if (regno < 16) {
199 red >>= 8;
200 green >>= 8;
201 blue >>= 8;
202
203 ((u32*)(info->pseudo_palette))[regno] = (red << 16) |
204 (green << 8) | blue;
205 }
206
207 return 0;
208}
209
210
211
212
213
214static int __devinit fm2fb_probe(struct zorro_dev *z,
215 const struct zorro_device_id *id);
216
217static struct zorro_device_id fm2fb_devices[] __devinitdata = {
218 { ZORRO_PROD_BSC_FRAMEMASTER_II },
219 { ZORRO_PROD_HELFRICH_RAINBOW_II },
220 { 0 }
221};
222MODULE_DEVICE_TABLE(zorro, fm2fb_devices);
223
224static struct zorro_driver fm2fb_driver = {
225 .name = "fm2fb",
226 .id_table = fm2fb_devices,
227 .probe = fm2fb_probe,
228};
229
230static int __devinit fm2fb_probe(struct zorro_dev *z,
231 const struct zorro_device_id *id)
232{
233 struct fb_info *info;
234 unsigned long *ptr;
235 int is_fm;
236 int x, y;
237
238 is_fm = z->id == ZORRO_PROD_BSC_FRAMEMASTER_II;
239
240 if (!zorro_request_device(z,"fm2fb"))
241 return -ENXIO;
242
243 info = framebuffer_alloc(16 * sizeof(u32), &z->dev);
244 if (!info) {
245 zorro_release_device(z);
246 return -ENOMEM;
247 }
248
249 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
250 framebuffer_release(info);
251 zorro_release_device(z);
252 return -ENOMEM;
253 }
254
255
256 fb_fix.smem_start = zorro_resource_start(z);
257 info->screen_base = ioremap(fb_fix.smem_start, FRAMEMASTER_SIZE);
258 fb_fix.mmio_start = fb_fix.smem_start + FRAMEMASTER_REG;
259 fm2fb_reg = (unsigned char *)(info->screen_base+FRAMEMASTER_REG);
260
261 strcpy(fb_fix.id, is_fm ? "FrameMaster II" : "Rainbow II");
262
263
264 ptr = (unsigned long *)fb_fix.smem_start;
265 for (y = 0; y < 576; y++) {
266 for (x = 0; x < 96; x++) *ptr++ = 0xffffff;
267 for (x = 0; x < 96; x++) *ptr++ = 0xffff00;
268 for (x = 0; x < 96; x++) *ptr++ = 0x00ffff;
269 for (x = 0; x < 96; x++) *ptr++ = 0x00ff00;
270 for (x = 0; x < 96; x++) *ptr++ = 0xff00ff;
271 for (x = 0; x < 96; x++) *ptr++ = 0xff0000;
272 for (x = 0; x < 96; x++) *ptr++ = 0x0000ff;
273 for (x = 0; x < 96; x++) *ptr++ = 0x000000;
274 }
275 fm2fb_blank(0, info);
276
277 if (fm2fb_mode == -1)
278 fm2fb_mode = FM2FB_MODE_PAL;
279
280 info->fbops = &fm2fb_ops;
281 info->var = fb_var_modes[fm2fb_mode];
282 info->pseudo_palette = info->par;
283 info->par = NULL;
284 info->fix = fb_fix;
285 info->flags = FBINFO_DEFAULT;
286
287 if (register_framebuffer(info) < 0) {
288 fb_dealloc_cmap(&info->cmap);
289 iounmap(info->screen_base);
290 framebuffer_release(info);
291 zorro_release_device(z);
292 return -EINVAL;
293 }
294 printk("fb%d: %s frame buffer device\n", info->node, fb_fix.id);
295 return 0;
296}
297
298int __init fm2fb_setup(char *options)
299{
300 char *this_opt;
301
302 if (!options || !*options)
303 return 0;
304
305 while ((this_opt = strsep(&options, ",")) != NULL) {
306 if (!strncmp(this_opt, "pal", 3))
307 fm2fb_mode = FM2FB_MODE_PAL;
308 else if (!strncmp(this_opt, "ntsc", 4))
309 fm2fb_mode = FM2FB_MODE_NTSC;
310 }
311 return 0;
312}
313
314int __init fm2fb_init(void)
315{
316 char *option = NULL;
317
318 if (fb_get_options("fm2fb", &option))
319 return -ENODEV;
320 fm2fb_setup(option);
321 return zorro_register_driver(&fm2fb_driver);
322}
323
324module_init(fm2fb_init);
325MODULE_LICENSE("GPL");
326