/*-*- linux-c -*-
* linux/drivers/video/i810_dvt.c -- Intel 810 Discrete Video Timings (Intel)
*
* Copyright (C) 2001 Antonino Daplas<adaplas@pol.net>
* All Rights Reserved
*
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#include <linux/kernel.h>
#include "i810_regs.h"
#include "i810.h"
#include "i810_main.h"
struct mode_registers std_modes[] = {
/* 640x480 @ 60Hz */
{ 25000 , 0 x0013, 0 x0003, 0 x40, 0 x5F, 0 x4F, 0 x50, 0 x82, 0 x51, 0 x9D,
0 x0B, 0 x10, 0 x40, 0 xE9, 0 x0B, 0 xDF, 0 x50, 0 xE7, 0 x04, 0 x02,
0 x01, 0 x01, 0 x01, 0 x00, 0 x01, 0 x22002000, 0 x22004000, 0 x22006000,
0 x22002000, 0 x22004000, 0 x22006000, 0 xC0 },
/* 640x480 @ 70Hz */
{ 28000 , 0 x0053, 0 x0010, 0 x40, 0 x61, 0 x4F, 0 x4F, 0 x85, 0 x52, 0 x9A,
0 xF2, 0 x10, 0 x40, 0 xE0, 0 x03, 0 xDF, 0 x50, 0 xDF, 0 xF3, 0 x01,
0 x01, 0 x01, 0 x01, 0 x00, 0 x01, 0 x22002000, 0 x22004000, 0 x22005000,
0 x22002000, 0 x22004000, 0 x22005000, 0 xC0 },
/* 640x480 @ 72Hz */
{ 31000 , 0 x0013, 0 x0002, 0 x40, 0 x63, 0 x4F, 0 x4F, 0 x87, 0 x52, 0 x97,
0 x06, 0 x0F, 0 x40, 0 xE8, 0 x0B, 0 xDF, 0 x50, 0 xDF, 0 x07, 0 x02,
0 x01, 0 x01, 0 x01, 0 x00, 0 x01, 0 x22003000, 0 x22005000, 0 x22007000,
0 x22003000, 0 x22005000, 0 x22007000, 0 xC0 },
/* 640x480 @ 75Hz */
{ 31000 , 0 x0013, 0 x0002, 0 x40, 0 x64, 0 x4F, 0 x4F, 0 x88, 0 x51, 0 x99,
0 xF2, 0 x10, 0 x40, 0 xE0, 0 x03, 0 xDF, 0 x50, 0 xDF, 0 xF3, 0 x01,
0 x01, 0 x01, 0 x01, 0 x00, 0 x01, 0 x22003000, 0 x22005000, 0 x22007000,
0 x22003000, 0 x22005000, 0 x22007000, 0 xC0 },
/* 640x480 @ 85Hz */
{ 36000 , 0 x0010, 0 x0001, 0 x40, 0 x63, 0 x4F, 0 x4F, 0 x87, 0 x56, 0 x9D,
0 xFB, 0 x10, 0 x40, 0 xE0, 0 x03, 0 xDF, 0 x50, 0 xDF, 0 xFC, 0 x01,
0 x01, 0 x01, 0 x01, 0 x00, 0 x01, 0 x22003000, 0 x22005000, 0 x22107000,
0 x22003000, 0 x22005000, 0 x22107000, 0 xC0 },
/* 800x600 @ 56Hz */
{ 36000 , 0 x0010, 0 x0001, 0 x40, 0 x7B, 0 x63, 0 x63, 0 x9F, 0 x66, 0 x8F,
0 x6F, 0 x10, 0 x40, 0 x58, 0 x0A, 0 x57, 0 xC8, 0 x57, 0 x70, 0 x02,
0 x02, 0 x02, 0 x02, 0 x00, 0 x01, 0 x22003000, 0 x22005000, 0 x22107000,
0 x22003000, 0 x22005000, 0 x22107000, 0 x00 },
/* 800x600 @ 60Hz */
{ 40000 , 0 x0008, 0 x0001, 0 x30, 0 x7F, 0 x63, 0 x63, 0 x83, 0 x68, 0 x18,
0 x72, 0 x10, 0 x40, 0 x58, 0 x0C, 0 x57, 0 xC8, 0 x57, 0 x73, 0 x02,
0 x02, 0 x02, 0 x02, 0 x00, 0 x00, 0 x22003000, 0 x22006000, 0 x22108000,
0 x22003000, 0 x22006000, 0 x22108000, 0 x00 },
/* 800x600 @ 70Hz */
{ 45000 , 0 x0054, 0 x0015, 0 x30, 0 x7D, 0 x63, 0 x63, 0 x81, 0 x68, 0 x12,
0 x6f, 0 x10, 0 x40, 0 x58, 0 x0b, 0 x57, 0 x64, 0 x57, 0 x70, 0 x02,
0 x02, 0 x02, 0 x02, 0 x00, 0 x00, 0 x22004000, 0 x22007000, 0 x2210A000,
0 x22004000, 0 x22007000, 0 x2210A000, 0 x00 },
/* 800x600 @ 72Hz */
{ 50000 , 0 x0017, 0 x0004, 0 x30, 0 x7D, 0 x63, 0 x63, 0 x81, 0 x6A, 0 x19,
0 x98, 0 x10, 0 x40, 0 x7C, 0 x02, 0 x57, 0 xC8, 0 x57, 0 x99, 0 x02,
0 x02, 0 x02, 0 x02, 0 x00, 0 x00, 0 x22004000, 0 x22007000, 0 x2210A000,
0 x22004000, 0 x22007000, 0 x2210A000, 0 x00 },
/* 800x600 @ 75Hz */
{ 49000 , 0 x001F, 0 x0006, 0 x30, 0 x7F, 0 x63, 0 x63, 0 x83, 0 x65, 0 x0F,
0 x6F, 0 x10, 0 x40, 0 x58, 0 x0B, 0 x57, 0 xC8, 0 x57, 0 x70, 0 x02,
0 x02, 0 x02, 0 x02, 0 x00, 0 x00, 0 x22004000, 0 x22007000, 0 x2210B000,
0 x22004000, 0 x22007000, 0 x2210B000, 0 x00 },
/* 800x600 @ 85Hz */
{ 56000 , 0 x0049, 0 x000E, 0 x30, 0 x7E, 0 x63, 0 x63, 0 x82, 0 x67, 0 x0F,
0 x75, 0 x10, 0 x40, 0 x58, 0 x0B, 0 x57, 0 xC8, 0 x57, 0 x76, 0 x02,
0 x02, 0 x02, 0 x02, 0 x00, 0 x00, 0 x22004000, 0 x22108000, 0 x2210b000,
0 x22004000, 0 x22108000, 0 x2210b000, 0 x00 },
/* 1024x768 @ 60Hz */
{ 65000 , 0 x003F, 0 x000A, 0 x30, 0 xA3, 0 x7F, 0 x7F, 0 x87, 0 x83, 0 x94,
0 x24, 0 x10, 0 x40, 0 x02, 0 x08, 0 xFF, 0 x80, 0 xFF, 0 x25, 0 x03,
0 x02, 0 x03, 0 x02, 0 x00, 0 x00, 0 x22005000, 0 x22109000, 0 x2220D000,
0 x22005000, 0 x22109000, 0 x2220D000, 0 xC0 },
/* 1024x768 @ 70Hz */
{ 75000 , 0 x0017, 0 x0002, 0 x30, 0 xA1, 0 x7F, 0 x7F, 0 x85, 0 x82, 0 x93,
0 x24, 0 x10, 0 x40, 0 x02, 0 x08, 0 xFF, 0 x80, 0 xFF, 0 x25, 0 x03,
0 x02, 0 x03, 0 x02, 0 x00, 0 x00, 0 x22005000, 0 x2210A000, 0 x2220F000,
0 x22005000, 0 x2210A000, 0 x2220F000, 0 xC0 },
/* 1024x768 @ 75Hz */
{ 78000 , 0 x0050, 0 x0017, 0 x20, 0 x9F, 0 x7F, 0 x7F, 0 x83, 0 x81, 0 x8D,
0 x1E, 0 x10, 0 x40, 0 x00, 0 x03, 0 xFF, 0 x80, 0 xFF, 0 x1F, 0 x03,
0 x02, 0 x03, 0 x02, 0 x00, 0 x00, 0 x22006000, 0 x2210B000, 0 x22210000,
0 x22006000, 0 x2210B000, 0 x22210000, 0 x00 },
/* 1024x768 @ 85Hz */
{ 94000 , 0 x003D, 0 x000E, 0 x20, 0 xA7, 0 x7F, 0 x7F, 0 x8B, 0 x85, 0 x91,
0 x26, 0 x10, 0 x40, 0 x00, 0 x03, 0 xFF, 0 x80, 0 xFF, 0 x27, 0 x03,
0 x02, 0 x03, 0 x02, 0 x00, 0 x00, 0 x22007000, 0 x2220E000, 0 x22212000,
0 x22007000, 0 x2220E000, 0 x22212000, 0 x00 },
/* 1152x864 @ 60Hz */
{ 80000 , 0 x0008, 0 x0001, 0 x20, 0 xB3, 0 x8F, 0 x8F, 0 x97, 0 x93, 0 x9f,
0 x87, 0 x10, 0 x40, 0 x60, 0 x03, 0 x5F, 0 x90, 0 x5f, 0 x88, 0 x03,
0 x03, 0 x03, 0 x03, 0 x00, 0 x00, 0 x2220C000, 0 x22210000, 0 x22415000,
0 x2220C000, 0 x22210000, 0 x22415000, 0 x00 },
/* 1152x864 @ 70Hz */
{ 96000 , 0 x000a, 0 x0001, 0 x20, 0 xbb, 0 x8F, 0 x8F, 0 x9f, 0 x98, 0 x87,
0 x82, 0 x10, 0 x40, 0 x60, 0 x03, 0 x5F, 0 x90, 0 x5F, 0 x83, 0 x03,
0 x03, 0 x03, 0 x03, 0 x00, 0 x00, 0 x22107000, 0 x22210000, 0 x22415000,
0 x22107000, 0 x22210000, 0 x22415000, 0 x00 },
/* 1152x864 @ 72Hz */
{ 99000 , 0 x001f, 0 x0006, 0 x20, 0 xbb, 0 x8F, 0 x8F, 0 x9f, 0 x98, 0 x87,
0 x83, 0 x10, 0 x40, 0 x60, 0 x03, 0 x5F, 0 x90, 0 x5F, 0 x84, 0 x03,
0 x03, 0 x03, 0 x03, 0 x00, 0 x00, 0 x22107000, 0 x22210000, 0 x22415000,
0 x22107000, 0 x22210000, 0 x22415000, 0 x00 },
/* 1152x864 @ 75Hz */
{ 108000 , 0 x0010, 0 x0002, 0 x20, 0 xC3, 0 x8F, 0 x8F, 0 x87, 0 x97, 0 x07,
0 x82, 0 x10, 0 x40, 0 x60, 0 x03, 0 x5F, 0 x90, 0 x5F, 0 x83, 0 x03,
0 x03, 0 x03, 0 x03, 0 x00, 0 x01, 0 x22107000, 0 x22210000, 0 x22415000,
0 x22107000, 0 x22210000, 0 x22415000, 0 x00 },
/* 1152x864 @ 85Hz */
{ 121000 , 0 x006D, 0 x0014, 0 x20, 0 xc0, 0 x8F, 0 x8F, 0 x84, 0 x97, 0 x07,
0 x93, 0 x10, 0 x40, 0 x60, 0 x03, 0 x5F, 0 x90, 0 x5F, 0 x94, 0 x03,
0 x03, 0 x03, 0 x03, 0 x00, 0 x01, 0 x2220C000, 0 x22210000, 0 x22415000,
0 x2220C000, 0 x22210000, 0 x22415000, 0 x0 },
/* 1280x960 @ 60Hz */
{ 108000 , 0 x0010, 0 x0002, 0 x20, 0 xDC, 0 x9F, 0 x9F, 0 x80, 0 xAB, 0 x99,
0 xE6, 0 x10, 0 x40, 0 xC0, 0 x03, 0 xBF, 0 xA0, 0 xBF, 0 xE7, 0 x03,
0 x03, 0 x03, 0 x03, 0 x00, 0 x01, 0 x2210A000, 0 x22210000, 0 x22415000,
0 x2210A000, 0 x22210000, 0 x22415000, 0 x00 },
/* 1280x960 @ 75Hz */
{ 129000 , 0 x0029, 0 x0006, 0 x20, 0 xD3, 0 x9F, 0 x9F, 0 x97, 0 xaa, 0 x1b,
0 xE8, 0 x10, 0 x40, 0 xC0, 0 x03, 0 xBF, 0 xA0, 0 xBF, 0 xE9, 0 x03,
0 x03, 0 x03, 0 x03, 0 x00, 0 x01, 0 x2210A000, 0 x22210000, 0 x2241B000,
0 x2210A000, 0 x22210000, 0 x2241B000, 0 x00 },
/* 1280x960 @ 85Hz */
{ 148000 , 0 x0042, 0 x0009, 0 x20, 0 xD3, 0 x9F, 0 x9F, 0 x97, 0 xA7, 0 x1B,
0 xF1, 0 x10, 0 x40, 0 xC0, 0 x03, 0 xBF, 0 xA0, 0 xBF, 0 xF2, 0 x03,
0 x03, 0 x03, 0 x03, 0 x00, 0 x01, 0 x2210A000, 0 x22220000, 0 x2241D000,
0 x2210A000, 0 x22220000, 0 x2241D000, 0 x00 },
/* 1600x1200 @ 60Hz */
{ 162000 , 0 x0019, 0 x0006, 0 x10, 0 x09, 0 xC7, 0 xC7, 0 x8D, 0 xcf, 0 x07,
0 xE0, 0 x10, 0 x40, 0 xB0, 0 x03, 0 xAF, 0 xC8, 0 xAF, 0 xE1, 0 x04,
0 x04, 0 x04, 0 x04, 0 x01, 0 x00, 0 x2210b000, 0 x22416000, 0 x44419000,
0 x2210b000, 0 x22416000, 0 x44419000, 0 x00 },
/* 1600x1200 @ 65 Hz */
{ 175000 , 0 x005d, 0 x0018, 0 x10, 0 x09, 0 xC7, 0 xC7, 0 x8D, 0 xcf, 0 x07,
0 xE0, 0 x10, 0 x40, 0 xB0, 0 x03, 0 xAF, 0 xC8, 0 xAF, 0 xE1, 0 x04,
0 x04, 0 x04, 0 x04, 0 x01, 0 x00, 0 x2210c000, 0 x22416000, 0 x44419000,
0 x2210c000, 0 x22416000, 0 x44419000, 0 x00 },
/* 1600x1200 @ 70 Hz */
{ 189000 , 0 x003D, 0 x000e, 0 x10, 0 x09, 0 xC7, 0 xC7, 0 x8d, 0 xcf, 0 x07,
0 xE0, 0 x10, 0 x40, 0 xb0, 0 x03, 0 xAF, 0 xC8, 0 xaf, 0 xE1, 0 x04,
0 x04, 0 x04, 0 x04, 0 x01, 0 x00, 0 x2220e000, 0 x22416000, 0 x44419000,
0 x2220e000, 0 x22416000, 0 x44419000, 0 x00 },
/* 1600x1200 @ 72 Hz */
{ 195000 , 0 x003f, 0 x000e, 0 x10, 0 x0b, 0 xC7, 0 xC7, 0 x8f, 0 xd5, 0 x0b,
0 xE1, 0 x10, 0 x40, 0 xb0, 0 x03, 0 xAF, 0 xC8, 0 xaf, 0 xe2, 0 x04, 0 x04,
0 x04, 0 x04, 0 x01, 0 x00, 0 x2220e000, 0 x22416000, 0 x44419000,
0 x2220e000, 0 x22416000, 0 x44419000, 0 x00 },
/* 1600x1200 @ 75 Hz */
{ 202000 , 0 x0024, 0 x0007, 0 x10, 0 x09, 0 xC7, 0 xC7, 0 x8d, 0 xcf, 0 x07,
0 xE0, 0 x10, 0 x40, 0 xb0, 0 x03, 0 xAF, 0 xC8, 0 xaf, 0 xE1, 0 x04, 0 x04,
0 x04, 0 x04, 0 x01, 0 x00, 0 x2220e000, 0 x22416000, 0 x44419000,
0 x2220e000, 0 x22416000, 0 x44419000, 0 x00 },
/* 1600x1200 @ 85 Hz */
{ 229000 , 0 x0029, 0 x0007, 0 x10, 0 x09, 0 xC7, 0 xC7, 0 x8d, 0 xcf, 0 x07,
0 xE0, 0 x10, 0 x40, 0 xb0, 0 x03, 0 xAF, 0 xC8, 0 xaf, 0 xE1, 0 x04, 0 x04,
0 x04, 0 x04, 0 x01, 0 x00, 0 x22210000, 0 x22416000, 0 x0,
0 x22210000, 0 x22416000, 0 x0, 0 x00 },
};
void round_off_xres(u32 *xres)
{
if (*xres <= 640 )
*xres = 640 ;
else if (*xres <= 800 )
*xres = 800 ;
else if (*xres <= 1024 )
*xres = 1024 ;
else if (*xres <= 1152 )
*xres = 1152 ;
else if (*xres <= 1280 )
*xres = 1280 ;
else
*xres = 1600 ;
}
inline void round_off_yres(u32 *xres, u32 *yres)
{
*yres = (*xres * 3 ) >> 2 ;
}
static int i810fb_find_best_mode(u32 xres, u32 yres, u32 pixclock)
{
u32 diff = 0 , diff_best = 0 xFFFFFFFF, i = 0 , i_best = 0 ;
u8 hfl = (u8) ((xres >> 3 ) - 1 );
for (i = 0 ; i < ARRAY_SIZE(std_modes); i++) {
if (std_modes[i].cr01 == hfl) {
if (std_modes[i].pixclock <= pixclock)
diff = pixclock - std_modes[i].pixclock;
if (diff < diff_best) {
i_best = i;
diff_best = diff;
}
}
}
return i_best;
}
void i810fb_encode_registers(const struct fb_var_screeninfo *var,
struct i810fb_par *par, u32 xres, u32 yres)
{
u32 i_best = i810fb_find_best_mode(xres, yres, par->regs.pixclock);
par->regs = std_modes[i_best];
/* overlay */
par->ovract = ((xres + var->right_margin + var->hsync_len +
var->left_margin - 32 ) | ((xres - 32 ) << 16 ));
}
void i810fb_fill_var_timings(struct fb_var_screeninfo *var)
{
u32 total, xres, yres;
u32 mode, pixclock;
xres = var->xres;
yres = var->yres;
pixclock = 1000000000 / var->pixclock;
mode = i810fb_find_best_mode(xres, yres, pixclock);
total = (std_modes[mode].cr00 | (std_modes[mode].cr35 & 1 ) << 8 ) + 3 ;
total <<= 3 ;
var->pixclock = 1000000000 / std_modes[mode].pixclock;
var->right_margin = (std_modes[mode].cr04 << 3 ) - xres;
var->hsync_len = ((std_modes[mode].cr05 & 0 x1F) -
(std_modes[mode].cr04 & 0 x1F)) << 3 ;
var->left_margin = (total - (xres + var->right_margin +
var->hsync_len));
var->sync = FB_SYNC_ON_GREEN;
if (~(std_modes[mode].msr & (1 << 6 )))
var->sync |= FB_SYNC_HOR_HIGH_ACT;
if (~(std_modes[mode].msr & (1 << 7 )))
var->sync |= FB_SYNC_VERT_HIGH_ACT;
total = (std_modes[mode].cr06 | (std_modes[mode].cr30 & 0 xF) << 8 ) + 2 ;
var->lower_margin = (std_modes[mode].cr10 |
(std_modes[mode].cr32 & 0 x0F) << 8 ) - yres;
var->vsync_len = (std_modes[mode].cr11 & 0 x0F) -
(var->lower_margin & 0 x0F);
var->upper_margin = total - (yres + var->lower_margin + var->vsync_len);
}
u32 i810_get_watermark(const struct fb_var_screeninfo *var,
struct i810fb_par *par)
{
struct mode_registers *params = &par->regs;
u32 wmark = 0 ;
if (par->mem_freq == 100 ) {
switch (var->bits_per_pixel) {
case 8 :
wmark = params->bpp8_100;
break ;
case 16 :
wmark = params->bpp16_100;
break ;
case 24 :
case 32 :
wmark = params->bpp24_100;
}
} else {
switch (var->bits_per_pixel) {
case 8 :
wmark = params->bpp8_133;
break ;
case 16 :
wmark = params->bpp16_133;
break ;
case 24 :
case 32 :
wmark = params->bpp24_133;
}
}
return wmark;
}
Messung V0.5 in Prozent C=95 H=92 G=93