📄 matroxfb_accel.c
字号:
/* * * Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200 and G400 * * (c) 1998-2001 Petr Vandrovec <vandrove@vc.cvut.cz> * * Version: 1.51 2001/06/18 * * MTRR stuff: 1998 Tom Rini <trini@kernel.crashing.org> * * Contributors: "menion?" <menion@mindless.com> * Betatesting, fixes, ideas * * "Kurt Garloff" <garloff@suse.de> * Betatesting, fixes, ideas, videomodes, videomodes timmings * * "Tom Rini" <trini@kernel.crashing.org> * MTRR stuff, PPC cleanups, betatesting, fixes, ideas * * "Bibek Sahu" <scorpio@dodds.net> * Access device through readb|w|l and write b|w|l * Extensive debugging stuff * * "Daniel Haun" <haund@usa.net> * Testing, hardware cursor fixes * * "Scott Wood" <sawst46+@pitt.edu> * Fixes * * "Gerd Knorr" <kraxel@goldbach.isdn.cs.tu-berlin.de> * Betatesting * * "Kelly French" <targon@hazmat.com> * "Fernando Herrera" <fherrera@eurielec.etsit.upm.es> * Betatesting, bug reporting * * "Pablo Bianucci" <pbian@pccp.com.ar> * Fixes, ideas, betatesting * * "Inaky Perez Gonzalez" <inaky@peloncho.fis.ucm.es> * Fixes, enhandcements, ideas, betatesting * * "Ryuichi Oikawa" <roikawa@rr.iiij4u.or.jp> * PPC betatesting, PPC support, backward compatibility * * "Paul Womar" <Paul@pwomar.demon.co.uk> * "Owen Waller" <O.Waller@ee.qub.ac.uk> * PPC betatesting * * "Thomas Pornin" <pornin@bolet.ens.fr> * Alpha betatesting * * "Pieter van Leuven" <pvl@iae.nl> * "Ulf Jaenicke-Roessler" <ujr@physik.phy.tu-dresden.de> * G100 testing * * "H. Peter Arvin" <hpa@transmeta.com> * Ideas * * "Cort Dougan" <cort@cs.nmt.edu> * CHRP fixes and PReP cleanup * * "Mark Vojkovich" <mvojkovi@ucsd.edu> * G400 support * * (following author is not in any relation with this code, but his code * is included in this driver) * * Based on framebuffer driver for VBE 2.0 compliant graphic boards * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> * * (following author is not in any relation with this code, but his ideas * were used when writting this driver) * * FreeVBE/AF (Matrox), "Shawn Hargreaves" <shawn@talula.demon.co.uk> * */#include "matroxfb_accel.h"#include "matroxfb_DAC1064.h"#include "matroxfb_Ti3026.h"#include "matroxfb_misc.h"#define curr_ydstorg(x) ACCESS_FBINFO2(x, curr.ydstorg.pixels)#define mga_ydstlen(y,l) mga_outl(M_YDSTLEN | M_EXEC, ((y) << 16) | (l))void matrox_cfbX_init(WPMINFO struct display* p) { u_int32_t maccess; u_int32_t mpitch; u_int32_t mopmode; DBG("matrox_cfbX_init") mpitch = p->var.xres_virtual; if (p->type == FB_TYPE_TEXT) { maccess = 0x00000000; mpitch = (mpitch >> 4) | 0x8000; /* set something */ mopmode = M_OPMODE_8BPP; } else { switch (p->var.bits_per_pixel) { case 4: maccess = 0x00000000; /* accelerate as 8bpp video */ mpitch = (mpitch >> 1) | 0x8000; /* disable linearization */ mopmode = M_OPMODE_4BPP; break; case 8: maccess = 0x00000000; mopmode = M_OPMODE_8BPP; break; case 16: if (p->var.green.length == 5) maccess = 0xC0000001; else maccess = 0x40000001; mopmode = M_OPMODE_16BPP; break; case 24: maccess = 0x00000003; mopmode = M_OPMODE_24BPP; break; case 32: maccess = 0x00000002; mopmode = M_OPMODE_32BPP; break; default: maccess = 0x00000000; mopmode = 0x00000000; break; /* turn off acceleration!!! */ } } mga_fifo(8); mga_outl(M_PITCH, mpitch); mga_outl(M_YDSTORG, curr_ydstorg(MINFO)); if (ACCESS_FBINFO(capable.plnwt)) mga_outl(M_PLNWT, -1); if (ACCESS_FBINFO(capable.srcorg)) { mga_outl(M_SRCORG, 0); mga_outl(M_DSTORG, 0); } mga_outl(M_OPMODE, mopmode); mga_outl(M_CXBNDRY, 0xFFFF0000); mga_outl(M_YTOP, 0); mga_outl(M_YBOT, 0x01FFFFFF); mga_outl(M_MACCESS, maccess); ACCESS_FBINFO(accel.m_dwg_rect) = M_DWG_TRAP | M_DWG_SOLID | M_DWG_ARZERO | M_DWG_SGNZERO | M_DWG_SHIFTZERO; if (isMilleniumII(MINFO)) ACCESS_FBINFO(accel.m_dwg_rect) |= M_DWG_TRANSC; ACCESS_FBINFO(accel.m_opmode) = mopmode;}EXPORT_SYMBOL(matrox_cfbX_init);static void matrox_cfbX_bmove(struct display* p, int sy, int sx, int dy, int dx, int height, int width) { int pixx = p->var.xres_virtual, start, end; CRITFLAGS MINFO_FROM_DISP(p); DBG("matrox_cfbX_bmove") CRITBEGIN sx *= fontwidth(p); dx *= fontwidth(p); width *= fontwidth(p); height *= fontheight(p); sy *= fontheight(p); dy *= fontheight(p); if ((dy < sy) || ((dy == sy) && (dx <= sx))) { mga_fifo(2); mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SHIFTZERO | M_DWG_SGNZERO | M_DWG_BFCOL | M_DWG_REPLACE); mga_outl(M_AR5, pixx); width--; start = sy*pixx+sx+curr_ydstorg(MINFO); end = start+width; } else { mga_fifo(3); mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SHIFTZERO | M_DWG_BFCOL | M_DWG_REPLACE); mga_outl(M_SGN, 5); mga_outl(M_AR5, -pixx); width--; end = (sy+height-1)*pixx+sx+curr_ydstorg(MINFO); start = end+width; dy += height-1; } mga_fifo(4); mga_outl(M_AR0, end); mga_outl(M_AR3, start); mga_outl(M_FXBNDRY, ((dx+width)<<16) | dx); mga_ydstlen(dy, height); WaitTillIdle(); CRITEND}#ifdef FBCON_HAS_CFB4static void matrox_cfb4_bmove(struct display* p, int sy, int sx, int dy, int dx, int height, int width) { int pixx, start, end; CRITFLAGS MINFO_FROM_DISP(p); /* both (sx or dx or width) and fontwidth() are odd, so their multiply is also odd, that means that we cannot use acceleration */ DBG("matrox_cfb4_bmove") CRITBEGIN if ((sx | dx | width) & fontwidth(p) & 1) { fbcon_cfb4_bmove(p, sy, sx, dy, dx, height, width); return; } sx *= fontwidth(p); dx *= fontwidth(p); width *= fontwidth(p); height *= fontheight(p); sy *= fontheight(p); dy *= fontheight(p); pixx = p->var.xres_virtual >> 1; sx >>= 1; dx >>= 1; width >>= 1; if ((dy < sy) || ((dy == sy) && (dx <= sx))) { mga_fifo(2); mga_outl(M_AR5, pixx); mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SHIFTZERO | M_DWG_SGNZERO | M_DWG_BFCOL | M_DWG_REPLACE); width--; start = sy*pixx+sx+curr_ydstorg(MINFO); end = start+width; } else { mga_fifo(3); mga_outl(M_SGN, 5); mga_outl(M_AR5, -pixx); mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SHIFTZERO | M_DWG_BFCOL | M_DWG_REPLACE); width--; end = (sy+height-1)*pixx+sx+curr_ydstorg(MINFO); start = end+width; dy += height-1; } mga_fifo(5); mga_outl(M_AR0, end); mga_outl(M_AR3, start); mga_outl(M_FXBNDRY, ((dx+width)<<16) | dx); mga_outl(M_YDST, dy*pixx >> 5); mga_outl(M_LEN | M_EXEC, height); WaitTillIdle(); CRITEND}#endifstatic void matroxfb_accel_clear(WPMINFO u_int32_t color, int sy, int sx, int height, int width) { CRITFLAGS DBG("matroxfb_accel_clear") CRITBEGIN mga_fifo(5); mga_outl(M_DWGCTL, ACCESS_FBINFO(accel.m_dwg_rect) | M_DWG_REPLACE); mga_outl(M_FCOL, color); mga_outl(M_FXBNDRY, ((sx + width) << 16) | sx); mga_ydstlen(sy, height); WaitTillIdle(); CRITEND}static void matrox_cfbX_clear(u_int32_t color, struct display* p, int sy, int sx, int height, int width) { DBG("matrox_cfbX_clear") matroxfb_accel_clear(PMXINFO(p) color, sy * fontheight(p), sx * fontwidth(p), height * fontheight(p), width * fontwidth(p));}#ifdef FBCON_HAS_CFB4static void matrox_cfb4_clear(struct vc_data* conp, struct display* p, int sy, int sx, int height, int width) { u_int32_t bgx; int whattodo; CRITFLAGS MINFO_FROM_DISP(p); DBG("matrox_cfb4_clear") CRITBEGIN whattodo = 0; bgx = attr_bgcol_ec(p, conp); bgx |= bgx << 4; bgx |= bgx << 8; bgx |= bgx << 16; sy *= fontheight(p); sx *= fontwidth(p); height *= fontheight(p); width *= fontwidth(p); if (sx & 1) { sx ++; if (!width) return; width --; whattodo = 1; } if (width & 1) { whattodo |= 2; } width >>= 1; sx >>= 1; if (width) { mga_fifo(5); mga_outl(M_DWGCTL, ACCESS_FBINFO(accel.m_dwg_rect) | M_DWG_REPLACE2); mga_outl(M_FCOL, bgx); mga_outl(M_FXBNDRY, ((sx + width) << 16) | sx); mga_outl(M_YDST, sy * p->var.xres_virtual >> 6); mga_outl(M_LEN | M_EXEC, height); WaitTillIdle(); } if (whattodo) { u_int32_t step = p->var.xres_virtual >> 1; vaddr_t vbase = ACCESS_FBINFO(video.vbase); if (whattodo & 1) { unsigned int uaddr = sy * step + sx - 1; u_int32_t loop; u_int8_t bgx2 = bgx & 0xF0; for (loop = height; loop > 0; loop --) { mga_writeb(vbase, uaddr, (mga_readb(vbase, uaddr) & 0x0F) | bgx2); uaddr += step; } } if (whattodo & 2) { unsigned int uaddr = sy * step + sx + width; u_int32_t loop; u_int8_t bgx2 = bgx & 0x0F; for (loop = height; loop > 0; loop --) { mga_writeb(vbase, uaddr, (mga_readb(vbase, uaddr) & 0xF0) | bgx2); uaddr += step; } } } CRITEND}#endif#ifdef FBCON_HAS_CFB8static void matrox_cfb8_clear(struct vc_data* conp, struct display* p, int sy, int sx, int height, int width) { u_int32_t bgx; DBG("matrox_cfb8_clear") bgx = attr_bgcol_ec(p, conp); bgx |= bgx << 8; bgx |= bgx << 16; matrox_cfbX_clear(bgx, p, sy, sx, height, width);}#endif#ifdef FBCON_HAS_CFB16static void matrox_cfb16_clear(struct vc_data* conp, struct display* p, int sy, int sx, int height, int width) { u_int32_t bgx; DBG("matrox_cfb16_clear") bgx = ((u_int16_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)]; matrox_cfbX_clear((bgx << 16) | bgx, p, sy, sx, height, width);}#endif#if defined(FBCON_HAS_CFB32) || defined(FBCON_HAS_CFB24)static void matrox_cfb32_clear(struct vc_data* conp, struct display* p, int sy, int sx, int height, int width) { u_int32_t bgx; DBG("matrox_cfb32_clear") bgx = ((u_int32_t*)p->dispsw_data)[attr_bgcol_ec(p, conp)]; matrox_cfbX_clear(bgx, p, sy, sx, height, width);}#endifstatic void matrox_cfbX_fastputc(u_int32_t fgx, u_int32_t bgx, struct display* p, int c, int yy, int xx) { unsigned int charcell; unsigned int ar3; CRITFLAGS MINFO_FROM_DISP(p); charcell = fontwidth(p) * fontheight(p); yy *= fontheight(p); xx *= fontwidth(p); CRITBEGIN mga_fifo(8); mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SGNZERO | M_DWG_SHIFTZERO | M_DWG_BMONOWF | M_DWG_LINEAR | M_DWG_REPLACE); mga_outl(M_FCOL, fgx); mga_outl(M_BCOL, bgx); mga_outl(M_FXBNDRY, ((xx + fontwidth(p) - 1) << 16) | xx); ar3 = ACCESS_FBINFO(fastfont.mgabase) + (c & p->charmask) * charcell; mga_outl(M_AR3, ar3); mga_outl(M_AR0, (ar3 + charcell - 1) & 0x0003FFFF); mga_ydstlen(yy, fontheight(p)); WaitTillIdle(); CRITEND}static void matrox_cfbX_putc(u_int32_t fgx, u_int32_t bgx, struct display* p, int c, int yy, int xx) { u_int32_t ar0; u_int32_t step; CRITFLAGS MINFO_FROM_DISP(p); DBG_HEAVY("matrox_cfbX_putc"); yy *= fontheight(p); xx *= fontwidth(p); CRITBEGIN#ifdef __BIG_ENDIAN WaitTillIdle(); mga_outl(M_OPMODE, M_OPMODE_8BPP);#else mga_fifo(7);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -