📄 macfb.c
字号:
lastreg = regno; return 0;}/* V8 and Brazil seem to use the same DAC. Sonora does as well. */static int v8_brazil_setpalette (unsigned int regno, unsigned int red, unsigned int green, unsigned int blue){ unsigned char _red =red>>8; unsigned char _green=green>>8; unsigned char _blue =blue>>8; unsigned char _regno; unsigned long flags; if (video_bpp>8) return 1; /* failsafe */ save_flags(flags); cli(); /* On these chips, the CLUT register numbers are spread out across the register space. Thus: 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 */ _regno = (regno<<(8-video_bpp)) | (0xFF>>video_bpp); writeb(_regno, &v8_brazil_cmap_regs->addr); nop(); /* send one color channel at a time */ writeb(_red, &v8_brazil_cmap_regs->lut); nop(); writeb(_green, &v8_brazil_cmap_regs->lut); nop(); writeb(_blue, &v8_brazil_cmap_regs->lut); restore_flags(flags); return 0;}static int rbv_setpalette (unsigned int regno, unsigned int red, unsigned int green, unsigned int blue){ /* use MSBs */ unsigned char _red =red>>8; unsigned char _green=green>>8; unsigned char _blue =blue>>8; unsigned char _regno; unsigned long flags; if (video_bpp>8) return 1; /* failsafe */ save_flags(flags); cli(); /* From the VideoToolbox driver. Seems to be saying that * regno #254 and #255 are the important ones for 1-bit color, * regno #252-255 are the important ones for 2-bit color, etc. */ _regno = regno + (256-(1<<video_bpp)); /* reset clut? (VideoToolbox sez "not necessary") */ writeb(0xFF, &rbv_cmap_regs->cntl); nop(); /* tell clut which address to use. */ writeb(_regno, &rbv_cmap_regs->addr); nop(); /* send one color channel at a time. */ writeb(_red, &rbv_cmap_regs->lut); nop(); writeb(_green, &rbv_cmap_regs->lut); nop(); writeb(_blue, &rbv_cmap_regs->lut); restore_flags(flags); /* done. */ return 0;}/* Macintosh Display Card (8x24) */static int mdc_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue){ volatile struct mdc_cmap_regs *cmap_regs = nubus_slot_addr(video_slot); /* use MSBs */ unsigned char _red =red>>8; unsigned char _green=green>>8; unsigned char _blue =blue>>8; unsigned char _regno=regno; unsigned long flags; save_flags(flags); cli(); /* the nop's are there to order writes. */ writeb(_regno, &cmap_regs->addr); nop(); writeb(_red, &cmap_regs->lut); nop(); writeb(_green, &cmap_regs->lut); nop(); writeb(_blue, &cmap_regs->lut); restore_flags(flags); return 0;}/* Toby frame buffer */static int toby_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue){ volatile struct toby_cmap_regs *cmap_regs = nubus_slot_addr(video_slot); /* use MSBs */ unsigned char _red =~(red>>8); unsigned char _green=~(green>>8); unsigned char _blue =~(blue>>8); unsigned char _regno = (regno<<(8-video_bpp)) | (0xFF>>video_bpp); unsigned long flags; save_flags(flags); cli(); writeb(_regno, &cmap_regs->addr); nop(); writeb(_red, &cmap_regs->lut); nop(); writeb(_green, &cmap_regs->lut); nop(); writeb(_blue, &cmap_regs->lut); restore_flags(flags); return 0;}/* Jet frame buffer */static int jet_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue){ volatile struct jet_cmap_regs *cmap_regs = nubus_slot_addr(video_slot); /* use MSBs */ unsigned char _red = (red>>8); unsigned char _green = (green>>8); unsigned char _blue = (blue>>8); unsigned long flags; save_flags(flags); cli(); writeb(regno, &cmap_regs->addr); nop(); writeb(_red, &cmap_regs->lut); nop(); writeb(_green, &cmap_regs->lut); nop(); writeb(_blue, &cmap_regs->lut); restore_flags(flags); return 0;}/* * Civic framebuffer -- Quadra AV built-in video. A chip * called Sebastian holds the actual color palettes, and * apparently, there are two different banks of 512K RAM * which can act as separate framebuffers for doing video * input and viewing the screen at the same time! The 840AV * Can add another 1MB RAM to give the two framebuffers * 1MB RAM apiece. * * FIXME: this doesn't seem to work anymore. */static int civic_setpalette (unsigned int regno, unsigned int red, unsigned int green, unsigned int blue){ static int lastreg = -1; unsigned long flags; int clut_status; if (video_bpp > 8) return 1; /* failsafe */ red >>= 8; green >>= 8; blue >>= 8; save_flags(flags); cli(); /* * Set the register address */ 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 = 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; * Then finally write the clut! */ clut_status = readb(&civic_cmap_regs->status2); if ((clut_status & 0x0008) == 0) {#if 0 if ((clut_status & 0x000D) != 0) { writeb(0x00, &civic_cmap_regs->lut); nop(); writeb(0x00, &civic_cmap_regs->lut); nop(); }#endif writeb( red, &civic_cmap_regs->lut); nop(); writeb(green, &civic_cmap_regs->lut); nop(); writeb( blue, &civic_cmap_regs->lut); nop(); writeb( 0x00, &civic_cmap_regs->lut); nop(); } else { unsigned char junk; junk = readb(&civic_cmap_regs->lut); nop(); junk = readb(&civic_cmap_regs->lut); nop(); junk = readb(&civic_cmap_regs->lut); nop(); junk = readb(&civic_cmap_regs->lut); nop(); if ((clut_status & 0x000D) != 0) { writeb(0x00, &civic_cmap_regs->lut); nop(); writeb(0x00, &civic_cmap_regs->lut); nop(); } writeb( red, &civic_cmap_regs->lut); nop(); writeb(green, &civic_cmap_regs->lut); nop(); writeb( blue, &civic_cmap_regs->lut); nop(); writeb( junk, &civic_cmap_regs->lut); nop(); } restore_flags(flags); lastreg = regno; return 0;}/* * The CSC is the framebuffer on the PowerBook 190 series * (and the 5300 too, but that's a PowerMac). This function * brought to you in part by the ECSC driver for MkLinux. */static int csc_setpalette (unsigned int regno, unsigned int red, unsigned int green, unsigned int blue){ mdelay(1); csc_cmap_regs->clut_waddr = regno; csc_cmap_regs->clut_data = red; csc_cmap_regs->clut_data = green; csc_cmap_regs->clut_data = blue; return 0;}#endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB4 || FBCON_HAS_CFB2 */static int macfb_getcolreg(unsigned regno, unsigned *red, unsigned *green, unsigned *blue, unsigned *transp, struct fb_info *fb_info){ /* * Read a single color register and split it into colors/transparent. * Return != 0 for invalid regno. */ if (regno >= video_cmap_len) return 1; *red = palette[regno].red; *green = palette[regno].green; *blue = palette[regno].blue; *transp = 0; return 0;}static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fb_info){ /* * Set a single color register. The values supplied are * already rounded down to the hardware's capabilities * (according to the entries in the `var' structure). Return * != 0 for invalid regno. */ if (regno >= video_cmap_len) return 1; palette[regno].red = red; palette[regno].green = green; palette[regno].blue = blue; switch (video_bpp) {#ifdef FBCON_HAS_MFB case 1: /* We shouldn't get here */ break;#endif#ifdef FBCON_HAS_CFB2 case 2: if (macfb_setpalette) macfb_setpalette(regno, red, green, blue); else return 1; break;#endif#ifdef FBCON_HAS_CFB4 case 4: if (macfb_setpalette) macfb_setpalette(regno, red, green, blue); else return 1; break;#endif#ifdef FBCON_HAS_CFB8 case 8: if (macfb_setpalette) macfb_setpalette(regno, red, green, blue); else return 1; break;#endif#ifdef FBCON_HAS_CFB16 case 15: case 16: /* 1:5:5:5 */ fbcon_cmap.cfb16[regno] = ((red & 0xf800) >> 1) | ((green & 0xf800) >> 6) | ((blue & 0xf800) >> 11) | ((transp != 0) << 15); break;#endif /* I'm pretty sure that one or the other of these doesn't exist on 68k Macs */#ifdef FBCON_HAS_CFB24 case 24: red >>= 8; green >>= 8; blue >>= 8; fbcon_cmap.cfb24[regno] = (red << macfb_defined.red.offset) | (green << macfb_defined.green.offset) | (blue << macfb_defined.blue.offset); break;#endif#ifdef FBCON_HAS_CFB32 case 32: red >>= 8; green >>= 8; blue >>= 8; fbcon_cmap.cfb32[regno] = (red << macfb_defined.red.offset) | (green << macfb_defined.green.offset) | (blue << macfb_defined.blue.offset); break;#endif } return 0;}static void do_install_cmap(int con, struct fb_info *info){ if (con != currcon) return; if (fb_display[con].cmap.len) fb_set_cmap(&fb_display[con].cmap, 1, macfb_setcolreg, info); else fb_set_cmap(fb_default_cmap(video_cmap_len), 1, macfb_setcolreg, info);}static int macfb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ if (con == currcon) /* current console? */ return fb_get_cmap(cmap, kspc, macfb_getcolreg, info); else if (fb_display[con].cmap.len) /* non default colormap? */ fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2); else fb_copy_cmap(fb_default_cmap(video_cmap_len), cmap, kspc ? 0 : 2); return 0;}static int macfb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info){ int err; if (!fb_display[con].cmap.len) { /* no colormap allocated? */ err = fb_alloc_cmap(&fb_display[con].cmap,video_cmap_len,0); if (err) return err; } if (con == currcon) /* current console? */ return fb_set_cmap(cmap, kspc, macfb_setcolreg, info); else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -