📄 libfbx-mga.c
字号:
/* * libfbx-mga.c -- mga optimizations for libfbx * (C)opyright 2001 U4X Labs * * Written by: Paul Mundt <lethal@u4xlabs.com> * Rob Salmond <rob.salmond@home.com> * * $Id: libfbx-mga.c,v 1.11 2001/03/03 01:34:43 lethal Exp $ * * This is the place for all the mga hardware specific * optimizations for the libfbx system go. * * See ChangeLog for modifications, CREDITS for credits. * * All source herein is copyright U4X Labs and its original author. * Any code modifications or additions are (C)opyright the original * author and U4X Labs respectively. * * libfbx is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * libfbx is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with libfbx; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */#include <libfbx/libfbx-drivers.h>#include <libfbx/drivers/libfbx-mga.h>#include <libfbx/libfbx.h>#include <sys/mman.h>mga_info *adapter = NULL;static struct fb_driver_ops mga_ops = { blank: mga_blank, fill_rect: mga_fill_rect, writec: mga_putc,};int fb_module_init(){ adapter = malloc(sizeof(mga_info)); adapter->accel = calloc(1, sizeof(mga_accel_info)); fb_map_mmio_region(); fb_screen->driver->ops = &mga_ops; fb_outl(M_FCOL, fb_screen->text.color); fb_outl(M_BCOL, fb_screen->text.bgcolor); adapter->accel->m_dwg_rect = M_DWG_TRAP | M_DWG_SOLID | M_DWG_ARZERO | M_DWG_SGNZERO | M_DWG_SHIFTZERO; return 0;}void fb_module_exit(){ fb_unmap_mmio_region(); cfree(adapter->accel); free(adapter);}inline void mga_blank(int val){ int seq = 0x20, crtc = 0x01; /* * Just a brief explanation of some of the values here.. * We have a list of 5 to choose from, and they are: * * 0 - unblank * 1 - blank * 2 - no vsync * 3 - no hsync * 4 - off * * I'm not entirely sure what the 4 pertains to.. my * guess would be for mobile displays to kick out the * LCD. But there aren't any MGA mobile adapters that * I know of, and this value isn't handled specially by * the framebuffer driver.. so your guess is as good as * mine. */ switch (val) { case 1: crtc = 0; break; case 2: case 3: case 4: crtc <<= val + 2; break; default: seq = crtc = 0; break; } fb_outb(M_SEQ_INDEX, 1); fb_outb(M_SEQ_DATA, (fb_inb(M_SEQ_DATA) & ~0x20) | seq); fb_outb(M_EXTVGA_INDEX, 1); fb_outb(M_EXTVGA_DATA, (fb_inb(M_EXTVGA_DATA) & ~0x30) | crtc);}void mga_fill_rect(__s32 x1, __s32 y1, __s32 x2, __s32 y2, __s32 r, __s32 g, __s32 b, fb_surface *surface){ x1 = MIN(x1, x2); y1 = MIN(y1, y2); mga_fifo(5); fb_outl(M_DWGCTL, adapter->accel->m_dwg_rect | M_DWG_REPLACE); fb_outl(M_FCOL, surface->make_color(r, g, b)); fb_outl(M_FXBNDRY, ((x2 - x1) << 16) | x1); mga_ydstlen(y1, (y2 - y1)); mga_wait_idle();}void mga_putc(__s32 x, __s32 y, __u32 c){ __u8 charcell = fb_screen->font.width * fb_screen->font.height; __u32 ar3; mga_fifo(8); fb_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SGNZERO | M_DWG_SHIFTZERO | M_DWG_BMONOWF | M_DWG_LINEAR | M_DWG_REPLACE); fb_outl(M_FXBNDRY, ((x + fb_screen->font.width - 1) << 16) | x); /* FIXME: This might need to be the mmio base?? */ ar3 = fb_screen->finfo->smem_start + (c & fb_screen->text.mask) * charcell; fb_outl(M_AR3, ar3); fb_outl(M_AR0, (ar3 + charcell - 1) & 0x0003ffff); mga_ydstlen(y, fb_screen->font.height); mga_wait_idle();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -