/*
|
/*
|
* linux/arch/m68k/amiga/cyberfb.c -- Low level implementation of the
|
* linux/arch/m68k/amiga/cyberfb.c -- Low level implementation of the
|
* Cybervision frame buffer device
|
* Cybervision frame buffer device
|
*
|
*
|
* Copyright (C) 1996 Martin Apel
|
* Copyright (C) 1996 Martin Apel
|
* Geert Uytterhoeven
|
* Geert Uytterhoeven
|
*
|
*
|
*
|
*
|
* This file is based on the Amiga frame buffer device (amifb.c):
|
* This file is based on the Amiga frame buffer device (amifb.c):
|
*
|
*
|
* Copyright (C) 1995 Geert Uytterhoeven
|
* Copyright (C) 1995 Geert Uytterhoeven
|
*
|
*
|
*
|
*
|
* History:
|
* History:
|
* - 22 Dec 95: Original version by Martin Apel
|
* - 22 Dec 95: Original version by Martin Apel
|
* - 05 Jan 96: Geert: integration into the current source tree
|
* - 05 Jan 96: Geert: integration into the current source tree
|
*
|
*
|
*
|
*
|
* 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
|
* License. See the file COPYING in the main directory of this archive
|
* for more details.
|
* for more details.
|
*/
|
*/
|
|
|
|
|
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
#include <linux/errno.h>
|
#include <linux/errno.h>
|
#include <linux/string.h>
|
#include <linux/string.h>
|
#include <linux/mm.h>
|
#include <linux/mm.h>
|
#include <linux/tty.h>
|
#include <linux/tty.h>
|
#include <linux/malloc.h>
|
#include <linux/malloc.h>
|
#include <linux/delay.h>
|
#include <linux/delay.h>
|
#include <asm/segment.h>
|
#include <asm/segment.h>
|
#include <asm/system.h>
|
#include <asm/system.h>
|
#include <asm/irq.h>
|
#include <asm/irq.h>
|
#include <asm/bootinfo.h>
|
#include <asm/bootinfo.h>
|
#include <asm/zorro.h>
|
#include <asm/zorro.h>
|
#include <asm/pgtable.h>
|
#include <asm/pgtable.h>
|
#include <linux/fb.h>
|
#include <linux/fb.h>
|
#include "s3blit.h"
|
#include "s3blit.h"
|
|
|
|
|
#define arraysize(x) (sizeof(x)/sizeof(*(x)))
|
#define arraysize(x) (sizeof(x)/sizeof(*(x)))
|
|
|
struct Cyber_fb_par {
|
struct Cyber_fb_par {
|
int xres;
|
int xres;
|
int yres;
|
int yres;
|
int bpp;
|
int bpp;
|
};
|
};
|
|
|
static struct Cyber_fb_par current_par;
|
static struct Cyber_fb_par current_par;
|
|
|
static int current_par_valid = 0;
|
static int current_par_valid = 0;
|
static int currcon = 0;
|
static int currcon = 0;
|
|
|
static struct display disp[MAX_NR_CONSOLES];
|
static struct display disp[MAX_NR_CONSOLES];
|
static struct fb_info fb_info;
|
static struct fb_info fb_info;
|
|
|
static int node; /* node of the /dev/fb?current file */
|
static int node; /* node of the /dev/fb?current file */
|
|
|
|
|
/*
|
/*
|
* Switch for Chipset Independency
|
* Switch for Chipset Independency
|
*/
|
*/
|
|
|
static struct fb_hwswitch {
|
static struct fb_hwswitch {
|
|
|
/* Initialisation */
|
/* Initialisation */
|
|
|
int (*init)(void);
|
int (*init)(void);
|
|
|
/* Display Control */
|
/* Display Control */
|
|
|
int (*encode_fix)(struct fb_fix_screeninfo *fix, struct Cyber_fb_par *par);
|
int (*encode_fix)(struct fb_fix_screeninfo *fix, struct Cyber_fb_par *par);
|
int (*decode_var)(struct fb_var_screeninfo *var, struct Cyber_fb_par *par);
|
int (*decode_var)(struct fb_var_screeninfo *var, struct Cyber_fb_par *par);
|
int (*encode_var)(struct fb_var_screeninfo *var, struct Cyber_fb_par *par);
|
int (*encode_var)(struct fb_var_screeninfo *var, struct Cyber_fb_par *par);
|
int (*getcolreg)(u_int regno, u_int *red, u_int *green, u_int *blue,
|
int (*getcolreg)(u_int regno, u_int *red, u_int *green, u_int *blue,
|
u_int *transp);
|
u_int *transp);
|
int (*setcolreg)(u_int regno, u_int red, u_int green, u_int blue,
|
int (*setcolreg)(u_int regno, u_int red, u_int green, u_int blue,
|
u_int transp);
|
u_int transp);
|
void (*blank)(int blank);
|
void (*blank)(int blank);
|
} *fbhw;
|
} *fbhw;
|
|
|
|
|
/*
|
/*
|
* Frame Buffer Name
|
* Frame Buffer Name
|
*/
|
*/
|
|
|
static char Cyber_fb_name[16] = "Cybervision";
|
static char Cyber_fb_name[16] = "Cybervision";
|
|
|
|
|
/*
|
/*
|
* Cybervision Graphics Board
|
* Cybervision Graphics Board
|
*/
|
*/
|
|
|
#define CYBER8_WIDTH 1152
|
#define CYBER8_WIDTH 1152
|
#define CYBER8_HEIGHT 886
|
#define CYBER8_HEIGHT 886
|
#define CYBER8_PIXCLOCK 12500 /* ++Geert: Just a guess */
|
#define CYBER8_PIXCLOCK 12500 /* ++Geert: Just a guess */
|
|
|
#define CYBER16_WIDTH 800
|
#define CYBER16_WIDTH 800
|
#define CYBER16_HEIGHT 600
|
#define CYBER16_HEIGHT 600
|
#define CYBER16_PIXCLOCK 25000 /* ++Geert: Just a guess */
|
#define CYBER16_PIXCLOCK 25000 /* ++Geert: Just a guess */
|
|
|
|
|
static int CyberKey = 0;
|
static int CyberKey = 0;
|
static u_char Cyber_colour_table [256][4];
|
static u_char Cyber_colour_table [256][4];
|
static unsigned long CyberMem;
|
static unsigned long CyberMem;
|
static unsigned long CyberSize;
|
static unsigned long CyberSize;
|
static volatile char *CyberRegs;
|
static volatile char *CyberRegs;
|
|
|
static long *memstart;
|
static long *memstart;
|
|
|
|
|
/*
|
/*
|
* Predefined Video Mode Names
|
* Predefined Video Mode Names
|
*/
|
*/
|
|
|
static char *Cyber_fb_modenames[] = {
|
static char *Cyber_fb_modenames[] = {
|
|
|
/*
|
/*
|
* Autodetect (Default) Video Mode
|
* Autodetect (Default) Video Mode
|
*/
|
*/
|
|
|
"default",
|
"default",
|
|
|
/*
|
/*
|
* Predefined Video Modes
|
* Predefined Video Modes
|
*/
|
*/
|
|
|
"cyber8", /* Cybervision 8 bpp */
|
"cyber8", /* Cybervision 8 bpp */
|
"cyber16", /* Cybervision 16 bpp */
|
"cyber16", /* Cybervision 16 bpp */
|
|
|
/*
|
/*
|
* Dummy Video Modes
|
* Dummy Video Modes
|
*/
|
*/
|
|
|
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
"dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
|
"dummy", "dummy", "dummy", "dummy",
|
"dummy", "dummy", "dummy", "dummy",
|
|
|
/*
|
/*
|
* User Defined Video Modes
|
* User Defined Video Modes
|
*
|
*
|
* This doesn't work yet!!
|
* This doesn't work yet!!
|
*/
|
*/
|
|
|
"user0", "user1", "user2", "user3", "user4", "user5", "user6", "user7"
|
"user0", "user1", "user2", "user3", "user4", "user5", "user6", "user7"
|
};
|
};
|
|
|
|
|
/*
|
/*
|
* Predefined Video Mode Definitions
|
* Predefined Video Mode Definitions
|
*/
|
*/
|
|
|
static struct fb_var_screeninfo Cyber_fb_predefined[] = {
|
static struct fb_var_screeninfo Cyber_fb_predefined[] = {
|
|
|
/*
|
/*
|
* Autodetect (Default) Video Mode
|
* Autodetect (Default) Video Mode
|
*/
|
*/
|
|
|
{ 0, },
|
{ 0, },
|
|
|
/*
|
/*
|
* Predefined Video Modes
|
* Predefined Video Modes
|
*/
|
*/
|
|
|
{
|
{
|
/* Cybervision 8 bpp */
|
/* Cybervision 8 bpp */
|
CYBER8_WIDTH, CYBER8_HEIGHT, CYBER8_WIDTH, CYBER8_HEIGHT, 0, 0, 8, 0,
|
CYBER8_WIDTH, CYBER8_HEIGHT, CYBER8_WIDTH, CYBER8_HEIGHT, 0, 0, 8, 0,
|
{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
|
{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
|
0, 0, -1, -1, FB_ACCEL_NONE, CYBER8_PIXCLOCK, 64, 96, 35, 12, 112, 2,
|
0, 0, -1, -1, FB_ACCEL_NONE, CYBER8_PIXCLOCK, 64, 96, 35, 12, 112, 2,
|
FB_SYNC_COMP_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
|
FB_SYNC_COMP_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
|
}, {
|
}, {
|
/* Cybervision 16 bpp */
|
/* Cybervision 16 bpp */
|
CYBER16_WIDTH, CYBER16_HEIGHT, CYBER16_WIDTH, CYBER16_HEIGHT, 0, 0, 16, 0,
|
CYBER16_WIDTH, CYBER16_HEIGHT, CYBER16_WIDTH, CYBER16_HEIGHT, 0, 0, 16, 0,
|
{11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0},
|
{11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0},
|
0, 0, -1, -1, FB_ACCEL_NONE, CYBER16_PIXCLOCK, 64, 96, 35, 12, 112, 2,
|
0, 0, -1, -1, FB_ACCEL_NONE, CYBER16_PIXCLOCK, 64, 96, 35, 12, 112, 2,
|
FB_SYNC_COMP_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
|
FB_SYNC_COMP_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
|
},
|
},
|
|
|
/*
|
/*
|
* Dummy Video Modes
|
* Dummy Video Modes
|
*/
|
*/
|
|
|
{ 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, },
|
{ 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, },
|
{ 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, },
|
{ 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, },
|
{ 0, }, { 0, },
|
{ 0, }, { 0, },
|
|
|
/*
|
/*
|
* User Defined Video Modes
|
* User Defined Video Modes
|
*/
|
*/
|
|
|
{ 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }
|
{ 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }
|
};
|
};
|
|
|
|
|
#define NUM_TOTAL_MODES arraysize(Cyber_fb_predefined)
|
#define NUM_TOTAL_MODES arraysize(Cyber_fb_predefined)
|
#define NUM_PREDEF_MODES (3)
|
#define NUM_PREDEF_MODES (3)
|
|
|
|
|
static int Cyberfb_inverse = 0;
|
static int Cyberfb_inverse = 0;
|
static int Cyberfb_Cyber8 = 0; /* Use Cybervision board */
|
static int Cyberfb_Cyber8 = 0; /* Use Cybervision board */
|
static int Cyberfb_Cyber16 = 0; /* Use Cybervision board */
|
static int Cyberfb_Cyber16 = 0; /* Use Cybervision board */
|
static int Cyberfb_mode = 0;
|
static int Cyberfb_mode = 0;
|
|
|
|
|
/*
|
/*
|
* Some default modes
|
* Some default modes
|
*/
|
*/
|
|
|
#define CYBER8_DEFMODE (1)
|
#define CYBER8_DEFMODE (1)
|
#define CYBER16_DEFMODE (2)
|
#define CYBER16_DEFMODE (2)
|
|
|
|
|
/*
|
/*
|
* Interface used by the world
|
* Interface used by the world
|
*/
|
*/
|
|
|
int Cyber_probe(void);
|
int Cyber_probe(void);
|
void Cyber_video_setup(char *options, int *ints);
|
void Cyber_video_setup(char *options, int *ints);
|
|
|
static int Cyber_fb_get_fix(struct fb_fix_screeninfo *fix, int con);
|
static int Cyber_fb_get_fix(struct fb_fix_screeninfo *fix, int con);
|
static int Cyber_fb_get_var(struct fb_var_screeninfo *var, int con);
|
static int Cyber_fb_get_var(struct fb_var_screeninfo *var, int con);
|
static int Cyber_fb_set_var(struct fb_var_screeninfo *var, int con);
|
static int Cyber_fb_set_var(struct fb_var_screeninfo *var, int con);
|
static int Cyber_fb_get_cmap(struct fb_cmap *cmap, int kspc, int con);
|
static int Cyber_fb_get_cmap(struct fb_cmap *cmap, int kspc, int con);
|
static int Cyber_fb_set_cmap(struct fb_cmap *cmap, int kspc, int con);
|
static int Cyber_fb_set_cmap(struct fb_cmap *cmap, int kspc, int con);
|
static int Cyber_fb_pan_display(struct fb_var_screeninfo *var, int con);
|
static int Cyber_fb_pan_display(struct fb_var_screeninfo *var, int con);
|
static int Cyber_fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
|
static int Cyber_fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
|
u_long arg, int con);
|
u_long arg, int con);
|
|
|
|
|
/*
|
/*
|
* Interface to the low level console driver
|
* Interface to the low level console driver
|
*/
|
*/
|
|
|
struct fb_info *Cyber_fb_init(long *mem_start); /* Through amiga_fb_init() */
|
struct fb_info *Cyber_fb_init(long *mem_start); /* Through amiga_fb_init() */
|
static int Cyberfb_switch(int con);
|
static int Cyberfb_switch(int con);
|
static int Cyberfb_updatevar(int con);
|
static int Cyberfb_updatevar(int con);
|
static void Cyberfb_blank(int blank);
|
static void Cyberfb_blank(int blank);
|
|
|
|
|
/*
|
/*
|
* Accelerated Functions used by the low level console driver
|
* Accelerated Functions used by the low level console driver
|
*/
|
*/
|
|
|
void Cyber_WaitQueue(u_short fifo);
|
void Cyber_WaitQueue(u_short fifo);
|
void Cyber_WaitBlit(void);
|
void Cyber_WaitBlit(void);
|
void Cyber_BitBLT(u_short curx, u_short cury, u_short destx, u_short desty,
|
void Cyber_BitBLT(u_short curx, u_short cury, u_short destx, u_short desty,
|
u_short width, u_short height, u_short mode);
|
u_short width, u_short height, u_short mode);
|
void Cyber_RectFill(u_short x, u_short y, u_short width, u_short height,
|
void Cyber_RectFill(u_short x, u_short y, u_short width, u_short height,
|
u_short mode, u_short color);
|
u_short mode, u_short color);
|
void Cyber_MoveCursor(u_short x, u_short y);
|
void Cyber_MoveCursor(u_short x, u_short y);
|
|
|
|
|
/*
|
/*
|
* Hardware Specific Routines
|
* Hardware Specific Routines
|
*/
|
*/
|
|
|
static int Cyber_init(void);
|
static int Cyber_init(void);
|
static int Cyber_encode_fix(struct fb_fix_screeninfo *fix,
|
static int Cyber_encode_fix(struct fb_fix_screeninfo *fix,
|
struct Cyber_fb_par *par);
|
struct Cyber_fb_par *par);
|
static int Cyber_decode_var(struct fb_var_screeninfo *var,
|
static int Cyber_decode_var(struct fb_var_screeninfo *var,
|
struct Cyber_fb_par *par);
|
struct Cyber_fb_par *par);
|
static int Cyber_encode_var(struct fb_var_screeninfo *var,
|
static int Cyber_encode_var(struct fb_var_screeninfo *var,
|
struct Cyber_fb_par *par);
|
struct Cyber_fb_par *par);
|
static int Cyber_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
|
static int Cyber_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
|
u_int *transp);
|
u_int *transp);
|
static int Cyber_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
|
static int Cyber_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
|
u_int transp);
|
u_int transp);
|
static void Cyber_blank(int blank);
|
static void Cyber_blank(int blank);
|
|
|
|
|
/*
|
/*
|
* Internal routines
|
* Internal routines
|
*/
|
*/
|
|
|
static void Cyber_fb_get_par(struct Cyber_fb_par *par);
|
static void Cyber_fb_get_par(struct Cyber_fb_par *par);
|
static void Cyber_fb_set_par(struct Cyber_fb_par *par);
|
static void Cyber_fb_set_par(struct Cyber_fb_par *par);
|
static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive);
|
static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive);
|
static struct fb_cmap *get_default_colormap(int bpp);
|
static struct fb_cmap *get_default_colormap(int bpp);
|
static int do_fb_get_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
|
static int do_fb_get_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
|
int kspc);
|
int kspc);
|
static int do_fb_set_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
|
static int do_fb_set_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
|
int kspc);
|
int kspc);
|
static void do_install_cmap(int con);
|
static void do_install_cmap(int con);
|
static void memcpy_fs(int fsfromto, void *to, void *from, int len);
|
static void memcpy_fs(int fsfromto, void *to, void *from, int len);
|
static void copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto);
|
static void copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto);
|
static int alloc_cmap(struct fb_cmap *cmap, int len, int transp);
|
static int alloc_cmap(struct fb_cmap *cmap, int len, int transp);
|
static void Cyber_fb_set_disp(int con);
|
static void Cyber_fb_set_disp(int con);
|
static int get_video_mode(const char *name);
|
static int get_video_mode(const char *name);
|
|
|
|
|
/* -------------------- Hardware specific routines -------------------------- */
|
/* -------------------- Hardware specific routines -------------------------- */
|
|
|
|
|
/*
|
/*
|
* Initialization
|
* Initialization
|
*
|
*
|
* Set the default video mode for this chipset. If a video mode was
|
* Set the default video mode for this chipset. If a video mode was
|
* specified on the command line, it will override the default mode.
|
* specified on the command line, it will override the default mode.
|
*/
|
*/
|
|
|
static int Cyber_init(void)
|
static int Cyber_init(void)
|
{
|
{
|
int i;
|
int i;
|
char size;
|
char size;
|
volatile u_long *CursorBase;
|
volatile u_long *CursorBase;
|
unsigned long board_addr;
|
unsigned long board_addr;
|
struct ConfigDev *cd;
|
struct ConfigDev *cd;
|
|
|
if (Cyberfb_mode == -1)
|
if (Cyberfb_mode == -1)
|
{
|
{
|
if (Cyberfb_Cyber8)
|
if (Cyberfb_Cyber8)
|
Cyberfb_mode = CYBER8_DEFMODE;
|
Cyberfb_mode = CYBER8_DEFMODE;
|
else
|
else
|
Cyberfb_mode = CYBER16_DEFMODE;
|
Cyberfb_mode = CYBER16_DEFMODE;
|
}
|
}
|
|
|
cd = zorro_get_board (CyberKey);
|
cd = zorro_get_board (CyberKey);
|
zorro_config_board (CyberKey, 0);
|
zorro_config_board (CyberKey, 0);
|
board_addr = (unsigned long)cd->cd_BoardAddr;
|
board_addr = (unsigned long)cd->cd_BoardAddr;
|
|
|
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
|
|
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
{
|
{
|
Cyber_colour_table [i][0] = i;
|
Cyber_colour_table [i][0] = i;
|
Cyber_colour_table [i][1] = i;
|
Cyber_colour_table [i][1] = i;
|
Cyber_colour_table [i][2] = i;
|
Cyber_colour_table [i][2] = i;
|
Cyber_colour_table [i][3] = 0;
|
Cyber_colour_table [i][3] = 0;
|
}
|
}
|
|
|
*memstart = (*memstart + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
|
*memstart = (*memstart + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
|
CyberMem = kernel_map (board_addr + 0x01400000, 0x00400000,
|
CyberMem = kernel_map (board_addr + 0x01400000, 0x00400000,
|
KERNELMAP_NOCACHE_SER, memstart);
|
KERNELMAP_NOCACHE_SER, memstart);
|
|
|
if (Cyberfb_Cyber8)
|
if (Cyberfb_Cyber8)
|
memset ((char*)CyberMem, 0, CYBER8_WIDTH * CYBER8_HEIGHT);
|
memset ((char*)CyberMem, 0, CYBER8_WIDTH * CYBER8_HEIGHT);
|
else
|
else
|
memset ((char*)CyberMem, 0, CYBER16_WIDTH * CYBER16_HEIGHT);
|
memset ((char*)CyberMem, 0, CYBER16_WIDTH * CYBER16_HEIGHT);
|
|
|
CyberRegs = (char*) kernel_map (board_addr + 0x02000000, 0xf000,
|
CyberRegs = (char*) kernel_map (board_addr + 0x02000000, 0xf000,
|
KERNELMAP_NOCACHE_SER, memstart);
|
KERNELMAP_NOCACHE_SER, memstart);
|
|
|
/* Disable hardware cursor */
|
/* Disable hardware cursor */
|
*(CyberRegs + S3_CRTC_ADR) = S3_REG_LOCK2;
|
*(CyberRegs + S3_CRTC_ADR) = S3_REG_LOCK2;
|
*(CyberRegs + S3_CRTC_DATA) = 0xa0;
|
*(CyberRegs + S3_CRTC_DATA) = 0xa0;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HGC_MODE;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HGC_MODE;
|
*(CyberRegs + S3_CRTC_DATA) = 0x00;
|
*(CyberRegs + S3_CRTC_DATA) = 0x00;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_DX;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_DX;
|
*(CyberRegs + S3_CRTC_DATA) = 0x00;
|
*(CyberRegs + S3_CRTC_DATA) = 0x00;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_DY;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_DY;
|
*(CyberRegs + S3_CRTC_DATA) = 0x00;
|
*(CyberRegs + S3_CRTC_DATA) = 0x00;
|
|
|
/* Set clipping rectangle to current screen size */
|
/* Set clipping rectangle to current screen size */
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x1000;
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x1000;
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x2000;
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x2000;
|
if (Cyberfb_Cyber8)
|
if (Cyberfb_Cyber8)
|
{
|
{
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x3000 | (CYBER8_HEIGHT - 1);
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x3000 | (CYBER8_HEIGHT - 1);
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x4000 | (CYBER8_WIDTH - 1);
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x4000 | (CYBER8_WIDTH - 1);
|
}
|
}
|
else
|
else
|
{
|
{
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x3000 | (CYBER16_HEIGHT - 1);
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x3000 | (CYBER16_HEIGHT - 1);
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x4000 | (CYBER16_WIDTH - 1);
|
*((u_short volatile *)(CyberRegs + 0xbee8)) = 0x4000 | (CYBER16_WIDTH - 1);
|
}
|
}
|
|
|
/* Get memory size (if not 2MB it is 4MB) */
|
/* Get memory size (if not 2MB it is 4MB) */
|
*(CyberRegs + S3_CRTC_ADR) = S3_LAW_CTL;
|
*(CyberRegs + S3_CRTC_ADR) = S3_LAW_CTL;
|
size = *(CyberRegs + S3_CRTC_DATA);
|
size = *(CyberRegs + S3_CRTC_DATA);
|
if ((size & 0x03) == 0x02)
|
if ((size & 0x03) == 0x02)
|
CyberSize = 0x00200000; /* 2 MB */
|
CyberSize = 0x00200000; /* 2 MB */
|
else
|
else
|
CyberSize = 0x00400000; /* 4 MB */
|
CyberSize = 0x00400000; /* 4 MB */
|
|
|
/* Initialize hardware cursor */
|
/* Initialize hardware cursor */
|
CursorBase = (u_long *)((char *)(CyberMem) + CyberSize - 0x400);
|
CursorBase = (u_long *)((char *)(CyberMem) + CyberSize - 0x400);
|
for (i=0; i < 8; i++)
|
for (i=0; i < 8; i++)
|
{
|
{
|
*(CursorBase +(i*4)) = 0xffffff00;
|
*(CursorBase +(i*4)) = 0xffffff00;
|
*(CursorBase+1+(i*4)) = 0xffff0000;
|
*(CursorBase+1+(i*4)) = 0xffff0000;
|
*(CursorBase+2+(i*4)) = 0xffff0000;
|
*(CursorBase+2+(i*4)) = 0xffff0000;
|
*(CursorBase+3+(i*4)) = 0xffff0000;
|
*(CursorBase+3+(i*4)) = 0xffff0000;
|
}
|
}
|
for (i=8; i < 64; i++)
|
for (i=8; i < 64; i++)
|
{
|
{
|
*(CursorBase +(i*4)) = 0xffff0000;
|
*(CursorBase +(i*4)) = 0xffff0000;
|
*(CursorBase+1+(i*4)) = 0xffff0000;
|
*(CursorBase+1+(i*4)) = 0xffff0000;
|
*(CursorBase+2+(i*4)) = 0xffff0000;
|
*(CursorBase+2+(i*4)) = 0xffff0000;
|
*(CursorBase+3+(i*4)) = 0xffff0000;
|
*(CursorBase+3+(i*4)) = 0xffff0000;
|
}
|
}
|
|
|
Cyber_setcolreg (255, 56, 100, 160, 0);
|
Cyber_setcolreg (255, 56, 100, 160, 0);
|
Cyber_setcolreg (254, 0, 0, 0, 0);
|
Cyber_setcolreg (254, 0, 0, 0, 0);
|
|
|
return (0);
|
return (0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* This function should fill in the `fix' structure based on the
|
* This function should fill in the `fix' structure based on the
|
* values in the `par' structure.
|
* values in the `par' structure.
|
*/
|
*/
|
|
|
static int Cyber_encode_fix(struct fb_fix_screeninfo *fix,
|
static int Cyber_encode_fix(struct fb_fix_screeninfo *fix,
|
struct Cyber_fb_par *par)
|
struct Cyber_fb_par *par)
|
{
|
{
|
int i;
|
int i;
|
|
|
strcpy(fix->id, Cyber_fb_name);
|
strcpy(fix->id, Cyber_fb_name);
|
fix->smem_start = CyberMem;
|
fix->smem_start = CyberMem;
|
fix->smem_len = CyberSize;
|
fix->smem_len = CyberSize;
|
|
|
fix->type = FB_TYPE_PACKED_PIXELS;
|
fix->type = FB_TYPE_PACKED_PIXELS;
|
fix->type_aux = 0;
|
fix->type_aux = 0;
|
if (par->bpp == 8)
|
if (par->bpp == 8)
|
fix->visual = FB_VISUAL_PSEUDOCOLOR;
|
fix->visual = FB_VISUAL_PSEUDOCOLOR;
|
else
|
else
|
fix->visual = FB_VISUAL_DIRECTCOLOR;
|
fix->visual = FB_VISUAL_DIRECTCOLOR;
|
|
|
fix->xpanstep = 0;
|
fix->xpanstep = 0;
|
fix->ypanstep = 0;
|
fix->ypanstep = 0;
|
fix->ywrapstep = 0;
|
fix->ywrapstep = 0;
|
|
|
for (i = 0; i < arraysize(fix->reserved); i++)
|
for (i = 0; i < arraysize(fix->reserved); i++)
|
fix->reserved[i] = 0;
|
fix->reserved[i] = 0;
|
|
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Get the video params out of `var'. If a value doesn't fit, round
|
* Get the video params out of `var'. If a value doesn't fit, round
|
* it up, if it's too big, return -EINVAL.
|
* it up, if it's too big, return -EINVAL.
|
*/
|
*/
|
|
|
static int Cyber_decode_var(struct fb_var_screeninfo *var,
|
static int Cyber_decode_var(struct fb_var_screeninfo *var,
|
struct Cyber_fb_par *par)
|
struct Cyber_fb_par *par)
|
{
|
{
|
if (Cyberfb_Cyber8) {
|
if (Cyberfb_Cyber8) {
|
par->xres = CYBER8_WIDTH;
|
par->xres = CYBER8_WIDTH;
|
par->yres = CYBER8_HEIGHT;
|
par->yres = CYBER8_HEIGHT;
|
par->bpp = 8;
|
par->bpp = 8;
|
} else {
|
} else {
|
par->xres = CYBER16_WIDTH;
|
par->xres = CYBER16_WIDTH;
|
par->yres = CYBER16_HEIGHT;
|
par->yres = CYBER16_HEIGHT;
|
par->bpp = 16;
|
par->bpp = 16;
|
}
|
}
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Fill the `var' structure based on the values in `par' and maybe
|
* Fill the `var' structure based on the values in `par' and maybe
|
* other values read out of the hardware.
|
* other values read out of the hardware.
|
*/
|
*/
|
|
|
static int Cyber_encode_var(struct fb_var_screeninfo *var,
|
static int Cyber_encode_var(struct fb_var_screeninfo *var,
|
struct Cyber_fb_par *par)
|
struct Cyber_fb_par *par)
|
{
|
{
|
int i;
|
int i;
|
|
|
var->xres = par->xres;
|
var->xres = par->xres;
|
var->yres = par->yres;
|
var->yres = par->yres;
|
var->xres_virtual = par->xres;
|
var->xres_virtual = par->xres;
|
var->yres_virtual = par->yres;
|
var->yres_virtual = par->yres;
|
var->xoffset = 0;
|
var->xoffset = 0;
|
var->yoffset = 0;
|
var->yoffset = 0;
|
|
|
var->bits_per_pixel = par->bpp;
|
var->bits_per_pixel = par->bpp;
|
var->grayscale = 0;
|
var->grayscale = 0;
|
|
|
if (par->bpp == 8) {
|
if (par->bpp == 8) {
|
var->red.offset = 0;
|
var->red.offset = 0;
|
var->red.length = 8;
|
var->red.length = 8;
|
var->red.msb_right = 0;
|
var->red.msb_right = 0;
|
var->blue = var->green = var->red;
|
var->blue = var->green = var->red;
|
} else {
|
} else {
|
var->red.offset = 11;
|
var->red.offset = 11;
|
var->red.length = 5;
|
var->red.length = 5;
|
var->red.msb_right = 0;
|
var->red.msb_right = 0;
|
var->green.offset = 5;
|
var->green.offset = 5;
|
var->green.length = 6;
|
var->green.length = 6;
|
var->green.msb_right = 0;
|
var->green.msb_right = 0;
|
var->blue.offset = 0;
|
var->blue.offset = 0;
|
var->blue.length = 5;
|
var->blue.length = 5;
|
var->blue.msb_right = 0;
|
var->blue.msb_right = 0;
|
}
|
}
|
var->transp.offset = 0;
|
var->transp.offset = 0;
|
var->transp.length = 0;
|
var->transp.length = 0;
|
var->transp.msb_right = 0;
|
var->transp.msb_right = 0;
|
|
|
var->nonstd = 0;
|
var->nonstd = 0;
|
var->activate = 0;
|
var->activate = 0;
|
|
|
var->height = -1;
|
var->height = -1;
|
var->width = -1;
|
var->width = -1;
|
var->accel = FB_ACCEL_CYBERVISION;
|
var->accel = FB_ACCEL_CYBERVISION;
|
var->vmode = FB_VMODE_NONINTERLACED;
|
var->vmode = FB_VMODE_NONINTERLACED;
|
|
|
/* Dummy values */
|
/* Dummy values */
|
|
|
if (par->bpp == 8)
|
if (par->bpp == 8)
|
var->pixclock = CYBER8_PIXCLOCK;
|
var->pixclock = CYBER8_PIXCLOCK;
|
else
|
else
|
var->pixclock = CYBER16_PIXCLOCK;
|
var->pixclock = CYBER16_PIXCLOCK;
|
var->sync = 0;
|
var->sync = 0;
|
var->left_margin = 64;
|
var->left_margin = 64;
|
var->right_margin = 96;
|
var->right_margin = 96;
|
var->upper_margin = 35;
|
var->upper_margin = 35;
|
var->lower_margin = 12;
|
var->lower_margin = 12;
|
var->hsync_len = 112;
|
var->hsync_len = 112;
|
var->vsync_len = 2;
|
var->vsync_len = 2;
|
|
|
for (i = 0; i < arraysize(var->reserved); i++)
|
for (i = 0; i < arraysize(var->reserved); i++)
|
var->reserved[i] = 0;
|
var->reserved[i] = 0;
|
|
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Set a single color register. The values supplied are already
|
* Set a single color register. The values supplied are already
|
* rounded down to the hardware's capabilities (according to the
|
* rounded down to the hardware's capabilities (according to the
|
* entries in the var structure). Return != 0 for invalid regno.
|
* entries in the var structure). Return != 0 for invalid regno.
|
*/
|
*/
|
|
|
static int Cyber_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
|
static int Cyber_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
|
u_int transp)
|
u_int transp)
|
{
|
{
|
if (regno > 255)
|
if (regno > 255)
|
return (1);
|
return (1);
|
|
|
*(CyberRegs + 0x3c8) = (char)regno;
|
*(CyberRegs + 0x3c8) = (char)regno;
|
Cyber_colour_table [regno][0] = red & 0xff;
|
Cyber_colour_table [regno][0] = red & 0xff;
|
Cyber_colour_table [regno][1] = green & 0xff;
|
Cyber_colour_table [regno][1] = green & 0xff;
|
Cyber_colour_table [regno][2] = blue & 0xff;
|
Cyber_colour_table [regno][2] = blue & 0xff;
|
Cyber_colour_table [regno][3] = transp;
|
Cyber_colour_table [regno][3] = transp;
|
|
|
*(CyberRegs + 0x3c9) = (red & 0xff) >> 2;
|
*(CyberRegs + 0x3c9) = (red & 0xff) >> 2;
|
*(CyberRegs + 0x3c9) = (green & 0xff) >> 2;
|
*(CyberRegs + 0x3c9) = (green & 0xff) >> 2;
|
*(CyberRegs + 0x3c9) = (blue & 0xff) >> 2;
|
*(CyberRegs + 0x3c9) = (blue & 0xff) >> 2;
|
|
|
return (0);
|
return (0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Read a single color register and split it into
|
* Read a single color register and split it into
|
* colors/transparent. Return != 0 for invalid regno.
|
* colors/transparent. Return != 0 for invalid regno.
|
*/
|
*/
|
|
|
static int Cyber_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
|
static int Cyber_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
|
u_int *transp)
|
u_int *transp)
|
{
|
{
|
if (regno >= 256)
|
if (regno >= 256)
|
return (1);
|
return (1);
|
*red = Cyber_colour_table [regno][0];
|
*red = Cyber_colour_table [regno][0];
|
*green = Cyber_colour_table [regno][1];
|
*green = Cyber_colour_table [regno][1];
|
*blue = Cyber_colour_table [regno][2];
|
*blue = Cyber_colour_table [regno][2];
|
*transp = Cyber_colour_table [regno][3];
|
*transp = Cyber_colour_table [regno][3];
|
return (0);
|
return (0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* (Un)Blank the screen
|
* (Un)Blank the screen
|
*/
|
*/
|
|
|
void Cyber_blank(int blank)
|
void Cyber_blank(int blank)
|
{
|
{
|
int i;
|
int i;
|
|
|
if (blank)
|
if (blank)
|
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
{
|
{
|
*(CyberRegs + 0x3c8) = i;
|
*(CyberRegs + 0x3c8) = i;
|
*(CyberRegs + 0x3c9) = 0;
|
*(CyberRegs + 0x3c9) = 0;
|
*(CyberRegs + 0x3c9) = 0;
|
*(CyberRegs + 0x3c9) = 0;
|
*(CyberRegs + 0x3c9) = 0;
|
*(CyberRegs + 0x3c9) = 0;
|
}
|
}
|
else
|
else
|
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
{
|
{
|
*(CyberRegs + 0x3c8) = i;
|
*(CyberRegs + 0x3c8) = i;
|
*(CyberRegs + 0x3c9) = Cyber_colour_table [i][0] >> 2;
|
*(CyberRegs + 0x3c9) = Cyber_colour_table [i][0] >> 2;
|
*(CyberRegs + 0x3c9) = Cyber_colour_table [i][1] >> 2;
|
*(CyberRegs + 0x3c9) = Cyber_colour_table [i][1] >> 2;
|
*(CyberRegs + 0x3c9) = Cyber_colour_table [i][2] >> 2;
|
*(CyberRegs + 0x3c9) = Cyber_colour_table [i][2] >> 2;
|
}
|
}
|
}
|
}
|
|
|
|
|
/**************************************************************
|
/**************************************************************
|
* We are waiting for "fifo" FIFO-slots empty
|
* We are waiting for "fifo" FIFO-slots empty
|
*/
|
*/
|
void Cyber_WaitQueue (u_short fifo)
|
void Cyber_WaitQueue (u_short fifo)
|
{
|
{
|
u_short status;
|
u_short status;
|
|
|
do
|
do
|
{
|
{
|
status = *((u_short volatile *)(CyberRegs + S3_GP_STAT));
|
status = *((u_short volatile *)(CyberRegs + S3_GP_STAT));
|
}
|
}
|
while (status & fifo);
|
while (status & fifo);
|
}
|
}
|
|
|
/**************************************************************
|
/**************************************************************
|
* We are waiting for Hardware (Graphics Engine) not busy
|
* We are waiting for Hardware (Graphics Engine) not busy
|
*/
|
*/
|
void Cyber_WaitBlit (void)
|
void Cyber_WaitBlit (void)
|
{
|
{
|
u_short status;
|
u_short status;
|
|
|
do
|
do
|
{
|
{
|
status = *((u_short volatile *)(CyberRegs + S3_GP_STAT));
|
status = *((u_short volatile *)(CyberRegs + S3_GP_STAT));
|
}
|
}
|
while (status & S3_HDW_BUSY);
|
while (status & S3_HDW_BUSY);
|
}
|
}
|
|
|
/**************************************************************
|
/**************************************************************
|
* BitBLT - Through the Plane
|
* BitBLT - Through the Plane
|
*/
|
*/
|
void Cyber_BitBLT (u_short curx, u_short cury, u_short destx, u_short desty,
|
void Cyber_BitBLT (u_short curx, u_short cury, u_short destx, u_short desty,
|
u_short width, u_short height, u_short mode)
|
u_short width, u_short height, u_short mode)
|
{
|
{
|
u_short blitcmd = S3_BITBLT;
|
u_short blitcmd = S3_BITBLT;
|
|
|
/* Set drawing direction */
|
/* Set drawing direction */
|
/* -Y, X maj, -X (default) */
|
/* -Y, X maj, -X (default) */
|
if (curx > destx)
|
if (curx > destx)
|
blitcmd |= 0x0020; /* Drawing direction +X */
|
blitcmd |= 0x0020; /* Drawing direction +X */
|
else
|
else
|
{
|
{
|
curx += (width - 1);
|
curx += (width - 1);
|
destx += (width - 1);
|
destx += (width - 1);
|
}
|
}
|
|
|
if (cury > desty)
|
if (cury > desty)
|
blitcmd |= 0x0080; /* Drawing direction +Y */
|
blitcmd |= 0x0080; /* Drawing direction +Y */
|
else
|
else
|
{
|
{
|
cury += (height - 1);
|
cury += (height - 1);
|
desty += (height - 1);
|
desty += (height - 1);
|
}
|
}
|
|
|
Cyber_WaitQueue (0x8000);
|
Cyber_WaitQueue (0x8000);
|
|
|
*((u_short volatile *)(CyberRegs + S3_PIXEL_CNTL)) = 0xa000;
|
*((u_short volatile *)(CyberRegs + S3_PIXEL_CNTL)) = 0xa000;
|
*((u_short volatile *)(CyberRegs + S3_FRGD_MIX)) = (0x0060 | mode);
|
*((u_short volatile *)(CyberRegs + S3_FRGD_MIX)) = (0x0060 | mode);
|
|
|
*((u_short volatile *)(CyberRegs + S3_CUR_X)) = curx;
|
*((u_short volatile *)(CyberRegs + S3_CUR_X)) = curx;
|
*((u_short volatile *)(CyberRegs + S3_CUR_Y)) = cury;
|
*((u_short volatile *)(CyberRegs + S3_CUR_Y)) = cury;
|
|
|
*((u_short volatile *)(CyberRegs + S3_DESTX_DIASTP)) = destx;
|
*((u_short volatile *)(CyberRegs + S3_DESTX_DIASTP)) = destx;
|
*((u_short volatile *)(CyberRegs + S3_DESTY_AXSTP)) = desty;
|
*((u_short volatile *)(CyberRegs + S3_DESTY_AXSTP)) = desty;
|
|
|
*((u_short volatile *)(CyberRegs + S3_MIN_AXIS_PCNT)) = height - 1;
|
*((u_short volatile *)(CyberRegs + S3_MIN_AXIS_PCNT)) = height - 1;
|
*((u_short volatile *)(CyberRegs + S3_MAJ_AXIS_PCNT)) = width - 1;
|
*((u_short volatile *)(CyberRegs + S3_MAJ_AXIS_PCNT)) = width - 1;
|
|
|
*((u_short volatile *)(CyberRegs + S3_CMD)) = blitcmd;
|
*((u_short volatile *)(CyberRegs + S3_CMD)) = blitcmd;
|
}
|
}
|
|
|
/**************************************************************
|
/**************************************************************
|
* Rectangle Fill Solid
|
* Rectangle Fill Solid
|
*/
|
*/
|
void Cyber_RectFill (u_short x, u_short y, u_short width, u_short height,
|
void Cyber_RectFill (u_short x, u_short y, u_short width, u_short height,
|
u_short mode, u_short color)
|
u_short mode, u_short color)
|
{
|
{
|
u_short blitcmd = S3_FILLEDRECT;
|
u_short blitcmd = S3_FILLEDRECT;
|
|
|
Cyber_WaitQueue (0x8000);
|
Cyber_WaitQueue (0x8000);
|
|
|
*((u_short volatile *)(CyberRegs + S3_PIXEL_CNTL)) = 0xa000;
|
*((u_short volatile *)(CyberRegs + S3_PIXEL_CNTL)) = 0xa000;
|
*((u_short volatile *)(CyberRegs + S3_FRGD_MIX)) = (0x0020 | mode);
|
*((u_short volatile *)(CyberRegs + S3_FRGD_MIX)) = (0x0020 | mode);
|
|
|
*((u_short volatile *)(CyberRegs + S3_MULT_MISC)) = 0xe000;
|
*((u_short volatile *)(CyberRegs + S3_MULT_MISC)) = 0xe000;
|
*((u_short volatile *)(CyberRegs + S3_FRGD_COLOR)) = color;
|
*((u_short volatile *)(CyberRegs + S3_FRGD_COLOR)) = color;
|
|
|
*((u_short volatile *)(CyberRegs + S3_CUR_X)) = x;
|
*((u_short volatile *)(CyberRegs + S3_CUR_X)) = x;
|
*((u_short volatile *)(CyberRegs + S3_CUR_Y)) = y;
|
*((u_short volatile *)(CyberRegs + S3_CUR_Y)) = y;
|
|
|
*((u_short volatile *)(CyberRegs + S3_MIN_AXIS_PCNT)) = height - 1;
|
*((u_short volatile *)(CyberRegs + S3_MIN_AXIS_PCNT)) = height - 1;
|
*((u_short volatile *)(CyberRegs + S3_MAJ_AXIS_PCNT)) = width - 1;
|
*((u_short volatile *)(CyberRegs + S3_MAJ_AXIS_PCNT)) = width - 1;
|
|
|
*((u_short volatile *)(CyberRegs + S3_CMD)) = blitcmd;
|
*((u_short volatile *)(CyberRegs + S3_CMD)) = blitcmd;
|
}
|
}
|
|
|
|
|
/**************************************************************
|
/**************************************************************
|
* Move cursor to x, y
|
* Move cursor to x, y
|
*/
|
*/
|
void Cyber_MoveCursor (u_short x, u_short y)
|
void Cyber_MoveCursor (u_short x, u_short y)
|
{
|
{
|
*(CyberRegs + S3_CRTC_ADR) = 0x39;
|
*(CyberRegs + S3_CRTC_ADR) = 0x39;
|
*(CyberRegs + S3_CRTC_DATA) = 0xa0;
|
*(CyberRegs + S3_CRTC_DATA) = 0xa0;
|
|
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_ORGX_H;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_ORGX_H;
|
*(CyberRegs + S3_CRTC_DATA) = (char)((x & 0x0700) >> 8);
|
*(CyberRegs + S3_CRTC_DATA) = (char)((x & 0x0700) >> 8);
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_ORGX_L;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_ORGX_L;
|
*(CyberRegs + S3_CRTC_DATA) = (char)(x & 0x00ff);
|
*(CyberRegs + S3_CRTC_DATA) = (char)(x & 0x00ff);
|
|
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_ORGY_H;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_ORGY_H;
|
*(CyberRegs + S3_CRTC_DATA) = (char)((y & 0x0700) >> 8);
|
*(CyberRegs + S3_CRTC_DATA) = (char)((y & 0x0700) >> 8);
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_ORGY_L;
|
*(CyberRegs + S3_CRTC_ADR) = S3_HWGC_ORGY_L;
|
*(CyberRegs + S3_CRTC_DATA) = (char)(y & 0x00ff);
|
*(CyberRegs + S3_CRTC_DATA) = (char)(y & 0x00ff);
|
}
|
}
|
|
|
|
|
/* -------------------- Interfaces to hardware functions -------------------- */
|
/* -------------------- Interfaces to hardware functions -------------------- */
|
|
|
|
|
static struct fb_hwswitch Cyber_switch = {
|
static struct fb_hwswitch Cyber_switch = {
|
Cyber_init, Cyber_encode_fix, Cyber_decode_var, Cyber_encode_var,
|
Cyber_init, Cyber_encode_fix, Cyber_decode_var, Cyber_encode_var,
|
Cyber_getcolreg, Cyber_setcolreg, Cyber_blank
|
Cyber_getcolreg, Cyber_setcolreg, Cyber_blank
|
};
|
};
|
|
|
|
|
/* -------------------- Generic routines ------------------------------------ */
|
/* -------------------- Generic routines ------------------------------------ */
|
|
|
|
|
/*
|
/*
|
* Fill the hardware's `par' structure.
|
* Fill the hardware's `par' structure.
|
*/
|
*/
|
|
|
static void Cyber_fb_get_par(struct Cyber_fb_par *par)
|
static void Cyber_fb_get_par(struct Cyber_fb_par *par)
|
{
|
{
|
if (current_par_valid)
|
if (current_par_valid)
|
*par = current_par;
|
*par = current_par;
|
else
|
else
|
fbhw->decode_var(&Cyber_fb_predefined[Cyberfb_mode], par);
|
fbhw->decode_var(&Cyber_fb_predefined[Cyberfb_mode], par);
|
}
|
}
|
|
|
|
|
static void Cyber_fb_set_par(struct Cyber_fb_par *par)
|
static void Cyber_fb_set_par(struct Cyber_fb_par *par)
|
{
|
{
|
current_par = *par;
|
current_par = *par;
|
current_par_valid = 1;
|
current_par_valid = 1;
|
}
|
}
|
|
|
|
|
static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive)
|
static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive)
|
{
|
{
|
int err, activate;
|
int err, activate;
|
struct Cyber_fb_par par;
|
struct Cyber_fb_par par;
|
|
|
if ((err = fbhw->decode_var(var, &par)))
|
if ((err = fbhw->decode_var(var, &par)))
|
return(err);
|
return(err);
|
activate = var->activate;
|
activate = var->activate;
|
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW && isactive)
|
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW && isactive)
|
Cyber_fb_set_par(&par);
|
Cyber_fb_set_par(&par);
|
fbhw->encode_var(var, &par);
|
fbhw->encode_var(var, &par);
|
var->activate = activate;
|
var->activate = activate;
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Default Colormaps
|
* Default Colormaps
|
*/
|
*/
|
|
|
static u_short red16[] =
|
static u_short red16[] =
|
{ 0xc000, 0x0000, 0x0000, 0x0000, 0xc000, 0xc000, 0xc000, 0x0000,
|
{ 0xc000, 0x0000, 0x0000, 0x0000, 0xc000, 0xc000, 0xc000, 0x0000,
|
0x8000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff};
|
0x8000, 0x0000, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff};
|
static u_short green16[] =
|
static u_short green16[] =
|
{ 0xc000, 0x0000, 0xc000, 0xc000, 0x0000, 0x0000, 0xc000, 0x0000,
|
{ 0xc000, 0x0000, 0xc000, 0xc000, 0x0000, 0x0000, 0xc000, 0x0000,
|
0x8000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff};
|
0x8000, 0x0000, 0xffff, 0xffff, 0x0000, 0x0000, 0xffff, 0xffff};
|
static u_short blue16[] =
|
static u_short blue16[] =
|
{ 0xc000, 0x0000, 0x0000, 0xc000, 0x0000, 0xc000, 0x0000, 0x0000,
|
{ 0xc000, 0x0000, 0x0000, 0xc000, 0x0000, 0xc000, 0x0000, 0x0000,
|
0x8000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff};
|
0x8000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff, 0x0000, 0xffff};
|
|
|
|
|
static struct fb_cmap default_16_colors =
|
static struct fb_cmap default_16_colors =
|
{ 0, 16, red16, green16, blue16, NULL };
|
{ 0, 16, red16, green16, blue16, NULL };
|
|
|
|
|
static struct fb_cmap *get_default_colormap(int bpp)
|
static struct fb_cmap *get_default_colormap(int bpp)
|
{
|
{
|
return(&default_16_colors);
|
return(&default_16_colors);
|
}
|
}
|
|
|
|
|
#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7fff-(val))>>16)
|
#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7fff-(val))>>16)
|
#define CNVT_FROMHW(val,width) (((width) ? ((((val)<<16)-(val)) / \
|
#define CNVT_FROMHW(val,width) (((width) ? ((((val)<<16)-(val)) / \
|
((1<<(width))-1)) : 0))
|
((1<<(width))-1)) : 0))
|
|
|
static int do_fb_get_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
|
static int do_fb_get_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
|
int kspc)
|
int kspc)
|
{
|
{
|
int i, start;
|
int i, start;
|
u_short *red, *green, *blue, *transp;
|
u_short *red, *green, *blue, *transp;
|
u_int hred, hgreen, hblue, htransp;
|
u_int hred, hgreen, hblue, htransp;
|
|
|
red = cmap->red;
|
red = cmap->red;
|
green = cmap->green;
|
green = cmap->green;
|
blue = cmap->blue;
|
blue = cmap->blue;
|
transp = cmap->transp;
|
transp = cmap->transp;
|
start = cmap->start;
|
start = cmap->start;
|
if (start < 0)
|
if (start < 0)
|
return(-EINVAL);
|
return(-EINVAL);
|
for (i = 0; i < cmap->len; i++) {
|
for (i = 0; i < cmap->len; i++) {
|
if (fbhw->getcolreg(start++, &hred, &hgreen, &hblue, &htransp))
|
if (fbhw->getcolreg(start++, &hred, &hgreen, &hblue, &htransp))
|
return(0);
|
return(0);
|
hred = CNVT_FROMHW(hred, var->red.length);
|
hred = CNVT_FROMHW(hred, var->red.length);
|
hgreen = CNVT_FROMHW(hgreen, var->green.length);
|
hgreen = CNVT_FROMHW(hgreen, var->green.length);
|
hblue = CNVT_FROMHW(hblue, var->blue.length);
|
hblue = CNVT_FROMHW(hblue, var->blue.length);
|
htransp = CNVT_FROMHW(htransp, var->transp.length);
|
htransp = CNVT_FROMHW(htransp, var->transp.length);
|
if (kspc) {
|
if (kspc) {
|
*red = hred;
|
*red = hred;
|
*green = hgreen;
|
*green = hgreen;
|
*blue = hblue;
|
*blue = hblue;
|
if (transp)
|
if (transp)
|
*transp = htransp;
|
*transp = htransp;
|
} else {
|
} else {
|
put_fs_word(hred, red);
|
put_fs_word(hred, red);
|
put_fs_word(hgreen, green);
|
put_fs_word(hgreen, green);
|
put_fs_word(hblue, blue);
|
put_fs_word(hblue, blue);
|
if (transp)
|
if (transp)
|
put_fs_word(htransp, transp);
|
put_fs_word(htransp, transp);
|
}
|
}
|
red++;
|
red++;
|
green++;
|
green++;
|
blue++;
|
blue++;
|
if (transp)
|
if (transp)
|
transp++;
|
transp++;
|
}
|
}
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
static int do_fb_set_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
|
static int do_fb_set_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
|
int kspc)
|
int kspc)
|
{
|
{
|
int i, start;
|
int i, start;
|
u_short *red, *green, *blue, *transp;
|
u_short *red, *green, *blue, *transp;
|
u_int hred, hgreen, hblue, htransp;
|
u_int hred, hgreen, hblue, htransp;
|
|
|
red = cmap->red;
|
red = cmap->red;
|
green = cmap->green;
|
green = cmap->green;
|
blue = cmap->blue;
|
blue = cmap->blue;
|
transp = cmap->transp;
|
transp = cmap->transp;
|
start = cmap->start;
|
start = cmap->start;
|
|
|
if (start < 0)
|
if (start < 0)
|
return(-EINVAL);
|
return(-EINVAL);
|
for (i = 0; i < cmap->len; i++) {
|
for (i = 0; i < cmap->len; i++) {
|
if (kspc) {
|
if (kspc) {
|
hred = *red;
|
hred = *red;
|
hgreen = *green;
|
hgreen = *green;
|
hblue = *blue;
|
hblue = *blue;
|
htransp = transp ? *transp : 0;
|
htransp = transp ? *transp : 0;
|
} else {
|
} else {
|
hred = get_fs_word(red);
|
hred = get_fs_word(red);
|
hgreen = get_fs_word(green);
|
hgreen = get_fs_word(green);
|
hblue = get_fs_word(blue);
|
hblue = get_fs_word(blue);
|
htransp = transp ? get_fs_word(transp) : 0;
|
htransp = transp ? get_fs_word(transp) : 0;
|
}
|
}
|
hred = CNVT_TOHW(hred, var->red.length);
|
hred = CNVT_TOHW(hred, var->red.length);
|
hgreen = CNVT_TOHW(hgreen, var->green.length);
|
hgreen = CNVT_TOHW(hgreen, var->green.length);
|
hblue = CNVT_TOHW(hblue, var->blue.length);
|
hblue = CNVT_TOHW(hblue, var->blue.length);
|
htransp = CNVT_TOHW(htransp, var->transp.length);
|
htransp = CNVT_TOHW(htransp, var->transp.length);
|
red++;
|
red++;
|
green++;
|
green++;
|
blue++;
|
blue++;
|
if (transp)
|
if (transp)
|
transp++;
|
transp++;
|
if (fbhw->setcolreg(start++, hred, hgreen, hblue, htransp))
|
if (fbhw->setcolreg(start++, hred, hgreen, hblue, htransp))
|
return(0);
|
return(0);
|
}
|
}
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
static void do_install_cmap(int con)
|
static void do_install_cmap(int con)
|
{
|
{
|
if (con != currcon)
|
if (con != currcon)
|
return;
|
return;
|
if (disp[con].cmap.len)
|
if (disp[con].cmap.len)
|
do_fb_set_cmap(&disp[con].cmap, &disp[con].var, 1);
|
do_fb_set_cmap(&disp[con].cmap, &disp[con].var, 1);
|
else
|
else
|
do_fb_set_cmap(get_default_colormap(disp[con].var.bits_per_pixel),
|
do_fb_set_cmap(get_default_colormap(disp[con].var.bits_per_pixel),
|
&disp[con].var, 1);
|
&disp[con].var, 1);
|
}
|
}
|
|
|
|
|
static void memcpy_fs(int fsfromto, void *to, void *from, int len)
|
static void memcpy_fs(int fsfromto, void *to, void *from, int len)
|
{
|
{
|
switch (fsfromto) {
|
switch (fsfromto) {
|
case 0:
|
case 0:
|
memcpy(to, from, len);
|
memcpy(to, from, len);
|
return;
|
return;
|
case 1:
|
case 1:
|
memcpy_fromfs(to, from, len);
|
memcpy_fromfs(to, from, len);
|
return;
|
return;
|
case 2:
|
case 2:
|
memcpy_tofs(to, from, len);
|
memcpy_tofs(to, from, len);
|
return;
|
return;
|
}
|
}
|
}
|
}
|
|
|
|
|
static void copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto)
|
static void copy_cmap(struct fb_cmap *from, struct fb_cmap *to, int fsfromto)
|
{
|
{
|
int size;
|
int size;
|
int tooff = 0, fromoff = 0;
|
int tooff = 0, fromoff = 0;
|
|
|
if (to->start > from->start)
|
if (to->start > from->start)
|
fromoff = to->start-from->start;
|
fromoff = to->start-from->start;
|
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 > from->len-fromoff)
|
size = from->len-fromoff;
|
size = from->len-fromoff;
|
if (size < 0)
|
if (size < 0)
|
return;
|
return;
|
size *= sizeof(u_short);
|
size *= sizeof(u_short);
|
memcpy_fs(fsfromto, to->red+tooff, from->red+fromoff, size);
|
memcpy_fs(fsfromto, to->red+tooff, from->red+fromoff, size);
|
memcpy_fs(fsfromto, to->green+tooff, from->green+fromoff, size);
|
memcpy_fs(fsfromto, to->green+tooff, from->green+fromoff, size);
|
memcpy_fs(fsfromto, to->blue+tooff, from->blue+fromoff, size);
|
memcpy_fs(fsfromto, to->blue+tooff, from->blue+fromoff, size);
|
if (from->transp && to->transp)
|
if (from->transp && to->transp)
|
memcpy_fs(fsfromto, to->transp+tooff, from->transp+fromoff, size);
|
memcpy_fs(fsfromto, to->transp+tooff, from->transp+fromoff, size);
|
}
|
}
|
|
|
|
|
static int alloc_cmap(struct fb_cmap *cmap, int len, int transp)
|
static int alloc_cmap(struct fb_cmap *cmap, int len, int transp)
|
{
|
{
|
int size = len*sizeof(u_short);
|
int size = len*sizeof(u_short);
|
|
|
if (cmap->len != len) {
|
if (cmap->len != len) {
|
if (cmap->red)
|
if (cmap->red)
|
kfree(cmap->red);
|
kfree(cmap->red);
|
if (cmap->green)
|
if (cmap->green)
|
kfree(cmap->green);
|
kfree(cmap->green);
|
if (cmap->blue)
|
if (cmap->blue)
|
kfree(cmap->blue);
|
kfree(cmap->blue);
|
if (cmap->transp)
|
if (cmap->transp)
|
kfree(cmap->transp);
|
kfree(cmap->transp);
|
cmap->red = cmap->green = cmap->blue = cmap->transp = NULL;
|
cmap->red = cmap->green = cmap->blue = cmap->transp = NULL;
|
cmap->len = 0;
|
cmap->len = 0;
|
if (!len)
|
if (!len)
|
return(0);
|
return(0);
|
if (!(cmap->red = kmalloc(size, GFP_ATOMIC)))
|
if (!(cmap->red = kmalloc(size, GFP_ATOMIC)))
|
return(-1);
|
return(-1);
|
if (!(cmap->green = kmalloc(size, GFP_ATOMIC)))
|
if (!(cmap->green = kmalloc(size, GFP_ATOMIC)))
|
return(-1);
|
return(-1);
|
if (!(cmap->blue = kmalloc(size, GFP_ATOMIC)))
|
if (!(cmap->blue = kmalloc(size, GFP_ATOMIC)))
|
return(-1);
|
return(-1);
|
if (transp) {
|
if (transp) {
|
if (!(cmap->transp = kmalloc(size, GFP_ATOMIC)))
|
if (!(cmap->transp = kmalloc(size, GFP_ATOMIC)))
|
return(-1);
|
return(-1);
|
} else
|
} else
|
cmap->transp = NULL;
|
cmap->transp = NULL;
|
}
|
}
|
cmap->start = 0;
|
cmap->start = 0;
|
cmap->len = len;
|
cmap->len = len;
|
copy_cmap(get_default_colormap(len), cmap, 0);
|
copy_cmap(get_default_colormap(len), cmap, 0);
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Get the Fixed Part of the Display
|
* Get the Fixed Part of the Display
|
*/
|
*/
|
|
|
static int Cyber_fb_get_fix(struct fb_fix_screeninfo *fix, int con)
|
static int Cyber_fb_get_fix(struct fb_fix_screeninfo *fix, int con)
|
{
|
{
|
struct Cyber_fb_par par;
|
struct Cyber_fb_par par;
|
int error = 0;
|
int error = 0;
|
|
|
if (con == -1)
|
if (con == -1)
|
Cyber_fb_get_par(&par);
|
Cyber_fb_get_par(&par);
|
else
|
else
|
error = fbhw->decode_var(&disp[con].var, &par);
|
error = fbhw->decode_var(&disp[con].var, &par);
|
return(error ? error : fbhw->encode_fix(fix, &par));
|
return(error ? error : fbhw->encode_fix(fix, &par));
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Get the User Defined Part of the Display
|
* Get the User Defined Part of the Display
|
*/
|
*/
|
|
|
static int Cyber_fb_get_var(struct fb_var_screeninfo *var, int con)
|
static int Cyber_fb_get_var(struct fb_var_screeninfo *var, int con)
|
{
|
{
|
struct Cyber_fb_par par;
|
struct Cyber_fb_par par;
|
int error = 0;
|
int error = 0;
|
|
|
if (con == -1) {
|
if (con == -1) {
|
Cyber_fb_get_par(&par);
|
Cyber_fb_get_par(&par);
|
error = fbhw->encode_var(var, &par);
|
error = fbhw->encode_var(var, &par);
|
} else
|
} else
|
*var = disp[con].var;
|
*var = disp[con].var;
|
return(error);
|
return(error);
|
}
|
}
|
|
|
|
|
static void Cyber_fb_set_disp(int con)
|
static void Cyber_fb_set_disp(int con)
|
{
|
{
|
struct fb_fix_screeninfo fix;
|
struct fb_fix_screeninfo fix;
|
|
|
Cyber_fb_get_fix(&fix, con);
|
Cyber_fb_get_fix(&fix, con);
|
if (con == -1)
|
if (con == -1)
|
con = 0;
|
con = 0;
|
disp[con].screen_base = (u_char *)fix.smem_start;
|
disp[con].screen_base = (u_char *)fix.smem_start;
|
disp[con].visual = fix.visual;
|
disp[con].visual = fix.visual;
|
disp[con].type = fix.type;
|
disp[con].type = fix.type;
|
disp[con].type_aux = fix.type_aux;
|
disp[con].type_aux = fix.type_aux;
|
disp[con].ypanstep = fix.ypanstep;
|
disp[con].ypanstep = fix.ypanstep;
|
disp[con].ywrapstep = fix.ywrapstep;
|
disp[con].ywrapstep = fix.ywrapstep;
|
disp[con].can_soft_blank = 1;
|
disp[con].can_soft_blank = 1;
|
disp[con].inverse = Cyberfb_inverse;
|
disp[con].inverse = Cyberfb_inverse;
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Set the User Defined Part of the Display
|
* Set the User Defined Part of the Display
|
*/
|
*/
|
|
|
static int Cyber_fb_set_var(struct fb_var_screeninfo *var, int con)
|
static int Cyber_fb_set_var(struct fb_var_screeninfo *var, int con)
|
{
|
{
|
int err, oldxres, oldyres, oldvxres, oldvyres, oldbpp;
|
int err, oldxres, oldyres, oldvxres, oldvyres, oldbpp;
|
|
|
if ((err = do_fb_set_var(var, con == currcon)))
|
if ((err = do_fb_set_var(var, con == currcon)))
|
return(err);
|
return(err);
|
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
|
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
|
oldxres = disp[con].var.xres;
|
oldxres = disp[con].var.xres;
|
oldyres = disp[con].var.yres;
|
oldyres = disp[con].var.yres;
|
oldvxres = disp[con].var.xres_virtual;
|
oldvxres = disp[con].var.xres_virtual;
|
oldvyres = disp[con].var.yres_virtual;
|
oldvyres = disp[con].var.yres_virtual;
|
oldbpp = disp[con].var.bits_per_pixel;
|
oldbpp = disp[con].var.bits_per_pixel;
|
disp[con].var = *var;
|
disp[con].var = *var;
|
if (oldxres != var->xres || oldyres != var->yres ||
|
if (oldxres != var->xres || oldyres != var->yres ||
|
oldvxres != var->xres_virtual || oldvyres != var->yres_virtual ||
|
oldvxres != var->xres_virtual || oldvyres != var->yres_virtual ||
|
oldbpp != var->bits_per_pixel) {
|
oldbpp != var->bits_per_pixel) {
|
Cyber_fb_set_disp(con);
|
Cyber_fb_set_disp(con);
|
(*fb_info.changevar)(con);
|
(*fb_info.changevar)(con);
|
alloc_cmap(&disp[con].cmap, 0, 0);
|
alloc_cmap(&disp[con].cmap, 0, 0);
|
do_install_cmap(con);
|
do_install_cmap(con);
|
}
|
}
|
}
|
}
|
var->activate = 0;
|
var->activate = 0;
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Get the Colormap
|
* Get the Colormap
|
*/
|
*/
|
|
|
static int Cyber_fb_get_cmap(struct fb_cmap *cmap, int kspc, int con)
|
static int Cyber_fb_get_cmap(struct fb_cmap *cmap, int kspc, int con)
|
{
|
{
|
if (con == currcon) /* current console? */
|
if (con == currcon) /* current console? */
|
return(do_fb_get_cmap(cmap, &disp[con].var, kspc));
|
return(do_fb_get_cmap(cmap, &disp[con].var, kspc));
|
else if (disp[con].cmap.len) /* non default colormap? */
|
else if (disp[con].cmap.len) /* non default colormap? */
|
copy_cmap(&disp[con].cmap, cmap, kspc ? 0 : 2);
|
copy_cmap(&disp[con].cmap, cmap, kspc ? 0 : 2);
|
else
|
else
|
copy_cmap(get_default_colormap(disp[con].var.bits_per_pixel), cmap,
|
copy_cmap(get_default_colormap(disp[con].var.bits_per_pixel), cmap,
|
kspc ? 0 : 2);
|
kspc ? 0 : 2);
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Set the Colormap
|
* Set the Colormap
|
*/
|
*/
|
|
|
static int Cyber_fb_set_cmap(struct fb_cmap *cmap, int kspc, int con)
|
static int Cyber_fb_set_cmap(struct fb_cmap *cmap, int kspc, int con)
|
{
|
{
|
int err;
|
int err;
|
|
|
if (!disp[con].cmap.len) { /* no colormap allocated? */
|
if (!disp[con].cmap.len) { /* no colormap allocated? */
|
if ((err = alloc_cmap(&disp[con].cmap, 1<<disp[con].var.bits_per_pixel,
|
if ((err = alloc_cmap(&disp[con].cmap, 1<<disp[con].var.bits_per_pixel,
|
0)))
|
0)))
|
return(err);
|
return(err);
|
}
|
}
|
if (con == currcon) /* current console? */
|
if (con == currcon) /* current console? */
|
return(do_fb_set_cmap(cmap, &disp[con].var, kspc));
|
return(do_fb_set_cmap(cmap, &disp[con].var, kspc));
|
else
|
else
|
copy_cmap(cmap, &disp[con].cmap, kspc ? 0 : 1);
|
copy_cmap(cmap, &disp[con].cmap, kspc ? 0 : 1);
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Pan or Wrap the Display
|
* Pan or Wrap the Display
|
*
|
*
|
* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
|
* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
|
*/
|
*/
|
|
|
static int Cyber_fb_pan_display(struct fb_var_screeninfo *var, int con)
|
static int Cyber_fb_pan_display(struct fb_var_screeninfo *var, int con)
|
{
|
{
|
return(-EINVAL);
|
return(-EINVAL);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Cybervision Frame Buffer Specific ioctls
|
* Cybervision Frame Buffer Specific ioctls
|
*/
|
*/
|
|
|
static int Cyber_fb_ioctl(struct inode *inode, struct file *file,
|
static int Cyber_fb_ioctl(struct inode *inode, struct file *file,
|
u_int cmd, u_long arg, int con)
|
u_int cmd, u_long arg, int con)
|
{
|
{
|
return(-EINVAL);
|
return(-EINVAL);
|
}
|
}
|
|
|
|
|
static struct fb_ops Cyber_fb_ops = {
|
static struct fb_ops Cyber_fb_ops = {
|
Cyber_fb_get_fix, Cyber_fb_get_var, Cyber_fb_set_var, Cyber_fb_get_cmap,
|
Cyber_fb_get_fix, Cyber_fb_get_var, Cyber_fb_set_var, Cyber_fb_get_cmap,
|
Cyber_fb_set_cmap, Cyber_fb_pan_display, Cyber_fb_ioctl
|
Cyber_fb_set_cmap, Cyber_fb_pan_display, Cyber_fb_ioctl
|
};
|
};
|
|
|
|
|
int Cyber_probe(void)
|
int Cyber_probe(void)
|
{
|
{
|
CyberKey = zorro_find(MANUF_PHASE5, PROD_CYBERVISION, 0, 0);
|
CyberKey = zorro_find(MANUF_PHASE5, PROD_CYBERVISION, 0, 0);
|
return(CyberKey);
|
return(CyberKey);
|
}
|
}
|
|
|
|
|
void Cyber_video_setup(char *options, int *ints)
|
void Cyber_video_setup(char *options, int *ints)
|
{
|
{
|
char *this_opt;
|
char *this_opt;
|
int i;
|
int i;
|
|
|
fb_info.fontname[0] = '\0';
|
fb_info.fontname[0] = '\0';
|
|
|
if (!options || !*options)
|
if (!options || !*options)
|
return;
|
return;
|
|
|
for (this_opt = strtok(options, ","); this_opt; this_opt = strtok(NULL, ","))
|
for (this_opt = strtok(options, ","); this_opt; this_opt = strtok(NULL, ","))
|
if (!strcmp(this_opt, "inverse")) {
|
if (!strcmp(this_opt, "inverse")) {
|
Cyberfb_inverse = 1;
|
Cyberfb_inverse = 1;
|
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
red16[i] = ~red16[i];
|
red16[i] = ~red16[i];
|
green16[i] = ~green16[i];
|
green16[i] = ~green16[i];
|
blue16[i] = ~blue16[i];
|
blue16[i] = ~blue16[i];
|
}
|
}
|
} else if (!strncmp(this_opt, "font:", 5))
|
} else if (!strncmp(this_opt, "font:", 5))
|
strcpy(fb_info.fontname, this_opt+5);
|
strcpy(fb_info.fontname, this_opt+5);
|
else if (!strcmp (this_opt, "cyber8"))
|
else if (!strcmp (this_opt, "cyber8"))
|
Cyberfb_Cyber8 = 1;
|
Cyberfb_Cyber8 = 1;
|
else if (!strcmp (this_opt, "cyber16"))
|
else if (!strcmp (this_opt, "cyber16"))
|
Cyberfb_Cyber16 = 1;
|
Cyberfb_Cyber16 = 1;
|
else
|
else
|
Cyberfb_mode = get_video_mode(this_opt);
|
Cyberfb_mode = get_video_mode(this_opt);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Initialization
|
* Initialization
|
*/
|
*/
|
|
|
struct fb_info *Cyber_fb_init(long *mem_start)
|
struct fb_info *Cyber_fb_init(long *mem_start)
|
{
|
{
|
int err;
|
int err;
|
struct Cyber_fb_par par;
|
struct Cyber_fb_par par;
|
|
|
memstart = mem_start;
|
memstart = mem_start;
|
|
|
fbhw = &Cyber_switch;
|
fbhw = &Cyber_switch;
|
|
|
err = register_framebuffer(Cyber_fb_name, &node, &Cyber_fb_ops,
|
err = register_framebuffer(Cyber_fb_name, &node, &Cyber_fb_ops,
|
NUM_TOTAL_MODES, Cyber_fb_predefined);
|
NUM_TOTAL_MODES, Cyber_fb_predefined);
|
if (err < 0)
|
if (err < 0)
|
panic("Cannot register frame buffer\n");
|
panic("Cannot register frame buffer\n");
|
|
|
fbhw->init();
|
fbhw->init();
|
fbhw->decode_var(&Cyber_fb_predefined[Cyberfb_mode], &par);
|
fbhw->decode_var(&Cyber_fb_predefined[Cyberfb_mode], &par);
|
fbhw->encode_var(&Cyber_fb_predefined[0], &par);
|
fbhw->encode_var(&Cyber_fb_predefined[0], &par);
|
|
|
strcpy(fb_info.modename, Cyber_fb_name);
|
strcpy(fb_info.modename, Cyber_fb_name);
|
fb_info.disp = disp;
|
fb_info.disp = disp;
|
fb_info.switch_con = &Cyberfb_switch;
|
fb_info.switch_con = &Cyberfb_switch;
|
fb_info.updatevar = &Cyberfb_updatevar;
|
fb_info.updatevar = &Cyberfb_updatevar;
|
fb_info.blank = &Cyberfb_blank;
|
fb_info.blank = &Cyberfb_blank;
|
|
|
do_fb_set_var(&Cyber_fb_predefined[0], 1);
|
do_fb_set_var(&Cyber_fb_predefined[0], 1);
|
Cyber_fb_get_var(&disp[0].var, -1);
|
Cyber_fb_get_var(&disp[0].var, -1);
|
Cyber_fb_set_disp(-1);
|
Cyber_fb_set_disp(-1);
|
do_install_cmap(0);
|
do_install_cmap(0);
|
return(&fb_info);
|
return(&fb_info);
|
}
|
}
|
|
|
|
|
static int Cyberfb_switch(int con)
|
static int Cyberfb_switch(int con)
|
{
|
{
|
/* Do we have to save the colormap? */
|
/* Do we have to save the colormap? */
|
if (disp[currcon].cmap.len)
|
if (disp[currcon].cmap.len)
|
do_fb_get_cmap(&disp[currcon].cmap, &disp[currcon].var, 1);
|
do_fb_get_cmap(&disp[currcon].cmap, &disp[currcon].var, 1);
|
|
|
do_fb_set_var(&disp[con].var, 1);
|
do_fb_set_var(&disp[con].var, 1);
|
currcon = con;
|
currcon = con;
|
/* Install new colormap */
|
/* Install new colormap */
|
do_install_cmap(con);
|
do_install_cmap(con);
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Update the `var' structure (called by fbcon.c)
|
* Update the `var' structure (called by fbcon.c)
|
*
|
*
|
* This call looks only at yoffset and the FB_VMODE_YWRAP flag in `var'.
|
* This call looks only at yoffset and the FB_VMODE_YWRAP flag in `var'.
|
* Since it's called by a kernel driver, no range checking is done.
|
* Since it's called by a kernel driver, no range checking is done.
|
*/
|
*/
|
|
|
static int Cyberfb_updatevar(int con)
|
static int Cyberfb_updatevar(int con)
|
{
|
{
|
return(0);
|
return(0);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Blank the display.
|
* Blank the display.
|
*/
|
*/
|
|
|
static void Cyberfb_blank(int blank)
|
static void Cyberfb_blank(int blank)
|
{
|
{
|
fbhw->blank(blank);
|
fbhw->blank(blank);
|
}
|
}
|
|
|
|
|
/*
|
/*
|
* Get a Video Mode
|
* Get a Video Mode
|
*/
|
*/
|
|
|
static int get_video_mode(const char *name)
|
static int get_video_mode(const char *name)
|
{
|
{
|
int i;
|
int i;
|
|
|
for (i = 1; i < NUM_PREDEF_MODES; i++)
|
for (i = 1; i < NUM_PREDEF_MODES; i++)
|
if (!strcmp(name, Cyber_fb_modenames[i]))
|
if (!strcmp(name, Cyber_fb_modenames[i]))
|
return(i);
|
return(i);
|
return(0);
|
return(0);
|
}
|
}
|
|
|