Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Michael Schmitz and committed by
Linus Torvalds
a1005012 c04cb856

+2987 -1316
+4 -1
drivers/video/Kconfig
··· 389 389 390 390 config FB_ATARI 391 391 bool "Atari native chipset support" 392 - depends on (FB = y) && ATARI && BROKEN 392 + depends on (FB = y) && ATARI 393 + select FB_CFB_FILLRECT 394 + select FB_CFB_COPYAREA 395 + select FB_CFB_IMAGEBLIT 393 396 help 394 397 This is the frame buffer device driver for the builtin graphics 395 398 chipset found in Ataris.
+2 -1
drivers/video/Makefile
··· 63 63 obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o 64 64 obj-$(CONFIG_FB_SGIVW) += sgivwfb.o 65 65 obj-$(CONFIG_FB_ACORN) += acornfb.o 66 - obj-$(CONFIG_FB_ATARI) += atafb.o 66 + obj-$(CONFIG_FB_ATARI) += atafb.o c2p.o atafb_mfb.o \ 67 + atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o 67 68 obj-$(CONFIG_FB_MAC) += macfb.o 68 69 obj-$(CONFIG_FB_HGA) += hgafb.o 69 70 obj-$(CONFIG_FB_IGA) += igafb.o
+1487 -1314
drivers/video/atafb.c
··· 2 2 * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device 3 3 * 4 4 * Copyright (C) 1994 Martin Schaller & Roman Hodek 5 - * 5 + * 6 6 * This file is subject to the terms and conditions of the GNU General Public 7 7 * License. See the file COPYING in the main directory of this archive 8 8 * for more details. ··· 70 70 #include <linux/fb.h> 71 71 #include <asm/atarikb.h> 72 72 73 - #include <video/fbcon.h> 74 - #include <video/fbcon-cfb8.h> 75 - #include <video/fbcon-cfb16.h> 76 - #include <video/fbcon-iplan2p2.h> 77 - #include <video/fbcon-iplan2p4.h> 78 - #include <video/fbcon-iplan2p8.h> 79 - #include <video/fbcon-mfb.h> 80 - 73 + #include "c2p.h" 74 + #include "atafb.h" 81 75 82 76 #define SWITCH_ACIA 0x01 /* modes for switch on OverScan */ 83 77 #define SWITCH_SND6 0x40 ··· 81 87 82 88 #define up(x, r) (((x) + (r) - 1) & ~((r)-1)) 83 89 90 + /* 91 + * Interface to the world 92 + */ 84 93 85 - static int default_par=0; /* default resolution (0=none) */ 94 + static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); 95 + static int atafb_set_par(struct fb_info *info); 96 + static int atafb_setcolreg(unsigned int regno, unsigned int red, unsigned int green, 97 + unsigned int blue, unsigned int transp, 98 + struct fb_info *info); 99 + static int atafb_blank(int blank, struct fb_info *info); 100 + static int atafb_pan_display(struct fb_var_screeninfo *var, 101 + struct fb_info *info); 102 + static void atafb_fillrect(struct fb_info *info, 103 + const struct fb_fillrect *rect); 104 + static void atafb_copyarea(struct fb_info *info, 105 + const struct fb_copyarea *region); 106 + static void atafb_imageblit(struct fb_info *info, const struct fb_image *image); 107 + static int atafb_ioctl(struct fb_info *info, unsigned int cmd, 108 + unsigned long arg); 86 109 87 - static unsigned long default_mem_req=0; 88 110 89 - static int hwscroll=-1; 111 + static int default_par; /* default resolution (0=none) */ 112 + 113 + static unsigned long default_mem_req; 114 + 115 + static int hwscroll = -1; 90 116 91 117 static int use_hwscroll = 1; 92 118 93 - static int sttt_xres=640,st_yres=400,tt_yres=480; 94 - static int sttt_xres_virtual=640,sttt_yres_virtual=400; 95 - static int ovsc_offset=0, ovsc_addlen=0; 119 + static int sttt_xres = 640, st_yres = 400, tt_yres = 480; 120 + static int sttt_xres_virtual = 640, sttt_yres_virtual = 400; 121 + static int ovsc_offset, ovsc_addlen; 122 + 123 + /* 124 + * Hardware parameters for current mode 125 + */ 96 126 97 127 static struct atafb_par { 98 128 void *screen_base; 99 129 int yres_virtual; 130 + u_long next_line; 131 + u_long next_plane; 100 132 #if defined ATAFB_TT || defined ATAFB_STE 101 133 union { 102 134 struct { ··· 158 138 /* Don't calculate an own resolution, and thus don't change the one found when 159 139 * booting (currently used for the Falcon to keep settings for internal video 160 140 * hardware extensions (e.g. ScreenBlaster) */ 161 - static int DontCalcRes = 0; 141 + static int DontCalcRes = 0; 162 142 163 143 #ifdef ATAFB_FALCON 164 144 #define HHT hw.falcon.hht ··· 183 163 #define VMO_PREMASK 0x0c 184 164 #endif 185 165 186 - static struct fb_info fb_info; 166 + static struct fb_info fb_info = { 167 + .fix = { 168 + .id = "Atari ", 169 + .visual = FB_VISUAL_PSEUDOCOLOR, 170 + .accel = FB_ACCEL_NONE, 171 + } 172 + }; 187 173 188 174 static void *screen_base; /* base address of screen */ 189 175 static void *real_screen_base; /* (only for Overscan) */ 190 176 191 177 static int screen_len; 192 178 193 - static int current_par_valid=0; 179 + static int current_par_valid; 194 180 195 - static int mono_moni=0; 196 - 197 - static struct display disp; 181 + static int mono_moni; 198 182 199 183 200 184 #ifdef ATAFB_EXT 185 + 201 186 /* external video handling */ 187 + static unsigned int external_xres; 188 + static unsigned int external_xres_virtual; 189 + static unsigned int external_yres; 202 190 203 - static unsigned external_xres; 204 - static unsigned external_xres_virtual; 205 - static unsigned external_yres; 206 - /* not needed - atafb will never support panning/hardwarescroll with external 207 - * static unsigned external_yres_virtual; 208 - */ 191 + /* 192 + * not needed - atafb will never support panning/hardwarescroll with external 193 + * static unsigned int external_yres_virtual; 194 + */ 195 + static unsigned int external_depth; 196 + static int external_pmode; 197 + static void *external_addr; 198 + static unsigned long external_len; 199 + static unsigned long external_vgaiobase; 200 + static unsigned int external_bitspercol = 6; 209 201 210 - static unsigned external_depth; 211 - static int external_pmode; 212 - static void *external_addr = 0; 213 - static unsigned long external_len; 214 - static unsigned long external_vgaiobase = 0; 215 - static unsigned int external_bitspercol = 6; 216 - 217 - /* 218 - JOE <joe@amber.dinoco.de>: 219 - added card type for external driver, is only needed for 220 - colormap handling. 221 - */ 222 - 202 + /* 203 + * JOE <joe@amber.dinoco.de>: 204 + * added card type for external driver, is only needed for 205 + * colormap handling. 206 + */ 223 207 enum cardtype { IS_VGA, IS_MV300 }; 224 208 static enum cardtype external_card_type = IS_VGA; 225 209 226 210 /* 227 - The MV300 mixes the color registers. So we need an array of munged 228 - indices in order to access the correct reg. 229 - */ 230 - static int MV300_reg_1bit[2]={0,1}; 231 - static int MV300_reg_4bit[16]={ 232 - 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; 233 - static int MV300_reg_8bit[256]={ 234 - 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 235 - 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 236 - 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 237 - 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 238 - 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 239 - 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 240 - 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 241 - 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 242 - 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 243 - 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 244 - 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 245 - 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 246 - 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 247 - 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 248 - 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 249 - 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 }; 211 + * The MV300 mixes the color registers. So we need an array of munged 212 + * indices in order to access the correct reg. 213 + */ 214 + static int MV300_reg_1bit[2] = { 215 + 0, 1 216 + }; 217 + static int MV300_reg_4bit[16] = { 218 + 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 219 + }; 220 + static int MV300_reg_8bit[256] = { 221 + 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 222 + 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 223 + 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 224 + 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 225 + 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 226 + 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 227 + 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 228 + 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 229 + 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 230 + 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 231 + 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 232 + 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 233 + 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 234 + 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 235 + 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 236 + 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 237 + }; 250 238 251 239 static int *MV300_reg = MV300_reg_8bit; 252 - 253 - /* 254 - And on the MV300 it's difficult to read out the hardware palette. So we 255 - just keep track of the set colors in our own array here, and use that! 256 - */ 257 - 258 - static struct { unsigned char red,green,blue,pad; } ext_color[256]; 259 240 #endif /* ATAFB_EXT */ 260 241 261 242 262 - static int inverse=0; 243 + static int inverse; 263 244 264 245 extern int fontheight_8x8; 265 246 extern int fontwidth_8x8; ··· 270 249 extern int fontwidth_8x16; 271 250 extern unsigned char fontdata_8x16[]; 272 251 252 + /* 253 + * struct fb_ops { 254 + * * open/release and usage marking 255 + * struct module *owner; 256 + * int (*fb_open)(struct fb_info *info, int user); 257 + * int (*fb_release)(struct fb_info *info, int user); 258 + * 259 + * * For framebuffers with strange non linear layouts or that do not 260 + * * work with normal memory mapped access 261 + * ssize_t (*fb_read)(struct file *file, char __user *buf, size_t count, loff_t *ppos); 262 + * ssize_t (*fb_write)(struct file *file, const char __user *buf, size_t count, loff_t *ppos); 263 + * 264 + * * checks var and eventually tweaks it to something supported, 265 + * * DOES NOT MODIFY PAR * 266 + * int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info); 267 + * 268 + * * set the video mode according to info->var * 269 + * int (*fb_set_par)(struct fb_info *info); 270 + * 271 + * * set color register * 272 + * int (*fb_setcolreg)(unsigned int regno, unsigned int red, unsigned int green, 273 + * unsigned int blue, unsigned int transp, struct fb_info *info); 274 + * 275 + * * set color registers in batch * 276 + * int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info); 277 + * 278 + * * blank display * 279 + * int (*fb_blank)(int blank, struct fb_info *info); 280 + * 281 + * * pan display * 282 + * int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info); 283 + * 284 + * *** The meat of the drawing engine *** 285 + * * Draws a rectangle * 286 + * void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect); 287 + * * Copy data from area to another * 288 + * void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region); 289 + * * Draws a image to the display * 290 + * void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image); 291 + * 292 + * * Draws cursor * 293 + * int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor); 294 + * 295 + * * Rotates the display * 296 + * void (*fb_rotate)(struct fb_info *info, int angle); 297 + * 298 + * * wait for blit idle, optional * 299 + * int (*fb_sync)(struct fb_info *info); 300 + * 301 + * * perform fb specific ioctl (optional) * 302 + * int (*fb_ioctl)(struct fb_info *info, unsigned int cmd, 303 + * unsigned long arg); 304 + * 305 + * * Handle 32bit compat ioctl (optional) * 306 + * int (*fb_compat_ioctl)(struct fb_info *info, unsigned int cmd, 307 + * unsigned long arg); 308 + * 309 + * * perform fb specific mmap * 310 + * int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma); 311 + * 312 + * * save current hardware state * 313 + * void (*fb_save_state)(struct fb_info *info); 314 + * 315 + * * restore saved state * 316 + * void (*fb_restore_state)(struct fb_info *info); 317 + * } ; 318 + */ 319 + 320 + 273 321 /* ++roman: This structure abstracts from the underlying hardware (ST(e), 274 322 * TT, or Falcon. 275 323 * 276 - * int (*detect)( void ) 324 + * int (*detect)(void) 277 325 * This function should detect the current video mode settings and 278 326 * store them in atafb_predefined[0] for later reference by the 279 327 * user. Return the index+1 of an equivalent predefined mode or 0 280 328 * if there is no such. 281 - * 282 - * int (*encode_fix)( struct fb_fix_screeninfo *fix, 283 - * struct atafb_par *par ) 329 + * 330 + * int (*encode_fix)(struct fb_fix_screeninfo *fix, 331 + * struct atafb_par *par) 284 332 * This function should fill in the 'fix' structure based on the 285 333 * values in the 'par' structure. 286 - * 287 - * int (*decode_var)( struct fb_var_screeninfo *var, 288 - * struct atafb_par *par ) 334 + * !!! Obsolete, perhaps !!! 335 + * 336 + * int (*decode_var)(struct fb_var_screeninfo *var, 337 + * struct atafb_par *par) 289 338 * Get the video params out of 'var'. If a value doesn't fit, round 290 339 * it up, if it's too big, return EINVAL. 291 - * Round up in the following order: bits_per_pixel, xres, yres, 292 - * xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, 340 + * Round up in the following order: bits_per_pixel, xres, yres, 341 + * xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, 293 342 * horizontal timing, vertical timing. 294 343 * 295 - * int (*encode_var)( struct fb_var_screeninfo *var, 296 - * struct atafb_par *par ); 344 + * int (*encode_var)(struct fb_var_screeninfo *var, 345 + * struct atafb_par *par); 297 346 * Fill the 'var' structure based on the values in 'par' and maybe 298 347 * other values read out of the hardware. 299 - * 300 - * void (*get_par)( struct atafb_par *par ) 348 + * 349 + * void (*get_par)(struct atafb_par *par) 301 350 * Fill the hardware's 'par' structure. 302 - * 303 - * void (*set_par)( struct atafb_par *par ) 351 + * !!! Used only by detect() !!! 352 + * 353 + * void (*set_par)(struct atafb_par *par) 304 354 * Set the hardware according to 'par'. 305 - * 306 - * int (*getcolreg)( unsigned regno, unsigned *red, 307 - * unsigned *green, unsigned *blue, 308 - * unsigned *transp, struct fb_info *info ) 309 - * Read a single color register and split it into 310 - * colors/transparent. Return != 0 for invalid regno. 311 355 * 312 356 * void (*set_screen_base)(void *s_base) 313 357 * Set the base address of the displayed frame buffer. Only called 314 358 * if yres_virtual > yres or xres_virtual > xres. 315 359 * 316 - * int (*blank)( int blank_mode ) 317 - * Blank the screen if blank_mode!=0, else unblank. If blank==NULL then 360 + * int (*blank)(int blank_mode) 361 + * Blank the screen if blank_mode != 0, else unblank. If blank == NULL then 318 362 * the caller blanks by setting the CLUT to all black. Return 0 if blanking 319 363 * succeeded, !=0 if un-/blanking failed due to e.g. a video mode which 320 364 * doesn't support it. Implements VESA suspend and powerdown modes on 321 365 * hardware that supports disabling hsync/vsync: 322 - * blank_mode==2: suspend vsync, 3:suspend hsync, 4: powerdown. 366 + * blank_mode == 2: suspend vsync, 3:suspend hsync, 4: powerdown. 323 367 */ 324 368 325 369 static struct fb_hwswitch { 326 - int (*detect)( void ); 327 - int (*encode_fix)( struct fb_fix_screeninfo *fix, 328 - struct atafb_par *par ); 329 - int (*decode_var)( struct fb_var_screeninfo *var, 330 - struct atafb_par *par ); 331 - int (*encode_var)( struct fb_var_screeninfo *var, 332 - struct atafb_par *par ); 333 - void (*get_par)( struct atafb_par *par ); 334 - void (*set_par)( struct atafb_par *par ); 335 - int (*getcolreg)( unsigned regno, unsigned *red, 336 - unsigned *green, unsigned *blue, 337 - unsigned *transp, struct fb_info *info ); 370 + int (*detect)(void); 371 + int (*encode_fix)(struct fb_fix_screeninfo *fix, 372 + struct atafb_par *par); 373 + int (*decode_var)(struct fb_var_screeninfo *var, 374 + struct atafb_par *par); 375 + int (*encode_var)(struct fb_var_screeninfo *var, 376 + struct atafb_par *par); 377 + void (*get_par)(struct atafb_par *par); 378 + void (*set_par)(struct atafb_par *par); 338 379 void (*set_screen_base)(void *s_base); 339 - int (*blank)( int blank_mode ); 340 - int (*pan_display)( struct fb_var_screeninfo *var, 341 - struct atafb_par *par); 380 + int (*blank)(int blank_mode); 381 + int (*pan_display)(struct fb_var_screeninfo *var, 382 + struct fb_info *info); 342 383 } *fbhw; 343 384 344 - static char *autodetect_names[] = {"autodetect", NULL}; 345 - static char *stlow_names[] = {"stlow", NULL}; 346 - static char *stmid_names[] = {"stmid", "default5", NULL}; 347 - static char *sthigh_names[] = {"sthigh", "default4", NULL}; 348 - static char *ttlow_names[] = {"ttlow", NULL}; 349 - static char *ttmid_names[]= {"ttmid", "default1", NULL}; 350 - static char *tthigh_names[]= {"tthigh", "default2", NULL}; 351 - static char *vga2_names[] = {"vga2", NULL}; 352 - static char *vga4_names[] = {"vga4", NULL}; 353 - static char *vga16_names[] = {"vga16", "default3", NULL}; 354 - static char *vga256_names[] = {"vga256", NULL}; 355 - static char *falh2_names[] = {"falh2", NULL}; 356 - static char *falh16_names[] = {"falh16", NULL}; 385 + static char *autodetect_names[] = { "autodetect", NULL }; 386 + static char *stlow_names[] = { "stlow", NULL }; 387 + static char *stmid_names[] = { "stmid", "default5", NULL }; 388 + static char *sthigh_names[] = { "sthigh", "default4", NULL }; 389 + static char *ttlow_names[] = { "ttlow", NULL }; 390 + static char *ttmid_names[] = { "ttmid", "default1", NULL }; 391 + static char *tthigh_names[] = { "tthigh", "default2", NULL }; 392 + static char *vga2_names[] = { "vga2", NULL }; 393 + static char *vga4_names[] = { "vga4", NULL }; 394 + static char *vga16_names[] = { "vga16", "default3", NULL }; 395 + static char *vga256_names[] = { "vga256", NULL }; 396 + static char *falh2_names[] = { "falh2", NULL }; 397 + static char *falh16_names[] = { "falh16", NULL }; 357 398 358 399 static char **fb_var_names[] = { 359 - /* Writing the name arrays directly in this array (via "(char *[]){...}") 360 - * crashes gcc 2.5.8 (sigsegv) if the inner array 361 - * contains more than two items. I've also seen that all elements 362 - * were identical to the last (my cross-gcc) :-(*/ 363 400 autodetect_names, 364 401 stlow_names, 365 402 stmid_names, ··· 432 353 falh2_names, 433 354 falh16_names, 434 355 NULL 435 - /* ,NULL */ /* this causes a sigsegv on my gcc-2.5.8 */ 436 356 }; 437 357 438 358 static struct fb_var_screeninfo atafb_predefined[] = { 439 - /* 440 - * yres_virtual==0 means use hw-scrolling if possible, else yres 441 - */ 442 - { /* autodetect */ 443 - 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */ 444 - {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, /* red green blue tran*/ 359 + /* 360 + * yres_virtual == 0 means use hw-scrolling if possible, else yres 361 + */ 362 + { /* autodetect */ 363 + 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */ 364 + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, /* red green blue tran*/ 445 365 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, 446 - { /* st low */ 366 + { /* st low */ 447 367 320, 200, 320, 0, 0, 0, 4, 0, 448 368 {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 449 369 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, ··· 492 414 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, 493 415 }; 494 416 495 - static int num_atafb_predefined=ARRAY_SIZE(atafb_predefined); 417 + static int num_atafb_predefined = ARRAY_SIZE(atafb_predefined); 418 + 419 + static struct fb_videomode atafb_modedb[] __initdata = { 420 + /* 421 + * Atari Video Modes 422 + * 423 + * If you change these, make sure to update DEFMODE_* as well! 424 + */ 425 + 426 + /* 427 + * ST/TT Video Modes 428 + */ 429 + 430 + { 431 + /* 320x200, 15 kHz, 60 Hz (ST low) */ 432 + "st-low", 60, 320, 200, 32000, 32, 16, 31, 14, 96, 4, 433 + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 434 + }, { 435 + /* 640x200, 15 kHz, 60 Hz (ST medium) */ 436 + "st-mid", 60, 640, 200, 32000, 32, 16, 31, 14, 96, 4, 437 + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 438 + }, { 439 + /* 640x400, 30.25 kHz, 63.5 Hz (ST high) */ 440 + "st-high", 63, 640, 400, 32000, 128, 0, 40, 14, 128, 4, 441 + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 442 + }, { 443 + /* 320x480, 15 kHz, 60 Hz (TT low) */ 444 + "tt-low", 60, 320, 480, 31041, 120, 100, 8, 16, 140, 30, 445 + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 446 + }, { 447 + /* 640x480, 29 kHz, 57 Hz (TT medium) */ 448 + "tt-mid", 60, 640, 480, 31041, 120, 100, 8, 16, 140, 30, 449 + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 450 + }, { 451 + /* 1280x960, 29 kHz, 60 Hz (TT high) */ 452 + "tt-high", 57, 640, 960, 31041, 120, 100, 8, 16, 140, 30, 453 + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 454 + }, 455 + 456 + /* 457 + * VGA Video Modes 458 + */ 459 + 460 + { 461 + /* 640x480, 31 kHz, 60 Hz (VGA) */ 462 + "vga", 63.5, 640, 480, 32000, 18, 42, 31, 11, 96, 3, 463 + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 464 + }, { 465 + /* 640x400, 31 kHz, 70 Hz (VGA) */ 466 + "vga70", 70, 640, 400, 32000, 18, 42, 31, 11, 96, 3, 467 + FB_SYNC_VERT_HIGH_ACT | FB_SYNC_COMP_HIGH_ACT, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 468 + }, 469 + 470 + /* 471 + * Falcon HiRes Video Modes 472 + */ 473 + 474 + { 475 + /* 896x608, 31 kHz, 60 Hz (Falcon High) */ 476 + "falh", 60, 896, 608, 32000, 18, 42, 31, 1, 96,3, 477 + 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP 478 + }, 479 + }; 480 + 481 + #define NUM_TOTAL_MODES ARRAY_SIZE(atafb_modedb) 482 + 483 + static char *mode_option __initdata = NULL; 484 + 485 + /* default modes */ 486 + 487 + #define DEFMODE_TT 5 /* "tt-high" for TT */ 488 + #define DEFMODE_F30 7 /* "vga70" for Falcon */ 489 + #define DEFMODE_STE 2 /* "st-high" for ST/E */ 490 + #define DEFMODE_EXT 6 /* "vga" for external */ 496 491 497 492 498 - static int 499 - get_video_mode(char *vname) 493 + static int get_video_mode(char *vname) 500 494 { 501 - char ***name_list; 502 - char **name; 503 - int i; 504 - name_list=fb_var_names; 505 - for (i = 0 ; i < num_atafb_predefined ; i++) { 506 - name=*(name_list++); 507 - if (! name || ! *name) 508 - break; 509 - while (*name) { 510 - if (! strcmp(vname, *name)) 511 - return i+1; 512 - name++; 495 + char ***name_list; 496 + char **name; 497 + int i; 498 + 499 + name_list = fb_var_names; 500 + for (i = 0; i < num_atafb_predefined; i++) { 501 + name = *name_list++; 502 + if (!name || !*name) 503 + break; 504 + while (*name) { 505 + if (!strcmp(vname, *name)) 506 + return i + 1; 507 + name++; 508 + } 513 509 } 514 - } 515 - return 0; 510 + return 0; 516 511 } 517 512 518 513 ··· 594 443 595 444 #ifdef ATAFB_TT 596 445 597 - static int tt_encode_fix( struct fb_fix_screeninfo *fix, 598 - struct atafb_par *par ) 599 - 446 + static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) 600 447 { 601 448 int mode; 602 449 603 - strcpy(fix->id,"Atari Builtin"); 450 + strcpy(fix->id, "Atari Builtin"); 604 451 fix->smem_start = (unsigned long)real_screen_base; 605 452 fix->smem_len = screen_len; 606 - fix->type=FB_TYPE_INTERLEAVED_PLANES; 607 - fix->type_aux=2; 608 - fix->visual=FB_VISUAL_PSEUDOCOLOR; 453 + fix->type = FB_TYPE_INTERLEAVED_PLANES; 454 + fix->type_aux = 2; 455 + fix->visual = FB_VISUAL_PSEUDOCOLOR; 609 456 mode = par->hw.tt.mode & TT_SHIFTER_MODEMASK; 610 457 if (mode == TT_SHIFTER_TTHIGH || mode == TT_SHIFTER_STHIGH) { 611 - fix->type=FB_TYPE_PACKED_PIXELS; 612 - fix->type_aux=0; 458 + fix->type = FB_TYPE_PACKED_PIXELS; 459 + fix->type_aux = 0; 613 460 if (mode == TT_SHIFTER_TTHIGH) 614 - fix->visual=FB_VISUAL_MONO01; 461 + fix->visual = FB_VISUAL_MONO01; 615 462 } 616 - fix->xpanstep=0; 617 - fix->ypanstep=1; 618 - fix->ywrapstep=0; 463 + fix->xpanstep = 0; 464 + fix->ypanstep = 1; 465 + fix->ywrapstep = 0; 619 466 fix->line_length = 0; 620 467 fix->accel = FB_ACCEL_ATARIBLITT; 621 468 return 0; 622 469 } 623 470 624 - 625 - static int tt_decode_var( struct fb_var_screeninfo *var, 626 - struct atafb_par *par ) 471 + static int tt_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) 627 472 { 628 - int xres=var->xres; 629 - int yres=var->yres; 630 - int bpp=var->bits_per_pixel; 473 + int xres = var->xres; 474 + int yres = var->yres; 475 + int bpp = var->bits_per_pixel; 631 476 int linelen; 632 477 int yres_virtual = var->yres_virtual; 633 478 634 479 if (mono_moni) { 635 - if (bpp > 1 || xres > sttt_xres*2 || yres >tt_yres*2) 480 + if (bpp > 1 || xres > sttt_xres * 2 || yres > tt_yres * 2) 636 481 return -EINVAL; 637 - par->hw.tt.mode=TT_SHIFTER_TTHIGH; 638 - xres=sttt_xres*2; 639 - yres=tt_yres*2; 640 - bpp=1; 482 + par->hw.tt.mode = TT_SHIFTER_TTHIGH; 483 + xres = sttt_xres * 2; 484 + yres = tt_yres * 2; 485 + bpp = 1; 641 486 } else { 642 487 if (bpp > 8 || xres > sttt_xres || yres > tt_yres) 643 488 return -EINVAL; 644 489 if (bpp > 4) { 645 - if (xres > sttt_xres/2 || yres > tt_yres) 490 + if (xres > sttt_xres / 2 || yres > tt_yres) 646 491 return -EINVAL; 647 - par->hw.tt.mode=TT_SHIFTER_TTLOW; 648 - xres=sttt_xres/2; 649 - yres=tt_yres; 650 - bpp=8; 651 - } 652 - else if (bpp > 2) { 492 + par->hw.tt.mode = TT_SHIFTER_TTLOW; 493 + xres = sttt_xres / 2; 494 + yres = tt_yres; 495 + bpp = 8; 496 + } else if (bpp > 2) { 653 497 if (xres > sttt_xres || yres > tt_yres) 654 498 return -EINVAL; 655 - if (xres > sttt_xres/2 || yres > st_yres/2) { 656 - par->hw.tt.mode=TT_SHIFTER_TTMID; 657 - xres=sttt_xres; 658 - yres=tt_yres; 659 - bpp=4; 499 + if (xres > sttt_xres / 2 || yres > st_yres / 2) { 500 + par->hw.tt.mode = TT_SHIFTER_TTMID; 501 + xres = sttt_xres; 502 + yres = tt_yres; 503 + bpp = 4; 504 + } else { 505 + par->hw.tt.mode = TT_SHIFTER_STLOW; 506 + xres = sttt_xres / 2; 507 + yres = st_yres / 2; 508 + bpp = 4; 660 509 } 661 - else { 662 - par->hw.tt.mode=TT_SHIFTER_STLOW; 663 - xres=sttt_xres/2; 664 - yres=st_yres/2; 665 - bpp=4; 666 - } 667 - } 668 - else if (bpp > 1) { 669 - if (xres > sttt_xres || yres > st_yres/2) 510 + } else if (bpp > 1) { 511 + if (xres > sttt_xres || yres > st_yres / 2) 670 512 return -EINVAL; 671 - par->hw.tt.mode=TT_SHIFTER_STMID; 672 - xres=sttt_xres; 673 - yres=st_yres/2; 674 - bpp=2; 675 - } 676 - else if (var->xres > sttt_xres || var->yres > st_yres) { 513 + par->hw.tt.mode = TT_SHIFTER_STMID; 514 + xres = sttt_xres; 515 + yres = st_yres / 2; 516 + bpp = 2; 517 + } else if (var->xres > sttt_xres || var->yres > st_yres) { 677 518 return -EINVAL; 678 - } 679 - else { 680 - par->hw.tt.mode=TT_SHIFTER_STHIGH; 681 - xres=sttt_xres; 682 - yres=st_yres; 683 - bpp=1; 519 + } else { 520 + par->hw.tt.mode = TT_SHIFTER_STHIGH; 521 + xres = sttt_xres; 522 + yres = st_yres; 523 + bpp = 1; 684 524 } 685 525 } 686 526 if (yres_virtual <= 0) ··· 679 537 else if (yres_virtual < yres) 680 538 yres_virtual = yres; 681 539 if (var->sync & FB_SYNC_EXT) 682 - par->hw.tt.sync=0; 540 + par->hw.tt.sync = 0; 683 541 else 684 - par->hw.tt.sync=1; 685 - linelen=xres*bpp/8; 542 + par->hw.tt.sync = 1; 543 + linelen = xres * bpp / 8; 686 544 if (yres_virtual * linelen > screen_len && screen_len) 687 545 return -EINVAL; 688 546 if (yres * linelen > screen_len && screen_len) ··· 694 552 return 0; 695 553 } 696 554 697 - static int tt_encode_var( struct fb_var_screeninfo *var, 698 - struct atafb_par *par ) 555 + static int tt_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) 699 556 { 700 557 int linelen; 701 558 memset(var, 0, sizeof(struct fb_var_screeninfo)); 702 - var->red.offset=0; 703 - var->red.length=4; 704 - var->red.msb_right=0; 705 - var->grayscale=0; 559 + var->red.offset = 0; 560 + var->red.length = 4; 561 + var->red.msb_right = 0; 562 + var->grayscale = 0; 706 563 707 - var->pixclock=31041; 708 - var->left_margin=120; /* these may be incorrect */ 709 - var->right_margin=100; 710 - var->upper_margin=8; 711 - var->lower_margin=16; 712 - var->hsync_len=140; 713 - var->vsync_len=30; 564 + var->pixclock = 31041; 565 + var->left_margin = 120; /* these may be incorrect */ 566 + var->right_margin = 100; 567 + var->upper_margin = 8; 568 + var->lower_margin = 16; 569 + var->hsync_len = 140; 570 + var->vsync_len = 30; 714 571 715 - var->height=-1; 716 - var->width=-1; 572 + var->height = -1; 573 + var->width = -1; 717 574 718 575 if (par->hw.tt.sync & 1) 719 - var->sync=0; 576 + var->sync = 0; 720 577 else 721 - var->sync=FB_SYNC_EXT; 578 + var->sync = FB_SYNC_EXT; 722 579 723 580 switch (par->hw.tt.mode & TT_SHIFTER_MODEMASK) { 724 581 case TT_SHIFTER_STLOW: 725 - var->xres=sttt_xres/2; 726 - var->xres_virtual=sttt_xres_virtual/2; 727 - var->yres=st_yres/2; 728 - var->bits_per_pixel=4; 582 + var->xres = sttt_xres / 2; 583 + var->xres_virtual = sttt_xres_virtual / 2; 584 + var->yres = st_yres / 2; 585 + var->bits_per_pixel = 4; 729 586 break; 730 587 case TT_SHIFTER_STMID: 731 - var->xres=sttt_xres; 732 - var->xres_virtual=sttt_xres_virtual; 733 - var->yres=st_yres/2; 734 - var->bits_per_pixel=2; 588 + var->xres = sttt_xres; 589 + var->xres_virtual = sttt_xres_virtual; 590 + var->yres = st_yres / 2; 591 + var->bits_per_pixel = 2; 735 592 break; 736 593 case TT_SHIFTER_STHIGH: 737 - var->xres=sttt_xres; 738 - var->xres_virtual=sttt_xres_virtual; 739 - var->yres=st_yres; 740 - var->bits_per_pixel=1; 594 + var->xres = sttt_xres; 595 + var->xres_virtual = sttt_xres_virtual; 596 + var->yres = st_yres; 597 + var->bits_per_pixel = 1; 741 598 break; 742 599 case TT_SHIFTER_TTLOW: 743 - var->xres=sttt_xres/2; 744 - var->xres_virtual=sttt_xres_virtual/2; 745 - var->yres=tt_yres; 746 - var->bits_per_pixel=8; 600 + var->xres = sttt_xres / 2; 601 + var->xres_virtual = sttt_xres_virtual / 2; 602 + var->yres = tt_yres; 603 + var->bits_per_pixel = 8; 747 604 break; 748 605 case TT_SHIFTER_TTMID: 749 - var->xres=sttt_xres; 750 - var->xres_virtual=sttt_xres_virtual; 751 - var->yres=tt_yres; 752 - var->bits_per_pixel=4; 606 + var->xres = sttt_xres; 607 + var->xres_virtual = sttt_xres_virtual; 608 + var->yres = tt_yres; 609 + var->bits_per_pixel = 4; 753 610 break; 754 611 case TT_SHIFTER_TTHIGH: 755 - var->red.length=0; 756 - var->xres=sttt_xres*2; 757 - var->xres_virtual=sttt_xres_virtual*2; 758 - var->yres=tt_yres*2; 759 - var->bits_per_pixel=1; 612 + var->red.length = 0; 613 + var->xres = sttt_xres * 2; 614 + var->xres_virtual = sttt_xres_virtual * 2; 615 + var->yres = tt_yres * 2; 616 + var->bits_per_pixel = 1; 760 617 break; 761 - } 762 - var->blue=var->green=var->red; 763 - var->transp.offset=0; 764 - var->transp.length=0; 765 - var->transp.msb_right=0; 766 - linelen=var->xres_virtual * var->bits_per_pixel / 8; 767 - if (! use_hwscroll) 768 - var->yres_virtual=var->yres; 618 + } 619 + var->blue = var->green = var->red; 620 + var->transp.offset = 0; 621 + var->transp.length = 0; 622 + var->transp.msb_right = 0; 623 + linelen = var->xres_virtual * var->bits_per_pixel / 8; 624 + if (!use_hwscroll) 625 + var->yres_virtual = var->yres; 769 626 else if (screen_len) { 770 627 if (par->yres_virtual) 771 628 var->yres_virtual = par->yres_virtual; 772 629 else 773 - /* yres_virtual==0 means use maximum */ 630 + /* yres_virtual == 0 means use maximum */ 774 631 var->yres_virtual = screen_len / linelen; 775 632 } else { 776 633 if (hwscroll < 0) 777 634 var->yres_virtual = 2 * var->yres; 778 635 else 779 - var->yres_virtual=var->yres+hwscroll * 16; 636 + var->yres_virtual = var->yres + hwscroll * 16; 780 637 } 781 - var->xoffset=0; 638 + var->xoffset = 0; 782 639 if (screen_base) 783 - var->yoffset=(par->screen_base - screen_base)/linelen; 640 + var->yoffset = (par->screen_base - screen_base) / linelen; 784 641 else 785 - var->yoffset=0; 786 - var->nonstd=0; 787 - var->activate=0; 788 - var->vmode=FB_VMODE_NONINTERLACED; 642 + var->yoffset = 0; 643 + var->nonstd = 0; 644 + var->activate = 0; 645 + var->vmode = FB_VMODE_NONINTERLACED; 789 646 return 0; 790 647 } 791 648 792 - 793 - static void tt_get_par( struct atafb_par *par ) 649 + static void tt_get_par(struct atafb_par *par) 794 650 { 795 651 unsigned long addr; 796 - par->hw.tt.mode=shifter_tt.tt_shiftmode; 797 - par->hw.tt.sync=shifter.syncmode; 652 + par->hw.tt.mode = shifter_tt.tt_shiftmode; 653 + par->hw.tt.sync = shifter.syncmode; 798 654 addr = ((shifter.bas_hi & 0xff) << 16) | 799 655 ((shifter.bas_md & 0xff) << 8) | 800 656 ((shifter.bas_lo & 0xff)); 801 657 par->screen_base = phys_to_virt(addr); 802 658 } 803 659 804 - static void tt_set_par( struct atafb_par *par ) 660 + static void tt_set_par(struct atafb_par *par) 805 661 { 806 - shifter_tt.tt_shiftmode=par->hw.tt.mode; 807 - shifter.syncmode=par->hw.tt.sync; 662 + shifter_tt.tt_shiftmode = par->hw.tt.mode; 663 + shifter.syncmode = par->hw.tt.sync; 808 664 /* only set screen_base if really necessary */ 809 665 if (current_par.screen_base != par->screen_base) 810 666 fbhw->set_screen_base(par->screen_base); 811 667 } 812 668 813 - 814 - static int tt_getcolreg(unsigned regno, unsigned *red, 815 - unsigned *green, unsigned *blue, 816 - unsigned *transp, struct fb_info *info) 817 - { 818 - int t, col; 819 - 820 - if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) 821 - regno += 254; 822 - if (regno > 255) 823 - return 1; 824 - t = tt_palette[regno]; 825 - col = t & 15; 826 - col |= col << 4; 827 - col |= col << 8; 828 - *blue = col; 829 - col = (t >> 4) & 15; 830 - col |= col << 4; 831 - col |= col << 8; 832 - *green = col; 833 - col = (t >> 8) & 15; 834 - col |= col << 4; 835 - col |= col << 8; 836 - *red = col; 837 - *transp = 0; 838 - return 0; 839 - } 840 - 841 - 842 - static int tt_setcolreg(unsigned regno, unsigned red, 843 - unsigned green, unsigned blue, 844 - unsigned transp, struct fb_info *info) 669 + static int tt_setcolreg(unsigned int regno, unsigned int red, 670 + unsigned int green, unsigned int blue, 671 + unsigned int transp, struct fb_info *info) 845 672 { 846 673 if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) 847 674 regno += 254; ··· 819 708 tt_palette[regno] = (((red >> 12) << 8) | ((green >> 12) << 4) | 820 709 (blue >> 12)); 821 710 if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == 822 - TT_SHIFTER_STHIGH && regno == 254) 711 + TT_SHIFTER_STHIGH && regno == 254) 823 712 tt_palette[0] = 0; 824 713 return 0; 825 714 } 826 715 827 - 828 - static int tt_detect( void ) 829 - 830 - { struct atafb_par par; 716 + static int tt_detect(void) 717 + { 718 + struct atafb_par par; 831 719 832 720 /* Determine the connected monitor: The DMA sound must be 833 721 * disabled before reading the MFP GPIP, because the Sound ··· 836 726 * announced that the Eagle is TT compatible, but only the PCM is 837 727 * missing... 838 728 */ 839 - if (ATARIHW_PRESENT(PCM_8BIT)) { 729 + if (ATARIHW_PRESENT(PCM_8BIT)) { 840 730 tt_dmasnd.ctrl = DMASND_CTRL_OFF; 841 - udelay(20); /* wait a while for things to settle down */ 731 + udelay(20); /* wait a while for things to settle down */ 842 732 } 843 733 mono_moni = (mfp.par_dt_reg & 0x80) == 0; 844 734 ··· 865 755 unsigned long f; /* f/[Hz] */ 866 756 unsigned long t; /* t/[ps] (=1/f) */ 867 757 int right, hsync, left; /* standard timing in clock cycles, not pixel */ 868 - /* hsync initialized in falcon_detect() */ 758 + /* hsync initialized in falcon_detect() */ 869 759 int sync_mask; /* or-mask for hw.falcon.sync to set this clock */ 870 760 int control_mask; /* ditto, for hw.falcon.vid_control */ 871 - } 872 - f25 = {25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25}, 873 - f32 = {32000000, 31250, 18, 0, 42, 0x0, 0}, 874 - fext = { 0, 0, 18, 0, 42, 0x1, 0}; 761 + } f25 = { 762 + 25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25 763 + }, f32 = { 764 + 32000000, 31250, 18, 0, 42, 0x0, 0 765 + }, fext = { 766 + 0, 0, 18, 0, 42, 0x1, 0 767 + }; 875 768 876 769 /* VIDEL-prescale values [mon_type][pixel_length from VCO] */ 877 - static int vdl_prescale[4][3] = {{4,2,1}, {4,2,1}, {4,2,2}, {4,2,1}}; 770 + static int vdl_prescale[4][3] = { 771 + { 4,2,1 }, { 4,2,1 }, { 4,2,2 }, { 4,2,1 } 772 + }; 878 773 879 774 /* Default hsync timing [mon_type] in picoseconds */ 880 - static long h_syncs[4] = {3000000, 4875000, 4000000, 4875000}; 775 + static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 }; 881 776 882 777 #ifdef FBCON_HAS_CFB16 883 778 static u16 fbcon_cfb16_cmap[16]; ··· 890 775 891 776 static inline int hxx_prescale(struct falcon_hw *hw) 892 777 { 893 - return hw->ste_mode ? 16 : 894 - vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; 778 + return hw->ste_mode ? 16 779 + : vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; 895 780 } 896 781 897 - static int falcon_encode_fix( struct fb_fix_screeninfo *fix, 898 - struct atafb_par *par ) 782 + static int falcon_encode_fix(struct fb_fix_screeninfo *fix, 783 + struct atafb_par *par) 899 784 { 900 785 strcpy(fix->id, "Atari Builtin"); 901 786 fix->smem_start = (unsigned long)real_screen_base; ··· 911 796 fix->type_aux = 0; 912 797 /* no smooth scrolling with longword aligned video mem */ 913 798 fix->xpanstep = 32; 914 - } 915 - else if (par->hw.falcon.f_shift & 0x100) { 799 + } else if (par->hw.falcon.f_shift & 0x100) { 916 800 fix->type = FB_TYPE_PACKED_PIXELS; 917 801 fix->type_aux = 0; 918 802 /* Is this ok or should it be DIRECTCOLOR? */ ··· 923 809 return 0; 924 810 } 925 811 926 - 927 - static int falcon_decode_var( struct fb_var_screeninfo *var, 928 - struct atafb_par *par ) 812 + static int falcon_decode_var(struct fb_var_screeninfo *var, 813 + struct atafb_par *par) 929 814 { 930 815 int bpp = var->bits_per_pixel; 931 816 int xres = var->xres; ··· 936 823 int linelen; 937 824 int interlace = 0, doubleline = 0; 938 825 struct pixel_clock *pclock; 939 - int plen; /* width of pixel in clock cycles */ 826 + int plen; /* width of pixel in clock cycles */ 940 827 int xstretch; 941 828 int prescale; 942 829 int longoffset = 0; 943 830 int hfreq, vfreq; 831 + int hdb_off, hde_off, base_off; 832 + int gstart, gend1, gend2, align; 944 833 945 834 /* 946 835 Get the video params out of 'var'. If a value doesn't fit, round 947 836 it up, if it's too big, return EINVAL. 948 - Round up in the following order: bits_per_pixel, xres, yres, 949 - xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, 837 + Round up in the following order: bits_per_pixel, xres, yres, 838 + xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, 950 839 horizontal timing, vertical timing. 951 840 952 841 There is a maximum of screen resolution determined by pixelclock ··· 958 843 Frequency range for multisync monitors is given via command line. 959 844 For TV and SM124 both frequencies are fixed. 960 845 961 - X % 16 == 0 to fit 8x?? font (except 1 bitplane modes must use X%32==0) 846 + X % 16 == 0 to fit 8x?? font (except 1 bitplane modes must use X%32 == 0) 962 847 Y % 16 == 0 to fit 8x16 font 963 848 Y % 8 == 0 if Y<400 964 849 965 - Currently interlace and doubleline mode in var are ignored. 850 + Currently interlace and doubleline mode in var are ignored. 966 851 On SM124 and TV only the standard resolutions can be used. 967 852 */ 968 853 ··· 970 855 if (!xres || !yres || !bpp) 971 856 return -EINVAL; 972 857 973 - if (mon_type == F_MON_SM && bpp != 1) { 858 + if (mon_type == F_MON_SM && bpp != 1) 974 859 return -EINVAL; 975 - } 976 - else if (bpp <= 1) { 860 + 861 + if (bpp <= 1) { 977 862 bpp = 1; 978 863 par->hw.falcon.f_shift = 0x400; 979 864 par->hw.falcon.st_shift = 0x200; 980 - } 981 - else if (bpp <= 2) { 865 + } else if (bpp <= 2) { 982 866 bpp = 2; 983 867 par->hw.falcon.f_shift = 0x000; 984 868 par->hw.falcon.st_shift = 0x100; 985 - } 986 - else if (bpp <= 4) { 869 + } else if (bpp <= 4) { 987 870 bpp = 4; 988 871 par->hw.falcon.f_shift = 0x000; 989 872 par->hw.falcon.st_shift = 0x000; 990 - } 991 - else if (bpp <= 8) { 873 + } else if (bpp <= 8) { 992 874 bpp = 8; 993 875 par->hw.falcon.f_shift = 0x010; 994 - } 995 - else if (bpp <= 16) { 996 - bpp = 16; /* packed pixel mode */ 997 - par->hw.falcon.f_shift = 0x100; /* hicolor, no overlay */ 998 - } 999 - else 876 + } else if (bpp <= 16) { 877 + bpp = 16; /* packed pixel mode */ 878 + par->hw.falcon.f_shift = 0x100; /* hicolor, no overlay */ 879 + } else 1000 880 return -EINVAL; 1001 881 par->hw.falcon.bpp = bpp; 1002 882 1003 883 if (mon_type == F_MON_SM || DontCalcRes) { 1004 884 /* Skip all calculations. VGA/TV/SC1224 only supported. */ 1005 885 struct fb_var_screeninfo *myvar = &atafb_predefined[0]; 1006 - 886 + 1007 887 if (bpp > myvar->bits_per_pixel || 1008 - var->xres > myvar->xres || 1009 - var->yres > myvar->yres) 888 + var->xres > myvar->xres || 889 + var->yres > myvar->yres) 1010 890 return -EINVAL; 1011 891 fbhw->get_par(par); /* Current par will be new par */ 1012 892 goto set_screen_base; /* Don't forget this */ ··· 1020 910 yres = 400; 1021 911 1022 912 /* 2 planes must use STE compatibility mode */ 1023 - par->hw.falcon.ste_mode = bpp==2; 1024 - par->hw.falcon.mono = bpp==1; 913 + par->hw.falcon.ste_mode = bpp == 2; 914 + par->hw.falcon.mono = bpp == 1; 1025 915 1026 916 /* Total and visible scanline length must be a multiple of one longword, 1027 917 * this and the console fontwidth yields the alignment for xres and ··· 1077 967 left_margin = hsync_len = 128 / plen; 1078 968 right_margin = 0; 1079 969 /* TODO set all margins */ 1080 - } 1081 - else 970 + } else 1082 971 #endif 1083 972 if (mon_type == F_MON_SC || mon_type == F_MON_TV) { 1084 973 plen = 2 * xstretch; ··· 1111 1002 vsync_len *= 2; 1112 1003 } 1113 1004 } 1114 - } 1115 - else 1116 - { /* F_MON_VGA */ 1005 + } else { /* F_MON_VGA */ 1117 1006 if (bpp == 16) 1118 - xstretch = 2; /* Double pixel width only for hicolor */ 1007 + xstretch = 2; /* Double pixel width only for hicolor */ 1119 1008 /* Default values are used for vert./hor. timing if no pixelclock given. */ 1120 1009 if (var->pixclock == 0) { 1121 1010 int linesize; 1122 1011 1123 1012 /* Choose master pixelclock depending on hor. timing */ 1124 1013 plen = 1 * xstretch; 1125 - if ((plen * xres + f25.right+f25.hsync+f25.left) * 1014 + if ((plen * xres + f25.right + f25.hsync + f25.left) * 1126 1015 fb_info.monspecs.hfmin < f25.f) 1127 1016 pclock = &f25; 1128 - else if ((plen * xres + f32.right+f32.hsync+f32.left) * 1129 - fb_info.monspecs.hfmin < f32.f) 1017 + else if ((plen * xres + f32.right + f32.hsync + 1018 + f32.left) * fb_info.monspecs.hfmin < f32.f) 1130 1019 pclock = &f32; 1131 - else if ((plen * xres + fext.right+fext.hsync+fext.left) * 1132 - fb_info.monspecs.hfmin < fext.f 1133 - && fext.f) 1020 + else if ((plen * xres + fext.right + fext.hsync + 1021 + fext.left) * fb_info.monspecs.hfmin < fext.f && 1022 + fext.f) 1134 1023 pclock = &fext; 1135 1024 else 1136 1025 return -EINVAL; ··· 1140 1033 upper_margin = 31; 1141 1034 lower_margin = 11; 1142 1035 vsync_len = 3; 1143 - } 1144 - else { 1036 + } else { 1145 1037 /* Choose largest pixelclock <= wanted clock */ 1146 1038 int i; 1147 1039 unsigned long pcl = ULONG_MAX; 1148 1040 pclock = 0; 1149 - for (i=1; i <= 4; i *= 2) { 1150 - if (f25.t*i >= var->pixclock && f25.t*i < pcl) { 1041 + for (i = 1; i <= 4; i *= 2) { 1042 + if (f25.t * i >= var->pixclock && 1043 + f25.t * i < pcl) { 1151 1044 pcl = f25.t * i; 1152 1045 pclock = &f25; 1153 1046 } 1154 - if (f32.t*i >= var->pixclock && f32.t*i < pcl) { 1047 + if (f32.t * i >= var->pixclock && 1048 + f32.t * i < pcl) { 1155 1049 pcl = f32.t * i; 1156 1050 pclock = &f32; 1157 1051 } 1158 - if (fext.t && fext.t*i >= var->pixclock && fext.t*i < pcl) { 1052 + if (fext.t && fext.t * i >= var->pixclock && 1053 + fext.t * i < pcl) { 1159 1054 pcl = fext.t * i; 1160 1055 pclock = &fext; 1161 1056 } ··· 1179 1070 upper_margin = (upper_margin + 1) / 2; 1180 1071 lower_margin = (lower_margin + 1) / 2; 1181 1072 vsync_len = (vsync_len + 1) / 2; 1182 - } 1183 - else if (var->vmode & FB_VMODE_DOUBLE) { 1073 + } else if (var->vmode & FB_VMODE_DOUBLE) { 1184 1074 /* External unit is [double lines per frame] */ 1185 1075 upper_margin *= 2; 1186 1076 lower_margin *= 2; ··· 1187 1079 } 1188 1080 } 1189 1081 if (pclock == &fext) 1190 - longoffset = 1; /* VIDEL doesn't synchronize on short offset */ 1082 + longoffset = 1; /* VIDEL doesn't synchronize on short offset */ 1191 1083 } 1192 1084 /* Is video bus bandwidth (32MB/s) too low for this resolution? */ 1193 1085 /* this is definitely wrong if bus clock != 32MHz */ ··· 1206 1098 * between interlace and non-interlace without messing around 1207 1099 * with these. 1208 1100 */ 1209 - again: 1101 + again: 1210 1102 /* Set base_offset 128 and video bus width */ 1211 1103 par->hw.falcon.vid_control = mon_type | f030_bus_width; 1212 1104 if (!longoffset) ··· 1220 1112 /* External or internal clock */ 1221 1113 par->hw.falcon.sync = pclock->sync_mask | 0x2; 1222 1114 /* Pixellength and prescale */ 1223 - par->hw.falcon.vid_mode = (2/plen) << 2; 1115 + par->hw.falcon.vid_mode = (2 / plen) << 2; 1224 1116 if (doubleline) 1225 1117 par->hw.falcon.vid_mode |= VMO_DOUBLE; 1226 1118 if (interlace) 1227 1119 par->hw.falcon.vid_mode |= VMO_INTER; 1228 1120 1229 1121 /********************* 1230 - Horizontal timing: unit = [master clock cycles] 1231 - unit of hxx-registers: [master clock cycles * prescale] 1232 - Hxx-registers are 9 bit wide 1233 - 1234 - 1 line = ((hht + 2) * 2 * prescale) clock cycles 1235 - 1236 - graphic output = hdb & 0x200 ? 1237 - ((hht+2)*2 - hdb + hde) * prescale - hdboff + hdeoff: 1238 - ( hht + 2 - hdb + hde) * prescale - hdboff + hdeoff 1239 - (this must be a multiple of plen*128/bpp, on VGA pixels 1240 - to the right may be cut off with a bigger right margin) 1241 - 1242 - start of graphics relative to start of 1st halfline = hdb & 0x200 ? 1243 - (hdb - hht - 2) * prescale + hdboff : 1244 - hdb * prescale + hdboff 1245 - 1246 - end of graphics relative to start of 1st halfline = 1247 - (hde + hht + 2) * prescale + hdeoff 1248 - *********************/ 1122 + * Horizontal timing: unit = [master clock cycles] 1123 + * unit of hxx-registers: [master clock cycles * prescale] 1124 + * Hxx-registers are 9 bit wide 1125 + * 1126 + * 1 line = ((hht + 2) * 2 * prescale) clock cycles 1127 + * 1128 + * graphic output = hdb & 0x200 ? 1129 + * ((hht + 2) * 2 - hdb + hde) * prescale - hdboff + hdeoff: 1130 + * (hht + 2 - hdb + hde) * prescale - hdboff + hdeoff 1131 + * (this must be a multiple of plen*128/bpp, on VGA pixels 1132 + * to the right may be cut off with a bigger right margin) 1133 + * 1134 + * start of graphics relative to start of 1st halfline = hdb & 0x200 ? 1135 + * (hdb - hht - 2) * prescale + hdboff : 1136 + * hdb * prescale + hdboff 1137 + * 1138 + * end of graphics relative to start of 1st halfline = 1139 + * (hde + hht + 2) * prescale + hdeoff 1140 + *********************/ 1249 1141 /* Calculate VIDEL registers */ 1250 - { 1251 - int hdb_off, hde_off, base_off; 1252 - int gstart, gend1, gend2, align; 1253 - 1142 + { 1254 1143 prescale = hxx_prescale(&par->hw.falcon); 1255 1144 base_off = par->hw.falcon.vid_control & VCO_SHORTOFFS ? 64 : 128; 1256 1145 ··· 1259 1154 align = 1; 1260 1155 hde_off = 0; 1261 1156 hdb_off = (base_off + 16 * plen) + prescale; 1262 - } 1263 - else { 1157 + } else { 1264 1158 align = 128 / bpp; 1265 1159 hde_off = ((128 / bpp + 2) * plen); 1266 1160 if (par->hw.falcon.ste_mode) ··· 1268 1164 hdb_off = (base_off + (128 / bpp + 18) * plen) + prescale; 1269 1165 } 1270 1166 1271 - gstart = (prescale/2 + plen * left_margin) / prescale; 1167 + gstart = (prescale / 2 + plen * left_margin) / prescale; 1272 1168 /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */ 1273 - gend1 = gstart + ((xres + align-1) / align)*align * plen / prescale; 1169 + gend1 = gstart + ((xres + align - 1) / align) * align * plen / prescale; 1274 1170 /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */ 1275 1171 gend2 = gstart + xres * plen / prescale; 1276 1172 par->HHT = plen * (left_margin + xres + right_margin) / 1277 1173 (2 * prescale) - 2; 1278 1174 /* par->HHT = (gend2 + plen * right_margin / prescale) / 2 - 2;*/ 1279 1175 1280 - par->HDB = gstart - hdb_off/prescale; 1176 + par->HDB = gstart - hdb_off / prescale; 1281 1177 par->HBE = gstart; 1282 - if (par->HDB < 0) par->HDB += par->HHT + 2 + 0x200; 1283 - par->HDE = gend1 - par->HHT - 2 - hde_off/prescale; 1178 + if (par->HDB < 0) 1179 + par->HDB += par->HHT + 2 + 0x200; 1180 + par->HDE = gend1 - par->HHT - 2 - hde_off / prescale; 1284 1181 par->HBB = gend2 - par->HHT - 2; 1285 1182 #if 0 1286 1183 /* One more Videl constraint: data fetch of two lines must not overlap */ 1287 - if ((par->HDB & 0x200) && (par->HDB & ~0x200) - par->HDE <= 5) { 1184 + if ((par->HDB & 0x200) && (par->HDB & ~0x200) - par->HDE <= 5) { 1288 1185 /* if this happens increase margins, decrease hfreq. */ 1289 1186 } 1290 1187 #endif ··· 1294 1189 par->HSS = par->HHT + 2 - plen * hsync_len / prescale; 1295 1190 if (par->HSS < par->HBB) 1296 1191 par->HSS = par->HBB; 1297 - } 1192 + } 1298 1193 1299 1194 /* check hor. frequency */ 1300 - hfreq = pclock->f / ((par->HHT+2)*prescale*2); 1301 - if (hfreq > fb_info.monspecs.hfmax && mon_type!=F_MON_VGA) { 1195 + hfreq = pclock->f / ((par->HHT + 2) * prescale * 2); 1196 + if (hfreq > fb_info.monspecs.hfmax && mon_type != F_MON_VGA) { 1302 1197 /* ++guenther: ^^^^^^^^^^^^^^^^^^^ can't remember why I did this */ 1303 1198 /* Too high -> enlarge margin */ 1304 1199 left_margin += 1; ··· 1318 1213 par->VBE = (upper_margin * 2 + 1); /* must begin on odd halfline */ 1319 1214 par->VDB = par->VBE; 1320 1215 par->VDE = yres; 1321 - if (!interlace) par->VDE <<= 1; 1322 - if (doubleline) par->VDE <<= 1; /* VDE now half lines per (half-)frame */ 1216 + if (!interlace) 1217 + par->VDE <<= 1; 1218 + if (doubleline) 1219 + par->VDE <<= 1; /* VDE now half lines per (half-)frame */ 1323 1220 par->VDE += par->VDB; 1324 1221 par->VBB = par->VDE; 1325 1222 par->VFT = par->VBB + (lower_margin * 2 - 1) - 1; 1326 - par->VSS = par->VFT+1 - (vsync_len * 2 - 1); 1223 + par->VSS = par->VFT + 1 - (vsync_len * 2 - 1); 1327 1224 /* vbb,vss,vft must be even in interlace mode */ 1328 1225 if (interlace) { 1329 1226 par->VBB++; ··· 1336 1229 /* V-frequency check, hope I didn't create any loop here. */ 1337 1230 /* Interlace and doubleline are mutually exclusive. */ 1338 1231 vfreq = (hfreq * 2) / (par->VFT + 1); 1339 - if (vfreq > fb_info.monspecs.vfmax && !doubleline && !interlace) { 1232 + if (vfreq > fb_info.monspecs.vfmax && !doubleline && !interlace) { 1340 1233 /* Too high -> try again with doubleline */ 1341 1234 doubleline = 1; 1342 1235 goto again; 1343 - } 1344 - else if (vfreq < fb_info.monspecs.vfmin && !interlace && !doubleline) { 1236 + } else if (vfreq < fb_info.monspecs.vfmin && !interlace && !doubleline) { 1345 1237 /* Too low -> try again with interlace */ 1346 1238 interlace = 1; 1347 1239 goto again; 1348 - } 1349 - else if (vfreq < fb_info.monspecs.vfmin && doubleline) { 1240 + } else if (vfreq < fb_info.monspecs.vfmin && doubleline) { 1350 1241 /* Doubleline too low -> clear doubleline and enlarge margins */ 1351 1242 int lines; 1352 1243 doubleline = 0; 1353 - for (lines=0; 1354 - (hfreq*2)/(par->VFT+1+4*lines-2*yres)>fb_info.monspecs.vfmax; 1244 + for (lines = 0; 1245 + (hfreq * 2) / (par->VFT + 1 + 4 * lines - 2 * yres) > 1246 + fb_info.monspecs.vfmax; 1355 1247 lines++) 1356 1248 ; 1357 1249 upper_margin += lines; 1358 1250 lower_margin += lines; 1359 1251 goto again; 1360 - } 1361 - else if (vfreq > fb_info.monspecs.vfmax && doubleline) { 1252 + } else if (vfreq > fb_info.monspecs.vfmax && doubleline) { 1362 1253 /* Doubleline too high -> enlarge margins */ 1363 1254 int lines; 1364 - for (lines=0; 1365 - (hfreq*2)/(par->VFT+1+4*lines)>fb_info.monspecs.vfmax; 1366 - lines+=2) 1255 + for (lines = 0; 1256 + (hfreq * 2) / (par->VFT + 1 + 4 * lines) > 1257 + fb_info.monspecs.vfmax; 1258 + lines += 2) 1367 1259 ; 1368 1260 upper_margin += lines; 1369 1261 lower_margin += lines; 1370 1262 goto again; 1371 - } 1372 - else if (vfreq > fb_info.monspecs.vfmax && interlace) { 1263 + } else if (vfreq > fb_info.monspecs.vfmax && interlace) { 1373 1264 /* Interlace, too high -> enlarge margins */ 1374 1265 int lines; 1375 - for (lines=0; 1376 - (hfreq*2)/(par->VFT+1+4*lines)>fb_info.monspecs.vfmax; 1266 + for (lines = 0; 1267 + (hfreq * 2) / (par->VFT + 1 + 4 * lines) > 1268 + fb_info.monspecs.vfmax; 1377 1269 lines++) 1378 1270 ; 1379 1271 upper_margin += lines; 1380 1272 lower_margin += lines; 1381 1273 goto again; 1382 - } 1383 - else if (vfreq < fb_info.monspecs.vfmin || 1384 - vfreq > fb_info.monspecs.vfmax) 1274 + } else if (vfreq < fb_info.monspecs.vfmin || 1275 + vfreq > fb_info.monspecs.vfmax) 1385 1276 return -EINVAL; 1386 1277 1387 - set_screen_base: 1278 + set_screen_base: 1388 1279 linelen = xres_virtual * bpp / 8; 1389 1280 if (yres_virtual * linelen > screen_len && screen_len) 1390 1281 return -EINVAL; ··· 1394 1289 par->screen_base = screen_base + var->yoffset * linelen; 1395 1290 par->hw.falcon.xoffset = 0; 1396 1291 1292 + // FIXME!!! sort of works, no crash 1293 + //par->next_line = linelen; 1294 + //par->next_plane = yres_virtual * linelen; 1295 + par->next_line = linelen; 1296 + par->next_plane = 2; 1297 + // crashes 1298 + //par->next_plane = linelen; 1299 + //par->next_line = yres_virtual * linelen; 1300 + 1397 1301 return 0; 1398 1302 } 1399 1303 1400 - static int falcon_encode_var( struct fb_var_screeninfo *var, 1401 - struct atafb_par *par ) 1304 + static int falcon_encode_var(struct fb_var_screeninfo *var, 1305 + struct atafb_par *par) 1402 1306 { 1403 1307 /* !!! only for VGA !!! */ 1404 1308 int linelen; ··· 1420 1306 var->pixclock = hw->sync & 0x1 ? fext.t : 1421 1307 hw->vid_control & VCO_CLOCK25 ? f25.t : f32.t; 1422 1308 1423 - var->height=-1; 1424 - var->width=-1; 1309 + var->height = -1; 1310 + var->width = -1; 1425 1311 1426 - var->sync=0; 1312 + var->sync = 0; 1427 1313 if (hw->vid_control & VCO_HSYPOS) 1428 1314 var->sync |= FB_SYNC_HOR_HIGH_ACT; 1429 1315 if (hw->vid_control & VCO_VSYPOS) ··· 1434 1320 var->vmode |= FB_VMODE_INTERLACED; 1435 1321 if (hw->vid_mode & VMO_DOUBLE) 1436 1322 var->vmode |= FB_VMODE_DOUBLE; 1437 - 1323 + 1438 1324 /* visible y resolution: 1439 1325 * Graphics display starts at line VDB and ends at line 1440 1326 * VDE. If interlace mode off unit of VC-registers is ··· 1446 1332 if (var->vmode & FB_VMODE_DOUBLE) 1447 1333 var->yres >>= 1; 1448 1334 1449 - /* to get bpp, we must examine f_shift and st_shift. 1335 + /* 1336 + * to get bpp, we must examine f_shift and st_shift. 1450 1337 * f_shift is valid if any of bits no. 10, 8 or 4 1451 1338 * is set. Priority in f_shift is: 10 ">" 8 ">" 4, i.e. 1452 1339 * if bit 10 set then bit 8 and bit 4 don't care... 1453 1340 * If all these bits are 0 get display depth from st_shift 1454 1341 * (as for ST and STE) 1455 1342 */ 1456 - if (hw->f_shift & 0x400) /* 2 colors */ 1343 + if (hw->f_shift & 0x400) /* 2 colors */ 1457 1344 var->bits_per_pixel = 1; 1458 1345 else if (hw->f_shift & 0x100) /* hicolor */ 1459 1346 var->bits_per_pixel = 16; ··· 1464 1349 var->bits_per_pixel = 4; 1465 1350 else if (hw->st_shift == 0x100) 1466 1351 var->bits_per_pixel = 2; 1467 - else /* if (hw->st_shift == 0x200) */ 1352 + else /* if (hw->st_shift == 0x200) */ 1468 1353 var->bits_per_pixel = 1; 1469 1354 1470 1355 var->xres = hw->line_width * 16 / var->bits_per_pixel; ··· 1473 1358 var->xres_virtual += 16; 1474 1359 1475 1360 if (var->bits_per_pixel == 16) { 1476 - var->red.offset=11; 1477 - var->red.length=5; 1478 - var->red.msb_right=0; 1479 - var->green.offset=5; 1480 - var->green.length=6; 1481 - var->green.msb_right=0; 1482 - var->blue.offset=0; 1483 - var->blue.length=5; 1484 - var->blue.msb_right=0; 1485 - } 1486 - else { 1487 - var->red.offset=0; 1361 + var->red.offset = 11; 1362 + var->red.length = 5; 1363 + var->red.msb_right = 0; 1364 + var->green.offset = 5; 1365 + var->green.length = 6; 1366 + var->green.msb_right = 0; 1367 + var->blue.offset = 0; 1368 + var->blue.length = 5; 1369 + var->blue.msb_right = 0; 1370 + } else { 1371 + var->red.offset = 0; 1488 1372 var->red.length = hw->ste_mode ? 4 : 6; 1489 - var->red.msb_right=0; 1490 - var->grayscale=0; 1491 - var->blue=var->green=var->red; 1373 + if (var->red.length > var->bits_per_pixel) 1374 + var->red.length = var->bits_per_pixel; 1375 + var->red.msb_right = 0; 1376 + var->grayscale = 0; 1377 + var->blue = var->green = var->red; 1492 1378 } 1493 - var->transp.offset=0; 1494 - var->transp.length=0; 1495 - var->transp.msb_right=0; 1379 + var->transp.offset = 0; 1380 + var->transp.length = 0; 1381 + var->transp.msb_right = 0; 1496 1382 1497 1383 linelen = var->xres_virtual * var->bits_per_pixel / 8; 1498 1384 if (screen_len) { 1499 1385 if (par->yres_virtual) 1500 1386 var->yres_virtual = par->yres_virtual; 1501 1387 else 1502 - /* yres_virtual==0 means use maximum */ 1388 + /* yres_virtual == 0 means use maximum */ 1503 1389 var->yres_virtual = screen_len / linelen; 1504 - } 1505 - else { 1390 + } else { 1506 1391 if (hwscroll < 0) 1507 1392 var->yres_virtual = 2 * var->yres; 1508 1393 else 1509 - var->yres_virtual=var->yres+hwscroll * 16; 1394 + var->yres_virtual = var->yres + hwscroll * 16; 1510 1395 } 1511 - var->xoffset=0; /* TODO change this */ 1396 + var->xoffset = 0; /* TODO change this */ 1512 1397 1513 1398 /* hdX-offsets */ 1514 1399 prescale = hxx_prescale(hw); ··· 1517 1402 if (hw->f_shift & 0x100) { 1518 1403 hde_off = 0; 1519 1404 hdb_off = (base_off + 16 * plen) + prescale; 1520 - } 1521 - else { 1405 + } else { 1522 1406 hde_off = ((128 / var->bits_per_pixel + 2) * plen); 1523 1407 if (hw->ste_mode) 1524 1408 hdb_off = (64 + base_off + (128 / var->bits_per_pixel + 2) * plen) ··· 1529 1415 1530 1416 /* Right margin includes hsync */ 1531 1417 var->left_margin = hdb_off + prescale * ((hw->hdb & 0x1ff) - 1532 - (hw->hdb & 0x200 ? 2+hw->hht : 0)); 1533 - if (hw->ste_mode || mon_type!=F_MON_VGA) 1418 + (hw->hdb & 0x200 ? 2 + hw->hht : 0)); 1419 + if (hw->ste_mode || mon_type != F_MON_VGA) 1534 1420 var->right_margin = prescale * (hw->hht + 2 - hw->hde) - hde_off; 1535 1421 else 1536 1422 /* can't use this in ste_mode, because hbb is +1 off */ ··· 1538 1424 var->hsync_len = prescale * (hw->hht + 2 - hw->hss); 1539 1425 1540 1426 /* Lower margin includes vsync */ 1541 - var->upper_margin = hw->vdb / 2 ; /* round down to full lines */ 1542 - var->lower_margin = (hw->vft+1 - hw->vde + 1) / 2; /* round up */ 1543 - var->vsync_len = (hw->vft+1 - hw->vss + 1) / 2; /* round up */ 1427 + var->upper_margin = hw->vdb / 2; /* round down to full lines */ 1428 + var->lower_margin = (hw->vft + 1 - hw->vde + 1) / 2; /* round up */ 1429 + var->vsync_len = (hw->vft + 1 - hw->vss + 1) / 2; /* round up */ 1544 1430 if (var->vmode & FB_VMODE_INTERLACED) { 1545 1431 var->upper_margin *= 2; 1546 1432 var->lower_margin *= 2; 1547 1433 var->vsync_len *= 2; 1548 - } 1549 - else if (var->vmode & FB_VMODE_DOUBLE) { 1434 + } else if (var->vmode & FB_VMODE_DOUBLE) { 1550 1435 var->upper_margin = (var->upper_margin + 1) / 2; 1551 1436 var->lower_margin = (var->lower_margin + 1) / 2; 1552 1437 var->vsync_len = (var->vsync_len + 1) / 2; ··· 1560 1447 var->lower_margin -= var->vsync_len; 1561 1448 1562 1449 if (screen_base) 1563 - var->yoffset=(par->screen_base - screen_base)/linelen; 1450 + var->yoffset = (par->screen_base - screen_base) / linelen; 1564 1451 else 1565 - var->yoffset=0; 1566 - var->nonstd=0; /* what is this for? */ 1567 - var->activate=0; 1452 + var->yoffset = 0; 1453 + var->nonstd = 0; /* what is this for? */ 1454 + var->activate = 0; 1568 1455 return 0; 1569 1456 } 1570 1457 1571 - 1572 - static int f_change_mode = 0; 1458 + static int f_change_mode; 1573 1459 static struct falcon_hw f_new_mode; 1574 - static int f_pan_display = 0; 1460 + static int f_pan_display; 1575 1461 1576 - static void falcon_get_par( struct atafb_par *par ) 1462 + static void falcon_get_par(struct atafb_par *par) 1577 1463 { 1578 1464 unsigned long addr; 1579 1465 struct falcon_hw *hw = &par->hw.falcon; ··· 1604 1492 par->screen_base = phys_to_virt(addr); 1605 1493 1606 1494 /* derived parameters */ 1607 - hw->ste_mode = (hw->f_shift & 0x510)==0 && hw->st_shift==0x100; 1495 + hw->ste_mode = (hw->f_shift & 0x510) == 0 && hw->st_shift == 0x100; 1608 1496 hw->mono = (hw->f_shift & 0x400) || 1609 - ((hw->f_shift & 0x510)==0 && hw->st_shift==0x200); 1497 + ((hw->f_shift & 0x510) == 0 && hw->st_shift == 0x200); 1610 1498 } 1611 1499 1612 - static void falcon_set_par( struct atafb_par *par ) 1500 + static void falcon_set_par(struct atafb_par *par) 1613 1501 { 1614 1502 f_change_mode = 0; 1615 1503 ··· 1631 1519 f_change_mode = 1; 1632 1520 } 1633 1521 1634 - 1635 - static irqreturn_t falcon_vbl_switcher( int irq, void *dummy ) 1522 + static irqreturn_t falcon_vbl_switcher(int irq, void *dummy) 1636 1523 { 1637 1524 struct falcon_hw *hw = &f_new_mode; 1638 1525 ··· 1640 1529 1641 1530 if (hw->sync & 0x1) { 1642 1531 /* Enable external pixelclock. This code only for ScreenWonder */ 1643 - *(volatile unsigned short*)0xffff9202 = 0xffbf; 1644 - } 1645 - else { 1532 + *(volatile unsigned short *)0xffff9202 = 0xffbf; 1533 + } else { 1646 1534 /* Turn off external clocks. Read sets all output bits to 1. */ 1647 - *(volatile unsigned short*)0xffff9202; 1535 + *(volatile unsigned short *)0xffff9202; 1648 1536 } 1649 1537 shifter.syncmode = hw->sync; 1650 1538 ··· 1660 1550 videl.vde = hw->vde; 1661 1551 videl.vss = hw->vss; 1662 1552 1663 - videl.f_shift = 0; /* write enables Falcon palette, 0: 4 planes */ 1553 + videl.f_shift = 0; /* write enables Falcon palette, 0: 4 planes */ 1664 1554 if (hw->ste_mode) { 1665 - videl.st_shift = hw->st_shift; /* write enables STE palette */ 1666 - } 1667 - else { 1555 + videl.st_shift = hw->st_shift; /* write enables STE palette */ 1556 + } else { 1668 1557 /* IMPORTANT: 1669 - * set st_shift 0, so we can tell the screen-depth if f_shift==0. 1558 + * set st_shift 0, so we can tell the screen-depth if f_shift == 0. 1670 1559 * Writing 0 to f_shift enables 4 plane Falcon mode but 1671 - * doesn't set st_shift. st_shift!=0 (!=4planes) is impossible 1560 + * doesn't set st_shift. st_shift != 0 (!= 4planes) is impossible 1672 1561 * with Falcon palette. 1673 1562 */ 1674 1563 videl.st_shift = 0; ··· 1689 1580 return IRQ_HANDLED; 1690 1581 } 1691 1582 1692 - 1693 - static int falcon_pan_display( struct fb_var_screeninfo *var, 1694 - struct atafb_par *par ) 1583 + static int falcon_pan_display(struct fb_var_screeninfo *var, 1584 + struct fb_info *info) 1695 1585 { 1586 + struct atafb_par *par = (struct atafb_par *)info->par; 1587 + 1696 1588 int xoffset; 1697 - int bpp = fb_display[fb_info.currcon].var.bits_per_pixel; 1589 + int bpp = info->var.bits_per_pixel; 1698 1590 1699 1591 if (bpp == 1) 1700 1592 var->xoffset = up(var->xoffset, 32); ··· 1706 1596 var->xoffset = up(var->xoffset, 2); 1707 1597 } 1708 1598 par->hw.falcon.line_offset = bpp * 1709 - (fb_display[fb_info.currcon].var.xres_virtual - fb_display[fb_info.currcon].var.xres) / 16; 1599 + (info->var.xres_virtual - info->var.xres) / 16; 1710 1600 if (par->hw.falcon.xoffset) 1711 1601 par->hw.falcon.line_offset -= bpp; 1712 1602 xoffset = var->xoffset - par->hw.falcon.xoffset; 1713 1603 1714 1604 par->screen_base = screen_base + 1715 - (var->yoffset * fb_display[fb_info.currcon].var.xres_virtual + xoffset) * bpp / 8; 1605 + (var->yoffset * info->var.xres_virtual + xoffset) * bpp / 8; 1716 1606 if (fbhw->set_screen_base) 1717 - fbhw->set_screen_base (par->screen_base); 1607 + fbhw->set_screen_base(par->screen_base); 1718 1608 else 1719 - return -EINVAL; /* shouldn't happen */ 1609 + return -EINVAL; /* shouldn't happen */ 1720 1610 f_pan_display = 1; 1721 1611 return 0; 1722 1612 } 1723 1613 1724 - 1725 - static int falcon_getcolreg( unsigned regno, unsigned *red, 1726 - unsigned *green, unsigned *blue, 1727 - unsigned *transp, struct fb_info *info ) 1728 - { unsigned long col; 1729 - 1730 - if (regno > 255) 1731 - return 1; 1732 - /* This works in STE-mode (with 4bit/color) since f030_col-registers 1733 - * hold up to 6bit/color. 1734 - * Even with hicolor r/g/b=5/6/5 bit! 1735 - */ 1736 - col = f030_col[regno]; 1737 - *red = (col >> 16) & 0xff00; 1738 - *green = (col >> 8) & 0xff00; 1739 - *blue = (col << 8) & 0xff00; 1740 - *transp = 0; 1741 - return 0; 1742 - } 1743 - 1744 - 1745 - static int falcon_setcolreg( unsigned regno, unsigned red, 1746 - unsigned green, unsigned blue, 1747 - unsigned transp, struct fb_info *info ) 1614 + static int falcon_setcolreg(unsigned int regno, unsigned int red, 1615 + unsigned int green, unsigned int blue, 1616 + unsigned int transp, struct fb_info *info) 1748 1617 { 1749 1618 if (regno > 255) 1750 1619 return 1; ··· 1744 1655 return 0; 1745 1656 } 1746 1657 1747 - 1748 - static int falcon_blank( int blank_mode ) 1658 + static int falcon_blank(int blank_mode) 1749 1659 { 1750 - /* ++guenther: we can switch off graphics by changing VDB and VDE, 1751 - * so VIDEL doesn't hog the bus while saving. 1752 - * (this may affect usleep()). 1753 - */ 1660 + /* ++guenther: we can switch off graphics by changing VDB and VDE, 1661 + * so VIDEL doesn't hog the bus while saving. 1662 + * (this may affect usleep()). 1663 + */ 1754 1664 int vdb, vss, hbe, hss; 1755 1665 1756 1666 if (mon_type == F_MON_SM) /* this doesn't work on SM124 */ ··· 1782 1694 return 0; 1783 1695 } 1784 1696 1785 - 1786 - static int falcon_detect( void ) 1697 + static int falcon_detect(void) 1787 1698 { 1788 1699 struct atafb_par par; 1789 1700 unsigned char fhw; 1790 1701 1791 1702 /* Determine connected monitor and set monitor parameters */ 1792 - fhw = *(unsigned char*)0xffff8006; 1703 + fhw = *(unsigned char *)0xffff8006; 1793 1704 mon_type = fhw >> 6 & 0x3; 1794 1705 /* bit 1 of fhw: 1=32 bit ram bus, 0=16 bit */ 1795 1706 f030_bus_width = fhw << 6 & 0x80; ··· 1802 1715 case F_MON_SC: 1803 1716 case F_MON_TV: 1804 1717 /* PAL...NTSC */ 1805 - fb_info.monspecs.vfmin = 49; /* not 50, since TOS defaults to 49.9x Hz */ 1718 + fb_info.monspecs.vfmin = 49; /* not 50, since TOS defaults to 49.9x Hz */ 1806 1719 fb_info.monspecs.vfmax = 60; 1807 1720 fb_info.monspecs.hfmin = 15620; 1808 1721 fb_info.monspecs.hfmax = 15755; ··· 1827 1740 1828 1741 #ifdef ATAFB_STE 1829 1742 1830 - static int stste_encode_fix( struct fb_fix_screeninfo *fix, 1831 - struct atafb_par *par ) 1832 - 1743 + static int stste_encode_fix(struct fb_fix_screeninfo *fix, 1744 + struct atafb_par *par) 1833 1745 { 1834 1746 int mode; 1835 1747 1836 - strcpy(fix->id,"Atari Builtin"); 1748 + strcpy(fix->id, "Atari Builtin"); 1837 1749 fix->smem_start = (unsigned long)real_screen_base; 1838 1750 fix->smem_len = screen_len; 1839 1751 fix->type = FB_TYPE_INTERLEAVED_PLANES; ··· 1857 1771 return 0; 1858 1772 } 1859 1773 1860 - 1861 - static int stste_decode_var( struct fb_var_screeninfo *var, 1862 - struct atafb_par *par ) 1774 + static int stste_decode_var(struct fb_var_screeninfo *var, 1775 + struct atafb_par *par) 1863 1776 { 1864 - int xres=var->xres; 1865 - int yres=var->yres; 1866 - int bpp=var->bits_per_pixel; 1777 + int xres = var->xres; 1778 + int yres = var->yres; 1779 + int bpp = var->bits_per_pixel; 1867 1780 int linelen; 1868 1781 int yres_virtual = var->yres_virtual; 1869 1782 1870 1783 if (mono_moni) { 1871 1784 if (bpp > 1 || xres > sttt_xres || yres > st_yres) 1872 1785 return -EINVAL; 1873 - par->hw.st.mode=ST_HIGH; 1874 - xres=sttt_xres; 1875 - yres=st_yres; 1876 - bpp=1; 1786 + par->hw.st.mode = ST_HIGH; 1787 + xres = sttt_xres; 1788 + yres = st_yres; 1789 + bpp = 1; 1877 1790 } else { 1878 1791 if (bpp > 4 || xres > sttt_xres || yres > st_yres) 1879 1792 return -EINVAL; 1880 1793 if (bpp > 2) { 1881 - if (xres > sttt_xres/2 || yres > st_yres/2) 1794 + if (xres > sttt_xres / 2 || yres > st_yres / 2) 1882 1795 return -EINVAL; 1883 - par->hw.st.mode=ST_LOW; 1884 - xres=sttt_xres/2; 1885 - yres=st_yres/2; 1886 - bpp=4; 1887 - } 1888 - else if (bpp > 1) { 1889 - if (xres > sttt_xres || yres > st_yres/2) 1796 + par->hw.st.mode = ST_LOW; 1797 + xres = sttt_xres / 2; 1798 + yres = st_yres / 2; 1799 + bpp = 4; 1800 + } else if (bpp > 1) { 1801 + if (xres > sttt_xres || yres > st_yres / 2) 1890 1802 return -EINVAL; 1891 - par->hw.st.mode=ST_MID; 1892 - xres=sttt_xres; 1893 - yres=st_yres/2; 1894 - bpp=2; 1895 - } 1896 - else 1803 + par->hw.st.mode = ST_MID; 1804 + xres = sttt_xres; 1805 + yres = st_yres / 2; 1806 + bpp = 2; 1807 + } else 1897 1808 return -EINVAL; 1898 1809 } 1899 1810 if (yres_virtual <= 0) ··· 1898 1815 else if (yres_virtual < yres) 1899 1816 yres_virtual = yres; 1900 1817 if (var->sync & FB_SYNC_EXT) 1901 - par->hw.st.sync=(par->hw.st.sync & ~1) | 1; 1818 + par->hw.st.sync = (par->hw.st.sync & ~1) | 1; 1902 1819 else 1903 - par->hw.st.sync=(par->hw.st.sync & ~1); 1904 - linelen=xres*bpp/8; 1820 + par->hw.st.sync = (par->hw.st.sync & ~1); 1821 + linelen = xres * bpp / 8; 1905 1822 if (yres_virtual * linelen > screen_len && screen_len) 1906 1823 return -EINVAL; 1907 1824 if (yres * linelen > screen_len && screen_len) ··· 1909 1826 if (var->yoffset + yres > yres_virtual && yres_virtual) 1910 1827 return -EINVAL; 1911 1828 par->yres_virtual = yres_virtual; 1912 - par->screen_base=screen_base+ var->yoffset*linelen; 1829 + par->screen_base = screen_base + var->yoffset * linelen; 1913 1830 return 0; 1914 1831 } 1915 1832 1916 - static int stste_encode_var( struct fb_var_screeninfo *var, 1917 - struct atafb_par *par ) 1833 + static int stste_encode_var(struct fb_var_screeninfo *var, 1834 + struct atafb_par *par) 1918 1835 { 1919 1836 int linelen; 1920 1837 memset(var, 0, sizeof(struct fb_var_screeninfo)); 1921 - var->red.offset=0; 1838 + var->red.offset = 0; 1922 1839 var->red.length = ATARIHW_PRESENT(EXTD_SHIFTER) ? 4 : 3; 1923 - var->red.msb_right=0; 1924 - var->grayscale=0; 1840 + var->red.msb_right = 0; 1841 + var->grayscale = 0; 1925 1842 1926 - var->pixclock=31041; 1927 - var->left_margin=120; /* these are incorrect */ 1928 - var->right_margin=100; 1929 - var->upper_margin=8; 1930 - var->lower_margin=16; 1931 - var->hsync_len=140; 1932 - var->vsync_len=30; 1843 + var->pixclock = 31041; 1844 + var->left_margin = 120; /* these are incorrect */ 1845 + var->right_margin = 100; 1846 + var->upper_margin = 8; 1847 + var->lower_margin = 16; 1848 + var->hsync_len = 140; 1849 + var->vsync_len = 30; 1933 1850 1934 - var->height=-1; 1935 - var->width=-1; 1851 + var->height = -1; 1852 + var->width = -1; 1936 1853 1937 1854 if (!(par->hw.st.sync & 1)) 1938 - var->sync=0; 1855 + var->sync = 0; 1939 1856 else 1940 - var->sync=FB_SYNC_EXT; 1857 + var->sync = FB_SYNC_EXT; 1941 1858 1942 1859 switch (par->hw.st.mode & 3) { 1943 1860 case ST_LOW: 1944 - var->xres=sttt_xres/2; 1945 - var->yres=st_yres/2; 1946 - var->bits_per_pixel=4; 1861 + var->xres = sttt_xres / 2; 1862 + var->yres = st_yres / 2; 1863 + var->bits_per_pixel = 4; 1947 1864 break; 1948 1865 case ST_MID: 1949 - var->xres=sttt_xres; 1950 - var->yres=st_yres/2; 1951 - var->bits_per_pixel=2; 1866 + var->xres = sttt_xres; 1867 + var->yres = st_yres / 2; 1868 + var->bits_per_pixel = 2; 1952 1869 break; 1953 1870 case ST_HIGH: 1954 - var->xres=sttt_xres; 1955 - var->yres=st_yres; 1956 - var->bits_per_pixel=1; 1871 + var->xres = sttt_xres; 1872 + var->yres = st_yres; 1873 + var->bits_per_pixel = 1; 1957 1874 break; 1958 - } 1959 - var->blue=var->green=var->red; 1960 - var->transp.offset=0; 1961 - var->transp.length=0; 1962 - var->transp.msb_right=0; 1963 - var->xres_virtual=sttt_xres_virtual; 1964 - linelen=var->xres_virtual * var->bits_per_pixel / 8; 1965 - ovsc_addlen=linelen*(sttt_yres_virtual - st_yres); 1966 - 1967 - if (! use_hwscroll) 1968 - var->yres_virtual=var->yres; 1875 + } 1876 + var->blue = var->green = var->red; 1877 + var->transp.offset = 0; 1878 + var->transp.length = 0; 1879 + var->transp.msb_right = 0; 1880 + var->xres_virtual = sttt_xres_virtual; 1881 + linelen = var->xres_virtual * var->bits_per_pixel / 8; 1882 + ovsc_addlen = linelen * (sttt_yres_virtual - st_yres); 1883 + 1884 + if (!use_hwscroll) 1885 + var->yres_virtual = var->yres; 1969 1886 else if (screen_len) { 1970 1887 if (par->yres_virtual) 1971 1888 var->yres_virtual = par->yres_virtual; 1972 1889 else 1973 - /* yres_virtual==0 means use maximum */ 1890 + /* yres_virtual == 0 means use maximum */ 1974 1891 var->yres_virtual = screen_len / linelen; 1975 - } 1976 - else { 1892 + } else { 1977 1893 if (hwscroll < 0) 1978 1894 var->yres_virtual = 2 * var->yres; 1979 1895 else 1980 - var->yres_virtual=var->yres+hwscroll * 16; 1896 + var->yres_virtual = var->yres + hwscroll * 16; 1981 1897 } 1982 - var->xoffset=0; 1898 + var->xoffset = 0; 1983 1899 if (screen_base) 1984 - var->yoffset=(par->screen_base - screen_base)/linelen; 1900 + var->yoffset = (par->screen_base - screen_base) / linelen; 1985 1901 else 1986 - var->yoffset=0; 1987 - var->nonstd=0; 1988 - var->activate=0; 1989 - var->vmode=FB_VMODE_NONINTERLACED; 1902 + var->yoffset = 0; 1903 + var->nonstd = 0; 1904 + var->activate = 0; 1905 + var->vmode = FB_VMODE_NONINTERLACED; 1990 1906 return 0; 1991 1907 } 1992 1908 1993 - 1994 - static void stste_get_par( struct atafb_par *par ) 1909 + static void stste_get_par(struct atafb_par *par) 1995 1910 { 1996 1911 unsigned long addr; 1997 - par->hw.st.mode=shifter_tt.st_shiftmode; 1998 - par->hw.st.sync=shifter.syncmode; 1912 + par->hw.st.mode = shifter_tt.st_shiftmode; 1913 + par->hw.st.sync = shifter.syncmode; 1999 1914 addr = ((shifter.bas_hi & 0xff) << 16) | 2000 1915 ((shifter.bas_md & 0xff) << 8); 2001 1916 if (ATARIHW_PRESENT(EXTD_SHIFTER)) ··· 2001 1920 par->screen_base = phys_to_virt(addr); 2002 1921 } 2003 1922 2004 - static void stste_set_par( struct atafb_par *par ) 1923 + static void stste_set_par(struct atafb_par *par) 2005 1924 { 2006 - shifter_tt.st_shiftmode=par->hw.st.mode; 2007 - shifter.syncmode=par->hw.st.sync; 1925 + shifter_tt.st_shiftmode = par->hw.st.mode; 1926 + shifter.syncmode = par->hw.st.sync; 2008 1927 /* only set screen_base if really necessary */ 2009 1928 if (current_par.screen_base != par->screen_base) 2010 1929 fbhw->set_screen_base(par->screen_base); 2011 1930 } 2012 1931 2013 - 2014 - static int stste_getcolreg(unsigned regno, unsigned *red, 2015 - unsigned *green, unsigned *blue, 2016 - unsigned *transp, struct fb_info *info) 2017 - { 2018 - unsigned col, t; 2019 - 2020 - if (regno > 15) 2021 - return 1; 2022 - col = shifter_tt.color_reg[regno]; 2023 - if (ATARIHW_PRESENT(EXTD_SHIFTER)) { 2024 - t = ((col >> 7) & 0xe) | ((col >> 11) & 1); 2025 - t |= t << 4; 2026 - *red = t | (t << 8); 2027 - t = ((col >> 3) & 0xe) | ((col >> 7) & 1); 2028 - t |= t << 4; 2029 - *green = t | (t << 8); 2030 - t = ((col << 1) & 0xe) | ((col >> 3) & 1); 2031 - t |= t << 4; 2032 - *blue = t | (t << 8); 2033 - } 2034 - else { 2035 - t = (col >> 7) & 0xe; 2036 - t |= t << 4; 2037 - *red = t | (t << 8); 2038 - t = (col >> 3) & 0xe; 2039 - t |= t << 4; 2040 - *green = t | (t << 8); 2041 - t = (col << 1) & 0xe; 2042 - t |= t << 4; 2043 - *blue = t | (t << 8); 2044 - } 2045 - *transp = 0; 2046 - return 0; 2047 - } 2048 - 2049 - 2050 - static int stste_setcolreg(unsigned regno, unsigned red, 2051 - unsigned green, unsigned blue, 2052 - unsigned transp, struct fb_info *info) 1932 + static int stste_setcolreg(unsigned int regno, unsigned int red, 1933 + unsigned int green, unsigned int blue, 1934 + unsigned int transp, struct fb_info *info) 2053 1935 { 2054 1936 if (regno > 15) 2055 1937 return 1; ··· 2032 1988 return 0; 2033 1989 } 2034 1990 2035 - 2036 - static int stste_detect( void ) 2037 - 2038 - { struct atafb_par par; 1991 + static int stste_detect(void) 1992 + { 1993 + struct atafb_par par; 2039 1994 2040 1995 /* Determine the connected monitor: The DMA sound must be 2041 1996 * disabled before reading the MFP GPIP, because the Sound ··· 2042 1999 */ 2043 2000 if (ATARIHW_PRESENT(PCM_8BIT)) { 2044 2001 tt_dmasnd.ctrl = DMASND_CTRL_OFF; 2045 - udelay(20); /* wait a while for things to settle down */ 2002 + udelay(20); /* wait a while for things to settle down */ 2046 2003 } 2047 2004 mono_moni = (mfp.par_dt_reg & 0x80) == 0; 2048 2005 ··· 2057 2014 static void stste_set_screen_base(void *s_base) 2058 2015 { 2059 2016 unsigned long addr; 2060 - addr= virt_to_phys(s_base); 2017 + addr = virt_to_phys(s_base); 2061 2018 /* Setup Screen Memory */ 2062 - shifter.bas_hi=(unsigned char) ((addr & 0xff0000) >> 16); 2063 - shifter.bas_md=(unsigned char) ((addr & 0x00ff00) >> 8); 2019 + shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); 2020 + shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); 2064 2021 if (ATARIHW_PRESENT(EXTD_SHIFTER)) 2065 - shifter.bas_lo=(unsigned char) (addr & 0x0000ff); 2022 + shifter.bas_lo = (unsigned char)(addr & 0x0000ff); 2066 2023 } 2067 2024 2068 2025 #endif /* ATAFB_STE */ ··· 2088 2045 /* SWITCH_ACIA may be used for Falcon (ScreenBlaster III internal!) */ 2089 2046 static void st_ovsc_switch(void) 2090 2047 { 2091 - unsigned long flags; 2092 - register unsigned char old, new; 2048 + unsigned long flags; 2049 + register unsigned char old, new; 2093 2050 2094 - if (!(atari_switches & ATARI_SWITCH_OVSC_MASK)) 2095 - return; 2096 - local_irq_save(flags); 2051 + if (!(atari_switches & ATARI_SWITCH_OVSC_MASK)) 2052 + return; 2053 + local_irq_save(flags); 2097 2054 2098 - mfp.tim_ct_b = 0x10; 2099 - mfp.active_edge |= 8; 2100 - mfp.tim_ct_b = 0; 2101 - mfp.tim_dt_b = 0xf0; 2102 - mfp.tim_ct_b = 8; 2103 - while (mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */ 2104 - ; 2105 - new = mfp.tim_dt_b; 2106 - do { 2107 - udelay(LINE_DELAY); 2108 - old = new; 2055 + mfp.tim_ct_b = 0x10; 2056 + mfp.active_edge |= 8; 2057 + mfp.tim_ct_b = 0; 2058 + mfp.tim_dt_b = 0xf0; 2059 + mfp.tim_ct_b = 8; 2060 + while (mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */ 2061 + ; 2109 2062 new = mfp.tim_dt_b; 2110 - } while (old != new); 2111 - mfp.tim_ct_b = 0x10; 2112 - udelay(SYNC_DELAY); 2063 + do { 2064 + udelay(LINE_DELAY); 2065 + old = new; 2066 + new = mfp.tim_dt_b; 2067 + } while (old != new); 2068 + mfp.tim_ct_b = 0x10; 2069 + udelay(SYNC_DELAY); 2113 2070 2114 - if (atari_switches & ATARI_SWITCH_OVSC_IKBD) 2115 - acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID | ACIA_RIE; 2116 - if (atari_switches & ATARI_SWITCH_OVSC_MIDI) 2117 - acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID; 2118 - if (atari_switches & (ATARI_SWITCH_OVSC_SND6|ATARI_SWITCH_OVSC_SND7)) { 2119 - sound_ym.rd_data_reg_sel = 14; 2120 - sound_ym.wd_data = sound_ym.rd_data_reg_sel | 2121 - ((atari_switches&ATARI_SWITCH_OVSC_SND6) ? 0x40:0) | 2122 - ((atari_switches&ATARI_SWITCH_OVSC_SND7) ? 0x80:0); 2123 - } 2124 - local_irq_restore(flags); 2071 + if (atari_switches & ATARI_SWITCH_OVSC_IKBD) 2072 + acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID | ACIA_RIE; 2073 + if (atari_switches & ATARI_SWITCH_OVSC_MIDI) 2074 + acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID; 2075 + if (atari_switches & (ATARI_SWITCH_OVSC_SND6|ATARI_SWITCH_OVSC_SND7)) { 2076 + sound_ym.rd_data_reg_sel = 14; 2077 + sound_ym.wd_data = sound_ym.rd_data_reg_sel | 2078 + ((atari_switches & ATARI_SWITCH_OVSC_SND6) ? 0x40:0) | 2079 + ((atari_switches & ATARI_SWITCH_OVSC_SND7) ? 0x80:0); 2080 + } 2081 + local_irq_restore(flags); 2125 2082 } 2126 2083 2127 2084 /* ------------------- External Video ---------------------- */ 2128 2085 2129 2086 #ifdef ATAFB_EXT 2130 2087 2131 - static int ext_encode_fix( struct fb_fix_screeninfo *fix, 2132 - struct atafb_par *par ) 2133 - 2088 + static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) 2134 2089 { 2135 - strcpy(fix->id,"Unknown Extern"); 2090 + strcpy(fix->id, "Unknown Extern"); 2136 2091 fix->smem_start = (unsigned long)external_addr; 2137 2092 fix->smem_len = PAGE_ALIGN(external_len); 2138 2093 if (external_depth == 1) { ··· 2140 2099 fix->visual = 2141 2100 (external_pmode == FB_TYPE_INTERLEAVED_PLANES || 2142 2101 external_pmode == FB_TYPE_PACKED_PIXELS) ? 2143 - FB_VISUAL_MONO10 : 2144 - FB_VISUAL_MONO01; 2145 - } 2146 - else { 2102 + FB_VISUAL_MONO10 : FB_VISUAL_MONO01; 2103 + } else { 2147 2104 /* Use STATIC if we don't know how to access color registers */ 2148 2105 int visual = external_vgaiobase ? 2149 2106 FB_VISUAL_PSEUDOCOLOR : 2150 2107 FB_VISUAL_STATIC_PSEUDOCOLOR; 2151 2108 switch (external_pmode) { 2152 - case -1: /* truecolor */ 2153 - fix->type=FB_TYPE_PACKED_PIXELS; 2154 - fix->visual=FB_VISUAL_TRUECOLOR; 2109 + case -1: /* truecolor */ 2110 + fix->type = FB_TYPE_PACKED_PIXELS; 2111 + fix->visual = FB_VISUAL_TRUECOLOR; 2155 2112 break; 2156 - case FB_TYPE_PACKED_PIXELS: 2157 - fix->type=FB_TYPE_PACKED_PIXELS; 2158 - fix->visual=visual; 2113 + case FB_TYPE_PACKED_PIXELS: 2114 + fix->type = FB_TYPE_PACKED_PIXELS; 2115 + fix->visual = visual; 2159 2116 break; 2160 - case FB_TYPE_PLANES: 2161 - fix->type=FB_TYPE_PLANES; 2162 - fix->visual=visual; 2117 + case FB_TYPE_PLANES: 2118 + fix->type = FB_TYPE_PLANES; 2119 + fix->visual = visual; 2163 2120 break; 2164 - case FB_TYPE_INTERLEAVED_PLANES: 2165 - fix->type=FB_TYPE_INTERLEAVED_PLANES; 2166 - fix->type_aux=2; 2167 - fix->visual=visual; 2121 + case FB_TYPE_INTERLEAVED_PLANES: 2122 + fix->type = FB_TYPE_INTERLEAVED_PLANES; 2123 + fix->type_aux = 2; 2124 + fix->visual = visual; 2168 2125 break; 2169 2126 } 2170 2127 } ··· 2173 2134 return 0; 2174 2135 } 2175 2136 2176 - 2177 - static int ext_decode_var( struct fb_var_screeninfo *var, 2178 - struct atafb_par *par ) 2137 + static int ext_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) 2179 2138 { 2180 2139 struct fb_var_screeninfo *myvar = &atafb_predefined[0]; 2181 - 2140 + 2182 2141 if (var->bits_per_pixel > myvar->bits_per_pixel || 2183 - var->xres > myvar->xres || 2184 - var->xres_virtual > myvar->xres_virtual || 2185 - var->yres > myvar->yres || 2186 - var->xoffset > 0 || 2187 - var->yoffset > 0) 2142 + var->xres > myvar->xres || 2143 + var->xres_virtual > myvar->xres_virtual || 2144 + var->yres > myvar->yres || 2145 + var->xoffset > 0 || 2146 + var->yoffset > 0) 2188 2147 return -EINVAL; 2189 2148 return 0; 2190 2149 } 2191 2150 2192 - 2193 - static int ext_encode_var( struct fb_var_screeninfo *var, 2194 - struct atafb_par *par ) 2151 + static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) 2195 2152 { 2196 2153 memset(var, 0, sizeof(struct fb_var_screeninfo)); 2197 - var->red.offset=0; 2198 - var->red.length=(external_pmode == -1) ? external_depth/3 : 2154 + var->red.offset = 0; 2155 + var->red.length = (external_pmode == -1) ? external_depth / 3 : 2199 2156 (external_vgaiobase ? external_bitspercol : 0); 2200 - var->red.msb_right=0; 2201 - var->grayscale=0; 2157 + var->red.msb_right = 0; 2158 + var->grayscale = 0; 2202 2159 2203 - var->pixclock=31041; 2204 - var->left_margin=120; /* these are surely incorrect */ 2205 - var->right_margin=100; 2206 - var->upper_margin=8; 2207 - var->lower_margin=16; 2208 - var->hsync_len=140; 2209 - var->vsync_len=30; 2160 + var->pixclock = 31041; 2161 + var->left_margin = 120; /* these are surely incorrect */ 2162 + var->right_margin = 100; 2163 + var->upper_margin = 8; 2164 + var->lower_margin = 16; 2165 + var->hsync_len = 140; 2166 + var->vsync_len = 30; 2210 2167 2211 - var->height=-1; 2212 - var->width=-1; 2168 + var->height = -1; 2169 + var->width = -1; 2213 2170 2214 - var->sync=0; 2171 + var->sync = 0; 2215 2172 2216 2173 var->xres = external_xres; 2217 2174 var->yres = external_yres; 2218 2175 var->xres_virtual = external_xres_virtual; 2219 2176 var->bits_per_pixel = external_depth; 2220 - 2221 - var->blue=var->green=var->red; 2222 - var->transp.offset=0; 2223 - var->transp.length=0; 2224 - var->transp.msb_right=0; 2225 - var->yres_virtual=var->yres; 2226 - var->xoffset=0; 2227 - var->yoffset=0; 2228 - var->nonstd=0; 2229 - var->activate=0; 2230 - var->vmode=FB_VMODE_NONINTERLACED; 2177 + 2178 + var->blue = var->green = var->red; 2179 + var->transp.offset = 0; 2180 + var->transp.length = 0; 2181 + var->transp.msb_right = 0; 2182 + var->yres_virtual = var->yres; 2183 + var->xoffset = 0; 2184 + var->yoffset = 0; 2185 + var->nonstd = 0; 2186 + var->activate = 0; 2187 + var->vmode = FB_VMODE_NONINTERLACED; 2231 2188 return 0; 2232 2189 } 2233 2190 2234 - 2235 - static void ext_get_par( struct atafb_par *par ) 2191 + static void ext_get_par(struct atafb_par *par) 2236 2192 { 2237 2193 par->screen_base = external_addr; 2238 2194 } 2239 2195 2240 - static void ext_set_par( struct atafb_par *par ) 2196 + static void ext_set_par(struct atafb_par *par) 2241 2197 { 2242 2198 } 2243 2199 2244 2200 #define OUTB(port,val) \ 2245 - *((unsigned volatile char *) ((port)+external_vgaiobase))=(val) 2201 + *((unsigned volatile char *) ((port)+external_vgaiobase)) = (val) 2246 2202 #define INB(port) \ 2247 2203 (*((unsigned volatile char *) ((port)+external_vgaiobase))) 2248 - #define DACDelay \ 2204 + #define DACDelay \ 2249 2205 do { \ 2250 - unsigned char tmp=INB(0x3da); \ 2251 - tmp=INB(0x3da); \ 2206 + unsigned char tmp = INB(0x3da); \ 2207 + tmp = INB(0x3da); \ 2252 2208 } while (0) 2253 2209 2254 - static int ext_getcolreg( unsigned regno, unsigned *red, 2255 - unsigned *green, unsigned *blue, 2256 - unsigned *transp, struct fb_info *info ) 2210 + static int ext_setcolreg(unsigned int regno, unsigned int red, 2211 + unsigned int green, unsigned int blue, 2212 + unsigned int transp, struct fb_info *info) 2257 2213 { 2258 - if (! external_vgaiobase) 2214 + unsigned char colmask = (1 << external_bitspercol) - 1; 2215 + 2216 + if (!external_vgaiobase) 2259 2217 return 1; 2260 - 2261 - *red = ext_color[regno].red; 2262 - *green = ext_color[regno].green; 2263 - *blue = ext_color[regno].blue; 2264 - *transp=0; 2265 - return 0; 2266 - } 2267 - 2268 - static int ext_setcolreg( unsigned regno, unsigned red, 2269 - unsigned green, unsigned blue, 2270 - unsigned transp, struct fb_info *info ) 2271 - 2272 - { unsigned char colmask = (1 << external_bitspercol) - 1; 2273 - 2274 - if (! external_vgaiobase) 2275 - return 1; 2276 - 2277 - ext_color[regno].red = red; 2278 - ext_color[regno].green = green; 2279 - ext_color[regno].blue = blue; 2280 2218 2281 2219 switch (external_card_type) { 2282 - case IS_VGA: 2283 - OUTB(0x3c8, regno); 2284 - DACDelay; 2285 - OUTB(0x3c9, red & colmask); 2286 - DACDelay; 2287 - OUTB(0x3c9, green & colmask); 2288 - DACDelay; 2289 - OUTB(0x3c9, blue & colmask); 2290 - DACDelay; 2291 - return 0; 2220 + case IS_VGA: 2221 + OUTB(0x3c8, regno); 2222 + DACDelay; 2223 + OUTB(0x3c9, red & colmask); 2224 + DACDelay; 2225 + OUTB(0x3c9, green & colmask); 2226 + DACDelay; 2227 + OUTB(0x3c9, blue & colmask); 2228 + DACDelay; 2229 + return 0; 2292 2230 2293 - case IS_MV300: 2294 - OUTB((MV300_reg[regno] << 2)+1, red); 2295 - OUTB((MV300_reg[regno] << 2)+1, green); 2296 - OUTB((MV300_reg[regno] << 2)+1, blue); 2297 - return 0; 2231 + case IS_MV300: 2232 + OUTB((MV300_reg[regno] << 2) + 1, red); 2233 + OUTB((MV300_reg[regno] << 2) + 1, green); 2234 + OUTB((MV300_reg[regno] << 2) + 1, blue); 2235 + return 0; 2298 2236 2299 - default: 2300 - return 1; 2301 - } 2237 + default: 2238 + return 1; 2239 + } 2302 2240 } 2303 - 2304 2241 2305 - static int ext_detect( void ) 2306 - 2242 + static int ext_detect(void) 2307 2243 { 2308 2244 struct fb_var_screeninfo *myvar = &atafb_predefined[0]; 2309 2245 struct atafb_par dummy_par; ··· 2298 2284 static void set_screen_base(void *s_base) 2299 2285 { 2300 2286 unsigned long addr; 2301 - addr= virt_to_phys(s_base); 2287 + 2288 + addr = virt_to_phys(s_base); 2302 2289 /* Setup Screen Memory */ 2303 - shifter.bas_hi=(unsigned char) ((addr & 0xff0000) >> 16); 2304 - shifter.bas_md=(unsigned char) ((addr & 0x00ff00) >> 8); 2305 - shifter.bas_lo=(unsigned char) (addr & 0x0000ff); 2290 + shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); 2291 + shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); 2292 + shifter.bas_lo = (unsigned char)(addr & 0x0000ff); 2306 2293 } 2307 2294 2308 - 2309 - static int pan_display( struct fb_var_screeninfo *var, 2310 - struct atafb_par *par ) 2295 + static int pan_display(struct fb_var_screeninfo *var, struct fb_info *info) 2311 2296 { 2297 + struct atafb_par *par = (struct atafb_par *)info->par; 2298 + 2312 2299 if (!fbhw->set_screen_base || 2313 - (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset)) 2300 + (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset)) 2314 2301 return -EINVAL; 2315 2302 var->xoffset = up(var->xoffset, 16); 2316 2303 par->screen_base = screen_base + 2317 - (var->yoffset * fb_display[fb_info.currcon].var.xres_virtual + var->xoffset) 2318 - * fb_display[fb_info.currcon].var.bits_per_pixel / 8; 2319 - fbhw->set_screen_base (par->screen_base); 2304 + (var->yoffset * info->var.xres_virtual + var->xoffset) 2305 + * info->var.bits_per_pixel / 8; 2306 + fbhw->set_screen_base(par->screen_base); 2320 2307 return 0; 2321 2308 } 2322 2309 2323 - 2324 2310 /* ------------ Interfaces to hardware functions ------------ */ 2325 - 2326 2311 2327 2312 #ifdef ATAFB_TT 2328 2313 static struct fb_hwswitch tt_switch = { 2329 - tt_detect, tt_encode_fix, tt_decode_var, tt_encode_var, 2330 - tt_get_par, tt_set_par, tt_getcolreg, 2331 - set_screen_base, NULL, pan_display 2314 + .detect = tt_detect, 2315 + .encode_fix = tt_encode_fix, 2316 + .decode_var = tt_decode_var, 2317 + .encode_var = tt_encode_var, 2318 + .get_par = tt_get_par, 2319 + .set_par = tt_set_par, 2320 + .set_screen_base = set_screen_base, 2321 + .pan_display = pan_display, 2332 2322 }; 2333 2323 #endif 2334 2324 2335 2325 #ifdef ATAFB_FALCON 2336 2326 static struct fb_hwswitch falcon_switch = { 2337 - falcon_detect, falcon_encode_fix, falcon_decode_var, falcon_encode_var, 2338 - falcon_get_par, falcon_set_par, falcon_getcolreg, 2339 - set_screen_base, falcon_blank, falcon_pan_display 2327 + .detect = falcon_detect, 2328 + .encode_fix = falcon_encode_fix, 2329 + .decode_var = falcon_decode_var, 2330 + .encode_var = falcon_encode_var, 2331 + .get_par = falcon_get_par, 2332 + .set_par = falcon_set_par, 2333 + .set_screen_base = set_screen_base, 2334 + .blank = falcon_blank, 2335 + .pan_display = falcon_pan_display, 2340 2336 }; 2341 2337 #endif 2342 2338 2343 2339 #ifdef ATAFB_STE 2344 2340 static struct fb_hwswitch st_switch = { 2345 - stste_detect, stste_encode_fix, stste_decode_var, stste_encode_var, 2346 - stste_get_par, stste_set_par, stste_getcolreg, 2347 - stste_set_screen_base, NULL, pan_display 2341 + .detect = stste_detect, 2342 + .encode_fix = stste_encode_fix, 2343 + .decode_var = stste_decode_var, 2344 + .encode_var = stste_encode_var, 2345 + .get_par = stste_get_par, 2346 + .set_par = stste_set_par, 2347 + .set_screen_base = stste_set_screen_base, 2348 + .pan_display = pan_display 2348 2349 }; 2349 2350 #endif 2350 2351 2351 2352 #ifdef ATAFB_EXT 2352 2353 static struct fb_hwswitch ext_switch = { 2353 - ext_detect, ext_encode_fix, ext_decode_var, ext_encode_var, 2354 - ext_get_par, ext_set_par, ext_getcolreg, NULL, NULL, NULL 2354 + .detect = ext_detect, 2355 + .encode_fix = ext_encode_fix, 2356 + .decode_var = ext_decode_var, 2357 + .encode_var = ext_encode_var, 2358 + .get_par = ext_get_par, 2359 + .set_par = ext_set_par, 2355 2360 }; 2356 2361 #endif 2357 2362 2358 - 2359 - 2360 - static void atafb_get_par( struct atafb_par *par ) 2363 + static void ata_get_par(struct atafb_par *par) 2361 2364 { 2362 - if (current_par_valid) { 2363 - *par=current_par; 2364 - } 2365 + if (current_par_valid) 2366 + *par = current_par; 2365 2367 else 2366 2368 fbhw->get_par(par); 2367 2369 } 2368 2370 2369 - 2370 - static void atafb_set_par( struct atafb_par *par ) 2371 + static void ata_set_par(struct atafb_par *par) 2371 2372 { 2372 2373 fbhw->set_par(par); 2373 - current_par=*par; 2374 - current_par_valid=1; 2374 + current_par = *par; 2375 + current_par_valid = 1; 2375 2376 } 2376 - 2377 2377 2378 2378 2379 2379 /* =========================================================== */ 2380 2380 /* ============== Hardware Independent Functions ============= */ 2381 2381 /* =========================================================== */ 2382 2382 2383 - 2384 2383 /* used for hardware scrolling */ 2385 2384 2386 - static int 2387 - fb_update_var(int con, struct fb_info *info) 2385 + static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive) 2388 2386 { 2389 - int off=fb_display[con].var.yoffset*fb_display[con].var.xres_virtual* 2390 - fb_display[con].var.bits_per_pixel>>3; 2391 - 2392 - current_par.screen_base=screen_base + off; 2393 - 2394 - if (fbhw->set_screen_base) 2395 - fbhw->set_screen_base(current_par.screen_base); 2396 - return 0; 2397 - } 2398 - 2399 - static int 2400 - do_fb_set_var(struct fb_var_screeninfo *var, int isactive) 2401 - { 2402 - int err,activate; 2387 + int err, activate; 2403 2388 struct atafb_par par; 2404 - if ((err=fbhw->decode_var(var, &par))) 2389 + 2390 + err = fbhw->decode_var(var, &par); 2391 + if (err) 2405 2392 return err; 2406 - activate=var->activate; 2393 + activate = var->activate; 2407 2394 if (((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive) 2408 - atafb_set_par(&par); 2395 + ata_set_par(&par); 2409 2396 fbhw->encode_var(var, &par); 2410 - var->activate=activate; 2397 + var->activate = activate; 2411 2398 return 0; 2412 2399 } 2413 2400 2414 - static int 2415 - atafb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) 2401 + static int atafb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info) 2416 2402 { 2417 2403 struct atafb_par par; 2418 - if (con == -1) 2419 - atafb_get_par(&par); 2420 - else { 2421 - int err; 2422 - if ((err=fbhw->decode_var(&fb_display[con].var,&par))) 2423 - return err; 2424 - } 2404 + int err; 2405 + // Get fix directly (case con == -1 before)?? 2406 + err = fbhw->decode_var(&info->var, &par); 2407 + if (err) 2408 + return err; 2425 2409 memset(fix, 0, sizeof(struct fb_fix_screeninfo)); 2426 2410 return fbhw->encode_fix(fix, &par); 2427 2411 } 2428 - 2429 - static int 2430 - atafb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) 2412 + 2413 + static int atafb_get_var(struct fb_var_screeninfo *var, struct fb_info *info) 2431 2414 { 2432 2415 struct atafb_par par; 2433 - if (con == -1) { 2434 - atafb_get_par(&par); 2435 - fbhw->encode_var(var, &par); 2436 - } 2437 - else 2438 - *var=fb_display[con].var; 2416 + 2417 + ata_get_par(&par); 2418 + fbhw->encode_var(var, &par); 2419 + 2439 2420 return 0; 2440 2421 } 2441 2422 2442 - static void 2443 - atafb_set_disp(int con, struct fb_info *info) 2423 + // No longer called by fbcon! 2424 + // Still called by set_var internally 2425 + 2426 + static void atafb_set_disp(struct fb_info *info) 2444 2427 { 2445 - struct fb_fix_screeninfo fix; 2446 - struct fb_var_screeninfo var; 2447 - struct display *display; 2428 + atafb_get_var(&info->var, info); 2429 + atafb_get_fix(&info->fix, info); 2448 2430 2449 - if (con >= 0) 2450 - display = &fb_display[con]; 2451 - else 2452 - display = &disp; /* used during initialization */ 2431 + info->screen_base = (void *)info->fix.smem_start; 2453 2432 2454 - atafb_get_fix(&fix, con, info); 2455 - atafb_get_var(&var, con, info); 2456 - if (con == -1) 2457 - con=0; 2458 - info->screen_base = (void *)fix.smem_start; 2459 - display->visual = fix.visual; 2460 - display->type = fix.type; 2461 - display->type_aux = fix.type_aux; 2462 - display->ypanstep = fix.ypanstep; 2463 - display->ywrapstep = fix.ywrapstep; 2464 - display->line_length = fix.line_length; 2465 - if (fix.visual != FB_VISUAL_PSEUDOCOLOR && 2466 - fix.visual != FB_VISUAL_DIRECTCOLOR) 2467 - display->can_soft_blank = 0; 2468 - else 2469 - display->can_soft_blank = 1; 2470 - display->inverse = 2471 - (fix.visual == FB_VISUAL_MONO01 ? !inverse : inverse); 2472 - switch (fix.type) { 2473 - case FB_TYPE_INTERLEAVED_PLANES: 2474 - switch (var.bits_per_pixel) { 2475 - #ifdef FBCON_HAS_IPLAN2P2 2476 - case 2: 2477 - display->dispsw = &fbcon_iplan2p2; 2433 + switch (info->fix.type) { 2434 + case FB_TYPE_INTERLEAVED_PLANES: 2435 + switch (info->var.bits_per_pixel) { 2436 + case 2: 2437 + // display->dispsw = &fbcon_iplan2p2; 2478 2438 break; 2479 - #endif 2480 - #ifdef FBCON_HAS_IPLAN2P4 2481 - case 4: 2482 - display->dispsw = &fbcon_iplan2p4; 2439 + case 4: 2440 + // display->dispsw = &fbcon_iplan2p4; 2483 2441 break; 2484 - #endif 2485 - #ifdef FBCON_HAS_IPLAN2P8 2486 - case 8: 2487 - display->dispsw = &fbcon_iplan2p8; 2442 + case 8: 2443 + // display->dispsw = &fbcon_iplan2p8; 2488 2444 break; 2489 - #endif 2490 2445 } 2491 2446 break; 2492 - case FB_TYPE_PACKED_PIXELS: 2493 - switch (var.bits_per_pixel) { 2447 + case FB_TYPE_PACKED_PIXELS: 2448 + switch (info->var.bits_per_pixel) { 2494 2449 #ifdef FBCON_HAS_MFB 2495 - case 1: 2496 - display->dispsw = &fbcon_mfb; 2450 + case 1: 2451 + // display->dispsw = &fbcon_mfb; 2497 2452 break; 2498 2453 #endif 2499 2454 #ifdef FBCON_HAS_CFB8 2500 - case 8: 2501 - display->dispsw = &fbcon_cfb8; 2455 + case 8: 2456 + // display->dispsw = &fbcon_cfb8; 2502 2457 break; 2503 2458 #endif 2504 2459 #ifdef FBCON_HAS_CFB16 2505 - case 16: 2506 - display->dispsw = &fbcon_cfb16; 2507 - display->dispsw_data = fbcon_cfb16_cmap; 2460 + case 16: 2461 + // display->dispsw = &fbcon_cfb16; 2462 + // display->dispsw_data = fbcon_cfb16_cmap; 2508 2463 break; 2509 2464 #endif 2510 2465 } ··· 2481 2498 } 2482 2499 } 2483 2500 2484 - static int 2485 - atafb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) 2501 + static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, 2502 + u_int transp, struct fb_info *info) 2486 2503 { 2487 - int err,oldxres,oldyres,oldbpp,oldxres_virtual, 2488 - oldyres_virtual,oldyoffset; 2489 - if ((err=do_fb_set_var(var, con==info->currcon))) 2490 - return err; 2491 - if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) { 2492 - oldxres=fb_display[con].var.xres; 2493 - oldyres=fb_display[con].var.yres; 2494 - oldxres_virtual=fb_display[con].var.xres_virtual; 2495 - oldyres_virtual=fb_display[con].var.yres_virtual; 2496 - oldbpp=fb_display[con].var.bits_per_pixel; 2497 - oldyoffset=fb_display[con].var.yoffset; 2498 - fb_display[con].var=*var; 2499 - if (oldxres != var->xres || oldyres != var->yres 2500 - || oldxres_virtual != var->xres_virtual 2501 - || oldyres_virtual != var->yres_virtual 2502 - || oldbpp != var->bits_per_pixel 2503 - || oldyoffset != var->yoffset) { 2504 - atafb_set_disp(con, info); 2505 - (*fb_info.changevar)(con); 2506 - fb_alloc_cmap(&fb_display[con].cmap, 0, 0); 2507 - do_install_cmap(con, info); 2508 - } 2509 - } 2510 - var->activate=0; 2511 - return 0; 2512 - } 2504 + red >>= 8; 2505 + green >>= 8; 2506 + blue >>= 8; 2513 2507 2514 - 2515 - 2516 - static int 2517 - atafb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) 2518 - { 2519 - if (con == info->currcon) /* current console ? */ 2520 - return fb_get_cmap(cmap, kspc, fbhw->getcolreg, info); 2521 - else 2522 - if (fb_display[con].cmap.len) /* non default colormap ? */ 2523 - fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2); 2524 - else 2525 - fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), 2526 - cmap, kspc ? 0 : 2); 2527 - return 0; 2508 + return info->fbops->fb_setcolreg(regno, red, green, blue, transp, info); 2528 2509 } 2529 2510 2530 2511 static int 2531 - atafb_pan_display(struct fb_var_screeninfo *var, int con, struct fb_info *info) 2512 + atafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) 2532 2513 { 2533 2514 int xoffset = var->xoffset; 2534 2515 int yoffset = var->yoffset; 2535 2516 int err; 2536 2517 2537 - if ( xoffset < 0 || xoffset + fb_display[con].var.xres > fb_display[con].var.xres_virtual 2538 - || yoffset < 0 || yoffset + fb_display[con].var.yres > fb_display[con].var.yres_virtual) 2539 - return -EINVAL; 2540 - 2541 - if (con == info->currcon) { 2542 - if (fbhw->pan_display) { 2543 - if ((err = fbhw->pan_display(var, &current_par))) 2544 - return err; 2545 - } 2546 - else 2518 + if (var->vmode & FB_VMODE_YWRAP) { 2519 + if (yoffset < 0 || yoffset >= info->var.yres_virtual || xoffset) 2520 + return -EINVAL; 2521 + } else { 2522 + if (xoffset + info->var.xres > info->var.xres_virtual || 2523 + yoffset + info->var.yres > info->var.yres_virtual) 2547 2524 return -EINVAL; 2548 2525 } 2549 - fb_display[con].var.xoffset = var->xoffset; 2550 - fb_display[con].var.yoffset = var->yoffset; 2526 + 2527 + if (fbhw->pan_display) { 2528 + err = fbhw->pan_display(var, info); 2529 + if (err) 2530 + return err; 2531 + } else 2532 + return -EINVAL; 2533 + 2534 + info->var.xoffset = xoffset; 2535 + info->var.yoffset = yoffset; 2536 + 2537 + if (var->vmode & FB_VMODE_YWRAP) 2538 + info->var.vmode |= FB_VMODE_YWRAP; 2539 + else 2540 + info->var.vmode &= ~FB_VMODE_YWRAP; 2541 + 2551 2542 return 0; 2543 + } 2544 + 2545 + /* 2546 + * generic drawing routines; imageblit needs updating for image depth > 1 2547 + */ 2548 + 2549 + #if BITS_PER_LONG == 32 2550 + #define BYTES_PER_LONG 4 2551 + #define SHIFT_PER_LONG 5 2552 + #elif BITS_PER_LONG == 64 2553 + #define BYTES_PER_LONG 8 2554 + #define SHIFT_PER_LONG 6 2555 + #else 2556 + #define Please update me 2557 + #endif 2558 + 2559 + 2560 + static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) 2561 + { 2562 + struct atafb_par *par = (struct atafb_par *)info->par; 2563 + int x2, y2; 2564 + u32 width, height; 2565 + 2566 + if (!rect->width || !rect->height) 2567 + return; 2568 + 2569 + /* 2570 + * We could use hardware clipping but on many cards you get around 2571 + * hardware clipping by writing to framebuffer directly. 2572 + * */ 2573 + x2 = rect->dx + rect->width; 2574 + y2 = rect->dy + rect->height; 2575 + x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; 2576 + y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; 2577 + width = x2 - rect->dx; 2578 + height = y2 - rect->dy; 2579 + 2580 + if (info->var.bits_per_pixel == 1) 2581 + atafb_mfb_fillrect(info, par->next_line, rect->color, 2582 + rect->dy, rect->dx, height, width); 2583 + else if (info->var.bits_per_pixel == 2) 2584 + atafb_iplan2p2_fillrect(info, par->next_line, rect->color, 2585 + rect->dy, rect->dx, height, width); 2586 + else if (info->var.bits_per_pixel == 4) 2587 + atafb_iplan2p4_fillrect(info, par->next_line, rect->color, 2588 + rect->dy, rect->dx, height, width); 2589 + else 2590 + atafb_iplan2p8_fillrect(info, par->next_line, rect->color, 2591 + rect->dy, rect->dx, height, width); 2592 + 2593 + return; 2594 + } 2595 + 2596 + static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area) 2597 + { 2598 + struct atafb_par *par = (struct atafb_par *)info->par; 2599 + int x2, y2; 2600 + u32 dx, dy, sx, sy, width, height; 2601 + int rev_copy = 0; 2602 + 2603 + /* clip the destination */ 2604 + x2 = area->dx + area->width; 2605 + y2 = area->dy + area->height; 2606 + dx = area->dx > 0 ? area->dx : 0; 2607 + dy = area->dy > 0 ? area->dy : 0; 2608 + x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; 2609 + y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; 2610 + width = x2 - dx; 2611 + height = y2 - dy; 2612 + 2613 + /* update sx,sy */ 2614 + sx = area->sx + (dx - area->dx); 2615 + sy = area->sy + (dy - area->dy); 2616 + 2617 + /* the source must be completely inside the virtual screen */ 2618 + if (sx < 0 || sy < 0 || (sx + width) > info->var.xres_virtual || 2619 + (sy + height) > info->var.yres_virtual) 2620 + return; 2621 + 2622 + if (dy > sy || (dy == sy && dx > sx)) { 2623 + dy += height; 2624 + sy += height; 2625 + rev_copy = 1; 2626 + } 2627 + 2628 + if (info->var.bits_per_pixel == 1) 2629 + atafb_mfb_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); 2630 + else if (info->var.bits_per_pixel == 2) 2631 + atafb_iplan2p2_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); 2632 + else if (info->var.bits_per_pixel == 4) 2633 + atafb_iplan2p4_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); 2634 + else 2635 + atafb_iplan2p8_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); 2636 + 2637 + return; 2638 + } 2639 + 2640 + static void atafb_imageblit(struct fb_info *info, const struct fb_image *image) 2641 + { 2642 + struct atafb_par *par = (struct atafb_par *)info->par; 2643 + int x2, y2; 2644 + unsigned long *dst; 2645 + int dst_idx; 2646 + const char *src; 2647 + u32 dx, dy, width, height, pitch; 2648 + 2649 + /* 2650 + * We could use hardware clipping but on many cards you get around 2651 + * hardware clipping by writing to framebuffer directly like we are 2652 + * doing here. 2653 + */ 2654 + x2 = image->dx + image->width; 2655 + y2 = image->dy + image->height; 2656 + dx = image->dx; 2657 + dy = image->dy; 2658 + x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; 2659 + y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; 2660 + width = x2 - dx; 2661 + height = y2 - dy; 2662 + 2663 + if (image->depth == 1) { 2664 + // used for font data 2665 + dst = (unsigned long *) 2666 + ((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1)); 2667 + dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8; 2668 + dst_idx += dy * par->next_line * 8 + dx; 2669 + src = image->data; 2670 + pitch = (image->width + 7) / 8; 2671 + while (height--) { 2672 + 2673 + if (info->var.bits_per_pixel == 1) 2674 + atafb_mfb_linefill(info, par->next_line, 2675 + dy, dx, width, src, 2676 + image->bg_color, image->fg_color); 2677 + else if (info->var.bits_per_pixel == 2) 2678 + atafb_iplan2p2_linefill(info, par->next_line, 2679 + dy, dx, width, src, 2680 + image->bg_color, image->fg_color); 2681 + else if (info->var.bits_per_pixel == 4) 2682 + atafb_iplan2p4_linefill(info, par->next_line, 2683 + dy, dx, width, src, 2684 + image->bg_color, image->fg_color); 2685 + else 2686 + atafb_iplan2p8_linefill(info, par->next_line, 2687 + dy, dx, width, src, 2688 + image->bg_color, image->fg_color); 2689 + dy++; 2690 + src += pitch; 2691 + } 2692 + } else { 2693 + // only used for logo; broken 2694 + c2p(info->screen_base, image->data, dx, dy, width, height, 2695 + par->next_line, par->next_plane, image->width, 2696 + info->var.bits_per_pixel); 2697 + } 2552 2698 } 2553 2699 2554 2700 static int ··· 2696 2584 if (copy_from_user((void *)&current_par, (void *)arg, 2697 2585 sizeof(struct atafb_par))) 2698 2586 return -EFAULT; 2699 - atafb_set_par(&current_par); 2587 + ata_set_par(&current_par); 2700 2588 return 0; 2701 2589 #endif 2702 2590 } ··· 2710 2598 * 3 = suspend hsync 2711 2599 * 4 = off 2712 2600 */ 2713 - static int 2714 - atafb_blank(int blank, struct fb_info *info) 2601 + static int atafb_blank(int blank, struct fb_info *info) 2715 2602 { 2716 2603 unsigned short black[16]; 2717 2604 struct fb_cmap cmap; 2718 2605 if (fbhw->blank && !fbhw->blank(blank)) 2719 2606 return 1; 2720 2607 if (blank) { 2721 - memset(black, 0, 16*sizeof(unsigned short)); 2722 - cmap.red=black; 2723 - cmap.green=black; 2724 - cmap.blue=black; 2725 - cmap.transp=NULL; 2726 - cmap.start=0; 2727 - cmap.len=16; 2728 - fb_set_cmap(&cmap, 1, info); 2608 + memset(black, 0, 16 * sizeof(unsigned short)); 2609 + cmap.red = black; 2610 + cmap.green = black; 2611 + cmap.blue = black; 2612 + cmap.transp = NULL; 2613 + cmap.start = 0; 2614 + cmap.len = 16; 2615 + fb_set_cmap(&cmap, info); 2729 2616 } 2617 + #if 0 2730 2618 else 2731 - do_install_cmap(info->currcon, info); 2619 + do_install_cmap(info); 2620 + #endif 2732 2621 return 0; 2733 2622 } 2734 2623 2624 + /* 2625 + * New fbcon interface ... 2626 + */ 2627 + 2628 + /* check var by decoding var into hw par, rounding if necessary, 2629 + * then encoding hw par back into new, validated var */ 2630 + static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 2631 + { 2632 + int err; 2633 + struct atafb_par par; 2634 + 2635 + /* Validate wanted screen parameters */ 2636 + // if ((err = ata_decode_var(var, &par))) 2637 + err = fbhw->decode_var(var, &par); 2638 + if (err) 2639 + return err; 2640 + 2641 + /* Encode (possibly rounded) screen parameters */ 2642 + fbhw->encode_var(var, &par); 2643 + return 0; 2644 + } 2645 + 2646 + /* actually set hw par by decoding var, then setting hardware from 2647 + * hw par just decoded */ 2648 + static int atafb_set_par(struct fb_info *info) 2649 + { 2650 + struct atafb_par *par = (struct atafb_par *)info->par; 2651 + 2652 + /* Decode wanted screen parameters */ 2653 + fbhw->decode_var(&info->var, par); 2654 + fbhw->encode_fix(&info->fix, par); 2655 + 2656 + /* Set new videomode */ 2657 + ata_set_par(par); 2658 + 2659 + return 0; 2660 + } 2661 + 2662 + 2735 2663 static struct fb_ops atafb_ops = { 2736 2664 .owner = THIS_MODULE, 2737 - .fb_get_fix = atafb_get_fix, 2738 - .fb_get_var = atafb_get_var, 2739 - .fb_set_var = atafb_set_var, 2740 - .fb_get_cmap = atafb_get_cmap, 2741 - .fb_set_cmap = gen_set_cmap, 2742 - .fb_pan_display =atafb_pan_display, 2665 + .fb_check_var = atafb_check_var, 2666 + .fb_set_par = atafb_set_par, 2667 + .fb_setcolreg = atafb_setcolreg, 2743 2668 .fb_blank = atafb_blank, 2669 + .fb_pan_display = atafb_pan_display, 2670 + .fb_fillrect = atafb_fillrect, 2671 + .fb_copyarea = atafb_copyarea, 2672 + .fb_imageblit = atafb_imageblit, 2744 2673 .fb_ioctl = atafb_ioctl, 2745 2674 }; 2746 2675 2747 - static void 2748 - check_default_par( int detected_mode ) 2676 + static void check_default_par(int detected_mode) 2749 2677 { 2750 2678 char default_name[10]; 2751 2679 int i; ··· 2794 2642 2795 2643 /* First try the user supplied mode */ 2796 2644 if (default_par) { 2797 - var=atafb_predefined[default_par-1]; 2645 + var = atafb_predefined[default_par - 1]; 2798 2646 var.activate = FB_ACTIVATE_TEST; 2799 - if (do_fb_set_var(&var,1)) 2800 - default_par=0; /* failed */ 2647 + if (do_fb_set_var(&var, 1)) 2648 + default_par = 0; /* failed */ 2801 2649 } 2802 2650 /* Next is the autodetected one */ 2803 - if (! default_par) { 2804 - var=atafb_predefined[detected_mode-1]; /* autodetect */ 2651 + if (!default_par) { 2652 + var = atafb_predefined[detected_mode - 1]; /* autodetect */ 2805 2653 var.activate = FB_ACTIVATE_TEST; 2806 - if (!do_fb_set_var(&var,1)) 2807 - default_par=detected_mode; 2654 + if (!do_fb_set_var(&var, 1)) 2655 + default_par = detected_mode; 2808 2656 } 2809 2657 /* If that also failed, try some default modes... */ 2810 - if (! default_par) { 2658 + if (!default_par) { 2811 2659 /* try default1, default2... */ 2812 - for (i=1 ; i < 10 ; i++) { 2813 - sprintf(default_name,"default%d",i); 2814 - default_par=get_video_mode(default_name); 2815 - if (! default_par) 2660 + for (i = 1; i < 10; i++) { 2661 + sprintf(default_name,"default%d", i); 2662 + default_par = get_video_mode(default_name); 2663 + if (!default_par) 2816 2664 panic("can't set default video mode"); 2817 - var=atafb_predefined[default_par-1]; 2665 + var = atafb_predefined[default_par - 1]; 2818 2666 var.activate = FB_ACTIVATE_TEST; 2819 - if (! do_fb_set_var(&var,1)) 2667 + if (!do_fb_set_var(&var,1)) 2820 2668 break; /* ok */ 2821 2669 } 2822 2670 } 2823 - min_mem=var.xres_virtual * var.yres_virtual * var.bits_per_pixel/8; 2671 + min_mem = var.xres_virtual * var.yres_virtual * var.bits_per_pixel / 8; 2824 2672 if (default_mem_req < min_mem) 2825 - default_mem_req=min_mem; 2673 + default_mem_req = min_mem; 2826 2674 } 2827 - 2828 - static int 2829 - atafb_switch(int con, struct fb_info *info) 2830 - { 2831 - /* Do we have to save the colormap ? */ 2832 - if (fb_display[info->currcon].cmap.len) 2833 - fb_get_cmap(&fb_display[info->currcon].cmap, 1, fbhw->getcolreg, 2834 - info); 2835 - do_fb_set_var(&fb_display[con].var,1); 2836 - info->currcon=con; 2837 - /* Install new colormap */ 2838 - do_install_cmap(con, info); 2839 - return 0; 2840 - } 2841 - 2842 - int __init atafb_init(void) 2843 - { 2844 - int pad; 2845 - int detected_mode; 2846 - unsigned long mem_req; 2847 - 2848 - if (!MACH_IS_ATARI) 2849 - return -ENXIO; 2850 - 2851 - do { 2852 - #ifdef ATAFB_EXT 2853 - if (external_addr) { 2854 - fbhw = &ext_switch; 2855 - atafb_ops.fb_setcolreg = &ext_setcolreg; 2856 - break; 2857 - } 2858 - #endif 2859 - #ifdef ATAFB_TT 2860 - if (ATARIHW_PRESENT(TT_SHIFTER)) { 2861 - fbhw = &tt_switch; 2862 - atafb_ops.fb_setcolreg = &tt_setcolreg; 2863 - break; 2864 - } 2865 - #endif 2866 - #ifdef ATAFB_FALCON 2867 - if (ATARIHW_PRESENT(VIDEL_SHIFTER)) { 2868 - fbhw = &falcon_switch; 2869 - atafb_ops.fb_setcolreg = &falcon_setcolreg; 2870 - request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO, 2871 - "framebuffer/modeswitch", falcon_vbl_switcher); 2872 - break; 2873 - } 2874 - #endif 2875 - #ifdef ATAFB_STE 2876 - if (ATARIHW_PRESENT(STND_SHIFTER) || 2877 - ATARIHW_PRESENT(EXTD_SHIFTER)) { 2878 - fbhw = &st_switch; 2879 - atafb_ops.fb_setcolreg = &stste_setcolreg; 2880 - break; 2881 - } 2882 - fbhw = &st_switch; 2883 - atafb_ops.fb_setcolreg = &stste_setcolreg; 2884 - printk("Cannot determine video hardware; defaulting to ST(e)\n"); 2885 - #else /* ATAFB_STE */ 2886 - /* no default driver included */ 2887 - /* Nobody will ever see this message :-) */ 2888 - panic("Cannot initialize video hardware"); 2889 - #endif 2890 - } while (0); 2891 - 2892 - /* Multisync monitor capabilities */ 2893 - /* Atari-TOS defaults if no boot option present */ 2894 - if (fb_info.monspecs.hfmin == 0) { 2895 - fb_info.monspecs.hfmin = 31000; 2896 - fb_info.monspecs.hfmax = 32000; 2897 - fb_info.monspecs.vfmin = 58; 2898 - fb_info.monspecs.vfmax = 62; 2899 - } 2900 - 2901 - detected_mode = fbhw->detect(); 2902 - check_default_par(detected_mode); 2903 - #ifdef ATAFB_EXT 2904 - if (!external_addr) { 2905 - #endif /* ATAFB_EXT */ 2906 - mem_req = default_mem_req + ovsc_offset + ovsc_addlen; 2907 - mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE; 2908 - screen_base = atari_stram_alloc(mem_req, "atafb"); 2909 - if (!screen_base) 2910 - panic("Cannot allocate screen memory"); 2911 - memset(screen_base, 0, mem_req); 2912 - pad = -(unsigned long)screen_base & (PAGE_SIZE-1); 2913 - screen_base+=pad; 2914 - real_screen_base=screen_base+ovsc_offset; 2915 - screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK; 2916 - st_ovsc_switch(); 2917 - if (CPU_IS_040_OR_060) { 2918 - /* On a '040+, the cache mode of video RAM must be set to 2919 - * write-through also for internal video hardware! */ 2920 - cache_push(virt_to_phys(screen_base), screen_len); 2921 - kernel_set_cachemode(screen_base, screen_len, 2922 - IOMAP_WRITETHROUGH); 2923 - } 2924 - #ifdef ATAFB_EXT 2925 - } 2926 - else { 2927 - /* Map the video memory (physical address given) to somewhere 2928 - * in the kernel address space. 2929 - */ 2930 - external_addr = 2931 - ioremap_writethrough((unsigned long)external_addr, 2932 - external_len); 2933 - if (external_vgaiobase) 2934 - external_vgaiobase = 2935 - (unsigned long)ioremap(external_vgaiobase, 0x10000); 2936 - screen_base = 2937 - real_screen_base = external_addr; 2938 - screen_len = external_len & PAGE_MASK; 2939 - memset (screen_base, 0, external_len); 2940 - } 2941 - #endif /* ATAFB_EXT */ 2942 - 2943 - strcpy(fb_info.modename, "Atari Builtin "); 2944 - fb_info.changevar = NULL; 2945 - fb_info.fbops = &atafb_ops; 2946 - fb_info.disp = &disp; 2947 - fb_info.currcon = -1; 2948 - fb_info.switch_con = &atafb_switch; 2949 - fb_info.updatevar = &fb_update_var; 2950 - fb_info.flags = FBINFO_FLAG_DEFAULT; 2951 - do_fb_set_var(&atafb_predefined[default_par-1], 1); 2952 - strcat(fb_info.modename, fb_var_names[default_par-1][0]); 2953 - 2954 - atafb_get_var(&disp.var, -1, &fb_info); 2955 - atafb_set_disp(-1, &fb_info); 2956 - do_install_cmap(0, &fb_info); 2957 - 2958 - if (register_framebuffer(&fb_info) < 0) { 2959 - #ifdef ATAFB_EXT 2960 - if (external_addr) { 2961 - iounmap(external_addr); 2962 - external_addr = NULL; 2963 - } 2964 - if (external_vgaiobase) { 2965 - iounmap((void*)external_vgaiobase); 2966 - external_vgaiobase = 0; 2967 - } 2968 - #endif 2969 - return -EINVAL; 2970 - } 2971 - 2972 - printk("Determined %dx%d, depth %d\n", 2973 - disp.var.xres, disp.var.yres, disp.var.bits_per_pixel); 2974 - if ((disp.var.xres != disp.var.xres_virtual) || 2975 - (disp.var.yres != disp.var.yres_virtual)) 2976 - printk(" virtual %dx%d\n", 2977 - disp.var.xres_virtual, disp.var.yres_virtual); 2978 - printk("fb%d: %s frame buffer device, using %dK of video memory\n", 2979 - fb_info.node, fb_info.modename, screen_len>>10); 2980 - 2981 - /* TODO: This driver cannot be unloaded yet */ 2982 - return 0; 2983 - } 2984 - 2985 2675 2986 2676 #ifdef ATAFB_EXT 2987 2677 static void __init atafb_setup_ext(char *spec) 2988 2678 { 2989 - int xres, xres_virtual, yres, depth, planes; 2679 + int xres, xres_virtual, yres, depth, planes; 2990 2680 unsigned long addr, len; 2991 2681 char *p; 2992 2682 ··· 2842 2848 * 2843 2849 * Even xres_virtual is available, we neither support panning nor hw-scrolling! 2844 2850 */ 2845 - if (!(p = strsep(&spec, ";")) || !*p) 2846 - return; 2851 + p = strsep(&spec, ";"); 2852 + if (!p || !*p) 2853 + return; 2847 2854 xres_virtual = xres = simple_strtoul(p, NULL, 10); 2848 2855 if (xres <= 0) 2849 - return; 2856 + return; 2850 2857 2851 - if (!(p = strsep(&spec, ";")) || !*p) 2852 - return; 2858 + p = strsep(&spec, ";"); 2859 + if (!p || !*p) 2860 + return; 2853 2861 yres = simple_strtoul(p, NULL, 10); 2854 2862 if (yres <= 0) 2855 - return; 2863 + return; 2856 2864 2857 - if (!(p = strsep(&spec, ";")) || !*p) 2858 - return; 2865 + p = strsep(&spec, ";"); 2866 + if (!p || !*p) 2867 + return; 2859 2868 depth = simple_strtoul(p, NULL, 10); 2860 2869 if (depth != 1 && depth != 2 && depth != 4 && depth != 8 && 2861 - depth != 16 && depth != 24) 2862 - return; 2870 + depth != 16 && depth != 24) 2871 + return; 2863 2872 2864 - if (!(p = strsep(&spec, ";")) || !*p) 2865 - return; 2873 + p = strsep(&spec, ";"); 2874 + if (!p || !*p) 2875 + return; 2866 2876 if (*p == 'i') 2867 2877 planes = FB_TYPE_INTERLEAVED_PLANES; 2868 2878 else if (*p == 'p') ··· 2874 2876 else if (*p == 'n') 2875 2877 planes = FB_TYPE_PLANES; 2876 2878 else if (*p == 't') 2877 - planes = -1; /* true color */ 2879 + planes = -1; /* true color */ 2878 2880 else 2879 2881 return; 2880 2882 2881 - 2882 - if (!(p = strsep(&spec, ";")) || !*p) 2883 + p = strsep(&spec, ";"); 2884 + if (!p || !*p) 2883 2885 return; 2884 2886 addr = simple_strtoul(p, NULL, 0); 2885 2887 2886 - if (!(p = strsep(&spec, ";")) || !*p) 2887 - len = xres*yres*depth/8; 2888 + p = strsep(&spec, ";"); 2889 + if (!p || !*p) 2890 + len = xres * yres * depth / 8; 2888 2891 else 2889 2892 len = simple_strtoul(p, NULL, 0); 2890 2893 2891 - if ((p = strsep(&spec, ";")) && *p) { 2892 - external_vgaiobase=simple_strtoul(p, NULL, 0); 2893 - } 2894 + p = strsep(&spec, ";"); 2895 + if (p && *p) 2896 + external_vgaiobase = simple_strtoul(p, NULL, 0); 2894 2897 2895 - if ((p = strsep(&spec, ";")) && *p) { 2898 + p = strsep(&spec, ";"); 2899 + if (p && *p) { 2896 2900 external_bitspercol = simple_strtoul(p, NULL, 0); 2897 2901 if (external_bitspercol > 8) 2898 2902 external_bitspercol = 8; ··· 2902 2902 external_bitspercol = 1; 2903 2903 } 2904 2904 2905 - if ((p = strsep(&spec, ";")) && *p) { 2905 + p = strsep(&spec, ";"); 2906 + if (p && *p) { 2906 2907 if (!strcmp(p, "vga")) 2907 2908 external_card_type = IS_VGA; 2908 2909 if (!strcmp(p, "mv300")) 2909 2910 external_card_type = IS_MV300; 2910 2911 } 2911 2912 2912 - if ((p = strsep(&spec, ";")) && *p) { 2913 + p = strsep(&spec, ";"); 2914 + if (p && *p) { 2913 2915 xres_virtual = simple_strtoul(p, NULL, 10); 2914 2916 if (xres_virtual < xres) 2915 2917 xres_virtual = xres; 2916 - if (xres_virtual*yres*depth/8 > len) 2917 - len=xres_virtual*yres*depth/8; 2918 + if (xres_virtual * yres * depth / 8 > len) 2919 + len = xres_virtual * yres * depth / 8; 2918 2920 } 2919 2921 2920 - external_xres = xres; 2921 - external_xres_virtual = xres_virtual; 2922 - external_yres = yres; 2922 + external_xres = xres; 2923 + external_xres_virtual = xres_virtual; 2924 + external_yres = yres; 2923 2925 external_depth = depth; 2924 2926 external_pmode = planes; 2925 - external_addr = (void *)addr; 2926 - external_len = len; 2927 + external_addr = (void *)addr; 2928 + external_len = len; 2927 2929 2928 - if (external_card_type == IS_MV300) 2929 - switch (external_depth) { 2930 - case 1: 2931 - MV300_reg = MV300_reg_1bit; 2932 - break; 2933 - case 4: 2934 - MV300_reg = MV300_reg_4bit; 2935 - break; 2936 - case 8: 2937 - MV300_reg = MV300_reg_8bit; 2938 - break; 2939 - } 2930 + if (external_card_type == IS_MV300) { 2931 + switch (external_depth) { 2932 + case 1: 2933 + MV300_reg = MV300_reg_1bit; 2934 + break; 2935 + case 4: 2936 + MV300_reg = MV300_reg_4bit; 2937 + break; 2938 + case 8: 2939 + MV300_reg = MV300_reg_8bit; 2940 + break; 2941 + } 2942 + } 2940 2943 } 2941 2944 #endif /* ATAFB_EXT */ 2942 - 2943 2945 2944 2946 static void __init atafb_setup_int(char *spec) 2945 2947 { 2946 2948 /* Format to config extended internal video hardware like OverScan: 2947 - "internal:<xres>;<yres>;<xres_max>;<yres_max>;<offset>" 2948 - Explanation: 2949 - <xres>: x-resolution 2950 - <yres>: y-resolution 2951 - The following are only needed if you have an overscan which 2952 - needs a black border: 2953 - <xres_max>: max. length of a line in pixels your OverScan hardware would allow 2954 - <yres_max>: max. number of lines your OverScan hardware would allow 2955 - <offset>: Offset from physical beginning to visible beginning 2956 - of screen in bytes 2957 - */ 2949 + * "internal:<xres>;<yres>;<xres_max>;<yres_max>;<offset>" 2950 + * Explanation: 2951 + * <xres>: x-resolution 2952 + * <yres>: y-resolution 2953 + * The following are only needed if you have an overscan which 2954 + * needs a black border: 2955 + * <xres_max>: max. length of a line in pixels your OverScan hardware would allow 2956 + * <yres_max>: max. number of lines your OverScan hardware would allow 2957 + * <offset>: Offset from physical beginning to visible beginning 2958 + * of screen in bytes 2959 + */ 2958 2960 int xres; 2959 2961 char *p; 2960 2962 ··· 2965 2963 xres = simple_strtoul(p, NULL, 10); 2966 2964 if (!(p = strsep(&spec, ";")) || !*p) 2967 2965 return; 2968 - sttt_xres=xres; 2969 - tt_yres=st_yres=simple_strtoul(p, NULL, 10); 2970 - if ((p=strsep(&spec, ";")) && *p) { 2971 - sttt_xres_virtual=simple_strtoul(p, NULL, 10); 2972 - } 2973 - if ((p=strsep(&spec, ";")) && *p) { 2974 - sttt_yres_virtual=simple_strtoul(p, NULL, 0); 2975 - } 2976 - if ((p=strsep(&spec, ";")) && *p) { 2977 - ovsc_offset=simple_strtoul(p, NULL, 0); 2978 - } 2966 + sttt_xres = xres; 2967 + tt_yres = st_yres = simple_strtoul(p, NULL, 10); 2968 + if ((p = strsep(&spec, ";")) && *p) 2969 + sttt_xres_virtual = simple_strtoul(p, NULL, 10); 2970 + if ((p = strsep(&spec, ";")) && *p) 2971 + sttt_yres_virtual = simple_strtoul(p, NULL, 0); 2972 + if ((p = strsep(&spec, ";")) && *p) 2973 + ovsc_offset = simple_strtoul(p, NULL, 0); 2979 2974 2980 2975 if (ovsc_offset || (sttt_yres_virtual != st_yres)) 2981 - use_hwscroll=0; 2976 + use_hwscroll = 0; 2982 2977 } 2983 - 2984 2978 2985 2979 #ifdef ATAFB_FALCON 2986 2980 static void __init atafb_setup_mcap(char *spec) ··· 3016 3018 } 3017 3019 #endif /* ATAFB_FALCON */ 3018 3020 3019 - 3020 3021 static void __init atafb_setup_user(char *spec) 3021 3022 { 3022 3023 /* Format of user defined video mode is: <xres>;<yres>;<depth> ··· 3023 3026 char *p; 3024 3027 int xres, yres, depth, temp; 3025 3028 3026 - if (!(p = strsep(&spec, ";")) || !*p) 3029 + p = strsep(&spec, ";"); 3030 + if (!p || !*p) 3027 3031 return; 3028 3032 xres = simple_strtoul(p, NULL, 10); 3029 - if (!(p = strsep(&spec, ";")) || !*p) 3033 + p = strsep(&spec, ";"); 3034 + if (!p || !*p) 3030 3035 return; 3031 3036 yres = simple_strtoul(p, NULL, 10); 3032 - if (!(p = strsep(&spec, "")) || !*p) 3037 + p = strsep(&spec, ""); 3038 + if (!p || !*p) 3033 3039 return; 3034 3040 depth = simple_strtoul(p, NULL, 10); 3035 - if ((temp=get_video_mode("user0"))) { 3036 - default_par=temp; 3037 - atafb_predefined[default_par-1].xres = xres; 3038 - atafb_predefined[default_par-1].yres = yres; 3039 - atafb_predefined[default_par-1].bits_per_pixel = depth; 3041 + temp = get_video_mode("user0"); 3042 + if (temp) { 3043 + default_par = temp; 3044 + atafb_predefined[default_par - 1].xres = xres; 3045 + atafb_predefined[default_par - 1].yres = yres; 3046 + atafb_predefined[default_par - 1].bits_per_pixel = depth; 3040 3047 } 3041 3048 } 3042 3049 3043 - int __init atafb_setup( char *options ) 3050 + int __init atafb_setup(char *options) 3044 3051 { 3045 - char *this_opt; 3046 - int temp; 3052 + char *this_opt; 3053 + int temp; 3047 3054 3048 - fb_info.fontname[0] = '\0'; 3049 - 3050 - if (!options || !*options) 3055 + if (!options || !*options) 3051 3056 return 0; 3052 - 3053 - while ((this_opt = strsep(&options, ",")) != NULL) { 3054 - if (!*this_opt) continue; 3055 - if ((temp=get_video_mode(this_opt))) 3056 - default_par=temp; 3057 - else if (! strcmp(this_opt, "inverse")) 3058 - inverse=1; 3059 - else if (!strncmp(this_opt, "font:", 5)) 3060 - strcpy(fb_info.fontname, this_opt+5); 3061 - else if (! strncmp(this_opt, "hwscroll_",9)) { 3062 - hwscroll=simple_strtoul(this_opt+9, NULL, 10); 3063 - if (hwscroll < 0) 3064 - hwscroll = 0; 3065 - if (hwscroll > 200) 3066 - hwscroll = 200; 3067 - } 3057 + 3058 + while ((this_opt = strsep(&options, ",")) != NULL) { 3059 + if (!*this_opt) 3060 + continue; 3061 + if ((temp = get_video_mode(this_opt))) { 3062 + default_par = temp; 3063 + mode_option = this_opt; 3064 + } else if (!strcmp(this_opt, "inverse")) 3065 + inverse = 1; 3066 + else if (!strncmp(this_opt, "hwscroll_", 9)) { 3067 + hwscroll = simple_strtoul(this_opt + 9, NULL, 10); 3068 + if (hwscroll < 0) 3069 + hwscroll = 0; 3070 + if (hwscroll > 200) 3071 + hwscroll = 200; 3072 + } 3068 3073 #ifdef ATAFB_EXT 3069 - else if (!strcmp(this_opt,"mv300")) { 3070 - external_bitspercol = 8; 3071 - external_card_type = IS_MV300; 3072 - } 3073 - else if (!strncmp(this_opt,"external:",9)) 3074 - atafb_setup_ext(this_opt+9); 3074 + else if (!strcmp(this_opt, "mv300")) { 3075 + external_bitspercol = 8; 3076 + external_card_type = IS_MV300; 3077 + } else if (!strncmp(this_opt, "external:", 9)) 3078 + atafb_setup_ext(this_opt + 9); 3075 3079 #endif 3076 - else if (!strncmp(this_opt,"internal:",9)) 3077 - atafb_setup_int(this_opt+9); 3080 + else if (!strncmp(this_opt, "internal:", 9)) 3081 + atafb_setup_int(this_opt + 9); 3078 3082 #ifdef ATAFB_FALCON 3079 - else if (!strncmp(this_opt, "eclock:", 7)) { 3080 - fext.f = simple_strtoul(this_opt+7, NULL, 10); 3081 - /* external pixelclock in kHz --> ps */ 3082 - fext.t = 1000000000/fext.f; 3083 - fext.f *= 1000; 3084 - } 3085 - else if (!strncmp(this_opt, "monitorcap:", 11)) 3086 - atafb_setup_mcap(this_opt+11); 3083 + else if (!strncmp(this_opt, "eclock:", 7)) { 3084 + fext.f = simple_strtoul(this_opt + 7, NULL, 10); 3085 + /* external pixelclock in kHz --> ps */ 3086 + fext.t = 1000000000 / fext.f; 3087 + fext.f *= 1000; 3088 + } else if (!strncmp(this_opt, "monitorcap:", 11)) 3089 + atafb_setup_mcap(this_opt + 11); 3087 3090 #endif 3088 - else if (!strcmp(this_opt, "keep")) 3089 - DontCalcRes = 1; 3090 - else if (!strncmp(this_opt, "R", 1)) 3091 - atafb_setup_user(this_opt+1); 3092 - } 3093 - return 0; 3091 + else if (!strcmp(this_opt, "keep")) 3092 + DontCalcRes = 1; 3093 + else if (!strncmp(this_opt, "R", 1)) 3094 + atafb_setup_user(this_opt + 1); 3095 + } 3096 + return 0; 3094 3097 } 3098 + 3099 + int __init atafb_init(void) 3100 + { 3101 + int pad; 3102 + int detected_mode; 3103 + unsigned int defmode = 0; 3104 + unsigned long mem_req; 3105 + 3106 + #ifndef MODULE 3107 + char *option = NULL; 3108 + 3109 + if (fb_get_options("atafb", &option)) 3110 + return -ENODEV; 3111 + atafb_setup(option); 3112 + #endif 3113 + printk("atafb_init: start\n"); 3114 + 3115 + if (!MACH_IS_ATARI) 3116 + return -ENXIO; 3117 + 3118 + do { 3119 + #ifdef ATAFB_EXT 3120 + if (external_addr) { 3121 + printk("atafb_init: initializing external hw\n"); 3122 + fbhw = &ext_switch; 3123 + atafb_ops.fb_setcolreg = &ext_setcolreg; 3124 + defmode = DEFMODE_EXT; 3125 + break; 3126 + } 3127 + #endif 3128 + #ifdef ATAFB_TT 3129 + if (ATARIHW_PRESENT(TT_SHIFTER)) { 3130 + printk("atafb_init: initializing TT hw\n"); 3131 + fbhw = &tt_switch; 3132 + atafb_ops.fb_setcolreg = &tt_setcolreg; 3133 + defmode = DEFMODE_TT; 3134 + break; 3135 + } 3136 + #endif 3137 + #ifdef ATAFB_FALCON 3138 + if (ATARIHW_PRESENT(VIDEL_SHIFTER)) { 3139 + printk("atafb_init: initializing Falcon hw\n"); 3140 + fbhw = &falcon_switch; 3141 + atafb_ops.fb_setcolreg = &falcon_setcolreg; 3142 + request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO, 3143 + "framebuffer/modeswitch", falcon_vbl_switcher); 3144 + defmode = DEFMODE_F30; 3145 + break; 3146 + } 3147 + #endif 3148 + #ifdef ATAFB_STE 3149 + if (ATARIHW_PRESENT(STND_SHIFTER) || 3150 + ATARIHW_PRESENT(EXTD_SHIFTER)) { 3151 + printk("atafb_init: initializing ST/E hw\n"); 3152 + fbhw = &st_switch; 3153 + atafb_ops.fb_setcolreg = &stste_setcolreg; 3154 + defmode = DEFMODE_STE; 3155 + break; 3156 + } 3157 + fbhw = &st_switch; 3158 + atafb_ops.fb_setcolreg = &stste_setcolreg; 3159 + printk("Cannot determine video hardware; defaulting to ST(e)\n"); 3160 + #else /* ATAFB_STE */ 3161 + /* no default driver included */ 3162 + /* Nobody will ever see this message :-) */ 3163 + panic("Cannot initialize video hardware"); 3164 + #endif 3165 + } while (0); 3166 + 3167 + /* Multisync monitor capabilities */ 3168 + /* Atari-TOS defaults if no boot option present */ 3169 + if (fb_info.monspecs.hfmin == 0) { 3170 + fb_info.monspecs.hfmin = 31000; 3171 + fb_info.monspecs.hfmax = 32000; 3172 + fb_info.monspecs.vfmin = 58; 3173 + fb_info.monspecs.vfmax = 62; 3174 + } 3175 + 3176 + detected_mode = fbhw->detect(); 3177 + check_default_par(detected_mode); 3178 + #ifdef ATAFB_EXT 3179 + if (!external_addr) { 3180 + #endif /* ATAFB_EXT */ 3181 + mem_req = default_mem_req + ovsc_offset + ovsc_addlen; 3182 + mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE; 3183 + screen_base = atari_stram_alloc(mem_req, "atafb"); 3184 + if (!screen_base) 3185 + panic("Cannot allocate screen memory"); 3186 + memset(screen_base, 0, mem_req); 3187 + pad = -(unsigned long)screen_base & (PAGE_SIZE - 1); 3188 + screen_base += pad; 3189 + real_screen_base = screen_base + ovsc_offset; 3190 + screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK; 3191 + st_ovsc_switch(); 3192 + if (CPU_IS_040_OR_060) { 3193 + /* On a '040+, the cache mode of video RAM must be set to 3194 + * write-through also for internal video hardware! */ 3195 + cache_push(virt_to_phys(screen_base), screen_len); 3196 + kernel_set_cachemode(screen_base, screen_len, 3197 + IOMAP_WRITETHROUGH); 3198 + } 3199 + printk("atafb: screen_base %p real_screen_base %p screen_len %d\n", 3200 + screen_base, real_screen_base, screen_len); 3201 + #ifdef ATAFB_EXT 3202 + } else { 3203 + /* Map the video memory (physical address given) to somewhere 3204 + * in the kernel address space. 3205 + */ 3206 + external_addr = ioremap_writethrough((unsigned long)external_addr, 3207 + external_len); 3208 + if (external_vgaiobase) 3209 + external_vgaiobase = 3210 + (unsigned long)ioremap(external_vgaiobase, 0x10000); 3211 + screen_base = 3212 + real_screen_base = external_addr; 3213 + screen_len = external_len & PAGE_MASK; 3214 + memset (screen_base, 0, external_len); 3215 + } 3216 + #endif /* ATAFB_EXT */ 3217 + 3218 + // strcpy(fb_info.mode->name, "Atari Builtin "); 3219 + fb_info.fbops = &atafb_ops; 3220 + // try to set default (detected; requested) var 3221 + do_fb_set_var(&atafb_predefined[default_par - 1], 1); 3222 + // reads hw state into current par, which may not be sane yet 3223 + ata_get_par(&current_par); 3224 + fb_info.par = &current_par; 3225 + // tries to read from HW which may not be initialized yet 3226 + // so set sane var first, then call atafb_set_par 3227 + atafb_get_var(&fb_info.var, &fb_info); 3228 + fb_info.flags = FBINFO_FLAG_DEFAULT; 3229 + 3230 + if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb, 3231 + NUM_TOTAL_MODES, &atafb_modedb[defmode], 3232 + fb_info.var.bits_per_pixel)) { 3233 + return -EINVAL; 3234 + } 3235 + 3236 + atafb_set_disp(&fb_info); 3237 + 3238 + fb_alloc_cmap(&(fb_info.cmap), 1 << fb_info.var.bits_per_pixel, 0); 3239 + 3240 + 3241 + printk("Determined %dx%d, depth %d\n", 3242 + fb_info.var.xres, fb_info.var.yres, fb_info.var.bits_per_pixel); 3243 + if ((fb_info.var.xres != fb_info.var.xres_virtual) || 3244 + (fb_info.var.yres != fb_info.var.yres_virtual)) 3245 + printk(" virtual %dx%d\n", fb_info.var.xres_virtual, 3246 + fb_info.var.yres_virtual); 3247 + 3248 + if (register_framebuffer(&fb_info) < 0) { 3249 + #ifdef ATAFB_EXT 3250 + if (external_addr) { 3251 + iounmap(external_addr); 3252 + external_addr = NULL; 3253 + } 3254 + if (external_vgaiobase) { 3255 + iounmap((void*)external_vgaiobase); 3256 + external_vgaiobase = 0; 3257 + } 3258 + #endif 3259 + return -EINVAL; 3260 + } 3261 + 3262 + // FIXME: mode needs setting! 3263 + //printk("fb%d: %s frame buffer device, using %dK of video memory\n", 3264 + // fb_info.node, fb_info.mode->name, screen_len>>10); 3265 + printk("fb%d: frame buffer device, using %dK of video memory\n", 3266 + fb_info.node, screen_len >> 10); 3267 + 3268 + /* TODO: This driver cannot be unloaded yet */ 3269 + return 0; 3270 + } 3271 + 3272 + module_init(atafb_init); 3095 3273 3096 3274 #ifdef MODULE 3097 3275 MODULE_LICENSE("GPL"); 3098 3276 3099 - int init_module(void) 3277 + int cleanup_module(void) 3100 3278 { 3101 - return atafb_init(); 3279 + unregister_framebuffer(&fb_info); 3280 + return atafb_deinit(); 3102 3281 } 3103 3282 #endif /* MODULE */
+36
drivers/video/atafb.h
··· 1 + #ifndef _VIDEO_ATAFB_H 2 + #define _VIDEO_ATAFB_H 3 + 4 + void atafb_mfb_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy, 5 + int dx, int height, int width); 6 + void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color, 7 + int sy, int sx, int height, int width); 8 + void atafb_mfb_linefill(struct fb_info *info, u_long next_line, 9 + int dy, int dx, u32 width, 10 + const u8 *data, u32 bgcolor, u32 fgcolor); 11 + 12 + void atafb_iplan2p2_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy, 13 + int dx, int height, int width); 14 + void atafb_iplan2p2_fillrect(struct fb_info *info, u_long next_line, u32 color, 15 + int sy, int sx, int height, int width); 16 + void atafb_iplan2p2_linefill(struct fb_info *info, u_long next_line, 17 + int dy, int dx, u32 width, 18 + const u8 *data, u32 bgcolor, u32 fgcolor); 19 + 20 + void atafb_iplan2p4_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy, 21 + int dx, int height, int width); 22 + void atafb_iplan2p4_fillrect(struct fb_info *info, u_long next_line, u32 color, 23 + int sy, int sx, int height, int width); 24 + void atafb_iplan2p4_linefill(struct fb_info *info, u_long next_line, 25 + int dy, int dx, u32 width, 26 + const u8 *data, u32 bgcolor, u32 fgcolor); 27 + 28 + void atafb_iplan2p8_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy, 29 + int dx, int height, int width); 30 + void atafb_iplan2p8_fillrect(struct fb_info *info, u_long next_line, u32 color, 31 + int sy, int sx, int height, int width); 32 + void atafb_iplan2p8_linefill(struct fb_info *info, u_long next_line, 33 + int dy, int dx, u32 width, 34 + const u8 *data, u32 bgcolor, u32 fgcolor); 35 + 36 + #endif /* _VIDEO_ATAFB_H */
+293
drivers/video/atafb_iplan2p2.c
··· 1 + /* 2 + * linux/drivers/video/iplan2p2.c -- Low level frame buffer operations for 3 + * interleaved bitplanes à la Atari (2 4 + * planes, 2 bytes interleave) 5 + * 6 + * Created 5 Apr 1997 by Geert Uytterhoeven 7 + * 8 + * This file is subject to the terms and conditions of the GNU General Public 9 + * License. See the file COPYING in the main directory of this archive for 10 + * more details. 11 + */ 12 + 13 + #include <linux/module.h> 14 + #include <linux/string.h> 15 + #include <linux/fb.h> 16 + 17 + #include <asm/setup.h> 18 + 19 + #include "atafb.h" 20 + 21 + #define BPL 2 22 + #include "atafb_utils.h" 23 + 24 + void atafb_iplan2p2_copyarea(struct fb_info *info, u_long next_line, 25 + int sy, int sx, int dy, int dx, 26 + int height, int width) 27 + { 28 + /* bmove() has to distinguish two major cases: If both, source and 29 + * destination, start at even addresses or both are at odd 30 + * addresses, just the first odd and last even column (if present) 31 + * require special treatment (memmove_col()). The rest between 32 + * then can be copied by normal operations, because all adjacent 33 + * bytes are affected and are to be stored in the same order. 34 + * The pathological case is when the move should go from an odd 35 + * address to an even or vice versa. Since the bytes in the plane 36 + * words must be assembled in new order, it seems wisest to make 37 + * all movements by memmove_col(). 38 + */ 39 + 40 + u8 *src, *dst; 41 + u32 *s, *d; 42 + int w, l , i, j; 43 + u_int colsize; 44 + u_int upwards = (dy < sy) || (dy == sy && dx < sx); 45 + 46 + colsize = height; 47 + if (!((sx ^ dx) & 15)) { 48 + /* odd->odd or even->even */ 49 + 50 + if (upwards) { 51 + src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); 52 + dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); 53 + if (sx & 15) { 54 + memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2); 55 + src += BPL * 2; 56 + dst += BPL * 2; 57 + width -= 8; 58 + } 59 + w = width >> 4; 60 + if (w) { 61 + s = (u32 *)src; 62 + d = (u32 *)dst; 63 + w *= BPL / 2; 64 + l = next_line - w * 4; 65 + for (j = height; j > 0; j--) { 66 + for (i = w; i > 0; i--) 67 + *d++ = *s++; 68 + s = (u32 *)((u8 *)s + l); 69 + d = (u32 *)((u8 *)d + l); 70 + } 71 + } 72 + if (width & 15) 73 + memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL), 74 + 0xff00ff00, height, next_line - BPL * 2); 75 + } else { 76 + src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); 77 + dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); 78 + 79 + if ((sx + width) & 15) { 80 + src -= BPL * 2; 81 + dst -= BPL * 2; 82 + memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2); 83 + width -= 8; 84 + } 85 + w = width >> 4; 86 + if (w) { 87 + s = (u32 *)src; 88 + d = (u32 *)dst; 89 + w *= BPL / 2; 90 + l = next_line - w * 4; 91 + for (j = height; j > 0; j--) { 92 + for (i = w; i > 0; i--) 93 + *--d = *--s; 94 + s = (u32 *)((u8 *)s - l); 95 + d = (u32 *)((u8 *)d - l); 96 + } 97 + } 98 + if (sx & 15) 99 + memmove32_col(dst - (width - 16) / (8 / BPL), 100 + src - (width - 16) / (8 / BPL), 101 + 0xff00ff, colsize, -next_line - BPL * 2); 102 + } 103 + } else { 104 + /* odd->even or even->odd */ 105 + if (upwards) { 106 + u32 *src32, *dst32; 107 + u32 pval[4], v, v1, mask; 108 + int i, j, w, f; 109 + 110 + src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); 111 + dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); 112 + 113 + mask = 0xff00ff00; 114 + f = 0; 115 + w = width; 116 + if (sx & 15) { 117 + f = 1; 118 + w += 8; 119 + } 120 + if ((sx + width) & 15) 121 + f |= 2; 122 + w >>= 4; 123 + for (i = height; i; i--) { 124 + src32 = (u32 *)src; 125 + dst32 = (u32 *)dst; 126 + 127 + if (f & 1) { 128 + pval[0] = (*src32++ << 8) & mask; 129 + } else { 130 + pval[0] = dst32[0] & mask; 131 + } 132 + 133 + for (j = w; j > 0; j--) { 134 + v = *src32++; 135 + v1 = v & mask; 136 + *dst32++ = pval[0] | (v1 >> 8); 137 + pval[0] = (v ^ v1) << 8; 138 + } 139 + 140 + if (f & 2) { 141 + dst32[0] = (dst32[0] & mask) | pval[0]; 142 + } 143 + 144 + src += next_line; 145 + dst += next_line; 146 + } 147 + } else { 148 + u32 *src32, *dst32; 149 + u32 pval[4], v, v1, mask; 150 + int i, j, w, f; 151 + 152 + src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); 153 + dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); 154 + 155 + mask = 0xff00ff; 156 + f = 0; 157 + w = width; 158 + if ((dx + width) & 15) 159 + f = 1; 160 + if (sx & 15) { 161 + f |= 2; 162 + w += 8; 163 + } 164 + w >>= 4; 165 + for (i = height; i; i--) { 166 + src32 = (u32 *)src; 167 + dst32 = (u32 *)dst; 168 + 169 + if (f & 1) { 170 + pval[0] = dst32[-1] & mask; 171 + } else { 172 + pval[0] = (*--src32 >> 8) & mask; 173 + } 174 + 175 + for (j = w; j > 0; j--) { 176 + v = *--src32; 177 + v1 = v & mask; 178 + *--dst32 = pval[0] | (v1 << 8); 179 + pval[0] = (v ^ v1) >> 8; 180 + } 181 + 182 + if (!(f & 2)) { 183 + dst32[-1] = (dst32[-1] & mask) | pval[0]; 184 + } 185 + 186 + src -= next_line; 187 + dst -= next_line; 188 + } 189 + } 190 + } 191 + } 192 + 193 + void atafb_iplan2p2_fillrect(struct fb_info *info, u_long next_line, u32 color, 194 + int sy, int sx, int height, int width) 195 + { 196 + u32 *dest; 197 + int rows, i; 198 + u32 cval[4]; 199 + 200 + dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL)); 201 + if (sx & 15) { 202 + u8 *dest8 = (u8 *)dest + 1; 203 + 204 + expand8_col2mask(color, cval); 205 + 206 + for (i = height; i; i--) { 207 + fill8_col(dest8, cval); 208 + dest8 += next_line; 209 + } 210 + dest += BPL / 2; 211 + width -= 8; 212 + } 213 + 214 + expand16_col2mask(color, cval); 215 + rows = width >> 4; 216 + if (rows) { 217 + u32 *d = dest; 218 + u32 off = next_line - rows * BPL * 2; 219 + for (i = height; i; i--) { 220 + d = fill16_col(d, rows, cval); 221 + d = (u32 *)((long)d + off); 222 + } 223 + dest += rows * BPL / 2; 224 + width &= 15; 225 + } 226 + 227 + if (width) { 228 + u8 *dest8 = (u8 *)dest; 229 + 230 + expand8_col2mask(color, cval); 231 + 232 + for (i = height; i; i--) { 233 + fill8_col(dest8, cval); 234 + dest8 += next_line; 235 + } 236 + } 237 + } 238 + 239 + void atafb_iplan2p2_linefill(struct fb_info *info, u_long next_line, 240 + int dy, int dx, u32 width, 241 + const u8 *data, u32 bgcolor, u32 fgcolor) 242 + { 243 + u32 *dest; 244 + const u16 *data16; 245 + int rows; 246 + u32 fgm[4], bgm[4], m; 247 + 248 + dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL)); 249 + if (dx & 15) { 250 + fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++); 251 + dest += BPL / 2; 252 + width -= 8; 253 + } 254 + 255 + if (width >= 16) { 256 + data16 = (const u16 *)data; 257 + expand16_2col2mask(fgcolor, bgcolor, fgm, bgm); 258 + 259 + for (rows = width / 16; rows; rows--) { 260 + u16 d = *data16++; 261 + m = d | ((u32)d << 16); 262 + *dest++ = (m & fgm[0]) ^ bgm[0]; 263 + } 264 + 265 + data = (const u8 *)data16; 266 + width &= 15; 267 + } 268 + 269 + if (width) 270 + fill8_2col((u8 *)dest, fgcolor, bgcolor, *data); 271 + } 272 + 273 + #ifdef MODULE 274 + MODULE_LICENSE("GPL"); 275 + 276 + int init_module(void) 277 + { 278 + return 0; 279 + } 280 + 281 + void cleanup_module(void) 282 + { 283 + } 284 + #endif /* MODULE */ 285 + 286 + 287 + /* 288 + * Visible symbols for modules 289 + */ 290 + 291 + EXPORT_SYMBOL(atafb_iplan2p2_copyarea); 292 + EXPORT_SYMBOL(atafb_iplan2p2_fillrect); 293 + EXPORT_SYMBOL(atafb_iplan2p2_linefill);
+308
drivers/video/atafb_iplan2p4.c
··· 1 + /* 2 + * linux/drivers/video/iplan2p4.c -- Low level frame buffer operations for 3 + * interleaved bitplanes à la Atari (4 4 + * planes, 2 bytes interleave) 5 + * 6 + * Created 5 Apr 1997 by Geert Uytterhoeven 7 + * 8 + * This file is subject to the terms and conditions of the GNU General Public 9 + * License. See the file COPYING in the main directory of this archive for 10 + * more details. 11 + */ 12 + 13 + #include <linux/module.h> 14 + #include <linux/string.h> 15 + #include <linux/fb.h> 16 + 17 + #include <asm/setup.h> 18 + 19 + #include "atafb.h" 20 + 21 + #define BPL 4 22 + #include "atafb_utils.h" 23 + 24 + void atafb_iplan2p4_copyarea(struct fb_info *info, u_long next_line, 25 + int sy, int sx, int dy, int dx, 26 + int height, int width) 27 + { 28 + /* bmove() has to distinguish two major cases: If both, source and 29 + * destination, start at even addresses or both are at odd 30 + * addresses, just the first odd and last even column (if present) 31 + * require special treatment (memmove_col()). The rest between 32 + * then can be copied by normal operations, because all adjacent 33 + * bytes are affected and are to be stored in the same order. 34 + * The pathological case is when the move should go from an odd 35 + * address to an even or vice versa. Since the bytes in the plane 36 + * words must be assembled in new order, it seems wisest to make 37 + * all movements by memmove_col(). 38 + */ 39 + 40 + u8 *src, *dst; 41 + u32 *s, *d; 42 + int w, l , i, j; 43 + u_int colsize; 44 + u_int upwards = (dy < sy) || (dy == sy && dx < sx); 45 + 46 + colsize = height; 47 + if (!((sx ^ dx) & 15)) { 48 + /* odd->odd or even->even */ 49 + 50 + if (upwards) { 51 + src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); 52 + dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); 53 + if (sx & 15) { 54 + memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2); 55 + src += BPL * 2; 56 + dst += BPL * 2; 57 + width -= 8; 58 + } 59 + w = width >> 4; 60 + if (w) { 61 + s = (u32 *)src; 62 + d = (u32 *)dst; 63 + w *= BPL / 2; 64 + l = next_line - w * 4; 65 + for (j = height; j > 0; j--) { 66 + for (i = w; i > 0; i--) 67 + *d++ = *s++; 68 + s = (u32 *)((u8 *)s + l); 69 + d = (u32 *)((u8 *)d + l); 70 + } 71 + } 72 + if (width & 15) 73 + memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL), 74 + 0xff00ff00, height, next_line - BPL * 2); 75 + } else { 76 + src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); 77 + dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); 78 + 79 + if ((sx + width) & 15) { 80 + src -= BPL * 2; 81 + dst -= BPL * 2; 82 + memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2); 83 + width -= 8; 84 + } 85 + w = width >> 4; 86 + if (w) { 87 + s = (u32 *)src; 88 + d = (u32 *)dst; 89 + w *= BPL / 2; 90 + l = next_line - w * 4; 91 + for (j = height; j > 0; j--) { 92 + for (i = w; i > 0; i--) 93 + *--d = *--s; 94 + s = (u32 *)((u8 *)s - l); 95 + d = (u32 *)((u8 *)d - l); 96 + } 97 + } 98 + if (sx & 15) 99 + memmove32_col(dst - (width - 16) / (8 / BPL), 100 + src - (width - 16) / (8 / BPL), 101 + 0xff00ff, colsize, -next_line - BPL * 2); 102 + } 103 + } else { 104 + /* odd->even or even->odd */ 105 + if (upwards) { 106 + u32 *src32, *dst32; 107 + u32 pval[4], v, v1, mask; 108 + int i, j, w, f; 109 + 110 + src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); 111 + dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); 112 + 113 + mask = 0xff00ff00; 114 + f = 0; 115 + w = width; 116 + if (sx & 15) { 117 + f = 1; 118 + w += 8; 119 + } 120 + if ((sx + width) & 15) 121 + f |= 2; 122 + w >>= 4; 123 + for (i = height; i; i--) { 124 + src32 = (u32 *)src; 125 + dst32 = (u32 *)dst; 126 + 127 + if (f & 1) { 128 + pval[0] = (*src32++ << 8) & mask; 129 + pval[1] = (*src32++ << 8) & mask; 130 + } else { 131 + pval[0] = dst32[0] & mask; 132 + pval[1] = dst32[1] & mask; 133 + } 134 + 135 + for (j = w; j > 0; j--) { 136 + v = *src32++; 137 + v1 = v & mask; 138 + *dst32++ = pval[0] | (v1 >> 8); 139 + pval[0] = (v ^ v1) << 8; 140 + v = *src32++; 141 + v1 = v & mask; 142 + *dst32++ = pval[1] | (v1 >> 8); 143 + pval[1] = (v ^ v1) << 8; 144 + } 145 + 146 + if (f & 2) { 147 + dst32[0] = (dst32[0] & mask) | pval[0]; 148 + dst32[1] = (dst32[1] & mask) | pval[1]; 149 + } 150 + 151 + src += next_line; 152 + dst += next_line; 153 + } 154 + } else { 155 + u32 *src32, *dst32; 156 + u32 pval[4], v, v1, mask; 157 + int i, j, w, f; 158 + 159 + src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); 160 + dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); 161 + 162 + mask = 0xff00ff; 163 + f = 0; 164 + w = width; 165 + if ((dx + width) & 15) 166 + f = 1; 167 + if (sx & 15) { 168 + f |= 2; 169 + w += 8; 170 + } 171 + w >>= 4; 172 + for (i = height; i; i--) { 173 + src32 = (u32 *)src; 174 + dst32 = (u32 *)dst; 175 + 176 + if (f & 1) { 177 + pval[0] = dst32[-1] & mask; 178 + pval[1] = dst32[-2] & mask; 179 + } else { 180 + pval[0] = (*--src32 >> 8) & mask; 181 + pval[1] = (*--src32 >> 8) & mask; 182 + } 183 + 184 + for (j = w; j > 0; j--) { 185 + v = *--src32; 186 + v1 = v & mask; 187 + *--dst32 = pval[0] | (v1 << 8); 188 + pval[0] = (v ^ v1) >> 8; 189 + v = *--src32; 190 + v1 = v & mask; 191 + *--dst32 = pval[1] | (v1 << 8); 192 + pval[1] = (v ^ v1) >> 8; 193 + } 194 + 195 + if (!(f & 2)) { 196 + dst32[-1] = (dst32[-1] & mask) | pval[0]; 197 + dst32[-2] = (dst32[-2] & mask) | pval[1]; 198 + } 199 + 200 + src -= next_line; 201 + dst -= next_line; 202 + } 203 + } 204 + } 205 + } 206 + 207 + void atafb_iplan2p4_fillrect(struct fb_info *info, u_long next_line, u32 color, 208 + int sy, int sx, int height, int width) 209 + { 210 + u32 *dest; 211 + int rows, i; 212 + u32 cval[4]; 213 + 214 + dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL)); 215 + if (sx & 15) { 216 + u8 *dest8 = (u8 *)dest + 1; 217 + 218 + expand8_col2mask(color, cval); 219 + 220 + for (i = height; i; i--) { 221 + fill8_col(dest8, cval); 222 + dest8 += next_line; 223 + } 224 + dest += BPL / 2; 225 + width -= 8; 226 + } 227 + 228 + expand16_col2mask(color, cval); 229 + rows = width >> 4; 230 + if (rows) { 231 + u32 *d = dest; 232 + u32 off = next_line - rows * BPL * 2; 233 + for (i = height; i; i--) { 234 + d = fill16_col(d, rows, cval); 235 + d = (u32 *)((long)d + off); 236 + } 237 + dest += rows * BPL / 2; 238 + width &= 15; 239 + } 240 + 241 + if (width) { 242 + u8 *dest8 = (u8 *)dest; 243 + 244 + expand8_col2mask(color, cval); 245 + 246 + for (i = height; i; i--) { 247 + fill8_col(dest8, cval); 248 + dest8 += next_line; 249 + } 250 + } 251 + } 252 + 253 + void atafb_iplan2p4_linefill(struct fb_info *info, u_long next_line, 254 + int dy, int dx, u32 width, 255 + const u8 *data, u32 bgcolor, u32 fgcolor) 256 + { 257 + u32 *dest; 258 + const u16 *data16; 259 + int rows; 260 + u32 fgm[4], bgm[4], m; 261 + 262 + dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL)); 263 + if (dx & 15) { 264 + fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++); 265 + dest += BPL / 2; 266 + width -= 8; 267 + } 268 + 269 + if (width >= 16) { 270 + data16 = (const u16 *)data; 271 + expand16_2col2mask(fgcolor, bgcolor, fgm, bgm); 272 + 273 + for (rows = width / 16; rows; rows--) { 274 + u16 d = *data16++; 275 + m = d | ((u32)d << 16); 276 + *dest++ = (m & fgm[0]) ^ bgm[0]; 277 + *dest++ = (m & fgm[1]) ^ bgm[1]; 278 + } 279 + 280 + data = (const u8 *)data16; 281 + width &= 15; 282 + } 283 + 284 + if (width) 285 + fill8_2col((u8 *)dest, fgcolor, bgcolor, *data); 286 + } 287 + 288 + #ifdef MODULE 289 + MODULE_LICENSE("GPL"); 290 + 291 + int init_module(void) 292 + { 293 + return 0; 294 + } 295 + 296 + void cleanup_module(void) 297 + { 298 + } 299 + #endif /* MODULE */ 300 + 301 + 302 + /* 303 + * Visible symbols for modules 304 + */ 305 + 306 + EXPORT_SYMBOL(atafb_iplan2p4_copyarea); 307 + EXPORT_SYMBOL(atafb_iplan2p4_fillrect); 308 + EXPORT_SYMBOL(atafb_iplan2p4_linefill);
+345
drivers/video/atafb_iplan2p8.c
··· 1 + /* 2 + * linux/drivers/video/iplan2p8.c -- Low level frame buffer operations for 3 + * interleaved bitplanes à la Atari (8 4 + * planes, 2 bytes interleave) 5 + * 6 + * Created 5 Apr 1997 by Geert Uytterhoeven 7 + * 8 + * This file is subject to the terms and conditions of the GNU General Public 9 + * License. See the file COPYING in the main directory of this archive for 10 + * more details. 11 + */ 12 + 13 + #include <linux/module.h> 14 + #include <linux/string.h> 15 + #include <linux/fb.h> 16 + 17 + #include <asm/setup.h> 18 + 19 + #include "atafb.h" 20 + 21 + #define BPL 8 22 + #include "atafb_utils.h" 23 + 24 + 25 + /* Copies a 8 plane column from 's', height 'h', to 'd'. */ 26 + 27 + /* This expands a 8 bit color into two longs for two movepl (8 plane) 28 + * operations. 29 + */ 30 + 31 + void atafb_iplan2p8_copyarea(struct fb_info *info, u_long next_line, 32 + int sy, int sx, int dy, int dx, 33 + int height, int width) 34 + { 35 + /* bmove() has to distinguish two major cases: If both, source and 36 + * destination, start at even addresses or both are at odd 37 + * addresses, just the first odd and last even column (if present) 38 + * require special treatment (memmove_col()). The rest between 39 + * then can be copied by normal operations, because all adjacent 40 + * bytes are affected and are to be stored in the same order. 41 + * The pathological case is when the move should go from an odd 42 + * address to an even or vice versa. Since the bytes in the plane 43 + * words must be assembled in new order, it seems wisest to make 44 + * all movements by memmove_col(). 45 + */ 46 + 47 + u8 *src, *dst; 48 + u32 *s, *d; 49 + int w, l , i, j; 50 + u_int colsize; 51 + u_int upwards = (dy < sy) || (dy == sy && dx < sx); 52 + 53 + colsize = height; 54 + if (!((sx ^ dx) & 15)) { 55 + /* odd->odd or even->even */ 56 + 57 + if (upwards) { 58 + src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); 59 + dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); 60 + if (sx & 15) { 61 + memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2); 62 + src += BPL * 2; 63 + dst += BPL * 2; 64 + width -= 8; 65 + } 66 + w = width >> 4; 67 + if (w) { 68 + s = (u32 *)src; 69 + d = (u32 *)dst; 70 + w *= BPL / 2; 71 + l = next_line - w * 4; 72 + for (j = height; j > 0; j--) { 73 + for (i = w; i > 0; i--) 74 + *d++ = *s++; 75 + s = (u32 *)((u8 *)s + l); 76 + d = (u32 *)((u8 *)d + l); 77 + } 78 + } 79 + if (width & 15) 80 + memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL), 81 + 0xff00ff00, height, next_line - BPL * 2); 82 + } else { 83 + src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); 84 + dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); 85 + 86 + if ((sx + width) & 15) { 87 + src -= BPL * 2; 88 + dst -= BPL * 2; 89 + memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2); 90 + width -= 8; 91 + } 92 + w = width >> 4; 93 + if (w) { 94 + s = (u32 *)src; 95 + d = (u32 *)dst; 96 + w *= BPL / 2; 97 + l = next_line - w * 4; 98 + for (j = height; j > 0; j--) { 99 + for (i = w; i > 0; i--) 100 + *--d = *--s; 101 + s = (u32 *)((u8 *)s - l); 102 + d = (u32 *)((u8 *)d - l); 103 + } 104 + } 105 + if (sx & 15) 106 + memmove32_col(dst - (width - 16) / (8 / BPL), 107 + src - (width - 16) / (8 / BPL), 108 + 0xff00ff, colsize, -next_line - BPL * 2); 109 + } 110 + } else { 111 + /* odd->even or even->odd */ 112 + if (upwards) { 113 + u32 *src32, *dst32; 114 + u32 pval[4], v, v1, mask; 115 + int i, j, w, f; 116 + 117 + src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); 118 + dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); 119 + 120 + mask = 0xff00ff00; 121 + f = 0; 122 + w = width; 123 + if (sx & 15) { 124 + f = 1; 125 + w += 8; 126 + } 127 + if ((sx + width) & 15) 128 + f |= 2; 129 + w >>= 4; 130 + for (i = height; i; i--) { 131 + src32 = (u32 *)src; 132 + dst32 = (u32 *)dst; 133 + 134 + if (f & 1) { 135 + pval[0] = (*src32++ << 8) & mask; 136 + pval[1] = (*src32++ << 8) & mask; 137 + pval[2] = (*src32++ << 8) & mask; 138 + pval[3] = (*src32++ << 8) & mask; 139 + } else { 140 + pval[0] = dst32[0] & mask; 141 + pval[1] = dst32[1] & mask; 142 + pval[2] = dst32[2] & mask; 143 + pval[3] = dst32[3] & mask; 144 + } 145 + 146 + for (j = w; j > 0; j--) { 147 + v = *src32++; 148 + v1 = v & mask; 149 + *dst32++ = pval[0] | (v1 >> 8); 150 + pval[0] = (v ^ v1) << 8; 151 + v = *src32++; 152 + v1 = v & mask; 153 + *dst32++ = pval[1] | (v1 >> 8); 154 + pval[1] = (v ^ v1) << 8; 155 + v = *src32++; 156 + v1 = v & mask; 157 + *dst32++ = pval[2] | (v1 >> 8); 158 + pval[2] = (v ^ v1) << 8; 159 + v = *src32++; 160 + v1 = v & mask; 161 + *dst32++ = pval[3] | (v1 >> 8); 162 + pval[3] = (v ^ v1) << 8; 163 + } 164 + 165 + if (f & 2) { 166 + dst32[0] = (dst32[0] & mask) | pval[0]; 167 + dst32[1] = (dst32[1] & mask) | pval[1]; 168 + dst32[2] = (dst32[2] & mask) | pval[2]; 169 + dst32[3] = (dst32[3] & mask) | pval[3]; 170 + } 171 + 172 + src += next_line; 173 + dst += next_line; 174 + } 175 + } else { 176 + u32 *src32, *dst32; 177 + u32 pval[4], v, v1, mask; 178 + int i, j, w, f; 179 + 180 + src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); 181 + dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); 182 + 183 + mask = 0xff00ff; 184 + f = 0; 185 + w = width; 186 + if ((dx + width) & 15) 187 + f = 1; 188 + if (sx & 15) { 189 + f |= 2; 190 + w += 8; 191 + } 192 + w >>= 4; 193 + for (i = height; i; i--) { 194 + src32 = (u32 *)src; 195 + dst32 = (u32 *)dst; 196 + 197 + if (f & 1) { 198 + pval[0] = dst32[-1] & mask; 199 + pval[1] = dst32[-2] & mask; 200 + pval[2] = dst32[-3] & mask; 201 + pval[3] = dst32[-4] & mask; 202 + } else { 203 + pval[0] = (*--src32 >> 8) & mask; 204 + pval[1] = (*--src32 >> 8) & mask; 205 + pval[2] = (*--src32 >> 8) & mask; 206 + pval[3] = (*--src32 >> 8) & mask; 207 + } 208 + 209 + for (j = w; j > 0; j--) { 210 + v = *--src32; 211 + v1 = v & mask; 212 + *--dst32 = pval[0] | (v1 << 8); 213 + pval[0] = (v ^ v1) >> 8; 214 + v = *--src32; 215 + v1 = v & mask; 216 + *--dst32 = pval[1] | (v1 << 8); 217 + pval[1] = (v ^ v1) >> 8; 218 + v = *--src32; 219 + v1 = v & mask; 220 + *--dst32 = pval[2] | (v1 << 8); 221 + pval[2] = (v ^ v1) >> 8; 222 + v = *--src32; 223 + v1 = v & mask; 224 + *--dst32 = pval[3] | (v1 << 8); 225 + pval[3] = (v ^ v1) >> 8; 226 + } 227 + 228 + if (!(f & 2)) { 229 + dst32[-1] = (dst32[-1] & mask) | pval[0]; 230 + dst32[-2] = (dst32[-2] & mask) | pval[1]; 231 + dst32[-3] = (dst32[-3] & mask) | pval[2]; 232 + dst32[-4] = (dst32[-4] & mask) | pval[3]; 233 + } 234 + 235 + src -= next_line; 236 + dst -= next_line; 237 + } 238 + } 239 + } 240 + } 241 + 242 + void atafb_iplan2p8_fillrect(struct fb_info *info, u_long next_line, u32 color, 243 + int sy, int sx, int height, int width) 244 + { 245 + u32 *dest; 246 + int rows, i; 247 + u32 cval[4]; 248 + 249 + dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL)); 250 + if (sx & 15) { 251 + u8 *dest8 = (u8 *)dest + 1; 252 + 253 + expand8_col2mask(color, cval); 254 + 255 + for (i = height; i; i--) { 256 + fill8_col(dest8, cval); 257 + dest8 += next_line; 258 + } 259 + dest += BPL / 2; 260 + width -= 8; 261 + } 262 + 263 + expand16_col2mask(color, cval); 264 + rows = width >> 4; 265 + if (rows) { 266 + u32 *d = dest; 267 + u32 off = next_line - rows * BPL * 2; 268 + for (i = height; i; i--) { 269 + d = fill16_col(d, rows, cval); 270 + d = (u32 *)((long)d + off); 271 + } 272 + dest += rows * BPL / 2; 273 + width &= 15; 274 + } 275 + 276 + if (width) { 277 + u8 *dest8 = (u8 *)dest; 278 + 279 + expand8_col2mask(color, cval); 280 + 281 + for (i = height; i; i--) { 282 + fill8_col(dest8, cval); 283 + dest8 += next_line; 284 + } 285 + } 286 + } 287 + 288 + void atafb_iplan2p8_linefill(struct fb_info *info, u_long next_line, 289 + int dy, int dx, u32 width, 290 + const u8 *data, u32 bgcolor, u32 fgcolor) 291 + { 292 + u32 *dest; 293 + const u16 *data16; 294 + int rows; 295 + u32 fgm[4], bgm[4], m; 296 + 297 + dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL)); 298 + if (dx & 15) { 299 + fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++); 300 + dest += BPL / 2; 301 + width -= 8; 302 + } 303 + 304 + if (width >= 16) { 305 + data16 = (const u16 *)data; 306 + expand16_2col2mask(fgcolor, bgcolor, fgm, bgm); 307 + 308 + for (rows = width / 16; rows; rows--) { 309 + u16 d = *data16++; 310 + m = d | ((u32)d << 16); 311 + *dest++ = (m & fgm[0]) ^ bgm[0]; 312 + *dest++ = (m & fgm[1]) ^ bgm[1]; 313 + *dest++ = (m & fgm[2]) ^ bgm[2]; 314 + *dest++ = (m & fgm[3]) ^ bgm[3]; 315 + } 316 + 317 + data = (const u8 *)data16; 318 + width &= 15; 319 + } 320 + 321 + if (width) 322 + fill8_2col((u8 *)dest, fgcolor, bgcolor, *data); 323 + } 324 + 325 + #ifdef MODULE 326 + MODULE_LICENSE("GPL"); 327 + 328 + int init_module(void) 329 + { 330 + return 0; 331 + } 332 + 333 + void cleanup_module(void) 334 + { 335 + } 336 + #endif /* MODULE */ 337 + 338 + 339 + /* 340 + * Visible symbols for modules 341 + */ 342 + 343 + EXPORT_SYMBOL(atafb_iplan2p8_copyarea); 344 + EXPORT_SYMBOL(atafb_iplan2p8_fillrect); 345 + EXPORT_SYMBOL(atafb_iplan2p8_linefill);
+112
drivers/video/atafb_mfb.c
··· 1 + /* 2 + * linux/drivers/video/mfb.c -- Low level frame buffer operations for 3 + * monochrome 4 + * 5 + * Created 5 Apr 1997 by Geert Uytterhoeven 6 + * 7 + * This file is subject to the terms and conditions of the GNU General Public 8 + * License. See the file COPYING in the main directory of this archive for 9 + * more details. 10 + */ 11 + 12 + #include <linux/module.h> 13 + #include <linux/string.h> 14 + #include <linux/fb.h> 15 + 16 + #include "atafb.h" 17 + #include "atafb_utils.h" 18 + 19 + 20 + /* 21 + * Monochrome 22 + */ 23 + 24 + void atafb_mfb_copyarea(struct fb_info *info, u_long next_line, 25 + int sy, int sx, int dy, int dx, 26 + int height, int width) 27 + { 28 + u8 *src, *dest; 29 + u_int rows; 30 + 31 + if (sx == 0 && dx == 0 && width == next_line) { 32 + src = (u8 *)info->screen_base + sy * (width >> 3); 33 + dest = (u8 *)info->screen_base + dy * (width >> 3); 34 + fb_memmove(dest, src, height * (width >> 3)); 35 + } else if (dy <= sy) { 36 + src = (u8 *)info->screen_base + sy * next_line + (sx >> 3); 37 + dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3); 38 + for (rows = height; rows--;) { 39 + fb_memmove(dest, src, width >> 3); 40 + src += next_line; 41 + dest += next_line; 42 + } 43 + } else { 44 + src = (u8 *)info->screen_base + (sy + height - 1) * next_line + (sx >> 3); 45 + dest = (u8 *)info->screen_base + (dy + height - 1) * next_line + (dx >> 3); 46 + for (rows = height; rows--;) { 47 + fb_memmove(dest, src, width >> 3); 48 + src -= next_line; 49 + dest -= next_line; 50 + } 51 + } 52 + } 53 + 54 + void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color, 55 + int sy, int sx, int height, int width) 56 + { 57 + u8 *dest; 58 + u_int rows; 59 + 60 + dest = (u8 *)info->screen_base + sy * next_line + (sx >> 3); 61 + 62 + if (sx == 0 && width == next_line) { 63 + if (color) 64 + fb_memset255(dest, height * (width >> 3)); 65 + else 66 + fb_memclear(dest, height * (width >> 3)); 67 + } else { 68 + for (rows = height; rows--; dest += next_line) { 69 + if (color) 70 + fb_memset255(dest, width >> 3); 71 + else 72 + fb_memclear_small(dest, width >> 3); 73 + } 74 + } 75 + } 76 + 77 + void atafb_mfb_linefill(struct fb_info *info, u_long next_line, 78 + int dy, int dx, u32 width, 79 + const u8 *data, u32 bgcolor, u32 fgcolor) 80 + { 81 + u8 *dest; 82 + u_int rows; 83 + 84 + dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3); 85 + 86 + for (rows = width / 8; rows--; /* check margins */ ) { 87 + // use fast_memmove or fb_memmove 88 + *dest++ = *data++; 89 + } 90 + } 91 + 92 + #ifdef MODULE 93 + MODULE_LICENSE("GPL"); 94 + 95 + int init_module(void) 96 + { 97 + return 0; 98 + } 99 + 100 + void cleanup_module(void) 101 + { 102 + } 103 + #endif /* MODULE */ 104 + 105 + 106 + /* 107 + * Visible symbols for modules 108 + */ 109 + 110 + EXPORT_SYMBOL(atafb_mfb_copyarea); 111 + EXPORT_SYMBOL(atafb_mfb_fillrect); 112 + EXPORT_SYMBOL(atafb_mfb_linefill);
+400
drivers/video/atafb_utils.h
··· 1 + #ifndef _VIDEO_ATAFB_UTILS_H 2 + #define _VIDEO_ATAFB_UTILS_H 3 + 4 + /* ================================================================= */ 5 + /* Utility Assembler Functions */ 6 + /* ================================================================= */ 7 + 8 + /* ====================================================================== */ 9 + 10 + /* Those of a delicate disposition might like to skip the next couple of 11 + * pages. 12 + * 13 + * These functions are drop in replacements for memmove and 14 + * memset(_, 0, _). However their five instances add at least a kilobyte 15 + * to the object file. You have been warned. 16 + * 17 + * Not a great fan of assembler for the sake of it, but I think 18 + * that these routines are at least 10 times faster than their C 19 + * equivalents for large blits, and that's important to the lowest level of 20 + * a graphics driver. Question is whether some scheme with the blitter 21 + * would be faster. I suspect not for simple text system - not much 22 + * asynchrony. 23 + * 24 + * Code is very simple, just gruesome expansion. Basic strategy is to 25 + * increase data moved/cleared at each step to 16 bytes to reduce 26 + * instruction per data move overhead. movem might be faster still 27 + * For more than 15 bytes, we try to align the write direction on a 28 + * longword boundary to get maximum speed. This is even more gruesome. 29 + * Unaligned read/write used requires 68020+ - think this is a problem? 30 + * 31 + * Sorry! 32 + */ 33 + 34 + 35 + /* ++roman: I've optimized Robert's original versions in some minor 36 + * aspects, e.g. moveq instead of movel, let gcc choose the registers, 37 + * use movem in some places... 38 + * For other modes than 1 plane, lots of more such assembler functions 39 + * were needed (e.g. the ones using movep or expanding color values). 40 + */ 41 + 42 + /* ++andreas: more optimizations: 43 + subl #65536,d0 replaced by clrw d0; subql #1,d0 for dbcc 44 + addal is faster than addaw 45 + movep is rather expensive compared to ordinary move's 46 + some functions rewritten in C for clarity, no speed loss */ 47 + 48 + static inline void *fb_memclear_small(void *s, size_t count) 49 + { 50 + if (!count) 51 + return 0; 52 + 53 + asm volatile ("\n" 54 + " lsr.l #1,%1 ; jcc 1f ; move.b %2,-(%0)\n" 55 + "1: lsr.l #1,%1 ; jcc 1f ; move.w %2,-(%0)\n" 56 + "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0)\n" 57 + "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0) ; move.l %2,-(%0)\n" 58 + "1:" 59 + : "=a" (s), "=d" (count) 60 + : "d" (0), "0" ((char *)s + count), "1" (count)); 61 + asm volatile ("\n" 62 + " subq.l #1,%1\n" 63 + " jcs 3f\n" 64 + " move.l %2,%%d4; move.l %2,%%d5; move.l %2,%%d6\n" 65 + "2: movem.l %2/%%d4/%%d5/%%d6,-(%0)\n" 66 + " dbra %1,2b\n" 67 + "3:" 68 + : "=a" (s), "=d" (count) 69 + : "d" (0), "0" (s), "1" (count) 70 + : "d4", "d5", "d6" 71 + ); 72 + 73 + return 0; 74 + } 75 + 76 + 77 + static inline void *fb_memclear(void *s, size_t count) 78 + { 79 + if (!count) 80 + return 0; 81 + 82 + if (count < 16) { 83 + asm volatile ("\n" 84 + " lsr.l #1,%1 ; jcc 1f ; clr.b (%0)+\n" 85 + "1: lsr.l #1,%1 ; jcc 1f ; clr.w (%0)+\n" 86 + "1: lsr.l #1,%1 ; jcc 1f ; clr.l (%0)+\n" 87 + "1: lsr.l #1,%1 ; jcc 1f ; clr.l (%0)+ ; clr.l (%0)+\n" 88 + "1:" 89 + : "=a" (s), "=d" (count) 90 + : "0" (s), "1" (count)); 91 + } else { 92 + long tmp; 93 + asm volatile ("\n" 94 + " move.l %1,%2\n" 95 + " lsr.l #1,%2 ; jcc 1f ; clr.b (%0)+ ; subq.w #1,%1\n" 96 + " lsr.l #1,%2 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/ 97 + " clr.w (%0)+ ; subq.w #2,%1 ; jra 2f\n" 98 + "1: lsr.l #1,%2 ; jcc 2f\n" 99 + " clr.w (%0)+ ; subq.w #2,%1\n" 100 + "2: move.w %1,%2; lsr.l #2,%1 ; jeq 6f\n" 101 + " lsr.l #1,%1 ; jcc 3f ; clr.l (%0)+\n" 102 + "3: lsr.l #1,%1 ; jcc 4f ; clr.l (%0)+ ; clr.l (%0)+\n" 103 + "4: subq.l #1,%1 ; jcs 6f\n" 104 + "5: clr.l (%0)+; clr.l (%0)+ ; clr.l (%0)+ ; clr.l (%0)+\n" 105 + " dbra %1,5b ; clr.w %1; subq.l #1,%1; jcc 5b\n" 106 + "6: move.w %2,%1; btst #1,%1 ; jeq 7f ; clr.w (%0)+\n" 107 + "7: btst #0,%1 ; jeq 8f ; clr.b (%0)+\n" 108 + "8:" 109 + : "=a" (s), "=d" (count), "=d" (tmp) 110 + : "0" (s), "1" (count)); 111 + } 112 + 113 + return 0; 114 + } 115 + 116 + 117 + static inline void *fb_memset255(void *s, size_t count) 118 + { 119 + if (!count) 120 + return 0; 121 + 122 + asm volatile ("\n" 123 + " lsr.l #1,%1 ; jcc 1f ; move.b %2,-(%0)\n" 124 + "1: lsr.l #1,%1 ; jcc 1f ; move.w %2,-(%0)\n" 125 + "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0)\n" 126 + "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0) ; move.l %2,-(%0)\n" 127 + "1:" 128 + : "=a" (s), "=d" (count) 129 + : "d" (-1), "0" ((char *)s+count), "1" (count)); 130 + asm volatile ("\n" 131 + " subq.l #1,%1 ; jcs 3f\n" 132 + " move.l %2,%%d4; move.l %2,%%d5; move.l %2,%%d6\n" 133 + "2: movem.l %2/%%d4/%%d5/%%d6,-(%0)\n" 134 + " dbra %1,2b\n" 135 + "3:" 136 + : "=a" (s), "=d" (count) 137 + : "d" (-1), "0" (s), "1" (count) 138 + : "d4", "d5", "d6"); 139 + 140 + return 0; 141 + } 142 + 143 + 144 + static inline void *fb_memmove(void *d, const void *s, size_t count) 145 + { 146 + if (d < s) { 147 + if (count < 16) { 148 + asm volatile ("\n" 149 + " lsr.l #1,%2 ; jcc 1f ; move.b (%1)+,(%0)+\n" 150 + "1: lsr.l #1,%2 ; jcc 1f ; move.w (%1)+,(%0)+\n" 151 + "1: lsr.l #1,%2 ; jcc 1f ; move.l (%1)+,(%0)+\n" 152 + "1: lsr.l #1,%2 ; jcc 1f ; move.l (%1)+,(%0)+ ; move.l (%1)+,(%0)+\n" 153 + "1:" 154 + : "=a" (d), "=a" (s), "=d" (count) 155 + : "0" (d), "1" (s), "2" (count)); 156 + } else { 157 + long tmp; 158 + asm volatile ("\n" 159 + " move.l %0,%3\n" 160 + " lsr.l #1,%3 ; jcc 1f ; move.b (%1)+,(%0)+ ; subqw #1,%2\n" 161 + " lsr.l #1,%3 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/ 162 + " move.w (%1)+,(%0)+ ; subqw #2,%2 ; jra 2f\n" 163 + "1: lsr.l #1,%3 ; jcc 2f\n" 164 + " move.w (%1)+,(%0)+ ; subqw #2,%2\n" 165 + "2: move.w %2,%-; lsr.l #2,%2 ; jeq 6f\n" 166 + " lsr.l #1,%2 ; jcc 3f ; move.l (%1)+,(%0)+\n" 167 + "3: lsr.l #1,%2 ; jcc 4f ; move.l (%1)+,(%0)+ ; move.l (%1)+,(%0)+\n" 168 + "4: subq.l #1,%2 ; jcs 6f\n" 169 + "5: move.l (%1)+,(%0)+; move.l (%1)+,(%0)+\n" 170 + " move.l (%1)+,(%0)+; move.l (%1)+,(%0)+\n" 171 + " dbra %2,5b ; clr.w %2; subq.l #1,%2; jcc 5b\n" 172 + "6: move.w %+,%2; btst #1,%2 ; jeq 7f ; move.w (%1)+,(%0)+\n" 173 + "7: btst #0,%2 ; jeq 8f ; move.b (%1)+,(%0)+\n" 174 + "8:" 175 + : "=a" (d), "=a" (s), "=d" (count), "=d" (tmp) 176 + : "0" (d), "1" (s), "2" (count)); 177 + } 178 + } else { 179 + if (count < 16) { 180 + asm volatile ("\n" 181 + " lsr.l #1,%2 ; jcc 1f ; move.b -(%1),-(%0)\n" 182 + "1: lsr.l #1,%2 ; jcc 1f ; move.w -(%1),-(%0)\n" 183 + "1: lsr.l #1,%2 ; jcc 1f ; move.l -(%1),-(%0)\n" 184 + "1: lsr.l #1,%2 ; jcc 1f ; move.l -(%1),-(%0) ; move.l -(%1),-(%0)\n" 185 + "1:" 186 + : "=a" (d), "=a" (s), "=d" (count) 187 + : "0" ((char *) d + count), "1" ((char *) s + count), "2" (count)); 188 + } else { 189 + long tmp; 190 + 191 + asm volatile ("\n" 192 + " move.l %0,%3\n" 193 + " lsr.l #1,%3 ; jcc 1f ; move.b -(%1),-(%0) ; subqw #1,%2\n" 194 + " lsr.l #1,%3 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/ 195 + " move.w -(%1),-(%0) ; subqw #2,%2 ; jra 2f\n" 196 + "1: lsr.l #1,%3 ; jcc 2f\n" 197 + " move.w -(%1),-(%0) ; subqw #2,%2\n" 198 + "2: move.w %2,%-; lsr.l #2,%2 ; jeq 6f\n" 199 + " lsr.l #1,%2 ; jcc 3f ; move.l -(%1),-(%0)\n" 200 + "3: lsr.l #1,%2 ; jcc 4f ; move.l -(%1),-(%0) ; move.l -(%1),-(%0)\n" 201 + "4: subq.l #1,%2 ; jcs 6f\n" 202 + "5: move.l -(%1),-(%0); move.l -(%1),-(%0)\n" 203 + " move.l -(%1),-(%0); move.l -(%1),-(%0)\n" 204 + " dbra %2,5b ; clr.w %2; subq.l #1,%2; jcc 5b\n" 205 + "6: move.w %+,%2; btst #1,%2 ; jeq 7f ; move.w -(%1),-(%0)\n" 206 + "7: btst #0,%2 ; jeq 8f ; move.b -(%1),-(%0)\n" 207 + "8:" 208 + : "=a" (d), "=a" (s), "=d" (count), "=d" (tmp) 209 + : "0" ((char *) d + count), "1" ((char *) s + count), "2" (count)); 210 + } 211 + } 212 + 213 + return 0; 214 + } 215 + 216 + 217 + /* ++andreas: Simple and fast version of memmove, assumes size is 218 + divisible by 16, suitable for moving the whole screen bitplane */ 219 + static inline void fast_memmove(char *dst, const char *src, size_t size) 220 + { 221 + if (!size) 222 + return; 223 + if (dst < src) 224 + asm volatile ("\n" 225 + "1: movem.l (%0)+,%%d0/%%d1/%%a0/%%a1\n" 226 + " movem.l %%d0/%%d1/%%a0/%%a1,%1@\n" 227 + " addq.l #8,%1; addq.l #8,%1\n" 228 + " dbra %2,1b\n" 229 + " clr.w %2; subq.l #1,%2\n" 230 + " jcc 1b" 231 + : "=a" (src), "=a" (dst), "=d" (size) 232 + : "0" (src), "1" (dst), "2" (size / 16 - 1) 233 + : "d0", "d1", "a0", "a1", "memory"); 234 + else 235 + asm volatile ("\n" 236 + "1: subq.l #8,%0; subq.l #8,%0\n" 237 + " movem.l %0@,%%d0/%%d1/%%a0/%%a1\n" 238 + " movem.l %%d0/%%d1/%%a0/%%a1,-(%1)\n" 239 + " dbra %2,1b\n" 240 + " clr.w %2; subq.l #1,%2\n" 241 + " jcc 1b" 242 + : "=a" (src), "=a" (dst), "=d" (size) 243 + : "0" (src + size), "1" (dst + size), "2" (size / 16 - 1) 244 + : "d0", "d1", "a0", "a1", "memory"); 245 + } 246 + 247 + #ifdef BPL 248 + 249 + /* 250 + * This expands a up to 8 bit color into two longs 251 + * for movel operations. 252 + */ 253 + static const u32 four2long[] = { 254 + 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, 255 + 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff, 256 + 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, 257 + 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff, 258 + }; 259 + 260 + static inline void expand8_col2mask(u8 c, u32 m[]) 261 + { 262 + m[0] = four2long[c & 15]; 263 + #if BPL > 4 264 + m[1] = four2long[c >> 4]; 265 + #endif 266 + } 267 + 268 + static inline void expand8_2col2mask(u8 fg, u8 bg, u32 fgm[], u32 bgm[]) 269 + { 270 + fgm[0] = four2long[fg & 15] ^ (bgm[0] = four2long[bg & 15]); 271 + #if BPL > 4 272 + fgm[1] = four2long[fg >> 4] ^ (bgm[1] = four2long[bg >> 4]); 273 + #endif 274 + } 275 + 276 + /* 277 + * set an 8bit value to a color 278 + */ 279 + static inline void fill8_col(u8 *dst, u32 m[]) 280 + { 281 + u32 tmp = m[0]; 282 + dst[0] = tmp; 283 + dst[2] = (tmp >>= 8); 284 + #if BPL > 2 285 + dst[4] = (tmp >>= 8); 286 + dst[6] = tmp >> 8; 287 + #endif 288 + #if BPL > 4 289 + tmp = m[1]; 290 + dst[8] = tmp; 291 + dst[10] = (tmp >>= 8); 292 + dst[12] = (tmp >>= 8); 293 + dst[14] = tmp >> 8; 294 + #endif 295 + } 296 + 297 + /* 298 + * set an 8bit value according to foreground/background color 299 + */ 300 + static inline void fill8_2col(u8 *dst, u8 fg, u8 bg, u32 mask) 301 + { 302 + u32 fgm[2], bgm[2], tmp; 303 + 304 + expand8_2col2mask(fg, bg, fgm, bgm); 305 + 306 + mask |= mask << 8; 307 + #if BPL > 2 308 + mask |= mask << 16; 309 + #endif 310 + tmp = (mask & fgm[0]) ^ bgm[0]; 311 + dst[0] = tmp; 312 + dst[2] = (tmp >>= 8); 313 + #if BPL > 2 314 + dst[4] = (tmp >>= 8); 315 + dst[6] = tmp >> 8; 316 + #endif 317 + #if BPL > 4 318 + tmp = (mask & fgm[1]) ^ bgm[1]; 319 + dst[8] = tmp; 320 + dst[10] = (tmp >>= 8); 321 + dst[12] = (tmp >>= 8); 322 + dst[14] = tmp >> 8; 323 + #endif 324 + } 325 + 326 + static const u32 two2word[] = { 327 + 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff 328 + }; 329 + 330 + static inline void expand16_col2mask(u8 c, u32 m[]) 331 + { 332 + m[0] = two2word[c & 3]; 333 + #if BPL > 2 334 + m[1] = two2word[(c >> 2) & 3]; 335 + #endif 336 + #if BPL > 4 337 + m[2] = two2word[(c >> 4) & 3]; 338 + m[3] = two2word[c >> 6]; 339 + #endif 340 + } 341 + 342 + static inline void expand16_2col2mask(u8 fg, u8 bg, u32 fgm[], u32 bgm[]) 343 + { 344 + bgm[0] = two2word[bg & 3]; 345 + fgm[0] = two2word[fg & 3] ^ bgm[0]; 346 + #if BPL > 2 347 + bgm[1] = two2word[(bg >> 2) & 3]; 348 + fgm[1] = two2word[(fg >> 2) & 3] ^ bgm[1]; 349 + #endif 350 + #if BPL > 4 351 + bgm[2] = two2word[(bg >> 4) & 3]; 352 + fgm[2] = two2word[(fg >> 4) & 3] ^ bgm[2]; 353 + bgm[3] = two2word[bg >> 6]; 354 + fgm[3] = two2word[fg >> 6] ^ bgm[3]; 355 + #endif 356 + } 357 + 358 + static inline u32 *fill16_col(u32 *dst, int rows, u32 m[]) 359 + { 360 + while (rows) { 361 + *dst++ = m[0]; 362 + #if BPL > 2 363 + *dst++ = m[1]; 364 + #endif 365 + #if BPL > 4 366 + *dst++ = m[2]; 367 + *dst++ = m[3]; 368 + #endif 369 + rows--; 370 + } 371 + return dst; 372 + } 373 + 374 + static inline void memmove32_col(void *dst, void *src, u32 mask, u32 h, u32 bytes) 375 + { 376 + u32 *s, *d, v; 377 + 378 + s = src; 379 + d = dst; 380 + do { 381 + v = (*s++ & mask) | (*d & ~mask); 382 + *d++ = v; 383 + #if BPL > 2 384 + v = (*s++ & mask) | (*d & ~mask); 385 + *d++ = v; 386 + #endif 387 + #if BPL > 4 388 + v = (*s++ & mask) | (*d & ~mask); 389 + *d++ = v; 390 + v = (*s++ & mask) | (*d & ~mask); 391 + *d++ = v; 392 + #endif 393 + d = (u32 *)((u8 *)d + bytes); 394 + s = (u32 *)((u8 *)s + bytes); 395 + } while (--h); 396 + } 397 + 398 + #endif 399 + 400 + #endif /* _VIDEO_ATAFB_UTILS_H */