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 * 2003-03-08 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
25 * Moved ims332 support in its own file. Code cleanup.
26 *
27 * 2003-09-08 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
28 * First attempt of mono and hw cursor support.
29 */
30
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/sched.h>
34 #include <linux/errno.h>
35 #include <linux/string.h>
36 #include <linux/mm.h>
37 #include <linux/tty.h>
38 #include <linux/slab.h>
39 #include <linux/delay.h>
40 #include <linux/timer.h>
41 #include <linux/init.h>
42 #include <linux/fb.h>
43 #include <linux/console.h>
44
45 /*
46 * bootinfo.h is needed for checking whether we are really running
47 * on a maxine.
48 */
49 #include <asm/bootinfo.h>
50 #include <asm/addrspace.h>
51
52 #include <video/fbcon.h>
53 #include <video/fbcon-mfb.h>
54 #include <video/fbcon-cfb2.h>
55 #include <video/fbcon-cfb4.h>
56 #include <video/fbcon-cfb8.h>
57
58 #include "ims332.h"
59
60 /* Version information */
61 #define DRIVER_VERSION "0.02"
62 #define DRIVER_AUTHOR "Karsten Merker <merker@linuxtag.org>"
63 #define DRIVER_DESCRIPTION "Maxine Framebuffer Driver"
64 #define DRIVER_DESCR "maxinefb"
65
66 /* Prototypes */
67 static int maxinefb_set_var(struct fb_var_screeninfo *var, int con,
68 struct fb_info *info);
69
70 /* Hardware cursor */
71 struct maxine_cursor {
72 struct timer_list timer;
73 int enable;
74 int on;
75 int vbl_cnt;
76 int blink_rate;
77 u16 x, y, width, height;
78 };
79
80 #define CURSOR_TIMER_FREQ (HZ / 50)
81 #define CURSOR_BLINK_RATE (20)
82 #define CURSOR_DRAW_DELAY (2)
83
84 static struct maxinefb_info {
85 struct fb_info info;
86 struct display disp;
87 struct display_switch dispsw;
88 struct ims332_regs *ims332;
89 unsigned long fb_start;
90 u32 fb_size;
91 struct maxine_cursor cursor;
92 } *my_info;
93
94 static struct maxinefb_par {
95 } current_par;
96
97 static int currcon = -1;
98
maxine_set_cursor(struct maxinefb_info * ip,int on)99 static void maxine_set_cursor(struct maxinefb_info *ip, int on)
100 {
101 struct maxine_cursor *c = &ip->cursor;
102
103 if (on)
104 ims332_position_cursor(ip->ims332, c->x, c->y);
105
106 ims332_enable_cursor(ip->ims332, on);
107 }
108
maxinefbcon_cursor(struct display * disp,int mode,int x,int y)109 static void maxinefbcon_cursor(struct display *disp, int mode, int x, int y)
110 {
111 struct maxinefb_info *ip = (struct maxinefb_info *)disp->fb_info;
112 struct maxine_cursor *c = &ip->cursor;
113
114 x *= fontwidth(disp);
115 y *= fontheight(disp);
116
117 if (c->x == x && c->y == y && (mode == CM_ERASE) == !c->enable)
118 return;
119
120 c->enable = 0;
121 if (c->on)
122 maxine_set_cursor(ip, 0);
123 c->x = x - disp->var.xoffset;
124 c->y = y - disp->var.yoffset;
125
126 switch (mode) {
127 case CM_ERASE:
128 c->on = 0;
129 break;
130 case CM_DRAW:
131 case CM_MOVE:
132 if (c->on)
133 maxine_set_cursor(ip, c->on);
134 else
135 c->vbl_cnt = CURSOR_DRAW_DELAY;
136 c->enable = 1;
137 break;
138 }
139 }
140
maxinefbcon_set_font(struct display * disp,int width,int height)141 static int maxinefbcon_set_font(struct display *disp, int width, int height)
142 {
143 struct maxinefb_info *ip = (struct maxinefb_info *)disp->fb_info;
144 struct maxine_cursor *c = &ip->cursor;
145 u8 fgc = ~attr_bgcol_ec(disp, disp->conp);
146
147 if (width > 64 || height > 64 || width < 0 || height < 0)
148 return -EINVAL;
149
150 c->height = height;
151 c->width = width;
152
153 ims332_set_font(ip->ims332, fgc, width, height);
154
155 return 1;
156 }
157
maxine_cursor_timer_handler(unsigned long data)158 static void maxine_cursor_timer_handler(unsigned long data)
159 {
160 struct maxinefb_info *ip = (struct maxinefb_info *)data;
161 struct maxine_cursor *c = &ip->cursor;
162
163 if (!c->enable)
164 goto out;
165
166 if (c->vbl_cnt && --c->vbl_cnt == 0) {
167 c->on ^= 1;
168 maxine_set_cursor(ip, c->on);
169 c->vbl_cnt = c->blink_rate;
170 }
171
172 out:
173 c->timer.expires = jiffies + CURSOR_TIMER_FREQ;
174 add_timer(&c->timer);
175 }
176
maxine_cursor_init(struct maxinefb_info * ip)177 static void __init maxine_cursor_init(struct maxinefb_info *ip)
178 {
179 struct maxine_cursor *c = &ip->cursor;
180
181 c->enable = 1;
182 c->on = 1;
183 c->x = c->y = 0;
184 c->width = c->height = 0;
185 c->vbl_cnt = CURSOR_DRAW_DELAY;
186 c->blink_rate = CURSOR_BLINK_RATE;
187
188 init_timer(&c->timer);
189 c->timer.data = (unsigned long)ip;
190 c->timer.function = maxine_cursor_timer_handler;
191 mod_timer(&c->timer, jiffies + CURSOR_TIMER_FREQ);
192 }
193
maxine_cursor_exit(struct maxinefb_info * ip)194 static void __exit maxine_cursor_exit(struct maxinefb_info *ip)
195 {
196 struct maxine_cursor *c = &ip->cursor;
197
198 del_timer_sync(&c->timer);
199 }
200
201 #ifdef FBCON_HAS_MFB
202 extern void fbcon_mfb_clear_margins(struct vc_data *conp, struct display *p,
203 int bottom_only);
204
205 static struct display_switch maxine_switch1 = {
206 .setup = fbcon_mfb_setup,
207 .bmove = fbcon_mfb_bmove,
208 .clear = fbcon_mfb_clear,
209 .putc = fbcon_mfb_putc,
210 .putcs = fbcon_mfb_putcs,
211 .revc = fbcon_mfb_revc,
212 .cursor = maxinefbcon_cursor,
213 .set_font = maxinefbcon_set_font,
214 .clear_margins = fbcon_mfb_clear_margins,
215 .fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
216 };
217 #endif
218 #ifdef FBCON_HAS_CFB2
219 static struct display_switch maxine_switch2 = {
220 .setup = fbcon_cfb2_setup,
221 .bmove = fbcon_cfb2_bmove,
222 .clear = fbcon_cfb2_clear,
223 .putc = fbcon_cfb2_putc,
224 .putcs = fbcon_cfb2_putcs,
225 .revc = fbcon_cfb2_revc,
226 .cursor = maxinefbcon_cursor,
227 .set_font = maxinefbcon_set_font,
228 .clear_margins = fbcon_cfb8_clear_margins, /* sigh.. */
229 .fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
230 };
231 #endif
232 #ifdef FBCON_HAS_CFB4
233 static struct display_switch maxine_switch4 = {
234 .setup = fbcon_cfb4_setup,
235 .bmove = fbcon_cfb4_bmove,
236 .clear = fbcon_cfb4_clear,
237 .putc = fbcon_cfb4_putc,
238 .putcs = fbcon_cfb4_putcs,
239 .revc = fbcon_cfb4_revc,
240 .cursor = maxinefbcon_cursor,
241 .set_font = maxinefbcon_set_font,
242 .clear_margins = fbcon_cfb8_clear_margins, /* sigh.. */
243 .fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
244 };
245 #endif
246 static struct display_switch maxine_switch8 = {
247 .setup = fbcon_cfb8_setup,
248 .bmove = fbcon_cfb8_bmove,
249 .clear = fbcon_cfb8_clear,
250 .putc = fbcon_cfb8_putc,
251 .putcs = fbcon_cfb8_putcs,
252 .revc = fbcon_cfb8_revc,
253 .cursor = maxinefbcon_cursor,
254 .set_font = maxinefbcon_set_font,
255 .clear_margins = fbcon_cfb8_clear_margins,
256 .fontwidthmask = FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
257 };
258
maxinefb_get_par(struct maxinefb_par * par)259 static void maxinefb_get_par(struct maxinefb_par *par)
260 {
261 *par = current_par;
262 }
263
maxinefb_get_fix(struct fb_fix_screeninfo * fix,int con,struct fb_info * info)264 static int maxinefb_get_fix(struct fb_fix_screeninfo *fix, int con,
265 struct fb_info *info)
266 {
267 struct maxinefb_info *ip = (struct maxinefb_info *)info;
268 struct display *disp = (con < 0) ? &ip->disp : (fb_display + con);
269 struct fb_var_screeninfo *var = &disp->var;
270
271 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
272 strcpy(fix->id, DRIVER_DESCR);
273 fix->smem_start = ip->fb_start;
274 fix->smem_len = ip->fb_size;
275 fix->type = FB_TYPE_PACKED_PIXELS;
276 fix->ypanstep = 1;
277 fix->ywrapstep = 1;
278 fix->visual = FB_VISUAL_PSEUDOCOLOR;
279 switch (var->bits_per_pixel) {
280 #ifdef FBCON_HAS_MFB
281 case 1: fix->line_length = var->xres / 8; break;
282 #endif
283 #ifdef FBCON_HAS_CFB2
284 case 2: fix->line_length = var->xres / 4; break;
285 #endif
286 #ifdef FBCON_HAS_CFB4
287 case 4: fix->line_length = var->xres / 2; break;
288 #endif
289 case 8:
290 default:
291 fix->line_length = var->xres;
292 var->bits_per_pixel = 8;
293 break;
294 }
295 fix->accel = FB_ACCEL_NONE;
296
297 return 0;
298 }
299
maxinefb_set_dispsw(struct display * disp,struct maxinefb_info * ip)300 static int maxinefb_set_dispsw(struct display *disp, struct maxinefb_info *ip)
301 {
302 if (disp->conp && disp->conp->vc_sw && disp->conp->vc_sw->con_cursor)
303 disp->conp->vc_sw->con_cursor(disp->conp, CM_ERASE);
304
305 switch (disp->var.bits_per_pixel) {
306 #ifdef FBCON_HAS_MFB
307 case 1: ip->dispsw = maxine_switch1; break;
308 #endif
309 #ifdef FBCON_HAS_CFB2
310 case 2: ip->dispsw = maxine_switch2; break;
311 #endif
312 #ifdef FBCON_HAS_CFB4
313 case 4: ip->dispsw = maxine_switch4; break;
314 #endif
315 case 8:
316 default:
317 ip->dispsw = maxine_switch8;
318 disp->var.bits_per_pixel = 8;
319 break;
320 }
321
322 ims332_set_color_depth(ip->ims332, disp->var.bits_per_pixel);
323 disp->dispsw = &ip->dispsw;
324 disp->dispsw_data = 0;
325 return 0;
326 }
327
maxinefb_set_disp(struct display * disp,int con,struct maxinefb_info * ip)328 static void maxinefb_set_disp(struct display *disp, int con,
329 struct maxinefb_info *ip)
330 {
331 struct fb_fix_screeninfo fix;
332
333 disp->fb_info = &ip->info;
334 maxinefb_set_var(&disp->var, con, &ip->info);
335 maxinefb_set_dispsw(disp, ip);
336
337 maxinefb_get_fix(&fix, con, &ip->info);
338 disp->screen_base = (u8 *)fix.smem_start;
339 disp->visual = fix.visual;
340 disp->type = fix.type;
341 disp->type_aux = fix.type_aux;
342 disp->ypanstep = fix.ypanstep;
343 disp->ywrapstep = fix.ywrapstep;
344 disp->line_length = fix.line_length;
345 disp->next_line = fix.line_length;
346 disp->can_soft_blank = 1;
347 disp->inverse = 0;
348 disp->scrollmode = SCROLL_YREDRAW;
349
350 maxinefbcon_set_font(disp, fontwidth(disp), fontheight(disp));
351 }
352
getcolreg(u32 reg,u32 * red,u32 * green,u32 * blue,u32 * transp,struct fb_info * info)353 static int getcolreg(u32 reg, u32 *red, u32 *green, u32 *blue, u32 *transp,
354 struct fb_info *info)
355 {
356 struct maxinefb_info *ip = (struct maxinefb_info *)info;
357
358 u8 r;
359 u8 g;
360 u8 b;
361
362 if (reg > 255)
363 return 1;
364
365 /*
366 * Cmap fields are 16 bits wide, but the hardware colormap
367 * has only 8 bits.
368 */
369 ims332_read_cmap(ip->ims332, reg, &r, &g, &b);
370 *red = r << 8;
371 *green = g << 8;
372 *blue = b << 8;
373 *transp = 0;
374
375 return 0;
376 }
377
setcolreg(u32 reg,u32 red,u32 green,u32 blue,u32 transp,struct fb_info * info)378 static int setcolreg(u32 reg, u32 red, u32 green, u32 blue, u32 transp,
379 struct fb_info *info)
380 {
381 struct maxinefb_info *ip = (struct maxinefb_info *)info;
382
383 if (reg > 255)
384 return 1;
385
386 /*
387 * Cmap fields are 16 bits wide, but the hardware colormap
388 * has only 8 bits.
389 */
390 red = (red >> 8) & 0xff;
391 green = (green >> 8) & 0xff;
392 blue = (blue >> 8) & 0xff;
393
394 ims332_write_cmap(ip->ims332, reg, red, green, blue);
395
396 return 0;
397 }
398
399 #define CMAP_LEN(disp) ((disp->visual == FB_VISUAL_PSEUDOCOLOR) \
400 ? (1 << disp->var.bits_per_pixel) : 16)
401
do_install_cmap(int con,struct maxinefb_info * ip)402 static void do_install_cmap(int con, struct maxinefb_info *ip)
403 {
404 struct display *disp = (con < 0) ? &ip->disp : (fb_display + con);
405 int len = CMAP_LEN(disp);
406
407 if (con != currcon)
408 return;
409 if (fb_display[con].cmap.len)
410 fb_set_cmap(&fb_display[con].cmap, 1, setcolreg, &ip->info);
411 else
412 fb_set_cmap(fb_default_cmap(len), 1, setcolreg, &ip->info);
413 }
414
do_save_cmap(int con,struct maxinefb_info * ip)415 static void do_save_cmap(int con, struct maxinefb_info *ip)
416 {
417 if (con != currcon)
418 return;
419 fb_get_cmap(&fb_display[con].cmap, 1, getcolreg, &ip->info);
420 }
421
maxinefb_get_cmap(struct fb_cmap * cmap,int kspc,int con,struct fb_info * info)422 static int maxinefb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
423 struct fb_info *info)
424 {
425 struct maxinefb_info *ip = (struct maxinefb_info *)info;
426 struct display *disp = (con < 0) ? &ip->disp : (fb_display + con);
427 int len = CMAP_LEN(disp);
428
429 if (con == currcon) /* current console? */
430 return fb_get_cmap(cmap, kspc, getcolreg, info);
431
432 if (disp->cmap.len) /* non default colormap? */
433 fb_copy_cmap(&disp->cmap, cmap, kspc ? 0 : 2);
434 else
435 fb_copy_cmap(fb_default_cmap(len), cmap, kspc ? 0 : 2);
436
437 return 0;
438 }
439
maxinefb_set_cmap(struct fb_cmap * cmap,int kspc,int con,struct fb_info * info)440 static int maxinefb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
441 struct fb_info *info)
442 {
443 struct maxinefb_info *ip = (struct maxinefb_info *)info;
444 struct display *disp = (con < 0) ? &ip->disp : (fb_display + con);
445 int len = CMAP_LEN(disp);
446 int err;
447
448 /* No colormap allocated? */
449 if ((err = fb_alloc_cmap(&disp->cmap, len, 0)))
450 return err;
451
452 if (con == currcon) /* current console? */
453 return fb_set_cmap(cmap, kspc, setcolreg, info);
454
455 fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
456
457 return 0;
458 }
459
maxinefb_ioctl(struct inode * inode,struct file * file,u32 cmd,unsigned long arg,int con,struct fb_info * info)460 static int maxinefb_ioctl(struct inode *inode, struct file *file, u32 cmd,
461 unsigned long arg, int con, struct fb_info *info)
462 {
463 /* TODO: Not yet implemented */
464 return -ENOIOCTLCMD;
465 }
466
maxinefb_switch(int con,struct fb_info * info)467 static int maxinefb_switch(int con, struct fb_info *info)
468 {
469 struct maxinefb_info *ip = (struct maxinefb_info *)info;
470 struct display *old = (currcon < 0) ? &ip->disp : (fb_display + currcon);
471 struct display *new = (con < 0) ? &ip->disp : (fb_display + con);
472
473 do_save_cmap(currcon, ip);
474 if (old->conp && old->conp->vc_sw && old->conp->vc_sw->con_cursor)
475 old->conp->vc_sw->con_cursor(old->conp, CM_ERASE);
476
477 /* Set the current console. */
478 currcon = con;
479 maxinefb_set_disp(new, con, ip);
480
481 return 0;
482 }
483
maxinefb_encode_var(struct fb_var_screeninfo * var,struct maxinefb_par * par)484 static int maxinefb_encode_var(struct fb_var_screeninfo *var,
485 struct maxinefb_par *par)
486 {
487 var->xres = 1024;
488 var->yres = 768;
489 var->xres_virtual = 1024;
490 var->yres_virtual = 1024;
491 var->xoffset = 0;
492 var->yoffset = 0;
493 var->grayscale = 0;
494 switch (var->bits_per_pixel) {
495 #ifdef FBCON_HAS_MFB
496 case 1:
497 var->red.offset = 0;
498 var->red.length = 1;
499 var->red.msb_right = 0;
500 var->green.offset = 0;
501 var->green.length = 1;
502 var->green.msb_right = 0;
503 var->blue.offset = 0;
504 var->blue.length = 1;
505 var->blue.msb_right = 0;
506 var->transp.offset = 0;
507 var->transp.length = 0;
508 var->transp.msb_right = 0;
509 break;
510 #endif
511 #ifdef FBCON_HAS_CFB2
512 case 2:
513 var->red.offset = 0;
514 var->red.length = 2;
515 var->red.msb_right = 0;
516 var->green.offset = 0;
517 var->green.length = 2;
518 var->green.msb_right = 0;
519 var->blue.offset = 0;
520 var->blue.length = 2;
521 var->blue.msb_right = 0;
522 var->transp.offset = 0;
523 var->transp.length = 0;
524 var->transp.msb_right = 0;
525 break;
526 #endif
527 #ifdef FBCON_HAS_CFB4
528 case 4:
529 var->red.offset = 0;
530 var->red.length = 4;
531 var->red.msb_right = 0;
532 var->green.offset = 0;
533 var->green.length = 4;
534 var->green.msb_right = 0;
535 var->blue.offset = 0;
536 var->blue.length = 4;
537 var->blue.msb_right = 0;
538 var->transp.offset = 0;
539 var->transp.length = 0;
540 var->transp.msb_right = 0;
541 break;
542 #endif
543 case 8:
544 default:
545 var->red.offset = 0;
546 var->red.length = 8;
547 var->red.msb_right = 0;
548 var->green.offset = 0;
549 var->green.length = 8;
550 var->green.msb_right = 0;
551 var->blue.offset = 0;
552 var->blue.length = 8;
553 var->blue.msb_right = 0;
554 var->transp.offset = 0;
555 var->transp.length = 0;
556 var->transp.msb_right = 0;
557 var->bits_per_pixel = 8;
558 break;
559 }
560 var->nonstd = 0;
561 var->activate &= ~FB_ACTIVATE_MASK & FB_ACTIVATE_NOW;
562 var->accel_flags = 0;
563 var->sync = FB_SYNC_ON_GREEN;
564 var->vmode &= ~FB_VMODE_MASK & FB_VMODE_NONINTERLACED;
565
566 return 0;
567 }
568
maxinefb_get_var(struct fb_var_screeninfo * var,int con,struct fb_info * info)569 static int maxinefb_get_var(struct fb_var_screeninfo *var, int con,
570 struct fb_info *info)
571 {
572 struct maxinefb_par par;
573 struct maxinefb_info *ip = (struct maxinefb_info *)info;
574 struct display *disp = (con < 0) ? &ip->disp : (fb_display + con);
575
576 if (con < 0) {
577 maxinefb_get_par(&par);
578 memset(var, 0, sizeof(struct fb_var_screeninfo));
579 return maxinefb_encode_var(var, &par);
580 } else
581 *var = disp->var;
582
583 return 0;
584 }
585
maxinefb_set_var(struct fb_var_screeninfo * var,int con,struct fb_info * info)586 static int maxinefb_set_var(struct fb_var_screeninfo *var, int con,
587 struct fb_info *info)
588 {
589 struct maxinefb_par par;
590 struct maxinefb_info *ip = (struct maxinefb_info *)info;
591 struct display *disp = (con < 0) ? &ip->disp : (fb_display + con);
592 int ret;
593
594 maxinefb_get_par(&par);
595 ret = maxinefb_encode_var(var, &par);
596 if (ret)
597 goto out;
598 disp->var = *var;
599
600 /* Set default colormap. */
601 ret = fb_alloc_cmap(&disp->cmap, 0, 0);
602 if (ret)
603 goto out;
604 do_install_cmap(con, ip);
605
606 out:
607 return ret;
608 }
609
maxinefb_fb_update_var(int con,struct fb_info * info)610 static int maxinefb_fb_update_var(int con, struct fb_info *info)
611 {
612 struct maxinefb_info *ip = (struct maxinefb_info *)info;
613 struct display *disp = (con < 0) ? &ip->disp : (fb_display + con);
614
615 if (con == currcon)
616 maxinefbcon_cursor(disp, CM_ERASE, ip->cursor.x,
617 ip->cursor.y);
618
619 return 0;
620 }
621
622 /* 0 unblanks, anything else blanks. */
623
maxinefb_blank(int blank,struct fb_info * info)624 static void maxinefb_blank(int blank, struct fb_info *info)
625 {
626 struct maxinefb_info *ip = (struct maxinefb_info *)info;
627
628 ims332_blank_screen(ip->ims332, !!blank);
629 }
630
631 static struct fb_ops maxinefb_ops = {
632 .owner = THIS_MODULE,
633 .fb_get_fix = maxinefb_get_fix,
634 .fb_get_var = maxinefb_get_var,
635 .fb_set_var = maxinefb_set_var,
636 .fb_get_cmap = maxinefb_get_cmap,
637 .fb_set_cmap = maxinefb_set_cmap,
638 .fb_ioctl = maxinefb_ioctl
639 };
640
maxinefb_init(void)641 int __init maxinefb_init(void)
642 {
643 /* Validate we're on the proper machine type. */
644 if (mips_machtype != MACH_DS5000_XX)
645 return -ENXIO;
646
647 my_info = (struct maxinefb_info *)kmalloc(sizeof(struct maxinefb_info), GFP_ATOMIC);
648 if (!my_info) {
649 printk(KERN_ERR DRIVER_DESCR ": can't alloc maxinefb_info\n");
650 return -ENOMEM;
651 }
652 memset(my_info, 0, sizeof(struct maxinefb_info));
653
654 /*
655 * Let there be consoles..
656 */
657 strcpy(my_info->info.modename, DRIVER_DESCRIPTION);
658 my_info->info.node = -1;
659 my_info->info.flags = FBINFO_FLAG_DEFAULT;
660 my_info->info.fbops = &maxinefb_ops;
661 my_info->info.disp = &my_info->disp;
662 my_info->info.changevar = NULL;
663 my_info->info.switch_con = &maxinefb_switch;
664 my_info->info.updatevar = &maxinefb_fb_update_var;
665 my_info->info.blank = &maxinefb_blank;
666
667 /* Initialize IMS G332 video controller. */
668 my_info->ims332 = (struct ims332_regs *)KSEG1ADDR(0x1c140000);
669 ims332_bootstrap(my_info->ims332);
670
671 /* Framebuffer memory, default resolution is 1024x768x8. */
672 my_info->fb_start = KSEG1ADDR(0x0a000000);
673 my_info->fb_size = 1024 * 1024;
674 memset((void *) my_info->fb_start, 0, my_info->fb_size);
675
676 maxine_cursor_init(my_info);
677 maxinefb_set_disp(&my_info->disp, currcon, my_info);
678
679 if (register_framebuffer(&my_info->info) < 0)
680 return -EINVAL;
681
682 printk(KERN_INFO "fb%d: %s\n", GET_FB_IDX(my_info->info.node),
683 my_info->info.modename);
684
685 return 0;
686 }
687
maxinefb_exit(void)688 static void __exit maxinefb_exit(void)
689 {
690 unregister_framebuffer(&my_info->info);
691 maxine_cursor_exit(my_info);
692 kfree(my_info);
693 }
694
695 MODULE_AUTHOR(DRIVER_AUTHOR);
696 MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
697 MODULE_LICENSE("GPL");
698 #ifdef MODULE
699 module_init(maxinefb_init);
700 module_exit(maxinefb_exit);
701 #endif
702