2 * valkyriefb.c -- frame buffer device for the PowerMac 'valkyrie' display
4 * Created 8 August 1998 by
5 * Martin Costabel <costabel@wanadoo.fr> and Kevin Schoedel
7 * Vmode-switching changes and vmode 15/17 modifications created 29 August
8 * 1998 by Barry K. Nathan <barryn@pobox.com>.
10 * Ported to m68k Macintosh by David Huggins-Daines <dhd@debian.org>
12 * Derived directly from:
14 * controlfb.c -- frame buffer device for the PowerMac 'control' display
15 * Copyright (C) 1998 Dan Jacobowitz <dan@debian.org>
17 * pmc-valkyrie.c -- Console support for PowerMac "valkyrie" display adaptor.
18 * Copyright (C) 1997 Paul Mackerras.
22 * Frame buffer structure from:
23 * drivers/video/chipsfb.c -- frame buffer device for
24 * Chips & Technologies 65550 chip.
26 * Copyright (C) 1998 Paul Mackerras
28 * This file is derived from the Powermac "chips" driver:
29 * Copyright (C) 1997 Fabio Riccardi.
30 * And from the frame buffer device for Open Firmware-initialized devices:
31 * Copyright (C) 1997 Geert Uytterhoeven.
33 * Hardware information from:
34 * control.c: Console support for PowerMac "control" display adaptor.
35 * Copyright (C) 1996 Paul Mackerras
37 * This file is subject to the terms and conditions of the GNU General Public
38 * License. See the file COPYING in the main directory of this archive for
42 #include <linux/config.h>
43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/errno.h>
46 #include <linux/string.h>
48 #include <linux/tty.h>
49 #include <linux/slab.h>
50 #include <linux/vmalloc.h>
51 #include <linux/delay.h>
52 #include <linux/interrupt.h>
54 #include <linux/selection.h>
55 #include <linux/init.h>
56 #include <linux/pci.h>
57 #include <linux/nvram.h>
58 #ifdef CONFIG_FB_COMPAT_XPMAC
59 #include <asm/vc_ioctl.h>
61 #include <linux/adb.h>
62 #include <linux/cuda.h>
65 #include <asm/bootinfo.h>
66 #include <asm/macintosh.h>
70 #include <asm/pgtable.h>
72 #include <video/fbcon.h>
73 #include <video/fbcon-cfb8.h>
74 #include <video/fbcon-cfb16.h>
75 #include <video/macmodes.h>
77 #include "valkyriefb.h"
79 static int can_soft_blank = 1;
82 /* We don't yet have functions to read the PRAM... perhaps we can
83 adapt them from the PPC code? */
84 static int default_vmode = VMODE_640_480_67;
85 static int default_cmode = CMODE_8;
87 static int default_vmode = VMODE_NVRAM;
88 static int default_cmode = CMODE_NVRAM;
90 static char fontname[40] __initdata = { 0 };
92 static int currcon = 0;
93 static int switching = 0;
95 struct fb_par_valkyrie {
102 struct fb_info_valkyrie {
104 struct fb_fix_screeninfo fix;
105 struct fb_var_screeninfo var;
107 struct fb_par_valkyrie par;
109 __u8 red, green, blue;
112 struct cmap_regs *cmap_regs;
113 unsigned long cmap_regs_phys;
115 struct valkyrie_regs *valkyrie_regs;
116 unsigned long valkyrie_regs_phys;
119 unsigned long frame_buffer_phys;
122 unsigned long total_vram;
123 #ifdef FBCON_HAS_CFB16
124 u16 fbcon_cfb16_cmap[16];
131 int valkyriefb_init(void);
132 int valkyriefb_setup(char*);
134 static int valkyrie_get_fix(struct fb_fix_screeninfo *fix, int con,
135 struct fb_info *info);
136 static int valkyrie_get_var(struct fb_var_screeninfo *var, int con,
137 struct fb_info *info);
138 static int valkyrie_set_var(struct fb_var_screeninfo *var, int con,
139 struct fb_info *info);
140 static int valkyrie_get_cmap(struct fb_cmap *cmap, int kspc, int con,
141 struct fb_info *info);
142 static int valkyrie_set_cmap(struct fb_cmap *cmap, int kspc, int con,
143 struct fb_info *info);
145 static int read_valkyrie_sense(struct fb_info_valkyrie *p);
146 static inline int valkyrie_vram_reqd(int video_mode, int color_mode);
147 static void set_valkyrie_clock(unsigned char *params);
148 static void valkyrie_set_par(const struct fb_par_valkyrie *p, struct fb_info_valkyrie *info);
149 static inline int valkyrie_par_to_var(struct fb_par_valkyrie *par, struct fb_var_screeninfo *var);
150 static int valkyrie_var_to_par(struct fb_var_screeninfo *var,
151 struct fb_par_valkyrie *par, const struct fb_info *fb_info);
153 static void valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p);
154 static void valkyrie_par_to_display(struct fb_par_valkyrie *par,
155 struct display *disp, struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p);
156 static void valkyrie_init_display(struct display *disp);
157 static void valkyrie_par_to_fix(struct fb_par_valkyrie *par, struct fb_fix_screeninfo *fix,
158 struct fb_info_valkyrie *p);
159 static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p);
161 static struct fb_ops valkyriefb_ops = {
163 fb_get_fix: valkyrie_get_fix,
164 fb_get_var: valkyrie_get_var,
165 fb_set_var: valkyrie_set_var,
166 fb_get_cmap: valkyrie_get_cmap,
167 fb_set_cmap: valkyrie_set_cmap,
170 static int valkyriefb_getcolreg(u_int regno, u_int *red, u_int *green,
171 u_int *blue, u_int *transp, struct fb_info *info);
172 static int valkyriefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
173 u_int transp, struct fb_info *info);
174 static void do_install_cmap(int con, struct fb_info *info);
176 static int valkyrie_get_fix(struct fb_fix_screeninfo *fix, int con,
177 struct fb_info *info)
179 struct fb_info_valkyrie *cp = (struct fb_info_valkyrie *) info;
185 static int valkyrie_get_var(struct fb_var_screeninfo *var, int con,
186 struct fb_info *info)
188 struct fb_info_valkyrie *cp = (struct fb_info_valkyrie *) info;
194 /* Sets everything according to var */
195 static int valkyrie_set_var(struct fb_var_screeninfo *var, int con,
196 struct fb_info *info)
198 struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info;
199 struct display *disp;
200 struct fb_par_valkyrie par;
201 int depthchange, err;
203 disp = (con >= 0) ? &fb_display[con] : &p->disp;
204 if ((err = valkyrie_var_to_par(var, &par, info))) {
205 /* printk (KERN_ERR "Error in valkyrie_set_var, calling valkyrie_var_to_par: %d.\n", err); */
209 if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) {
210 /* printk(KERN_ERR "Not activating, in valkyrie_set_var.\n"); */
211 valkyrie_par_to_var(&par, var);
216 * I know, we want to use fb_display[con], but grab certain info
217 * from p->var instead.
219 #define DIRTY(x) (p->var.x != var->x)
220 depthchange = DIRTY(bits_per_pixel);
221 /* adding "&& !DIRTY(pixclock)" corrects vmode-switching problems */
222 if(!DIRTY(xres) && !DIRTY(yres) && !DIRTY(xres_virtual) &&
223 !DIRTY(yres_virtual) && !DIRTY(bits_per_pixel) && !DIRTY(pixclock)) {
224 valkyrie_par_to_var(&par, var);
225 p->var = disp->var = *var;
230 valkyrie_par_to_var(&par, var);
232 valkyrie_par_to_fix(&par, &p->fix, p);
233 valkyrie_par_to_display(&par, disp, &p->fix, p);
236 if (info->changevar && !switching) {
237 /* Don't want to do this if just switching consoles. */
238 (*info->changevar)(con);
241 valkyrie_set_par(&par, p);
243 if ((err = fb_alloc_cmap(&disp->cmap, 0, 0)))
245 if (depthchange || switching)
246 do_install_cmap(con, info);
250 static int valkyrie_get_cmap(struct fb_cmap *cmap, int kspc, int con,
251 struct fb_info *info)
253 if (con == currcon) {
254 /* current console? */
255 return fb_get_cmap(cmap, kspc, valkyriefb_getcolreg, info);
257 if (fb_display[con].cmap.len) { /* non default colormap? */
258 fb_copy_cmap(&fb_display[con].cmap, cmap, kspc? 0: 2);
261 int size = fb_display[con].var.bits_per_pixel == 16 ? 32 : 256;
262 fb_copy_cmap(fb_default_cmap(size), cmap, kspc ? 0 : 2);
267 static int valkyrie_set_cmap(struct fb_cmap *cmap, int kspc, int con,
268 struct fb_info *info)
270 struct display *disp = &fb_display[con];
273 if (disp->cmap.len == 0) {
274 int size = fb_display[con].var.bits_per_pixel == 16 ? 32 : 256;
275 err = fb_alloc_cmap(&disp->cmap, size, 0);
281 if (con == currcon) {
282 return fb_set_cmap(cmap, kspc, valkyriefb_setcolreg, info);
284 fb_copy_cmap(cmap, &disp->cmap, kspc ? 0 : 1);
288 static int valkyriefb_switch(int con, struct fb_info *fb)
290 struct fb_info_valkyrie *info = (struct fb_info_valkyrie *) fb;
291 struct fb_par_valkyrie par;
293 if (fb_display[currcon].cmap.len)
294 fb_get_cmap(&fb_display[currcon].cmap, 1, valkyriefb_getcolreg,
298 valkyrie_var_to_par(&fb_display[currcon].var, &par, fb);
299 valkyrie_set_par(&par, info);
300 do_install_cmap(con, fb);
302 /* I see no reason not to do this. Minus info->changevar(). */
303 /* DOH. This makes valkyrie_set_var compare, you guessed it, */
304 /* fb_display[con].var (first param), and fb_display[con].var! */
305 /* Perhaps I just fixed that... */
307 valkyrie_set_var(&fb_display[con].var, con, info);
313 static int valkyriefb_updatevar(int con, struct fb_info *info)
318 static void valkyriefb_blank(int blank_mode, struct fb_info *info)
321 * Blank the screen if blank_mode != 0, else unblank. If blank_mode == NULL
322 * then the caller blanks by setting the CLUT (Color Look Up Table) to all
323 * black. Return 0 if blanking succeeded, != 0 if un-/blanking failed due
324 * to e.g. a video mode which doesn't support it. Implements VESA suspend
325 * and powerdown modes on hardware that supports disabling hsync/vsync:
326 * blank_mode == 2: suspend vsync
327 * blank_mode == 3: suspend hsync
328 * blank_mode == 4: powerdown
330 struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info;
331 struct valkyrie_regvals *init;
334 if (p->disp.can_soft_blank
335 && ((vmode = p->par.vmode) > 0)
336 && (vmode <= VMODE_MAX)
337 && ((init = valkyrie_reg_init[vmode - 1]) != NULL)) {
340 switch (blank_mode) {
341 default: /* unblank */
342 out_8(&p->valkyrie_regs->mode.r, init->mode);
344 case VESA_VSYNC_SUSPEND:
345 case VESA_HSYNC_SUSPEND:
347 * [kps] Value extracted from MacOS. I don't know
348 * whether this bit disables hsync or vsync, or
349 * whether the hardware can do the other as well.
351 out_8(&p->valkyrie_regs->mode.r, init->mode | 0x40);
354 out_8(&p->valkyrie_regs->mode.r, 0x66);
360 static int valkyriefb_getcolreg(u_int regno, u_int *red, u_int *green,
361 u_int *blue, u_int *transp, struct fb_info *info)
363 struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info;
367 *red = (p->palette[regno].red<<8) | p->palette[regno].red;
368 *green = (p->palette[regno].green<<8) | p->palette[regno].green;
369 *blue = (p->palette[regno].blue<<8) | p->palette[regno].blue;
374 static int valkyriefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
375 u_int transp, struct fb_info *info)
377 struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) info;
378 volatile struct cmap_regs *cmap_regs = p->cmap_regs;
386 p->palette[regno].red = red;
387 p->palette[regno].green = green;
388 p->palette[regno].blue = blue;
390 /* tell clut which address to fill */
391 out_8(&p->cmap_regs->addr, regno);
393 /* send one color channel at a time */
394 out_8(&cmap_regs->lut, red);
395 out_8(&cmap_regs->lut, green);
396 out_8(&cmap_regs->lut, blue);
399 #ifdef FBCON_HAS_CFB16
400 p->fbcon_cfb16_cmap[regno] = (regno << 10) | (regno << 5) | regno;
407 static void do_install_cmap(int con, struct fb_info *info)
411 if (fb_display[con].cmap.len) {
412 fb_set_cmap(&fb_display[con].cmap, 1, valkyriefb_setcolreg,
416 int size = fb_display[con].var.bits_per_pixel == 16 ? 32 : 256;
417 fb_set_cmap(fb_default_cmap(size), 1, valkyriefb_setcolreg,
422 #ifdef CONFIG_FB_COMPAT_XPMAC
423 extern struct vc_mode display_info;
424 extern struct fb_info *console_fb_info;
425 #endif /* CONFIG_FB_COMPAT_XPMAC */
427 static int valkyrie_vram_reqd(int video_mode, int color_mode)
431 if ((pitch = valkyrie_reg_init[video_mode-1]->pitch[color_mode]) == 0)
432 pitch = 2 * valkyrie_reg_init[video_mode-1]->pitch[0];
433 return valkyrie_reg_init[video_mode-1]->vres * pitch;
436 static void set_valkyrie_clock(unsigned char *params)
438 struct adb_request req;
441 #ifdef CONFIG_ADB_CUDA
442 for (i = 0; i < 3; ++i) {
443 cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_GET_SET_IIC,
444 0x50, i + 1, params[i]);
445 while (!req.complete)
451 static void __init init_valkyrie(struct fb_info_valkyrie *p)
453 struct fb_par_valkyrie *par = &p->par;
454 struct fb_var_screeninfo var;
457 p->sense = read_valkyrie_sense(p);
458 printk(KERN_INFO "Monitor sense value = 0x%x, ", p->sense);
461 /* Try to pick a video mode out of NVRAM if we have one. */
462 if (default_vmode == VMODE_NVRAM) {
463 default_vmode = nvram_read_byte(NV_VMODE);
464 if (default_vmode <= 0
465 || default_vmode > VMODE_MAX
466 || !valkyrie_reg_init[default_vmode - 1])
467 default_vmode = VMODE_CHOOSE;
469 if (default_cmode == CMODE_NVRAM)
470 default_cmode = nvram_read_byte(NV_CMODE);
472 if (default_vmode == VMODE_CHOOSE)
473 default_vmode = mac_map_monitor_sense(p->sense);
474 if (!valkyrie_reg_init[default_vmode - 1])
475 default_vmode = VMODE_640_480_67;
478 * Reduce the pixel size if we don't have enough VRAM or bandwitdh.
480 if (default_cmode < CMODE_8
481 || default_cmode > CMODE_16
482 || valkyrie_reg_init[default_vmode-1]->pitch[default_cmode] == 0
483 || valkyrie_vram_reqd(default_vmode, default_cmode) > p->total_vram)
484 default_cmode = CMODE_8;
486 printk(KERN_INFO "using video mode %d and color mode %d.\n", default_vmode, default_cmode);
488 mac_vmode_to_var(default_vmode, default_cmode, &var);
489 if (valkyrie_var_to_par(&var, par, &p->info)) {
490 printk(KERN_ERR "valkyriefb: can't set default video mode\n");
494 valkyrie_init_fix(&p->fix, p);
495 valkyrie_par_to_fix(&p->par, &p->fix, p);
496 valkyrie_par_to_var(&p->par, &p->var);
497 valkyrie_init_display(&p->disp);
498 valkyrie_par_to_display(&p->par, &p->disp, &p->fix, p);
499 valkyrie_init_info(&p->info, p);
501 /* Initialize colormap */
502 for (j = 0; j < 16; j++) {
504 p->palette[j].red = default_red[k];
505 p->palette[j].green = default_grn[k];
506 p->palette[j].blue = default_blu[k];
509 valkyrie_set_var (&var, -1, &p->info);
511 if (register_framebuffer(&p->info) < 0) {
516 printk(KERN_INFO "fb%d: valkyrie frame buffer device\n", GET_FB_IDX(p->info.node));
519 static void valkyrie_set_par(const struct fb_par_valkyrie *par,
520 struct fb_info_valkyrie *p)
522 struct valkyrie_regvals *init;
523 volatile struct valkyrie_regs *valkyrie_regs = p->valkyrie_regs;
531 || (init = valkyrie_reg_init[vmode - 1]) == NULL)
532 panic("valkyrie: display mode %d not supported", vmode);
534 /* Reset the valkyrie */
535 out_8(&valkyrie_regs->status.r, 0);
538 /* Initialize display timing registers */
539 out_8(&valkyrie_regs->mode.r, init->mode | 0x80);
540 out_8(&valkyrie_regs->depth.r, cmode + 3);
541 set_valkyrie_clock(init->clock_params);
544 /* Turn on display */
545 out_8(&valkyrie_regs->mode.r, init->mode);
547 #ifdef CONFIG_FB_COMPAT_XPMAC
548 /* And let the world know the truth. */
549 if (!console_fb_info || console_fb_info == &p->info) {
550 display_info.height = p->var.yres;
551 display_info.width = p->var.xres;
552 display_info.depth = (cmode == CMODE_16) ? 16 : 8;
553 display_info.pitch = p->fix.line_length;
554 display_info.mode = vmode;
555 strncpy(display_info.name, "valkyrie",
556 sizeof(display_info.name));
557 display_info.fb_address = p->frame_buffer_phys + 0x1000;
558 display_info.cmap_adr_address = p->cmap_regs_phys;
559 display_info.cmap_data_address = p->cmap_regs_phys + 8;
560 display_info.disp_reg_address = p->valkyrie_regs_phys;
561 console_fb_info = &p->info;
563 #endif /* CONFIG_FB_COMPAT_XPMAC */
566 int __init valkyriefb_init(void)
568 struct fb_info_valkyrie *p;
569 unsigned long frame_buffer_phys, cmap_regs_phys, flags;
574 if (!(mac_bi_data.id == MAC_MODEL_Q630
575 /* I'm not sure about this one */
576 || mac_bi_data.id == MAC_MODEL_P588))
579 /* Hardcoded addresses... welcome to 68k Macintosh country :-) */
580 frame_buffer_phys = 0xf9000000;
581 cmap_regs_phys = 0x50f24000;
582 flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */
583 #else /* ppc (!CONFIG_MAC) */
584 struct device_node *dp;
586 dp = find_devices("valkyrie");
590 if(dp->n_addrs != 1) {
591 printk(KERN_ERR "expecting 1 address for valkyrie (got %d)", dp->n_addrs);
595 frame_buffer_phys = dp->addrs[0].address;
596 cmap_regs_phys = dp->addrs[0].address+0x304000;
597 flags = _PAGE_WRITETHRU;
598 #endif /* ppc (!CONFIG_MAC) */
600 p = kmalloc(sizeof(*p), GFP_ATOMIC);
603 memset(p, 0, sizeof(*p));
605 /* Map in frame buffer and registers */
606 if (!request_mem_region(frame_buffer_phys, 0x100000, "valkyriefb")) {
610 p->total_vram = 0x100000;
611 p->frame_buffer_phys = frame_buffer_phys;
612 p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags);
613 p->cmap_regs_phys = cmap_regs_phys;
614 p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000);
615 p->valkyrie_regs_phys = cmap_regs_phys+0x6000;
616 p->valkyrie_regs = ioremap(p->valkyrie_regs_phys, 0x1000);
622 * Get the monitor sense value.
624 static int read_valkyrie_sense(struct fb_info_valkyrie *p)
628 out_8(&p->valkyrie_regs->msense.r, 0); /* release all lines */
630 sense = ((in = in_8(&p->valkyrie_regs->msense.r)) & 0x70) << 4;
631 /* drive each sense line low in turn and collect the other 2 */
632 out_8(&p->valkyrie_regs->msense.r, 4); /* drive A low */
634 sense |= ((in = in_8(&p->valkyrie_regs->msense.r)) & 0x30);
635 out_8(&p->valkyrie_regs->msense.r, 2); /* drive B low */
637 sense |= ((in = in_8(&p->valkyrie_regs->msense.r)) & 0x40) >> 3;
638 sense |= (in & 0x10) >> 2;
639 out_8(&p->valkyrie_regs->msense.r, 1); /* drive C low */
641 sense |= ((in = in_8(&p->valkyrie_regs->msense.r)) & 0x60) >> 5;
643 out_8(&p->valkyrie_regs->msense.r, 7);
649 * This routine takes a user-supplied var,
650 * and picks the best vmode/cmode from it.
652 static int valkyrie_var_to_par(struct fb_var_screeninfo *var,
653 struct fb_par_valkyrie *par, const struct fb_info *fb_info)
655 /* [bkn] I did a major overhaul of this function.
657 * Much of the old code was "swiped by jonh from atyfb.c". Because
658 * macmodes has mac_var_to_vmode, I felt that it would be better to
659 * rework this function to use that, instead of reinventing the wheel to
660 * add support for vmode 17. This was reinforced by the fact that
661 * the previously swiped atyfb.c code is no longer there.
663 * So, I swiped and adapted platinum_var_to_par (from platinumfb.c), replacing
664 * most, but not all, of the old code in the process. One side benefit of
665 * swiping the platinumfb code is that we now have more comprehensible error
666 * messages when a vmode/cmode switch fails. (Most of the error messages are
667 * platinumfb.c, but I added two of my own, and I also changed some commas
668 * into colons to make the messages more consistent with other Linux error
669 * messages.) In addition, I think the new code *might* fix some vmode-
670 * switching oddities, but I'm not sure.
672 * There may be some more opportunities for cleanup in here, but this is a
677 int bpp = var->bits_per_pixel;
678 struct valkyrie_regvals *init;
679 struct fb_info_valkyrie *p = (struct fb_info_valkyrie *) fb_info;
682 if(mac_var_to_vmode(var, &par->vmode, &par->cmode) != 0) {
683 printk(KERN_ERR "valkyrie_var_to_par: %dx%dx%d unsuccessful.\n",var->xres,var->yres,var->bits_per_pixel);
687 /* Check if we know about the wanted video mode */
688 if(!valkyrie_reg_init[par->vmode-1]) {
689 printk(KERN_ERR "valkyrie_var_to_par: vmode %d not valid.\n", par->vmode);
693 par->xres = var->xres;
694 par->yres = var->yres;
697 par->vxres = par->xres;
698 par->vyres = par->yres;
700 if (var->xres_virtual > var->xres || var->yres_virtual > var->yres
701 || var->xoffset != 0 || var->yoffset != 0) {
706 par->cmode = CMODE_8;
708 par->cmode = CMODE_16;
710 printk(KERN_ERR "valkyrie_var_to_par: cmode %d not supported.\n", par->cmode);
714 init = valkyrie_reg_init[par->vmode-1];
715 if (init->pitch[par->cmode] == 0) {
716 printk(KERN_ERR "valkyrie_var_to_par: vmode %d does not support cmode %d.\n", par->vmode, par->cmode);
720 if (valkyrie_vram_reqd(par->vmode, par->cmode) > p->total_vram) {
721 printk(KERN_ERR "valkyrie_var_to_par: not enough ram for vmode %d, cmode %d.\n", par->vmode, par->cmode);
728 static int valkyrie_par_to_var(struct fb_par_valkyrie *par, struct fb_var_screeninfo *var)
730 return mac_vmode_to_var(par->vmode, par->cmode, var);
733 static void valkyrie_init_fix(struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p)
735 memset(fix, 0, sizeof(*fix));
736 strcpy(fix->id, "valkyrie");
737 fix->mmio_start = p->valkyrie_regs_phys;
738 fix->mmio_len = sizeof(struct valkyrie_regs);
739 fix->type = FB_TYPE_PACKED_PIXELS;
748 /* Fix must already be inited above */
749 static void valkyrie_par_to_fix(struct fb_par_valkyrie *par,
750 struct fb_fix_screeninfo *fix,
751 struct fb_info_valkyrie *p)
753 fix->smem_start = p->frame_buffer_phys + 0x1000;
755 fix->smem_len = valkyrie_vram_reqd(par->vmode, par->cmode);
757 fix->smem_len = p->total_vram;
759 fix->visual = (par->cmode == CMODE_8) ?
760 FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
761 fix->line_length = par->vxres << par->cmode;
762 /* ywrapstep, xpanstep, ypanstep */
765 static void valkyrie_init_display(struct display *disp)
767 memset(disp, 0, sizeof(*disp));
768 disp->type = /* fix->type */ FB_TYPE_PACKED_PIXELS;
769 disp->can_soft_blank = can_soft_blank;
770 disp->scrollmode = SCROLL_YREDRAW;
773 static void valkyrie_par_to_display(struct fb_par_valkyrie *par,
774 struct display *disp, struct fb_fix_screeninfo *fix, struct fb_info_valkyrie *p)
777 disp->screen_base = (char *) p->frame_buffer + 0x1000;
778 disp->visual = fix->visual;
779 disp->line_length = fix->line_length;
781 if(disp->scrollmode != SCROLL_YREDRAW) {
782 printk(KERN_ERR "Scroll mode not YREDRAW in valkyrie_par_to_display\n");
783 disp->scrollmode = SCROLL_YREDRAW;
785 switch (par->cmode) {
786 #ifdef FBCON_HAS_CFB8
788 disp->dispsw = &fbcon_cfb8;
791 #ifdef FBCON_HAS_CFB16
793 disp->dispsw = &fbcon_cfb16;
794 disp->dispsw_data = p->fbcon_cfb16_cmap;
798 disp->dispsw = &fbcon_dummy;
803 static void __init valkyrie_init_info(struct fb_info *info, struct fb_info_valkyrie *p)
805 strcpy(info->modename, p->fix.id);
806 info->node = -1; /* ??? danj */
807 info->fbops = &valkyriefb_ops;
808 info->disp = &p->disp;
809 strcpy(info->fontname, fontname);
810 info->changevar = NULL;
811 info->switch_con = &valkyriefb_switch;
812 info->updatevar = &valkyriefb_updatevar;
813 info->blank = &valkyriefb_blank;
814 info->flags = FBINFO_FLAG_DEFAULT;
819 * Parse user speficied options (`video=valkyriefb:')
821 int __init valkyriefb_setup(char *options)
825 if (!options || !*options)
828 while ((this_opt = strsep(&options, ",")) != NULL) {
829 if (!strncmp(this_opt, "font:", 5)) {
834 for (i = 0; i < sizeof(fontname) - 1; i++)
835 if (!*p || *p == ' ' || *p == ',')
837 memcpy(fontname, this_opt + 5, i);
840 else if (!strncmp(this_opt, "vmode:", 6)) {
841 int vmode = simple_strtoul(this_opt+6, NULL, 0);
842 if (vmode > 0 && vmode <= VMODE_MAX)
843 default_vmode = vmode;
845 else if (!strncmp(this_opt, "cmode:", 6)) {
846 int depth = simple_strtoul(this_opt+6, NULL, 0);
849 default_cmode = CMODE_8;
853 default_cmode = CMODE_16;
857 /* XXX - remove these options once blanking has been tested */
858 else if (!strncmp(this_opt, "noblank", 7)) {
861 else if (!strncmp(this_opt, "blank", 5)) {
868 MODULE_LICENSE("GPL");