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