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 * Russel 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: /cvshome/samwise/ppclinux/drivers/video/pm3fb.c,v 1.1.1.1 2005/04/11 02:50:42 jack 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/config.h>
56 #include <linux/module.h>
57 #include <linux/version.h>
58 #include <linux/kernel.h>
59 #include <linux/errno.h>
60 #include <linux/string.h>
62 #include <linux/tty.h>
63 #include <linux/slab.h>
64 #include <linux/vmalloc.h>
65 #include <linux/delay.h>
66 #include <linux/interrupt.h>
68 #include <linux/init.h>
69 #include <linux/pci.h>
70 #include <linux/ioport.h>
72 #include <video/fbcon.h>
73 #include <video/fbcon-mfb.h>
74 #include <video/fbcon-cfb2.h>
75 #include <video/fbcon-cfb4.h>
76 #include <video/fbcon-cfb8.h>
77 #include <video/fbcon-cfb16.h>
78 #include <video/fbcon-cfb24.h>
79 #include <video/fbcon-cfb32.h>
82 #include <asm/uaccess.h>
90 /* ************************************* */
91 /* ***** The various "global" data ***** */
92 /* ************************************* */
94 /* those will need a rework for multiple board support */
96 static const char permedia3_name[16] = "Permedia3";
98 /* the fb_par struct, mandatory */
100 u32 pixclock; /* pixclock in KHz */
102 u32 width; /* width of virtual screen */
103 u32 height; /* height of virtual screen */
105 u32 hsstart; /* horiz. sync start */
106 u32 hsend; /* horiz. sync end */
107 u32 hbend; /* horiz. blank end (also gate end) */
108 u32 htotal; /* total width (w/ sync & blank) */
110 u32 vsstart; /* vert. sync start */
111 u32 vsend; /* vert. sync end */
112 u32 vbend; /* vert. blank end */
113 u32 vtotal; /* total height (w/ sync & blank) */
115 u32 stride; /* screen stride */
116 u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */
117 /* NOTE : unlike other pm3 stuff above, stored *after* shiftbpp. don't ask */
118 u32 depth; /* screen depth (8, 12, 15, 16 or 32) */
119 u32 video; /* video control (hsync,vsync) */
126 unsigned long timings;
127 unsigned long control;
128 unsigned long refresh;
129 unsigned long powerdown;
131 typedef enum pm3fb_timing_result { pm3fb_timing_ok, pm3fb_timing_problem, pm3fb_timing_retry } pm3fb_timing_result;
132 #define PM3FB_UNKNOWN_TIMING_VALUE ((unsigned long)-1)
133 #define PM3FB_UNKNOWN_TIMINGS { PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE }
135 /* the fb_info struct, mandatory */
137 struct fb_info_gen gen;
138 unsigned long board_num; /* internal board number */
139 unsigned long use_current;
140 struct pm3fb_par *current_par;
141 struct pci_dev *dev; /* PCI device */
143 struct device_node *dn; /* OF node for the PCI device */
144 #endif /* SUPPORT_FB_OF */
145 unsigned long board_type; /* index in the cardbase */
146 unsigned char *fb_base; /* framebuffer memory base */
147 u32 fb_size; /* framebuffer memory size */
148 unsigned char *p_fb; /* physical address of frame buffer */
149 unsigned char *v_fb; /* virtual address of frame buffer */
150 unsigned char *pIOBase; /* physical address of registers region, must be rg_base or rg_base+PM2_REGS_SIZE depending on the host endianness */
151 unsigned char *vIOBase; /* address of registers after ioremap() */
159 #ifdef FBCON_HAS_CFB16
160 u16 cmap12[16]; /* RGBA 4444 */
161 u16 cmap15[16]; /* RGBA 5551 */
162 u16 cmap16[16]; /* RGBA 5650 */
164 #ifdef FBCON_HAS_CFB32
168 struct pm3fb_timings memt;
171 /* regular resolution database*/
174 struct pm3fb_par user_mode;
175 } mode_base[] __initdata = {
178 49500, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625,
180 PM3VideoControl_ENABLE |
181 PM3VideoControl_HSYNC_ACTIVE_HIGH
183 PM3VideoControl_VSYNC_ACTIVE_HIGH
184 | PM3VideoControl_PIXELSIZE_8BIT}}, {
186 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
188 PM3VideoControl_ENABLE |
189 PM3VideoControl_HSYNC_ACTIVE_HIGH
191 PM3VideoControl_VSYNC_ACTIVE_HIGH
192 | PM3VideoControl_PIXELSIZE_8BIT}}, {
194 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
196 PM3VideoControl_ENABLE |
197 PM3VideoControl_HSYNC_ACTIVE_HIGH
199 PM3VideoControl_VSYNC_ACTIVE_HIGH
200 | PM3VideoControl_PIXELSIZE_32BIT}},
201 /* Generated mode : "1600x1024", for the SGI 1600SW flat panel*/
204 108000, 1600, 1024, 16, 56, 104, 1704, 3, 6, 32,
206 PM3VideoControl_ENABLE|
207 PM3VideoControl_HSYNC_ACTIVE_LOW|PM3VideoControl_VSYNC_ACTIVE_LOW|
208 PM3VideoControl_PIXELSIZE_32BIT}},
209 /* ##### auto-generated mode, by fbtimings2pm3 */
210 /* Generated mode : "640x480-60" */
213 25174, 640, 480, 16, 112, 160, 800, 10, 12, 45,
215 PM3VideoControl_ENABLE |
216 PM3VideoControl_HSYNC_ACTIVE_LOW
218 PM3VideoControl_VSYNC_ACTIVE_LOW
219 | PM3VideoControl_PIXELSIZE_8BIT}},
220 /* Generated mode : "640x480-72" */
223 31199, 640, 480, 24, 64, 192, 832, 9, 12, 40, 520,
225 PM3VideoControl_ENABLE |
226 PM3VideoControl_HSYNC_ACTIVE_LOW
228 PM3VideoControl_VSYNC_ACTIVE_LOW
229 | PM3VideoControl_PIXELSIZE_8BIT}},
230 /* Generated mode : "640x480-75" */
233 31499, 640, 480, 16, 80, 200, 840, 1, 4, 20, 500,
235 PM3VideoControl_ENABLE |
236 PM3VideoControl_HSYNC_ACTIVE_LOW
238 PM3VideoControl_VSYNC_ACTIVE_LOW
239 | PM3VideoControl_PIXELSIZE_8BIT}},
240 /* Generated mode : "640x480-90" */
243 39909, 640, 480, 32, 72, 192, 832, 25, 39, 53, 533,
245 PM3VideoControl_ENABLE |
246 PM3VideoControl_HSYNC_ACTIVE_LOW
248 PM3VideoControl_VSYNC_ACTIVE_LOW
249 | PM3VideoControl_PIXELSIZE_8BIT}},
250 /* Generated mode : "640x480-100" */
253 44899, 640, 480, 32, 160, 208, 848, 22, 34, 51,
255 PM3VideoControl_ENABLE |
256 PM3VideoControl_HSYNC_ACTIVE_LOW
258 PM3VideoControl_VSYNC_ACTIVE_LOW
259 | PM3VideoControl_PIXELSIZE_8BIT}},
260 /* Generated mode : "800x600-48-lace" */
261 /* INTERLACED NOT SUPPORTED
262 {"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}},
263 INTERLACED NOT SUPPORTED */
264 /* Generated mode : "800x600-56" */
267 35999, 800, 600, 24, 96, 224, 1024, 1, 3, 25, 625,
269 PM3VideoControl_ENABLE |
270 PM3VideoControl_HSYNC_ACTIVE_HIGH
272 PM3VideoControl_VSYNC_ACTIVE_HIGH
273 | PM3VideoControl_PIXELSIZE_8BIT}},
274 /* Generated mode : "800x600-60" */
277 40000, 800, 600, 40, 168, 256, 1056, 1, 5, 28, 628,
279 PM3VideoControl_ENABLE |
280 PM3VideoControl_HSYNC_ACTIVE_HIGH
282 PM3VideoControl_VSYNC_ACTIVE_HIGH
283 | PM3VideoControl_PIXELSIZE_8BIT}},
284 /* Generated mode : "800x600-70" */
287 44899, 800, 600, 24, 168, 208, 1008, 9, 21, 36,
289 PM3VideoControl_ENABLE |
290 PM3VideoControl_HSYNC_ACTIVE_HIGH
292 PM3VideoControl_VSYNC_ACTIVE_LOW
293 | PM3VideoControl_PIXELSIZE_8BIT}},
294 /* Generated mode : "800x600-72" */
297 50000, 800, 600, 56, 176, 240, 1040, 37, 43, 66,
299 PM3VideoControl_ENABLE |
300 PM3VideoControl_HSYNC_ACTIVE_HIGH
302 PM3VideoControl_VSYNC_ACTIVE_HIGH
303 | PM3VideoControl_PIXELSIZE_8BIT}},
304 /* Generated mode : "800x600-75" */
307 49497, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625,
309 PM3VideoControl_ENABLE |
310 PM3VideoControl_HSYNC_ACTIVE_HIGH
312 PM3VideoControl_VSYNC_ACTIVE_HIGH
313 | PM3VideoControl_PIXELSIZE_8BIT}},
314 /* Generated mode : "800x600-90" */
317 56637, 800, 600, 8, 72, 192, 992, 8, 19, 35, 635,
319 PM3VideoControl_ENABLE |
320 PM3VideoControl_HSYNC_ACTIVE_HIGH
322 PM3VideoControl_VSYNC_ACTIVE_HIGH
323 | PM3VideoControl_PIXELSIZE_8BIT}},
324 /* Generated mode : "800x600-100", from /etc/fb.modes */
325 /* DISABLED, hsstart == 0
328 67499, 800, 600, 0, 64, 280, 1080, 7, 11, 25, 625,
330 PM3VideoControl_ENABLE |
331 PM3VideoControl_HSYNC_ACTIVE_HIGH
333 PM3VideoControl_VSYNC_ACTIVE_HIGH
334 | PM3VideoControl_PIXELSIZE_8BIT}},
336 /* Generated mode : "800x600-100", from ??? */
339 69650, 800, 600, 64, 128, 288, 1088, 4, 10, 40, 640, 800, 0, 8,
340 PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW|
341 PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}},
342 /* Generated mode : "1024x768-43-lace" */
343 /* INTERLACED NOT SUPPORTED
344 {"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}},
345 INTERLACED NOT SUPPORTED */
346 /* Generated mode : "1024x768-60" */
349 64998, 1024, 768, 24, 160, 320, 1344, 3, 9, 38,
351 PM3VideoControl_ENABLE |
352 PM3VideoControl_HSYNC_ACTIVE_LOW
354 PM3VideoControl_VSYNC_ACTIVE_LOW
355 | PM3VideoControl_PIXELSIZE_8BIT}},
356 /* Generated mode : "1024x768-70" */
359 74996, 1024, 768, 24, 160, 304, 1328, 3, 9, 38,
361 PM3VideoControl_ENABLE |
362 PM3VideoControl_HSYNC_ACTIVE_LOW
364 PM3VideoControl_VSYNC_ACTIVE_LOW
365 | PM3VideoControl_PIXELSIZE_8BIT}},
366 /* Generated mode : "1024x768-72" */
369 74996, 10224, 768, 24, 160, 264, 10488, 3, 9, 38,
371 PM3VideoControl_ENABLE |
372 PM3VideoControl_HSYNC_ACTIVE_LOW
374 PM3VideoControl_VSYNC_ACTIVE_LOW
375 | PM3VideoControl_PIXELSIZE_8BIT}},
376 /* Generated mode : "1024x768-75" */
379 78746, 1024, 768, 16, 112, 288, 1312, 1, 4, 32,
381 PM3VideoControl_ENABLE |
382 PM3VideoControl_HSYNC_ACTIVE_HIGH
384 PM3VideoControl_VSYNC_ACTIVE_HIGH
385 | PM3VideoControl_PIXELSIZE_8BIT}},
386 /* Generated mode : "1024x768-90" */
389 100000, 1024, 768, 0, 96, 288, 1312, 21, 36, 77,
391 PM3VideoControl_ENABLE |
392 PM3VideoControl_HSYNC_ACTIVE_LOW
394 PM3VideoControl_VSYNC_ACTIVE_LOW
395 | PM3VideoControl_PIXELSIZE_8BIT}},
396 /* Generated mode : "1024x768-100", from /etc/fb.modes */
397 /* DISABLED, vsstart == 0
400 109998, 1024, 768, 0, 88, 368, 1392, 0, 8, 24, 792,
402 PM3VideoControl_ENABLE |
403 PM3VideoControl_HSYNC_ACTIVE_LOW
405 PM3VideoControl_VSYNC_ACTIVE_LOW
406 | PM3VideoControl_PIXELSIZE_8BIT}},
408 /* Generated mode : "1024x768-100", from ??? */
411 115500, 1024, 768, 32, 224, 416, 1440, 3, 13, 34, 802, 1024, 0, 8,
412 PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW|
413 PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}},
414 /* Generated mode : "1152x864-43-lace" */
415 /* INTERLACED NOT SUPPORTED
416 {"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}},
417 INTERLACED NOT SUPPORTED */
418 /* Generated mode : "1152x864-47-lace" */
419 /* INTERLACED NOT SUPPORTED
420 {"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}},
421 INTERLACED NOT SUPPORTED */
422 /* Generated mode : "1152x864-60" */
425 80000, 1152, 864, 64, 176, 304, 1456, 6, 11, 52,
427 PM3VideoControl_ENABLE |
428 PM3VideoControl_HSYNC_ACTIVE_HIGH
430 PM3VideoControl_VSYNC_ACTIVE_HIGH
431 | PM3VideoControl_PIXELSIZE_8BIT}},
432 /* Generated mode : "1152x864-70" */
435 100000, 1152, 864, 40, 192, 360, 1512, 13, 24, 81,
437 PM3VideoControl_ENABLE |
438 PM3VideoControl_HSYNC_ACTIVE_HIGH
440 PM3VideoControl_VSYNC_ACTIVE_HIGH
441 | PM3VideoControl_PIXELSIZE_8BIT}},
442 /* Generated mode : "1152x864-75" */
445 109998, 1152, 864, 24, 168, 312, 1464, 45, 53, 138,
447 PM3VideoControl_ENABLE |
448 PM3VideoControl_HSYNC_ACTIVE_HIGH
450 PM3VideoControl_VSYNC_ACTIVE_HIGH
451 | PM3VideoControl_PIXELSIZE_8BIT}},
452 /* Generated mode : "1152x864-80" */
455 109998, 1152, 864, 16, 128, 288, 1440, 30, 37, 94,
457 PM3VideoControl_ENABLE |
458 PM3VideoControl_HSYNC_ACTIVE_HIGH
460 PM3VideoControl_VSYNC_ACTIVE_HIGH
461 | PM3VideoControl_PIXELSIZE_8BIT}},
462 /* Generated mode : "1280x1024-43-lace" */
463 /* INTERLACED NOT SUPPORTED
464 {"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}},
465 INTERLACED NOT SUPPORTED */
466 /* Generated mode : "1280x1024-47-lace" */
467 /* INTERLACED NOT SUPPORTED
468 {"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}},
469 INTERLACED NOT SUPPORTED */
470 /* Generated mode : "1280x1024-60" */
473 107991, 1280, 1024, 48, 160, 408, 1688, 1, 4, 42,
475 PM3VideoControl_ENABLE |
476 PM3VideoControl_HSYNC_ACTIVE_HIGH
478 PM3VideoControl_VSYNC_ACTIVE_HIGH
479 | PM3VideoControl_PIXELSIZE_8BIT}},
480 /* Generated mode : "1280x1024-70" */
483 125992, 1280, 1024, 80, 192, 408, 1688, 1, 6, 42,
485 PM3VideoControl_ENABLE |
486 PM3VideoControl_HSYNC_ACTIVE_HIGH
488 PM3VideoControl_VSYNC_ACTIVE_HIGH
489 | PM3VideoControl_PIXELSIZE_8BIT}},
490 /* Generated mode : "1280x1024-74" */
493 134989, 1280, 1024, 32, 176, 432, 1712, 0, 30, 40,
495 PM3VideoControl_ENABLE |
496 PM3VideoControl_HSYNC_ACTIVE_HIGH
498 PM3VideoControl_VSYNC_ACTIVE_HIGH
499 | PM3VideoControl_PIXELSIZE_8BIT}},
500 /* Generated mode : "1280x1024-75" */
503 134989, 1280, 1024, 16, 160, 408, 1688, 1, 4, 42,
505 PM3VideoControl_ENABLE |
506 PM3VideoControl_HSYNC_ACTIVE_HIGH
508 PM3VideoControl_VSYNC_ACTIVE_HIGH
509 | PM3VideoControl_PIXELSIZE_8BIT}},
510 /* Generated mode : "1600x1200-60" */
513 155981, 1600, 1200, 32, 192, 448, 2048, 10, 18, 70,
515 PM3VideoControl_ENABLE |
516 PM3VideoControl_HSYNC_ACTIVE_LOW
518 PM3VideoControl_VSYNC_ACTIVE_LOW
519 | PM3VideoControl_PIXELSIZE_8BIT}},
520 /* Generated mode : "1600x1200-66" */
523 171998, 1600, 1200, 40, 176, 480, 2080, 3, 6, 53,
525 PM3VideoControl_ENABLE |
526 PM3VideoControl_HSYNC_ACTIVE_LOW
528 PM3VideoControl_VSYNC_ACTIVE_LOW
529 | PM3VideoControl_PIXELSIZE_8BIT}},
530 /* Generated mode : "1600x1200-76" */
533 197980, 1600, 1200, 40, 176, 480, 2080, 3, 8, 50,
535 PM3VideoControl_ENABLE |
536 PM3VideoControl_HSYNC_ACTIVE_LOW
538 PM3VideoControl_VSYNC_ACTIVE_LOW
539 | PM3VideoControl_PIXELSIZE_8BIT}},
540 /* ##### end of auto-generated mode */
545 /* more mandatory stuff (see skeletonfb.c + framebuffer driver HOWTO */
546 static struct pm3fb_info fb_info[PM3_MAX_BOARD];
547 static struct pm3fb_par current_par[PM3_MAX_BOARD];
548 static int current_par_valid[PM3_MAX_BOARD];
549 /* to allow explicit filtering of board */
550 short bus[PM3_MAX_BOARD];
551 short slot[PM3_MAX_BOARD];
552 short func[PM3_MAX_BOARD];
553 short disable[PM3_MAX_BOARD];
554 short noaccel[PM3_MAX_BOARD];
555 char fontn[PM3_MAX_BOARD][PM3_FONTNAME_SIZE];
556 short depth[PM3_MAX_BOARD];
557 short flatpanel[PM3_MAX_BOARD];
558 static struct display disp[PM3_MAX_BOARD];
559 static char g_options[PM3_OPTIONS_SIZE] __initdata = "pm3fb,dummy";
560 short printtimings = 0;
561 short forcesize[PM3_MAX_BOARD];
563 /* ********************* */
564 /* ***** prototype ***** */
565 /* ********************* */
567 static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info);
568 /* permedia3-specific */
569 static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info);
570 static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info);
571 static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info);
572 static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info,
574 static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */
575 unsigned long refclock, /* In kHz units */
576 unsigned char *prescale, /* ClkPreScale */
577 unsigned char *feedback, /* ClkFeedBackScale */
578 unsigned char *postscale
579 /* ClkPostScale */ );
580 static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc);
581 static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b);
582 static void pm3fb_common_init(struct pm3fb_info *l_fb_info);
583 static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info,
584 unsigned long depth, int v);
585 static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info,
586 unsigned long depth, int v);
587 static void pm3fb_mapIO(struct pm3fb_info *l_fb_info);
588 static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info);
589 #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
590 static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info);
592 static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info);
593 static void pm3fb_write_mode(struct pm3fb_info *l_fb_info);
594 static void pm3fb_read_mode(struct pm3fb_info *l_fb_info,
595 struct pm3fb_par *curpar);
596 static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info);
597 /* accelerated permedia3-specific */
598 #ifdef PM3FB_USE_ACCEL
599 static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info);
600 static void pm3fb_init_engine(struct pm3fb_info *l_fb_info);
601 #ifdef FBCON_HAS_CFB32
602 static void pm3fb_cfb32_clear(struct vc_data *conp,
604 int sy, int sx, int height, int width);
605 static void pm3fb_cfb32_clear_margins(struct vc_data *conp,
606 struct display *p, int bottom_only);
607 #endif /* FBCON_HAS_CFB32 */
608 #ifdef FBCON_HAS_CFB16
609 static void pm3fb_cfb16_clear(struct vc_data *conp,
611 int sy, int sx, int height, int width);
612 static void pm3fb_cfb16_clear_margins(struct vc_data *conp,
613 struct display *p, int bottom_only);
614 #endif /* FBCON_HAS_CFB16 */
615 #ifdef FBCON_HAS_CFB8
616 static void pm3fb_cfb8_clear(struct vc_data *conp,
618 int sy, int sx, int height, int width);
619 static void pm3fb_cfb8_clear_margins(struct vc_data *conp,
620 struct display *p, int bottom_only);
621 #endif /* FBCON_HAS_CFB8 */
622 #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
623 static void pm3fb_cfbX_bmove(struct display *p,
625 int dy, int dx, int height, int width);
626 static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p,
627 int c, int yy, int xx);
628 static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p,
629 const unsigned short *s, int count, int yy,
631 static void pm3fb_cfbX_revc(struct display *p, int xx, int yy);
632 #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
633 #endif /* PM3FB_USE_ACCEL */
635 static void pm3fb_mode_setup(char *mode, unsigned long board_num);
636 static void pm3fb_pciid_setup(char *pciid, unsigned long board_num);
637 static char *pm3fb_boardnum_setup(char *options, unsigned long *bn);
638 static void pm3fb_real_setup(char *options);
640 static int pm3fb_open(struct fb_info *info, int user);
641 static int pm3fb_release(struct fb_info *info, int user);
642 static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix,
643 const void *par, struct fb_info_gen *info);
644 static int pm3fb_decode_var(const struct fb_var_screeninfo *var,
645 void *par, struct fb_info_gen *info);
646 static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d);
647 static int pm3fb_encode_var(struct fb_var_screeninfo *var,
648 const void *par, struct fb_info_gen *info);
649 static void pm3fb_get_par(void *par, struct fb_info_gen *info);
650 static void pm3fb_set_par(const void *par, struct fb_info_gen *info);
651 static void pm3fb_set_color(struct pm3fb_info *l_fb_info,
652 unsigned char regno, unsigned char r,
653 unsigned char g, unsigned char b);
654 static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green,
655 unsigned *blue, unsigned *transp,
656 struct fb_info *info);
657 static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
658 unsigned blue, unsigned transp,
659 struct fb_info *info);
660 static int pm3fb_blank(int blank_mode, struct fb_info_gen *info);
661 static void pm3fb_set_disp(const void *par, struct display *disp,
662 struct fb_info_gen *info);
663 static void pm3fb_detect(void);
664 static int pm3fb_pan_display(const struct fb_var_screeninfo *var,
665 struct fb_info_gen *info);
666 static int pm3fb_ioctl(struct inode *inode, struct file *file,
667 u_int cmd, u_long arg, int con,
668 struct fb_info *info);
671 /* the struct that hold them together */
673 struct fbgen_hwswitch pm3fb_switch = {
674 pm3fb_detect, pm3fb_encode_fix, pm3fb_decode_var, pm3fb_encode_var,
675 pm3fb_get_par, pm3fb_set_par, pm3fb_getcolreg, pm3fb_setcolreg,
676 pm3fb_pan_display, pm3fb_blank, pm3fb_set_disp
679 static struct fb_ops pm3fb_ops = {
680 pm3fb_open, pm3fb_release,
681 fbgen_get_fix, fbgen_get_var, fbgen_set_var,
682 fbgen_get_cmap, fbgen_set_cmap, fbgen_pan_display, pm3fb_ioctl,
685 #endif /* KERNEL_2_2 */
686 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
687 struct fbgen_hwswitch pm3fb_switch = {
688 pm3fb_detect, pm3fb_encode_fix, pm3fb_decode_var, pm3fb_encode_var,
689 pm3fb_get_par, pm3fb_set_par, pm3fb_getcolreg, pm3fb_setcolreg,
690 pm3fb_pan_display, pm3fb_blank, pm3fb_set_disp
693 static struct fb_ops pm3fb_ops = {
695 pm3fb_open, pm3fb_release,
696 fbgen_get_fix, fbgen_get_var, fbgen_set_var,
697 fbgen_get_cmap, fbgen_set_cmap, fbgen_pan_display, pm3fb_ioctl, NULL, NULL
699 #endif /* KERNEL_2_4 or KERNEL_2_5 */
700 #ifdef PM3FB_USE_ACCEL
701 #ifdef FBCON_HAS_CFB32
702 static struct display_switch pm3fb_cfb32 = {
703 fbcon_cfb32_setup, pm3fb_cfbX_bmove, pm3fb_cfb32_clear,
704 pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc,
705 NULL /* cursor() */ , NULL /* set_font() */ ,
706 pm3fb_cfb32_clear_margins,
707 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
709 #endif /* FBCON_HAS_CFB32 */
710 #ifdef FBCON_HAS_CFB16
711 static struct display_switch pm3fb_cfb16 = {
712 fbcon_cfb16_setup, pm3fb_cfbX_bmove, pm3fb_cfb16_clear,
713 pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc,
714 NULL /* cursor() */ , NULL /* set_font() */ ,
715 pm3fb_cfb16_clear_margins,
716 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
718 #endif /* FBCON_HAS_CFB16 */
719 #ifdef FBCON_HAS_CFB8
720 static struct display_switch pm3fb_cfb8 = {
721 fbcon_cfb8_setup, pm3fb_cfbX_bmove, pm3fb_cfb8_clear,
722 pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc,
723 NULL /* cursor() */ , NULL /* set_font() */ ,
724 pm3fb_cfb8_clear_margins,
725 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
727 #endif /* FBCON_HAS_CFB8 */
728 #endif /* PM3FB_USE_ACCEL */
730 /* ****************************** */
731 /* ***** card-specific data ***** */
732 /* ****************************** */
733 struct pm3fb_card_timings {
734 unsigned long memsize; /* 0 for last value (i.e. default) */
735 struct pm3fb_timings memt;
738 static struct pm3fb_card_timings t_FormacProFormance3[] = {
739 { 16, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} },
740 { 0, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} } /* from 16 MB PF3 */
743 static struct pm3fb_card_timings t_AppianJeronimo2000[] = {
744 { 32, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} },
745 { 0, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} } /* from 32MB J2000 */
748 static struct pm3fb_card_timings t_3DLabsOxygenVX1[] = {
749 { 32, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} },
750 { 0, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} } /* from 32MB VX1 */
754 char cardname[32]; /* recognized card name */
755 u16 subvendor; /* subvendor of the card */
756 u16 subdevice; /* subdevice of the card */
757 u8 func; /* function of the card to which the extra init apply */
758 void (*specific_setup)(struct pm3fb_info *l_fb_info); /* card/func specific setup, done before _any_ FB access */
759 struct pm3fb_card_timings *c_memt; /* defauls timings for the boards */
761 { "Unknown Permedia3 board", 0xFFFF, 0xFFFF, 0xFF, NULL, NULL },
762 { "Appian Jeronimo 2000 head 1", 0x1097, 0x3d32, 1, NULL,
765 { "Appian Jeronimo 2000 head 2", 0x1097, 0x3d32, 2, pm3fb_j2000_setup,
768 { "Formac ProFormance 3", PCI_VENDOR_ID_3DLABS, 0x000a, 0, NULL, /* Formac use 3DLabs ID ?!? */
771 { "3DLabs Permedia3 Create!", PCI_VENDOR_ID_3DLABS, 0x0127, 0, NULL, NULL },
772 { "3DLabs Oxygen VX1 PCI", PCI_VENDOR_ID_3DLABS, 0x0121, 0, NULL,
775 { "3DLabs Oxygen VX1 AGP", PCI_VENDOR_ID_3DLABS, 0x0125, 0, NULL, NULL },
776 { "3DLabs Oxygen VX1-16 AGP", PCI_VENDOR_ID_3DLABS, 0x0140, 0, NULL, NULL },
777 { "3DLabs Oxygen VX1-1600SW PCI", PCI_VENDOR_ID_3DLABS, 0x0800, 0, NULL, NULL },
778 { "\0", 0x0, 0x0, 0, NULL, NULL }
781 /* ********************************** */
782 /* ***** card-specific function ***** */
783 /* ********************************** */
784 static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info)
785 { /* the appian j2000 require more initialization of the second head */
786 /* l_fb_info must point to the _second_ head of the J2000 */
790 l_fb_info->memt = t_AppianJeronimo2000[0].memt; /* 32 MB, first and only j2000 ? */
792 pm3fb_write_memory_timings(l_fb_info);
795 /* *************************************** */
796 /* ***** permedia3-specific function ***** */
797 /* *************************************** */
798 static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info)
800 l_fb_info->memt.caps = PM3_READ_REG(PM3LocalMemCaps);
801 l_fb_info->memt.timings = PM3_READ_REG(PM3LocalMemTimings);
802 l_fb_info->memt.control = PM3_READ_REG(PM3LocalMemControl);
803 l_fb_info->memt.refresh = PM3_READ_REG(PM3LocalMemRefresh);
804 l_fb_info->memt.powerdown = PM3_READ_REG(PM3LocalMemPowerDown);
806 if ((l_fb_info->memt.caps == PM3FB_UNKNOWN_TIMING_VALUE) ||
807 (l_fb_info->memt.timings == PM3FB_UNKNOWN_TIMING_VALUE) ||
808 (l_fb_info->memt.control == PM3FB_UNKNOWN_TIMING_VALUE) ||
809 (l_fb_info->memt.refresh == PM3FB_UNKNOWN_TIMING_VALUE) ||
810 (l_fb_info->memt.powerdown == PM3FB_UNKNOWN_TIMING_VALUE))
812 printk(KERN_ERR "pm3fb: invalid memory timings in permedia3 board #%ld\n", l_fb_info->board_num);
813 return(pm3fb_try_memory_timings(l_fb_info));
815 return(pm3fb_timing_ok);
818 static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info)
820 if (cardbase[l_fb_info->board_type].c_memt)
825 if ((cardbase[l_fb_info->board_type].c_memt[i].memsize == l_fb_info->fb_size)
826 || !(cardbase[l_fb_info->board_type].c_memt[i].memsize))
827 { /* will use the 0-sized timings by default */
829 l_fb_info->memt = cardbase[l_fb_info->board_type].c_memt[i].memt;
830 printk(KERN_WARNING "pm3fb: trying to use predefined memory timings for permedia3 board #%ld (%s, %ld MB)\n",
831 l_fb_info->board_num,
832 cardbase[l_fb_info->board_type].cardname,
833 cardbase[l_fb_info->board_type].c_memt[i].memsize);
834 pm3fb_write_memory_timings(l_fb_info);
835 return(pm3fb_timing_retry);
840 return(pm3fb_timing_problem);
841 return(pm3fb_timing_ok);
844 static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info)
846 unsigned char m, n, p;
847 unsigned long clockused;
849 PM3_SLOW_WRITE_REG(PM3LocalMemCaps, l_fb_info->memt.caps);
850 PM3_SLOW_WRITE_REG(PM3LocalMemTimings, l_fb_info->memt.timings);
851 PM3_SLOW_WRITE_REG(PM3LocalMemControl, l_fb_info->memt.control);
852 PM3_SLOW_WRITE_REG(PM3LocalMemRefresh, l_fb_info->memt.refresh);
853 PM3_SLOW_WRITE_REG(PM3LocalMemPowerDown, l_fb_info->memt.powerdown);
856 pm3fb_CalculateClock(l_fb_info, 2 * 105000, PM3_REF_CLOCK, &m,
859 PM3_WRITE_DAC_REG(PM3RD_KClkPreScale, m);
860 PM3_WRITE_DAC_REG(PM3RD_KClkFeedbackScale, n);
861 PM3_WRITE_DAC_REG(PM3RD_KClkPostScale, p);
862 PM3_WRITE_DAC_REG(PM3RD_KClkControl,
863 PM3RD_KClkControl_STATE_RUN |
864 PM3RD_KClkControl_SOURCE_PLL |
865 PM3RD_KClkControl_ENABLE);
866 PM3_WRITE_DAC_REG(PM3RD_MClkControl,
867 PM3RD_MClkControl_STATE_RUN |
868 PM3RD_MClkControl_SOURCE_KCLK |
869 PM3RD_MClkControl_ENABLE);
870 PM3_WRITE_DAC_REG(PM3RD_SClkControl,
871 PM3RD_SClkControl_STATE_RUN |
872 PM3RD_SClkControl_SOURCE_PCLK |
873 PM3RD_SClkControl_ENABLE);
876 static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info,
879 DASSERT((l_fb_info->vIOBase != (unsigned char *) (-1)),
880 "l_fb_info->vIOBase mapped in read dac reg\n");
883 return (PM3_READ_REG(PM3RD_IndexedData));
886 /* Calculating various clock parameter */
887 static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */
888 unsigned long refclock, /* In kHz units */
889 unsigned char *prescale, /* ClkPreScale */
890 unsigned char *feedback, /* ClkFeedBackScale */
891 unsigned char *postscale
897 unsigned long actualclock = 0;
901 for (f = 1; f < 256; f++) {
902 for (pre = 1; pre < 256; pre++) {
903 for (post = 0; post < 5; post++) {
905 ((2 * refclock * f) /
906 (pre * (1 << post)));
907 if ((reqclock > freq - freqerr)
908 && (reqclock < freq + freqerr)) {
912 freq : freq - reqclock;
922 return (actualclock);
925 static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info,
926 unsigned long depth, int v)
940 DPRINTK(1, "Unsupported depth %ld\n", depth);
944 static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info,
945 unsigned long depth, int v)
959 DPRINTK(1, "Unsupported depth %ld\n", depth);
963 static void pm3fb_mapIO(struct pm3fb_info *l_fb_info)
968 ioremap((unsigned long) l_fb_info->pIOBase, PM3_REGS_SIZE);
970 ioremap((unsigned long) l_fb_info->p_fb, l_fb_info->fb_size);
971 DPRINTK(2, "IO mapping : IOBase %lx / %lx, fb %lx / %lx\n",
972 (unsigned long) l_fb_info->pIOBase,
973 (unsigned long) l_fb_info->vIOBase,
974 (unsigned long) l_fb_info->p_fb,
975 (unsigned long) l_fb_info->v_fb);
978 static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info)
982 iounmap(l_fb_info->vIOBase);
983 iounmap(l_fb_info->v_fb);
984 l_fb_info->vIOBase = (unsigned char *) -1;
985 l_fb_info->v_fb = (unsigned char *) -1;
988 #if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
989 static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info)
991 DPRINTK(2, "PM3Aperture0: 0x%08x\n", PM3_READ_REG(PM3Aperture0));
992 DPRINTK(2, "PM3Aperture1: 0x%08x\n", PM3_READ_REG(PM3Aperture1));
993 DPRINTK(2, "PM3ByAperture1Mode: 0x%08x\n",
994 PM3_READ_REG(PM3ByAperture1Mode));
995 DPRINTK(2, "PM3ByAperture2Mode: 0x%08x\n",
996 PM3_READ_REG(PM3ByAperture2Mode));
997 DPRINTK(2, "PM3ChipConfig: 0x%08x\n", PM3_READ_REG(PM3ChipConfig));
998 DPRINTK(2, "PM3FIFODis: 0x%08x\n", PM3_READ_REG(PM3FIFODis));
999 DPRINTK(2, "PM3HTotal: 0x%08x\n", PM3_READ_REG(PM3HTotal));
1000 DPRINTK(2, "PM3HbEnd: 0x%08x\n", PM3_READ_REG(PM3HbEnd));
1001 DPRINTK(2, "PM3HgEnd: 0x%08x\n", PM3_READ_REG(PM3HgEnd));
1002 DPRINTK(2, "PM3HsEnd: 0x%08x\n", PM3_READ_REG(PM3HsEnd));
1003 DPRINTK(2, "PM3HsStart: 0x%08x\n", PM3_READ_REG(PM3HsStart));
1004 DPRINTK(2, "PM3MemBypassWriteMask: 0x%08x\n",
1005 PM3_READ_REG(PM3MemBypassWriteMask));
1006 DPRINTK(2, "PM3RD_IndexControl: 0x%08x\n",
1007 PM3_READ_REG(PM3RD_IndexControl));
1008 DPRINTK(2, "PM3ScreenBase: 0x%08x\n", PM3_READ_REG(PM3ScreenBase));
1009 DPRINTK(2, "PM3ScreenStride: 0x%08x\n",
1010 PM3_READ_REG(PM3ScreenStride));
1011 DPRINTK(2, "PM3VClkCtl: 0x%08x\n", PM3_READ_REG(PM3VClkCtl));
1012 DPRINTK(2, "PM3VTotal: 0x%08x\n", PM3_READ_REG(PM3VTotal));
1013 DPRINTK(2, "PM3VbEnd: 0x%08x\n", PM3_READ_REG(PM3VbEnd));
1014 DPRINTK(2, "PM3VideoControl: 0x%08x\n",
1015 PM3_READ_REG(PM3VideoControl));
1016 DPRINTK(2, "PM3VsEnd: 0x%08x\n", PM3_READ_REG(PM3VsEnd));
1017 DPRINTK(2, "PM3VsStart: 0x%08x\n", PM3_READ_REG(PM3VsStart));
1019 DPRINTK(2, "PM3RD_ColorFormat: %ld\n",
1020 PM3_READ_DAC_REG(PM3RD_ColorFormat));
1021 DPRINTK(2, "PM3RD_DACControl: %ld\n",
1022 PM3_READ_DAC_REG(PM3RD_DACControl));
1023 DPRINTK(2, "PM3RD_DClk0FeedbackScale: %ld\n",
1024 PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale));
1025 DPRINTK(2, "PM3RD_DClk0PostScale: %ld\n",
1026 PM3_READ_DAC_REG(PM3RD_DClk0PostScale));
1027 DPRINTK(2, "PM3RD_DClk0PreScale: %ld\n",
1028 PM3_READ_DAC_REG(PM3RD_DClk0PreScale));
1029 DPRINTK(2, "[not set] PM3RD_IndexControl: %ld\n",
1030 PM3_READ_DAC_REG(PM3RD_IndexControl));
1031 DPRINTK(2, "PM3RD_MiscControl: %ld\n",
1032 PM3_READ_DAC_REG(PM3RD_MiscControl));
1033 DPRINTK(2, "PM3RD_PixelSize: %ld\n",
1034 PM3_READ_DAC_REG(PM3RD_PixelSize));
1035 DPRINTK(2, "PM3RD_SyncControl: %ld\n",
1036 PM3_READ_DAC_REG(PM3RD_SyncControl));
1039 #endif /* defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) */
1040 static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info)
1042 u16 subvendor, subdevice;
1044 if ((!pci_read_config_word
1045 (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor))
1047 (!pci_read_config_word
1048 (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) {
1049 /* well, nothing... */
1051 subvendor = subdevice = (u16)-1;
1054 printk(KERN_INFO "pm3fb: memory timings for board #%ld (subvendor: 0x%hx, subdevice: 0x%hx)\n", l_fb_info->board_num, subvendor, subdevice);
1055 printk(KERN_INFO " PM3LocalMemCaps: 0x%08x\n",
1056 PM3_READ_REG(PM3LocalMemCaps));
1057 printk(KERN_INFO " PM3LocalMemTimings: 0x%08x\n",
1058 PM3_READ_REG(PM3LocalMemTimings));
1059 printk(KERN_INFO " PM3LocalMemControl: 0x%08x\n",
1060 PM3_READ_REG(PM3LocalMemControl));
1061 printk(KERN_INFO " PM3LocalMemRefresh: 0x%08x\n",
1062 PM3_READ_REG(PM3LocalMemRefresh));
1063 printk(KERN_INFO " PM3LocalMemPowerDown: 0x%08x\n",
1064 PM3_READ_REG(PM3LocalMemPowerDown));
1067 /* write the mode to registers */
1068 static void pm3fb_write_mode(struct pm3fb_info *l_fb_info)
1070 char tempsync = 0x00, tempmisc = 0x00;
1073 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xffffffff);
1074 PM3_SLOW_WRITE_REG(PM3Aperture0, 0x00000000);
1075 PM3_SLOW_WRITE_REG(PM3Aperture1, 0x00000000);
1076 PM3_SLOW_WRITE_REG(PM3FIFODis, 0x00000007);
1078 PM3_SLOW_WRITE_REG(PM3HTotal,
1079 pm3fb_Shiftbpp(l_fb_info,
1080 l_fb_info->current_par->depth,
1081 l_fb_info->current_par->htotal -
1083 PM3_SLOW_WRITE_REG(PM3HsEnd,
1084 pm3fb_Shiftbpp(l_fb_info,
1085 l_fb_info->current_par->depth,
1086 l_fb_info->current_par->hsend));
1087 PM3_SLOW_WRITE_REG(PM3HsStart,
1088 pm3fb_Shiftbpp(l_fb_info,
1089 l_fb_info->current_par->depth,
1090 l_fb_info->current_par->
1092 PM3_SLOW_WRITE_REG(PM3HbEnd,
1093 pm3fb_Shiftbpp(l_fb_info,
1094 l_fb_info->current_par->depth,
1095 l_fb_info->current_par->hbend));
1096 PM3_SLOW_WRITE_REG(PM3HgEnd,
1097 pm3fb_Shiftbpp(l_fb_info,
1098 l_fb_info->current_par->depth,
1099 l_fb_info->current_par->hbend));
1100 PM3_SLOW_WRITE_REG(PM3ScreenStride,
1101 pm3fb_Shiftbpp(l_fb_info,
1102 l_fb_info->current_par->depth,
1103 l_fb_info->current_par->stride));
1104 PM3_SLOW_WRITE_REG(PM3VTotal, l_fb_info->current_par->vtotal - 1);
1105 PM3_SLOW_WRITE_REG(PM3VsEnd, l_fb_info->current_par->vsend - 1);
1106 PM3_SLOW_WRITE_REG(PM3VsStart,
1107 l_fb_info->current_par->vsstart - 1);
1108 PM3_SLOW_WRITE_REG(PM3VbEnd, l_fb_info->current_par->vbend);
1110 switch (l_fb_info->current_par->depth) {
1112 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
1113 PM3ByApertureMode_PIXELSIZE_8BIT);
1114 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
1115 PM3ByApertureMode_PIXELSIZE_8BIT);
1121 #ifndef __BIG_ENDIAN
1122 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
1123 PM3ByApertureMode_PIXELSIZE_16BIT);
1124 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
1125 PM3ByApertureMode_PIXELSIZE_16BIT);
1127 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
1128 PM3ByApertureMode_PIXELSIZE_16BIT |
1129 PM3ByApertureMode_BYTESWAP_BADC);
1130 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
1131 PM3ByApertureMode_PIXELSIZE_16BIT |
1132 PM3ByApertureMode_BYTESWAP_BADC);
1133 #endif /* ! __BIG_ENDIAN */
1137 #ifndef __BIG_ENDIAN
1138 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
1139 PM3ByApertureMode_PIXELSIZE_32BIT);
1140 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
1141 PM3ByApertureMode_PIXELSIZE_32BIT);
1143 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode,
1144 PM3ByApertureMode_PIXELSIZE_32BIT |
1145 PM3ByApertureMode_BYTESWAP_DCBA);
1146 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode,
1147 PM3ByApertureMode_PIXELSIZE_32BIT |
1148 PM3ByApertureMode_BYTESWAP_DCBA);
1149 #endif /* ! __BIG_ENDIAN */
1153 DPRINTK(1, "Unsupported depth %d\n",
1154 l_fb_info->current_par->depth);
1159 * Oxygen VX1 - it appears that setting PM3VideoControl and
1160 * then PM3RD_SyncControl to the same SYNC settings undoes
1161 * any net change - they seem to xor together. Only set the
1162 * sync options in PM3RD_SyncControl. --rmk
1165 unsigned int video = l_fb_info->current_par->video;
1167 video &= ~(PM3VideoControl_HSYNC_MASK |
1168 PM3VideoControl_VSYNC_MASK);
1169 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
1170 PM3VideoControl_VSYNC_ACTIVE_HIGH;
1171 PM3_SLOW_WRITE_REG(PM3VideoControl, video);
1173 PM3_SLOW_WRITE_REG(PM3VClkCtl,
1174 (PM3_READ_REG(PM3VClkCtl) & 0xFFFFFFFC));
1175 PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base);
1176 PM3_SLOW_WRITE_REG(PM3ChipConfig,
1177 (PM3_READ_REG(PM3ChipConfig) & 0xFFFFFFFD));
1180 unsigned char m; /* ClkPreScale */
1181 unsigned char n; /* ClkFeedBackScale */
1182 unsigned char p; /* ClkPostScale */
1183 (void)pm3fb_CalculateClock(l_fb_info, l_fb_info->current_par->pixclock, PM3_REF_CLOCK, &m, &n, &p);
1186 "Pixclock: %d, Pre: %d, Feedback: %d, Post: %d\n",
1187 l_fb_info->current_par->pixclock, (int) m, (int) n,
1190 PM3_WRITE_DAC_REG(PM3RD_DClk0PreScale, m);
1191 PM3_WRITE_DAC_REG(PM3RD_DClk0FeedbackScale, n);
1192 PM3_WRITE_DAC_REG(PM3RD_DClk0PostScale, p);
1195 PM3_WRITE_DAC_REG(PM3RD_IndexControl, 0x00);
1198 PM3_SLOW_WRITE_REG(PM3RD_IndexControl, 0x00);
1200 if ((l_fb_info->current_par->video & PM3VideoControl_HSYNC_MASK) ==
1201 PM3VideoControl_HSYNC_ACTIVE_HIGH)
1202 tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH;
1203 if ((l_fb_info->current_par->video & PM3VideoControl_VSYNC_MASK) ==
1204 PM3VideoControl_VSYNC_ACTIVE_HIGH)
1205 tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH;
1207 PM3_WRITE_DAC_REG(PM3RD_SyncControl, tempsync);
1208 DPRINTK(2, "PM3RD_SyncControl: %d\n", tempsync);
1210 if (flatpanel[l_fb_info->board_num])
1212 PM3_WRITE_DAC_REG(PM3RD_DACControl, PM3RD_DACControl_BLANK_PEDESTAL_ENABLE);
1214 PM3_WRITE_REG(PM3VSConfiguration, 0x06);
1215 PM3_WRITE_REG(0x5a00, 1 << 14); /* black magic... */
1216 tempmisc = PM3RD_MiscControl_VSB_OUTPUT_ENABLE;
1219 PM3_WRITE_DAC_REG(PM3RD_DACControl, 0x00);
1221 switch (l_fb_info->current_par->depth) {
1223 PM3_WRITE_DAC_REG(PM3RD_PixelSize,
1224 PM3RD_PixelSize_8_BIT_PIXELS);
1225 PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
1226 PM3RD_ColorFormat_CI8_COLOR |
1227 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
1228 tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1231 PM3_WRITE_DAC_REG(PM3RD_PixelSize,
1232 PM3RD_PixelSize_16_BIT_PIXELS);
1233 PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
1234 PM3RD_ColorFormat_4444_COLOR |
1235 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
1236 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
1237 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
1238 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1241 PM3_WRITE_DAC_REG(PM3RD_PixelSize,
1242 PM3RD_PixelSize_16_BIT_PIXELS);
1243 PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
1244 PM3RD_ColorFormat_5551_FRONT_COLOR |
1245 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
1246 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
1247 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
1248 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1251 PM3_WRITE_DAC_REG(PM3RD_PixelSize,
1252 PM3RD_PixelSize_16_BIT_PIXELS);
1253 PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
1254 PM3RD_ColorFormat_565_FRONT_COLOR |
1255 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
1256 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
1257 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
1258 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1261 PM3_WRITE_DAC_REG(PM3RD_PixelSize,
1262 PM3RD_PixelSize_32_BIT_PIXELS);
1263 PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
1264 PM3RD_ColorFormat_8888_COLOR |
1265 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
1266 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
1267 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1270 PM3_WRITE_DAC_REG(PM3RD_MiscControl, tempmisc);
1275 static void pm3fb_read_mode(struct pm3fb_info *l_fb_info,
1276 struct pm3fb_par *curpar)
1278 unsigned long pixsize1, pixsize2, clockused;
1279 unsigned long pre, feedback, post;
1283 clockused = PM3_READ_REG(PM3VClkCtl);
1285 switch (clockused) {
1287 pre = PM3_READ_DAC_REG(PM3RD_DClk3PreScale);
1288 feedback = PM3_READ_DAC_REG(PM3RD_DClk3FeedbackScale);
1289 post = PM3_READ_DAC_REG(PM3RD_DClk3PostScale);
1292 "DClk3 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
1293 pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
1298 pre = PM3_READ_DAC_REG(PM3RD_DClk2PreScale);
1299 feedback = PM3_READ_DAC_REG(PM3RD_DClk2FeedbackScale);
1300 post = PM3_READ_DAC_REG(PM3RD_DClk2PostScale);
1303 "DClk2 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
1304 pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
1309 pre = PM3_READ_DAC_REG(PM3RD_DClk1PreScale);
1310 feedback = PM3_READ_DAC_REG(PM3RD_DClk1FeedbackScale);
1311 post = PM3_READ_DAC_REG(PM3RD_DClk1PostScale);
1314 "DClk1 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
1315 pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
1320 pre = PM3_READ_DAC_REG(PM3RD_DClk0PreScale);
1321 feedback = PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale);
1322 post = PM3_READ_DAC_REG(PM3RD_DClk0PostScale);
1325 "DClk0 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n",
1326 pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
1331 pre = feedback = post = 0;
1332 DPRINTK(1, "Unknowk D clock used : %ld\n", clockused);
1336 curpar->pixclock = PM3_SCALE_TO_CLOCK(pre, feedback, post);
1339 PM3ByApertureMode_PIXELSIZE_MASK &
1340 (PM3_READ_REG(PM3ByAperture1Mode));
1342 PM3ByApertureMode_PIXELSIZE_MASK &
1343 (PM3_READ_REG(PM3ByAperture2Mode));
1345 DASSERT((pixsize1 == pixsize2),
1346 "pixsize the same in both aperture\n");
1348 if (pixsize1 & PM3ByApertureMode_PIXELSIZE_32BIT)
1350 else if (pixsize1 & PM3ByApertureMode_PIXELSIZE_16BIT)
1357 /* not sure if I need to add one on the next ; it give better result with */
1359 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1360 1 + PM3_READ_REG(PM3HTotal));
1362 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1363 PM3_READ_REG(PM3HsEnd));
1365 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1366 PM3_READ_REG(PM3HsStart));
1368 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1369 PM3_READ_REG(PM3HbEnd));
1372 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1373 PM3_READ_REG(PM3ScreenStride));
1375 curpar->vtotal = 1 + PM3_READ_REG(PM3VTotal);
1376 curpar->vsend = 1 + PM3_READ_REG(PM3VsEnd);
1377 curpar->vsstart = 1 + PM3_READ_REG(PM3VsStart);
1378 curpar->vbend = PM3_READ_REG(PM3VbEnd);
1380 curpar->video = PM3_READ_REG(PM3VideoControl);
1382 curpar->base = PM3_READ_REG(PM3ScreenBase);
1383 curpar->width = curpar->htotal - curpar->hbend; /* make virtual == displayed resolution */
1384 curpar->height = curpar->vtotal - curpar->vbend;
1386 DPRINTK(2, "Found : %d * %d, %d Khz, stride is %08x\n",
1387 curpar->width, curpar->height, curpar->pixclock,
1391 static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info)
1393 unsigned long memsize = 0, tempBypass, i, temp1, temp2;
1394 u16 subvendor, subdevice;
1395 pm3fb_timing_result ptr;
1399 l_fb_info->fb_size = 64 * 1024 * 1024; /* pm3 aperture always 64 MB */
1400 pm3fb_mapIO(l_fb_info); /* temporary map IO */
1402 DASSERT((l_fb_info->vIOBase != NULL),
1403 "IO successfully mapped before mem detect\n");
1404 DASSERT((l_fb_info->v_fb != NULL),
1405 "FB successfully mapped before mem detect\n");
1407 /* card-specific stuff, *before* accessing *any* FB memory */
1408 if ((!pci_read_config_word
1409 (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor))
1411 (!pci_read_config_word
1412 (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) {
1413 i = 0; l_fb_info->board_type = 0;
1414 while ((cardbase[i].cardname[0]) && !(l_fb_info->board_type)) {
1415 if ((cardbase[i].subvendor == subvendor) &&
1416 (cardbase[i].subdevice == subdevice) &&
1417 (cardbase[i].func == PCI_FUNC(l_fb_info->dev->devfn))) {
1418 DPRINTK(2, "Card #%ld is an %s\n",
1419 l_fb_info->board_num,
1420 cardbase[i].cardname);
1421 if (cardbase[i].specific_setup)
1422 cardbase[i].specific_setup(l_fb_info);
1423 l_fb_info->board_type = i;
1427 if (!l_fb_info->board_type) {
1428 DPRINTK(1, "Card #%ld is an unknown 0x%04x / 0x%04x\n",
1429 l_fb_info->board_num, subvendor, subdevice);
1432 printk(KERN_ERR "pm3fb: Error: pci_read_config_word failed, board #%ld\n",
1433 l_fb_info->board_num);
1437 pm3fb_show_cur_timing(l_fb_info);
1439 /* card-specific setup is done, we preserve the final
1440 memory timing for future reference */
1441 if ((ptr = pm3fb_preserve_memory_timings(l_fb_info)) == pm3fb_timing_problem) { /* memory timings were wrong ! oops.... */
1445 tempBypass = PM3_READ_REG(PM3MemBypassWriteMask);
1447 DPRINTK(2, "PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass);
1449 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xFFFFFFFF);
1451 /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */
1452 for (i = 0; i < 32; i++) {
1454 #ifdef MUST_BYTESWAP
1455 writel(__swab32(i * 0x00345678),
1456 (l_fb_info->v_fb + (i * 1048576)));
1458 writel(i * 0x00345678, (l_fb_info->v_fb + (i * 1048576)));
1461 #ifdef MUST_BYTESWAP
1462 temp1 = __swab32(readl((l_fb_info->v_fb + (i * 1048576))));
1464 temp1 = readl((l_fb_info->v_fb + (i * 1048576)));
1466 #endif /* KERNEL_2_2 */
1467 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
1468 fb_writel(i * 0x00345678,
1469 (l_fb_info->v_fb + (i * 1048576)));
1471 temp1 = fb_readl((l_fb_info->v_fb + (i * 1048576)));
1472 #endif /* KERNEL_2_4 or KERNEL_2_5 */
1473 /* Let's check for wrapover, write will fail at 16MB boundary */
1474 if (temp1 == (i * 0x00345678))
1480 DPRINTK(2, "First detect pass already got %ld MB\n", memsize + 1);
1483 for (i = 0; i < 32; i++) {
1484 /* Clear first 32MB ; 0 is 0, no need to byteswap */
1486 (l_fb_info->v_fb + (i * 1048576)));
1490 for (i = 32; i < 64; i++) {
1492 #ifdef MUST_BYTESWAP
1493 writel(__swab32(i * 0x00345678),
1494 (l_fb_info->v_fb + (i * 1048576)));
1496 writel(i * 0x00345678,
1497 (l_fb_info->v_fb + (i * 1048576)));
1500 #ifdef MUST_BYTESWAP
1503 ((l_fb_info->v_fb + (i * 1048576))));
1507 ((i - 32) * 1048576))));
1509 temp1 = readl((l_fb_info->v_fb + (i * 1048576)));
1511 readl((l_fb_info->v_fb +
1512 ((i - 32) * 1048576)));
1514 #endif /* KERNEL_2_2 */
1515 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
1516 fb_writel(i * 0x00345678,
1517 (l_fb_info->v_fb + (i * 1048576)));
1520 fb_readl((l_fb_info->v_fb + (i * 1048576)));
1522 fb_readl((l_fb_info->v_fb +
1523 ((i - 32) * 1048576)));
1524 #endif /* KERNEL_2_4 or KERNEL_2_5 */
1525 if ((temp1 == (i * 0x00345678)) && (temp2 == 0)) /* different value, different RAM... */
1532 DPRINTK(2, "Second detect pass got %ld MB\n", memsize + 1);
1534 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, tempBypass);
1536 pm3fb_unmapIO(l_fb_info);
1537 memsize = 1048576 * (memsize + 1);
1539 DPRINTK(2, "Returning 0x%08lx bytes\n", memsize);
1541 if (forcesize[l_fb_info->board_num] && ((forcesize[l_fb_info->board_num] * 1048576) != memsize))
1543 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]);
1544 memsize = 1048576 * forcesize[l_fb_info->board_num];
1547 l_fb_info->fb_size = memsize;
1549 if (ptr == pm3fb_timing_retry)
1551 printk(KERN_WARNING "pm3fb: retrying memory timings check");
1552 if (pm3fb_try_memory_timings(l_fb_info) == pm3fb_timing_problem)
1559 static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc)
1565 for (i = 0; i < (l_fb_info->fb_size / sizeof(u32)) ; i++) /* clear entire FB memory to black */
1568 #ifdef MUST_BYTESWAP
1569 writel(__swab32(cc), (l_fb_info->v_fb + (i * sizeof(u32))));
1571 writel(cc, (l_fb_info->v_fb + (i * sizeof(u32))));
1574 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
1575 fb_writel(cc, (l_fb_info->v_fb + (i * sizeof(u32))));
1580 static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b)
1586 for (i = 0; i < 256 ; i++) /* fill color map with white */
1587 pm3fb_set_color(l_fb_info, i, r, g, b);
1591 /* common initialisation */
1592 static void pm3fb_common_init(struct pm3fb_info *l_fb_info)
1596 DPRINTK(2, "Initializing board #%ld @ %lx\n", l_fb_info->board_num,
1597 (unsigned long) l_fb_info);
1599 strcpy(l_fb_info->gen.info.modename, permedia3_name);
1600 disp[l_fb_info->board_num].scrollmode = 0; /* SCROLL_YNOMOVE; *//* 0 means "let fbcon choose" */
1601 l_fb_info->gen.parsize = sizeof(struct pm3fb_par);
1602 l_fb_info->gen.info.changevar = NULL;
1603 l_fb_info->gen.info.node = B_FREE;
1604 l_fb_info->gen.info.fbops = &pm3fb_ops;
1605 l_fb_info->gen.info.disp = &(disp[l_fb_info->board_num]);
1606 if (fontn[l_fb_info->board_num][0])
1607 strcpy(l_fb_info->gen.info.fontname,
1608 fontn[l_fb_info->board_num]);
1609 l_fb_info->gen.info.switch_con = &fbgen_switch;
1610 l_fb_info->gen.info.updatevar = &fbgen_update_var; /* */
1611 l_fb_info->gen.info.blank = &fbgen_blank; /* */
1612 l_fb_info->gen.info.flags = FBINFO_FLAG_DEFAULT;
1614 pm3fb_mapIO(l_fb_info);
1616 pm3fb_clear_memory(l_fb_info, 0);
1617 pm3fb_clear_colormap(l_fb_info, 0, 0, 0);
1619 (void) fbgen_get_var(&(disp[l_fb_info->board_num]).var, -1,
1620 &l_fb_info->gen.info);
1622 if (depth[l_fb_info->board_num]) /* override mode-defined depth */
1624 pm3fb_encode_depth(&(disp[l_fb_info->board_num]).var, depth[l_fb_info->board_num]);
1625 (disp[l_fb_info->board_num]).var.bits_per_pixel = depth2bpp(depth[l_fb_info->board_num]);
1628 (void) fbgen_do_set_var(&(disp[l_fb_info->board_num]).var, 1,
1631 fbgen_set_disp(-1, &l_fb_info->gen);
1633 fbgen_install_cmap(0, &l_fb_info->gen);
1635 if (register_framebuffer(&l_fb_info->gen.info) < 0) {
1636 DPRINTK(1, "Couldn't register framebuffer\n");
1640 PM3_WRITE_DAC_REG(PM3RD_CursorMode,
1641 PM3RD_CursorMode_CURSOR_DISABLE);
1645 pm3fb_write_mode(l_fb_info);
1647 printk("fb%d: %s, using %uK of video memory (%s)\n",
1648 GET_FB_IDX(l_fb_info->gen.info.node),
1649 permedia3_name, (u32) (l_fb_info->fb_size >> 10),
1650 cardbase[l_fb_info->board_type].cardname);
1653 /* **************************************************** */
1654 /* ***** accelerated permedia3-specific functions ***** */
1655 /* **************************************************** */
1656 #ifdef PM3FB_USE_ACCEL
1657 static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info)
1661 PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync);
1662 PM3_SLOW_WRITE_REG(PM3Sync, 0);
1665 while ((PM3_READ_REG(PM3OutFIFOWords)) == 0);
1667 } while ((PM3_READ_REG(PM3OutputFifo)) != PM3Sync_Tag);
1670 static void pm3fb_init_engine(struct pm3fb_info *l_fb_info)
1672 PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync);
1673 PM3_SLOW_WRITE_REG(PM3StatisticMode, 0x0);
1674 PM3_SLOW_WRITE_REG(PM3DeltaMode, 0x0);
1675 PM3_SLOW_WRITE_REG(PM3RasterizerMode, 0x0);
1676 PM3_SLOW_WRITE_REG(PM3ScissorMode, 0x0);
1677 PM3_SLOW_WRITE_REG(PM3LineStippleMode, 0x0);
1678 PM3_SLOW_WRITE_REG(PM3AreaStippleMode, 0x0);
1679 PM3_SLOW_WRITE_REG(PM3GIDMode, 0x0);
1680 PM3_SLOW_WRITE_REG(PM3DepthMode, 0x0);
1681 PM3_SLOW_WRITE_REG(PM3StencilMode, 0x0);
1682 PM3_SLOW_WRITE_REG(PM3StencilData, 0x0);
1683 PM3_SLOW_WRITE_REG(PM3ColorDDAMode, 0x0);
1684 PM3_SLOW_WRITE_REG(PM3TextureCoordMode, 0x0);
1685 PM3_SLOW_WRITE_REG(PM3TextureIndexMode0, 0x0);
1686 PM3_SLOW_WRITE_REG(PM3TextureIndexMode1, 0x0);
1687 PM3_SLOW_WRITE_REG(PM3TextureReadMode, 0x0);
1688 PM3_SLOW_WRITE_REG(PM3LUTMode, 0x0);
1689 PM3_SLOW_WRITE_REG(PM3TextureFilterMode, 0x0);
1690 PM3_SLOW_WRITE_REG(PM3TextureCompositeMode, 0x0);
1691 PM3_SLOW_WRITE_REG(PM3TextureApplicationMode, 0x0);
1692 PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode1, 0x0);
1693 PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode1, 0x0);
1694 PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode0, 0x0);
1695 PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode0, 0x0);
1696 PM3_SLOW_WRITE_REG(PM3FogMode, 0x0);
1697 PM3_SLOW_WRITE_REG(PM3ChromaTestMode, 0x0);
1698 PM3_SLOW_WRITE_REG(PM3AlphaTestMode, 0x0);
1699 PM3_SLOW_WRITE_REG(PM3AntialiasMode, 0x0);
1700 PM3_SLOW_WRITE_REG(PM3YUVMode, 0x0);
1701 PM3_SLOW_WRITE_REG(PM3AlphaBlendColorMode, 0x0);
1702 PM3_SLOW_WRITE_REG(PM3AlphaBlendAlphaMode, 0x0);
1703 PM3_SLOW_WRITE_REG(PM3DitherMode, 0x0);
1704 PM3_SLOW_WRITE_REG(PM3LogicalOpMode, 0x0);
1705 PM3_SLOW_WRITE_REG(PM3RouterMode, 0x0);
1706 PM3_SLOW_WRITE_REG(PM3Window, 0x0);
1708 PM3_SLOW_WRITE_REG(PM3Config2D, 0x0);
1710 PM3_SLOW_WRITE_REG(PM3SpanColorMask, 0xffffffff);
1712 PM3_SLOW_WRITE_REG(PM3XBias, 0x0);
1713 PM3_SLOW_WRITE_REG(PM3YBias, 0x0);
1714 PM3_SLOW_WRITE_REG(PM3DeltaControl, 0x0);
1716 PM3_SLOW_WRITE_REG(PM3BitMaskPattern, 0xffffffff);
1718 PM3_SLOW_WRITE_REG(PM3FBDestReadEnables,
1719 PM3FBDestReadEnables_E(0xff) |
1720 PM3FBDestReadEnables_R(0xff) |
1721 PM3FBDestReadEnables_ReferenceAlpha(0xff));
1722 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferAddr0, 0x0);
1723 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferOffset0, 0x0);
1724 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferWidth0,
1725 PM3FBDestReadBufferWidth_Width(l_fb_info->
1729 PM3_SLOW_WRITE_REG(PM3FBDestReadMode,
1730 PM3FBDestReadMode_ReadEnable |
1731 PM3FBDestReadMode_Enable0);
1732 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferAddr, 0x0);
1733 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferOffset, 0x0);
1734 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferWidth,
1735 PM3FBSourceReadBufferWidth_Width(l_fb_info->
1738 PM3_SLOW_WRITE_REG(PM3FBSourceReadMode,
1739 PM3FBSourceReadMode_Blocking |
1740 PM3FBSourceReadMode_ReadEnable);
1743 unsigned long rm = 1;
1744 switch (l_fb_info->current_par->depth) {
1746 PM3_SLOW_WRITE_REG(PM3PixelSize,
1747 PM3PixelSize_GLOBAL_8BIT);
1752 PM3_SLOW_WRITE_REG(PM3PixelSize,
1753 PM3PixelSize_GLOBAL_16BIT);
1756 PM3_SLOW_WRITE_REG(PM3PixelSize,
1757 PM3PixelSize_GLOBAL_32BIT);
1760 DPRINTK(1, "Unsupported depth %d\n",
1761 l_fb_info->current_par->depth);
1764 PM3_SLOW_WRITE_REG(PM3RasterizerMode, rm);
1767 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xffffffff);
1768 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xffffffff);
1769 PM3_SLOW_WRITE_REG(PM3FBWriteMode,
1770 PM3FBWriteMode_WriteEnable |
1771 PM3FBWriteMode_OpaqueSpan |
1772 PM3FBWriteMode_Enable0);
1773 PM3_SLOW_WRITE_REG(PM3FBWriteBufferAddr0, 0x0);
1774 PM3_SLOW_WRITE_REG(PM3FBWriteBufferOffset0, 0x0);
1775 PM3_SLOW_WRITE_REG(PM3FBWriteBufferWidth0,
1776 PM3FBWriteBufferWidth_Width(l_fb_info->
1780 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 0x0);
1782 unsigned long sofb = (8UL * l_fb_info->fb_size) /
1783 ((depth2bpp(l_fb_info->current_par->depth))
1784 * l_fb_info->current_par->width); /* size in lines of FB */
1786 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 4095);
1788 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, sofb);
1790 switch (l_fb_info->current_par->depth) {
1792 PM3_SLOW_WRITE_REG(PM3DitherMode,
1793 (1 << 10) | (2 << 3));
1798 PM3_SLOW_WRITE_REG(PM3DitherMode,
1799 (1 << 10) | (1 << 3));
1802 PM3_SLOW_WRITE_REG(PM3DitherMode,
1803 (1 << 10) | (0 << 3));
1806 DPRINTK(1, "Unsupported depth %d\n",
1807 l_fb_info->current_par->depth);
1812 PM3_SLOW_WRITE_REG(PM3dXDom, 0x0);
1813 PM3_SLOW_WRITE_REG(PM3dXSub, 0x0);
1814 PM3_SLOW_WRITE_REG(PM3dY, (1 << 16));
1815 PM3_SLOW_WRITE_REG(PM3StartXDom, 0x0);
1816 PM3_SLOW_WRITE_REG(PM3StartXSub, 0x0);
1817 PM3_SLOW_WRITE_REG(PM3StartY, 0x0);
1818 PM3_SLOW_WRITE_REG(PM3Count, 0x0);
1820 /* Disable LocalBuffer. better safe than sorry */
1821 PM3_SLOW_WRITE_REG(PM3LBDestReadMode, 0x0);
1822 PM3_SLOW_WRITE_REG(PM3LBDestReadEnables, 0x0);
1823 PM3_SLOW_WRITE_REG(PM3LBSourceReadMode, 0x0);
1824 PM3_SLOW_WRITE_REG(PM3LBWriteMode, 0x0);
1826 pm3fb_wait_pm3(l_fb_info);
1829 #ifdef FBCON_HAS_CFB32
1830 static void pm3fb_cfb32_clear(struct vc_data *conp,
1832 int sy, int sx, int height, int width)
1834 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
1839 sx = sx * fontwidth(p);
1840 width = width * fontwidth(p);
1841 sy = sy * fontheight(p);
1842 height = height * fontheight(p);
1843 c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
1845 /* block fills in 32bpp are hard, but in low res (width <= 1600 :-)
1846 we can use 16bpp operations, but not if NoWriteMask is on (SDRAM) */
1847 if ((l_fb_info->current_par->width > 1600) ||
1848 (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)) {
1851 PM3_WRITE_REG(PM3Config2D,
1852 PM3Config2D_UseConstantSource |
1853 PM3Config2D_ForegroundROPEnable |
1854 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1855 PM3Config2D_FBWriteEnable);
1857 PM3_WRITE_REG(PM3ForegroundColor, c);
1859 PM3_WRITE_REG(PM3RectanglePosition,
1860 (PM3RectanglePosition_XOffset(sx)) |
1861 (PM3RectanglePosition_YOffset(sy)));
1863 PM3_WRITE_REG(PM3Render2D,
1864 PM3Render2D_XPositive |
1865 PM3Render2D_YPositive |
1866 PM3Render2D_Operation_Normal |
1867 PM3Render2D_SpanOperation |
1868 (PM3Render2D_Width(width)) |
1869 (PM3Render2D_Height(height)));
1873 PM3_WRITE_REG(PM3FBBlockColor, c);
1875 PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_16BIT);
1877 PM3_WRITE_REG(PM3FBWriteBufferWidth0,
1878 PM3FBWriteBufferWidth_Width(l_fb_info->
1882 PM3_WRITE_REG(PM3Config2D,
1883 PM3Config2D_UseConstantSource |
1884 PM3Config2D_ForegroundROPEnable |
1885 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1886 PM3Config2D_FBWriteEnable);
1888 PM3_WRITE_REG(PM3RectanglePosition,
1889 (PM3RectanglePosition_XOffset(sx << 1)) |
1890 (PM3RectanglePosition_YOffset(sy)));
1892 PM3_WRITE_REG(PM3Render2D,
1893 PM3Render2D_XPositive |
1894 PM3Render2D_YPositive |
1895 PM3Render2D_Operation_Normal |
1896 (PM3Render2D_Width(width << 1)) |
1897 (PM3Render2D_Height(height)));
1899 PM3_WRITE_REG(PM3FBWriteBufferWidth0,
1900 PM3FBWriteBufferWidth_Width(l_fb_info->
1904 PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_32BIT);
1907 pm3fb_wait_pm3(l_fb_info);
1910 static void pm3fb_cfb32_clear_margins(struct vc_data *conp,
1911 struct display *p, int bottom_only)
1913 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
1919 sx = conp->vc_cols * fontwidth(p); /* right margin */
1920 sy = conp->vc_rows * fontheight(p); /* bottom margin */
1921 c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
1923 if (!bottom_only) { /* right margin top->bottom */
1926 PM3_WRITE_REG(PM3Config2D,
1927 PM3Config2D_UseConstantSource |
1928 PM3Config2D_ForegroundROPEnable |
1929 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1930 PM3Config2D_FBWriteEnable);
1932 PM3_WRITE_REG(PM3ForegroundColor, c);
1934 PM3_WRITE_REG(PM3RectanglePosition,
1935 (PM3RectanglePosition_XOffset
1937 sx)) | (PM3RectanglePosition_YOffset(p->
1941 PM3_WRITE_REG(PM3Render2D,
1942 PM3Render2D_XPositive |
1943 PM3Render2D_YPositive |
1944 PM3Render2D_Operation_Normal |
1945 PM3Render2D_SpanOperation |
1946 (PM3Render2D_Width(p->var.xres - sx)) |
1947 (PM3Render2D_Height(p->var.yres)));
1950 /* bottom margin left -> right */
1953 PM3_WRITE_REG(PM3Config2D,
1954 PM3Config2D_UseConstantSource |
1955 PM3Config2D_ForegroundROPEnable |
1956 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1957 PM3Config2D_FBWriteEnable);
1959 PM3_WRITE_REG(PM3ForegroundColor, c);
1961 PM3_WRITE_REG(PM3RectanglePosition,
1962 (PM3RectanglePosition_XOffset(p->var.xoffset)) |
1963 (PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
1965 PM3_WRITE_REG(PM3Render2D,
1966 PM3Render2D_XPositive |
1967 PM3Render2D_YPositive |
1968 PM3Render2D_Operation_Normal |
1969 PM3Render2D_SpanOperation |
1970 (PM3Render2D_Width(p->var.xres)) |
1971 (PM3Render2D_Height(p->var.yres - sy)));
1973 pm3fb_wait_pm3(l_fb_info);
1975 #endif /* FBCON_HAS_CFB32 */
1976 #ifdef FBCON_HAS_CFB16
1977 static void pm3fb_cfb16_clear(struct vc_data *conp,
1979 int sy, int sx, int height, int width)
1981 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
1986 sx = sx * fontwidth(p);
1987 width = width * fontwidth(p);
1988 sy = sy * fontheight(p);
1989 height = height * fontheight(p);
1990 c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
1995 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
1996 PM3_WRITE_REG(PM3ForegroundColor, c);
1998 PM3_WRITE_REG(PM3FBBlockColor, c);
2000 PM3_WRITE_REG(PM3Config2D,
2001 PM3Config2D_UseConstantSource |
2002 PM3Config2D_ForegroundROPEnable |
2003 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2004 PM3Config2D_FBWriteEnable);
2006 PM3_WRITE_REG(PM3RectanglePosition,
2007 (PM3RectanglePosition_XOffset(sx)) |
2008 (PM3RectanglePosition_YOffset(sy)));
2010 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2011 PM3_WRITE_REG(PM3Render2D,
2012 PM3Render2D_XPositive |
2013 PM3Render2D_YPositive |
2014 PM3Render2D_Operation_Normal |
2015 PM3Render2D_SpanOperation |
2016 (PM3Render2D_Width(width)) |
2017 (PM3Render2D_Height(height)));
2019 PM3_WRITE_REG(PM3Render2D,
2020 PM3Render2D_XPositive |
2021 PM3Render2D_YPositive |
2022 PM3Render2D_Operation_Normal |
2023 (PM3Render2D_Width(width)) |
2024 (PM3Render2D_Height(height)));
2026 pm3fb_wait_pm3(l_fb_info);
2029 static void pm3fb_cfb16_clear_margins(struct vc_data *conp,
2030 struct display *p, int bottom_only)
2032 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2038 sx = conp->vc_cols * fontwidth(p); /* right margin */
2039 sy = conp->vc_rows * fontheight(p); /* bottom margin */
2040 c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
2043 if (!bottom_only) { /* right margin top->bottom */
2046 PM3_WRITE_REG(PM3Config2D,
2047 PM3Config2D_UseConstantSource |
2048 PM3Config2D_ForegroundROPEnable |
2049 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2050 PM3Config2D_FBWriteEnable);
2052 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2053 PM3_WRITE_REG(PM3ForegroundColor, c);
2055 PM3_WRITE_REG(PM3FBBlockColor, c);
2057 PM3_WRITE_REG(PM3RectanglePosition,
2058 (PM3RectanglePosition_XOffset
2060 sx)) | (PM3RectanglePosition_YOffset(p->
2063 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2064 PM3_WRITE_REG(PM3Render2D,
2065 PM3Render2D_XPositive |
2066 PM3Render2D_YPositive |
2067 PM3Render2D_Operation_Normal |
2068 PM3Render2D_SpanOperation |
2069 (PM3Render2D_Width(p->var.xres - sx)) |
2070 (PM3Render2D_Height(p->var.yres)));
2072 PM3_WRITE_REG(PM3Render2D,
2073 PM3Render2D_XPositive |
2074 PM3Render2D_YPositive |
2075 PM3Render2D_Operation_Normal |
2076 (PM3Render2D_Width(p->var.xres - sx)) |
2077 (PM3Render2D_Height(p->var.yres)));
2080 /* bottom margin left -> right */
2083 PM3_WRITE_REG(PM3Config2D,
2084 PM3Config2D_UseConstantSource |
2085 PM3Config2D_ForegroundROPEnable |
2086 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2087 PM3Config2D_FBWriteEnable);
2089 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2090 PM3_WRITE_REG(PM3ForegroundColor, c);
2092 PM3_WRITE_REG(PM3FBBlockColor, c);
2095 PM3_WRITE_REG(PM3RectanglePosition,
2096 (PM3RectanglePosition_XOffset(p->var.xoffset)) |
2097 (PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
2099 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2100 PM3_WRITE_REG(PM3Render2D,
2101 PM3Render2D_XPositive |
2102 PM3Render2D_YPositive |
2103 PM3Render2D_Operation_Normal |
2104 PM3Render2D_SpanOperation |
2105 (PM3Render2D_Width(p->var.xres)) |
2106 (PM3Render2D_Height(p->var.yres - sy)));
2108 PM3_WRITE_REG(PM3Render2D,
2109 PM3Render2D_XPositive |
2110 PM3Render2D_YPositive |
2111 PM3Render2D_Operation_Normal |
2112 (PM3Render2D_Width(p->var.xres)) |
2113 (PM3Render2D_Height(p->var.yres - sy)));
2115 pm3fb_wait_pm3(l_fb_info);
2117 #endif /* FBCON_HAS_CFB16 */
2118 #ifdef FBCON_HAS_CFB8
2119 static void pm3fb_cfb8_clear(struct vc_data *conp,
2121 int sy, int sx, int height, int width)
2123 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2128 sx = sx * fontwidth(p);
2129 width = width * fontwidth(p);
2130 sy = sy * fontheight(p);
2131 height = height * fontheight(p);
2133 c = attr_bgcol_ec(p, conp);
2139 PM3_WRITE_REG(PM3Config2D,
2140 PM3Config2D_UseConstantSource |
2141 PM3Config2D_ForegroundROPEnable |
2142 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2143 PM3Config2D_FBWriteEnable);
2145 PM3_WRITE_REG(PM3ForegroundColor, c);
2147 PM3_WRITE_REG(PM3RectanglePosition,
2148 (PM3RectanglePosition_XOffset(sx)) |
2149 (PM3RectanglePosition_YOffset(sy)));
2151 PM3_WRITE_REG(PM3Render2D,
2152 PM3Render2D_XPositive |
2153 PM3Render2D_YPositive |
2154 PM3Render2D_Operation_Normal |
2155 PM3Render2D_SpanOperation |
2156 (PM3Render2D_Width(width)) |
2157 (PM3Render2D_Height(height)));
2159 pm3fb_wait_pm3(l_fb_info);
2162 static void pm3fb_cfb8_clear_margins(struct vc_data *conp,
2163 struct display *p, int bottom_only)
2165 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2171 sx = conp->vc_cols * fontwidth(p); /* right margin */
2172 sy = conp->vc_rows * fontheight(p); /* bottom margin */
2173 c = attr_bgcol_ec(p, conp);
2177 if (!bottom_only) { /* right margin top->bottom */
2180 PM3_WRITE_REG(PM3Config2D,
2181 PM3Config2D_UseConstantSource |
2182 PM3Config2D_ForegroundROPEnable |
2183 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2184 PM3Config2D_FBWriteEnable);
2186 PM3_WRITE_REG(PM3ForegroundColor, c);
2188 PM3_WRITE_REG(PM3RectanglePosition,
2189 (PM3RectanglePosition_XOffset
2191 sx)) | (PM3RectanglePosition_YOffset(p->
2195 PM3_WRITE_REG(PM3Render2D,
2196 PM3Render2D_XPositive |
2197 PM3Render2D_YPositive |
2198 PM3Render2D_Operation_Normal |
2199 PM3Render2D_SpanOperation |
2200 (PM3Render2D_Width(p->var.xres - sx)) |
2201 (PM3Render2D_Height(p->var.yres)));
2204 /* bottom margin left -> right */
2207 PM3_WRITE_REG(PM3Config2D,
2208 PM3Config2D_UseConstantSource |
2209 PM3Config2D_ForegroundROPEnable |
2210 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2211 PM3Config2D_FBWriteEnable);
2213 PM3_WRITE_REG(PM3ForegroundColor, c);
2215 PM3_WRITE_REG(PM3RectanglePosition,
2216 (PM3RectanglePosition_XOffset(p->var.xoffset)) |
2217 (PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
2219 PM3_WRITE_REG(PM3Render2D,
2220 PM3Render2D_XPositive |
2221 PM3Render2D_YPositive |
2222 PM3Render2D_Operation_Normal |
2223 PM3Render2D_SpanOperation |
2224 (PM3Render2D_Width(p->var.xres)) |
2225 (PM3Render2D_Height(p->var.yres - sy)));
2227 pm3fb_wait_pm3(l_fb_info);
2229 #endif /* FBCON_HAS_CFB8 */
2230 #if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
2231 static void pm3fb_cfbX_bmove(struct display *p,
2233 int dy, int dx, int height, int width)
2235 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2236 int x_align, o_x, o_y;
2240 sx = sx * fontwidth(p);
2241 dx = dx * fontwidth(p);
2242 width = width * fontwidth(p);
2243 sy = sy * fontheight(p);
2244 dy = dy * fontheight(p);
2245 height = height * fontheight(p);
2247 o_x = sx - dx; /*(sx > dx ) ? (sx - dx) : (dx - sx); */
2248 o_y = sy - dy; /*(sy > dy ) ? (sy - dy) : (dy - sy); */
2250 x_align = (sx & 0x1f);
2254 PM3_WRITE_REG(PM3Config2D,
2255 PM3Config2D_UserScissorEnable |
2256 PM3Config2D_ForegroundROPEnable |
2257 PM3Config2D_Blocking |
2258 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2259 PM3Config2D_FBWriteEnable);
2261 PM3_WRITE_REG(PM3ScissorMinXY,
2262 ((dy & 0x0fff) << 16) | (dx & 0x0fff));
2263 PM3_WRITE_REG(PM3ScissorMaxXY,
2264 (((dy + height) & 0x0fff) << 16) |
2265 ((dx + width) & 0x0fff));
2267 PM3_WRITE_REG(PM3FBSourceReadBufferOffset,
2268 PM3FBSourceReadBufferOffset_XOffset(o_x) |
2269 PM3FBSourceReadBufferOffset_YOffset(o_y));
2271 PM3_WRITE_REG(PM3RectanglePosition,
2272 (PM3RectanglePosition_XOffset(dx - x_align)) |
2273 (PM3RectanglePosition_YOffset(dy)));
2275 PM3_WRITE_REG(PM3Render2D,
2276 ((sx > dx) ? PM3Render2D_XPositive : 0) |
2277 ((sy > dy) ? PM3Render2D_YPositive : 0) |
2278 PM3Render2D_Operation_Normal |
2279 PM3Render2D_SpanOperation |
2280 PM3Render2D_FBSourceReadEnable |
2281 (PM3Render2D_Width(width + x_align)) |
2282 (PM3Render2D_Height(height)));
2284 pm3fb_wait_pm3(l_fb_info);
2287 static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p,
2288 int c, int yy, int xx)
2290 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2291 u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0;
2297 if (l_fb_info->current_par->depth == 8)
2298 fgx = attr_fgcol(p, c);
2299 else if (depth2bpp(l_fb_info->current_par->depth) == 16)
2300 fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, c)];
2302 fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, c)];
2306 if (l_fb_info->current_par->depth == 8)
2307 bgx = attr_bgcol(p, c);
2308 else if (depth2bpp(l_fb_info->current_par->depth) == 16)
2309 bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, c)];
2311 bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, c)];
2317 PM3_WRITE_REG(PM3Config2D,
2318 PM3Config2D_UseConstantSource |
2319 PM3Config2D_ForegroundROPEnable |
2320 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2321 PM3Config2D_FBWriteEnable | PM3Config2D_OpaqueSpan);
2323 PM3_WRITE_REG(PM3ForegroundColor, fgx);
2324 PM3_WRITE_REG(PM3FillBackgroundColor, bgx);
2326 /* WARNING : adress select X need to specify 8 bits for fontwidth <= 8 */
2327 /* and 16 bits for fontwidth <= 16 */
2328 /* same in _putcs, same for Y and fontheight */
2329 if (fontwidth(p) <= 8)
2331 else if (fontwidth(p) <= 16)
2332 asx = 3; /* look OK */
2333 if (fontheight(p) <= 8)
2335 else if (fontheight(p) <= 16)
2336 asy = 3; /* look OK */
2337 else if (fontheight(p) <= 32)
2338 asy = 4; /* look OK */
2340 sx = xx * fontwidth(p);
2341 sy = yy * fontheight(p);
2343 if (fontwidth(p) <= 8)
2344 o_x = (8 - (sx & 0x7)) & 0x7;
2345 else if (fontwidth(p) <= 16)
2346 o_x = (16 - (sx & 0xF)) & 0xF;
2347 if (fontheight(p) <= 8)
2348 o_y = (8 - (sy & 0x7)) & 0x7;
2349 else if (fontheight(p) <= 16)
2350 o_y = (16 - (sy & 0xF)) & 0xF;
2351 else if (fontheight(p) <= 32)
2352 o_y = (32 - (sy & 0x1F)) & 0x1F;
2354 PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */
2355 (1 << 18) | /* BE */
2356 1 | (asx << 1) | (asy << 4) | /* address select x/y */
2357 (1 << 20)); /* OpaqueSpan */
2359 if (fontwidth(p) <= 8) {
2360 cdat = p->fontdata + (c & p->charmask) * fontheight(p);
2364 ((c & p->charmask) * (fontheight(p) << 1));
2367 PM3_WAIT(2 + fontheight(p));
2369 for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */
2370 if (fontwidth(p) <= 8) {
2372 } else { /* assume fontwidth <= 16 ATM */
2374 ldat = ((*cdat++) << 8);
2377 PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat);
2380 PM3_WRITE_REG(PM3RectanglePosition,
2381 (PM3RectanglePosition_XOffset(sx)) |
2382 (PM3RectanglePosition_YOffset(sy)));
2384 PM3_WRITE_REG(PM3Render2D,
2385 PM3Render2D_AreaStippleEnable |
2386 PM3Render2D_XPositive |
2387 PM3Render2D_YPositive |
2388 PM3Render2D_Operation_Normal |
2389 PM3Render2D_SpanOperation |
2390 (PM3Render2D_Width(fontwidth(p))) |
2391 (PM3Render2D_Height(fontheight(p))));
2393 pm3fb_wait_pm3(l_fb_info);
2396 static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p,
2397 const unsigned short *s, int count, int yy,
2400 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2401 u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0;
2409 if (l_fb_info->current_par->depth == 8)
2410 fgx = attr_fgcol(p, sc);
2411 else if (depth2bpp(l_fb_info->current_par->depth) == 16)
2412 fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, sc)];
2414 fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, sc)];
2418 if (l_fb_info->current_par->depth == 8)
2419 bgx = attr_bgcol(p, sc);
2420 else if (depth2bpp(l_fb_info->current_par->depth) == 16)
2421 bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, sc)];
2423 bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, sc)];
2429 PM3_WRITE_REG(PM3Config2D,
2430 PM3Config2D_UseConstantSource |
2431 PM3Config2D_ForegroundROPEnable |
2432 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2433 PM3Config2D_FBWriteEnable |
2434 PM3Config2D_OpaqueSpan);
2436 PM3_WRITE_REG(PM3ForegroundColor, fgx);
2437 PM3_WRITE_REG(PM3FillBackgroundColor, bgx);
2439 /* WARNING : adress select X need to specify 8 bits for fontwidth <= 8 */
2440 /* and 16 bits for fontwidth <= 16 */
2441 /* same in _putc, same for Y and fontheight */
2442 if (fontwidth(p) <= 8)
2444 else if (fontwidth(p) <= 16)
2445 asx = 3; /* look OK */
2446 if (fontheight(p) <= 8)
2448 else if (fontheight(p) <= 16)
2449 asy = 3; /* look OK */
2450 else if (fontheight(p) <= 32)
2451 asy = 4; /* look OK */
2453 sy = yy * fontheight(p);
2455 if (fontheight(p) <= 8)
2456 o_y = (8 - (sy & 0x7)) & 0x7;
2457 else if (fontheight(p) <= 16)
2458 o_y = (16 - (sy & 0xF)) & 0xF;
2459 else if (fontheight(p) <= 32)
2460 o_y = (32 - (sy & 0x1F)) & 0x1F;
2462 for (j = 0; j < count; j++) {
2463 sc = scr_readw(s + j);
2464 if (fontwidth(p) <= 8)
2465 cdat = p->fontdata +
2466 (sc & p->charmask) * fontheight(p);
2468 cdat = p->fontdata +
2469 ((sc & p->charmask) * fontheight(p) << 1);
2471 sx = (xx + j) * fontwidth(p);
2473 if (fontwidth(p) <= 8)
2474 o_x = (8 - (sx & 0x7)) & 0x7;
2475 else if (fontwidth(p) <= 16)
2476 o_x = (16 - (sx & 0xF)) & 0xF;
2478 PM3_WAIT(3 + fontheight(p));
2480 PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */
2481 (1 << 18) | /* BE */
2482 1 | (asx << 1) | (asy << 4) | /* address select x/y */
2483 (1 << 20)); /* OpaqueSpan */
2485 for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */
2486 if (fontwidth(p) <= 8) {
2488 } else { /* assume fontwidth <= 16 ATM */
2489 ldat = ((*cdat++) << 8);
2492 PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat);
2495 PM3_WRITE_REG(PM3RectanglePosition,
2496 (PM3RectanglePosition_XOffset(sx)) |
2497 (PM3RectanglePosition_YOffset(sy)));
2499 PM3_WRITE_REG(PM3Render2D,
2500 PM3Render2D_AreaStippleEnable |
2501 PM3Render2D_XPositive |
2502 PM3Render2D_YPositive |
2503 PM3Render2D_Operation_Normal |
2504 PM3Render2D_SpanOperation |
2505 (PM3Render2D_Width(fontwidth(p))) |
2506 (PM3Render2D_Height(fontheight(p))));
2508 pm3fb_wait_pm3(l_fb_info);
2511 static void pm3fb_cfbX_revc(struct display *p, int xx, int yy)
2513 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2515 xx = xx * fontwidth(p);
2516 yy = yy * fontheight(p);
2518 if (l_fb_info->current_par->depth == 8)
2520 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2521 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0x0F0F0F0F);
2523 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0x0F0F0F0F);
2528 PM3_WRITE_REG(PM3Config2D,
2529 PM3Config2D_UseConstantSource |
2530 PM3Config2D_ForegroundROPEnable |
2531 (PM3Config2D_ForegroundROP(0xa)) | /* Oxa is GXinvert */
2532 PM3Config2D_FBDestReadEnable |
2533 PM3Config2D_FBWriteEnable);
2535 PM3_WRITE_REG(PM3RectanglePosition,
2536 (PM3RectanglePosition_XOffset(xx)) |
2537 (PM3RectanglePosition_YOffset(yy)));
2539 PM3_WRITE_REG(PM3Render2D,
2540 PM3Render2D_XPositive |
2541 PM3Render2D_YPositive |
2542 PM3Render2D_Operation_Normal |
2543 PM3Render2D_SpanOperation |
2544 (PM3Render2D_Width(fontwidth(p))) |
2545 (PM3Render2D_Height(fontheight(p))));
2547 pm3fb_wait_pm3(l_fb_info);
2549 if (l_fb_info->current_par->depth == 8)
2551 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2552 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xFFFFFFFF);
2554 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xFFFFFFFF);
2558 #endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
2559 #endif /* PM3FB_USE_ACCEL */
2560 /* *********************************** */
2561 /* ***** pre-init board(s) setup ***** */
2562 /* *********************************** */
2564 static void pm3fb_mode_setup(char *mode, unsigned long board_num)
2566 struct pm3fb_info *l_fb_info = &(fb_info[board_num]);
2567 struct pm3fb_par *l_fb_par = &(current_par[board_num]);
2568 unsigned long i = 0;
2570 current_par_valid[board_num] = 0;
2572 if (!strncmp(mode, "current", 7)) {
2573 l_fb_info->use_current = 1; /* default w/ OpenFirmware */
2575 while ((mode_base[i].name[0])
2576 && (!current_par_valid[board_num])) {
2579 (mode, mode_base[i].name,
2580 strlen(mode_base[i].name)))) {
2581 memcpy(l_fb_par, &(mode_base[i].user_mode),
2582 sizeof(struct pm3fb_par));
2583 current_par_valid[board_num] = 1;
2584 DPRINTK(2, "Mode set to %s\n",
2589 DASSERT(current_par_valid[board_num],
2590 "Valid mode on command line\n");
2594 static void pm3fb_pciid_setup(char *pciid, unsigned long board_num)
2596 short l_bus = -1, l_slot = -1, l_func = -1;
2600 l_bus = simple_strtoul(pciid, &next, 10);
2601 if (next && (next[0] == ':')) {
2603 l_slot = simple_strtoul(pciid, &next, 10);
2604 if (next && (next[0] == ':')) {
2607 simple_strtoul(pciid, (char **) NULL,
2614 if ((l_bus >= 0) && (l_slot >= 0) && (l_func >= 0)) {
2615 bus[board_num] = l_bus;
2616 slot[board_num] = l_slot;
2617 func[board_num] = l_func;
2618 DPRINTK(2, "Board #%ld will be PciId: %hd:%hd:%hd\n",
2619 board_num, l_bus, l_slot, l_func);
2621 DPRINTK(1, "Invalid PciId: %hd:%hd:%hd for board #%ld\n",
2622 l_bus, l_slot, l_func, board_num);
2626 static void pm3fb_font_setup(char *lf, unsigned long board_num)
2628 unsigned long lfs = strlen(lf);
2630 if (lfs > (PM3_FONTNAME_SIZE - 1)) {
2631 DPRINTK(1, "Fontname %s too long\n", lf);
2634 strncpy(fontn[board_num], lf, lfs);
2635 fontn[board_num][lfs] = '\0';
2638 static void pm3fb_bootdepth_setup(char *bds, unsigned long board_num)
2640 unsigned long bd = simple_strtoul(bds, (char **) NULL, 10);
2642 if (!(depth_supported(bd))) {
2643 printk(KERN_WARNING "pm3fb: ignoring invalid depth %s for board #%ld\n",
2647 depth[board_num] = bd;
2650 static void pm3fb_forcesize_setup(char *bds, unsigned long board_num)
2652 unsigned long bd = simple_strtoul(bds, (char **) NULL, 10);
2655 printk(KERN_WARNING "pm3fb: ignoring invalid memory size %s for board #%ld\n",
2659 forcesize[board_num] = bd;
2662 static char *pm3fb_boardnum_setup(char *options, unsigned long *bn)
2666 if (!(CHAR_IS_NUM(options[0]))) {
2671 (*bn) = simple_strtoul(options, &next, 10);
2673 if (next && (next[0] == ':') && ((*bn) >= 0)
2674 && ((*bn) <= PM3_MAX_BOARD)) {
2675 DPRINTK(2, "Board_num seen as %ld\n", (*bn));
2679 DPRINTK(2, "Board_num default to %ld\n", (*bn));
2684 static void pm3fb_real_setup(char *options)
2687 unsigned long i, bn;
2688 struct pm3fb_info *l_fb_info;
2692 DPRINTK(2, "Options : %s\n", options);
2694 for (i = 0; i < PM3_MAX_BOARD; i++) {
2695 l_fb_info = &(fb_info[i]);
2696 memset(l_fb_info, 0, sizeof(struct pm3fb_info));
2697 l_fb_info->gen.fbhw = &pm3fb_switch;
2698 l_fb_info->board_num = i;
2699 current_par_valid[i] = 0;
2707 l_fb_info->current_par = &(current_par[i]);
2710 /* eat up prefix pm3fb and whatever is used as separator i.e. :,= */
2711 if (!strncmp(options, "pm3fb", 5)) {
2713 while (((*options) == ',') || ((*options) == ':')
2714 || ((*options) == '='))
2720 if ((next = strchr(options, ','))) {
2725 if (!strncmp(options, "mode:", 5)) {
2726 options = pm3fb_boardnum_setup(options + 5, &bn);
2727 DPRINTK(2, "Setting mode for board #%ld\n", bn);
2728 pm3fb_mode_setup(options, bn);
2729 } else if (!strncmp(options, "off:", 4)) {
2730 options = pm3fb_boardnum_setup(options + 4, &bn);
2731 DPRINTK(2, "Disabling board #%ld\n", bn);
2733 } else if (!strncmp(options, "off", 3)) { /* disable everything */
2734 for (i = 0; i < PM3_MAX_BOARD; i++)
2736 } else if (!strncmp(options, "disable:", 8)) {
2737 options = pm3fb_boardnum_setup(options + 8, &bn);
2738 DPRINTK(2, "Disabling board #%ld\n", bn);
2740 } else if (!strncmp(options, "pciid:", 6)) {
2741 options = pm3fb_boardnum_setup(options + 6, &bn);
2742 DPRINTK(2, "Setting PciID for board #%ld\n", bn);
2743 pm3fb_pciid_setup(options, bn);
2744 } else if (!strncmp(options, "noaccel:", 8)) {
2745 options = pm3fb_boardnum_setup(options + 8, &bn);
2747 } else if (!strncmp(options, "font:", 5)) {
2748 options = pm3fb_boardnum_setup(options + 5, &bn);
2749 pm3fb_font_setup(options, bn);
2750 } else if (!strncmp(options, "depth:", 6)) {
2751 options = pm3fb_boardnum_setup(options + 6, &bn);
2752 pm3fb_bootdepth_setup(options, bn);
2753 } else if (!strncmp(options, "printtimings", 12)) {
2755 } else if (!strncmp(options, "flatpanel:", 10)) {
2756 options = pm3fb_boardnum_setup(options + 10, &bn);
2758 } else if (!strncmp(options, "forcesize:", 10)) {
2759 options = pm3fb_boardnum_setup(options + 10, &bn);
2760 pm3fb_forcesize_setup(options, bn);
2766 /* ********************************************** */
2767 /* ***** framebuffer API standard functions ***** */
2768 /* ********************************************** */
2770 static int pm3fb_open(struct fb_info *info, int user)
2779 static int pm3fb_release(struct fb_info *info, int user)
2788 static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix,
2789 const void *par, struct fb_info_gen *info)
2791 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
2792 struct pm3fb_par *p = (struct pm3fb_par *) par;
2796 strcpy(fix->id, permedia3_name);
2797 fix->smem_start = (unsigned long)l_fb_info->p_fb;
2798 fix->smem_len = l_fb_info->fb_size;
2799 fix->mmio_start = (unsigned long)l_fb_info->pIOBase;
2800 fix->mmio_len = PM3_REGS_SIZE;
2801 #ifdef PM3FB_USE_ACCEL
2802 if (!(noaccel[l_fb_info->board_num]))
2803 fix->accel = FB_ACCEL_3DLABS_PERMEDIA3;
2805 #endif /* PM3FB_USE_ACCEL */
2806 fix->accel = FB_ACCEL_NONE;
2807 fix->type = FB_TYPE_PACKED_PIXELS;
2809 (p->depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
2810 if (current_par_valid[l_fb_info->board_num])
2812 l_fb_info->current_par->width *
2813 depth2ByPP(l_fb_info->current_par->depth);
2815 fix->line_length = 0;
2816 fix->xpanstep = 64 / depth2bpp(p->depth);
2822 static int pm3fb_decode_var(const struct fb_var_screeninfo *var,
2823 void *par, struct fb_info_gen *info)
2825 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
2826 struct pm3fb_par *p = (struct pm3fb_par *) par;
2827 struct pm3fb_par temp_p;
2832 DASSERT((var != NULL), "fb_var_screeninfo* not NULL");
2833 DASSERT((p != NULL), "pm3fb_par* not NULL");
2834 DASSERT((l_fb_info != NULL), "pm3fb_info* not NULL");
2836 memset(&temp_p, 0, sizeof(struct pm3fb_par));
2837 temp_p.width = (var->xres_virtual + 7) & ~7;
2838 temp_p.height = var->yres_virtual;
2840 if (!(depth_supported(var->bits_per_pixel))) /* round unsupported up to a multiple of 8 */
2841 temp_p.depth = depth2bpp(var->bits_per_pixel);
2843 temp_p.depth = var->bits_per_pixel;
2845 temp_p.depth = (temp_p.depth > 32) ? 32 : temp_p.depth; /* max 32 */
2846 temp_p.depth = (temp_p.depth == 24) ? 32 : temp_p.depth; /* 24 unsupported, round-up to 32 */
2848 if ((temp_p.depth == 16) && (var->red.length == 5) && (var->green.length == 5) && (var->blue.length == 5))
2849 temp_p.depth = 15; /* RGBA 5551 is stored as depth 15 */
2851 if ((temp_p.depth == 16) && (var->red.length == 4) && (var->green.length == 4) && (var->blue.length == 4))
2852 temp_p.depth = 12; /* RGBA 4444 is stored as depth 12 */
2856 "xres: %d, yres: %d, vxres: %d, vyres: %d ; xoffset:%d, yoffset: %d\n",
2857 var->xres, var->yres, var->xres_virtual, var->yres_virtual,
2858 var->xoffset, var->yoffset);
2860 xres = (var->xres + 31) & ~31;
2861 if (temp_p.width < xres + var->xoffset)
2862 temp_p.width = xres + var->xoffset;
2863 if (temp_p.height < var->yres + var->yoffset)
2864 temp_p.height = var->yres + var->yoffset;
2866 if (temp_p.width > 2048) {
2867 DPRINTK(1, "virtual width not supported: %u\n",
2871 if (var->yres < 200) {
2872 DPRINTK(1, "height not supported: %u\n", (u32) var->yres);
2875 if (temp_p.height < 200 || temp_p.height > 4095) {
2876 DPRINTK(1, "virtual height not supported: %u\n",
2880 if (!(depth_supported(temp_p.depth))) {
2881 DPRINTK(1, "depth not supported: %u\n", temp_p.depth);
2884 if ((temp_p.width * temp_p.height * depth2ByPP(temp_p.depth)) >
2885 l_fb_info->fb_size) {
2886 DPRINTK(1, "no memory for screen (%ux%ux%u)\n",
2887 temp_p.width, temp_p.height, temp_p.depth);
2891 if ((!var->pixclock) ||
2892 (!var->right_margin) ||
2893 (!var->hsync_len) ||
2894 (!var->left_margin) ||
2895 (!var->lower_margin) ||
2896 (!var->vsync_len) || (!var->upper_margin)
2898 unsigned long i = 0, done = 0;
2899 printk(KERN_WARNING "pm3fb: refusing to use a likely wrong timing\n");
2901 while ((mode_base[i].user_mode.width) && !done) {
2902 if ((mode_base[i].user_mode.width == temp_p.width)
2903 && (mode_base[i].user_mode.height ==
2905 printk(KERN_NOTICE "pm3fb: using close match %s\n",
2907 temp_p = mode_base[i].user_mode;
2915 temp_p.pixclock = PICOS2KHZ(var->pixclock);
2916 if (temp_p.pixclock > PM3_MAX_PIXCLOCK) {
2917 DPRINTK(1, "pixclock too high (%uKHz)\n",
2922 temp_p.hsstart = var->right_margin;
2923 temp_p.hsend = var->right_margin + var->hsync_len;
2925 var->right_margin + var->hsync_len + var->left_margin;
2926 temp_p.htotal = xres + temp_p.hbend;
2928 temp_p.vsstart = var->lower_margin;
2929 temp_p.vsend = var->lower_margin + var->vsync_len;
2931 var->lower_margin + var->vsync_len + var->upper_margin;
2932 temp_p.vtotal = var->yres + temp_p.vbend;
2934 temp_p.stride = temp_p.width;
2936 DPRINTK(2, "Using %d * %d, %d Khz, stride is %08x\n",
2937 temp_p.width, temp_p.height, temp_p.pixclock,
2941 pm3fb_Shiftbpp(l_fb_info, temp_p.depth,
2942 (var->yoffset * xres) + var->xoffset);
2946 if (var->sync & FB_SYNC_HOR_HIGH_ACT)
2947 temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_HIGH;
2949 temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_LOW;
2951 if (var->sync & FB_SYNC_VERT_HIGH_ACT)
2952 temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_HIGH;
2954 temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_LOW;
2956 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
2957 DPRINTK(1, "Interlaced mode not supported\n\n");
2961 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
2962 temp_p.video |= PM3VideoControl_LINE_DOUBLE_ON;
2964 temp_p.video |= PM3VideoControl_LINE_DOUBLE_OFF;
2966 if (var->activate == FB_ACTIVATE_NOW)
2967 temp_p.video |= PM3VideoControl_ENABLE;
2969 temp_p.video |= PM3VideoControl_DISABLE;
2970 DPRINTK(2, "PM3Video disabled\n");
2973 switch (temp_p.depth) {
2975 temp_p.video |= PM3VideoControl_PIXELSIZE_8BIT;
2980 temp_p.video |= PM3VideoControl_PIXELSIZE_16BIT;
2983 temp_p.video |= PM3VideoControl_PIXELSIZE_32BIT;
2986 DPRINTK(1, "Unsupported depth\n");
2992 #ifdef PM3FB_USE_ACCEL
2993 if (var->accel_flags & FB_ACCELF_TEXT)
2994 noaccel[l_fb_info->board_num] = 0;
2996 noaccel[l_fb_info->board_num] = 1;
2997 #endif /* PM3FB_USE_ACCEL */
3002 static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d)
3006 var->red.length = var->green.length = var->blue.length = 8;
3007 var->red.offset = var->green.offset = var->blue.offset = 0;
3008 var->transp.offset = var->transp.length = 0;
3012 var->red.offset = 8;
3013 var->red.length = 4;
3014 var->green.offset = 4;
3015 var->green.length = 4;
3016 var->blue.offset = 0;
3017 var->blue.length = 4;
3018 var->transp.offset = 12;
3019 var->transp.length = 4;
3023 var->red.offset = 10;
3024 var->red.length = 5;
3025 var->green.offset = 5;
3026 var->green.length = 5;
3027 var->blue.offset = 0;
3028 var->blue.length = 5;
3029 var->transp.offset = 15;
3030 var->transp.length = 1;
3034 var->red.offset = 11;
3035 var->red.length = 5;
3036 var->green.offset = 5;
3037 var->green.length = 6;
3038 var->blue.offset = 0;
3039 var->blue.length = 5;
3040 var->transp.offset = var->transp.length = 0;
3044 var->transp.offset = 24;
3045 var->red.offset = 16;
3046 var->green.offset = 8;
3047 var->blue.offset = 0;
3048 var->red.length = var->green.length =
3049 var->blue.length = var->transp.length = 8;
3053 DPRINTK(1, "Unsupported depth %ld\n", d);
3058 static int pm3fb_encode_var(struct fb_var_screeninfo *var,
3059 const void *par, struct fb_info_gen *info)
3061 struct pm3fb_par *p = (struct pm3fb_par *) par;
3062 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3068 DASSERT((var != NULL), "fb_var_screeninfo* not NULL");
3069 DASSERT((p != NULL), "pm3fb_par* not NULL");
3070 DASSERT((info != NULL), "fb_info_gen* not NULL");
3072 memset(var, 0, sizeof(struct fb_var_screeninfo));
3074 #ifdef PM3FB_USE_ACCEL
3075 if (!(noaccel[l_fb_info->board_num]))
3076 var->accel_flags |= FB_ACCELF_TEXT;
3077 #endif /* PM3FB_USE_ACCEL */
3079 var->xres_virtual = p->width;
3080 var->yres_virtual = p->height;
3081 var->xres = p->htotal - p->hbend;
3082 var->yres = p->vtotal - p->vbend;
3084 DPRINTK(2, "xres = %d, yres : %d\n", var->xres, var->yres);
3086 var->right_margin = p->hsstart;
3087 var->hsync_len = p->hsend - p->hsstart;
3088 var->left_margin = p->hbend - p->hsend;
3089 var->lower_margin = p->vsstart;
3090 var->vsync_len = p->vsend - p->vsstart;
3091 var->upper_margin = p->vbend - p->vsend;
3092 var->bits_per_pixel = depth2bpp(p->depth);
3094 pm3fb_encode_depth(var, p->depth);
3096 base = pm3fb_Unshiftbpp(l_fb_info, p->depth, p->base);
3098 var->xoffset = base % var->xres;
3099 var->yoffset = base / var->xres;
3101 var->height = var->width = -1;
3103 var->pixclock = KHZ2PICOS(p->pixclock);
3105 if ((p->video & PM3VideoControl_HSYNC_MASK) ==
3106 PM3VideoControl_HSYNC_ACTIVE_HIGH)
3107 var->sync |= FB_SYNC_HOR_HIGH_ACT;
3108 if ((p->video & PM3VideoControl_VSYNC_MASK) ==
3109 PM3VideoControl_VSYNC_ACTIVE_HIGH)
3110 var->sync |= FB_SYNC_VERT_HIGH_ACT;
3111 if (p->video & PM3VideoControl_LINE_DOUBLE_ON)
3112 var->vmode = FB_VMODE_DOUBLE;
3117 static void pm3fb_get_par(void *par, struct fb_info_gen *info)
3119 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3123 if (!current_par_valid[l_fb_info->board_num]) {
3124 if (l_fb_info->use_current)
3125 pm3fb_read_mode(l_fb_info, l_fb_info->current_par);
3127 memcpy(l_fb_info->current_par,
3128 &(mode_base[0].user_mode),
3129 sizeof(struct pm3fb_par));
3130 current_par_valid[l_fb_info->board_num] = 1;
3132 *((struct pm3fb_par *) par) = *(l_fb_info->current_par);
3135 static void pm3fb_set_par(const void *par, struct fb_info_gen *info)
3137 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3141 *(l_fb_info->current_par) = *((struct pm3fb_par *) par);
3142 current_par_valid[l_fb_info->board_num] = 1;
3144 pm3fb_write_mode(l_fb_info);
3146 #ifdef PM3FB_USE_ACCEL
3147 pm3fb_init_engine(l_fb_info);
3148 #endif /* PM3FB_USE_ACCEL */
3151 static void pm3fb_set_color(struct pm3fb_info *l_fb_info,
3152 unsigned char regno, unsigned char r,
3153 unsigned char g, unsigned char b)
3157 PM3_SLOW_WRITE_REG(PM3RD_PaletteWriteAddress, regno);
3158 PM3_SLOW_WRITE_REG(PM3RD_PaletteData, r);
3159 PM3_SLOW_WRITE_REG(PM3RD_PaletteData, g);
3160 PM3_SLOW_WRITE_REG(PM3RD_PaletteData, b);
3163 static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green,
3164 unsigned *blue, unsigned *transp,
3165 struct fb_info *info)
3167 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3173 l_fb_info->palette[regno].red << 8 | l_fb_info->
3176 l_fb_info->palette[regno].green << 8 | l_fb_info->
3177 palette[regno].green;
3179 l_fb_info->palette[regno].blue << 8 | l_fb_info->
3180 palette[regno].blue;
3182 l_fb_info->palette[regno].transp << 8 | l_fb_info->
3183 palette[regno].transp;
3185 return (regno > 255);
3188 static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
3189 unsigned blue, unsigned transp,
3190 struct fb_info *info)
3192 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3197 switch (l_fb_info->current_par->depth) {
3198 #ifdef FBCON_HAS_CFB8
3202 #ifdef FBCON_HAS_CFB16
3204 l_fb_info->cmap.cmap12[regno] =
3205 (((u32) red & 0xf000) >> 4) |
3206 (((u32) green & 0xf000) >> 8) |
3207 (((u32) blue & 0xf000) >> 12);
3211 l_fb_info->cmap.cmap15[regno] =
3212 (((u32) red & 0xf800) >> 1) |
3213 (((u32) green & 0xf800) >> 6) |
3214 (((u32) blue & 0xf800) >> 11);
3218 l_fb_info->cmap.cmap16[regno] =
3219 ((u32) red & 0xf800) |
3220 (((u32) green & 0xfc00) >> 5) |
3221 (((u32) blue & 0xf800) >> 11);
3224 #ifdef FBCON_HAS_CFB32
3226 l_fb_info->cmap.cmap32[regno] =
3227 (((u32) transp & 0xff00) << 16) |
3228 (((u32) red & 0xff00) << 8) |
3229 (((u32) green & 0xff00)) |
3230 (((u32) blue & 0xff00) >> 8);
3234 DPRINTK(1, "bad depth %u\n",
3235 l_fb_info->current_par->depth);
3240 l_fb_info->palette[regno].red = red >> 8;
3241 l_fb_info->palette[regno].green = green >> 8;
3242 l_fb_info->palette[regno].blue = blue >> 8;
3243 l_fb_info->palette[regno].transp = transp >> 8;
3244 if (l_fb_info->current_par->depth == 8)
3245 pm3fb_set_color(l_fb_info, regno, red >> 8,
3246 green >> 8, blue >> 8);
3248 return (regno > 255);
3251 static int pm3fb_blank(int blank_mode, struct fb_info_gen *info)
3253 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3258 if (!current_par_valid[l_fb_info->board_num])
3261 video = l_fb_info->current_par->video;
3264 * Oxygen VX1 - it appears that setting PM3VideoControl and
3265 * then PM3RD_SyncControl to the same SYNC settings undoes
3266 * any net change - they seem to xor together. Only set the
3267 * sync options in PM3RD_SyncControl. --rmk
3269 video &= ~(PM3VideoControl_HSYNC_MASK |
3270 PM3VideoControl_VSYNC_MASK);
3271 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
3272 PM3VideoControl_VSYNC_ACTIVE_HIGH;
3274 if (blank_mode > 0) {
3275 switch (blank_mode - 1) {
3277 case VESA_NO_BLANKING: /* FIXME */
3278 video = video & ~(PM3VideoControl_ENABLE);
3281 case VESA_HSYNC_SUSPEND:
3282 video = video & ~(PM3VideoControl_HSYNC_MASK |
3283 PM3VideoControl_BLANK_ACTIVE_LOW);
3285 case VESA_VSYNC_SUSPEND:
3286 video = video & ~(PM3VideoControl_VSYNC_MASK |
3287 PM3VideoControl_BLANK_ACTIVE_LOW);
3289 case VESA_POWERDOWN:
3290 video = video & ~(PM3VideoControl_HSYNC_MASK |
3291 PM3VideoControl_VSYNC_MASK |
3292 PM3VideoControl_BLANK_ACTIVE_LOW);
3295 DPRINTK(1, "Unsupported blanking %d\n",
3302 PM3_SLOW_WRITE_REG(PM3VideoControl, video);
3307 static void pm3fb_set_disp(const void *par, struct display *disp,
3308 struct fb_info_gen *info)
3310 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3311 struct pm3fb_par *p = (struct pm3fb_par *) par;
3318 disp->screen_base = l_fb_info->v_fb;
3320 #ifdef FBCON_HAS_CFB8
3322 #ifdef PM3FB_USE_ACCEL
3323 if (!(noaccel[l_fb_info->board_num]))
3324 disp->dispsw = &pm3fb_cfb8;
3326 #endif /* PM3FB_USE_ACCEL */
3327 disp->dispsw = &fbcon_cfb8;
3330 #ifdef FBCON_HAS_CFB16
3332 #ifdef PM3FB_USE_ACCEL
3333 if (!(noaccel[l_fb_info->board_num]))
3334 disp->dispsw = &pm3fb_cfb16;
3336 #endif /* PM3FB_USE_ACCEL */
3337 disp->dispsw = &fbcon_cfb16;
3338 disp->dispsw_data = l_fb_info->cmap.cmap12;
3341 #ifdef PM3FB_USE_ACCEL
3342 if (!(noaccel[l_fb_info->board_num]))
3343 disp->dispsw = &pm3fb_cfb16;
3345 #endif /* PM3FB_USE_ACCEL */
3346 disp->dispsw = &fbcon_cfb16;
3347 disp->dispsw_data = l_fb_info->cmap.cmap15;
3350 #ifdef PM3FB_USE_ACCEL
3351 if (!(noaccel[l_fb_info->board_num]))
3352 disp->dispsw = &pm3fb_cfb16;
3354 #endif /* PM3FB_USE_ACCEL */
3355 disp->dispsw = &fbcon_cfb16;
3356 disp->dispsw_data = l_fb_info->cmap.cmap16;
3359 #ifdef FBCON_HAS_CFB32
3361 #ifdef PM3FB_USE_ACCEL
3362 if (!(noaccel[l_fb_info->board_num]))
3363 disp->dispsw = &pm3fb_cfb32;
3365 #endif /* PM3FB_USE_ACCEL */
3366 disp->dispsw = &fbcon_cfb32;
3367 disp->dispsw_data = l_fb_info->cmap.cmap32;
3369 #endif /* FBCON_HAS_CFB32 */
3371 disp->dispsw = &fbcon_dummy;
3372 DPRINTK(1, "Invalid depth, using fbcon_dummy\n");
3375 restore_flags(flags);
3379 static void pm3fb_detect(void)
3381 struct pci_dev *dev_array[PM3_MAX_BOARD];
3382 struct pci_dev *dev = NULL;
3383 struct pm3fb_info *l_fb_info = &(fb_info[0]);
3384 unsigned long i, j, done;
3388 for (i = 0; i < PM3_MAX_BOARD; i++) {
3389 dev_array[i] = NULL;
3390 fb_info[i].dev = NULL;
3394 pci_find_device(PCI_VENDOR_ID_3DLABS,
3395 PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev);
3397 for (i = 0; ((i < PM3_MAX_BOARD) && dev); i++) {
3400 pci_find_device(PCI_VENDOR_ID_3DLABS,
3401 PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev);
3404 if (dev) { /* more than PM3_MAX_BOARD */
3405 printk(KERN_WARNING "pm3fb: Warning: more than %d boards found\n",
3409 if (!dev_array[0]) { /* not a single board, abort */
3413 /* allocate user-defined boards */
3414 for (i = 0; i < PM3_MAX_BOARD; i++) {
3415 if ((bus[i] >= 0) && (slot[i] >= 0) && (func[i] >= 0)) {
3416 for (j = 0; j < PM3_MAX_BOARD; j++) {
3417 if ((dev_array[j] != NULL) &&
3418 (dev_array[j]->bus->number == bus[i])
3419 && (PCI_SLOT(dev_array[j]->devfn) ==
3421 && (PCI_FUNC(dev_array[j]->devfn) ==
3423 fb_info[i].dev = dev_array[j];
3424 dev_array[j] = NULL;
3429 /* allocate remaining boards */
3430 for (i = 0; i < PM3_MAX_BOARD; i++) {
3431 if (fb_info[i].dev == NULL) {
3433 for (j = 0; ((j < PM3_MAX_BOARD) && (!done)); j++) {
3434 if (dev_array[j] != NULL) {
3435 fb_info[i].dev = dev_array[j];
3436 dev_array[j] = NULL;
3443 /* at that point, all PCI Permedia3 are detected and allocated */
3444 /* now, initialize... or not */
3445 for (i = 0; i < PM3_MAX_BOARD; i++) {
3446 l_fb_info = &(fb_info[i]);
3447 if ((l_fb_info->dev) && (!disable[i])) { /* PCI device was found and not disabled by user */
3448 #ifdef SUPPORT_FB_OF
3449 struct device_node *dp =
3450 find_pci_device_OFnode(l_fb_info->dev->bus->
3452 l_fb_info->dev->devfn);
3454 if ((dp) && (!strncmp(dp->name, "formacGA12", 10))) {
3455 /* do nothing, init of board is done in pm3fb_of_init */
3459 "found @%lx Vendor %lx Device %lx ; base @ : %lx - %lx - %lx - %lx - %lx - %lx, irq %ld\n",
3460 (unsigned long) l_fb_info->dev,
3461 (unsigned long) l_fb_info->dev->
3463 (unsigned long) l_fb_info->dev->
3466 pci_resource_start(l_fb_info->dev,
3469 pci_resource_start(l_fb_info->dev,
3472 pci_resource_start(l_fb_info->dev,
3475 pci_resource_start(l_fb_info->dev,
3478 pci_resource_start(l_fb_info->dev,
3481 pci_resource_start(l_fb_info->dev,
3483 (unsigned long) l_fb_info->dev->
3486 l_fb_info->pIOBase =
3488 pci_resource_start(l_fb_info->dev, 0);
3490 l_fb_info->pIOBase += PM3_REGS_SIZE;
3492 l_fb_info->vIOBase = (unsigned char *) -1;
3495 pci_resource_start(l_fb_info->dev, 1);
3496 l_fb_info->v_fb = (unsigned char *) -1;
3498 #if (defined KERNEL_2_4) || (defined KERNEL_2_5) /* full resource management, new in linux-2.4.x */
3499 if (!request_mem_region
3500 ((unsigned long)l_fb_info->p_fb, 64 * 1024 * 1024, /* request full aperture size */
3503 (KERN_ERR "pm3fb: Error: couldn't request framebuffer memory, board #%ld\n",
3504 l_fb_info->board_num);
3507 if (!request_mem_region
3508 ((unsigned long)l_fb_info->pIOBase, PM3_REGS_SIZE,
3509 "pm3fb I/O regs")) {
3511 (KERN_ERR "pm3fb: Error: couldn't request IObase memory, board #%ld\n",
3512 l_fb_info->board_num);
3515 #endif /* KERNEL_2_4 or KERNEL_2_5 */
3516 if (forcesize[l_fb_info->board_num])
3517 l_fb_info->fb_size = forcesize[l_fb_info->board_num];
3519 l_fb_info->fb_size =
3520 pm3fb_size_memory(l_fb_info);
3522 if (l_fb_info->fb_size) {
3523 (void) pci_enable_device(l_fb_info->dev);
3524 pm3fb_common_init(l_fb_info);
3526 printk(KERN_ERR "pm3fb: memory problem, not enabling board #%ld\n", l_fb_info->board_num);
3528 #ifdef SUPPORT_FB_OF
3530 #endif /* SUPPORT_FB_OF */
3535 static int pm3fb_pan_display(const struct fb_var_screeninfo *var,
3536 struct fb_info_gen *info)
3538 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3542 if (!current_par_valid[l_fb_info->board_num])
3545 l_fb_info->current_par->base = /* in 128 bits chunk - i.e. AFTER Shiftbpp */
3546 pm3fb_Shiftbpp(l_fb_info,
3547 l_fb_info->current_par->depth,
3548 (var->yoffset * l_fb_info->current_par->width) +
3550 PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base);
3554 static int pm3fb_ioctl(struct inode *inode, struct file *file,
3555 u_int cmd, u_long arg, int con,
3556 struct fb_info *info)
3558 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3560 #ifdef PM3FB_MASTER_DEBUG
3562 #endif /* PM3FB_MASTER_DEBUG */
3566 #ifdef PM3FB_MASTER_DEBUG
3567 case PM3FBIO_CLEARMEMORY:
3568 if (copy_from_user(&cm, (void *)arg, sizeof(u32)))
3570 pm3fb_clear_memory(l_fb_info, cm);
3574 case PM3FBIO_CLEARCMAP:
3575 if (copy_from_user(cc, (void*)arg, 3 * sizeof(char)))
3577 pm3fb_clear_colormap(l_fb_info, cc[0], cc[1], cc[2]);
3580 #endif /* PM3FB_MASTER_DEBUG */
3582 case PM3FBIO_RESETCHIP:
3584 PM3_SLOW_WRITE_REG(PM3ResetStatus, 1);
3585 for (i = 0 ; (i < 10000) && cm ; i++)
3588 cm = PM3_READ_REG(PM3ResetStatus);
3592 printk(KERN_ERR "pm3fb: chip reset failed with status 0x%x\n", cm);
3595 /* first thing first, reload memory timings */
3596 pm3fb_write_memory_timings(l_fb_info);
3597 #ifdef PM3FB_USE_ACCEL
3598 pm3fb_init_engine(l_fb_info);
3599 #endif /* PM3FB_USE_ACCEL */
3600 pm3fb_write_mode(l_fb_info);
3605 DPRINTK(2, "unknown ioctl: %d (%x)\n", cmd, cmd);
3610 /* ****************************************** */
3611 /* ***** standard FB API init functions ***** */
3612 /* ****************************************** */
3614 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
3615 int __init pm3fb_setup(char *options)
3618 __initfunc(void pm3fb_setup(char *options, int *ints))
3621 long opsi = strlen(options);
3625 memcpy(g_options, options,
3627 PM3_OPTIONS_SIZE) ? PM3_OPTIONS_SIZE : (opsi + 1));
3628 g_options[PM3_OPTIONS_SIZE - 1] = 0;
3630 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
3635 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
3636 int __init pm3fb_init(void)
3639 __initfunc(void pm3fb_init(void))
3644 DPRINTK(2, "This is pm3fb.c, CVS version: $Header: /cvshome/samwise/ppclinux/drivers/video/pm3fb.c,v 1.1.1.1 2005/04/11 02:50:42 jack Exp $");
3646 pm3fb_real_setup(g_options);
3650 if (!fb_info[0].dev) { /* not even one board ??? */
3651 DPRINTK(1, "No PCI Permedia3 board detected\n");
3653 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
3658 #ifdef SUPPORT_FB_OF /* linux-2.2.x only */
3659 __initfunc(void pm3fb_of_init(struct device_node *dp))
3661 struct pm3fb_info *l_fb_info = NULL;
3664 struct device_node *dn;
3668 DPRINTK(2, "OpenFirmware board : %s\n", dp->full_name);
3670 for (i = 0; i < dp->n_addrs; i++) {
3671 DPRINTK(2, "MemRange : 0x%08x - 0x%x\n",
3672 dp->addrs[i].address, dp->addrs[i].size);
3675 for (i = 0; i < PM3_MAX_BOARD; i++) { /* find which PCI board is the OF device */
3676 if (fb_info[i].dev) {
3677 dn = find_pci_device_OFnode(fb_info[i].dev->bus->
3679 fb_info[i].dev->devfn);
3685 "Error: Multiple PCI device for a single OpenFirmware node\n");
3692 DPRINTK(1, "Warning: non-PCI Permedia3 found\n");
3694 while (fb_info[i].dev && (i < PM3_MAX_BOARD))
3696 if (i < PM3_MAX_BOARD)
3700 (KERN_ERR "pm3fb: Error: Couldn't find room for OpenFirmware device");
3705 l_fb_info = &(fb_info[bn]);
3709 l_fb_info->pIOBase = (unsigned char *) dp->addrs[3].address;
3711 l_fb_info->pIOBase += PM3_REGS_SIZE;
3713 l_fb_info->vIOBase = (unsigned char *) -1;
3714 l_fb_info->p_fb = (unsigned char *) dp->addrs[1].address;
3715 l_fb_info->v_fb = (unsigned char *) -1;
3717 l_fb_info->fb_size = pm3fb_size_memory(l_fb_info); /* (unsigned long)dp->addrs[1].size; *//* OF is a liar ! it claims 256 Mb */
3720 "OpenFirmware board (#%ld) : IOBase 0x%08lx, p_fb 0x%08lx, fb_size %d KB\n",
3721 bn, (unsigned long) l_fb_info->pIOBase,
3722 (unsigned long) l_fb_info->p_fb, l_fb_info->fb_size >> 10);
3724 l_fb_info->use_current = 1; /* will use current mode by default */
3726 pm3fb_common_init(l_fb_info);
3728 #endif /* SUPPORT_FB_OF */
3730 /* ************************* */
3731 /* **** Module support ***** */
3732 /* ************************* */
3735 MODULE_AUTHOR("Romain Dolbeau");
3736 MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
3737 static char *mode[PM3_MAX_BOARD];
3738 MODULE_PARM(mode,PM3_MAX_BOARD_MODULE_ARRAY_STRING);
3739 MODULE_PARM_DESC(mode,"video mode");
3740 MODULE_PARM(disable,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
3741 MODULE_PARM_DESC(disable,"disable board");
3742 static short off[PM3_MAX_BOARD];
3743 MODULE_PARM(off,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
3744 MODULE_PARM_DESC(off,"disable board");
3745 static char *pciid[PM3_MAX_BOARD];
3746 MODULE_PARM(pciid,PM3_MAX_BOARD_MODULE_ARRAY_STRING);
3747 MODULE_PARM_DESC(pciid,"board PCI Id");
3748 MODULE_PARM(noaccel,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
3749 MODULE_PARM_DESC(noaccel,"disable accel");
3750 static char *font[PM3_MAX_BOARD];
3751 MODULE_PARM(font,PM3_MAX_BOARD_MODULE_ARRAY_STRING);
3752 MODULE_PARM_DESC(font,"choose font");
3753 MODULE_PARM(depth,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
3754 MODULE_PARM_DESC(depth,"boot-time depth");
3755 MODULE_PARM(printtimings, "h");
3756 MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)");
3757 MODULE_PARM(forcesize, PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
3758 MODULE_PARM_DESC(forcesize, "force specified memory size");
3760 MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards")
3761 MODULE_GENERIC_TABLE(gtype,name)
3762 MODULE_DEVICE_TABLE(type,name)
3765 void pm3fb_build_options(void)
3770 strcpy(g_options, "pm3fb");
3771 for (i = 0; i < PM3_MAX_BOARD ; i++)
3775 sprintf(ts, ",mode:%d:%s", i, mode[i]);
3776 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3778 if (disable[i] || off[i])
3780 sprintf(ts, ",disable:%d:", i);
3781 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3785 sprintf(ts, ",pciid:%d:%s", i, pciid[i]);
3786 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3790 sprintf(ts, ",noaccel:%d:", i);
3791 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3795 sprintf(ts, ",font:%d:%s", i, font[i]);
3796 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3800 sprintf(ts, ",depth:%d:%d", i, depth[i]);
3801 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3804 g_options[PM3_OPTIONS_SIZE - 1] = '\0';
3805 DPRINTK(1, "pm3fb use options: %s\n", g_options);
3808 int init_module(void)
3812 pm3fb_build_options();
3819 void cleanup_module(void)
3824 struct pm3fb_info *l_fb_info;
3825 for (i = 0; i < PM3_MAX_BOARD; i++) {
3826 l_fb_info = &(fb_info[i]);
3827 if ((l_fb_info->dev != NULL)
3828 && (!(disable[l_fb_info->board_num]))) {
3829 if (l_fb_info->vIOBase !=
3830 (unsigned char *) -1) {
3831 pm3fb_unmapIO(l_fb_info);
3832 #if (defined KERNEL_2_4) || (defined KERNEL_2_5)
3833 release_mem_region(l_fb_info->p_fb,
3836 release_mem_region(l_fb_info->
3839 #endif /* KERNEL_2_4 or KERNEL_2_5 */
3841 unregister_framebuffer(&l_fb_info->gen.