Commit 7eceec64 authored by James Simmons's avatar James Simmons

Ported over the TX3912 framebuffer to the new api. Fixed a NODEV error for the...

Ported over the TX3912 framebuffer to the new api. Fixed a NODEV error for the Permedia framebuffer driver and patched fbcmap.c to prevent another Oops.
parent e494e41d
...@@ -236,25 +236,25 @@ if [ "$CONFIG_FB" = "y" ]; then ...@@ -236,25 +236,25 @@ if [ "$CONFIG_FB" = "y" ]; then
if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_AMIGA" = "y" -o \ if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_AMIGA" = "y" -o \
"$CONFIG_FB_ATARI" = "y" -o "$CONFIG_FB_CYBER" = "y" -o \ "$CONFIG_FB_ATARI" = "y" -o "$CONFIG_FB_CYBER" = "y" -o \
"$CONFIG_FB_MAC" = "y" -o "$CONFIG_FB_RETINAZ3" = "y" -o \ "$CONFIG_FB_MAC" = "y" -o "$CONFIG_FB_RETINAZ3" = "y" -o \
"$CONFIG_FB_VIRGE" = "y" -o "$CONFIG_FB_TX3912" = "y" -o \ "$CONFIG_FB_VIRGE" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \
"$CONFIG_FB_BWTWO" = "y" -o "$CONFIG_FB_CLGEN" = "y" ]; then "$CONFIG_FB_BWTWO" = "y" ]; then
define_tristate CONFIG_FBCON_MFB y define_tristate CONFIG_FBCON_MFB y
else else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_AMIGA" = "m" -o \ if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_AMIGA" = "m" -o \
"$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_CYBER" = "m" -o \ "$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_CYBER" = "m" -o \
"$CONFIG_FB_MAC" = "m" -o "$CONFIG_FB_RETINAZ3" = "m" -o \ "$CONFIG_FB_MAC" = "m" -o "$CONFIG_FB_RETINAZ3" = "m" -o \
"$CONFIG_FB_VIRGE" = "m" -o "$CONFIG_FB_TX3912" = "m" -o \ "$CONFIG_FB_VIRGE" = "m" -o "$CONFIG_FB_CLGEN" = "m" -o \
"$CONFIG_FB_BWTWO" = "m" -o "$CONFIG_FB_CLGEN" = "m" ]; then "$CONFIG_FB_BWTWO" = "m" ]; then
define_tristate CONFIG_FBCON_MFB m define_tristate CONFIG_FBCON_MFB m
fi fi
fi fi
if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_MAC" = "y" -o \ if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_MAC" = "y" -o \
"$CONFIG_FB_SA1100" = "y" -o "$CONFIG_FB_TX3912" = "y" ]; then "$CONFIG_FB_SA1100" = "y" ]; then
define_tristate CONFIG_FBCON_CFB2 y define_tristate CONFIG_FBCON_CFB2 y
define_tristate CONFIG_FBCON_CFB4 y define_tristate CONFIG_FBCON_CFB4 y
else else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_MAC" = "m" -o \ if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_MAC" = "m" -o \
"$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_TX3912" = "m" ]; then "$CONFIG_FB_SA1100" = "m" ]; then
define_tristate CONFIG_FBCON_CFB2 m define_tristate CONFIG_FBCON_CFB2 m
define_tristate CONFIG_FBCON_CFB4 m define_tristate CONFIG_FBCON_CFB4 m
fi fi
...@@ -262,7 +262,7 @@ if [ "$CONFIG_FB" = "y" ]; then ...@@ -262,7 +262,7 @@ if [ "$CONFIG_FB" = "y" ]; then
if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_ATARI" = "y" -o \ if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_ATARI" = "y" -o \
"$CONFIG_FB_ATY" = "y" -o "$CONFIG_FB_MAC" = "y" -o \ "$CONFIG_FB_ATY" = "y" -o "$CONFIG_FB_MAC" = "y" -o \
"$CONFIG_FB_OF" = "y" -o "$CONFIG_FB_TGA" = "y" -o \ "$CONFIG_FB_OF" = "y" -o "$CONFIG_FB_TGA" = "y" -o \
"$CONFIG_FB_TX3912" = "y" -o "$CONFIG_FB_PM3" = "y" -o \ "$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_PM3" = "y" -o \
"$CONFIG_FB_TCX" = "y" -o "$CONFIG_FB_CGTHREE" = "y" -o \ "$CONFIG_FB_TCX" = "y" -o "$CONFIG_FB_CGTHREE" = "y" -o \
"$CONFIG_FB_CONTROL" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \ "$CONFIG_FB_CONTROL" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \
"$CONFIG_FB_CGFOURTEEN" = "y" -o "$CONFIG_FB_TRIDENT" = "y" -o \ "$CONFIG_FB_CGFOURTEEN" = "y" -o "$CONFIG_FB_TRIDENT" = "y" -o \
...@@ -273,7 +273,7 @@ if [ "$CONFIG_FB" = "y" ]; then ...@@ -273,7 +273,7 @@ if [ "$CONFIG_FB" = "y" ]; then
"$CONFIG_FB_P9100" = "y" -o "$CONFIG_FB_ATY128" = "y" -o \ "$CONFIG_FB_P9100" = "y" -o "$CONFIG_FB_ATY128" = "y" -o \
"$CONFIG_FB_RIVA" = "y" -o "$CONFIG_FB_RADEON" = "y" -o \ "$CONFIG_FB_RIVA" = "y" -o "$CONFIG_FB_RADEON" = "y" -o \
"$CONFIG_FB_SGIVW" = "y" -o "$CONFIG_FB_CYBER2000" = "y" -o \ "$CONFIG_FB_SGIVW" = "y" -o "$CONFIG_FB_CYBER2000" = "y" -o \
"$CONFIG_FB_SA1100" = "y" -o "$CONFIG_FB_SIS" = "y" ]; then "$CONFIG_FB_SA1100" = "y" ]; then
define_tristate CONFIG_FBCON_CFB8 y define_tristate CONFIG_FBCON_CFB8 y
else else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_ATARI" = "m" -o \ if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_ATARI" = "m" -o \
...@@ -288,9 +288,9 @@ if [ "$CONFIG_FB" = "y" ]; then ...@@ -288,9 +288,9 @@ if [ "$CONFIG_FB" = "y" ]; then
"$CONFIG_FB_IGA" = "m" -o "$CONFIG_FB_MATROX" = "m" -o \ "$CONFIG_FB_IGA" = "m" -o "$CONFIG_FB_MATROX" = "m" -o \
"$CONFIG_FB_CT65550" = "m" -o "$CONFIG_FB_PM2" = "m" -o \ "$CONFIG_FB_CT65550" = "m" -o "$CONFIG_FB_PM2" = "m" -o \
"$CONFIG_FB_P9100" = "m" -o "$CONFIG_FB_ATY128" = "m" -o \ "$CONFIG_FB_P9100" = "m" -o "$CONFIG_FB_ATY128" = "m" -o \
"$CONFIG_FB_RIVA" = "m" -o "$CONFIG_FB_TX3912" = "m" -o \ "$CONFIG_FB_RIVA" = "m" -o "$CONFIG_FB_RADEON" = "m" -o \
"$CONFIG_FB_SGIVW" = "m" -o "$CONFIG_FB_CYBER2000" = "m" -o \ "$CONFIG_FB_SGIVW" = "m" -o "$CONFIG_FB_CYBER2000" = "m" -o \
"$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_RADEON" = "m" ]; then "$CONFIG_FB_SA1100" = "m" ]; then
define_tristate CONFIG_FBCON_CFB8 m define_tristate CONFIG_FBCON_CFB8 m
fi fi
fi fi
...@@ -370,7 +370,7 @@ if [ "$CONFIG_FB" = "y" ]; then ...@@ -370,7 +370,7 @@ if [ "$CONFIG_FB" = "y" ]; then
"$CONFIG_FB_VIRTUAL" = "y" -o "$CONFIG_FB_CLPS711X" = "y" -o \ "$CONFIG_FB_VIRTUAL" = "y" -o "$CONFIG_FB_CLPS711X" = "y" -o \
"$CONFIG_FB_3DFX" = "y" -o "$CONFIG_FB_APOLLO" = "y" -o \ "$CONFIG_FB_3DFX" = "y" -o "$CONFIG_FB_APOLLO" = "y" -o \
"$CONFIG_FB_PMAG_BA" = "y" -o "$CONFIG_FB_PMAGB_B" = "y" -o \ "$CONFIG_FB_PMAG_BA" = "y" -o "$CONFIG_FB_PMAGB_B" = "y" -o \
"$CONFIG_FB_MAXINE" = "y" ]; then "$CONFIG_FB_MAXINE" = "y" -o "$CONFIG_FB_TX3912" = "y" ]; then
define_tristate CONFIG_FBCON_ACCEL y define_tristate CONFIG_FBCON_ACCEL y
else else
if [ "$CONFIG_FB_NEOMAGIC" = "m" -o "$CONFIG_FB_HIT" = "m" -o \ if [ "$CONFIG_FB_NEOMAGIC" = "m" -o "$CONFIG_FB_HIT" = "m" -o \
......
...@@ -88,10 +88,10 @@ obj-$(CONFIG_FB_CGFOURTEEN) += cgfourteenfb.o sbusfb.o ...@@ -88,10 +88,10 @@ obj-$(CONFIG_FB_CGFOURTEEN) += cgfourteenfb.o sbusfb.o
obj-$(CONFIG_FB_P9100) += p9100fb.o sbusfb.o obj-$(CONFIG_FB_P9100) += p9100fb.o sbusfb.o
obj-$(CONFIG_FB_LEO) += leofb.o sbusfb.o obj-$(CONFIG_FB_LEO) += leofb.o sbusfb.o
obj-$(CONFIG_FB_STI) += stifb.o sticore.o obj-$(CONFIG_FB_STI) += stifb.o sticore.o
obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_MAXINE) += maxinefb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_MAXINE) += maxinefb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_TX3912) += tx3912fb.o obj-$(CONFIG_FB_TX3912) += tx3912fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_MATROX) += matrox/ obj-$(CONFIG_FB_MATROX) += matrox/
obj-$(CONFIG_FB_RIVA) += riva/ obj-$(CONFIG_FB_RIVA) += riva/
......
...@@ -150,7 +150,7 @@ void fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto) ...@@ -150,7 +150,7 @@ void fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto)
else else
tooff = from->start-to->start; tooff = from->start-to->start;
size = to->len-tooff; size = to->len-tooff;
if (size > from->len-fromoff) if (size > (int) (from->len - fromoff))
size = from->len-fromoff; size = from->len-fromoff;
if (size <= 0) if (size <= 0)
return; return;
......
...@@ -132,6 +132,7 @@ extern int pmagbafb_init(void); ...@@ -132,6 +132,7 @@ extern int pmagbafb_init(void);
extern int pmagbbfb_init(void); extern int pmagbbfb_init(void);
extern void maxinefb_init(void); extern void maxinefb_init(void);
extern int tx3912fb_init(void); extern int tx3912fb_init(void);
extern int tx3912fb_setup(char*);
extern int radeonfb_init(void); extern int radeonfb_init(void);
extern int radeonfb_setup(char*); extern int radeonfb_setup(char*);
extern int e1355fb_init(void); extern int e1355fb_init(void);
...@@ -300,7 +301,7 @@ static struct { ...@@ -300,7 +301,7 @@ static struct {
{ "hitfb", hitfb_init, NULL }, { "hitfb", hitfb_init, NULL },
#endif #endif
#ifdef CONFIG_FB_TX3912 #ifdef CONFIG_FB_TX3912
{ "tx3912", tx3912fb_init, NULL }, { "tx3912", tx3912fb_init, tx3912fb_setup },
#endif #endif
#ifdef CONFIG_FB_E1355 #ifdef CONFIG_FB_E1355
{ "e1355fb", e1355fb_init, e1355fb_setup }, { "e1355fb", e1355fb_init, e1355fb_setup },
......
...@@ -2270,7 +2270,7 @@ int __init pm2fb_init(void) { ...@@ -2270,7 +2270,7 @@ int __init pm2fb_init(void) {
fb_info.gen.parsize=sizeof(struct pm2fb_par); fb_info.gen.parsize=sizeof(struct pm2fb_par);
fb_info.gen.fbhw=&pm2fb_hwswitch; fb_info.gen.fbhw=&pm2fb_hwswitch;
strcpy(fb_info.gen.info.modename, permedia2_name); strcpy(fb_info.gen.info.modename, permedia2_name);
fb_info.gen.info.node=-1; fb_info.gen.info.node = NODEV;
fb_info.gen.info.flags=FBINFO_FLAG_DEFAULT; fb_info.gen.info.flags=FBINFO_FLAG_DEFAULT;
fb_info.gen.info.fbops=&pm2fb_ops; fb_info.gen.info.fbops=&pm2fb_ops;
fb_info.gen.info.disp=&fb_info.disp; fb_info.gen.info.disp=&fb_info.disp;
......
/* /*
* linux/drivers/video/tx3912fb.c * drivers/video/tx3912fb.c
* *
* Copyright (C) 1999 Harald Koerfgen * Copyright (C) 1999 Harald Koerfgen
* Copyright (C) 2001 Steven Hill (sjhill@realitydiluted.com) * Copyright (C) 2001 Steven Hill (sjhill@realitydiluted.com)
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
* *
* Framebuffer for LCD controller in TMPR3912/05 and PR31700 processors * Framebuffer for LCD controller in TMPR3912/05 and PR31700 processors
*/ */
#include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -20,42 +21,69 @@ ...@@ -20,42 +21,69 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <video/fbcon.h>
#include <asm/io.h>
#include <asm/bootinfo.h> #include <asm/bootinfo.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <video/fbcon.h> #include <asm/tx3912.h>
#include <video/fbcon-mfb.h> #include <video/tx3912.h>
#include <video/fbcon-cfb2.h>
#include <video/fbcon-cfb4.h>
#include <video/fbcon-cfb8.h>
#include "tx3912fb.h"
/* /*
* Frame buffer, palette and console structures * Frame buffer, palette and console structures
*/ */
static struct fb_info fb_info; static struct fb_info fb_info;
static struct { u_char red, green, blue, pad; } palette[256]; static u32 cfb8[16];
static struct display global_disp; static struct display disp;
/* static struct fb_fix_screeninfo tx3912fb_fix __initdata = {
* Interface used by the world id: "tx3912fb",
*/ #ifdef CONFIG_NINO_16MB
static int tx3912fb_get_fix(struct fb_fix_screeninfo *fix, int con, smem_len: (240 * 320),
struct fb_info *info); #else
static int tx3912fb_get_var(struct fb_var_screeninfo *var, int con, smem_len: ((240 * 320)/2),
struct fb_info *info); #endif
static int tx3912fb_set_var(struct fb_var_screeninfo *var, int con, type: FB_TYPE_PACKED_PIXELS,
struct fb_info *info); visual: FB_VISUAL_TRUECOLOR,
static int tx3912fb_get_cmap(struct fb_cmap *cmap, int kspc, int con, xpanstep: 1,
struct fb_info *info); ypanstep: 1,
static int tx3912fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ywrapstep: 1,
u_int transp, struct fb_info *info); accel: FB_ACCEL_NONE,
};
static struct fb_var_screeninfo tx3912fb_var = {
xres: 240,
yres: 320,
xres_virtual: 240,
yres_virtual: 320,
#ifdef CONFIG_NINO_16MB
bits_per_pixel: 8,
red: { 5, 3, 0 }, /* RGB 332 */
green: { 2, 3, 0 },
blue: { 0, 2, 0 },
#else
bits_per_pixel: 4,
#endif
activate: FB_ACTIVATE_NOW,
width: -1,
height: -1,
pixclock: 20000,
left_margin: 64,
right_margin: 64,
upper_margin: 32,
lower_margin: 32,
hsync_len: 64,
vsync_len: 2,
vmode: FB_VMODE_NONINTERLACED,
};
/* /*
* Interface used by console driver * Interface used by the world
*/ */
int tx3912fb_init(void); int tx3912fb_init(void);
static int tx3912fbcon_switch(int con, struct fb_info *info);
static int tx3912fbcon_updatevar(int con, struct fb_info *info); static int tx3912fb_setcolreg(u_int regno, u_int red, u_int green,
u_int blue, u_int transp,
struct fb_info *info);
/* /*
* Macros * Macros
...@@ -63,239 +91,123 @@ static int tx3912fbcon_updatevar(int con, struct fb_info *info); ...@@ -63,239 +91,123 @@ static int tx3912fbcon_updatevar(int con, struct fb_info *info);
#define get_line_length(xres_virtual, bpp) \ #define get_line_length(xres_virtual, bpp) \
(u_long) (((int) xres_virtual * (int) bpp + 7) >> 3) (u_long) (((int) xres_virtual * (int) bpp + 7) >> 3)
/*
* Internal routines
*/
static int tx3912fb_getcolreg(u_int regno, u_int *red, u_int *green,
u_int *blue, u_int *transp, struct fb_info *info);
/* /*
* Frame buffer operations structure used by console driver * Frame buffer operations structure used by console driver
*/ */
static struct fb_ops tx3912fb_ops = { static struct fb_ops tx3912fb_ops = {
owner: THIS_MODULE, owner: THIS_MODULE,
fb_get_fix: tx3912fb_get_fix, fb_get_fix: gen_get_fix,
fb_get_var: tx3912fb_get_var, fb_get_var: gen_get_var,
fb_set_var: tx3912fb_set_var, fb_set_var: gen_set_var,
fb_get_cmap: tx3912fb_get_cmap, fb_get_cmap: gen_get_cmap,
fb_set_cmap: gen_set_cmap, fb_set_cmap: gen_set_cmap,
fb_setcolreg: tx3912fb_setcolreg, fb_setcolreg: tx3912fb_setcolreg,
fb_fillrect: cfb_fillrect,
fb_copyarea: cfb_copyarea,
fb_imageblit: cfb_imageblit,
}; };
static int tx3912fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
/*
* Get fixed display data
*/
static int tx3912fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
{ {
struct display *display;
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id, TX3912FB_NAME);
if (con == -1)
display = &global_disp;
else
display = &fb_display[con];
fix->smem_start = tx3912fb_vaddr;
fix->smem_len = tx3912fb_size;
fix->type = display->type;
fix->type_aux = display->type_aux;
fix->xpanstep = 0;
fix->ypanstep = display->ypanstep;
fix->ywrapstep = display->ywrapstep;
fix->visual = display->visual;
fix->line_length = display->line_length;
fix->accel = FB_ACCEL_NONE;
return 0;
}
/*
* Get user display data
*/
static int tx3912fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
if (con == -1)
*var = tx3912fb_info;
else
*var = fb_display[con].var;
return 0;
}
/*
* Set user display data
*/
static int tx3912fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
int err, activate = var->activate;
int oldxres, oldyres, oldvxres, oldvyres, oldbpp;
u_long line_length;
struct display *display;
if (con == -1)
display = &global_disp;
else
display = &fb_display[con];
/*
* FB_VMODE_CONUPDATE and FB_VMODE_SMOOTH_XPAN are equal
* as FB_VMODE_SMOOTH_XPAN is only used internally
*/
if (var->vmode & FB_VMODE_CONUPDATE) {
var->xoffset = display->var.xoffset;
var->yoffset = display->var.yoffset;
var->vmode |= FB_VMODE_YWRAP;
}
/*
* Make sure values are in range
*/
if (!var->xres)
var->xres = 1;
if (!var->yres)
var->yres = 1;
if (var->xres > var->xres_virtual)
var->xres_virtual = var->xres;
if (var->yres > var->yres_virtual)
var->yres_virtual = var->yres;
if (var->bits_per_pixel <= 1)
var->bits_per_pixel = 1;
else if (var->bits_per_pixel <= 2)
var->bits_per_pixel = 2;
else if (var->bits_per_pixel <= 4)
var->bits_per_pixel = 4;
else if (var->bits_per_pixel <= 8)
var->bits_per_pixel = 8;
else
return -EINVAL;
/* /*
* Memory limit * Memory limit
*/ */
line_length = get_line_length(var->xres_virtual, var->bits_per_pixel); line_length =
if ((line_length * var->yres_virtual) > tx3912fb_size) get_line_length(var->xres_virtual, var->bits_per_pixel);
if ((line_length * var->yres_virtual) > info->fix.smem_len)
return -ENOMEM; return -ENOMEM;
/* return 0;
* This is only for color and we only support 8-bit color }
*/
if (var->bits_per_pixel) {
/* RGB 332 */
var->red.offset = 5;
var->red.length = 3;
var->green.offset = 2;
var->green.length = 3;
var->blue.offset = 0;
var->blue.length = 2;
var->transp.offset = 0;
var->transp.length = 0;
}
var->red.msb_right = 0;
var->green.msb_right = 0;
var->blue.msb_right = 0;
var->transp.msb_right = 0;
/*
* Make changes if necessary
*/
if ((activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
oldxres = display->var.xres;
oldyres = display->var.yres;
oldvxres = display->var.xres_virtual;
oldvyres = display->var.yres_virtual;
oldbpp = display->var.bits_per_pixel;
display->var = *var;
if (oldxres != var->xres || oldyres != var->yres || static int tx3912fb_set_par(struct fb_info *info)
oldvxres != var->xres_virtual || {
oldvyres != var->yres_virtual || u_long tx3912fb_paddr = 0;
oldbpp != var->bits_per_pixel) {
/* Disable the video logic */
outl(inl(TX3912_VIDEO_CTRL1) &
~(TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON),
TX3912_VIDEO_CTRL1);
udelay(200);
switch (var->bits_per_pixel) { /* Set start address for DMA transfer */
case 1: outl(tx3912fb_paddr, TX3912_VIDEO_CTRL3);
display->visual = FB_VISUAL_MONO10;
break;
case 2:
display->visual = FB_VISUAL_PSEUDOCOLOR;
case 4:
case 8:
display->visual = FB_VISUAL_TRUECOLOR;
break;
}
display->type = FB_TYPE_PACKED_PIXELS; /* Set end address for DMA transfer */
display->type_aux = 0; outl((tx3912fb_paddr + tx3912fb_fix.smem_len + 1), TX3912_VIDEO_CTRL4);
display->ypanstep = 0;
display->ywrapstep = 0;
display->next_line =
display->line_length =
get_line_length(var->xres_virtual,
var->bits_per_pixel);
display->can_soft_blank = 0;
display->inverse = FB_IS_INVERSE;
switch (var->bits_per_pixel) { /* Set the pixel depth */
#ifdef CONFIG_FBCON_MFB switch (info->var.bits_per_pixel) {
case 1: case 1:
display->dispsw = &fbcon_mfb; /* Monochrome */
break; outl(inl(TX3912_VIDEO_CTRL1) &
#endif ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
#ifdef CONFIG_FBCON_CFB2 info->fix.visual = FB_VISUAL_MONO10;
case 2:
display->dispsw = &fbcon_cfb2;
break; break;
#endif
#ifdef CONFIG_FBCON_CFB4
case 4: case 4:
display->dispsw = &fbcon_cfb4; /* 4-bit gray */
outl(inl(TX3912_VIDEO_CTRL1) &
~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
outl(inl(TX3912_VIDEO_CTRL1) |
TX3912_VIDEO_CTRL1_BITSEL_4BIT_GRAY,
TX3912_VIDEO_CTRL1);
info->fix.visual = FB_VISUAL_TRUECOLOR;
break; break;
#endif
#ifdef CONFIG_FBCON_CFB8
case 8: case 8:
display->dispsw = &fbcon_cfb8; /* 8-bit color */
display->dispsw_data = fbcon_cmap.cfb8; outl(inl(TX3912_VIDEO_CTRL1) &
~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
outl(inl(TX3912_VIDEO_CTRL1) |
TX3912_VIDEO_CTRL1_BITSEL_8BIT_COLOR,
TX3912_VIDEO_CTRL1);
info->fix.visual = FB_VISUAL_TRUECOLOR;
break; break;
#endif case 2:
default: default:
display->dispsw = &fbcon_dummy; /* 2-bit gray */
outl(inl(TX3912_VIDEO_CTRL1) &
~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
outl(inl(TX3912_VIDEO_CTRL1) |
TX3912_VIDEO_CTRL1_BITSEL_2BIT_GRAY,
TX3912_VIDEO_CTRL1);
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
break; break;
} }
if (fb_info.changevar) /* Enable the video clock */
(*fb_info.changevar)(con); outl(inl(TX3912_CLK_CTRL) | TX3912_CLK_CTRL_ENVIDCLK,
} TX3912_CLK_CTRL);
if (oldbpp != var->bits_per_pixel) { /* Unfreeze video logic and enable DF toggle */
if ((err = fb_alloc_cmap(&display->cmap, 0, 0))) outl(inl(TX3912_VIDEO_CTRL1) &
return err; ~(TX3912_VIDEO_CTRL1_ENFREEZEFRAME |
do_install_cmap(con, info); TX3912_VIDEO_CTRL1_DFMODE)
} , TX3912_VIDEO_CTRL1);
} udelay(200);
return 0; /* Enable the video logic */
outl(inl(TX3912_VIDEO_CTRL1) |
(TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON),
TX3912_VIDEO_CTRL1);
info->fix.line_length = get_line_length(var->xres_virtual,
var->bits_per_pixel);
} }
/* /*
* Get the colormap * Set a single color register
*/ */
static int tx3912fb_get_cmap(struct fb_cmap *cmap, int kspc, int con, static int tx3912fb_setcolreg(u_int regno, u_int red, u_int green,
u_int blue, u_int transp,
struct fb_info *info) struct fb_info *info)
{ {
if (con == info->currcon) if (regno > 255)
return fb_get_cmap(cmap, kspc, tx3912fb_getcolreg, info); return 1;
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(1<<fb_display[con].var.bits_per_pixel), cmap, kspc ? 0 : 2);
if (regno < 16)
((u32 *)(info->pseudo_palette))[regno] = ((red & 0xe000) >> 8)
| ((green & 0xe000) >> 11)
| ((blue & 0xc000) >> 14);
return 0; return 0;
} }
...@@ -304,164 +216,126 @@ static int tx3912fb_get_cmap(struct fb_cmap *cmap, int kspc, int con, ...@@ -304,164 +216,126 @@ static int tx3912fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
*/ */
int __init tx3912fb_init(void) int __init tx3912fb_init(void)
{ {
/* Stop the video logic when frame completes */ u_long tx3912fb_paddr = 0;
VidCtrl1 |= ENFREEZEFRAME;
IntClear1 |= INT1_LCDINT;
while (!(IntStatus1 & INT1_LCDINT));
/* Disable the video logic */ /* Disable the video logic */
VidCtrl1 &= ~(ENVID | DISPON); outl(inl(TX3912_VIDEO_CTRL1) &
~(TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON),
TX3912_VIDEO_CTRL1);
udelay(200); udelay(200);
/* Set start address for DMA transfer */ /* Set start address for DMA transfer */
VidCtrl3 = tx3912fb_paddr & outl(tx3912fb_paddr, TX3912_VIDEO_CTRL3);
(TX3912_VIDCTRL3_VIDBANK_MASK | TX3912_VIDCTRL3_VIDBASEHI_MASK);
/* Set end address for DMA transfer */ /* Set end address for DMA transfer */
VidCtrl4 = (tx3912fb_paddr + tx3912fb_size + 1) & outl((tx3912fb_paddr + tx3912fb_fix.smem_len + 1), TX3912_VIDEO_CTRL4);
TX3912_VIDCTRL4_VIDBASELO_MASK;
/* Set the pixel depth */ /* Set the pixel depth */
switch (tx3912fb_info.bits_per_pixel) { switch (tx3912fb_var.bits_per_pixel) {
case 1: case 1:
/* Monochrome */ /* Monochrome */
VidCtrl1 &= ~TX3912_VIDCTRL1_BITSEL_MASK; outl(inl(TX3912_VIDEO_CTRL1) &
~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
tx3912fb_fix.visual = FB_VISUAL_MONO10;
break; break;
case 4: case 4:
/* 4-bit gray */ /* 4-bit gray */
VidCtrl1 &= ~TX3912_VIDCTRL1_BITSEL_MASK; outl(inl(TX3912_VIDEO_CTRL1) &
VidCtrl1 |= TX3912_VIDCTRL1_4BIT_GRAY; ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
outl(inl(TX3912_VIDEO_CTRL1) |
TX3912_VIDEO_CTRL1_BITSEL_4BIT_GRAY,
TX3912_VIDEO_CTRL1);
tx3912fb_fix.visual = FB_VISUAL_TRUECOLOR;
tx3912fb_fix.grayscale = 1;
break; break;
case 8: case 8:
/* 8-bit color */ /* 8-bit color */
VidCtrl1 &= ~TX3912_VIDCTRL1_BITSEL_MASK; outl(inl(TX3912_VIDEO_CTRL1) &
VidCtrl1 |= TX3912_VIDCTRL1_8BIT_COLOR; ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
outl(inl(TX3912_VIDEO_CTRL1) |
TX3912_VIDEO_CTRL1_BITSEL_8BIT_COLOR,
TX3912_VIDEO_CTRL1);
tx3912fb_fix.visual = FB_VISUAL_TRUECOLOR;
break; break;
case 2: case 2:
default: default:
/* 2-bit gray */ /* 2-bit gray */
VidCtrl1 &= ~TX3912_VIDCTRL1_BITSEL_MASK; outl(inl(TX3912_VIDEO_CTRL1) &
VidCtrl1 |= TX3912_VIDCTRL1_2BIT_GRAY; ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
outl(inl(TX3912_VIDEO_CTRL1) |
TX3912_VIDEO_CTRL1_BITSEL_2BIT_GRAY,
TX3912_VIDEO_CTRL1);
tx3912fb_fix.visual = FB_VISUAL_PSEUDOCOLOR;
tx3912fb_fix.grayscale = 1;
break; break;
} }
/* Enable the video clock */
outl(inl(TX3912_CLK_CTRL) | TX3912_CLK_CTRL_ENVIDCLK,
TX3912_CLK_CTRL);
/* Unfreeze video logic and enable DF toggle */ /* Unfreeze video logic and enable DF toggle */
VidCtrl1 &= ~(ENFREEZEFRAME | DFMODE); outl(inl(TX3912_VIDEO_CTRL1) &
~(TX3912_VIDEO_CTRL1_ENFREEZEFRAME | TX3912_VIDEO_CTRL1_DFMODE),
TX3912_VIDEO_CTRL1);
udelay(200); udelay(200);
/* Clear the framebuffer */ /* Clear the framebuffer */
memset((void *) tx3912fb_vaddr, 0xff, tx3912fb_size); memset((void *) tx3912fb_fix.smem_start, 0xff, tx3912fb_fix.smem_len);
udelay(200); udelay(200);
/* Enable the video logic */ /* Enable the video logic */
VidCtrl1 |= (DISPON | ENVID); outl(inl(TX3912_VIDEO_CTRL1) |
(TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON),
TX3912_VIDEO_CTRL1);
/*
* Memory limit
*/
tx3912fb_fix.line_length =
get_line_length(tx3912fb_var.xres_virtual, tx3912fb_var.bits_per_pixel);
if ((tx3912fb_fix.line_length * tx3912fb_var.yres_virtual) > tx3912fb_fix.smem_len)
return -ENOMEM;
strcpy(fb_info.modename, TX3912FB_NAME); strcpy(fb_info.modename, tx3912fb_fix.id);
fb_info.changevar = NULL; fb_info.changevar = NULL;
fb_info.node = NODEV; fb_info.node = NODEV;
fb_info.fbops = &tx3912fb_ops;
fb_info.screen_base = (u_char *) tx3912fb_vaddr;
fb_info.disp = &global_disp;
fb_info.currcon = -1; fb_info.currcon = -1;
fb_info.switch_con = &tx3912fbcon_switch; fb_info.fbops = &tx3912fb_ops;
fb_info.updatevar = &tx3912fbcon_updatevar; fb_info.var = tx3912fb_var;
fb_info.fix = tx3912fb_fix;
fb_info.pseudo_palette = pseudo_palette;
fb_info.disp = &disp;
fb_info.switch_con = gen_switch;
fb_info.updatevar = gen_update_var;
fb_info.flags = FBINFO_FLAG_DEFAULT; fb_info.flags = FBINFO_FLAG_DEFAULT;
tx3912fb_set_var(&tx3912fb_info, -1, &fb_info); /* Clear the framebuffer */
memset((void *) fb_info.fix.smem_start, 0xff, fb_info.fix.smem_len);
udelay(200);
fb_alloc_cmap(&info->cmap, size, 0);
gen_set_disp(-1, &disp);
if (register_framebuffer(&fb_info) < 0) if (register_framebuffer(&fb_info) < 0)
return -1; return -1;
printk (KERN_INFO "fb%d: TX3912 frame buffer using %uKB.\n", printk(KERN_INFO "fb%d: TX3912 frame buffer using %uKB.\n",
GET_FB_IDX(fb_info.node), (u_int) (tx3912fb_size >> 10)); GET_FB_IDX(fb_info.node), (u_int) (fb_info.fix.smem_len >> 10));
return 0; return 0;
} }
/* int __init tx3912fb_setup(char *options)
* Switch the console to be the framebuffer
*/
static int tx3912fbcon_switch(int con, struct fb_info *info)
{ {
/* Save off the color map if needed */ char *this_opt;
if (fb_display[info->currcon].cmap.len)
fb_get_cmap(&fb_display[info->currcon].cmap, 1,
tx3912fb_getcolreg, info);
/* Make the switch */
info->currcon = con;
/* Install new colormap */
do_install_cmap(con, info);
return 0;
}
/* if (!options || !*options)
* Update variable structure
*/
static int tx3912fbcon_updatevar(int con, struct fb_info *info)
{
/* Nothing */
return 0; return 0;
}
/* while ((this_opt = strsep(&options, ","))) {
* Read a single color register if (!strncmp(options, "bpp:", 4))
*/ tx3912fb_var.bits_per_pixel = simple_strtoul(options+4, NULL, 0);
static int tx3912fb_getcolreg(u_int regno, u_int *red, u_int *green,
u_int *blue, u_int *transp, struct fb_info *info)
{
if (regno > 255)
return 1;
#if FB_IS_GREY
{
u_int grey;
grey = regno * 255 / 15;
#if FB_IS_INVERSE
grey ^= 255;
#endif
grey |= grey << 8;
*red = grey;
*green = grey;
*blue = grey;
} }
#else
*red = (palette[regno].red<<8) | palette[regno].red;
*green = (palette[regno].green<<8) | palette[regno].green;
*blue = (palette[regno].blue<<8) | palette[regno].blue;
#endif
*transp = 0;
return 0;
}
/*
* Set a single color register
*/
static int tx3912fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{
if (regno > 255)
return 1;
#ifdef FBCON_HAS_CFB8
if( regno < 16 )
fbcon_cmap.cfb8[regno] = ((red & 0xe000) >> 8)
| ((green & 0xe000) >> 11)
| ((blue & 0xc000) >> 14);
#endif
red >>= 8;
green >>= 8;
blue >>= 8;
palette[regno].red = red;
palette[regno].green = green;
palette[regno].blue = blue;
return 0;
} }
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
/* /*
* linux/drivers/video/tx3912fb.h * linux/include/video/tx3912.h
* *
* Copyright (C) 2001 Steven Hill (sjhill@realitydiluted.com) * Copyright (C) 2001 Steven Hill (sjhill@realitydiluted.com)
* *
...@@ -60,69 +60,3 @@ ...@@ -60,69 +60,3 @@
/* Video Control 4 Register */ /* Video Control 4 Register */
#define TX3912_VIDCTRL4_VIDBASELO_MASK 0x000ffff0 #define TX3912_VIDCTRL4_VIDBASELO_MASK 0x000ffff0
/*
* Begin platform specific configurations
*/
#if defined(CONFIG_NINO_4MB) || defined(CONFIG_NINO_8MB)
#define FB_X_RES 240
#define FB_Y_RES 320
#if defined(CONFIG_FBCON_CFB4)
#define FB_BPP 4
#else
#if defined(CONFIG_FBCON_CFB2)
#define FB_BPP 2
#else
#define FB_BPP 1
#endif
#endif
#define FB_IS_GREY 1
#define FB_IS_INVERSE 0
#endif
#ifdef CONFIG_NINO_16MB
#define FB_X_RES 240
#define FB_Y_RES 320
#define FB_BPP 8
#define FB_IS_GREY 0
#define FB_IS_INVERSE 0
#endif
/*
* Define virtual resolutions if necessary
*/
#ifndef FB_X_VIRTUAL_RES
#define FB_X_VIRTUAL_RES FB_X_RES
#endif
#ifndef FB_Y_VIRTUAL_RES
#define FB_Y_VIRTUAL_RES FB_Y_RES
#endif
/*
* Framebuffer address and size
*/
u_long tx3912fb_paddr = 0;
u_long tx3912fb_vaddr = 0;
u_long tx3912fb_size = (FB_X_RES * FB_Y_RES * FB_BPP / 8);
/*
* Framebuffer info structure
*/
static struct fb_var_screeninfo tx3912fb_info = {
FB_X_RES, FB_Y_RES,
FB_X_VIRTUAL_RES, FB_Y_VIRTUAL_RES,
0, 0,
FB_BPP, FB_IS_GREY,
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
0, FB_ACTIVATE_NOW,
-1, -1, 0, 20000,
64, 64, 32, 32, 64, 2,
0, FB_VMODE_NONINTERLACED,
{0,0,0,0,0,0}
};
/*
* Framebuffer name
*/
static char TX3912FB_NAME[16] = "tx3912fb";
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