Commit e417962c authored by Paul Mundt's avatar Paul Mundt Committed by Stephen Lord

[PATCH] pvr2fb update

Here's an update for pvr2fb (with a patch this time), which makes it compile
again.
parent 909bd86e
...@@ -69,7 +69,7 @@ obj-$(CONFIG_FB_SA1100) += sa1100fb.o cfbfillrect.o cfbcopyarea.o cfbi ...@@ -69,7 +69,7 @@ obj-$(CONFIG_FB_SA1100) += sa1100fb.o cfbfillrect.o cfbcopyarea.o cfbi
obj-$(CONFIG_FB_VIRTUAL) += vfb.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 cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_E1355) += epson1355fb.o obj-$(CONFIG_FB_E1355) += epson1355fb.o
obj-$(CONFIG_FB_PVR2) += pvr2fb.o obj-$(CONFIG_FB_PVR2) += pvr2fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_VOODOO1) += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_VOODOO1) += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_FFB) += ffb.o sbuslib.o cfbimgblt.o cfbcopyarea.o obj-$(CONFIG_FB_FFB) += ffb.o sbuslib.o cfbimgblt.o cfbcopyarea.o
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Dreamcast. * Dreamcast.
* *
* Copyright (c) 2001 M. R. Brown <mrbrown@0xd6.org> * Copyright (c) 2001 M. R. Brown <mrbrown@0xd6.org>
* Copyright (c) 2001 Paul Mundt <lethal@chaoticdreams.org> * Copyright (c) 2001, 2002, 2003 Paul Mundt <lethal@linux-sh.org>
* *
* This file is part of the LinuxDC project (linuxdc.sourceforge.net). * This file is part of the LinuxDC project (linuxdc.sourceforge.net).
* *
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
/* /*
* This driver is mostly based on the excellent amifb and vfb sources. It uses * This driver is mostly based on the excellent amifb and vfb sources. It uses
* an odd scheme for converting hardware values to/from framebuffer values, here are * an odd scheme for converting hardware values to/from framebuffer values,
* some hacked-up formulas: * here are some hacked-up formulas:
* *
* The Dreamcast has screen offsets from each side of its four borders and the start * The Dreamcast has screen offsets from each side of its four borders and
* offsets of the display window. I used these values to calculate 'pseudo' values * the start offsets of the display window. I used these values to calculate
* (think of them as placeholders) for the fb video mode, so that when it came time * 'pseudo' values (think of them as placeholders) for the fb video mode, so
* to convert these values back into their hardware values, I could just add mode- * that when it came time to convert these values back into their hardware
* specific offsets to get the correct mode settings: * values, I could just add mode- specific offsets to get the correct mode
* settings:
* *
* left_margin = diwstart_h - borderstart_h; * left_margin = diwstart_h - borderstart_h;
* right_margin = borderstop_h - (diwstart_h + xres); * right_margin = borderstop_h - (diwstart_h + xres);
...@@ -29,9 +30,9 @@ ...@@ -29,9 +30,9 @@
* hsync_len = borderstart_h + (hsync_total - borderstop_h); * hsync_len = borderstart_h + (hsync_total - borderstop_h);
* vsync_len = borderstart_v + (vsync_total - borderstop_v); * vsync_len = borderstart_v + (vsync_total - borderstop_v);
* *
* Then, when it's time to convert back to hardware settings, the only constants * Then, when it's time to convert back to hardware settings, the only
* are the borderstart_* offsets, all other values are derived from the fb video * constants are the borderstart_* offsets, all other values are derived from
* mode: * the fb video mode:
* *
* // PAL * // PAL
* borderstart_h = 116; * borderstart_h = 116;
...@@ -57,7 +58,6 @@ ...@@ -57,7 +58,6 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/console.h>
#ifdef CONFIG_SH_DREAMCAST #ifdef CONFIG_SH_DREAMCAST
#include <asm/io.h> #include <asm/io.h>
...@@ -66,14 +66,9 @@ ...@@ -66,14 +66,9 @@
#endif #endif
#ifdef CONFIG_MTRR #ifdef CONFIG_MTRR
#include <asm/mtrr.h> #include <asm/mtrr.h>
#endif #endif
#include <video/fbcon.h>
#include <video/fbcon-cfb16.h>
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
#ifdef CONFIG_FB_PVR2_DEBUG #ifdef CONFIG_FB_PVR2_DEBUG
# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
#else #else
...@@ -124,16 +119,6 @@ static struct pvr2_params outputs[] __initdata = { ...@@ -124,16 +119,6 @@ static struct pvr2_params outputs[] __initdata = {
*/ */
static struct pvr2fb_par { static struct pvr2fb_par {
int xres;
int yres;
int vxres;
int vyres;
int xoffset;
int yoffset;
u_short bpp;
u_long pixclock;
u_short hsync_total; /* Clocks/line */ u_short hsync_total; /* Clocks/line */
u_short vsync_total; /* Lines/field */ u_short vsync_total; /* Lines/field */
u_short borderstart_h; u_short borderstart_h;
...@@ -144,53 +129,49 @@ static struct pvr2fb_par { ...@@ -144,53 +129,49 @@ static struct pvr2fb_par {
u_short diwstart_v; /* Vertical offset of the display field, for u_short diwstart_v; /* Vertical offset of the display field, for
interlaced modes, this is the long field */ interlaced modes, this is the long field */
u_long disp_start; /* Address of image within VRAM */ u_long disp_start; /* Address of image within VRAM */
u_long next_line; /* Modulo for next line */
u_char is_interlaced; /* Is the display interlaced? */ u_char is_interlaced; /* Is the display interlaced? */
u_char is_doublescan; /* Are scanlines output twice? (doublescan) */ u_char is_doublescan; /* Are scanlines output twice? (doublescan) */
u_char is_lowres; /* Is horizontal pixel-doubling enabled? */ u_char is_lowres; /* Is horizontal pixel-doubling enabled? */
} *currentpar;
u_long bordercolor; /* RGB888 format border color */ static struct fb_info *fb_info;
u_long vmode;
} currentpar;
static int currbpp;
static struct display disp;
static struct fb_info fb_info;
static int pvr2fb_inverse = 0; static int pvr2fb_inverse = 0;
static struct { u_short red, green, blue, alpha; } palette[256]; static struct fb_fix_screeninfo pvr2_fix __initdata = {
static union { .id = "NEC PowerVR2",
#ifdef FBCON_HAS_CFB16 .type = FB_TYPE_PACKED_PIXELS,
u16 cfb16[16]; .visual = FB_VISUAL_TRUECOLOR,
#endif .ypanstep = 1,
#ifdef FBCON_HAS_CFB24 .ywrapstep = 1,
u32 cfb24[16]; .accel = FB_ACCEL_NONE,
#endif };
#ifdef FBCON_HAS_CFB32
u32 cfb32[16];
#endif
} fbcon_cmap;
static char pvr2fb_name[16] = "NEC PowerVR2"; static struct fb_var_screeninfo pvr2_var __initdata = {
.xres = 640,
.yres = 480,
.xres_virtual = 640,
.yres_virtual = 480,
.bits_per_pixel =16,
.red = { 11, 5, 0 },
.green = { 5, 6, 0 },
.blue = { 0, 5, 0 },
.activate = FB_ACTIVATE_NOW,
.height = -1,
.width = -1,
.vmode = FB_VMODE_NONINTERLACED,
};
#define VIDEOMEMSIZE (8*1024*1024) #define VIDEOMEMSIZE (8*1024*1024)
static u_long videomemory = 0xa5000000, videomemorysize = VIDEOMEMSIZE; static u_long videomemory = 0xa5000000, videomemorysize = VIDEOMEMSIZE;
static int cable_type = -1; static int cable_type = -1;
static int video_output = -1; static int video_output = -1;
#ifdef CONFIG_MTRR static int nopan = 0;
static int enable_mtrr = 1; static int nowrap = 1;
static int mtrr_handle;
#endif
/* /*
* We do all updating, blanking, etc. during the vertical retrace period * We do all updating, blanking, etc. during the vertical retrace period
*/ */
static u_short do_vmode_full = 0; /* Change the video mode */ static u_short do_vmode_full = 0; /* Change the video mode */
static u_short do_vmode_pan = 0; /* Update the video mode */ static u_short do_vmode_pan = 0; /* Update the video mode */
static short do_blank = 0; /* (Un)Blank the screen */ static short do_blank = 0; /* (Un)Blank the screen */
...@@ -201,50 +182,15 @@ static u_short is_blanked = 0; /* Is the screen blanked? */ ...@@ -201,50 +182,15 @@ static u_short is_blanked = 0; /* Is the screen blanked? */
int pvr2fb_setup(char*); int pvr2fb_setup(char*);
static int pvr2fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
static int pvr2fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int pvr2fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int pvr2fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int pvr2fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
static int pvr2fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info); u_int transp, struct fb_info *info);
static int pvr2fb_blank(int blank, struct fb_info *info); static int pvr2fb_blank(int blank, struct fb_info *info);
/*
* Interface to the low level console driver
*/
static int pvr2fbcon_switch(int con, struct fb_info *info);
static int pvr2fbcon_updatevar(int con, struct fb_info *info);
/*
* Internal/hardware-specific routines
*/
static u_long get_line_length(int xres_virtual, int bpp); static u_long get_line_length(int xres_virtual, int bpp);
static void set_color_bitfields(struct fb_var_screeninfo *var); static void set_color_bitfields(struct fb_var_screeninfo *var);
static int pvr2_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue, static int pvr2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info);
u_int *transp, struct fb_info *info); static int pvr2fb_set_par(struct fb_info *info);
static void pvr2_update_display(struct fb_info *info);
static int pvr2_encode_fix(struct fb_fix_screeninfo *fix, static void pvr2_init_display(struct fb_info *info);
struct pvr2fb_par *par);
static int pvr2_decode_var(struct fb_var_screeninfo *var,
struct pvr2fb_par *par);
static int pvr2_encode_var(struct fb_var_screeninfo *var,
struct pvr2fb_par *par);
static void pvr2_get_par(struct pvr2fb_par *par);
static void pvr2_set_var(struct fb_var_screeninfo *var);
static void pvr2_pan_var(struct fb_var_screeninfo *var);
static int pvr2_update_par(void);
static void pvr2_update_display(void);
static void pvr2_init_display(void);
static void pvr2_do_blank(void); static void pvr2_do_blank(void);
static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp); static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp);
static int pvr2_init_cable(void); static int pvr2_init_cable(void);
...@@ -253,18 +199,17 @@ static int pvr2_get_param(const struct pvr2_params *p, const char *s, ...@@ -253,18 +199,17 @@ static int pvr2_get_param(const struct pvr2_params *p, const char *s,
static struct fb_ops pvr2fb_ops = { static struct fb_ops pvr2fb_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.fb_get_fix = pvr2fb_get_fix,
.fb_get_var = pvr2fb_get_var,
.fb_set_var = pvr2fb_set_var,
.fb_get_cmap = pvr2fb_get_cmap,
.fb_set_cmap = pvr2fb_set_cmap,
.fb_setcolreg = pvr2fb_setcolreg, .fb_setcolreg = pvr2fb_setcolreg,
.fb_pan_display = pvr2fb_pan_display,
.fb_blank = pvr2fb_blank, .fb_blank = pvr2fb_blank,
.fb_check_var = pvr2fb_check_var,
.fb_set_par = pvr2fb_set_par,
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
.fb_cursor = soft_cursor,
}; };
static struct fb_videomode pvr2_modedb[] __initdata = { static struct fb_videomode pvr2_modedb[] __initdata = {
/* /*
* Broadcast video modes (PAL and NTSC). I'm unfamiliar with * Broadcast video modes (PAL and NTSC). I'm unfamiliar with
* PAL-M and PAL-N, but from what I've read both modes parallel PAL and * PAL-M and PAL-N, but from what I've read both modes parallel PAL and
...@@ -275,21 +220,16 @@ static struct fb_videomode pvr2_modedb[] __initdata = { ...@@ -275,21 +220,16 @@ static struct fb_videomode pvr2_modedb[] __initdata = {
/* 640x480 @ 60Hz interlaced (NTSC) */ /* 640x480 @ 60Hz interlaced (NTSC) */
"ntsc_640x480i", 60, 640, 480, TV_CLK, 38, 33, 0, 18, 146, 26, "ntsc_640x480i", 60, 640, 480, TV_CLK, 38, 33, 0, 18, 146, 26,
FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
}, }, {
{
/* 640x240 @ 60Hz (NTSC) */ /* 640x240 @ 60Hz (NTSC) */
/* XXX: Broken! Don't use... */ /* XXX: Broken! Don't use... */
"ntsc_640x240", 60, 640, 240, TV_CLK, 38, 33, 0, 0, 146, 22, "ntsc_640x240", 60, 640, 240, TV_CLK, 38, 33, 0, 0, 146, 22,
FB_SYNC_BROADCAST, FB_VMODE_YWRAP FB_SYNC_BROADCAST, FB_VMODE_YWRAP
}, }, {
{
/* 640x480 @ 60hz (VGA) */ /* 640x480 @ 60hz (VGA) */
"vga_640x480", 60, 640, 480, VGA_CLK, 38, 33, 0, 18, 146, 26, "vga_640x480", 60, 640, 480, VGA_CLK, 38, 33, 0, 18, 146, 26,
0, FB_VMODE_YWRAP 0, FB_VMODE_YWRAP
}, },
}; };
#define NUM_TOTAL_MODES ARRAY_SIZE(pvr2_modedb) #define NUM_TOTAL_MODES ARRAY_SIZE(pvr2_modedb)
...@@ -301,222 +241,10 @@ static struct fb_videomode pvr2_modedb[] __initdata = { ...@@ -301,222 +241,10 @@ static struct fb_videomode pvr2_modedb[] __initdata = {
static int defmode = DEFMODE_NTSC; static int defmode = DEFMODE_NTSC;
static char *mode_option __initdata = NULL; static char *mode_option __initdata = NULL;
/* Get the fixed part of the display */
static int pvr2fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
{
struct pvr2fb_par par;
if (con == -1)
pvr2_get_par(&par);
else {
int err;
if ((err = pvr2_decode_var(&fb_display[con].var, &par)))
return err;
}
return pvr2_encode_fix(fix, &par);
}
/* Get the user-defined part of the display */
static int pvr2fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
int err = 0;
if (con == -1) {
struct pvr2fb_par par;
pvr2_get_par(&par);
err = pvr2_encode_var(var, &par);
} else
*var = fb_display[con].var;
return err;
}
/* Set the user-defined part of the display */
static int pvr2fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
int err, activate = var->activate;
int oldxres, oldyres, oldvxres, oldvyres, oldbpp;
struct pvr2fb_par par;
struct display *display;
if (con >= 0)
display = &fb_display[con];
else
display = &disp; /* used during initialization */
/*
* 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->vmode |= FB_VMODE_YWRAP;
var->xoffset = display->var.xoffset;
var->yoffset = display->var.yoffset;
}
if ((err = pvr2_decode_var(var, &par)))
return err;
pvr2_encode_var(var, &par);
/* Do memory check and bitfield set here?? */
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 ||
oldvxres != var->xres_virtual || oldvyres != var->yres_virtual ||
oldbpp != var->bits_per_pixel) {
struct fb_fix_screeninfo fix;
pvr2_encode_fix(&fix, &par);
display->scrollmode = SCROLL_YREDRAW;
display->visual = fix.visual;
display->type = fix.type;
display->type_aux = fix.type_aux;
display->ypanstep = fix.ypanstep;
display->ywrapstep = fix.ywrapstep;
display->line_length = fix.line_length;
display->can_soft_blank = 1;
display->inverse = pvr2fb_inverse;
switch (var->bits_per_pixel) {
#ifdef FBCON_HAS_CFB16
case 16:
display->dispsw = &fbcon_cfb16;
display->dispsw_data = fbcon_cmap.cfb16;
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:
display->dispsw = &fbcon_cfb24;
display->dispsw_data = fbcon_cmap.cfb24;
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
display->dispsw = &fbcon_cfb32;
display->dispsw_data = fbcon_cmap.cfb32;
break;
#endif
default:
display->dispsw = &fbcon_dummy;
break;
}
if (fb_info.changevar)
(*fb_info.changevar)(con);
}
if (oldbpp != var->bits_per_pixel) {
if ((err = fb_alloc_cmap(&display->cmap, 0, 0)))
return err;
do_install_cmap(con, info);
}
if (con == info->currcon)
pvr2_set_var(&display->var);
}
return 0;
}
/*
* Pan or wrap the display.
* This call looks only at xoffset, yoffset and the FB_VMODE_YRAP flag
*/
static int pvr2fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
if (var->vmode & FB_VMODE_YWRAP) {
if (var->yoffset<0 || var->yoffset >=
fb_display[con].var.yres_virtual || var->xoffset)
return -EINVAL;
} else {
if (var->xoffset+fb_display[con].var.xres >
fb_display[con].var.xres_virtual ||
var->yoffset+fb_display[con].var.yres >
fb_display[con].var.yres_virtual)
return -EINVAL;
}
if (con == info->currcon)
pvr2_pan_var(var);
fb_display[con].var.xoffset = var->xoffset;
fb_display[con].var.yoffset = var->yoffset;
if (var->vmode & FB_VMODE_YWRAP)
fb_display[con].var.vmode |= FB_VMODE_YWRAP;
else
fb_display[con].var.vmode &= ~FB_VMODE_YWRAP;
return 0;
}
/* Get the colormap */
static int pvr2fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
if (con == info->currcon) /* current console? */
return fb_get_cmap(cmap, kspc, pvr2_getcolreg, info);
else if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else
fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel),
cmap, kspc ? 0 : 2);
return 0;
}
/* Set the colormap */
static int pvr2fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
int err;
if (!fb_display[con].cmap.len) { /* no colormap allocated? */
if ((err = fb_alloc_cmap(&fb_display[con].cmap,
1<<fb_display[con].var.bits_per_pixel,
0)))
return err;
}
if (con == info->currcon) /* current console? */
return fb_set_cmap(cmap, kspc, info);
else
fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);
return 0;
}
static int pvr2fbcon_switch(int con, struct fb_info *info)
{
/* Do we have to save the colormap? */
if (fb_display[info->currcon].cmap.len)
fb_get_cmap(&fb_display[info->currcon].cmap, 1, pvr2_getcolreg, info);
info->currcon = con;
pvr2_set_var(&fb_display[con].var);
/* Install new colormap */
do_install_cmap(con, info);
return 0;
}
static int pvr2fbcon_updatevar(int con, struct fb_info *info)
{
pvr2_pan_var(&fb_display[con].var);
return 0;
}
static int pvr2fb_blank(int blank, struct fb_info *info) static int pvr2fb_blank(int blank, struct fb_info *info)
{ {
do_blank = blank ? blank : -1; do_blank = blank ? blank : -1;
return 0;
} }
static inline u_long get_line_length(int xres_virtual, int bpp) static inline u_long get_line_length(int xres_virtual, int bpp)
...@@ -548,52 +276,29 @@ static void set_color_bitfields(struct fb_var_screeninfo *var) ...@@ -548,52 +276,29 @@ static void set_color_bitfields(struct fb_var_screeninfo *var)
} }
} }
static int pvr2_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;
*red = palette[regno].red;
*green = palette[regno].green;
*blue = palette[regno].blue;
*transp = 0;
return 0;
}
static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info) u_int transp, struct fb_info *info)
{ {
if (regno > 255) if (regno > 255)
return 1; return 1;
palette[regno].red = red;
palette[regno].green = green;
palette[regno].blue = blue;
if (regno < 16) { if (regno < 16) {
switch (currbpp) { switch (info->var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB16
case 16: /* RGB 565 */ case 16: /* RGB 565 */
fbcon_cmap.cfb16[regno] = (red & 0xf800) | ((u16*)(info->pseudo_palette))[regno] = (red & 0xf800) |
((green & 0xfc00) >> 5) | ((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11); ((blue & 0xf800) >> 11);
break; break;
#endif
#ifdef FBCON_HAS_CFB24
case 24: /* RGB 888 */ case 24: /* RGB 888 */
red >>= 8; green >>= 8; blue >>= 8; red >>= 8; green >>= 8; blue >>= 8;
fbcon_cmap.cfb24[regno] = (red << 16) | (green << 8) | blue; ((u32*)(info->pseudo_palette))[regno] = (red << 16) | (green << 8) | blue;
break; break;
#endif
#ifdef FBCON_HAS_CFB32
case 32: /* ARGB 8888 */ case 32: /* ARGB 8888 */
red >>= 8; green >>= 8; blue >>= 8; red >>= 8; green >>= 8; blue >>= 8;
fbcon_cmap.cfb32[regno] = (red << 16) | (green << 8) | blue; ((u32*)(info->pseudo_palette))[regno] = (transp << 24) |(red << 16) | (green << 8) | blue;
break; break;
#endif
default: default:
DPRINTK("Invalid bit depth %d?!?\n", currbpp); DPRINTK("Invalid bit depth %d?!?\n", info->var.bits_per_pixel);
return 1; return 1;
} }
} }
...@@ -601,85 +306,33 @@ static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ...@@ -601,85 +306,33 @@ static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
return 0; return 0;
} }
static int pvr2fb_set_par(struct fb_info *info)
static int pvr2_encode_fix(struct fb_fix_screeninfo *fix,
struct pvr2fb_par *par)
{
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id, pvr2fb_name);
fix->smem_start = videomemory;
fix->smem_len = videomemorysize;
fix->type = FB_TYPE_PACKED_PIXELS;
fix->type_aux = 0;
fix->visual = FB_VISUAL_TRUECOLOR;
if (par->vmode & FB_VMODE_YWRAP) {
fix->ywrapstep = 1;
fix->xpanstep = fix->ypanstep = 0;
} else {
fix->ywrapstep = 0;
fix->xpanstep = 1;
fix->ypanstep = 1;
}
fix->line_length = par->next_line;
return 0;
}
/*
* Create a hardware video mode using the framebuffer values. If a value needs
* to be clipped or constrained it's done here. This routine needs a bit more
* work to make sure we're doing the right tests at the right time.
*/
static int pvr2_decode_var(struct fb_var_screeninfo *var,
struct pvr2fb_par *par)
{ {
struct pvr2fb_par *par = (struct pvr2fb_par *)info->par;
struct fb_var_screeninfo *var = &info->var;
u_long line_length; u_long line_length;
u_short vtotal; u_short vtotal;
if (var->pixclock != TV_CLK && var->pixclock != VGA_CLK) {
DPRINTK("Invalid pixclock value %d\n", var->pixclock);
return -EINVAL;
}
par->pixclock = var->pixclock;
if ((par->xres = var->xres) < 320)
par->xres = 320;
if ((par->yres = var->yres) < 240)
par->yres = 240;
if ((par->vxres = var->xres_virtual) < par->xres)
par->vxres = par->xres;
if ((par->vyres = var->yres_virtual) < par->yres)
par->vyres = par->yres;
if ((par->bpp = var->bits_per_pixel) <= 16)
par->bpp = 16;
else if ((par->bpp = var->bits_per_pixel) <= 24)
par->bpp = 24;
else if ((par->bpp = var->bits_per_pixel) <= 32)
par->bpp = 32;
currbpp = par->bpp;
/* /*
* XXX: It's possible that a user could use a VGA box, change the cable * XXX: It's possible that a user could use a VGA box, change the cable
* type in hardware (i.e. switch from VGA<->composite), then change modes * type in hardware (i.e. switch from VGA<->composite), then change
* (i.e. switching to another VT). If that happens we should automagically * modes (i.e. switching to another VT). If that happens we should
* change the output format to cope, but currently I don't have a VGA box * automagically change the output format to cope, but currently I
* to make sure this works properly. * don't have a VGA box to make sure this works properly.
*/ */
cable_type = pvr2_init_cable(); cable_type = pvr2_init_cable();
if (cable_type == CT_VGA && video_output != VO_VGA) if (cable_type == CT_VGA && video_output != VO_VGA)
video_output = VO_VGA; video_output = VO_VGA;
par->vmode = var->vmode & FB_VMODE_MASK; var->vmode &= FB_VMODE_MASK;
if (par->vmode & FB_VMODE_INTERLACED && video_output != VO_VGA) if (var->vmode & FB_VMODE_INTERLACED && video_output != VO_VGA)
par->is_interlaced = 1; par->is_interlaced = 1;
/* /*
* XXX: Need to be more creative with this (i.e. allow doublecan for * XXX: Need to be more creative with this (i.e. allow doublecan for
* PAL/NTSC output). * PAL/NTSC output).
*/ */
par->is_doublescan = (par->yres < 480 && video_output == VO_VGA); if (var->vmode & FB_VMODE_DOUBLE && video_output == VO_VGA)
par->is_doublescan = 1;
par->hsync_total = var->left_margin + var->xres + var->right_margin + par->hsync_total = var->left_margin + var->xres + var->right_margin +
var->hsync_len; var->hsync_len;
...@@ -691,22 +344,12 @@ static int pvr2_decode_var(struct fb_var_screeninfo *var, ...@@ -691,22 +344,12 @@ static int pvr2_decode_var(struct fb_var_screeninfo *var,
if (par->is_interlaced) if (par->is_interlaced)
vtotal /= 2; vtotal /= 2;
if (vtotal > (PAL_VTOTAL + NTSC_VTOTAL)/2) { if (vtotal > (PAL_VTOTAL + NTSC_VTOTAL)/2) {
/* PAL video output */
/* XXX: Should be using a range here ... ? */
if (par->hsync_total != PAL_HTOTAL) {
DPRINTK("invalid hsync total for PAL\n");
return -EINVAL;
}
/* XXX: Check for start values here... */ /* XXX: Check for start values here... */
/* XXX: Check hardware for PAL-compatibility */ /* XXX: Check hardware for PAL-compatibility */
par->borderstart_h = 116; par->borderstart_h = 116;
par->borderstart_v = 44; par->borderstart_v = 44;
} else { } else {
/* NTSC video output */ /* NTSC video output */
if (par->hsync_total != NTSC_HTOTAL) {
DPRINTK("invalid hsync total for NTSC\n");
return -EINVAL;
}
par->borderstart_h = 126; par->borderstart_h = 126;
par->borderstart_v = 18; par->borderstart_v = 18;
} }
...@@ -714,155 +357,123 @@ static int pvr2_decode_var(struct fb_var_screeninfo *var, ...@@ -714,155 +357,123 @@ static int pvr2_decode_var(struct fb_var_screeninfo *var,
/* VGA mode */ /* VGA mode */
/* XXX: What else needs to be checked? */ /* XXX: What else needs to be checked? */
/* /*
* XXX: We have a little freedom in VGA modes, what ranges should * XXX: We have a little freedom in VGA modes, what ranges
* be here (i.e. hsync/vsync totals, etc.)? * should be here (i.e. hsync/vsync totals, etc.)?
*/ */
par->borderstart_h = 126; par->borderstart_h = 126;
par->borderstart_v = 40; par->borderstart_v = 40;
} }
/* Calculate the remainding offsets */ /* Calculate the remainding offsets */
par->borderstop_h = par->borderstart_h + par->hsync_total -
var->hsync_len;
par->borderstop_v = par->borderstart_v + par->vsync_total -
var->vsync_len;
par->diwstart_h = par->borderstart_h + var->left_margin; par->diwstart_h = par->borderstart_h + var->left_margin;
par->diwstart_v = par->borderstart_v + var->upper_margin; par->diwstart_v = par->borderstart_v + var->upper_margin;
par->borderstop_h = par->diwstart_h + var->xres +
var->right_margin;
par->borderstop_v = par->diwstart_v + var->yres +
var->lower_margin;
if (!par->is_interlaced) if (!par->is_interlaced)
par->borderstop_v /= 2; par->borderstop_v /= 2;
if (info->var.xres < 640)
if (par->xres < 640)
par->is_lowres = 1; par->is_lowres = 1;
/* XXX: Needs testing. */
if (!((par->vmode ^ var->vmode) & FB_VMODE_YWRAP)) {
par->xoffset = var->xoffset;
par->yoffset = var->yoffset;
if (par->vmode & FB_VMODE_YWRAP) {
if (par->xoffset || par->yoffset < 0 || par->yoffset >=
par->vyres)
par->xoffset = par->yoffset = 0;
} else {
if (par->xoffset < 0 || par->xoffset > par->vxres-par->xres ||
par->yoffset < 0 || par->yoffset > par->vyres-par->yres)
par->xoffset = par->yoffset = 0;
}
} else
par->xoffset = par->yoffset = 0;
/* Check memory sizes */
line_length = get_line_length(var->xres_virtual, var->bits_per_pixel); line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
if (line_length * var->yres_virtual > videomemorysize) par->disp_start = videomemory + (line_length * var->yoffset) * line_length;
return -ENOMEM; info->fix.line_length = line_length;
par->disp_start = videomemory + (get_line_length(par->vxres, par->bpp) *
par->yoffset) * get_line_length(par->xoffset, par->bpp);
par->next_line = line_length;
return 0; return 0;
} }
static int pvr2_encode_var(struct fb_var_screeninfo *var, static int pvr2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
struct pvr2fb_par *par)
{ {
memset(var, 0, sizeof(struct fb_var_screeninfo)); u_short vtotal, hsync_total;
u_long line_length;
var->xres = par->xres; if (var->pixclock != TV_CLK || var->pixclock != VGA_CLK) {
var->yres = par->yres; DPRINTK("Invalid pixclock value %d\n", var->pixclock);
var->xres_virtual = par->vxres; return -EINVAL;
var->yres_virtual = par->vyres; }
var->xoffset = par->xoffset;
var->yoffset = par->yoffset;
var->bits_per_pixel = par->bpp; if (var->xres < 320)
set_color_bitfields(var); var->xres = 320;
if (var->yres < 240)
var->yres = 240;
if (var->xres_virtual < var->xres)
var->xres_virtual = var->xres;
if (var->yres_virtual < var->yres)
var->yres_virtual = var->yres;
if (var->bits_per_pixel <= 16)
var->bits_per_pixel = 16;
else if (var->bits_per_pixel <= 24)
var->bits_per_pixel = 24;
else if (var->bits_per_pixel <= 32)
var->bits_per_pixel = 32;
var->activate = FB_ACTIVATE_NOW; set_color_bitfields(var);
var->height = -1;
var->width = -1;
var->pixclock = par->pixclock; if (var->vmode & FB_VMODE_YWRAP) {
if (var->xoffset || var->yoffset < 0 ||
var->yoffset >= var->yres_virtual) {
var->xoffset = var->yoffset = 0;
} else {
if (var->xoffset > var->xres_virtual - var->xres ||
var->yoffset > var->yres_virtual - var->yres ||
var->xoffset < 0 || var->yoffset < 0)
var->xoffset = var->yoffset = 0;
}
} else {
var->xoffset = var->yoffset = 0;
}
if (par->is_doublescan) /*
* XXX: Need to be more creative with this (i.e. allow doublecan for
* PAL/NTSC output).
*/
if (var->yres < 480 && video_output == VO_VGA)
var->vmode = FB_VMODE_DOUBLE; var->vmode = FB_VMODE_DOUBLE;
if (par->is_interlaced)
var->vmode |= FB_VMODE_INTERLACED;
else
var->vmode |= FB_VMODE_NONINTERLACED;
var->right_margin = par->borderstop_h - (par->diwstart_h + par->xres);
var->left_margin = par->diwstart_h - par->borderstart_h;
var->hsync_len = par->borderstart_h + (par->hsync_total - par->borderstop_h);
var->upper_margin = par->diwstart_v - par->borderstart_v;
var->lower_margin = par->borderstop_v - (par->diwstart_v + par->yres);
var->vsync_len = par->borderstart_v + (par->vsync_total - par->borderstop_v);
if (video_output != VO_VGA) if (video_output != VO_VGA)
var->sync = FB_SYNC_BROADCAST; var->sync = FB_SYNC_BROADCAST | FB_VMODE_INTERLACED;
if (par->vmode & FB_VMODE_YWRAP)
var->vmode |= FB_VMODE_YWRAP;
return 0;
}
static void pvr2_get_par(struct pvr2fb_par *par)
{
*par = currentpar;
}
/* Setup the new videomode in hardware */
static void pvr2_set_var(struct fb_var_screeninfo *var)
{
do_vmode_pan = 0;
do_vmode_full = 0;
pvr2_decode_var(var, &currentpar);
do_vmode_full = 1;
}
/*
* Pan or wrap the display
* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag in `var'.
*/
static void pvr2_pan_var(struct fb_var_screeninfo *var)
{
struct pvr2fb_par *par = &currentpar;
par->xoffset = var->xoffset;
par->yoffset = var->yoffset;
if (var->vmode & FB_VMODE_YWRAP)
par->vmode |= FB_VMODE_YWRAP;
else
par->vmode &= ~FB_VMODE_YWRAP;
do_vmode_pan = 0; hsync_total = var->left_margin + var->xres + var->right_margin +
pvr2_update_par(); var->hsync_len;
do_vmode_pan = 1; vtotal = var->upper_margin + var->yres + var->lower_margin +
} var->vsync_len;
static int pvr2_update_par(void)
{
struct pvr2fb_par *par = &currentpar;
u_long move;
move = get_line_length(par->xoffset, par->bpp);
if (par->yoffset) {
par->disp_start += (par->next_line * par->yoffset) + move;
} else
par->disp_start += move;
if (var->sync & FB_SYNC_BROADCAST) {
if (var->vmode & FB_VMODE_INTERLACED)
vtotal /= 2;
if (vtotal > (PAL_VTOTAL + NTSC_VTOTAL)/2) {
/* PAL video output */
/* XXX: Should be using a range here ... ? */
if (hsync_total != PAL_HTOTAL) {
DPRINTK("invalid hsync total for PAL\n");
return -EINVAL;
}
} else {
/* NTSC video output */
if (hsync_total != NTSC_HTOTAL) {
DPRINTK("invalid hsync total for NTSC\n");
return -EINVAL;
}
}
}
/* Check memory sizes */
line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
if (line_length * var->yres_virtual > videomemorysize)
return -ENOMEM;
return 0; return 0;
} }
static void pvr2_update_display(void) static void pvr2_update_display(struct fb_info *info)
{ {
struct pvr2fb_par *par = &currentpar; struct pvr2fb_par *par = (struct pvr2fb_par *) info->par;
struct fb_var_screeninfo *var = &info->var;
/* Update the start address of the display image */ /* Update the start address of the display image */
ctrl_outl(par->disp_start, DISP_DIWADDRL); ctrl_outl(par->disp_start, DISP_DIWADDRL);
ctrl_outl(par->disp_start + ctrl_outl(par->disp_start +
get_line_length(par->xoffset + par->xres, par->bpp), get_line_length(var->xoffset+var->xres, var->bits_per_pixel),
DISP_DIWADDRS); DISP_DIWADDRS);
} }
...@@ -872,11 +483,12 @@ static void pvr2_update_display(void) ...@@ -872,11 +483,12 @@ static void pvr2_update_display(void)
* registers are still undocumented. * registers are still undocumented.
*/ */
static void pvr2_init_display(void) static void pvr2_init_display(struct fb_info *info)
{ {
struct pvr2fb_par *par = &currentpar; struct pvr2fb_par *par = (struct pvr2fb_par *) info->par;
struct fb_var_screeninfo *var = &info->var;
u_short diw_height, diw_width, diw_modulo = 1; u_short diw_height, diw_width, diw_modulo = 1;
u_short bytesperpixel = par->bpp / 8; u_short bytesperpixel = var->bits_per_pixel >> 3;
/* hsync and vsync totals */ /* hsync and vsync totals */
ctrl_outl((par->vsync_total << 16) | par->hsync_total, DISP_SYNCSIZE); ctrl_outl((par->vsync_total << 16) | par->hsync_total, DISP_SYNCSIZE);
...@@ -885,16 +497,16 @@ static void pvr2_init_display(void) ...@@ -885,16 +497,16 @@ static void pvr2_init_display(void)
/* since we're "panning" within vram, we need to offset things based /* since we're "panning" within vram, we need to offset things based
* on the offset from the virtual x start to our real gfx. */ * on the offset from the virtual x start to our real gfx. */
if (video_output != VO_VGA && par->is_interlaced) if (video_output != VO_VGA && par->is_interlaced)
diw_modulo += par->next_line / 4; diw_modulo += info->fix.line_length / 4;
diw_height = (par->is_interlaced ? par->yres / 2 : par->yres); diw_height = (par->is_interlaced ? var->yres / 2 : var->yres);
diw_width = get_line_length(par->xres, par->bpp) / 4; diw_width = get_line_length(var->xres, var->bits_per_pixel) / 4;
ctrl_outl((diw_modulo << 20) | (--diw_height << 10) | --diw_width, ctrl_outl((diw_modulo << 20) | (--diw_height << 10) | --diw_width,
DISP_DIWSIZE); DISP_DIWSIZE);
/* display address, long and short fields */ /* display address, long and short fields */
ctrl_outl(par->disp_start, DISP_DIWADDRL); ctrl_outl(par->disp_start, DISP_DIWADDRL);
ctrl_outl(par->disp_start + ctrl_outl(par->disp_start +
get_line_length(par->xoffset + par->xres, par->bpp), get_line_length(var->xoffset+var->xres, var->bits_per_pixel),
DISP_DIWADDRS); DISP_DIWADDRS);
/* border horizontal, border vertical, border color */ /* border horizontal, border vertical, border color */
...@@ -919,7 +531,6 @@ static void pvr2_init_display(void) ...@@ -919,7 +531,6 @@ static void pvr2_init_display(void)
/* video enable, color sync, interlace, /* video enable, color sync, interlace,
* hsync and vsync polarity (currently unused) */ * hsync and vsync polarity (currently unused) */
ctrl_outl(0x100 | ((par->is_interlaced /*|4*/) << 4), DISP_SYNCCONF); ctrl_outl(0x100 | ((par->is_interlaced /*|4*/) << 4), DISP_SYNCCONF);
} }
/* Simulate blanking by making the border cover the entire screen */ /* Simulate blanking by making the border cover the entire screen */
...@@ -941,23 +552,20 @@ static void pvr2_do_blank(void) ...@@ -941,23 +552,20 @@ static void pvr2_do_blank(void)
static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp) static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp)
{ {
if (do_vmode_pan || do_vmode_full) struct fb_info *info = dev_id;
pvr2_update_display();
if (do_vmode_pan || do_vmode_full)
pvr2_update_display(info);
if (do_vmode_full) if (do_vmode_full)
pvr2_init_display(); pvr2_init_display(info);
if (do_vmode_pan) if (do_vmode_pan)
do_vmode_pan = 0; do_vmode_pan = 0;
if (do_vmode_full)
do_vmode_full = 0;
if (do_blank) { if (do_blank) {
pvr2_do_blank(); pvr2_do_blank();
do_blank = 0; do_blank = 0;
} }
if (do_vmode_full) {
do_vmode_full = 0;
}
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -991,94 +599,120 @@ static int pvr2_init_cable(void) ...@@ -991,94 +599,120 @@ static int pvr2_init_cable(void)
int __init pvr2fb_init(void) int __init pvr2fb_init(void)
{ {
struct fb_var_screeninfo var;
u_long modememused; u_long modememused;
int err = -EINVAL;
if (!MACH_DREAMCAST) if (!mach_is_dreamcast())
return -ENXIO; return -ENXIO;
fb_info = kmalloc(sizeof(struct fb_info) + sizeof(struct pvr2fb_par) +
sizeof(u32) * 16, GFP_KERNEL);
if (!fb_info) {
printk(KERN_ERR "Failed to allocate memory for fb_info\n");
return -ENOMEM;
}
memset(fb_info, 0, sizeof(fb_info) + sizeof(struct pvr2fb_par) + sizeof(u32) * 16);
currentpar = (struct pvr2fb_par *)(fb_info + 1);
/* Make a guess at the monitor based on the attached cable */ /* Make a guess at the monitor based on the attached cable */
if (pvr2_init_cable() == CT_VGA) { if (pvr2_init_cable() == CT_VGA) {
fb_info.monspecs.hfmin = 30000; fb_info->monspecs.hfmin = 30000;
fb_info.monspecs.hfmax = 70000; fb_info->monspecs.hfmax = 70000;
fb_info.monspecs.vfmin = 60; fb_info->monspecs.vfmin = 60;
fb_info.monspecs.vfmax = 60; fb_info->monspecs.vfmax = 60;
} } else {
else { /* Not VGA, using a TV (taken from acornfb) */ /* Not VGA, using a TV (taken from acornfb) */
fb_info.monspecs.hfmin = 15469; fb_info->monspecs.hfmin = 15469;
fb_info.monspecs.hfmax = 15781; fb_info->monspecs.hfmax = 15781;
fb_info.monspecs.vfmin = 49; fb_info->monspecs.vfmin = 49;
fb_info.monspecs.vfmax = 51; fb_info->monspecs.vfmax = 51;
} }
/* XXX: This needs to pull default video output via BIOS or other means */ /*
* XXX: This needs to pull default video output via BIOS or other means
*/
if (video_output < 0) { if (video_output < 0) {
if (cable_type == CT_VGA) if (cable_type == CT_VGA) {
video_output = VO_VGA; video_output = VO_VGA;
else } else {
video_output = VO_NTSC; video_output = VO_NTSC;
} }
}
strcpy(fb_info.modename, pvr2fb_name); pvr2_fix.smem_start = videomemory;
fb_info.changevar = NULL; pvr2_fix.smem_len = videomemorysize;
fb_info.fbops = &pvr2fb_ops;
fb_info.screen_base = (char *) videomemory; fb_info->screen_base = ioremap_nocache(pvr2_fix.smem_start,
fb_info.disp = &disp; pvr2_fix.smem_len);
fb_info.currcon = -1;
fb_info.switch_con = &pvr2fbcon_switch; if (!fb_info->screen_base) {
fb_info.updatevar = &pvr2fbcon_updatevar; printk("Failed to remap MMIO space\n");
fb_info.flags = FBINFO_FLAG_DEFAULT; err = -ENXIO;
memset(&var, 0, sizeof(var)); goto out_err;
}
memset_io((unsigned long)fb_info->screen_base, 0, pvr2_fix.smem_len);
pvr2_fix.ypanstep = nopan ? 0 : 1;
pvr2_fix.ywrapstep = nowrap ? 0 : 1;
fb_info->fbops = &pvr2fb_ops;
fb_info->fix = pvr2_fix;
fb_info->par = currentpar;
fb_info->pseudo_palette = (void *)(fb_info->par + 1);
fb_info->flags = FBINFO_FLAG_DEFAULT;
if (video_output == VO_VGA) if (video_output == VO_VGA)
defmode = DEFMODE_VGA; defmode = DEFMODE_VGA;
if (!fb_find_mode(&var, &fb_info, mode_option, pvr2_modedb, if (!mode_option)
NUM_TOTAL_MODES, &pvr2_modedb[defmode], 16)) { mode_option = "640x480@60";
return -EINVAL;
}
if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0, if (!fb_find_mode(&fb_info->var, fb_info, mode_option, pvr2_modedb,
"pvr2 VBL handler", &currentpar)) { NUM_TOTAL_MODES, &pvr2_modedb[defmode], 16))
DPRINTK("couldn't register VBL int\n"); fb_info->var = pvr2_var;
return -EBUSY;
}
#ifdef CONFIG_MTRR if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
if (enable_mtrr) { "pvr2 VBL handler", fb_info)) {
mtrr_handle = mtrr_add(videomemory, videomemorysize, MTRR_TYPE_WRCOMB, 1); err = -EBUSY;
printk("pvr2fb: MTRR turned on\n"); goto out_err;
} }
#endif
pvr2fb_set_var(&var, -1, &fb_info); if (register_framebuffer(fb_info) < 0)
goto reg_failed;
if (register_framebuffer(&fb_info) < 0) modememused = get_line_length(fb_info->var.xres_virtual,
return -EINVAL; fb_info->var.bits_per_pixel);
modememused *= fb_info->var.yres_virtual;
modememused = get_line_length(var.xres_virtual, var.bits_per_pixel);
modememused *= var.yres_virtual;
printk("fb%d: %s frame buffer device, using %ldk/%ldk of video memory\n", printk("fb%d: %s frame buffer device, using %ldk/%ldk of video memory\n",
fb_info.node, fb_info.modename, modememused>>10, fb_info->node, fb_info->fix.id, modememused>>10,
videomemorysize>>10); videomemorysize>>10);
printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n", printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n",
fb_info.node, var.xres, var.yres, var.bits_per_pixel, fb_info->node, fb_info->var.xres, fb_info->var.yres,
get_line_length(var.xres, var.bits_per_pixel), fb_info->var.bits_per_pixel,
get_line_length(fb_info->var.xres, fb_info->var.bits_per_pixel),
(char *)pvr2_get_param(cables, NULL, cable_type, 3), (char *)pvr2_get_param(cables, NULL, cable_type, 3),
(char *)pvr2_get_param(outputs, NULL, video_output, 3)); (char *)pvr2_get_param(outputs, NULL, video_output, 3));
return 0; return 0;
reg_failed:
free_irq(HW_EVENT_VSYNC, 0);
out_err:
kfree(fb_info);
return err;
} }
static void __exit pvr2fb_exit(void) static void __exit pvr2fb_exit(void)
{ {
#ifdef CONFIG_MTRR unregister_framebuffer(fb_info);
if (enable_mtrr) { free_irq(HW_EVENT_VSYNC, 0);
mtrr_del(mtrr_handle, videomemory, videomemorysize); kfree(fb_info);
printk("pvr2fb: MTRR turned off\n");
}
#endif
unregister_framebuffer(&fb_info);
} }
static int __init pvr2_get_param(const struct pvr2_params *p, const char *s, static int __init pvr2_get_param(const struct pvr2_params *p, const char *s,
...@@ -1102,7 +736,6 @@ static int __init pvr2_get_param(const struct pvr2_params *p, const char *s, ...@@ -1102,7 +736,6 @@ static int __init pvr2_get_param(const struct pvr2_params *p, const char *s,
* Parse command arguments. Supported arguments are: * Parse command arguments. Supported arguments are:
* inverse Use inverse color maps * inverse Use inverse color maps
* nomtrr Disable MTRR usage * nomtrr Disable MTRR usage
* font:<fontname> Specify console font
* cable:composite|rgb|vga Override the video cable type * cable:composite|rgb|vga Override the video cable type
* output:NTSC|PAL|VGA Override the video output format * output:NTSC|PAL|VGA Override the video output format
* *
...@@ -1117,8 +750,6 @@ int __init pvr2fb_setup(char *options) ...@@ -1117,8 +750,6 @@ int __init pvr2fb_setup(char *options)
char cable_arg[80]; char cable_arg[80];
char output_arg[80]; char output_arg[80];
fb_info.fontname[0] = '\0';
if (!options || !*options) if (!options || !*options)
return 0; return 0;
...@@ -1128,23 +759,21 @@ int __init pvr2fb_setup(char *options) ...@@ -1128,23 +759,21 @@ int __init pvr2fb_setup(char *options)
if (!strcmp(this_opt, "inverse")) { if (!strcmp(this_opt, "inverse")) {
pvr2fb_inverse = 1; pvr2fb_inverse = 1;
fb_invert_cmaps(); fb_invert_cmaps();
} else if (!strncmp(this_opt, "font:", 5)) } else if (!strncmp(this_opt, "cable:", 6)) {
strcpy(fb_info.fontname, this_opt + 5);
else if (!strncmp(this_opt, "cable:", 6))
strcpy(cable_arg, this_opt + 6); strcpy(cable_arg, this_opt + 6);
else if (!strncmp(this_opt, "output:", 7)) } else if (!strncmp(this_opt, "output:", 7)) {
strcpy(output_arg, this_opt + 7); strcpy(output_arg, this_opt + 7);
#ifdef CONFIG_MTRR } else if (!strncmp(this_opt, "nopan", 5)) {
else if (!strncmp(this_opt, "nomtrr", 6)) nopan = 1;
enable_mtrr = 0; } else if (!strncmp(this_opt, "nowrap", 6)) {
#endif nowrap = 1;
else } else {
mode_option = this_opt; mode_option = this_opt;
} }
}
if (*cable_arg) if (*cable_arg)
cable_type = pvr2_get_param(cables, cable_arg, 0, 3); cable_type = pvr2_get_param(cables, cable_arg, 0, 3);
if (*output_arg) if (*output_arg)
video_output = pvr2_get_param(outputs, output_arg, 0, 3); video_output = pvr2_get_param(outputs, output_arg, 0, 3);
......
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