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>
73 #include <asm/pgtable.h>
74 #include <asm/system.h>
80 #include <video/vga.h>
81 #include <video/neomagic.h>
83 #define NEOFB_VERSION "0.4.2"
85 /* --------------------------------------------------------------------- */
91 static int nopciburst
;
92 static char *mode_option __devinitdata
= NULL
;
96 MODULE_AUTHOR("(c) 2001-2002 Denis Oliver Kropp <dok@convergence.de>");
97 MODULE_LICENSE("GPL");
98 MODULE_DESCRIPTION("FBDev driver for NeoMagic PCI Chips");
99 module_param(internal
, bool, 0);
100 MODULE_PARM_DESC(internal
, "Enable output on internal LCD Display.");
101 module_param(external
, bool, 0);
102 MODULE_PARM_DESC(external
, "Enable output on external CRT.");
103 module_param(libretto
, bool, 0);
104 MODULE_PARM_DESC(libretto
, "Force Libretto 100/110 800x480 LCD.");
105 module_param(nostretch
, bool, 0);
106 MODULE_PARM_DESC(nostretch
,
107 "Disable stretching of modes smaller than LCD.");
108 module_param(nopciburst
, bool, 0);
109 MODULE_PARM_DESC(nopciburst
, "Disable PCI burst mode.");
110 module_param(mode_option
, charp
, 0);
111 MODULE_PARM_DESC(mode_option
, "Preferred video mode ('640x480-8@60', etc)");
116 /* --------------------------------------------------------------------- */
118 static biosMode bios8
[] = {
127 static biosMode bios16
[] = {
136 static biosMode bios24
[] = {
142 #ifdef NO_32BIT_SUPPORT_YET
143 /* FIXME: guessed values, wrong */
144 static biosMode bios32
[] = {
151 static inline void write_le32(int regindex
, u32 val
, const struct neofb_par
*par
)
153 writel(val
, par
->neo2200
+ par
->cursorOff
+ regindex
);
156 static int neoFindMode(int xres
, int yres
, int depth
)
164 size
= ARRAY_SIZE(bios8
);
168 size
= ARRAY_SIZE(bios16
);
172 size
= ARRAY_SIZE(bios24
);
175 #ifdef NO_32BIT_SUPPORT_YET
177 size
= ARRAY_SIZE(bios32
);
185 for (i
= 0; i
< size
; i
++) {
186 if (xres
<= mode
[i
].x_res
) {
187 xres_s
= mode
[i
].x_res
;
188 for (; i
< size
; i
++) {
189 if (mode
[i
].x_res
!= xres_s
)
190 return mode
[i
- 1].mode
;
191 if (yres
<= mode
[i
].y_res
)
196 return mode
[size
- 1].mode
;
202 * Determine the closest clock frequency to the one requested.
208 static void neoCalcVCLK(const struct fb_info
*info
,
209 struct neofb_par
*par
, long freq
)
212 int n_best
= 0, d_best
= 0, f_best
= 0;
213 long f_best_diff
= 0x7ffff;
215 for (f
= 0; f
<= MAX_F
; f
++)
216 for (d
= 0; d
<= MAX_D
; d
++)
217 for (n
= 0; n
<= MAX_N
; n
++) {
221 f_out
= ((14318 * (n
+ 1)) / (d
+ 1)) >> f
;
222 f_diff
= abs(f_out
- freq
);
223 if (f_diff
<= f_best_diff
) {
224 f_best_diff
= f_diff
;
233 if (info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2200
||
234 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2230
||
235 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2360
||
236 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2380
) {
237 /* NOT_DONE: We are trying the full range of the 2200 clock.
238 We should be able to try n up to 2047 */
239 par
->VCLK3NumeratorLow
= n_best
;
240 par
->VCLK3NumeratorHigh
= (f_best
<< 7);
242 par
->VCLK3NumeratorLow
= n_best
| (f_best
<< 7);
244 par
->VCLK3Denominator
= d_best
;
247 printk(KERN_DEBUG
"neoVCLK: f:%ld NumLow=%d NumHi=%d Den=%d Df=%ld\n",
249 par
->VCLK3NumeratorLow
,
250 par
->VCLK3NumeratorHigh
,
251 par
->VCLK3Denominator
, f_best_diff
);
257 * Handle the initialization, etc. of a screen.
258 * Return FALSE on failure.
261 static int vgaHWInit(const struct fb_var_screeninfo
*var
,
262 struct neofb_par
*par
)
264 int hsync_end
= var
->xres
+ var
->right_margin
+ var
->hsync_len
;
265 int htotal
= (hsync_end
+ var
->left_margin
) >> 3;
266 int vsync_start
= var
->yres
+ var
->lower_margin
;
267 int vsync_end
= vsync_start
+ var
->vsync_len
;
268 int vtotal
= vsync_end
+ var
->upper_margin
;
270 par
->MiscOutReg
= 0x23;
272 if (!(var
->sync
& FB_SYNC_HOR_HIGH_ACT
))
273 par
->MiscOutReg
|= 0x40;
275 if (!(var
->sync
& FB_SYNC_VERT_HIGH_ACT
))
276 par
->MiscOutReg
|= 0x80;
281 par
->Sequencer
[0] = 0x00;
282 par
->Sequencer
[1] = 0x01;
283 par
->Sequencer
[2] = 0x0F;
284 par
->Sequencer
[3] = 0x00; /* Font select */
285 par
->Sequencer
[4] = 0x0E; /* Misc */
290 par
->CRTC
[0] = htotal
- 5;
291 par
->CRTC
[1] = (var
->xres
>> 3) - 1;
292 par
->CRTC
[2] = (var
->xres
>> 3) - 1;
293 par
->CRTC
[3] = ((htotal
- 1) & 0x1F) | 0x80;
294 par
->CRTC
[4] = ((var
->xres
+ var
->right_margin
) >> 3);
295 par
->CRTC
[5] = (((htotal
- 1) & 0x20) << 2)
296 | (((hsync_end
>> 3)) & 0x1F);
297 par
->CRTC
[6] = (vtotal
- 2) & 0xFF;
298 par
->CRTC
[7] = (((vtotal
- 2) & 0x100) >> 8)
299 | (((var
->yres
- 1) & 0x100) >> 7)
300 | ((vsync_start
& 0x100) >> 6)
301 | (((var
->yres
- 1) & 0x100) >> 5)
302 | 0x10 | (((vtotal
- 2) & 0x200) >> 4)
303 | (((var
->yres
- 1) & 0x200) >> 3)
304 | ((vsync_start
& 0x200) >> 2);
306 par
->CRTC
[9] = (((var
->yres
- 1) & 0x200) >> 4) | 0x40;
308 if (var
->vmode
& FB_VMODE_DOUBLE
)
309 par
->CRTC
[9] |= 0x80;
311 par
->CRTC
[10] = 0x00;
312 par
->CRTC
[11] = 0x00;
313 par
->CRTC
[12] = 0x00;
314 par
->CRTC
[13] = 0x00;
315 par
->CRTC
[14] = 0x00;
316 par
->CRTC
[15] = 0x00;
317 par
->CRTC
[16] = vsync_start
& 0xFF;
318 par
->CRTC
[17] = (vsync_end
& 0x0F) | 0x20;
319 par
->CRTC
[18] = (var
->yres
- 1) & 0xFF;
320 par
->CRTC
[19] = var
->xres_virtual
>> 4;
321 par
->CRTC
[20] = 0x00;
322 par
->CRTC
[21] = (var
->yres
- 1) & 0xFF;
323 par
->CRTC
[22] = (vtotal
- 1) & 0xFF;
324 par
->CRTC
[23] = 0xC3;
325 par
->CRTC
[24] = 0xFF;
328 * are these unnecessary?
329 * vgaHWHBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
330 * vgaHWVBlankKGA(mode, regp, 0, KGA_FIX_OVERSCAN | KGA_ENABLE_ON_ZERO);
334 * Graphics Display Controller
336 par
->Graphics
[0] = 0x00;
337 par
->Graphics
[1] = 0x00;
338 par
->Graphics
[2] = 0x00;
339 par
->Graphics
[3] = 0x00;
340 par
->Graphics
[4] = 0x00;
341 par
->Graphics
[5] = 0x40;
342 par
->Graphics
[6] = 0x05; /* only map 64k VGA memory !!!! */
343 par
->Graphics
[7] = 0x0F;
344 par
->Graphics
[8] = 0xFF;
347 par
->Attribute
[0] = 0x00; /* standard colormap translation */
348 par
->Attribute
[1] = 0x01;
349 par
->Attribute
[2] = 0x02;
350 par
->Attribute
[3] = 0x03;
351 par
->Attribute
[4] = 0x04;
352 par
->Attribute
[5] = 0x05;
353 par
->Attribute
[6] = 0x06;
354 par
->Attribute
[7] = 0x07;
355 par
->Attribute
[8] = 0x08;
356 par
->Attribute
[9] = 0x09;
357 par
->Attribute
[10] = 0x0A;
358 par
->Attribute
[11] = 0x0B;
359 par
->Attribute
[12] = 0x0C;
360 par
->Attribute
[13] = 0x0D;
361 par
->Attribute
[14] = 0x0E;
362 par
->Attribute
[15] = 0x0F;
363 par
->Attribute
[16] = 0x41;
364 par
->Attribute
[17] = 0xFF;
365 par
->Attribute
[18] = 0x0F;
366 par
->Attribute
[19] = 0x00;
367 par
->Attribute
[20] = 0x00;
371 static void vgaHWLock(struct vgastate
*state
)
373 /* Protect CRTC[0-7] */
374 vga_wcrt(state
->vgabase
, 0x11, vga_rcrt(state
->vgabase
, 0x11) | 0x80);
377 static void vgaHWUnlock(void)
379 /* Unprotect CRTC[0-7] */
380 vga_wcrt(NULL
, 0x11, vga_rcrt(NULL
, 0x11) & ~0x80);
383 static void neoLock(struct vgastate
*state
)
385 vga_wgfx(state
->vgabase
, 0x09, 0x00);
389 static void neoUnlock(void)
392 vga_wgfx(NULL
, 0x09, 0x26);
396 * VGA Palette management
398 static int paletteEnabled
= 0;
400 static inline void VGAenablePalette(void)
402 vga_r(NULL
, VGA_IS1_RC
);
403 vga_w(NULL
, VGA_ATT_W
, 0x00);
407 static inline void VGAdisablePalette(void)
409 vga_r(NULL
, VGA_IS1_RC
);
410 vga_w(NULL
, VGA_ATT_W
, 0x20);
414 static inline void VGAwATTR(u8 index
, u8 value
)
421 vga_r(NULL
, VGA_IS1_RC
);
422 vga_wattr(NULL
, index
, value
);
425 static void vgaHWProtect(int on
)
431 * Turn off screen and disable sequencer.
433 tmp
= vga_rseq(NULL
, 0x01);
434 vga_wseq(NULL
, 0x00, 0x01); /* Synchronous Reset */
435 vga_wseq(NULL
, 0x01, tmp
| 0x20); /* disable the display */
440 * Reenable sequencer, then turn on screen.
442 tmp
= vga_rseq(NULL
, 0x01);
443 vga_wseq(NULL
, 0x01, tmp
& ~0x20); /* reenable display */
444 vga_wseq(NULL
, 0x00, 0x03); /* clear synchronousreset */
450 static void vgaHWRestore(const struct fb_info
*info
,
451 const struct neofb_par
*par
)
455 vga_w(NULL
, VGA_MIS_W
, par
->MiscOutReg
);
457 for (i
= 1; i
< 5; i
++)
458 vga_wseq(NULL
, i
, par
->Sequencer
[i
]);
460 /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or CRTC[17] */
461 vga_wcrt(NULL
, 17, par
->CRTC
[17] & ~0x80);
463 for (i
= 0; i
< 25; i
++)
464 vga_wcrt(NULL
, i
, par
->CRTC
[i
]);
466 for (i
= 0; i
< 9; i
++)
467 vga_wgfx(NULL
, i
, par
->Graphics
[i
]);
471 for (i
= 0; i
< 21; i
++)
472 VGAwATTR(i
, par
->Attribute
[i
]);
478 /* -------------------- Hardware specific routines ------------------------- */
481 * Hardware Acceleration for Neo2200+
483 static inline int neo2200_sync(struct fb_info
*info
)
485 struct neofb_par
*par
= info
->par
;
487 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
;
561 mutex_lock(&par
->open_lock
);
562 if (!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
);
568 mutex_unlock(&par
->open_lock
);
574 neofb_release(struct fb_info
*info
, int user
)
576 struct neofb_par
*par
= info
->par
;
578 mutex_lock(&par
->open_lock
);
579 if (!par
->ref_count
) {
580 mutex_unlock(&par
->open_lock
);
583 if (par
->ref_count
== 1) {
584 restore_vga(&par
->state
);
587 mutex_unlock(&par
->open_lock
);
593 neofb_check_var(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
595 struct neofb_par
*par
= info
->par
;
599 DBG("neofb_check_var");
601 if (PICOS2KHZ(var
->pixclock
) > par
->maxClock
)
604 /* Is the mode larger than the LCD panel? */
605 if (par
->internal_display
&&
606 ((var
->xres
> par
->NeoPanelWidth
) ||
607 (var
->yres
> par
->NeoPanelHeight
))) {
609 "Mode (%dx%d) larger than the LCD panel (%dx%d)\n",
610 var
->xres
, var
->yres
, par
->NeoPanelWidth
,
611 par
->NeoPanelHeight
);
615 /* Is the mode one of the acceptable sizes? */
616 if (!par
->internal_display
)
621 if (var
->yres
== 1024)
625 if (var
->yres
== 768)
629 if (var
->yres
== (par
->libretto
? 480 : 600))
633 if (var
->yres
== 480)
641 "Mode (%dx%d) won't display properly on LCD\n",
642 var
->xres
, var
->yres
);
646 var
->red
.msb_right
= 0;
647 var
->green
.msb_right
= 0;
648 var
->blue
.msb_right
= 0;
649 var
->transp
.msb_right
= 0;
651 switch (var
->bits_per_pixel
) {
652 case 8: /* PSEUDOCOLOUR, 256 */
653 var
->transp
.offset
= 0;
654 var
->transp
.length
= 0;
657 var
->green
.offset
= 0;
658 var
->green
.length
= 8;
659 var
->blue
.offset
= 0;
660 var
->blue
.length
= 8;
663 case 16: /* DIRECTCOLOUR, 64k */
664 var
->transp
.offset
= 0;
665 var
->transp
.length
= 0;
666 var
->red
.offset
= 11;
668 var
->green
.offset
= 5;
669 var
->green
.length
= 6;
670 var
->blue
.offset
= 0;
671 var
->blue
.length
= 5;
674 case 24: /* TRUECOLOUR, 16m */
675 var
->transp
.offset
= 0;
676 var
->transp
.length
= 0;
677 var
->red
.offset
= 16;
679 var
->green
.offset
= 8;
680 var
->green
.length
= 8;
681 var
->blue
.offset
= 0;
682 var
->blue
.length
= 8;
685 #ifdef NO_32BIT_SUPPORT_YET
686 case 32: /* TRUECOLOUR, 16m */
687 var
->transp
.offset
= 24;
688 var
->transp
.length
= 8;
689 var
->red
.offset
= 16;
691 var
->green
.offset
= 8;
692 var
->green
.length
= 8;
693 var
->blue
.offset
= 0;
694 var
->blue
.length
= 8;
698 printk(KERN_WARNING
"neofb: no support for %dbpp\n",
699 var
->bits_per_pixel
);
703 vramlen
= info
->fix
.smem_len
;
704 if (vramlen
> 4 * 1024 * 1024)
705 vramlen
= 4 * 1024 * 1024;
707 if (var
->yres_virtual
< var
->yres
)
708 var
->yres_virtual
= var
->yres
;
709 if (var
->xres_virtual
< var
->xres
)
710 var
->xres_virtual
= var
->xres
;
712 memlen
= var
->xres_virtual
* var
->bits_per_pixel
* var
->yres_virtual
>> 3;
714 if (memlen
> vramlen
) {
715 var
->yres_virtual
= vramlen
* 8 / (var
->xres_virtual
*
716 var
->bits_per_pixel
);
717 memlen
= var
->xres_virtual
* var
->bits_per_pixel
*
718 var
->yres_virtual
/ 8;
721 /* we must round yres/xres down, we already rounded y/xres_virtual up
722 if it was possible. We should return -EINVAL, but I disagree */
723 if (var
->yres_virtual
< var
->yres
)
724 var
->yres
= var
->yres_virtual
;
725 if (var
->xres_virtual
< var
->xres
)
726 var
->xres
= var
->xres_virtual
;
727 if (var
->xoffset
+ var
->xres
> var
->xres_virtual
)
728 var
->xoffset
= var
->xres_virtual
- var
->xres
;
729 if (var
->yoffset
+ var
->yres
> var
->yres_virtual
)
730 var
->yoffset
= var
->yres_virtual
- var
->yres
;
736 if (var
->bits_per_pixel
>= 24 || !par
->neo2200
)
737 var
->accel_flags
&= ~FB_ACCELF_TEXT
;
741 static int neofb_set_par(struct fb_info
*info
)
743 struct neofb_par
*par
= info
->par
;
747 int hoffset
, voffset
;
748 int vsync_start
, vtotal
;
750 DBG("neofb_set_par");
754 vgaHWProtect(1); /* Blank the screen */
756 vsync_start
= info
->var
.yres
+ info
->var
.lower_margin
;
757 vtotal
= vsync_start
+ info
->var
.vsync_len
+ info
->var
.upper_margin
;
760 * This will allocate the datastructure and initialize all of the
761 * generic VGA registers.
764 if (vgaHWInit(&info
->var
, par
))
768 * The default value assigned by vgaHW.c is 0x41, but this does
769 * not work for NeoMagic.
771 par
->Attribute
[16] = 0x01;
773 switch (info
->var
.bits_per_pixel
) {
775 par
->CRTC
[0x13] = info
->var
.xres_virtual
>> 3;
776 par
->ExtCRTOffset
= info
->var
.xres_virtual
>> 11;
777 par
->ExtColorModeSelect
= 0x11;
780 par
->CRTC
[0x13] = info
->var
.xres_virtual
>> 2;
781 par
->ExtCRTOffset
= info
->var
.xres_virtual
>> 10;
782 par
->ExtColorModeSelect
= 0x13;
785 par
->CRTC
[0x13] = (info
->var
.xres_virtual
* 3) >> 3;
786 par
->ExtCRTOffset
= (info
->var
.xres_virtual
* 3) >> 11;
787 par
->ExtColorModeSelect
= 0x14;
789 #ifdef NO_32BIT_SUPPORT_YET
790 case 32: /* FIXME: guessed values */
791 par
->CRTC
[0x13] = info
->var
.xres_virtual
>> 1;
792 par
->ExtCRTOffset
= info
->var
.xres_virtual
>> 9;
793 par
->ExtColorModeSelect
= 0x15;
800 par
->ExtCRTDispAddr
= 0x10;
802 /* Vertical Extension */
803 par
->VerticalExt
= (((vtotal
- 2) & 0x400) >> 10)
804 | (((info
->var
.yres
- 1) & 0x400) >> 9)
805 | (((vsync_start
) & 0x400) >> 8)
806 | (((vsync_start
) & 0x400) >> 7);
808 /* Fast write bursts on unless disabled. */
810 par
->SysIfaceCntl1
= 0x30;
812 par
->SysIfaceCntl1
= 0x00;
814 par
->SysIfaceCntl2
= 0xc0; /* VESA Bios sets this to 0x80! */
816 /* Initialize: by default, we want display config register to be read */
817 par
->PanelDispCntlRegRead
= 1;
819 /* Enable any user specified display devices. */
820 par
->PanelDispCntlReg1
= 0x00;
821 if (par
->internal_display
)
822 par
->PanelDispCntlReg1
|= 0x02;
823 if (par
->external_display
)
824 par
->PanelDispCntlReg1
|= 0x01;
826 /* If the user did not specify any display devices, then... */
827 if (par
->PanelDispCntlReg1
== 0x00) {
828 /* Default to internal (i.e., LCD) only. */
829 par
->PanelDispCntlReg1
= vga_rgfx(NULL
, 0x20) & 0x03;
832 /* If we are using a fixed mode, then tell the chip we are. */
833 switch (info
->var
.xres
) {
835 par
->PanelDispCntlReg1
|= 0x60;
838 par
->PanelDispCntlReg1
|= 0x40;
841 par
->PanelDispCntlReg1
|= 0x20;
848 /* Setup shadow register locking. */
849 switch (par
->PanelDispCntlReg1
& 0x03) {
850 case 0x01: /* External CRT only mode: */
851 par
->GeneralLockReg
= 0x00;
852 /* We need to program the VCLK for external display only mode. */
853 par
->ProgramVCLK
= 1;
855 case 0x02: /* Internal LCD only mode: */
856 case 0x03: /* Simultaneous internal/external (LCD/CRT) mode: */
857 par
->GeneralLockReg
= 0x01;
858 /* Don't program the VCLK when using the LCD. */
859 par
->ProgramVCLK
= 0;
864 * If the screen is to be stretched, turn on stretching for the
867 * OPTION_LCD_STRETCH means stretching should be turned off!
869 par
->PanelDispCntlReg2
= 0x00;
870 par
->PanelDispCntlReg3
= 0x00;
872 if (par
->lcd_stretch
&& (par
->PanelDispCntlReg1
== 0x02) && /* LCD only */
873 (info
->var
.xres
!= par
->NeoPanelWidth
)) {
874 switch (info
->var
.xres
) {
875 case 320: /* Needs testing. KEM -- 24 May 98 */
876 case 400: /* Needs testing. KEM -- 24 May 98 */
881 par
->PanelDispCntlReg2
|= 0xC6;
885 /* No stretching in these modes. */
891 * If the screen is to be centerd, turn on the centering for the
894 par
->PanelVertCenterReg1
= 0x00;
895 par
->PanelVertCenterReg2
= 0x00;
896 par
->PanelVertCenterReg3
= 0x00;
897 par
->PanelVertCenterReg4
= 0x00;
898 par
->PanelVertCenterReg5
= 0x00;
899 par
->PanelHorizCenterReg1
= 0x00;
900 par
->PanelHorizCenterReg2
= 0x00;
901 par
->PanelHorizCenterReg3
= 0x00;
902 par
->PanelHorizCenterReg4
= 0x00;
903 par
->PanelHorizCenterReg5
= 0x00;
906 if (par
->PanelDispCntlReg1
& 0x02) {
907 if (info
->var
.xres
== par
->NeoPanelWidth
) {
909 * No centering required when the requested display width
910 * equals the panel width.
913 par
->PanelDispCntlReg2
|= 0x01;
914 par
->PanelDispCntlReg3
|= 0x10;
916 /* Calculate the horizontal and vertical offsets. */
919 ((par
->NeoPanelWidth
-
920 info
->var
.xres
) >> 4) - 1;
922 ((par
->NeoPanelHeight
-
923 info
->var
.yres
) >> 1) - 2;
925 /* Stretched modes cannot be centered. */
930 switch (info
->var
.xres
) {
931 case 320: /* Needs testing. KEM -- 24 May 98 */
932 par
->PanelHorizCenterReg3
= hoffset
;
933 par
->PanelVertCenterReg2
= voffset
;
935 case 400: /* Needs testing. KEM -- 24 May 98 */
936 par
->PanelHorizCenterReg4
= hoffset
;
937 par
->PanelVertCenterReg1
= voffset
;
940 par
->PanelHorizCenterReg1
= hoffset
;
941 par
->PanelVertCenterReg3
= voffset
;
944 par
->PanelHorizCenterReg2
= hoffset
;
945 par
->PanelVertCenterReg4
= voffset
;
948 par
->PanelHorizCenterReg5
= hoffset
;
949 par
->PanelVertCenterReg5
= voffset
;
953 /* No centering in these modes. */
960 neoFindMode(info
->var
.xres
, info
->var
.yres
,
961 info
->var
.bits_per_pixel
);
964 * Calculate the VCLK that most closely matches the requested dot
967 neoCalcVCLK(info
, par
, PICOS2KHZ(info
->var
.pixclock
));
969 /* Since we program the clocks ourselves, always use VCLK3. */
970 par
->MiscOutReg
|= 0x0C;
972 /* alread unlocked above */
973 /* BOGUS vga_wgfx(NULL, 0x09, 0x26); */
975 /* don't know what this is, but it's 0 from bootup anyway */
976 vga_wgfx(NULL
, 0x15, 0x00);
978 /* was set to 0x01 by my bios in text and vesa modes */
979 vga_wgfx(NULL
, 0x0A, par
->GeneralLockReg
);
982 * The color mode needs to be set before calling vgaHWRestore
983 * to ensure the DAC is initialized properly.
985 * NOTE: Make sure we don't change bits make sure we don't change
988 temp
= vga_rgfx(NULL
, 0x90);
989 switch (info
->fix
.accel
) {
990 case FB_ACCEL_NEOMAGIC_NM2070
:
991 temp
&= 0xF0; /* Save bits 7:4 */
992 temp
|= (par
->ExtColorModeSelect
& ~0xF0);
994 case FB_ACCEL_NEOMAGIC_NM2090
:
995 case FB_ACCEL_NEOMAGIC_NM2093
:
996 case FB_ACCEL_NEOMAGIC_NM2097
:
997 case FB_ACCEL_NEOMAGIC_NM2160
:
998 case FB_ACCEL_NEOMAGIC_NM2200
:
999 case FB_ACCEL_NEOMAGIC_NM2230
:
1000 case FB_ACCEL_NEOMAGIC_NM2360
:
1001 case FB_ACCEL_NEOMAGIC_NM2380
:
1002 temp
&= 0x70; /* Save bits 6:4 */
1003 temp
|= (par
->ExtColorModeSelect
& ~0x70);
1007 vga_wgfx(NULL
, 0x90, temp
);
1010 * In some rare cases a lockup might occur if we don't delay
1011 * here. (Reported by Miles Lane)
1016 * Disable horizontal and vertical graphics and text expansions so
1017 * that vgaHWRestore works properly.
1019 temp
= vga_rgfx(NULL
, 0x25);
1021 vga_wgfx(NULL
, 0x25, temp
);
1024 * Sleep for 200ms to make sure that the two operations above have
1025 * had time to take effect.
1030 * This function handles restoring the generic VGA registers. */
1031 vgaHWRestore(info
, par
);
1033 /* linear colormap for non palettized modes */
1034 switch (info
->var
.bits_per_pixel
) {
1036 /* PseudoColor, 256 */
1037 info
->fix
.visual
= FB_VISUAL_PSEUDOCOLOR
;
1040 /* TrueColor, 64k */
1041 info
->fix
.visual
= FB_VISUAL_TRUECOLOR
;
1043 for (i
= 0; i
< 64; i
++) {
1046 outb(i
<< 1, 0x3c9);
1048 outb(i
<< 1, 0x3c9);
1052 #ifdef NO_32BIT_SUPPORT_YET
1055 /* TrueColor, 16m */
1056 info
->fix
.visual
= FB_VISUAL_TRUECOLOR
;
1058 for (i
= 0; i
< 256; i
++) {
1068 vga_wgfx(NULL
, 0x0E, par
->ExtCRTDispAddr
);
1069 vga_wgfx(NULL
, 0x0F, par
->ExtCRTOffset
);
1070 temp
= vga_rgfx(NULL
, 0x10);
1071 temp
&= 0x0F; /* Save bits 3:0 */
1072 temp
|= (par
->SysIfaceCntl1
& ~0x0F); /* VESA Bios sets bit 1! */
1073 vga_wgfx(NULL
, 0x10, temp
);
1075 vga_wgfx(NULL
, 0x11, par
->SysIfaceCntl2
);
1076 vga_wgfx(NULL
, 0x15, 0 /*par->SingleAddrPage */ );
1077 vga_wgfx(NULL
, 0x16, 0 /*par->DualAddrPage */ );
1079 temp
= vga_rgfx(NULL
, 0x20);
1080 switch (info
->fix
.accel
) {
1081 case FB_ACCEL_NEOMAGIC_NM2070
:
1082 temp
&= 0xFC; /* Save bits 7:2 */
1083 temp
|= (par
->PanelDispCntlReg1
& ~0xFC);
1085 case FB_ACCEL_NEOMAGIC_NM2090
:
1086 case FB_ACCEL_NEOMAGIC_NM2093
:
1087 case FB_ACCEL_NEOMAGIC_NM2097
:
1088 case FB_ACCEL_NEOMAGIC_NM2160
:
1089 temp
&= 0xDC; /* Save bits 7:6,4:2 */
1090 temp
|= (par
->PanelDispCntlReg1
& ~0xDC);
1092 case FB_ACCEL_NEOMAGIC_NM2200
:
1093 case FB_ACCEL_NEOMAGIC_NM2230
:
1094 case FB_ACCEL_NEOMAGIC_NM2360
:
1095 case FB_ACCEL_NEOMAGIC_NM2380
:
1096 temp
&= 0x98; /* Save bits 7,4:3 */
1097 temp
|= (par
->PanelDispCntlReg1
& ~0x98);
1100 vga_wgfx(NULL
, 0x20, temp
);
1102 temp
= vga_rgfx(NULL
, 0x25);
1103 temp
&= 0x38; /* Save bits 5:3 */
1104 temp
|= (par
->PanelDispCntlReg2
& ~0x38);
1105 vga_wgfx(NULL
, 0x25, temp
);
1107 if (info
->fix
.accel
!= FB_ACCEL_NEOMAGIC_NM2070
) {
1108 temp
= vga_rgfx(NULL
, 0x30);
1109 temp
&= 0xEF; /* Save bits 7:5 and bits 3:0 */
1110 temp
|= (par
->PanelDispCntlReg3
& ~0xEF);
1111 vga_wgfx(NULL
, 0x30, temp
);
1114 vga_wgfx(NULL
, 0x28, par
->PanelVertCenterReg1
);
1115 vga_wgfx(NULL
, 0x29, par
->PanelVertCenterReg2
);
1116 vga_wgfx(NULL
, 0x2a, par
->PanelVertCenterReg3
);
1118 if (info
->fix
.accel
!= FB_ACCEL_NEOMAGIC_NM2070
) {
1119 vga_wgfx(NULL
, 0x32, par
->PanelVertCenterReg4
);
1120 vga_wgfx(NULL
, 0x33, par
->PanelHorizCenterReg1
);
1121 vga_wgfx(NULL
, 0x34, par
->PanelHorizCenterReg2
);
1122 vga_wgfx(NULL
, 0x35, par
->PanelHorizCenterReg3
);
1125 if (info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2160
)
1126 vga_wgfx(NULL
, 0x36, par
->PanelHorizCenterReg4
);
1128 if (info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2200
||
1129 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2230
||
1130 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2360
||
1131 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2380
) {
1132 vga_wgfx(NULL
, 0x36, par
->PanelHorizCenterReg4
);
1133 vga_wgfx(NULL
, 0x37, par
->PanelVertCenterReg5
);
1134 vga_wgfx(NULL
, 0x38, par
->PanelHorizCenterReg5
);
1139 /* Program VCLK3 if needed. */
1140 if (par
->ProgramVCLK
&& ((vga_rgfx(NULL
, 0x9B) != par
->VCLK3NumeratorLow
)
1141 || (vga_rgfx(NULL
, 0x9F) != par
->VCLK3Denominator
)
1142 || (clock_hi
&& ((vga_rgfx(NULL
, 0x8F) & ~0x0f)
1143 != (par
->VCLK3NumeratorHigh
&
1145 vga_wgfx(NULL
, 0x9B, par
->VCLK3NumeratorLow
);
1147 temp
= vga_rgfx(NULL
, 0x8F);
1148 temp
&= 0x0F; /* Save bits 3:0 */
1149 temp
|= (par
->VCLK3NumeratorHigh
& ~0x0F);
1150 vga_wgfx(NULL
, 0x8F, temp
);
1152 vga_wgfx(NULL
, 0x9F, par
->VCLK3Denominator
);
1156 vga_wcrt(NULL
, 0x23, par
->biosMode
);
1158 vga_wgfx(NULL
, 0x93, 0xc0); /* Gives 5x faster framebuffer writes !!! */
1160 /* Program vertical extension register */
1161 if (info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2200
||
1162 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2230
||
1163 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2360
||
1164 info
->fix
.accel
== FB_ACCEL_NEOMAGIC_NM2380
) {
1165 vga_wcrt(NULL
, 0x70, par
->VerticalExt
);
1168 vgaHWProtect(0); /* Turn on screen */
1170 /* Calling this also locks offset registers required in update_start */
1171 neoLock(&par
->state
);
1173 info
->fix
.line_length
=
1174 info
->var
.xres_virtual
* (info
->var
.bits_per_pixel
>> 3);
1176 switch (info
->fix
.accel
) {
1177 case FB_ACCEL_NEOMAGIC_NM2200
:
1178 case FB_ACCEL_NEOMAGIC_NM2230
:
1179 case FB_ACCEL_NEOMAGIC_NM2360
:
1180 case FB_ACCEL_NEOMAGIC_NM2380
:
1181 neo2200_accel_init(info
, &info
->var
);
1189 static void neofb_update_start(struct fb_info
*info
,
1190 struct fb_var_screeninfo
*var
)
1192 struct neofb_par
*par
= info
->par
;
1193 struct vgastate
*state
= &par
->state
;
1194 int oldExtCRTDispAddr
;
1197 DBG("neofb_update_start");
1199 Base
= (var
->yoffset
* var
->xres_virtual
+ var
->xoffset
) >> 2;
1200 Base
*= (var
->bits_per_pixel
+ 7) / 8;
1205 * These are the generic starting address registers.
1207 vga_wcrt(state
->vgabase
, 0x0C, (Base
& 0x00FF00) >> 8);
1208 vga_wcrt(state
->vgabase
, 0x0D, (Base
& 0x00FF));
1211 * Make sure we don't clobber some other bits that might already
1212 * have been set. NOTE: NM2200 has a writable bit 3, but it shouldn't
1215 oldExtCRTDispAddr
= vga_rgfx(NULL
, 0x0E);
1216 vga_wgfx(state
->vgabase
, 0x0E, (((Base
>> 16) & 0x0f) | (oldExtCRTDispAddr
& 0xf0)));
1222 * Pan or Wrap the Display
1224 static int neofb_pan_display(struct fb_var_screeninfo
*var
,
1225 struct fb_info
*info
)
1229 y_bottom
= var
->yoffset
;
1231 if (!(var
->vmode
& FB_VMODE_YWRAP
))
1232 y_bottom
+= var
->yres
;
1234 if (var
->xoffset
> (var
->xres_virtual
- var
->xres
))
1236 if (y_bottom
> info
->var
.yres_virtual
)
1239 neofb_update_start(info
, var
);
1241 info
->var
.xoffset
= var
->xoffset
;
1242 info
->var
.yoffset
= var
->yoffset
;
1244 if (var
->vmode
& FB_VMODE_YWRAP
)
1245 info
->var
.vmode
|= FB_VMODE_YWRAP
;
1247 info
->var
.vmode
&= ~FB_VMODE_YWRAP
;
1251 static int neofb_setcolreg(u_int regno
, u_int red
, u_int green
, u_int blue
,
1252 u_int transp
, struct fb_info
*fb
)
1254 if (regno
>= fb
->cmap
.len
|| regno
> 255)
1257 if (fb
->var
.bits_per_pixel
<= 8) {
1260 outb(red
>> 10, 0x3c9);
1261 outb(green
>> 10, 0x3c9);
1262 outb(blue
>> 10, 0x3c9);
1263 } else if (regno
< 16) {
1264 switch (fb
->var
.bits_per_pixel
) {
1266 ((u32
*) fb
->pseudo_palette
)[regno
] =
1267 ((red
& 0xf800)) | ((green
& 0xfc00) >> 5) |
1268 ((blue
& 0xf800) >> 11);
1271 ((u32
*) fb
->pseudo_palette
)[regno
] =
1272 ((red
& 0xff00) << 8) | ((green
& 0xff00)) |
1273 ((blue
& 0xff00) >> 8);
1275 #ifdef NO_32BIT_SUPPORT_YET
1277 ((u32
*) fb
->pseudo_palette
)[regno
] =
1278 ((transp
& 0xff00) << 16) | ((red
& 0xff00) << 8) |
1279 ((green
& 0xff00)) | ((blue
& 0xff00) >> 8);
1291 * (Un)Blank the display.
1293 static int neofb_blank(int blank_mode
, struct fb_info
*info
)
1296 * Blank the screen if blank_mode != 0, else unblank.
1297 * Return 0 if blanking succeeded, != 0 if un-/blanking failed due to
1298 * e.g. a video mode which doesn't support it. Implements VESA suspend
1299 * and powerdown modes for monitors, and backlight control on LCDs.
1300 * blank_mode == 0: unblanked (backlight on)
1301 * blank_mode == 1: blank (backlight on)
1302 * blank_mode == 2: suspend vsync (backlight off)
1303 * blank_mode == 3: suspend hsync (backlight off)
1304 * blank_mode == 4: powerdown (backlight off)
1306 * wms...Enable VESA DPMS compatible powerdown mode
1307 * run "setterm -powersave powerdown" to take advantage
1309 struct neofb_par
*par
= info
->par
;
1310 int seqflags
, lcdflags
, dpmsflags
, reg
, tmpdisp
;
1313 * Read back the register bits related to display configuration. They might
1314 * have been changed underneath the driver via Fn key stroke.
1317 tmpdisp
= vga_rgfx(NULL
, 0x20) & 0x03;
1318 neoLock(&par
->state
);
1320 /* In case we blank the screen, we want to store the possibly new
1321 * configuration in the driver. During un-blank, we re-apply this setting,
1322 * since the LCD bit will be cleared in order to switch off the backlight.
1324 if (par
->PanelDispCntlRegRead
) {
1325 par
->PanelDispCntlReg1
= tmpdisp
;
1327 par
->PanelDispCntlRegRead
= !blank_mode
;
1329 switch (blank_mode
) {
1330 case FB_BLANK_POWERDOWN
: /* powerdown - both sync lines down */
1331 seqflags
= VGA_SR01_SCREEN_OFF
; /* Disable sequencer */
1332 lcdflags
= 0; /* LCD off */
1333 dpmsflags
= NEO_GR01_SUPPRESS_HSYNC
|
1334 NEO_GR01_SUPPRESS_VSYNC
;
1335 #ifdef CONFIG_TOSHIBA
1336 /* Do we still need this ? */
1337 /* attempt to turn off backlight on toshiba; also turns off external */
1341 regs
.eax
= 0xff00; /* HCI_SET */
1342 regs
.ebx
= 0x0002; /* HCI_BACKLIGHT */
1343 regs
.ecx
= 0x0000; /* HCI_DISABLE */
1348 case FB_BLANK_HSYNC_SUSPEND
: /* hsync off */
1349 seqflags
= VGA_SR01_SCREEN_OFF
; /* Disable sequencer */
1350 lcdflags
= 0; /* LCD off */
1351 dpmsflags
= NEO_GR01_SUPPRESS_HSYNC
;
1353 case FB_BLANK_VSYNC_SUSPEND
: /* vsync off */
1354 seqflags
= VGA_SR01_SCREEN_OFF
; /* Disable sequencer */
1355 lcdflags
= 0; /* LCD off */
1356 dpmsflags
= NEO_GR01_SUPPRESS_VSYNC
;
1358 case FB_BLANK_NORMAL
: /* just blank screen (backlight stays on) */
1359 seqflags
= VGA_SR01_SCREEN_OFF
; /* Disable sequencer */
1361 * During a blank operation with the LID shut, we might store "LCD off"
1362 * by mistake. Due to timing issues, the BIOS may switch the lights
1363 * back on, and we turn it back off once we "unblank".
1365 * So here is an attempt to implement ">=" - if we are in the process
1366 * of unblanking, and the LCD bit is unset in the driver but set in the
1367 * register, we must keep it.
1369 lcdflags
= ((par
->PanelDispCntlReg1
| tmpdisp
) & 0x02); /* LCD normal */
1370 dpmsflags
= 0x00; /* no hsync/vsync suppression */
1372 case FB_BLANK_UNBLANK
: /* unblank */
1373 seqflags
= 0; /* Enable sequencer */
1374 lcdflags
= ((par
->PanelDispCntlReg1
| tmpdisp
) & 0x02); /* LCD normal */
1375 dpmsflags
= 0x00; /* no hsync/vsync suppression */
1376 #ifdef CONFIG_TOSHIBA
1377 /* Do we still need this ? */
1378 /* attempt to re-enable backlight/external on toshiba */
1382 regs
.eax
= 0xff00; /* HCI_SET */
1383 regs
.ebx
= 0x0002; /* HCI_BACKLIGHT */
1384 regs
.ecx
= 0x0001; /* HCI_ENABLE */
1389 default: /* Anything else we don't understand; return 1 to tell
1390 * fb_blank we didn't aactually do anything */
1395 reg
= (vga_rseq(NULL
, 0x01) & ~0x20) | seqflags
;
1396 vga_wseq(NULL
, 0x01, reg
);
1397 reg
= (vga_rgfx(NULL
, 0x20) & ~0x02) | lcdflags
;
1398 vga_wgfx(NULL
, 0x20, reg
);
1399 reg
= (vga_rgfx(NULL
, 0x01) & ~0xF0) | 0x80 | dpmsflags
;
1400 vga_wgfx(NULL
, 0x01, reg
);
1401 neoLock(&par
->state
);
1406 neo2200_fillrect(struct fb_info
*info
, const struct fb_fillrect
*rect
)
1408 struct neofb_par
*par
= info
->par
;
1411 dst
= rect
->dx
+ rect
->dy
* info
->var
.xres_virtual
;
1412 rop
= rect
->rop
? 0x060000 : 0x0c0000;
1414 neo2200_wait_fifo(info
, 4);
1416 /* set blt control */
1417 writel(NEO_BC3_FIFO_EN
|
1418 NEO_BC0_SRC_IS_FG
| NEO_BC3_SKIP_MAPPING
|
1419 // NEO_BC3_DST_XY_ADDR |
1420 // NEO_BC3_SRC_XY_ADDR |
1421 rop
, &par
->neo2200
->bltCntl
);
1423 switch (info
->var
.bits_per_pixel
) {
1425 writel(rect
->color
, &par
->neo2200
->fgColor
);
1429 writel(((u32
*) (info
->pseudo_palette
))[rect
->color
],
1430 &par
->neo2200
->fgColor
);
1434 writel(dst
* ((info
->var
.bits_per_pixel
+ 7) >> 3),
1435 &par
->neo2200
->dstStart
);
1436 writel((rect
->height
<< 16) | (rect
->width
& 0xffff),
1437 &par
->neo2200
->xyExt
);
1441 neo2200_copyarea(struct fb_info
*info
, const struct fb_copyarea
*area
)
1443 u32 sx
= area
->sx
, sy
= area
->sy
, dx
= area
->dx
, dy
= area
->dy
;
1444 struct neofb_par
*par
= info
->par
;
1445 u_long src
, dst
, bltCntl
;
1447 bltCntl
= NEO_BC3_FIFO_EN
| NEO_BC3_SKIP_MAPPING
| 0x0C0000;
1449 if ((dy
> sy
) || ((dy
== sy
) && (dx
> sx
))) {
1450 /* Start with the lower right corner */
1451 sy
+= (area
->height
- 1);
1452 dy
+= (area
->height
- 1);
1453 sx
+= (area
->width
- 1);
1454 dx
+= (area
->width
- 1);
1456 bltCntl
|= NEO_BC0_X_DEC
| NEO_BC0_DST_Y_DEC
| NEO_BC0_SRC_Y_DEC
;
1459 src
= sx
* (info
->var
.bits_per_pixel
>> 3) + sy
*info
->fix
.line_length
;
1460 dst
= dx
* (info
->var
.bits_per_pixel
>> 3) + dy
*info
->fix
.line_length
;
1462 neo2200_wait_fifo(info
, 4);
1464 /* set blt control */
1465 writel(bltCntl
, &par
->neo2200
->bltCntl
);
1467 writel(src
, &par
->neo2200
->srcStart
);
1468 writel(dst
, &par
->neo2200
->dstStart
);
1469 writel((area
->height
<< 16) | (area
->width
& 0xffff),
1470 &par
->neo2200
->xyExt
);
1474 neo2200_imageblit(struct fb_info
*info
, const struct fb_image
*image
)
1476 struct neofb_par
*par
= info
->par
;
1477 int s_pitch
= (image
->width
* image
->depth
+ 7) >> 3;
1478 int scan_align
= info
->pixmap
.scan_align
- 1;
1479 int buf_align
= info
->pixmap
.buf_align
- 1;
1480 int bltCntl_flags
, d_pitch
, data_len
;
1482 // The data is padded for the hardware
1483 d_pitch
= (s_pitch
+ scan_align
) & ~scan_align
;
1484 data_len
= ((d_pitch
* image
->height
) + buf_align
) & ~buf_align
;
1488 if (image
->depth
== 1) {
1489 if (info
->var
.bits_per_pixel
== 24 && image
->width
< 16) {
1490 /* FIXME. There is a bug with accelerated color-expanded
1491 * transfers in 24 bit mode if the image being transferred
1492 * is less than 16 bits wide. This is due to insufficient
1493 * padding when writing the image. We need to adjust
1494 * struct fb_pixmap. Not yet done. */
1495 return cfb_imageblit(info
, image
);
1497 bltCntl_flags
= NEO_BC0_SRC_MONO
;
1498 } else if (image
->depth
== info
->var
.bits_per_pixel
) {
1501 /* We don't currently support hardware acceleration if image
1502 * depth is different from display */
1503 return cfb_imageblit(info
, image
);
1506 switch (info
->var
.bits_per_pixel
) {
1508 writel(image
->fg_color
, &par
->neo2200
->fgColor
);
1509 writel(image
->bg_color
, &par
->neo2200
->bgColor
);
1513 writel(((u32
*) (info
->pseudo_palette
))[image
->fg_color
],
1514 &par
->neo2200
->fgColor
);
1515 writel(((u32
*) (info
->pseudo_palette
))[image
->bg_color
],
1516 &par
->neo2200
->bgColor
);
1520 writel(NEO_BC0_SYS_TO_VID
|
1521 NEO_BC3_SKIP_MAPPING
| bltCntl_flags
|
1522 // NEO_BC3_DST_XY_ADDR |
1523 0x0c0000, &par
->neo2200
->bltCntl
);
1525 writel(0, &par
->neo2200
->srcStart
);
1526 // par->neo2200->dstStart = (image->dy << 16) | (image->dx & 0xffff);
1527 writel(((image
->dx
& 0xffff) * (info
->var
.bits_per_pixel
>> 3) +
1528 image
->dy
* info
->fix
.line_length
), &par
->neo2200
->dstStart
);
1529 writel((image
->height
<< 16) | (image
->width
& 0xffff),
1530 &par
->neo2200
->xyExt
);
1532 memcpy_toio(par
->mmio_vbase
+ 0x100000, image
->data
, data_len
);
1536 neofb_fillrect(struct fb_info
*info
, const struct fb_fillrect
*rect
)
1538 switch (info
->fix
.accel
) {
1539 case FB_ACCEL_NEOMAGIC_NM2200
:
1540 case FB_ACCEL_NEOMAGIC_NM2230
:
1541 case FB_ACCEL_NEOMAGIC_NM2360
:
1542 case FB_ACCEL_NEOMAGIC_NM2380
:
1543 neo2200_fillrect(info
, rect
);
1546 cfb_fillrect(info
, rect
);
1552 neofb_copyarea(struct fb_info
*info
, const struct fb_copyarea
*area
)
1554 switch (info
->fix
.accel
) {
1555 case FB_ACCEL_NEOMAGIC_NM2200
:
1556 case FB_ACCEL_NEOMAGIC_NM2230
:
1557 case FB_ACCEL_NEOMAGIC_NM2360
:
1558 case FB_ACCEL_NEOMAGIC_NM2380
:
1559 neo2200_copyarea(info
, area
);
1562 cfb_copyarea(info
, area
);
1568 neofb_imageblit(struct fb_info
*info
, const struct fb_image
*image
)
1570 switch (info
->fix
.accel
) {
1571 case FB_ACCEL_NEOMAGIC_NM2200
:
1572 case FB_ACCEL_NEOMAGIC_NM2230
:
1573 case FB_ACCEL_NEOMAGIC_NM2360
:
1574 case FB_ACCEL_NEOMAGIC_NM2380
:
1575 neo2200_imageblit(info
, image
);
1578 cfb_imageblit(info
, image
);
1584 neofb_sync(struct fb_info
*info
)
1586 switch (info
->fix
.accel
) {
1587 case FB_ACCEL_NEOMAGIC_NM2200
:
1588 case FB_ACCEL_NEOMAGIC_NM2230
:
1589 case FB_ACCEL_NEOMAGIC_NM2360
:
1590 case FB_ACCEL_NEOMAGIC_NM2380
:
1601 neofb_draw_cursor(struct fb_info *info, u8 *dst, u8 *src, unsigned int width)
1603 //memset_io(info->sprite.addr, 0xff, 1);
1607 neofb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1609 struct neofb_par *par = (struct neofb_par *) info->par;
1612 write_le32(NEOREG_CURSCNTL, ~NEO_CURS_ENABLE, par);
1614 if (cursor->set & FB_CUR_SETPOS) {
1615 u32 x = cursor->image.dx;
1616 u32 y = cursor->image.dy;
1618 info->cursor.image.dx = x;
1619 info->cursor.image.dy = y;
1620 write_le32(NEOREG_CURSX, x, par);
1621 write_le32(NEOREG_CURSY, y, par);
1624 if (cursor->set & FB_CUR_SETSIZE) {
1625 info->cursor.image.height = cursor->image.height;
1626 info->cursor.image.width = cursor->image.width;
1629 if (cursor->set & FB_CUR_SETHOT)
1630 info->cursor.hot = cursor->hot;
1632 if (cursor->set & FB_CUR_SETCMAP) {
1633 if (cursor->image.depth == 1) {
1634 u32 fg = cursor->image.fg_color;
1635 u32 bg = cursor->image.bg_color;
1637 info->cursor.image.fg_color = fg;
1638 info->cursor.image.bg_color = bg;
1640 fg = ((fg & 0xff0000) >> 16) | ((fg & 0xff) << 16) | (fg & 0xff00);
1641 bg = ((bg & 0xff0000) >> 16) | ((bg & 0xff) << 16) | (bg & 0xff00);
1642 write_le32(NEOREG_CURSFGCOLOR, fg, par);
1643 write_le32(NEOREG_CURSBGCOLOR, bg, par);
1647 if (cursor->set & FB_CUR_SETSHAPE)
1648 fb_load_cursor_image(info);
1650 if (info->cursor.enable)
1651 write_le32(NEOREG_CURSCNTL, NEO_CURS_ENABLE, par);
1656 static struct fb_ops neofb_ops
= {
1657 .owner
= THIS_MODULE
,
1658 .fb_open
= neofb_open
,
1659 .fb_release
= neofb_release
,
1660 .fb_check_var
= neofb_check_var
,
1661 .fb_set_par
= neofb_set_par
,
1662 .fb_setcolreg
= neofb_setcolreg
,
1663 .fb_pan_display
= neofb_pan_display
,
1664 .fb_blank
= neofb_blank
,
1665 .fb_sync
= neofb_sync
,
1666 .fb_fillrect
= neofb_fillrect
,
1667 .fb_copyarea
= neofb_copyarea
,
1668 .fb_imageblit
= neofb_imageblit
,
1671 /* --------------------------------------------------------------------- */
1673 static struct fb_videomode __devinitdata mode800x480
= {
1683 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
1684 .vmode
= FB_VMODE_NONINTERLACED
1687 static int __devinit
neo_map_mmio(struct fb_info
*info
,
1688 struct pci_dev
*dev
)
1690 struct neofb_par
*par
= info
->par
;
1692 DBG("neo_map_mmio");
1694 switch (info
->fix
.accel
) {
1695 case FB_ACCEL_NEOMAGIC_NM2070
:
1696 info
->fix
.mmio_start
= pci_resource_start(dev
, 0)+
1699 case FB_ACCEL_NEOMAGIC_NM2090
:
1700 case FB_ACCEL_NEOMAGIC_NM2093
:
1701 info
->fix
.mmio_start
= pci_resource_start(dev
, 0)+
1704 case FB_ACCEL_NEOMAGIC_NM2160
:
1705 case FB_ACCEL_NEOMAGIC_NM2097
:
1706 case FB_ACCEL_NEOMAGIC_NM2200
:
1707 case FB_ACCEL_NEOMAGIC_NM2230
:
1708 case FB_ACCEL_NEOMAGIC_NM2360
:
1709 case FB_ACCEL_NEOMAGIC_NM2380
:
1710 info
->fix
.mmio_start
= pci_resource_start(dev
, 1);
1713 info
->fix
.mmio_start
= pci_resource_start(dev
, 0);
1715 info
->fix
.mmio_len
= MMIO_SIZE
;
1717 if (!request_mem_region
1718 (info
->fix
.mmio_start
, MMIO_SIZE
, "memory mapped I/O")) {
1719 printk("neofb: memory mapped IO in use\n");
1723 par
->mmio_vbase
= ioremap(info
->fix
.mmio_start
, MMIO_SIZE
);
1724 if (!par
->mmio_vbase
) {
1725 printk("neofb: unable to map memory mapped IO\n");
1726 release_mem_region(info
->fix
.mmio_start
,
1727 info
->fix
.mmio_len
);
1730 printk(KERN_INFO
"neofb: mapped io at %p\n",
1735 static void neo_unmap_mmio(struct fb_info
*info
)
1737 struct neofb_par
*par
= info
->par
;
1739 DBG("neo_unmap_mmio");
1741 iounmap(par
->mmio_vbase
);
1742 par
->mmio_vbase
= NULL
;
1744 release_mem_region(info
->fix
.mmio_start
,
1745 info
->fix
.mmio_len
);
1748 static int __devinit
neo_map_video(struct fb_info
*info
,
1749 struct pci_dev
*dev
, int video_len
)
1751 //unsigned long addr;
1753 DBG("neo_map_video");
1755 info
->fix
.smem_start
= pci_resource_start(dev
, 0);
1756 info
->fix
.smem_len
= video_len
;
1758 if (!request_mem_region(info
->fix
.smem_start
, info
->fix
.smem_len
,
1760 printk("neofb: frame buffer in use\n");
1765 ioremap(info
->fix
.smem_start
, info
->fix
.smem_len
);
1766 if (!info
->screen_base
) {
1767 printk("neofb: unable to map screen memory\n");
1768 release_mem_region(info
->fix
.smem_start
,
1769 info
->fix
.smem_len
);
1772 printk(KERN_INFO
"neofb: mapped framebuffer at %p\n",
1776 ((struct neofb_par
*)(info
->par
))->mtrr
=
1777 mtrr_add(info
->fix
.smem_start
, pci_resource_len(dev
, 0),
1778 MTRR_TYPE_WRCOMB
, 1);
1781 /* Clear framebuffer, it's all white in memory after boot */
1782 memset_io(info
->screen_base
, 0, info
->fix
.smem_len
);
1784 /* Allocate Cursor drawing pad.
1785 info->fix.smem_len -= PAGE_SIZE;
1786 addr = info->fix.smem_start + info->fix.smem_len;
1787 write_le32(NEOREG_CURSMEMPOS, ((0x000f & (addr >> 10)) << 8) |
1788 ((0x0ff0 & (addr >> 10)) >> 4), par);
1789 addr = (unsigned long) info->screen_base + info->fix.smem_len;
1790 info->sprite.addr = (u8 *) addr; */
1794 static void neo_unmap_video(struct fb_info
*info
)
1796 DBG("neo_unmap_video");
1800 struct neofb_par
*par
= info
->par
;
1802 mtrr_del(par
->mtrr
, info
->fix
.smem_start
,
1803 info
->fix
.smem_len
);
1806 iounmap(info
->screen_base
);
1807 info
->screen_base
= NULL
;
1809 release_mem_region(info
->fix
.smem_start
,
1810 info
->fix
.smem_len
);
1813 static int __devinit
neo_scan_monitor(struct fb_info
*info
)
1815 struct neofb_par
*par
= info
->par
;
1816 unsigned char type
, display
;
1819 // Eventually we will have i2c support.
1820 info
->monspecs
.modedb
= kmalloc(sizeof(struct fb_videomode
), GFP_KERNEL
);
1821 if (!info
->monspecs
.modedb
)
1823 info
->monspecs
.modedb_len
= 1;
1825 /* Determine the panel type */
1826 vga_wgfx(NULL
, 0x09, 0x26);
1827 type
= vga_rgfx(NULL
, 0x21);
1828 display
= vga_rgfx(NULL
, 0x20);
1829 if (!par
->internal_display
&& !par
->external_display
) {
1830 par
->internal_display
= display
& 2 || !(display
& 3) ? 1 : 0;
1831 par
->external_display
= display
& 1;
1832 printk (KERN_INFO
"Autodetected %s display\n",
1833 par
->internal_display
&& par
->external_display
? "simultaneous" :
1834 par
->internal_display
? "internal" : "external");
1837 /* Determine panel width -- used in NeoValidMode. */
1838 w
= vga_rgfx(NULL
, 0x20);
1839 vga_wgfx(NULL
, 0x09, 0x00);
1840 switch ((w
& 0x18) >> 3) {
1843 par
->NeoPanelWidth
= 640;
1844 par
->NeoPanelHeight
= 480;
1845 memcpy(info
->monspecs
.modedb
, &vesa_modes
[3], sizeof(struct fb_videomode
));
1848 par
->NeoPanelWidth
= 800;
1849 if (par
->libretto
) {
1850 par
->NeoPanelHeight
= 480;
1851 memcpy(info
->monspecs
.modedb
, &mode800x480
, sizeof(struct fb_videomode
));
1854 par
->NeoPanelHeight
= 600;
1855 memcpy(info
->monspecs
.modedb
, &vesa_modes
[8], sizeof(struct fb_videomode
));
1860 par
->NeoPanelWidth
= 1024;
1861 par
->NeoPanelHeight
= 768;
1862 memcpy(info
->monspecs
.modedb
, &vesa_modes
[13], sizeof(struct fb_videomode
));
1865 /* 1280x1024@60 panel support needs to be added */
1867 par
->NeoPanelWidth
= 1280;
1868 par
->NeoPanelHeight
= 1024;
1869 memcpy(info
->monspecs
.modedb
, &vesa_modes
[20], sizeof(struct fb_videomode
));
1873 "neofb: Only 640x480, 800x600/480 and 1024x768 panels are currently supported\n");
1878 par
->NeoPanelWidth
= 640;
1879 par
->NeoPanelHeight
= 480;
1880 memcpy(info
->monspecs
.modedb
, &vesa_modes
[3], sizeof(struct fb_videomode
));
1884 printk(KERN_INFO
"Panel is a %dx%d %s %s display\n",
1886 par
->NeoPanelHeight
,
1887 (type
& 0x02) ? "color" : "monochrome",
1888 (type
& 0x10) ? "TFT" : "dual scan");
1892 static int __devinit
neo_init_hw(struct fb_info
*info
)
1894 struct neofb_par
*par
= info
->par
;
1896 int maxClock
= 65000;
1897 int CursorMem
= 1024;
1898 int CursorOff
= 0x100;
1905 printk(KERN_DEBUG
"--- Neo extended register dump ---\n");
1906 for (int w
= 0; w
< 0x85; w
++)
1907 printk(KERN_DEBUG
"CR %p: %p\n", (void *) w
,
1908 (void *) vga_rcrt(NULL
, w
));
1909 for (int w
= 0; w
< 0xC7; w
++)
1910 printk(KERN_DEBUG
"GR %p: %p\n", (void *) w
,
1911 (void *) vga_rgfx(NULL
, w
));
1913 switch (info
->fix
.accel
) {
1914 case FB_ACCEL_NEOMAGIC_NM2070
:
1918 case FB_ACCEL_NEOMAGIC_NM2090
:
1919 case FB_ACCEL_NEOMAGIC_NM2093
:
1920 case FB_ACCEL_NEOMAGIC_NM2097
:
1924 case FB_ACCEL_NEOMAGIC_NM2160
:
1928 case FB_ACCEL_NEOMAGIC_NM2200
:
1932 case FB_ACCEL_NEOMAGIC_NM2230
:
1936 case FB_ACCEL_NEOMAGIC_NM2360
:
1940 case FB_ACCEL_NEOMAGIC_NM2380
:
1945 switch (info
->fix
.accel
) {
1946 case FB_ACCEL_NEOMAGIC_NM2070
:
1947 case FB_ACCEL_NEOMAGIC_NM2090
:
1948 case FB_ACCEL_NEOMAGIC_NM2093
:
1952 case FB_ACCEL_NEOMAGIC_NM2097
:
1953 case FB_ACCEL_NEOMAGIC_NM2160
:
1957 case FB_ACCEL_NEOMAGIC_NM2200
:
1958 case FB_ACCEL_NEOMAGIC_NM2230
:
1959 case FB_ACCEL_NEOMAGIC_NM2360
:
1960 case FB_ACCEL_NEOMAGIC_NM2380
:
1964 par
->neo2200
= (Neo2200 __iomem
*) par
->mmio_vbase
;
1968 info->sprite.size = CursorMem;
1969 info->sprite.scan_align = 1;
1970 info->sprite.buf_align = 1;
1971 info->sprite.flags = FB_PIXMAP_IO;
1972 info->sprite.outbuf = neofb_draw_cursor;
1974 par
->maxClock
= maxClock
;
1975 par
->cursorOff
= CursorOff
;
1976 return videoRam
* 1024;
1980 static struct fb_info
*__devinit
neo_alloc_fb_info(struct pci_dev
*dev
, const struct
1983 struct fb_info
*info
;
1984 struct neofb_par
*par
;
1986 info
= framebuffer_alloc(sizeof(struct neofb_par
), &dev
->dev
);
1993 info
->fix
.accel
= id
->driver_data
;
1995 mutex_init(&par
->open_lock
);
1996 par
->pci_burst
= !nopciburst
;
1997 par
->lcd_stretch
= !nostretch
;
1998 par
->libretto
= libretto
;
2000 par
->internal_display
= internal
;
2001 par
->external_display
= external
;
2002 info
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
2004 switch (info
->fix
.accel
) {
2005 case FB_ACCEL_NEOMAGIC_NM2070
:
2006 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2009 case FB_ACCEL_NEOMAGIC_NM2090
:
2010 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2013 case FB_ACCEL_NEOMAGIC_NM2093
:
2014 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2015 "MagicGraph 128ZV");
2017 case FB_ACCEL_NEOMAGIC_NM2097
:
2018 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2019 "MagicGraph 128ZV+");
2021 case FB_ACCEL_NEOMAGIC_NM2160
:
2022 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2023 "MagicGraph 128XD");
2025 case FB_ACCEL_NEOMAGIC_NM2200
:
2026 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2027 "MagicGraph 256AV");
2028 info
->flags
|= FBINFO_HWACCEL_IMAGEBLIT
|
2029 FBINFO_HWACCEL_COPYAREA
|
2030 FBINFO_HWACCEL_FILLRECT
;
2032 case FB_ACCEL_NEOMAGIC_NM2230
:
2033 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2034 "MagicGraph 256AV+");
2035 info
->flags
|= FBINFO_HWACCEL_IMAGEBLIT
|
2036 FBINFO_HWACCEL_COPYAREA
|
2037 FBINFO_HWACCEL_FILLRECT
;
2039 case FB_ACCEL_NEOMAGIC_NM2360
:
2040 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2041 "MagicGraph 256ZX");
2042 info
->flags
|= FBINFO_HWACCEL_IMAGEBLIT
|
2043 FBINFO_HWACCEL_COPYAREA
|
2044 FBINFO_HWACCEL_FILLRECT
;
2046 case FB_ACCEL_NEOMAGIC_NM2380
:
2047 snprintf(info
->fix
.id
, sizeof(info
->fix
.id
),
2048 "MagicGraph 256XL+");
2049 info
->flags
|= FBINFO_HWACCEL_IMAGEBLIT
|
2050 FBINFO_HWACCEL_COPYAREA
|
2051 FBINFO_HWACCEL_FILLRECT
;
2055 info
->fix
.type
= FB_TYPE_PACKED_PIXELS
;
2056 info
->fix
.type_aux
= 0;
2057 info
->fix
.xpanstep
= 0;
2058 info
->fix
.ypanstep
= 4;
2059 info
->fix
.ywrapstep
= 0;
2060 info
->fix
.accel
= id
->driver_data
;
2062 info
->fbops
= &neofb_ops
;
2063 info
->pseudo_palette
= par
->palette
;
2067 static void neo_free_fb_info(struct fb_info
*info
)
2071 * Free the colourmap
2073 fb_dealloc_cmap(&info
->cmap
);
2074 framebuffer_release(info
);
2078 /* --------------------------------------------------------------------- */
2080 static int __devinit
neofb_probe(struct pci_dev
*dev
,
2081 const struct pci_device_id
*id
)
2083 struct fb_info
*info
;
2084 u_int h_sync
, v_sync
;
2089 err
= pci_enable_device(dev
);
2094 info
= neo_alloc_fb_info(dev
, id
);
2098 err
= neo_map_mmio(info
, dev
);
2102 err
= neo_scan_monitor(info
);
2104 goto err_scan_monitor
;
2106 video_len
= neo_init_hw(info
);
2107 if (video_len
< 0) {
2112 err
= neo_map_video(info
, dev
, video_len
);
2116 if (!fb_find_mode(&info
->var
, info
, mode_option
, NULL
, 0,
2117 info
->monspecs
.modedb
, 16)) {
2118 printk(KERN_ERR
"neofb: Unable to find usable video mode.\n");
2123 * Calculate the hsync and vsync frequencies. Note that
2124 * we split the 1e12 constant up so that we can preserve
2125 * the precision and fit the results into 32-bit registers.
2126 * (1953125000 * 512 = 1e12)
2128 h_sync
= 1953125000 / info
->var
.pixclock
;
2130 h_sync
* 512 / (info
->var
.xres
+ info
->var
.left_margin
+
2131 info
->var
.right_margin
+ info
->var
.hsync_len
);
2133 h_sync
/ (info
->var
.yres
+ info
->var
.upper_margin
+
2134 info
->var
.lower_margin
+ info
->var
.vsync_len
);
2136 printk(KERN_INFO
"neofb v" NEOFB_VERSION
2137 ": %dkB VRAM, using %dx%d, %d.%03dkHz, %dHz\n",
2138 info
->fix
.smem_len
>> 10, info
->var
.xres
,
2139 info
->var
.yres
, h_sync
/ 1000, h_sync
% 1000, v_sync
);
2141 if (fb_alloc_cmap(&info
->cmap
, 256, 0) < 0)
2144 err
= register_framebuffer(info
);
2148 printk(KERN_INFO
"fb%d: %s frame buffer device\n",
2149 info
->node
, info
->fix
.id
);
2154 pci_set_drvdata(dev
, info
);
2158 fb_dealloc_cmap(&info
->cmap
);
2160 neo_unmap_video(info
);
2162 fb_destroy_modedb(info
->monspecs
.modedb
);
2164 neo_unmap_mmio(info
);
2166 neo_free_fb_info(info
);
2170 static void __devexit
neofb_remove(struct pci_dev
*dev
)
2172 struct fb_info
*info
= pci_get_drvdata(dev
);
2174 DBG("neofb_remove");
2178 * If unregister_framebuffer fails, then
2179 * we will be leaving hooks that could cause
2180 * oopsen laying around.
2182 if (unregister_framebuffer(info
))
2184 "neofb: danger danger! Oopsen imminent!\n");
2186 neo_unmap_video(info
);
2187 fb_destroy_modedb(info
->monspecs
.modedb
);
2188 neo_unmap_mmio(info
);
2189 neo_free_fb_info(info
);
2192 * Ensure that the driver data is no longer
2195 pci_set_drvdata(dev
, NULL
);
2199 static struct pci_device_id neofb_devices
[] = {
2200 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2070
,
2201 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2070
},
2203 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2090
,
2204 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2090
},
2206 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2093
,
2207 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2093
},
2209 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2097
,
2210 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2097
},
2212 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2160
,
2213 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2160
},
2215 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2200
,
2216 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2200
},
2218 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2230
,
2219 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2230
},
2221 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2360
,
2222 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2360
},
2224 {PCI_VENDOR_ID_NEOMAGIC
, PCI_CHIP_NM2380
,
2225 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, FB_ACCEL_NEOMAGIC_NM2380
},
2227 {0, 0, 0, 0, 0, 0, 0}
2230 MODULE_DEVICE_TABLE(pci
, neofb_devices
);
2232 static struct pci_driver neofb_driver
= {
2234 .id_table
= neofb_devices
,
2235 .probe
= neofb_probe
,
2236 .remove
= __devexit_p(neofb_remove
)
2239 /* ************************* init in-kernel code ************************** */
2242 static int __init
neofb_setup(char *options
)
2248 if (!options
|| !*options
)
2251 while ((this_opt
= strsep(&options
, ",")) != NULL
) {
2255 if (!strncmp(this_opt
, "internal", 8))
2257 else if (!strncmp(this_opt
, "external", 8))
2259 else if (!strncmp(this_opt
, "nostretch", 9))
2261 else if (!strncmp(this_opt
, "nopciburst", 10))
2263 else if (!strncmp(this_opt
, "libretto", 8))
2266 mode_option
= this_opt
;
2272 static int __init
neofb_init(void)
2275 char *option
= NULL
;
2277 if (fb_get_options("neofb", &option
))
2279 neofb_setup(option
);
2281 return pci_register_driver(&neofb_driver
);
2284 module_init(neofb_init
);
2287 static void __exit
neofb_exit(void)
2289 pci_unregister_driver(&neofb_driver
);
2292 module_exit(neofb_exit
);