diff options
author | Tony Lindgren <tony@atomide.com> | 2010-03-01 23:19:05 +0100 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2010-03-01 23:19:05 +0100 |
commit | d702d12167a2c05a346f49aac7a311d597762495 (patch) | |
tree | baae42c299cce34d6df24b5d01f8b1d0b481bd9a /drivers/video | |
parent | omap2: Initialize Menelaus and MMC for N8X0 (diff) | |
parent | Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm (diff) | |
download | linux-d702d12167a2c05a346f49aac7a311d597762495.tar.xz linux-d702d12167a2c05a346f49aac7a311d597762495.zip |
Merge with mainline to remove plat-omap/Kconfig conflict
Conflicts:
arch/arm/plat-omap/Kconfig
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/aty/aty128fb.c | 14 | ||||
-rw-r--r-- | drivers/video/aty/atyfb_base.c | 10 | ||||
-rw-r--r-- | drivers/video/aty/radeon_backlight.c | 6 | ||||
-rw-r--r-- | drivers/video/efifb.c | 11 | ||||
-rw-r--r-- | drivers/video/fsl-diu-fb.c | 5 | ||||
-rw-r--r-- | drivers/video/macfb.c | 736 | ||||
-rw-r--r-- | drivers/video/macmodes.c | 80 | ||||
-rw-r--r-- | drivers/video/pvr2fb.c | 2 | ||||
-rw-r--r-- | drivers/video/sh_mobile_lcdcfb.c | 88 | ||||
-rw-r--r-- | drivers/video/valkyriefb.c | 6 | ||||
-rw-r--r-- | drivers/video/valkyriefb.h | 31 |
11 files changed, 499 insertions, 490 deletions
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index e4e4d433b007..9ee67d6da710 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c @@ -1931,22 +1931,22 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i * PowerMac2,2 summer 2000 iMacs * PowerMac4,1 january 2001 iMacs "flower power" */ - if (machine_is_compatible("PowerMac2,1") || - machine_is_compatible("PowerMac2,2") || - machine_is_compatible("PowerMac4,1")) + if (of_machine_is_compatible("PowerMac2,1") || + of_machine_is_compatible("PowerMac2,2") || + of_machine_is_compatible("PowerMac4,1")) default_vmode = VMODE_1024_768_75; /* iBook SE */ - if (machine_is_compatible("PowerBook2,2")) + if (of_machine_is_compatible("PowerBook2,2")) default_vmode = VMODE_800_600_60; /* PowerBook Firewire (Pismo), iBook Dual USB */ - if (machine_is_compatible("PowerBook3,1") || - machine_is_compatible("PowerBook4,1")) + if (of_machine_is_compatible("PowerBook3,1") || + of_machine_is_compatible("PowerBook4,1")) default_vmode = VMODE_1024_768_60; /* PowerBook Titanium */ - if (machine_is_compatible("PowerBook3,2")) + if (of_machine_is_compatible("PowerBook3,2")) default_vmode = VMODE_1152_768_60; if (default_cmode > 16) diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 1ddeb4c34763..e45ab8db2ddc 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c @@ -2439,7 +2439,7 @@ static int __devinit aty_init(struct fb_info *info) * The Apple iBook1 uses non-standard memory frequencies. * We detect it and set the frequency manually. */ - if (machine_is_compatible("PowerBook2,1")) { + if (of_machine_is_compatible("PowerBook2,1")) { par->pll_limits.mclk = 70; par->pll_limits.xclk = 53; } @@ -2659,7 +2659,7 @@ static int __devinit aty_init(struct fb_info *info) FBINFO_HWACCEL_YPAN; #ifdef CONFIG_PMAC_BACKLIGHT - if (M64_HAS(G3_PB_1_1) && machine_is_compatible("PowerBook1,1")) { + if (M64_HAS(G3_PB_1_1) && of_machine_is_compatible("PowerBook1,1")) { /* * these bits let the 101 powerbook * wake up from sleep -- paulus @@ -2690,9 +2690,9 @@ static int __devinit aty_init(struct fb_info *info) if (M64_HAS(G3_PB_1024x768)) /* G3 PowerBook with 1024x768 LCD */ default_vmode = VMODE_1024_768_60; - else if (machine_is_compatible("iMac")) + else if (of_machine_is_compatible("iMac")) default_vmode = VMODE_1024_768_75; - else if (machine_is_compatible("PowerBook2,1")) + else if (of_machine_is_compatible("PowerBook2,1")) /* iBook with 800x600 LCD */ default_vmode = VMODE_800_600_60; else @@ -3104,7 +3104,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, } dp = pci_device_to_OF_node(pdev); - if (node == dp->node) { + if (node == dp->phandle) { struct fb_var_screeninfo *var = &default_var; unsigned int N, P, Q, M, T, R; u32 v_total, h_total; diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c index 1a056adb61c8..fa1198c4ccc5 100644 --- a/drivers/video/aty/radeon_backlight.c +++ b/drivers/video/aty/radeon_backlight.c @@ -175,9 +175,9 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) #ifdef CONFIG_PMAC_BACKLIGHT pdata->negative = pdata->negative || - machine_is_compatible("PowerBook4,3") || - machine_is_compatible("PowerBook6,3") || - machine_is_compatible("PowerBook6,5"); + of_machine_is_compatible("PowerBook4,3") || + of_machine_is_compatible("PowerBook6,3") || + of_machine_is_compatible("PowerBook6,5"); #endif rinfo->info->bl_dev = bd; diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c index eb12182b2059..d25df51bb0d2 100644 --- a/drivers/video/efifb.c +++ b/drivers/video/efifb.c @@ -161,8 +161,17 @@ static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green, return 0; } +static void efifb_destroy(struct fb_info *info) +{ + if (info->screen_base) + iounmap(info->screen_base); + release_mem_region(info->aperture_base, info->aperture_size); + framebuffer_release(info); +} + static struct fb_ops efifb_ops = { .owner = THIS_MODULE, + .fb_destroy = efifb_destroy, .fb_setcolreg = efifb_setcolreg, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, @@ -281,7 +290,7 @@ static int __init efifb_probe(struct platform_device *dev) info->par = NULL; info->aperture_base = efifb_fix.smem_start; - info->aperture_size = size_total; + info->aperture_size = size_remap; info->screen_base = ioremap(efifb_fix.smem_start, efifb_fix.smem_len); if (!info->screen_base) { diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c index 72d68b3dc478..4637bcbe03a4 100644 --- a/drivers/video/fsl-diu-fb.c +++ b/drivers/video/fsl-diu-fb.c @@ -1633,6 +1633,11 @@ static int __init fsl_diu_setup(char *options) #endif static struct of_device_id fsl_diu_match[] = { +#ifdef CONFIG_PPC_MPC512x + { + .compatible = "fsl,mpc5121-diu", + }, +#endif { .compatible = "fsl,diu", }, diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c index d66887e8cbb1..43207cc6cc19 100644 --- a/drivers/video/macfb.c +++ b/drivers/video/macfb.c @@ -1,29 +1,33 @@ -/* macfb.c: Generic framebuffer for Macs whose colourmaps/modes we - don't know how to set */ - -/* (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> - - 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. - - 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 - License, version 2, or any later version, at your convenience. */ +/* + * macfb.c: Generic framebuffer for Macs whose colourmaps/modes we + * don't know how to set. + * + * (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> + * + * 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. + * + * valkyriefb.c, by Martin Costabel, Kevin Schoedel, Barry Nathan, Dan + * Jacobowitz, Paul Mackerras, Fabio Riccardi, and Geert Uytterhoeven. + * + * The VideoToolbox "Bugs" web page at + * 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/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> -#include <linux/slab.h> #include <linux/delay.h> #include <linux/nubus.h> #include <linux/init.h> @@ -31,9 +35,6 @@ #include <asm/setup.h> #include <asm/bootinfo.h> -#include <asm/uaccess.h> -#include <asm/pgtable.h> -#include <asm/irq.h> #include <asm/macintosh.h> #include <asm/io.h> @@ -44,7 +45,7 @@ #define DAFB_BASE 0xf9800200 /* 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 */ #define GSC_BASE 0x50F20000 @@ -52,37 +53,9 @@ /* CSC (Color Screen Controller) base address */ #define CSC_BASE 0x50F20000 -static int (*macfb_setpalette) (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) = NULL; -static int valkyrie_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info); -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, - struct fb_info *fb_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 { - unsigned char addr; - /* Note: word-aligned */ - char pad[3]; - unsigned char lut; -} __iomem *valkyrie_cmap_regs; +static int (*macfb_setpalette)(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info); static struct { unsigned char addr; @@ -116,15 +89,15 @@ static struct { } __iomem *civic_cmap_regs; static struct { - char pad1[0x40]; - unsigned char clut_waddr; /* 0x40 */ - char pad2; - unsigned char clut_data; /* 0x42 */ - char pad3[0x3]; - unsigned char clut_raddr; /* 0x46 */ + char pad1[0x40]; + unsigned char clut_waddr; /* 0x40 */ + char pad2; + unsigned char clut_data; /* 0x42 */ + char pad3[0x3]; + unsigned char clut_raddr; /* 0x46 */ } __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 { char pad1[0x200200]; unsigned char addr; @@ -145,13 +118,10 @@ struct jet_cmap_regs { unsigned char lut; }; -#define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */ - -/* mode */ -static int video_slot = 0; +#define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */ static struct fb_var_screeninfo macfb_defined = { - .bits_per_pixel = 8, + .bits_per_pixel = 8, .activate = FB_ACTIVATE_NOW, .width = -1, .height = -1, @@ -167,181 +137,152 @@ static struct fb_fix_screeninfo macfb_fix = { .accel = FB_ACCEL_NONE, }; +static void *slot_addr; static struct fb_info fb_info; static u32 pseudo_palette[16]; -static int inverse = 0; -static int vidtest = 0; +static int inverse; +static int vidtest; -static int valkyrie_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) -{ - unsigned long flags; - - red >>= 8; - green >>= 8; - blue >>= 8; - - local_irq_save(flags); - - /* tell clut which address to fill */ - nubus_writeb(regno, &valkyrie_cmap_regs->addr); - nop(); - - /* send one color channel at a time */ - nubus_writeb(red, &valkyrie_cmap_regs->lut); - nop(); - nubus_writeb(green, &valkyrie_cmap_regs->lut); - nop(); - nubus_writeb(blue, &valkyrie_cmap_regs->lut); - - local_irq_restore(flags); - return 0; -} - -/* Unlike the Valkyrie, the DAFB cannot set individual colormap - registers. Therefore, we do what the MacOS driver does (no - kidding!) and simply set them one by one until we hit the one we - want. */ -static int dafb_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) +/* + * Unlike the Valkyrie, the DAFB cannot set individual colormap + * registers. Therefore, we do what the MacOS driver does (no + * kidding!) and simply set them one by one until we hit the one we + * want. + */ +static int dafb_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { - /* FIXME: really, really need to use ioremap() here, - phys_to_virt() doesn't work anymore */ static int lastreg = -1; unsigned long flags; - - red >>= 8; - green >>= 8; - blue >>= 8; local_irq_save(flags); - - /* fbdev will set an entire colourmap, but X won't. Hopefully - this should accommodate both of them */ - if (regno != lastreg+1) { + + /* + * fbdev will set an entire colourmap, but X won't. Hopefully + * this should accommodate both of them + */ + if (regno != lastreg + 1) { int i; - + /* Stab in the dark trying to reset the CLUT pointer */ nubus_writel(0, &dafb_cmap_regs->reset); nop(); - + /* Loop until we get to the register we want */ 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(); - nubus_writeb(info->cmap.green[i] >> 8, &dafb_cmap_regs->lut); + nubus_writeb(info->cmap.green[i] >> 8, + &dafb_cmap_regs->lut); nop(); - nubus_writeb(info->cmap.blue[i] >> 8, &dafb_cmap_regs->lut); + nubus_writeb(info->cmap.blue[i] >> 8, + &dafb_cmap_regs->lut); nop(); } } - + nubus_writeb(red, &dafb_cmap_regs->lut); nop(); nubus_writeb(green, &dafb_cmap_regs->lut); nop(); nubus_writeb(blue, &dafb_cmap_regs->lut); - + local_irq_restore(flags); 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, - struct fb_info *info) +static int v8_brazil_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { unsigned int bpp = info->var.bits_per_pixel; - unsigned char _red =red>>8; - unsigned char _green=green>>8; - unsigned char _blue =blue>>8; - unsigned char _regno; unsigned long flags; - if (bpp > 8) return 1; /* failsafe */ + if (bpp > 8) + return 1; /* failsafe */ local_irq_save(flags); /* 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 - bpp)) | (0xFF >> bpp); - nubus_writeb(_regno, &v8_brazil_cmap_regs->addr); nop(); + * 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 - bpp)) | (0xFF >> bpp); + nubus_writeb(regno, &v8_brazil_cmap_regs->addr); + nop(); /* send one color channel at a time */ - nubus_writeb(_red, &v8_brazil_cmap_regs->lut); nop(); - nubus_writeb(_green, &v8_brazil_cmap_regs->lut); nop(); - nubus_writeb(_blue, &v8_brazil_cmap_regs->lut); + nubus_writeb(red, &v8_brazil_cmap_regs->lut); + nop(); + nubus_writeb(green, &v8_brazil_cmap_regs->lut); + nop(); + nubus_writeb(blue, &v8_brazil_cmap_regs->lut); - local_irq_restore(flags); + local_irq_restore(flags); return 0; } -static int rbv_setpalette (unsigned int regno, unsigned int red, - unsigned int green, unsigned int blue, - struct fb_info *info) +/* RAM-Based Video */ +static int rbv_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { - /* use MSBs */ - unsigned char _red =red>>8; - unsigned char _green=green>>8; - unsigned char _blue =blue>>8; - unsigned char _regno; 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); - + /* 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 << info->var.bits_per_pixel)); + regno += 256 - (1 << info->var.bits_per_pixel); /* 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. */ - nubus_writeb(_regno, &rbv_cmap_regs->addr); nop(); - + nubus_writeb(regno, &rbv_cmap_regs->addr); + nop(); + /* send one color channel at a time. */ - nubus_writeb(_red, &rbv_cmap_regs->lut); nop(); - nubus_writeb(_green, &rbv_cmap_regs->lut); nop(); - nubus_writeb(_blue, &rbv_cmap_regs->lut); - - local_irq_restore(flags); /* done. */ + nubus_writeb(red, &rbv_cmap_regs->lut); + nop(); + nubus_writeb(green, &rbv_cmap_regs->lut); + nop(); + nubus_writeb(blue, &rbv_cmap_regs->lut); + + local_irq_restore(flags); return 0; } -/* Macintosh Display Card (8x24) */ +/* Macintosh Display Card (8*24) */ static int mdc_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) { - 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; + struct mdc_cmap_regs *cmap_regs = slot_addr; unsigned long flags; local_irq_save(flags); - + /* the nop's are there to order writes. */ - nubus_writeb(_regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); nop(); - nubus_writeb(_blue, &cmap_regs->lut); + nubus_writeb(regno, &cmap_regs->addr); + nop(); + nubus_writeb(red, &cmap_regs->lut); + nop(); + nubus_writeb(green, &cmap_regs->lut); + nop(); + nubus_writeb(blue, &cmap_regs->lut); local_irq_restore(flags); return 0; @@ -350,24 +291,26 @@ static int mdc_setpalette(unsigned int regno, unsigned int red, /* Toby frame buffer */ static int toby_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, - struct fb_info *info) + struct fb_info *info) { - volatile struct toby_cmap_regs *cmap_regs = - nubus_slot_addr(video_slot); + struct toby_cmap_regs *cmap_regs = slot_addr; unsigned int bpp = info->var.bits_per_pixel; - /* use MSBs */ - unsigned char _red =~(red>>8); - unsigned char _green=~(green>>8); - unsigned char _blue =~(blue>>8); - unsigned char _regno = (regno << (8 - bpp)) | (0xFF >> bpp); unsigned long flags; + red = ~red; + green = ~green; + blue = ~blue; + regno = (regno << (8 - bpp)) | (0xFF >> bpp); + local_irq_save(flags); - - nubus_writeb(_regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); nop(); - nubus_writeb(_blue, &cmap_regs->lut); + + nubus_writeb(regno, &cmap_regs->addr); + nop(); + nubus_writeb(red, &cmap_regs->lut); + nop(); + nubus_writeb(green, &cmap_regs->lut); + nop(); + nubus_writeb(blue, &cmap_regs->lut); local_irq_restore(flags); return 0; @@ -378,20 +321,18 @@ static int jet_setpalette(unsigned int regno, unsigned int red, unsigned int green, unsigned int blue, struct fb_info *info) { - 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); + struct jet_cmap_regs *cmap_regs = slot_addr; unsigned long flags; local_irq_save(flags); - - nubus_writeb(regno, &cmap_regs->addr); nop(); - nubus_writeb(_red, &cmap_regs->lut); nop(); - nubus_writeb(_green, &cmap_regs->lut); nop(); - nubus_writeb(_blue, &cmap_regs->lut); + + nubus_writeb(regno, &cmap_regs->addr); + nop(); + nubus_writeb(red, &cmap_regs->lut); + nop(); + nubus_writeb(green, &cmap_regs->lut); + nop(); + nubus_writeb(blue, &cmap_regs->lut); local_irq_restore(flags); return 0; @@ -400,53 +341,27 @@ static int jet_setpalette(unsigned int regno, unsigned int red, /* * 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 + * 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 + * 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, - struct fb_info *info) +static int civic_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { - static int lastreg = -1; unsigned long flags; int clut_status; - if (info->var.bits_per_pixel > 8) return 1; /* failsafe */ - - red >>= 8; - green >>= 8; - blue >>= 8; + if (info->var.bits_per_pixel > 8) + return 1; /* failsafe */ local_irq_save(flags); - - /* - * Set the register address - */ - 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 + /* Set the register address */ + nubus_writeb(regno, &civic_cmap_regs->addr); + nop(); /* * Grab a status word and do some checking; @@ -459,39 +374,52 @@ static int civic_setpalette (unsigned int regno, unsigned int red, #if 0 if ((clut_status & 0x000D) != 0) { - nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); - nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); + nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); + nop(); } #endif - nubus_writeb( red, &civic_cmap_regs->lut); nop(); - nubus_writeb(green, &civic_cmap_regs->lut); nop(); - nubus_writeb( blue, &civic_cmap_regs->lut); nop(); - nubus_writeb( 0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(red, &civic_cmap_regs->lut); + nop(); + nubus_writeb(green, &civic_cmap_regs->lut); + nop(); + nubus_writeb(blue, &civic_cmap_regs->lut); + nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); } else { unsigned char junk; - junk = nubus_readb(&civic_cmap_regs->lut); nop(); - junk = nubus_readb(&civic_cmap_regs->lut); nop(); - junk = nubus_readb(&civic_cmap_regs->lut); nop(); - junk = nubus_readb(&civic_cmap_regs->lut); nop(); + junk = nubus_readb(&civic_cmap_regs->lut); + nop(); + junk = nubus_readb(&civic_cmap_regs->lut); + nop(); + junk = nubus_readb(&civic_cmap_regs->lut); + nop(); + junk = nubus_readb(&civic_cmap_regs->lut); + nop(); if ((clut_status & 0x000D) != 0) { - nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); - nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); + nop(); + nubus_writeb(0x00, &civic_cmap_regs->lut); + nop(); } - nubus_writeb( red, &civic_cmap_regs->lut); nop(); - nubus_writeb(green, &civic_cmap_regs->lut); nop(); - nubus_writeb( blue, &civic_cmap_regs->lut); nop(); - nubus_writeb( junk, &civic_cmap_regs->lut); nop(); + nubus_writeb(red, &civic_cmap_regs->lut); + nop(); + nubus_writeb(green, &civic_cmap_regs->lut); + nop(); + nubus_writeb(blue, &civic_cmap_regs->lut); + nop(); + nubus_writeb(junk, &civic_cmap_regs->lut); } local_irq_restore(flags); - lastreg = regno; return 0; } @@ -500,16 +428,21 @@ static int civic_setpalette (unsigned int regno, unsigned int red, * (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, - struct fb_info *info) +static int csc_setpalette(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + struct fb_info *info) { - mdelay(1); + unsigned long flags; + + local_irq_save(flags); + + udelay(1); /* mklinux on PB 5300 waits for 260 ns */ nubus_writeb(regno, &csc_cmap_regs->clut_waddr); - nubus_writeb(red, &csc_cmap_regs->clut_data); + nubus_writeb(red, &csc_cmap_regs->clut_data); nubus_writeb(green, &csc_cmap_regs->clut_data); - nubus_writeb(blue, &csc_cmap_regs->clut_data); + nubus_writeb(blue, &csc_cmap_regs->clut_data); + + local_irq_restore(flags); return 0; } @@ -518,10 +451,10 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, 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. + * 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 non-zero for invalid regno. */ if (regno >= fb_info->cmap.len) @@ -536,8 +469,8 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, case 4: case 8: if (macfb_setpalette) - macfb_setpalette(regno, red, green, blue, - fb_info); + macfb_setpalette(regno, red >> 8, green >> 8, + blue >> 8, fb_info); else return 1; break; @@ -555,28 +488,22 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green, } else { /* 0:5:6:5 */ ((u32*) (fb_info->pseudo_palette))[regno] = - ((red & 0xf800) ) | + ((red & 0xf800) >> 0) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11); } 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: - 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: red >>= 8; green >>= 8; blue >>= 8; ((u32 *)(fb_info->pseudo_palette))[regno] = - (red << fb_info->var.red.offset) | + (red << fb_info->var.red.offset) | (green << fb_info->var.green.offset) | (blue << fb_info->var.blue.offset); break; @@ -597,25 +524,24 @@ static struct fb_ops macfb_ops = { static void __init macfb_setup(char *options) { char *this_opt; - + if (!options || !*options) return; - + while ((this_opt = strsep(&options, ",")) != NULL) { - if (!*this_opt) continue; - - if (! strcmp(this_opt, "inverse")) - inverse=1; - /* This means "turn on experimental CLUT code" */ - else if (!strcmp(this_opt, "vidtest")) - vidtest=1; + if (!*this_opt) + continue; + + if (!strcmp(this_opt, "inverse")) + inverse = 1; + else + if (!strcmp(this_opt, "vidtest")) + vidtest = 1; /* enable experimental CLUT code */ } } static void __init iounmap_macfb(void) { - if (valkyrie_cmap_regs) - iounmap(valkyrie_cmap_regs); if (dafb_cmap_regs) iounmap(dafb_cmap_regs); if (v8_brazil_cmap_regs) @@ -642,48 +568,55 @@ static int __init macfb_init(void) if (!MACH_IS_MAC) return -ENODEV; - /* There can only be one internal video controller anyway so - we're not too worried about this */ + if (mac_bi_data.id == MAC_MODEL_Q630 || + mac_bi_data.id == MAC_MODEL_P588) + return -ENODEV; /* See valkyriefb.c */ + macfb_defined.xres = mac_bi_data.dimensions & 0xFFFF; macfb_defined.yres = mac_bi_data.dimensions >> 16; macfb_defined.bits_per_pixel = mac_bi_data.videodepth; + 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) */ - 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 - 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); - - 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); - 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_fix.smem_start = mac_bi_data.videoaddr; + /* - * Fill in the available video resolution + * 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 + * way to ensure that this driver will work on every possible Mac */ - - macfb_defined.xres_virtual = macfb_defined.xres; - macfb_defined.yres_virtual = macfb_defined.yres; - macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres); - macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres); + fb_info.screen_base = ioremap(mac_bi_data.videoaddr, + macfb_fix.smem_len); + if (!fb_info.screen_base) + return -ENODEV; - printk("macfb: scrolling: redraw\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); + 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); + + /* Fill in the available video resolution */ + macfb_defined.xres_virtual = macfb_defined.xres; macfb_defined.yres_virtual = macfb_defined.yres; + macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres); + macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres); - /* some dummy values for timing to make fbset happy */ - macfb_defined.pixclock = 10000000 / macfb_defined.xres * 1000 / macfb_defined.yres; + /* Some dummy values for timing to make fbset happy */ + macfb_defined.pixclock = 10000000 / macfb_defined.xres * + 1000 / macfb_defined.yres; macfb_defined.left_margin = (macfb_defined.xres / 8) & 0xf8; macfb_defined.hsync_len = (macfb_defined.xres / 8) & 0xf8; switch (macfb_defined.bits_per_pixel) { 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.green.length = macfb_defined.bits_per_pixel; macfb_defined.blue.length = macfb_defined.bits_per_pixel; @@ -708,53 +641,52 @@ static int __init macfb_init(void) macfb_defined.green.length = 5; macfb_defined.blue.offset = 0; macfb_defined.blue.length = 5; - printk("macfb: directcolor: " - "size=1:5:5:5, shift=15:10:5:0\n"); 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; break; case 24: 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.length = 8; macfb_defined.green.offset = 8; macfb_defined.green.length = 8; macfb_defined.blue.offset = 0; macfb_defined.blue.length = 8; - printk("macfb: truecolor: " - "size=0:8:8:8, shift=0:16:8:0\n"); video_cmap_len = 16; macfb_fix.visual = FB_VISUAL_TRUECOLOR; + break; default: video_cmap_len = 0; 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; } - /* Hardware dependent stuff */ - /* We take a wild guess that if the video physical address is - * in nubus slot space, that the nubus card is driving video. - * Penguin really ought to tell us whether we are using internal - * video or not. + /* + * We take a wild guess that if the video physical address is + * in nubus slot space, that the nubus card is driving video. + * Penguin really ought to tell us whether we are using internal + * 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)) - != NULL) + while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY, + NUBUS_TYPE_VIDEO, ndev))) { - if (!(mac_bi_data.videoaddr >= ndev->board->slot_addr - && (mac_bi_data.videoaddr < - (unsigned long)nubus_slot_addr(ndev->board->slot+1)))) + unsigned long base = ndev->board->slot_addr; + + if (mac_bi_data.videoaddr < base || + mac_bi_data.videoaddr - base > 0xFFFFFF) continue; + video_is_nubus = 1; - /* We should probably just use the slot address... */ - video_slot = ndev->board->slot; + slot_addr = (unsigned char *)base; switch(ndev->dr_hw) { case NUBUS_DRHW_APPLE_MDC: @@ -771,7 +703,7 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "Jet"); macfb_setpalette = jet_setpalette; macfb_defined.activate = FB_ACTIVATE_NOW; - break; + break; default: strcpy(macfb_fix.id, "Generic NuBus"); break; @@ -779,30 +711,19 @@ static int __init macfb_init(void) } /* 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) - switch( mac_bi_data.id ) - { - /* Valkyrie Quadras */ - case MAC_MODEL_Q630: - /* I'm not sure about this one */ - case MAC_MODEL_P588: - strcpy(macfb_fix.id, "Valkyrie"); - macfb_setpalette = valkyrie_setpalette; - macfb_defined.activate = FB_ACTIVATE_NOW; - valkyrie_cmap_regs = ioremap(DAC_BASE, 0x1000); - break; - - /* DAFB Quadras */ - /* Note: these first four have the v7 DAFB, which is - known to be rather unlike the ones used in the - other models */ + switch (mac_bi_data.id) { + /* + * DAFB Quadras + * Note: these first four have the v7 DAFB, which is + * known to be rather unlike the ones used in the + * other models + */ case MAC_MODEL_P475: case MAC_MODEL_P475F: case MAC_MODEL_P575: case MAC_MODEL_Q605: - + case MAC_MODEL_Q800: case MAC_MODEL_Q650: case MAC_MODEL_Q610: @@ -817,17 +738,21 @@ static int __init macfb_init(void) dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000); break; - /* LC II uses the V8 framebuffer */ + /* + * LC II uses the V8 framebuffer + */ case MAC_MODEL_LCII: strcpy(macfb_fix.id, "V8"); macfb_setpalette = v8_brazil_setpalette; macfb_defined.activate = FB_ACTIVATE_NOW; v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); break; - - /* IIvi, IIvx use the "Brazil" framebuffer (which is - very much like the V8, it seems, and probably uses - the same DAC) */ + + /* + * IIvi, IIvx use the "Brazil" framebuffer (which is + * very much like the V8, it seems, and probably uses + * the same DAC) + */ case MAC_MODEL_IIVI: case MAC_MODEL_IIVX: case MAC_MODEL_P600: @@ -836,12 +761,14 @@ static int __init macfb_init(void) macfb_defined.activate = FB_ACTIVATE_NOW; v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); break; - - /* LC III (and friends) use the Sonora framebuffer */ - /* Incidentally this is also used in the non-AV models - of the x100 PowerMacs */ - /* These do in fact seem to use the same DAC interface - as the LC II. */ + + /* + * LC III (and friends) use the Sonora framebuffer + * Incidentally this is also used in the non-AV models + * of the x100 PowerMacs + * These do in fact seem to use the same DAC interface + * as the LC II. + */ case MAC_MODEL_LCIII: case MAC_MODEL_P520: case MAC_MODEL_P550: @@ -852,9 +779,11 @@ static int __init macfb_init(void) v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); break; - /* IIci and IIsi use the infamous RBV chip - (the IIsi is just a rebadged and crippled - IIci in a different case, BTW) */ + /* + * IIci and IIsi use the infamous RBV chip + * (the IIsi is just a rebadged and crippled + * IIci in a different case, BTW) + */ case MAC_MODEL_IICI: case MAC_MODEL_IISI: macfb_setpalette = rbv_setpalette; @@ -863,7 +792,9 @@ static int __init macfb_init(void) rbv_cmap_regs = ioremap(DAC_BASE, 0x1000); break; - /* AVs use the Civic framebuffer */ + /* + * AVs use the Civic framebuffer + */ case MAC_MODEL_Q840: case MAC_MODEL_C660: macfb_setpalette = civic_setpalette; @@ -873,15 +804,10 @@ static int __init macfb_init(void) break; - /* Write a setpalette function for your machine, then - you can add something similar here. These are - grouped by classes of video chipsets. Some of this - 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 */ + /* + * Assorted weirdos + * We think this may be like the LC II + */ case MAC_MODEL_LC: if (vidtest) { macfb_setpalette = v8_brazil_setpalette; @@ -891,7 +817,10 @@ static int __init macfb_init(void) } strcpy(macfb_fix.id, "LC"); break; - /* We think this may be like the LC II */ + + /* + * We think this may be like the LC II + */ case MAC_MODEL_CCL: if (vidtest) { macfb_setpalette = v8_brazil_setpalette; @@ -902,31 +831,42 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "Color Classic"); break; - /* And we *do* mean "weirdos" */ + /* + * And we *do* mean "weirdos" + */ case MAC_MODEL_TV: strcpy(macfb_fix.id, "Mac TV"); 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_CLII: strcpy(macfb_fix.id, "Monochrome"); break; - /* Powerbooks are particularly difficult. Many of - them have separate framebuffers for external and - internal video, which is admittedly pretty cool, - but will be a bit of a headache to support here. - Also, many of them are grayscale, and we don't - really support that. */ - + /* + * Powerbooks are particularly difficult. Many of + * them have separate framebuffers for external and + * internal video, which is admittedly pretty cool, + * but will be a bit of a headache to support here. + * Also, many of them are grayscale, and we don't + * really support that. + */ + + /* + * Slot 0 ROM says TIM. No external video. B&W. + */ case MAC_MODEL_PB140: case MAC_MODEL_PB145: case MAC_MODEL_PB170: strcpy(macfb_fix.id, "DDC"); 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_PB160: case MAC_MODEL_PB165: @@ -936,13 +876,17 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "GSC"); break; - /* Internal is TIM, External is ViSC */ + /* + * Internal is TIM, External is ViSC + */ case MAC_MODEL_PB165C: case MAC_MODEL_PB180C: strcpy(macfb_fix.id, "TIM"); 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_PB520: case MAC_MODEL_PB250: @@ -954,7 +898,7 @@ static int __init macfb_init(void) strcpy(macfb_fix.id, "CSC"); csc_cmap_regs = ioremap(CSC_BASE, 0x1000); break; - + default: strcpy(macfb_fix.id, "Unknown"); break; @@ -969,7 +913,7 @@ static int __init macfb_init(void) err = fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0); if (err) goto fail_unmap; - + err = register_framebuffer(&fb_info); if (err) goto fail_dealloc; diff --git a/drivers/video/macmodes.c b/drivers/video/macmodes.c index 083f60321ed8..af86c081d2be 100644 --- a/drivers/video/macmodes.c +++ b/drivers/video/macmodes.c @@ -33,6 +33,10 @@ static const struct fb_videomode mac_modedb[] = { { + /* 512x384, 60Hz, Non-Interlaced (15.67 MHz dot clock) */ + "mac2", 60, 512, 384, 63828, 80, 16, 19, 1, 32, 3, + 0, FB_VMODE_NONINTERLACED + }, { /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */ "mac5", 60, 640, 480, 39722, 32, 32, 33, 10, 96, 2, 0, FB_VMODE_NONINTERLACED @@ -41,6 +45,10 @@ static const struct fb_videomode mac_modedb[] = { "mac6", 67, 640, 480, 33334, 80, 80, 39, 3, 64, 3, 0, FB_VMODE_NONINTERLACED }, { + /* 640x870, 75Hz (portrait), Non-Interlaced (57.28 MHz dot clock) */ + "mac7", 75, 640, 870, 17457, 80, 32, 42, 3, 80, 3, + 0, FB_VMODE_NONINTERLACED + }, { /* 800x600, 56 Hz, Non-Interlaced (36.00 MHz dotclock) */ "mac9", 56, 800, 600, 27778, 112, 40, 22, 1, 72, 2, FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED @@ -105,10 +113,6 @@ static const struct fb_videomode mac_modedb[] = { "mac1", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen, sync, FB_VMODE_INTERLACED }, { - /* VMODE_512_384_60: 512x384, 60Hz, Non-Interlaced */ - "mac2", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen, - sync, FB_VMODE_NONINTERLACED - }, { /* VMODE_640_480_50I: 640x480, 50Hz, Interlaced (PAL) */ "mac3", 50, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, sync, FB_VMODE_INTERLACED @@ -117,10 +121,6 @@ static const struct fb_videomode mac_modedb[] = { "mac4", 60, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, sync, FB_VMODE_INTERLACED }, { - /* VMODE_640_870_75P: 640x870, 75Hz (portrait), Non-Interlaced */ - "mac7", 75, 640, 870, pixclock, left, right, upper, lower, hslen, vslen, - sync, FB_VMODE_NONINTERLACED - }, { /* VMODE_768_576_50I: 768x576, 50Hz (PAL full frame), Interlaced */ "mac8", 50, 768, 576, pixclock, left, right, upper, lower, hslen, vslen, sync, FB_VMODE_INTERLACED @@ -134,38 +134,42 @@ static const struct fb_videomode mac_modedb[] = { * * These MUST be ordered in * - increasing resolution - * - decreasing refresh rate + * - decreasing pixel clock period */ static const struct mode_map { int vmode; const struct fb_videomode *mode; } mac_modes[] = { + /* 512x384 */ + { VMODE_512_384_60, &mac_modedb[0] }, /* 640x480 */ - { VMODE_640_480_67, &mac_modedb[1] }, - { VMODE_640_480_60, &mac_modedb[0] }, + { VMODE_640_480_60, &mac_modedb[1] }, + { VMODE_640_480_67, &mac_modedb[2] }, + /* 640x870 */ + { VMODE_640_870_75P, &mac_modedb[3] }, /* 800x600 */ - { VMODE_800_600_75, &mac_modedb[5] }, - { VMODE_800_600_72, &mac_modedb[4] }, - { VMODE_800_600_60, &mac_modedb[3] }, - { VMODE_800_600_56, &mac_modedb[2] }, + { VMODE_800_600_56, &mac_modedb[4] }, + { VMODE_800_600_60, &mac_modedb[5] }, + { VMODE_800_600_75, &mac_modedb[7] }, + { VMODE_800_600_72, &mac_modedb[6] }, /* 832x624 */ - { VMODE_832_624_75, &mac_modedb[6] }, + { VMODE_832_624_75, &mac_modedb[8] }, /* 1024x768 */ - { VMODE_1024_768_75, &mac_modedb[10] }, - { VMODE_1024_768_75V, &mac_modedb[9] }, - { VMODE_1024_768_70, &mac_modedb[8] }, - { VMODE_1024_768_60, &mac_modedb[7] }, + { VMODE_1024_768_60, &mac_modedb[9] }, + { VMODE_1024_768_70, &mac_modedb[10] }, + { VMODE_1024_768_75V, &mac_modedb[11] }, + { VMODE_1024_768_75, &mac_modedb[12] }, /* 1152x768 */ - { VMODE_1152_768_60, &mac_modedb[14] }, + { VMODE_1152_768_60, &mac_modedb[16] }, /* 1152x870 */ - { VMODE_1152_870_75, &mac_modedb[11] }, + { VMODE_1152_870_75, &mac_modedb[13] }, /* 1280x960 */ - { VMODE_1280_960_75, &mac_modedb[12] }, + { VMODE_1280_960_75, &mac_modedb[14] }, /* 1280x1024 */ - { VMODE_1280_1024_75, &mac_modedb[13] }, + { VMODE_1280_1024_75, &mac_modedb[15] }, /* 1600x1024 */ - { VMODE_1600_1024_60, &mac_modedb[15] }, + { VMODE_1600_1024_60, &mac_modedb[17] }, { -1, NULL } }; @@ -299,7 +303,6 @@ EXPORT_SYMBOL(mac_vmode_to_var); int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, int *cmode) { - const struct fb_videomode *mode = NULL; const struct mode_map *map; if (var->bits_per_pixel <= 8) @@ -311,8 +314,13 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, else return -EINVAL; + /* + * Find the mac_mode with a matching resolution or failing that, the + * closest larger resolution. Skip modes with a shorter pixel clock period. + */ for (map = mac_modes; map->vmode != -1; map++) { - mode = map->mode; + const struct fb_videomode *mode = map->mode; + if (var->xres > mode->xres || var->yres > mode->yres) continue; if (var->xres_virtual > mode->xres || var->yres_virtual > mode->yres) @@ -322,6 +330,24 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, if ((var->vmode & FB_VMODE_MASK) != mode->vmode) continue; *vmode = map->vmode; + + /* + * Having found a good resolution, find the matching pixel clock + * or failing that, the closest longer pixel clock period. + */ + map++; + while (map->vmode != -1) { + const struct fb_videomode *clk_mode = map->mode; + + if (mode->xres != clk_mode->xres || mode->yres != clk_mode->yres) + break; + if (var->pixclock > mode->pixclock) + break; + if (mode->vmode != clk_mode->vmode) + continue; + *vmode = map->vmode; + map++; + } return 0; } return -EINVAL; diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c index 53f8f1100e81..f9975100d56d 100644 --- a/drivers/video/pvr2fb.c +++ b/drivers/video/pvr2fb.c @@ -831,7 +831,7 @@ static int __devinit pvr2fb_common_init(void) printk(KERN_NOTICE "fb%d: registering with SQ API\n", fb_info->node); pvr2fb_map = sq_remap(fb_info->fix.smem_start, fb_info->fix.smem_len, - fb_info->fix.id, pgprot_val(PAGE_SHARED)); + fb_info->fix.id, PAGE_SHARED); printk(KERN_NOTICE "fb%d: Mapped video memory to SQ addr 0x%lx\n", fb_info->node, pvr2fb_map); diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c index a69830d26f7f..8d7653e56df5 100644 --- a/drivers/video/sh_mobile_lcdcfb.c +++ b/drivers/video/sh_mobile_lcdcfb.c @@ -19,6 +19,7 @@ #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/vmalloc.h> +#include <linux/ioctl.h> #include <video/sh_mobile_lcdc.h> #include <asm/atomic.h> @@ -106,6 +107,7 @@ static unsigned long lcdc_offs_sublcd[NR_CH_REGS] = { #define LDRCNTR_SRC 0x00010000 #define LDRCNTR_MRS 0x00000002 #define LDRCNTR_MRC 0x00000001 +#define LDSR_MRS 0x00000100 struct sh_mobile_lcdc_priv; struct sh_mobile_lcdc_chan { @@ -122,8 +124,8 @@ struct sh_mobile_lcdc_chan { struct scatterlist *sglist; unsigned long frame_end; unsigned long pan_offset; - unsigned long new_pan_offset; wait_queue_head_t frame_end_wait; + struct completion vsync_completion; }; struct sh_mobile_lcdc_priv { @@ -366,19 +368,8 @@ static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data) } /* VSYNC End */ - if (ldintr & LDINTR_VES) { - unsigned long ldrcntr = lcdc_read(priv, _LDRCNTR); - /* Set the source address for the next refresh */ - lcdc_write_chan_mirror(ch, LDSA1R, ch->dma_handle + - ch->new_pan_offset); - if (lcdc_chan_is_sublcd(ch)) - lcdc_write(ch->lcdc, _LDRCNTR, - ldrcntr ^ LDRCNTR_SRS); - else - lcdc_write(ch->lcdc, _LDRCNTR, - ldrcntr ^ LDRCNTR_MRS); - ch->pan_offset = ch->new_pan_offset; - } + if (ldintr & LDINTR_VES) + complete(&ch->vsync_completion); } return IRQ_HANDLED; @@ -767,25 +758,69 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { struct sh_mobile_lcdc_chan *ch = info->par; + struct sh_mobile_lcdc_priv *priv = ch->lcdc; + unsigned long ldrcntr; + unsigned long new_pan_offset; + + new_pan_offset = (var->yoffset * info->fix.line_length) + + (var->xoffset * (info->var.bits_per_pixel / 8)); - if (info->var.xoffset == var->xoffset && - info->var.yoffset == var->yoffset) + if (new_pan_offset == ch->pan_offset) return 0; /* No change, do nothing */ - ch->new_pan_offset = (var->yoffset * info->fix.line_length) + - (var->xoffset * (info->var.bits_per_pixel / 8)); + ldrcntr = lcdc_read(priv, _LDRCNTR); - if (ch->new_pan_offset != ch->pan_offset) { - unsigned long ldintr; - ldintr = lcdc_read(ch->lcdc, _LDINTR); - ldintr |= LDINTR_VEE; - lcdc_write(ch->lcdc, _LDINTR, ldintr); - sh_mobile_lcdc_deferred_io_touch(info); - } + /* Set the source address for the next refresh */ + lcdc_write_chan_mirror(ch, LDSA1R, ch->dma_handle + new_pan_offset); + if (lcdc_chan_is_sublcd(ch)) + lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_SRS); + else + lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_MRS); + + ch->pan_offset = new_pan_offset; + + sh_mobile_lcdc_deferred_io_touch(info); + + return 0; +} + +static int sh_mobile_wait_for_vsync(struct fb_info *info) +{ + struct sh_mobile_lcdc_chan *ch = info->par; + unsigned long ldintr; + int ret; + + /* Enable VSync End interrupt */ + ldintr = lcdc_read(ch->lcdc, _LDINTR); + ldintr |= LDINTR_VEE; + lcdc_write(ch->lcdc, _LDINTR, ldintr); + + ret = wait_for_completion_interruptible_timeout(&ch->vsync_completion, + msecs_to_jiffies(100)); + if (!ret) + return -ETIMEDOUT; return 0; } +static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd, + unsigned long arg) +{ + int retval; + + switch (cmd) { + case FBIO_WAITFORVSYNC: + retval = sh_mobile_wait_for_vsync(info); + break; + + default: + retval = -ENOIOCTLCMD; + break; + } + return retval; +} + + static struct fb_ops sh_mobile_lcdc_ops = { .owner = THIS_MODULE, .fb_setcolreg = sh_mobile_lcdc_setcolreg, @@ -795,6 +830,7 @@ static struct fb_ops sh_mobile_lcdc_ops = { .fb_copyarea = sh_mobile_lcdc_copyarea, .fb_imageblit = sh_mobile_lcdc_imageblit, .fb_pan_display = sh_mobile_fb_pan_display, + .fb_ioctl = sh_mobile_ioctl, }; static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp) @@ -962,8 +998,8 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) goto err1; } init_waitqueue_head(&priv->ch[i].frame_end_wait); + init_completion(&priv->ch[i].vsync_completion); priv->ch[j].pan_offset = 0; - priv->ch[j].new_pan_offset = 0; switch (pdata->ch[i].chan) { case LCDC_CHAN_MAINLCD: diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c index 4bb9a0b18950..6b52bf65f0b5 100644 --- a/drivers/video/valkyriefb.c +++ b/drivers/video/valkyriefb.c @@ -69,7 +69,7 @@ #ifdef CONFIG_MAC /* We don't yet have functions to read the PRAM... perhaps we can adapt them from the PPC code? */ -static int default_vmode = VMODE_640_480_67; +static int default_vmode = VMODE_CHOOSE; static int default_cmode = CMODE_8; #else static int default_vmode = VMODE_NVRAM; @@ -326,11 +326,11 @@ int __init valkyriefb_init(void) #ifdef CONFIG_MAC if (!MACH_IS_MAC) - return 0; + return -ENODEV; if (!(mac_bi_data.id == MAC_MODEL_Q630 /* I'm not sure about this one */ || mac_bi_data.id == MAC_MODEL_P588)) - return 0; + return -ENODEV; /* Hardcoded addresses... welcome to 68k Macintosh country :-) */ frame_buffer_phys = 0xf9000000; diff --git a/drivers/video/valkyriefb.h b/drivers/video/valkyriefb.h index 97aaf7bb6417..d787441e5a42 100644 --- a/drivers/video/valkyriefb.h +++ b/drivers/video/valkyriefb.h @@ -134,15 +134,7 @@ static struct valkyrie_regvals valkyrie_reg_init_14 = { { 1024, 0 }, 1024, 768 }; - -/* Register values for 800x600, 72Hz mode (11) */ -static struct valkyrie_regvals valkyrie_reg_init_11 = { - 13, - { 17, 27, 3 }, /* pixel clock = 49.63MHz for V=71.66Hz */ - { 800, 0 }, - 800, 600 -}; -#endif /* CONFIG_MAC */ +#endif /* !defined CONFIG_MAC */ /* Register values for 832x624, 75Hz mode (13) */ static struct valkyrie_regvals valkyrie_reg_init_13 = { @@ -152,6 +144,14 @@ static struct valkyrie_regvals valkyrie_reg_init_13 = { 832, 624 }; +/* Register values for 800x600, 72Hz mode (11) */ +static struct valkyrie_regvals valkyrie_reg_init_11 = { + 13, + { 17, 27, 3 }, /* pixel clock = 49.63MHz for V=71.66Hz */ + { 800, 0 }, + 800, 600 +}; + /* Register values for 800x600, 60Hz mode (10) */ static struct valkyrie_regvals valkyrie_reg_init_10 = { 12, @@ -188,24 +188,13 @@ static struct valkyrie_regvals *valkyrie_reg_init[VMODE_MAX] = { NULL, NULL, &valkyrie_reg_init_10, -#ifdef CONFIG_MAC - NULL, - NULL, - &valkyrie_reg_init_13, - NULL, - NULL, - NULL, - NULL, -#else &valkyrie_reg_init_11, NULL, &valkyrie_reg_init_13, +#ifndef CONFIG_MAC &valkyrie_reg_init_14, &valkyrie_reg_init_15, NULL, &valkyrie_reg_init_17, #endif - NULL, - NULL, - NULL }; |