Commit 34c41d0a authored by Finn Thain's avatar Finn Thain Committed by Geert Uytterhoeven

macfb: cleanup

Cleanup whitespace and code style. Remove unused #includes and prototypes.
Remove obsolete, redundant or misleading comments. Remove dead code and
redundant initialisers.
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
parent 1bb63845
/* macfb.c: Generic framebuffer for Macs whose colourmaps/modes we /*
don't know how to set */ * macfb.c: Generic framebuffer for Macs whose colourmaps/modes we
* don't know how to set.
/* (c) 1999 David Huggins-Daines <dhd@debian.org> *
* (c) 1999 David Huggins-Daines <dhd@debian.org>
Primarily based on vesafb.c, by Gerd Knorr *
(c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> * Primarily based on vesafb.c, by Gerd Knorr
* (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
Also uses information and code from: *
* Also uses information and code from:
The original macfb.c from Linux/mac68k 2.0, by Alan Cox, Juergen *
Mellinger, Mikael Forselius, Michael Schmitz, and others. * The original macfb.c from Linux/mac68k 2.0, by Alan Cox, Juergen
* Mellinger, Mikael Forselius, Michael Schmitz, and others.
valkyriefb.c, by Martin Costabel, Kevin Schoedel, Barry Nathan, Dan *
Jacobowitz, Paul Mackerras, Fabio Riccardi, and Geert Uytterhoeven. * valkyriefb.c, by Martin Costabel, Kevin Schoedel, Barry Nathan, Dan
* Jacobowitz, Paul Mackerras, Fabio Riccardi, and Geert Uytterhoeven.
This code is free software. You may copy, modify, and distribute *
it subject to the terms and conditions of the GNU General Public * The VideoToolbox "Bugs" web page at
License, version 2, or any later version, at your convenience. */ * http://rajsky.psych.nyu.edu/Tips/VideoBugs.html
*
* This code is free software. You may copy, modify, and distribute
* it subject to the terms and conditions of the GNU General Public
* License, version 2, or any later version, at your convenience.
*/
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/nubus.h> #include <linux/nubus.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -31,9 +35,6 @@ ...@@ -31,9 +35,6 @@
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/bootinfo.h> #include <asm/bootinfo.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/irq.h>
#include <asm/macintosh.h> #include <asm/macintosh.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
#define DAFB_BASE 0xf9800200 #define DAFB_BASE 0xf9800200
/* Address for the built-in Civic framebuffer in Quadra AVs */ /* Address for the built-in Civic framebuffer in Quadra AVs */
#define CIVIC_BASE 0x50f30800 /* Only tested on 660AV! */ #define CIVIC_BASE 0x50f30800
/* GSC (Gray Scale Controller) base address */ /* GSC (Gray Scale Controller) base address */
#define GSC_BASE 0x50F20000 #define GSC_BASE 0x50F20000
...@@ -52,27 +53,9 @@ ...@@ -52,27 +53,9 @@
/* CSC (Color Screen Controller) base address */ /* CSC (Color Screen Controller) base address */
#define CSC_BASE 0x50F20000 #define CSC_BASE 0x50F20000
static int (*macfb_setpalette) (unsigned int regno, unsigned int red, static int (*macfb_setpalette)(unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue,
struct fb_info *info) = NULL;
static int dafb_setpalette (unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue,
struct fb_info *fb_info);
static int rbv_setpalette (unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue, unsigned int green, unsigned int blue,
struct fb_info *fb_info); struct fb_info *info);
static int mdc_setpalette (unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue,
struct fb_info *fb_info);
static int toby_setpalette (unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue,
struct fb_info *fb_info);
static int civic_setpalette (unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue,
struct fb_info *fb_info);
static int csc_setpalette (unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue,
struct fb_info *fb_info);
static struct { static struct {
unsigned char addr; unsigned char addr;
...@@ -114,7 +97,7 @@ static struct { ...@@ -114,7 +97,7 @@ static struct {
unsigned char clut_raddr; /* 0x46 */ unsigned char clut_raddr; /* 0x46 */
} __iomem *csc_cmap_regs; } __iomem *csc_cmap_regs;
/* We will leave these the way they are for the time being */ /* The registers in these structs are in NuBus slot space */
struct mdc_cmap_regs { struct mdc_cmap_regs {
char pad1[0x200200]; char pad1[0x200200];
unsigned char addr; unsigned char addr;
...@@ -137,7 +120,6 @@ struct jet_cmap_regs { ...@@ -137,7 +120,6 @@ struct jet_cmap_regs {
#define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */ #define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */
/* mode */
static int video_slot = 0; static int video_slot = 0;
static struct fb_var_screeninfo macfb_defined = { static struct fb_var_screeninfo macfb_defined = {
...@@ -159,19 +141,19 @@ static struct fb_fix_screeninfo macfb_fix = { ...@@ -159,19 +141,19 @@ static struct fb_fix_screeninfo macfb_fix = {
static struct fb_info fb_info; static struct fb_info fb_info;
static u32 pseudo_palette[16]; static u32 pseudo_palette[16];
static int inverse = 0; static int inverse;
static int vidtest = 0; static int vidtest;
/* Unlike the Valkyrie, the DAFB cannot set individual colormap /*
registers. Therefore, we do what the MacOS driver does (no * Unlike the Valkyrie, the DAFB cannot set individual colormap
kidding!) and simply set them one by one until we hit the one we * registers. Therefore, we do what the MacOS driver does (no
want. */ * kidding!) and simply set them one by one until we hit the one we
static int dafb_setpalette (unsigned int regno, unsigned int red, * want.
*/
static int dafb_setpalette(unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue, unsigned int green, unsigned int blue,
struct fb_info *info) struct fb_info *info)
{ {
/* FIXME: really, really need to use ioremap() here,
phys_to_virt() doesn't work anymore */
static int lastreg = -1; static int lastreg = -1;
unsigned long flags; unsigned long flags;
...@@ -181,9 +163,11 @@ static int dafb_setpalette (unsigned int regno, unsigned int red, ...@@ -181,9 +163,11 @@ static int dafb_setpalette (unsigned int regno, unsigned int red,
local_irq_save(flags); local_irq_save(flags);
/* fbdev will set an entire colourmap, but X won't. Hopefully /*
this should accommodate both of them */ * fbdev will set an entire colourmap, but X won't. Hopefully
if (regno != lastreg+1) { * this should accommodate both of them
*/
if (regno != lastreg + 1) {
int i; int i;
/* Stab in the dark trying to reset the CLUT pointer */ /* Stab in the dark trying to reset the CLUT pointer */
...@@ -192,11 +176,14 @@ static int dafb_setpalette (unsigned int regno, unsigned int red, ...@@ -192,11 +176,14 @@ static int dafb_setpalette (unsigned int regno, unsigned int red,
/* Loop until we get to the register we want */ /* Loop until we get to the register we want */
for (i = 0; i < regno; i++) { for (i = 0; i < regno; i++) {
nubus_writeb(info->cmap.red[i] >> 8, &dafb_cmap_regs->lut); nubus_writeb(info->cmap.red[i] >> 8,
&dafb_cmap_regs->lut);
nop(); nop();
nubus_writeb(info->cmap.green[i] >> 8, &dafb_cmap_regs->lut); nubus_writeb(info->cmap.green[i] >> 8,
&dafb_cmap_regs->lut);
nop(); nop();
nubus_writeb(info->cmap.blue[i] >> 8, &dafb_cmap_regs->lut); nubus_writeb(info->cmap.blue[i] >> 8,
&dafb_cmap_regs->lut);
nop(); nop();
} }
} }
...@@ -213,7 +200,7 @@ static int dafb_setpalette (unsigned int regno, unsigned int red, ...@@ -213,7 +200,7 @@ static int dafb_setpalette (unsigned int regno, unsigned int red,
} }
/* V8 and Brazil seem to use the same DAC. Sonora does as well. */ /* V8 and Brazil seem to use the same DAC. Sonora does as well. */
static int v8_brazil_setpalette (unsigned int regno, unsigned int red, static int v8_brazil_setpalette(unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue, unsigned int green, unsigned int blue,
struct fb_info *info) struct fb_info *info)
{ {
...@@ -224,31 +211,34 @@ static int v8_brazil_setpalette (unsigned int regno, unsigned int red, ...@@ -224,31 +211,34 @@ static int v8_brazil_setpalette (unsigned int regno, unsigned int red,
unsigned char _regno; unsigned char _regno;
unsigned long flags; unsigned long flags;
if (bpp > 8) return 1; /* failsafe */ if (bpp > 8)
return 1; /* failsafe */
local_irq_save(flags); local_irq_save(flags);
/* On these chips, the CLUT register numbers are spread out /* On these chips, the CLUT register numbers are spread out
across the register space. Thus: * across the register space. Thus:
* In 8bpp, all regnos are valid.
In 8bpp, all regnos are valid. * In 4bpp, the regnos are 0x0f, 0x1f, 0x2f, etc, etc
* In 2bpp, the regnos are 0x3f, 0x7f, 0xbf, 0xff
In 4bpp, the regnos are 0x0f, 0x1f, 0x2f, etc, etc */
In 2bpp, the regnos are 0x3f, 0x7f, 0xbf, 0xff */
_regno = (regno << (8 - bpp)) | (0xFF >> bpp); _regno = (regno << (8 - bpp)) | (0xFF >> bpp);
nubus_writeb(_regno, &v8_brazil_cmap_regs->addr); nop(); nubus_writeb(_regno, &v8_brazil_cmap_regs->addr);
nop();
/* send one color channel at a time */ /* send one color channel at a time */
nubus_writeb(_red, &v8_brazil_cmap_regs->lut); nop(); nubus_writeb(_red, &v8_brazil_cmap_regs->lut);
nubus_writeb(_green, &v8_brazil_cmap_regs->lut); nop(); nop();
nubus_writeb(_green, &v8_brazil_cmap_regs->lut);
nop();
nubus_writeb(_blue, &v8_brazil_cmap_regs->lut); nubus_writeb(_blue, &v8_brazil_cmap_regs->lut);
local_irq_restore(flags); local_irq_restore(flags);
return 0; return 0;
} }
static int rbv_setpalette (unsigned int regno, unsigned int red, /* RAM-Based Video */
static int rbv_setpalette(unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue, unsigned int green, unsigned int blue,
struct fb_info *info) struct fb_info *info)
{ {
...@@ -259,7 +249,8 @@ static int rbv_setpalette (unsigned int regno, unsigned int red, ...@@ -259,7 +249,8 @@ static int rbv_setpalette (unsigned int regno, unsigned int red,
unsigned char _regno; unsigned char _regno;
unsigned long flags; unsigned long flags;
if (info->var.bits_per_pixel > 8) return 1; /* failsafe */ if (info->var.bits_per_pixel > 8)
return 1; /* failsafe */
local_irq_save(flags); local_irq_save(flags);
...@@ -270,21 +261,25 @@ static int rbv_setpalette (unsigned int regno, unsigned int red, ...@@ -270,21 +261,25 @@ static int rbv_setpalette (unsigned int regno, unsigned int red,
_regno = regno + (256-(1 << info->var.bits_per_pixel)); _regno = regno + (256-(1 << info->var.bits_per_pixel));
/* reset clut? (VideoToolbox sez "not necessary") */ /* reset clut? (VideoToolbox sez "not necessary") */
nubus_writeb(0xFF, &rbv_cmap_regs->cntl); nop(); nubus_writeb(0xFF, &rbv_cmap_regs->cntl);
nop();
/* tell clut which address to use. */ /* tell clut which address to use. */
nubus_writeb(_regno, &rbv_cmap_regs->addr); nop(); nubus_writeb(_regno, &rbv_cmap_regs->addr);
nop();
/* send one color channel at a time. */ /* send one color channel at a time. */
nubus_writeb(_red, &rbv_cmap_regs->lut); nop(); nubus_writeb(_red, &rbv_cmap_regs->lut);
nubus_writeb(_green, &rbv_cmap_regs->lut); nop(); nop();
nubus_writeb(_green, &rbv_cmap_regs->lut);
nop();
nubus_writeb(_blue, &rbv_cmap_regs->lut); nubus_writeb(_blue, &rbv_cmap_regs->lut);
local_irq_restore(flags); /* done. */ local_irq_restore(flags);
return 0; return 0;
} }
/* Macintosh Display Card (8x24) */ /* Macintosh Display Card (8*24) */
static int mdc_setpalette(unsigned int regno, unsigned int red, static int mdc_setpalette(unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue, unsigned int green, unsigned int blue,
struct fb_info *info) struct fb_info *info)
...@@ -301,9 +296,12 @@ static int mdc_setpalette(unsigned int regno, unsigned int red, ...@@ -301,9 +296,12 @@ static int mdc_setpalette(unsigned int regno, unsigned int red,
local_irq_save(flags); local_irq_save(flags);
/* the nop's are there to order writes. */ /* the nop's are there to order writes. */
nubus_writeb(_regno, &cmap_regs->addr); nop(); nubus_writeb(_regno, &cmap_regs->addr);
nubus_writeb(_red, &cmap_regs->lut); nop(); nop();
nubus_writeb(_green, &cmap_regs->lut); nop(); nubus_writeb(_red, &cmap_regs->lut);
nop();
nubus_writeb(_green, &cmap_regs->lut);
nop();
nubus_writeb(_blue, &cmap_regs->lut); nubus_writeb(_blue, &cmap_regs->lut);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -327,9 +325,12 @@ static int toby_setpalette(unsigned int regno, unsigned int red, ...@@ -327,9 +325,12 @@ static int toby_setpalette(unsigned int regno, unsigned int red,
local_irq_save(flags); local_irq_save(flags);
nubus_writeb(_regno, &cmap_regs->addr); nop(); nubus_writeb(_regno, &cmap_regs->addr);
nubus_writeb(_red, &cmap_regs->lut); nop(); nop();
nubus_writeb(_green, &cmap_regs->lut); nop(); nubus_writeb(_red, &cmap_regs->lut);
nop();
nubus_writeb(_green, &cmap_regs->lut);
nop();
nubus_writeb(_blue, &cmap_regs->lut); nubus_writeb(_blue, &cmap_regs->lut);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -351,9 +352,12 @@ static int jet_setpalette(unsigned int regno, unsigned int red, ...@@ -351,9 +352,12 @@ static int jet_setpalette(unsigned int regno, unsigned int red,
local_irq_save(flags); local_irq_save(flags);
nubus_writeb(regno, &cmap_regs->addr); nop(); nubus_writeb(regno, &cmap_regs->addr);
nubus_writeb(_red, &cmap_regs->lut); nop(); nop();
nubus_writeb(_green, &cmap_regs->lut); nop(); nubus_writeb(_red, &cmap_regs->lut);
nop();
nubus_writeb(_green, &cmap_regs->lut);
nop();
nubus_writeb(_blue, &cmap_regs->lut); nubus_writeb(_blue, &cmap_regs->lut);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -368,18 +372,16 @@ static int jet_setpalette(unsigned int regno, unsigned int red, ...@@ -368,18 +372,16 @@ static int jet_setpalette(unsigned int regno, unsigned int red,
* input and viewing the screen at the same time! The 840AV * input and viewing the screen at the same time! The 840AV
* Can add another 1MB RAM to give the two framebuffers * Can add another 1MB RAM to give the two framebuffers
* 1MB RAM apiece. * 1MB RAM apiece.
*
* FIXME: this doesn't seem to work anymore.
*/ */
static int civic_setpalette (unsigned int regno, unsigned int red, static int civic_setpalette(unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue, unsigned int green, unsigned int blue,
struct fb_info *info) struct fb_info *info)
{ {
static int lastreg = -1;
unsigned long flags; unsigned long flags;
int clut_status; int clut_status;
if (info->var.bits_per_pixel > 8) return 1; /* failsafe */ if (info->var.bits_per_pixel > 8)
return 1; /* failsafe */
red >>= 8; red >>= 8;
green >>= 8; green >>= 8;
...@@ -387,29 +389,9 @@ static int civic_setpalette (unsigned int regno, unsigned int red, ...@@ -387,29 +389,9 @@ static int civic_setpalette (unsigned int regno, unsigned int red,
local_irq_save(flags); local_irq_save(flags);
/* /* Set the register address */
* Set the register address nubus_writeb(regno, &civic_cmap_regs->addr);
*/ nop();
nubus_writeb(regno, &civic_cmap_regs->addr); nop();
/*
* Wait for VBL interrupt here;
* They're usually not enabled from Penguin, so we won't check
*/
#if 0
{
#define CIVIC_VBL_OFFSET 0x120
volatile unsigned long *vbl = nubus_readl(civic_cmap_regs->vbl_addr + CIVIC_VBL_OFFSET);
/* do interrupt setup stuff here? */
*vbl = 0L; nop(); /* clear */
*vbl = 1L; nop(); /* set */
while (*vbl != 0L) /* wait for next vbl */
{
usleep(10); /* needed? */
}
/* do interrupt shutdown stuff here? */
}
#endif
/* /*
* Grab a status word and do some checking; * Grab a status word and do some checking;
...@@ -422,39 +404,52 @@ static int civic_setpalette (unsigned int regno, unsigned int red, ...@@ -422,39 +404,52 @@ static int civic_setpalette (unsigned int regno, unsigned int red,
#if 0 #if 0
if ((clut_status & 0x000D) != 0) if ((clut_status & 0x000D) != 0)
{ {
nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); nubus_writeb(0x00, &civic_cmap_regs->lut);
nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); nop();
nubus_writeb(0x00, &civic_cmap_regs->lut);
nop();
} }
#endif #endif
nubus_writeb( red, &civic_cmap_regs->lut); nop(); nubus_writeb(red, &civic_cmap_regs->lut);
nubus_writeb(green, &civic_cmap_regs->lut); nop(); nop();
nubus_writeb( blue, &civic_cmap_regs->lut); nop(); nubus_writeb(green, &civic_cmap_regs->lut);
nubus_writeb( 0x00, &civic_cmap_regs->lut); nop(); nop();
nubus_writeb(blue, &civic_cmap_regs->lut);
nop();
nubus_writeb(0x00, &civic_cmap_regs->lut);
} }
else else
{ {
unsigned char junk; unsigned char junk;
junk = nubus_readb(&civic_cmap_regs->lut); nop(); junk = nubus_readb(&civic_cmap_regs->lut);
junk = nubus_readb(&civic_cmap_regs->lut); nop(); nop();
junk = nubus_readb(&civic_cmap_regs->lut); nop(); junk = nubus_readb(&civic_cmap_regs->lut);
junk = nubus_readb(&civic_cmap_regs->lut); nop(); nop();
junk = nubus_readb(&civic_cmap_regs->lut);
nop();
junk = nubus_readb(&civic_cmap_regs->lut);
nop();
if ((clut_status & 0x000D) != 0) if ((clut_status & 0x000D) != 0)
{ {
nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); nubus_writeb(0x00, &civic_cmap_regs->lut);
nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); nop();
nubus_writeb(0x00, &civic_cmap_regs->lut);
nop();
} }
nubus_writeb( red, &civic_cmap_regs->lut); nop(); nubus_writeb(red, &civic_cmap_regs->lut);
nubus_writeb(green, &civic_cmap_regs->lut); nop(); nop();
nubus_writeb( blue, &civic_cmap_regs->lut); nop(); nubus_writeb(green, &civic_cmap_regs->lut);
nubus_writeb( junk, &civic_cmap_regs->lut); nop(); nop();
nubus_writeb(blue, &civic_cmap_regs->lut);
nop();
nubus_writeb(junk, &civic_cmap_regs->lut);
} }
local_irq_restore(flags); local_irq_restore(flags);
lastreg = regno;
return 0; return 0;
} }
...@@ -463,8 +458,7 @@ static int civic_setpalette (unsigned int regno, unsigned int red, ...@@ -463,8 +458,7 @@ static int civic_setpalette (unsigned int regno, unsigned int red,
* (and the 5300 too, but that's a PowerMac). This function * (and the 5300 too, but that's a PowerMac). This function
* brought to you in part by the ECSC driver for MkLinux. * brought to you in part by the ECSC driver for MkLinux.
*/ */
static int csc_setpalette(unsigned int regno, unsigned int red,
static int csc_setpalette (unsigned int regno, unsigned int red,
unsigned int green, unsigned int blue, unsigned int green, unsigned int blue,
struct fb_info *info) struct fb_info *info)
{ {
...@@ -483,8 +477,8 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, ...@@ -483,8 +477,8 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green,
/* /*
* Set a single color register. The values supplied are * Set a single color register. The values supplied are
* already rounded down to the hardware's capabilities * already rounded down to the hardware's capabilities
* (according to the entries in the `var' structure). Return * (according to the entries in the `var' structure).
* != 0 for invalid regno. * Return non-zero for invalid regno.
*/ */
if (regno >= fb_info->cmap.len) if (regno >= fb_info->cmap.len)
...@@ -518,22 +512,16 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, ...@@ -518,22 +512,16 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green,
} else { } else {
/* 0:5:6:5 */ /* 0:5:6:5 */
((u32*) (fb_info->pseudo_palette))[regno] = ((u32*) (fb_info->pseudo_palette))[regno] =
((red & 0xf800) ) | ((red & 0xf800) >> 0) |
((green & 0xfc00) >> 5) | ((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11); ((blue & 0xf800) >> 11);
} }
break; break;
/* I'm pretty sure that one or the other of these /*
doesn't exist on 68k Macs */ * 24-bit colour almost doesn't exist on 68k Macs --
* http://support.apple.com/kb/TA28634 (Old Article: 10992)
*/
case 24: case 24:
red >>= 8;
green >>= 8;
blue >>= 8;
((u32 *)(fb_info->pseudo_palette))[regno] =
(red << fb_info->var.red.offset) |
(green << fb_info->var.green.offset) |
(blue << fb_info->var.blue.offset);
break;
case 32: case 32:
red >>= 8; red >>= 8;
green >>= 8; green >>= 8;
...@@ -565,13 +553,14 @@ static void __init macfb_setup(char *options) ...@@ -565,13 +553,14 @@ static void __init macfb_setup(char *options)
return; return;
while ((this_opt = strsep(&options, ",")) != NULL) { while ((this_opt = strsep(&options, ",")) != NULL) {
if (!*this_opt) continue; if (!*this_opt)
continue;
if (! strcmp(this_opt, "inverse")) if (!strcmp(this_opt, "inverse"))
inverse=1; inverse = 1;
/* This means "turn on experimental CLUT code" */ else
else if (!strcmp(this_opt, "vidtest")) if (!strcmp(this_opt, "vidtest"))
vidtest=1; vidtest = 1; /* enable experimental CLUT code */
} }
} }
...@@ -607,48 +596,52 @@ static int __init macfb_init(void) ...@@ -607,48 +596,52 @@ static int __init macfb_init(void)
mac_bi_data.id == MAC_MODEL_P588) mac_bi_data.id == MAC_MODEL_P588)
return -ENODEV; /* See valkyriefb.c */ return -ENODEV; /* See valkyriefb.c */
/* There can only be one internal video controller anyway so
we're not too worried about this */
macfb_defined.xres = mac_bi_data.dimensions & 0xFFFF; macfb_defined.xres = mac_bi_data.dimensions & 0xFFFF;
macfb_defined.yres = mac_bi_data.dimensions >> 16; macfb_defined.yres = mac_bi_data.dimensions >> 16;
macfb_defined.bits_per_pixel = mac_bi_data.videodepth; macfb_defined.bits_per_pixel = mac_bi_data.videodepth;
macfb_fix.line_length = mac_bi_data.videorow; macfb_fix.line_length = mac_bi_data.videorow;
macfb_fix.smem_len = macfb_fix.line_length * macfb_defined.yres; macfb_fix.smem_len = macfb_fix.line_length * macfb_defined.yres;
/* Note: physical address (since 2.1.127) */ /* Note: physical address (since 2.1.127) */
macfb_fix.smem_start = mac_bi_data.videoaddr; macfb_fix.smem_start = mac_bi_data.videoaddr;
/* This is actually redundant with the initial mappings.
However, there are some non-obvious aspects to the way /*
those mappings are set up, so this is in fact the safest * This is actually redundant with the initial mappings.
way to ensure that this driver will work on every possible * However, there are some non-obvious aspects to the way
Mac */ * those mappings are set up, so this is in fact the safest
* way to ensure that this driver will work on every possible Mac
*/
fb_info.screen_base = ioremap(mac_bi_data.videoaddr, macfb_fix.smem_len); fb_info.screen_base = ioremap(mac_bi_data.videoaddr, macfb_fix.smem_len);
printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n", printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n",
macfb_fix.smem_start, fb_info.screen_base, macfb_fix.smem_len/1024); macfb_fix.smem_start, fb_info.screen_base,
macfb_fix.smem_len / 1024);
printk("macfb: mode is %dx%dx%d, linelength=%d\n", printk("macfb: mode is %dx%dx%d, linelength=%d\n",
macfb_defined.xres, macfb_defined.yres, macfb_defined.bits_per_pixel, macfb_fix.line_length); macfb_defined.xres, macfb_defined.yres,
macfb_defined.bits_per_pixel, macfb_fix.line_length);
/* /*
* Fill in the available video resolution * Fill in the available video resolution
*/ */
macfb_defined.xres_virtual = macfb_defined.xres; macfb_defined.xres_virtual = macfb_defined.xres;
macfb_defined.yres_virtual = macfb_defined.yres; macfb_defined.yres_virtual = macfb_defined.yres;
macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres); macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres);
macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres); macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres);
printk("macfb: scrolling: redraw\n"); printk("macfb: scrolling: redraw\n");
macfb_defined.yres_virtual = macfb_defined.yres;
/* some dummy values for timing to make fbset happy */ /* some dummy values for timing to make fbset happy */
macfb_defined.pixclock = 10000000 / macfb_defined.xres * 1000 / macfb_defined.yres; macfb_defined.pixclock = 10000000 / macfb_defined.xres *
1000 / macfb_defined.yres;
macfb_defined.left_margin = (macfb_defined.xres / 8) & 0xf8; macfb_defined.left_margin = (macfb_defined.xres / 8) & 0xf8;
macfb_defined.hsync_len = (macfb_defined.xres / 8) & 0xf8; macfb_defined.hsync_len = (macfb_defined.xres / 8) & 0xf8;
switch (macfb_defined.bits_per_pixel) { switch (macfb_defined.bits_per_pixel) {
case 1: case 1:
/* XXX: I think this will catch any program that tries /*
to do FBIO_PUTCMAP when the visual is monochrome */ * XXX: I think this will catch any program that tries
* to do FBIO_PUTCMAP when the visual is monochrome.
*/
macfb_defined.red.length = macfb_defined.bits_per_pixel; macfb_defined.red.length = macfb_defined.bits_per_pixel;
macfb_defined.green.length = macfb_defined.bits_per_pixel; macfb_defined.green.length = macfb_defined.bits_per_pixel;
macfb_defined.blue.length = macfb_defined.bits_per_pixel; macfb_defined.blue.length = macfb_defined.bits_per_pixel;
...@@ -676,14 +669,14 @@ static int __init macfb_init(void) ...@@ -676,14 +669,14 @@ static int __init macfb_init(void)
printk("macfb: directcolor: " printk("macfb: directcolor: "
"size=1:5:5:5, shift=15:10:5:0\n"); "size=1:5:5:5, shift=15:10:5:0\n");
video_cmap_len = 16; video_cmap_len = 16;
/* Should actually be FB_VISUAL_DIRECTCOLOR, but this /*
works too */ * Should actually be FB_VISUAL_DIRECTCOLOR, but this
* works too
*/
macfb_fix.visual = FB_VISUAL_TRUECOLOR; macfb_fix.visual = FB_VISUAL_TRUECOLOR;
break; break;
case 24: case 24:
case 32: case 32:
/* XXX: have to test these... can any 68k Macs
actually do this on internal video? */
macfb_defined.red.offset = 16; macfb_defined.red.offset = 16;
macfb_defined.red.length = 8; macfb_defined.red.length = 8;
macfb_defined.green.offset = 8; macfb_defined.green.offset = 8;
...@@ -697,18 +690,19 @@ static int __init macfb_init(void) ...@@ -697,18 +690,19 @@ static int __init macfb_init(void)
default: default:
video_cmap_len = 0; video_cmap_len = 0;
macfb_fix.visual = FB_VISUAL_MONO01; macfb_fix.visual = FB_VISUAL_MONO01;
printk("macfb: unknown or unsupported bit depth: %d\n", macfb_defined.bits_per_pixel); printk("macfb: unknown or unsupported bit depth: %d\n",
macfb_defined.bits_per_pixel);
break; break;
} }
/* Hardware dependent stuff */ /*
/* We take a wild guess that if the video physical address is * We take a wild guess that if the video physical address is
* in nubus slot space, that the nubus card is driving video. * in nubus slot space, that the nubus card is driving video.
* Penguin really ought to tell us whether we are using internal * Penguin really ought to tell us whether we are using internal
* video or not. * video or not.
* Hopefully we only find one of them. Otherwise our NuBus
* code is really broken :-)
*/ */
/* Hopefully we only find one of them. Otherwise our NuBus
code is really broken :-) */
while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY, NUBUS_TYPE_VIDEO, ndev)) while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY, NUBUS_TYPE_VIDEO, ndev))
!= NULL) != NULL)
...@@ -744,15 +738,14 @@ static int __init macfb_init(void) ...@@ -744,15 +738,14 @@ static int __init macfb_init(void)
} }
/* If it's not a NuBus card, it must be internal video */ /* If it's not a NuBus card, it must be internal video */
/* FIXME: this function is getting way too big. (this driver
is too...) */
if (!video_is_nubus) if (!video_is_nubus)
switch( mac_bi_data.id ) switch (mac_bi_data.id) {
{ /*
/* DAFB Quadras */ * DAFB Quadras
/* Note: these first four have the v7 DAFB, which is * Note: these first four have the v7 DAFB, which is
known to be rather unlike the ones used in the * known to be rather unlike the ones used in the
other models */ * other models
*/
case MAC_MODEL_P475: case MAC_MODEL_P475:
case MAC_MODEL_P475F: case MAC_MODEL_P475F:
case MAC_MODEL_P575: case MAC_MODEL_P575:
...@@ -772,7 +765,9 @@ static int __init macfb_init(void) ...@@ -772,7 +765,9 @@ static int __init macfb_init(void)
dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000); dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000);
break; break;
/* LC II uses the V8 framebuffer */ /*
* LC II uses the V8 framebuffer
*/
case MAC_MODEL_LCII: case MAC_MODEL_LCII:
strcpy(macfb_fix.id, "V8"); strcpy(macfb_fix.id, "V8");
macfb_setpalette = v8_brazil_setpalette; macfb_setpalette = v8_brazil_setpalette;
...@@ -780,9 +775,11 @@ static int __init macfb_init(void) ...@@ -780,9 +775,11 @@ static int __init macfb_init(void)
v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
break; break;
/* IIvi, IIvx use the "Brazil" framebuffer (which is /*
very much like the V8, it seems, and probably uses * IIvi, IIvx use the "Brazil" framebuffer (which is
the same DAC) */ * very much like the V8, it seems, and probably uses
* the same DAC)
*/
case MAC_MODEL_IIVI: case MAC_MODEL_IIVI:
case MAC_MODEL_IIVX: case MAC_MODEL_IIVX:
case MAC_MODEL_P600: case MAC_MODEL_P600:
...@@ -792,11 +789,13 @@ static int __init macfb_init(void) ...@@ -792,11 +789,13 @@ static int __init macfb_init(void)
v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
break; break;
/* LC III (and friends) use the Sonora framebuffer */ /*
/* Incidentally this is also used in the non-AV models * LC III (and friends) use the Sonora framebuffer
of the x100 PowerMacs */ * Incidentally this is also used in the non-AV models
/* These do in fact seem to use the same DAC interface * of the x100 PowerMacs
as the LC II. */ * These do in fact seem to use the same DAC interface
* as the LC II.
*/
case MAC_MODEL_LCIII: case MAC_MODEL_LCIII:
case MAC_MODEL_P520: case MAC_MODEL_P520:
case MAC_MODEL_P550: case MAC_MODEL_P550:
...@@ -807,9 +806,11 @@ static int __init macfb_init(void) ...@@ -807,9 +806,11 @@ static int __init macfb_init(void)
v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
break; break;
/* IIci and IIsi use the infamous RBV chip /*
(the IIsi is just a rebadged and crippled * IIci and IIsi use the infamous RBV chip
IIci in a different case, BTW) */ * (the IIsi is just a rebadged and crippled
* IIci in a different case, BTW)
*/
case MAC_MODEL_IICI: case MAC_MODEL_IICI:
case MAC_MODEL_IISI: case MAC_MODEL_IISI:
macfb_setpalette = rbv_setpalette; macfb_setpalette = rbv_setpalette;
...@@ -818,7 +819,9 @@ static int __init macfb_init(void) ...@@ -818,7 +819,9 @@ static int __init macfb_init(void)
rbv_cmap_regs = ioremap(DAC_BASE, 0x1000); rbv_cmap_regs = ioremap(DAC_BASE, 0x1000);
break; break;
/* AVs use the Civic framebuffer */ /*
* AVs use the Civic framebuffer
*/
case MAC_MODEL_Q840: case MAC_MODEL_Q840:
case MAC_MODEL_C660: case MAC_MODEL_C660:
macfb_setpalette = civic_setpalette; macfb_setpalette = civic_setpalette;
...@@ -828,15 +831,10 @@ static int __init macfb_init(void) ...@@ -828,15 +831,10 @@ static int __init macfb_init(void)
break; break;
/* Write a setpalette function for your machine, then /*
you can add something similar here. These are * Assorted weirdos
grouped by classes of video chipsets. Some of this * We think this may be like the LC II
information is from the VideoToolbox "Bugs" web */
page at
http://rajsky.psych.nyu.edu/Tips/VideoBugs.html */
/* Assorted weirdos */
/* We think this may be like the LC II */
case MAC_MODEL_LC: case MAC_MODEL_LC:
if (vidtest) { if (vidtest) {
macfb_setpalette = v8_brazil_setpalette; macfb_setpalette = v8_brazil_setpalette;
...@@ -846,7 +844,10 @@ static int __init macfb_init(void) ...@@ -846,7 +844,10 @@ static int __init macfb_init(void)
} }
strcpy(macfb_fix.id, "LC"); strcpy(macfb_fix.id, "LC");
break; break;
/* We think this may be like the LC II */
/*
* We think this may be like the LC II
*/
case MAC_MODEL_CCL: case MAC_MODEL_CCL:
if (vidtest) { if (vidtest) {
macfb_setpalette = v8_brazil_setpalette; macfb_setpalette = v8_brazil_setpalette;
...@@ -857,23 +858,29 @@ static int __init macfb_init(void) ...@@ -857,23 +858,29 @@ static int __init macfb_init(void)
strcpy(macfb_fix.id, "Color Classic"); strcpy(macfb_fix.id, "Color Classic");
break; break;
/* And we *do* mean "weirdos" */ /*
* And we *do* mean "weirdos"
*/
case MAC_MODEL_TV: case MAC_MODEL_TV:
strcpy(macfb_fix.id, "Mac TV"); strcpy(macfb_fix.id, "Mac TV");
break; break;
/* These don't have colour, so no need to worry */ /*
* These don't have colour, so no need to worry
*/
case MAC_MODEL_SE30: case MAC_MODEL_SE30:
case MAC_MODEL_CLII: case MAC_MODEL_CLII:
strcpy(macfb_fix.id, "Monochrome"); strcpy(macfb_fix.id, "Monochrome");
break; break;
/* Powerbooks are particularly difficult. Many of /*
them have separate framebuffers for external and * Powerbooks are particularly difficult. Many of
internal video, which is admittedly pretty cool, * them have separate framebuffers for external and
but will be a bit of a headache to support here. * internal video, which is admittedly pretty cool,
Also, many of them are grayscale, and we don't * but will be a bit of a headache to support here.
really support that. */ * Also, many of them are grayscale, and we don't
* really support that.
*/
case MAC_MODEL_PB140: case MAC_MODEL_PB140:
case MAC_MODEL_PB145: case MAC_MODEL_PB145:
...@@ -881,7 +888,9 @@ static int __init macfb_init(void) ...@@ -881,7 +888,9 @@ static int __init macfb_init(void)
strcpy(macfb_fix.id, "DDC"); strcpy(macfb_fix.id, "DDC");
break; break;
/* Internal is GSC, External (if present) is ViSC */ /*
* Internal is GSC, External (if present) is ViSC
*/
case MAC_MODEL_PB150: /* no external video */ case MAC_MODEL_PB150: /* no external video */
case MAC_MODEL_PB160: case MAC_MODEL_PB160:
case MAC_MODEL_PB165: case MAC_MODEL_PB165:
...@@ -891,13 +900,17 @@ static int __init macfb_init(void) ...@@ -891,13 +900,17 @@ static int __init macfb_init(void)
strcpy(macfb_fix.id, "GSC"); strcpy(macfb_fix.id, "GSC");
break; break;
/* Internal is TIM, External is ViSC */ /*
* Internal is TIM, External is ViSC
*/
case MAC_MODEL_PB165C: case MAC_MODEL_PB165C:
case MAC_MODEL_PB180C: case MAC_MODEL_PB180C:
strcpy(macfb_fix.id, "TIM"); strcpy(macfb_fix.id, "TIM");
break; break;
/* Internal is CSC, External is Keystone+Ariel. */ /*
* Internal is CSC, External is Keystone+Ariel.
*/
case MAC_MODEL_PB190: /* external video is optional */ case MAC_MODEL_PB190: /* external video is optional */
case MAC_MODEL_PB520: case MAC_MODEL_PB520:
case MAC_MODEL_PB250: case MAC_MODEL_PB250:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment