Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / video / tridentfb.c
blob0897f03819c28815f1be1ec6c75ec18d25345924
1 /*
2 * Frame buffer driver for Trident Blade and Image series
4 * Copyright 2001, 2002 - Jani Monoses <jani@iv.ro>
7 * CREDITS:(in order of appearance)
8 * skeletonfb.c by Geert Uytterhoeven and other fb code in drivers/video
9 * Special thanks ;) to Mattia Crivellini <tia@mclink.it>
10 * much inspired by the XFree86 4.x Trident driver sources
11 * by Alan Hourihane the FreeVGA project
12 * Francesco Salvestrini <salvestrini@users.sf.net> XP support,
13 * code, suggestions
14 * TODO:
15 * timing value tweaking so it looks good on every monitor in every mode
16 * TGUI acceleration
19 #include <linux/module.h>
20 #include <linux/fb.h>
21 #include <linux/init.h>
22 #include <linux/pci.h>
24 #include <linux/delay.h>
25 #include <video/trident.h>
27 #define VERSION "0.7.8-NEWAPI"
29 struct tridentfb_par {
30 int vclk; /* in MHz */
31 void __iomem *io_virt; /* iospace virtual memory address */
34 static unsigned char eng_oper; /* engine operation... */
35 static struct fb_ops tridentfb_ops;
37 static struct tridentfb_par default_par;
39 /* FIXME:kmalloc these 3 instead */
40 static struct fb_info fb_info;
41 static u32 pseudo_pal[16];
43 static struct fb_var_screeninfo default_var;
45 static struct fb_fix_screeninfo tridentfb_fix = {
46 .id = "Trident",
47 .type = FB_TYPE_PACKED_PIXELS,
48 .ypanstep = 1,
49 .visual = FB_VISUAL_PSEUDOCOLOR,
50 .accel = FB_ACCEL_NONE,
53 static int chip_id;
55 static int defaultaccel;
56 static int displaytype;
58 /* defaults which are normally overriden by user values */
60 /* video mode */
61 static char *mode = "640x480";
62 static int bpp = 8;
64 static int noaccel;
66 static int center;
67 static int stretch;
69 static int fp;
70 static int crt;
72 static int memsize;
73 static int memdiff;
74 static int nativex;
76 module_param(mode, charp, 0);
77 module_param(bpp, int, 0);
78 module_param(center, int, 0);
79 module_param(stretch, int, 0);
80 module_param(noaccel, int, 0);
81 module_param(memsize, int, 0);
82 module_param(memdiff, int, 0);
83 module_param(nativex, int, 0);
84 module_param(fp, int, 0);
85 module_param(crt, int, 0);
87 static int chip3D;
88 static int chipcyber;
90 static int is3Dchip(int id)
92 return ((id == BLADE3D) || (id == CYBERBLADEE4) ||
93 (id == CYBERBLADEi7) || (id == CYBERBLADEi7D) ||
94 (id == CYBER9397) || (id == CYBER9397DVD) ||
95 (id == CYBER9520) || (id == CYBER9525DVD) ||
96 (id == IMAGE975) || (id == IMAGE985) ||
97 (id == CYBERBLADEi1) || (id == CYBERBLADEi1D) ||
98 (id == CYBERBLADEAi1) || (id == CYBERBLADEAi1D) ||
99 (id == CYBERBLADEXPm8) || (id == CYBERBLADEXPm16) ||
100 (id == CYBERBLADEXPAi1));
103 static int iscyber(int id)
105 switch (id) {
106 case CYBER9388:
107 case CYBER9382:
108 case CYBER9385:
109 case CYBER9397:
110 case CYBER9397DVD:
111 case CYBER9520:
112 case CYBER9525DVD:
113 case CYBERBLADEE4:
114 case CYBERBLADEi7D:
115 case CYBERBLADEi1:
116 case CYBERBLADEi1D:
117 case CYBERBLADEAi1:
118 case CYBERBLADEAi1D:
119 case CYBERBLADEXPAi1:
120 return 1;
122 case CYBER9320:
123 case TGUI9660:
124 case IMAGE975:
125 case IMAGE985:
126 case BLADE3D:
127 case CYBERBLADEi7: /* VIA MPV4 integrated version */
129 default:
130 /* case CYBERBLDAEXPm8: Strange */
131 /* case CYBERBLDAEXPm16: Strange */
132 return 0;
136 #define CRT 0x3D0 /* CRTC registers offset for color display */
138 #ifndef TRIDENT_MMIO
139 #define TRIDENT_MMIO 1
140 #endif
142 #if TRIDENT_MMIO
143 #define t_outb(val, reg) writeb(val,((struct tridentfb_par *)(fb_info.par))->io_virt + reg)
144 #define t_inb(reg) readb(((struct tridentfb_par*)(fb_info.par))->io_virt + reg)
145 #else
146 #define t_outb(val, reg) outb(val, reg)
147 #define t_inb(reg) inb(reg)
148 #endif
151 static struct accel_switch {
152 void (*init_accel) (int, int);
153 void (*wait_engine) (void);
154 void (*fill_rect) (u32, u32, u32, u32, u32, u32);
155 void (*copy_rect) (u32, u32, u32, u32, u32, u32);
156 } *acc;
158 #define writemmr(r, v) writel(v, ((struct tridentfb_par *)fb_info.par)->io_virt + r)
159 #define readmmr(r) readl(((struct tridentfb_par *)fb_info.par)->io_virt + r)
162 * Blade specific acceleration.
165 #define point(x, y) ((y) << 16 | (x))
166 #define STA 0x2120
167 #define CMD 0x2144
168 #define ROP 0x2148
169 #define CLR 0x2160
170 #define SR1 0x2100
171 #define SR2 0x2104
172 #define DR1 0x2108
173 #define DR2 0x210C
175 #define ROP_S 0xCC
177 static void blade_init_accel(int pitch, int bpp)
179 int v1 = (pitch >> 3) << 20;
180 int tmp = 0, v2;
181 switch (bpp) {
182 case 8:
183 tmp = 0;
184 break;
185 case 15:
186 tmp = 5;
187 break;
188 case 16:
189 tmp = 1;
190 break;
191 case 24:
192 case 32:
193 tmp = 2;
194 break;
196 v2 = v1 | (tmp << 29);
197 writemmr(0x21C0, v2);
198 writemmr(0x21C4, v2);
199 writemmr(0x21B8, v2);
200 writemmr(0x21BC, v2);
201 writemmr(0x21D0, v1);
202 writemmr(0x21D4, v1);
203 writemmr(0x21C8, v1);
204 writemmr(0x21CC, v1);
205 writemmr(0x216C, 0);
208 static void blade_wait_engine(void)
210 while (readmmr(STA) & 0xFA800000) ;
213 static void blade_fill_rect(u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop)
215 writemmr(CLR, c);
216 writemmr(ROP, rop ? 0x66 : ROP_S);
217 writemmr(CMD, 0x20000000 | 1 << 19 | 1 << 4 | 2 << 2);
219 writemmr(DR1, point(x, y));
220 writemmr(DR2, point(x + w - 1, y + h - 1));
223 static void blade_copy_rect(u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h)
225 u32 s1, s2, d1, d2;
226 int direction = 2;
227 s1 = point(x1, y1);
228 s2 = point(x1 + w - 1, y1 + h - 1);
229 d1 = point(x2, y2);
230 d2 = point(x2 + w - 1, y2 + h - 1);
232 if ((y1 > y2) || ((y1 == y2) && (x1 > x2)))
233 direction = 0;
235 writemmr(ROP, ROP_S);
236 writemmr(CMD, 0xE0000000 | 1 << 19 | 1 << 4 | 1 << 2 | direction);
238 writemmr(SR1, direction ? s2 : s1);
239 writemmr(SR2, direction ? s1 : s2);
240 writemmr(DR1, direction ? d2 : d1);
241 writemmr(DR2, direction ? d1 : d2);
244 static struct accel_switch accel_blade = {
245 blade_init_accel,
246 blade_wait_engine,
247 blade_fill_rect,
248 blade_copy_rect,
252 * BladeXP specific acceleration functions
255 #define ROP_P 0xF0
256 #define masked_point(x, y) ((y & 0xffff)<<16|(x & 0xffff))
258 static void xp_init_accel(int pitch, int bpp)
260 int tmp = 0, v1;
261 unsigned char x = 0;
263 switch (bpp) {
264 case 8:
265 x = 0;
266 break;
267 case 16:
268 x = 1;
269 break;
270 case 24:
271 x = 3;
272 break;
273 case 32:
274 x = 2;
275 break;
278 switch (pitch << (bpp >> 3)) {
279 case 8192:
280 case 512:
281 x |= 0x00;
282 break;
283 case 1024:
284 x |= 0x04;
285 break;
286 case 2048:
287 x |= 0x08;
288 break;
289 case 4096:
290 x |= 0x0C;
291 break;
294 t_outb(x, 0x2125);
296 eng_oper = x | 0x40;
298 switch (bpp) {
299 case 8:
300 tmp = 18;
301 break;
302 case 15:
303 case 16:
304 tmp = 19;
305 break;
306 case 24:
307 case 32:
308 tmp = 20;
309 break;
312 v1 = pitch << tmp;
314 writemmr(0x2154, v1);
315 writemmr(0x2150, v1);
316 t_outb(3, 0x2126);
319 static void xp_wait_engine(void)
321 int busy;
322 int count, timeout;
324 count = 0;
325 timeout = 0;
326 for (;;) {
327 busy = t_inb(STA) & 0x80;
328 if (busy != 0x80)
329 return;
330 count++;
331 if (count == 10000000) {
332 /* Timeout */
333 count = 9990000;
334 timeout++;
335 if (timeout == 8) {
336 /* Reset engine */
337 t_outb(0x00, 0x2120);
338 return;
344 static void xp_fill_rect(u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop)
346 writemmr(0x2127, ROP_P);
347 writemmr(0x2158, c);
348 writemmr(0x2128, 0x4000);
349 writemmr(0x2140, masked_point(h, w));
350 writemmr(0x2138, masked_point(y, x));
351 t_outb(0x01, 0x2124);
352 t_outb(eng_oper, 0x2125);
355 static void xp_copy_rect(u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h)
357 int direction;
358 u32 x1_tmp, x2_tmp, y1_tmp, y2_tmp;
360 direction = 0x0004;
362 if ((x1 < x2) && (y1 == y2)) {
363 direction |= 0x0200;
364 x1_tmp = x1 + w - 1;
365 x2_tmp = x2 + w - 1;
366 } else {
367 x1_tmp = x1;
368 x2_tmp = x2;
371 if (y1 < y2) {
372 direction |= 0x0100;
373 y1_tmp = y1 + h - 1;
374 y2_tmp = y2 + h - 1;
375 } else {
376 y1_tmp = y1;
377 y2_tmp = y2;
380 writemmr(0x2128, direction);
381 t_outb(ROP_S, 0x2127);
382 writemmr(0x213C, masked_point(y1_tmp, x1_tmp));
383 writemmr(0x2138, masked_point(y2_tmp, x2_tmp));
384 writemmr(0x2140, masked_point(h, w));
385 t_outb(0x01, 0x2124);
388 static struct accel_switch accel_xp = {
389 xp_init_accel,
390 xp_wait_engine,
391 xp_fill_rect,
392 xp_copy_rect,
396 * Image specific acceleration functions
398 static void image_init_accel(int pitch, int bpp)
400 int tmp = 0;
401 switch (bpp) {
402 case 8:
403 tmp = 0;
404 break;
405 case 15:
406 tmp = 5;
407 break;
408 case 16:
409 tmp = 1;
410 break;
411 case 24:
412 case 32:
413 tmp = 2;
414 break;
416 writemmr(0x2120, 0xF0000000);
417 writemmr(0x2120, 0x40000000 | tmp);
418 writemmr(0x2120, 0x80000000);
419 writemmr(0x2144, 0x00000000);
420 writemmr(0x2148, 0x00000000);
421 writemmr(0x2150, 0x00000000);
422 writemmr(0x2154, 0x00000000);
423 writemmr(0x2120, 0x60000000 | (pitch << 16) | pitch);
424 writemmr(0x216C, 0x00000000);
425 writemmr(0x2170, 0x00000000);
426 writemmr(0x217C, 0x00000000);
427 writemmr(0x2120, 0x10000000);
428 writemmr(0x2130, (2047 << 16) | 2047);
431 static void image_wait_engine(void)
433 while (readmmr(0x2164) & 0xF0000000) ;
436 static void image_fill_rect(u32 x, u32 y, u32 w, u32 h, u32 c, u32 rop)
438 writemmr(0x2120, 0x80000000);
439 writemmr(0x2120, 0x90000000 | ROP_S);
441 writemmr(0x2144, c);
443 writemmr(DR1, point(x, y));
444 writemmr(DR2, point(x + w - 1, y + h - 1));
446 writemmr(0x2124, 0x80000000 | 3 << 22 | 1 << 10 | 1 << 9);
449 static void image_copy_rect(u32 x1, u32 y1, u32 x2, u32 y2, u32 w, u32 h)
451 u32 s1, s2, d1, d2;
452 int direction = 2;
453 s1 = point(x1, y1);
454 s2 = point(x1 + w - 1, y1 + h - 1);
455 d1 = point(x2, y2);
456 d2 = point(x2 + w - 1, y2 + h - 1);
458 if ((y1 > y2) || ((y1 == y2) && (x1 > x2)))
459 direction = 0;
461 writemmr(0x2120, 0x80000000);
462 writemmr(0x2120, 0x90000000 | ROP_S);
464 writemmr(SR1, direction ? s2 : s1);
465 writemmr(SR2, direction ? s1 : s2);
466 writemmr(DR1, direction ? d2 : d1);
467 writemmr(DR2, direction ? d1 : d2);
468 writemmr(0x2124, 0x80000000 | 1 << 22 | 1 << 10 | 1 << 7 | direction);
471 static struct accel_switch accel_image = {
472 image_init_accel,
473 image_wait_engine,
474 image_fill_rect,
475 image_copy_rect,
479 * Accel functions called by the upper layers
481 #ifdef CONFIG_FB_TRIDENT_ACCEL
482 static void tridentfb_fillrect(struct fb_info *info,
483 const struct fb_fillrect *fr)
485 int bpp = info->var.bits_per_pixel;
486 int col = 0;
488 switch (bpp) {
489 default:
490 case 8:
491 col |= fr->color;
492 col |= col << 8;
493 col |= col << 16;
494 break;
495 case 16:
496 col = ((u32 *)(info->pseudo_palette))[fr->color];
497 break;
498 case 32:
499 col = ((u32 *)(info->pseudo_palette))[fr->color];
500 break;
503 acc->fill_rect(fr->dx, fr->dy, fr->width, fr->height, col, fr->rop);
504 acc->wait_engine();
506 static void tridentfb_copyarea(struct fb_info *info,
507 const struct fb_copyarea *ca)
509 acc->copy_rect(ca->sx, ca->sy, ca->dx, ca->dy, ca->width, ca->height);
510 acc->wait_engine();
512 #else /* !CONFIG_FB_TRIDENT_ACCEL */
513 #define tridentfb_fillrect cfb_fillrect
514 #define tridentfb_copyarea cfb_copyarea
515 #endif /* CONFIG_FB_TRIDENT_ACCEL */
519 * Hardware access functions
522 static inline unsigned char read3X4(int reg)
524 struct tridentfb_par *par = (struct tridentfb_par *)fb_info.par;
525 writeb(reg, par->io_virt + CRT + 4);
526 return readb(par->io_virt + CRT + 5);
529 static inline void write3X4(int reg, unsigned char val)
531 struct tridentfb_par *par = (struct tridentfb_par *)fb_info.par;
532 writeb(reg, par->io_virt + CRT + 4);
533 writeb(val, par->io_virt + CRT + 5);
536 static inline unsigned char read3C4(int reg)
538 t_outb(reg, 0x3C4);
539 return t_inb(0x3C5);
542 static inline void write3C4(int reg, unsigned char val)
544 t_outb(reg, 0x3C4);
545 t_outb(val, 0x3C5);
548 static inline unsigned char read3CE(int reg)
550 t_outb(reg, 0x3CE);
551 return t_inb(0x3CF);
554 static inline void writeAttr(int reg, unsigned char val)
556 readb(((struct tridentfb_par *)fb_info.par)->io_virt + CRT + 0x0A); /* flip-flop to index */
557 t_outb(reg, 0x3C0);
558 t_outb(val, 0x3C0);
561 static inline void write3CE(int reg, unsigned char val)
563 t_outb(reg, 0x3CE);
564 t_outb(val, 0x3CF);
567 <<<<<<< HEAD:drivers/video/tridentfb.c
568 static inline void enable_mmio(void)
569 =======
570 static void enable_mmio(void)
571 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
573 /* Goto New Mode */
574 outb(0x0B, 0x3C4);
575 inb(0x3C5);
577 /* Unprotect registers */
578 outb(NewMode1, 0x3C4);
579 outb(0x80, 0x3C5);
581 /* Enable MMIO */
582 outb(PCIReg, 0x3D4);
583 outb(inb(0x3D5) | 0x01, 0x3D5);
586 <<<<<<< HEAD:drivers/video/tridentfb.c
587 =======
588 static void disable_mmio(void)
590 /* Goto New Mode */
591 t_outb(0x0B, 0x3C4);
592 t_inb(0x3C5);
594 /* Unprotect registers */
595 t_outb(NewMode1, 0x3C4);
596 t_outb(0x80, 0x3C5);
598 /* Disable MMIO */
599 t_outb(PCIReg, 0x3D4);
600 t_outb(t_inb(0x3D5) & ~0x01, 0x3D5);
603 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
604 #define crtc_unlock() write3X4(CRTVSyncEnd, read3X4(CRTVSyncEnd) & 0x7F)
606 /* Return flat panel's maximum x resolution */
607 static int __devinit get_nativex(void)
609 int x, y, tmp;
611 if (nativex)
612 return nativex;
614 tmp = (read3CE(VertStretch) >> 4) & 3;
616 switch (tmp) {
617 case 0:
618 x = 1280; y = 1024;
619 break;
620 case 2:
621 x = 1024; y = 768;
622 break;
623 case 3:
624 x = 800; y = 600;
625 break;
626 case 4:
627 x = 1400; y = 1050;
628 break;
629 case 1:
630 default:
631 x = 640; y = 480;
632 break;
635 output("%dx%d flat panel found\n", x, y);
636 return x;
639 /* Set pitch */
640 static void set_lwidth(int width)
642 write3X4(Offset, width & 0xFF);
643 write3X4(AddColReg,
644 (read3X4(AddColReg) & 0xCF) | ((width & 0x300) >> 4));
647 /* For resolutions smaller than FP resolution stretch */
648 static void screen_stretch(void)
650 if (chip_id != CYBERBLADEXPAi1)
651 write3CE(BiosReg, 0);
652 else
653 write3CE(BiosReg, 8);
654 write3CE(VertStretch, (read3CE(VertStretch) & 0x7C) | 1);
655 write3CE(HorStretch, (read3CE(HorStretch) & 0x7C) | 1);
658 /* For resolutions smaller than FP resolution center */
659 static void screen_center(void)
661 write3CE(VertStretch, (read3CE(VertStretch) & 0x7C) | 0x80);
662 write3CE(HorStretch, (read3CE(HorStretch) & 0x7C) | 0x80);
665 /* Address of first shown pixel in display memory */
666 static void set_screen_start(int base)
668 write3X4(StartAddrLow, base & 0xFF);
669 write3X4(StartAddrHigh, (base & 0xFF00) >> 8);
670 write3X4(CRTCModuleTest,
671 (read3X4(CRTCModuleTest) & 0xDF) | ((base & 0x10000) >> 11));
672 write3X4(CRTHiOrd,
673 (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17));
676 /* Use 20.12 fixed-point for NTSC value and frequency calculation */
677 #define calc_freq(n, m, k) ( ((unsigned long)0xE517 * (n + 8) / ((m + 2) * (1 << k))) >> 12 )
679 /* Set dotclock frequency */
680 static void set_vclk(int freq)
682 int m, n, k;
683 int f, fi, d, di;
684 unsigned char lo = 0, hi = 0;
686 d = 20;
687 for (k = 2; k >= 0; k--)
688 for (m = 0; m < 63; m++)
689 for (n = 0; n < 128; n++) {
690 fi = calc_freq(n, m, k);
691 if ((di = abs(fi - freq)) < d) {
692 d = di;
693 f = fi;
694 lo = n;
695 hi = (k << 6) | m;
698 if (chip3D) {
699 write3C4(ClockHigh, hi);
700 write3C4(ClockLow, lo);
701 } else {
702 outb(lo, 0x43C8);
703 outb(hi, 0x43C9);
705 debug("VCLK = %X %X\n", hi, lo);
708 /* Set number of lines for flat panels*/
709 static void set_number_of_lines(int lines)
711 int tmp = read3CE(CyberEnhance) & 0x8F;
712 if (lines > 1024)
713 tmp |= 0x50;
714 else if (lines > 768)
715 tmp |= 0x30;
716 else if (lines > 600)
717 tmp |= 0x20;
718 else if (lines > 480)
719 tmp |= 0x10;
720 write3CE(CyberEnhance, tmp);
724 * If we see that FP is active we assume we have one.
725 * Otherwise we have a CRT display.User can override.
727 static unsigned int __devinit get_displaytype(void)
729 if (fp)
730 return DISPLAY_FP;
731 if (crt || !chipcyber)
732 return DISPLAY_CRT;
733 return (read3CE(FPConfig) & 0x10) ? DISPLAY_FP : DISPLAY_CRT;
736 /* Try detecting the video memory size */
737 static unsigned int __devinit get_memsize(void)
739 unsigned char tmp, tmp2;
740 unsigned int k;
742 /* If memory size provided by user */
743 if (memsize)
744 k = memsize * Kb;
745 else
746 switch (chip_id) {
747 case CYBER9525DVD:
748 k = 2560 * Kb;
749 break;
750 default:
751 tmp = read3X4(SPR) & 0x0F;
752 switch (tmp) {
754 case 0x01:
755 <<<<<<< HEAD:drivers/video/tridentfb.c
756 k = 512;
757 =======
758 k = 512 * Kb;
759 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
760 break;
761 case 0x02:
762 k = 6 * Mb; /* XP */
763 break;
764 case 0x03:
765 k = 1 * Mb;
766 break;
767 case 0x04:
768 k = 8 * Mb;
769 break;
770 case 0x06:
771 k = 10 * Mb; /* XP */
772 break;
773 case 0x07:
774 k = 2 * Mb;
775 break;
776 case 0x08:
777 k = 12 * Mb; /* XP */
778 break;
779 case 0x0A:
780 k = 14 * Mb; /* XP */
781 break;
782 case 0x0C:
783 k = 16 * Mb; /* XP */
784 break;
785 case 0x0E: /* XP */
787 tmp2 = read3C4(0xC1);
788 switch (tmp2) {
789 case 0x00:
790 k = 20 * Mb;
791 break;
792 case 0x01:
793 k = 24 * Mb;
794 break;
795 case 0x10:
796 k = 28 * Mb;
797 break;
798 case 0x11:
799 k = 32 * Mb;
800 break;
801 default:
802 k = 1 * Mb;
803 break;
805 break;
807 case 0x0F:
808 k = 4 * Mb;
809 break;
810 default:
811 k = 1 * Mb;
812 break;
816 k -= memdiff * Kb;
817 output("framebuffer size = %d Kb\n", k / Kb);
818 return k;
821 /* See if we can handle the video mode described in var */
822 static int tridentfb_check_var(struct fb_var_screeninfo *var,
823 struct fb_info *info)
825 int bpp = var->bits_per_pixel;
826 debug("enter\n");
828 /* check color depth */
829 if (bpp == 24)
830 bpp = var->bits_per_pixel = 32;
831 /* check whether resolution fits on panel and in memory */
832 if (flatpanel && nativex && var->xres > nativex)
833 return -EINVAL;
834 if (var->xres * var->yres_virtual * bpp / 8 > info->fix.smem_len)
835 return -EINVAL;
837 switch (bpp) {
838 case 8:
839 var->red.offset = 0;
840 var->green.offset = 0;
841 var->blue.offset = 0;
842 var->red.length = 6;
843 var->green.length = 6;
844 var->blue.length = 6;
845 break;
846 case 16:
847 var->red.offset = 11;
848 var->green.offset = 5;
849 var->blue.offset = 0;
850 var->red.length = 5;
851 var->green.length = 6;
852 var->blue.length = 5;
853 break;
854 case 32:
855 var->red.offset = 16;
856 var->green.offset = 8;
857 var->blue.offset = 0;
858 var->red.length = 8;
859 var->green.length = 8;
860 var->blue.length = 8;
861 break;
862 default:
863 return -EINVAL;
865 debug("exit\n");
867 return 0;
871 /* Pan the display */
872 static int tridentfb_pan_display(struct fb_var_screeninfo *var,
873 struct fb_info *info)
875 unsigned int offset;
877 debug("enter\n");
878 offset = (var->xoffset + (var->yoffset * var->xres))
879 * var->bits_per_pixel / 32;
880 info->var.xoffset = var->xoffset;
881 info->var.yoffset = var->yoffset;
882 set_screen_start(offset);
883 debug("exit\n");
884 return 0;
887 #define shadowmode_on() write3CE(CyberControl, read3CE(CyberControl) | 0x81)
888 #define shadowmode_off() write3CE(CyberControl, read3CE(CyberControl) & 0x7E)
890 /* Set the hardware to the requested video mode */
891 static int tridentfb_set_par(struct fb_info *info)
893 struct tridentfb_par *par = (struct tridentfb_par *)(info->par);
894 u32 htotal, hdispend, hsyncstart, hsyncend, hblankstart, hblankend;
895 u32 vtotal, vdispend, vsyncstart, vsyncend, vblankstart, vblankend;
896 struct fb_var_screeninfo *var = &info->var;
897 int bpp = var->bits_per_pixel;
898 unsigned char tmp;
899 debug("enter\n");
900 hdispend = var->xres / 8 - 1;
901 hsyncstart = (var->xres + var->right_margin) / 8;
902 hsyncend = var->hsync_len / 8;
903 htotal =
904 (var->xres + var->left_margin + var->right_margin +
905 var->hsync_len) / 8 - 10;
906 hblankstart = hdispend + 1;
907 hblankend = htotal + 5;
909 vdispend = var->yres - 1;
910 vsyncstart = var->yres + var->lower_margin;
911 vsyncend = var->vsync_len;
912 vtotal = var->upper_margin + vsyncstart + vsyncend - 2;
913 vblankstart = var->yres;
914 vblankend = vtotal + 2;
916 enable_mmio();
917 crtc_unlock();
918 write3CE(CyberControl, 8);
920 if (flatpanel && var->xres < nativex) {
922 * on flat panels with native size larger
923 * than requested resolution decide whether
924 * we stretch or center
926 t_outb(0xEB, 0x3C2);
928 shadowmode_on();
930 if (center)
931 screen_center();
932 else if (stretch)
933 screen_stretch();
935 } else {
936 t_outb(0x2B, 0x3C2);
937 write3CE(CyberControl, 8);
940 /* vertical timing values */
941 write3X4(CRTVTotal, vtotal & 0xFF);
942 write3X4(CRTVDispEnd, vdispend & 0xFF);
943 write3X4(CRTVSyncStart, vsyncstart & 0xFF);
944 write3X4(CRTVSyncEnd, (vsyncend & 0x0F));
945 write3X4(CRTVBlankStart, vblankstart & 0xFF);
946 write3X4(CRTVBlankEnd, 0 /* p->vblankend & 0xFF */ );
948 /* horizontal timing values */
949 write3X4(CRTHTotal, htotal & 0xFF);
950 write3X4(CRTHDispEnd, hdispend & 0xFF);
951 write3X4(CRTHSyncStart, hsyncstart & 0xFF);
952 write3X4(CRTHSyncEnd, (hsyncend & 0x1F) | ((hblankend & 0x20) << 2));
953 write3X4(CRTHBlankStart, hblankstart & 0xFF);
954 write3X4(CRTHBlankEnd, 0 /* (p->hblankend & 0x1F) */ );
956 /* higher bits of vertical timing values */
957 tmp = 0x10;
958 if (vtotal & 0x100) tmp |= 0x01;
959 if (vdispend & 0x100) tmp |= 0x02;
960 if (vsyncstart & 0x100) tmp |= 0x04;
961 if (vblankstart & 0x100) tmp |= 0x08;
963 if (vtotal & 0x200) tmp |= 0x20;
964 if (vdispend & 0x200) tmp |= 0x40;
965 if (vsyncstart & 0x200) tmp |= 0x80;
966 write3X4(CRTOverflow, tmp);
968 tmp = read3X4(CRTHiOrd) | 0x08; /* line compare bit 10 */
969 if (vtotal & 0x400) tmp |= 0x80;
970 if (vblankstart & 0x400) tmp |= 0x40;
971 if (vsyncstart & 0x400) tmp |= 0x20;
972 if (vdispend & 0x400) tmp |= 0x10;
973 write3X4(CRTHiOrd, tmp);
975 tmp = 0;
976 if (htotal & 0x800) tmp |= 0x800 >> 11;
977 if (hblankstart & 0x800) tmp |= 0x800 >> 7;
978 write3X4(HorizOverflow, tmp);
980 tmp = 0x40;
981 if (vblankstart & 0x200) tmp |= 0x20;
982 //FIXME if (info->var.vmode & FB_VMODE_DOUBLE) tmp |= 0x80; /* double scan for 200 line modes */
983 write3X4(CRTMaxScanLine, tmp);
985 write3X4(CRTLineCompare, 0xFF);
986 write3X4(CRTPRowScan, 0);
987 write3X4(CRTModeControl, 0xC3);
989 write3X4(LinearAddReg, 0x20); /* enable linear addressing */
991 tmp = (info->var.vmode & FB_VMODE_INTERLACED) ? 0x84 : 0x80;
992 write3X4(CRTCModuleTest, tmp); /* enable access extended memory */
994 write3X4(GraphEngReg, 0x80); /* enable GE for text acceleration */
996 #ifdef CONFIG_FB_TRIDENT_ACCEL
997 acc->init_accel(info->var.xres, bpp);
998 #endif
1000 switch (bpp) {
1001 case 8:
1002 tmp = 0x00;
1003 break;
1004 case 16:
1005 tmp = 0x05;
1006 break;
1007 case 24:
1008 tmp = 0x29;
1009 break;
1010 case 32:
1011 tmp = 0x09;
1012 break;
1015 write3X4(PixelBusReg, tmp);
1017 tmp = 0x10;
1018 if (chipcyber)
1019 tmp |= 0x20;
1020 write3X4(DRAMControl, tmp); /* both IO, linear enable */
1022 write3X4(InterfaceSel, read3X4(InterfaceSel) | 0x40);
1023 write3X4(Performance, 0x92);
1024 write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */
1026 /* convert from picoseconds to MHz */
1027 par->vclk = 1000000 / info->var.pixclock;
1028 if (bpp == 32)
1029 par->vclk *= 2;
1030 set_vclk(par->vclk);
1032 write3C4(0, 3);
1033 write3C4(1, 1); /* set char clock 8 dots wide */
1034 write3C4(2, 0x0F); /* enable 4 maps because needed in chain4 mode */
1035 write3C4(3, 0);
1036 write3C4(4, 0x0E); /* memory mode enable bitmaps ?? */
1038 write3CE(MiscExtFunc, (bpp == 32) ? 0x1A : 0x12); /* divide clock by 2 if 32bpp */
1039 /* chain4 mode display and CPU path */
1040 write3CE(0x5, 0x40); /* no CGA compat, allow 256 col */
1041 write3CE(0x6, 0x05); /* graphics mode */
1042 write3CE(0x7, 0x0F); /* planes? */
1044 if (chip_id == CYBERBLADEXPAi1) {
1045 /* This fixes snow-effect in 32 bpp */
1046 write3X4(CRTHSyncStart, 0x84);
1049 writeAttr(0x10, 0x41); /* graphics mode and support 256 color modes */
1050 writeAttr(0x12, 0x0F); /* planes */
1051 writeAttr(0x13, 0); /* horizontal pel panning */
1053 /* colors */
1054 for (tmp = 0; tmp < 0x10; tmp++)
1055 writeAttr(tmp, tmp);
1056 readb(par->io_virt + CRT + 0x0A); /* flip-flop to index */
1057 t_outb(0x20, 0x3C0); /* enable attr */
1059 switch (bpp) {
1060 case 8:
1061 tmp = 0;
1062 break;
1063 case 15:
1064 tmp = 0x10;
1065 break;
1066 case 16:
1067 tmp = 0x30;
1068 break;
1069 case 24:
1070 case 32:
1071 tmp = 0xD0;
1072 break;
1075 t_inb(0x3C8);
1076 t_inb(0x3C6);
1077 t_inb(0x3C6);
1078 t_inb(0x3C6);
1079 t_inb(0x3C6);
1080 t_outb(tmp, 0x3C6);
1081 t_inb(0x3C8);
1083 if (flatpanel)
1084 set_number_of_lines(info->var.yres);
1085 set_lwidth(info->var.xres * bpp / (4 * 16));
1086 info->fix.visual = (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
1087 info->fix.line_length = info->var.xres * (bpp >> 3);
1088 info->cmap.len = (bpp == 8) ? 256 : 16;
1089 debug("exit\n");
1090 return 0;
1093 /* Set one color register */
1094 static int tridentfb_setcolreg(unsigned regno, unsigned red, unsigned green,
1095 unsigned blue, unsigned transp,
1096 struct fb_info *info)
1098 int bpp = info->var.bits_per_pixel;
1100 if (regno >= info->cmap.len)
1101 return 1;
1103 if (bpp == 8) {
1104 t_outb(0xFF, 0x3C6);
1105 t_outb(regno, 0x3C8);
1107 t_outb(red >> 10, 0x3C9);
1108 t_outb(green >> 10, 0x3C9);
1109 t_outb(blue >> 10, 0x3C9);
1111 } else if (regno < 16) {
1112 if (bpp == 16) { /* RGB 565 */
1113 u32 col;
1115 col = (red & 0xF800) | ((green & 0xFC00) >> 5) |
1116 ((blue & 0xF800) >> 11);
1117 col |= col << 16;
1118 ((u32 *)(info->pseudo_palette))[regno] = col;
1119 } else if (bpp == 32) /* ARGB 8888 */
1120 ((u32*)info->pseudo_palette)[regno] =
1121 ((transp & 0xFF00) << 16) |
1122 ((red & 0xFF00) << 8) |
1123 ((green & 0xFF00)) |
1124 ((blue & 0xFF00) >> 8);
1127 /* debug("exit\n"); */
1128 return 0;
1131 /* Try blanking the screen.For flat panels it does nothing */
1132 static int tridentfb_blank(int blank_mode, struct fb_info *info)
1134 unsigned char PMCont, DPMSCont;
1136 debug("enter\n");
1137 if (flatpanel)
1138 return 0;
1139 t_outb(0x04, 0x83C8); /* Read DPMS Control */
1140 PMCont = t_inb(0x83C6) & 0xFC;
1141 DPMSCont = read3CE(PowerStatus) & 0xFC;
1142 switch (blank_mode) {
1143 case FB_BLANK_UNBLANK:
1144 /* Screen: On, HSync: On, VSync: On */
1145 case FB_BLANK_NORMAL:
1146 /* Screen: Off, HSync: On, VSync: On */
1147 PMCont |= 0x03;
1148 DPMSCont |= 0x00;
1149 break;
1150 case FB_BLANK_HSYNC_SUSPEND:
1151 /* Screen: Off, HSync: Off, VSync: On */
1152 PMCont |= 0x02;
1153 DPMSCont |= 0x01;
1154 break;
1155 case FB_BLANK_VSYNC_SUSPEND:
1156 /* Screen: Off, HSync: On, VSync: Off */
1157 PMCont |= 0x02;
1158 DPMSCont |= 0x02;
1159 break;
1160 case FB_BLANK_POWERDOWN:
1161 /* Screen: Off, HSync: Off, VSync: Off */
1162 PMCont |= 0x00;
1163 DPMSCont |= 0x03;
1164 break;
1167 write3CE(PowerStatus, DPMSCont);
1168 t_outb(4, 0x83C8);
1169 t_outb(PMCont, 0x83C6);
1171 debug("exit\n");
1173 /* let fbcon do a softblank for us */
1174 return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0;
1177 static struct fb_ops tridentfb_ops = {
1178 .owner = THIS_MODULE,
1179 .fb_setcolreg = tridentfb_setcolreg,
1180 .fb_pan_display = tridentfb_pan_display,
1181 .fb_blank = tridentfb_blank,
1182 .fb_check_var = tridentfb_check_var,
1183 .fb_set_par = tridentfb_set_par,
1184 .fb_fillrect = tridentfb_fillrect,
1185 .fb_copyarea = tridentfb_copyarea,
1186 .fb_imageblit = cfb_imageblit,
1189 static int __devinit trident_pci_probe(struct pci_dev * dev,
1190 const struct pci_device_id * id)
1192 int err;
1193 unsigned char revision;
1195 err = pci_enable_device(dev);
1196 if (err)
1197 return err;
1199 chip_id = id->device;
1201 if (chip_id == CYBERBLADEi1)
1202 output("*** Please do use cyblafb, Cyberblade/i1 support "
1203 "will soon be removed from tridentfb!\n");
1206 /* If PCI id is 0x9660 then further detect chip type */
1208 if (chip_id == TGUI9660) {
1209 outb(RevisionID, 0x3C4);
1210 revision = inb(0x3C5);
1212 switch (revision) {
1213 case 0x22:
1214 case 0x23:
1215 chip_id = CYBER9397;
1216 break;
1217 case 0x2A:
1218 chip_id = CYBER9397DVD;
1219 break;
1220 case 0x30:
1221 case 0x33:
1222 case 0x34:
1223 case 0x35:
1224 case 0x38:
1225 case 0x3A:
1226 case 0xB3:
1227 chip_id = CYBER9385;
1228 break;
1229 case 0x40 ... 0x43:
1230 chip_id = CYBER9382;
1231 break;
1232 case 0x4A:
1233 chip_id = CYBER9388;
1234 break;
1235 default:
1236 break;
1240 chip3D = is3Dchip(chip_id);
1241 chipcyber = iscyber(chip_id);
1243 if (is_xp(chip_id)) {
1244 acc = &accel_xp;
1245 } else if (is_blade(chip_id)) {
1246 acc = &accel_blade;
1247 } else {
1248 acc = &accel_image;
1251 /* acceleration is on by default for 3D chips */
1252 defaultaccel = chip3D && !noaccel;
1254 fb_info.par = &default_par;
1256 /* setup MMIO region */
1257 tridentfb_fix.mmio_start = pci_resource_start(dev, 1);
1258 tridentfb_fix.mmio_len = chip3D ? 0x20000 : 0x10000;
1260 if (!request_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len, "tridentfb")) {
1261 debug("request_region failed!\n");
1262 return -1;
1265 default_par.io_virt = ioremap_nocache(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1267 if (!default_par.io_virt) {
1268 <<<<<<< HEAD:drivers/video/tridentfb.c
1269 release_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1270 =======
1271 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1272 debug("ioremap failed\n");
1273 <<<<<<< HEAD:drivers/video/tridentfb.c
1274 return -1;
1275 =======
1276 err = -1;
1277 goto out_unmap1;
1278 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1281 enable_mmio();
1283 /* setup framebuffer memory */
1284 tridentfb_fix.smem_start = pci_resource_start(dev, 0);
1285 tridentfb_fix.smem_len = get_memsize();
1287 if (!request_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len, "tridentfb")) {
1288 debug("request_mem_region failed!\n");
1289 <<<<<<< HEAD:drivers/video/tridentfb.c
1290 =======
1291 disable_mmio();
1292 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1293 err = -1;
1294 <<<<<<< HEAD:drivers/video/tridentfb.c
1295 goto out_unmap;
1296 =======
1297 goto out_unmap1;
1298 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1301 fb_info.screen_base = ioremap_nocache(tridentfb_fix.smem_start,
1302 tridentfb_fix.smem_len);
1304 if (!fb_info.screen_base) {
1305 <<<<<<< HEAD:drivers/video/tridentfb.c
1306 release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
1307 =======
1308 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1309 debug("ioremap failed\n");
1310 err = -1;
1311 <<<<<<< HEAD:drivers/video/tridentfb.c
1312 goto out_unmap;
1313 =======
1314 goto out_unmap2;
1315 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1318 output("%s board found\n", pci_name(dev));
1319 <<<<<<< HEAD:drivers/video/tridentfb.c
1320 #if 0
1321 output("Trident board found : mem = %X, io = %X, mem_v = %X, io_v = %X\n",
1322 tridentfb_fix.smem_start, tridentfb_fix.mmio_start, fb_info.screen_base, default_par.io_virt);
1323 #endif
1324 =======
1325 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1326 displaytype = get_displaytype();
1328 if (flatpanel)
1329 nativex = get_nativex();
1331 fb_info.fix = tridentfb_fix;
1332 fb_info.fbops = &tridentfb_ops;
1335 fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1336 #ifdef CONFIG_FB_TRIDENT_ACCEL
1337 fb_info.flags |= FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT;
1338 #endif
1339 fb_info.pseudo_palette = pseudo_pal;
1341 if (!fb_find_mode(&default_var, &fb_info, mode, NULL, 0, NULL, bpp)) {
1342 err = -EINVAL;
1343 <<<<<<< HEAD:drivers/video/tridentfb.c
1344 goto out_unmap;
1345 =======
1346 goto out_unmap2;
1347 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1349 <<<<<<< HEAD:drivers/video/tridentfb.c
1350 fb_alloc_cmap(&fb_info.cmap, 256, 0);
1351 =======
1352 err = fb_alloc_cmap(&fb_info.cmap, 256, 0);
1353 if (err < 0)
1354 goto out_unmap2;
1356 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1357 if (defaultaccel && acc)
1358 default_var.accel_flags |= FB_ACCELF_TEXT;
1359 else
1360 default_var.accel_flags &= ~FB_ACCELF_TEXT;
1361 default_var.activate |= FB_ACTIVATE_NOW;
1362 fb_info.var = default_var;
1363 fb_info.device = &dev->dev;
1364 if (register_framebuffer(&fb_info) < 0) {
1365 printk(KERN_ERR "tridentfb: could not register Trident framebuffer\n");
1366 <<<<<<< HEAD:drivers/video/tridentfb.c
1367 =======
1368 fb_dealloc_cmap(&fb_info.cmap);
1369 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1370 err = -EINVAL;
1371 <<<<<<< HEAD:drivers/video/tridentfb.c
1372 goto out_unmap;
1373 =======
1374 goto out_unmap2;
1375 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1377 output("fb%d: %s frame buffer device %dx%d-%dbpp\n",
1378 fb_info.node, fb_info.fix.id, default_var.xres,
1379 default_var.yres, default_var.bits_per_pixel);
1380 return 0;
1382 <<<<<<< HEAD:drivers/video/tridentfb.c
1383 out_unmap:
1384 if (default_par.io_virt)
1385 iounmap(default_par.io_virt);
1386 =======
1387 out_unmap2:
1388 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1389 if (fb_info.screen_base)
1390 iounmap(fb_info.screen_base);
1391 <<<<<<< HEAD:drivers/video/tridentfb.c
1392 =======
1393 release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
1394 disable_mmio();
1395 out_unmap1:
1396 if (default_par.io_virt)
1397 iounmap(default_par.io_virt);
1398 release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1399 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1400 return err;
1403 static void __devexit trident_pci_remove(struct pci_dev *dev)
1405 struct tridentfb_par *par = (struct tridentfb_par*)fb_info.par;
1406 unregister_framebuffer(&fb_info);
1407 iounmap(par->io_virt);
1408 iounmap(fb_info.screen_base);
1409 release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
1410 <<<<<<< HEAD:drivers/video/tridentfb.c
1411 release_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1412 =======
1413 release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
1414 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/tridentfb.c
1417 /* List of boards that we are trying to support */
1418 static struct pci_device_id trident_devices[] = {
1419 {PCI_VENDOR_ID_TRIDENT, BLADE3D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1420 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1421 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi7D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1422 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1423 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEi1D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1424 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1425 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEAi1D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1426 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEE4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1427 {PCI_VENDOR_ID_TRIDENT, TGUI9660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1428 {PCI_VENDOR_ID_TRIDENT, IMAGE975, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1429 {PCI_VENDOR_ID_TRIDENT, IMAGE985, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1430 {PCI_VENDOR_ID_TRIDENT, CYBER9320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1431 {PCI_VENDOR_ID_TRIDENT, CYBER9388, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1432 {PCI_VENDOR_ID_TRIDENT, CYBER9520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1433 {PCI_VENDOR_ID_TRIDENT, CYBER9525DVD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1434 {PCI_VENDOR_ID_TRIDENT, CYBER9397, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1435 {PCI_VENDOR_ID_TRIDENT, CYBER9397DVD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1436 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPAi1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1437 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPm8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1438 {PCI_VENDOR_ID_TRIDENT, CYBERBLADEXPm16, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1439 {0,}
1442 MODULE_DEVICE_TABLE(pci, trident_devices);
1444 static struct pci_driver tridentfb_pci_driver = {
1445 .name = "tridentfb",
1446 .id_table = trident_devices,
1447 .probe = trident_pci_probe,
1448 .remove = __devexit_p(trident_pci_remove)
1452 * Parse user specified options (`video=trident:')
1453 * example:
1454 * video=trident:800x600,bpp=16,noaccel
1456 #ifndef MODULE
1457 static int tridentfb_setup(char *options)
1459 char *opt;
1460 if (!options || !*options)
1461 return 0;
1462 while ((opt = strsep(&options, ",")) != NULL) {
1463 if (!*opt)
1464 continue;
1465 if (!strncmp(opt, "noaccel", 7))
1466 noaccel = 1;
1467 else if (!strncmp(opt, "fp", 2))
1468 displaytype = DISPLAY_FP;
1469 else if (!strncmp(opt, "crt", 3))
1470 displaytype = DISPLAY_CRT;
1471 else if (!strncmp(opt, "bpp=", 4))
1472 bpp = simple_strtoul(opt + 4, NULL, 0);
1473 else if (!strncmp(opt, "center", 6))
1474 center = 1;
1475 else if (!strncmp(opt, "stretch", 7))
1476 stretch = 1;
1477 else if (!strncmp(opt, "memsize=", 8))
1478 memsize = simple_strtoul(opt + 8, NULL, 0);
1479 else if (!strncmp(opt, "memdiff=", 8))
1480 memdiff = simple_strtoul(opt + 8, NULL, 0);
1481 else if (!strncmp(opt, "nativex=", 8))
1482 nativex = simple_strtoul(opt + 8, NULL, 0);
1483 else
1484 mode = opt;
1486 return 0;
1488 #endif
1490 static int __init tridentfb_init(void)
1492 #ifndef MODULE
1493 char *option = NULL;
1495 if (fb_get_options("tridentfb", &option))
1496 return -ENODEV;
1497 tridentfb_setup(option);
1498 #endif
1499 output("Trident framebuffer %s initializing\n", VERSION);
1500 return pci_register_driver(&tridentfb_pci_driver);
1503 static void __exit tridentfb_exit(void)
1505 pci_unregister_driver(&tridentfb_pci_driver);
1508 module_init(tridentfb_init);
1509 module_exit(tridentfb_exit);
1511 MODULE_AUTHOR("Jani Monoses <jani@iv.ro>");
1512 MODULE_DESCRIPTION("Framebuffer driver for Trident cards");
1513 MODULE_LICENSE("GPL");