📄 atafb.c
字号:
/* * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device * * Copyright (C) 1994 Martin Schaller & Roman Hodek * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. * * History: * - 03 Jan 95: Original version by Martin Schaller: The TT driver and * all the device independent stuff * - 09 Jan 95: Roman: I've added the hardware abstraction (hw_switch) * and wrote the Falcon, ST(E), and External drivers * based on the original TT driver. * - 07 May 95: Martin: Added colormap operations for the external driver * - 21 May 95: Martin: Added support for overscan * Andreas: some bug fixes for this * - Jul 95: Guenther Kelleter <guenther@pool.informatik.rwth-aachen.de>: * Programmable Falcon video modes * (thanks to Christian Cartus for documentation * of VIDEL registers). * - 27 Dec 95: Guenther: Implemented user definable video modes "user[0-7]" * on minor 24...31. "user0" may be set on commandline by * "R<x>;<y>;<depth>". (Makes sense only on Falcon) * Video mode switch on Falcon now done at next VBL interrupt * to avoid the annoying right shift of the screen. * - 23 Sep 97: Juergen: added xres_virtual for cards like ProMST * The external-part is legacy, therefore hardware-specific * functions like panning/hardwarescrolling/blanking isn't * supported. * - 29 Sep 97: Juergen: added Romans suggestion for pan_display * (var->xoffset was changed even if no set_screen_base avail.) * - 05 Oct 97: Juergen: extfb (PACKED_PIXEL) is FB_PSEUDOCOLOR 'cause * we know how to set the colors * ext_*palette: read from ext_colors (former MV300_colors) * write to ext_colors and RAMDAC * * To do: * - For the Falcon it is not possible to set random video modes on * SM124 and SC/TV, only the bootup resolution is supported. * */#define ATAFB_TT#define ATAFB_STE#define ATAFB_EXT#define ATAFB_FALCON#include <linux/module.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/mm.h>#include <linux/tty.h>#include <linux/slab.h>#include <linux/delay.h>#include <linux/init.h>#include <asm/setup.h>#include <asm/uaccess.h>#include <asm/pgtable.h>#include <asm/irq.h>#include <asm/io.h>#include <asm/atarihw.h>#include <asm/atariints.h>#include <asm/atari_stram.h>#include <linux/fb.h>#include <asm/atarikb.h>#include <video/fbcon.h>#include <video/fbcon-cfb8.h>#include <video/fbcon-cfb16.h>#include <video/fbcon-iplan2p2.h>#include <video/fbcon-iplan2p4.h>#include <video/fbcon-iplan2p8.h>#include <video/fbcon-mfb.h>#define SWITCH_ACIA 0x01 /* modes for switch on OverScan */#define SWITCH_SND6 0x40#define SWITCH_SND7 0x80#define SWITCH_NONE 0x00#define up(x, r) (((x) + (r) - 1) & ~((r)-1))static int default_par=0; /* default resolution (0=none) */static unsigned long default_mem_req=0;static int hwscroll=-1;static int use_hwscroll = 1;static int sttt_xres=640,st_yres=400,tt_yres=480;static int sttt_xres_virtual=640,sttt_yres_virtual=400;static int ovsc_offset=0, ovsc_addlen=0;static struct atafb_par { void *screen_base; int yres_virtual;#if defined ATAFB_TT || defined ATAFB_STE union { struct { int mode; int sync; } tt, st;#endif#ifdef ATAFB_FALCON struct falcon_hw { /* Here are fields for storing a video mode, as direct * parameters for the hardware. */ short sync; short line_width; short line_offset; short st_shift; short f_shift; short vid_control; short vid_mode; short xoffset; short hht, hbb, hbe, hdb, hde, hss; short vft, vbb, vbe, vdb, vde, vss; /* auxiliary information */ short mono; short ste_mode; short bpp; } falcon;#endif /* Nothing needed for external mode */ } hw;} current_par;/* Don't calculate an own resolution, and thus don't change the one found when * booting (currently used for the Falcon to keep settings for internal video * hardware extensions (e.g. ScreenBlaster) */static int DontCalcRes = 0; #ifdef ATAFB_FALCON#define HHT hw.falcon.hht#define HBB hw.falcon.hbb#define HBE hw.falcon.hbe#define HDB hw.falcon.hdb#define HDE hw.falcon.hde#define HSS hw.falcon.hss#define VFT hw.falcon.vft#define VBB hw.falcon.vbb#define VBE hw.falcon.vbe#define VDB hw.falcon.vdb#define VDE hw.falcon.vde#define VSS hw.falcon.vss#define VCO_CLOCK25 0x04#define VCO_CSYPOS 0x10#define VCO_VSYPOS 0x20#define VCO_HSYPOS 0x40#define VCO_SHORTOFFS 0x100#define VMO_DOUBLE 0x01#define VMO_INTER 0x02#define VMO_PREMASK 0x0c#endifstatic struct fb_info fb_info;static void *screen_base; /* base address of screen */static void *real_screen_base; /* (only for Overscan) */static int screen_len;static int current_par_valid=0; static int currcon=0;static int mono_moni=0;static struct display disp;#ifdef ATAFB_EXT/* external video handling */static unsigned external_xres;static unsigned external_xres_virtual;static unsigned external_yres;/* not needed - atafb will never support panning/hardwarescroll with external * static unsigned external_yres_virtual; */static unsigned external_depth;static int external_pmode;static void *external_addr = 0;static unsigned long external_len;static unsigned long external_vgaiobase = 0;static unsigned int external_bitspercol = 6;/* JOE <joe@amber.dinoco.de>: added card type for external driver, is only needed forcolormap handling.*/enum cardtype { IS_VGA, IS_MV300 };static enum cardtype external_card_type = IS_VGA;/*The MV300 mixes the color registers. So we need an array of mungedindices in order to access the correct reg.*/static int MV300_reg_1bit[2]={0,1};static int MV300_reg_4bit[16]={0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 };static int MV300_reg_8bit[256]={0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 }; static int *MV300_reg = MV300_reg_8bit;/*And on the MV300 it's difficult to read out the hardware palette. So wejust keep track of the set colors in our own array here, and use that!*/static struct { unsigned char red,green,blue,pad; } ext_color[256];#endif /* ATAFB_EXT */static int inverse=0;extern int fontheight_8x8;extern int fontwidth_8x8;extern unsigned char fontdata_8x8[];extern int fontheight_8x16;extern int fontwidth_8x16;extern unsigned char fontdata_8x16[];/* ++roman: This structure abstracts from the underlying hardware (ST(e), * TT, or Falcon. * * int (*detect)( void ) * This function should detect the current video mode settings and * store them in atafb_predefined[0] for later reference by the * user. Return the index+1 of an equivalent predefined mode or 0 * if there is no such. * * int (*encode_fix)( struct fb_fix_screeninfo *fix, * struct atafb_par *par ) * This function should fill in the 'fix' structure based on the * values in the 'par' structure. * * int (*decode_var)( struct fb_var_screeninfo *var, * struct atafb_par *par ) * Get the video params out of 'var'. If a value doesn't fit, round * it up, if it's too big, return EINVAL. * Round up in the following order: bits_per_pixel, xres, yres, * xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, * horizontal timing, vertical timing. * * int (*encode_var)( struct fb_var_screeninfo *var, * struct atafb_par *par ); * Fill the 'var' structure based on the values in 'par' and maybe * other values read out of the hardware. * * void (*get_par)( struct atafb_par *par ) * Fill the hardware's 'par' structure. * * void (*set_par)( struct atafb_par *par ) * Set the hardware according to 'par'. * * int (*setcolreg)( unsigned regno, unsigned red, * unsigned green, unsigned blue, * unsigned transp, struct fb_info *info ) * Set a single color register. The values supplied are already * rounded down to the hardware's capabilities (according to the * entries in the var structure). Return != 0 for invalid regno. * * int (*getcolreg)( unsigned regno, unsigned *red, * unsigned *green, unsigned *blue, * unsigned *transp, struct fb_info *info ) * Read a single color register and split it into * colors/transparent. Return != 0 for invalid regno. * * void (*set_screen_base)(void *s_base) * Set the base address of the displayed frame buffer. Only called * if yres_virtual > yres or xres_virtual > xres. * * int (*blank)( int blank_mode ) * Blank the screen if blank_mode!=0, else unblank. If blank==NULL then * the caller blanks by setting the CLUT to all black. Return 0 if blanking * succeeded, !=0 if un-/blanking failed due to e.g. a video mode which * doesn't support it. Implements VESA suspend and powerdown modes on * hardware that supports disabling hsync/vsync: * blank_mode==2: suspend vsync, 3:suspend hsync, 4: powerdown. */static struct fb_hwswitch { int (*detect)( void ); int (*encode_fix)( struct fb_fix_screeninfo *fix, struct atafb_par *par ); int (*decode_var)( struct fb_var_screeninfo *var, struct atafb_par *par ); int (*encode_var)( struct fb_var_screeninfo *var, struct atafb_par *par ); void (*get_par)( struct atafb_par *par ); void (*set_par)( struct atafb_par *par ); int (*getcolreg)( unsigned regno, unsigned *red, unsigned *green, unsigned *blue, unsigned *transp, struct fb_info *info ); int (*setcolreg)( unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info ); void (*set_screen_base)(void *s_base); int (*blank)( int blank_mode ); int (*pan_display)( struct fb_var_screeninfo *var, struct atafb_par *par);} *fbhw;static char *autodetect_names[] = {"autodetect", NULL};static char *stlow_names[] = {"stlow", NULL};static char *stmid_names[] = {"stmid", "default5", NULL};static char *sthigh_names[] = {"sthigh", "default4", NULL};static char *ttlow_names[] = {"ttlow", NULL};static char *ttmid_names[]= {"ttmid", "default1", NULL};static char *tthigh_names[]= {"tthigh", "default2", NULL};static char *vga2_names[] = {"vga2", NULL};static char *vga4_names[] = {"vga4", NULL};static char *vga16_names[] = {"vga16", "default3", NULL};static char *vga256_names[] = {"vga256", NULL};static char *falh2_names[] = {"falh2", NULL};static char *falh16_names[] = {"falh16", NULL};static char **fb_var_names[] = { /* Writing the name arrays directly in this array (via "(char *[]){...}") * crashes gcc 2.5.8 (sigsegv) if the inner array * contains more than two items. I've also seen that all elements * were identical to the last (my cross-gcc) :-(*/ autodetect_names, stlow_names, stmid_names, sthigh_names, ttlow_names, ttmid_names, tthigh_names, vga2_names, vga4_names, vga16_names, vga256_names, falh2_names, falh16_names, NULL /* ,NULL */ /* this causes a sigsegv on my gcc-2.5.8 */};static struct fb_var_screeninfo atafb_predefined[] = { /* * yres_virtual==0 means use hw-scrolling if possible, else yres */ { /* autodetect */ 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, /* red green blue tran*/ 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* st low */ 320, 200, 320, 0, 0, 0, 4, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* st mid */ 640, 200, 640, 0, 0, 0, 2, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* st high */ 640, 400, 640, 0, 0, 0, 1, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* tt low */ 320, 480, 320, 0, 0, 0, 8, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* tt mid */ 640, 480, 640, 0, 0, 0, 4, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* tt high */ 1280, 960, 1280, 0, 0, 0, 1, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* vga2 */ 640, 480, 640, 0, 0, 0, 1, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* vga4 */ 640, 480, 640, 0, 0, 0, 2, 0, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* vga16 */ 640, 480, 640, 0, 0, 0, 4, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* vga256 */ 640, 480, 640, 0, 0, 0, 8, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* falh2 */ 896, 608, 896, 0, 0, 0, 1, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, { /* falh16 */ 896, 608, 896, 0, 0, 0, 4, 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },};static int num_atafb_predefined=ARRAY_SIZE(atafb_predefined);static intget_video_mode(char *vname){ char ***name_list; char **name; int i; name_list=fb_var_names; for (i = 0 ; i < num_atafb_predefined ; i++) { name=*(name_list++); if (! name || ! *name) break; while (*name) { if (! strcmp(vname, *name)) return i+1; name++; } } return 0;}/* ------------------- TT specific functions ---------------------- */#ifdef ATAFB_TTstatic int tt_encode_fix( struct fb_fix_screeninfo *fix, struct atafb_par *par ){ int mode; strcpy(fix->id,"Atari Builtin"); fix->smem_start = (unsigned long)real_screen_base; fix->smem_len = screen_len; fix->type=FB_TYPE_INTERLEAVED_PLANES; fix->type_aux=2; fix->visual=FB_VISUAL_PSEUDOCOLOR; mode = par->hw.tt.mode & TT_SHIFTER_MODEMASK; if (mode == TT_SHIFTER_TTHIGH || mode == TT_SHIFTER_STHIGH) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -