/* * linux/drivers/video/hgafb.c -- Hercules graphics adaptor frame buffer device * * Created 25 Nov 1999 by Ferenc Bakonyi ([email protected]) * Based on skeletonfb.c by Geert Uytterhoeven and * mdacon.c by Andrew Apted * * History: * * - Revision 0.1.8 (23 Oct 2002): Ported to new framebuffer api. * * - Revision 0.1.7 (23 Jan 2001): fix crash resulting from MDA only cards * being detected as Hercules. (Paul G.) * - Revision 0.1.6 (17 Aug 2000): new style structs * documentation * - Revision 0.1.5 (13 Mar 2000): spinlocks instead of saveflags();cli();etc * minor fixes * - Revision 0.1.4 (24 Jan 2000): fixed a bug in hga_card_detect() for * HGA-only systems * - Revision 0.1.3 (22 Jan 2000): modified for the new fb_info structure * screen is cleared after rmmod * virtual resolutions * module parameter 'nologo={0|1}' * the most important: boot logo :) * - Revision 0.1.0 (6 Dec 1999): faster scrolling and minor fixes * - First release (25 Nov 1999) * * 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/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/spinlock.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/delay.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/ioport.h> #include <linux/platform_device.h> #include <asm/io.h> #include <asm/vga.h> #if 0 #define DPRINTK … #else #define DPRINTK(args...) … #endif #if 0 #define CHKINFO … #else #define CHKINFO(ret) … #endif /* Description of the hardware layout */ static void __iomem *hga_vram; /* Base of video memory */ static unsigned long hga_vram_len; /* Size of video memory */ #define HGA_ROWADDR(row) … #define HGA_TXT … #define HGA_GFX … static inline u8 __iomem * rowaddr(struct fb_info *info, u_int row) { … } static int hga_mode = …; /* 0 = txt, 1 = gfx mode */ static enum { … } hga_type; static char *hga_type_name; #define HGA_INDEX_PORT … #define HGA_VALUE_PORT … #define HGA_MODE_PORT … #define HGA_STATUS_PORT … #define HGA_GFX_PORT … /* HGA register values */ #define HGA_CURSOR_BLINKING … #define HGA_CURSOR_OFF … #define HGA_CURSOR_SLOWBLINK … #define HGA_MODE_GRAPHICS … #define HGA_MODE_VIDEO_EN … #define HGA_MODE_BLINK_EN … #define HGA_MODE_GFX_PAGE1 … #define HGA_STATUS_HSYNC … #define HGA_STATUS_VSYNC … #define HGA_STATUS_VIDEO … #define HGA_CONFIG_COL132 … #define HGA_GFX_MODE_EN … #define HGA_GFX_PAGE_EN … /* Global locks */ static DEFINE_SPINLOCK(hga_reg_lock); /* Framebuffer driver structures */ static const struct fb_var_screeninfo hga_default_var = …; static struct fb_fix_screeninfo hga_fix = …; /* Don't assume that tty1 will be the initial current console. */ static int release_io_port = …; static int release_io_ports = …; static bool nologo = …; /* ------------------------------------------------------------------------- * * Low level hardware functions * * ------------------------------------------------------------------------- */ static void write_hga_b(unsigned int val, unsigned char reg) { … } static void write_hga_w(unsigned int val, unsigned char reg) { … } static int test_hga_b(unsigned char val, unsigned char reg) { … } static void hga_clear_screen(void) { … } static void hga_txt_mode(void) { … } static void hga_gfx_mode(void) { … } static void hga_show_logo(struct fb_info *info) { … } static void hga_pan(unsigned int xoffset, unsigned int yoffset) { … } static void hga_blank(int blank_mode) { … } static int hga_card_detect(void) { … } /** * hgafb_open - open the framebuffer device * @info: pointer to fb_info object containing info for current hga board * @init: open by console system or userland. * * Returns: %0 */ static int hgafb_open(struct fb_info *info, int init) { … } /** * hgafb_release - open the framebuffer device * @info: pointer to fb_info object containing info for current hga board * @init: open by console system or userland. * * Returns: %0 */ static int hgafb_release(struct fb_info *info, int init) { … } /** * hgafb_setcolreg - set color registers * @regno:register index to set * @red:red value, unused * @green:green value, unused * @blue:blue value, unused * @transp:transparency value, unused * @info:unused * * This callback function is used to set the color registers of a HGA * board. Since we have only two fixed colors only @regno is checked. * A zero is returned on success and 1 for failure. * * Returns: %0 */ static int hgafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *info) { … } /** * hgafb_pan_display - pan or wrap the display * @var:contains new xoffset, yoffset and vmode values * @info:pointer to fb_info object containing info for current hga board * * This function looks only at xoffset, yoffset and the %FB_VMODE_YWRAP * flag in @var. If input parameters are correct it calls hga_pan() to * program the hardware. @info->var is updated to the new values. * * Returns: %0 on success or %-EINVAL for failure. */ static int hgafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { … } /** * hgafb_blank - (un)blank the screen * @blank_mode:blanking method to use * @info:unused * * Blank the screen if blank_mode != 0, else unblank. * Implements VESA suspend and powerdown modes on hardware that supports * disabling hsync/vsync: * @blank_mode == 2 means suspend vsync, * @blank_mode == 3 means suspend hsync, * @blank_mode == 4 means powerdown. * * Returns: %0 */ static int hgafb_blank(int blank_mode, struct fb_info *info) { … } /* * Accel functions */ static void hgafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { … } static void hgafb_copyarea(struct fb_info *info, const struct fb_copyarea *area) { … } static void hgafb_imageblit(struct fb_info *info, const struct fb_image *image) { … } static const struct fb_ops hgafb_ops = …; /* ------------------------------------------------------------------------- * * * Functions in fb_info * * ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */ /* * Initialization */ static int hgafb_probe(struct platform_device *pdev) { … } static void hgafb_remove(struct platform_device *pdev) { … } static struct platform_driver hgafb_driver = …; static struct platform_device *hgafb_device; static int __init hgafb_init(void) { … } static void __exit hgafb_exit(void) { … } /* ------------------------------------------------------------------------- * * Modularization * * ------------------------------------------------------------------------- */ MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; module_param(nologo, bool, 0); MODULE_PARM_DESC(…) …; module_init(…) …; module_exit(hgafb_exit);