Blame view
drivers/video/amifb.c
99.7 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
/* * linux/drivers/video/amifb.c -- Amiga builtin chipset frame buffer device * * Copyright (C) 1995-2003 Geert Uytterhoeven * * with work by Roman Zippel * * * This file is based on the Atari frame buffer device (atafb.c): * * Copyright (C) 1994 Martin Schaller * Roman Hodek * * with work by Andreas Schwab * Guenther Kelleter * * and on the original Amiga console driver (amicon.c): * * Copyright (C) 1993 Hamish Macdonald * Greg Harp * Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk] * * with work by William Rucklidge (wjr@cs.cornell.edu) * Geert Uytterhoeven * Jes Sorensen (jds@kom.auc.dk) * * * History: * * - 24 Jul 96: Copper generates now vblank interrupt and * VESA Power Saving Protocol is fully implemented * - 14 Jul 96: Rework and hopefully last ECS bugs fixed * - 7 Mar 96: Hardware sprite support by Roman Zippel * - 18 Feb 96: OCS and ECS support by Roman Zippel * Hardware functions completely rewritten * - 2 Dec 95: AGA version by Geert Uytterhoeven * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> |
1da177e4c Linux-2.6.12-rc2 |
48 |
#include <linux/delay.h> |
1da177e4c Linux-2.6.12-rc2 |
49 50 51 52 |
#include <linux/interrupt.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/ioport.h> |
fa6688e1c m68k: amiga - Fra... |
53 |
#include <linux/platform_device.h> |
84902b7af fbdev: change asm... |
54 |
#include <linux/uaccess.h> |
fa6688e1c m68k: amiga - Fra... |
55 |
|
1da177e4c Linux-2.6.12-rc2 |
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
#include <asm/system.h> #include <asm/irq.h> #include <asm/amigahw.h> #include <asm/amigaints.h> #include <asm/setup.h> #include "c2p.h" #define DEBUG #if !defined(CONFIG_FB_AMIGA_OCS) && !defined(CONFIG_FB_AMIGA_ECS) && !defined(CONFIG_FB_AMIGA_AGA) #define CONFIG_FB_AMIGA_OCS /* define at least one fb driver, this will change later */ #endif #if !defined(CONFIG_FB_AMIGA_OCS) # define IS_OCS (0) #elif defined(CONFIG_FB_AMIGA_ECS) || defined(CONFIG_FB_AMIGA_AGA) # define IS_OCS (chipset == TAG_OCS) #else # define CONFIG_FB_AMIGA_OCS_ONLY # define IS_OCS (1) #endif #if !defined(CONFIG_FB_AMIGA_ECS) # define IS_ECS (0) #elif defined(CONFIG_FB_AMIGA_OCS) || defined(CONFIG_FB_AMIGA_AGA) # define IS_ECS (chipset == TAG_ECS) #else # define CONFIG_FB_AMIGA_ECS_ONLY # define IS_ECS (1) #endif #if !defined(CONFIG_FB_AMIGA_AGA) # define IS_AGA (0) #elif defined(CONFIG_FB_AMIGA_OCS) || defined(CONFIG_FB_AMIGA_ECS) # define IS_AGA (chipset == TAG_AGA) #else # define CONFIG_FB_AMIGA_AGA_ONLY # define IS_AGA (1) #endif #ifdef DEBUG |
5ae121705 video: replace re... |
99 |
# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args) |
1da177e4c Linux-2.6.12-rc2 |
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
#else # define DPRINTK(fmt, args...) #endif /******************************************************************************* Generic video timings --------------------- Timings used by the frame buffer interface: +----------+---------------------------------------------+----------+-------+ | | ^ | | | | | |upper_margin | | | |
96de0e252 Convert files to ... |
115 |
| | v | | | |
1da177e4c Linux-2.6.12-rc2 |
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
+----------###############################################----------+-------+ | # ^ # | | | # | # | | | # | # | | | # | # | | | left # | # right | hsync | | margin # | xres # margin | len | |<-------->#<---------------+--------------------------->#<-------->|<----->| | # | # | | | # | # | | | # | # | | | # |yres # | | | # | # | | | # | # | | | # | # | | | # | # | | | # | # | | | # | # | | | # | # | | | # | # | | |
96de0e252 Convert files to ... |
136 |
| # v # | | |
1da177e4c Linux-2.6.12-rc2 |
137 138 139 |
+----------###############################################----------+-------+ | | ^ | | | | | |lower_margin | | | |
96de0e252 Convert files to ... |
140 |
| | v | | | |
1da177e4c Linux-2.6.12-rc2 |
141 142 143 |
+----------+---------------------------------------------+----------+-------+ | | ^ | | | | | |vsync_len | | | |
96de0e252 Convert files to ... |
144 |
| | v | | | |
1da177e4c Linux-2.6.12-rc2 |
145 146 147 148 149 150 151 152 153 154 |
+----------+---------------------------------------------+----------+-------+ Amiga video timings ------------------- The Amiga native chipsets uses another timing scheme: - hsstrt: Start of horizontal synchronization pulse - hsstop: End of horizontal synchronization pulse |
f0058b4bb fbdev/amifb: Corr... |
155 |
- htotal: Last value on the line (i.e. line length = htotal + 1) |
1da177e4c Linux-2.6.12-rc2 |
156 157 |
- vsstrt: Start of vertical synchronization pulse - vsstop: End of vertical synchronization pulse |
f0058b4bb fbdev/amifb: Corr... |
158 |
- vtotal: Last line value (i.e. number of lines = vtotal + 1) |
1da177e4c Linux-2.6.12-rc2 |
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
- hcenter: Start of vertical retrace for interlace You can specify the blanking timings independently. Currently I just set them equal to the respective synchronization values: - hbstrt: Start of horizontal blank - hbstop: End of horizontal blank - vbstrt: Start of vertical blank - vbstop: End of vertical blank Horizontal values are in color clock cycles (280 ns), vertical values are in scanlines. (0, 0) is somewhere in the upper-left corner :-) Amiga visible window definitions -------------------------------- Currently I only have values for AGA, SHRES (28 MHz dotclock). Feel free to make corrections and/or additions. Within the above synchronization specifications, the visible window is defined by the following parameters (actual register resolutions may be different; all horizontal values are normalized with respect to the pixel clock): - diwstrt_h: Horizontal start of the visible window |
f0058b4bb fbdev/amifb: Corr... |
187 |
- diwstop_h: Horizontal stop + 1(*) of the visible window |
1da177e4c Linux-2.6.12-rc2 |
188 189 190 191 192 193 194 |
- diwstrt_v: Vertical start of the visible window - diwstop_v: Vertical stop of the visible window - ddfstrt: Horizontal start of display DMA - ddfstop: Horizontal stop of display DMA - hscroll: Horizontal display output delay Sprite positioning: |
f0058b4bb fbdev/amifb: Corr... |
195 |
- sprstrt_h: Horizontal start - 4 of sprite |
1da177e4c Linux-2.6.12-rc2 |
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
- sprstrt_v: Vertical start of sprite (*) Even Commodore did it wrong in the AGA monitor drivers by not adding 1. Horizontal values are in dotclock cycles (35 ns), vertical values are in scanlines. (0, 0) is somewhere in the upper-left corner :-) Dependencies (AGA, SHRES (35 ns dotclock)) ------------------------------------------- Since there are much more parameters for the Amiga display than for the frame buffer interface, there must be some dependencies among the Amiga display parameters. Here's what I found out: - ddfstrt and ddfstop are best aligned to 64 pixels. |
f0058b4bb fbdev/amifb: Corr... |
214 215 216 217 |
- the chipset needs 64 + 4 horizontal pixels after the DMA start before the first pixel is output, so diwstrt_h = ddfstrt + 64 + 4 if you want to display the first pixel on the line too. Increase diwstrt_h for virtual screen panning. |
1da177e4c Linux-2.6.12-rc2 |
218 |
- the display DMA always fetches 64 pixels at a time (fmode = 3). |
f0058b4bb fbdev/amifb: Corr... |
219 220 221 |
- ddfstop is ddfstrt+#pixels - 64. - diwstop_h = diwstrt_h + xres + 1. Because of the additional 1 this can be 1 more than htotal. |
1da177e4c Linux-2.6.12-rc2 |
222 |
- hscroll simply adds a delay to the display output. Smooth horizontal |
f0058b4bb fbdev/amifb: Corr... |
223 224 |
panning needs an extra 64 pixels on the left to prefetch the pixels that `fall off' on the left. |
1da177e4c Linux-2.6.12-rc2 |
225 |
- if ddfstrt < 192, the sprite DMA cycles are all stolen by the bitplane |
f0058b4bb fbdev/amifb: Corr... |
226 |
DMA, so it's best to make the DMA start as late as possible. |
1da177e4c Linux-2.6.12-rc2 |
227 |
- you really don't want to make ddfstrt < 128, since this will steal DMA |
f0058b4bb fbdev/amifb: Corr... |
228 |
cycles from the other DMA channels (audio, floppy and Chip RAM refresh). |
1da177e4c Linux-2.6.12-rc2 |
229 230 231 232 233 234 |
- I make diwstop_h and diwstop_v as large as possible. General dependencies -------------------- - all values are SHRES pixel (35ns) |
f0058b4bb fbdev/amifb: Corr... |
235 236 |
table 1:fetchstart table 2:prefetch table 3:fetchsize ------------------ ---------------- ----------------- |
1da177e4c Linux-2.6.12-rc2 |
237 238 239 240 241 242 243 244 245 |
Pixclock # SHRES|HIRES|LORES # SHRES|HIRES|LORES # SHRES|HIRES|LORES -------------#------+-----+------#------+-----+------#------+-----+------ Bus width 1x # 16 | 32 | 64 # 16 | 32 | 64 # 64 | 64 | 64 Bus width 2x # 32 | 64 | 128 # 32 | 64 | 64 # 64 | 64 | 128 Bus width 4x # 64 | 128 | 256 # 64 | 64 | 64 # 64 | 128 | 256 - chipset needs 4 pixels before the first pixel is output - ddfstrt must be aligned to fetchstart (table 1) - chipset needs also prefetch (table 2) to get first pixel data, so |
f0058b4bb fbdev/amifb: Corr... |
246 |
ddfstrt = ((diwstrt_h - 4) & -fetchstart) - prefetch |
1da177e4c Linux-2.6.12-rc2 |
247 248 249 |
- for horizontal panning decrease diwstrt_h - the length of a fetchline must be aligned to fetchsize (table 3) - if fetchstart is smaller than fetchsize, then ddfstrt can a little bit |
f0058b4bb fbdev/amifb: Corr... |
250 251 |
moved to optimize use of dma (useful for OCS/ECS overscan displays) - ddfstop is ddfstrt + ddfsize - fetchsize |
1da177e4c Linux-2.6.12-rc2 |
252 |
- If C= didn't change anything for AGA, then at following positions the |
f0058b4bb fbdev/amifb: Corr... |
253 254 255 256 257 258 |
dma bus is already used: ddfstrt < 48 -> memory refresh < 96 -> disk dma < 160 -> audio dma < 192 -> sprite 0 dma < 416 -> sprite dma (32 per sprite) |
1da177e4c Linux-2.6.12-rc2 |
259 |
- in accordance with the hardware reference manual a hardware stop is at |
f0058b4bb fbdev/amifb: Corr... |
260 |
192, but AGA (ECS?) can go below this. |
1da177e4c Linux-2.6.12-rc2 |
261 262 263 264 265 266 267 268 269 |
DMA priorities -------------- Since there are limits on the earliest start value for display DMA and the display of sprites, I use the following policy on horizontal panning and the hardware cursor: - if you want to start display DMA too early, you lose the ability to |
f0058b4bb fbdev/amifb: Corr... |
270 |
do smooth horizontal panning (xpanstep 1 -> 64). |
1da177e4c Linux-2.6.12-rc2 |
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
- if you want to go even further, you lose the hardware cursor too. IMHO a hardware cursor is more important for X than horizontal scrolling, so that's my motivation. Implementation -------------- ami_decode_var() converts the frame buffer values to the Amiga values. It's just a `straightforward' implementation of the above rules. Standard VGA timings -------------------- |
f0058b4bb fbdev/amifb: Corr... |
286 287 |
xres yres left right upper lower hsync vsync ---- ---- ---- ----- ----- ----- ----- ----- |
1da177e4c Linux-2.6.12-rc2 |
288 289 290 291 292 293 294 295 |
80x25 720 400 27 45 35 12 108 2 80x30 720 480 27 45 30 9 108 2 These were taken from a XFree86 configuration file, recalculated for a 28 MHz dotclock (Amigas don't have a 25 MHz dotclock) and converted to frame buffer generic timings. As a comparison, graphics/monitor.h suggests the following: |
f0058b4bb fbdev/amifb: Corr... |
296 297 |
xres yres left right upper lower hsync vsync ---- ---- ---- ----- ----- ----- ----- ----- |
1da177e4c Linux-2.6.12-rc2 |
298 299 300 301 302 303 304 305 306 307 |
VGA 640 480 52 112 24 19 112 - 2 + VGA70 640 400 52 112 27 21 112 - 2 - Sync polarities --------------- VSYNC HSYNC Vertical size Vertical total ----- ----- ------------- -------------- |
f0058b4bb fbdev/amifb: Corr... |
308 309 310 311 |
+ + Reserved Reserved + - 400 414 - + 350 362 - - 480 496 |
1da177e4c Linux-2.6.12-rc2 |
312 313 314 315 316 317 318 319 320 321 322 |
Source: CL-GD542X Technical Reference Manual, Cirrus Logic, Oct 1992 Broadcast video timings ----------------------- According to the CCIR and RETMA specifications, we have the following values: CCIR -> PAL ----------- |
96de0e252 Convert files to ... |
323 |
- a scanline is 64 µs long, of which 52.48 µs are visible. This is about |
f0058b4bb fbdev/amifb: Corr... |
324 |
736 visible 70 ns pixels per line. |
1da177e4c Linux-2.6.12-rc2 |
325 |
- we have 625 scanlines, of which 575 are visible (interlaced); after |
f0058b4bb fbdev/amifb: Corr... |
326 |
rounding this becomes 576. |
1da177e4c Linux-2.6.12-rc2 |
327 328 329 |
RETMA -> NTSC ------------- |
96de0e252 Convert files to ... |
330 |
- a scanline is 63.5 µs long, of which 53.5 µs are visible. This is about |
f0058b4bb fbdev/amifb: Corr... |
331 |
736 visible 70 ns pixels per line. |
1da177e4c Linux-2.6.12-rc2 |
332 |
- we have 525 scanlines, of which 485 are visible (interlaced); after |
f0058b4bb fbdev/amifb: Corr... |
333 |
rounding this becomes 484. |
1da177e4c Linux-2.6.12-rc2 |
334 335 336 337 |
Thus if you want a PAL compatible display, you have to do the following: - set the FB_SYNC_BROADCAST flag to indicate that standard broadcast |
f0058b4bb fbdev/amifb: Corr... |
338 339 340 341 342 343 |
timings are to be used. - make sure upper_margin + yres + lower_margin + vsync_len = 625 for an interlaced, 312 for a non-interlaced and 156 for a doublescanned display. - make sure left_margin + xres + right_margin + hsync_len = 1816 for a SHRES, 908 for a HIRES and 454 for a LORES display. |
1da177e4c Linux-2.6.12-rc2 |
344 |
- the left visible part begins at 360 (SHRES; HIRES:180, LORES:90), |
f0058b4bb fbdev/amifb: Corr... |
345 |
left_margin + 2 * hsync_len must be greater or equal. |
1da177e4c Linux-2.6.12-rc2 |
346 |
- the upper visible part begins at 48 (interlaced; non-interlaced:24, |
f0058b4bb fbdev/amifb: Corr... |
347 348 |
doublescanned:12), upper_margin + 2 * vsync_len must be greater or equal. |
1da177e4c Linux-2.6.12-rc2 |
349 |
- ami_encode_var() calculates margins with a hsync of 5320 ns and a vsync |
f0058b4bb fbdev/amifb: Corr... |
350 |
of 4 scanlines |
1da177e4c Linux-2.6.12-rc2 |
351 352 353 354 355 356 |
The settings for a NTSC compatible display are straightforward. Note that in a strict sense the PAL and NTSC standards only define the encoding of the color part (chrominance) of the video signal and don't say anything about horizontal/vertical synchronization nor refresh rates. |
f0058b4bb fbdev/amifb: Corr... |
357 |
-- Geert -- |
1da177e4c Linux-2.6.12-rc2 |
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
*******************************************************************************/ /* * Custom Chipset Definitions */ #define CUSTOM_OFS(fld) ((long)&((struct CUSTOM*)0)->fld) /* * BPLCON0 -- Bitplane Control Register 0 */ #define BPC0_HIRES (0x8000) #define BPC0_BPU2 (0x4000) /* Bit plane used count */ #define BPC0_BPU1 (0x2000) #define BPC0_BPU0 (0x1000) #define BPC0_HAM (0x0800) /* HAM mode */ #define BPC0_DPF (0x0400) /* Double playfield */ #define BPC0_COLOR (0x0200) /* Enable colorburst */ #define BPC0_GAUD (0x0100) /* Genlock audio enable */ #define BPC0_UHRES (0x0080) /* Ultrahi res enable */ #define BPC0_SHRES (0x0040) /* Super hi res mode */ #define BPC0_BYPASS (0x0020) /* Bypass LUT - AGA */ #define BPC0_BPU3 (0x0010) /* AGA */ #define BPC0_LPEN (0x0008) /* Light pen enable */ #define BPC0_LACE (0x0004) /* Interlace */ #define BPC0_ERSY (0x0002) /* External resync */ #define BPC0_ECSENA (0x0001) /* ECS enable */ /* * BPLCON2 -- Bitplane Control Register 2 */ #define BPC2_ZDBPSEL2 (0x4000) /* Bitplane to be used for ZD - AGA */ #define BPC2_ZDBPSEL1 (0x2000) #define BPC2_ZDBPSEL0 (0x1000) #define BPC2_ZDBPEN (0x0800) /* Enable ZD with ZDBPSELx - AGA */ #define BPC2_ZDCTEN (0x0400) /* Enable ZD with palette bit #31 - AGA */ #define BPC2_KILLEHB (0x0200) /* Kill EHB mode - AGA */ #define BPC2_RDRAM (0x0100) /* Color table accesses read, not write - AGA */ #define BPC2_SOGEN (0x0080) /* SOG output pin high - AGA */ #define BPC2_PF2PRI (0x0040) /* PF2 priority over PF1 */ #define BPC2_PF2P2 (0x0020) /* PF2 priority wrt sprites */ #define BPC2_PF2P1 (0x0010) #define BPC2_PF2P0 (0x0008) #define BPC2_PF1P2 (0x0004) /* ditto PF1 */ #define BPC2_PF1P1 (0x0002) #define BPC2_PF1P0 (0x0001) /* * BPLCON3 -- Bitplane Control Register 3 (AGA) */ #define BPC3_BANK2 (0x8000) /* Bits to select color register bank */ #define BPC3_BANK1 (0x4000) #define BPC3_BANK0 (0x2000) #define BPC3_PF2OF2 (0x1000) /* Bits for color table offset when PF2 */ #define BPC3_PF2OF1 (0x0800) #define BPC3_PF2OF0 (0x0400) #define BPC3_LOCT (0x0200) /* Color register writes go to low bits */ #define BPC3_SPRES1 (0x0080) /* Sprite resolution bits */ #define BPC3_SPRES0 (0x0040) #define BPC3_BRDRBLNK (0x0020) /* Border blanked? */ #define BPC3_BRDRTRAN (0x0010) /* Border transparent? */ #define BPC3_ZDCLKEN (0x0004) /* ZD pin is 14 MHz (HIRES) clock output */ #define BPC3_BRDRSPRT (0x0002) /* Sprites in border? */ #define BPC3_EXTBLKEN (0x0001) /* BLANK programmable */ /* * BPLCON4 -- Bitplane Control Register 4 (AGA) */ #define BPC4_BPLAM7 (0x8000) /* bitplane color XOR field */ #define BPC4_BPLAM6 (0x4000) #define BPC4_BPLAM5 (0x2000) #define BPC4_BPLAM4 (0x1000) #define BPC4_BPLAM3 (0x0800) #define BPC4_BPLAM2 (0x0400) #define BPC4_BPLAM1 (0x0200) #define BPC4_BPLAM0 (0x0100) #define BPC4_ESPRM7 (0x0080) /* 4 high bits for even sprite colors */ #define BPC4_ESPRM6 (0x0040) #define BPC4_ESPRM5 (0x0020) #define BPC4_ESPRM4 (0x0010) #define BPC4_OSPRM7 (0x0008) /* 4 high bits for odd sprite colors */ #define BPC4_OSPRM6 (0x0004) #define BPC4_OSPRM5 (0x0002) #define BPC4_OSPRM4 (0x0001) /* * BEAMCON0 -- Beam Control Register */ #define BMC0_HARDDIS (0x4000) /* Disable hardware limits */ #define BMC0_LPENDIS (0x2000) /* Disable light pen latch */ #define BMC0_VARVBEN (0x1000) /* Enable variable vertical blank */ #define BMC0_LOLDIS (0x0800) /* Disable long/short line toggle */ #define BMC0_CSCBEN (0x0400) /* Composite sync/blank */ #define BMC0_VARVSYEN (0x0200) /* Enable variable vertical sync */ #define BMC0_VARHSYEN (0x0100) /* Enable variable horizontal sync */ #define BMC0_VARBEAMEN (0x0080) /* Enable variable beam counters */ #define BMC0_DUAL (0x0040) /* Enable alternate horizontal beam counter */ #define BMC0_PAL (0x0020) /* Set decodes for PAL */ #define BMC0_VARCSYEN (0x0010) /* Enable variable composite sync */ #define BMC0_BLANKEN (0x0008) /* Blank enable (no longer used on AGA) */ #define BMC0_CSYTRUE (0x0004) /* CSY polarity */ #define BMC0_VSYTRUE (0x0002) /* VSY polarity */ #define BMC0_HSYTRUE (0x0001) /* HSY polarity */ /* * FMODE -- Fetch Mode Control Register (AGA) */ #define FMODE_SSCAN2 (0x8000) /* Sprite scan-doubling */ #define FMODE_BSCAN2 (0x4000) /* Use PF2 modulus every other line */ #define FMODE_SPAGEM (0x0008) /* Sprite page mode */ #define FMODE_SPR32 (0x0004) /* Sprite 32 bit fetch */ #define FMODE_BPAGEM (0x0002) /* Bitplane page mode */ #define FMODE_BPL32 (0x0001) /* Bitplane 32 bit fetch */ /* * Tags used to indicate a specific Pixel Clock * * clk_shift is the shift value to get the timings in 35 ns units */ enum { TAG_SHRES, TAG_HIRES, TAG_LORES }; /* * Tags used to indicate the specific chipset */ enum { TAG_OCS, TAG_ECS, TAG_AGA }; /* * Tags used to indicate the memory bandwidth */ enum { TAG_FMODE_1, TAG_FMODE_2, TAG_FMODE_4 }; /* * Clock Definitions, Maximum Display Depth * * These depend on the E-Clock or the Chipset, so they are filled in * dynamically */ static u_long pixclock[3]; /* SHRES/HIRES/LORES: index = clk_shift */ static u_short maxdepth[3]; /* SHRES/HIRES/LORES: index = clk_shift */ static u_short maxfmode, chipset; /* * Broadcast Video Timings * * Horizontal values are in 35 ns (SHRES) units * Vertical values are in interlaced scanlines */ #define PAL_DIWSTRT_H (360) /* PAL Window Limits */ #define PAL_DIWSTRT_V (48) #define PAL_HTOTAL (1816) #define PAL_VTOTAL (625) #define NTSC_DIWSTRT_H (360) /* NTSC Window Limits */ #define NTSC_DIWSTRT_V (40) #define NTSC_HTOTAL (1816) #define NTSC_VTOTAL (525) /* * Various macros */ |
f0058b4bb fbdev/amifb: Corr... |
535 |
#define up2(v) (((v) + 1) & -2) |
1da177e4c Linux-2.6.12-rc2 |
536 537 538 |
#define down2(v) ((v) & -2) #define div2(v) ((v)>>1) #define mod2(v) ((v) & 1) |
f0058b4bb fbdev/amifb: Corr... |
539 |
#define up4(v) (((v) + 3) & -4) |
1da177e4c Linux-2.6.12-rc2 |
540 |
#define down4(v) ((v) & -4) |
f0058b4bb fbdev/amifb: Corr... |
541 |
#define mul4(v) ((v) << 2) |
1da177e4c Linux-2.6.12-rc2 |
542 543 |
#define div4(v) ((v)>>2) #define mod4(v) ((v) & 3) |
f0058b4bb fbdev/amifb: Corr... |
544 |
#define up8(v) (((v) + 7) & -8) |
1da177e4c Linux-2.6.12-rc2 |
545 546 547 |
#define down8(v) ((v) & -8) #define div8(v) ((v)>>3) #define mod8(v) ((v) & 7) |
f0058b4bb fbdev/amifb: Corr... |
548 |
#define up16(v) (((v) + 15) & -16) |
1da177e4c Linux-2.6.12-rc2 |
549 550 551 |
#define down16(v) ((v) & -16) #define div16(v) ((v)>>4) #define mod16(v) ((v) & 15) |
f0058b4bb fbdev/amifb: Corr... |
552 |
#define up32(v) (((v) + 31) & -32) |
1da177e4c Linux-2.6.12-rc2 |
553 554 555 |
#define down32(v) ((v) & -32) #define div32(v) ((v)>>5) #define mod32(v) ((v) & 31) |
f0058b4bb fbdev/amifb: Corr... |
556 |
#define up64(v) (((v) + 63) & -64) |
1da177e4c Linux-2.6.12-rc2 |
557 558 559 |
#define down64(v) ((v) & -64) #define div64(v) ((v)>>6) #define mod64(v) ((v) & 63) |
f0058b4bb fbdev/amifb: Corr... |
560 561 562 |
#define upx(x, v) (((v) + (x) - 1) & -(x)) #define downx(x, v) ((v) & -(x)) #define modx(x, v) ((v) & ((x) - 1)) |
1da177e4c Linux-2.6.12-rc2 |
563 564 565 566 |
/* if x1 is not a constant, this macro won't make real sense :-) */ #ifdef __mc68000__ #define DIVUL(x1, x2) ({int res; asm("divul %1,%2,%3": "=d" (res): \ |
f0058b4bb fbdev/amifb: Corr... |
567 |
"d" (x2), "d" ((long)((x1) / 0x100000000ULL)), "0" ((long)(x1))); res;}) |
1da177e4c Linux-2.6.12-rc2 |
568 569 570 571 572 573 574 575 |
#else /* We know a bit about the numbers, so we can do it this way */ #define DIVUL(x1, x2) ((((long)((unsigned long long)x1 >> 8) / x2) << 8) + \ ((((long)((unsigned long long)x1 >> 8) % x2) << 8) / x2)) #endif #define highw(x) ((u_long)(x)>>16 & 0xffff) #define loww(x) ((u_long)(x) & 0xffff) |
b4290a23c [PATCH] m68k: nam... |
576 |
#define custom amiga_custom |
1da177e4c Linux-2.6.12-rc2 |
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
#define VBlankOn() custom.intena = IF_SETCLR|IF_COPER #define VBlankOff() custom.intena = IF_COPER /* * Chip RAM we reserve for the Frame Buffer * * This defines the Maximum Virtual Screen Size * (Setable per kernel options?) */ #define VIDEOMEMSIZE_AGA_2M (1310720) /* AGA (2MB) : max 1280*1024*256 */ #define VIDEOMEMSIZE_AGA_1M (786432) /* AGA (1MB) : max 1024*768*256 */ #define VIDEOMEMSIZE_ECS_2M (655360) /* ECS (2MB) : max 1280*1024*16 */ #define VIDEOMEMSIZE_ECS_1M (393216) /* ECS (1MB) : max 1024*768*16 */ #define VIDEOMEMSIZE_OCS (262144) /* OCS : max ca. 800*600*16 */ |
f0058b4bb fbdev/amifb: Corr... |
593 |
#define SPRITEMEMSIZE (64 * 64 / 4) /* max 64*64*4 */ |
1da177e4c Linux-2.6.12-rc2 |
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
#define DUMMYSPRITEMEMSIZE (8) static u_long spritememory; #define CHIPRAM_SAFETY_LIMIT (16384) static u_long videomemory; /* * This is the earliest allowed start of fetching display data. * Only if you really want no hardware cursor and audio, * set this to 128, but let it better at 192 */ static u_long min_fstrt = 192; #define assignchunk(name, type, ptr, size) \ { \ (name) = (type)(ptr); \ ptr += size; \ } /* * Copper Instructions */ |
f0058b4bb fbdev/amifb: Corr... |
619 620 621 |
#define CMOVE(val, reg) (CUSTOM_OFS(reg) << 16 | (val)) #define CMOVE2(val, reg) ((CUSTOM_OFS(reg) + 2) << 16 | (val)) #define CWAIT(x, y) (((y) & 0x1fe) << 23 | ((x) & 0x7f0) << 13 | 0x0001fffe) |
1da177e4c Linux-2.6.12-rc2 |
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
#define CEND (0xfffffffe) typedef union { u_long l; u_short w[2]; } copins; static struct copdisplay { copins *init; copins *wait; copins *list[2][2]; copins *rebuild[2]; } copdisplay; static u_short currentcop = 0; /* * Hardware Cursor API Definitions * These used to be in linux/fb.h, but were preliminary and used by * amifb only anyway */ #define FBIOGET_FCURSORINFO 0x4607 #define FBIOGET_VCURSORINFO 0x4608 #define FBIOPUT_VCURSORINFO 0x4609 #define FBIOGET_CURSORSTATE 0x460A #define FBIOPUT_CURSORSTATE 0x460B struct fb_fix_cursorinfo { __u16 crsr_width; /* width and height of the cursor in */ __u16 crsr_height; /* pixels (zero if no cursor) */ __u16 crsr_xsize; /* cursor size in display pixels */ __u16 crsr_ysize; __u16 crsr_color1; /* colormap entry for cursor color1 */ __u16 crsr_color2; /* colormap entry for cursor color2 */ }; struct fb_var_cursorinfo { __u16 width; __u16 height; __u16 xspot; __u16 yspot; __u8 data[1]; /* field with [height][width] */ }; struct fb_cursorstate { __s16 xoffset; __s16 yoffset; __u16 mode; }; #define FB_CURSOR_OFF 0 #define FB_CURSOR_ON 1 #define FB_CURSOR_FLASH 2 /* * Hardware Cursor */ static int cursorrate = 20; /* Number of frames/flash toggle */ static u_short cursorstate = -1; static u_short cursormode = FB_CURSOR_OFF; static u_short *lofsprite, *shfsprite, *dummysprite; /* * Current Video Mode */ |
61640c295 fbdev/amifb: Use ... |
693 |
struct amifb_par { |
1da177e4c Linux-2.6.12-rc2 |
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 |
/* General Values */ int xres; /* vmode */ int yres; /* vmode */ int vxres; /* vmode */ int vyres; /* vmode */ int xoffset; /* vmode */ int yoffset; /* vmode */ u_short bpp; /* vmode */ u_short clk_shift; /* vmode */ u_short line_shift; /* vmode */ int vmode; /* vmode */ u_short diwstrt_h; /* vmode */ u_short diwstop_h; /* vmode */ u_short diwstrt_v; /* vmode */ u_short diwstop_v; /* vmode */ u_long next_line; /* modulo for next line */ u_long next_plane; /* modulo for next plane */ /* Cursor Values */ struct { short crsr_x; /* movecursor */ short crsr_y; /* movecursor */ short spot_x; short spot_y; u_short height; u_short width; u_short fmode; } crsr; /* OCS Hardware Registers */ u_long bplpt0; /* vmode, pan (Note: physical address) */ u_long bplpt0wrap; /* vmode, pan (Note: physical address) */ u_short ddfstrt; u_short ddfstop; u_short bpl1mod; u_short bpl2mod; u_short bplcon0; /* vmode */ u_short bplcon1; /* vmode */ u_short htotal; /* vmode */ u_short vtotal; /* vmode */ /* Additional ECS Hardware Registers */ u_short bplcon3; /* vmode */ u_short beamcon0; /* vmode */ u_short hsstrt; /* vmode */ u_short hsstop; /* vmode */ u_short hbstrt; /* vmode */ u_short hbstop; /* vmode */ u_short vsstrt; /* vmode */ u_short vsstop; /* vmode */ u_short vbstrt; /* vmode */ u_short vbstop; /* vmode */ u_short hcenter; /* vmode */ /* Additional AGA Hardware Registers */ u_short fmode; /* vmode */ |
1da177e4c Linux-2.6.12-rc2 |
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
}; /* * Saved color entry 0 so we can restore it when unblanking */ static u_char red0, green0, blue0; #if defined(CONFIG_FB_AMIGA_ECS) static u_short ecs_palette[32]; #endif /* * Latches for Display Changes during VBlank */ static u_short do_vmode_full = 0; /* Change the Video Mode */ static u_short do_vmode_pan = 0; /* Update the Video Mode */ |
96de0e252 Convert files to ... |
777 |
static short do_blank = 0; /* (Un)Blank the Screen (±1) */ |
1da177e4c Linux-2.6.12-rc2 |
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 |
static u_short do_cursor = 0; /* Move the Cursor */ /* * Various Flags */ static u_short is_blanked = 0; /* Screen is Blanked */ static u_short is_lace = 0; /* Screen is laced */ /* * Predefined Video Modes * */ static struct fb_videomode ami_modedb[] __initdata = { |
f0058b4bb fbdev/amifb: Corr... |
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 |
/* * AmigaOS Video Modes * * If you change these, make sure to update DEFMODE_* as well! */ { /* 640x200, 15 kHz, 60 Hz (NTSC) */ "ntsc", 60, 640, 200, TAG_HIRES, 106, 86, 44, 16, 76, 2, FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x400, 15 kHz, 60 Hz interlaced (NTSC) */ "ntsc-lace", 60, 640, 400, TAG_HIRES, 106, 86, 88, 33, 76, 4, FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP }, { /* 640x256, 15 kHz, 50 Hz (PAL) */ "pal", 50, 640, 256, TAG_HIRES, 106, 86, 40, 14, 76, 2, FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x512, 15 kHz, 50 Hz interlaced (PAL) */ "pal-lace", 50, 640, 512, TAG_HIRES, 106, 86, 80, 29, 76, 4, FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP }, { /* 640x480, 29 kHz, 57 Hz */ "multiscan", 57, 640, 480, TAG_SHRES, 96, 112, 29, 8, 72, 8, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x960, 29 kHz, 57 Hz interlaced */ "multiscan-lace", 57, 640, 960, TAG_SHRES, 96, 112, 58, 16, 72, 16, 0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP }, { /* 640x200, 15 kHz, 72 Hz */ "euro36", 72, 640, 200, TAG_HIRES, 92, 124, 6, 6, 52, 5, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x400, 15 kHz, 72 Hz interlaced */ "euro36-lace", 72, 640, 400, TAG_HIRES, 92, 124, 12, 12, 52, 10, 0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP }, { /* 640x400, 29 kHz, 68 Hz */ "euro72", 68, 640, 400, TAG_SHRES, 164, 92, 9, 9, 80, 8, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x800, 29 kHz, 68 Hz interlaced */ "euro72-lace", 68, 640, 800, TAG_SHRES, 164, 92, 18, 18, 80, 16, 0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP }, { /* 800x300, 23 kHz, 70 Hz */ "super72", 70, 800, 300, TAG_SHRES, 212, 140, 10, 11, 80, 7, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 800x600, 23 kHz, 70 Hz interlaced */ "super72-lace", 70, 800, 600, TAG_SHRES, 212, 140, 20, 22, 80, 14, 0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP }, { /* 640x200, 27 kHz, 57 Hz doublescan */ "dblntsc", 57, 640, 200, TAG_SHRES, 196, 124, 18, 17, 80, 4, 0, FB_VMODE_DOUBLE | FB_VMODE_YWRAP }, { /* 640x400, 27 kHz, 57 Hz */ "dblntsc-ff", 57, 640, 400, TAG_SHRES, 196, 124, 36, 35, 80, 7, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x800, 27 kHz, 57 Hz interlaced */ "dblntsc-lace", 57, 640, 800, TAG_SHRES, 196, 124, 72, 70, 80, 14, 0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP }, { /* 640x256, 27 kHz, 47 Hz doublescan */ "dblpal", 47, 640, 256, TAG_SHRES, 196, 124, 14, 13, 80, 4, 0, FB_VMODE_DOUBLE | FB_VMODE_YWRAP }, { /* 640x512, 27 kHz, 47 Hz */ "dblpal-ff", 47, 640, 512, TAG_SHRES, 196, 124, 28, 27, 80, 7, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x1024, 27 kHz, 47 Hz interlaced */ "dblpal-lace", 47, 640, 1024, TAG_SHRES, 196, 124, 56, 54, 80, 14, 0, FB_VMODE_INTERLACED | FB_VMODE_YWRAP }, /* * VGA Video Modes */ { /* 640x480, 31 kHz, 60 Hz (VGA) */ "vga", 60, 640, 480, TAG_SHRES, 64, 96, 30, 9, 112, 2, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 640x400, 31 kHz, 70 Hz (VGA) */ "vga70", 70, 640, 400, TAG_SHRES, 64, 96, 35, 12, 112, 2, FB_SYNC_VERT_HIGH_ACT | FB_SYNC_COMP_HIGH_ACT, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, |
1da177e4c Linux-2.6.12-rc2 |
894 895 |
#if 0 |
f0058b4bb fbdev/amifb: Corr... |
896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
/* * A2024 video modes * These modes don't work yet because there's no A2024 driver. */ { /* 1024x800, 10 Hz */ "a2024-10", 10, 1024, 800, TAG_HIRES, 0, 0, 0, 0, 0, 0, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP }, { /* 1024x800, 15 Hz */ "a2024-15", 15, 1024, 800, TAG_HIRES, 0, 0, 0, 0, 0, 0, 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP } |
1da177e4c Linux-2.6.12-rc2 |
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
#endif }; #define NUM_TOTAL_MODES ARRAY_SIZE(ami_modedb) static char *mode_option __initdata = NULL; static int round_down_bpp = 1; /* for mode probing */ /* * Some default modes */ #define DEFMODE_PAL 2 /* "pal" for PAL OCS/ECS */ #define DEFMODE_NTSC 0 /* "ntsc" for NTSC OCS/ECS */ #define DEFMODE_AMBER_PAL 3 /* "pal-lace" for flicker fixed PAL (A3000) */ #define DEFMODE_AMBER_NTSC 1 /* "ntsc-lace" for flicker fixed NTSC (A3000) */ #define DEFMODE_AGA 19 /* "vga70" for AGA */ static int amifb_ilbm = 0; /* interleaved or normal bitplanes */ static int amifb_inverse = 0; |
03c740a04 fbdev/amifb: Stor... |
932 933 934 935 |
static u32 amifb_hfmin __initdata; /* monitor hfreq lower limit (Hz) */ static u32 amifb_hfmax __initdata; /* monitor hfreq upper limit (Hz) */ static u16 amifb_vfmin __initdata; /* monitor vfreq lower limit (Hz) */ static u16 amifb_vfmax __initdata; /* monitor vfreq upper limit (Hz) */ |
1da177e4c Linux-2.6.12-rc2 |
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 |
/* * Macros for the conversion from real world values to hardware register * values * * This helps us to keep our attention on the real stuff... * * Hardware limits for AGA: * * parameter min max step * --------- --- ---- ---- * diwstrt_h 0 2047 1 * diwstrt_v 0 2047 1 * diwstop_h 0 4095 1 * diwstop_v 0 4095 1 * * ddfstrt 0 2032 16 * ddfstop 0 2032 16 * * htotal 8 2048 8 * hsstrt 0 2040 8 * hsstop 0 2040 8 * vtotal 1 4096 1 * vsstrt 0 4095 1 * vsstop 0 4095 1 * hcenter 0 2040 8 * * hbstrt 0 2047 1 * hbstop 0 2047 1 * vbstrt 0 4095 1 * vbstop 0 4095 1 * * Horizontal values are in 35 ns (SHRES) pixels * Vertical values are in half scanlines */ /* bplcon1 (smooth scrolling) */ #define hscroll2hw(hscroll) \ |
f0058b4bb fbdev/amifb: Corr... |
975 976 977 |
(((hscroll) << 12 & 0x3000) | ((hscroll) << 8 & 0xc300) | \ ((hscroll) << 4 & 0x0c00) | ((hscroll) << 2 & 0x00f0) | \ ((hscroll)>>2 & 0x000f)) |
1da177e4c Linux-2.6.12-rc2 |
978 979 980 981 |
/* diwstrt/diwstop/diwhigh (visible display window) */ #define diwstrt2hw(diwstrt_h, diwstrt_v) \ |
f0058b4bb fbdev/amifb: Corr... |
982 |
(((diwstrt_v) << 7 & 0xff00) | ((diwstrt_h)>>2 & 0x00ff)) |
1da177e4c Linux-2.6.12-rc2 |
983 |
#define diwstop2hw(diwstop_h, diwstop_v) \ |
f0058b4bb fbdev/amifb: Corr... |
984 |
(((diwstop_v) << 7 & 0xff00) | ((diwstop_h)>>2 & 0x00ff)) |
1da177e4c Linux-2.6.12-rc2 |
985 |
#define diwhigh2hw(diwstrt_h, diwstrt_v, diwstop_h, diwstop_v) \ |
f0058b4bb fbdev/amifb: Corr... |
986 |
(((diwstop_h) << 3 & 0x2000) | ((diwstop_h) << 11 & 0x1800) | \ |
1da177e4c Linux-2.6.12-rc2 |
987 |
((diwstop_v)>>1 & 0x0700) | ((diwstrt_h)>>5 & 0x0020) | \ |
f0058b4bb fbdev/amifb: Corr... |
988 |
((diwstrt_h) << 3 & 0x0018) | ((diwstrt_v)>>9 & 0x0007)) |
1da177e4c Linux-2.6.12-rc2 |
989 990 991 992 993 994 995 996 997 998 |
/* ddfstrt/ddfstop (display DMA) */ #define ddfstrt2hw(ddfstrt) div8(ddfstrt) #define ddfstop2hw(ddfstop) div8(ddfstop) /* hsstrt/hsstop/htotal/vsstrt/vsstop/vtotal/hcenter (sync timings) */ #define hsstrt2hw(hsstrt) (div8(hsstrt)) #define hsstop2hw(hsstop) (div8(hsstop)) |
f0058b4bb fbdev/amifb: Corr... |
999 |
#define htotal2hw(htotal) (div8(htotal) - 1) |
1da177e4c Linux-2.6.12-rc2 |
1000 1001 |
#define vsstrt2hw(vsstrt) (div2(vsstrt)) #define vsstop2hw(vsstop) (div2(vsstop)) |
f0058b4bb fbdev/amifb: Corr... |
1002 |
#define vtotal2hw(vtotal) (div2(vtotal) - 1) |
1da177e4c Linux-2.6.12-rc2 |
1003 1004 1005 |
#define hcenter2hw(htotal) (div8(htotal)) /* hbstrt/hbstop/vbstrt/vbstop (blanking timings) */ |
f0058b4bb fbdev/amifb: Corr... |
1006 1007 |
#define hbstrt2hw(hbstrt) (((hbstrt) << 8 & 0x0700) | ((hbstrt)>>3 & 0x00ff)) #define hbstop2hw(hbstop) (((hbstop) << 8 & 0x0700) | ((hbstop)>>3 & 0x00ff)) |
1da177e4c Linux-2.6.12-rc2 |
1008 1009 1010 1011 1012 1013 |
#define vbstrt2hw(vbstrt) (div2(vbstrt)) #define vbstop2hw(vbstop) (div2(vbstop)) /* colour */ #define rgb2hw8_high(red, green, blue) \ |
f0058b4bb fbdev/amifb: Corr... |
1014 |
(((red & 0xf0) << 4) | (green & 0xf0) | ((blue & 0xf0)>>4)) |
1da177e4c Linux-2.6.12-rc2 |
1015 |
#define rgb2hw8_low(red, green, blue) \ |
f0058b4bb fbdev/amifb: Corr... |
1016 |
(((red & 0x0f) << 8) | ((green & 0x0f) << 4) | (blue & 0x0f)) |
1da177e4c Linux-2.6.12-rc2 |
1017 |
#define rgb2hw4(red, green, blue) \ |
f0058b4bb fbdev/amifb: Corr... |
1018 |
(((red & 0xf0) << 4) | (green & 0xf0) | ((blue & 0xf0)>>4)) |
1da177e4c Linux-2.6.12-rc2 |
1019 |
#define rgb2hw2(red, green, blue) \ |
f0058b4bb fbdev/amifb: Corr... |
1020 |
(((red & 0xc0) << 4) | (green & 0xc0) | ((blue & 0xc0)>>4)) |
1da177e4c Linux-2.6.12-rc2 |
1021 1022 1023 1024 |
/* sprpos/sprctl (sprite positioning) */ #define spr2hw_pos(start_v, start_h) \ |
f0058b4bb fbdev/amifb: Corr... |
1025 |
(((start_v) << 7 & 0xff00) | ((start_h)>>3 & 0x00ff)) |
1da177e4c Linux-2.6.12-rc2 |
1026 |
#define spr2hw_ctl(start_v, start_h, stop_v) \ |
f0058b4bb fbdev/amifb: Corr... |
1027 1028 1029 1030 |
(((stop_v) << 7 & 0xff00) | ((start_v)>>4 & 0x0040) | \ ((stop_v)>>5 & 0x0020) | ((start_h) << 3 & 0x0018) | \ ((start_v)>>7 & 0x0004) | ((stop_v)>>8 & 0x0002) | \ ((start_h)>>2 & 0x0001)) |
1da177e4c Linux-2.6.12-rc2 |
1031 1032 1033 1034 1035 1036 1037 |
/* get current vertical position of beam */ #define get_vbpos() ((u_short)((*(u_long volatile *)&custom.vposr >> 7) & 0xffe)) /* * Copper Initialisation List */ |
f0058b4bb fbdev/amifb: Corr... |
1038 |
#define COPINITSIZE (sizeof(copins) * 40) |
1da177e4c Linux-2.6.12-rc2 |
1039 1040 1041 1042 1043 1044 1045 1046 1047 |
enum { cip_bplcon0 }; /* * Long Frame/Short Frame Copper List * Don't change the order, build_copper()/rebuild_copper() rely on this */ |
f0058b4bb fbdev/amifb: Corr... |
1048 |
#define COPLISTSIZE (sizeof(copins) * 64) |
1da177e4c Linux-2.6.12-rc2 |
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 |
enum { cop_wait, cop_bplcon0, cop_spr0ptrh, cop_spr0ptrl, cop_diwstrt, cop_diwstop, cop_diwhigh, }; /* * Pixel modes for Bitplanes and Sprites */ static u_short bplpixmode[3] = { BPC0_SHRES, /* 35 ns */ BPC0_HIRES, /* 70 ns */ 0 /* 140 ns */ }; static u_short sprpixmode[3] = { BPC3_SPRES1 | BPC3_SPRES0, /* 35 ns */ BPC3_SPRES1, /* 70 ns */ BPC3_SPRES0 /* 140 ns */ }; /* * Fetch modes for Bitplanes and Sprites */ static u_short bplfetchmode[3] = { 0, /* 1x */ FMODE_BPL32, /* 2x */ FMODE_BPAGEM | FMODE_BPL32 /* 4x */ }; static u_short sprfetchmode[3] = { 0, /* 1x */ FMODE_SPR32, /* 2x */ FMODE_SPAGEM | FMODE_SPR32 /* 4x */ }; |
f1cbb17ac fbdev/amifb: Reor... |
1088 |
/* --------------------------- Hardware routines --------------------------- */ |
1da177e4c Linux-2.6.12-rc2 |
1089 1090 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
1091 1092 |
* Get the video params out of `var'. If a value doesn't fit, round * it up, if it's too big, return -EINVAL. |
1da177e4c Linux-2.6.12-rc2 |
1093 |
*/ |
61640c295 fbdev/amifb: Use ... |
1094 1095 |
static int ami_decode_var(struct fb_var_screeninfo *var, struct amifb_par *par, const struct fb_info *info) |
1da177e4c Linux-2.6.12-rc2 |
1096 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
1097 1098 1099 |
u_short clk_shift, line_shift; u_long maxfetchstop, fstrt, fsize, fconst, xres_n, yres_n; u_int htotal, vtotal; |
1da177e4c Linux-2.6.12-rc2 |
1100 |
|
f1cbb17ac fbdev/amifb: Reor... |
1101 1102 |
/* * Find a matching Pixel Clock |
1da177e4c Linux-2.6.12-rc2 |
1103 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
1104 1105 1106 1107 1108 1109 1110 |
for (clk_shift = TAG_SHRES; clk_shift <= TAG_LORES; clk_shift++) if (var->pixclock <= pixclock[clk_shift]) break; if (clk_shift > TAG_LORES) { DPRINTK("pixclock too high "); return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
1111 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1112 |
par->clk_shift = clk_shift; |
1da177e4c Linux-2.6.12-rc2 |
1113 |
|
f1cbb17ac fbdev/amifb: Reor... |
1114 1115 1116 |
/* * Check the Geometry Values */ |
1da177e4c Linux-2.6.12-rc2 |
1117 |
|
f1cbb17ac fbdev/amifb: Reor... |
1118 1119 1120 1121 1122 1123 1124 1125 |
if ((par->xres = var->xres) < 64) par->xres = 64; if ((par->yres = var->yres) < 64) par->yres = 64; if ((par->vxres = var->xres_virtual) < par->xres) par->vxres = par->xres; if ((par->vyres = var->yres_virtual) < par->yres) par->vyres = par->yres; |
1da177e4c Linux-2.6.12-rc2 |
1126 |
|
f1cbb17ac fbdev/amifb: Reor... |
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
par->bpp = var->bits_per_pixel; if (!var->nonstd) { if (par->bpp < 1) par->bpp = 1; if (par->bpp > maxdepth[clk_shift]) { if (round_down_bpp && maxdepth[clk_shift]) par->bpp = maxdepth[clk_shift]; else { DPRINTK("invalid bpp "); return -EINVAL; } } } else if (var->nonstd == FB_NONSTD_HAM) { if (par->bpp < 6) par->bpp = 6; if (par->bpp != 6) { if (par->bpp < 8) par->bpp = 8; if (par->bpp != 8 || !IS_AGA) { DPRINTK("invalid bpp for ham mode "); return -EINVAL; } } |
1da177e4c Linux-2.6.12-rc2 |
1152 |
} else { |
f1cbb17ac fbdev/amifb: Reor... |
1153 1154 1155 |
DPRINTK("unknown nonstd mode "); return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
1156 |
} |
1da177e4c Linux-2.6.12-rc2 |
1157 1158 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
1159 1160 |
* FB_VMODE_SMOOTH_XPAN will be cleared, if one of the folloing * checks failed and smooth scrolling is not possible |
1da177e4c Linux-2.6.12-rc2 |
1161 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 |
par->vmode = var->vmode | FB_VMODE_SMOOTH_XPAN; switch (par->vmode & FB_VMODE_MASK) { case FB_VMODE_INTERLACED: line_shift = 0; break; case FB_VMODE_NONINTERLACED: line_shift = 1; break; case FB_VMODE_DOUBLE: if (!IS_AGA) { DPRINTK("double mode only possible with aga "); |
1da177e4c Linux-2.6.12-rc2 |
1174 |
return -EINVAL; |
f1cbb17ac fbdev/amifb: Reor... |
1175 1176 1177 1178 1179 1180 1181 1182 |
} line_shift = 2; break; default: DPRINTK("unknown video mode "); return -EINVAL; break; |
1da177e4c Linux-2.6.12-rc2 |
1183 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1184 |
par->line_shift = line_shift; |
1da177e4c Linux-2.6.12-rc2 |
1185 |
|
f1cbb17ac fbdev/amifb: Reor... |
1186 1187 1188 |
/* * Vertical and Horizontal Timings */ |
1da177e4c Linux-2.6.12-rc2 |
1189 |
|
f1cbb17ac fbdev/amifb: Reor... |
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 |
xres_n = par->xres << clk_shift; yres_n = par->yres << line_shift; par->htotal = down8((var->left_margin + par->xres + var->right_margin + var->hsync_len) << clk_shift); par->vtotal = down2(((var->upper_margin + par->yres + var->lower_margin + var->vsync_len) << line_shift) + 1); if (IS_AGA) par->bplcon3 = sprpixmode[clk_shift]; else par->bplcon3 = 0; if (var->sync & FB_SYNC_BROADCAST) { par->diwstop_h = par->htotal - ((var->right_margin - var->hsync_len) << clk_shift); if (IS_AGA) par->diwstop_h += mod4(var->hsync_len); else par->diwstop_h = down4(par->diwstop_h); par->diwstrt_h = par->diwstop_h - xres_n; par->diwstop_v = par->vtotal - ((var->lower_margin - var->vsync_len) << line_shift); par->diwstrt_v = par->diwstop_v - yres_n; if (par->diwstop_h >= par->htotal + 8) { DPRINTK("invalid diwstop_h "); return -EINVAL; } if (par->diwstop_v > par->vtotal) { DPRINTK("invalid diwstop_v "); return -EINVAL; } |
1da177e4c Linux-2.6.12-rc2 |
1224 |
|
f1cbb17ac fbdev/amifb: Reor... |
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 |
if (!IS_OCS) { /* Initialize sync with some reasonable values for pwrsave */ par->hsstrt = 160; par->hsstop = 320; par->vsstrt = 30; par->vsstop = 34; } else { par->hsstrt = 0; par->hsstop = 0; par->vsstrt = 0; par->vsstop = 0; } if (par->vtotal > (PAL_VTOTAL + NTSC_VTOTAL) / 2) { /* PAL video mode */ if (par->htotal != PAL_HTOTAL) { DPRINTK("htotal invalid for pal "); return -EINVAL; } if (par->diwstrt_h < PAL_DIWSTRT_H) { DPRINTK("diwstrt_h too low for pal "); return -EINVAL; } if (par->diwstrt_v < PAL_DIWSTRT_V) { DPRINTK("diwstrt_v too low for pal "); return -EINVAL; } htotal = PAL_HTOTAL>>clk_shift; vtotal = PAL_VTOTAL>>1; if (!IS_OCS) { par->beamcon0 = BMC0_PAL; par->bplcon3 |= BPC3_BRDRBLNK; } else if (AMIGAHW_PRESENT(AGNUS_HR_PAL) || AMIGAHW_PRESENT(AGNUS_HR_NTSC)) { par->beamcon0 = BMC0_PAL; par->hsstop = 1; } else if (amiga_vblank != 50) { DPRINTK("pal not supported by this chipset "); return -EINVAL; } } else { /* NTSC video mode * In the AGA chipset seems to be hardware bug with BPC3_BRDRBLNK * and NTSC activated, so than better let diwstop_h <= 1812 */ if (par->htotal != NTSC_HTOTAL) { DPRINTK("htotal invalid for ntsc "); return -EINVAL; } if (par->diwstrt_h < NTSC_DIWSTRT_H) { DPRINTK("diwstrt_h too low for ntsc "); return -EINVAL; } if (par->diwstrt_v < NTSC_DIWSTRT_V) { DPRINTK("diwstrt_v too low for ntsc "); return -EINVAL; } htotal = NTSC_HTOTAL>>clk_shift; vtotal = NTSC_VTOTAL>>1; if (!IS_OCS) { par->beamcon0 = 0; par->bplcon3 |= BPC3_BRDRBLNK; } else if (AMIGAHW_PRESENT(AGNUS_HR_PAL) || AMIGAHW_PRESENT(AGNUS_HR_NTSC)) { par->beamcon0 = 0; par->hsstop = 1; } else if (amiga_vblank != 60) { DPRINTK("ntsc not supported by this chipset "); return -EINVAL; } } if (IS_OCS) { if (par->diwstrt_h >= 1024 || par->diwstop_h < 1024 || par->diwstrt_v >= 512 || par->diwstop_v < 256) { DPRINTK("invalid position for display on ocs "); return -EINVAL; } } } else if (!IS_OCS) { /* Programmable video mode */ par->hsstrt = var->right_margin << clk_shift; par->hsstop = (var->right_margin + var->hsync_len) << clk_shift; par->diwstop_h = par->htotal - mod8(par->hsstrt) + 8 - (1 << clk_shift); if (!IS_AGA) par->diwstop_h = down4(par->diwstop_h) - 16; par->diwstrt_h = par->diwstop_h - xres_n; par->hbstop = par->diwstrt_h + 4; par->hbstrt = par->diwstop_h + 4; if (par->hbstrt >= par->htotal + 8) par->hbstrt -= par->htotal; par->hcenter = par->hsstrt + (par->htotal >> 1); par->vsstrt = var->lower_margin << line_shift; par->vsstop = (var->lower_margin + var->vsync_len) << line_shift; par->diwstop_v = par->vtotal; if ((par->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) par->diwstop_v -= 2; par->diwstrt_v = par->diwstop_v - yres_n; par->vbstop = par->diwstrt_v - 2; par->vbstrt = par->diwstop_v - 2; if (par->vtotal > 2048) { DPRINTK("vtotal too high "); return -EINVAL; } if (par->htotal > 2048) { DPRINTK("htotal too high "); return -EINVAL; } par->bplcon3 |= BPC3_EXTBLKEN; par->beamcon0 = BMC0_HARDDIS | BMC0_VARVBEN | BMC0_LOLDIS | BMC0_VARVSYEN | BMC0_VARHSYEN | BMC0_VARBEAMEN | BMC0_PAL | BMC0_VARCSYEN; if (var->sync & FB_SYNC_HOR_HIGH_ACT) par->beamcon0 |= BMC0_HSYTRUE; if (var->sync & FB_SYNC_VERT_HIGH_ACT) par->beamcon0 |= BMC0_VSYTRUE; if (var->sync & FB_SYNC_COMP_HIGH_ACT) par->beamcon0 |= BMC0_CSYTRUE; htotal = par->htotal>>clk_shift; vtotal = par->vtotal>>1; } else { DPRINTK("only broadcast modes possible for ocs "); return -EINVAL; } |
1da177e4c Linux-2.6.12-rc2 |
1359 |
|
f0058b4bb fbdev/amifb: Corr... |
1360 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
1361 |
* Checking the DMA timing |
f0058b4bb fbdev/amifb: Corr... |
1362 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
1363 |
|
f1cbb17ac fbdev/amifb: Reor... |
1364 |
fconst = 16 << maxfmode << clk_shift; |
1da177e4c Linux-2.6.12-rc2 |
1365 |
|
f1cbb17ac fbdev/amifb: Reor... |
1366 1367 1368 1369 |
/* * smallest window start value without turn off other dma cycles * than sprite1-7, unless you change min_fstrt */ |
1da177e4c Linux-2.6.12-rc2 |
1370 |
|
1da177e4c Linux-2.6.12-rc2 |
1371 |
|
f1cbb17ac fbdev/amifb: Reor... |
1372 1373 1374 1375 1376 1377 1378 |
fsize = ((maxfmode + clk_shift <= 1) ? fconst : 64); fstrt = downx(fconst, par->diwstrt_h - 4) - fsize; if (fstrt < min_fstrt) { DPRINTK("fetch start too low "); return -EINVAL; } |
1da177e4c Linux-2.6.12-rc2 |
1379 |
|
f0058b4bb fbdev/amifb: Corr... |
1380 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
1381 |
* smallest window start value where smooth scrolling is possible |
f0058b4bb fbdev/amifb: Corr... |
1382 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
1383 |
|
f1cbb17ac fbdev/amifb: Reor... |
1384 1385 1386 1387 |
fstrt = downx(fconst, par->diwstrt_h - fconst + (1 << clk_shift) - 4) - fsize; if (fstrt < min_fstrt) par->vmode &= ~FB_VMODE_SMOOTH_XPAN; |
1da177e4c Linux-2.6.12-rc2 |
1388 |
|
f1cbb17ac fbdev/amifb: Reor... |
1389 |
maxfetchstop = down16(par->htotal - 80); |
1da177e4c Linux-2.6.12-rc2 |
1390 |
|
f1cbb17ac fbdev/amifb: Reor... |
1391 1392 1393 1394 1395 |
fstrt = downx(fconst, par->diwstrt_h - 4) - 64 - fconst; fsize = upx(fconst, xres_n + modx(fconst, downx(1 << clk_shift, par->diwstrt_h - 4))); if (fstrt + fsize > maxfetchstop) par->vmode &= ~FB_VMODE_SMOOTH_XPAN; |
1da177e4c Linux-2.6.12-rc2 |
1396 |
|
f1cbb17ac fbdev/amifb: Reor... |
1397 1398 1399 1400 1401 1402 |
fsize = upx(fconst, xres_n); if (fstrt + fsize > maxfetchstop) { DPRINTK("fetch stop too high "); return -EINVAL; } |
1da177e4c Linux-2.6.12-rc2 |
1403 |
|
f1cbb17ac fbdev/amifb: Reor... |
1404 1405 1406 1407 |
if (maxfmode + clk_shift <= 1) { fsize = up64(xres_n + fconst - 1); if (min_fstrt + fsize - 64 > maxfetchstop) par->vmode &= ~FB_VMODE_SMOOTH_XPAN; |
1da177e4c Linux-2.6.12-rc2 |
1408 |
|
f1cbb17ac fbdev/amifb: Reor... |
1409 1410 1411 1412 1413 1414 |
fsize = up64(xres_n); if (min_fstrt + fsize - 64 > maxfetchstop) { DPRINTK("fetch size too high "); return -EINVAL; } |
1da177e4c Linux-2.6.12-rc2 |
1415 |
|
f1cbb17ac fbdev/amifb: Reor... |
1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 |
fsize -= 64; } else fsize -= fconst; /* * Check if there is enough time to update the bitplane pointers for ywrap */ if (par->htotal - fsize - 64 < par->bpp * 64) par->vmode &= ~FB_VMODE_YWRAP; /* * Bitplane calculations and check the Memory Requirements */ if (amifb_ilbm) { par->next_plane = div8(upx(16 << maxfmode, par->vxres)); par->next_line = par->bpp * par->next_plane; |
61640c295 fbdev/amifb: Use ... |
1434 |
if (par->next_line * par->vyres > info->fix.smem_len) { |
f1cbb17ac fbdev/amifb: Reor... |
1435 1436 1437 |
DPRINTK("too few video mem "); return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
1438 1439 |
} } else { |
f1cbb17ac fbdev/amifb: Reor... |
1440 1441 |
par->next_line = div8(upx(16 << maxfmode, par->vxres)); par->next_plane = par->vyres * par->next_line; |
61640c295 fbdev/amifb: Use ... |
1442 |
if (par->next_plane * par->bpp > info->fix.smem_len) { |
f1cbb17ac fbdev/amifb: Reor... |
1443 1444 1445 1446 1447 |
DPRINTK("too few video mem "); return -EINVAL; } } |
1da177e4c Linux-2.6.12-rc2 |
1448 |
|
f1cbb17ac fbdev/amifb: Reor... |
1449 1450 1451 |
/* * Hardware Register Values */ |
1da177e4c Linux-2.6.12-rc2 |
1452 |
|
f1cbb17ac fbdev/amifb: Reor... |
1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 |
par->bplcon0 = BPC0_COLOR | bplpixmode[clk_shift]; if (!IS_OCS) par->bplcon0 |= BPC0_ECSENA; if (par->bpp == 8) par->bplcon0 |= BPC0_BPU3; else par->bplcon0 |= par->bpp << 12; if (var->nonstd == FB_NONSTD_HAM) par->bplcon0 |= BPC0_HAM; if (var->sync & FB_SYNC_EXT) par->bplcon0 |= BPC0_ERSY; |
1da177e4c Linux-2.6.12-rc2 |
1464 |
|
f1cbb17ac fbdev/amifb: Reor... |
1465 1466 |
if (IS_AGA) par->fmode = bplfetchmode[maxfmode]; |
1da177e4c Linux-2.6.12-rc2 |
1467 |
|
f1cbb17ac fbdev/amifb: Reor... |
1468 1469 1470 1471 1472 1473 1474 1475 |
switch (par->vmode & FB_VMODE_MASK) { case FB_VMODE_INTERLACED: par->bplcon0 |= BPC0_LACE; break; case FB_VMODE_DOUBLE: if (IS_AGA) par->fmode |= FMODE_SSCAN2 | FMODE_BSCAN2; break; |
1da177e4c Linux-2.6.12-rc2 |
1476 |
} |
1da177e4c Linux-2.6.12-rc2 |
1477 |
|
f1cbb17ac fbdev/amifb: Reor... |
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 |
if (!((par->vmode ^ var->vmode) & FB_VMODE_YWRAP)) { par->xoffset = var->xoffset; par->yoffset = var->yoffset; if (par->vmode & FB_VMODE_YWRAP) { if (par->xoffset || par->yoffset < 0 || par->yoffset >= par->vyres) par->xoffset = par->yoffset = 0; } else { if (par->xoffset < 0 || par->xoffset > upx(16 << maxfmode, par->vxres - par->xres) || par->yoffset < 0 || par->yoffset > par->vyres - par->yres) par->xoffset = par->yoffset = 0; } } else par->xoffset = par->yoffset = 0; par->crsr.crsr_x = par->crsr.crsr_y = 0; par->crsr.spot_x = par->crsr.spot_y = 0; par->crsr.height = par->crsr.width = 0; return 0; } |
1da177e4c Linux-2.6.12-rc2 |
1500 |
|
f0058b4bb fbdev/amifb: Corr... |
1501 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
1502 1503 |
* Fill the `var' structure based on the values in `par' and maybe * other values read out of the hardware. |
f0058b4bb fbdev/amifb: Corr... |
1504 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
1505 |
|
61640c295 fbdev/amifb: Use ... |
1506 1507 |
static void ami_encode_var(struct fb_var_screeninfo *var, struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
1508 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
1509 |
u_short clk_shift, line_shift; |
1da177e4c Linux-2.6.12-rc2 |
1510 |
|
f1cbb17ac fbdev/amifb: Reor... |
1511 |
memset(var, 0, sizeof(struct fb_var_screeninfo)); |
1da177e4c Linux-2.6.12-rc2 |
1512 |
|
f1cbb17ac fbdev/amifb: Reor... |
1513 1514 |
clk_shift = par->clk_shift; line_shift = par->line_shift; |
1da177e4c Linux-2.6.12-rc2 |
1515 |
|
f1cbb17ac fbdev/amifb: Reor... |
1516 1517 1518 1519 1520 1521 |
var->xres = par->xres; var->yres = par->yres; var->xres_virtual = par->vxres; var->yres_virtual = par->vyres; var->xoffset = par->xoffset; var->yoffset = par->yoffset; |
1da177e4c Linux-2.6.12-rc2 |
1522 |
|
f1cbb17ac fbdev/amifb: Reor... |
1523 1524 |
var->bits_per_pixel = par->bpp; var->grayscale = 0; |
1da177e4c Linux-2.6.12-rc2 |
1525 |
|
f1cbb17ac fbdev/amifb: Reor... |
1526 1527 1528 1529 1530 1531 1532 1533 1534 |
var->red.offset = 0; var->red.msb_right = 0; var->red.length = par->bpp; if (par->bplcon0 & BPC0_HAM) var->red.length -= 2; var->blue = var->green = var->red; var->transp.offset = 0; var->transp.length = 0; var->transp.msb_right = 0; |
1da177e4c Linux-2.6.12-rc2 |
1535 |
|
f1cbb17ac fbdev/amifb: Reor... |
1536 1537 1538 1539 1540 |
if (par->bplcon0 & BPC0_HAM) var->nonstd = FB_NONSTD_HAM; else var->nonstd = 0; var->activate = 0; |
1da177e4c Linux-2.6.12-rc2 |
1541 |
|
f1cbb17ac fbdev/amifb: Reor... |
1542 1543 |
var->height = -1; var->width = -1; |
1da177e4c Linux-2.6.12-rc2 |
1544 |
|
f1cbb17ac fbdev/amifb: Reor... |
1545 |
var->pixclock = pixclock[clk_shift]; |
1da177e4c Linux-2.6.12-rc2 |
1546 |
|
f1cbb17ac fbdev/amifb: Reor... |
1547 1548 1549 1550 1551 1552 |
if (IS_AGA && par->fmode & FMODE_BSCAN2) var->vmode = FB_VMODE_DOUBLE; else if (par->bplcon0 & BPC0_LACE) var->vmode = FB_VMODE_INTERLACED; else var->vmode = FB_VMODE_NONINTERLACED; |
1da177e4c Linux-2.6.12-rc2 |
1553 |
|
f1cbb17ac fbdev/amifb: Reor... |
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 |
if (!IS_OCS && par->beamcon0 & BMC0_VARBEAMEN) { var->hsync_len = (par->hsstop - par->hsstrt)>>clk_shift; var->right_margin = par->hsstrt>>clk_shift; var->left_margin = (par->htotal>>clk_shift) - var->xres - var->right_margin - var->hsync_len; var->vsync_len = (par->vsstop - par->vsstrt)>>line_shift; var->lower_margin = par->vsstrt>>line_shift; var->upper_margin = (par->vtotal>>line_shift) - var->yres - var->lower_margin - var->vsync_len; var->sync = 0; if (par->beamcon0 & BMC0_HSYTRUE) var->sync |= FB_SYNC_HOR_HIGH_ACT; if (par->beamcon0 & BMC0_VSYTRUE) var->sync |= FB_SYNC_VERT_HIGH_ACT; if (par->beamcon0 & BMC0_CSYTRUE) var->sync |= FB_SYNC_COMP_HIGH_ACT; } else { var->sync = FB_SYNC_BROADCAST; var->hsync_len = (152>>clk_shift) + mod4(par->diwstop_h); var->right_margin = ((par->htotal - down4(par->diwstop_h))>>clk_shift) + var->hsync_len; var->left_margin = (par->htotal>>clk_shift) - var->xres - var->right_margin - var->hsync_len; var->vsync_len = 4>>line_shift; var->lower_margin = ((par->vtotal - par->diwstop_v)>>line_shift) + var->vsync_len; var->upper_margin = (((par->vtotal - 2)>>line_shift) + 1) - var->yres - var->lower_margin - var->vsync_len; |
1da177e4c Linux-2.6.12-rc2 |
1577 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1578 1579 1580 1581 1582 |
if (par->bplcon0 & BPC0_ERSY) var->sync |= FB_SYNC_EXT; if (par->vmode & FB_VMODE_YWRAP) var->vmode |= FB_VMODE_YWRAP; |
1da177e4c Linux-2.6.12-rc2 |
1583 |
} |
f0058b4bb fbdev/amifb: Corr... |
1584 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
1585 |
* Update hardware |
f0058b4bb fbdev/amifb: Corr... |
1586 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
1587 |
|
61640c295 fbdev/amifb: Use ... |
1588 |
static void ami_update_par(struct fb_info *info) |
1da177e4c Linux-2.6.12-rc2 |
1589 |
{ |
61640c295 fbdev/amifb: Use ... |
1590 |
struct amifb_par *par = info->par; |
f1cbb17ac fbdev/amifb: Reor... |
1591 |
short clk_shift, vshift, fstrt, fsize, fstop, fconst, shift, move, mod; |
1da177e4c Linux-2.6.12-rc2 |
1592 |
|
f1cbb17ac fbdev/amifb: Reor... |
1593 |
clk_shift = par->clk_shift; |
1da177e4c Linux-2.6.12-rc2 |
1594 |
|
f1cbb17ac fbdev/amifb: Reor... |
1595 1596 |
if (!(par->vmode & FB_VMODE_SMOOTH_XPAN)) par->xoffset = upx(16 << maxfmode, par->xoffset); |
1da177e4c Linux-2.6.12-rc2 |
1597 |
|
f1cbb17ac fbdev/amifb: Reor... |
1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 |
fconst = 16 << maxfmode << clk_shift; vshift = modx(16 << maxfmode, par->xoffset); fstrt = par->diwstrt_h - (vshift << clk_shift) - 4; fsize = (par->xres + vshift) << clk_shift; shift = modx(fconst, fstrt); move = downx(2 << maxfmode, div8(par->xoffset)); if (maxfmode + clk_shift > 1) { fstrt = downx(fconst, fstrt) - 64; fsize = upx(fconst, fsize); fstop = fstrt + fsize - fconst; } else { mod = fstrt = downx(fconst, fstrt) - fconst; fstop = fstrt + upx(fconst, fsize) - 64; fsize = up64(fsize); fstrt = fstop - fsize + 64; if (fstrt < min_fstrt) { fstop += min_fstrt - fstrt; fstrt = min_fstrt; } move = move - div8((mod - fstrt)>>clk_shift); } mod = par->next_line - div8(fsize>>clk_shift); par->ddfstrt = fstrt; par->ddfstop = fstop; par->bplcon1 = hscroll2hw(shift); par->bpl2mod = mod; if (par->bplcon0 & BPC0_LACE) par->bpl2mod += par->next_line; if (IS_AGA && (par->fmode & FMODE_BSCAN2)) par->bpl1mod = -div8(fsize>>clk_shift); else par->bpl1mod = par->bpl2mod; |
1da177e4c Linux-2.6.12-rc2 |
1630 |
|
f1cbb17ac fbdev/amifb: Reor... |
1631 |
if (par->yoffset) { |
61640c295 fbdev/amifb: Use ... |
1632 |
par->bplpt0 = info->fix.smem_start + |
f1cbb17ac fbdev/amifb: Reor... |
1633 1634 1635 |
par->next_line * par->yoffset + move; if (par->vmode & FB_VMODE_YWRAP) { if (par->yoffset > par->vyres - par->yres) { |
61640c295 fbdev/amifb: Use ... |
1636 |
par->bplpt0wrap = info->fix.smem_start + move; |
f1cbb17ac fbdev/amifb: Reor... |
1637 1638 1639 1640 |
if (par->bplcon0 & BPC0_LACE && mod2(par->diwstrt_v + par->vyres - par->yoffset)) par->bplpt0wrap += par->next_line; |
1da177e4c Linux-2.6.12-rc2 |
1641 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1642 1643 |
} } else |
61640c295 fbdev/amifb: Use ... |
1644 |
par->bplpt0 = info->fix.smem_start + move; |
1da177e4c Linux-2.6.12-rc2 |
1645 |
|
f1cbb17ac fbdev/amifb: Reor... |
1646 1647 |
if (par->bplcon0 & BPC0_LACE && mod2(par->diwstrt_v)) par->bplpt0 += par->next_line; |
f1cbb17ac fbdev/amifb: Reor... |
1648 |
} |
1da177e4c Linux-2.6.12-rc2 |
1649 |
|
1da177e4c Linux-2.6.12-rc2 |
1650 |
|
f1cbb17ac fbdev/amifb: Reor... |
1651 1652 1653 1654 1655 1656 |
/* * Pan or Wrap the Display * * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag * in `var'. */ |
1da177e4c Linux-2.6.12-rc2 |
1657 |
|
61640c295 fbdev/amifb: Use ... |
1658 |
static void ami_pan_var(struct fb_var_screeninfo *var, struct fb_info *info) |
f1cbb17ac fbdev/amifb: Reor... |
1659 |
{ |
61640c295 fbdev/amifb: Use ... |
1660 |
struct amifb_par *par = info->par; |
1da177e4c Linux-2.6.12-rc2 |
1661 |
|
f1cbb17ac fbdev/amifb: Reor... |
1662 1663 1664 1665 1666 1667 1668 1669 |
par->xoffset = var->xoffset; par->yoffset = var->yoffset; if (var->vmode & FB_VMODE_YWRAP) par->vmode |= FB_VMODE_YWRAP; else par->vmode &= ~FB_VMODE_YWRAP; do_vmode_pan = 0; |
61640c295 fbdev/amifb: Use ... |
1670 |
ami_update_par(info); |
f1cbb17ac fbdev/amifb: Reor... |
1671 |
do_vmode_pan = 1; |
1da177e4c Linux-2.6.12-rc2 |
1672 |
} |
61640c295 fbdev/amifb: Use ... |
1673 |
static void ami_update_display(const struct amifb_par *par) |
f1cbb17ac fbdev/amifb: Reor... |
1674 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
1675 1676 1677 1678 1679 1680 |
custom.bplcon1 = par->bplcon1; custom.bpl1mod = par->bpl1mod; custom.bpl2mod = par->bpl2mod; custom.ddfstrt = ddfstrt2hw(par->ddfstrt); custom.ddfstop = ddfstop2hw(par->ddfstop); } |
f0058b4bb fbdev/amifb: Corr... |
1681 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
1682 |
* Change the video mode (called by VBlank interrupt) |
f0058b4bb fbdev/amifb: Corr... |
1683 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
1684 |
|
61640c295 fbdev/amifb: Use ... |
1685 |
static void ami_init_display(const struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
1686 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
1687 |
int i; |
1da177e4c Linux-2.6.12-rc2 |
1688 |
|
f1cbb17ac fbdev/amifb: Reor... |
1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 |
custom.bplcon0 = par->bplcon0 & ~BPC0_LACE; custom.bplcon2 = (IS_OCS ? 0 : BPC2_KILLEHB) | BPC2_PF2P2 | BPC2_PF1P2; if (!IS_OCS) { custom.bplcon3 = par->bplcon3; if (IS_AGA) custom.bplcon4 = BPC4_ESPRM4 | BPC4_OSPRM4; if (par->beamcon0 & BMC0_VARBEAMEN) { custom.htotal = htotal2hw(par->htotal); custom.hbstrt = hbstrt2hw(par->hbstrt); custom.hbstop = hbstop2hw(par->hbstop); custom.hsstrt = hsstrt2hw(par->hsstrt); custom.hsstop = hsstop2hw(par->hsstop); custom.hcenter = hcenter2hw(par->hcenter); custom.vtotal = vtotal2hw(par->vtotal); custom.vbstrt = vbstrt2hw(par->vbstrt); custom.vbstop = vbstop2hw(par->vbstop); custom.vsstrt = vsstrt2hw(par->vsstrt); custom.vsstop = vsstop2hw(par->vsstop); } } if (!IS_OCS || par->hsstop) custom.beamcon0 = par->beamcon0; if (IS_AGA) custom.fmode = par->fmode; |
1da177e4c Linux-2.6.12-rc2 |
1713 |
|
f1cbb17ac fbdev/amifb: Reor... |
1714 1715 1716 |
/* * The minimum period for audio depends on htotal */ |
1da177e4c Linux-2.6.12-rc2 |
1717 |
|
f1cbb17ac fbdev/amifb: Reor... |
1718 |
amiga_audio_min_period = div16(par->htotal); |
1da177e4c Linux-2.6.12-rc2 |
1719 |
|
f1cbb17ac fbdev/amifb: Reor... |
1720 1721 1722 1723 |
is_lace = par->bplcon0 & BPC0_LACE ? 1 : 0; #if 1 if (is_lace) { i = custom.vposr >> 15; |
1da177e4c Linux-2.6.12-rc2 |
1724 |
} else { |
f1cbb17ac fbdev/amifb: Reor... |
1725 1726 |
custom.vposw = custom.vposr | 0x8000; i = 1; |
1da177e4c Linux-2.6.12-rc2 |
1727 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1728 1729 1730 1731 1732 |
#else i = 1; custom.vposw = custom.vposr | 0x8000; #endif custom.cop2lc = (u_short *)ZTWO_PADDR(copdisplay.list[currentcop][i]); |
1da177e4c Linux-2.6.12-rc2 |
1733 |
} |
f0058b4bb fbdev/amifb: Corr... |
1734 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
1735 |
* (Un)Blank the screen (called by VBlank interrupt) |
f0058b4bb fbdev/amifb: Corr... |
1736 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
1737 |
|
61640c295 fbdev/amifb: Use ... |
1738 |
static void ami_do_blank(const struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
1739 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
1740 1741 |
#if defined(CONFIG_FB_AMIGA_AGA) u_short bplcon3 = par->bplcon3; |
1da177e4c Linux-2.6.12-rc2 |
1742 |
#endif |
f1cbb17ac fbdev/amifb: Reor... |
1743 |
u_char red, green, blue; |
1da177e4c Linux-2.6.12-rc2 |
1744 |
|
f1cbb17ac fbdev/amifb: Reor... |
1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 |
if (do_blank > 0) { custom.dmacon = DMAF_RASTER | DMAF_SPRITE; red = green = blue = 0; if (!IS_OCS && do_blank > 1) { switch (do_blank) { case FB_BLANK_VSYNC_SUSPEND: custom.hsstrt = hsstrt2hw(par->hsstrt); custom.hsstop = hsstop2hw(par->hsstop); custom.vsstrt = vsstrt2hw(par->vtotal + 4); custom.vsstop = vsstop2hw(par->vtotal + 4); break; case FB_BLANK_HSYNC_SUSPEND: custom.hsstrt = hsstrt2hw(par->htotal + 16); custom.hsstop = hsstop2hw(par->htotal + 16); custom.vsstrt = vsstrt2hw(par->vsstrt); custom.vsstop = vsstrt2hw(par->vsstop); break; case FB_BLANK_POWERDOWN: custom.hsstrt = hsstrt2hw(par->htotal + 16); custom.hsstop = hsstop2hw(par->htotal + 16); custom.vsstrt = vsstrt2hw(par->vtotal + 4); custom.vsstop = vsstop2hw(par->vtotal + 4); break; } if (!(par->beamcon0 & BMC0_VARBEAMEN)) { custom.htotal = htotal2hw(par->htotal); custom.vtotal = vtotal2hw(par->vtotal); custom.beamcon0 = BMC0_HARDDIS | BMC0_VARBEAMEN | BMC0_VARVSYEN | BMC0_VARHSYEN | BMC0_VARCSYEN; } |
1da177e4c Linux-2.6.12-rc2 |
1775 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 |
} else { custom.dmacon = DMAF_SETCLR | DMAF_RASTER | DMAF_SPRITE; red = red0; green = green0; blue = blue0; if (!IS_OCS) { custom.hsstrt = hsstrt2hw(par->hsstrt); custom.hsstop = hsstop2hw(par->hsstop); custom.vsstrt = vsstrt2hw(par->vsstrt); custom.vsstop = vsstop2hw(par->vsstop); custom.beamcon0 = par->beamcon0; |
1da177e4c Linux-2.6.12-rc2 |
1787 |
} |
1da177e4c Linux-2.6.12-rc2 |
1788 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 |
#if defined(CONFIG_FB_AMIGA_AGA) if (IS_AGA) { custom.bplcon3 = bplcon3; custom.color[0] = rgb2hw8_high(red, green, blue); custom.bplcon3 = bplcon3 | BPC3_LOCT; custom.color[0] = rgb2hw8_low(red, green, blue); custom.bplcon3 = bplcon3; } else #endif #if defined(CONFIG_FB_AMIGA_ECS) if (par->bplcon0 & BPC0_SHRES) { u_short color, mask; int i; mask = 0x3333; color = rgb2hw2(red, green, blue); for (i = 12; i >= 0; i -= 4) custom.color[i] = ecs_palette[i] = (ecs_palette[i] & mask) | color; mask <<= 2; color >>= 2; for (i = 3; i >= 0; i--) custom.color[i] = ecs_palette[i] = (ecs_palette[i] & mask) | color; } else #endif custom.color[0] = rgb2hw4(red, green, blue); is_blanked = do_blank > 0 ? do_blank : 0; |
1da177e4c Linux-2.6.12-rc2 |
1814 |
} |
61640c295 fbdev/amifb: Use ... |
1815 1816 |
static int ami_get_fix_cursorinfo(struct fb_fix_cursorinfo *fix, const struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
1817 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
1818 1819 1820 1821 1822 |
fix->crsr_width = fix->crsr_xsize = par->crsr.width; fix->crsr_height = fix->crsr_ysize = par->crsr.height; fix->crsr_color1 = 17; fix->crsr_color2 = 18; return 0; |
1da177e4c Linux-2.6.12-rc2 |
1823 |
} |
61640c295 fbdev/amifb: Use ... |
1824 1825 1826 |
static int ami_get_var_cursorinfo(struct fb_var_cursorinfo *var, u_char __user *data, const struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
1827 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 |
register u_short *lspr, *sspr; #ifdef __mc68000__ register u_long datawords asm ("d2"); #else register u_long datawords; #endif register short delta; register u_char color; short height, width, bits, words; int size, alloc; |
1da177e4c Linux-2.6.12-rc2 |
1838 |
|
f1cbb17ac fbdev/amifb: Reor... |
1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 |
size = par->crsr.height * par->crsr.width; alloc = var->height * var->width; var->height = par->crsr.height; var->width = par->crsr.width; var->xspot = par->crsr.spot_x; var->yspot = par->crsr.spot_y; if (size > var->height * var->width) return -ENAMETOOLONG; if (!access_ok(VERIFY_WRITE, data, size)) return -EFAULT; delta = 1 << par->crsr.fmode; lspr = lofsprite + (delta << 1); if (par->bplcon0 & BPC0_LACE) sspr = shfsprite + (delta << 1); else sspr = NULL; for (height = (short)var->height - 1; height >= 0; height--) { bits = 0; words = delta; datawords = 0; for (width = (short)var->width - 1; width >= 0; width--) { if (bits == 0) { bits = 16; --words; #ifdef __mc68000__ asm volatile ("movew %1@(%3:w:2),%0 ; swap %0 ; movew %1@+,%0" : "=d" (datawords), "=a" (lspr) : "1" (lspr), "d" (delta)); #else datawords = (*(lspr + delta) << 16) | (*lspr++); #endif } --bits; #ifdef __mc68000__ asm volatile ( "clrb %0 ; swap %1 ; lslw #1,%1 ; roxlb #1,%0 ; " "swap %1 ; lslw #1,%1 ; roxlb #1,%0" : "=d" (color), "=d" (datawords) : "1" (datawords)); #else color = (((datawords >> 30) & 2) | ((datawords >> 15) & 1)); datawords <<= 1; #endif put_user(color, data++); |
1da177e4c Linux-2.6.12-rc2 |
1879 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1880 1881 |
if (bits > 0) { --words; ++lspr; |
1da177e4c Linux-2.6.12-rc2 |
1882 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 |
while (--words >= 0) ++lspr; #ifdef __mc68000__ asm volatile ("lea %0@(%4:w:2),%0 ; tstl %1 ; jeq 1f ; exg %0,%1 1:" : "=a" (lspr), "=a" (sspr) : "0" (lspr), "1" (sspr), "d" (delta)); #else lspr += delta; if (sspr) { u_short *tmp = lspr; lspr = sspr; sspr = tmp; |
1da177e4c Linux-2.6.12-rc2 |
1895 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1896 |
#endif |
1da177e4c Linux-2.6.12-rc2 |
1897 |
} |
f1cbb17ac fbdev/amifb: Reor... |
1898 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
1899 |
} |
61640c295 fbdev/amifb: Use ... |
1900 1901 |
static int ami_set_var_cursorinfo(struct fb_var_cursorinfo *var, u_char __user *data, struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
1902 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
1903 1904 1905 1906 1907 1908 1909 1910 1911 |
register u_short *lspr, *sspr; #ifdef __mc68000__ register u_long datawords asm ("d2"); #else register u_long datawords; #endif register short delta; u_short fmode; short height, width, bits, words; |
f0058b4bb fbdev/amifb: Corr... |
1912 |
|
f1cbb17ac fbdev/amifb: Reor... |
1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 |
if (!var->width) return -EINVAL; else if (var->width <= 16) fmode = TAG_FMODE_1; else if (var->width <= 32) fmode = TAG_FMODE_2; else if (var->width <= 64) fmode = TAG_FMODE_4; else return -EINVAL; if (fmode > maxfmode) return -EINVAL; if (!var->height) return -EINVAL; if (!access_ok(VERIFY_READ, data, var->width * var->height)) return -EFAULT; delta = 1 << fmode; lofsprite = shfsprite = (u_short *)spritememory; lspr = lofsprite + (delta << 1); if (par->bplcon0 & BPC0_LACE) { if (((var->height + 4) << fmode << 2) > SPRITEMEMSIZE) return -EINVAL; memset(lspr, 0, (var->height + 4) << fmode << 2); shfsprite += ((var->height + 5)&-2) << fmode; sspr = shfsprite + (delta << 1); } else { if (((var->height + 2) << fmode << 2) > SPRITEMEMSIZE) return -EINVAL; memset(lspr, 0, (var->height + 2) << fmode << 2); sspr = NULL; } for (height = (short)var->height - 1; height >= 0; height--) { bits = 16; words = delta; datawords = 0; for (width = (short)var->width - 1; width >= 0; width--) { unsigned long tdata = 0; get_user(tdata, data); data++; #ifdef __mc68000__ asm volatile ( "lsrb #1,%2 ; roxlw #1,%0 ; swap %0 ; " "lsrb #1,%2 ; roxlw #1,%0 ; swap %0" : "=d" (datawords) : "0" (datawords), "d" (tdata)); #else datawords = ((datawords << 1) & 0xfffefffe); datawords |= tdata & 1; datawords |= (tdata & 2) << (16 - 1); #endif if (--bits == 0) { bits = 16; --words; #ifdef __mc68000__ asm volatile ("swap %2 ; movew %2,%0@(%3:w:2) ; swap %2 ; movew %2,%0@+" : "=a" (lspr) : "0" (lspr), "d" (datawords), "d" (delta)); #else *(lspr + delta) = (u_short) (datawords >> 16); *lspr++ = (u_short) (datawords & 0xffff); #endif } } if (bits < 16) { --words; #ifdef __mc68000__ asm volatile ( "swap %2 ; lslw %4,%2 ; movew %2,%0@(%3:w:2) ; " "swap %2 ; lslw %4,%2 ; movew %2,%0@+" : "=a" (lspr) : "0" (lspr), "d" (datawords), "d" (delta), "d" (bits)); #else *(lspr + delta) = (u_short) (datawords >> (16 + bits)); *lspr++ = (u_short) ((datawords & 0x0000ffff) >> bits); #endif } while (--words >= 0) { #ifdef __mc68000__ asm volatile ("moveql #0,%%d0 ; movew %%d0,%0@(%2:w:2) ; movew %%d0,%0@+" : "=a" (lspr) : "0" (lspr), "d" (delta) : "d0"); #else *(lspr + delta) = 0; *lspr++ = 0; #endif } #ifdef __mc68000__ asm volatile ("lea %0@(%4:w:2),%0 ; tstl %1 ; jeq 1f ; exg %0,%1 1:" : "=a" (lspr), "=a" (sspr) : "0" (lspr), "1" (sspr), "d" (delta)); #else lspr += delta; if (sspr) { u_short *tmp = lspr; lspr = sspr; sspr = tmp; } #endif } par->crsr.height = var->height; par->crsr.width = var->width; par->crsr.spot_x = var->xspot; par->crsr.spot_y = var->yspot; par->crsr.fmode = fmode; if (IS_AGA) { par->fmode &= ~(FMODE_SPAGEM | FMODE_SPR32); par->fmode |= sprfetchmode[fmode]; custom.fmode = par->fmode; |
f0058b4bb fbdev/amifb: Corr... |
2015 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2016 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
2017 |
} |
61640c295 fbdev/amifb: Use ... |
2018 2019 |
static int ami_get_cursorstate(struct fb_cursorstate *state, const struct amifb_par *par) |
f1cbb17ac fbdev/amifb: Reor... |
2020 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
2021 2022 2023 2024 2025 |
state->xoffset = par->crsr.crsr_x; state->yoffset = par->crsr.crsr_y; state->mode = cursormode; return 0; } |
1da177e4c Linux-2.6.12-rc2 |
2026 |
|
61640c295 fbdev/amifb: Use ... |
2027 2028 |
static int ami_set_cursorstate(struct fb_cursorstate *state, struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
2029 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
2030 2031 2032 2033 2034 2035 2036 |
par->crsr.crsr_x = state->xoffset; par->crsr.crsr_y = state->yoffset; if ((cursormode = state->mode) == FB_CURSOR_OFF) cursorstate = -1; do_cursor = 1; return 0; } |
1da177e4c Linux-2.6.12-rc2 |
2037 |
|
61640c295 fbdev/amifb: Use ... |
2038 |
static void ami_set_sprite(const struct amifb_par *par) |
f1cbb17ac fbdev/amifb: Reor... |
2039 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 |
copins *copl, *cops; u_short hs, vs, ve; u_long pl, ps, pt; short mx, my; cops = copdisplay.list[currentcop][0]; copl = copdisplay.list[currentcop][1]; ps = pl = ZTWO_PADDR(dummysprite); mx = par->crsr.crsr_x - par->crsr.spot_x; my = par->crsr.crsr_y - par->crsr.spot_y; if (!(par->vmode & FB_VMODE_YWRAP)) { mx -= par->xoffset; my -= par->yoffset; } if (!is_blanked && cursorstate > 0 && par->crsr.height > 0 && mx > -(short)par->crsr.width && mx < par->xres && my > -(short)par->crsr.height && my < par->yres) { pl = ZTWO_PADDR(lofsprite); hs = par->diwstrt_h + (mx << par->clk_shift) - 4; vs = par->diwstrt_v + (my << par->line_shift); ve = vs + (par->crsr.height << par->line_shift); if (par->bplcon0 & BPC0_LACE) { ps = ZTWO_PADDR(shfsprite); lofsprite[0] = spr2hw_pos(vs, hs); shfsprite[0] = spr2hw_pos(vs + 1, hs); if (mod2(vs)) { lofsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs, hs, ve); shfsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs + 1, hs, ve + 1); pt = pl; pl = ps; ps = pt; } else { lofsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs, hs, ve + 1); shfsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs + 1, hs, ve); } } else { lofsprite[0] = spr2hw_pos(vs, hs) | (IS_AGA && (par->fmode & FMODE_BSCAN2) ? 0x80 : 0); lofsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs, hs, ve); |
1da177e4c Linux-2.6.12-rc2 |
2076 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2077 2078 2079 2080 2081 2082 |
} copl[cop_spr0ptrh].w[1] = highw(pl); copl[cop_spr0ptrl].w[1] = loww(pl); if (par->bplcon0 & BPC0_LACE) { cops[cop_spr0ptrh].w[1] = highw(ps); cops[cop_spr0ptrl].w[1] = loww(ps); |
1da177e4c Linux-2.6.12-rc2 |
2083 2084 2085 2086 2087 |
} } /* |
f1cbb17ac fbdev/amifb: Reor... |
2088 |
* Initialise the Copper Initialisation List |
1da177e4c Linux-2.6.12-rc2 |
2089 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2090 |
static void __init ami_init_copper(void) |
1da177e4c Linux-2.6.12-rc2 |
2091 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
2092 2093 |
copins *cop = copdisplay.init; u_long p; |
1da177e4c Linux-2.6.12-rc2 |
2094 |
int i; |
f1cbb17ac fbdev/amifb: Reor... |
2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 |
if (!IS_OCS) { (cop++)->l = CMOVE(BPC0_COLOR | BPC0_SHRES | BPC0_ECSENA, bplcon0); (cop++)->l = CMOVE(0x0181, diwstrt); (cop++)->l = CMOVE(0x0281, diwstop); (cop++)->l = CMOVE(0x0000, diwhigh); } else (cop++)->l = CMOVE(BPC0_COLOR, bplcon0); p = ZTWO_PADDR(dummysprite); for (i = 0; i < 8; i++) { (cop++)->l = CMOVE(0, spr[i].pos); (cop++)->l = CMOVE(highw(p), sprpt[i]); (cop++)->l = CMOVE2(loww(p), sprpt[i]); } |
f0058b4bb fbdev/amifb: Corr... |
2108 |
|
f1cbb17ac fbdev/amifb: Reor... |
2109 2110 2111 2112 2113 |
(cop++)->l = CMOVE(IF_SETCLR | IF_COPER, intreq); copdisplay.wait = cop; (cop++)->l = CEND; (cop++)->l = CMOVE(0, copjmp2); cop->l = CEND; |
f0058b4bb fbdev/amifb: Corr... |
2114 |
|
f1cbb17ac fbdev/amifb: Reor... |
2115 2116 |
custom.cop1lc = (u_short *)ZTWO_PADDR(copdisplay.init); custom.copjmp1 = 0; |
1da177e4c Linux-2.6.12-rc2 |
2117 |
} |
61640c295 fbdev/amifb: Use ... |
2118 |
static void ami_reinit_copper(const struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
2119 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
2120 2121 |
copdisplay.init[cip_bplcon0].w[1] = ~(BPC0_BPU3 | BPC0_BPU2 | BPC0_BPU1 | BPC0_BPU0) & par->bplcon0; copdisplay.wait->l = CWAIT(32, par->diwstrt_v - 4); |
1da177e4c Linux-2.6.12-rc2 |
2122 2123 2124 2125 |
} /* |
f1cbb17ac fbdev/amifb: Reor... |
2126 2127 2128 |
* Rebuild the Copper List * * We only change the things that are not static |
1da177e4c Linux-2.6.12-rc2 |
2129 |
*/ |
61640c295 fbdev/amifb: Use ... |
2130 |
static void ami_rebuild_copper(const struct amifb_par *par) |
1da177e4c Linux-2.6.12-rc2 |
2131 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
2132 2133 2134 2135 |
copins *copl, *cops; u_short line, h_end1, h_end2; short i; u_long p; |
1da177e4c Linux-2.6.12-rc2 |
2136 |
|
f1cbb17ac fbdev/amifb: Reor... |
2137 2138 2139 2140 2141 |
if (IS_AGA && maxfmode + par->clk_shift == 0) h_end1 = par->diwstrt_h - 64; else h_end1 = par->htotal - 32; h_end2 = par->ddfstop + 64; |
1da177e4c Linux-2.6.12-rc2 |
2142 |
|
61640c295 fbdev/amifb: Use ... |
2143 |
ami_set_sprite(par); |
1da177e4c Linux-2.6.12-rc2 |
2144 |
|
f1cbb17ac fbdev/amifb: Reor... |
2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 |
copl = copdisplay.rebuild[1]; p = par->bplpt0; if (par->vmode & FB_VMODE_YWRAP) { if ((par->vyres - par->yoffset) != 1 || !mod2(par->diwstrt_v)) { if (par->yoffset > par->vyres - par->yres) { for (i = 0; i < (short)par->bpp; i++, p += par->next_plane) { (copl++)->l = CMOVE(highw(p), bplpt[i]); (copl++)->l = CMOVE2(loww(p), bplpt[i]); } line = par->diwstrt_v + ((par->vyres - par->yoffset) << par->line_shift) - 1; while (line >= 512) { (copl++)->l = CWAIT(h_end1, 510); line -= 512; } if (line >= 510 && IS_AGA && maxfmode + par->clk_shift == 0) (copl++)->l = CWAIT(h_end1, line); else (copl++)->l = CWAIT(h_end2, line); p = par->bplpt0wrap; } } else p = par->bplpt0wrap; } for (i = 0; i < (short)par->bpp; i++, p += par->next_plane) { (copl++)->l = CMOVE(highw(p), bplpt[i]); (copl++)->l = CMOVE2(loww(p), bplpt[i]); } copl->l = CEND; |
1da177e4c Linux-2.6.12-rc2 |
2173 |
|
f1cbb17ac fbdev/amifb: Reor... |
2174 2175 2176 2177 2178 |
if (par->bplcon0 & BPC0_LACE) { cops = copdisplay.rebuild[0]; p = par->bplpt0; if (mod2(par->diwstrt_v)) p -= par->next_line; |
f0058b4bb fbdev/amifb: Corr... |
2179 |
else |
f1cbb17ac fbdev/amifb: Reor... |
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 |
p += par->next_line; if (par->vmode & FB_VMODE_YWRAP) { if ((par->vyres - par->yoffset) != 1 || mod2(par->diwstrt_v)) { if (par->yoffset > par->vyres - par->yres + 1) { for (i = 0; i < (short)par->bpp; i++, p += par->next_plane) { (cops++)->l = CMOVE(highw(p), bplpt[i]); (cops++)->l = CMOVE2(loww(p), bplpt[i]); } line = par->diwstrt_v + ((par->vyres - par->yoffset) << par->line_shift) - 2; while (line >= 512) { (cops++)->l = CWAIT(h_end1, 510); line -= 512; } if (line > 510 && IS_AGA && maxfmode + par->clk_shift == 0) (cops++)->l = CWAIT(h_end1, line); else (cops++)->l = CWAIT(h_end2, line); p = par->bplpt0wrap; if (mod2(par->diwstrt_v + par->vyres - par->yoffset)) p -= par->next_line; else p += par->next_line; } } else p = par->bplpt0wrap - par->next_line; } for (i = 0; i < (short)par->bpp; i++, p += par->next_plane) { (cops++)->l = CMOVE(highw(p), bplpt[i]); (cops++)->l = CMOVE2(loww(p), bplpt[i]); } cops->l = CEND; |
1da177e4c Linux-2.6.12-rc2 |
2212 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2213 |
} |
1da177e4c Linux-2.6.12-rc2 |
2214 |
|
1da177e4c Linux-2.6.12-rc2 |
2215 2216 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
2217 |
* Build the Copper List |
1da177e4c Linux-2.6.12-rc2 |
2218 |
*/ |
61640c295 fbdev/amifb: Use ... |
2219 |
static void ami_build_copper(struct fb_info *info) |
f1cbb17ac fbdev/amifb: Reor... |
2220 |
{ |
61640c295 fbdev/amifb: Use ... |
2221 |
struct amifb_par *par = info->par; |
f1cbb17ac fbdev/amifb: Reor... |
2222 2223 |
copins *copl, *cops; u_long p; |
1da177e4c Linux-2.6.12-rc2 |
2224 |
|
f1cbb17ac fbdev/amifb: Reor... |
2225 |
currentcop = 1 - currentcop; |
1da177e4c Linux-2.6.12-rc2 |
2226 |
|
f1cbb17ac fbdev/amifb: Reor... |
2227 |
copl = copdisplay.list[currentcop][1]; |
1da177e4c Linux-2.6.12-rc2 |
2228 |
|
f1cbb17ac fbdev/amifb: Reor... |
2229 2230 2231 2232 |
(copl++)->l = CWAIT(0, 10); (copl++)->l = CMOVE(par->bplcon0, bplcon0); (copl++)->l = CMOVE(0, sprpt[0]); (copl++)->l = CMOVE2(0, sprpt[0]); |
1da177e4c Linux-2.6.12-rc2 |
2233 |
|
f1cbb17ac fbdev/amifb: Reor... |
2234 2235 |
if (par->bplcon0 & BPC0_LACE) { cops = copdisplay.list[currentcop][0]; |
db3e5289f amifb: Register A... |
2236 |
|
f1cbb17ac fbdev/amifb: Reor... |
2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 |
(cops++)->l = CWAIT(0, 10); (cops++)->l = CMOVE(par->bplcon0, bplcon0); (cops++)->l = CMOVE(0, sprpt[0]); (cops++)->l = CMOVE2(0, sprpt[0]); (copl++)->l = CMOVE(diwstrt2hw(par->diwstrt_h, par->diwstrt_v + 1), diwstrt); (copl++)->l = CMOVE(diwstop2hw(par->diwstop_h, par->diwstop_v + 1), diwstop); (cops++)->l = CMOVE(diwstrt2hw(par->diwstrt_h, par->diwstrt_v), diwstrt); (cops++)->l = CMOVE(diwstop2hw(par->diwstop_h, par->diwstop_v), diwstop); if (!IS_OCS) { (copl++)->l = CMOVE(diwhigh2hw(par->diwstrt_h, par->diwstrt_v + 1, par->diwstop_h, par->diwstop_v + 1), diwhigh); (cops++)->l = CMOVE(diwhigh2hw(par->diwstrt_h, par->diwstrt_v, par->diwstop_h, par->diwstop_v), diwhigh); #if 0 if (par->beamcon0 & BMC0_VARBEAMEN) { (copl++)->l = CMOVE(vtotal2hw(par->vtotal), vtotal); (copl++)->l = CMOVE(vbstrt2hw(par->vbstrt + 1), vbstrt); (copl++)->l = CMOVE(vbstop2hw(par->vbstop + 1), vbstop); (cops++)->l = CMOVE(vtotal2hw(par->vtotal), vtotal); (cops++)->l = CMOVE(vbstrt2hw(par->vbstrt), vbstrt); (cops++)->l = CMOVE(vbstop2hw(par->vbstop), vbstop); } #endif } p = ZTWO_PADDR(copdisplay.list[currentcop][0]); (copl++)->l = CMOVE(highw(p), cop2lc); (copl++)->l = CMOVE2(loww(p), cop2lc); p = ZTWO_PADDR(copdisplay.list[currentcop][1]); (cops++)->l = CMOVE(highw(p), cop2lc); (cops++)->l = CMOVE2(loww(p), cop2lc); copdisplay.rebuild[0] = cops; } else { (copl++)->l = CMOVE(diwstrt2hw(par->diwstrt_h, par->diwstrt_v), diwstrt); (copl++)->l = CMOVE(diwstop2hw(par->diwstop_h, par->diwstop_v), diwstop); if (!IS_OCS) { (copl++)->l = CMOVE(diwhigh2hw(par->diwstrt_h, par->diwstrt_v, par->diwstop_h, par->diwstop_v), diwhigh); #if 0 if (par->beamcon0 & BMC0_VARBEAMEN) { (copl++)->l = CMOVE(vtotal2hw(par->vtotal), vtotal); (copl++)->l = CMOVE(vbstrt2hw(par->vbstrt), vbstrt); (copl++)->l = CMOVE(vbstop2hw(par->vbstop), vbstop); } #endif } |
a707642a0 fbdev/amifb: Do n... |
2283 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2284 |
copdisplay.rebuild[1] = copl; |
1da177e4c Linux-2.6.12-rc2 |
2285 |
|
61640c295 fbdev/amifb: Use ... |
2286 2287 |
ami_update_par(info); ami_rebuild_copper(info->par); |
f1cbb17ac fbdev/amifb: Reor... |
2288 |
} |
1da177e4c Linux-2.6.12-rc2 |
2289 |
|
1da177e4c Linux-2.6.12-rc2 |
2290 |
|
f1cbb17ac fbdev/amifb: Reor... |
2291 2292 2293 2294 |
static void __init amifb_setup_mcap(char *spec) { char *p; int vmin, vmax, hmin, hmax; |
1da177e4c Linux-2.6.12-rc2 |
2295 |
|
f1cbb17ac fbdev/amifb: Reor... |
2296 2297 2298 |
/* Format for monitor capabilities is: <Vmin>;<Vmax>;<Hmin>;<Hmax> * <V*> vertical freq. in Hz * <H*> horizontal freq. in kHz |
1da177e4c Linux-2.6.12-rc2 |
2299 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 |
if (!(p = strsep(&spec, ";")) || !*p) return; vmin = simple_strtoul(p, NULL, 10); if (vmin <= 0) return; if (!(p = strsep(&spec, ";")) || !*p) return; vmax = simple_strtoul(p, NULL, 10); if (vmax <= 0 || vmax <= vmin) return; if (!(p = strsep(&spec, ";")) || !*p) return; hmin = 1000 * simple_strtoul(p, NULL, 10); if (hmin <= 0) return; if (!(p = strsep(&spec, "")) || !*p) return; hmax = 1000 * simple_strtoul(p, NULL, 10); if (hmax <= 0 || hmax <= hmin) return; |
1da177e4c Linux-2.6.12-rc2 |
2320 |
|
03c740a04 fbdev/amifb: Stor... |
2321 2322 2323 2324 |
amifb_hfmin = hmin; amifb_hfmax = hmax; amifb_vfmin = vmin; amifb_vfmax = vmax; |
f1cbb17ac fbdev/amifb: Reor... |
2325 |
} |
1da177e4c Linux-2.6.12-rc2 |
2326 |
|
78ffd70e6 fbdev/amifb: Make... |
2327 |
static int __init amifb_setup(char *options) |
f1cbb17ac fbdev/amifb: Reor... |
2328 2329 |
{ char *this_opt; |
1da177e4c Linux-2.6.12-rc2 |
2330 |
|
f1cbb17ac fbdev/amifb: Reor... |
2331 2332 |
if (!options || !*options) return 0; |
1da177e4c Linux-2.6.12-rc2 |
2333 |
|
f1cbb17ac fbdev/amifb: Reor... |
2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 |
while ((this_opt = strsep(&options, ",")) != NULL) { if (!*this_opt) continue; if (!strcmp(this_opt, "inverse")) { amifb_inverse = 1; fb_invert_cmaps(); } else if (!strcmp(this_opt, "ilbm")) amifb_ilbm = 1; else if (!strncmp(this_opt, "monitorcap:", 11)) amifb_setup_mcap(this_opt + 11); else if (!strncmp(this_opt, "fstart:", 7)) min_fstrt = simple_strtoul(this_opt + 7, NULL, 0); else mode_option = this_opt; |
1da177e4c Linux-2.6.12-rc2 |
2348 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2349 2350 |
if (min_fstrt < 48) min_fstrt = 48; |
1da177e4c Linux-2.6.12-rc2 |
2351 2352 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
2353 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2354 2355 |
static int amifb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
1da177e4c Linux-2.6.12-rc2 |
2356 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
2357 2358 2359 2360 |
int err; struct amifb_par par; /* Validate wanted screen parameters */ |
61640c295 fbdev/amifb: Use ... |
2361 2362 |
err = ami_decode_var(var, &par, info); if (err) |
f1cbb17ac fbdev/amifb: Reor... |
2363 |
return err; |
1da177e4c Linux-2.6.12-rc2 |
2364 |
|
f1cbb17ac fbdev/amifb: Reor... |
2365 2366 |
/* Encode (possibly rounded) screen parameters */ ami_encode_var(var, &par); |
1da177e4c Linux-2.6.12-rc2 |
2367 2368 |
return 0; } |
1da177e4c Linux-2.6.12-rc2 |
2369 |
|
f1cbb17ac fbdev/amifb: Reor... |
2370 |
static int amifb_set_par(struct fb_info *info) |
1da177e4c Linux-2.6.12-rc2 |
2371 |
{ |
423a53086 fbdev/amifb: Remo... |
2372 |
struct amifb_par *par = info->par; |
61640c295 fbdev/amifb: Use ... |
2373 |
int error; |
1da177e4c Linux-2.6.12-rc2 |
2374 |
|
f1cbb17ac fbdev/amifb: Reor... |
2375 2376 |
do_vmode_pan = 0; do_vmode_full = 0; |
1da177e4c Linux-2.6.12-rc2 |
2377 |
|
f1cbb17ac fbdev/amifb: Reor... |
2378 |
/* Decode wanted screen parameters */ |
61640c295 fbdev/amifb: Use ... |
2379 2380 2381 |
error = ami_decode_var(&info->var, par, info); if (error) return error; |
1da177e4c Linux-2.6.12-rc2 |
2382 |
|
f1cbb17ac fbdev/amifb: Reor... |
2383 |
/* Set new videomode */ |
61640c295 fbdev/amifb: Use ... |
2384 |
ami_build_copper(info); |
1da177e4c Linux-2.6.12-rc2 |
2385 |
|
f1cbb17ac fbdev/amifb: Reor... |
2386 2387 |
/* Set VBlank trigger */ do_vmode_full = 1; |
1da177e4c Linux-2.6.12-rc2 |
2388 |
|
f1cbb17ac fbdev/amifb: Reor... |
2389 2390 2391 2392 2393 2394 2395 |
/* Update fix for new screen parameters */ if (par->bpp == 1) { info->fix.type = FB_TYPE_PACKED_PIXELS; info->fix.type_aux = 0; } else if (amifb_ilbm) { info->fix.type = FB_TYPE_INTERLEAVED_PLANES; info->fix.type_aux = par->next_line; |
1da177e4c Linux-2.6.12-rc2 |
2396 |
} else { |
f1cbb17ac fbdev/amifb: Reor... |
2397 2398 |
info->fix.type = FB_TYPE_PLANES; info->fix.type_aux = 0; |
1da177e4c Linux-2.6.12-rc2 |
2399 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2400 |
info->fix.line_length = div8(upx(16 << maxfmode, par->vxres)); |
1da177e4c Linux-2.6.12-rc2 |
2401 |
|
f1cbb17ac fbdev/amifb: Reor... |
2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 |
if (par->vmode & FB_VMODE_YWRAP) { info->fix.ywrapstep = 1; info->fix.xpanstep = 0; info->fix.ypanstep = 0; info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YWRAP | FBINFO_READS_FAST; /* override SCROLL_REDRAW */ } else { info->fix.ywrapstep = 0; if (par->vmode & FB_VMODE_SMOOTH_XPAN) info->fix.xpanstep = 1; else info->fix.xpanstep = 16 << maxfmode; info->fix.ypanstep = 1; info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; |
1da177e4c Linux-2.6.12-rc2 |
2416 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2417 2418 |
return 0; } |
1da177e4c Linux-2.6.12-rc2 |
2419 |
|
1da177e4c Linux-2.6.12-rc2 |
2420 2421 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
2422 2423 2424 |
* Set a single color register. The values supplied are already * rounded down to the hardware's capabilities (according to the * entries in the var structure). Return != 0 for invalid regno. |
1da177e4c Linux-2.6.12-rc2 |
2425 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2426 2427 |
static int amifb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) |
1da177e4c Linux-2.6.12-rc2 |
2428 |
{ |
61640c295 fbdev/amifb: Use ... |
2429 |
const struct amifb_par *par = info->par; |
f1cbb17ac fbdev/amifb: Reor... |
2430 2431 2432 |
if (IS_AGA) { if (regno > 255) return 1; |
61640c295 fbdev/amifb: Use ... |
2433 |
} else if (par->bplcon0 & BPC0_SHRES) { |
f1cbb17ac fbdev/amifb: Reor... |
2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 |
if (regno > 3) return 1; } else { if (regno > 31) return 1; } red >>= 8; green >>= 8; blue >>= 8; if (!regno) { red0 = red; green0 = green; blue0 = blue; } |
1da177e4c Linux-2.6.12-rc2 |
2448 2449 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
2450 2451 2452 2453 2454 |
* Update the corresponding Hardware Color Register, unless it's Color * Register 0 and the screen is blanked. * * VBlank is switched off to protect bplcon3 or ecs_palette[] from * being changed by ami_do_blank() during the VBlank. |
1da177e4c Linux-2.6.12-rc2 |
2455 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2456 2457 2458 |
if (regno || !is_blanked) { #if defined(CONFIG_FB_AMIGA_AGA) if (IS_AGA) { |
61640c295 fbdev/amifb: Use ... |
2459 |
u_short bplcon3 = par->bplcon3; |
f1cbb17ac fbdev/amifb: Reor... |
2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 |
VBlankOff(); custom.bplcon3 = bplcon3 | (regno << 8 & 0xe000); custom.color[regno & 31] = rgb2hw8_high(red, green, blue); custom.bplcon3 = bplcon3 | (regno << 8 & 0xe000) | BPC3_LOCT; custom.color[regno & 31] = rgb2hw8_low(red, green, blue); custom.bplcon3 = bplcon3; VBlankOn(); } else #endif #if defined(CONFIG_FB_AMIGA_ECS) |
61640c295 fbdev/amifb: Use ... |
2473 |
if (par->bplcon0 & BPC0_SHRES) { |
f1cbb17ac fbdev/amifb: Reor... |
2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 |
u_short color, mask; int i; mask = 0x3333; color = rgb2hw2(red, green, blue); VBlankOff(); for (i = regno + 12; i >= (int)regno; i -= 4) custom.color[i] = ecs_palette[i] = (ecs_palette[i] & mask) | color; mask <<= 2; color >>= 2; regno = down16(regno) + mul4(mod4(regno)); for (i = regno + 3; i >= (int)regno; i--) custom.color[i] = ecs_palette[i] = (ecs_palette[i] & mask) | color; VBlankOn(); } else #endif custom.color[regno] = rgb2hw4(red, green, blue); |
1da177e4c Linux-2.6.12-rc2 |
2490 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2491 2492 |
return 0; } |
1da177e4c Linux-2.6.12-rc2 |
2493 2494 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
2495 |
* Blank the display. |
1da177e4c Linux-2.6.12-rc2 |
2496 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2497 2498 2499 |
static int amifb_blank(int blank, struct fb_info *info) { do_blank = blank ? blank : -1; |
1da177e4c Linux-2.6.12-rc2 |
2500 |
|
f1cbb17ac fbdev/amifb: Reor... |
2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 |
return 0; } /* * Pan or Wrap the Display * * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag */ static int amifb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { if (var->vmode & FB_VMODE_YWRAP) { if (var->yoffset < 0 || var->yoffset >= info->var.yres_virtual || var->xoffset) |
1da177e4c Linux-2.6.12-rc2 |
2517 |
return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
2518 |
} else { |
f1cbb17ac fbdev/amifb: Reor... |
2519 2520 2521 2522 2523 2524 2525 2526 |
/* * TODO: There will be problems when xpan!=1, so some columns * on the right side will never be seen */ if (var->xoffset + info->var.xres > upx(16 << maxfmode, info->var.xres_virtual) || var->yoffset + info->var.yres > info->var.yres_virtual) return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
2527 |
} |
61640c295 fbdev/amifb: Use ... |
2528 |
ami_pan_var(var, info); |
f1cbb17ac fbdev/amifb: Reor... |
2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 |
info->var.xoffset = var->xoffset; info->var.yoffset = var->yoffset; if (var->vmode & FB_VMODE_YWRAP) info->var.vmode |= FB_VMODE_YWRAP; else info->var.vmode &= ~FB_VMODE_YWRAP; return 0; } #if BITS_PER_LONG == 32 #define BYTES_PER_LONG 4 #define SHIFT_PER_LONG 5 #elif BITS_PER_LONG == 64 #define BYTES_PER_LONG 8 #define SHIFT_PER_LONG 6 #else #define Please update me #endif |
1da177e4c Linux-2.6.12-rc2 |
2548 2549 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
2550 2551 |
* Compose two values, using a bitmask as decision value * This is equivalent to (a & mask) | (b & ~mask) |
1da177e4c Linux-2.6.12-rc2 |
2552 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 |
static inline unsigned long comp(unsigned long a, unsigned long b, unsigned long mask) { return ((a ^ b) & mask) ^ b; } static inline unsigned long xor(unsigned long a, unsigned long b, unsigned long mask) { return (a & mask) ^ b; } |
1da177e4c Linux-2.6.12-rc2 |
2565 2566 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
2567 |
* Unaligned forward bit copy using 32-bit or 64-bit memory accesses |
1da177e4c Linux-2.6.12-rc2 |
2568 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2569 2570 2571 2572 2573 2574 2575 |
static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src, int src_idx, u32 n) { unsigned long first, last; int shift = dst_idx - src_idx, left, right; unsigned long d0, d1; int m; |
1da177e4c Linux-2.6.12-rc2 |
2576 |
|
f1cbb17ac fbdev/amifb: Reor... |
2577 2578 |
if (!n) return; |
1da177e4c Linux-2.6.12-rc2 |
2579 |
|
f1cbb17ac fbdev/amifb: Reor... |
2580 2581 2582 |
shift = dst_idx - src_idx; first = ~0UL >> dst_idx; last = ~(~0UL >> ((dst_idx + n) % BITS_PER_LONG)); |
1da177e4c Linux-2.6.12-rc2 |
2583 |
|
f1cbb17ac fbdev/amifb: Reor... |
2584 2585 2586 2587 2588 2589 2590 2591 |
if (!shift) { // Same alignment for source and dest if (dst_idx + n <= BITS_PER_LONG) { // Single word if (last) first &= last; *dst = comp(*src, *dst, first); |
1da177e4c Linux-2.6.12-rc2 |
2592 |
} else { |
f1cbb17ac fbdev/amifb: Reor... |
2593 2594 2595 2596 2597 2598 2599 |
// Multiple destination words // Leading bits if (first) { *dst = comp(*src, *dst, first); dst++; src++; n -= BITS_PER_LONG - dst_idx; |
1da177e4c Linux-2.6.12-rc2 |
2600 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 |
// Main chunk n /= BITS_PER_LONG; while (n >= 8) { *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; *dst++ = *src++; n -= 8; |
1da177e4c Linux-2.6.12-rc2 |
2614 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 |
while (n--) *dst++ = *src++; // Trailing bits if (last) *dst = comp(*src, *dst, last); } } else { // Different alignment for source and dest right = shift & (BITS_PER_LONG - 1); left = -shift & (BITS_PER_LONG - 1); if (dst_idx + n <= BITS_PER_LONG) { // Single destination word if (last) first &= last; if (shift > 0) { // Single source word *dst = comp(*src >> right, *dst, first); } else if (src_idx + n <= BITS_PER_LONG) { // Single source word *dst = comp(*src << left, *dst, first); } else { // 2 source words d0 = *src++; d1 = *src; *dst = comp(d0 << left | d1 >> right, *dst, first); |
1da177e4c Linux-2.6.12-rc2 |
2644 2645 |
} } else { |
f1cbb17ac fbdev/amifb: Reor... |
2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 |
// Multiple destination words d0 = *src++; // Leading bits if (shift > 0) { // Single source word *dst = comp(d0 >> right, *dst, first); dst++; n -= BITS_PER_LONG - dst_idx; } else { // 2 source words d1 = *src++; *dst = comp(d0 << left | d1 >> right, *dst, first); d0 = d1; dst++; n -= BITS_PER_LONG - dst_idx; |
1da177e4c Linux-2.6.12-rc2 |
2662 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 |
// Main chunk m = n % BITS_PER_LONG; n /= BITS_PER_LONG; while (n >= 4) { d1 = *src++; *dst++ = d0 << left | d1 >> right; d0 = d1; d1 = *src++; *dst++ = d0 << left | d1 >> right; d0 = d1; d1 = *src++; *dst++ = d0 << left | d1 >> right; d0 = d1; d1 = *src++; *dst++ = d0 << left | d1 >> right; d0 = d1; n -= 4; |
1da177e4c Linux-2.6.12-rc2 |
2681 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2682 2683 2684 2685 |
while (n--) { d1 = *src++; *dst++ = d0 << left | d1 >> right; d0 = d1; |
1da177e4c Linux-2.6.12-rc2 |
2686 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 |
// Trailing bits if (last) { if (m <= right) { // Single source word *dst = comp(d0 << left, *dst, last); } else { // 2 source words d1 = *src; *dst = comp(d0 << left | d1 >> right, *dst, last); } |
1da177e4c Linux-2.6.12-rc2 |
2699 2700 |
} } |
1da177e4c Linux-2.6.12-rc2 |
2701 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2702 |
} |
1da177e4c Linux-2.6.12-rc2 |
2703 |
|
1da177e4c Linux-2.6.12-rc2 |
2704 2705 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
2706 |
* Unaligned reverse bit copy using 32-bit or 64-bit memory accesses |
1da177e4c Linux-2.6.12-rc2 |
2707 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 |
static void bitcpy_rev(unsigned long *dst, int dst_idx, const unsigned long *src, int src_idx, u32 n) { unsigned long first, last; int shift = dst_idx - src_idx, left, right; unsigned long d0, d1; int m; if (!n) return; |
1da177e4c Linux-2.6.12-rc2 |
2718 |
|
f1cbb17ac fbdev/amifb: Reor... |
2719 2720 2721 2722 2723 2724 2725 2726 2727 |
dst += (n - 1) / BITS_PER_LONG; src += (n - 1) / BITS_PER_LONG; if ((n - 1) % BITS_PER_LONG) { dst_idx += (n - 1) % BITS_PER_LONG; dst += dst_idx >> SHIFT_PER_LONG; dst_idx &= BITS_PER_LONG - 1; src_idx += (n - 1) % BITS_PER_LONG; src += src_idx >> SHIFT_PER_LONG; src_idx &= BITS_PER_LONG - 1; |
1da177e4c Linux-2.6.12-rc2 |
2728 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2729 2730 2731 |
shift = dst_idx - src_idx; first = ~0UL << (BITS_PER_LONG - 1 - dst_idx); last = ~(~0UL << (BITS_PER_LONG - 1 - ((dst_idx - n) % BITS_PER_LONG))); |
1da177e4c Linux-2.6.12-rc2 |
2732 |
|
f1cbb17ac fbdev/amifb: Reor... |
2733 2734 |
if (!shift) { // Same alignment for source and dest |
1da177e4c Linux-2.6.12-rc2 |
2735 |
|
f1cbb17ac fbdev/amifb: Reor... |
2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 |
if ((unsigned long)dst_idx + 1 >= n) { // Single word if (last) first &= last; *dst = comp(*src, *dst, first); } else { // Multiple destination words // Leading bits if (first) { *dst = comp(*src, *dst, first); dst--; src--; n -= dst_idx + 1; } |
1da177e4c Linux-2.6.12-rc2 |
2750 |
|
f1cbb17ac fbdev/amifb: Reor... |
2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 |
// Main chunk n /= BITS_PER_LONG; while (n >= 8) { *dst-- = *src--; *dst-- = *src--; *dst-- = *src--; *dst-- = *src--; *dst-- = *src--; *dst-- = *src--; *dst-- = *src--; *dst-- = *src--; n -= 8; } while (n--) *dst-- = *src--; |
1da177e4c Linux-2.6.12-rc2 |
2766 |
|
f1cbb17ac fbdev/amifb: Reor... |
2767 2768 2769 |
// Trailing bits if (last) *dst = comp(*src, *dst, last); |
1da177e4c Linux-2.6.12-rc2 |
2770 |
} |
f1cbb17ac fbdev/amifb: Reor... |
2771 2772 |
} else { // Different alignment for source and dest |
1da177e4c Linux-2.6.12-rc2 |
2773 |
|
f1cbb17ac fbdev/amifb: Reor... |
2774 2775 |
right = shift & (BITS_PER_LONG - 1); left = -shift & (BITS_PER_LONG - 1); |
1da177e4c Linux-2.6.12-rc2 |
2776 |
|
f1cbb17ac fbdev/amifb: Reor... |
2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 |
if ((unsigned long)dst_idx + 1 >= n) { // Single destination word if (last) first &= last; if (shift < 0) { // Single source word *dst = comp(*src << left, *dst, first); } else if (1 + (unsigned long)src_idx >= n) { // Single source word *dst = comp(*src >> right, *dst, first); } else { // 2 source words d0 = *src--; d1 = *src; *dst = comp(d0 >> right | d1 << left, *dst, first); } } else { // Multiple destination words d0 = *src--; // Leading bits if (shift < 0) { // Single source word *dst = comp(d0 << left, *dst, first); dst--; n -= dst_idx + 1; } else { // 2 source words d1 = *src--; *dst = comp(d0 >> right | d1 << left, *dst, first); d0 = d1; dst--; n -= dst_idx + 1; } |
1da177e4c Linux-2.6.12-rc2 |
2812 |
|
f1cbb17ac fbdev/amifb: Reor... |
2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 |
// Main chunk m = n % BITS_PER_LONG; n /= BITS_PER_LONG; while (n >= 4) { d1 = *src--; *dst-- = d0 >> right | d1 << left; d0 = d1; d1 = *src--; *dst-- = d0 >> right | d1 << left; d0 = d1; d1 = *src--; *dst-- = d0 >> right | d1 << left; d0 = d1; d1 = *src--; *dst-- = d0 >> right | d1 << left; d0 = d1; n -= 4; } while (n--) { d1 = *src--; *dst-- = d0 >> right | d1 << left; d0 = d1; } |
1da177e4c Linux-2.6.12-rc2 |
2836 |
|
f1cbb17ac fbdev/amifb: Reor... |
2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 |
// Trailing bits if (last) { if (m <= left) { // Single source word *dst = comp(d0 >> right, *dst, last); } else { // 2 source words d1 = *src; *dst = comp(d0 >> right | d1 << left, *dst, last); } } |
1da177e4c Linux-2.6.12-rc2 |
2849 2850 |
} } |
f1cbb17ac fbdev/amifb: Reor... |
2851 |
} |
1da177e4c Linux-2.6.12-rc2 |
2852 2853 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
2854 2855 |
* Unaligned forward inverting bit copy using 32-bit or 64-bit memory * accesses |
1da177e4c Linux-2.6.12-rc2 |
2856 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
2857 2858 2859 2860 2861 2862 2863 |
static void bitcpy_not(unsigned long *dst, int dst_idx, const unsigned long *src, int src_idx, u32 n) { unsigned long first, last; int shift = dst_idx - src_idx, left, right; unsigned long d0, d1; int m; |
1da177e4c Linux-2.6.12-rc2 |
2864 |
|
f1cbb17ac fbdev/amifb: Reor... |
2865 2866 |
if (!n) return; |
1da177e4c Linux-2.6.12-rc2 |
2867 |
|
f1cbb17ac fbdev/amifb: Reor... |
2868 2869 2870 |
shift = dst_idx - src_idx; first = ~0UL >> dst_idx; last = ~(~0UL >> ((dst_idx + n) % BITS_PER_LONG)); |
1da177e4c Linux-2.6.12-rc2 |
2871 |
|
f1cbb17ac fbdev/amifb: Reor... |
2872 2873 2874 2875 2876 2877 2878 2879 |
if (!shift) { // Same alignment for source and dest if (dst_idx + n <= BITS_PER_LONG) { // Single word if (last) first &= last; *dst = comp(~*src, *dst, first); |
1da177e4c Linux-2.6.12-rc2 |
2880 |
} else { |
f1cbb17ac fbdev/amifb: Reor... |
2881 2882 2883 2884 2885 2886 2887 2888 |
// Multiple destination words // Leading bits if (first) { *dst = comp(~*src, *dst, first); dst++; src++; n -= BITS_PER_LONG - dst_idx; } |
1da177e4c Linux-2.6.12-rc2 |
2889 |
|
f1cbb17ac fbdev/amifb: Reor... |
2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 |
// Main chunk n /= BITS_PER_LONG; while (n >= 8) { *dst++ = ~*src++; *dst++ = ~*src++; *dst++ = ~*src++; *dst++ = ~*src++; *dst++ = ~*src++; *dst++ = ~*src++; *dst++ = ~*src++; *dst++ = ~*src++; n -= 8; } while (n--) *dst++ = ~*src++; |
1da177e4c Linux-2.6.12-rc2 |
2905 |
|
f1cbb17ac fbdev/amifb: Reor... |
2906 2907 2908 2909 2910 2911 |
// Trailing bits if (last) *dst = comp(~*src, *dst, last); } } else { // Different alignment for source and dest |
1da177e4c Linux-2.6.12-rc2 |
2912 |
|
f1cbb17ac fbdev/amifb: Reor... |
2913 2914 |
right = shift & (BITS_PER_LONG - 1); left = -shift & (BITS_PER_LONG - 1); |
1da177e4c Linux-2.6.12-rc2 |
2915 |
|
f1cbb17ac fbdev/amifb: Reor... |
2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 |
if (dst_idx + n <= BITS_PER_LONG) { // Single destination word if (last) first &= last; if (shift > 0) { // Single source word *dst = comp(~*src >> right, *dst, first); } else if (src_idx + n <= BITS_PER_LONG) { // Single source word *dst = comp(~*src << left, *dst, first); } else { // 2 source words d0 = ~*src++; d1 = ~*src; *dst = comp(d0 << left | d1 >> right, *dst, first); } } else { // Multiple destination words d0 = ~*src++; // Leading bits if (shift > 0) { // Single source word *dst = comp(d0 >> right, *dst, first); dst++; n -= BITS_PER_LONG - dst_idx; } else { // 2 source words d1 = ~*src++; *dst = comp(d0 << left | d1 >> right, *dst, first); d0 = d1; dst++; n -= BITS_PER_LONG - dst_idx; } |
1da177e4c Linux-2.6.12-rc2 |
2951 |
|
f1cbb17ac fbdev/amifb: Reor... |
2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 |
// Main chunk m = n % BITS_PER_LONG; n /= BITS_PER_LONG; while (n >= 4) { d1 = ~*src++; *dst++ = d0 << left | d1 >> right; d0 = d1; d1 = ~*src++; *dst++ = d0 << left | d1 >> right; d0 = d1; d1 = ~*src++; *dst++ = d0 << left | d1 >> right; d0 = d1; d1 = ~*src++; *dst++ = d0 << left | d1 >> right; d0 = d1; n -= 4; } while (n--) { d1 = ~*src++; *dst++ = d0 << left | d1 >> right; d0 = d1; } |
1da177e4c Linux-2.6.12-rc2 |
2975 |
|
f1cbb17ac fbdev/amifb: Reor... |
2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 |
// Trailing bits if (last) { if (m <= right) { // Single source word *dst = comp(d0 << left, *dst, last); } else { // 2 source words d1 = ~*src; *dst = comp(d0 << left | d1 >> right, *dst, last); } } } } } |
1da177e4c Linux-2.6.12-rc2 |
2991 |
|
1da177e4c Linux-2.6.12-rc2 |
2992 |
|
f1cbb17ac fbdev/amifb: Reor... |
2993 2994 2995 |
/* * Unaligned 32-bit pattern fill using 32/64-bit memory accesses */ |
1da177e4c Linux-2.6.12-rc2 |
2996 |
|
f1cbb17ac fbdev/amifb: Reor... |
2997 2998 2999 3000 |
static void bitfill32(unsigned long *dst, int dst_idx, u32 pat, u32 n) { unsigned long val = pat; unsigned long first, last; |
1da177e4c Linux-2.6.12-rc2 |
3001 |
|
f1cbb17ac fbdev/amifb: Reor... |
3002 3003 |
if (!n) return; |
1da177e4c Linux-2.6.12-rc2 |
3004 |
|
f1cbb17ac fbdev/amifb: Reor... |
3005 3006 3007 |
#if BITS_PER_LONG == 64 val |= val << 32; #endif |
1da177e4c Linux-2.6.12-rc2 |
3008 |
|
f1cbb17ac fbdev/amifb: Reor... |
3009 3010 |
first = ~0UL >> dst_idx; last = ~(~0UL >> ((dst_idx + n) % BITS_PER_LONG)); |
1da177e4c Linux-2.6.12-rc2 |
3011 |
|
f1cbb17ac fbdev/amifb: Reor... |
3012 3013 3014 3015 3016 |
if (dst_idx + n <= BITS_PER_LONG) { // Single word if (last) first &= last; *dst = comp(val, *dst, first); |
1da177e4c Linux-2.6.12-rc2 |
3017 |
} else { |
f1cbb17ac fbdev/amifb: Reor... |
3018 3019 3020 3021 3022 3023 3024 |
// Multiple destination words // Leading bits if (first) { *dst = comp(val, *dst, first); dst++; n -= BITS_PER_LONG - dst_idx; } |
1da177e4c Linux-2.6.12-rc2 |
3025 |
|
f1cbb17ac fbdev/amifb: Reor... |
3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 |
// Main chunk n /= BITS_PER_LONG; while (n >= 8) { *dst++ = val; *dst++ = val; *dst++ = val; *dst++ = val; *dst++ = val; *dst++ = val; *dst++ = val; *dst++ = val; n -= 8; } while (n--) *dst++ = val; |
1da177e4c Linux-2.6.12-rc2 |
3041 |
|
f1cbb17ac fbdev/amifb: Reor... |
3042 3043 3044 3045 |
// Trailing bits if (last) *dst = comp(val, *dst, last); } |
1da177e4c Linux-2.6.12-rc2 |
3046 3047 3048 3049 |
} /* |
f1cbb17ac fbdev/amifb: Reor... |
3050 |
* Unaligned 32-bit pattern xor using 32/64-bit memory accesses |
1da177e4c Linux-2.6.12-rc2 |
3051 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
3052 |
static void bitxor32(unsigned long *dst, int dst_idx, u32 pat, u32 n) |
1da177e4c Linux-2.6.12-rc2 |
3053 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
3054 3055 |
unsigned long val = pat; unsigned long first, last; |
1da177e4c Linux-2.6.12-rc2 |
3056 |
|
f1cbb17ac fbdev/amifb: Reor... |
3057 3058 |
if (!n) return; |
1da177e4c Linux-2.6.12-rc2 |
3059 |
|
f1cbb17ac fbdev/amifb: Reor... |
3060 3061 3062 |
#if BITS_PER_LONG == 64 val |= val << 32; #endif |
1da177e4c Linux-2.6.12-rc2 |
3063 |
|
f1cbb17ac fbdev/amifb: Reor... |
3064 3065 |
first = ~0UL >> dst_idx; last = ~(~0UL >> ((dst_idx + n) % BITS_PER_LONG)); |
1da177e4c Linux-2.6.12-rc2 |
3066 |
|
f1cbb17ac fbdev/amifb: Reor... |
3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 |
if (dst_idx + n <= BITS_PER_LONG) { // Single word if (last) first &= last; *dst = xor(val, *dst, first); } else { // Multiple destination words // Leading bits if (first) { *dst = xor(val, *dst, first); dst++; n -= BITS_PER_LONG - dst_idx; } |
1da177e4c Linux-2.6.12-rc2 |
3080 |
|
f1cbb17ac fbdev/amifb: Reor... |
3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 |
// Main chunk n /= BITS_PER_LONG; while (n >= 4) { *dst++ ^= val; *dst++ ^= val; *dst++ ^= val; *dst++ ^= val; n -= 4; } while (n--) *dst++ ^= val; |
1da177e4c Linux-2.6.12-rc2 |
3092 |
|
f1cbb17ac fbdev/amifb: Reor... |
3093 3094 3095 3096 3097 |
// Trailing bits if (last) *dst = xor(val, *dst, last); } } |
1da177e4c Linux-2.6.12-rc2 |
3098 |
|
f1cbb17ac fbdev/amifb: Reor... |
3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 |
static inline void fill_one_line(int bpp, unsigned long next_plane, unsigned long *dst, int dst_idx, u32 n, u32 color) { while (1) { dst += dst_idx >> SHIFT_PER_LONG; dst_idx &= (BITS_PER_LONG - 1); bitfill32(dst, dst_idx, color & 1 ? ~0 : 0, n); if (!--bpp) break; color >>= 1; dst_idx += next_plane * 8; |
1da177e4c Linux-2.6.12-rc2 |
3111 |
} |
1da177e4c Linux-2.6.12-rc2 |
3112 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 |
static inline void xor_one_line(int bpp, unsigned long next_plane, unsigned long *dst, int dst_idx, u32 n, u32 color) { while (color) { dst += dst_idx >> SHIFT_PER_LONG; dst_idx &= (BITS_PER_LONG - 1); bitxor32(dst, dst_idx, color & 1 ? ~0 : 0, n); if (!--bpp) break; color >>= 1; dst_idx += next_plane * 8; } } |
1da177e4c Linux-2.6.12-rc2 |
3127 |
|
1da177e4c Linux-2.6.12-rc2 |
3128 |
|
f1cbb17ac fbdev/amifb: Reor... |
3129 3130 |
static void amifb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) |
1da177e4c Linux-2.6.12-rc2 |
3131 |
{ |
423a53086 fbdev/amifb: Remo... |
3132 |
struct amifb_par *par = info->par; |
f1cbb17ac fbdev/amifb: Reor... |
3133 3134 3135 3136 3137 3138 |
int dst_idx, x2, y2; unsigned long *dst; u32 width, height; if (!rect->width || !rect->height) return; |
1da177e4c Linux-2.6.12-rc2 |
3139 3140 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
3141 3142 3143 3144 3145 3146 3147 3148 3149 |
* We could use hardware clipping but on many cards you get around * hardware clipping by writing to framebuffer directly. * */ x2 = rect->dx + rect->width; y2 = rect->dy + rect->height; x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; width = x2 - rect->dx; height = y2 - rect->dy; |
1da177e4c Linux-2.6.12-rc2 |
3150 |
|
f1cbb17ac fbdev/amifb: Reor... |
3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 |
dst = (unsigned long *) ((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1)); dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8; dst_idx += rect->dy * par->next_line * 8 + rect->dx; while (height--) { switch (rect->rop) { case ROP_COPY: fill_one_line(info->var.bits_per_pixel, par->next_plane, dst, dst_idx, width, rect->color); break; |
1da177e4c Linux-2.6.12-rc2 |
3162 |
|
f1cbb17ac fbdev/amifb: Reor... |
3163 3164 3165 3166 3167 3168 |
case ROP_XOR: xor_one_line(info->var.bits_per_pixel, par->next_plane, dst, dst_idx, width, rect->color); break; } dst_idx += par->next_line * 8; |
1da177e4c Linux-2.6.12-rc2 |
3169 |
} |
1da177e4c Linux-2.6.12-rc2 |
3170 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3171 3172 3173 |
static inline void copy_one_line(int bpp, unsigned long next_plane, unsigned long *dst, int dst_idx, unsigned long *src, int src_idx, u32 n) |
1da177e4c Linux-2.6.12-rc2 |
3174 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 |
while (1) { dst += dst_idx >> SHIFT_PER_LONG; dst_idx &= (BITS_PER_LONG - 1); src += src_idx >> SHIFT_PER_LONG; src_idx &= (BITS_PER_LONG - 1); bitcpy(dst, dst_idx, src, src_idx, n); if (!--bpp) break; dst_idx += next_plane * 8; src_idx += next_plane * 8; } |
1da177e4c Linux-2.6.12-rc2 |
3186 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3187 3188 3189 |
static inline void copy_one_line_rev(int bpp, unsigned long next_plane, unsigned long *dst, int dst_idx, unsigned long *src, int src_idx, u32 n) |
1da177e4c Linux-2.6.12-rc2 |
3190 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 |
while (1) { dst += dst_idx >> SHIFT_PER_LONG; dst_idx &= (BITS_PER_LONG - 1); src += src_idx >> SHIFT_PER_LONG; src_idx &= (BITS_PER_LONG - 1); bitcpy_rev(dst, dst_idx, src, src_idx, n); if (!--bpp) break; dst_idx += next_plane * 8; src_idx += next_plane * 8; |
1da177e4c Linux-2.6.12-rc2 |
3201 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3202 |
} |
1da177e4c Linux-2.6.12-rc2 |
3203 |
|
1da177e4c Linux-2.6.12-rc2 |
3204 |
|
f1cbb17ac fbdev/amifb: Reor... |
3205 3206 3207 |
static void amifb_copyarea(struct fb_info *info, const struct fb_copyarea *area) { |
423a53086 fbdev/amifb: Remo... |
3208 |
struct amifb_par *par = info->par; |
f1cbb17ac fbdev/amifb: Reor... |
3209 3210 3211 3212 3213 |
int x2, y2; u32 dx, dy, sx, sy, width, height; unsigned long *dst, *src; int dst_idx, src_idx; int rev_copy = 0; |
1da177e4c Linux-2.6.12-rc2 |
3214 |
|
f1cbb17ac fbdev/amifb: Reor... |
3215 3216 3217 3218 3219 3220 3221 3222 3223 |
/* clip the destination */ x2 = area->dx + area->width; y2 = area->dy + area->height; dx = area->dx > 0 ? area->dx : 0; dy = area->dy > 0 ? area->dy : 0; x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; width = x2 - dx; height = y2 - dy; |
1da177e4c Linux-2.6.12-rc2 |
3224 |
|
f1cbb17ac fbdev/amifb: Reor... |
3225 3226 |
if (area->sx + dx < area->dx || area->sy + dy < area->dy) return; |
1da177e4c Linux-2.6.12-rc2 |
3227 |
|
f1cbb17ac fbdev/amifb: Reor... |
3228 3229 3230 |
/* update sx,sy */ sx = area->sx + (dx - area->dx); sy = area->sy + (dy - area->dy); |
1da177e4c Linux-2.6.12-rc2 |
3231 |
|
f1cbb17ac fbdev/amifb: Reor... |
3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 |
/* the source must be completely inside the virtual screen */ if (sx + width > info->var.xres_virtual || sy + height > info->var.yres_virtual) return; if (dy > sy || (dy == sy && dx > sx)) { dy += height; sy += height; rev_copy = 1; } dst = (unsigned long *) ((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1)); src = dst; dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8; src_idx = dst_idx; dst_idx += dy * par->next_line * 8 + dx; src_idx += sy * par->next_line * 8 + sx; if (rev_copy) { while (height--) { dst_idx -= par->next_line * 8; src_idx -= par->next_line * 8; copy_one_line_rev(info->var.bits_per_pixel, par->next_plane, dst, dst_idx, src, src_idx, width); |
1da177e4c Linux-2.6.12-rc2 |
3256 3257 |
} } else { |
f1cbb17ac fbdev/amifb: Reor... |
3258 3259 3260 3261 3262 3263 |
while (height--) { copy_one_line(info->var.bits_per_pixel, par->next_plane, dst, dst_idx, src, src_idx, width); dst_idx += par->next_line * 8; src_idx += par->next_line * 8; |
1da177e4c Linux-2.6.12-rc2 |
3264 3265 |
} } |
1da177e4c Linux-2.6.12-rc2 |
3266 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3267 3268 3269 3270 |
static inline void expand_one_line(int bpp, unsigned long next_plane, unsigned long *dst, int dst_idx, u32 n, const u8 *data, u32 bgcolor, u32 fgcolor) |
1da177e4c Linux-2.6.12-rc2 |
3271 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
3272 3273 |
const unsigned long *src; int src_idx; |
1da177e4c Linux-2.6.12-rc2 |
3274 |
|
f1cbb17ac fbdev/amifb: Reor... |
3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 |
while (1) { dst += dst_idx >> SHIFT_PER_LONG; dst_idx &= (BITS_PER_LONG - 1); if ((bgcolor ^ fgcolor) & 1) { src = (unsigned long *) ((unsigned long)data & ~(BYTES_PER_LONG - 1)); src_idx = ((unsigned long)data & (BYTES_PER_LONG - 1)) * 8; if (fgcolor & 1) bitcpy(dst, dst_idx, src, src_idx, n); else bitcpy_not(dst, dst_idx, src, src_idx, n); /* set or clear */ } else bitfill32(dst, dst_idx, fgcolor & 1 ? ~0 : 0, n); if (!--bpp) break; bgcolor >>= 1; fgcolor >>= 1; dst_idx += next_plane * 8; } |
1da177e4c Linux-2.6.12-rc2 |
3295 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3296 3297 |
static void amifb_imageblit(struct fb_info *info, const struct fb_image *image) |
1da177e4c Linux-2.6.12-rc2 |
3298 |
{ |
423a53086 fbdev/amifb: Remo... |
3299 |
struct amifb_par *par = info->par; |
f1cbb17ac fbdev/amifb: Reor... |
3300 3301 3302 3303 3304 |
int x2, y2; unsigned long *dst; int dst_idx; const char *src; u32 dx, dy, width, height, pitch; |
1da177e4c Linux-2.6.12-rc2 |
3305 |
|
f1cbb17ac fbdev/amifb: Reor... |
3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 |
/* * We could use hardware clipping but on many cards you get around * hardware clipping by writing to framebuffer directly like we are * doing here. */ x2 = image->dx + image->width; y2 = image->dy + image->height; dx = image->dx; dy = image->dy; x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; width = x2 - dx; height = y2 - dy; if (image->depth == 1) { dst = (unsigned long *) ((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1)); dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8; dst_idx += dy * par->next_line * 8 + dx; src = image->data; pitch = (image->width + 7) / 8; while (height--) { expand_one_line(info->var.bits_per_pixel, par->next_plane, dst, dst_idx, width, src, image->bg_color, image->fg_color); dst_idx += par->next_line * 8; src += pitch; |
1da177e4c Linux-2.6.12-rc2 |
3334 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3335 3336 3337 3338 |
} else { c2p_planar(info->screen_base, image->data, dx, dy, width, height, par->next_line, par->next_plane, image->width, info->var.bits_per_pixel); |
1da177e4c Linux-2.6.12-rc2 |
3339 |
} |
1da177e4c Linux-2.6.12-rc2 |
3340 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3341 3342 3343 3344 3345 3346 3347 |
/* * Amiga Frame Buffer Specific ioctls */ static int amifb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) |
1da177e4c Linux-2.6.12-rc2 |
3348 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
3349 3350 3351 3352 3353 3354 3355 |
union { struct fb_fix_cursorinfo fix; struct fb_var_cursorinfo var; struct fb_cursorstate state; } crsr; void __user *argp = (void __user *)arg; int i; |
1da177e4c Linux-2.6.12-rc2 |
3356 |
|
f1cbb17ac fbdev/amifb: Reor... |
3357 3358 |
switch (cmd) { case FBIOGET_FCURSORINFO: |
61640c295 fbdev/amifb: Use ... |
3359 |
i = ami_get_fix_cursorinfo(&crsr.fix, info->par); |
f1cbb17ac fbdev/amifb: Reor... |
3360 3361 3362 3363 3364 3365 3366 |
if (i) return i; return copy_to_user(argp, &crsr.fix, sizeof(crsr.fix)) ? -EFAULT : 0; case FBIOGET_VCURSORINFO: i = ami_get_var_cursorinfo(&crsr.var, |
61640c295 fbdev/amifb: Use ... |
3367 3368 |
((struct fb_var_cursorinfo __user *)arg)->data, info->par); |
f1cbb17ac fbdev/amifb: Reor... |
3369 3370 3371 3372 3373 3374 3375 3376 3377 |
if (i) return i; return copy_to_user(argp, &crsr.var, sizeof(crsr.var)) ? -EFAULT : 0; case FBIOPUT_VCURSORINFO: if (copy_from_user(&crsr.var, argp, sizeof(crsr.var))) return -EFAULT; return ami_set_var_cursorinfo(&crsr.var, |
61640c295 fbdev/amifb: Use ... |
3378 3379 |
((struct fb_var_cursorinfo __user *)arg)->data, info->par); |
f1cbb17ac fbdev/amifb: Reor... |
3380 3381 |
case FBIOGET_CURSORSTATE: |
61640c295 fbdev/amifb: Use ... |
3382 |
i = ami_get_cursorstate(&crsr.state, info->par); |
f1cbb17ac fbdev/amifb: Reor... |
3383 3384 3385 3386 3387 3388 3389 3390 |
if (i) return i; return copy_to_user(argp, &crsr.state, sizeof(crsr.state)) ? -EFAULT : 0; case FBIOPUT_CURSORSTATE: if (copy_from_user(&crsr.state, argp, sizeof(crsr.state))) return -EFAULT; |
61640c295 fbdev/amifb: Use ... |
3391 |
return ami_set_cursorstate(&crsr.state, info->par); |
1da177e4c Linux-2.6.12-rc2 |
3392 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3393 |
return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
3394 |
} |
1da177e4c Linux-2.6.12-rc2 |
3395 |
|
f1cbb17ac fbdev/amifb: Reor... |
3396 3397 3398 |
/* * Flash the cursor (called by VBlank interrupt) */ |
1da177e4c Linux-2.6.12-rc2 |
3399 |
|
f1cbb17ac fbdev/amifb: Reor... |
3400 |
static int flash_cursor(void) |
1da177e4c Linux-2.6.12-rc2 |
3401 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
3402 |
static int cursorcount = 1; |
1da177e4c Linux-2.6.12-rc2 |
3403 |
|
f1cbb17ac fbdev/amifb: Reor... |
3404 3405 3406 3407 3408 3409 3410 3411 |
if (cursormode == FB_CURSOR_FLASH) { if (!--cursorcount) { cursorstate = -cursorstate; cursorcount = cursorrate; if (!is_blanked) return 1; } } |
1da177e4c Linux-2.6.12-rc2 |
3412 3413 |
return 0; } |
f1cbb17ac fbdev/amifb: Reor... |
3414 3415 3416 3417 3418 |
/* * VBlank Display Interrupt */ static irqreturn_t amifb_interrupt(int irq, void *dev_id) |
1da177e4c Linux-2.6.12-rc2 |
3419 |
{ |
61640c295 fbdev/amifb: Use ... |
3420 |
struct amifb_par *par = dev_id; |
f1cbb17ac fbdev/amifb: Reor... |
3421 |
if (do_vmode_pan || do_vmode_full) |
61640c295 fbdev/amifb: Use ... |
3422 |
ami_update_display(par); |
1da177e4c Linux-2.6.12-rc2 |
3423 |
|
f1cbb17ac fbdev/amifb: Reor... |
3424 |
if (do_vmode_full) |
61640c295 fbdev/amifb: Use ... |
3425 |
ami_init_display(par); |
f1cbb17ac fbdev/amifb: Reor... |
3426 3427 3428 |
if (do_vmode_pan) { flash_cursor(); |
61640c295 fbdev/amifb: Use ... |
3429 |
ami_rebuild_copper(par); |
f1cbb17ac fbdev/amifb: Reor... |
3430 3431 3432 |
do_cursor = do_vmode_pan = 0; } else if (do_cursor) { flash_cursor(); |
61640c295 fbdev/amifb: Use ... |
3433 |
ami_set_sprite(par); |
f1cbb17ac fbdev/amifb: Reor... |
3434 3435 3436 |
do_cursor = 0; } else { if (flash_cursor()) |
61640c295 fbdev/amifb: Use ... |
3437 |
ami_set_sprite(par); |
1da177e4c Linux-2.6.12-rc2 |
3438 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3439 3440 |
if (do_blank) { |
61640c295 fbdev/amifb: Use ... |
3441 |
ami_do_blank(par); |
f1cbb17ac fbdev/amifb: Reor... |
3442 |
do_blank = 0; |
1da177e4c Linux-2.6.12-rc2 |
3443 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3444 3445 |
if (do_vmode_full) { |
61640c295 fbdev/amifb: Use ... |
3446 |
ami_reinit_copper(par); |
f1cbb17ac fbdev/amifb: Reor... |
3447 |
do_vmode_full = 0; |
1da177e4c Linux-2.6.12-rc2 |
3448 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3449 |
return IRQ_HANDLED; |
1da177e4c Linux-2.6.12-rc2 |
3450 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 |
static struct fb_ops amifb_ops = { .owner = THIS_MODULE, .fb_check_var = amifb_check_var, .fb_set_par = amifb_set_par, .fb_setcolreg = amifb_setcolreg, .fb_blank = amifb_blank, .fb_pan_display = amifb_pan_display, .fb_fillrect = amifb_fillrect, .fb_copyarea = amifb_copyarea, .fb_imageblit = amifb_imageblit, .fb_ioctl = amifb_ioctl, }; |
1da177e4c Linux-2.6.12-rc2 |
3463 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
3464 |
* Allocate, Clear and Align a Block of Chip Memory |
1da177e4c Linux-2.6.12-rc2 |
3465 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
3466 3467 3468 |
static void *aligned_chipptr; static inline u_long __init chipalloc(u_long size) |
1da177e4c Linux-2.6.12-rc2 |
3469 |
{ |
f1cbb17ac fbdev/amifb: Reor... |
3470 3471 3472 3473 3474 3475 3476 3477 |
aligned_chipptr = amiga_chip_alloc(size, "amifb [RAM]"); if (!aligned_chipptr) { pr_err("amifb: No Chip RAM for frame buffer"); return 0; } memset(aligned_chipptr, 0, size); return (u_long)aligned_chipptr; } |
1da177e4c Linux-2.6.12-rc2 |
3478 |
|
f1cbb17ac fbdev/amifb: Reor... |
3479 3480 3481 3482 3483 |
static inline void chipfree(void) { if (aligned_chipptr) amiga_chip_free(aligned_chipptr); } |
f1cbb17ac fbdev/amifb: Reor... |
3484 3485 3486 3487 3488 3489 |
/* * Initialisation */ static int __init amifb_probe(struct platform_device *pdev) { |
61640c295 fbdev/amifb: Use ... |
3490 |
struct fb_info *info; |
f1cbb17ac fbdev/amifb: Reor... |
3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 |
int tag, i, err = 0; u_long chipptr; u_int defmode; #ifndef MODULE char *option = NULL; if (fb_get_options("amifb", &option)) { amifb_video_off(); return -ENODEV; } amifb_setup(option); #endif custom.dmacon = DMAF_ALL | DMAF_MASTER; |
61640c295 fbdev/amifb: Use ... |
3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 |
info = framebuffer_alloc(sizeof(struct amifb_par), &pdev->dev); if (!info) { dev_err(&pdev->dev, "framebuffer_alloc failed "); return -ENOMEM; } strcpy(info->fix.id, "Amiga "); info->fix.visual = FB_VISUAL_PSEUDOCOLOR; info->fix.accel = FB_ACCEL_AMIGABLITT; |
f1cbb17ac fbdev/amifb: Reor... |
3515 3516 3517 |
switch (amiga_chipset) { #ifdef CONFIG_FB_AMIGA_OCS case CS_OCS: |
61640c295 fbdev/amifb: Use ... |
3518 |
strcat(info->fix.id, "OCS"); |
f1cbb17ac fbdev/amifb: Reor... |
3519 3520 3521 3522 3523 3524 3525 |
default_chipset: chipset = TAG_OCS; maxdepth[TAG_SHRES] = 0; /* OCS means no SHRES */ maxdepth[TAG_HIRES] = 4; maxdepth[TAG_LORES] = 6; maxfmode = TAG_FMODE_1; defmode = amiga_vblank == 50 ? DEFMODE_PAL : DEFMODE_NTSC; |
61640c295 fbdev/amifb: Use ... |
3526 |
info->fix.smem_len = VIDEOMEMSIZE_OCS; |
f1cbb17ac fbdev/amifb: Reor... |
3527 3528 3529 3530 3531 |
break; #endif /* CONFIG_FB_AMIGA_OCS */ #ifdef CONFIG_FB_AMIGA_ECS case CS_ECS: |
61640c295 fbdev/amifb: Use ... |
3532 |
strcat(info->fix.id, "ECS"); |
f1cbb17ac fbdev/amifb: Reor... |
3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 |
chipset = TAG_ECS; maxdepth[TAG_SHRES] = 2; maxdepth[TAG_HIRES] = 4; maxdepth[TAG_LORES] = 6; maxfmode = TAG_FMODE_1; if (AMIGAHW_PRESENT(AMBER_FF)) defmode = amiga_vblank == 50 ? DEFMODE_AMBER_PAL : DEFMODE_AMBER_NTSC; else defmode = amiga_vblank == 50 ? DEFMODE_PAL : DEFMODE_NTSC; if (amiga_chip_avail() - CHIPRAM_SAFETY_LIMIT > VIDEOMEMSIZE_ECS_2M) |
61640c295 fbdev/amifb: Use ... |
3546 |
info->fix.smem_len = VIDEOMEMSIZE_ECS_2M; |
f1cbb17ac fbdev/amifb: Reor... |
3547 |
else |
61640c295 fbdev/amifb: Use ... |
3548 |
info->fix.smem_len = VIDEOMEMSIZE_ECS_1M; |
f1cbb17ac fbdev/amifb: Reor... |
3549 3550 3551 3552 3553 |
break; #endif /* CONFIG_FB_AMIGA_ECS */ #ifdef CONFIG_FB_AMIGA_AGA case CS_AGA: |
61640c295 fbdev/amifb: Use ... |
3554 |
strcat(info->fix.id, "AGA"); |
f1cbb17ac fbdev/amifb: Reor... |
3555 3556 3557 3558 3559 3560 3561 3562 |
chipset = TAG_AGA; maxdepth[TAG_SHRES] = 8; maxdepth[TAG_HIRES] = 8; maxdepth[TAG_LORES] = 8; maxfmode = TAG_FMODE_4; defmode = DEFMODE_AGA; if (amiga_chip_avail() - CHIPRAM_SAFETY_LIMIT > VIDEOMEMSIZE_AGA_2M) |
61640c295 fbdev/amifb: Use ... |
3563 |
info->fix.smem_len = VIDEOMEMSIZE_AGA_2M; |
f1cbb17ac fbdev/amifb: Reor... |
3564 |
else |
61640c295 fbdev/amifb: Use ... |
3565 |
info->fix.smem_len = VIDEOMEMSIZE_AGA_1M; |
f1cbb17ac fbdev/amifb: Reor... |
3566 3567 3568 3569 3570 3571 3572 |
break; #endif /* CONFIG_FB_AMIGA_AGA */ default: #ifdef CONFIG_FB_AMIGA_OCS printk("Unknown graphics chipset, defaulting to OCS "); |
61640c295 fbdev/amifb: Use ... |
3573 |
strcat(info->fix.id, "Unknown"); |
f1cbb17ac fbdev/amifb: Reor... |
3574 3575 3576 |
goto default_chipset; #else /* CONFIG_FB_AMIGA_OCS */ err = -ENODEV; |
61640c295 fbdev/amifb: Use ... |
3577 |
goto release; |
f1cbb17ac fbdev/amifb: Reor... |
3578 3579 |
#endif /* CONFIG_FB_AMIGA_OCS */ break; |
1da177e4c Linux-2.6.12-rc2 |
3580 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3581 3582 3583 |
/* * Calculate the Pixel Clock Values for this Machine */ |
1da177e4c Linux-2.6.12-rc2 |
3584 |
|
f1cbb17ac fbdev/amifb: Reor... |
3585 3586 |
{ u_long tmp = DIVUL(200000000000ULL, amiga_eclock); |
1da177e4c Linux-2.6.12-rc2 |
3587 |
|
f1cbb17ac fbdev/amifb: Reor... |
3588 3589 3590 3591 |
pixclock[TAG_SHRES] = (tmp + 4) / 8; /* SHRES: 35 ns / 28 MHz */ pixclock[TAG_HIRES] = (tmp + 2) / 4; /* HIRES: 70 ns / 14 MHz */ pixclock[TAG_LORES] = (tmp + 1) / 2; /* LORES: 140 ns / 7 MHz */ } |
1da177e4c Linux-2.6.12-rc2 |
3592 3593 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
3594 |
* Replace the Tag Values with the Real Pixel Clock Values |
1da177e4c Linux-2.6.12-rc2 |
3595 |
*/ |
f1cbb17ac fbdev/amifb: Reor... |
3596 3597 3598 3599 3600 3601 3602 |
for (i = 0; i < NUM_TOTAL_MODES; i++) { struct fb_videomode *mode = &ami_modedb[i]; tag = mode->pixclock; if (tag == TAG_SHRES || tag == TAG_HIRES || tag == TAG_LORES) { mode->pixclock = pixclock[tag]; } } |
1da177e4c Linux-2.6.12-rc2 |
3603 |
|
03c740a04 fbdev/amifb: Stor... |
3604 |
if (amifb_hfmin) { |
61640c295 fbdev/amifb: Use ... |
3605 3606 3607 3608 |
info->monspecs.hfmin = amifb_hfmin; info->monspecs.hfmax = amifb_hfmax; info->monspecs.vfmin = amifb_vfmin; info->monspecs.vfmax = amifb_vfmax; |
03c740a04 fbdev/amifb: Stor... |
3609 3610 3611 3612 |
} else { /* * These are for a typical Amiga monitor (e.g. A1960) */ |
61640c295 fbdev/amifb: Use ... |
3613 3614 3615 3616 |
info->monspecs.hfmin = 15000; info->monspecs.hfmax = 38000; info->monspecs.vfmin = 49; info->monspecs.vfmax = 90; |
f1cbb17ac fbdev/amifb: Reor... |
3617 |
} |
1da177e4c Linux-2.6.12-rc2 |
3618 |
|
61640c295 fbdev/amifb: Use ... |
3619 3620 3621 |
info->fbops = &amifb_ops; info->flags = FBINFO_DEFAULT; info->device = &pdev->dev; |
1da177e4c Linux-2.6.12-rc2 |
3622 |
|
61640c295 fbdev/amifb: Use ... |
3623 |
if (!fb_find_mode(&info->var, info, mode_option, ami_modedb, |
f1cbb17ac fbdev/amifb: Reor... |
3624 3625 |
NUM_TOTAL_MODES, &ami_modedb[defmode], 4)) { err = -EINVAL; |
61640c295 fbdev/amifb: Use ... |
3626 |
goto release; |
f1cbb17ac fbdev/amifb: Reor... |
3627 |
} |
1da177e4c Linux-2.6.12-rc2 |
3628 |
|
f1cbb17ac fbdev/amifb: Reor... |
3629 |
fb_videomode_to_modelist(ami_modedb, NUM_TOTAL_MODES, |
61640c295 fbdev/amifb: Use ... |
3630 |
&info->modelist); |
1da177e4c Linux-2.6.12-rc2 |
3631 |
|
f1cbb17ac fbdev/amifb: Reor... |
3632 |
round_down_bpp = 0; |
61640c295 fbdev/amifb: Use ... |
3633 |
chipptr = chipalloc(info->fix.smem_len + SPRITEMEMSIZE + |
f1cbb17ac fbdev/amifb: Reor... |
3634 3635 3636 3637 |
DUMMYSPRITEMEMSIZE + COPINITSIZE + 4 * COPLISTSIZE); if (!chipptr) { err = -ENOMEM; |
61640c295 fbdev/amifb: Use ... |
3638 |
goto release; |
1da177e4c Linux-2.6.12-rc2 |
3639 |
} |
1da177e4c Linux-2.6.12-rc2 |
3640 |
|
61640c295 fbdev/amifb: Use ... |
3641 |
assignchunk(videomemory, u_long, chipptr, info->fix.smem_len); |
f1cbb17ac fbdev/amifb: Reor... |
3642 3643 3644 3645 3646 3647 3648 |
assignchunk(spritememory, u_long, chipptr, SPRITEMEMSIZE); assignchunk(dummysprite, u_short *, chipptr, DUMMYSPRITEMEMSIZE); assignchunk(copdisplay.init, copins *, chipptr, COPINITSIZE); assignchunk(copdisplay.list[0][0], copins *, chipptr, COPLISTSIZE); assignchunk(copdisplay.list[0][1], copins *, chipptr, COPLISTSIZE); assignchunk(copdisplay.list[1][0], copins *, chipptr, COPLISTSIZE); assignchunk(copdisplay.list[1][1], copins *, chipptr, COPLISTSIZE); |
1da177e4c Linux-2.6.12-rc2 |
3649 3650 |
/* |
f1cbb17ac fbdev/amifb: Reor... |
3651 |
* access the videomem with writethrough cache |
1da177e4c Linux-2.6.12-rc2 |
3652 |
*/ |
61640c295 fbdev/amifb: Use ... |
3653 3654 3655 |
info->fix.smem_start = (u_long)ZTWO_PADDR(videomemory); videomemory = (u_long)ioremap_writethrough(info->fix.smem_start, info->fix.smem_len); |
f1cbb17ac fbdev/amifb: Reor... |
3656 |
if (!videomemory) { |
61640c295 fbdev/amifb: Use ... |
3657 3658 3659 3660 |
dev_warn(&pdev->dev, "Unable to map videomem cached writethrough "); info->screen_base = (char *)ZTWO_VADDR(info->fix.smem_start); |
f1cbb17ac fbdev/amifb: Reor... |
3661 |
} else |
61640c295 fbdev/amifb: Use ... |
3662 |
info->screen_base = (char *)videomemory; |
1da177e4c Linux-2.6.12-rc2 |
3663 |
|
f1cbb17ac fbdev/amifb: Reor... |
3664 |
memset(dummysprite, 0, DUMMYSPRITEMEMSIZE); |
1da177e4c Linux-2.6.12-rc2 |
3665 |
|
f1cbb17ac fbdev/amifb: Reor... |
3666 |
/* |
af5761d60 fbdev/amifb: Enab... |
3667 |
* Make sure the Copper has something to do |
f1cbb17ac fbdev/amifb: Reor... |
3668 |
*/ |
af5761d60 fbdev/amifb: Enab... |
3669 |
ami_init_copper(); |
1da177e4c Linux-2.6.12-rc2 |
3670 |
|
f1cbb17ac fbdev/amifb: Reor... |
3671 |
/* |
af5761d60 fbdev/amifb: Enab... |
3672 |
* Enable Display DMA |
f1cbb17ac fbdev/amifb: Reor... |
3673 |
*/ |
af5761d60 fbdev/amifb: Enab... |
3674 3675 |
custom.dmacon = DMAF_SETCLR | DMAF_MASTER | DMAF_RASTER | DMAF_COPPER | DMAF_BLITTER | DMAF_SPRITE; |
f1cbb17ac fbdev/amifb: Reor... |
3676 |
|
61640c295 fbdev/amifb: Use ... |
3677 3678 3679 3680 |
err = request_irq(IRQ_AMIGA_COPPER, amifb_interrupt, 0, "fb vertb handler", info->par); if (err) goto disable_dma; |
1da177e4c Linux-2.6.12-rc2 |
3681 |
|
61640c295 fbdev/amifb: Use ... |
3682 |
err = fb_alloc_cmap(&info->cmap, 1 << info->var.bits_per_pixel, 0); |
f1cbb17ac fbdev/amifb: Reor... |
3683 |
if (err) |
61640c295 fbdev/amifb: Use ... |
3684 |
goto free_irq; |
f1cbb17ac fbdev/amifb: Reor... |
3685 |
|
61640c295 fbdev/amifb: Use ... |
3686 3687 3688 3689 3690 |
dev_set_drvdata(&pdev->dev, info); err = register_framebuffer(info); if (err) goto unset_drvdata; |
f1cbb17ac fbdev/amifb: Reor... |
3691 3692 3693 |
printk("fb%d: %s frame buffer device, using %dK of video memory ", |
61640c295 fbdev/amifb: Use ... |
3694 |
info->node, info->fix.id, info->fix.smem_len>>10); |
f1cbb17ac fbdev/amifb: Reor... |
3695 3696 |
return 0; |
61640c295 fbdev/amifb: Use ... |
3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 |
unset_drvdata: dev_set_drvdata(&pdev->dev, NULL); fb_dealloc_cmap(&info->cmap); free_irq: free_irq(IRQ_AMIGA_COPPER, info->par); disable_dma: custom.dmacon = DMAF_ALL | DMAF_MASTER; if (videomemory) iounmap((void *)videomemory); chipfree(); release: framebuffer_release(info); |
f1cbb17ac fbdev/amifb: Reor... |
3709 |
return err; |
1da177e4c Linux-2.6.12-rc2 |
3710 |
} |
f1cbb17ac fbdev/amifb: Reor... |
3711 |
|
fa6688e1c m68k: amiga - Fra... |
3712 |
static int __exit amifb_remove(struct platform_device *pdev) |
1da177e4c Linux-2.6.12-rc2 |
3713 |
{ |
61640c295 fbdev/amifb: Use ... |
3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 |
struct fb_info *info = dev_get_drvdata(&pdev->dev); unregister_framebuffer(info); dev_set_drvdata(&pdev->dev, NULL); fb_dealloc_cmap(&info->cmap); free_irq(IRQ_AMIGA_COPPER, info->par); custom.dmacon = DMAF_ALL | DMAF_MASTER; if (videomemory) iounmap((void *)videomemory); chipfree(); framebuffer_release(info); |
1da177e4c Linux-2.6.12-rc2 |
3725 |
amifb_video_off(); |
fa6688e1c m68k: amiga - Fra... |
3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 |
return 0; } static struct platform_driver amifb_driver = { .remove = __exit_p(amifb_remove), .driver = { .name = "amiga-video", .owner = THIS_MODULE, }, }; static int __init amifb_init(void) { return platform_driver_probe(&amifb_driver, amifb_probe); |
1da177e4c Linux-2.6.12-rc2 |
3740 |
} |
5798712d6 drivers/video/ami... |
3741 3742 |
module_init(amifb_init); |
fa6688e1c m68k: amiga - Fra... |
3743 3744 3745 3746 3747 |
static void __exit amifb_exit(void) { platform_driver_unregister(&amifb_driver); } |
5798712d6 drivers/video/ami... |
3748 3749 3750 |
module_exit(amifb_exit); MODULE_LICENSE("GPL"); |
fa6688e1c m68k: amiga - Fra... |
3751 |
MODULE_ALIAS("platform:amiga-video"); |