blob: 262490a74bb70a20381a20db45cd88038c32dd50 [file] [log] [blame]
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001/*
2 * linux/drivers/video/s3fb.c -- Frame buffer device driver for S3 Trio/Virge
3 *
4 * Copyright (c) 2006-2007 Ondrej Zajicek <santiago@crfreenet.org>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
8 * more details.
9 *
10 * Code is based on David Boucher's viafb (http://davesdomain.org.uk/viafb/)
11 * which is based on the code of neofb.
12 */
13
Ondrej Zajiceka2684222007-02-12 00:54:49 -080014#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/errno.h>
17#include <linux/string.h>
18#include <linux/mm.h>
19#include <linux/tty.h>
Ondrej Zajiceka2684222007-02-12 00:54:49 -080020#include <linux/delay.h>
21#include <linux/fb.h>
22#include <linux/svga.h>
23#include <linux/init.h>
24#include <linux/pci.h>
Torben Hohnac751ef2011-01-25 15:07:35 -080025#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
Ondrej Zajiceka2684222007-02-12 00:54:49 -080026#include <video/vga.h>
27
28#ifdef CONFIG_MTRR
29#include <asm/mtrr.h>
30#endif
31
32struct s3fb_info {
33 int chip, rev, mclk_freq;
34 int mtrr_reg;
35 struct vgastate state;
36 struct mutex open_lock;
37 unsigned int ref_count;
38 u32 pseudo_palette[16];
39};
40
41
42/* ------------------------------------------------------------------------- */
43
44static const struct svga_fb_format s3fb_formats[] = {
45 { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
46 FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP4, FB_VISUAL_PSEUDOCOLOR, 8, 16},
Michal Januszewskic26d7b22009-04-13 14:39:49 -070047 { 4, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 0,
Ondrej Zajiceka2684222007-02-12 00:54:49 -080048 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 16},
Michal Januszewskic26d7b22009-04-13 14:39:49 -070049 { 4, {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, 1,
Ondrej Zajiceka2684222007-02-12 00:54:49 -080050 FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 8, 16},
Michal Januszewskic26d7b22009-04-13 14:39:49 -070051 { 8, {0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
Ondrej Zajiceka2684222007-02-12 00:54:49 -080052 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 4, 8},
53 {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0,
54 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 4},
55 {16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0,
56 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 4},
57 {24, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
58 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 1, 2},
59 {32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
60 FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 1, 2},
61 SVGA_FORMAT_END
62};
63
64
65static const struct svga_pll s3_pll = {3, 129, 3, 33, 0, 3,
Ondrej Zajicek249bdbb2007-05-08 00:39:24 -070066 35000, 240000, 14318};
Ondrej Zajiceka2684222007-02-12 00:54:49 -080067
68static const int s3_memsizes[] = {4096, 0, 3072, 8192, 2048, 6144, 1024, 512};
69
70static const char * const s3_names[] = {"S3 Unknown", "S3 Trio32", "S3 Trio64", "S3 Trio64V+",
71 "S3 Trio64UV+", "S3 Trio64V2/DX", "S3 Trio64V2/GX",
72 "S3 Plato/PX", "S3 Aurora64VP", "S3 Virge",
73 "S3 Virge/VX", "S3 Virge/DX", "S3 Virge/GX",
Ondrej Zary9966c4f2010-05-26 14:42:27 -070074 "S3 Virge/GX2", "S3 Virge/GX2P", "S3 Virge/GX2P",
75 "S3 Trio3D/1X", "S3 Trio3D/2X", "S3 Trio3D/2X"};
Ondrej Zajiceka2684222007-02-12 00:54:49 -080076
77#define CHIP_UNKNOWN 0x00
78#define CHIP_732_TRIO32 0x01
79#define CHIP_764_TRIO64 0x02
80#define CHIP_765_TRIO64VP 0x03
81#define CHIP_767_TRIO64UVP 0x04
82#define CHIP_775_TRIO64V2_DX 0x05
83#define CHIP_785_TRIO64V2_GX 0x06
84#define CHIP_551_PLATO_PX 0x07
85#define CHIP_M65_AURORA64VP 0x08
86#define CHIP_325_VIRGE 0x09
87#define CHIP_988_VIRGE_VX 0x0A
88#define CHIP_375_VIRGE_DX 0x0B
89#define CHIP_385_VIRGE_GX 0x0C
90#define CHIP_356_VIRGE_GX2 0x0D
91#define CHIP_357_VIRGE_GX2P 0x0E
92#define CHIP_359_VIRGE_GX2P 0x0F
Ondrej Zary9966c4f2010-05-26 14:42:27 -070093#define CHIP_360_TRIO3D_1X 0x10
94#define CHIP_362_TRIO3D_2X 0x11
95#define CHIP_368_TRIO3D_2X 0x12
Ondrej Zajiceka2684222007-02-12 00:54:49 -080096
97#define CHIP_XXX_TRIO 0x80
98#define CHIP_XXX_TRIO64V2_DXGX 0x81
99#define CHIP_XXX_VIRGE_DXGX 0x82
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700100#define CHIP_36X_TRIO3D_1X_2X 0x83
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800101
102#define CHIP_UNDECIDED_FLAG 0x80
103#define CHIP_MASK 0xFF
104
105/* CRT timing register sets */
106
107static const struct vga_regset s3_h_total_regs[] = {{0x00, 0, 7}, {0x5D, 0, 0}, VGA_REGSET_END};
108static const struct vga_regset s3_h_display_regs[] = {{0x01, 0, 7}, {0x5D, 1, 1}, VGA_REGSET_END};
109static const struct vga_regset s3_h_blank_start_regs[] = {{0x02, 0, 7}, {0x5D, 2, 2}, VGA_REGSET_END};
110static const struct vga_regset s3_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7}, VGA_REGSET_END};
111static const struct vga_regset s3_h_sync_start_regs[] = {{0x04, 0, 7}, {0x5D, 4, 4}, VGA_REGSET_END};
112static const struct vga_regset s3_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END};
113
114static const struct vga_regset s3_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x5E, 0, 0}, VGA_REGSET_END};
115static const struct vga_regset s3_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x5E, 1, 1}, VGA_REGSET_END};
116static const struct vga_regset s3_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x5E, 2, 2}, VGA_REGSET_END};
117static const struct vga_regset s3_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END};
118static const struct vga_regset s3_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x5E, 4, 4}, VGA_REGSET_END};
119static const struct vga_regset s3_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END};
120
121static const struct vga_regset s3_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, {0x5E, 6, 6}, VGA_REGSET_END};
122static const struct vga_regset s3_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x31, 4, 5}, {0x51, 0, 1}, VGA_REGSET_END};
123static const struct vga_regset s3_offset_regs[] = {{0x13, 0, 7}, {0x51, 4, 5}, VGA_REGSET_END}; /* set 0x43 bit 2 to 0 */
124
125static const struct svga_timing_regs s3_timing_regs = {
126 s3_h_total_regs, s3_h_display_regs, s3_h_blank_start_regs,
127 s3_h_blank_end_regs, s3_h_sync_start_regs, s3_h_sync_end_regs,
128 s3_v_total_regs, s3_v_display_regs, s3_v_blank_start_regs,
129 s3_v_blank_end_regs, s3_v_sync_start_regs, s3_v_sync_end_regs,
130};
131
132
133/* ------------------------------------------------------------------------- */
134
135/* Module parameters */
136
137
Krzysztof Helta8140542008-04-28 02:15:09 -0700138static char *mode_option __devinitdata = "640x480-8@60";
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800139
140#ifdef CONFIG_MTRR
Krzysztof Helta8140542008-04-28 02:15:09 -0700141static int mtrr __devinitdata = 1;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800142#endif
143
144static int fasttext = 1;
145
146
147MODULE_AUTHOR("(c) 2006-2007 Ondrej Zajicek <santiago@crfreenet.org>");
148MODULE_LICENSE("GPL");
149MODULE_DESCRIPTION("fbdev driver for S3 Trio/Virge");
150
Krzysztof Helta8140542008-04-28 02:15:09 -0700151module_param(mode_option, charp, 0444);
152MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
153module_param_named(mode, mode_option, charp, 0444);
154MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc) (deprecated)");
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800155
156#ifdef CONFIG_MTRR
157module_param(mtrr, int, 0444);
158MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, default=1)");
159#endif
160
161module_param(fasttext, int, 0644);
162MODULE_PARM_DESC(fasttext, "Enable S3 fast text mode (1=enable, 0=disable, default=1)");
163
164
165/* ------------------------------------------------------------------------- */
166
167/* Set font in S3 fast text mode */
168
169static void s3fb_settile_fast(struct fb_info *info, struct fb_tilemap *map)
170{
171 const u8 *font = map->data;
Antonino A. Daplas75814d82007-05-08 00:38:49 -0700172 u8 __iomem *fb = (u8 __iomem *) info->screen_base;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800173 int i, c;
174
175 if ((map->width != 8) || (map->height != 16) ||
176 (map->depth != 1) || (map->length != 256)) {
177 printk(KERN_ERR "fb%d: unsupported font parameters: width %d, height %d, depth %d, length %d\n",
178 info->node, map->width, map->height, map->depth, map->length);
179 return;
180 }
181
182 fb += 2;
183 for (i = 0; i < map->height; i++) {
184 for (c = 0; c < map->length; c++) {
Antonino A. Daplas75814d82007-05-08 00:38:49 -0700185 fb_writeb(font[c * map->height + i], fb + c * 4);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800186 }
187 fb += 1024;
188 }
189}
190
David Miller55db0922011-01-11 23:52:11 +0000191static void s3fb_tilecursor(struct fb_info *info, struct fb_tilecursor *cursor)
192{
193 struct s3fb_info *par = info->par;
194
195 svga_tilecursor(par->state.vgabase, info, cursor);
196}
197
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800198static struct fb_tile_ops s3fb_tile_ops = {
199 .fb_settile = svga_settile,
200 .fb_tilecopy = svga_tilecopy,
201 .fb_tilefill = svga_tilefill,
202 .fb_tileblit = svga_tileblit,
David Miller55db0922011-01-11 23:52:11 +0000203 .fb_tilecursor = s3fb_tilecursor,
Ondrej Zajicek34ed25f2007-05-08 00:40:00 -0700204 .fb_get_tilemax = svga_get_tilemax,
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800205};
206
207static struct fb_tile_ops s3fb_fast_tile_ops = {
208 .fb_settile = s3fb_settile_fast,
209 .fb_tilecopy = svga_tilecopy,
210 .fb_tilefill = svga_tilefill,
211 .fb_tileblit = svga_tileblit,
David Miller55db0922011-01-11 23:52:11 +0000212 .fb_tilecursor = s3fb_tilecursor,
Ondrej Zajicek34ed25f2007-05-08 00:40:00 -0700213 .fb_get_tilemax = svga_get_tilemax,
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800214};
215
216
217/* ------------------------------------------------------------------------- */
218
219/* image data is MSB-first, fb structure is MSB-first too */
220static inline u32 expand_color(u32 c)
221{
222 return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF;
223}
224
225/* s3fb_iplan_imageblit silently assumes that almost everything is 8-pixel aligned */
226static void s3fb_iplan_imageblit(struct fb_info *info, const struct fb_image *image)
227{
228 u32 fg = expand_color(image->fg_color);
229 u32 bg = expand_color(image->bg_color);
230 const u8 *src1, *src;
231 u8 __iomem *dst1;
232 u32 __iomem *dst;
233 u32 val;
234 int x, y;
235
236 src1 = image->data;
237 dst1 = info->screen_base + (image->dy * info->fix.line_length)
238 + ((image->dx / 8) * 4);
239
240 for (y = 0; y < image->height; y++) {
241 src = src1;
242 dst = (u32 __iomem *) dst1;
243 for (x = 0; x < image->width; x += 8) {
244 val = *(src++) * 0x01010101;
245 val = (val & fg) | (~val & bg);
246 fb_writel(val, dst++);
247 }
248 src1 += image->width / 8;
249 dst1 += info->fix.line_length;
250 }
251
252}
253
254/* s3fb_iplan_fillrect silently assumes that almost everything is 8-pixel aligned */
255static void s3fb_iplan_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
256{
257 u32 fg = expand_color(rect->color);
258 u8 __iomem *dst1;
259 u32 __iomem *dst;
260 int x, y;
261
262 dst1 = info->screen_base + (rect->dy * info->fix.line_length)
263 + ((rect->dx / 8) * 4);
264
265 for (y = 0; y < rect->height; y++) {
266 dst = (u32 __iomem *) dst1;
267 for (x = 0; x < rect->width; x += 8) {
268 fb_writel(fg, dst++);
269 }
270 dst1 += info->fix.line_length;
271 }
272}
273
274
275/* image data is MSB-first, fb structure is high-nibble-in-low-byte-first */
276static inline u32 expand_pixel(u32 c)
277{
278 return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) |
279 ((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF;
280}
281
282/* s3fb_cfb4_imageblit silently assumes that almost everything is 8-pixel aligned */
283static void s3fb_cfb4_imageblit(struct fb_info *info, const struct fb_image *image)
284{
285 u32 fg = image->fg_color * 0x11111111;
286 u32 bg = image->bg_color * 0x11111111;
287 const u8 *src1, *src;
288 u8 __iomem *dst1;
289 u32 __iomem *dst;
290 u32 val;
291 int x, y;
292
293 src1 = image->data;
294 dst1 = info->screen_base + (image->dy * info->fix.line_length)
295 + ((image->dx / 8) * 4);
296
297 for (y = 0; y < image->height; y++) {
298 src = src1;
299 dst = (u32 __iomem *) dst1;
300 for (x = 0; x < image->width; x += 8) {
301 val = expand_pixel(*(src++));
302 val = (val & fg) | (~val & bg);
303 fb_writel(val, dst++);
304 }
305 src1 += image->width / 8;
306 dst1 += info->fix.line_length;
307 }
308}
309
310static void s3fb_imageblit(struct fb_info *info, const struct fb_image *image)
311{
312 if ((info->var.bits_per_pixel == 4) && (image->depth == 1)
313 && ((image->width % 8) == 0) && ((image->dx % 8) == 0)) {
314 if (info->fix.type == FB_TYPE_INTERLEAVED_PLANES)
315 s3fb_iplan_imageblit(info, image);
316 else
317 s3fb_cfb4_imageblit(info, image);
318 } else
319 cfb_imageblit(info, image);
320}
321
322static void s3fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
323{
324 if ((info->var.bits_per_pixel == 4)
325 && ((rect->width % 8) == 0) && ((rect->dx % 8) == 0)
326 && (info->fix.type == FB_TYPE_INTERLEAVED_PLANES))
327 s3fb_iplan_fillrect(info, rect);
328 else
329 cfb_fillrect(info, rect);
330}
331
332
333
334/* ------------------------------------------------------------------------- */
335
336
337static void s3_set_pixclock(struct fb_info *info, u32 pixclock)
338{
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700339 struct s3fb_info *par = info->par;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800340 u16 m, n, r;
341 u8 regval;
Ondrej Zajicek249bdbb2007-05-08 00:39:24 -0700342 int rv;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800343
Ondrej Zajicek249bdbb2007-05-08 00:39:24 -0700344 rv = svga_compute_pll(&s3_pll, 1000000000 / pixclock, &m, &n, &r, info->node);
345 if (rv < 0) {
346 printk(KERN_ERR "fb%d: cannot set requested pixclock, keeping old value\n", info->node);
347 return;
348 }
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800349
350 /* Set VGA misc register */
David Millerf8645932011-01-11 23:52:57 +0000351 regval = vga_r(par->state.vgabase, VGA_MIS_R);
352 vga_w(par->state.vgabase, VGA_MIS_W, regval | VGA_MIS_ENB_PLL_LOAD);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800353
354 /* Set S3 clock registers */
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700355 if (par->chip == CHIP_360_TRIO3D_1X ||
356 par->chip == CHIP_362_TRIO3D_2X ||
357 par->chip == CHIP_368_TRIO3D_2X) {
David Millerf8645932011-01-11 23:52:57 +0000358 vga_wseq(par->state.vgabase, 0x12, (n - 2) | ((r & 3) << 6)); /* n and two bits of r */
359 vga_wseq(par->state.vgabase, 0x29, r >> 2); /* remaining highest bit of r */
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700360 } else
David Millerf8645932011-01-11 23:52:57 +0000361 vga_wseq(par->state.vgabase, 0x12, (n - 2) | (r << 5));
362 vga_wseq(par->state.vgabase, 0x13, m - 2);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800363
364 udelay(1000);
365
366 /* Activate clock - write 0, 1, 0 to seq/15 bit 5 */
David Millerf8645932011-01-11 23:52:57 +0000367 regval = vga_rseq (par->state.vgabase, 0x15); /* | 0x80; */
368 vga_wseq(par->state.vgabase, 0x15, regval & ~(1<<5));
369 vga_wseq(par->state.vgabase, 0x15, regval | (1<<5));
370 vga_wseq(par->state.vgabase, 0x15, regval & ~(1<<5));
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800371}
372
373
374/* Open framebuffer */
375
376static int s3fb_open(struct fb_info *info, int user)
377{
378 struct s3fb_info *par = info->par;
379
380 mutex_lock(&(par->open_lock));
381 if (par->ref_count == 0) {
382 memset(&(par->state), 0, sizeof(struct vgastate));
383 par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS | VGA_SAVE_CMAP;
384 par->state.num_crtc = 0x70;
385 par->state.num_seq = 0x20;
386 save_vga(&(par->state));
387 }
388
389 par->ref_count++;
390 mutex_unlock(&(par->open_lock));
391
392 return 0;
393}
394
395/* Close framebuffer */
396
397static int s3fb_release(struct fb_info *info, int user)
398{
399 struct s3fb_info *par = info->par;
400
401 mutex_lock(&(par->open_lock));
402 if (par->ref_count == 0) {
403 mutex_unlock(&(par->open_lock));
404 return -EINVAL;
405 }
406
407 if (par->ref_count == 1)
408 restore_vga(&(par->state));
409
410 par->ref_count--;
411 mutex_unlock(&(par->open_lock));
412
413 return 0;
414}
415
416/* Validate passed in var */
417
418static int s3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
419{
420 struct s3fb_info *par = info->par;
421 int rv, mem, step;
Krzysztof Heltc3ca34f2007-10-16 01:29:54 -0700422 u16 m, n, r;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800423
424 /* Find appropriate format */
425 rv = svga_match_format (s3fb_formats, var, NULL);
Ondrej Zajicekd4b766a2007-10-16 01:29:52 -0700426
427 /* 32bpp mode is not supported on VIRGE VX,
428 24bpp is not supported on others */
429 if ((par->chip == CHIP_988_VIRGE_VX) ? (rv == 7) : (rv == 6))
430 rv = -EINVAL;
431
432 if (rv < 0) {
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800433 printk(KERN_ERR "fb%d: unsupported mode requested\n", info->node);
434 return rv;
435 }
436
437 /* Do not allow to have real resoulution larger than virtual */
438 if (var->xres > var->xres_virtual)
439 var->xres_virtual = var->xres;
440
441 if (var->yres > var->yres_virtual)
442 var->yres_virtual = var->yres;
443
444 /* Round up xres_virtual to have proper alignment of lines */
445 step = s3fb_formats[rv].xresstep - 1;
446 var->xres_virtual = (var->xres_virtual+step) & ~step;
447
448 /* Check whether have enough memory */
449 mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual;
Krzysztof Heltc3ca34f2007-10-16 01:29:54 -0700450 if (mem > info->screen_size) {
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800451 printk(KERN_ERR "fb%d: not enough framebuffer memory (%d kB requested , %d kB available)\n",
452 info->node, mem >> 10, (unsigned int) (info->screen_size >> 10));
453 return -EINVAL;
454 }
455
456 rv = svga_check_timings (&s3_timing_regs, var, info->node);
Krzysztof Heltc3ca34f2007-10-16 01:29:54 -0700457 if (rv < 0) {
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800458 printk(KERN_ERR "fb%d: invalid timings requested\n", info->node);
459 return rv;
460 }
461
Krzysztof Heltc3ca34f2007-10-16 01:29:54 -0700462 rv = svga_compute_pll(&s3_pll, PICOS2KHZ(var->pixclock), &m, &n, &r,
463 info->node);
464 if (rv < 0) {
465 printk(KERN_ERR "fb%d: invalid pixclock value requested\n",
466 info->node);
467 return rv;
468 }
469
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800470 return 0;
471}
472
473/* Set video mode from par */
474
475static int s3fb_set_par(struct fb_info *info)
476{
477 struct s3fb_info *par = info->par;
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700478 u32 value, mode, hmul, offset_value, screen_size, multiplex, dbytes;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800479 u32 bpp = info->var.bits_per_pixel;
480
481 if (bpp != 0) {
482 info->fix.ypanstep = 1;
483 info->fix.line_length = (info->var.xres_virtual * bpp) / 8;
484
485 info->flags &= ~FBINFO_MISC_TILEBLITTING;
486 info->tileops = NULL;
487
Ondrej Zajicek34ed25f2007-05-08 00:40:00 -0700488 /* in 4bpp supports 8p wide tiles only, any tiles otherwise */
489 info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0);
Antonino A. Daplas8db51662007-05-08 00:39:14 -0700490 info->pixmap.blit_y = ~(u32)0;
Ondrej Zajicek34ed25f2007-05-08 00:40:00 -0700491
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800492 offset_value = (info->var.xres_virtual * bpp) / 64;
493 screen_size = info->var.yres_virtual * info->fix.line_length;
494 } else {
495 info->fix.ypanstep = 16;
496 info->fix.line_length = 0;
497
498 info->flags |= FBINFO_MISC_TILEBLITTING;
499 info->tileops = fasttext ? &s3fb_fast_tile_ops : &s3fb_tile_ops;
Ondrej Zajicek34ed25f2007-05-08 00:40:00 -0700500
Antonino A. Daplas8db51662007-05-08 00:39:14 -0700501 /* supports 8x16 tiles only */
502 info->pixmap.blit_x = 1 << (8 - 1);
503 info->pixmap.blit_y = 1 << (16 - 1);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800504
505 offset_value = info->var.xres_virtual / 16;
506 screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64;
507 }
508
509 info->var.xoffset = 0;
510 info->var.yoffset = 0;
511 info->var.activate = FB_ACTIVATE_NOW;
512
513 /* Unlock registers */
David Millerf8645932011-01-11 23:52:57 +0000514 vga_wcrt(par->state.vgabase, 0x38, 0x48);
515 vga_wcrt(par->state.vgabase, 0x39, 0xA5);
516 vga_wseq(par->state.vgabase, 0x08, 0x06);
David Millerea770782011-01-11 23:51:26 +0000517 svga_wcrt_mask(par->state.vgabase, 0x11, 0x00, 0x80);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800518
519 /* Blank screen and turn off sync */
David Millerd907ec02011-01-11 23:51:08 +0000520 svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
David Millerea770782011-01-11 23:51:26 +0000521 svga_wcrt_mask(par->state.vgabase, 0x17, 0x00, 0x80);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800522
523 /* Set default values */
David Millere2fade22011-01-11 23:50:04 +0000524 svga_set_default_gfx_regs(par->state.vgabase);
David Millerf51a14d2011-01-11 23:50:36 +0000525 svga_set_default_atc_regs(par->state.vgabase);
David Millera4ade8392011-01-11 23:50:54 +0000526 svga_set_default_seq_regs(par->state.vgabase);
David Miller1d28fca2011-01-11 23:51:41 +0000527 svga_set_default_crt_regs(par->state.vgabase);
David Miller21da3862011-01-11 23:49:34 +0000528 svga_wcrt_multi(par->state.vgabase, s3_line_compare_regs, 0xFFFFFFFF);
529 svga_wcrt_multi(par->state.vgabase, s3_start_address_regs, 0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800530
531 /* S3 specific initialization */
David Millerea770782011-01-11 23:51:26 +0000532 svga_wcrt_mask(par->state.vgabase, 0x58, 0x10, 0x10); /* enable linear framebuffer */
533 svga_wcrt_mask(par->state.vgabase, 0x31, 0x08, 0x08); /* enable sequencer access to framebuffer above 256 kB */
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800534
David Millerea770782011-01-11 23:51:26 +0000535/* svga_wcrt_mask(par->state.vgabase, 0x33, 0x08, 0x08); */ /* DDR ? */
536/* svga_wcrt_mask(par->state.vgabase, 0x43, 0x01, 0x01); */ /* DDR ? */
537 svga_wcrt_mask(par->state.vgabase, 0x33, 0x00, 0x08); /* no DDR ? */
538 svga_wcrt_mask(par->state.vgabase, 0x43, 0x00, 0x01); /* no DDR ? */
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800539
David Millerea770782011-01-11 23:51:26 +0000540 svga_wcrt_mask(par->state.vgabase, 0x5D, 0x00, 0x28); /* Clear strange HSlen bits */
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800541
David Millerea770782011-01-11 23:51:26 +0000542/* svga_wcrt_mask(par->state.vgabase, 0x58, 0x03, 0x03); */
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800543
David Millerea770782011-01-11 23:51:26 +0000544/* svga_wcrt_mask(par->state.vgabase, 0x53, 0x12, 0x13); */ /* enable MMIO */
545/* svga_wcrt_mask(par->state.vgabase, 0x40, 0x08, 0x08); */ /* enable write buffer */
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800546
547
548 /* Set the offset register */
549 pr_debug("fb%d: offset register : %d\n", info->node, offset_value);
David Miller21da3862011-01-11 23:49:34 +0000550 svga_wcrt_multi(par->state.vgabase, s3_offset_regs, offset_value);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800551
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700552 if (par->chip != CHIP_360_TRIO3D_1X &&
553 par->chip != CHIP_362_TRIO3D_2X &&
554 par->chip != CHIP_368_TRIO3D_2X) {
David Millerf8645932011-01-11 23:52:57 +0000555 vga_wcrt(par->state.vgabase, 0x54, 0x18); /* M parameter */
556 vga_wcrt(par->state.vgabase, 0x60, 0xff); /* N parameter */
557 vga_wcrt(par->state.vgabase, 0x61, 0xff); /* L parameter */
558 vga_wcrt(par->state.vgabase, 0x62, 0xff); /* L parameter */
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700559 }
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800560
David Millerf8645932011-01-11 23:52:57 +0000561 vga_wcrt(par->state.vgabase, 0x3A, 0x35);
David Millerf6b0cc42011-01-11 23:49:18 +0000562 svga_wattr(par->state.vgabase, 0x33, 0x00);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800563
564 if (info->var.vmode & FB_VMODE_DOUBLE)
David Millerea770782011-01-11 23:51:26 +0000565 svga_wcrt_mask(par->state.vgabase, 0x09, 0x80, 0x80);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800566 else
David Millerea770782011-01-11 23:51:26 +0000567 svga_wcrt_mask(par->state.vgabase, 0x09, 0x00, 0x80);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800568
569 if (info->var.vmode & FB_VMODE_INTERLACED)
David Millerea770782011-01-11 23:51:26 +0000570 svga_wcrt_mask(par->state.vgabase, 0x42, 0x20, 0x20);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800571 else
David Millerea770782011-01-11 23:51:26 +0000572 svga_wcrt_mask(par->state.vgabase, 0x42, 0x00, 0x20);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800573
574 /* Disable hardware graphics cursor */
David Millerea770782011-01-11 23:51:26 +0000575 svga_wcrt_mask(par->state.vgabase, 0x45, 0x00, 0x01);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800576 /* Disable Streams engine */
David Millerea770782011-01-11 23:51:26 +0000577 svga_wcrt_mask(par->state.vgabase, 0x67, 0x00, 0x0C);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800578
579 mode = svga_match_format(s3fb_formats, &(info->var), &(info->fix));
580
581 /* S3 virge DX hack */
582 if (par->chip == CHIP_375_VIRGE_DX) {
David Millerf8645932011-01-11 23:52:57 +0000583 vga_wcrt(par->state.vgabase, 0x86, 0x80);
584 vga_wcrt(par->state.vgabase, 0x90, 0x00);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800585 }
586
587 /* S3 virge VX hack */
588 if (par->chip == CHIP_988_VIRGE_VX) {
David Millerf8645932011-01-11 23:52:57 +0000589 vga_wcrt(par->state.vgabase, 0x50, 0x00);
590 vga_wcrt(par->state.vgabase, 0x67, 0x50);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800591
David Millerf8645932011-01-11 23:52:57 +0000592 vga_wcrt(par->state.vgabase, 0x63, (mode <= 2) ? 0x90 : 0x09);
593 vga_wcrt(par->state.vgabase, 0x66, 0x90);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800594 }
595
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700596 if (par->chip == CHIP_360_TRIO3D_1X ||
597 par->chip == CHIP_362_TRIO3D_2X ||
598 par->chip == CHIP_368_TRIO3D_2X) {
599 dbytes = info->var.xres * ((bpp+7)/8);
David Millerf8645932011-01-11 23:52:57 +0000600 vga_wcrt(par->state.vgabase, 0x91, (dbytes + 7) / 8);
601 vga_wcrt(par->state.vgabase, 0x90, (((dbytes + 7) / 8) >> 8) | 0x80);
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700602
David Millerf8645932011-01-11 23:52:57 +0000603 vga_wcrt(par->state.vgabase, 0x66, 0x81);
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700604 }
605
David Millerea770782011-01-11 23:51:26 +0000606 svga_wcrt_mask(par->state.vgabase, 0x31, 0x00, 0x40);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800607 multiplex = 0;
608 hmul = 1;
609
610 /* Set mode-specific register values */
611 switch (mode) {
612 case 0:
613 pr_debug("fb%d: text mode\n", info->node);
David Miller9c963942011-01-11 23:51:56 +0000614 svga_set_textmode_vga_regs(par->state.vgabase);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800615
616 /* Set additional registers like in 8-bit mode */
David Millerea770782011-01-11 23:51:26 +0000617 svga_wcrt_mask(par->state.vgabase, 0x50, 0x00, 0x30);
618 svga_wcrt_mask(par->state.vgabase, 0x67, 0x00, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800619
620 /* Disable enhanced mode */
David Millerea770782011-01-11 23:51:26 +0000621 svga_wcrt_mask(par->state.vgabase, 0x3A, 0x00, 0x30);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800622
623 if (fasttext) {
624 pr_debug("fb%d: high speed text mode set\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000625 svga_wcrt_mask(par->state.vgabase, 0x31, 0x40, 0x40);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800626 }
627 break;
628 case 1:
629 pr_debug("fb%d: 4 bit pseudocolor\n", info->node);
David Millerf8645932011-01-11 23:52:57 +0000630 vga_wgfx(par->state.vgabase, VGA_GFX_MODE, 0x40);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800631
632 /* Set additional registers like in 8-bit mode */
David Millerea770782011-01-11 23:51:26 +0000633 svga_wcrt_mask(par->state.vgabase, 0x50, 0x00, 0x30);
634 svga_wcrt_mask(par->state.vgabase, 0x67, 0x00, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800635
636 /* disable enhanced mode */
David Millerea770782011-01-11 23:51:26 +0000637 svga_wcrt_mask(par->state.vgabase, 0x3A, 0x00, 0x30);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800638 break;
639 case 2:
640 pr_debug("fb%d: 4 bit pseudocolor, planar\n", info->node);
641
642 /* Set additional registers like in 8-bit mode */
David Millerea770782011-01-11 23:51:26 +0000643 svga_wcrt_mask(par->state.vgabase, 0x50, 0x00, 0x30);
644 svga_wcrt_mask(par->state.vgabase, 0x67, 0x00, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800645
646 /* disable enhanced mode */
David Millerea770782011-01-11 23:51:26 +0000647 svga_wcrt_mask(par->state.vgabase, 0x3A, 0x00, 0x30);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800648 break;
649 case 3:
650 pr_debug("fb%d: 8 bit pseudocolor\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000651 svga_wcrt_mask(par->state.vgabase, 0x50, 0x00, 0x30);
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700652 if (info->var.pixclock > 20000 ||
653 par->chip == CHIP_360_TRIO3D_1X ||
654 par->chip == CHIP_362_TRIO3D_2X ||
655 par->chip == CHIP_368_TRIO3D_2X)
David Millerea770782011-01-11 23:51:26 +0000656 svga_wcrt_mask(par->state.vgabase, 0x67, 0x00, 0xF0);
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700657 else {
David Millerea770782011-01-11 23:51:26 +0000658 svga_wcrt_mask(par->state.vgabase, 0x67, 0x10, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800659 multiplex = 1;
660 }
661 break;
662 case 4:
663 pr_debug("fb%d: 5/5/5 truecolor\n", info->node);
664 if (par->chip == CHIP_988_VIRGE_VX) {
665 if (info->var.pixclock > 20000)
David Millerea770782011-01-11 23:51:26 +0000666 svga_wcrt_mask(par->state.vgabase, 0x67, 0x20, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800667 else
David Millerea770782011-01-11 23:51:26 +0000668 svga_wcrt_mask(par->state.vgabase, 0x67, 0x30, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800669 } else {
David Millerea770782011-01-11 23:51:26 +0000670 svga_wcrt_mask(par->state.vgabase, 0x50, 0x10, 0x30);
671 svga_wcrt_mask(par->state.vgabase, 0x67, 0x30, 0xF0);
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700672 if (par->chip != CHIP_360_TRIO3D_1X &&
673 par->chip != CHIP_362_TRIO3D_2X &&
674 par->chip != CHIP_368_TRIO3D_2X)
675 hmul = 2;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800676 }
677 break;
678 case 5:
679 pr_debug("fb%d: 5/6/5 truecolor\n", info->node);
680 if (par->chip == CHIP_988_VIRGE_VX) {
681 if (info->var.pixclock > 20000)
David Millerea770782011-01-11 23:51:26 +0000682 svga_wcrt_mask(par->state.vgabase, 0x67, 0x40, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800683 else
David Millerea770782011-01-11 23:51:26 +0000684 svga_wcrt_mask(par->state.vgabase, 0x67, 0x50, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800685 } else {
David Millerea770782011-01-11 23:51:26 +0000686 svga_wcrt_mask(par->state.vgabase, 0x50, 0x10, 0x30);
687 svga_wcrt_mask(par->state.vgabase, 0x67, 0x50, 0xF0);
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700688 if (par->chip != CHIP_360_TRIO3D_1X &&
689 par->chip != CHIP_362_TRIO3D_2X &&
690 par->chip != CHIP_368_TRIO3D_2X)
691 hmul = 2;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800692 }
693 break;
694 case 6:
695 /* VIRGE VX case */
696 pr_debug("fb%d: 8/8/8 truecolor\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000697 svga_wcrt_mask(par->state.vgabase, 0x67, 0xD0, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800698 break;
699 case 7:
700 pr_debug("fb%d: 8/8/8/8 truecolor\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000701 svga_wcrt_mask(par->state.vgabase, 0x50, 0x30, 0x30);
702 svga_wcrt_mask(par->state.vgabase, 0x67, 0xD0, 0xF0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800703 break;
704 default:
705 printk(KERN_ERR "fb%d: unsupported mode - bug\n", info->node);
706 return -EINVAL;
707 }
708
709 if (par->chip != CHIP_988_VIRGE_VX) {
David Millerd907ec02011-01-11 23:51:08 +0000710 svga_wseq_mask(par->state.vgabase, 0x15, multiplex ? 0x10 : 0x00, 0x10);
711 svga_wseq_mask(par->state.vgabase, 0x18, multiplex ? 0x80 : 0x00, 0x80);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800712 }
713
714 s3_set_pixclock(info, info->var.pixclock);
David Miller38d26202011-01-11 23:52:25 +0000715 svga_set_timings(par->state.vgabase, &s3_timing_regs, &(info->var), hmul, 1,
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800716 (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1,
717 (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1,
718 hmul, info->node);
719
720 /* Set interlaced mode start/end register */
721 value = info->var.xres + info->var.left_margin + info->var.right_margin + info->var.hsync_len;
722 value = ((value * hmul) / 8) - 5;
David Millerf8645932011-01-11 23:52:57 +0000723 vga_wcrt(par->state.vgabase, 0x3C, (value + 1) / 2);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800724
Antonino A. Daplas75814d82007-05-08 00:38:49 -0700725 memset_io(info->screen_base, 0x00, screen_size);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800726 /* Device and screen back on */
David Millerea770782011-01-11 23:51:26 +0000727 svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80);
David Millerd907ec02011-01-11 23:51:08 +0000728 svga_wseq_mask(par->state.vgabase, 0x01, 0x00, 0x20);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800729
730 return 0;
731}
732
733/* Set a colour register */
734
735static int s3fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
736 u_int transp, struct fb_info *fb)
737{
738 switch (fb->var.bits_per_pixel) {
739 case 0:
740 case 4:
741 if (regno >= 16)
742 return -EINVAL;
743
744 if ((fb->var.bits_per_pixel == 4) &&
745 (fb->var.nonstd == 0)) {
746 outb(0xF0, VGA_PEL_MSK);
747 outb(regno*16, VGA_PEL_IW);
748 } else {
749 outb(0x0F, VGA_PEL_MSK);
750 outb(regno, VGA_PEL_IW);
751 }
752 outb(red >> 10, VGA_PEL_D);
753 outb(green >> 10, VGA_PEL_D);
754 outb(blue >> 10, VGA_PEL_D);
755 break;
756 case 8:
757 if (regno >= 256)
758 return -EINVAL;
759
760 outb(0xFF, VGA_PEL_MSK);
761 outb(regno, VGA_PEL_IW);
762 outb(red >> 10, VGA_PEL_D);
763 outb(green >> 10, VGA_PEL_D);
764 outb(blue >> 10, VGA_PEL_D);
765 break;
766 case 16:
767 if (regno >= 16)
Ondrej Zajicek249bdbb2007-05-08 00:39:24 -0700768 return 0;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800769
770 if (fb->var.green.length == 5)
771 ((u32*)fb->pseudo_palette)[regno] = ((red & 0xF800) >> 1) |
772 ((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11);
773 else if (fb->var.green.length == 6)
774 ((u32*)fb->pseudo_palette)[regno] = (red & 0xF800) |
775 ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
776 else return -EINVAL;
777 break;
778 case 24:
779 case 32:
780 if (regno >= 16)
Ondrej Zajicek249bdbb2007-05-08 00:39:24 -0700781 return 0;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800782
Ondrej Zajicek249bdbb2007-05-08 00:39:24 -0700783 ((u32*)fb->pseudo_palette)[regno] = ((red & 0xFF00) << 8) |
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800784 (green & 0xFF00) | ((blue & 0xFF00) >> 8);
785 break;
786 default:
787 return -EINVAL;
788 }
789
790 return 0;
791}
792
793
794/* Set the display blanking state */
795
796static int s3fb_blank(int blank_mode, struct fb_info *info)
797{
David Millerd907ec02011-01-11 23:51:08 +0000798 struct s3fb_info *par = info->par;
799
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800800 switch (blank_mode) {
801 case FB_BLANK_UNBLANK:
802 pr_debug("fb%d: unblank\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000803 svga_wcrt_mask(par->state.vgabase, 0x56, 0x00, 0x06);
David Millerd907ec02011-01-11 23:51:08 +0000804 svga_wseq_mask(par->state.vgabase, 0x01, 0x00, 0x20);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800805 break;
806 case FB_BLANK_NORMAL:
807 pr_debug("fb%d: blank\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000808 svga_wcrt_mask(par->state.vgabase, 0x56, 0x00, 0x06);
David Millerd907ec02011-01-11 23:51:08 +0000809 svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800810 break;
811 case FB_BLANK_HSYNC_SUSPEND:
812 pr_debug("fb%d: hsync\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000813 svga_wcrt_mask(par->state.vgabase, 0x56, 0x02, 0x06);
David Millerd907ec02011-01-11 23:51:08 +0000814 svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800815 break;
816 case FB_BLANK_VSYNC_SUSPEND:
817 pr_debug("fb%d: vsync\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000818 svga_wcrt_mask(par->state.vgabase, 0x56, 0x04, 0x06);
David Millerd907ec02011-01-11 23:51:08 +0000819 svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800820 break;
821 case FB_BLANK_POWERDOWN:
822 pr_debug("fb%d: sync down\n", info->node);
David Millerea770782011-01-11 23:51:26 +0000823 svga_wcrt_mask(par->state.vgabase, 0x56, 0x06, 0x06);
David Millerd907ec02011-01-11 23:51:08 +0000824 svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800825 break;
826 }
827
828 return 0;
829}
830
831
832/* Pan the display */
833
David Miller21da3862011-01-11 23:49:34 +0000834static int s3fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
835{
836 struct s3fb_info *par = info->par;
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800837 unsigned int offset;
838
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800839 /* Calculate the offset */
840 if (var->bits_per_pixel == 0) {
841 offset = (var->yoffset / 16) * (var->xres_virtual / 2) + (var->xoffset / 2);
842 offset = offset >> 2;
843 } else {
844 offset = (var->yoffset * info->fix.line_length) +
845 (var->xoffset * var->bits_per_pixel / 8);
846 offset = offset >> 2;
847 }
848
849 /* Set the offset */
David Miller21da3862011-01-11 23:49:34 +0000850 svga_wcrt_multi(par->state.vgabase, s3_start_address_regs, offset);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800851
852 return 0;
853}
854
855/* ------------------------------------------------------------------------- */
856
857/* Frame buffer operations */
858
859static struct fb_ops s3fb_ops = {
860 .owner = THIS_MODULE,
861 .fb_open = s3fb_open,
862 .fb_release = s3fb_release,
863 .fb_check_var = s3fb_check_var,
864 .fb_set_par = s3fb_set_par,
865 .fb_setcolreg = s3fb_setcolreg,
866 .fb_blank = s3fb_blank,
867 .fb_pan_display = s3fb_pan_display,
868 .fb_fillrect = s3fb_fillrect,
869 .fb_copyarea = cfb_copyarea,
870 .fb_imageblit = s3fb_imageblit,
Antonino A. Daplas5a87ede2007-05-09 02:35:32 -0700871 .fb_get_caps = svga_get_caps,
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800872};
873
874/* ------------------------------------------------------------------------- */
875
David Millerf8645932011-01-11 23:52:57 +0000876static int __devinit s3_identification(struct s3fb_info *par)
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800877{
David Millerf8645932011-01-11 23:52:57 +0000878 int chip = par->chip;
879
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800880 if (chip == CHIP_XXX_TRIO) {
David Millerf8645932011-01-11 23:52:57 +0000881 u8 cr30 = vga_rcrt(par->state.vgabase, 0x30);
882 u8 cr2e = vga_rcrt(par->state.vgabase, 0x2e);
883 u8 cr2f = vga_rcrt(par->state.vgabase, 0x2f);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800884
885 if ((cr30 == 0xE0) || (cr30 == 0xE1)) {
886 if (cr2e == 0x10)
887 return CHIP_732_TRIO32;
888 if (cr2e == 0x11) {
889 if (! (cr2f & 0x40))
890 return CHIP_764_TRIO64;
891 else
892 return CHIP_765_TRIO64VP;
893 }
894 }
895 }
896
897 if (chip == CHIP_XXX_TRIO64V2_DXGX) {
David Millerf8645932011-01-11 23:52:57 +0000898 u8 cr6f = vga_rcrt(par->state.vgabase, 0x6f);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800899
900 if (! (cr6f & 0x01))
901 return CHIP_775_TRIO64V2_DX;
902 else
903 return CHIP_785_TRIO64V2_GX;
904 }
905
906 if (chip == CHIP_XXX_VIRGE_DXGX) {
David Millerf8645932011-01-11 23:52:57 +0000907 u8 cr6f = vga_rcrt(par->state.vgabase, 0x6f);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800908
909 if (! (cr6f & 0x01))
910 return CHIP_375_VIRGE_DX;
911 else
912 return CHIP_385_VIRGE_GX;
913 }
914
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700915 if (chip == CHIP_36X_TRIO3D_1X_2X) {
David Millerf8645932011-01-11 23:52:57 +0000916 switch (vga_rcrt(par->state.vgabase, 0x2f)) {
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700917 case 0x00:
918 return CHIP_360_TRIO3D_1X;
919 case 0x01:
920 return CHIP_362_TRIO3D_2X;
921 case 0x02:
922 return CHIP_368_TRIO3D_2X;
923 }
924 }
925
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800926 return CHIP_UNKNOWN;
927}
928
929
930/* PCI probe */
931
932static int __devinit s3_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
933{
934 struct fb_info *info;
935 struct s3fb_info *par;
936 int rc;
937 u8 regval, cr38, cr39;
938
939 /* Ignore secondary VGA device because there is no VGA arbitration */
940 if (! svga_primary_device(dev)) {
941 dev_info(&(dev->dev), "ignoring secondary device\n");
942 return -ENODEV;
943 }
944
945 /* Allocate and fill driver data structure */
Ondrej Zajicek20e061f2008-04-28 02:15:18 -0700946 info = framebuffer_alloc(sizeof(struct s3fb_info), &(dev->dev));
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800947 if (!info) {
948 dev_err(&(dev->dev), "cannot allocate memory\n");
949 return -ENOMEM;
950 }
951
952 par = info->par;
953 mutex_init(&par->open_lock);
954
955 info->flags = FBINFO_PARTIAL_PAN_OK | FBINFO_HWACCEL_YPAN;
956 info->fbops = &s3fb_ops;
957
958 /* Prepare PCI device */
959 rc = pci_enable_device(dev);
960 if (rc < 0) {
Ondrej Zajicek594a8812008-08-05 13:01:06 -0700961 dev_err(info->device, "cannot enable PCI device\n");
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800962 goto err_enable_device;
963 }
964
965 rc = pci_request_regions(dev, "s3fb");
966 if (rc < 0) {
Ondrej Zajicek594a8812008-08-05 13:01:06 -0700967 dev_err(info->device, "cannot reserve framebuffer region\n");
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800968 goto err_request_regions;
969 }
970
971
972 info->fix.smem_start = pci_resource_start(dev, 0);
973 info->fix.smem_len = pci_resource_len(dev, 0);
974
975 /* Map physical IO memory address into kernel space */
976 info->screen_base = pci_iomap(dev, 0, 0);
977 if (! info->screen_base) {
978 rc = -ENOMEM;
Ondrej Zajicek594a8812008-08-05 13:01:06 -0700979 dev_err(info->device, "iomap for framebuffer failed\n");
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800980 goto err_iomap;
981 }
982
983 /* Unlock regs */
David Millerf8645932011-01-11 23:52:57 +0000984 cr38 = vga_rcrt(par->state.vgabase, 0x38);
985 cr39 = vga_rcrt(par->state.vgabase, 0x39);
986 vga_wseq(par->state.vgabase, 0x08, 0x06);
987 vga_wcrt(par->state.vgabase, 0x38, 0x48);
988 vga_wcrt(par->state.vgabase, 0x39, 0xA5);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800989
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700990 /* Identify chip type */
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800991 par->chip = id->driver_data & CHIP_MASK;
David Millerf8645932011-01-11 23:52:57 +0000992 par->rev = vga_rcrt(par->state.vgabase, 0x2f);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800993 if (par->chip & CHIP_UNDECIDED_FLAG)
David Millerf8645932011-01-11 23:52:57 +0000994 par->chip = s3_identification(par);
Ondrej Zajiceka2684222007-02-12 00:54:49 -0800995
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700996 /* Find how many physical memory there is on card */
997 /* 0x36 register is accessible even if other registers are locked */
David Millerf8645932011-01-11 23:52:57 +0000998 regval = vga_rcrt(par->state.vgabase, 0x36);
Ondrej Zary9966c4f2010-05-26 14:42:27 -0700999 if (par->chip == CHIP_360_TRIO3D_1X ||
1000 par->chip == CHIP_362_TRIO3D_2X ||
1001 par->chip == CHIP_368_TRIO3D_2X) {
1002 switch ((regval & 0xE0) >> 5) {
1003 case 0: /* 8MB -- only 4MB usable for display */
1004 case 1: /* 4MB with 32-bit bus */
1005 case 2: /* 4MB */
1006 info->screen_size = 4 << 20;
1007 break;
1008 case 6: /* 2MB */
1009 info->screen_size = 2 << 20;
1010 break;
1011 }
1012 } else
1013 info->screen_size = s3_memsizes[regval >> 5] << 10;
1014 info->fix.smem_len = info->screen_size;
1015
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001016 /* Find MCLK frequency */
David Millerf8645932011-01-11 23:52:57 +00001017 regval = vga_rseq(par->state.vgabase, 0x10);
1018 par->mclk_freq = ((vga_rseq(par->state.vgabase, 0x11) + 2) * 14318) / ((regval & 0x1F) + 2);
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001019 par->mclk_freq = par->mclk_freq >> (regval >> 5);
1020
1021 /* Restore locks */
David Millerf8645932011-01-11 23:52:57 +00001022 vga_wcrt(par->state.vgabase, 0x38, cr38);
1023 vga_wcrt(par->state.vgabase, 0x39, cr39);
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001024
1025 strcpy(info->fix.id, s3_names [par->chip]);
1026 info->fix.mmio_start = 0;
1027 info->fix.mmio_len = 0;
1028 info->fix.type = FB_TYPE_PACKED_PIXELS;
1029 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
1030 info->fix.ypanstep = 0;
1031 info->fix.accel = FB_ACCEL_NONE;
1032 info->pseudo_palette = (void*) (par->pseudo_palette);
1033
1034 /* Prepare startup mode */
Krzysztof Helta8140542008-04-28 02:15:09 -07001035 rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001036 if (! ((rc == 1) || (rc == 2))) {
1037 rc = -EINVAL;
Ondrej Zajicek594a8812008-08-05 13:01:06 -07001038 dev_err(info->device, "mode %s not found\n", mode_option);
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001039 goto err_find_mode;
1040 }
1041
1042 rc = fb_alloc_cmap(&info->cmap, 256, 0);
1043 if (rc < 0) {
Ondrej Zajicek594a8812008-08-05 13:01:06 -07001044 dev_err(info->device, "cannot allocate colormap\n");
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001045 goto err_alloc_cmap;
1046 }
1047
1048 rc = register_framebuffer(info);
1049 if (rc < 0) {
Ondrej Zajicek594a8812008-08-05 13:01:06 -07001050 dev_err(info->device, "cannot register framebuffer\n");
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001051 goto err_reg_fb;
1052 }
1053
1054 printk(KERN_INFO "fb%d: %s on %s, %d MB RAM, %d MHz MCLK\n", info->node, info->fix.id,
1055 pci_name(dev), info->fix.smem_len >> 20, (par->mclk_freq + 500) / 1000);
1056
1057 if (par->chip == CHIP_UNKNOWN)
1058 printk(KERN_INFO "fb%d: unknown chip, CR2D=%x, CR2E=%x, CRT2F=%x, CRT30=%x\n",
David Millerf8645932011-01-11 23:52:57 +00001059 info->node, vga_rcrt(par->state.vgabase, 0x2d), vga_rcrt(par->state.vgabase, 0x2e),
1060 vga_rcrt(par->state.vgabase, 0x2f), vga_rcrt(par->state.vgabase, 0x30));
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001061
1062 /* Record a reference to the driver data */
1063 pci_set_drvdata(dev, info);
1064
1065#ifdef CONFIG_MTRR
1066 if (mtrr) {
1067 par->mtrr_reg = -1;
1068 par->mtrr_reg = mtrr_add(info->fix.smem_start, info->fix.smem_len, MTRR_TYPE_WRCOMB, 1);
1069 }
1070#endif
1071
1072 return 0;
1073
1074 /* Error handling */
1075err_reg_fb:
1076 fb_dealloc_cmap(&info->cmap);
1077err_alloc_cmap:
1078err_find_mode:
1079 pci_iounmap(dev, info->screen_base);
1080err_iomap:
1081 pci_release_regions(dev);
1082err_request_regions:
1083/* pci_disable_device(dev); */
1084err_enable_device:
1085 framebuffer_release(info);
1086 return rc;
1087}
1088
1089
1090/* PCI remove */
1091
1092static void __devexit s3_pci_remove(struct pci_dev *dev)
1093{
1094 struct fb_info *info = pci_get_drvdata(dev);
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001095
1096 if (info) {
1097
1098#ifdef CONFIG_MTRR
Adrian Bunk47ebea82007-03-22 00:11:16 -08001099 struct s3fb_info *par = info->par;
1100
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001101 if (par->mtrr_reg >= 0) {
1102 mtrr_del(par->mtrr_reg, 0, 0);
1103 par->mtrr_reg = -1;
1104 }
1105#endif
1106
1107 unregister_framebuffer(info);
1108 fb_dealloc_cmap(&info->cmap);
1109
1110 pci_iounmap(dev, info->screen_base);
1111 pci_release_regions(dev);
1112/* pci_disable_device(dev); */
1113
1114 pci_set_drvdata(dev, NULL);
1115 framebuffer_release(info);
1116 }
1117}
1118
1119/* PCI suspend */
1120
1121static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1122{
1123 struct fb_info *info = pci_get_drvdata(dev);
1124 struct s3fb_info *par = info->par;
1125
Ondrej Zajicek594a8812008-08-05 13:01:06 -07001126 dev_info(info->device, "suspend\n");
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001127
Torben Hohnac751ef2011-01-25 15:07:35 -08001128 console_lock();
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001129 mutex_lock(&(par->open_lock));
1130
1131 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
1132 mutex_unlock(&(par->open_lock));
Torben Hohnac751ef2011-01-25 15:07:35 -08001133 console_unlock();
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001134 return 0;
1135 }
1136
1137 fb_set_suspend(info, 1);
1138
1139 pci_save_state(dev);
1140 pci_disable_device(dev);
1141 pci_set_power_state(dev, pci_choose_state(dev, state));
1142
1143 mutex_unlock(&(par->open_lock));
Torben Hohnac751ef2011-01-25 15:07:35 -08001144 console_unlock();
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001145
1146 return 0;
1147}
1148
1149
1150/* PCI resume */
1151
1152static int s3_pci_resume(struct pci_dev* dev)
1153{
1154 struct fb_info *info = pci_get_drvdata(dev);
1155 struct s3fb_info *par = info->par;
Randy Dunlap6314db42007-05-08 00:38:11 -07001156 int err;
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001157
Ondrej Zajicek594a8812008-08-05 13:01:06 -07001158 dev_info(info->device, "resume\n");
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001159
Torben Hohnac751ef2011-01-25 15:07:35 -08001160 console_lock();
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001161 mutex_lock(&(par->open_lock));
1162
1163 if (par->ref_count == 0) {
1164 mutex_unlock(&(par->open_lock));
Torben Hohnac751ef2011-01-25 15:07:35 -08001165 console_unlock();
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001166 return 0;
1167 }
1168
1169 pci_set_power_state(dev, PCI_D0);
1170 pci_restore_state(dev);
Randy Dunlap6314db42007-05-08 00:38:11 -07001171 err = pci_enable_device(dev);
1172 if (err) {
1173 mutex_unlock(&(par->open_lock));
Torben Hohnac751ef2011-01-25 15:07:35 -08001174 console_unlock();
Ondrej Zajicek594a8812008-08-05 13:01:06 -07001175 dev_err(info->device, "error %d enabling device for resume\n", err);
Randy Dunlap6314db42007-05-08 00:38:11 -07001176 return err;
1177 }
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001178 pci_set_master(dev);
1179
1180 s3fb_set_par(info);
1181 fb_set_suspend(info, 0);
1182
1183 mutex_unlock(&(par->open_lock));
Torben Hohnac751ef2011-01-25 15:07:35 -08001184 console_unlock();
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001185
1186 return 0;
1187}
1188
1189
1190/* List of boards that we are trying to support */
1191
1192static struct pci_device_id s3_devices[] __devinitdata = {
1193 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8810), .driver_data = CHIP_XXX_TRIO},
1194 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8811), .driver_data = CHIP_XXX_TRIO},
1195 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8812), .driver_data = CHIP_M65_AURORA64VP},
1196 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8814), .driver_data = CHIP_767_TRIO64UVP},
1197 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8901), .driver_data = CHIP_XXX_TRIO64V2_DXGX},
1198 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8902), .driver_data = CHIP_551_PLATO_PX},
1199
1200 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x5631), .driver_data = CHIP_325_VIRGE},
1201 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x883D), .driver_data = CHIP_988_VIRGE_VX},
1202 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8A01), .driver_data = CHIP_XXX_VIRGE_DXGX},
1203 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8A10), .driver_data = CHIP_356_VIRGE_GX2},
1204 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8A11), .driver_data = CHIP_357_VIRGE_GX2P},
1205 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8A12), .driver_data = CHIP_359_VIRGE_GX2P},
Ondrej Zary9966c4f2010-05-26 14:42:27 -07001206 {PCI_DEVICE(PCI_VENDOR_ID_S3, 0x8A13), .driver_data = CHIP_36X_TRIO3D_1X_2X},
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001207
1208 {0, 0, 0, 0, 0, 0, 0}
1209};
1210
1211
1212MODULE_DEVICE_TABLE(pci, s3_devices);
1213
1214static struct pci_driver s3fb_pci_driver = {
1215 .name = "s3fb",
1216 .id_table = s3_devices,
1217 .probe = s3_pci_probe,
1218 .remove = __devexit_p(s3_pci_remove),
1219 .suspend = s3_pci_suspend,
1220 .resume = s3_pci_resume,
1221};
1222
1223/* Parse user speficied options */
1224
1225#ifndef MODULE
1226static int __init s3fb_setup(char *options)
1227{
1228 char *opt;
1229
1230 if (!options || !*options)
1231 return 0;
1232
1233 while ((opt = strsep(&options, ",")) != NULL) {
1234
1235 if (!*opt)
1236 continue;
1237#ifdef CONFIG_MTRR
Ondrej Zajicek62fa4dc2007-02-22 17:00:41 +01001238 else if (!strncmp(opt, "mtrr:", 5))
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001239 mtrr = simple_strtoul(opt + 5, NULL, 0);
1240#endif
Ondrej Zajicek62fa4dc2007-02-22 17:00:41 +01001241 else if (!strncmp(opt, "fasttext:", 9))
1242 fasttext = simple_strtoul(opt + 9, NULL, 0);
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001243 else
Krzysztof Helta8140542008-04-28 02:15:09 -07001244 mode_option = opt;
Ondrej Zajiceka2684222007-02-12 00:54:49 -08001245 }
1246
1247 return 0;
1248}
1249#endif
1250
1251/* Cleanup */
1252
1253static void __exit s3fb_cleanup(void)
1254{
1255 pr_debug("s3fb: cleaning up\n");
1256 pci_unregister_driver(&s3fb_pci_driver);
1257}
1258
1259/* Driver Initialisation */
1260
1261static int __init s3fb_init(void)
1262{
1263
1264#ifndef MODULE
1265 char *option = NULL;
1266
1267 if (fb_get_options("s3fb", &option))
1268 return -ENODEV;
1269 s3fb_setup(option);
1270#endif
1271
1272 pr_debug("s3fb: initializing\n");
1273 return pci_register_driver(&s3fb_pci_driver);
1274}
1275
1276/* ------------------------------------------------------------------------- */
1277
1278/* Modularization */
1279
1280module_init(s3fb_init);
1281module_exit(s3fb_cleanup);