diff options
author | Michael Schmitz <schmitz@opal.biophys.uni-duesseldorf.de> | 2007-05-01 22:32:39 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-04 17:59:05 -0700 |
commit | a100501212f2e26bb6d70bfb5c55eefd90e22b65 (patch) | |
tree | 64373f2a78d8920e11fe2a66152f280332b51363 /drivers/video/atafb.c | |
parent | c04cb856e20a8bf68762d60737b84328c1ab5900 (diff) |
m68k: Atari fb revival
Update the atari fb to 2.6 by Michael Schmitz,
Reformatting and rewrite of bit plane functions by Roman Zippel,
A few more fixes by Geert Uytterhoeven.
Signed-off-by: Michael Schmitz <schmitz@debian.org>
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/atafb.c')
-rw-r--r-- | drivers/video/atafb.c | 2801 |
1 files changed, 1487 insertions, 1314 deletions
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c index bffe2b94634..0038a0541c7 100644 --- a/drivers/video/atafb.c +++ b/drivers/video/atafb.c @@ -2,7 +2,7 @@ * 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. @@ -70,14 +70,8 @@ #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> - +#include "c2p.h" +#include "atafb.h" #define SWITCH_ACIA 0x01 /* modes for switch on OverScan */ #define SWITCH_SND6 0x40 @@ -87,22 +81,48 @@ #define up(x, r) (((x) + (r) - 1) & ~((r)-1)) + /* + * Interface to the world + */ + +static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); +static int atafb_set_par(struct fb_info *info); +static int atafb_setcolreg(unsigned int regno, unsigned int red, unsigned int green, + unsigned int blue, unsigned int transp, + struct fb_info *info); +static int atafb_blank(int blank, struct fb_info *info); +static int atafb_pan_display(struct fb_var_screeninfo *var, + struct fb_info *info); +static void atafb_fillrect(struct fb_info *info, + const struct fb_fillrect *rect); +static void atafb_copyarea(struct fb_info *info, + const struct fb_copyarea *region); +static void atafb_imageblit(struct fb_info *info, const struct fb_image *image); +static int atafb_ioctl(struct fb_info *info, unsigned int cmd, + unsigned long arg); + -static int default_par=0; /* default resolution (0=none) */ +static int default_par; /* default resolution (0=none) */ -static unsigned long default_mem_req=0; +static unsigned long default_mem_req; -static int hwscroll=-1; +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 int sttt_xres = 640, st_yres = 400, tt_yres = 480; +static int sttt_xres_virtual = 640, sttt_yres_virtual = 400; +static int ovsc_offset, ovsc_addlen; + + /* + * Hardware parameters for current mode + */ static struct atafb_par { void *screen_base; int yres_virtual; + u_long next_line; + u_long next_plane; #if defined ATAFB_TT || defined ATAFB_STE union { struct { @@ -138,7 +158,7 @@ static struct atafb_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; +static int DontCalcRes = 0; #ifdef ATAFB_FALCON #define HHT hw.falcon.hht @@ -163,83 +183,84 @@ static int DontCalcRes = 0; #define VMO_PREMASK 0x0c #endif -static struct fb_info fb_info; +static struct fb_info fb_info = { + .fix = { + .id = "Atari ", + .visual = FB_VISUAL_PSEUDOCOLOR, + .accel = FB_ACCEL_NONE, + } +}; 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 current_par_valid; -static int mono_moni=0; - -static struct display disp; +static int mono_moni; #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; -*/ +/* external video handling */ +static unsigned int external_xres; +static unsigned int external_xres_virtual; +static unsigned int external_yres; -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 for -colormap handling. -*/ +/* + * not needed - atafb will never support panning/hardwarescroll with external + * static unsigned int external_yres_virtual; + */ +static unsigned int external_depth; +static int external_pmode; +static void *external_addr; +static unsigned long external_len; +static unsigned long external_vgaiobase; +static unsigned int external_bitspercol = 6; +/* + * JOE <joe@amber.dinoco.de>: + * added card type for external driver, is only needed for + * colormap 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 munged -indices 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 }; + * The MV300 mixes the color registers. So we need an array of munged + * indices 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 we -just 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; +static int inverse; extern int fontheight_8x8; extern int fontwidth_8x8; @@ -249,96 +270,154 @@ extern int fontheight_8x16; extern int fontwidth_8x16; extern unsigned char fontdata_8x16[]; +/* + * struct fb_ops { + * * open/release and usage marking + * struct module *owner; + * int (*fb_open)(struct fb_info *info, int user); + * int (*fb_release)(struct fb_info *info, int user); + * + * * For framebuffers with strange non linear layouts or that do not + * * work with normal memory mapped access + * ssize_t (*fb_read)(struct file *file, char __user *buf, size_t count, loff_t *ppos); + * ssize_t (*fb_write)(struct file *file, const char __user *buf, size_t count, loff_t *ppos); + * + * * checks var and eventually tweaks it to something supported, + * * DOES NOT MODIFY PAR * + * int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info); + * + * * set the video mode according to info->var * + * int (*fb_set_par)(struct fb_info *info); + * + * * set color register * + * int (*fb_setcolreg)(unsigned int regno, unsigned int red, unsigned int green, + * unsigned int blue, unsigned int transp, struct fb_info *info); + * + * * set color registers in batch * + * int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info); + * + * * blank display * + * int (*fb_blank)(int blank, struct fb_info *info); + * + * * pan display * + * int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info); + * + * *** The meat of the drawing engine *** + * * Draws a rectangle * + * void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect); + * * Copy data from area to another * + * void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region); + * * Draws a image to the display * + * void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image); + * + * * Draws cursor * + * int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor); + * + * * Rotates the display * + * void (*fb_rotate)(struct fb_info *info, int angle); + * + * * wait for blit idle, optional * + * int (*fb_sync)(struct fb_info *info); + * + * * perform fb specific ioctl (optional) * + * int (*fb_ioctl)(struct fb_info *info, unsigned int cmd, + * unsigned long arg); + * + * * Handle 32bit compat ioctl (optional) * + * int (*fb_compat_ioctl)(struct fb_info *info, unsigned int cmd, + * unsigned long arg); + * + * * perform fb specific mmap * + * int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma); + * + * * save current hardware state * + * void (*fb_save_state)(struct fb_info *info); + * + * * restore saved state * + * void (*fb_restore_state)(struct fb_info *info); + * } ; + */ + + /* ++roman: This structure abstracts from the underlying hardware (ST(e), * TT, or Falcon. * - * int (*detect)( void ) + * 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 ) + * + * 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 ) + * !!! Obsolete, perhaps !!! + * + * 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, + * 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 ); + * 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 ) + * + * void (*get_par)(struct atafb_par *par) * Fill the hardware's 'par' structure. - * - * void (*set_par)( struct atafb_par *par ) + * !!! Used only by detect() !!! + * + * void (*set_par)(struct atafb_par *par) * Set the hardware according to 'par'. - * - * 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 + * 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. + * 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 (*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); void (*set_screen_base)(void *s_base); - int (*blank)( int blank_mode ); - int (*pan_display)( struct fb_var_screeninfo *var, - struct atafb_par *par); + int (*blank)(int blank_mode); + int (*pan_display)(struct fb_var_screeninfo *var, + struct fb_info *info); } *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 *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, @@ -353,18 +432,17 @@ static char **fb_var_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*/ + /* + * 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 */ + { /* 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 }, @@ -414,27 +492,100 @@ static struct fb_var_screeninfo atafb_predefined[] = { 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, }; -static int num_atafb_predefined=ARRAY_SIZE(atafb_predefined); +static int num_atafb_predefined = ARRAY_SIZE(atafb_predefined); +static struct fb_videomode atafb_modedb[] __initdata = { + /* + * Atari Video Modes + * + * If you change these, make sure to update DEFMODE_* as well! + */ -static int -get_video_mode(char *vname) + /* + * ST/TT Video Modes + */ + + { + /* 320x200, 15 kHz, 60 Hz (ST low) */ + "st-low", 60, 320, 200, 32000, 32, 16, 31, 14, 96, 4, + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, { + /* 640x200, 15 kHz, 60 Hz (ST medium) */ + "st-mid", 60, 640, 200, 32000, 32, 16, 31, 14, 96, 4, + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, { + /* 640x400, 30.25 kHz, 63.5 Hz (ST high) */ + "st-high", 63, 640, 400, 32000, 128, 0, 40, 14, 128, 4, + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, { + /* 320x480, 15 kHz, 60 Hz (TT low) */ + "tt-low", 60, 320, 480, 31041, 120, 100, 8, 16, 140, 30, + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, { + /* 640x480, 29 kHz, 57 Hz (TT medium) */ + "tt-mid", 60, 640, 480, 31041, 120, 100, 8, 16, 140, 30, + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, { + /* 1280x960, 29 kHz, 60 Hz (TT high) */ + "tt-high", 57, 640, 960, 31041, 120, 100, 8, 16, 140, 30, + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, + + /* + * VGA Video Modes + */ + + { + /* 640x480, 31 kHz, 60 Hz (VGA) */ + "vga", 63.5, 640, 480, 32000, 18, 42, 31, 11, 96, 3, + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, { + /* 640x400, 31 kHz, 70 Hz (VGA) */ + "vga70", 70, 640, 400, 32000, 18, 42, 31, 11, 96, 3, + FB_SYNC_VERT_HIGH_ACT | FB_SYNC_COMP_HIGH_ACT, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, + + /* + * Falcon HiRes Video Modes + */ + + { + /* 896x608, 31 kHz, 60 Hz (Falcon High) */ + "falh", 60, 896, 608, 32000, 18, 42, 31, 1, 96,3, + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP + }, +}; + +#define NUM_TOTAL_MODES ARRAY_SIZE(atafb_modedb) + +static char *mode_option __initdata = NULL; + + /* default modes */ + +#define DEFMODE_TT 5 /* "tt-high" for TT */ +#define DEFMODE_F30 7 /* "vga70" for Falcon */ +#define DEFMODE_STE 2 /* "st-high" for ST/E */ +#define DEFMODE_EXT 6 /* "vga" for external */ + + +static int get_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++; + 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; + return 0; } @@ -443,93 +594,84 @@ get_video_mode(char *vname) #ifdef ATAFB_TT -static int tt_encode_fix( struct fb_fix_screeninfo *fix, - struct atafb_par *par ) - +static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) { int mode; - strcpy(fix->id,"Atari Builtin"); + 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; + 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) { - fix->type=FB_TYPE_PACKED_PIXELS; - fix->type_aux=0; + fix->type = FB_TYPE_PACKED_PIXELS; + fix->type_aux = 0; if (mode == TT_SHIFTER_TTHIGH) - fix->visual=FB_VISUAL_MONO01; + fix->visual = FB_VISUAL_MONO01; } - fix->xpanstep=0; - fix->ypanstep=1; - fix->ywrapstep=0; + fix->xpanstep = 0; + fix->ypanstep = 1; + fix->ywrapstep = 0; fix->line_length = 0; fix->accel = FB_ACCEL_ATARIBLITT; return 0; } - -static int tt_decode_var( struct fb_var_screeninfo *var, - struct atafb_par *par ) +static int tt_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { - int xres=var->xres; - int yres=var->yres; - int bpp=var->bits_per_pixel; + int xres = var->xres; + int yres = var->yres; + int bpp = var->bits_per_pixel; int linelen; int yres_virtual = var->yres_virtual; if (mono_moni) { - if (bpp > 1 || xres > sttt_xres*2 || yres >tt_yres*2) + if (bpp > 1 || xres > sttt_xres * 2 || yres > tt_yres * 2) return -EINVAL; - par->hw.tt.mode=TT_SHIFTER_TTHIGH; - xres=sttt_xres*2; - yres=tt_yres*2; - bpp=1; + par->hw.tt.mode = TT_SHIFTER_TTHIGH; + xres = sttt_xres * 2; + yres = tt_yres * 2; + bpp = 1; } else { if (bpp > 8 || xres > sttt_xres || yres > tt_yres) return -EINVAL; if (bpp > 4) { - if (xres > sttt_xres/2 || yres > tt_yres) + if (xres > sttt_xres / 2 || yres > tt_yres) return -EINVAL; - par->hw.tt.mode=TT_SHIFTER_TTLOW; - xres=sttt_xres/2; - yres=tt_yres; - bpp=8; - } - else if (bpp > 2) { + par->hw.tt.mode = TT_SHIFTER_TTLOW; + xres = sttt_xres / 2; + yres = tt_yres; + bpp = 8; + } else if (bpp > 2) { if (xres > sttt_xres || yres > tt_yres) return -EINVAL; - if (xres > sttt_xres/2 || yres > st_yres/2) { - par->hw.tt.mode=TT_SHIFTER_TTMID; - xres=sttt_xres; - yres=tt_yres; - bpp=4; - } - else { - par->hw.tt.mode=TT_SHIFTER_STLOW; - xres=sttt_xres/2; - yres=st_yres/2; - bpp=4; + if (xres > sttt_xres / 2 || yres > st_yres / 2) { + par->hw.tt.mode = TT_SHIFTER_TTMID; + xres = sttt_xres; + yres = tt_yres; + bpp = 4; + } else { + par->hw.tt.mode = TT_SHIFTER_STLOW; + xres = sttt_xres / 2; + yres = st_yres / 2; + bpp = 4; } - } - else if (bpp > 1) { - if (xres > sttt_xres || yres > st_yres/2) + } else if (bpp > 1) { + if (xres > sttt_xres || yres > st_yres / 2) return -EINVAL; - par->hw.tt.mode=TT_SHIFTER_STMID; - xres=sttt_xres; - yres=st_yres/2; - bpp=2; - } - else if (var->xres > sttt_xres || var->yres > st_yres) { + par->hw.tt.mode = TT_SHIFTER_STMID; + xres = sttt_xres; + yres = st_yres / 2; + bpp = 2; + } else if (var->xres > sttt_xres || var->yres > st_yres) { return -EINVAL; - } - else { - par->hw.tt.mode=TT_SHIFTER_STHIGH; - xres=sttt_xres; - yres=st_yres; - bpp=1; + } else { + par->hw.tt.mode = TT_SHIFTER_STHIGH; + xres = sttt_xres; + yres = st_yres; + bpp = 1; } } if (yres_virtual <= 0) @@ -537,10 +679,10 @@ static int tt_decode_var( struct fb_var_screeninfo *var, else if (yres_virtual < yres) yres_virtual = yres; if (var->sync & FB_SYNC_EXT) - par->hw.tt.sync=0; + par->hw.tt.sync = 0; else - par->hw.tt.sync=1; - linelen=xres*bpp/8; + par->hw.tt.sync = 1; + linelen = xres * bpp / 8; if (yres_virtual * linelen > screen_len && screen_len) return -EINVAL; if (yres * linelen > screen_len && screen_len) @@ -552,154 +694,123 @@ static int tt_decode_var( struct fb_var_screeninfo *var, return 0; } -static int tt_encode_var( struct fb_var_screeninfo *var, - struct atafb_par *par ) +static int tt_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) { int linelen; memset(var, 0, sizeof(struct fb_var_screeninfo)); - var->red.offset=0; - var->red.length=4; - var->red.msb_right=0; - var->grayscale=0; - - var->pixclock=31041; - var->left_margin=120; /* these may be incorrect */ - var->right_margin=100; - var->upper_margin=8; - var->lower_margin=16; - var->hsync_len=140; - var->vsync_len=30; - - var->height=-1; - var->width=-1; + var->red.offset = 0; + var->red.length = 4; + var->red.msb_right = 0; + var->grayscale = 0; + + var->pixclock = 31041; + var->left_margin = 120; /* these may be incorrect */ + var->right_margin = 100; + var->upper_margin = 8; + var->lower_margin = 16; + var->hsync_len = 140; + var->vsync_len = 30; + + var->height = -1; + var->width = -1; if (par->hw.tt.sync & 1) - var->sync=0; + var->sync = 0; else - var->sync=FB_SYNC_EXT; + var->sync = FB_SYNC_EXT; switch (par->hw.tt.mode & TT_SHIFTER_MODEMASK) { case TT_SHIFTER_STLOW: - var->xres=sttt_xres/2; - var->xres_virtual=sttt_xres_virtual/2; - var->yres=st_yres/2; - var->bits_per_pixel=4; + var->xres = sttt_xres / 2; + var->xres_virtual = sttt_xres_virtual / 2; + var->yres = st_yres / 2; + var->bits_per_pixel = 4; break; case TT_SHIFTER_STMID: - var->xres=sttt_xres; - var->xres_virtual=sttt_xres_virtual; - var->yres=st_yres/2; - var->bits_per_pixel=2; + var->xres = sttt_xres; + var->xres_virtual = sttt_xres_virtual; + var->yres = st_yres / 2; + var->bits_per_pixel = 2; break; case TT_SHIFTER_STHIGH: - var->xres=sttt_xres; - var->xres_virtual=sttt_xres_virtual; - var->yres=st_yres; - var->bits_per_pixel=1; + var->xres = sttt_xres; + var->xres_virtual = sttt_xres_virtual; + var->yres = st_yres; + var->bits_per_pixel = 1; break; case TT_SHIFTER_TTLOW: - var->xres=sttt_xres/2; - var->xres_virtual=sttt_xres_virtual/2; - var->yres=tt_yres; - var->bits_per_pixel=8; + var->xres = sttt_xres / 2; + var->xres_virtual = sttt_xres_virtual / 2; + var->yres = tt_yres; + var->bits_per_pixel = 8; break; case TT_SHIFTER_TTMID: - var->xres=sttt_xres; - var->xres_virtual=sttt_xres_virtual; - var->yres=tt_yres; - var->bits_per_pixel=4; + var->xres = sttt_xres; + var->xres_virtual = sttt_xres_virtual; + var->yres = tt_yres; + var->bits_per_pixel = 4; break; case TT_SHIFTER_TTHIGH: - var->red.length=0; - var->xres=sttt_xres*2; - var->xres_virtual=sttt_xres_virtual*2; - var->yres=tt_yres*2; - var->bits_per_pixel=1; + var->red.length = 0; + var->xres = sttt_xres * 2; + var->xres_virtual = sttt_xres_virtual * 2; + var->yres = tt_yres * 2; + var->bits_per_pixel = 1; break; - } - var->blue=var->green=var->red; - var->transp.offset=0; - var->transp.length=0; - var->transp.msb_right=0; - linelen=var->xres_virtual * var->bits_per_pixel / 8; - if (! use_hwscroll) - var->yres_virtual=var->yres; + } + var->blue = var->green = var->red; + var->transp.offset = 0; + var->transp.length = 0; + var->transp.msb_right = 0; + linelen = var->xres_virtual * var->bits_per_pixel / 8; + if (!use_hwscroll) + var->yres_virtual = var->yres; else if (screen_len) { if (par->yres_virtual) var->yres_virtual = par->yres_virtual; else - /* yres_virtual==0 means use maximum */ + /* yres_virtual == 0 means use maximum */ var->yres_virtual = screen_len / linelen; } else { if (hwscroll < 0) var->yres_virtual = 2 * var->yres; else - var->yres_virtual=var->yres+hwscroll * 16; + var->yres_virtual = var->yres + hwscroll * 16; } - var->xoffset=0; + var->xoffset = 0; if (screen_base) - var->yoffset=(par->screen_base - screen_base)/linelen; + var->yoffset = (par->screen_base - screen_base) / linelen; else - var->yoffset=0; - var->nonstd=0; - var->activate=0; - var->vmode=FB_VMODE_NONINTERLACED; + var->yoffset = 0; + var->nonstd = 0; + var->activate = 0; + var->vmode = FB_VMODE_NONINTERLACED; return 0; } - -static void tt_get_par( struct atafb_par *par ) +static void tt_get_par(struct atafb_par *par) { unsigned long addr; - par->hw.tt.mode=shifter_tt.tt_shiftmode; - par->hw.tt.sync=shifter.syncmode; + par->hw.tt.mode = shifter_tt.tt_shiftmode; + par->hw.tt.sync = shifter.syncmode; addr = ((shifter.bas_hi & 0xff) << 16) | ((shifter.bas_md & 0xff) << 8) | ((shifter.bas_lo & 0xff)); par->screen_base = phys_to_virt(addr); } -static void tt_set_par( struct atafb_par *par ) +static void tt_set_par(struct atafb_par *par) { - shifter_tt.tt_shiftmode=par->hw.tt.mode; - shifter.syncmode=par->hw.tt.sync; + shifter_tt.tt_shiftmode = par->hw.tt.mode; + shifter.syncmode = par->hw.tt.sync; /* only set screen_base if really necessary */ if (current_par.screen_base != par->screen_base) fbhw->set_screen_base(par->screen_base); } - -static int tt_getcolreg(unsigned regno, unsigned *red, - unsigned *green, unsigned *blue, - unsigned *transp, struct fb_info *info) -{ - int t, col; - - if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) - regno += 254; - if (regno > 255) - return 1; - t = tt_palette[regno]; - col = t & 15; - col |= col << 4; - col |= col << 8; - *blue = col; - col = (t >> 4) & 15; - col |= col << 4; - col |= col << 8; - *green = col; - col = (t >> 8) & 15; - col |= col << 4; - col |= col << 8; - *red = col; - *transp = 0; - return 0; -} - - -static int tt_setcolreg(unsigned regno, unsigned red, - unsigned green, unsigned blue, - unsigned transp, struct fb_info *info) +static int tt_setcolreg(unsigned int regno, unsigned int red, + unsigned int green, unsigned int blue, + unsigned int transp, struct fb_info *info) { if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) regno += 254; @@ -708,15 +819,14 @@ static int tt_setcolreg(unsigned regno, unsigned red, tt_palette[regno] = (((red >> 12) << 8) | ((green >> 12) << 4) | (blue >> 12)); if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == - TT_SHIFTER_STHIGH && regno == 254) + TT_SHIFTER_STHIGH && regno == 254) tt_palette[0] = 0; return 0; } - -static int tt_detect( void ) - -{ struct atafb_par par; +static int tt_detect(void) +{ + struct atafb_par par; /* Determine the connected monitor: The DMA sound must be * disabled before reading the MFP GPIP, because the Sound @@ -726,9 +836,9 @@ static int tt_detect( void ) * announced that the Eagle is TT compatible, but only the PCM is * missing... */ - if (ATARIHW_PRESENT(PCM_8BIT)) { + if (ATARIHW_PRESENT(PCM_8BIT)) { tt_dmasnd.ctrl = DMASND_CTRL_OFF; - udelay(20); /* wait a while for things to settle down */ + udelay(20); /* wait a while for things to settle down */ } mono_moni = (mfp.par_dt_reg & 0x80) == 0; @@ -755,19 +865,24 @@ static struct pixel_clock { unsigned long f; /* f/[Hz] */ unsigned long t; /* t/[ps] (=1/f) */ int right, hsync, left; /* standard timing in clock cycles, not pixel */ - /* hsync initialized in falcon_detect() */ + /* hsync initialized in falcon_detect() */ int sync_mask; /* or-mask for hw.falcon.sync to set this clock */ int control_mask; /* ditto, for hw.falcon.vid_control */ -} -f25 = {25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25}, -f32 = {32000000, 31250, 18, 0, 42, 0x0, 0}, -fext = { 0, 0, 18, 0, 42, 0x1, 0}; +} f25 = { + 25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25 +}, f32 = { + 32000000, 31250, 18, 0, 42, 0x0, 0 +}, fext = { + 0, 0, 18, 0, 42, 0x1, 0 +}; /* VIDEL-prescale values [mon_type][pixel_length from VCO] */ -static int vdl_prescale[4][3] = {{4,2,1}, {4,2,1}, {4,2,2}, {4,2,1}}; +static int vdl_prescale[4][3] = { + { 4,2,1 }, { 4,2,1 }, { 4,2,2 }, { 4,2,1 } +}; /* Default hsync timing [mon_type] in picoseconds */ -static long h_syncs[4] = {3000000, 4875000, 4000000, 4875000}; +static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 }; #ifdef FBCON_HAS_CFB16 static u16 fbcon_cfb16_cmap[16]; @@ -775,12 +890,12 @@ static u16 fbcon_cfb16_cmap[16]; static inline int hxx_prescale(struct falcon_hw *hw) { - return hw->ste_mode ? 16 : - vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; + return hw->ste_mode ? 16 + : vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; } -static int falcon_encode_fix( struct fb_fix_screeninfo *fix, - struct atafb_par *par ) +static int falcon_encode_fix(struct fb_fix_screeninfo *fix, + struct atafb_par *par) { strcpy(fix->id, "Atari Builtin"); fix->smem_start = (unsigned long)real_screen_base; @@ -796,8 +911,7 @@ static int falcon_encode_fix( struct fb_fix_screeninfo *fix, fix->type_aux = 0; /* no smooth scrolling with longword aligned video mem */ fix->xpanstep = 32; - } - else if (par->hw.falcon.f_shift & 0x100) { + } else if (par->hw.falcon.f_shift & 0x100) { fix->type = FB_TYPE_PACKED_PIXELS; fix->type_aux = 0; /* |