Commit 7cb3c483 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] sh: sh-specific framebuffer updates

From: Paul Mundt <lethal@linux-sh.org>

This includes sh-specific framebuffer updates, including updates to hitfb and
pvr2fb, as well as adding sh to the pgprot_writecombine() users in fb_mmap().
parent ddb9a23b
...@@ -1181,11 +1181,9 @@ fb_mmap(struct file *file, struct vm_area_struct * vma) ...@@ -1181,11 +1181,9 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
#elif defined(__mips__) #elif defined(__mips__)
pgprot_val(vma->vm_page_prot) &= ~_CACHE_MASK; pgprot_val(vma->vm_page_prot) &= ~_CACHE_MASK;
pgprot_val(vma->vm_page_prot) |= _CACHE_UNCACHED; pgprot_val(vma->vm_page_prot) |= _CACHE_UNCACHED;
#elif defined(__sh__)
pgprot_val(vma->vm_page_prot) &= ~_PAGE_CACHABLE;
#elif defined(__hppa__) #elif defined(__hppa__)
pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
#elif defined(__ia64__) || defined(__arm__) #elif defined(__ia64__) || defined(__arm__) || defined(__sh__)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
#else #else
#warning What do we have to do here?? #warning What do we have to do here??
......
/* /*
* $Id: hitfb.c,v 1.10 2004/02/01 19:46:04 lethal Exp $ * $Id: hitfb.c,v 1.12 2004/03/16 00:07:51 lethal Exp $
* linux/drivers/video/hitfb.c -- Hitachi LCD frame buffer device * linux/drivers/video/hitfb.c -- Hitachi LCD frame buffer device
* (C) 1999 Mihai Spatar * (C) 1999 Mihai Spatar
* (C) 2000 YAEGASHI Takeshi * (C) 2000 YAEGASHI Takeshi
* (C) 2003, 2004 Paul Mundt * (C) 2003, 2004 Paul Mundt
* (C) 2003 Andriy Skulysh * (C) 2003, 2004 Andriy Skulysh
* *
* This file is subject to the terms and conditions of the GNU General Public * This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for * License. See the file COPYING in the main directory of this archive for
* more details. * more details.
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -30,139 +30,137 @@ ...@@ -30,139 +30,137 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/hd64461/hd64461.h> #include <asm/hd64461/hd64461.h>
#ifdef MACH_HP600
#include <asm/cpu/dac.h>
#include <asm/hp6xx/hp6xx.h>
#endif
#define WIDTH 640
static struct fb_var_screeninfo hitfb_var __initdata = { static struct fb_var_screeninfo hitfb_var __initdata = {
.activate = FB_ACTIVATE_NOW, .activate = FB_ACTIVATE_NOW,
.height = -1, .height = -1,
.width = -1, .width = -1,
.vmode = FB_VMODE_NONINTERLACED, .vmode = FB_VMODE_NONINTERLACED,
}; };
static struct fb_fix_screeninfo hitfb_fix __initdata = { static struct fb_fix_screeninfo hitfb_fix __initdata = {
.id = "Hitachi HD64461", .id = "Hitachi HD64461",
.type = FB_TYPE_PACKED_PIXELS, .type = FB_TYPE_PACKED_PIXELS,
.ypanstep = 8, .ypanstep = 8,
.accel = FB_ACCEL_NONE, .accel = FB_ACCEL_NONE,
}; };
static u32 pseudo_palette[16]; static u32 pseudo_palette[16];
static struct fb_info fb_info; static struct fb_info fb_info;
static inline void hitfb_accel_wait(void)
#define WIDTH 640
static void hitfb_set_base(u32 offset)
{
fb_writew(offset>>10,HD64461_LCDCBAR);
}
static inline void hitfb_accel_wait()
{ {
while (fb_readw(HD64461_GRCFGR) & HD64461_GRCFGR_ACCSTATUS) while (fb_readw(HD64461_GRCFGR) & HD64461_GRCFGR_ACCSTATUS) ;
;
} }
static inline void hitfb_accel_start(int truecolor) static inline void hitfb_accel_start(int truecolor)
{ {
if (truecolor) { if (truecolor) {
fb_writew(6,HD64461_GRCFGR); fb_writew(6, HD64461_GRCFGR);
} else { } else {
fb_writew(7,HD64461_GRCFGR); fb_writew(7, HD64461_GRCFGR);
} }
} }
static inline void hitfb_accel_set_dest(int truecolor, u16 dx, u16 dy, static inline void hitfb_accel_set_dest(int truecolor, u16 dx, u16 dy,
u16 width, u16 height) u16 width, u16 height)
{ {
u32 saddr=WIDTH*dy+dx; u32 saddr = WIDTH * dy + dx;
if (truecolor) if (truecolor)
saddr <<= 1; saddr <<= 1;
fb_writew(width,HD64461_BBTDWR); fb_writew(width, HD64461_BBTDWR);
fb_writew(height,HD64461_BBTDHR); fb_writew(height, HD64461_BBTDHR);
fb_writew(saddr&0xffff,HD64461_BBTDSARL); fb_writew(saddr & 0xffff, HD64461_BBTDSARL);
fb_writew(saddr>>16,HD64461_BBTDSARH); fb_writew(saddr >> 16, HD64461_BBTDSARH);
} }
static inline void hitfb_accel_solidfill(int truecolor, u16 dx, u16 dy, static inline void hitfb_accel_solidfill(int truecolor, u16 dx, u16 dy,
u16 width, u16 height, u16 color) u16 width, u16 height, u16 color)
{ {
hitfb_accel_set_dest(truecolor,dx,dy,width,height); hitfb_accel_set_dest(truecolor, dx, dy, width, height);
fb_writew(0x00f0,HD64461_BBTROPR); fb_writew(0x00f0, HD64461_BBTROPR);
fb_writew(16,HD64461_BBTMDR); fb_writew(16, HD64461_BBTMDR);
fb_writew(color,HD64461_GRSCR); fb_writew(color, HD64461_GRSCR);
hitfb_accel_start(truecolor); hitfb_accel_start(truecolor);
} }
static inline void hitfb_accel_bitblt(int truecolor, u16 sx, u16 sy, u16 dx, u16 dy, static inline void hitfb_accel_bitblt(int truecolor, u16 sx, u16 sy, u16 dx,
u16 width, u16 height, u16 rop, u32 mask_addr) u16 dy, u16 width, u16 height, u16 rop,
u32 mask_addr)
{ {
u32 saddr,daddr; u32 saddr, daddr;
u32 maddr=0; u32 maddr = 0;
fb_writew(rop,HD64461_BBTROPR);
if((sy<dy)||((sy==dy)&&(sx<=dx))) {
saddr=WIDTH*(sy+height)+sx+width;
daddr=WIDTH*(dy+height)+dx+width;
fb_writew(rop, HD64461_BBTROPR);
if ((sy < dy) || ((sy == dy) && (sx <= dx))) {
saddr = WIDTH * (sy + height) + sx + width;
daddr = WIDTH * (dy + height) + dx + width;
if (mask_addr) { if (mask_addr) {
if (truecolor) { if (truecolor)
maddr=((width>>3)+1)*(height+1)-1; maddr = ((width >> 3) + 1) * (height + 1) - 1;
} else { else
maddr=(((width>>4)+1)*(height+1)-1)*2; maddr =
} (((width >> 4) + 1) * (height + 1) - 1) * 2;
fb_writew((1<<5)|1,HD64461_BBTMDR); fb_writew((1 << 5) | 1, HD64461_BBTMDR);
} else { } else
fb_writew(1,HD64461_BBTMDR); fb_writew(1, HD64461_BBTMDR);
}
} else { } else {
saddr=WIDTH*sy+sx; saddr = WIDTH * sy + sx;
daddr=WIDTH*dy+dx; daddr = WIDTH * dy + dx;
if (mask_addr) { if (mask_addr) {
fb_writew((1<<5),HD64461_BBTMDR); fb_writew((1 << 5), HD64461_BBTMDR);
} else { } else {
outw(0,HD64461_BBTMDR); fb_writew(0, HD64461_BBTMDR);
} }
} }
if (truecolor) { if (truecolor) {
saddr<<=1; saddr <<= 1;
daddr<<=1; daddr <<= 1;
} }
fb_writew(width, HD64461_BBTDWR);
fb_writew(width,HD64461_BBTDWR); fb_writew(height, HD64461_BBTDHR);
fb_writew(height,HD64461_BBTDHR); fb_writew(saddr & 0xffff, HD64461_BBTSSARL);
fb_writew(saddr&0xffff,HD64461_BBTSSARL); fb_writew(saddr >> 16, HD64461_BBTSSARH);
fb_writew(saddr>>16,HD64461_BBTSSARH); fb_writew(daddr & 0xffff, HD64461_BBTDSARL);
fb_writew(daddr&0xffff,HD64461_BBTDSARL); fb_writew(daddr >> 16, HD64461_BBTDSARH);
fb_writew(daddr>>16,HD64461_BBTDSARH);
if (mask_addr) { if (mask_addr) {
maddr+=mask_addr; maddr += mask_addr;
fb_writew(maddr&0xffff,HD64461_BBTMARL); fb_writew(maddr & 0xffff, HD64461_BBTMARL);
fb_writew(maddr>>16,HD64461_BBTMARH); fb_writew(maddr >> 16, HD64461_BBTMARH);
} }
hitfb_accel_start(truecolor); hitfb_accel_start(truecolor);
} }
static void hitfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect) static void hitfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
{ {
if (rect->rop != ROP_COPY) { if (rect->rop != ROP_COPY)
cfb_fillrect(p,rect); cfb_fillrect(p, rect);
} else { else {
fb_writew(0x00f0,HD64461_BBTROPR); fb_writew(0x00f0, HD64461_BBTROPR);
fb_writew(16,HD64461_BBTMDR); fb_writew(16, HD64461_BBTMDR);
if (p->var.bits_per_pixel==16) { if (p->var.bits_per_pixel == 16) {
fb_writew( ((u32*)(p->pseudo_palette))[rect->color] , HD64461_GRSCR ); fb_writew(((u32 *) (p->pseudo_palette))[rect->color],
hitfb_accel_set_dest(1,rect->dx,rect->dy,rect->width,rect->height); HD64461_GRSCR);
hitfb_accel_set_dest(1, rect->dx, rect->dy, rect->width,
rect->height);
hitfb_accel_start(1); hitfb_accel_start(1);
} else { } else {
fb_writew(rect->color, HD64461_GRSCR); fb_writew(rect->color, HD64461_GRSCR);
hitfb_accel_set_dest(0,rect->dx,rect->dy,rect->width,rect->height); hitfb_accel_set_dest(0, rect->dx, rect->dy, rect->width,
rect->height);
hitfb_accel_start(0); hitfb_accel_start(0);
} }
hitfb_accel_wait(); hitfb_accel_wait();
...@@ -171,23 +169,24 @@ static void hitfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect) ...@@ -171,23 +169,24 @@ static void hitfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
static void hitfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) static void hitfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
{ {
hitfb_accel_bitblt(p->var.bits_per_pixel==16,area->sx,area->sy, hitfb_accel_bitblt(p->var.bits_per_pixel == 16, area->sx, area->sy,
area->dx,area->dy,area->width,area->height,0x00cc,0); area->dx, area->dy, area->width, area->height,
0x00cc, 0);
hitfb_accel_wait(); hitfb_accel_wait();
} }
static int hitfb_pan_display(struct fb_var_screeninfo *var, static int hitfb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info) struct fb_info *info)
{ {
int xoffset = var->xoffset; int xoffset = var->xoffset;
int yoffset = var->yoffset; int yoffset = var->yoffset;
if (xoffset!=0) if (xoffset != 0)
return -EINVAL; return -EINVAL;
hitfb_set_base(yoffset*2*640); fb_writew(yoffset, HD64461_LCDCBAR);
return 0; return 0;
} }
int hitfb_blank(int blank_mode, struct fb_info *info) int hitfb_blank(int blank_mode, struct fb_info *info)
...@@ -195,6 +194,12 @@ int hitfb_blank(int blank_mode, struct fb_info *info) ...@@ -195,6 +194,12 @@ int hitfb_blank(int blank_mode, struct fb_info *info)
unsigned short v; unsigned short v;
if (blank_mode) { if (blank_mode) {
#ifdef MACH_HP600
sh_dac_disable(DAC_LCD_BRIGHTNESS);
v = fb_readw(HD64461_GPBDR);
v |= HD64461_GPBDR_LCDOFF;
fb_writew(v, HD64461_GPBDR);
#endif
v = fb_readw(HD64461_LDR1); v = fb_readw(HD64461_LDR1);
v &= ~HD64461_LDR1_DON; v &= ~HD64461_LDR1_DON;
fb_writew(v, HD64461_LDR1); fb_writew(v, HD64461_LDR1);
...@@ -210,7 +215,12 @@ int hitfb_blank(int blank_mode, struct fb_info *info) ...@@ -210,7 +215,12 @@ int hitfb_blank(int blank_mode, struct fb_info *info)
v = fb_readw(HD64461_STBCR); v = fb_readw(HD64461_STBCR);
v &= ~HD64461_STBCR_SLCDST; v &= ~HD64461_STBCR_SLCDST;
fb_writew(v, HD64461_STBCR); fb_writew(v, HD64461_STBCR);
#ifdef MACH_HP600
sh_dac_enable(DAC_LCD_BRIGHTNESS);
v = fb_readw(HD64461_GPBDR);
v &= ~HD64461_GPBDR_LCDOFF;
fb_writew(v, HD64461_GPBDR);
#endif
v = fb_readw(HD64461_LDR1); v = fb_readw(HD64461_LDR1);
v |= HD64461_LDR1_DON; v |= HD64461_LDR1_DON;
fb_writew(v, HD64461_LDR1); fb_writew(v, HD64461_LDR1);
...@@ -219,36 +229,71 @@ int hitfb_blank(int blank_mode, struct fb_info *info) ...@@ -219,36 +229,71 @@ int hitfb_blank(int blank_mode, struct fb_info *info)
v &= ~HD64461_LCDCCR_MOFF; v &= ~HD64461_LCDCCR_MOFF;
fb_writew(v, HD64461_LCDCCR); fb_writew(v, HD64461_LCDCCR);
} }
return 0; return 0;
} }
static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green, static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp, unsigned blue, unsigned transp, struct fb_info *info)
struct fb_info *info)
{ {
if (regno >= info->cmap.len) if (regno >= info->cmap.len)
return 1; return 1;
switch (info->var.bits_per_pixel) { switch (info->var.bits_per_pixel) {
case 8: case 8:
fb_writew(regno << 8, HD64461_CPTWAR); fb_writew(regno << 8, HD64461_CPTWAR);
fb_writew(red >> 10, HD64461_CPTWDR); fb_writew(red >> 10, HD64461_CPTWDR);
fb_writew(green >> 10, HD64461_CPTWDR); fb_writew(green >> 10, HD64461_CPTWDR);
fb_writew(blue >> 10, HD64461_CPTWDR); fb_writew(blue >> 10, HD64461_CPTWDR);
break; break;
case 16: case 16:
((u32*)(info->pseudo_palette))[regno] = ((u32 *) (info->pseudo_palette))[regno] =
((red & 0xf800) ) | ((red & 0xf800)) |
((green & 0xfc00) >> 5) | ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11);
((blue & 0xf800) >> 11); break;
break;
} }
return 0; return 0;
} }
static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) static struct fb_ops hitfb_ops = {
.owner = THIS_MODULE,
.fb_setcolreg = hitfb_setcolreg,
.fb_blank = hitfb_blank,
.fb_pan_display = hitfb_pan_display,
.fb_fillrect = hitfb_fillrect,
.fb_copyarea = hitfb_copyarea,
.fb_imageblit = cfb_imageblit,
.fb_cursor = soft_cursor,
};
int __init hitfb_init(void)
{ {
unsigned short lcdclor, ldr3, ldvndr;
int size;
hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000;
hitfb_fix.smem_len = (MACH_HP690) ? 1024 * 1024 : 512 * 1024;
lcdclor = fb_readw(HD64461_LCDCLOR);
ldvndr = fb_readw(HD64461_LDVNDR);
ldr3 = fb_readw(HD64461_LDR3);
switch (ldr3 & 15) {
default:
case 4:
hitfb_var.bits_per_pixel = 8;
hitfb_var.xres = lcdclor;
break;
case 8:
hitfb_var.bits_per_pixel = 16;
hitfb_var.xres = lcdclor / 2;
break;
}
hitfb_fix.line_length = lcdclor;
hitfb_fix.visual = (hitfb_var.bits_per_pixel == 8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
hitfb_var.yres = ldvndr + 1;
hitfb_var.xres_virtual = hitfb_var.xres;
hitfb_var.yres_virtual = hitfb_fix.smem_len / lcdclor;
switch (hitfb_var.bits_per_pixel) { switch (hitfb_var.bits_per_pixel) {
case 8: case 8:
hitfb_var.red.offset = 0; hitfb_var.red.offset = 0;
...@@ -260,7 +305,7 @@ static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) ...@@ -260,7 +305,7 @@ static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
hitfb_var.transp.offset = 0; hitfb_var.transp.offset = 0;
hitfb_var.transp.length = 0; hitfb_var.transp.length = 0;
break; break;
case 16: /* RGB 565 */ case 16: /* RGB 565 */
hitfb_var.red.offset = 11; hitfb_var.red.offset = 11;
hitfb_var.red.length = 5; hitfb_var.red.length = 5;
hitfb_var.green.offset = 5; hitfb_var.green.offset = 5;
...@@ -272,70 +317,22 @@ static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) ...@@ -272,70 +317,22 @@ static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
break; break;
} }
return 0; fb_info.fbops = &hitfb_ops;
} fb_info.var = hitfb_var;
fb_info.fix = hitfb_fix;
fb_info.pseudo_palette = pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT;
static struct fb_ops hitfb_ops = { fb_info.screen_base = (void *)hitfb_fix.smem_start;
.owner = THIS_MODULE,
.fb_check_var = hitfb_check_var,
.fb_set_par = hitfb_set_par,
.fb_setcolreg = hitfb_setcolreg,
.fb_pan_display = hitfb_pan_display,
.fb_blank = hitfb_blank,
.fb_fillrect = hitfb_fillrect,
.fb_copyarea = hitfb_copyarea,
.fb_imageblit = cfb_imageblit,
.fb_cursor = soft_cursor,
};
int __init hitfb_init(void)
{
unsigned short lcdclor, ldr3, ldvndr;
int size;
hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000;
hitfb_fix.smem_len = (MACH_HP690) ? 1024*1024 : 512*1024;
lcdclor = inw(HD64461_LCDCLOR);
ldvndr = inw(HD64461_LDVNDR);
ldr3 = inw(HD64461_LDR3);
switch (ldr3&15) {
default:
case 4:
hitfb_var.bits_per_pixel = 8;
hitfb_var.xres = lcdclor;
break;
case 8:
hitfb_var.bits_per_pixel = 16;
hitfb_var.xres = lcdclor/2;
break;
}
/* XXX: Most of this should go into hitfb_set_par().. --PFM. */
hitfb_fix.line_length = lcdclor;
hitfb_fix.visual = (hitfb_var.bits_per_pixel == 8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
hitfb_var.yres = ldvndr+1;
hitfb_var.xres_virtual = hitfb_var.xres;
hitfb_var.yres_virtual = hitfb_fix.smem_len/lcdclor;
fb_info.fbops = &hitfb_ops;
fb_info.var = hitfb_var;
fb_info.fix = hitfb_fix;
fb_info.pseudo_palette = pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT;
fb_info.screen_base = (void *) hitfb_fix.smem_start;
size = (fb_info.var.bits_per_pixel == 8) ? 256 : 16; size = (fb_info.var.bits_per_pixel == 8) ? 256 : 16;
fb_alloc_cmap(&fb_info.cmap, size, 0); fb_alloc_cmap(&fb_info.cmap, size, 0);
if (register_framebuffer(&fb_info) < 0) if (register_framebuffer(&fb_info) < 0)
return -EINVAL; return -EINVAL;
printk(KERN_INFO "fb%d: %s frame buffer device\n", printk(KERN_INFO "fb%d: %s frame buffer device\n",
fb_info.node, fb_info.fix.id); fb_info.node, fb_info.fix.id);
return 0; return 0;
} }
...@@ -350,4 +347,3 @@ module_exit(hitfb_exit); ...@@ -350,4 +347,3 @@ module_exit(hitfb_exit);
#endif #endif
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -338,6 +338,7 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red, ...@@ -338,6 +338,7 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
((blue & 0xf800) >> 11); ((blue & 0xf800) >> 11);
pvr2fb_set_pal_entry(par, regno, tmp); pvr2fb_set_pal_entry(par, regno, tmp);
((u16*)(info->pseudo_palette))[regno] = tmp;
break; break;
case 24: /* RGB 888 */ case 24: /* RGB 888 */
red >>= 8; green >>= 8; blue >>= 8; red >>= 8; green >>= 8; blue >>= 8;
...@@ -348,6 +349,7 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red, ...@@ -348,6 +349,7 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
tmp = (transp << 24) | (red << 16) | (green << 8) | blue; tmp = (transp << 24) | (red << 16) | (green << 8) | blue;
pvr2fb_set_pal_entry(par, regno, tmp); pvr2fb_set_pal_entry(par, regno, tmp);
((u32*)(info->pseudo_palette))[regno] = tmp;
break; break;
default: default:
pr_debug("Invalid bit depth %d?!?\n", info->var.bits_per_pixel); pr_debug("Invalid bit depth %d?!?\n", info->var.bits_per_pixel);
......
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