170
182
/* ------------------------------------------------------------------------- */
184
#ifdef CONFIG_FB_S3_DDC
186
#define DDC_REG 0xaa /* Trio 3D/1X/2X */
187
#define DDC_MMIO_REG 0xff20 /* all other chips */
188
#define DDC_SCL_OUT (1 << 0)
189
#define DDC_SDA_OUT (1 << 1)
190
#define DDC_SCL_IN (1 << 2)
191
#define DDC_SDA_IN (1 << 3)
192
#define DDC_DRIVE_EN (1 << 4)
194
static bool s3fb_ddc_needs_mmio(int chip)
196
return !(chip == CHIP_360_TRIO3D_1X ||
197
chip == CHIP_362_TRIO3D_2X ||
198
chip == CHIP_368_TRIO3D_2X);
201
static u8 s3fb_ddc_read(struct s3fb_info *par)
203
if (s3fb_ddc_needs_mmio(par->chip))
204
return readb(par->mmio + DDC_MMIO_REG);
206
return vga_rcrt(par->state.vgabase, DDC_REG);
209
static void s3fb_ddc_write(struct s3fb_info *par, u8 val)
211
if (s3fb_ddc_needs_mmio(par->chip))
212
writeb(val, par->mmio + DDC_MMIO_REG);
214
vga_wcrt(par->state.vgabase, DDC_REG, val);
217
static void s3fb_ddc_setscl(void *data, int val)
219
struct s3fb_info *par = data;
222
reg = s3fb_ddc_read(par) | DDC_DRIVE_EN;
227
s3fb_ddc_write(par, reg);
230
static void s3fb_ddc_setsda(void *data, int val)
232
struct s3fb_info *par = data;
235
reg = s3fb_ddc_read(par) | DDC_DRIVE_EN;
240
s3fb_ddc_write(par, reg);
243
static int s3fb_ddc_getscl(void *data)
245
struct s3fb_info *par = data;
247
return !!(s3fb_ddc_read(par) & DDC_SCL_IN);
250
static int s3fb_ddc_getsda(void *data)
252
struct s3fb_info *par = data;
254
return !!(s3fb_ddc_read(par) & DDC_SDA_IN);
257
static int __devinit s3fb_setup_ddc_bus(struct fb_info *info)
259
struct s3fb_info *par = info->par;
261
strlcpy(par->ddc_adapter.name, info->fix.id,
262
sizeof(par->ddc_adapter.name));
263
par->ddc_adapter.owner = THIS_MODULE;
264
par->ddc_adapter.class = I2C_CLASS_DDC;
265
par->ddc_adapter.algo_data = &par->ddc_algo;
266
par->ddc_adapter.dev.parent = info->device;
267
par->ddc_algo.setsda = s3fb_ddc_setsda;
268
par->ddc_algo.setscl = s3fb_ddc_setscl;
269
par->ddc_algo.getsda = s3fb_ddc_getsda;
270
par->ddc_algo.getscl = s3fb_ddc_getscl;
271
par->ddc_algo.udelay = 10;
272
par->ddc_algo.timeout = 20;
273
par->ddc_algo.data = par;
275
i2c_set_adapdata(&par->ddc_adapter, par);
278
* some Virge cards have external MUX to switch chip I2C bus between
279
* DDC and extension pins - switch it do DDC
281
/* vga_wseq(par->state.vgabase, 0x08, 0x06); - not needed, already unlocked */
282
if (par->chip == CHIP_357_VIRGE_GX2 ||
283
par->chip == CHIP_359_VIRGE_GX2P)
284
svga_wseq_mask(par->state.vgabase, 0x0d, 0x01, 0x03);
286
svga_wseq_mask(par->state.vgabase, 0x0d, 0x00, 0x03);
287
/* some Virge need this or the DDC is ignored */
288
svga_wcrt_mask(par->state.vgabase, 0x5c, 0x03, 0x03);
290
return i2c_bit_add_bus(&par->ddc_adapter);
292
#endif /* CONFIG_FB_S3_DDC */
295
/* ------------------------------------------------------------------------- */
172
297
/* Set font in S3 fast text mode */
174
299
static void s3fb_settile_fast(struct fb_info *info, struct fb_tilemap *map)
1110
1236
info->fix.ypanstep = 0;
1111
1237
info->fix.accel = FB_ACCEL_NONE;
1112
1238
info->pseudo_palette = (void*) (par->pseudo_palette);
1239
info->var.bits_per_pixel = 8;
1241
#ifdef CONFIG_FB_S3_DDC
1242
/* Enable MMIO if needed */
1243
if (s3fb_ddc_needs_mmio(par->chip)) {
1244
par->mmio = ioremap(info->fix.smem_start + MMIO_OFFSET, MMIO_SIZE);
1246
svga_wcrt_mask(par->state.vgabase, 0x53, 0x08, 0x08); /* enable MMIO */
1248
dev_err(info->device, "unable to map MMIO at 0x%lx, disabling DDC",
1249
info->fix.smem_start + MMIO_OFFSET);
1251
if (!s3fb_ddc_needs_mmio(par->chip) || par->mmio)
1252
if (s3fb_setup_ddc_bus(info) == 0) {
1253
u8 *edid = fb_ddc_read(&par->ddc_adapter);
1254
par->ddc_registered = true;
1256
fb_edid_to_monspecs(edid, &info->monspecs);
1258
if (!info->monspecs.modedb)
1259
dev_err(info->device, "error getting mode database\n");
1261
const struct fb_videomode *m;
1263
fb_videomode_to_modelist(info->monspecs.modedb,
1264
info->monspecs.modedb_len,
1266
m = fb_find_best_display(&info->monspecs, &info->modelist);
1268
fb_videomode_to_var(&info->var, m);
1269
/* fill all other info->var's fields */
1270
if (s3fb_check_var(&info->var, info) == 0)
1277
if (!mode_option && !found)
1278
mode_option = "640x480-8@60";
1114
1280
/* Prepare startup mode */
1115
rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
1116
if (! ((rc == 1) || (rc == 2))) {
1118
dev_err(info->device, "mode %s not found\n", mode_option);
1282
rc = fb_find_mode(&info->var, info, mode_option,
1283
info->monspecs.modedb, info->monspecs.modedb_len,
1284
NULL, info->var.bits_per_pixel);
1285
if (!rc || rc == 4) {
1287
dev_err(info->device, "mode %s not found\n", mode_option);
1288
fb_destroy_modedb(info->monspecs.modedb);
1289
info->monspecs.modedb = NULL;
1294
fb_destroy_modedb(info->monspecs.modedb);
1295
info->monspecs.modedb = NULL;
1297
/* maximize virtual vertical size for fast scrolling */
1298
info->var.yres_virtual = info->fix.smem_len * 8 /
1299
(info->var.bits_per_pixel * info->var.xres_virtual);
1300
if (info->var.yres_virtual < info->var.yres) {
1301
dev_err(info->device, "virtual vertical size smaller than real\n");
1119
1302
goto err_find_mode;