2 * linux/drivers/video/neofb.c -- NeoMagic Framebuffer Driver
4 * Copyright (c) 2001-2002 Denis Oliver Kropp <dok@directfb.org>
7 * Card specific code is based on XFree86's neomagic driver.
8 * Framebuffer framework code is based on code of cyber2000fb.
10 * This file is subject to the terms and conditions of the GNU General
11 * Public License. See the file COPYING in the main directory of this
12 * archive for more details.
16 * - Cosmetic changes (dok)
19 * - Toshiba Libretto support, allow modes larger than LCD size if
20 * LCD is disabled, keep BIOS settings if internal/external display
21 * haven't been enabled explicitly
22 * (Thomas J. Moore <dark@mama.indstate.edu>)
25 * - Porting over to new fbdev api. (jsimmons)
28 * - got rid of all floating point (dok)
31 * - added module license (dok)
34 * - hardware accelerated clear and move for 2200 and above (dok)
35 * - maximum allowed dotclock is handled now (dok)
38 * - correct panning after X usage (dok)
39 * - added module and kernel parameters (dok)
40 * - no stretching if external display is enabled (dok)
43 * - initial version (dok)
47 * - ioctl for internal/external switching
49 * - 32bit depth support, maybe impossible
50 * - disable pan-on-sync, need specs
53 * - white margin on bootup like with tdfxfb (colormap problem?)
57 #include <linux/module.h>
58 #include <linux/kernel.h>
59 #include <linux/errno.h>
60 #include <linux/string.h>
62 #include <linux/slab.h>
63 #include <linux/delay.h>
65 #include <linux/pci.h>
66 #include <linux/init.h>
68 #include <linux/toshiba.h>
69 extern int tosh_smm(SMMRegisters
*regs
);
74 #include <asm/pgtable.h>
75 #include <asm/system.h>
76 #include <asm/uaccess.h>
82 #include <video/vga.h>
83 #include <video/neomagic.h>
85 #define NEOFB_VERSION "0.4.2"
87 /* --------------------------------------------------------------------- */
93 static int nopciburst
;
94 static char *mode_option __devinitdata
= NULL
;
98 MODULE_AUTHOR("(c) 2001-2002 Denis Oliver Kropp <dok@convergence.de>");
99 MODULE_LICENSE("GPL");
100 MODULE_DESCRIPTION("FBDev driver for NeoMagic PCI Chips");
101 module_param(internal
, bool, 0);
102 MODULE_PARM_DESC(internal
, "Enable output on internal LCD Display.");
103 module_param(external
, bool, 0);
104 MODULE_PARM_DESC(external
, "Enable output on external CRT.");
105 module_param(libretto
, bool, 0);
106 MODULE_PARM_DESC(libretto
, "Force Libretto 100/110 800x480 LCD.");
107 module_param(nostretch
, bool, 0);
108 MODULE_PARM_DESC(nostretch
,
109 "Disable stretching of modes smaller than LCD.");
110 module_param(nopciburst
, bool, 0);
111 MODULE_PARM_DESC(nopciburst
, "Disable PCI burst mode.");
112 module_param(mode_option
, charp
, 0);
113 MODULE_PARM_DESC(mode_option
, "Preferred video mode ('640x480-8@60', etc)");
118 /* --------------------------------------------------------------------- */
120 static biosMode bios8
[] = {
129 static biosMode bios16
[] = {
138 static biosMode bios24
[] = {
144 #ifdef NO_32BIT_SUPPORT_YET
145 /* FIXME: guessed values, wrong */
146 static biosMode bios32
[] = {
153 static inline void write_le32(int regindex
, u32 val
, const struct neofb_par
*par
)
155 writel(val
, par
->neo2200
+ par
->cursorOff
+ regindex
);
158 static int neoFindMode(int xres
, int yres
, int depth
)
166 size
= ARRAY_SIZE(bios8
);
170 size
= ARRAY_SIZE(bios16
);
174 size
= ARRAY_SIZE(bios24
);
177 #ifdef NO_32BIT_SUPPORT_YET
179 size
= ARRAY_SIZE(bios32
);
187 for (i
= 0; i
< size
; i
++) {
188 if (xres
<= mode
[i
].x_res
) {
189 xres_s
= mode
[i
].x_res
;
190 for (; i
< size
; i
++) {
191 if (mode
[i
].x_res
!= xres_s
)
192 return mode
[i
- 1].mode
;
193 if (yres
<= mode
[i
].y_res
)
198 return mode
[size
- 1].mode
;
204 * Determine the closest clock frequency to the one requested.
206 #define REF_FREQ 0xe517 /* 14.31818 in 20.12 fixed point */
211 static void neoCalcVCLK(const struct fb_info
*info
,
212 struct neofb_par
*par
, long freq
)
215 int n_best
= 0, d_best
= 0, f_best
= 0;
216 long f_best_diff
= (0x7ffff << 12); /* 20.12 */
217 long f_target
= (freq
<< 12) / 1000; /* 20.12 */
219 for (f
= 0; f
<= MAX_F
; f
++)
220 for (n
= 0; n
<= MAX_N
; n
++)
221 for (d
= 0; d
<= MAX_D
; d
++) {
222 long f_out
; /* 20.12 */
223 long f_diff
; /* 20.12 */
226 ((((n
+ 1) << 12) / ((d
+
230 f_diff
= abs(f_out
- f_target
);
231 if (f_diff
< f_best_diff
) {
232 f_best_diff
= f_diff
;
239 if (info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2200
||
240 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2230
||
241 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2360
||
242 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2380
) {
243 /* NOT_DONE: We are trying the full range of the 2200 clock.
244 We should be able to try n up to 2047 */
245 par
->VCLK3NumeratorLow
= n_best
;
246 par
->VCLK3NumeratorHigh
= (f_best
<< 7);
248 par
->VCLK3NumeratorLow
= n_best
| (f_best
<< 7);
250 par
->VCLK3Denominator
= d_best
;
253 printk("neoVCLK: f:%d NumLow=%d NumHi=%d Den=%d Df=%d\n",
255 par
->VCLK3NumeratorLow
,
256 par
->VCLK3NumeratorHigh
,
257 par
->VCLK3Denominator
, f_best_diff
>> 12);
263 * Handle the initialization, etc. of a screen.
264 * Return FALSE on failure.
267 static int vgaHWInit(const struct fb_var_screeninfo
*var
,
268 const struct fb_info
*info
,
269 struct neofb_par
*par
, struct xtimings
*timings
)
271 par
->MiscOutReg
= 0x23;
273 if (!(timings
->sync
& FB_SYNC_HOR_HIGH_ACT
))
274 par
->MiscOutReg
|= 0x40;
276 if (!(timings
->sync
& FB_SYNC_VERT_HIGH_ACT
))
277 par
->MiscOutReg
|= 0x80;
282 par
->Sequencer
[0] = 0x00;
283 par
->Sequencer
[1] = 0x01;
284 par
->Sequencer
[2] = 0x0F;
285 par
->Sequencer
[3] = 0x00; /* Font select */
286 par
->Sequencer
[4] = 0x0E; /* Misc */
291 par
->CRTC
[0] = (timings
->HTotal
>> 3) - 5;
292 par
->CRTC
[1] = (timings
->HDisplay
>> 3) - 1;
293 par
->CRTC
[2] = (timings
->HDisplay
>> 3) - 1;
294 par
->CRTC
[3] = (((timings
->HTotal
>> 3) - 1) & 0x1F) | 0x80;
295 par
->CRTC
[4] = (timings
->HSyncStart
>> 3);
296 par
->CRTC
[5] = ((((timings
->HTotal
>> 3) - 1) & 0x20) << 2)
297 | (((timings
->HSyncEnd
>> 3)) & 0x1F);
298 par
->CRTC
[6] = (timings
->VTotal
- 2) & 0xFF;
299 par
->CRTC
[7] = (((timings
->VTotal
- 2) & 0x100) >> 8)
300 | (((timings
->VDisplay
- 1) & 0x100) >> 7)
301 | ((timings
->VSyncStart
& 0x100) >> 6)
302 | (((timings
->VDisplay
- 1) & 0x100) >> 5)
303 | 0x10 | (((timings
->VTotal
- 2) & 0x200) >> 4)
304 | (((timings
->VDisplay
- 1) & 0x200) >> 3)
305 | ((timings
->VSyncStart
& 0x200) >> 2);
307 par
->CRTC
[9] = (((timings
->VDisplay
- 1) & 0x200) >> 4) | 0x40;
309 if (timings
->dblscan
)
310 par
->CRTC
[9] |= 0x80;
312 par
->CRTC
[10] = 0x00;
313 par
->CRTC
[11] = 0x00;
314 par
->CRTC
[12] = 0x00;
315 par
->CRTC
[13] = 0x00;
316 par
->CRTC
[14] = 0x00;
317 par
->CRTC
[15] = 0x00;
318 par
->CRTC
[16] = timings
->VSyncStart
& 0xFF;
319 par
->CRTC
[17] = (timings
->VSyncEnd
& 0x0F) | 0x20;
320 par
->CRTC
[18] = (timings
->VDisplay
- 1) & 0xFF;
321 par
->CRTC
[19] = var
->xres_virtual
>> 4;
322 par
->CRTC
[20] = 0x00;
323 par
->CRTC
[21] = (timings
->VDisplay
- 1) & 0xFF;
324 par
->CRTC
[22] = (timings
->VTotal
- 1) & 0xFF;
325 par
->CRTC
[23] = 0xC3;
326 par
->CRTC
[24] = 0xFF;
329 * are these unnecessary?
330 * vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
331 * vgaHWVBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
335 * Graphics Display Controller
337 par
->Graphics
[0] = 0x00;
338 par
->Graphics
[1] = 0x00;
339 par
->Graphics
[2] = 0x00;
340 par
->Graphics
[3] = 0x00;
341 par
->Graphics
[4] = 0x00;
342 par
->Graphics
[5] = 0x40;
343 par
->Graphics
[6] = 0x05; /* only map 64k VGA memory !!!! */
344 par
->Graphics
[7] = 0x0F;
345 par
->Graphics
[8] = 0xFF;
348 par
->Attribute
[0] = 0x00; /* standard colormap translation */
349 par
->Attribute
[1] = 0x01;
350 par
->Attribute
[2] = 0x02;
351 par
->Attribute
[3] = 0x03;
352 par
->Attribute
[4] = 0x04;
353 par
->Attribute
[5] = 0x05;
354 par
->Attribute
[6] = 0x06;
355 par
->Attribute
[7] = 0x07;
356 par
->Attribute
[8] = 0x08;
357 par
->Attribute
[9] = 0x09;
358 par
->Attribute
[10] = 0x0A;
359 par
->Attribute
[11] = 0x0B;
360 par
->Attribute
[12] = 0x0C;
361 par
->Attribute
[13] = 0x0D;
362 par
->Attribute
[14] = 0x0E;
363 par
->Attribute
[15] = 0x0F;
364 par
->Attribute
[16] = 0x41;
365 par
->Attribute
[17] = 0xFF;
366 par
->Attribute
[18] = 0x0F;
367 par
->Attribute
[19] = 0x00;
368 par
->Attribute
[20] = 0x00;
372 static void vgaHWLock(struct vgastate
*state
)
374 /* Protect CRTC[0-7] */
375 vga_wcrt(state
->vgabase
, 0x11, vga_rcrt(state
->vgabase
, 0x11) | 0x80);
378 static void vgaHWUnlock(void)
380 /* Unprotect CRTC[0-7] */
381 vga_wcrt(NULL
, 0x11, vga_rcrt(NULL
, 0x11) & ~0x80);
384 static void neoLock(struct vgastate
*state
)
386 vga_wgfx(state
->vgabase
, 0x09, 0x00);
390 static void neoUnlock(void)
393 vga_wgfx(NULL
, 0x09, 0x26);
397 * VGA Palette management
399 static int paletteEnabled
= 0;
401 static inline void VGAenablePalette(void)
403 vga_r(NULL
, VGA_IS1_RC
);
404 vga_w(NULL
, VGA_ATT_W
, 0x00);
408 static inline void VGAdisablePalette(void)
410 vga_r(NULL
, VGA_IS1_RC
);
411 vga_w(NULL
, VGA_ATT_W
, 0x20);
415 static inline void VGAwATTR(u8 index
, u8 value
)
422 vga_r(NULL
, VGA_IS1_RC
);
423 vga_wattr(NULL
, index
, value
);
426 static void vgaHWProtect(int on
)
432 * Turn off screen and disable sequencer.
434 tmp
= vga_rseq(NULL
, 0x01);
435 vga_wseq(NULL
, 0x00, 0x01); /* Synchronous Reset */
436 vga_wseq(NULL
, 0x01, tmp
| 0x20); /* disable the display */
441 * Reenable sequencer, then turn on screen.
443 tmp
= vga_rseq(NULL
, 0x01);
444 vga_wseq(NULL
, 0x01, tmp
& ~0x20); /* reenable display */
445 vga_wseq(NULL
, 0x00, 0x03); /* clear synchronousreset */
451 static void vgaHWRestore(const struct fb_info
*info
,
452 const struct neofb_par
*par
)
456 vga_w(NULL
, VGA_MIS_W
, par
->MiscOutReg
);
458 for (i
= 1; i
< 5; i
++)
459 vga_wseq(NULL
, i
, par
->Sequencer
[i
]);
461 /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or CRTC[17] */
462 vga_wcrt(NULL
, 17, par
->CRTC
[17] & ~0x80);
464 for (i
= 0; i
< 25; i
++)
465 vga_wcrt(NULL
, i
, par
->CRTC
[i
]);
467 for (i
= 0; i
< 9; i
++)
468 vga_wgfx(NULL
, i
, par
->Graphics
[i
]);
472 for (i
= 0; i
< 21; i
++)
473 VGAwATTR(i
, par
->Attribute
[i
]);
479 /* -------------------- Hardware specific routines ------------------------- */
482 * Hardware Acceleration for Neo2200+
484 static inline int neo2200_sync(struct fb_info
*info
)
486 struct neofb_par
*par
= info
->par
;
488 while (readl(&par
->neo2200
->bltStat
) & 1);
492 static inline void neo2200_wait_fifo(struct fb_info
*info
,
493 int requested_fifo_space
)
495 // ndev->neo.waitfifo_calls++;
496 // ndev->neo.waitfifo_sum += requested_fifo_space;
498 /* FIXME: does not work
499 if (neo_fifo_space < requested_fifo_space)
501 neo_fifo_waitcycles++;
505 neo_fifo_space = (neo2200->bltStat >> 8);
506 if (neo_fifo_space >= requested_fifo_space)
512 neo_fifo_cache_hits++;
515 neo_fifo_space -= requested_fifo_space;
521 static inline void neo2200_accel_init(struct fb_info
*info
,
522 struct fb_var_screeninfo
*var
)
524 struct neofb_par
*par
= info
->par
;
525 Neo2200 __iomem
*neo2200
= par
->neo2200
;
530 switch (var
->bits_per_pixel
) {
532 bltMod
= NEO_MODE1_DEPTH8
;
533 pitch
= var
->xres_virtual
;
537 bltMod
= NEO_MODE1_DEPTH16
;
538 pitch
= var
->xres_virtual
* 2;
541 bltMod
= NEO_MODE1_DEPTH24
;
542 pitch
= var
->xres_virtual
* 3;
546 "neofb: neo2200_accel_init: unexpected bits per pixel!\n");
550 writel(bltMod
<< 16, &neo2200
->bltStat
);
551 writel((pitch
<< 16) | pitch
, &neo2200
->pitch
);
554 /* --------------------------------------------------------------------- */
557 neofb_open(struct fb_info
*info
, int user
)
559 struct neofb_par
*par
= info
->par
;
560 int cnt
= atomic_read(&par
->ref_count
);
563 memset(&par
->state
, 0, sizeof(struct vgastate
));
564 par
->state
.flags
= VGA_SAVE_MODE
| VGA_SAVE_FONTS
;
565 save_vga(&par
->state
);
567 atomic_inc(&par
->ref_count
);
572 neofb_release(struct fb_info
*info
, int user
)
574 struct neofb_par
*par
= info
->par
;
575 int cnt
= atomic_read(&par
->ref_count
);
580 restore_vga(&par
->state
);
582 atomic_dec(&par
->ref_count
);
587 neofb_check_var(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
589 struct neofb_par
*par
= info
->par
;
590 unsigned int pixclock
= var
->pixclock
;
591 struct xtimings timings
;
595 DBG("neofb_check_var");
598 pixclock
= 10000; /* 10ns = 100MHz */
599 timings
.pixclock
= 1000000000 / pixclock
;
600 if (timings
.pixclock
< 1)
601 timings
.pixclock
= 1;
603 if (timings
.pixclock
> par
->maxClock
)
606 timings
.dblscan
= var
->vmode
& FB_VMODE_DOUBLE
;
607 timings
.interlaced
= var
->vmode
& FB_VMODE_INTERLACED
;
608 timings
.HDisplay
= var
->xres
;
609 timings
.HSyncStart
= timings
.HDisplay
+ var
->right_margin
;
610 timings
.HSyncEnd
= timings
.HSyncStart
+ var
->hsync_len
;
611 timings
.HTotal
= timings
.HSyncEnd
+ var
->left_margin
;
612 timings
.VDisplay
= var
->yres
;
613 timings
.VSyncStart
= timings
.VDisplay
+ var
->lower_margin
;
614 timings
.VSyncEnd
= timings
.VSyncStart
+ var
->vsync_len
;
615 timings
.VTotal
= timings
.VSyncEnd
+ var
->upper_margin
;
616 timings
.sync
= var
->sync
;
618 /* Is the mode larger than the LCD panel? */
619 if (par
->internal_display
&&
620 ((var
->xres
> par
->NeoPanelWidth
) ||
621 (var
->yres
> par
->NeoPanelHeight
))) {
623 "Mode (%dx%d) larger than the LCD panel (%dx%d)\n",
624 var
->xres
, var
->yres
, par
->NeoPanelWidth
,
625 par
->NeoPanelHeight
);
629 /* Is the mode one of the acceptable sizes? */
630 if (!par
->internal_display
)
635 if (var
->yres
== 1024)
639 if (var
->yres
== 768)
643 if (var
->yres
== (par
->libretto
? 480 : 600))
647 if (var
->yres
== 480)
655 "Mode (%dx%d) won't display properly on LCD\n",
656 var
->xres
, var
->yres
);
660 var
->red
.msb_right
= 0;
661 var
->green
.msb_right
= 0;
662 var
->blue
.msb_right
= 0;
664 switch (var
->bits_per_pixel
) {
665 case 8: /* PSEUDOCOLOUR, 256 */
666 var
->transp
.offset
= 0;
667 var
->transp
.length
= 0;
670 var
->green
.offset
= 0;
671 var
->green
.length
= 8;
672 var
->blue
.offset
= 0;
673 var
->blue
.length
= 8;
676 case 16: /* DIRECTCOLOUR, 64k */
677 var
->transp
.offset
= 0;
678 var
->transp
.length
= 0;
679 var
->red
.offset
= 11;
681 var
->green
.offset
= 5;
682 var
->green
.length
= 6;
683 var
->blue
.offset
= 0;
684 var
->blue
.length
= 5;
687 case 24: /* TRUECOLOUR, 16m */
688 var
->transp
.offset
= 0;
689 var
->transp
.length
= 0;
690 var
->red
.offset
= 16;
692 var
->green
.offset
= 8;
693 var
->green
.length
= 8;
694 var
->blue
.offset
= 0;
695 var
->blue
.length
= 8;
698 #ifdef NO_32BIT_SUPPORT_YET
699 case 32: /* TRUECOLOUR, 16m */
700 var
->transp
.offset
= 24;
701 var
->transp
.length
= 8;
702 var
->red
.offset
= 16;
704 var
->green
.offset
= 8;
705 var
->green
.length
= 8;
706 var
->blue
.offset
= 0;
707 var
->blue
.length
= 8;
711 printk(KERN_WARNING
"neofb: no support for %dbpp\n",
712 var
->bits_per_pixel
);
716 vramlen
= info
->fix
.smem_len
;
717 if (vramlen
> 4 * 1024 * 1024)
718 vramlen
= 4 * 1024 * 1024;
720 if (var
->yres_virtual
< var
->yres
)
721 var
->yres_virtual
= var
->yres
;
722 if (var
->xres_virtual
< var
->xres
)
723 var
->xres_virtual
= var
->xres
;
725 memlen
= var
->xres_virtual
* var
->bits_per_pixel
* var
->yres_virtual
>> 3;
727 if (memlen
> vramlen
) {
728 var
->yres_virtual
= vramlen
* 8 / (var
->xres_virtual
*
729 var
->bits_per_pixel
);
730 memlen
= var
->xres_virtual
* var
->bits_per_pixel
*
731 var
->yres_virtual
/ 8;
734 /* we must round yres/xres down, we already rounded y/xres_virtual up
735 if it was possible. We should return -EINVAL, but I disagree */
736 if (var
->yres_virtual
< var
->yres
)
737 var
->yres
= var
->yres_virtual
;
738 if (var
->xres_virtual
< var
->xres
)
739 var
->xres
= var
->xres_virtual
;
740 if (var
->xoffset
+ var
->xres
> var
->xres_virtual
)
741 var
->xoffset
= var
->xres_virtual
- var
->xres
;
742 if (var
->yoffset
+ var
->yres
> var
->yres_virtual
)
743 var
->yoffset
= var
->yres_virtual
- var
->yres
;
749 if (var
->bits_per_pixel
>= 24 || !par
->neo2200
)
750 var
->accel_flags
&= ~FB_ACCELF_TEXT
;
754 static int neofb_set_par(struct fb_info
*info
)
756 struct neofb_par
*par
= info
->par
;
757 struct xtimings timings
;
761 int hoffset
, voffset
;
763 DBG("neofb_set_par");
767 vgaHWProtect(1); /* Blank the screen */
769 timings
.dblscan
= info
->var
.vmode
& FB_VMODE_DOUBLE
;
770 timings
.interlaced
= info
->var
.vmode
& FB_VMODE_INTERLACED
;
771 timings
.HDisplay
= info
->var
.xres
;
772 timings
.HSyncStart
= timings
.HDisplay
+ info
->var
.right_margin
;
773 timings
.HSyncEnd
= timings
.HSyncStart
+ info
->var
.hsync_len
;
774 timings
.HTotal
= timings
.HSyncEnd
+ info
->var
.left_margin
;
775 timings
.VDisplay
= info
->var
.yres
;
776 timings
.VSyncStart
= timings
.VDisplay
+ info
->var
.lower_margin
;
777 timings
.VSyncEnd
= timings
.VSyncStart
+ info
->var
.vsync_len
;
778 timings
.VTotal
= timings
.VSyncEnd
+ info
->var
.upper_margin
;
779 timings
.sync
= info
->var
.sync
;
780 timings
.pixclock
= PICOS2KHZ(info
->var
.pixclock
);
782 if (timings
.pixclock
< 1)
783 timings
.pixclock
= 1;
786 * This will allocate the datastructure and initialize all of the
787 * generic VGA registers.
790 if (vgaHWInit(&info
->var
, info
, par
, &timings
))
794 * The default value assigned by vgaHW.c is 0x41, but this does
795 * not work for NeoMagic.
797 par
->Attribute
[16] = 0x01;
799 switch (info
->var
.bits_per_pixel
) {
801 par
->CRTC
[0x13] = info
->var
.xres_virtual
>> 3;
802 par
->ExtCRTOffset
= info
->var
.xres_virtual
>> 11;
803 par
->ExtColorModeSelect
= 0x11;
806 par
->CRTC
[0x13] = info
->var
.xres_virtual
>> 2;
807 par
->ExtCRTOffset
= info
->var
.xres_virtual
>> 10;
808 par
->ExtColorModeSelect
= 0x13;
811 par
->CRTC
[0x13] = (info
->var
.xres_virtual
* 3) >> 3;
812 par
->ExtCRTOffset
= (info
->var
.xres_virtual
* 3) >> 11;
813 par
->ExtColorModeSelect
= 0x14;
815 #ifdef NO_32BIT_SUPPORT_YET
816 case 32: /* FIXME: guessed values */
817 par
->CRTC
[0x13] = info
->var
.xres_virtual
>> 1;
818 par
->ExtCRTOffset
= info
->var
.xres_virtual
>> 9;
819 par
->ExtColorModeSelect
= 0x15;
826 par
->ExtCRTDispAddr
= 0x10;
828 /* Vertical Extension */
829 par
->VerticalExt
= (((timings
.VTotal
- 2) & 0x400) >> 10)
830 | (((timings
.VDisplay
- 1) & 0x400) >> 9)
831 | (((timings
.VSyncStart
) & 0x400) >> 8)
832 | (((timings
.VSyncStart
) & 0x400) >> 7);
834 /* Fast write bursts on unless disabled. */
836 par
->SysIfaceCntl1
= 0x30;
838 par
->SysIfaceCntl1
= 0x00;
840 par
->SysIfaceCntl2
= 0xc0; /* VESA Bios sets this to 0x80! */
842 /* Initialize: by default, we want display config register to be read */
843 par
->PanelDispCntlRegRead
= 1;
845 /* Enable any user specified display devices. */
846 par
->PanelDispCntlReg1
= 0x00;
847 if (par
->internal_display
)
848 par
->PanelDispCntlReg1
|= 0x02;
849 if (par
->external_display
)
850 par
->PanelDispCntlReg1
|= 0x01;
852 /* If the user did not specify any display devices, then... */
853 if (par
->PanelDispCntlReg1
== 0x00) {
854 /* Default to internal (i.e., LCD) only. */
855 par
->PanelDispCntlReg1
= vga_rgfx(NULL
, 0x20) & 0x03;
858 /* If we are using a fixed mode, then tell the chip we are. */
859 switch (info
->var
.xres
) {
861 par
->PanelDispCntlReg1
|= 0x60;
864 par
->PanelDispCntlReg1
|= 0x40;
867 par
->PanelDispCntlReg1
|= 0x20;
874 /* Setup shadow register locking. */
875 switch (par
->PanelDispCntlReg1
& 0x03) {
876 case 0x01: /* External CRT only mode: */
877 par
->GeneralLockReg
= 0x00;
878 /* We need to program the VCLK for external display only mode. */
879 par
->ProgramVCLK
= 1;
881 case 0x02: /* Internal LCD only mode: */
882 case 0x03: /* Simultaneous internal/external (LCD/CRT) mode: */
883 par
->GeneralLockReg
= 0x01;
884 /* Don't program the VCLK when using the LCD. */
885 par
->ProgramVCLK
= 0;
890 * If the screen is to be stretched, turn on stretching for the
893 * OPTION_LCD_STRETCH means stretching should be turned off!
895 par
->PanelDispCntlReg2
= 0x00;
896 par
->PanelDispCntlReg3
= 0x00;
898 if (par
->lcd_stretch
&& (par
->PanelDispCntlReg1
== 0x02) && /* LCD only */
899 (info
->var
.xres
!= par
->NeoPanelWidth
)) {
900 switch (info
->var
.xres
) {
901 case 320: /* Needs testing. KEM -- 24 May 98 */
902 case 400: /* Needs testing. KEM -- 24 May 98 */
907 par
->PanelDispCntlReg2
|= 0xC6;
911 /* No stretching in these modes. */
917 * If the screen is to be centerd, turn on the centering for the
920 par
->PanelVertCenterReg1
= 0x00;
921 par
->PanelVertCenterReg2
= 0x00;
922 par
->PanelVertCenterReg3
= 0x00;
923 par
->PanelVertCenterReg4
= 0x00;
924 par
->PanelVertCenterReg5
= 0x00;
925 par
->PanelHorizCenterReg1
= 0x00;
926 par
->PanelHorizCenterReg2
= 0x00;
927 par
->PanelHorizCenterReg3
= 0x00;
928 par
->PanelHorizCenterReg4
= 0x00;
929 par
->PanelHorizCenterReg5
= 0x00;
932 if (par
->PanelDispCntlReg1
& 0x02) {
933 if (info
->var
.xres
== par
->NeoPanelWidth
) {
935 * No centering required when the requested display width
936 * equals the panel width.
939 par
->PanelDispCntlReg2
|= 0x01;
940 par
->PanelDispCntlReg3
|= 0x10;
942 /* Calculate the horizontal and vertical offsets. */
945 ((par
->NeoPanelWidth
-
946 info
->var
.xres
) >> 4) - 1;
948 ((par
->NeoPanelHeight
-
949 info
->var
.yres
) >> 1) - 2;
951 /* Stretched modes cannot be centered. */
956 switch (info
->var
.xres
) {
957 case 320: /* Needs testing. KEM -- 24 May 98 */
958 par
->PanelHorizCenterReg3
= hoffset
;
959 par
->PanelVertCenterReg2
= voffset
;
961 case 400: /* Needs testing. KEM -- 24 May 98 */
962 par
->PanelHorizCenterReg4
= hoffset
;
963 par
->PanelVertCenterReg1
= voffset
;
966 par
->PanelHorizCenterReg1
= hoffset
;
967 par
->PanelVertCenterReg3
= voffset
;
970 par
->PanelHorizCenterReg2
= hoffset
;
971 par
->PanelVertCenterReg4
= voffset
;
974 par
->PanelHorizCenterReg5
= hoffset
;
975 par
->PanelVertCenterReg5
= voffset
;
979 /* No centering in these modes. */
986 neoFindMode(info
->var
.xres
, info
->var
.yres
,
987 info
->var
.bits_per_pixel
);
990 * Calculate the VCLK that most closely matches the requested dot
993 neoCalcVCLK(info
, par
, timings
.pixclock
);
995 /* Since we program the clocks ourselves, always use VCLK3. */
996 par
->MiscOutReg
|= 0x0C;
998 /* alread unlocked above */
999 /* BOGUS vga_wgfx(NULL, 0x09, 0x26); */
1001 /* don't know what this is, but it's 0 from bootup anyway */
1002 vga_wgfx(NULL
, 0x15, 0x00);
1004 /* was set to 0x01 by my bios in text and vesa modes */
1005 vga_wgfx(NULL
, 0x0A, par
->GeneralLockReg
);
1008 * The color mode needs to be set before calling vgaHWRestore
1009 * to ensure the DAC is initialized properly.
1011 * NOTE: Make sure we don't change bits make sure we don't change
1012 * any reserved bits.
1014 temp
= vga_rgfx(NULL
, 0x90);
1015 switch (info
->fix
.accel
) {
1016 case FB_ACCEL_NEOMAGIC_NM2070
:
1017 temp
&= 0xF0; /* Save bits 7:4 */
1018 temp
|= (par
->ExtColorModeSelect
& ~0xF0);
1020 case FB_ACCEL_NEOMAGIC_NM2090
:
1021 case FB_ACCEL_NEOMAGIC_NM2093
:
1022 case FB_ACCEL_NEOMAGIC_NM2097
:
1023 case FB_ACCEL_NEOMAGIC_NM2160
:
1024 case FB_ACCEL_NEOMAGIC_NM2200
:
1025 case FB_ACCEL_NEOMAGIC_NM2230
:
1026 case FB_ACCEL_NEOMAGIC_NM2360
:
1027 case FB_ACCEL_NEOMAGIC_NM2380
:
1028 temp
&= 0x70; /* Save bits 6:4 */
1029 temp
|= (par
->ExtColorModeSelect
& ~0x70);
1033 vga_wgfx(NULL
, 0x90, temp
);
1036 * In some rare cases a lockup might occur if we don't delay
1037 * here. (Reported by Miles Lane)
1042 * Disable horizontal and vertical graphics and text expansions so
1043 * that vgaHWRestore works properly.
1045 temp
= vga_rgfx(NULL
, 0x25);
1047 vga_wgfx(NULL
, 0x25, temp
);
1050 * Sleep for 200ms to make sure that the two operations above have
1051 * had time to take effect.
1056 * This function handles restoring the generic VGA registers. */
1057 vgaHWRestore(info
, par
);
1059 /* linear colormap for non palettized modes */
1060 switch (info
->var
.bits_per_pixel
) {
1062 /* PseudoColor, 256 */
1063 info
->fix
.visual
= FB_VISUAL_PSEUDOCOLOR
;
1066 /* TrueColor, 64k */
1067 info
->fix
.visual
= FB_VISUAL_TRUECOLOR
;
1069 for (i
= 0; i
< 64; i
++) {
1072 outb(i
<< 1, 0x3c9);
1074 outb(i
<< 1, 0x3c9);
1078 #ifdef NO_32BIT_SUPPORT_YET
1081 /* TrueColor, 16m */
1082 info
->fix
.visual
= FB_VISUAL_TRUECOLOR
;
1084 for (i
= 0; i
< 256; i
++) {
1094 vga_wgfx(NULL
, 0x0E, par
->ExtCRTDispAddr
);
1095 vga_wgfx(NULL
, 0x0F, par
->ExtCRTOffset
);
1096 temp
= vga_rgfx(NULL
, 0x10);
1097 temp
&= 0x0F; /* Save bits 3:0 */
1098 temp
|= (par
->SysIfaceCntl1
& ~0x0F); /* VESA Bios sets bit 1! */
1099 vga_wgfx(NULL
, 0x10, temp
);
1101 vga_wgfx(NULL
, 0x11, par
->SysIfaceCntl2
);
1102 vga_wgfx(NULL
, 0x15, 0 /*par->SingleAddrPage */ );
1103 vga_wgfx(NULL
, 0x16, 0 /*par->DualAddrPage */ );
1105 temp
= vga_rgfx(NULL
, 0x20);
1106 switch (info
->fix
.accel
) {
1107 case FB_ACCEL_NEOMAGIC_NM2070
:
1108 temp
&= 0xFC; /* Save bits 7:2 */
1109 temp
|= (par
->PanelDispCntlReg1
& ~0xFC);
1111 case FB_ACCEL_NEOMAGIC_NM2090
:
1112 case FB_ACCEL_NEOMAGIC_NM2093
:
1113 case FB_ACCEL_NEOMAGIC_NM2097
:
1114 case FB_ACCEL_NEOMAGIC_NM2160
:
1115 temp
&= 0xDC; /* Save bits 7:6,4:2 */
1116 temp
|= (par
->PanelDispCntlReg1
& ~0xDC);
1118 case FB_ACCEL_NEOMAGIC_NM2200
:
1119 case FB_ACCEL_NEOMAGIC_NM2230
:
1120 case FB_ACCEL_NEOMAGIC_NM2360
:
1121 case FB_ACCEL_NEOMAGIC_NM2380
:
1122 temp
&= 0x98; /* Save bits 7,4:3 */
1123 temp
|= (par
->PanelDispCntlReg1
& ~0x98);
1126 vga_wgfx(NULL
, 0x20, temp
);
1128 temp
= vga_rgfx(NULL
, 0x25);
1129 temp
&= 0x38; /* Save bits 5:3 */
1130 temp
|= (par
->PanelDispCntlReg2
& ~0x38);
1131 vga_wgfx(NULL
, 0x25, temp
);
1133 if (info
->fix
.accel
!= FB_ACCEL_NEOMAGIC_NM2070
) {
1134 temp
= vga_rgfx(NULL
, 0x30);
1135 temp
&= 0xEF; /* Save bits 7:5 and bits 3:0 */
1136 temp
|= (par
->PanelDispCntlReg3
& ~0xEF);
1137 vga_wgfx(NULL
, 0x30, temp
);
1140 vga_wgfx(NULL
, 0x28, par
->PanelVertCenterReg1
);
1141 vga_wgfx(NULL
, 0x29, par
->PanelVertCenterReg2
);
1142 vga_wgfx(NULL
, 0x2a, par
->PanelVertCenterReg3
);
1144 if (info
->fix
.accel
!= FB_ACCEL_NEOMAGIC_NM2070
) {
1145 vga_wgfx(NULL
, 0x32, par
->PanelVertCenterReg4
);
1146 vga_wgfx(NULL
, 0x33, par
->PanelHorizCenterReg1
);
1147 vga_wgfx(NULL
, 0x34, par
->PanelHorizCenterReg2
);
1148 vga_wgfx(NULL
, 0x35, par
->PanelHorizCenterReg3
);
1151 if (info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2160
)
1152 vga_wgfx(NULL
, 0x36, par
->PanelHorizCenterReg4
);
1154 if (info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2200
||
1155 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2230
||
1156 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2360
||
1157 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2380
) {
1158 vga_wgfx(NULL
, 0x36, par
->PanelHorizCenterReg4
);
1159 vga_wgfx(NULL
, 0x37, par
->PanelVertCenterReg5
);
1160 vga_wgfx(NULL
, 0x38, par
->PanelHorizCenterReg5
);
1165 /* Program VCLK3 if needed. */
1166 if (par
->ProgramVCLK
&& ((vga_rgfx(NULL
, 0x9B) != par
->VCLK3NumeratorLow
)
1167 || (vga_rgfx(NULL
, 0x9F) != par
->VCLK3Denominator
)
1168 || (clock_hi
&& ((vga_rgfx(NULL
, 0x8F) & ~0x0f)
1169 != (par
->VCLK3NumeratorHigh
&
1171 vga_wgfx(NULL
, 0x9B, par
->VCLK3NumeratorLow
);
1173 temp
= vga_rgfx(NULL
, 0x8F);
1174 temp
&= 0x0F; /* Save bits 3:0 */
1175 temp
|= (par
->VCLK3NumeratorHigh
& ~0x0F);
1176 vga_wgfx(NULL
, 0x8F, temp
);
1178 vga_wgfx(NULL
, 0x9F, par
->VCLK3Denominator
);
1182 vga_wcrt(NULL
, 0x23, par
->biosMode
);
1184 vga_wgfx(NULL
, 0x93, 0xc0); /* Gives 5x faster framebuffer writes !!! */
1186 /* Program vertical extension register */
1187 if (info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2200
||
1188 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2230
||
1189 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2360
||
1190 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2380
) {
1191 vga_wcrt(NULL
, 0x70, par
->VerticalExt
);
1194 vgaHWProtect(0); /* Turn on screen */
1196 /* Calling this also locks offset registers required in update_start */
1197 neoLock(&par
->state
);
1199 info
->fix
.line_length
=
1200 info
->var
.xres_virtual
* (info
->var
.bits_per_pixel
>> 3);
1202 switch (info
->fix
.accel
) {
1203 case FB_ACCEL_NEOMAGIC_NM2200
:
1204 case FB_ACCEL_NEOMAGIC_NM2230
:
1205 case FB_ACCEL_NEOMAGIC_NM2360
:
1206 case FB_ACCEL_NEOMAGIC_NM2380
:
1207 neo2200_accel_init(info
, &info
->var
);
1215 static void neofb_update_start(struct fb_info
*info
,
1216 struct fb_var_screeninfo
*var
)
1218 struct neofb_par
*par
= info
->par
;
1219 struct vgastate
*state
= &par
->state
;
1220 int oldExtCRTDispAddr
;
1223 DBG("neofb_update_start");
1225 Base
= (var
->yoffset
* var
->xres_virtual
+ var
->xoffset
) >> 2;
1226 Base
*= (var
->bits_per_pixel
+ 7) / 8;
1231 * These are the generic starting address registers.
1233 vga_wcrt(state
->vgabase
, 0x0C, (Base
& 0x00FF00) >> 8);
1234 vga_wcrt(state
->vgabase
, 0x0D, (Base
& 0x00FF));
1237 * Make sure we don't clobber some other bits that might already
1238 * have been set. NOTE: NM2200 has a writable bit 3, but it shouldn't
1241 oldExtCRTDispAddr
= vga_rgfx(NULL
, 0x0E);
1242 vga_wgfx(state
->vgabase
, 0x0E, (((Base
>> 16) & 0x0f) | (oldExtCRTDispAddr
& 0xf0)));
1248 * Pan or Wrap the Display
1250 static int neofb_pan_display(struct fb_var_screeninfo
*var
,
1251 struct fb_info
*info
)
1255 y_bottom
= var
->yoffset
;
1257 if (!(var
->vmode
& FB_VMODE_YWRAP
))
1258 y_bottom
+= var
->yres
;
1260 if (var
->xoffset
> (var
->xres_virtual
- var
->xres
))
1262 if (y_bottom
> info
->var
.yres_virtual
)
1265 neofb_update_start(info
, var
);
1267 info
->var
.xoffset
= var
->xoffset
;
1268 info
->var
.yoffset
= var
->yoffset
;
1270 if (var
->vmode
& FB_VMODE_YWRAP
)
1271 info
->var
.vmode
|= FB_VMODE_YWRAP
;
1273 info
->var
.vmode
&= ~FB_VMODE_YWRAP
;
1277 static int neofb_setcolreg(u_int regno
, u_int red
, u_int green
, u_int blue
,
1278 u_int transp
, struct fb_info
*fb
)
1280 if (regno
>= fb
->cmap
.len
|| regno
> 255)
1283 switch (fb
->var
.bits_per_pixel
) {
1287 outb(red
>> 10, 0x3c9);
1288 outb(green
>> 10, 0x3c9);
1289 outb(blue
>> 10, 0x3c9);
1292 ((u32
*) fb
->pseudo_palette
)[regno
] =
1293 ((red
& 0xf800)) | ((green
& 0xfc00) >> 5) |
1294 ((blue
& 0xf800) >> 11);
1297 ((u32
*) fb
->pseudo_palette
)[regno
] =
1298 ((red
& 0xff00) << 8) | ((green
& 0xff00)) |
1299 ((blue
& 0xff00) >> 8);
1301 #ifdef NO_32BIT_SUPPORT_YET
1303 ((u32
*) fb
->pseudo_palette
)[regno
] =
1304 ((transp
& 0xff00) << 16) | ((red
& 0xff00) << 8) |
1305 ((green
& 0xff00)) | ((blue
& 0xff00) >> 8);
1315 * (Un)Blank the display.
1317 static int neofb_blank(int blank_mode
, struct fb_info
*info
)
1320 * Blank the screen if blank_mode != 0, else unblank.
1321 * Return 0 if blanking succeeded, != 0 if un-/blanking failed due to
1322 * e.g. a video mode which doesn't support it. Implements VESA suspend
1323 * and powerdown modes for monitors, and backlight control on LCDs.
1324 * blank_mode == 0: unblanked (backlight on)
1325 * blank_mode == 1: blank (backlight on)
1326 * blank_mode == 2: suspend vsync (backlight off)
1327 * blank_mode == 3: suspend hsync (backlight off)
1328 * blank_mode == 4: powerdown (backlight off)
1330 * wms...Enable VESA DPMS compatible powerdown mode
1331 * run "setterm -powersave powerdown" to take advantage
1333 struct neofb_par
*par
= info
->par
;
1334 int seqflags
, lcdflags
, dpmsflags
, reg
, tmpdisp
;
1337 * Read back the register bits related to display configuration. They might
1338 * have been changed underneath the driver via Fn key stroke.
1341 tmpdisp
= vga_rgfx(NULL
, 0x20) & 0x03;
1342 neoLock(&par
->state
);
1344 /* In case we blank the screen, we want to store the possibly new
1345 * configuration in the driver. During un-blank, we re-apply this setting,
1346 * since the LCD bit will be cleared in order to switch off the backlight.
1348 if (par
->PanelDispCntlRegRead
) {
1349 par
->PanelDispCntlReg1
= tmpdisp
;
1351 par
->PanelDispCntlRegRead
= !blank_mode
;
1353 switch (blank_mode
) {
1354 case FB_BLANK_POWERDOWN
: /* powerdown - both sync lines down */
1355 seqflags
= VGA_SR01_SCREEN_OFF
; /* Disable sequencer */
1356 lcdflags
= 0; /* LCD off */
1357 dpmsflags
= NEO_GR01_SUPPRESS_HSYNC
|
1358 NEO_GR01_SUPPRESS_VSYNC
;
1359 #ifdef CONFIG_TOSHIBA
1360 /* Do we still need this ? */
1361 /* attempt to turn off backlight on toshiba; also turns off external */
1365 regs
.eax
= 0xff00; /* HCI_SET */
1366 regs
.ebx
= 0x0002; /* HCI_BACKLIGHT */
1367 regs
.ecx
= 0x0000; /* HCI_DISABLE */
1372 case FB_BLANK_HSYNC_SUSPEND
: /* hsync off */
1373 seqflags
= VGA_SR01_SCREEN_OFF
; /* Disable sequencer */
1374 lcdflags
= 0; /* LCD off */
1375 dpmsflags
= NEO_GR01_SUPPRESS_HSYNC
;
1377 case FB_BLANK_VSYNC_SUSPEND
: /* vsync off */
1378 seqflags
= VGA_SR01_SCREEN_OFF
; /* Disable sequencer */
1379 lcdflags
= 0; /* LCD off */
1380 dpmsflags
= NEO_GR01_SUPPRESS_VSYNC
;
1382 case FB_BLANK_NORMAL
: /* just blank screen (backlight stays on) */
1383 seqflags
= VGA_SR01_SCREEN_OFF
; /* Disable sequencer */
1385 * During a blank operation with the LID shut, we might store "LCD off"
1386 * by mistake. Due to timing issues, the BIOS may switch the lights
1387 * back on, and we turn it back off once we "unblank".
1389 * So here is an attempt to implement ">=" - if we are in the process
1390 * of unblanking, and the LCD bit is unset in the driver but set in the
1391 * register, we must keep it.
1393 lcdflags
= ((par
->PanelDispCntlReg1
| tmpdisp
) & 0x02); /* LCD normal */
1394 dpmsflags
= 0x00; /* no hsync/vsync suppression */
1396 case FB_BLANK_UNBLANK
: /* unblank */
1397 seqflags
= 0; /* Enable sequencer */
1398 lcdflags
= ((par
->PanelDispCntlReg1
| tmpdisp
) & 0x02); /* LCD normal */
1399 dpmsflags
= 0x00; /* no hsync/vsync suppression */
1400 #ifdef CONFIG_TOSHIBA
1401 /* Do we still need this ? */
1402 /* attempt to re-enable backlight/external on toshiba */
1406 regs
.eax
= 0xff00; /* HCI_SET */
1407 regs
.ebx
= 0x0002; /* HCI_BACKLIGHT */
1408 regs
.ecx
= 0x0001; /* HCI_ENABLE */
1413 default: /* Anything else we don't understand; return 1 to tell
1414 * fb_blank we didn't aactually do anything */
1419 reg
= (vga_rseq(NULL
, 0x01) & ~0x20) | seqflags
;
1420 vga_wseq(NULL
, 0x01, reg
);
1421 reg
= (vga_rgfx(NULL
, 0x20) & ~0x02) | lcdflags
;
1422 vga_wgfx(NULL
, 0x20, reg
);
1423 reg
= (vga_rgfx(NULL
, 0x01) & ~0xF0) | 0x80 | dpmsflags
;
1424 vga_wgfx(NULL
, 0x01, reg
);
1425 neoLock(&par
->state
);
1430 neo2200_fillrect(struct fb_info
*info
, const struct fb_fillrect
*rect
)
1432 struct neofb_par
*par
= info
->par
;
1435 dst
= rect
->dx
+ rect
->dy
* info
->var
.xres_virtual
;
1436 rop
= rect
->rop
? 0x060000 : 0x0c0000;
1438 neo2200_wait_fifo(info
, 4);
1440 /* set blt control */
1441 writel(NEO_BC3_FIFO_EN
|
1442 NEO_BC0_SRC_IS_FG
| NEO_BC3_SKIP_MAPPING
|
1443 // NEO_BC3_DST_XY_ADDR |
1444 // NEO_BC3_SRC_XY_ADDR |
1445 rop
, &par
->neo2200
->bltCntl
);
1447 switch (info
->var
.bits_per_pixel
) {
1449 writel(rect
->color
, &par
->neo2200
->fgColor
);
1453 writel(((u32
*) (info
->pseudo_palette
))[rect
->color
],
1454 &par
->neo2200
->fgColor
);
1458 writel(dst
* ((info
->var
.bits_per_pixel
+ 7) >> 3),
1459 &par
->neo2200
->dstStart
);
1460 writel((rect
->height
<< 16) | (rect
->width
& 0xffff),
1461 &par
->neo2200
->xyExt
);
1465 neo2200_copyarea(struct fb_info
*info
, const struct fb_copyarea
*area
)
1467 u32 sx
= area
->sx
, sy
= area
->sy
, dx
= area
->dx
, dy
= area
->dy
;
1468 struct neofb_par
*par
= info
->par
;
1469 u_long src
, dst
, bltCntl
;
1471 bltCntl
= NEO_BC3_FIFO_EN
| NEO_BC3_SKIP_MAPPING
| 0x0C0000;
1473 if ((dy
> sy
) || ((dy
== sy
) && (dx
> sx
))) {
1474 /* Start with the lower right corner */
1475 sy
+= (area
->height
- 1);
1476 dy
+= (area
->height
- 1);
1477 sx
+= (area
->width
- 1);
1478 dx
+= (area
->width
- 1);
1480 bltCntl
|= NEO_BC0_X_DEC
| NEO_BC0_DST_Y_DEC
| NEO_BC0_SRC_Y_DEC
;
1483 src
= sx
* (info
->var
.bits_per_pixel
>> 3) + sy
*info
->fix
.line_length
;
1484 dst
= dx
* (info
->var
.bits_per_pixel
>> 3) + dy
*info
->fix
.line_length
;
1486 neo2200_wait_fifo(info
, 4);
1488 /* set blt control */
1489 writel(bltCntl
, &par
->neo2200
->bltCntl
);
1491 writel(src
, &par
->neo2200
->srcStart
);
1492 writel(dst
, &par
->neo2200
->dstStart
);
1493 writel((area
->height
<< 16) | (area
->width
& 0xffff),
1494 &par
->neo2200
->xyExt
);
1498 neo2200_imageblit(struct fb_info
*info
, const struct fb_image
*image
)
1500 struct neofb_par
*par
= info
->par
;
1501 int s_pitch
= (image
->width
* image
->depth
+ 7) >> 3;
1502 int scan_align
= info
->pixmap
.scan_align
- 1;
1503 int buf_align
= info
->pixmap
.buf_align
- 1;
1504 int bltCntl_flags
, d_pitch
, data_len
;
1506 // The data is padded for the hardware
1507 d_pitch
= (s_pitch
+ scan_align
) & ~scan_align
;
1508 data_len
= ((d_pitch
* image
->height
) + buf_align
) & ~buf_align
;
1512 if (image
->depth
== 1) {
1513 if (info
->var
.bits_per_pixel
== 24 && image
->width
< 16) {
1514 /* FIXME. There is a bug with accelerated color-expanded
1515 * transfers in 24 bit mode if the image being transferred
1516 * is less than 16 bits wide. This is due to insufficient
1517 * padding when writing the image. We need to adjust
1518 * struct fb_pixmap. Not yet done. */
1519 return cfb_imageblit(info
, image
);
1521 bltCntl_flags
= NEO_BC0_SRC_MONO
;
1522 } else if (image
->depth
== info
->var
.bits_per_pixel
) {
1525 /* We don't currently support hardware acceleration if image
1526 * depth is different from display */
1527 return cfb_imageblit(info
, image
);
1530 switch (info
->var
.bits_per_pixel
) {
1532 writel(image
->fg_color
, &par
->neo2200
->fgColor
);
1533 writel(image
->bg_color
, &par
->neo2200
->bgColor
);
1537 writel(((u32
*) (info
->pseudo_palette
))[image
->fg_color
],
1538 &par
->neo2200
->fgColor
);
1539 writel(((u32
*) (info
->pseudo_palette
))[image
->bg_color
],
1540 &par
->neo2200
->bgColor
);
1544 writel(NEO_BC0_SYS_TO_VID
|
1545 NEO_BC3_SKIP_MAPPING
| bltCntl_flags
|
1546 // NEO_BC3_DST_XY_ADDR |
1547 0x0c0000, &par
->neo2200
->bltCntl
);
1549 writel(0, &par
->neo2200
->srcStart
);
1550 // par->neo2200->dstStart = (image->dy << 16) | (image->dx & 0xffff);
1551 writel(((image
->dx
& 0xffff) * (info
->var
.bits_per_pixel
>> 3) +
1552 image
->dy
* info
->fix
.line_length
), &par
->neo2200
->dstStart
);
1553 writel((image
->height
<< 16) | (image
->width
& 0xffff),
1554 &par
->neo2200
->xyExt
);
1556 memcpy_toio(par
->mmio_vbase
+ 0x100000, image
->data
, data_len
);
1560 neofb_fillrect(struct fb_info
*info
, const struct fb_fillrect
*rect
)
1562 switch (info
->fix
.accel
) {
1563 case FB_ACCEL_NEOMAGIC_NM2200
:
1564 case FB_ACCEL_NEOMAGIC_NM2230
:
1565 case FB_ACCEL_NEOMAGIC_NM2360
:
1566 case FB_ACCEL_NEOMAGIC_NM2380
:
1567 neo2200_fillrect(info
, rect
);
1570 cfb_fillrect(info
, rect
);
1576 neofb_copyarea(struct fb_info
*info
, const struct fb_copyarea
*area
)
1578 switch (info
->fix
.accel
) {
1579 case FB_ACCEL_NEOMAGIC_NM2200
:
1580 case FB_ACCEL_NEOMAGIC_NM2230
:
1581 case FB_ACCEL_NEOMAGIC_NM2360
:
1582 case FB_ACCEL_NEOMAGIC_NM2380
:
1583 neo2200_copyarea(info
, area
);
1586 cfb_copyarea(info
, area
);
1592 neofb_imageblit(struct fb_info
*info
, const struct fb_image
*image
)
1594 switch (info
->fix
.accel
) {
1595 case FB_ACCEL_NEOMAGIC_NM2200
:
1596 case FB_ACCEL_NEOMAGIC_NM2230
:
1597 case FB_ACCEL_NEOMAGIC_NM2360
:
1598 case FB_ACCEL_NEOMAGIC_NM2380
:
1599 neo2200_imageblit(info
, image
);
1602 cfb_imageblit(info
, image
);
1608 neofb_sync(struct fb_info
*info
)
1610 switch (info
->fix
.accel
) {
1611 case FB_ACCEL_NEOMAGIC_NM2200
:
1612 case FB_ACCEL_NEOMAGIC_NM2230
:
1613 case FB_ACCEL_NEOMAGIC_NM2360
:
1614 case FB_ACCEL_NEOMAGIC_NM2380
:
1625 neofb_draw_cursor(struct fb_info *info, u8 *dst, u8 *src, unsigned int width)
1627 //memset_io(info->sprite.addr, 0xff, 1);
1631 neofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1633 struct neofb_par *par = (struct neofb_par *) info->par;
1636 write_le32(NEOREG_CURSCNTL, ~NEO_CURS_ENABLE, par);
1638 if (cursor->set & FB_CUR_SETPOS) {
1639 u32 x = cursor->image.dx;
1640 u32 y = cursor->image.dy;
1642 info->cursor.image.dx = x;
1643 info->cursor.image.dy = y;
1644 write_le32(NEOREG_CURSX, x, par);
1645 write_le32(NEOREG_CURSY, y, par);
1648 if (cursor->set & FB_CUR_SETSIZE) {
1649 info->cursor.image.height = cursor->image.height;
1650 info->cursor.image.width = cursor->image.width;
1653 if (cursor->set & FB_CUR_SETHOT)
1654 info->cursor.hot = cursor->hot;
1656 if (cursor->set & FB_CUR_SETCMAP) {
1657 if (cursor->image.depth == 1) {
1658 u32 fg = cursor->image.fg_color;
1659 u32 bg = cursor->image.bg_color;
1661 info->cursor.image.fg_color = fg;
1662 info->cursor.image.bg_color = bg;
1664 fg = ((fg & 0xff0000) >> 16) | ((fg & 0xff) << 16) | (fg & 0xff00);
1665 bg = ((bg & 0xff0000) >> 16) | ((bg & 0xff) << 16) | (bg & 0xff00);
1666 write_le32(NEOREG_CURSFGCOLOR, fg, par);
1667 write_le32(NEOREG_CURSBGCOLOR, bg, par);
1671 if (cursor->set & FB_CUR_SETSHAPE)
1672 fb_load_cursor_image(info);
1674 if (info->cursor.enable)
1675 write_le32(NEOREG_CURSCNTL, NEO_CURS_ENABLE, par);
1680 static struct fb_ops neofb_ops
= {
1681 .owner
= THIS_MODULE
,
1682 .fb_open
= neofb_open
,
1683 .fb_release
= neofb_release
,
1684 .fb_check_var
= neofb_check_var
,
1685 .fb_set_par
= neofb_set_par
,
1686 .fb_setcolreg
= neofb_setcolreg
,
1687 .fb_pan_display
= neofb_pan_display
,
1688 .fb_blank
= neofb_blank
,
1689 .fb_sync
= neofb_sync
,
1690 .fb_fillrect
= neofb_fillrect
,
1691 .fb_copyarea
= neofb_copyarea
,
1692 .fb_imageblit
= neofb_imageblit
,
1695 /* --------------------------------------------------------------------- */
1697 static struct fb_videomode __devinitdata mode800x480
= {
1707 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
1708 .vmode
= FB_VMODE_NONINTERLACED
1711 static int __devinit
neo_map_mmio(struct fb_info
*info
,
1712 struct pci_dev
*dev
)
1714 struct neofb_par
*par
= info
->par
;
1716 DBG("neo_map_mmio");
1718 switch (info
->fix
.accel
) {
1719 case FB_ACCEL_NEOMAGIC_NM2070
:
1720 info
->fix
.mmio_start
= pci_resource_start(dev
, 0)+
1723 case FB_ACCEL_NEOMAGIC_NM2090
:
1724 case FB_ACCEL_NEOMAGIC_NM2093
:
1725 info
->fix
.mmio_start
= pci_resource_start(dev
, 0)+
1728 case FB_ACCEL_NEOMAGIC_NM2160
:
1729 case FB_ACCEL_NEOMAGIC_NM2097
:
1730 case FB_ACCEL_NEOMAGIC_NM2200
:
1731 case FB_ACCEL_NEOMAGIC_NM2230
:
1732 case FB_ACCEL_NEOMAGIC_NM2360
:
1733 case FB_ACCEL_NEOMAGIC_NM2380
:
1734 info
->fix
.mmio_start
= pci_resource_start(dev
, 1);
1737 info
->fix
.mmio_start
= pci_resource_start(dev
, 0);
1739 info
->fix
.mmio_len
= MMIO_SIZE
;
1741 if (!request_mem_region
1742 (info
->fix
.mmio_start
, MMIO_SIZE
, "memory mapped I/O")) {
1743 printk("neofb: memory mapped IO in use\n");
1747 par
->mmio_vbase
= ioremap(info
->fix
.mmio_start
, MMIO_SIZE
);
1748 if (!par
->mmio_vbase
) {
1749 printk("neofb: unable to map memory mapped IO\n");
1750 release_mem_region(info
->fix
.mmio_start
,
1751 info
->fix
.mmio_len
);
1754 printk(KERN_INFO
"neofb: mapped io at %p\n",
1759 static void neo_unmap_mmio(struct fb_info
*info
)
1761 struct neofb_par
*par
= info
->par
;
1763 DBG("neo_unmap_mmio");
1765 iounmap(par
->mmio_vbase
);
1766 par
->mmio_vbase
= NULL
;
1768 release_mem_region(info
->fix
.mmio_start
,
1769 info
->fix
.mmio_len
);
1772 static int __devinit
neo_map_video(struct fb_info
*info
,
1773 struct pci_dev
*dev
, int video_len
)
1775 //unsigned long addr;
1777 DBG("neo_map_video");
1779 info
->fix
.smem_start
= pci_resource_start(dev
, 0);
1780 info
->fix
.smem_len
= video_len
;
1782 if (!request_mem_region(info
->fix
.smem_start
, info
->fix
.smem_len
,
1784 printk("neofb: frame buffer in use\n");
1789 ioremap(info
->fix
.smem_start
, info
->fix
.smem_len
);
1790 if (!info
->screen_base
) {
1791 printk("neofb: unable to map screen memory\n");
1792 release_mem_region(info
->fix
.smem_start
,
1793 info
->fix
.smem_len
);
1796 printk(KERN_INFO
"neofb: mapped framebuffer at %p\n",
1800 ((struct neofb_par
*)(info
->par
))->mtrr
=
1801 mtrr_add(info
->fix
.smem_start
, pci_resource_len(dev
, 0),
1802 MTRR_TYPE_WRCOMB
, 1);
1805 /* Clear framebuffer, it's all white in memory after boot */
1806 memset_io(info
->screen_base
, 0, info
->fix
.smem_len
);
1808 /* Allocate Cursor drawing pad.
1809 info->fix.smem_len -= PAGE_SIZE;
1810 addr = info->fix.smem_start + info->fix.smem_len;
1811 write_le32(NEOREG_CURSMEMPOS, ((0x000f & (addr >> 10)) << 8) |
1812 ((0x0ff0 & (addr >> 10)) >> 4), par);
1813 addr = (unsigned long) info->screen_base + info->fix.smem_len;
1814 info->sprite.addr = (u8 *) addr; */
1818 static void neo_unmap_video(struct fb_info
*info
)
1820 DBG("neo_unmap_video");
1824 struct neofb_par
*par
= info
->par
;
1826 mtrr_del(par
->mtrr
, info
->fix
.smem_start
,
1827 info
->fix
.smem_len
);
1830 iounmap(info
->screen_base
);
1831 info
->screen_base
= NULL
;
1833 release_mem_region(info
->fix
.smem_start
,
1834 info
->fix
.smem_len
);
1837 static int __devinit
neo_scan_monitor(struct fb_info
*info
)
1839 struct neofb_par
*par
= info
->par
;
1840 unsigned char type
, display
;
1843 // Eventually we will have i2c support.
1844 info
->monspecs
.modedb
= kmalloc(sizeof(struct fb_videomode
), GFP_KERNEL
);
1845 if (!info
->monspecs
.modedb
)
1847 info
->monspecs
.modedb_len
= 1;
1849 /* Determine the panel type */
1850 vga_wgfx(NULL
, 0x09, 0x26);
1851 type
= vga_rgfx(NULL
, 0x21);
1852 display
= vga_rgfx(NULL
, 0x20);
1853 if (!par
->internal_display
&& !par
->external_display
) {
1854 par
->internal_display
= display
& 2 || !(display
& 3) ? 1 : 0;
1855 par
->external_display
= display
& 1;
1856 printk (KERN_INFO
"Autodetected %s display\n",
1857 par
->internal_display
&& par
->external_display
? "simultaneous" :
1858 par
->internal_display
? "internal" : "external");
1861 /* Determine panel width -- used in NeoValidMode. */
1862 w
= vga_rgfx(NULL
, 0x20);
1863 vga_wgfx(NULL
, 0x09, 0x00);
1864 switch ((w
& 0x18) >> 3) {
1867 par
->NeoPanelWidth
= 640;
1868 par
->NeoPanelHeight
= 480;
1869 memcpy(info
->monspecs
.modedb
, &vesa_modes
[3], sizeof(struct fb_videomode
));
1872 par
->NeoPanelWidth
= 800;
1873 if (par
->libretto
) {
1874 par
->NeoPanelHeight
= 480;
1875 memcpy(info
->monspecs
.modedb
, &mode800x480
, sizeof(struct fb_videomode
));
1878 par
->NeoPanelHeight
= 600;
1879 memcpy(info
->monspecs
.modedb
, &vesa_modes
[8], sizeof(struct fb_videomode
));
1884 par
->NeoPanelWidth
= 1024;
1885 par
->NeoPanelHeight
= 768;
1886 memcpy(info
->monspecs
.modedb
, &vesa_modes
[13], sizeof(struct fb_videomode
));
1889 /* 1280x1024@60 panel support needs to be added */
1891 par
->NeoPanelWidth
= 1280;
1892 par
->NeoPanelHeight
= 1024;
1893 memcpy(info
->monspecs
.modedb
, &vesa_modes
[20], sizeof(struct fb_videomode
));
1897 "neofb: Only 640x480, 800x600/480 and 1024x768 panels are currently supported\n");
1902 par
->NeoPanelWidth
= 640;
1903 par
->NeoPanelHeight
= 480;
1904 memcpy(info
->monspecs
.modedb
, &vesa_modes
[3], sizeof(struct fb_videomode
));
1908 printk(KERN_INFO
"Panel is a %dx%d %s %s display\n",
1910 par
->NeoPanelHeight
,
1911 (type
& 0x02) ? "color" : "monochrome",
1912 (type
& 0x10) ? "TFT" : "dual scan");
1916 static int __devinit
neo_init_hw(struct fb_info
*info
)
1918 struct neofb_par
*par
= info
->par
;
1920 int maxClock
= 65000;
1921 int CursorMem
= 1024;
1922 int CursorOff
= 0x100;
1923 int linearSize
= 1024;
1924 int maxWidth
= 1024;
1925 int maxHeight
= 1024;
1932 printk(KERN_DEBUG
"--- Neo extended register dump ---\n");
1933 for (int w
= 0; w
< 0x85; w
++)
1934 printk(KERN_DEBUG
"CR %p: %p\n", (void *) w
,
1935 (void *) vga_rcrt(NULL
, w
));
1936 for (int w
= 0; w
< 0xC7; w
++)
1937 printk(KERN_DEBUG
"GR %p: %p\n", (void *) w
,
1938 (void *) vga_rgfx(NULL
, w
));
1940 switch (info
->fix
.accel
) {
1941 case FB_ACCEL_NEOMAGIC_NM2070
:
1950 case FB_ACCEL_NEOMAGIC_NM2090
:
1951 case FB_ACCEL_NEOMAGIC_NM2093
:
1960 case FB_ACCEL_NEOMAGIC_NM2097
:
1969 case FB_ACCEL_NEOMAGIC_NM2160
:
1978 case FB_ACCEL_NEOMAGIC_NM2200
:
1985 maxHeight
= 1024; /* ???? */
1987 par
->neo2200
= (Neo2200 __iomem
*) par
->mmio_vbase
;
1989 case FB_ACCEL_NEOMAGIC_NM2230
:
1996 maxHeight
= 1024; /* ???? */
1998 par
->neo2200
= (Neo2200 __iomem
*) par
->mmio_vbase
;
2000 case FB_ACCEL_NEOMAGIC_NM2360
:
2007 maxHeight
= 1024; /* ???? */
2009 par
->neo2200
= (Neo2200 __iomem
*) par
->mmio_vbase
;
2011 case FB_ACCEL_NEOMAGIC_NM2380
:
2018 maxHeight
= 1024; /* ???? */
2020 par
->neo2200
= (Neo2200 __iomem
*) par
->mmio_vbase
;
2024 info->sprite.size = CursorMem;
2025 info->sprite.scan_align = 1;
2026 info->sprite.buf_align = 1;
2027 info->sprite.flags = FB_PIXMAP_IO;
2028 info->sprite.outbuf = neofb_draw_cursor;
2030 par
->maxClock
= maxClock
;
2031 par
->cursorOff
= CursorOff
;
2032 return ((videoRam
* 1024));
2036 static struct fb_info
*__devinit
neo_alloc_fb_info(struct pci_dev
*dev
, const struct
2039 struct fb_info
*info
;
2040 struct neofb_par
*par
;
2042 info
= framebuffer_alloc(sizeof(struct neofb_par
), &dev
->dev
);
2049 info
->fix
.accel
= id
->driver_data
;
2051 par
->pci_burst
= !nopciburst
;
2052 par
->lcd_stretch
= !nostretch
;
2053 par
->libretto
= libretto
;
2055 par
->internal_display
= internal
;
2056 par
->external_display
= external
;
2057 info
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
2059 switch (info
->fix
.accel
) {
2060 case FB_ACCEL_NEOMAGIC_NM2070
:
2061 sprintf(info
->fix
.id
, "MagicGraph 128");
2063 case FB_ACCEL_NEOMAGIC_NM2090
:
2064 sprintf(info
->fix
.id
, "MagicGraph 128V");
2066 case FB_ACCEL_NEOMAGIC_NM2093
:
2067 sprintf(info
->fix
.id
, "MagicGraph 128ZV");
2069 case FB_ACCEL_NEOMAGIC_NM2097
:
2070 sprintf(info
->fix
.id
, "MagicGraph 128ZV+");
2072 case FB_ACCEL_NEOMAGIC_NM2160
:
2073 sprintf(info
->fix
.id
, "MagicGraph 128XD");
2075 case FB_ACCEL_NEOMAGIC_NM2200
:
2076 sprintf(info
->fix
.id
, "MagicGraph 256AV");
2077 info
->flags
|= FBINFO_HWACCEL_IMAGEBLIT
|
2078 FBINFO_HWACCEL_COPYAREA
|
2079 FBINFO_HWACCEL_FILLRECT
;
2081 case FB_ACCEL_NEOMAGIC_NM2230
:
2082 sprintf(info
->fix
.id
, "MagicGraph 256AV+");
2083 info
->flags
|= FBINFO_HWACCEL_IMAGEBLIT
|
2084 FBINFO_HWACCEL_COPYAREA
|
2085 FBINFO_HWACCEL_FILLRECT
;
2087 case FB_ACCEL_NEOMAGIC_NM2360
:
2088 sprintf(info
->fix
.id
, "MagicGraph 256ZX");
2089 info
->flags
|= FBINFO_HWACCEL_IMAGEBLIT
|
2090 FBINFO_HWACCEL_COPYAREA
|
2091 FBINFO_HWACCEL_FILLRECT
;
2093 case FB_ACCEL_NEOMAGIC_NM2380
:
2094 sprintf(info
->fix
.id
, "MagicGraph 256XL+");
2095 info
->flags
|= FBINFO_HWACCEL_IMAGEBLIT
|
2096 FBINFO_HWACCEL_COPYAREA
|
2097 FBINFO_HWACCEL_FILLRECT
;
2101 info
->fix
.type
= FB_TYPE_PACKED_PIXELS
;
2102 info
->fix
.type_aux
= 0;
2103 info
->fix
.xpanstep
= 0;
2104 info
->fix
.ypanstep
= 4;
2105 info
->fix
.ywrapstep
= 0;
2106 info
->fix
.accel
= id
->driver_data
;
2108 info
->fbops
= &neofb_ops
;
2109 info
->pseudo_palette
= par
->palette
;
2113 static void neo_free_fb_info(struct fb_info
*info
)
2117 * Free the colourmap
2119 fb_dealloc_cmap(&info
->cmap
);
2120 framebuffer_release(info
);
2124 /* --------------------------------------------------------------------- */
2126 static int __devinit
neofb_probe(struct pci_dev
*dev
,
2127 const struct pci_device_id
*id
)
2129 struct fb_info
*info
;
2130 u_int h_sync
, v_sync
;
2135 err
= pci_enable_device(dev
);
2140 info
= neo_alloc_fb_info(dev
, id
);
2144 err
= neo_map_mmio(info
, dev
);
2148 err
= neo_scan_monitor(info
);
2150 goto err_scan_monitor
;
2152 video_len
= neo_init_hw(info
);
2153 if (video_len
< 0) {
2158 err
= neo_map_video(info
, dev
, video_len
);
2162 if (!fb_find_mode(&info
->var
, info
, mode_option
, NULL
, 0,
2163 info
->monspecs
.modedb
, 16)) {
2164 printk(KERN_ERR
"neofb: Unable to find usable video mode.\n");
2169 * Calculate the hsync and vsync frequencies. Note that
2170 * we split the 1e12 constant up so that we can preserve
2171 * the precision and fit the results into 32-bit registers.
2172 * (1953125000 * 512 = 1e12)
2174 h_sync
= 1953125000 / info
->var
.pixclock
;
2176 h_sync
* 512 / (info
->var
.xres
+ info
->var
.left_margin
+
2177 info
->var
.right_margin
+ info
->var
.hsync_len
);
2179 h_sync
/ (info
->var
.yres
+ info
->var
.upper_margin
+
2180 info
->var
.lower_margin
+ info
->var
.vsync_len
);
2182 printk(KERN_INFO
"neofb v" NEOFB_VERSION
2183 ": %dkB VRAM, using %dx%d, %d.%03dkHz, %dHz\n",
2184 info
->fix
.smem_len
>> 10, info
->var
.xres
,
2185 info
->var
.yres
, h_sync
/ 1000, h_sync
% 1000, v_sync
);
2187 if (fb_alloc_cmap(&info
->cmap
, 256, 0) < 0)
2190 err
= register_framebuffer(info
);
2194 printk(KERN_INFO
"fb%d: %s frame buffer device\n",
2195 info
->node
, info
->fix
.id
);
2200 pci_set_drvdata(dev
, info
);
2204 fb_dealloc_cmap(&info
->cmap
);
2206 neo_unmap_video(info
);
2208 fb_destroy_modedb(info
->monspecs
.modedb
);
2210 neo_unmap_mmio(info
);
2212 neo_free_fb_info(info
);
2216 static void __devexit
neofb_remove(struct pci_dev
*dev
)
2218 struct fb_info
*info
= pci_get_drvdata(dev
);
2220 DBG("neofb_remove");
2224 * If unregister_framebuffer fails, then
2225 * we will be leaving hooks that could cause
2226 * oopsen laying around.
2228 if (unregister_framebuffer(info
))
2230 "neofb: danger danger! Oopsen imminent!\n");
2232 neo_unmap_video(info
);
2233 fb_destroy_modedb(info
->monspecs
.modedb
);
2234 neo_unmap_mmio(info
);
2235 neo_free_fb_info(info
);
2238 * Ensure that the driver data is no longer
2241 pci_set_drvdata(dev
, NULL
);
2245 static struct pci_device_id neofb_devices
[] = {
2246 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2070
,
2247 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2070
},
2249 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2090
,
2250 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2090
},
2252 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2093
,
2253 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2093
},
2255 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2097
,
2256 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2097
},
2258 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2160
,
2259 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2160
},
2261 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2200
,
2262 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2200
},
2264 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2230
,
2265 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2230
},
2267 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2360
,
2268 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2360
},
2270 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2380
,
2271 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2380
},
2273 {0, 0, 0, 0, 0, 0, 0}
2276 MODULE_DEVICE_TABLE(pci
, neofb_devices
);
2278 static struct pci_driver neofb_driver
= {
2280 .id_table
= neofb_devices
,
2281 .probe
= neofb_probe
,
2282 .remove
= __devexit_p(neofb_remove
)
2285 /* ************************* init in-kernel code ************************** */
2288 static int __init
neofb_setup(char *options
)
2294 if (!options
|| !*options
)
2297 while ((this_opt
= strsep(&options
, ",")) != NULL
) {
2301 if (!strncmp(this_opt
, "internal", 8))
2303 else if (!strncmp(this_opt
, "external", 8))
2305 else if (!strncmp(this_opt
, "nostretch", 9))
2307 else if (!strncmp(this_opt
, "nopciburst", 10))
2309 else if (!strncmp(this_opt
, "libretto", 8))
2312 mode_option
= this_opt
;
2318 static int __init
neofb_init(void)
2321 char *option
= NULL
;
2323 if (fb_get_options("neofb", &option
))
2325 neofb_setup(option
);
2327 return pci_register_driver(&neofb_driver
);
2330 module_init(neofb_init
);
2333 static void __exit
neofb_exit(void)
2335 pci_unregister_driver(&neofb_driver
);
2338 module_exit(neofb_exit
);