Commit 7748d302 authored by Petr Vandrovec's avatar Petr Vandrovec

Update matroxfb to the current fbdev API.

parent 4393c27f
......@@ -2,11 +2,11 @@
*
* Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200, G400 and G450.
*
* (c) 1998-2001 Petr Vandrovec <vandrove@vc.cvut.cz>
* (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>
*
* Portions Copyright (c) 2001 Matrox Graphics Inc.
*
* Version: 1.62 2001/11/29
* Version: 1.65 2002/08/14
*
* See matroxfb_base.c for contributors.
*
......@@ -150,7 +150,7 @@ static int matroxfb_DAC1064_setfont(struct display* p, int width, int height) {
return 0;
}
static int DAC1064_selhwcursor(WPMINFO struct display* p) {
static int DAC1064_selhwcursor(WPMINFO2) {
ACCESS_FBINFO(dispsw.cursor) = matroxfb_DAC1064_cursor;
ACCESS_FBINFO(dispsw.set_font) = matroxfb_DAC1064_setfont;
return 0;
......@@ -453,24 +453,24 @@ void DAC1064_global_restore(WPMINFO2) {
}
}
static int DAC1064_init_1(WPMINFO struct my_timming* m, struct display *p) {
static int DAC1064_init_1(WPMINFO struct my_timming* m) {
struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
DBG("DAC1064_init_1")
memcpy(hw->DACreg, MGA1064_DAC, sizeof(MGA1064_DAC_regs));
if (p->type == FB_TYPE_TEXT) {
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
hw->DACreg[POS1064_XMISCCTRL] = M1064_XMISCCTRL_DAC_6BIT;
hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_8BPP
| M1064_XMULCTRL_GRAPHICS_PALETIZED;
} else {
switch (p->var.bits_per_pixel) {
switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) {
/* case 4: not supported by MGA1064 DAC */
case 8:
hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_8BPP | M1064_XMULCTRL_GRAPHICS_PALETIZED;
break;
case 16:
if (p->var.green.length == 5)
if (ACCESS_FBINFO(fbcon).var.green.length == 5)
hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_15BPP_1BPP | M1064_XMULCTRL_GRAPHICS_PALETIZED;
else
hw->DACreg[POS1064_XMULCTRL] = M1064_XMULCTRL_DEPTH_16BPP | M1064_XMULCTRL_GRAPHICS_PALETIZED;
......@@ -495,12 +495,12 @@ static int DAC1064_init_1(WPMINFO struct my_timming* m, struct display *p) {
return 0;
}
static int DAC1064_init_2(WPMINFO struct my_timming* m, struct display* p) {
static int DAC1064_init_2(WPMINFO struct my_timming* m) {
struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
DBG("DAC1064_init_2")
if (p->var.bits_per_pixel > 16) { /* 256 entries */
if (ACCESS_FBINFO(fbcon).var.bits_per_pixel > 16) { /* 256 entries */
int i;
for (i = 0; i < 256; i++) {
......@@ -508,8 +508,8 @@ static int DAC1064_init_2(WPMINFO struct my_timming* m, struct display* p) {
hw->DACpal[i * 3 + 1] = i;
hw->DACpal[i * 3 + 2] = i;
}
} else if (p->var.bits_per_pixel > 8) {
if (p->var.green.length == 5) { /* 0..31, 128..159 */
} else if (ACCESS_FBINFO(fbcon).var.bits_per_pixel > 8) {
if (ACCESS_FBINFO(fbcon).var.green.length == 5) { /* 0..31, 128..159 */
int i;
for (i = 0; i < 32; i++) {
......@@ -646,7 +646,7 @@ static int MGA1064_init(WPMINFO struct my_timming* m, struct display* p) {
DBG("MGA1064_init")
if (DAC1064_init_1(PMINFO m, p)) return 1;
if (DAC1064_init_1(PMINFO m)) return 1;
if (matroxfb_vgaHWinit(PMINFO m, p)) return 1;
hw->MiscOutReg = 0xCB;
......@@ -657,7 +657,7 @@ static int MGA1064_init(WPMINFO struct my_timming* m, struct display* p) {
if (m->sync & FB_SYNC_COMP_HIGH_ACT) /* should be only FB_SYNC_COMP */
hw->CRTCEXT[3] |= 0x40;
if (DAC1064_init_2(PMINFO m, p)) return 1;
if (DAC1064_init_2(PMINFO m)) return 1;
return 0;
}
#endif
......@@ -668,7 +668,7 @@ static int MGAG100_init(WPMINFO struct my_timming* m, struct display* p) {
DBG("MGAG100_init")
if (DAC1064_init_1(PMINFO m, p)) return 1;
if (DAC1064_init_1(PMINFO m)) return 1;
hw->MXoptionReg &= ~0x2000;
if (matroxfb_vgaHWinit(PMINFO m, p)) return 1;
......@@ -680,7 +680,7 @@ static int MGAG100_init(WPMINFO struct my_timming* m, struct display* p) {
if (m->sync & FB_SYNC_COMP_HIGH_ACT) /* should be only FB_SYNC_COMP */
hw->CRTCEXT[3] |= 0x40;
if (DAC1064_init_2(PMINFO m, p)) return 1;
if (DAC1064_init_2(PMINFO m)) return 1;
return 0;
}
#endif /* G100 */
......
......@@ -6,7 +6,7 @@
*
* Portions Copyright (c) 2001 Matrox Graphics Inc.
*
* Version: 1.64 2002/06/10
* Version: 1.65 2002/08/14
*
* MTRR stuff: 1998 Tom Rini <trini@kernel.crashing.org>
*
......@@ -402,7 +402,7 @@ static int matroxfb_ti3026_setfont(struct display* p, int width, int height) {
return 0;
}
static int matroxfb_ti3026_selhwcursor(WPMINFO struct display* p) {
static int matroxfb_ti3026_selhwcursor(WPMINFO2) {
ACCESS_FBINFO(dispsw.cursor) = matroxfb_ti3026_cursor;
ACCESS_FBINFO(dispsw.set_font) = matroxfb_ti3026_setfont;
return 0;
......@@ -434,7 +434,7 @@ static int Ti3026_setpclk(WPMINFO int clk, struct display* p) {
hw->DACclk[1] = pixfeed;
hw->DACclk[2] = pixpost | 0xB0;
if (p->type == FB_TYPE_TEXT) {
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
hw->DACreg[POS3026_XMEMPLLCTRL] = TVP3026_XMEMPLLCTRL_MCLK_MCLKPLL | TVP3026_XMEMPLLCTRL_RCLK_PIXPLL;
hw->DACclk[3] = 0xFD;
hw->DACclk[4] = 0x3D;
......@@ -502,7 +502,7 @@ static int Ti3026_init(WPMINFO struct my_timming* m, struct display* p) {
DBG("Ti3026_init")
memcpy(hw->DACreg, MGADACbpp32, sizeof(hw->DACreg));
if (p->type == FB_TYPE_TEXT) {
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
hw->DACreg[POS3026_XLATCHCTRL] = TVP3026_XLATCHCTRL_8_1;
hw->DACreg[POS3026_XTRUECOLORCTRL] = TVP3026_XTRUECOLORCTRL_PSEUDOCOLOR;
hw->DACreg[POS3026_XMUXCTRL] = TVP3026_XMUXCTRL_VGA;
......@@ -569,7 +569,7 @@ static int Ti3026_init(WPMINFO struct my_timming* m, struct display* p) {
/* set interleaving */
hw->MXoptionReg &= ~0x00001000;
if ((p->type != FB_TYPE_TEXT) && isInterleave(MINFO)) hw->MXoptionReg |= 0x00001000;
if ((ACCESS_FBINFO(fbcon).fix.type != FB_TYPE_TEXT) && isInterleave(MINFO)) hw->MXoptionReg |= 0x00001000;
/* set DAC */
Ti3026_setpclk(PMINFO m->pixclock, p);
......
......@@ -2,9 +2,9 @@
*
* Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200 and G400
*
* (c) 1998-2001 Petr Vandrovec <vandrove@vc.cvut.cz>
* (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>
*
* Version: 1.51 2001/06/18
* Version: 1.65 2002/08/14
*
* MTRR stuff: 1998 Tom Rini <trini@kernel.crashing.org>
*
......@@ -85,21 +85,21 @@
#define mga_ydstlen(y,l) mga_outl(M_YDSTLEN | M_EXEC, ((y) << 16) | (l))
void matrox_cfbX_init(WPMINFO struct display* p) {
void matrox_cfbX_init(WPMINFO2) {
u_int32_t maccess;
u_int32_t mpitch;
u_int32_t mopmode;
DBG("matrox_cfbX_init")
mpitch = p->var.xres_virtual;
mpitch = ACCESS_FBINFO(fbcon).var.xres_virtual;
if (p->type == FB_TYPE_TEXT) {
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
maccess = 0x00000000;
mpitch = (mpitch >> 4) | 0x8000; /* set something */
mopmode = M_OPMODE_8BPP;
} else {
switch (p->var.bits_per_pixel) {
switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) {
case 4: maccess = 0x00000000; /* accelerate as 8bpp video */
mpitch = (mpitch >> 1) | 0x8000; /* disable linearization */
mopmode = M_OPMODE_4BPP;
......@@ -107,7 +107,7 @@ void matrox_cfbX_init(WPMINFO struct display* p) {
case 8: maccess = 0x00000000;
mopmode = M_OPMODE_8BPP;
break;
case 16: if (p->var.green.length == 5)
case 16: if (ACCESS_FBINFO(fbcon).var.green.length == 5)
maccess = 0xC0000001;
else
maccess = 0x40000001;
......@@ -816,7 +816,7 @@ static void matrox_cfbX_clear_margins(struct vc_data* conp, struct display* p, i
static void matrox_text_setup(struct display* p) {
MINFO_FROM_DISP(p);
p->next_line = p->line_length ? p->line_length : ((p->var.xres_virtual / (fontwidth(p)?fontwidth(p):8)) * ACCESS_FBINFO(devflags.textstep));
p->next_line = ACCESS_FBINFO(fbcon).fix.line_length ? ACCESS_FBINFO(fbcon).fix.line_length : ((p->var.xres_virtual / (fontwidth(p)?fontwidth(p):8)) * ACCESS_FBINFO(devflags.textstep));
p->next_plane = 0;
}
......@@ -1040,7 +1040,7 @@ static int matrox_text_setfont(struct display* p, int width, int height) {
MINFO_FROM_DISP(p);
matrox_text_round(PMINFO &p->var, p);
p->next_line = p->line_length = ((p->var.xres_virtual / (fontwidth(p)?fontwidth(p):8)) * ACCESS_FBINFO(devflags.textstep));
p->next_line = ACCESS_FBINFO(fbcon).fix.line_length = ((p->var.xres_virtual / (fontwidth(p)?fontwidth(p):8)) * ACCESS_FBINFO(devflags.textstep));
if (p->conp)
matrox_text_createcursor(PMINFO p);
......@@ -1144,11 +1144,11 @@ void initMatrox(WPMINFO struct display* p) {
if (p->dispsw && p->conp)
fb_con.con_cursor(p->conp, CM_ERASE);
p->dispsw_data = NULL;
if ((p->var.accel_flags & FB_ACCELF_TEXT) != FB_ACCELF_TEXT) {
if (p->type == FB_TYPE_TEXT) {
if ((ACCESS_FBINFO(fbcon).var.accel_flags & FB_ACCELF_TEXT) != FB_ACCELF_TEXT) {
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
swtmp = &matroxfb_text;
} else {
switch (p->var.bits_per_pixel) {
switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB4
case 4:
swtmp = &fbcon_cfb4;
......@@ -1183,10 +1183,10 @@ void initMatrox(WPMINFO struct display* p) {
}
}
dprintk(KERN_INFO "matroxfb: acceleration disabled\n");
} else if (p->type == FB_TYPE_TEXT) {
} else if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
swtmp = &matroxfb_text;
} else {
switch (p->var.bits_per_pixel) {
switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB4
case 4:
swtmp = &matroxfb_cfb4;
......@@ -1222,8 +1222,8 @@ void initMatrox(WPMINFO struct display* p) {
}
memcpy(&ACCESS_FBINFO(dispsw), swtmp, sizeof(ACCESS_FBINFO(dispsw)));
p->dispsw = &ACCESS_FBINFO(dispsw);
if ((p->type != FB_TYPE_TEXT) && ACCESS_FBINFO(devflags.hwcursor)) {
ACCESS_FBINFO(hw_switch)->selhwcursor(PMINFO p);
if ((ACCESS_FBINFO(fbcon).fix.type != FB_TYPE_TEXT) && ACCESS_FBINFO(devflags.hwcursor)) {
ACCESS_FBINFO(hw_switch)->selhwcursor(PMINFO2);
}
}
......@@ -1233,7 +1233,7 @@ void matrox_init_putc(WPMINFO struct display* p, void (*dac_createcursor)(WPMINF
int i;
if (p && p->conp) {
if (p->type == FB_TYPE_TEXT) {
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
matrox_text_createcursor(PMINFO p);
matrox_text_loadfont(PMINFO p);
i = 0;
......
......@@ -4,7 +4,7 @@
#include "matroxfb_base.h"
void matrox_init_putc(WPMINFO struct display* p, void (*)(WPMINFO struct display *p));
void matrox_cfbX_init(WPMINFO struct display* p);
void matrox_cfbX_init(WPMINFO2);
void matrox_text_round(CPMINFO struct fb_var_screeninfo* var, struct display* p);
void initMatrox(WPMINFO struct display* p);
......
......@@ -6,7 +6,7 @@
*
* Portions Copyright (c) 2001 Matrox Graphics Inc.
*
* Version: 1.64 2002/06/10
* Version: 1.65 2002/08/14
*
* MTRR stuff: 1998 Tom Rini <trini@kernel.crashing.org>
*
......@@ -81,7 +81,10 @@
* Fixes
*
* "Mike Pieper" <mike@pieper-family.de>
* TVOut enhandcements.
* TVOut enhandcements, V4L2 control interface.
*
* "Diego Biurrun" <diego@biurrun.de>
* DFP testing
*
* (following author is not in any relation with this code, but his code
* is included in this driver)
......@@ -176,11 +179,13 @@ static void matrox_pan_var(WPMINFO struct fb_var_screeninfo *var) {
if (ACCESS_FBINFO(dead))
return;
ACCESS_FBINFO(fbcon).var.xoffset = var->xoffset;
ACCESS_FBINFO(fbcon).var.yoffset = var->yoffset;
disp = ACCESS_FBINFO(currcon_display);
if (disp->type == FB_TYPE_TEXT) {
pos = var->yoffset / fontheight(disp) * disp->next_line / ACCESS_FBINFO(devflags.textstep) + var->xoffset / (fontwidth(disp)?fontwidth(disp):8);
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
pos = ACCESS_FBINFO(fbcon).var.yoffset / fontheight(disp) * disp->next_line / ACCESS_FBINFO(devflags.textstep) + ACCESS_FBINFO(fbcon).var.xoffset / (fontwidth(disp)?fontwidth(disp):8);
} else {
pos = (var->yoffset * var->xres_virtual + var->xoffset) * ACCESS_FBINFO(curr.final_bppShift) / 32;
pos = (ACCESS_FBINFO(fbcon).var.yoffset * ACCESS_FBINFO(fbcon).var.xres_virtual + ACCESS_FBINFO(fbcon).var.xoffset) * ACCESS_FBINFO(curr.final_bppShift) / 32;
pos += ACCESS_FBINFO(curr.ydstorg.chunks);
}
p0 = ACCESS_FBINFO(hw).CRTC[0x0D] = pos & 0xFF;
......@@ -567,7 +572,6 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp,
struct fb_info *fb_info)
{
struct display* p;
#ifdef CONFIG_FB_MATROX_MULTIHEAD
struct matrox_fb_info* minfo = container_of(fb_info, struct matrox_fb_info, fbcon);
#endif
......@@ -589,18 +593,17 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
ACCESS_FBINFO(palette[regno].blue) = blue;
ACCESS_FBINFO(palette[regno].transp) = transp;
p = ACCESS_FBINFO(currcon_display);
if (p->var.grayscale) {
if (ACCESS_FBINFO(fbcon).var.grayscale) {
/* gray = 0.30*R + 0.59*G + 0.11*B */
red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
}
red = CNVT_TOHW(red, p->var.red.length);
green = CNVT_TOHW(green, p->var.green.length);
blue = CNVT_TOHW(blue, p->var.blue.length);
transp = CNVT_TOHW(transp, p->var.transp.length);
red = CNVT_TOHW(red, ACCESS_FBINFO(fbcon).var.red.length);
green = CNVT_TOHW(green, ACCESS_FBINFO(fbcon).var.green.length);
blue = CNVT_TOHW(blue, ACCESS_FBINFO(fbcon).var.blue.length);
transp = CNVT_TOHW(transp, ACCESS_FBINFO(fbcon).var.transp.length);
switch (p->var.bits_per_pixel) {
switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) {
#if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB4) || defined(FBCON_HAS_VGATEXT)
#ifdef FBCON_HAS_VGATEXT
case 0:
......@@ -620,81 +623,48 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
#ifdef FBCON_HAS_CFB16
case 16:
ACCESS_FBINFO(cmap.cfb16[regno]) =
(red << p->var.red.offset) |
(green << p->var.green.offset) |
(blue << p->var.blue.offset) |
(transp << p->var.transp.offset); /* for 1:5:5:5 */
(red << ACCESS_FBINFO(fbcon).var.red.offset) |
(green << ACCESS_FBINFO(fbcon).var.green.offset) |
(blue << ACCESS_FBINFO(fbcon).var.blue.offset) |
(transp << ACCESS_FBINFO(fbcon).var.transp.offset); /* for 1:5:5:5 */
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:
ACCESS_FBINFO(cmap.cfb24[regno]) =
(red << p->var.red.offset) |
(green << p->var.green.offset) |
(blue << p->var.blue.offset);
(red << ACCESS_FBINFO(fbcon).var.red.offset) |
(green << ACCESS_FBINFO(fbcon).var.green.offset) |
(blue << ACCESS_FBINFO(fbcon).var.blue.offset);
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
ACCESS_FBINFO(cmap.cfb32[regno]) =
(red << p->var.red.offset) |
(green << p->var.green.offset) |
(blue << p->var.blue.offset) |
(transp << p->var.transp.offset); /* 8:8:8:8 */
(red << ACCESS_FBINFO(fbcon).var.red.offset) |
(green << ACCESS_FBINFO(fbcon).var.green.offset) |
(blue << ACCESS_FBINFO(fbcon).var.blue.offset) |
(transp << ACCESS_FBINFO(fbcon).var.transp.offset); /* 8:8:8:8 */
break;
#endif
}
return 0;
}
static int matroxfb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
static void matroxfb_update_fix(WPMINFO2)
{
struct display* p;
struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix;
DBG("matroxfb_get_fix")
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
if (ACCESS_FBINFO(dead)) {
return -ENXIO;
}
if (con >= 0)
p = fb_display + con;
else
p = ACCESS_FBINFO(fbcon.disp);
memset(fix, 0, sizeof(*fix));
strcpy(fix->id,"MATROX");
fix->smem_start = ACCESS_FBINFO(video.base) + ACCESS_FBINFO(curr.ydstorg.bytes);
fix->smem_len = ACCESS_FBINFO(video.len_usable) - ACCESS_FBINFO(curr.ydstorg.bytes);
fix->type = p->type;
fix->type_aux = p->type_aux;
fix->visual = p->visual;
fix->xpanstep = 8; /* 8 for 8bpp, 4 for 16bpp, 2 for 32bpp */
fix->xpanstep = 8; /* 8 for 8bpp, 4 for 16bpp, 2 for 32bpp */
fix->ypanstep = 1;
fix->ywrapstep = 0;
fix->line_length = p->line_length;
fix->mmio_start = ACCESS_FBINFO(mmio.base);
fix->mmio_len = ACCESS_FBINFO(mmio.len);
fix->accel = ACCESS_FBINFO(devflags.accelerator);
return 0;
#undef minfo
}
static int matroxfb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
#define minfo (container_of(info, struct matrox_fb_info, fbcon))
DBG("matroxfb_get_var")
if(con < 0)
*var=ACCESS_FBINFO(fbcon.disp)->var;
else
*var=fb_display[con].var;
return 0;
#undef minfo
}
static int matroxfb_set_var(struct fb_var_screeninfo *var, int con,
......@@ -741,17 +711,19 @@ static int matroxfb_set_var(struct fb_var_screeninfo *var, int con,
display->var = *var;
/* cmap */
ACCESS_FBINFO(fbcon.screen_base) = vaddr_va(ACCESS_FBINFO(video.vbase)) + ydstorg;
display->visual = visual;
display->ypanstep = 1;
display->ywrapstep = 0;
if (var->bits_per_pixel) {
display->type = FB_TYPE_PACKED_PIXELS;
display->type_aux = 0;
display->next_line = display->line_length = (var->xres_virtual * var->bits_per_pixel) >> 3;
} else {
display->type = FB_TYPE_TEXT;
display->type_aux = ACCESS_FBINFO(devflags.text_type_aux);
display->next_line = display->line_length = (var->xres_virtual / (fontwidth(display)?fontwidth(display):8)) * ACCESS_FBINFO(devflags.textstep);
if (display == ACCESS_FBINFO(currcon_display)) {
ACCESS_FBINFO(fbcon).var = *var;
matroxfb_update_fix(PMINFO2);
ACCESS_FBINFO(fbcon).fix.visual = visual;
if (var->bits_per_pixel) {
ACCESS_FBINFO(fbcon).fix.type = FB_TYPE_PACKED_PIXELS;
ACCESS_FBINFO(fbcon).fix.type_aux = 0;
display->next_line = ACCESS_FBINFO(fbcon).fix.line_length = (var->xres_virtual * var->bits_per_pixel) >> 3;
} else {
ACCESS_FBINFO(fbcon).fix.type = FB_TYPE_TEXT;
ACCESS_FBINFO(fbcon).fix.type_aux = ACCESS_FBINFO(devflags.text_type_aux);
display->next_line = ACCESS_FBINFO(fbcon).fix.line_length = (var->xres_virtual / (fontwidth(display)?fontwidth(display):8)) * ACCESS_FBINFO(devflags.textstep);
}
}
display->can_soft_blank = 1;
display->inverse = ACCESS_FBINFO(devflags.inverse);
......@@ -766,7 +738,7 @@ static int matroxfb_set_var(struct fb_var_screeninfo *var, int con,
unsigned int pos;
ACCESS_FBINFO(curr.cmap_len) = cmap_len;
if (display->type == FB_TYPE_TEXT) {
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
/* textmode must be in first megabyte, so no ydstorg allowed */
ACCESS_FBINFO(curr.ydstorg.bytes) = 0;
ACCESS_FBINFO(curr.ydstorg.chunks) = 0;
......@@ -825,7 +797,7 @@ static int matroxfb_set_var(struct fb_var_screeninfo *var, int con,
ACCESS_FBINFO(crtc1).pixclock = mt.pixclock;
ACCESS_FBINFO(crtc1).mnp = mt.mnp;
ACCESS_FBINFO(hw_switch->init(PMINFO &mt, display));
if (display->type == FB_TYPE_TEXT) {
if (ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT) {
if (fontheight(display))
pos = var->yoffset / fontheight(display) * display->next_line / ACCESS_FBINFO(devflags.textstep) + var->xoffset / (fontwidth(display)?fontwidth(display):8);
else
......@@ -855,7 +827,7 @@ static int matroxfb_set_var(struct fb_var_screeninfo *var, int con,
}
}
up_read(&ACCESS_FBINFO(altout).lock);
matrox_cfbX_init(PMINFO display);
matrox_cfbX_init(PMINFO2);
my_install_cmap(PMINFO2);
}
}
......@@ -956,7 +928,7 @@ static int matroxfb_get_vblank(CPMINFO struct fb_vblank *vblank)
vblank->flags |= FB_VBLANK_HBLANKING;
if (sts1 & 8)
vblank->flags |= FB_VBLANK_VSYNCING;
if (vblank->vcount >= ACCESS_FBINFO(currcon_display)->var.yres)
if (vblank->vcount >= ACCESS_FBINFO(fbcon).var.yres)
vblank->flags |= FB_VBLANK_VBLANKING;
vblank->hcount = 0;
vblank->count = 0;
......@@ -1213,8 +1185,6 @@ static struct fb_ops matroxfb_ops = {
.owner = THIS_MODULE,
.fb_open = matroxfb_open,
.fb_release = matroxfb_release,
.fb_get_fix = matroxfb_get_fix,
.fb_get_var = matroxfb_get_var,
.fb_set_var = matroxfb_set_var,
.fb_get_cmap = matroxfb_get_cmap,
.fb_set_cmap = matroxfb_set_cmap,
......
......@@ -2,7 +2,7 @@
*
* Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200, G400 and G450
*
* (c) 1998,1999,2000,2001 Petr Vandrovec <vandrove@vc.cvut.cz>
* (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>
*
*/
#ifndef __MATROXFB_H__
......@@ -670,7 +670,7 @@ struct matrox_switch {
void (*reset)(WPMINFO2);
int (*init)(WPMINFO struct my_timming*, struct display*);
void (*restore)(WPMINFO struct display*);
int (*selhwcursor)(WPMINFO struct display*);
int (*selhwcursor)(WPMINFO2);
};
struct matroxfb_driver {
......
......@@ -6,7 +6,7 @@
*
* Portions Copyright (c) 2001 Matrox Graphics Inc.
*
* Version: 1.64 2002/06/10
* Version: 1.65 2002/08/14
*
*/
......@@ -42,7 +42,6 @@ static int matroxfb_dh_getcolreg(unsigned regno, unsigned *red, unsigned *green,
static int matroxfb_dh_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned transp, struct fb_info* info) {
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
struct display* p;
if (regno >= 16)
return 1;
......@@ -50,33 +49,32 @@ static int matroxfb_dh_setcolreg(unsigned regno, unsigned red, unsigned green,
m2info->palette[regno].blue = blue;
m2info->palette[regno].green = green;
m2info->palette[regno].transp = transp;
p = m2info->currcon_display;
if (p->var.grayscale) {
if (m2info->fbcon.var.grayscale) {
/* gray = 0.30*R + 0.59*G + 0.11*B */
red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
}
red = CNVT_TOHW(red, p->var.red.length);
green = CNVT_TOHW(green, p->var.green.length);
blue = CNVT_TOHW(blue, p->var.blue.length);
transp = CNVT_TOHW(transp, p->var.transp.length);
red = CNVT_TOHW(red, m2info->fbcon.var.red.length);
green = CNVT_TOHW(green, m2info->fbcon.var.green.length);
blue = CNVT_TOHW(blue, m2info->fbcon.var.blue.length);
transp = CNVT_TOHW(transp, m2info->fbcon.var.transp.length);
switch (p->var.bits_per_pixel) {
switch (m2info->fbcon.var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB16
case 16:
m2info->cmap.cfb16[regno] =
(red << p->var.red.offset) |
(green << p->var.green.offset) |
(blue << p->var.blue.offset) |
(transp << p->var.transp.offset);
(red << m2info->fbcon.var.red.offset) |
(green << m2info->fbcon.var.green.offset) |
(blue << m2info->fbcon.var.blue.offset) |
(transp << m2info->fbcon.var.transp.offset);
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
m2info->cmap.cfb32[regno] =
(red << p->var.red.offset) |
(green << p->var.green.offset) |
(blue << p->var.blue.offset) |
(transp << p->var.transp.offset);
(red << m2info->fbcon.var.red.offset) |
(green << m2info->fbcon.var.green.offset) |
(blue << m2info->fbcon.var.blue.offset) |
(transp << m2info->fbcon.var.transp.offset);
break;
#endif
}
......@@ -99,7 +97,6 @@ static inline void my_install_cmap(struct matroxfb_dh_fb_info* m2info)
static void matroxfb_dh_restore(struct matroxfb_dh_fb_info* m2info,
struct my_timming* mt,
struct display* p,
int mode,
unsigned int pos) {
u_int32_t tmp;
......@@ -157,7 +154,7 @@ static void matroxfb_dh_restore(struct matroxfb_dh_fb_info* m2info,
mga_outl(0x3C20, ((mt->VSyncEnd - 1) << 16) | (mt->VSyncStart - 1));
mga_outl(0x3C24, ((mt->VSyncStart) << 16) | (mt->HSyncStart)); /* preload */
{
u_int32_t linelen = p->var.xres_virtual * (p->var.bits_per_pixel >> 3);
u_int32_t linelen = m2info->fbcon.var.xres_virtual * (m2info->fbcon.var.bits_per_pixel >> 3);
if (tmp & 0x02000000) {
/* field #0 is smaller, so... */
mga_outl(0x3C2C, pos); /* field #1 vmemory start */
......@@ -202,8 +199,7 @@ static void matroxfb_dh_disable(struct matroxfb_dh_fb_info* m2info) {
ACCESS_FBINFO(hw).crtc2.ctl = 0x00000004;
}
static void matroxfb_dh_cfbX_init(struct matroxfb_dh_fb_info* m2info,
struct display* p) {
static void matroxfb_dh_cfbX_init(struct matroxfb_dh_fb_info* m2info) {
/* no acceleration for secondary head... */
}
......@@ -214,9 +210,11 @@ static void matroxfb_dh_pan_var(struct matroxfb_dh_fb_info* m2info,
unsigned int pixelsize;
MINFO_FROM(m2info->primary_dev);
pixelsize = var->bits_per_pixel >> 3;
linelen = var->xres_virtual * pixelsize;
pos = var->yoffset * linelen + var->xoffset * pixelsize;
m2info->fbcon.var.xoffset = var->xoffset;
m2info->fbcon.var.yoffset = var->yoffset;
pixelsize = m2info->fbcon.var.bits_per_pixel >> 3;
linelen = m2info->fbcon.var.xres_virtual * pixelsize;
pos = m2info->fbcon.var.yoffset * linelen + m2info->fbcon.var.xoffset * pixelsize;
pos += m2info->video.offbase;
if (m2info->interlaced) {
mga_outl(0x3C2C, pos);
......@@ -227,7 +225,6 @@ static void matroxfb_dh_pan_var(struct matroxfb_dh_fb_info* m2info,
}
static int matroxfb_dh_decode_var(struct matroxfb_dh_fb_info* m2info,
struct display* p,
struct fb_var_screeninfo* var,
int *visual,
int *video_cmap_len,
......@@ -306,7 +303,7 @@ static int matroxfb_dh_decode_var(struct matroxfb_dh_fb_info* m2info,
}
static void initMatroxDH(struct matroxfb_dh_fb_info* m2info, struct display* p) {
switch (p->var.bits_per_pixel) {
switch (m2info->fbcon.var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB16
case 16:
p->dispsw_data = m2info->cmap.cfb16;
......@@ -349,44 +346,19 @@ static int matroxfb_dh_release(struct fb_info* info, int user) {
#undef m2info
}
static int matroxfb_dh_get_fix(struct fb_fix_screeninfo* fix, int con,
struct fb_info* info) {
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
struct display* p;
static void matroxfb_dh_update_fix(struct matroxfb_dh_fb_info *m2info) {
struct fb_fix_screeninfo *fix = &m2info->fbcon.fix;
if (con >= 0)
p = fb_display + con;
else
p = m2info->fbcon.disp;
memset(fix, 0, sizeof(*fix));
strcpy(fix->id, "MATROX DH");
fix->smem_start = m2info->video.base;
fix->smem_len = m2info->video.len_usable;
fix->type = p->type;
fix->type_aux = p->type_aux;
fix->visual = p->visual;
fix->xpanstep = 8; /* TBD */
fix->ypanstep = 1;
fix->ywrapstep = 0;
fix->line_length = p->line_length;
fix->xpanstep = 8; /* TBD */
fix->mmio_start = m2info->mmio.base;
fix->mmio_len = m2info->mmio.len;
fix->accel = 0; /* no accel... */
return 0;
#undef m2info
}
static int matroxfb_dh_get_var(struct fb_var_screeninfo* var, int con,
struct fb_info* info) {
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
if (con < 0)
*var = m2info->fbcon.disp->var;
else
*var = fb_display[con].var;
return 0;
#undef m2info
}
static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
......@@ -404,7 +376,7 @@ static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
p = m2info->fbcon.disp;
else
p = fb_display + con;
if ((err = matroxfb_dh_decode_var(m2info, p, var, &visual, &cmap_len, &mode)) != 0)
if ((err = matroxfb_dh_decode_var(m2info, var, &visual, &cmap_len, &mode)) != 0)
return err;
switch (var->activate & FB_ACTIVATE_MASK) {
case FB_ACTIVATE_TEST: return 0;
......@@ -425,13 +397,15 @@ static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
chgvar = 0;
p->var = *var;
/* cmap */
m2info->fbcon.screen_base = vaddr_va(m2info->video.vbase);
p->visual = visual;
p->ypanstep = 1;
p->ywrapstep = 0;
p->type = FB_TYPE_PACKED_PIXELS;
p->type_aux = 0;
p->next_line = p->line_length = (var->xres_virtual * var->bits_per_pixel) >> 3;
if (con == m2info->fbcon.currcon) {
m2info->fbcon.screen_base = vaddr_va(m2info->video.vbase);
m2info->fbcon.var = *var;
m2info->fbcon.fix.visual = visual;
m2info->fbcon.fix.type = FB_TYPE_PACKED_PIXELS;
m2info->fbcon.fix.type_aux = 0;
p->next_line = m2info->fbcon.fix.line_length = (var->xres_virtual * var->bits_per_pixel) >> 3;
matroxfb_dh_update_fix(m2info);
}
p->can_soft_blank = 0;
p->inverse = 0; /* TBD */
initMatroxDH(m2info, p);
......@@ -443,12 +417,12 @@ static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
int out;
int cnt;
matroxfb_var2my(var, &mt);
matroxfb_var2my(&m2info->fbcon.var, &mt);
mt.crtc = MATROXFB_SRC_CRTC2;
/* CRTC2 delay */
mt.delay = 34;
pos = (var->yoffset * var->xres_virtual + var->xoffset) * var->bits_per_pixel >> 3;
pos = (m2info->fbcon.var.yoffset * m2info->fbcon.var.xres_virtual + m2info->fbcon.var.xoffset) * m2info->fbcon.var.bits_per_pixel >> 3;
pos += m2info->video.offbase;
cnt = 0;
down_read(&ACCESS_FBINFO(altout).lock);
......@@ -464,7 +438,7 @@ static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
ACCESS_FBINFO(crtc2).mnp = mt.mnp;
up_read(&ACCESS_FBINFO(altout).lock);
if (cnt) {
matroxfb_dh_restore(m2info, &mt, p, mode, pos);
matroxfb_dh_restore(m2info, &mt, mode, pos);
} else {
matroxfb_dh_disable(m2info);
}
......@@ -484,7 +458,7 @@ static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
}
}
up_read(&ACCESS_FBINFO(altout).lock);
matroxfb_dh_cfbX_init(m2info, p);
matroxfb_dh_cfbX_init(m2info);
my_install_cmap(m2info);
}
return 0;
......@@ -558,7 +532,7 @@ static int matroxfb_dh_get_vblank(const struct matroxfb_dh_fb_info* m2info, stru
/* mask out reserved bits + field number (odd/even) */
vblank->vcount = mga_inl(0x3C48) & 0x000007FF;
/* compatibility stuff */
if (vblank->vcount >= m2info->currcon_display->var.yres)
if (vblank->vcount >= m2info->fbcon.var.yres)
vblank->flags |= FB_VBLANK_VBLANKING;
return 0;
}
......@@ -701,8 +675,6 @@ static struct fb_ops matroxfb_dh_ops = {
.owner = THIS_MODULE,
.fb_open = matroxfb_dh_open,
.fb_release = matroxfb_dh_release,
.fb_get_fix = matroxfb_dh_get_fix,
.fb_get_var = matroxfb_dh_get_var,
.fb_set_var = matroxfb_dh_set_var,
.fb_get_cmap = matroxfb_dh_get_cmap,
.fb_set_cmap = matroxfb_dh_set_cmap,
......
......@@ -2,11 +2,11 @@
*
* Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200 and G400
*
* (c) 1998,1999,2000,2001 Petr Vandrovec <vandrove@vc.cvut.cz>
* (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>
*
* Portions Copyright (c) 2001 Matrox Graphics Inc.
*
* Version: 1.62 2001/11/29
* Version: 1.65 2002/08/14
*
* MTRR stuff: 1998 Tom Rini <trini@kernel.crashing.org>
*
......@@ -227,7 +227,7 @@ int matroxfb_vgaHWinit(WPMINFO struct my_timming* m, struct display* p) {
unsigned int wd;
unsigned int divider;
int i;
int text = p->type == FB_TYPE_TEXT;
int text = ACCESS_FBINFO(fbcon).fix.type == FB_TYPE_TEXT;
int fwidth;
struct matrox_hw_state * const hw = &ACCESS_FBINFO(hw);
......@@ -1013,6 +1013,6 @@ EXPORT_SYMBOL(matroxfb_vgaHWinit); /* DAC1064, Ti3026 */
EXPORT_SYMBOL(matroxfb_vgaHWrestore); /* DAC1064, Ti3026 */
EXPORT_SYMBOL(matroxfb_read_pins);
MODULE_AUTHOR("(c) 1999-2001 Petr Vandrovec <vandrove@vc.cvut.cz>");
MODULE_AUTHOR("(c) 1999-2002 Petr Vandrovec <vandrove@vc.cvut.cz>");
MODULE_DESCRIPTION("Miscellaneous support for Matrox video cards");
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment