2 * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device
4 * Copyright (C) 2001 Romain Dolbeau <dolbeau@irisa.fr>
5 * Based on code written by:
6 * Sven Luther, <luther@dpt-info.u-strasbg.fr>
7 * Alan Hourihane, <alanh@fairlite.demon.co.uk>
8 * Russell King, <rmk@arm.linux.org.uk>
9 * Based on linux/drivers/video/skeletonfb.c:
10 * Copyright (C) 1997 Geert Uytterhoeven
11 * Based on linux/driver/video/pm2fb.c:
12 * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT)
13 * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file COPYING in the main directory of this archive for
19 * $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $
22 * Mon Feb 11 10:35:48 MET 2002, v 1.4.11B: Cosmetic update.
23 * Wed Jan 23 14:16:59 MET 2002, v 1.4.11: Preliminary 2.5.x support, patch for 2.5.2.
24 * Wed Nov 28 11:08:29 MET 2001, v 1.4.10: potential bug fix for SDRAM-based board, patch for 2.4.16.
25 * Thu Sep 20 10:24:42 MET DST 2001, v 1.4.9: sync bug fix, preliminary flatpanel support, better timings.
26 * Tue Aug 28 10:13:01 MET DST 2001, v 1.4.8: memory timings check, minor bug fixes.
27 * Wed Jul 18 19:06:14 CEST 2001, v 1.4.7: Mode fix (800x600-100, 1024x768-100 changed), using HW panning + accel bug fix.
28 * Mon Jun 25 10:33:56 MET DST 2001, v 1.4.6: Depth 12 fix, chip reset ioctl, moved memory erase ioctl to DEBUG.
29 * Wed Jun 20 11:13:08 MET DST 2001, v 1.4.5: Fixed missing blinking cursor in 8bpp, code cleaning, memory erase IOCTL.
30 * Mon Jun 18 16:00:27 CEST 2001, v 1.4.4: Depth 12 (RGBA 4444) support, code cleaning.
31 * Fri Jun 15 13:53:01 CEST 2001, v 1.4.3: Removed warnings, depth 15 support, add 'depth' option.
32 * Thu Jun 14 10:13:52 MET DST 2001, v 1.4.2: Fixed depth switching bug, preliminary 15bpp (RGB5551) support.
33 * Thu Apr 12 11:16:45 MET DST 2001, v 1.4.1B: Doc updates.
34 * Fri Apr 6 11:12:53 MET DST 2001, v 1.4.1: Configure.help, minor cleanup
35 * Thu Mar 29 10:56:50 MET DST 2001, v 1.4.0: Module & module options support (note: linux patch changed, 2.2.19 added).
36 * Thu Mar 15 15:30:31 MET 2001, v 1.3.2: Fixed mirroring bug on little-endian.
37 * Wed Mar 14 21:25:54 CET 2001, v 1.3.1: Fixed bug in BlockMove (_bmov).
38 * Tue Mar 13 10:53:19 MET 2001, v 1.3.0: Character drawing hardware support (in all width between 1 and 16), fixes.
39 * Thu Mar 8 10:20:16 MET 2001, v 1.2.2: Better J2000 support, "font:" option.
40 * Tue Mar 6 21:25:04 CET 2001, v 1.2.1: Better acceleration support.
41 * Mon Mar 5 21:54:17 CET 2001, v 1.2.0: Partial acceleration support (clear & bmove)
42 * Mon Mar 5 12:52:15 CET 2001, v 1.1.3: Big pan_display fix.
43 * Sun Mar 4 22:21:50 CET 2001, v 1.1.2: (numerous) bug fixes.
44 * Fri Mar 2 15:54:07 CET 2001, v 1.1.1: Might have Appian J2000 support, resource mangement in 2.4
45 * Wed Feb 28 18:21:35 CET 2001, v 1.1.0: Might have multiple boards support (added, but not yest tested)
46 * Tue Feb 27 17:31:12 CET 2001, v 1.0.6: fixes boot-time mode select, add more default mode
47 * Tue Feb 27 14:01:36 CET 2001, v 1.0.5: fixes (1.0.4 was broken for 2.2), cleaning up
48 * Mon Feb 26 23:17:36 CET 2001, v 1.0.4: preliminary 2.4.x support, dropped (useless on pm3) partial product, more OF fix
49 * Mon Feb 26 20:59:05 CET 2001, v 1.0.3: No more shadow register (and wasted memory), endianess fix, use OF-preset resolution by default
50 * Wed Feb 21 22:09:30 CET 2001, v 1.0.2: Code cleaning for future multiboard support, better OF support, bugs fix
51 * Wed Feb 21 19:58:56 CET 2001, v 1.0.1: OpenFirmware support, fixed memory detection, better debug support, code cleaning
52 * Wed Feb 21 14:47:06 CET 2001, v 1.0.0: First working version
55 #include <linux/module.h>
56 #include <linux/kernel.h>
57 #include <linux/errno.h>
58 #include <linux/string.h>
60 #include <linux/tty.h>
61 #include <linux/slab.h>
62 #include <linux/vmalloc.h>
63 #include <linux/delay.h>
64 #include <linux/interrupt.h>
66 #include <linux/init.h>
67 #include <linux/pci.h>
68 #include <linux/ioport.h>
69 #include <linux/ctype.h>
71 #include <video/fbcon.h>
72 #include <video/fbcon-mfb.h>
73 #include <video/fbcon-cfb2.h>
74 #include <video/fbcon-cfb4.h>
75 #include <video/fbcon-cfb8.h>
76 #include <video/fbcon-cfb16.h>
77 #include <video/fbcon-cfb24.h>
78 #include <video/fbcon-cfb32.h>
79 #include <video/pm3fb.h>
82 #include <asm/uaccess.h>
88 /* ************************************* */
89 /* ***** The various "global" data ***** */
90 /* ************************************* */
92 /* those will need a rework for multiple board support */
94 static const char permedia3_name
[16] = "Permedia3";
96 /* the fb_par struct, mandatory */
98 u32 pixclock
; /* pixclock in KHz */
100 u32 width
; /* width of virtual screen */
101 u32 height
; /* height of virtual screen */
103 u32 hsstart
; /* horiz. sync start */
104 u32 hsend
; /* horiz. sync end */
105 u32 hbend
; /* horiz. blank end (also gate end) */
106 u32 htotal
; /* total width (w/ sync & blank) */
108 u32 vsstart
; /* vert. sync start */
109 u32 vsend
; /* vert. sync end */
110 u32 vbend
; /* vert. blank end */
111 u32 vtotal
; /* total height (w/ sync & blank) */
113 u32 stride
; /* screen stride */
114 u32 base
; /* screen base (xoffset+yoffset) in 128 bits unit */
115 /* NOTE : unlike other pm3 stuff above, stored *after* shiftbpp. don't ask */
116 u32 depth
; /* screen depth (8, 12, 15, 16 or 32) */
117 u32 video
; /* video control (hsync,vsync) */
124 unsigned long timings
;
125 unsigned long control
;
126 unsigned long refresh
;
127 unsigned long powerdown
;
129 typedef enum pm3fb_timing_result
{ pm3fb_timing_ok
, pm3fb_timing_problem
, pm3fb_timing_retry
} pm3fb_timing_result
;
130 #define PM3FB_UNKNOWN_TIMING_VALUE ((unsigned long)-1)
131 #define PM3FB_UNKNOWN_TIMINGS { PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE }
133 /* the fb_info struct, mandatory */
135 struct fb_info_gen gen
;
136 unsigned long board_num
; /* internal board number */
137 unsigned long use_current
;
138 struct pm3fb_par
*current_par
;
139 struct pci_dev
*dev
; /* PCI device */
140 unsigned long board_type
; /* index in the cardbase */
141 unsigned char *fb_base
; /* framebuffer memory base */
142 u32 fb_size
; /* framebuffer memory size */
143 unsigned char *p_fb
; /* physical address of frame buffer */
144 unsigned char *v_fb
; /* virtual address of frame buffer */
145 unsigned char *pIOBase
; /* physical address of registers region, must be rg_base or rg_base+PM2_REGS_SIZE depending on the host endianness */
146 unsigned char *vIOBase
; /* address of registers after ioremap() */
154 #ifdef FBCON_HAS_CFB16
155 u16 cmap12
[16]; /* RGBA 4444 */
156 u16 cmap15
[16]; /* RGBA 5551 */
157 u16 cmap16
[16]; /* RGBA 5650 */
159 #ifdef FBCON_HAS_CFB32
163 struct pm3fb_timings memt
;
166 /* regular resolution database*/
169 struct pm3fb_par user_mode
;
170 } mode_base
[] __initdata
= {
173 49500, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625,
175 PM3VideoControl_ENABLE
|
176 PM3VideoControl_HSYNC_ACTIVE_HIGH
178 PM3VideoControl_VSYNC_ACTIVE_HIGH
179 | PM3VideoControl_PIXELSIZE_8BIT
}}, {
181 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
183 PM3VideoControl_ENABLE
|
184 PM3VideoControl_HSYNC_ACTIVE_HIGH
186 PM3VideoControl_VSYNC_ACTIVE_HIGH
187 | PM3VideoControl_PIXELSIZE_8BIT
}}, {
189 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
191 PM3VideoControl_ENABLE
|
192 PM3VideoControl_HSYNC_ACTIVE_HIGH
194 PM3VideoControl_VSYNC_ACTIVE_HIGH
195 | PM3VideoControl_PIXELSIZE_32BIT
}},
196 /* Generated mode : "1600x1024", for the SGI 1600SW flat panel*/
199 108000, 1600, 1024, 16, 56, 104, 1704, 3, 6, 32,
201 PM3VideoControl_ENABLE
|
202 PM3VideoControl_HSYNC_ACTIVE_LOW
|PM3VideoControl_VSYNC_ACTIVE_LOW
|
203 PM3VideoControl_PIXELSIZE_32BIT
}},
204 /* ##### auto-generated mode, by fbtimings2pm3 */
205 /* Generated mode : "640x480-60" */
208 25174, 640, 480, 16, 112, 160, 800, 10, 12, 45,
210 PM3VideoControl_ENABLE
|
211 PM3VideoControl_HSYNC_ACTIVE_LOW
213 PM3VideoControl_VSYNC_ACTIVE_LOW
214 | PM3VideoControl_PIXELSIZE_8BIT
}},
215 /* Generated mode : "640x480-72" */
218 31199, 640, 480, 24, 64, 192, 832, 9, 12, 40, 520,
220 PM3VideoControl_ENABLE
|
221 PM3VideoControl_HSYNC_ACTIVE_LOW
223 PM3VideoControl_VSYNC_ACTIVE_LOW
224 | PM3VideoControl_PIXELSIZE_8BIT
}},
225 /* Generated mode : "640x480-75" */
228 31499, 640, 480, 16, 80, 200, 840, 1, 4, 20, 500,
230 PM3VideoControl_ENABLE
|
231 PM3VideoControl_HSYNC_ACTIVE_LOW
233 PM3VideoControl_VSYNC_ACTIVE_LOW
234 | PM3VideoControl_PIXELSIZE_8BIT
}},
235 /* Generated mode : "640x480-90" */
238 39909, 640, 480, 32, 72, 192, 832, 25, 39, 53, 533,
240 PM3VideoControl_ENABLE
|
241 PM3VideoControl_HSYNC_ACTIVE_LOW
243 PM3VideoControl_VSYNC_ACTIVE_LOW
244 | PM3VideoControl_PIXELSIZE_8BIT
}},
245 /* Generated mode : "640x480-100" */
248 44899, 640, 480, 32, 160, 208, 848, 22, 34, 51,
250 PM3VideoControl_ENABLE
|
251 PM3VideoControl_HSYNC_ACTIVE_LOW
253 PM3VideoControl_VSYNC_ACTIVE_LOW
254 | PM3VideoControl_PIXELSIZE_8BIT
}},
255 /* Generated mode : "800x600-48-lace" */
256 /* INTERLACED NOT SUPPORTED
257 {"800x600-48-lace", {35999, 800, 600, 80, 208, 264, 1064, 11, 23, 102, 702, 800, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
258 INTERLACED NOT SUPPORTED */
259 /* Generated mode : "800x600-56" */
262 35999, 800, 600, 24, 96, 224, 1024, 1, 3, 25, 625,
264 PM3VideoControl_ENABLE
|
265 PM3VideoControl_HSYNC_ACTIVE_HIGH
267 PM3VideoControl_VSYNC_ACTIVE_HIGH
268 | PM3VideoControl_PIXELSIZE_8BIT
}},
269 /* Generated mode : "800x600-60" */
272 40000, 800, 600, 40, 168, 256, 1056, 1, 5, 28, 628,
274 PM3VideoControl_ENABLE
|
275 PM3VideoControl_HSYNC_ACTIVE_HIGH
277 PM3VideoControl_VSYNC_ACTIVE_HIGH
278 | PM3VideoControl_PIXELSIZE_8BIT
}},
279 /* Generated mode : "800x600-70" */
282 44899, 800, 600, 24, 168, 208, 1008, 9, 21, 36,
284 PM3VideoControl_ENABLE
|
285 PM3VideoControl_HSYNC_ACTIVE_HIGH
287 PM3VideoControl_VSYNC_ACTIVE_LOW
288 | PM3VideoControl_PIXELSIZE_8BIT
}},
289 /* Generated mode : "800x600-72" */
292 50000, 800, 600, 56, 176, 240, 1040, 37, 43, 66,
294 PM3VideoControl_ENABLE
|
295 PM3VideoControl_HSYNC_ACTIVE_HIGH
297 PM3VideoControl_VSYNC_ACTIVE_HIGH
298 | PM3VideoControl_PIXELSIZE_8BIT
}},
299 /* Generated mode : "800x600-75" */
302 49497, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625,
304 PM3VideoControl_ENABLE
|
305 PM3VideoControl_HSYNC_ACTIVE_HIGH
307 PM3VideoControl_VSYNC_ACTIVE_HIGH
308 | PM3VideoControl_PIXELSIZE_8BIT
}},
309 /* Generated mode : "800x600-90" */
312 56637, 800, 600, 8, 72, 192, 992, 8, 19, 35, 635,
314 PM3VideoControl_ENABLE
|
315 PM3VideoControl_HSYNC_ACTIVE_HIGH
317 PM3VideoControl_VSYNC_ACTIVE_HIGH
318 | PM3VideoControl_PIXELSIZE_8BIT
}},
319 /* Generated mode : "800x600-100", from /etc/fb.modes */
320 /* DISABLED, hsstart == 0
323 67499, 800, 600, 0, 64, 280, 1080, 7, 11, 25, 625,
325 PM3VideoControl_ENABLE |
326 PM3VideoControl_HSYNC_ACTIVE_HIGH
328 PM3VideoControl_VSYNC_ACTIVE_HIGH
329 | PM3VideoControl_PIXELSIZE_8BIT}},
331 /* Generated mode : "800x600-100", from ??? */
334 69650, 800, 600, 64, 128, 288, 1088, 4, 10, 40, 640, 800, 0, 8,
335 PM3VideoControl_ENABLE
|PM3VideoControl_HSYNC_ACTIVE_LOW
|
336 PM3VideoControl_VSYNC_ACTIVE_LOW
|PM3VideoControl_PIXELSIZE_8BIT
}},
337 /* Generated mode : "1024x768-43-lace" */
338 /* INTERLACED NOT SUPPORTED
339 {"1024x768-43-lace", {44899, 1024, 768, 8, 184, 240, 1264, 1, 9, 49, 817, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
340 INTERLACED NOT SUPPORTED */
341 /* Generated mode : "1024x768-60" */
344 64998, 1024, 768, 24, 160, 320, 1344, 3, 9, 38,
346 PM3VideoControl_ENABLE
|
347 PM3VideoControl_HSYNC_ACTIVE_LOW
349 PM3VideoControl_VSYNC_ACTIVE_LOW
350 | PM3VideoControl_PIXELSIZE_8BIT
}},
351 /* Generated mode : "1024x768-70" */
354 74996, 1024, 768, 24, 160, 304, 1328, 3, 9, 38,
356 PM3VideoControl_ENABLE
|
357 PM3VideoControl_HSYNC_ACTIVE_LOW
359 PM3VideoControl_VSYNC_ACTIVE_LOW
360 | PM3VideoControl_PIXELSIZE_8BIT
}},
361 /* Generated mode : "1024x768-72" */
364 74996, 10224, 768, 24, 160, 264, 10488, 3, 9, 38,
366 PM3VideoControl_ENABLE
|
367 PM3VideoControl_HSYNC_ACTIVE_LOW
369 PM3VideoControl_VSYNC_ACTIVE_LOW
370 | PM3VideoControl_PIXELSIZE_8BIT
}},
371 /* Generated mode : "1024x768-75" */
374 78746, 1024, 768, 16, 112, 288, 1312, 1, 4, 32,
376 PM3VideoControl_ENABLE
|
377 PM3VideoControl_HSYNC_ACTIVE_HIGH
379 PM3VideoControl_VSYNC_ACTIVE_HIGH
380 | PM3VideoControl_PIXELSIZE_8BIT
}},
381 /* Generated mode : "1024x768-90" */
384 100000, 1024, 768, 0, 96, 288, 1312, 21, 36, 77,
386 PM3VideoControl_ENABLE
|
387 PM3VideoControl_HSYNC_ACTIVE_LOW
389 PM3VideoControl_VSYNC_ACTIVE_LOW
390 | PM3VideoControl_PIXELSIZE_8BIT
}},
391 /* Generated mode : "1024x768-100", from /etc/fb.modes */
392 /* DISABLED, vsstart == 0
395 109998, 1024, 768, 0, 88, 368, 1392, 0, 8, 24, 792,
397 PM3VideoControl_ENABLE |
398 PM3VideoControl_HSYNC_ACTIVE_LOW
400 PM3VideoControl_VSYNC_ACTIVE_LOW
401 | PM3VideoControl_PIXELSIZE_8BIT}},
403 /* Generated mode : "1024x768-100", from ??? */
406 115500, 1024, 768, 32, 224, 416, 1440, 3, 13, 34, 802, 1024, 0, 8,
407 PM3VideoControl_ENABLE
|PM3VideoControl_HSYNC_ACTIVE_LOW
|
408 PM3VideoControl_VSYNC_ACTIVE_LOW
|PM3VideoControl_PIXELSIZE_8BIT
}},
409 /* Generated mode : "1152x864-43-lace" */
410 /* INTERLACED NOT SUPPORTED
411 {"1152x864-43-lace", {64998, 1152, 864, 72, 200, 264, 1416, 78, 87, 191, 1055, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
412 INTERLACED NOT SUPPORTED */
413 /* Generated mode : "1152x864-47-lace" */
414 /* INTERLACED NOT SUPPORTED
415 {"1152x864-47-lace", {64998, 1152, 864, 88, 216, 296, 1448, 30, 39, 83, 947, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
416 INTERLACED NOT SUPPORTED */
417 /* Generated mode : "1152x864-60" */
420 80000, 1152, 864, 64, 176, 304, 1456, 6, 11, 52,
422 PM3VideoControl_ENABLE
|
423 PM3VideoControl_HSYNC_ACTIVE_HIGH
425 PM3VideoControl_VSYNC_ACTIVE_HIGH
426 | PM3VideoControl_PIXELSIZE_8BIT
}},
427 /* Generated mode : "1152x864-70" */
430 100000, 1152, 864, 40, 192, 360, 1512, 13, 24, 81,
432 PM3VideoControl_ENABLE
|
433 PM3VideoControl_HSYNC_ACTIVE_HIGH
435 PM3VideoControl_VSYNC_ACTIVE_HIGH
436 | PM3VideoControl_PIXELSIZE_8BIT
}},
437 /* Generated mode : "1152x864-75" */
440 109998, 1152, 864, 24, 168, 312, 1464, 45, 53, 138,
442 PM3VideoControl_ENABLE
|
443 PM3VideoControl_HSYNC_ACTIVE_HIGH
445 PM3VideoControl_VSYNC_ACTIVE_HIGH
446 | PM3VideoControl_PIXELSIZE_8BIT
}},
447 /* Generated mode : "1152x864-80" */
450 109998, 1152, 864, 16, 128, 288, 1440, 30, 37, 94,
452 PM3VideoControl_ENABLE
|
453 PM3VideoControl_HSYNC_ACTIVE_HIGH
455 PM3VideoControl_VSYNC_ACTIVE_HIGH
456 | PM3VideoControl_PIXELSIZE_8BIT
}},
457 /* Generated mode : "1280x1024-43-lace" */
458 /* INTERLACED NOT SUPPORTED
459 {"1280x1024-43-lace", {80000, 1024, 1024, 80, 160, 320, 1344, 50, 60, 125, 1149, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
460 INTERLACED NOT SUPPORTED */
461 /* Generated mode : "1280x1024-47-lace" */
462 /* INTERLACED NOT SUPPORTED
463 {"1280x1024-47-lace", {80000, 1280, 1024, 80, 160, 320, 1600, 1, 11, 29, 1053, 1280, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
464 INTERLACED NOT SUPPORTED */
465 /* Generated mode : "1280x1024-60" */
468 107991, 1280, 1024, 48, 160, 408, 1688, 1, 4, 42,
470 PM3VideoControl_ENABLE
|
471 PM3VideoControl_HSYNC_ACTIVE_HIGH
473 PM3VideoControl_VSYNC_ACTIVE_HIGH
474 | PM3VideoControl_PIXELSIZE_8BIT
}},
475 /* Generated mode : "1280x1024-70" */
478 125992, 1280, 1024, 80, 192, 408, 1688, 1, 6, 42,
480 PM3VideoControl_ENABLE
|
481 PM3VideoControl_HSYNC_ACTIVE_HIGH
483 PM3VideoControl_VSYNC_ACTIVE_HIGH
484 | PM3VideoControl_PIXELSIZE_8BIT
}},
485 /* Generated mode : "1280x1024-74" */
488 134989, 1280, 1024, 32, 176, 432, 1712, 0, 30, 40,
490 PM3VideoControl_ENABLE
|
491 PM3VideoControl_HSYNC_ACTIVE_HIGH
493 PM3VideoControl_VSYNC_ACTIVE_HIGH
494 | PM3VideoControl_PIXELSIZE_8BIT
}},
495 /* Generated mode : "1280x1024-75" */
498 134989, 1280, 1024, 16, 160, 408, 1688, 1, 4, 42,
500 PM3VideoControl_ENABLE
|
501 PM3VideoControl_HSYNC_ACTIVE_HIGH
503 PM3VideoControl_VSYNC_ACTIVE_HIGH
504 | PM3VideoControl_PIXELSIZE_8BIT
}},
505 /* Generated mode : "1600x1200-60" */
508 155981, 1600, 1200, 32, 192, 448, 2048, 10, 18, 70,
510 PM3VideoControl_ENABLE
|
511 PM3VideoControl_HSYNC_ACTIVE_LOW
513 PM3VideoControl_VSYNC_ACTIVE_LOW
514 | PM3VideoControl_PIXELSIZE_8BIT
}},
515 /* Generated mode : "1600x1200-66" */
518 171998, 1600, 1200, 40, 176, 480, 2080, 3, 6, 53,
520 PM3VideoControl_ENABLE
|
521 PM3VideoControl_HSYNC_ACTIVE_LOW
523 PM3VideoControl_VSYNC_ACTIVE_LOW
524 | PM3VideoControl_PIXELSIZE_8BIT
}},
525 /* Generated mode : "1600x1200-76" */
528 197980, 1600, 1200, 40, 176, 480, 2080, 3, 8, 50,
530 PM3VideoControl_ENABLE
|
531 PM3VideoControl_HSYNC_ACTIVE_LOW
533 PM3VideoControl_VSYNC_ACTIVE_LOW
534 | PM3VideoControl_PIXELSIZE_8BIT
}},
535 /* ##### end of auto-generated mode */
540 /* more mandatory stuff (see skeletonfb.c + framebuffer driver HOWTO */
541 static struct pm3fb_info fb_info
[PM3_MAX_BOARD
];
542 static struct pm3fb_par current_par
[PM3_MAX_BOARD
];
543 static int current_par_valid
[PM3_MAX_BOARD
];
544 /* to allow explicit filtering of board */
545 short bus
[PM3_MAX_BOARD
];
546 short slot
[PM3_MAX_BOARD
];
547 short func
[PM3_MAX_BOARD
];
548 short disable
[PM3_MAX_BOARD
];
549 short noaccel
[PM3_MAX_BOARD
];
550 char fontn
[PM3_MAX_BOARD
][PM3_FONTNAME_SIZE
];
551 short depth
[PM3_MAX_BOARD
];
552 short flatpanel
[PM3_MAX_BOARD
];
553 static struct display disp
[PM3_MAX_BOARD
];
554 static char g_options
[PM3_OPTIONS_SIZE
] __initdata
= "pm3fb,dummy";
555 short printtimings
= 0;
556 short forcesize
[PM3_MAX_BOARD
];
558 /* ********************* */
559 /* ***** prototype ***** */
560 /* ********************* */
562 static void pm3fb_j2000_setup(struct pm3fb_info
*l_fb_info
);
563 /* permedia3-specific */
564 static pm3fb_timing_result
pm3fb_preserve_memory_timings(struct pm3fb_info
*l_fb_info
);
565 static pm3fb_timing_result
pm3fb_try_memory_timings(struct pm3fb_info
*l_fb_info
);
566 static void pm3fb_write_memory_timings(struct pm3fb_info
*l_fb_info
);
567 static unsigned long pm3fb_read_dac_reg(struct pm3fb_info
*l_fb_info
,
569 static unsigned long pm3fb_CalculateClock(struct pm3fb_info
*l_fb_info
, unsigned long reqclock
, /* In kHz units */
570 unsigned long refclock
, /* In kHz units */
571 unsigned char *prescale
, /* ClkPreScale */
572 unsigned char *feedback
, /* ClkFeedBackScale */
573 unsigned char *postscale
574 /* ClkPostScale */ );
575 static void pm3fb_clear_memory(struct pm3fb_info
*l_fb_info
, u32 cc
);
576 static void pm3fb_clear_colormap(struct pm3fb_info
*l_fb_info
, unsigned char r
, unsigned char g
, unsigned char b
);
577 static void pm3fb_common_init(struct pm3fb_info
*l_fb_info
);
578 static int pm3fb_Shiftbpp(struct pm3fb_info
*l_fb_info
,
579 unsigned long depth
, int v
);
580 static int pm3fb_Unshiftbpp(struct pm3fb_info
*l_fb_info
,
581 unsigned long depth
, int v
);
582 static void pm3fb_mapIO(struct pm3fb_info
*l_fb_info
);
583 static void pm3fb_unmapIO(struct pm3fb_info
*l_fb_info
);
584 #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
585 static void pm3fb_show_cur_mode(struct pm3fb_info
*l_fb_info
);
587 static void pm3fb_show_cur_timing(struct pm3fb_info
*l_fb_info
);
588 static void pm3fb_write_mode(struct pm3fb_info
*l_fb_info
);
589 static void pm3fb_read_mode(struct pm3fb_info
*l_fb_info
,
590 struct pm3fb_par
*curpar
);
591 static unsigned long pm3fb_size_memory(struct pm3fb_info
*l_fb_info
);
592 /* accelerated permedia3-specific */
593 #ifdef PM3FB_USE_ACCEL
594 static void pm3fb_wait_pm3(struct pm3fb_info
*l_fb_info
);
595 static void pm3fb_init_engine(struct pm3fb_info
*l_fb_info
);
596 #ifdef FBCON_HAS_CFB32
597 static void pm3fb_cfb32_clear(struct vc_data
*conp
,
599 int sy
, int sx
, int height
, int width
);
600 static void pm3fb_cfb32_clear_margins(struct vc_data
*conp
,
601 struct display
*p
, int bottom_only
);
602 #endif /* FBCON_HAS_CFB32 */
603 #ifdef FBCON_HAS_CFB16
604 static void pm3fb_cfb16_clear(struct vc_data
*conp
,
606 int sy
, int sx
, int height
, int width
);
607 static void pm3fb_cfb16_clear_margins(struct vc_data
*conp
,
608 struct display
*p
, int bottom_only
);
609 #endif /* FBCON_HAS_CFB16 */
610 #ifdef FBCON_HAS_CFB8
611 static void pm3fb_cfb8_clear(struct vc_data
*conp
,
613 int sy
, int sx
, int height
, int width
);
614 static void pm3fb_cfb8_clear_margins(struct vc_data
*conp
,
615 struct display
*p
, int bottom_only
);
616 #endif /* FBCON_HAS_CFB8 */
617 #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
618 static void pm3fb_cfbX_bmove(struct display
*p
,
620 int dy
, int dx
, int height
, int width
);
621 static void pm3fb_cfbX_putc(struct vc_data
*conp
, struct display
*p
,
622 int c
, int yy
, int xx
);
623 static void pm3fb_cfbX_putcs(struct vc_data
*conp
, struct display
*p
,
624 const unsigned short *s
, int count
, int yy
,
626 static void pm3fb_cfbX_revc(struct display
*p
, int xx
, int yy
);
627 #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
628 #endif /* PM3FB_USE_ACCEL */
630 static void pm3fb_mode_setup(char *mode
, unsigned long board_num
);
631 static void pm3fb_pciid_setup(char *pciid
, unsigned long board_num
);
632 static char *pm3fb_boardnum_setup(char *options
, unsigned long *bn
);
633 static void pm3fb_real_setup(char *options
);
635 static int pm3fb_encode_fix(struct fb_fix_screeninfo
*fix
,
636 const void *par
, struct fb_info_gen
*info
);
637 static int pm3fb_decode_var(const struct fb_var_screeninfo
*var
,
638 void *par
, struct fb_info_gen
*info
);
639 static void pm3fb_encode_depth(struct fb_var_screeninfo
*var
, long d
);
640 static int pm3fb_encode_var(struct fb_var_screeninfo
*var
,
641 const void *par
, struct fb_info_gen
*info
);
642 static void pm3fb_get_par(void *par
, struct fb_info_gen
*info
);
643 static void pm3fb_set_par(const void *par
, struct fb_info_gen
*info
);
644 static void pm3fb_set_color(struct pm3fb_info
*l_fb_info
,
645 unsigned char regno
, unsigned char r
,
646 unsigned char g
, unsigned char b
);
647 static int pm3fb_getcolreg(unsigned regno
, unsigned *red
, unsigned *green
,
648 unsigned *blue
, unsigned *transp
,
649 struct fb_info
*info
);
650 static int pm3fb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
651 unsigned blue
, unsigned transp
,
652 struct fb_info
*info
);
653 static int pm3fb_blank(int blank_mode
, struct fb_info_gen
*info
);
654 static void pm3fb_set_disp(const void *par
, struct display
*disp
,
655 struct fb_info_gen
*info
);
656 static void pm3fb_detect(void);
657 static int pm3fb_pan_display(const struct fb_var_screeninfo
*var
,
658 struct fb_info_gen
*info
);
659 static int pm3fb_ioctl(struct fb_info
*info
, u_int cmd
, u_long arg
);
662 /* the struct that hold them together */
663 struct fbgen_hwswitch pm3fb_switch
= {
664 pm3fb_detect
, pm3fb_encode_fix
, pm3fb_decode_var
, pm3fb_encode_var
,
665 pm3fb_get_par
, pm3fb_set_par
, pm3fb_getcolreg
,
666 pm3fb_pan_display
, pm3fb_blank
, pm3fb_set_disp
669 static struct fb_ops pm3fb_ops
= {
670 .owner
= THIS_MODULE
,
671 .fb_get_fix
= fbgen_get_fix
,
672 .fb_get_var
= fbgen_get_var
,
673 .fb_set_var
= fbgen_set_var
,
674 .fb_get_cmap
= fbgen_get_cmap
,
675 .fb_set_cmap
= fbgen_set_cmap
,
676 .fb_setcolreg
= pm3fb_setcolreg
,
677 .fb_pan_display
=fbgen_pan_display
,
678 .fb_blank
= fbgen_blank
,
679 .fb_ioctl
= pm3fb_ioctl
,
682 #ifdef PM3FB_USE_ACCEL
683 #ifdef FBCON_HAS_CFB32
684 static struct display_switch pm3fb_cfb32
= {
685 fbcon_cfb32_setup
, pm3fb_cfbX_bmove
, pm3fb_cfb32_clear
,
686 pm3fb_cfbX_putc
, pm3fb_cfbX_putcs
, pm3fb_cfbX_revc
,
687 NULL
/* cursor() */ , NULL
/* set_font() */ ,
688 pm3fb_cfb32_clear_margins
,
689 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
691 #endif /* FBCON_HAS_CFB32 */
692 #ifdef FBCON_HAS_CFB16
693 static struct display_switch pm3fb_cfb16
= {
694 fbcon_cfb16_setup
, pm3fb_cfbX_bmove
, pm3fb_cfb16_clear
,
695 pm3fb_cfbX_putc
, pm3fb_cfbX_putcs
, pm3fb_cfbX_revc
,
696 NULL
/* cursor() */ , NULL
/* set_font() */ ,
697 pm3fb_cfb16_clear_margins
,
698 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
700 #endif /* FBCON_HAS_CFB16 */
701 #ifdef FBCON_HAS_CFB8
702 static struct display_switch pm3fb_cfb8
= {
703 fbcon_cfb8_setup
, pm3fb_cfbX_bmove
, pm3fb_cfb8_clear
,
704 pm3fb_cfbX_putc
, pm3fb_cfbX_putcs
, pm3fb_cfbX_revc
,
705 NULL
/* cursor() */ , NULL
/* set_font() */ ,
706 pm3fb_cfb8_clear_margins
,
707 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
709 #endif /* FBCON_HAS_CFB8 */
710 #endif /* PM3FB_USE_ACCEL */
712 /* ****************************** */
713 /* ***** card-specific data ***** */
714 /* ****************************** */
715 struct pm3fb_card_timings
{
716 unsigned long memsize
; /* 0 for last value (i.e. default) */
717 struct pm3fb_timings memt
;
720 static struct pm3fb_card_timings t_FormacProFormance3
[] = {
721 { 16, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} },
722 { 0, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} } /* from 16 MB PF3 */
725 static struct pm3fb_card_timings t_AppianJeronimo2000
[] = {
726 { 32, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} },
727 { 0, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} } /* from 32MB J2000 */
730 static struct pm3fb_card_timings t_3DLabsOxygenVX1
[] = {
731 { 32, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} },
732 { 0, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} } /* from 32MB VX1 */
736 char cardname
[32]; /* recognized card name */
737 u16 subvendor
; /* subvendor of the card */
738 u16 subdevice
; /* subdevice of the card */
739 u8 func
; /* function of the card to which the extra init apply */
740 void (*specific_setup
)(struct pm3fb_info
*l_fb_info
); /* card/func specific setup, done before _any_ FB access */
741 struct pm3fb_card_timings
*c_memt
; /* defauls timings for the boards */
743 { "Unknown Permedia3 board", 0xFFFF, 0xFFFF, 0xFF, NULL
, NULL
},
744 { "Appian Jeronimo 2000 head 1", 0x1097, 0x3d32, 1, NULL
,
747 { "Appian Jeronimo 2000 head 2", 0x1097, 0x3d32, 2, pm3fb_j2000_setup
,
750 { "Formac ProFormance 3", PCI_VENDOR_ID_3DLABS
, 0x000a, 0, NULL
, /* Formac use 3DLabs ID ?!? */
753 { "3DLabs Permedia3 Create!", PCI_VENDOR_ID_3DLABS
, 0x0127, 0, NULL
, NULL
},
754 { "3DLabs Oxygen VX1 PCI", PCI_VENDOR_ID_3DLABS
, 0x0121, 0, NULL
,
757 { "3DLabs Oxygen VX1 AGP", PCI_VENDOR_ID_3DLABS
, 0x0125, 0, NULL
, NULL
},
758 { "3DLabs Oxygen VX1-16 AGP", PCI_VENDOR_ID_3DLABS
, 0x0140, 0, NULL
, NULL
},
759 { "3DLabs Oxygen VX1-1600SW PCI", PCI_VENDOR_ID_3DLABS
, 0x0800, 0, NULL
, NULL
},
760 { "\0", 0x0, 0x0, 0, NULL
, NULL
}
763 /* ********************************** */
764 /* ***** card-specific function ***** */
765 /* ********************************** */
766 static void pm3fb_j2000_setup(struct pm3fb_info
*l_fb_info
)
767 { /* the appian j2000 require more initialization of the second head */
768 /* l_fb_info must point to the _second_ head of the J2000 */
772 l_fb_info
->memt
= t_AppianJeronimo2000
[0].memt
; /* 32 MB, first and only j2000 ? */
774 pm3fb_write_memory_timings(l_fb_info
);
777 /* *************************************** */
778 /* ***** permedia3-specific function ***** */
779 /* *************************************** */
780 static pm3fb_timing_result
pm3fb_preserve_memory_timings(struct pm3fb_info
*l_fb_info
)
782 l_fb_info
->memt
.caps
= PM3_READ_REG(PM3LocalMemCaps
);
783 l_fb_info
->memt
.timings
= PM3_READ_REG(PM3LocalMemTimings
);
784 l_fb_info
->memt
.control
= PM3_READ_REG(PM3LocalMemControl
);
785 l_fb_info
->memt
.refresh
= PM3_READ_REG(PM3LocalMemRefresh
);
786 l_fb_info
->memt
.powerdown
= PM3_READ_REG(PM3LocalMemPowerDown
);
788 if ((l_fb_info
->memt
.caps
== PM3FB_UNKNOWN_TIMING_VALUE
) ||
789 (l_fb_info
->memt
.timings
== PM3FB_UNKNOWN_TIMING_VALUE
) ||
790 (l_fb_info
->memt
.control
== PM3FB_UNKNOWN_TIMING_VALUE
) ||
791 (l_fb_info
->memt
.refresh
== PM3FB_UNKNOWN_TIMING_VALUE
) ||
792 (l_fb_info
->memt
.powerdown
== PM3FB_UNKNOWN_TIMING_VALUE
))
794 printk(KERN_ERR
"pm3fb: invalid memory timings in permedia3 board #%ld\n", l_fb_info
->board_num
);
795 return(pm3fb_try_memory_timings(l_fb_info
));
797 return(pm3fb_timing_ok
);
800 static pm3fb_timing_result
pm3fb_try_memory_timings(struct pm3fb_info
*l_fb_info
)
802 if (cardbase
[l_fb_info
->board_type
].c_memt
)
807 if ((cardbase
[l_fb_info
->board_type
].c_memt
[i
].memsize
== l_fb_info
->fb_size
)
808 || !(cardbase
[l_fb_info
->board_type
].c_memt
[i
].memsize
))
809 { /* will use the 0-sized timings by default */
811 l_fb_info
->memt
= cardbase
[l_fb_info
->board_type
].c_memt
[i
].memt
;
812 printk(KERN_WARNING
"pm3fb: trying to use predefined memory timings for permedia3 board #%ld (%s, %ld MB)\n",
813 l_fb_info
->board_num
,
814 cardbase
[l_fb_info
->board_type
].cardname
,
815 cardbase
[l_fb_info
->board_type
].c_memt
[i
].memsize
);
816 pm3fb_write_memory_timings(l_fb_info
);
817 return(pm3fb_timing_retry
);
822 return(pm3fb_timing_problem
);
823 return(pm3fb_timing_ok
);
826 static void pm3fb_write_memory_timings(struct pm3fb_info
*l_fb_info
)
828 unsigned char m
, n
, p
;
829 unsigned long clockused
;
831 PM3_SLOW_WRITE_REG(PM3LocalMemCaps
, l_fb_info
->memt
.caps
);
832 PM3_SLOW_WRITE_REG(PM3LocalMemTimings
, l_fb_info
->memt
.timings
);
833 PM3_SLOW_WRITE_REG(PM3LocalMemControl
, l_fb_info
->memt
.control
);
834 PM3_SLOW_WRITE_REG(PM3LocalMemRefresh
, l_fb_info
->memt
.refresh
);
835 PM3_SLOW_WRITE_REG(PM3LocalMemPowerDown
, l_fb_info
->memt
.powerdown
);
838 pm3fb_CalculateClock(l_fb_info
, 2 * 105000, PM3_REF_CLOCK
, &m
,
841 PM3_WRITE_DAC_REG(PM3RD_KClkPreScale
, m
);
842 PM3_WRITE_DAC_REG(PM3RD_KClkFeedbackScale
, n
);
843 PM3_WRITE_DAC_REG(PM3RD_KClkPostScale
, p
);
844 PM3_WRITE_DAC_REG(PM3RD_KClkControl
,
845 PM3RD_KClkControl_STATE_RUN
|
846 PM3RD_KClkControl_SOURCE_PLL
|
847 PM3RD_KClkControl_ENABLE
);
848 PM3_WRITE_DAC_REG(PM3RD_MClkControl
,
849 PM3RD_MClkControl_STATE_RUN
|
850 PM3RD_MClkControl_SOURCE_KCLK
|
851 PM3RD_MClkControl_ENABLE
);
852 PM3_WRITE_DAC_REG(PM3RD_SClkControl
,
853 PM3RD_SClkControl_STATE_RUN
|
854 PM3RD_SClkControl_SOURCE_PCLK
|
855 PM3RD_SClkControl_ENABLE
);
858 static unsigned long pm3fb_read_dac_reg(struct pm3fb_info
*l_fb_info
,
861 DASSERT((l_fb_info
->vIOBase
!= (unsigned char *) (-1)),
862 "l_fb_info->vIOBase mapped in read dac reg\n");
865 return (PM3_READ_REG(PM3RD_IndexedData
));
868 /* Calculating various clock parameter */
869 static unsigned long pm3fb_CalculateClock(struct pm3fb_info
*l_fb_info
, unsigned long reqclock
, /* In kHz units */
870 unsigned long refclock
, /* In kHz units */
871 unsigned char *prescale
, /* ClkPreScale */
872 unsigned char *feedback
, /* ClkFeedBackScale */
873 unsigned char *postscale
879 unsigned long actualclock
= 0;
883 for (f
= 1; f
< 256; f
++) {
884 for (pre
= 1; pre
< 256; pre
++) {
885 for (post
= 0; post
< 5; post
++) {
887 ((2 * refclock
* f
) /
888 (pre
* (1 << post
)));
889 if ((reqclock
> freq
- freqerr
)
890 && (reqclock
< freq
+ freqerr
)) {
894 freq
: freq
- reqclock
;
904 return (actualclock
);
907 static int pm3fb_Shiftbpp(struct pm3fb_info
*l_fb_info
,
908 unsigned long depth
, int v
)
922 DPRINTK(1, "Unsupported depth %ld\n", depth
);
926 static int pm3fb_Unshiftbpp(struct pm3fb_info
*l_fb_info
,
927 unsigned long depth
, int v
)
941 DPRINTK(1, "Unsupported depth %ld\n", depth
);
945 static void pm3fb_mapIO(struct pm3fb_info
*l_fb_info
)
950 ioremap((unsigned long) l_fb_info
->pIOBase
, PM3_REGS_SIZE
);
952 ioremap((unsigned long) l_fb_info
->p_fb
, l_fb_info
->fb_size
);
953 DPRINTK(2, "IO mapping : IOBase %lx / %lx, fb %lx / %lx\n",
954 (unsigned long) l_fb_info
->pIOBase
,
955 (unsigned long) l_fb_info
->vIOBase
,
956 (unsigned long) l_fb_info
->p_fb
,
957 (unsigned long) l_fb_info
->v_fb
);
960 static void pm3fb_unmapIO(struct pm3fb_info
*l_fb_info
)
964 iounmap(l_fb_info
->vIOBase
);
965 iounmap(l_fb_info
->v_fb
);
966 l_fb_info
->vIOBase
= (unsigned char *) -1;
967 l_fb_info
->v_fb
= (unsigned char *) -1;
970 #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
971 static void pm3fb_show_cur_mode(struct pm3fb_info
*l_fb_info
)
973 DPRINTK(2, "PM3Aperture0: 0x%08x\n", PM3_READ_REG(PM3Aperture0
));
974 DPRINTK(2, "PM3Aperture1: 0x%08x\n", PM3_READ_REG(PM3Aperture1
));
975 DPRINTK(2, "PM3ByAperture1Mode: 0x%08x\n",
976 PM3_READ_REG(PM3ByAperture1Mode
));
977 DPRINTK(2, "PM3ByAperture2Mode: 0x%08x\n",
978 PM3_READ_REG(PM3ByAperture2Mode
));
979 DPRINTK(2, "PM3ChipConfig: 0x%08x\n", PM3_READ_REG(PM3ChipConfig
));
980 DPRINTK(2, "PM3FIFODis: 0x%08x\n", PM3_READ_REG(PM3FIFODis
));
981 DPRINTK(2, "PM3HTotal: 0x%08x\n", PM3_READ_REG(PM3HTotal
));
982 DPRINTK(2, "PM3HbEnd: 0x%08x\n", PM3_READ_REG(PM3HbEnd
));
983 DPRINTK(2, "PM3HgEnd: 0x%08x\n", PM3_READ_REG(PM3HgEnd
));
984 DPRINTK(2, "PM3HsEnd: 0x%08x\n", PM3_READ_REG(PM3HsEnd
));
985 DPRINTK(2, "PM3HsStart: 0x%08x\n", PM3_READ_REG(PM3HsStart
));
986 DPRINTK(2, "PM3MemBypassWriteMask: 0x%08x\n",
987 PM3_READ_REG(PM3MemBypassWriteMask
));
988 DPRINTK(2, "PM3RD_IndexControl: 0x%08x\n",
989 PM3_READ_REG(PM3RD_IndexControl
));
990 DPRINTK(2, "PM3ScreenBase: 0x%08x\n", PM3_READ_REG(PM3ScreenBase
));
991 DPRINTK(2, "PM3ScreenStride: 0x%08x\n",
992 PM3_READ_REG(PM3ScreenStride
));
993 DPRINTK(2, "PM3VClkCtl: 0x%08x\n", PM3_READ_REG(PM3VClkCtl
));
994 DPRINTK(2, "PM3VTotal: 0x%08x\n", PM3_READ_REG(PM3VTotal
));
995 DPRINTK(2, "PM3VbEnd: 0x%08x\n", PM3_READ_REG(PM3VbEnd
));
996 DPRINTK(2, "PM3VideoControl: 0x%08x\n",
997 PM3_READ_REG(PM3VideoControl
));
998 DPRINTK(2, "PM3VsEnd: 0x%08x\n", PM3_READ_REG(PM3VsEnd
));
999 DPRINTK(2, "PM3VsStart: 0x%08x\n", PM3_READ_REG(PM3VsStart
));
1001 DPRINTK(2, "PM3RD_ColorFormat: %ld\n",
1002 PM3_READ_DAC_REG(PM3RD_ColorFormat
));
1003 DPRINTK(2, "PM3RD_DACControl: %ld\n",
1004 PM3_READ_DAC_REG(PM3RD_DACControl
));
1005 DPRINTK(2, "PM3RD_DClk0FeedbackScale: %ld\n",
1006 PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale
));
1007 DPRINTK(2, "PM3RD_DClk0PostScale: %ld\n",
1008 PM3_READ_DAC_REG(PM3RD_DClk0PostScale
));
1009 DPRINTK(2, "PM3RD_DClk0PreScale: %ld\n",
1010 PM3_READ_DAC_REG(PM3RD_DClk0PreScale
));
1011 DPRINTK(2, "[not set] PM3RD_IndexControl: %ld\n",
1012 PM3_READ_DAC_REG(PM3RD_IndexControl
));
1013 DPRINTK(2, "PM3RD_MiscControl: %ld\n",
1014 PM3_READ_DAC_REG(PM3RD_MiscControl
));
1015 DPRINTK(2, "PM3RD_PixelSize: %ld\n",
1016 PM3_READ_DAC_REG(PM3RD_PixelSize
));
1017 DPRINTK(2, "PM3RD_SyncControl: %ld\n",
1018 PM3_READ_DAC_REG(PM3RD_SyncControl
));
1021 #endif /* defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) */
1022 static void pm3fb_show_cur_timing(struct pm3fb_info
*l_fb_info
)
1024 u16 subvendor
, subdevice
;
1026 if ((!pci_read_config_word
1027 (l_fb_info
->dev
, PCI_SUBSYSTEM_VENDOR_ID
, &subvendor
))
1029 (!pci_read_config_word
1030 (l_fb_info
->dev
, PCI_SUBSYSTEM_ID
, &subdevice
))) {
1031 /* well, nothing... */
1033 subvendor
= subdevice
= (u16
)-1;
1036 printk(KERN_INFO
"pm3fb: memory timings for board #%ld (subvendor: 0x%hx, subdevice: 0x%hx)\n", l_fb_info
->board_num
, subvendor
, subdevice
);
1037 printk(KERN_INFO
" PM3LocalMemCaps: 0x%08x\n",
1038 PM3_READ_REG(PM3LocalMemCaps
));
1039 printk(KERN_INFO
" PM3LocalMemTimings: 0x%08x\n",
1040 PM3_READ_REG(PM3LocalMemTimings
));
1041 printk(KERN_INFO
" PM3LocalMemControl: 0x%08x\n",
1042 PM3_READ_REG(PM3LocalMemControl
));
1043 printk(KERN_INFO
" PM3LocalMemRefresh: 0x%08x\n",
1044 PM3_READ_REG(PM3LocalMemRefresh
));
1045 printk(KERN_INFO
" PM3LocalMemPowerDown: 0x%08x\n",
1046 PM3_READ_REG(PM3LocalMemPowerDown
));
1049 /* write the mode to registers */
1050 static void pm3fb_write_mode(struct pm3fb_info
*l_fb_info
)
1052 char tempsync
= 0x00, tempmisc
= 0x00;
1055 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask
, 0xffffffff);
1056 PM3_SLOW_WRITE_REG(PM3Aperture0
, 0x00000000);
1057 PM3_SLOW_WRITE_REG(PM3Aperture1
, 0x00000000);
1058 PM3_SLOW_WRITE_REG(PM3FIFODis
, 0x00000007);
1060 PM3_SLOW_WRITE_REG(PM3HTotal
,
1061 pm3fb_Shiftbpp(l_fb_info
,
1062 l_fb_info
->current_par
->depth
,
1063 l_fb_info
->current_par
->htotal
-
1065 PM3_SLOW_WRITE_REG(PM3HsEnd
,
1066 pm3fb_Shiftbpp(l_fb_info
,
1067 l_fb_info
->current_par
->depth
,
1068 l_fb_info
->current_par
->hsend
));
1069 PM3_SLOW_WRITE_REG(PM3HsStart
,
1070 pm3fb_Shiftbpp(l_fb_info
,
1071 l_fb_info
->current_par
->depth
,
1072 l_fb_info
->current_par
->
1074 PM3_SLOW_WRITE_REG(PM3HbEnd
,
1075 pm3fb_Shiftbpp(l_fb_info
,
1076 l_fb_info
->current_par
->depth
,
1077 l_fb_info
->current_par
->hbend
));
1078 PM3_SLOW_WRITE_REG(PM3HgEnd
,
1079 pm3fb_Shiftbpp(l_fb_info
,
1080 l_fb_info
->current_par
->depth
,
1081 l_fb_info
->current_par
->hbend
));
1082 PM3_SLOW_WRITE_REG(PM3ScreenStride
,
1083 pm3fb_Shiftbpp(l_fb_info
,
1084 l_fb_info
->current_par
->depth
,
1085 l_fb_info
->current_par
->stride
));
1086 PM3_SLOW_WRITE_REG(PM3VTotal
, l_fb_info
->current_par
->vtotal
- 1);
1087 PM3_SLOW_WRITE_REG(PM3VsEnd
, l_fb_info
->current_par
->vsend
- 1);
1088 PM3_SLOW_WRITE_REG(PM3VsStart
,
1089 l_fb_info
->current_par
->vsstart
- 1);
1090 PM3_SLOW_WRITE_REG(PM3VbEnd
, l_fb_info
->current_par
->vbend
);
1092 switch (l_fb_info
->current_par
->depth
) {
1094 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode
,
1095 PM3ByApertureMode_PIXELSIZE_8BIT
);
1096 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode
,
1097 PM3ByApertureMode_PIXELSIZE_8BIT
);
1103 #ifndef __BIG_ENDIAN
1104 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode
,
1105 PM3ByApertureMode_PIXELSIZE_16BIT
);
1106 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode
,
1107 PM3ByApertureMode_PIXELSIZE_16BIT
);
1109 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode
,
1110 PM3ByApertureMode_PIXELSIZE_16BIT
|
1111 PM3ByApertureMode_BYTESWAP_BADC
);
1112 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode
,
1113 PM3ByApertureMode_PIXELSIZE_16BIT
|
1114 PM3ByApertureMode_BYTESWAP_BADC
);
1115 #endif /* ! __BIG_ENDIAN */
1119 #ifndef __BIG_ENDIAN
1120 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode
,
1121 PM3ByApertureMode_PIXELSIZE_32BIT
);
1122 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode
,
1123 PM3ByApertureMode_PIXELSIZE_32BIT
);
1125 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode
,
1126 PM3ByApertureMode_PIXELSIZE_32BIT
|
1127 PM3ByApertureMode_BYTESWAP_DCBA
);
1128 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode
,
1129 PM3ByApertureMode_PIXELSIZE_32BIT
|
1130 PM3ByApertureMode_BYTESWAP_DCBA
);
1131 #endif /* ! __BIG_ENDIAN */
1135 DPRINTK(1, "Unsupported depth %d\n",
1136 l_fb_info
->current_par
->depth
);
1141 * Oxygen VX1 - it appears that setting PM3VideoControl and
1142 * then PM3RD_SyncControl to the same SYNC settings undoes
1143 * any net change - they seem to xor together. Only set the
1144 * sync options in PM3RD_SyncControl. --rmk
1147 unsigned int video
= l_fb_info
->current_par
->video
;
1149 video
&= ~(PM3VideoControl_HSYNC_MASK
|
1150 PM3VideoControl_VSYNC_MASK
);
1151 video
|= PM3VideoControl_HSYNC_ACTIVE_HIGH
|
1152 PM3VideoControl_VSYNC_ACTIVE_HIGH
;
1153 PM3_SLOW_WRITE_REG(PM3VideoControl
, video
);
1155 PM3_SLOW_WRITE_REG(PM3VClkCtl
,
1156 (PM3_READ_REG(PM3VClkCtl
) & 0xFFFFFFFC));
1157 PM3_SLOW_WRITE_REG(PM3ScreenBase
, l_fb_info
->current_par
->base
);
1158 PM3_SLOW_WRITE_REG(PM3ChipConfig
,
1159 (PM3_READ_REG(PM3ChipConfig
) & 0xFFFFFFFD));
1162 unsigned char m
; /* ClkPreScale */
1163 unsigned char n
; /* ClkFeedBackScale */
1164 unsigned char p
; /* ClkPostScale */
1165 (void)pm3fb_CalculateClock(l_fb_info
, l_fb_info
->current_par
->pixclock
, PM3_REF_CLOCK
, &m
, &n
, &p
);
1168 "Pixclock: %d, Pre: %d, Feedback: %d, Post: %d\n",
1169 l_fb_info
->current_par
->pixclock
, (int) m
, (int) n
,
1172 PM3_WRITE_DAC_REG(PM3RD_DClk0PreScale
, m
);
1173 PM3_WRITE_DAC_REG(PM3RD_DClk0FeedbackScale
, n
);
1174 PM3_WRITE_DAC_REG(PM3RD_DClk0PostScale
, p
);
1177 PM3_WRITE_DAC_REG(PM3RD_IndexControl, 0x00);
1180 PM3_SLOW_WRITE_REG(PM3RD_IndexControl, 0x00);
1182 if ((l_fb_info
->current_par
->video
& PM3VideoControl_HSYNC_MASK
) ==
1183 PM3VideoControl_HSYNC_ACTIVE_HIGH
)
1184 tempsync
|= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH
;
1185 if ((l_fb_info
->current_par
->video
& PM3VideoControl_VSYNC_MASK
) ==
1186 PM3VideoControl_VSYNC_ACTIVE_HIGH
)
1187 tempsync
|= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH
;
1189 PM3_WRITE_DAC_REG(PM3RD_SyncControl
, tempsync
);
1190 DPRINTK(2, "PM3RD_SyncControl: %d\n", tempsync
);
1192 if (flatpanel
[l_fb_info
->board_num
])
1194 PM3_WRITE_DAC_REG(PM3RD_DACControl
, PM3RD_DACControl_BLANK_PEDESTAL_ENABLE
);
1196 PM3_WRITE_REG(PM3VSConfiguration
, 0x06);
1197 PM3_WRITE_REG(0x5a00, 1 << 14); /* black magic... */
1198 tempmisc
= PM3RD_MiscControl_VSB_OUTPUT_ENABLE
;
1201 PM3_WRITE_DAC_REG(PM3RD_DACControl
, 0x00);
1203 switch (l_fb_info
->current_par
->depth
) {
1205 PM3_WRITE_DAC_REG(PM3RD_PixelSize
,
1206 PM3RD_PixelSize_8_BIT_PIXELS
);
1207 PM3_WRITE_DAC_REG(PM3RD_ColorFormat
,
1208 PM3RD_ColorFormat_CI8_COLOR
|
1209 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW
);
1210 tempmisc
|= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE
;
1213 PM3_WRITE_DAC_REG(PM3RD_PixelSize
,
1214 PM3RD_PixelSize_16_BIT_PIXELS
);
1215 PM3_WRITE_DAC_REG(PM3RD_ColorFormat
,
1216 PM3RD_ColorFormat_4444_COLOR
|
1217 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW
|
1218 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE
);
1219 tempmisc
|= PM3RD_MiscControl_DIRECTCOLOR_ENABLE
|
1220 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE
;
1223 PM3_WRITE_DAC_REG(PM3RD_PixelSize
,
1224 PM3RD_PixelSize_16_BIT_PIXELS
);
1225 PM3_WRITE_DAC_REG(PM3RD_ColorFormat
,
1226 PM3RD_ColorFormat_5551_FRONT_COLOR
|
1227 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW
|
1228 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE
);
1229 tempmisc
|= PM3RD_MiscControl_DIRECTCOLOR_ENABLE
|
1230 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE
;
1233 PM3_WRITE_DAC_REG(PM3RD_PixelSize
,
1234 PM3RD_PixelSize_16_BIT_PIXELS
);
1235 PM3_WRITE_DAC_REG(PM3RD_ColorFormat
,
1236 PM3RD_ColorFormat_565_FRONT_COLOR
|
1237 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW
|
1238 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE
);
1239 tempmisc
|= PM3RD_MiscControl_DIRECTCOLOR_ENABLE
|
1240 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE
;
1243 PM3_WRITE_DAC_REG(PM3RD_PixelSize
,
1244 PM3RD_PixelSize_32_BIT_PIXELS
);
1245 PM3_WRITE_DAC_REG(PM3RD_ColorFormat
,
1246 PM3RD_ColorFormat_8888_COLOR
|
1247 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW
);
1248 tempmisc
|= PM3RD_MiscControl_DIRECTCOLOR_ENABLE
|
1249 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE
;
1252 PM3_WRITE_DAC_REG(PM3RD_MiscControl
, tempmisc
);
1257 static void pm3fb_read_mode(struct pm3fb_info
*l_fb_info
,
1258 struct pm3fb_par
*curpar
)
1260 unsigned long pixsize1
, pixsize2
, clockused
;
1261 unsigned long pre
, feedback
, post
;
1265 clockused
= PM3_READ_REG(PM3VClkCtl
);
1267 switch (clockused
) {
1269 pre
= PM3_READ_DAC_REG(PM3RD_DClk3PreScale
);
1270 feedback
= PM3_READ_DAC_REG(PM3RD_DClk3FeedbackScale
);
1271 post
= PM3_READ_DAC_REG(PM3RD_DClk3PostScale
);
1274 "DClk3 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
1275 pre
, feedback
, post
, PM3_SCALE_TO_CLOCK(pre
,
1280 pre
= PM3_READ_DAC_REG(PM3RD_DClk2PreScale
);
1281 feedback
= PM3_READ_DAC_REG(PM3RD_DClk2FeedbackScale
);
1282 post
= PM3_READ_DAC_REG(PM3RD_DClk2PostScale
);
1285 "DClk2 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
1286 pre
, feedback
, post
, PM3_SCALE_TO_CLOCK(pre
,
1291 pre
= PM3_READ_DAC_REG(PM3RD_DClk1PreScale
);
1292 feedback
= PM3_READ_DAC_REG(PM3RD_DClk1FeedbackScale
);
1293 post
= PM3_READ_DAC_REG(PM3RD_DClk1PostScale
);
1296 "DClk1 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
1297 pre
, feedback
, post
, PM3_SCALE_TO_CLOCK(pre
,
1302 pre
= PM3_READ_DAC_REG(PM3RD_DClk0PreScale
);
1303 feedback
= PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale
);
1304 post
= PM3_READ_DAC_REG(PM3RD_DClk0PostScale
);
1307 "DClk0 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
1308 pre
, feedback
, post
, PM3_SCALE_TO_CLOCK(pre
,
1313 pre
= feedback
= post
= 0;
1314 DPRINTK(1, "Unknowk D clock used : %ld\n", clockused
);
1318 curpar
->pixclock
= PM3_SCALE_TO_CLOCK(pre
, feedback
, post
);
1321 PM3ByApertureMode_PIXELSIZE_MASK
&
1322 (PM3_READ_REG(PM3ByAperture1Mode
));
1324 PM3ByApertureMode_PIXELSIZE_MASK
&
1325 (PM3_READ_REG(PM3ByAperture2Mode
));
1327 DASSERT((pixsize1
== pixsize2
),
1328 "pixsize the same in both aperture\n");
1330 if (pixsize1
& PM3ByApertureMode_PIXELSIZE_32BIT
)
1332 else if (pixsize1
& PM3ByApertureMode_PIXELSIZE_16BIT
)
1339 /* not sure if I need to add one on the next ; it give better result with */
1341 pm3fb_Unshiftbpp(l_fb_info
, curpar
->depth
,
1342 1 + PM3_READ_REG(PM3HTotal
));
1344 pm3fb_Unshiftbpp(l_fb_info
, curpar
->depth
,
1345 PM3_READ_REG(PM3HsEnd
));
1347 pm3fb_Unshiftbpp(l_fb_info
, curpar
->depth
,
1348 PM3_READ_REG(PM3HsStart
));
1350 pm3fb_Unshiftbpp(l_fb_info
, curpar
->depth
,
1351 PM3_READ_REG(PM3HbEnd
));
1354 pm3fb_Unshiftbpp(l_fb_info
, curpar
->depth
,
1355 PM3_READ_REG(PM3ScreenStride
));
1357 curpar
->vtotal
= 1 + PM3_READ_REG(PM3VTotal
);
1358 curpar
->vsend
= 1 + PM3_READ_REG(PM3VsEnd
);
1359 curpar
->vsstart
= 1 + PM3_READ_REG(PM3VsStart
);
1360 curpar
->vbend
= PM3_READ_REG(PM3VbEnd
);
1362 curpar
->video
= PM3_READ_REG(PM3VideoControl
);
1364 curpar
->base
= PM3_READ_REG(PM3ScreenBase
);
1365 curpar
->width
= curpar
->htotal
- curpar
->hbend
; /* make virtual == displayed resolution */
1366 curpar
->height
= curpar
->vtotal
- curpar
->vbend
;
1368 DPRINTK(2, "Found : %d * %d, %d Khz, stride is %08x\n",
1369 curpar
->width
, curpar
->height
, curpar
->pixclock
,
1373 static unsigned long pm3fb_size_memory(struct pm3fb_info
*l_fb_info
)
1375 unsigned long memsize
= 0, tempBypass
, i
, temp1
, temp2
;
1376 u16 subvendor
, subdevice
;
1377 pm3fb_timing_result ptr
;
1381 l_fb_info
->fb_size
= 64 * 1024 * 1024; /* pm3 aperture always 64 MB */
1382 pm3fb_mapIO(l_fb_info
); /* temporary map IO */
1384 DASSERT((l_fb_info
->vIOBase
!= NULL
),
1385 "IO successfully mapped before mem detect\n");
1386 DASSERT((l_fb_info
->v_fb
!= NULL
),
1387 "FB successfully mapped before mem detect\n");
1389 /* card-specific stuff, *before* accessing *any* FB memory */
1390 if ((!pci_read_config_word
1391 (l_fb_info
->dev
, PCI_SUBSYSTEM_VENDOR_ID
, &subvendor
))
1393 (!pci_read_config_word
1394 (l_fb_info
->dev
, PCI_SUBSYSTEM_ID
, &subdevice
))) {
1395 i
= 0; l_fb_info
->board_type
= 0;
1396 while ((cardbase
[i
].cardname
[0]) && !(l_fb_info
->board_type
)) {
1397 if ((cardbase
[i
].subvendor
== subvendor
) &&
1398 (cardbase
[i
].subdevice
== subdevice
) &&
1399 (cardbase
[i
].func
== PCI_FUNC(l_fb_info
->dev
->devfn
))) {
1400 DPRINTK(2, "Card #%ld is an %s\n",
1401 l_fb_info
->board_num
,
1402 cardbase
[i
].cardname
);
1403 if (cardbase
[i
].specific_setup
)
1404 cardbase
[i
].specific_setup(l_fb_info
);
1405 l_fb_info
->board_type
= i
;
1409 if (!l_fb_info
->board_type
) {
1410 DPRINTK(1, "Card #%ld is an unknown 0x%04x / 0x%04x\n",
1411 l_fb_info
->board_num
, subvendor
, subdevice
);
1414 printk(KERN_ERR
"pm3fb: Error: pci_read_config_word failed, board #%ld\n",
1415 l_fb_info
->board_num
);
1419 pm3fb_show_cur_timing(l_fb_info
);
1421 /* card-specific setup is done, we preserve the final
1422 memory timing for future reference */
1423 if ((ptr
= pm3fb_preserve_memory_timings(l_fb_info
)) == pm3fb_timing_problem
) { /* memory timings were wrong ! oops.... */
1427 tempBypass
= PM3_READ_REG(PM3MemBypassWriteMask
);
1429 DPRINTK(2, "PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass
);
1431 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask
, 0xFFFFFFFF);
1433 /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */
1434 for (i
= 0; i
< 32; i
++) {
1435 fb_writel(i
* 0x00345678,
1436 (l_fb_info
->v_fb
+ (i
* 1048576)));
1438 temp1
= fb_readl((l_fb_info
->v_fb
+ (i
* 1048576)));
1440 /* Let's check for wrapover, write will fail at 16MB boundary */
1441 if (temp1
== (i
* 0x00345678))
1447 DPRINTK(2, "First detect pass already got %ld MB\n", memsize
+ 1);
1450 for (i
= 0; i
< 32; i
++) {
1451 /* Clear first 32MB ; 0 is 0, no need to byteswap */
1453 (l_fb_info
->v_fb
+ (i
* 1048576)));
1457 for (i
= 32; i
< 64; i
++) {
1458 fb_writel(i
* 0x00345678,
1459 (l_fb_info
->v_fb
+ (i
* 1048576)));
1462 fb_readl((l_fb_info
->v_fb
+ (i
* 1048576)));
1464 fb_readl((l_fb_info
->v_fb
+
1465 ((i
- 32) * 1048576)));
1466 if ((temp1
== (i
* 0x00345678)) && (temp2
== 0)) /* different value, different RAM... */
1473 DPRINTK(2, "Second detect pass got %ld MB\n", memsize
+ 1);
1475 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask
, tempBypass
);
1477 pm3fb_unmapIO(l_fb_info
);
1478 memsize
= 1048576 * (memsize
+ 1);
1480 DPRINTK(2, "Returning 0x%08lx bytes\n", memsize
);
1482 if (forcesize
[l_fb_info
->board_num
] && ((forcesize
[l_fb_info
->board_num
] * 1048576) != memsize
))
1484 printk(KERN_WARNING
"pm3fb: mismatch between probed (%ld MB) and specified (%hd MB) memory size, using SPECIFIED !\n", memsize
, forcesize
[l_fb_info
->board_num
]);
1485 memsize
= 1048576 * forcesize
[l_fb_info
->board_num
];
1488 l_fb_info
->fb_size
= memsize
;
1490 if (ptr
== pm3fb_timing_retry
)
1492 printk(KERN_WARNING
"pm3fb: retrying memory timings check");
1493 if (pm3fb_try_memory_timings(l_fb_info
) == pm3fb_timing_problem
)
1500 static void pm3fb_clear_memory(struct pm3fb_info
*l_fb_info
, u32 cc
)
1506 for (i
= 0; i
< (l_fb_info
->fb_size
/ sizeof(u32
)) ; i
++) /* clear entire FB memory to black */
1508 fb_writel(cc
, (l_fb_info
->v_fb
+ (i
* sizeof(u32
))));
1512 static void pm3fb_clear_colormap(struct pm3fb_info
*l_fb_info
, unsigned char r
, unsigned char g
, unsigned char b
)
1518 for (i
= 0; i
< 256 ; i
++) /* fill color map with white */
1519 pm3fb_set_color(l_fb_info
, i
, r
, g
, b
);
1523 /* common initialisation */
1524 static void pm3fb_common_init(struct pm3fb_info
*l_fb_info
)
1528 DPRINTK(2, "Initializing board #%ld @ %lx\n", l_fb_info
->board_num
,
1529 (unsigned long) l_fb_info
);
1531 strcpy(l_fb_info
->gen
.info
.modename
, permedia3_name
);
1532 disp
[l_fb_info
->board_num
].scrollmode
= 0; /* SCROLL_YNOMOVE; *//* 0 means "let fbcon choose" */
1533 l_fb_info
->gen
.parsize
= sizeof(struct pm3fb_par
);
1534 l_fb_info
->gen
.info
.changevar
= NULL
;
1535 l_fb_info
->gen
.info
.fbops
= &pm3fb_ops
;
1536 l_fb_info
->gen
.info
.disp
= &(disp
[l_fb_info
->board_num
]);
1537 if (fontn
[l_fb_info
->board_num
][0])
1538 strcpy(l_fb_info
->gen
.info
.fontname
,
1539 fontn
[l_fb_info
->board_num
]);
1540 l_fb_info
->gen
.info
.switch_con
= &fbgen_switch
;
1541 l_fb_info
->gen
.info
.updatevar
= &fbgen_update_var
; /* */
1542 l_fb_info
->gen
.info
.flags
= FBINFO_FLAG_DEFAULT
;
1544 pm3fb_mapIO(l_fb_info
);
1546 pm3fb_clear_memory(l_fb_info
, 0);
1547 pm3fb_clear_colormap(l_fb_info
, 0, 0, 0);
1549 (void) fbgen_get_var(&(disp
[l_fb_info
->board_num
]).var
, -1,
1550 &l_fb_info
->gen
.info
);
1552 if (depth
[l_fb_info
->board_num
]) /* override mode-defined depth */
1554 pm3fb_encode_depth(&(disp
[l_fb_info
->board_num
]).var
, depth
[l_fb_info
->board_num
]);
1555 (disp
[l_fb_info
->board_num
]).var
.bits_per_pixel
= depth2bpp(depth
[l_fb_info
->board_num
]);
1558 (void) fbgen_do_set_var(&(disp
[l_fb_info
->board_num
]).var
, 1,
1561 fbgen_set_disp(-1, &l_fb_info
->gen
);
1563 do_install_cmap(0, &l_fb_info
->gen
.info
);
1565 if (register_framebuffer(&l_fb_info
->gen
.info
) < 0) {
1566 DPRINTK(1, "Couldn't register framebuffer\n");
1570 PM3_WRITE_DAC_REG(PM3RD_CursorMode
,
1571 PM3RD_CursorMode_CURSOR_DISABLE
);
1575 pm3fb_write_mode(l_fb_info
);
1577 printk("fb%d: %s, using %uK of video memory (%s)\n",
1578 l_fb_info
->gen
.info
.node
,
1579 permedia3_name
, (u32
) (l_fb_info
->fb_size
>> 10),
1580 cardbase
[l_fb_info
->board_type
].cardname
);
1583 /* **************************************************** */
1584 /* ***** accelerated permedia3-specific functions ***** */
1585 /* **************************************************** */
1586 #ifdef PM3FB_USE_ACCEL
1587 static void pm3fb_wait_pm3(struct pm3fb_info
*l_fb_info
)
1591 PM3_SLOW_WRITE_REG(PM3FilterMode
, PM3FilterModeSync
);
1592 PM3_SLOW_WRITE_REG(PM3Sync
, 0);
1595 while ((PM3_READ_REG(PM3OutFIFOWords
)) == 0);
1597 } while ((PM3_READ_REG(PM3OutputFifo
)) != PM3Sync_Tag
);
1600 static void pm3fb_init_engine(struct pm3fb_info
*l_fb_info
)
1602 PM3_SLOW_WRITE_REG(PM3FilterMode
, PM3FilterModeSync
);
1603 PM3_SLOW_WRITE_REG(PM3StatisticMode
, 0x0);
1604 PM3_SLOW_WRITE_REG(PM3DeltaMode
, 0x0);
1605 PM3_SLOW_WRITE_REG(PM3RasterizerMode
, 0x0);
1606 PM3_SLOW_WRITE_REG(PM3ScissorMode
, 0x0);
1607 PM3_SLOW_WRITE_REG(PM3LineStippleMode
, 0x0);
1608 PM3_SLOW_WRITE_REG(PM3AreaStippleMode
, 0x0);
1609 PM3_SLOW_WRITE_REG(PM3GIDMode
, 0x0);
1610 PM3_SLOW_WRITE_REG(PM3DepthMode
, 0x0);
1611 PM3_SLOW_WRITE_REG(PM3StencilMode
, 0x0);
1612 PM3_SLOW_WRITE_REG(PM3StencilData
, 0x0);
1613 PM3_SLOW_WRITE_REG(PM3ColorDDAMode
, 0x0);
1614 PM3_SLOW_WRITE_REG(PM3TextureCoordMode
, 0x0);
1615 PM3_SLOW_WRITE_REG(PM3TextureIndexMode0
, 0x0);
1616 PM3_SLOW_WRITE_REG(PM3TextureIndexMode1
, 0x0);
1617 PM3_SLOW_WRITE_REG(PM3TextureReadMode
, 0x0);
1618 PM3_SLOW_WRITE_REG(PM3LUTMode
, 0x0);
1619 PM3_SLOW_WRITE_REG(PM3TextureFilterMode
, 0x0);
1620 PM3_SLOW_WRITE_REG(PM3TextureCompositeMode
, 0x0);
1621 PM3_SLOW_WRITE_REG(PM3TextureApplicationMode
, 0x0);
1622 PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode1
, 0x0);
1623 PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode1
, 0x0);
1624 PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode0
, 0x0);
1625 PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode0
, 0x0);
1626 PM3_SLOW_WRITE_REG(PM3FogMode
, 0x0);
1627 PM3_SLOW_WRITE_REG(PM3ChromaTestMode
, 0x0);
1628 PM3_SLOW_WRITE_REG(PM3AlphaTestMode
, 0x0);
1629 PM3_SLOW_WRITE_REG(PM3AntialiasMode
, 0x0);
1630 PM3_SLOW_WRITE_REG(PM3YUVMode
, 0x0);
1631 PM3_SLOW_WRITE_REG(PM3AlphaBlendColorMode
, 0x0);
1632 PM3_SLOW_WRITE_REG(PM3AlphaBlendAlphaMode
, 0x0);
1633 PM3_SLOW_WRITE_REG(PM3DitherMode
, 0x0);
1634 PM3_SLOW_WRITE_REG(PM3LogicalOpMode
, 0x0);
1635 PM3_SLOW_WRITE_REG(PM3RouterMode
, 0x0);
1636 PM3_SLOW_WRITE_REG(PM3Window
, 0x0);
1638 PM3_SLOW_WRITE_REG(PM3Config2D
, 0x0);
1640 PM3_SLOW_WRITE_REG(PM3SpanColorMask
, 0xffffffff);
1642 PM3_SLOW_WRITE_REG(PM3XBias
, 0x0);
1643 PM3_SLOW_WRITE_REG(PM3YBias
, 0x0);
1644 PM3_SLOW_WRITE_REG(PM3DeltaControl
, 0x0);
1646 PM3_SLOW_WRITE_REG(PM3BitMaskPattern
, 0xffffffff);
1648 PM3_SLOW_WRITE_REG(PM3FBDestReadEnables
,
1649 PM3FBDestReadEnables_E(0xff) |
1650 PM3FBDestReadEnables_R(0xff) |
1651 PM3FBDestReadEnables_ReferenceAlpha(0xff));
1652 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferAddr0
, 0x0);
1653 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferOffset0
, 0x0);
1654 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferWidth0
,
1655 PM3FBDestReadBufferWidth_Width(l_fb_info
->
1659 PM3_SLOW_WRITE_REG(PM3FBDestReadMode
,
1660 PM3FBDestReadMode_ReadEnable
|
1661 PM3FBDestReadMode_Enable0
);
1662 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferAddr
, 0x0);
1663 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferOffset
, 0x0);
1664 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferWidth
,
1665 PM3FBSourceReadBufferWidth_Width(l_fb_info
->
1668 PM3_SLOW_WRITE_REG(PM3FBSourceReadMode
,
1669 PM3FBSourceReadMode_Blocking
|
1670 PM3FBSourceReadMode_ReadEnable
);
1673 unsigned long rm
= 1;
1674 switch (l_fb_info
->current_par
->depth
) {
1676 PM3_SLOW_WRITE_REG(PM3PixelSize
,
1677 PM3PixelSize_GLOBAL_8BIT
);
1682 PM3_SLOW_WRITE_REG(PM3PixelSize
,
1683 PM3PixelSize_GLOBAL_16BIT
);
1686 PM3_SLOW_WRITE_REG(PM3PixelSize
,
1687 PM3PixelSize_GLOBAL_32BIT
);
1690 DPRINTK(1, "Unsupported depth %d\n",
1691 l_fb_info
->current_par
->depth
);
1694 PM3_SLOW_WRITE_REG(PM3RasterizerMode
, rm
);
1697 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask
, 0xffffffff);
1698 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask
, 0xffffffff);
1699 PM3_SLOW_WRITE_REG(PM3FBWriteMode
,
1700 PM3FBWriteMode_WriteEnable
|
1701 PM3FBWriteMode_OpaqueSpan
|
1702 PM3FBWriteMode_Enable0
);
1703 PM3_SLOW_WRITE_REG(PM3FBWriteBufferAddr0
, 0x0);
1704 PM3_SLOW_WRITE_REG(PM3FBWriteBufferOffset0
, 0x0);
1705 PM3_SLOW_WRITE_REG(PM3FBWriteBufferWidth0
,
1706 PM3FBWriteBufferWidth_Width(l_fb_info
->
1710 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer
, 0x0);
1712 unsigned long sofb
= (8UL * l_fb_info
->fb_size
) /
1713 ((depth2bpp(l_fb_info
->current_par
->depth
))
1714 * l_fb_info
->current_par
->width
); /* size in lines of FB */
1716 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer
, 4095);
1718 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer
, sofb
);
1720 switch (l_fb_info
->current_par
->depth
) {
1722 PM3_SLOW_WRITE_REG(PM3DitherMode
,
1723 (1 << 10) | (2 << 3));
1728 PM3_SLOW_WRITE_REG(PM3DitherMode
,
1729 (1 << 10) | (1 << 3));
1732 PM3_SLOW_WRITE_REG(PM3DitherMode
,
1733 (1 << 10) | (0 << 3));
1736 DPRINTK(1, "Unsupported depth %d\n",
1737 l_fb_info
->current_par
->depth
);
1742 PM3_SLOW_WRITE_REG(PM3dXDom
, 0x0);
1743 PM3_SLOW_WRITE_REG(PM3dXSub
, 0x0);
1744 PM3_SLOW_WRITE_REG(PM3dY
, (1 << 16));
1745 PM3_SLOW_WRITE_REG(PM3StartXDom
, 0x0);
1746 PM3_SLOW_WRITE_REG(PM3StartXSub
, 0x0);
1747 PM3_SLOW_WRITE_REG(PM3StartY
, 0x0);
1748 PM3_SLOW_WRITE_REG(PM3Count
, 0x0);
1750 /* Disable LocalBuffer. better safe than sorry */
1751 PM3_SLOW_WRITE_REG(PM3LBDestReadMode
, 0x0);
1752 PM3_SLOW_WRITE_REG(PM3LBDestReadEnables
, 0x0);
1753 PM3_SLOW_WRITE_REG(PM3LBSourceReadMode
, 0x0);
1754 PM3_SLOW_WRITE_REG(PM3LBWriteMode
, 0x0);
1756 pm3fb_wait_pm3(l_fb_info
);
1759 #ifdef FBCON_HAS_CFB32
1760 static void pm3fb_cfb32_clear(struct vc_data
*conp
,
1762 int sy
, int sx
, int height
, int width
)
1764 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
1769 sx
= sx
* fontwidth(p
);
1770 width
= width
* fontwidth(p
);
1771 sy
= sy
* fontheight(p
);
1772 height
= height
* fontheight(p
);
1773 c
= ((u32
*) p
->dispsw_data
)[attr_bgcol_ec(p
, conp
)];
1775 /* block fills in 32bpp are hard, but in low res (width <= 1600 :-)
1776 we can use 16bpp operations, but not if NoWriteMask is on (SDRAM) */
1777 if ((l_fb_info
->current_par
->width
> 1600) ||
1778 (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)) {
1781 PM3_WRITE_REG(PM3Config2D
,
1782 PM3Config2D_UseConstantSource
|
1783 PM3Config2D_ForegroundROPEnable
|
1784 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1785 PM3Config2D_FBWriteEnable
);
1787 PM3_WRITE_REG(PM3ForegroundColor
, c
);
1789 PM3_WRITE_REG(PM3RectanglePosition
,
1790 (PM3RectanglePosition_XOffset(sx
)) |
1791 (PM3RectanglePosition_YOffset(sy
)));
1793 PM3_WRITE_REG(PM3Render2D
,
1794 PM3Render2D_XPositive
|
1795 PM3Render2D_YPositive
|
1796 PM3Render2D_Operation_Normal
|
1797 PM3Render2D_SpanOperation
|
1798 (PM3Render2D_Width(width
)) |
1799 (PM3Render2D_Height(height
)));
1803 PM3_WRITE_REG(PM3FBBlockColor
, c
);
1805 PM3_WRITE_REG(PM3PixelSize
, PM3PixelSize_GLOBAL_16BIT
);
1807 PM3_WRITE_REG(PM3FBWriteBufferWidth0
,
1808 PM3FBWriteBufferWidth_Width(l_fb_info
->
1812 PM3_WRITE_REG(PM3Config2D
,
1813 PM3Config2D_UseConstantSource
|
1814 PM3Config2D_ForegroundROPEnable
|
1815 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1816 PM3Config2D_FBWriteEnable
);
1818 PM3_WRITE_REG(PM3RectanglePosition
,
1819 (PM3RectanglePosition_XOffset(sx
<< 1)) |
1820 (PM3RectanglePosition_YOffset(sy
)));
1822 PM3_WRITE_REG(PM3Render2D
,
1823 PM3Render2D_XPositive
|
1824 PM3Render2D_YPositive
|
1825 PM3Render2D_Operation_Normal
|
1826 (PM3Render2D_Width(width
<< 1)) |
1827 (PM3Render2D_Height(height
)));
1829 PM3_WRITE_REG(PM3FBWriteBufferWidth0
,
1830 PM3FBWriteBufferWidth_Width(l_fb_info
->
1834 PM3_WRITE_REG(PM3PixelSize
, PM3PixelSize_GLOBAL_32BIT
);
1837 pm3fb_wait_pm3(l_fb_info
);
1840 static void pm3fb_cfb32_clear_margins(struct vc_data
*conp
,
1841 struct display
*p
, int bottom_only
)
1843 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
1849 sx
= conp
->vc_cols
* fontwidth(p
); /* right margin */
1850 sy
= conp
->vc_rows
* fontheight(p
); /* bottom margin */
1851 c
= ((u32
*) p
->dispsw_data
)[attr_bgcol_ec(p
, conp
)];
1853 if (!bottom_only
) { /* right margin top->bottom */
1856 PM3_WRITE_REG(PM3Config2D
,
1857 PM3Config2D_UseConstantSource
|
1858 PM3Config2D_ForegroundROPEnable
|
1859 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1860 PM3Config2D_FBWriteEnable
);
1862 PM3_WRITE_REG(PM3ForegroundColor
, c
);
1864 PM3_WRITE_REG(PM3RectanglePosition
,
1865 (PM3RectanglePosition_XOffset
1867 sx
)) | (PM3RectanglePosition_YOffset(p
->
1871 PM3_WRITE_REG(PM3Render2D
,
1872 PM3Render2D_XPositive
|
1873 PM3Render2D_YPositive
|
1874 PM3Render2D_Operation_Normal
|
1875 PM3Render2D_SpanOperation
|
1876 (PM3Render2D_Width(p
->var
.xres
- sx
)) |
1877 (PM3Render2D_Height(p
->var
.yres
)));
1880 /* bottom margin left -> right */
1883 PM3_WRITE_REG(PM3Config2D
,
1884 PM3Config2D_UseConstantSource
|
1885 PM3Config2D_ForegroundROPEnable
|
1886 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1887 PM3Config2D_FBWriteEnable
);
1889 PM3_WRITE_REG(PM3ForegroundColor
, c
);
1891 PM3_WRITE_REG(PM3RectanglePosition
,
1892 (PM3RectanglePosition_XOffset(p
->var
.xoffset
)) |
1893 (PM3RectanglePosition_YOffset(p
->var
.yoffset
+ sy
)));
1895 PM3_WRITE_REG(PM3Render2D
,
1896 PM3Render2D_XPositive
|
1897 PM3Render2D_YPositive
|
1898 PM3Render2D_Operation_Normal
|
1899 PM3Render2D_SpanOperation
|
1900 (PM3Render2D_Width(p
->var
.xres
)) |
1901 (PM3Render2D_Height(p
->var
.yres
- sy
)));
1903 pm3fb_wait_pm3(l_fb_info
);
1905 #endif /* FBCON_HAS_CFB32 */
1906 #ifdef FBCON_HAS_CFB16
1907 static void pm3fb_cfb16_clear(struct vc_data
*conp
,
1909 int sy
, int sx
, int height
, int width
)
1911 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
1916 sx
= sx
* fontwidth(p
);
1917 width
= width
* fontwidth(p
);
1918 sy
= sy
* fontheight(p
);
1919 height
= height
* fontheight(p
);
1920 c
= ((u16
*) p
->dispsw_data
)[attr_bgcol_ec(p
, conp
)];
1925 if (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)
1926 PM3_WRITE_REG(PM3ForegroundColor
, c
);
1928 PM3_WRITE_REG(PM3FBBlockColor
, c
);
1930 PM3_WRITE_REG(PM3Config2D
,
1931 PM3Config2D_UseConstantSource
|
1932 PM3Config2D_ForegroundROPEnable
|
1933 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1934 PM3Config2D_FBWriteEnable
);
1936 PM3_WRITE_REG(PM3RectanglePosition
,
1937 (PM3RectanglePosition_XOffset(sx
)) |
1938 (PM3RectanglePosition_YOffset(sy
)));
1940 if (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)
1941 PM3_WRITE_REG(PM3Render2D
,
1942 PM3Render2D_XPositive
|
1943 PM3Render2D_YPositive
|
1944 PM3Render2D_Operation_Normal
|
1945 PM3Render2D_SpanOperation
|
1946 (PM3Render2D_Width(width
)) |
1947 (PM3Render2D_Height(height
)));
1949 PM3_WRITE_REG(PM3Render2D
,
1950 PM3Render2D_XPositive
|
1951 PM3Render2D_YPositive
|
1952 PM3Render2D_Operation_Normal
|
1953 (PM3Render2D_Width(width
)) |
1954 (PM3Render2D_Height(height
)));
1956 pm3fb_wait_pm3(l_fb_info
);
1959 static void pm3fb_cfb16_clear_margins(struct vc_data
*conp
,
1960 struct display
*p
, int bottom_only
)
1962 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
1968 sx
= conp
->vc_cols
* fontwidth(p
); /* right margin */
1969 sy
= conp
->vc_rows
* fontheight(p
); /* bottom margin */
1970 c
= ((u16
*) p
->dispsw_data
)[attr_bgcol_ec(p
, conp
)];
1973 if (!bottom_only
) { /* right margin top->bottom */
1976 PM3_WRITE_REG(PM3Config2D
,
1977 PM3Config2D_UseConstantSource
|
1978 PM3Config2D_ForegroundROPEnable
|
1979 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1980 PM3Config2D_FBWriteEnable
);
1982 if (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)
1983 PM3_WRITE_REG(PM3ForegroundColor
, c
);
1985 PM3_WRITE_REG(PM3FBBlockColor
, c
);
1987 PM3_WRITE_REG(PM3RectanglePosition
,
1988 (PM3RectanglePosition_XOffset
1990 sx
)) | (PM3RectanglePosition_YOffset(p
->
1993 if (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)
1994 PM3_WRITE_REG(PM3Render2D
,
1995 PM3Render2D_XPositive
|
1996 PM3Render2D_YPositive
|
1997 PM3Render2D_Operation_Normal
|
1998 PM3Render2D_SpanOperation
|
1999 (PM3Render2D_Width(p
->var
.xres
- sx
)) |
2000 (PM3Render2D_Height(p
->var
.yres
)));
2002 PM3_WRITE_REG(PM3Render2D
,
2003 PM3Render2D_XPositive
|
2004 PM3Render2D_YPositive
|
2005 PM3Render2D_Operation_Normal
|
2006 (PM3Render2D_Width(p
->var
.xres
- sx
)) |
2007 (PM3Render2D_Height(p
->var
.yres
)));
2010 /* bottom margin left -> right */
2013 PM3_WRITE_REG(PM3Config2D
,
2014 PM3Config2D_UseConstantSource
|
2015 PM3Config2D_ForegroundROPEnable
|
2016 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2017 PM3Config2D_FBWriteEnable
);
2019 if (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)
2020 PM3_WRITE_REG(PM3ForegroundColor
, c
);
2022 PM3_WRITE_REG(PM3FBBlockColor
, c
);
2025 PM3_WRITE_REG(PM3RectanglePosition
,
2026 (PM3RectanglePosition_XOffset(p
->var
.xoffset
)) |
2027 (PM3RectanglePosition_YOffset(p
->var
.yoffset
+ sy
)));
2029 if (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)
2030 PM3_WRITE_REG(PM3Render2D
,
2031 PM3Render2D_XPositive
|
2032 PM3Render2D_YPositive
|
2033 PM3Render2D_Operation_Normal
|
2034 PM3Render2D_SpanOperation
|
2035 (PM3Render2D_Width(p
->var
.xres
)) |
2036 (PM3Render2D_Height(p
->var
.yres
- sy
)));
2038 PM3_WRITE_REG(PM3Render2D
,
2039 PM3Render2D_XPositive
|
2040 PM3Render2D_YPositive
|
2041 PM3Render2D_Operation_Normal
|
2042 (PM3Render2D_Width(p
->var
.xres
)) |
2043 (PM3Render2D_Height(p
->var
.yres
- sy
)));
2045 pm3fb_wait_pm3(l_fb_info
);
2047 #endif /* FBCON_HAS_CFB16 */
2048 #ifdef FBCON_HAS_CFB8
2049 static void pm3fb_cfb8_clear(struct vc_data
*conp
,
2051 int sy
, int sx
, int height
, int width
)
2053 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
2058 sx
= sx
* fontwidth(p
);
2059 width
= width
* fontwidth(p
);
2060 sy
= sy
* fontheight(p
);
2061 height
= height
* fontheight(p
);
2063 c
= attr_bgcol_ec(p
, conp
);
2069 PM3_WRITE_REG(PM3Config2D
,
2070 PM3Config2D_UseConstantSource
|
2071 PM3Config2D_ForegroundROPEnable
|
2072 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2073 PM3Config2D_FBWriteEnable
);
2075 PM3_WRITE_REG(PM3ForegroundColor
, c
);
2077 PM3_WRITE_REG(PM3RectanglePosition
,
2078 (PM3RectanglePosition_XOffset(sx
)) |
2079 (PM3RectanglePosition_YOffset(sy
)));
2081 PM3_WRITE_REG(PM3Render2D
,
2082 PM3Render2D_XPositive
|
2083 PM3Render2D_YPositive
|
2084 PM3Render2D_Operation_Normal
|
2085 PM3Render2D_SpanOperation
|
2086 (PM3Render2D_Width(width
)) |
2087 (PM3Render2D_Height(height
)));
2089 pm3fb_wait_pm3(l_fb_info
);
2092 static void pm3fb_cfb8_clear_margins(struct vc_data
*conp
,
2093 struct display
*p
, int bottom_only
)
2095 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
2101 sx
= conp
->vc_cols
* fontwidth(p
); /* right margin */
2102 sy
= conp
->vc_rows
* fontheight(p
); /* bottom margin */
2103 c
= attr_bgcol_ec(p
, conp
);
2107 if (!bottom_only
) { /* right margin top->bottom */
2110 PM3_WRITE_REG(PM3Config2D
,
2111 PM3Config2D_UseConstantSource
|
2112 PM3Config2D_ForegroundROPEnable
|
2113 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2114 PM3Config2D_FBWriteEnable
);
2116 PM3_WRITE_REG(PM3ForegroundColor
, c
);
2118 PM3_WRITE_REG(PM3RectanglePosition
,
2119 (PM3RectanglePosition_XOffset
2121 sx
)) | (PM3RectanglePosition_YOffset(p
->
2125 PM3_WRITE_REG(PM3Render2D
,
2126 PM3Render2D_XPositive
|
2127 PM3Render2D_YPositive
|
2128 PM3Render2D_Operation_Normal
|
2129 PM3Render2D_SpanOperation
|
2130 (PM3Render2D_Width(p
->var
.xres
- sx
)) |
2131 (PM3Render2D_Height(p
->var
.yres
)));
2134 /* bottom margin left -> right */
2137 PM3_WRITE_REG(PM3Config2D
,
2138 PM3Config2D_UseConstantSource
|
2139 PM3Config2D_ForegroundROPEnable
|
2140 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2141 PM3Config2D_FBWriteEnable
);
2143 PM3_WRITE_REG(PM3ForegroundColor
, c
);
2145 PM3_WRITE_REG(PM3RectanglePosition
,
2146 (PM3RectanglePosition_XOffset(p
->var
.xoffset
)) |
2147 (PM3RectanglePosition_YOffset(p
->var
.yoffset
+ sy
)));
2149 PM3_WRITE_REG(PM3Render2D
,
2150 PM3Render2D_XPositive
|
2151 PM3Render2D_YPositive
|
2152 PM3Render2D_Operation_Normal
|
2153 PM3Render2D_SpanOperation
|
2154 (PM3Render2D_Width(p
->var
.xres
)) |
2155 (PM3Render2D_Height(p
->var
.yres
- sy
)));
2157 pm3fb_wait_pm3(l_fb_info
);
2159 #endif /* FBCON_HAS_CFB8 */
2160 #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
2161 static void pm3fb_cfbX_bmove(struct display
*p
,
2163 int dy
, int dx
, int height
, int width
)
2165 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
2166 int x_align
, o_x
, o_y
;
2170 sx
= sx
* fontwidth(p
);
2171 dx
= dx
* fontwidth(p
);
2172 width
= width
* fontwidth(p
);
2173 sy
= sy
* fontheight(p
);
2174 dy
= dy
* fontheight(p
);
2175 height
= height
* fontheight(p
);
2177 o_x
= sx
- dx
; /*(sx > dx ) ? (sx - dx) : (dx - sx); */
2178 o_y
= sy
- dy
; /*(sy > dy ) ? (sy - dy) : (dy - sy); */
2180 x_align
= (sx
& 0x1f);
2184 PM3_WRITE_REG(PM3Config2D
,
2185 PM3Config2D_UserScissorEnable
|
2186 PM3Config2D_ForegroundROPEnable
|
2187 PM3Config2D_Blocking
|
2188 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2189 PM3Config2D_FBWriteEnable
);
2191 PM3_WRITE_REG(PM3ScissorMinXY
,
2192 ((dy
& 0x0fff) << 16) | (dx
& 0x0fff));
2193 PM3_WRITE_REG(PM3ScissorMaxXY
,
2194 (((dy
+ height
) & 0x0fff) << 16) |
2195 ((dx
+ width
) & 0x0fff));
2197 PM3_WRITE_REG(PM3FBSourceReadBufferOffset
,
2198 PM3FBSourceReadBufferOffset_XOffset(o_x
) |
2199 PM3FBSourceReadBufferOffset_YOffset(o_y
));
2201 PM3_WRITE_REG(PM3RectanglePosition
,
2202 (PM3RectanglePosition_XOffset(dx
- x_align
)) |
2203 (PM3RectanglePosition_YOffset(dy
)));
2205 PM3_WRITE_REG(PM3Render2D
,
2206 ((sx
> dx
) ? PM3Render2D_XPositive
: 0) |
2207 ((sy
> dy
) ? PM3Render2D_YPositive
: 0) |
2208 PM3Render2D_Operation_Normal
|
2209 PM3Render2D_SpanOperation
|
2210 PM3Render2D_FBSourceReadEnable
|
2211 (PM3Render2D_Width(width
+ x_align
)) |
2212 (PM3Render2D_Height(height
)));
2214 pm3fb_wait_pm3(l_fb_info
);
2217 static void pm3fb_cfbX_putc(struct vc_data
*conp
, struct display
*p
,
2218 int c
, int yy
, int xx
)
2220 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
2221 u8
*cdat
, asx
= 0, asy
= 0, o_x
= 0, o_y
= 0;
2227 if (l_fb_info
->current_par
->depth
== 8)
2228 fgx
= attr_fgcol(p
, c
);
2229 else if (depth2bpp(l_fb_info
->current_par
->depth
) == 16)
2230 fgx
= ((u16
*) p
->dispsw_data
)[attr_fgcol(p
, c
)];
2232 fgx
= ((u32
*) p
->dispsw_data
)[attr_fgcol(p
, c
)];
2236 if (l_fb_info
->current_par
->depth
== 8)
2237 bgx
= attr_bgcol(p
, c
);
2238 else if (depth2bpp(l_fb_info
->current_par
->depth
) == 16)
2239 bgx
= ((u16
*) p
->dispsw_data
)[attr_bgcol(p
, c
)];
2241 bgx
= ((u32
*) p
->dispsw_data
)[attr_bgcol(p
, c
)];
2247 PM3_WRITE_REG(PM3Config2D
,
2248 PM3Config2D_UseConstantSource
|
2249 PM3Config2D_ForegroundROPEnable
|
2250 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2251 PM3Config2D_FBWriteEnable
| PM3Config2D_OpaqueSpan
);
2253 PM3_WRITE_REG(PM3ForegroundColor
, fgx
);
2254 PM3_WRITE_REG(PM3FillBackgroundColor
, bgx
);
2256 /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */
2257 /* and 16 bits for fontwidth <= 16 */
2258 /* same in _putcs, same for Y and fontheight */
2259 if (fontwidth(p
) <= 8)
2261 else if (fontwidth(p
) <= 16)
2262 asx
= 3; /* look OK */
2263 if (fontheight(p
) <= 8)
2265 else if (fontheight(p
) <= 16)
2266 asy
= 3; /* look OK */
2267 else if (fontheight(p
) <= 32)
2268 asy
= 4; /* look OK */
2270 sx
= xx
* fontwidth(p
);
2271 sy
= yy
* fontheight(p
);
2273 if (fontwidth(p
) <= 8)
2274 o_x
= (8 - (sx
& 0x7)) & 0x7;
2275 else if (fontwidth(p
) <= 16)
2276 o_x
= (16 - (sx
& 0xF)) & 0xF;
2277 if (fontheight(p
) <= 8)
2278 o_y
= (8 - (sy
& 0x7)) & 0x7;
2279 else if (fontheight(p
) <= 16)
2280 o_y
= (16 - (sy
& 0xF)) & 0xF;
2281 else if (fontheight(p
) <= 32)
2282 o_y
= (32 - (sy
& 0x1F)) & 0x1F;
2284 PM3_WRITE_REG(PM3AreaStippleMode
, (o_x
<< 7) | (o_y
<< 12) | /* x_offset, y_offset in pattern */
2285 (1 << 18) | /* BE */
2286 1 | (asx
<< 1) | (asy
<< 4) | /* address select x/y */
2287 (1 << 20)); /* OpaqueSpan */
2289 if (fontwidth(p
) <= 8) {
2290 cdat
= p
->fontdata
+ (c
& p
->charmask
) * fontheight(p
);
2294 ((c
& p
->charmask
) * (fontheight(p
) << 1));
2297 PM3_WAIT(2 + fontheight(p
));
2299 for (i
= 0; i
< fontheight(p
); i
++) { /* assume fontheight <= 32 */
2300 if (fontwidth(p
) <= 8) {
2302 } else { /* assume fontwidth <= 16 ATM */
2304 ldat
= ((*cdat
++) << 8);
2307 PM3_WRITE_REG(AreaStipplePattern_indexed(i
), ldat
);
2310 PM3_WRITE_REG(PM3RectanglePosition
,
2311 (PM3RectanglePosition_XOffset(sx
)) |
2312 (PM3RectanglePosition_YOffset(sy
)));
2314 PM3_WRITE_REG(PM3Render2D
,
2315 PM3Render2D_AreaStippleEnable
|
2316 PM3Render2D_XPositive
|
2317 PM3Render2D_YPositive
|
2318 PM3Render2D_Operation_Normal
|
2319 PM3Render2D_SpanOperation
|
2320 (PM3Render2D_Width(fontwidth(p
))) |
2321 (PM3Render2D_Height(fontheight(p
))));
2323 pm3fb_wait_pm3(l_fb_info
);
2326 static void pm3fb_cfbX_putcs(struct vc_data
*conp
, struct display
*p
,
2327 const unsigned short *s
, int count
, int yy
,
2330 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
2331 u8
*cdat
, asx
= 0, asy
= 0, o_x
= 0, o_y
= 0;
2339 if (l_fb_info
->current_par
->depth
== 8)
2340 fgx
= attr_fgcol(p
, sc
);
2341 else if (depth2bpp(l_fb_info
->current_par
->depth
) == 16)
2342 fgx
= ((u16
*) p
->dispsw_data
)[attr_fgcol(p
, sc
)];
2344 fgx
= ((u32
*) p
->dispsw_data
)[attr_fgcol(p
, sc
)];
2348 if (l_fb_info
->current_par
->depth
== 8)
2349 bgx
= attr_bgcol(p
, sc
);
2350 else if (depth2bpp(l_fb_info
->current_par
->depth
) == 16)
2351 bgx
= ((u16
*) p
->dispsw_data
)[attr_bgcol(p
, sc
)];
2353 bgx
= ((u32
*) p
->dispsw_data
)[attr_bgcol(p
, sc
)];
2359 PM3_WRITE_REG(PM3Config2D
,
2360 PM3Config2D_UseConstantSource
|
2361 PM3Config2D_ForegroundROPEnable
|
2362 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2363 PM3Config2D_FBWriteEnable
|
2364 PM3Config2D_OpaqueSpan
);
2366 PM3_WRITE_REG(PM3ForegroundColor
, fgx
);
2367 PM3_WRITE_REG(PM3FillBackgroundColor
, bgx
);
2369 /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */
2370 /* and 16 bits for fontwidth <= 16 */
2371 /* same in _putc, same for Y and fontheight */
2372 if (fontwidth(p
) <= 8)
2374 else if (fontwidth(p
) <= 16)
2375 asx
= 3; /* look OK */
2376 if (fontheight(p
) <= 8)
2378 else if (fontheight(p
) <= 16)
2379 asy
= 3; /* look OK */
2380 else if (fontheight(p
) <= 32)
2381 asy
= 4; /* look OK */
2383 sy
= yy
* fontheight(p
);
2385 if (fontheight(p
) <= 8)
2386 o_y
= (8 - (sy
& 0x7)) & 0x7;
2387 else if (fontheight(p
) <= 16)
2388 o_y
= (16 - (sy
& 0xF)) & 0xF;
2389 else if (fontheight(p
) <= 32)
2390 o_y
= (32 - (sy
& 0x1F)) & 0x1F;
2392 for (j
= 0; j
< count
; j
++) {
2393 sc
= scr_readw(s
+ j
);
2394 if (fontwidth(p
) <= 8)
2395 cdat
= p
->fontdata
+
2396 (sc
& p
->charmask
) * fontheight(p
);
2398 cdat
= p
->fontdata
+
2399 ((sc
& p
->charmask
) * fontheight(p
) << 1);
2401 sx
= (xx
+ j
) * fontwidth(p
);
2403 if (fontwidth(p
) <= 8)
2404 o_x
= (8 - (sx
& 0x7)) & 0x7;
2405 else if (fontwidth(p
) <= 16)
2406 o_x
= (16 - (sx
& 0xF)) & 0xF;
2408 PM3_WAIT(3 + fontheight(p
));
2410 PM3_WRITE_REG(PM3AreaStippleMode
, (o_x
<< 7) | (o_y
<< 12) | /* x_offset, y_offset in pattern */
2411 (1 << 18) | /* BE */
2412 1 | (asx
<< 1) | (asy
<< 4) | /* address select x/y */
2413 (1 << 20)); /* OpaqueSpan */
2415 for (i
= 0; i
< fontheight(p
); i
++) { /* assume fontheight <= 32 */
2416 if (fontwidth(p
) <= 8) {
2418 } else { /* assume fontwidth <= 16 ATM */
2419 ldat
= ((*cdat
++) << 8);
2422 PM3_WRITE_REG(AreaStipplePattern_indexed(i
), ldat
);
2425 PM3_WRITE_REG(PM3RectanglePosition
,
2426 (PM3RectanglePosition_XOffset(sx
)) |
2427 (PM3RectanglePosition_YOffset(sy
)));
2429 PM3_WRITE_REG(PM3Render2D
,
2430 PM3Render2D_AreaStippleEnable
|
2431 PM3Render2D_XPositive
|
2432 PM3Render2D_YPositive
|
2433 PM3Render2D_Operation_Normal
|
2434 PM3Render2D_SpanOperation
|
2435 (PM3Render2D_Width(fontwidth(p
))) |
2436 (PM3Render2D_Height(fontheight(p
))));
2438 pm3fb_wait_pm3(l_fb_info
);
2441 static void pm3fb_cfbX_revc(struct display
*p
, int xx
, int yy
)
2443 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) p
->fb_info
;
2445 xx
= xx
* fontwidth(p
);
2446 yy
= yy
* fontheight(p
);
2448 if (l_fb_info
->current_par
->depth
== 8)
2450 if (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)
2451 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask
, 0x0F0F0F0F);
2453 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask
, 0x0F0F0F0F);
2458 PM3_WRITE_REG(PM3Config2D
,
2459 PM3Config2D_UseConstantSource
|
2460 PM3Config2D_ForegroundROPEnable
|
2461 (PM3Config2D_ForegroundROP(0xa)) | /* Oxa is GXinvert */
2462 PM3Config2D_FBDestReadEnable
|
2463 PM3Config2D_FBWriteEnable
);
2465 PM3_WRITE_REG(PM3RectanglePosition
,
2466 (PM3RectanglePosition_XOffset(xx
)) |
2467 (PM3RectanglePosition_YOffset(yy
)));
2469 PM3_WRITE_REG(PM3Render2D
,
2470 PM3Render2D_XPositive
|
2471 PM3Render2D_YPositive
|
2472 PM3Render2D_Operation_Normal
|
2473 PM3Render2D_SpanOperation
|
2474 (PM3Render2D_Width(fontwidth(p
))) |
2475 (PM3Render2D_Height(fontheight(p
))));
2477 pm3fb_wait_pm3(l_fb_info
);
2479 if (l_fb_info
->current_par
->depth
== 8)
2481 if (l_fb_info
->memt
.caps
& PM3LocalMemCaps_NoWriteMask
)
2482 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask
, 0xFFFFFFFF);
2484 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask
, 0xFFFFFFFF);
2488 #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
2489 #endif /* PM3FB_USE_ACCEL */
2490 /* *********************************** */
2491 /* ***** pre-init board(s) setup ***** */
2492 /* *********************************** */
2494 static void pm3fb_mode_setup(char *mode
, unsigned long board_num
)
2496 struct pm3fb_info
*l_fb_info
= &(fb_info
[board_num
]);
2497 struct pm3fb_par
*l_fb_par
= &(current_par
[board_num
]);
2498 unsigned long i
= 0;
2500 current_par_valid
[board_num
] = 0;
2502 if (!strncmp(mode
, "current", 7)) {
2503 l_fb_info
->use_current
= 1; /* default w/ OpenFirmware */
2505 while ((mode_base
[i
].name
[0])
2506 && (!current_par_valid
[board_num
])) {
2509 (mode
, mode_base
[i
].name
,
2510 strlen(mode_base
[i
].name
)))) {
2511 memcpy(l_fb_par
, &(mode_base
[i
].user_mode
),
2512 sizeof(struct pm3fb_par
));
2513 current_par_valid
[board_num
] = 1;
2514 DPRINTK(2, "Mode set to %s\n",
2519 DASSERT(current_par_valid
[board_num
],
2520 "Valid mode on command line\n");
2524 static void pm3fb_pciid_setup(char *pciid
, unsigned long board_num
)
2526 short l_bus
= -1, l_slot
= -1, l_func
= -1;
2530 l_bus
= simple_strtoul(pciid
, &next
, 10);
2531 if (next
&& (next
[0] == ':')) {
2533 l_slot
= simple_strtoul(pciid
, &next
, 10);
2534 if (next
&& (next
[0] == ':')) {
2537 simple_strtoul(pciid
, (char **) NULL
,
2544 if ((l_bus
>= 0) && (l_slot
>= 0) && (l_func
>= 0)) {
2545 bus
[board_num
] = l_bus
;
2546 slot
[board_num
] = l_slot
;
2547 func
[board_num
] = l_func
;
2548 DPRINTK(2, "Board #%ld will be PciId: %hd:%hd:%hd\n",
2549 board_num
, l_bus
, l_slot
, l_func
);
2551 DPRINTK(1, "Invalid PciId: %hd:%hd:%hd for board #%ld\n",
2552 l_bus
, l_slot
, l_func
, board_num
);
2556 static void pm3fb_font_setup(char *lf
, unsigned long board_num
)
2558 unsigned long lfs
= strlen(lf
);
2560 if (lfs
> (PM3_FONTNAME_SIZE
- 1)) {
2561 DPRINTK(1, "Fontname %s too long\n", lf
);
2564 strlcpy(fontn
[board_num
], lf
, lfs
+ 1);
2567 static void pm3fb_bootdepth_setup(char *bds
, unsigned long board_num
)
2569 unsigned long bd
= simple_strtoul(bds
, (char **) NULL
, 10);
2571 if (!(depth_supported(bd
))) {
2572 printk(KERN_WARNING
"pm3fb: ignoring invalid depth %s for board #%ld\n",
2576 depth
[board_num
] = bd
;
2579 static void pm3fb_forcesize_setup(char *bds
, unsigned long board_num
)
2581 unsigned long bd
= simple_strtoul(bds
, (char **) NULL
, 10);
2584 printk(KERN_WARNING
"pm3fb: ignoring invalid memory size %s for board #%ld\n",
2588 forcesize
[board_num
] = bd
;
2591 static char *pm3fb_boardnum_setup(char *options
, unsigned long *bn
)
2595 if (!(isdigit(options
[0]))) {
2600 (*bn
) = simple_strtoul(options
, &next
, 10);
2602 if (next
&& (next
[0] == ':') && ((*bn
) >= 0)
2603 && ((*bn
) <= PM3_MAX_BOARD
)) {
2604 DPRINTK(2, "Board_num seen as %ld\n", (*bn
));
2608 DPRINTK(2, "Board_num default to %ld\n", (*bn
));
2613 static void pm3fb_real_setup(char *options
)
2616 unsigned long i
, bn
;
2617 struct pm3fb_info
*l_fb_info
;
2621 DPRINTK(2, "Options : %s\n", options
);
2623 for (i
= 0; i
< PM3_MAX_BOARD
; i
++) {
2624 l_fb_info
= &(fb_info
[i
]);
2625 memset(l_fb_info
, 0, sizeof(struct pm3fb_info
));
2626 l_fb_info
->gen
.fbhw
= &pm3fb_switch
;
2627 l_fb_info
->board_num
= i
;
2628 current_par_valid
[i
] = 0;
2636 l_fb_info
->current_par
= &(current_par
[i
]);
2639 /* eat up prefix pm3fb and whatever is used as separator i.e. :,= */
2640 if (!strncmp(options
, "pm3fb", 5)) {
2642 while (((*options
) == ',') || ((*options
) == ':')
2643 || ((*options
) == '='))
2649 if ((next
= strchr(options
, ','))) {
2654 if (!strncmp(options
, "mode:", 5)) {
2655 options
= pm3fb_boardnum_setup(options
+ 5, &bn
);
2656 DPRINTK(2, "Setting mode for board #%ld\n", bn
);
2657 pm3fb_mode_setup(options
, bn
);
2658 } else if (!strncmp(options
, "off:", 4)) {
2659 options
= pm3fb_boardnum_setup(options
+ 4, &bn
);
2660 DPRINTK(2, "Disabling board #%ld\n", bn
);
2662 } else if (!strncmp(options
, "off", 3)) { /* disable everything */
2663 for (i
= 0; i
< PM3_MAX_BOARD
; i
++)
2665 } else if (!strncmp(options
, "disable:", 8)) {
2666 options
= pm3fb_boardnum_setup(options
+ 8, &bn
);
2667 DPRINTK(2, "Disabling board #%ld\n", bn
);
2669 } else if (!strncmp(options
, "pciid:", 6)) {
2670 options
= pm3fb_boardnum_setup(options
+ 6, &bn
);
2671 DPRINTK(2, "Setting PciID for board #%ld\n", bn
);
2672 pm3fb_pciid_setup(options
, bn
);
2673 } else if (!strncmp(options
, "noaccel:", 8)) {
2674 options
= pm3fb_boardnum_setup(options
+ 8, &bn
);
2676 } else if (!strncmp(options
, "font:", 5)) {
2677 options
= pm3fb_boardnum_setup(options
+ 5, &bn
);
2678 pm3fb_font_setup(options
, bn
);
2679 } else if (!strncmp(options
, "depth:", 6)) {
2680 options
= pm3fb_boardnum_setup(options
+ 6, &bn
);
2681 pm3fb_bootdepth_setup(options
, bn
);
2682 } else if (!strncmp(options
, "printtimings", 12)) {
2684 } else if (!strncmp(options
, "flatpanel:", 10)) {
2685 options
= pm3fb_boardnum_setup(options
+ 10, &bn
);
2687 } else if (!strncmp(options
, "forcesize:", 10)) {
2688 options
= pm3fb_boardnum_setup(options
+ 10, &bn
);
2689 pm3fb_forcesize_setup(options
, bn
);
2695 /* ********************************************** */
2696 /* ***** framebuffer API standard functions ***** */
2697 /* ********************************************** */
2699 static int pm3fb_encode_fix(struct fb_fix_screeninfo
*fix
,
2700 const void *par
, struct fb_info_gen
*info
)
2702 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
2703 struct pm3fb_par
*p
= (struct pm3fb_par
*) par
;
2707 strcpy(fix
->id
, permedia3_name
);
2708 fix
->smem_start
= (unsigned long)l_fb_info
->p_fb
;
2709 fix
->smem_len
= l_fb_info
->fb_size
;
2710 fix
->mmio_start
= (unsigned long)l_fb_info
->pIOBase
;
2711 fix
->mmio_len
= PM3_REGS_SIZE
;
2712 #ifdef PM3FB_USE_ACCEL
2713 if (!(noaccel
[l_fb_info
->board_num
]))
2714 fix
->accel
= FB_ACCEL_3DLABS_PERMEDIA3
;
2716 #endif /* PM3FB_USE_ACCEL */
2717 fix
->accel
= FB_ACCEL_NONE
;
2718 fix
->type
= FB_TYPE_PACKED_PIXELS
;
2720 (p
->depth
== 8) ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR
;
2721 if (current_par_valid
[l_fb_info
->board_num
])
2723 l_fb_info
->current_par
->width
*
2724 depth2ByPP(l_fb_info
->current_par
->depth
);
2726 fix
->line_length
= 0;
2727 fix
->xpanstep
= 64 / depth2bpp(p
->depth
);
2733 static int pm3fb_decode_var(const struct fb_var_screeninfo
*var
,
2734 void *par
, struct fb_info_gen
*info
)
2736 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
2737 struct pm3fb_par
*p
= (struct pm3fb_par
*) par
;
2738 struct pm3fb_par temp_p
;
2743 DASSERT((var
!= NULL
), "fb_var_screeninfo* not NULL");
2744 DASSERT((p
!= NULL
), "pm3fb_par* not NULL");
2745 DASSERT((l_fb_info
!= NULL
), "pm3fb_info* not NULL");
2747 memset(&temp_p
, 0, sizeof(struct pm3fb_par
));
2748 temp_p
.width
= (var
->xres_virtual
+ 7) & ~7;
2749 temp_p
.height
= var
->yres_virtual
;
2751 if (!(depth_supported(var
->bits_per_pixel
))) /* round unsupported up to a multiple of 8 */
2752 temp_p
.depth
= depth2bpp(var
->bits_per_pixel
);
2754 temp_p
.depth
= var
->bits_per_pixel
;
2756 temp_p
.depth
= (temp_p
.depth
> 32) ? 32 : temp_p
.depth
; /* max 32 */
2757 temp_p
.depth
= (temp_p
.depth
== 24) ? 32 : temp_p
.depth
; /* 24 unsupported, round-up to 32 */
2759 if ((temp_p
.depth
== 16) && (var
->red
.length
== 5) && (var
->green
.length
== 5) && (var
->blue
.length
== 5))
2760 temp_p
.depth
= 15; /* RGBA 5551 is stored as depth 15 */
2762 if ((temp_p
.depth
== 16) && (var
->red
.length
== 4) && (var
->green
.length
== 4) && (var
->blue
.length
== 4))
2763 temp_p
.depth
= 12; /* RGBA 4444 is stored as depth 12 */
2767 "xres: %d, yres: %d, vxres: %d, vyres: %d ; xoffset:%d, yoffset: %d\n",
2768 var
->xres
, var
->yres
, var
->xres_virtual
, var
->yres_virtual
,
2769 var
->xoffset
, var
->yoffset
);
2771 xres
= (var
->xres
+ 31) & ~31;
2772 if (temp_p
.width
< xres
+ var
->xoffset
)
2773 temp_p
.width
= xres
+ var
->xoffset
;
2774 if (temp_p
.height
< var
->yres
+ var
->yoffset
)
2775 temp_p
.height
= var
->yres
+ var
->yoffset
;
2777 if (temp_p
.width
> 2048) {
2778 DPRINTK(1, "virtual width not supported: %u\n",
2782 if (var
->yres
< 200) {
2783 DPRINTK(1, "height not supported: %u\n", (u32
) var
->yres
);
2786 if (temp_p
.height
< 200 || temp_p
.height
> 4095) {
2787 DPRINTK(1, "virtual height not supported: %u\n",
2791 if (!(depth_supported(temp_p
.depth
))) {
2792 DPRINTK(1, "depth not supported: %u\n", temp_p
.depth
);
2795 if ((temp_p
.width
* temp_p
.height
* depth2ByPP(temp_p
.depth
)) >
2796 l_fb_info
->fb_size
) {
2797 DPRINTK(1, "no memory for screen (%ux%ux%u)\n",
2798 temp_p
.width
, temp_p
.height
, temp_p
.depth
);
2802 if ((!var
->pixclock
) ||
2803 (!var
->right_margin
) ||
2804 (!var
->hsync_len
) ||
2805 (!var
->left_margin
) ||
2806 (!var
->lower_margin
) ||
2807 (!var
->vsync_len
) || (!var
->upper_margin
)
2809 unsigned long i
= 0, done
= 0;
2810 printk(KERN_WARNING
"pm3fb: refusing to use a likely wrong timing\n");
2812 while ((mode_base
[i
].user_mode
.width
) && !done
) {
2813 if ((mode_base
[i
].user_mode
.width
== temp_p
.width
)
2814 && (mode_base
[i
].user_mode
.height
==
2816 printk(KERN_NOTICE
"pm3fb: using close match %s\n",
2818 temp_p
= mode_base
[i
].user_mode
;
2826 temp_p
.pixclock
= PICOS2KHZ(var
->pixclock
);
2827 if (temp_p
.pixclock
> PM3_MAX_PIXCLOCK
) {
2828 DPRINTK(1, "pixclock too high (%uKHz)\n",
2833 temp_p
.hsstart
= var
->right_margin
;
2834 temp_p
.hsend
= var
->right_margin
+ var
->hsync_len
;
2836 var
->right_margin
+ var
->hsync_len
+ var
->left_margin
;
2837 temp_p
.htotal
= xres
+ temp_p
.hbend
;
2839 temp_p
.vsstart
= var
->lower_margin
;
2840 temp_p
.vsend
= var
->lower_margin
+ var
->vsync_len
;
2842 var
->lower_margin
+ var
->vsync_len
+ var
->upper_margin
;
2843 temp_p
.vtotal
= var
->yres
+ temp_p
.vbend
;
2845 temp_p
.stride
= temp_p
.width
;
2847 DPRINTK(2, "Using %d * %d, %d Khz, stride is %08x\n",
2848 temp_p
.width
, temp_p
.height
, temp_p
.pixclock
,
2852 pm3fb_Shiftbpp(l_fb_info
, temp_p
.depth
,
2853 (var
->yoffset
* xres
) + var
->xoffset
);
2857 if (var
->sync
& FB_SYNC_HOR_HIGH_ACT
)
2858 temp_p
.video
|= PM3VideoControl_HSYNC_ACTIVE_HIGH
;
2860 temp_p
.video
|= PM3VideoControl_HSYNC_ACTIVE_LOW
;
2862 if (var
->sync
& FB_SYNC_VERT_HIGH_ACT
)
2863 temp_p
.video
|= PM3VideoControl_VSYNC_ACTIVE_HIGH
;
2865 temp_p
.video
|= PM3VideoControl_VSYNC_ACTIVE_LOW
;
2867 if ((var
->vmode
& FB_VMODE_MASK
) == FB_VMODE_INTERLACED
) {
2868 DPRINTK(1, "Interlaced mode not supported\n\n");
2872 if ((var
->vmode
& FB_VMODE_MASK
) == FB_VMODE_DOUBLE
)
2873 temp_p
.video
|= PM3VideoControl_LINE_DOUBLE_ON
;
2875 temp_p
.video
|= PM3VideoControl_LINE_DOUBLE_OFF
;
2877 if (var
->activate
== FB_ACTIVATE_NOW
)
2878 temp_p
.video
|= PM3VideoControl_ENABLE
;
2880 temp_p
.video
|= PM3VideoControl_DISABLE
;
2881 DPRINTK(2, "PM3Video disabled\n");
2884 switch (temp_p
.depth
) {
2886 temp_p
.video
|= PM3VideoControl_PIXELSIZE_8BIT
;
2891 temp_p
.video
|= PM3VideoControl_PIXELSIZE_16BIT
;
2894 temp_p
.video
|= PM3VideoControl_PIXELSIZE_32BIT
;
2897 DPRINTK(1, "Unsupported depth\n");
2903 #ifdef PM3FB_USE_ACCEL
2904 if (var
->accel_flags
& FB_ACCELF_TEXT
)
2905 noaccel
[l_fb_info
->board_num
] = 0;
2907 noaccel
[l_fb_info
->board_num
] = 1;
2908 #endif /* PM3FB_USE_ACCEL */
2913 static void pm3fb_encode_depth(struct fb_var_screeninfo
*var
, long d
)
2917 var
->red
.length
= var
->green
.length
= var
->blue
.length
= 8;
2918 var
->red
.offset
= var
->green
.offset
= var
->blue
.offset
= 0;
2919 var
->transp
.offset
= var
->transp
.length
= 0;
2923 var
->red
.offset
= 8;
2924 var
->red
.length
= 4;
2925 var
->green
.offset
= 4;
2926 var
->green
.length
= 4;
2927 var
->blue
.offset
= 0;
2928 var
->blue
.length
= 4;
2929 var
->transp
.offset
= 12;
2930 var
->transp
.length
= 4;
2934 var
->red
.offset
= 10;
2935 var
->red
.length
= 5;
2936 var
->green
.offset
= 5;
2937 var
->green
.length
= 5;
2938 var
->blue
.offset
= 0;
2939 var
->blue
.length
= 5;
2940 var
->transp
.offset
= 15;
2941 var
->transp
.length
= 1;
2945 var
->red
.offset
= 11;
2946 var
->red
.length
= 5;
2947 var
->green
.offset
= 5;
2948 var
->green
.length
= 6;
2949 var
->blue
.offset
= 0;
2950 var
->blue
.length
= 5;
2951 var
->transp
.offset
= var
->transp
.length
= 0;
2955 var
->transp
.offset
= 24;
2956 var
->red
.offset
= 16;
2957 var
->green
.offset
= 8;
2958 var
->blue
.offset
= 0;
2959 var
->red
.length
= var
->green
.length
=
2960 var
->blue
.length
= var
->transp
.length
= 8;
2964 DPRINTK(1, "Unsupported depth %ld\n", d
);
2969 static int pm3fb_encode_var(struct fb_var_screeninfo
*var
,
2970 const void *par
, struct fb_info_gen
*info
)
2972 struct pm3fb_par
*p
= (struct pm3fb_par
*) par
;
2973 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
2979 DASSERT((var
!= NULL
), "fb_var_screeninfo* not NULL");
2980 DASSERT((p
!= NULL
), "pm3fb_par* not NULL");
2981 DASSERT((info
!= NULL
), "fb_info_gen* not NULL");
2983 memset(var
, 0, sizeof(struct fb_var_screeninfo
));
2985 #ifdef PM3FB_USE_ACCEL
2986 if (!(noaccel
[l_fb_info
->board_num
]))
2987 var
->accel_flags
|= FB_ACCELF_TEXT
;
2988 #endif /* PM3FB_USE_ACCEL */
2990 var
->xres_virtual
= p
->width
;
2991 var
->yres_virtual
= p
->height
;
2992 var
->xres
= p
->htotal
- p
->hbend
;
2993 var
->yres
= p
->vtotal
- p
->vbend
;
2995 DPRINTK(2, "xres = %d, yres : %d\n", var
->xres
, var
->yres
);
2997 var
->right_margin
= p
->hsstart
;
2998 var
->hsync_len
= p
->hsend
- p
->hsstart
;
2999 var
->left_margin
= p
->hbend
- p
->hsend
;
3000 var
->lower_margin
= p
->vsstart
;
3001 var
->vsync_len
= p
->vsend
- p
->vsstart
;
3002 var
->upper_margin
= p
->vbend
- p
->vsend
;
3003 var
->bits_per_pixel
= depth2bpp(p
->depth
);
3005 pm3fb_encode_depth(var
, p
->depth
);
3007 base
= pm3fb_Unshiftbpp(l_fb_info
, p
->depth
, p
->base
);
3009 var
->xoffset
= base
% var
->xres
;
3010 var
->yoffset
= base
/ var
->xres
;
3012 var
->height
= var
->width
= -1;
3014 var
->pixclock
= KHZ2PICOS(p
->pixclock
);
3016 if ((p
->video
& PM3VideoControl_HSYNC_MASK
) ==
3017 PM3VideoControl_HSYNC_ACTIVE_HIGH
)
3018 var
->sync
|= FB_SYNC_HOR_HIGH_ACT
;
3019 if ((p
->video
& PM3VideoControl_VSYNC_MASK
) ==
3020 PM3VideoControl_VSYNC_ACTIVE_HIGH
)
3021 var
->sync
|= FB_SYNC_VERT_HIGH_ACT
;
3022 if (p
->video
& PM3VideoControl_LINE_DOUBLE_ON
)
3023 var
->vmode
= FB_VMODE_DOUBLE
;
3028 static void pm3fb_get_par(void *par
, struct fb_info_gen
*info
)
3030 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
3034 if (!current_par_valid
[l_fb_info
->board_num
]) {
3035 if (l_fb_info
->use_current
)
3036 pm3fb_read_mode(l_fb_info
, l_fb_info
->current_par
);
3038 memcpy(l_fb_info
->current_par
,
3039 &(mode_base
[0].user_mode
),
3040 sizeof(struct pm3fb_par
));
3041 current_par_valid
[l_fb_info
->board_num
] = 1;
3043 *((struct pm3fb_par
*) par
) = *(l_fb_info
->current_par
);
3046 static void pm3fb_set_par(const void *par
, struct fb_info_gen
*info
)
3048 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
3052 *(l_fb_info
->current_par
) = *((struct pm3fb_par
*) par
);
3053 current_par_valid
[l_fb_info
->board_num
] = 1;
3055 pm3fb_write_mode(l_fb_info
);
3057 #ifdef PM3FB_USE_ACCEL
3058 pm3fb_init_engine(l_fb_info
);
3059 #endif /* PM3FB_USE_ACCEL */
3062 static void pm3fb_set_color(struct pm3fb_info
*l_fb_info
,
3063 unsigned char regno
, unsigned char r
,
3064 unsigned char g
, unsigned char b
)
3068 PM3_SLOW_WRITE_REG(PM3RD_PaletteWriteAddress
, regno
);
3069 PM3_SLOW_WRITE_REG(PM3RD_PaletteData
, r
);
3070 PM3_SLOW_WRITE_REG(PM3RD_PaletteData
, g
);
3071 PM3_SLOW_WRITE_REG(PM3RD_PaletteData
, b
);
3074 static int pm3fb_getcolreg(unsigned regno
, unsigned *red
, unsigned *green
,
3075 unsigned *blue
, unsigned *transp
,
3076 struct fb_info
*info
)
3078 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
3084 l_fb_info
->palette
[regno
].red
<< 8 | l_fb_info
->
3087 l_fb_info
->palette
[regno
].green
<< 8 | l_fb_info
->
3088 palette
[regno
].green
;
3090 l_fb_info
->palette
[regno
].blue
<< 8 | l_fb_info
->
3091 palette
[regno
].blue
;
3093 l_fb_info
->palette
[regno
].transp
<< 8 | l_fb_info
->
3094 palette
[regno
].transp
;
3096 return (regno
> 255);
3099 static int pm3fb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
3100 unsigned blue
, unsigned transp
,
3101 struct fb_info
*info
)
3103 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
3108 switch (l_fb_info
->current_par
->depth
) {
3109 #ifdef FBCON_HAS_CFB8
3113 #ifdef FBCON_HAS_CFB16
3115 l_fb_info
->cmap
.cmap12
[regno
] =
3116 (((u32
) red
& 0xf000) >> 4) |
3117 (((u32
) green
& 0xf000) >> 8) |
3118 (((u32
) blue
& 0xf000) >> 12);
3122 l_fb_info
->cmap
.cmap15
[regno
] =
3123 (((u32
) red
& 0xf800) >> 1) |
3124 (((u32
) green
& 0xf800) >> 6) |
3125 (((u32
) blue
& 0xf800) >> 11);
3129 l_fb_info
->cmap
.cmap16
[regno
] =
3130 ((u32
) red
& 0xf800) |
3131 (((u32
) green
& 0xfc00) >> 5) |
3132 (((u32
) blue
& 0xf800) >> 11);
3135 #ifdef FBCON_HAS_CFB32
3137 l_fb_info
->cmap
.cmap32
[regno
] =
3138 (((u32
) transp
& 0xff00) << 16) |
3139 (((u32
) red
& 0xff00) << 8) |
3140 (((u32
) green
& 0xff00)) |
3141 (((u32
) blue
& 0xff00) >> 8);
3145 DPRINTK(1, "bad depth %u\n",
3146 l_fb_info
->current_par
->depth
);
3151 l_fb_info
->palette
[regno
].red
= red
>> 8;
3152 l_fb_info
->palette
[regno
].green
= green
>> 8;
3153 l_fb_info
->palette
[regno
].blue
= blue
>> 8;
3154 l_fb_info
->palette
[regno
].transp
= transp
>> 8;
3155 if (l_fb_info
->current_par
->depth
== 8)
3156 pm3fb_set_color(l_fb_info
, regno
, red
>> 8,
3157 green
>> 8, blue
>> 8);
3159 return (regno
> 255);
3162 static int pm3fb_blank(int blank_mode
, struct fb_info_gen
*info
)
3164 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
3169 if (!current_par_valid
[l_fb_info
->board_num
])
3172 video
= l_fb_info
->current_par
->video
;
3175 * Oxygen VX1 - it appears that setting PM3VideoControl and
3176 * then PM3RD_SyncControl to the same SYNC settings undoes
3177 * any net change - they seem to xor together. Only set the
3178 * sync options in PM3RD_SyncControl. --rmk
3180 video
&= ~(PM3VideoControl_HSYNC_MASK
|
3181 PM3VideoControl_VSYNC_MASK
);
3182 video
|= PM3VideoControl_HSYNC_ACTIVE_HIGH
|
3183 PM3VideoControl_VSYNC_ACTIVE_HIGH
;
3185 if (blank_mode
> 0) {
3186 switch (blank_mode
- 1) {
3188 case VESA_NO_BLANKING
: /* FIXME */
3189 video
= video
& ~(PM3VideoControl_ENABLE
);
3192 case VESA_HSYNC_SUSPEND
:
3193 video
= video
& ~(PM3VideoControl_HSYNC_MASK
|
3194 PM3VideoControl_BLANK_ACTIVE_LOW
);
3196 case VESA_VSYNC_SUSPEND
:
3197 video
= video
& ~(PM3VideoControl_VSYNC_MASK
|
3198 PM3VideoControl_BLANK_ACTIVE_LOW
);
3200 case VESA_POWERDOWN
:
3201 video
= video
& ~(PM3VideoControl_HSYNC_MASK
|
3202 PM3VideoControl_VSYNC_MASK
|
3203 PM3VideoControl_BLANK_ACTIVE_LOW
);
3206 DPRINTK(1, "Unsupported blanking %d\n",
3213 PM3_SLOW_WRITE_REG(PM3VideoControl
, video
);
3218 static void pm3fb_set_disp(const void *par
, struct display
*disp
,
3219 struct fb_info_gen
*info
)
3221 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
3222 struct pm3fb_par
*p
= (struct pm3fb_par
*) par
;
3227 local_irq_save(flags
);
3228 info
->info
.screen_base
= l_fb_info
->v_fb
;
3230 #ifdef FBCON_HAS_CFB8
3232 #ifdef PM3FB_USE_ACCEL
3233 if (!(noaccel
[l_fb_info
->board_num
]))
3234 disp
->dispsw
= &pm3fb_cfb8
;
3236 #endif /* PM3FB_USE_ACCEL */
3237 disp
->dispsw
= &fbcon_cfb8
;
3240 #ifdef FBCON_HAS_CFB16
3242 #ifdef PM3FB_USE_ACCEL
3243 if (!(noaccel
[l_fb_info
->board_num
]))
3244 disp
->dispsw
= &pm3fb_cfb16
;
3246 #endif /* PM3FB_USE_ACCEL */
3247 disp
->dispsw
= &fbcon_cfb16
;
3248 disp
->dispsw_data
= l_fb_info
->cmap
.cmap12
;
3251 #ifdef PM3FB_USE_ACCEL
3252 if (!(noaccel
[l_fb_info
->board_num
]))
3253 disp
->dispsw
= &pm3fb_cfb16
;
3255 #endif /* PM3FB_USE_ACCEL */
3256 disp
->dispsw
= &fbcon_cfb16
;
3257 disp
->dispsw_data
= l_fb_info
->cmap
.cmap15
;
3260 #ifdef PM3FB_USE_ACCEL
3261 if (!(noaccel
[l_fb_info
->board_num
]))
3262 disp
->dispsw
= &pm3fb_cfb16
;
3264 #endif /* PM3FB_USE_ACCEL */
3265 disp
->dispsw
= &fbcon_cfb16
;
3266 disp
->dispsw_data
= l_fb_info
->cmap
.cmap16
;
3269 #ifdef FBCON_HAS_CFB32
3271 #ifdef PM3FB_USE_ACCEL
3272 if (!(noaccel
[l_fb_info
->board_num
]))
3273 disp
->dispsw
= &pm3fb_cfb32
;
3275 #endif /* PM3FB_USE_ACCEL */
3276 disp
->dispsw
= &fbcon_cfb32
;
3277 disp
->dispsw_data
= l_fb_info
->cmap
.cmap32
;
3279 #endif /* FBCON_HAS_CFB32 */
3281 disp
->dispsw
= &fbcon_dummy
;
3282 DPRINTK(1, "Invalid depth, using fbcon_dummy\n");
3285 local_irq_restore(flags
);
3289 static void pm3fb_detect(void)
3291 struct pci_dev
*dev_array
[PM3_MAX_BOARD
];
3292 struct pci_dev
*dev
= NULL
;
3293 struct pm3fb_info
*l_fb_info
= &(fb_info
[0]);
3294 unsigned long i
, j
, done
;
3298 for (i
= 0; i
< PM3_MAX_BOARD
; i
++) {
3299 dev_array
[i
] = NULL
;
3300 fb_info
[i
].dev
= NULL
;
3304 pci_find_device(PCI_VENDOR_ID_3DLABS
,
3305 PCI_DEVICE_ID_3DLABS_PERMEDIA3
, dev
);
3307 for (i
= 0; ((i
< PM3_MAX_BOARD
) && dev
); i
++) {
3310 pci_find_device(PCI_VENDOR_ID_3DLABS
,
3311 PCI_DEVICE_ID_3DLABS_PERMEDIA3
, dev
);
3314 if (dev
) { /* more than PM3_MAX_BOARD */
3315 printk(KERN_WARNING
"pm3fb: Warning: more than %d boards found\n",
3319 if (!dev_array
[0]) { /* not a single board, abort */
3323 /* allocate user-defined boards */
3324 for (i
= 0; i
< PM3_MAX_BOARD
; i
++) {
3325 if ((bus
[i
] >= 0) && (slot
[i
] >= 0) && (func
[i
] >= 0)) {
3326 for (j
= 0; j
< PM3_MAX_BOARD
; j
++) {
3327 if ((dev_array
[j
] != NULL
) &&
3328 (dev_array
[j
]->bus
->number
== bus
[i
])
3329 && (PCI_SLOT(dev_array
[j
]->devfn
) ==
3331 && (PCI_FUNC(dev_array
[j
]->devfn
) ==
3333 fb_info
[i
].dev
= dev_array
[j
];
3334 dev_array
[j
] = NULL
;
3339 /* allocate remaining boards */
3340 for (i
= 0; i
< PM3_MAX_BOARD
; i
++) {
3341 if (fb_info
[i
].dev
== NULL
) {
3343 for (j
= 0; ((j
< PM3_MAX_BOARD
) && (!done
)); j
++) {
3344 if (dev_array
[j
] != NULL
) {
3345 fb_info
[i
].dev
= dev_array
[j
];
3346 dev_array
[j
] = NULL
;
3353 /* at that point, all PCI Permedia3 are detected and allocated */
3354 /* now, initialize... or not */
3355 for (i
= 0; i
< PM3_MAX_BOARD
; i
++) {
3356 l_fb_info
= &(fb_info
[i
]);
3357 if ((l_fb_info
->dev
) && (!disable
[i
])) { /* PCI device was found and not disabled by user */
3359 "found @%lx Vendor %lx Device %lx ; base @ : %lx - %lx - %lx - %lx - %lx - %lx, irq %ld\n",
3360 (unsigned long) l_fb_info
->dev
,
3361 (unsigned long) l_fb_info
->dev
->vendor
,
3362 (unsigned long) l_fb_info
->dev
->device
,
3364 pci_resource_start(l_fb_info
->dev
, 0),
3366 pci_resource_start(l_fb_info
->dev
, 1),
3368 pci_resource_start(l_fb_info
->dev
, 2),
3370 pci_resource_start(l_fb_info
->dev
, 3),
3372 pci_resource_start(l_fb_info
->dev
, 4),
3374 pci_resource_start(l_fb_info
->dev
, 5),
3375 (unsigned long) l_fb_info
->dev
->irq
);
3377 l_fb_info
->pIOBase
=
3379 pci_resource_start(l_fb_info
->dev
, 0);
3381 l_fb_info
->pIOBase
+= PM3_REGS_SIZE
;
3383 l_fb_info
->vIOBase
= (unsigned char *) -1;
3386 pci_resource_start(l_fb_info
->dev
, 1);
3387 l_fb_info
->v_fb
= (unsigned char *) -1;
3389 if (!request_mem_region
3390 ((unsigned long)l_fb_info
->p_fb
, 64 * 1024 * 1024, /* request full aperture size */
3393 (KERN_ERR
"pm3fb: Error: couldn't request framebuffer memory, board #%ld\n",
3394 l_fb_info
->board_num
);
3397 if (!request_mem_region
3398 ((unsigned long)l_fb_info
->pIOBase
, PM3_REGS_SIZE
,
3399 "pm3fb I/O regs")) {
3401 (KERN_ERR
"pm3fb: Error: couldn't request IObase memory, board #%ld\n",
3402 l_fb_info
->board_num
);
3405 if (forcesize
[l_fb_info
->board_num
])
3406 l_fb_info
->fb_size
= forcesize
[l_fb_info
->board_num
];
3408 l_fb_info
->fb_size
=
3409 pm3fb_size_memory(l_fb_info
);
3410 if (l_fb_info
->fb_size
) {
3411 (void) pci_enable_device(l_fb_info
->dev
);
3412 pm3fb_common_init(l_fb_info
);
3414 printk(KERN_ERR
"pm3fb: memory problem, not enabling board #%ld\n", l_fb_info
->board_num
);
3419 static int pm3fb_pan_display(const struct fb_var_screeninfo
*var
,
3420 struct fb_info_gen
*info
)
3422 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
3426 if (!current_par_valid
[l_fb_info
->board_num
])
3429 l_fb_info
->current_par
->base
= /* in 128 bits chunk - i.e. AFTER Shiftbpp */
3430 pm3fb_Shiftbpp(l_fb_info
,
3431 l_fb_info
->current_par
->depth
,
3432 (var
->yoffset
* l_fb_info
->current_par
->width
) +
3434 PM3_SLOW_WRITE_REG(PM3ScreenBase
, l_fb_info
->current_par
->base
);
3438 static int pm3fb_ioctl(struct fb_info
*info
, u_int cmd
, u_long arg
)
3440 struct pm3fb_info
*l_fb_info
= (struct pm3fb_info
*) info
;
3442 #ifdef PM3FB_MASTER_DEBUG
3444 #endif /* PM3FB_MASTER_DEBUG */
3448 #ifdef PM3FB_MASTER_DEBUG
3449 case PM3FBIO_CLEARMEMORY
:
3450 if (copy_from_user(&cm
, (void *)arg
, sizeof(u32
)))
3452 pm3fb_clear_memory(l_fb_info
, cm
);
3456 case PM3FBIO_CLEARCMAP
:
3457 if (copy_from_user(cc
, (void*)arg
, 3 * sizeof(char)))
3459 pm3fb_clear_colormap(l_fb_info
, cc
[0], cc
[1], cc
[2]);
3462 #endif /* PM3FB_MASTER_DEBUG */
3464 case PM3FBIO_RESETCHIP
:
3466 PM3_SLOW_WRITE_REG(PM3ResetStatus
, 1);
3467 for (i
= 0 ; (i
< 10000) && cm
; i
++)
3470 cm
= PM3_READ_REG(PM3ResetStatus
);
3474 printk(KERN_ERR
"pm3fb: chip reset failed with status 0x%x\n", cm
);
3477 /* first thing first, reload memory timings */
3478 pm3fb_write_memory_timings(l_fb_info
);
3479 #ifdef PM3FB_USE_ACCEL
3480 pm3fb_init_engine(l_fb_info
);
3481 #endif /* PM3FB_USE_ACCEL */
3482 pm3fb_write_mode(l_fb_info
);
3487 DPRINTK(2, "unknown ioctl: %d (%x)\n", cmd
, cmd
);
3492 /* ****************************************** */
3493 /* ***** standard FB API init functions ***** */
3494 /* ****************************************** */
3496 int __init
pm3fb_setup(char *options
)
3498 long opsi
= strlen(options
);
3502 memcpy(g_options
, options
,
3504 PM3_OPTIONS_SIZE
) ? PM3_OPTIONS_SIZE
: (opsi
+ 1));
3505 g_options
[PM3_OPTIONS_SIZE
- 1] = 0;
3510 int __init
pm3fb_init(void)
3514 DPRINTK(2, "This is pm3fb.c, CVS version: $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $");
3516 pm3fb_real_setup(g_options
);
3520 if (!fb_info
[0].dev
) { /* not even one board ??? */
3521 DPRINTK(1, "No PCI Permedia3 board detected\n");
3526 /* ************************* */
3527 /* **** Module support ***** */
3528 /* ************************* */
3531 MODULE_AUTHOR("Romain Dolbeau");
3532 MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
3533 static char *mode
[PM3_MAX_BOARD
];
3534 module_param_array(mode
, charp
, NULL
, 0);
3535 MODULE_PARM_DESC(mode
,"video mode");
3536 module_param_array(disable
, short, NULL
, 0);
3537 MODULE_PARM_DESC(disable
,"disable board");
3538 static short off
[PM3_MAX_BOARD
];
3539 module_param_array(off
, short, NULL
, 0);
3540 MODULE_PARM_DESC(off
,"disable board");
3541 static char *pciid
[PM3_MAX_BOARD
];
3542 module_param_array(pciid
, charp
, NULL
, 0);
3543 MODULE_PARM_DESC(pciid
,"board PCI Id");
3544 module_param_array(noaccel
, short, NULL
, 0);
3545 MODULE_PARM_DESC(noaccel
,"disable accel");
3546 static char *font
[PM3_MAX_BOARD
];
3547 module_param_array(font
, charp
, NULL
, 0);
3548 MODULE_PARM_DESC(font
,"choose font");
3549 module_param(depth
, short, NULL
, 0);
3550 MODULE_PARM_DESC(depth
,"boot-time depth");
3551 module_param(printtimings
, short, NULL
, 0);
3552 MODULE_PARM_DESC(printtimings
, "print the memory timings of the card(s)");
3553 module_param(forcesize
, short, NULL
, 0);
3554 MODULE_PARM_DESC(forcesize
, "force specified memory size");
3556 MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards")
3557 MODULE_GENERIC_TABLE(gtype,name)
3558 MODULE_DEVICE_TABLE(type,name)
3561 void pm3fb_build_options(void)
3566 strcpy(g_options
, "pm3fb");
3567 for (i
= 0; i
< PM3_MAX_BOARD
; i
++)
3571 sprintf(ts
, ",mode:%d:%s", i
, mode
[i
]);
3572 strncat(g_options
, ts
, PM3_OPTIONS_SIZE
- strlen(g_options
));
3574 if (disable
[i
] || off
[i
])
3576 sprintf(ts
, ",disable:%d:", i
);
3577 strncat(g_options
, ts
, PM3_OPTIONS_SIZE
- strlen(g_options
));
3581 sprintf(ts
, ",pciid:%d:%s", i
, pciid
[i
]);
3582 strncat(g_options
, ts
, PM3_OPTIONS_SIZE
- strlen(g_options
));
3586 sprintf(ts
, ",noaccel:%d:", i
);
3587 strncat(g_options
, ts
, PM3_OPTIONS_SIZE
- strlen(g_options
));
3591 sprintf(ts
, ",font:%d:%s", i
, font
[i
]);
3592 strncat(g_options
, ts
, PM3_OPTIONS_SIZE
- strlen(g_options
));
3596 sprintf(ts
, ",depth:%d:%d", i
, depth
[i
]);
3597 strncat(g_options
, ts
, PM3_OPTIONS_SIZE
- strlen(g_options
));
3600 g_options
[PM3_OPTIONS_SIZE
- 1] = '\0';
3601 DPRINTK(1, "pm3fb use options: %s\n", g_options
);
3604 int init_module(void)
3608 pm3fb_build_options();
3615 void cleanup_module(void)
3620 struct pm3fb_info
*l_fb_info
;
3621 for (i
= 0; i
< PM3_MAX_BOARD
; i
++) {
3622 l_fb_info
= &(fb_info
[i
]);
3623 if ((l_fb_info
->dev
!= NULL
)
3624 && (!(disable
[l_fb_info
->board_num
]))) {
3625 if (l_fb_info
->vIOBase
!=
3626 (unsigned char *) -1) {
3627 pm3fb_unmapIO(l_fb_info
);
3628 release_mem_region(l_fb_info
->p_fb
,
3631 release_mem_region(l_fb_info
->
3635 unregister_framebuffer(&l_fb_info
->gen
.