14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/errno.h>
17 #include <linux/string.h>
19 #include <linux/tty.h>
24 #include <linux/pci.h>
28 #include <linux/i2c.h>
42 #ifdef CONFIG_FB_S3_DDC
54 { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
56 { 4, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0,
58 { 4, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 1,
60 { 8, {0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
62 {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0,
64 {16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0,
66 {24, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
68 {32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
74 static const struct svga_pll s3_pll = {3, 129, 3, 33, 0, 3,
75 35000, 240000, 14318};
76 static const struct svga_pll s3_trio3d_pll = {3, 129, 3, 31, 0, 4,
77 230000, 460000, 14318};
79 static const int s3_memsizes[] = {4096, 0, 3072, 8192, 2048, 6144, 1024, 512};
81 static const char *
const s3_names[] = {
"S3 Unknown",
"S3 Trio32",
"S3 Trio64",
"S3 Trio64V+",
82 "S3 Trio64UV+",
"S3 Trio64V2/DX",
"S3 Trio64V2/GX",
83 "S3 Plato/PX",
"S3 Aurora64V+",
"S3 Virge",
84 "S3 Virge/VX",
"S3 Virge/DX",
"S3 Virge/GX",
85 "S3 Virge/GX2",
"S3 Virge/GX2+",
"",
86 "S3 Trio3D/1X",
"S3 Trio3D/2X",
"S3 Trio3D/2X",
87 "S3 Trio3D",
"S3 Virge/MX"};
89 #define CHIP_UNKNOWN 0x00
90 #define CHIP_732_TRIO32 0x01
91 #define CHIP_764_TRIO64 0x02
92 #define CHIP_765_TRIO64VP 0x03
93 #define CHIP_767_TRIO64UVP 0x04
94 #define CHIP_775_TRIO64V2_DX 0x05
95 #define CHIP_785_TRIO64V2_GX 0x06
96 #define CHIP_551_PLATO_PX 0x07
97 #define CHIP_M65_AURORA64VP 0x08
98 #define CHIP_325_VIRGE 0x09
99 #define CHIP_988_VIRGE_VX 0x0A
100 #define CHIP_375_VIRGE_DX 0x0B
101 #define CHIP_385_VIRGE_GX 0x0C
102 #define CHIP_357_VIRGE_GX2 0x0D
103 #define CHIP_359_VIRGE_GX2P 0x0E
104 #define CHIP_360_TRIO3D_1X 0x10
105 #define CHIP_362_TRIO3D_2X 0x11
106 #define CHIP_368_TRIO3D_2X 0x12
107 #define CHIP_365_TRIO3D 0x13
108 #define CHIP_260_VIRGE_MX 0x14
110 #define CHIP_XXX_TRIO 0x80
111 #define CHIP_XXX_TRIO64V2_DXGX 0x81
112 #define CHIP_XXX_VIRGE_DXGX 0x82
113 #define CHIP_36X_TRIO3D_1X_2X 0x83
115 #define CHIP_UNDECIDED_FLAG 0x80
116 #define CHIP_MASK 0xFF
118 #define MMIO_OFFSET 0x1000000
119 #define MMIO_SIZE 0x10000
130 static const struct vga_regset s3_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x5E, 0, 0},
VGA_REGSET_END};
131 static const struct vga_regset s3_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x5E, 1, 1},
VGA_REGSET_END};
132 static const struct vga_regset s3_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x5E, 2, 2},
VGA_REGSET_END};
134 static const struct vga_regset s3_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x5E, 4, 4},
VGA_REGSET_END};
137 static const struct vga_regset s3_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, {0x5E, 6, 6},
VGA_REGSET_END};
138 static const struct vga_regset s3_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x69, 0, 4},
VGA_REGSET_END};
144 s3_h_total_regs, s3_h_display_regs, s3_h_blank_start_regs,
145 s3_h_blank_end_regs, s3_h_sync_start_regs, s3_h_sync_end_regs,
146 s3_v_total_regs, s3_v_display_regs, s3_v_blank_start_regs,
147 s3_v_blank_end_regs, s3_v_sync_start_regs, s3_v_sync_end_regs,
162 static int fasttext = 1;
176 MODULE_PARM_DESC(mtrr,
"Enable write-combining with MTRR (1=enable, 0=disable, default=1)");
180 MODULE_PARM_DESC(fasttext,
"Enable S3 fast text mode (1=enable, 0=disable, default=1)");
185 #ifdef CONFIG_FB_S3_DDC
188 #define DDC_MMIO_REG 0xff20
189 #define DDC_SCL_OUT (1 << 0)
190 #define DDC_SDA_OUT (1 << 1)
191 #define DDC_SCL_IN (1 << 2)
192 #define DDC_SDA_IN (1 << 3)
193 #define DDC_DRIVE_EN (1 << 4)
195 static bool s3fb_ddc_needs_mmio(
int chip)
204 if (s3fb_ddc_needs_mmio(par->
chip))
205 return readb(par->mmio + DDC_MMIO_REG);
207 return vga_rcrt(par->
state.vgabase, DDC_REG);
212 if (s3fb_ddc_needs_mmio(par->
chip))
213 writeb(val, par->mmio + DDC_MMIO_REG);
215 vga_wcrt(par->
state.vgabase, DDC_REG, val);
218 static void s3fb_ddc_setscl(
void *
data,
int val)
223 reg = s3fb_ddc_read(par) | DDC_DRIVE_EN;
228 s3fb_ddc_write(par, reg);
231 static void s3fb_ddc_setsda(
void *data,
int val)
236 reg = s3fb_ddc_read(par) | DDC_DRIVE_EN;
241 s3fb_ddc_write(par, reg);
244 static int s3fb_ddc_getscl(
void *data)
251 static int s3fb_ddc_getsda(
void *data)
263 sizeof(par->ddc_adapter.name));
266 par->ddc_adapter.algo_data = &par->ddc_algo;
267 par->ddc_adapter.dev.parent = info->
device;
268 par->ddc_algo.setsda = s3fb_ddc_setsda;
269 par->ddc_algo.setscl = s3fb_ddc_setscl;
270 par->ddc_algo.getsda = s3fb_ddc_getsda;
271 par->ddc_algo.getscl = s3fb_ddc_getscl;
272 par->ddc_algo.udelay = 10;
273 par->ddc_algo.timeout = 20;
274 par->ddc_algo.data = par;
276 i2c_set_adapdata(&par->ddc_adapter, par);
286 svga_wseq_mask(par->
state.vgabase, 0x0d, 0x01, 0x03);
288 svga_wseq_mask(par->
state.vgabase, 0x0d, 0x00, 0x03);
290 svga_wcrt_mask(par->
state.vgabase, 0x5c, 0x03, 0x03);
301 static void s3fb_settile_fast(
struct fb_info *info,
struct fb_tilemap *
map)
303 const u8 *font = map->data;
307 if ((map->width != 8) || (map->height != 16) ||
308 (map->depth != 1) || (map->length != 256)) {
309 printk(
KERN_ERR "fb%d: unsupported font parameters: width %d, height %d, depth %d, length %d\n",
310 info->
node, map->width, map->height, map->depth, map->length);
315 for (i = 0; i < map->height; i++) {
316 for (
c = 0;
c < map->length;
c++) {
323 static void s3fb_tilecursor(
struct fb_info *info,
struct fb_tilecursor *cursor)
330 static struct fb_tile_ops s3fb_tile_ops = {
335 .fb_tilecursor = s3fb_tilecursor,
339 static struct fb_tile_ops s3fb_fast_tile_ops = {
340 .fb_settile = s3fb_settile_fast,
344 .fb_tilecursor = s3fb_tilecursor,
352 static inline u32 expand_color(
u32 c)
354 return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF;
362 const u8 *src1, *
src;
370 + ((image->
dx / 8) * 4);
372 for (y = 0; y < image->
height; y++) {
375 for (x = 0; x < image->
width; x += 8) {
376 val = *(src++) * 0x01010101;
377 val = (val & fg) | (~val & bg);
380 src1 += image->
width / 8;
381 dst1 += info->
fix.line_length;
395 + ((rect->
dx / 8) * 4);
397 for (y = 0; y < rect->
height; y++) {
399 for (x = 0; x < rect->
width; x += 8) {
402 dst1 += info->
fix.line_length;
408 static inline u32 expand_pixel(
u32 c)
410 return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) |
411 ((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF;
415 static void s3fb_cfb4_imageblit(
struct fb_info *info,
const struct fb_image *image)
419 const u8 *src1, *
src;
427 + ((image->
dx / 8) * 4);
429 for (y = 0; y < image->
height; y++) {
432 for (x = 0; x < image->
width; x += 8) {
433 val = expand_pixel(*(src++));
434 val = (val & fg) | (~val & bg);
437 src1 += image->
width / 8;
438 dst1 += info->
fix.line_length;
442 static void s3fb_imageblit(
struct fb_info *info,
const struct fb_image *image)
444 if ((info->
var.bits_per_pixel == 4) && (image->
depth == 1)
445 && ((image->
width % 8) == 0) && ((image->
dx % 8) == 0)) {
447 s3fb_iplan_imageblit(info, image);
449 s3fb_cfb4_imageblit(info, image);
456 if ((info->
var.bits_per_pixel == 4)
457 && ((rect->
width % 8) == 0) && ((rect->
dx % 8) == 0)
459 s3fb_iplan_fillrect(info, rect);
469 static void s3_set_pixclock(
struct fb_info *info,
u32 pixclock)
477 1000000000 / pixclock, &m, &n, &r, info->
node);
479 printk(
KERN_ERR "fb%d: cannot set requested pixclock, keeping old value\n", info->
node);
494 vga_wseq(par->
state.vgabase, 0x12, (n - 2) | ((r & 3) << 6));
495 vga_wseq(par->
state.vgabase, 0x29, r >> 2);
497 vga_wseq(par->
state.vgabase, 0x12, (n - 2) | (r << 5));
498 vga_wseq(par->
state.vgabase, 0x13, m - 2);
503 regval = vga_rseq (par->
state.vgabase, 0x15);
504 vga_wseq(par->
state.vgabase, 0x15, regval & ~(1<<5));
505 vga_wseq(par->
state.vgabase, 0x15, regval | (1<<5));
506 vga_wseq(par->
state.vgabase, 0x15, regval & ~(1<<5));
512 static int s3fb_open(
struct fb_info *info,
int user)
521 par->
state.vgabase = vgabase;
523 par->
state.num_crtc = 0x70;
524 par->
state.num_seq = 0x20;
536 static int s3fb_release(
struct fb_info *info,
int user)
584 step = s3fb_formats[rv].
xresstep - 1;
590 printk(
KERN_ERR "fb%d: not enough framebuffer memory (%d kB requested , %d kB available)\n",
614 static int s3fb_set_par(
struct fb_info *info)
617 u32 value,
mode, hmul, offset_value, screen_size, multiplex, dbytes;
622 info->
fix.ypanstep = 1;
623 info->
fix.line_length = (info->
var.xres_virtual *
bpp) / 8;
626 info->tileops =
NULL;
629 info->
pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(
u32)0);
632 offset_value = (info->
var.xres_virtual *
bpp) / 64;
633 screen_size = info->
var.yres_virtual * info->
fix.line_length;
635 info->
fix.ypanstep = 16;
636 info->
fix.line_length = 0;
639 info->tileops = fasttext ? &s3fb_fast_tile_ops : &s3fb_tile_ops;
642 info->
pixmap.blit_x = 1 << (8 - 1);
643 info->
pixmap.blit_y = 1 << (16 - 1);
645 offset_value = info->
var.xres_virtual / 16;
646 screen_size = (info->
var.xres_virtual * info->
var.yres_virtual) / 64;
649 info->
var.xoffset = 0;
650 info->
var.yoffset = 0;
654 vga_wcrt(par->
state.vgabase, 0x38, 0x48);
655 vga_wcrt(par->
state.vgabase, 0x39, 0xA5);
656 vga_wseq(par->
state.vgabase, 0x08, 0x06);
657 svga_wcrt_mask(par->
state.vgabase, 0x11, 0x00, 0x80);
660 svga_wseq_mask(par->
state.vgabase, 0x01, 0x20, 0x20);
661 svga_wcrt_mask(par->
state.vgabase, 0x17, 0x00, 0x80);
672 svga_wcrt_mask(par->
state.vgabase, 0x58, 0x10, 0x10);
673 svga_wcrt_mask(par->
state.vgabase, 0x31, 0x08, 0x08);
677 svga_wcrt_mask(par->
state.vgabase, 0x33, 0x00, 0x08);
678 svga_wcrt_mask(par->
state.vgabase, 0x43, 0x00, 0x01);
680 svga_wcrt_mask(par->
state.vgabase, 0x5D, 0x00, 0x28);
689 pr_debug(
"fb%d: offset register : %d\n", info->
node, offset_value);
698 vga_wcrt(par->
state.vgabase, 0x54, 0x18);
699 vga_wcrt(par->
state.vgabase, 0x60, 0xff);
700 vga_wcrt(par->
state.vgabase, 0x61, 0xff);
701 vga_wcrt(par->
state.vgabase, 0x62, 0xff);
704 vga_wcrt(par->
state.vgabase, 0x3A, 0x35);
705 svga_wattr(par->
state.vgabase, 0x33, 0x00);
708 svga_wcrt_mask(par->
state.vgabase, 0x09, 0x80, 0x80);
710 svga_wcrt_mask(par->
state.vgabase, 0x09, 0x00, 0x80);
713 svga_wcrt_mask(par->
state.vgabase, 0x42, 0x20, 0x20);
715 svga_wcrt_mask(par->
state.vgabase, 0x42, 0x00, 0x20);
718 svga_wcrt_mask(par->
state.vgabase, 0x45, 0x00, 0x01);
720 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x00, 0x0C);
726 vga_wcrt(par->
state.vgabase, 0
x86, 0x80);
727 vga_wcrt(par->
state.vgabase, 0x90, 0x00);
732 vga_wcrt(par->
state.vgabase, 0x50, 0x00);
733 vga_wcrt(par->
state.vgabase, 0x67, 0x50);
735 vga_wcrt(par->
state.vgabase, 0x63, (mode <= 2) ? 0x90 : 0x09);
736 vga_wcrt(par->
state.vgabase, 0x66, 0x90);
748 dbytes = info->
var.xres * ((bpp+7)/8);
749 vga_wcrt(par->
state.vgabase, 0x91, (dbytes + 7) / 8);
750 vga_wcrt(par->
state.vgabase, 0x90, (((dbytes + 7) / 8) >> 8) | 0x80);
752 vga_wcrt(par->
state.vgabase, 0x66, 0x81);
761 vga_wcrt(par->
state.vgabase, 0x34, 0x00);
763 vga_wcrt(par->
state.vgabase, 0x34, 0x10);
765 svga_wcrt_mask(par->
state.vgabase, 0x31, 0x00, 0x40);
776 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x00, 0x30);
777 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x00, 0xF0);
780 svga_wcrt_mask(par->
state.vgabase, 0x3A, 0x00, 0x30);
783 pr_debug(
"fb%d: high speed text mode set\n", info->
node);
784 svga_wcrt_mask(par->
state.vgabase, 0x31, 0x40, 0x40);
792 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x00, 0x30);
793 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x00, 0xF0);
796 svga_wcrt_mask(par->
state.vgabase, 0x3A, 0x00, 0x30);
799 pr_debug(
"fb%d: 4 bit pseudocolor, planar\n", info->
node);
802 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x00, 0x30);
803 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x00, 0xF0);
806 svga_wcrt_mask(par->
state.vgabase, 0x3A, 0x00, 0x30);
810 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x00, 0x30);
811 if (info->
var.pixclock > 20000 ||
818 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x00, 0xF0);
820 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x10, 0xF0);
827 if (info->
var.pixclock > 20000)
828 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x20, 0xF0);
830 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x30, 0xF0);
832 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x10, 0x30);
833 if (info->
var.pixclock > 8695) {
834 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x30, 0xF0);
837 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x20, 0xF0);
841 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x10, 0x30);
842 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x30, 0xF0);
855 if (info->
var.pixclock > 20000)
856 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x40, 0xF0);
858 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x50, 0xF0);
860 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x10, 0x30);
861 if (info->
var.pixclock > 8695) {
862 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x50, 0xF0);
865 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x40, 0xF0);
869 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x10, 0x30);
870 svga_wcrt_mask(par->
state.vgabase, 0x67, 0x50, 0xF0);
883 svga_wcrt_mask(par->
state.vgabase, 0x67, 0xD0, 0xF0);
887 svga_wcrt_mask(par->
state.vgabase, 0x50, 0x30, 0x30);
888 svga_wcrt_mask(par->
state.vgabase, 0x67, 0xD0, 0xF0);
896 svga_wseq_mask(par->
state.vgabase, 0x15, multiplex ? 0x10 : 0x00, 0x10);
897 svga_wseq_mask(par->
state.vgabase, 0x18, multiplex ? 0x80 : 0x00, 0x80);
900 s3_set_pixclock(info, info->
var.pixclock);
907 htotal = info->
var.xres + info->
var.left_margin + info->
var.right_margin + info->
var.hsync_len;
908 htotal = ((htotal * hmul) / 8) - 5;
909 vga_wcrt(par->
state.vgabase, 0x3C, (htotal + 1) / 2);
912 hsstart = ((info->
var.xres + info->
var.right_margin) * hmul) / 8;
914 value =
clamp((htotal + hsstart + 1) / 2 + 2, hsstart + 4, htotal + 1);
919 svga_wcrt_mask(par->
state.vgabase, 0x17, 0x80, 0x80);
920 svga_wseq_mask(par->
state.vgabase, 0x01, 0x00, 0x20);
930 switch (fb->
var.bits_per_pixel) {
936 if ((fb->
var.bits_per_pixel == 4) &&
937 (fb->
var.nonstd == 0)) {
962 if (fb->
var.green.length == 5)
964 ((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11);
965 else if (fb->
var.green.length == 6)
967 ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
976 (green & 0xFF00) | ((blue & 0xFF00) >> 8);
988 static int s3fb_blank(
int blank_mode,
struct fb_info *info)
992 switch (blank_mode) {
995 svga_wcrt_mask(par->
state.vgabase, 0x56, 0x00, 0x06);
996 svga_wseq_mask(par->
state.vgabase, 0x01, 0x00, 0x20);
1000 svga_wcrt_mask(par->
state.vgabase, 0x56, 0x00, 0x06);
1001 svga_wseq_mask(par->
state.vgabase, 0x01, 0x20, 0x20);
1005 svga_wcrt_mask(par->
state.vgabase, 0x56, 0x02, 0x06);
1006 svga_wseq_mask(par->
state.vgabase, 0x01, 0x20, 0x20);
1010 svga_wcrt_mask(par->
state.vgabase, 0x56, 0x04, 0x06);
1011 svga_wseq_mask(par->
state.vgabase, 0x01, 0x20, 0x20);
1015 svga_wcrt_mask(par->
state.vgabase, 0x56, 0x06, 0x06);
1016 svga_wseq_mask(par->
state.vgabase, 0x01, 0x20, 0x20);
1032 if (info->
var.bits_per_pixel == 0) {
1033 offset = (var->
yoffset / 16) * (info->
var.xres_virtual / 2)
1035 offset = offset >> 2;
1037 offset = (var->
yoffset * info->
fix.line_length) +
1038 (var->
xoffset * info->
var.bits_per_pixel / 8);
1039 offset = offset >> 2;
1052 static struct fb_ops s3fb_ops = {
1054 .fb_open = s3fb_open,
1055 .fb_release = s3fb_release,
1056 .fb_check_var = s3fb_check_var,
1057 .fb_set_par = s3fb_set_par,
1058 .fb_setcolreg = s3fb_setcolreg,
1059 .fb_blank = s3fb_blank,
1060 .fb_pan_display = s3fb_pan_display,
1061 .fb_fillrect = s3fb_fillrect,
1063 .fb_imageblit = s3fb_imageblit,
1074 u8 cr30 = vga_rcrt(par->
state.vgabase, 0x30);
1075 u8 cr2e = vga_rcrt(par->
state.vgabase, 0x2e);
1076 u8 cr2f = vga_rcrt(par->
state.vgabase, 0x2f);
1078 if ((cr30 == 0xE0) || (cr30 == 0xE1)) {
1082 if (! (cr2f & 0x40))
1091 u8 cr6f = vga_rcrt(par->
state.vgabase, 0x6f);
1093 if (! (cr6f & 0x01))
1100 u8 cr6f = vga_rcrt(par->
state.vgabase, 0x6f);
1102 if (! (cr6f & 0x01))
1109 switch (vga_rcrt(par->
state.vgabase, 0x2f)) {
1136 if (! svga_primary_device(dev)) {
1137 dev_info(&(dev->
dev),
"ignoring secondary device\n");
1144 dev_err(&(dev->
dev),
"cannot allocate memory\n");
1152 info->
fbops = &s3fb_ops;
1158 goto err_enable_device;
1163 dev_err(info->
device,
"cannot reserve framebuffer region\n");
1164 goto err_request_regions;
1180 bus_reg.end = 64 * 1024;
1189 cr38 = vga_rcrt(par->
state.vgabase, 0x38);
1190 cr39 = vga_rcrt(par->
state.vgabase, 0x39);
1191 vga_wseq(par->
state.vgabase, 0x08, 0x06);
1192 vga_wcrt(par->
state.vgabase, 0x38, 0x48);
1193 vga_wcrt(par->
state.vgabase, 0x39, 0xA5);
1197 par->
rev = vga_rcrt(par->
state.vgabase, 0x2f);
1199 par->
chip = s3_identification(par);
1203 regval = vga_rcrt(par->
state.vgabase, 0x36);
1208 switch ((regval & 0xE0) >> 5) {
1222 switch ((regval & 0xC0) >> 6) {
1231 switch ((regval & 0x60) >> 5) {
1246 regval = vga_rcrt(par->
state.vgabase, 0x37);
1247 switch ((regval & 0x60) >> 5) {
1256 info->
screen_size = s3_memsizes[regval >> 5] << 10;
1260 regval = vga_rseq(par->
state.vgabase, 0x10);
1261 par->
mclk_freq = ((vga_rseq(par->
state.vgabase, 0x11) + 2) * 14318) / ((regval & 0x1F) + 2);
1265 vga_wcrt(par->
state.vgabase, 0x38, cr38);
1266 vga_wcrt(par->
state.vgabase, 0x39, cr39);
1269 info->
fix.mmio_start = 0;
1270 info->
fix.mmio_len = 0;
1273 info->
fix.ypanstep = 0;
1276 info->
var.bits_per_pixel = 8;
1278 #ifdef CONFIG_FB_S3_DDC
1280 if (s3fb_ddc_needs_mmio(par->
chip)) {
1283 svga_wcrt_mask(par->
state.vgabase, 0x53, 0x08, 0x08);
1285 dev_err(info->
device,
"unable to map MMIO at 0x%lx, disabling DDC",
1288 if (!s3fb_ddc_needs_mmio(par->
chip) || par->mmio)
1289 if (s3fb_setup_ddc_bus(info) == 0) {
1291 par->ddc_registered =
true;
1307 if (s3fb_check_var(&info->
var, info) == 0)
1314 if (!mode_option && !found)
1315 mode_option =
"640x480-8@60";
1321 NULL, info->
var.bits_per_pixel);
1322 if (!rc || rc == 4) {
1335 info->
var.yres_virtual = info->
fix.smem_len * 8 /
1336 (info->
var.bits_per_pixel * info->
var.xres_virtual);
1337 if (info->
var.yres_virtual < info->
var.yres) {
1338 dev_err(info->
device,
"virtual vertical size smaller than real\n");
1343 info->
var.yres_virtual = info->
fix.smem_len * 8 /
1344 (info->
var.bits_per_pixel * info->
var.xres_virtual);
1345 if (info->
var.yres_virtual < info->
var.yres) {
1346 dev_err(info->
device,
"virtual vertical size smaller than real\n");
1353 goto err_alloc_cmap;
1363 pci_name(dev), info->
fix.smem_len >> 20, (par->
mclk_freq + 500) / 1000);
1366 printk(
KERN_INFO "fb%d: unknown chip, CR2D=%x, CR2E=%x, CRT2F=%x, CRT30=%x\n",
1367 info->
node, vga_rcrt(par->
state.vgabase, 0x2d), vga_rcrt(par->
state.vgabase, 0x2e),
1368 vga_rcrt(par->
state.vgabase, 0x2f), vga_rcrt(par->
state.vgabase, 0x30));
1371 pci_set_drvdata(dev, info);
1387 #ifdef CONFIG_FB_S3_DDC
1388 if (par->ddc_registered)
1396 err_request_regions:
1408 struct fb_info *info = pci_get_drvdata(dev);
1423 #ifdef CONFIG_FB_S3_DDC
1424 if (par->ddc_registered)
1434 pci_set_drvdata(dev,
NULL);
1443 struct fb_info *info = pci_get_drvdata(dev);
1472 static int s3_pci_resume(
struct pci_dev* dev)
1474 struct fb_info *info = pci_get_drvdata(dev);
1495 dev_err(info->
device,
"error %d enabling device for resume\n", err);
1530 {0, 0, 0, 0, 0, 0, 0}
1538 .id_table = s3_devices,
1539 .probe = s3_pci_probe,
1541 .suspend = s3_pci_suspend,
1542 .resume = s3_pci_resume,
1552 if (!options || !*options)
1555 while ((opt =
strsep(&options,
",")) !=
NULL) {
1560 else if (!
strncmp(opt,
"mtrr:", 5))
1563 else if (!
strncmp(opt,
"fasttext:", 9))
1575 static void __exit s3fb_cleanup(
void)
1583 static int __init s3fb_init(
void)
1595 return pci_register_driver(&s3fb_pci_driver);