196ae6ea0SThomas Gleixner /* -*- linux-c -*- ------------------------------------------------------- * 296ae6ea0SThomas Gleixner * 396ae6ea0SThomas Gleixner * Copyright (C) 1991, 1992 Linus Torvalds 496ae6ea0SThomas Gleixner * Copyright 2007 rPath, Inc. - All Rights Reserved 596ae6ea0SThomas Gleixner * 696ae6ea0SThomas Gleixner * This file is part of the Linux kernel, and is made available under 796ae6ea0SThomas Gleixner * the terms of the GNU General Public License version 2. 896ae6ea0SThomas Gleixner * 996ae6ea0SThomas Gleixner * ----------------------------------------------------------------------- */ 1096ae6ea0SThomas Gleixner 1196ae6ea0SThomas Gleixner /* 1296ae6ea0SThomas Gleixner * arch/i386/boot/video.h 1396ae6ea0SThomas Gleixner * 1496ae6ea0SThomas Gleixner * Header file for the real-mode video probing code 1596ae6ea0SThomas Gleixner */ 1696ae6ea0SThomas Gleixner 1796ae6ea0SThomas Gleixner #ifndef BOOT_VIDEO_H 1896ae6ea0SThomas Gleixner #define BOOT_VIDEO_H 1996ae6ea0SThomas Gleixner 2096ae6ea0SThomas Gleixner #include <linux/types.h> 2196ae6ea0SThomas Gleixner 2296ae6ea0SThomas Gleixner /* Enable autodetection of SVGA adapters and modes. */ 2396ae6ea0SThomas Gleixner #undef CONFIG_VIDEO_SVGA 2496ae6ea0SThomas Gleixner 2596ae6ea0SThomas Gleixner /* Enable autodetection of VESA modes */ 2696ae6ea0SThomas Gleixner #define CONFIG_VIDEO_VESA 2796ae6ea0SThomas Gleixner 2896ae6ea0SThomas Gleixner /* Retain screen contents when switching modes */ 2996ae6ea0SThomas Gleixner #define CONFIG_VIDEO_RETAIN 3096ae6ea0SThomas Gleixner 3196ae6ea0SThomas Gleixner /* Force 400 scan lines for standard modes (hack to fix bad BIOS behaviour */ 3296ae6ea0SThomas Gleixner #undef CONFIG_VIDEO_400_HACK 3396ae6ea0SThomas Gleixner 3496ae6ea0SThomas Gleixner /* This code uses an extended set of video mode numbers. These include: 3596ae6ea0SThomas Gleixner * Aliases for standard modes 3696ae6ea0SThomas Gleixner * NORMAL_VGA (-1) 3796ae6ea0SThomas Gleixner * EXTENDED_VGA (-2) 3896ae6ea0SThomas Gleixner * ASK_VGA (-3) 3996ae6ea0SThomas Gleixner * Video modes numbered by menu position -- NOT RECOMMENDED because of lack 4096ae6ea0SThomas Gleixner * of compatibility when extending the table. These are between 0x00 and 0xff. 4196ae6ea0SThomas Gleixner */ 4296ae6ea0SThomas Gleixner #define VIDEO_FIRST_MENU 0x0000 4396ae6ea0SThomas Gleixner 4496ae6ea0SThomas Gleixner /* Standard BIOS video modes (BIOS number + 0x0100) */ 4596ae6ea0SThomas Gleixner #define VIDEO_FIRST_BIOS 0x0100 4696ae6ea0SThomas Gleixner 4796ae6ea0SThomas Gleixner /* VESA BIOS video modes (VESA number + 0x0200) */ 4896ae6ea0SThomas Gleixner #define VIDEO_FIRST_VESA 0x0200 4996ae6ea0SThomas Gleixner 5096ae6ea0SThomas Gleixner /* Video7 special modes (BIOS number + 0x0900) */ 5196ae6ea0SThomas Gleixner #define VIDEO_FIRST_V7 0x0900 5296ae6ea0SThomas Gleixner 5396ae6ea0SThomas Gleixner /* Special video modes */ 5496ae6ea0SThomas Gleixner #define VIDEO_FIRST_SPECIAL 0x0f00 5596ae6ea0SThomas Gleixner #define VIDEO_80x25 0x0f00 5696ae6ea0SThomas Gleixner #define VIDEO_8POINT 0x0f01 5796ae6ea0SThomas Gleixner #define VIDEO_80x43 0x0f02 5896ae6ea0SThomas Gleixner #define VIDEO_80x28 0x0f03 5996ae6ea0SThomas Gleixner #define VIDEO_CURRENT_MODE 0x0f04 6096ae6ea0SThomas Gleixner #define VIDEO_80x30 0x0f05 6196ae6ea0SThomas Gleixner #define VIDEO_80x34 0x0f06 6296ae6ea0SThomas Gleixner #define VIDEO_80x60 0x0f07 6396ae6ea0SThomas Gleixner #define VIDEO_GFX_HACK 0x0f08 6496ae6ea0SThomas Gleixner #define VIDEO_LAST_SPECIAL 0x0f09 6596ae6ea0SThomas Gleixner 6696ae6ea0SThomas Gleixner /* Video modes given by resolution */ 6796ae6ea0SThomas Gleixner #define VIDEO_FIRST_RESOLUTION 0x1000 6896ae6ea0SThomas Gleixner 6996ae6ea0SThomas Gleixner /* The "recalculate timings" flag */ 7096ae6ea0SThomas Gleixner #define VIDEO_RECALC 0x8000 7196ae6ea0SThomas Gleixner 7296ae6ea0SThomas Gleixner /* Define DO_STORE according to CONFIG_VIDEO_RETAIN */ 7396ae6ea0SThomas Gleixner #ifdef CONFIG_VIDEO_RETAIN 7496ae6ea0SThomas Gleixner void store_screen(void); 7596ae6ea0SThomas Gleixner #define DO_STORE() store_screen() 7696ae6ea0SThomas Gleixner #else 7796ae6ea0SThomas Gleixner #define DO_STORE() ((void)0) 7896ae6ea0SThomas Gleixner #endif /* CONFIG_VIDEO_RETAIN */ 7996ae6ea0SThomas Gleixner 8096ae6ea0SThomas Gleixner /* 8196ae6ea0SThomas Gleixner * Mode table structures 8296ae6ea0SThomas Gleixner */ 8396ae6ea0SThomas Gleixner 8496ae6ea0SThomas Gleixner struct mode_info { 8596ae6ea0SThomas Gleixner u16 mode; /* Mode number (vga= style) */ 86*1cac5004SH. Peter Anvin u16 x, y; /* Width, height */ 87*1cac5004SH. Peter Anvin u16 depth; /* Bits per pixel, 0 for text mode */ 8896ae6ea0SThomas Gleixner }; 8996ae6ea0SThomas Gleixner 9096ae6ea0SThomas Gleixner struct card_info { 9196ae6ea0SThomas Gleixner const char *card_name; 9296ae6ea0SThomas Gleixner int (*set_mode)(struct mode_info *mode); 9396ae6ea0SThomas Gleixner int (*probe)(void); 9496ae6ea0SThomas Gleixner struct mode_info *modes; 9596ae6ea0SThomas Gleixner int nmodes; /* Number of probed modes so far */ 9696ae6ea0SThomas Gleixner int unsafe; /* Probing is unsafe, only do after "scan" */ 9796ae6ea0SThomas Gleixner u16 xmode_first; /* Unprobed modes to try to call anyway */ 9896ae6ea0SThomas Gleixner u16 xmode_n; /* Size of unprobed mode range */ 9996ae6ea0SThomas Gleixner }; 10096ae6ea0SThomas Gleixner 10196ae6ea0SThomas Gleixner #define __videocard struct card_info __attribute__((section(".videocards"))) 10296ae6ea0SThomas Gleixner extern struct card_info video_cards[], video_cards_end[]; 10396ae6ea0SThomas Gleixner 10496ae6ea0SThomas Gleixner int mode_defined(u16 mode); /* video.c */ 10596ae6ea0SThomas Gleixner 10696ae6ea0SThomas Gleixner /* Basic video information */ 10796ae6ea0SThomas Gleixner #define ADAPTER_CGA 0 /* CGA/MDA/HGC */ 10896ae6ea0SThomas Gleixner #define ADAPTER_EGA 1 10996ae6ea0SThomas Gleixner #define ADAPTER_VGA 2 11096ae6ea0SThomas Gleixner 11196ae6ea0SThomas Gleixner extern int adapter; 11296ae6ea0SThomas Gleixner extern u16 video_segment; 11396ae6ea0SThomas Gleixner extern int force_x, force_y; /* Don't query the BIOS for cols/rows */ 11496ae6ea0SThomas Gleixner extern int do_restore; /* Restore screen contents */ 11596ae6ea0SThomas Gleixner extern int graphic_mode; /* Graphics mode with linear frame buffer */ 11696ae6ea0SThomas Gleixner 11796ae6ea0SThomas Gleixner /* 11896ae6ea0SThomas Gleixner * int $0x10 is notorious for touching registers it shouldn't. 11996ae6ea0SThomas Gleixner * gcc doesn't like %ebp being clobbered, so define it as a push/pop 12096ae6ea0SThomas Gleixner * sequence here. 12196ae6ea0SThomas Gleixner * 12296ae6ea0SThomas Gleixner * A number of systems, including the original PC can clobber %bp in 12396ae6ea0SThomas Gleixner * certain circumstances, like when scrolling. There exists at least 12496ae6ea0SThomas Gleixner * one Trident video card which could clobber DS under a set of 12596ae6ea0SThomas Gleixner * circumstances that we are unlikely to encounter (scrolling when 12696ae6ea0SThomas Gleixner * using an extended graphics mode of more than 800x600 pixels), but 12796ae6ea0SThomas Gleixner * it's cheap insurance to deal with that here. 12896ae6ea0SThomas Gleixner */ 12996ae6ea0SThomas Gleixner #define INT10 "pushl %%ebp; pushw %%ds; int $0x10; popw %%ds; popl %%ebp" 13096ae6ea0SThomas Gleixner 13196ae6ea0SThomas Gleixner /* Accessing VGA indexed registers */ 13296ae6ea0SThomas Gleixner static inline u8 in_idx(u16 port, u8 index) 13396ae6ea0SThomas Gleixner { 13496ae6ea0SThomas Gleixner outb(index, port); 13596ae6ea0SThomas Gleixner return inb(port+1); 13696ae6ea0SThomas Gleixner } 13796ae6ea0SThomas Gleixner 13896ae6ea0SThomas Gleixner static inline void out_idx(u8 v, u16 port, u8 index) 13996ae6ea0SThomas Gleixner { 14096ae6ea0SThomas Gleixner outw(index+(v << 8), port); 14196ae6ea0SThomas Gleixner } 14296ae6ea0SThomas Gleixner 14396ae6ea0SThomas Gleixner /* Writes a value to an indexed port and then reads the port again */ 14496ae6ea0SThomas Gleixner static inline u8 tst_idx(u8 v, u16 port, u8 index) 14596ae6ea0SThomas Gleixner { 14696ae6ea0SThomas Gleixner out_idx(port, index, v); 14796ae6ea0SThomas Gleixner return in_idx(port, index); 14896ae6ea0SThomas Gleixner } 14996ae6ea0SThomas Gleixner 15096ae6ea0SThomas Gleixner /* Get the I/O port of the VGA CRTC */ 15196ae6ea0SThomas Gleixner u16 vga_crtc(void); /* video-vga.c */ 15296ae6ea0SThomas Gleixner 15396ae6ea0SThomas Gleixner #endif /* BOOT_VIDEO_H */ 154