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 * Header file for the real-mode video probing code 1396ae6ea0SThomas Gleixner */ 1496ae6ea0SThomas Gleixner 1596ae6ea0SThomas Gleixner #ifndef BOOT_VIDEO_H 1696ae6ea0SThomas Gleixner #define BOOT_VIDEO_H 1796ae6ea0SThomas Gleixner 1896ae6ea0SThomas Gleixner #include <linux/types.h> 1996ae6ea0SThomas Gleixner 20*2495fbf7SH. Peter Anvin /* 21*2495fbf7SH. Peter Anvin * This code uses an extended set of video mode numbers. These include: 2296ae6ea0SThomas Gleixner * Aliases for standard modes 2396ae6ea0SThomas Gleixner * NORMAL_VGA (-1) 2496ae6ea0SThomas Gleixner * EXTENDED_VGA (-2) 2596ae6ea0SThomas Gleixner * ASK_VGA (-3) 2696ae6ea0SThomas Gleixner * Video modes numbered by menu position -- NOT RECOMMENDED because of lack 2796ae6ea0SThomas Gleixner * of compatibility when extending the table. These are between 0x00 and 0xff. 2896ae6ea0SThomas Gleixner */ 2996ae6ea0SThomas Gleixner #define VIDEO_FIRST_MENU 0x0000 3096ae6ea0SThomas Gleixner 3196ae6ea0SThomas Gleixner /* Standard BIOS video modes (BIOS number + 0x0100) */ 3296ae6ea0SThomas Gleixner #define VIDEO_FIRST_BIOS 0x0100 3396ae6ea0SThomas Gleixner 3496ae6ea0SThomas Gleixner /* VESA BIOS video modes (VESA number + 0x0200) */ 3596ae6ea0SThomas Gleixner #define VIDEO_FIRST_VESA 0x0200 3696ae6ea0SThomas Gleixner 3796ae6ea0SThomas Gleixner /* Video7 special modes (BIOS number + 0x0900) */ 3896ae6ea0SThomas Gleixner #define VIDEO_FIRST_V7 0x0900 3996ae6ea0SThomas Gleixner 4096ae6ea0SThomas Gleixner /* Special video modes */ 4196ae6ea0SThomas Gleixner #define VIDEO_FIRST_SPECIAL 0x0f00 4296ae6ea0SThomas Gleixner #define VIDEO_80x25 0x0f00 4396ae6ea0SThomas Gleixner #define VIDEO_8POINT 0x0f01 4496ae6ea0SThomas Gleixner #define VIDEO_80x43 0x0f02 4596ae6ea0SThomas Gleixner #define VIDEO_80x28 0x0f03 4696ae6ea0SThomas Gleixner #define VIDEO_CURRENT_MODE 0x0f04 4796ae6ea0SThomas Gleixner #define VIDEO_80x30 0x0f05 4896ae6ea0SThomas Gleixner #define VIDEO_80x34 0x0f06 4996ae6ea0SThomas Gleixner #define VIDEO_80x60 0x0f07 5096ae6ea0SThomas Gleixner #define VIDEO_GFX_HACK 0x0f08 5196ae6ea0SThomas Gleixner #define VIDEO_LAST_SPECIAL 0x0f09 5296ae6ea0SThomas Gleixner 5396ae6ea0SThomas Gleixner /* Video modes given by resolution */ 5496ae6ea0SThomas Gleixner #define VIDEO_FIRST_RESOLUTION 0x1000 5596ae6ea0SThomas Gleixner 5696ae6ea0SThomas Gleixner /* The "recalculate timings" flag */ 5796ae6ea0SThomas Gleixner #define VIDEO_RECALC 0x8000 5896ae6ea0SThomas Gleixner 5996ae6ea0SThomas Gleixner void store_screen(void); 6096ae6ea0SThomas Gleixner #define DO_STORE() store_screen() 6196ae6ea0SThomas Gleixner 6296ae6ea0SThomas Gleixner /* 6396ae6ea0SThomas Gleixner * Mode table structures 6496ae6ea0SThomas Gleixner */ 6596ae6ea0SThomas Gleixner 6696ae6ea0SThomas Gleixner struct mode_info { 6796ae6ea0SThomas Gleixner u16 mode; /* Mode number (vga= style) */ 681cac5004SH. Peter Anvin u16 x, y; /* Width, height */ 691cac5004SH. Peter Anvin u16 depth; /* Bits per pixel, 0 for text mode */ 7096ae6ea0SThomas Gleixner }; 7196ae6ea0SThomas Gleixner 7296ae6ea0SThomas Gleixner struct card_info { 7396ae6ea0SThomas Gleixner const char *card_name; 7496ae6ea0SThomas Gleixner int (*set_mode)(struct mode_info *mode); 7596ae6ea0SThomas Gleixner int (*probe)(void); 7696ae6ea0SThomas Gleixner struct mode_info *modes; 7796ae6ea0SThomas Gleixner int nmodes; /* Number of probed modes so far */ 7896ae6ea0SThomas Gleixner int unsafe; /* Probing is unsafe, only do after "scan" */ 7996ae6ea0SThomas Gleixner u16 xmode_first; /* Unprobed modes to try to call anyway */ 8096ae6ea0SThomas Gleixner u16 xmode_n; /* Size of unprobed mode range */ 8196ae6ea0SThomas Gleixner }; 8296ae6ea0SThomas Gleixner 8396ae6ea0SThomas Gleixner #define __videocard struct card_info __attribute__((section(".videocards"))) 8496ae6ea0SThomas Gleixner extern struct card_info video_cards[], video_cards_end[]; 8596ae6ea0SThomas Gleixner 8696ae6ea0SThomas Gleixner int mode_defined(u16 mode); /* video.c */ 8796ae6ea0SThomas Gleixner 8896ae6ea0SThomas Gleixner /* Basic video information */ 8996ae6ea0SThomas Gleixner #define ADAPTER_CGA 0 /* CGA/MDA/HGC */ 9096ae6ea0SThomas Gleixner #define ADAPTER_EGA 1 9196ae6ea0SThomas Gleixner #define ADAPTER_VGA 2 9296ae6ea0SThomas Gleixner 9396ae6ea0SThomas Gleixner extern int adapter; 9496ae6ea0SThomas Gleixner extern u16 video_segment; 9596ae6ea0SThomas Gleixner extern int force_x, force_y; /* Don't query the BIOS for cols/rows */ 9696ae6ea0SThomas Gleixner extern int do_restore; /* Restore screen contents */ 9796ae6ea0SThomas Gleixner extern int graphic_mode; /* Graphics mode with linear frame buffer */ 9896ae6ea0SThomas Gleixner 9996ae6ea0SThomas Gleixner /* Accessing VGA indexed registers */ 10096ae6ea0SThomas Gleixner static inline u8 in_idx(u16 port, u8 index) 10196ae6ea0SThomas Gleixner { 10296ae6ea0SThomas Gleixner outb(index, port); 10396ae6ea0SThomas Gleixner return inb(port+1); 10496ae6ea0SThomas Gleixner } 10596ae6ea0SThomas Gleixner 10696ae6ea0SThomas Gleixner static inline void out_idx(u8 v, u16 port, u8 index) 10796ae6ea0SThomas Gleixner { 10896ae6ea0SThomas Gleixner outw(index+(v << 8), port); 10996ae6ea0SThomas Gleixner } 11096ae6ea0SThomas Gleixner 11196ae6ea0SThomas Gleixner /* Writes a value to an indexed port and then reads the port again */ 11296ae6ea0SThomas Gleixner static inline u8 tst_idx(u8 v, u16 port, u8 index) 11396ae6ea0SThomas Gleixner { 11496ae6ea0SThomas Gleixner out_idx(port, index, v); 11596ae6ea0SThomas Gleixner return in_idx(port, index); 11696ae6ea0SThomas Gleixner } 11796ae6ea0SThomas Gleixner 11896ae6ea0SThomas Gleixner /* Get the I/O port of the VGA CRTC */ 11996ae6ea0SThomas Gleixner u16 vga_crtc(void); /* video-vga.c */ 12096ae6ea0SThomas Gleixner 12196ae6ea0SThomas Gleixner #endif /* BOOT_VIDEO_H */ 122