Commit b197d6e3 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] sh: hitfb updates (and accel)

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

This updates hitfb, and also adds basic accel support.  Also as we don't need
the generic cfb_copyarea anymore, we no longer link cfbcopyarea.o in at build
time.
parent 74cc3c1a
......@@ -68,7 +68,7 @@ obj-$(CONFIG_FB_SUN3) += sun3fb.o
obj-$(CONFIG_FB_HGA) += hgafb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_SA1100) += sa1100fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_VIRTUAL) += vfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_HIT) += hitfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_HIT) += hitfb.o cfbfillrect.o cfbimgblt.o
obj-$(CONFIG_FB_E1355) += epson1355fb.o
obj-$(CONFIG_FB_PVR2) += pvr2fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_KYRO) += kyro/ cfbfillrect.o cfbcopyarea.o cfbimgblt.o
......
/*
* $Id: hitfb.c,v 1.2 2000/07/04 06:24:46 yaegashi Exp $
* $Id: hitfb.c,v 1.10 2004/02/01 19:46:04 lethal Exp $
* linux/drivers/video/hitfb.c -- Hitachi LCD frame buffer device
* (C) 1999 Mihai Spatar
* (C) 2000 YAEGASHI Takeshi
* (C) 2003, 2004 Paul Mundt
* (C) 2003 Andriy Skulysh
*
* 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
......@@ -19,7 +21,6 @@
#include <linux/tty.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/nubus.h>
#include <linux/init.h>
#include <linux/fb.h>
......@@ -27,7 +28,7 @@
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/io.h>
#include <asm/hd64461.h>
#include <asm/hd64461/hd64461.h>
static struct fb_var_screeninfo hitfb_var __initdata = {
.activate = FB_ACTIVATE_NOW,
......@@ -39,57 +40,186 @@ static struct fb_var_screeninfo hitfb_var __initdata = {
static struct fb_fix_screeninfo hitfb_fix __initdata = {
.id = "Hitachi HD64461",
.type = FB_TYPE_PACKED_PIXELS,
.visual = FB_VISUAL_TRUECOLOR,
.accel_flags = FB_ACCEL_NONE,
.ypanstep = 8,
.accel = FB_ACCEL_NONE,
};
static u16 pseudo_palette[17];
struct fb_info fb_info;
static u32 pseudo_palette[16];
static struct fb_info fb_info;
static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
#define WIDTH 640
static void hitfb_set_base(u32 offset)
{
var->xres_virtual = var->xres;
var->yres_virtual = var->yres;
fb_writew(offset>>10,HD64461_LCDCBAR);
}
switch (var->bits_per_pixel) {
case 8:
var->red.offset = 0;
var->red.length = 8;
var->green.offset = 0;
var->green.length = 8;
var->blue.offset = 0;
var->blue.length = 8;
var->transp.offset = 0;
var->transp.length = 0;
break;
case 16: /* RGB 565 */
var->red.offset = 11;
var->red.length = 5;
var->green.offset = 5;
var->green.length = 6;
var->blue.offset = 0;
var->blue.length = 5;
var->transp.offset = 0;
var->transp.length = 0;
break;
static inline void hitfb_accel_wait()
{
while (fb_readw(HD64461_GRCFGR) & HD64461_GRCFGR_ACCSTATUS)
;
}
static inline void hitfb_accel_start(int truecolor)
{
if (truecolor) {
fb_writew(6,HD64461_GRCFGR);
} else {
fb_writew(7,HD64461_GRCFGR);
}
}
static inline void hitfb_accel_set_dest(int truecolor, u16 dx, u16 dy,
u16 width, u16 height)
{
u32 saddr=WIDTH*dy+dx;
if (truecolor)
saddr <<= 1;
fb_writew(width,HD64461_BBTDWR);
fb_writew(height,HD64461_BBTDHR);
fb_writew(saddr&0xffff,HD64461_BBTDSARL);
fb_writew(saddr>>16,HD64461_BBTDSARH);
}
static inline void hitfb_accel_solidfill(int truecolor, u16 dx, u16 dy,
u16 width, u16 height, u16 color)
{
hitfb_accel_set_dest(truecolor,dx,dy,width,height);
fb_writew(0x00f0,HD64461_BBTROPR);
fb_writew(16,HD64461_BBTMDR);
fb_writew(color,HD64461_GRSCR);
hitfb_accel_start(truecolor);
}
static inline void hitfb_accel_bitblt(int truecolor, u16 sx, u16 sy, u16 dx, u16 dy,
u16 width, u16 height, u16 rop, u32 mask_addr)
{
u32 saddr,daddr;
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;
if (mask_addr) {
if (truecolor) {
maddr=((width>>3)+1)*(height+1)-1;
} else {
maddr=(((width>>4)+1)*(height+1)-1)*2;
}
fb_writew((1<<5)|1,HD64461_BBTMDR);
} else {
fb_writew(1,HD64461_BBTMDR);
}
} else {
saddr=WIDTH*sy+sx;
daddr=WIDTH*dy+dx;
if (mask_addr) {
fb_writew((1<<5),HD64461_BBTMDR);
} else {
outw(0,HD64461_BBTMDR);
}
}
if (truecolor) {
saddr<<=1;
daddr<<=1;
}
fb_writew(width,HD64461_BBTDWR);
fb_writew(height,HD64461_BBTDHR);
fb_writew(saddr&0xffff,HD64461_BBTSSARL);
fb_writew(saddr>>16,HD64461_BBTSSARH);
fb_writew(daddr&0xffff,HD64461_BBTDSARL);
fb_writew(daddr>>16,HD64461_BBTDSARH);
if (mask_addr) {
maddr+=mask_addr;
fb_writew(maddr&0xffff,HD64461_BBTMARL);
fb_writew(maddr>>16,HD64461_BBTMARH);
}
hitfb_accel_start(truecolor);
}
static void hitfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
{
if (rect->rop != ROP_COPY) {
cfb_fillrect(p,rect);
} else {
fb_writew(0x00f0,HD64461_BBTROPR);
fb_writew(16,HD64461_BBTMDR);
if (p->var.bits_per_pixel==16) {
fb_writew( ((u32*)(p->pseudo_palette))[rect->color] , HD64461_GRSCR );
hitfb_accel_set_dest(1,rect->dx,rect->dy,rect->width,rect->height);
hitfb_accel_start(1);
} else {
fb_writew(rect->color, HD64461_GRSCR);
hitfb_accel_set_dest(0,rect->dx,rect->dy,rect->width,rect->height);
hitfb_accel_start(0);
}
hitfb_accel_wait();
}
}
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,
area->dx,area->dy,area->width,area->height,0x00cc,0);
hitfb_accel_wait();
}
static int hitfb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info)
{
int xoffset = var->xoffset;
int yoffset = var->yoffset;
if (xoffset!=0)
return -EINVAL;
hitfb_set_base(yoffset*2*640);
return 0;
}
static int hitfb_set_par(struct fb_info *info)
int hitfb_blank(int blank_mode, struct fb_info *info)
{
info->fix.visual = (info->var.bits_per_pixel == 8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
unsigned short v;
switch(info->var.bits_per_pixel) {
default:
case 8:
info->fix.line_length = info->var.xres;
break;
case 16:
info->fix.line_length = info->var.xres*2;
break;
if (blank_mode) {
v = fb_readw(HD64461_LDR1);
v &= ~HD64461_LDR1_DON;
fb_writew(v, HD64461_LDR1);
v = fb_readw(HD64461_LCDCCR);
v |= HD64461_LCDCCR_MOFF;
fb_writew(v, HD64461_LCDCCR);
v = fb_readw(HD64461_STBCR);
v |= HD64461_STBCR_SLCDST;
fb_writew(v, HD64461_STBCR);
} else {
v = fb_readw(HD64461_STBCR);
v &= ~HD64461_STBCR_SLCDST;
fb_writew(v, HD64461_STBCR);
v = fb_readw(HD64461_LDR1);
v |= HD64461_LDR1_DON;
fb_writew(v, HD64461_LDR1);
v = fb_readw(HD64461_LCDCCR);
v &= ~HD64461_LCDCCR_MOFF;
fb_writew(v, HD64461_LCDCCR);
}
return 0;
}
......@@ -97,24 +227,51 @@ static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
struct fb_info *info)
{
if (regno > 255)
if (regno >= info->cmap.len)
return 1;
outw(regno << 8, HD64461_CPTWAR);
outw(red >> 10, HD64461_CPTWDR);
outw(green >> 10, HD64461_CPTWDR);
outw(blue >> 10, HD64461_CPTWDR);
if (regno < 16) {
switch(info->var.bits_per_pixel) {
switch (info->var.bits_per_pixel) {
case 8:
fb_writew(regno << 8, HD64461_CPTWAR);
fb_writew(red >> 10, HD64461_CPTWDR);
fb_writew(green >> 10, HD64461_CPTWDR);
fb_writew(blue >> 10, HD64461_CPTWDR);
break;
case 16:
((u16 *)(info->pseudo_palette))[regno] =
((u32*)(info->pseudo_palette))[regno] =
((red & 0xf800) ) |
((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11);
break;
}
return 0;
}
static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
{
switch (hitfb_var.bits_per_pixel) {
case 8:
hitfb_var.red.offset = 0;
hitfb_var.red.length = 8;
hitfb_var.green.offset = 0;
hitfb_var.green.length = 8;
hitfb_var.blue.offset = 0;
hitfb_var.blue.length = 8;
hitfb_var.transp.offset = 0;
hitfb_var.transp.length = 0;
break;
case 16: /* RGB 565 */
hitfb_var.red.offset = 11;
hitfb_var.red.length = 5;
hitfb_var.green.offset = 5;
hitfb_var.green.length = 6;
hitfb_var.blue.offset = 0;
hitfb_var.blue.length = 5;
hitfb_var.transp.offset = 0;
hitfb_var.transp.length = 0;
break;
}
return 0;
}
......@@ -123,21 +280,24 @@ static struct fb_ops hitfb_ops = {
.fb_check_var = hitfb_check_var,
.fb_set_par = hitfb_set_par,
.fb_setcolreg = hitfb_setcolreg,
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.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, ldvntr;
unsigned short lcdclor, ldr3, ldvndr;
int size;
hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000;
hitfb_fix.smem_len = (MACH_HP680 || MACH_HP690) ? 1024*1024 : 512*1024;
hitfb_fix.smem_len = (MACH_HP690) ? 1024*1024 : 512*1024;
lcdclor = inw(HD64461_LCDCLOR);
ldvntr = inw(HD64461_LDVNTR);
ldvndr = inw(HD64461_LDVNDR);
ldr3 = inw(HD64461_LDR3);
switch (ldr3&15) {
......@@ -151,7 +311,14 @@ int __init hitfb_init(void)
hitfb_var.xres = lcdclor/2;
break;
}
hitfb_var.yres = ldvntr+1;
/* 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;
......@@ -172,29 +339,15 @@ int __init hitfb_init(void)
return 0;
}
void hitfb_cleanup(struct fb_info *info)
static void __exit hitfb_exit(void)
{
unregister_framebuffer(info);
unregister_framebuffer(&fb_info);
}
#ifdef MODULE
MODULE_LICENSE("GPL");
int init_module(void)
{
return hitfb_init();
}
void cleanup_module(void)
{
hitfb_cleanup(void);
}
module_init(hitfb_init);
module_exit(hitfb_exit);
#endif
/*
* Local variables:
* c-basic-offset: 4
* End:
*/
MODULE_LICENSE("GPL");
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