?? smifb.c
字號(hào):
0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x36, 0x36,
0x00, 0x00, 0x00, 0x00,
},
{ /* Init_SRA0_SRAF */
0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xBF, 0xDF,
},
{ /* Init_GR00_GR08 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
0xFF,
},
{ /* Init_AR00_AR14 */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00,
},
{ /* Init_CR00_CR18 */
0x7F, 0x63, 0x63, 0x00, 0x68, 0x18, 0x72, 0xF0,
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x58, 0x0C, 0x57, 0x64, 0x40, 0x57, 0x00, 0xE3,
0xFF,
},
{ /* Init_CR30_CR4D */
0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x03, 0x20,
0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xBF, 0xFD,
0x7F, 0x63, 0x00, 0x69, 0x18, 0x72, 0x57, 0x00,
0x58, 0x0C, 0xE0, 0x20, 0x63, 0x57,
},
{ /* Init_CR90_CRA7 */
0x56, 0x4B, 0x5E, 0x55, 0x86, 0x9D, 0x8E, 0xAA,
0xDB, 0x2A, 0xDF, 0x33, 0x00, 0x00, 0x18, 0x00,
0x20, 0x1F, 0x1A, 0x19, 0x0F, 0x0F, 0x0F, 0x00,
},
},
};
static void smi_set_timing(struct smifb_info *sfb,struct par_info *hw)
{
int i=0,j=0;
u32 m_nScreenStride;
for (j=0;j < numVGAModes;j++) {
if (VGAMode[j].mmSizeX == hw->width &&
VGAMode[j].mmSizeY == hw->height &&
VGAMode[j].bpp == sfb->fb.var.bits_per_pixel &&
VGAMode[j].hz == hw->hz)
{
smi_mmiowb(0x0,0x3c6);
smi_seqw(0,0x1);
smi_mmiowb(VGAMode[j].Init_MISC,0x3c2);
for (i=0;i<SIZE_SR00_SR04;i++) // init SEQ register SR00 - SR04
{
smi_seqw(i,VGAMode[j].Init_SR00_SR04[i]);
}
for (i=0;i<SIZE_SR10_SR24;i++) // init SEQ register SR10 - SR24
{
smi_seqw(i+0x10,VGAMode[j].Init_SR10_SR24[i]);
}
for (i=0;i<SIZE_SR30_SR75;i++) // init SEQ register SR30 - SR75
{
if (((i+0x30) != 0x62) && ((i+0x30) != 0x6a) && ((i+0x30) != 0x6b))
smi_seqw(i+0x30,VGAMode[j].Init_SR30_SR75[i]);
}
for (i=0;i<SIZE_SR80_SR93;i++) // init SEQ register SR80 - SR93
{
smi_seqw(i+0x80,VGAMode[j].Init_SR80_SR93[i]);
}
for (i=0;i<SIZE_SRA0_SRAF;i++) // init SEQ register SRA0 - SRAF
{
smi_seqw(i+0xa0,VGAMode[j].Init_SRA0_SRAF[i]);
}
for (i=0;i<SIZE_GR00_GR08;i++) // init Graphic register GR00 - GR08
{
smi_grphw(i,VGAMode[j].Init_GR00_GR08[i]);
}
for (i=0;i<SIZE_AR00_AR14;i++) // init Attribute register AR00 - AR14
{
smi_attrw(i,VGAMode[j].Init_AR00_AR14[i]);
}
for (i=0;i<SIZE_CR00_CR18;i++) // init CRTC register CR00 - CR18
{
smi_crtcw(i,VGAMode[j].Init_CR00_CR18[i]);
}
for (i=0;i<SIZE_CR30_CR4D;i++) // init CRTC register CR30 - CR4D
{
smi_crtcw(i+0x30,VGAMode[j].Init_CR30_CR4D[i]);
}
for (i=0;i<SIZE_CR90_CRA7;i++) // init CRTC register CR90 - CRA7
{
smi_crtcw(i+0x90,VGAMode[j].Init_CR90_CRA7[i]);
}
}
}
smi_mmiowb(0x67,0x3c2);
// set VPR registers
writel(0x0,hw->m_pVPR+0x0C);
writel(0x0,hw->m_pVPR+0x40);
// set data width
m_nScreenStride = (hw->width * sfb->fb.var.bits_per_pixel) / 64;
switch (sfb->fb.var.bits_per_pixel)
{
case 8:
writel(0x0,hw->m_pVPR+0x0);
break;
case 16:
writel(0x00020000,hw->m_pVPR+0x0);
break;
case 24:
writel(0x00040000,hw->m_pVPR+0x0);
break;
}
writel((u32)(((m_nScreenStride + 2) << 16) | m_nScreenStride),hw->m_pVPR+0x10);
}
/*
* Get the VAR structure pointer for the specified console
*/
static inline struct fb_var_screeninfo *get_con_var(struct fb_info *info, int con)
{
struct smifb_info *sfb = (struct smifb_info *)info;
return (con == sfb->currcon) ? &sfb->fb.var : &fb_display[con].var;
}
/*
* Get the DISPLAY structure pointer for the specified console
*/
static inline struct display *get_con_display(struct fb_info *info, int con)
{
struct smifb_info *sfb = (struct smifb_info *)info;
return (con < 0) ? sfb->fb.disp : &fb_display[con];
}
/*
* Get the CMAP pointer for the specified console
*/
static inline struct fb_cmap *get_con_cmap(struct fb_info *info, int con)
{
struct smifb_info *sfb = (struct smifb_info *)info;
return (con == sfb->currcon) ? &sfb->fb.cmap : &fb_display[con].cmap;
}
/*
* Set the color palette
*/
static int
smifb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int trans, struct fb_info *info)
{
struct smifb_info *sfb = (struct smifbinfo *)info;
u16 *pal;
switch (sfb->fb.disp->visual) {
case FB_VISUAL_TRUECOLOR: /* RGB 5:6:5 True Colour */
pal = sfb->fb.pseudo_palette; // System has 16 default color
if (regno >= 16)
return 1;
pal[regno] = (red & 0xf800) |
((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11);
break;
}
return 0;
}
/*
* smifb_decode_var():
* Get the video params out of 'var'. If a value doesn't fit, round it up,
* if it's too big, return -EINVAL.
*
* Suggestion: Round up in the following order: bits_per_pixel, xres,
* yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale,
* bitfields, horizontal timing, vertical timing.
*/
static int smifb_decode_var(struct fb_var_screeninfo *var, struct smifb_info *sfb, struct par_info *hw)
{
var->xres_virtual =
var->xres_virtual < var->xres ? var->xres : var->xres_virtual;
var->yres_virtual =
var->yres_virtual < var->yres ? var->yres : var->yres_virtual;
hw->width = var->xres;
hw->height = var->yres;
hw->hz = 60;
switch (var->bits_per_pixel) {
case 8:
case 16: /* RGB 565 */
case 24:
break;
default:
return -EINVAL;
}
return 0;
}
static void
smifb_hw_set_var(struct fb_var_screeninfo *var, struct smifb_info *sfb)
{
struct display *display = sfb->fb.disp;
struct fb_cmap *cmap;
sfb->palette_size = var->bits_per_pixel == 8 ? 256 : 16;
if (display->cmap.len)
cmap = &display->cmap;
else
cmap = fb_default_cmap(sfb->palette_size);
fb_set_cmap(cmap, 1, smifb_setcolreg, &sfb->fb);
}
static int
smifb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
{
struct smifb_info *sfb = (struct smifb_info *)info;
struct fb_var_screeninfo *dvar = get_con_var(&sfb->fb, con);
struct display *display = get_con_display(&sfb->fb, con);
int err, chgvar = 0;
/*
* Decode var contents into a par structure, adjusting any
* out of range values.
*/
err = smifb_decode_var(var, sfb, &hw);
if (err) {
return err;
}
if (var->activate & FB_ACTIVATE_TEST)
return 0;
if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)
return -EINVAL;
if (dvar->xres != var->xres)
chgvar = 1;
if (dvar->yres != var->yres)
chgvar = 1;
if (dvar->xres_virtual != var->xres_virtual)
chgvar = 1;
if (dvar->yres_virtual != var->yres_virtual)
chgvar = 1;
if (dvar->bits_per_pixel != var->bits_per_pixel)
chgvar = 1;
if (con < 0)
chgvar = 0;
switch (var->bits_per_pixel) {
#ifdef FBCON_HAS_CFB16
case 16:
dvar->red.offset = 11;
dvar->red.length = 5;
dvar->green.offset = 5;
dvar->green.length = 6;
dvar->blue.offset = 0;
dvar->blue.length = 5;
display->visual = FB_VISUAL_TRUECOLOR;
display->line_length= var->xres * 2;
display->dispsw = &fbcon_cfb16;
display->dispsw_data= sfb->fb.pseudo_palette;
break;
#endif
default:
display->dispsw = &fbcon_dummy;
break;
}
display->screen_base= sfb->fb.screen_base;
display->next_line = display->line_length;
display->type = sfb->fb.fix.type;
display->type_aux = sfb->fb.fix.type_aux;
display->ypanstep = sfb->fb.fix.ypanstep;
display->ywrapstep = sfb->fb.fix.ywrapstep;
display->can_soft_blank = 1;
display->inverse = 0;
*dvar = *var;
dvar->activate &= ~FB_ACTIVATE_ALL;
/*
* Update the old var. The fbcon drivers still use this.
* Once they are using sfb->fb.var, this can be dropped.
*/
display->var = *dvar;
/*
* If we are setting all the virtual consoles, also set the
* defaults used to create new consoles.
*/
if (var->activate & FB_ACTIVATE_ALL)
sfb->fb.disp->var = *dvar;
/*
* If the console has changed and the console has defined
* a changevar function, call that function.
*/
if (chgvar && info && sfb->fb.changevar)
sfb->fb.changevar(con);
/* If the current console is selected, activate the new var. */
if (con != sfb->currcon)
return 0;
smifb_hw_set_var(dvar, sfb);
smi_set_timing(sfb, &hw);
return 0;
}
static int
__do_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
struct smifb_info *sfb = (struct smifb_info *)info;
struct fb_cmap *dcmap = get_con_cmap(info, con);
int err = 0;
/* no colormap allocated? */
if (!dcmap->len)
err = fb_alloc_cmap(dcmap, 256, 0);
if (!err && con == sfb->currcon)
err = fb_set_cmap(cmap, kspc, smifb_setcolreg, info);
if (!err)
fb_copy_cmap(cmap, dcmap, kspc ? 0 : 1);
return err;
}
static int
smifb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
struct display *disp = get_con_display(info, con);
if (disp->visual == FB_VISUAL_TRUECOLOR)
return -EINVAL;
return __do_set_cmap(cmap, kspc, con, info);
}
static int
smifb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
{
struct display *display = get_con_display(info, con);
*fix = info->fix;
fix->line_length = display->line_length;
fix->visual = display->visual;
return 0;
}
static int
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -