26 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <linux/errno.h>
29 #include <linux/string.h>
32 #include <linux/nubus.h>
36 #include <asm/setup.h>
37 #include <asm/bootinfo.h>
42 #define DAC_BASE 0x50f24000
45 #define DAFB_BASE 0xf9800200
48 #define CIVIC_BASE 0x50f30800
51 #define GSC_BASE 0x50F20000
54 #define CSC_BASE 0x50F20000
56 static int (*macfb_setpalette)(
unsigned int regno,
unsigned int red,
75 unsigned long pad1[3];
76 unsigned char pad2[3];
82 unsigned char pad1[15];
84 unsigned char pad2[15];
121 #define PIXEL_TO_MM(a) (((a)*10)/28)
140 static void *slot_addr;
152 static int dafb_setpalette(
unsigned int regno,
unsigned int red,
156 static int lastreg = -1;
165 if (regno != lastreg + 1) {
173 for (i = 0; i < regno; i++) {
175 &dafb_cmap_regs->lut);
178 &dafb_cmap_regs->lut);
181 &dafb_cmap_regs->lut);
198 static int v8_brazil_setpalette(
unsigned int regno,
unsigned int red,
199 unsigned int green,
unsigned int blue,
202 unsigned int bpp = info->
var.bits_per_pixel;
216 regno = (regno << (8 -
bpp)) | (0xFF >>
bpp);
232 static int rbv_setpalette(
unsigned int regno,
unsigned int red,
233 unsigned int green,
unsigned int blue,
238 if (info->
var.bits_per_pixel > 8)
247 regno += 256 - (1 << info->
var.bits_per_pixel);
269 static int mdc_setpalette(
unsigned int regno,
unsigned int red,
270 unsigned int green,
unsigned int blue,
292 static int toby_setpalette(
unsigned int regno,
unsigned int red,
293 unsigned int green,
unsigned int blue,
297 unsigned int bpp = info->
var.bits_per_pixel;
303 regno = (regno << (8 -
bpp)) | (0xFF >>
bpp);
320 static int jet_setpalette(
unsigned int regno,
unsigned int red,
321 unsigned int green,
unsigned int blue,
350 static int civic_setpalette(
unsigned int regno,
unsigned int red,
351 unsigned int green,
unsigned int blue,
357 if (info->
var.bits_per_pixel > 8)
370 clut_status =
nubus_readb(&civic_cmap_regs->status2);
372 if ((clut_status & 0x0008) == 0)
375 if ((clut_status & 0x000D) != 0)
405 if ((clut_status & 0x000D) != 0)
431 static int csc_setpalette(
unsigned int regno,
unsigned int red,
432 unsigned int green,
unsigned int blue,
449 static int macfb_setcolreg(
unsigned regno,
unsigned red,
unsigned green,
450 unsigned blue,
unsigned transp,
460 if (regno >= fb_info->
cmap.len)
463 if (fb_info->
var.bits_per_pixel <= 8) {
464 switch (fb_info->
var.bits_per_pixel) {
471 if (macfb_setpalette)
472 macfb_setpalette(regno, red >> 8, green >> 8,
478 }
else if (regno < 16) {
479 switch (fb_info->
var.bits_per_pixel) {
481 if (fb_info->
var.red.offset == 10) {
484 ((red & 0xf800) >> 1) |
485 ((green & 0xf800) >> 6) |
486 ((blue & 0xf800) >> 11) |
487 ((transp != 0) << 15);
491 ((red & 0xf800) >> 0) |
492 ((green & 0xfc00) >> 5) |
493 ((blue & 0xf800) >> 11);
506 (red << fb_info->
var.red.offset) |
507 (green << fb_info->
var.green.offset) |
508 (blue << fb_info->
var.blue.offset);
516 static struct fb_ops macfb_ops = {
518 .fb_setcolreg = macfb_setcolreg,
528 if (!options || !*options)
531 while ((this_opt =
strsep(&options,
",")) !=
NULL) {
535 if (!
strcmp(this_opt,
"inverse"))
538 if (!
strcmp(this_opt,
"vidtest"))
543 static void __init iounmap_macfb(
void)
547 if (v8_brazil_cmap_regs)
557 static int __init macfb_init(
void)
559 int video_cmap_len, video_is_nubus = 0;
595 pr_info(
"macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n",
598 pr_info(
"macfb: mode is %dx%dx%d, linelength=%d\n",
599 macfb_defined.
xres, macfb_defined.
yres,
609 macfb_defined.
pixclock = 10000000 / macfb_defined.
xres *
610 1000 / macfb_defined.
yres;
632 macfb_defined.
transp.offset = 15;
633 macfb_defined.
transp.length = 1;
634 macfb_defined.
red.offset = 10;
635 macfb_defined.
red.length = 5;
636 macfb_defined.
green.offset = 5;
637 macfb_defined.
green.length = 5;
638 macfb_defined.
blue.offset = 0;
639 macfb_defined.
blue.length = 5;
649 macfb_defined.
red.offset = 16;
650 macfb_defined.
red.length = 8;
651 macfb_defined.
green.offset = 8;
652 macfb_defined.
green.length = 8;
653 macfb_defined.
blue.offset = 0;
654 macfb_defined.
blue.length = 8;
659 pr_err(
"macfb: unknown or unsupported bit depth: %d\n",
677 unsigned long base = ndev->
board->slot_addr;
684 slot_addr = (
unsigned char *)base;
686 switch(ndev->
dr_hw) {
688 strcpy(macfb_fix.
id,
"Mac Disp. Card");
689 macfb_setpalette = mdc_setpalette;
694 macfb_setpalette = toby_setpalette;
699 macfb_setpalette = jet_setpalette;
703 strcpy(macfb_fix.
id,
"Generic NuBus");
731 macfb_setpalette = dafb_setpalette;
741 macfb_setpalette = v8_brazil_setpalette;
755 macfb_setpalette = v8_brazil_setpalette;
772 macfb_setpalette = v8_brazil_setpalette;
785 macfb_setpalette = rbv_setpalette;
796 macfb_setpalette = civic_setpalette;
809 macfb_setpalette = v8_brazil_setpalette;
810 v8_brazil_cmap_regs =
820 strcpy(macfb_fix.
id,
"Color Classic");
822 macfb_setpalette = v8_brazil_setpalette;
823 v8_brazil_cmap_regs =
892 macfb_setpalette = csc_setpalette;
902 fb_info.
fbops = &macfb_ops;
903 fb_info.
var = macfb_defined;
904 fb_info.
fix = macfb_fix;
916 pr_info(
"fb%d: %s frame buffer device\n",