xref: /openbmc/linux/arch/x86/boot/video.h (revision 96ae6ea0be1b902c28b3b463c27da42b41e2b63a)
1*96ae6ea0SThomas Gleixner /* -*- linux-c -*- ------------------------------------------------------- *
2*96ae6ea0SThomas Gleixner  *
3*96ae6ea0SThomas Gleixner  *   Copyright (C) 1991, 1992 Linus Torvalds
4*96ae6ea0SThomas Gleixner  *   Copyright 2007 rPath, Inc. - All Rights Reserved
5*96ae6ea0SThomas Gleixner  *
6*96ae6ea0SThomas Gleixner  *   This file is part of the Linux kernel, and is made available under
7*96ae6ea0SThomas Gleixner  *   the terms of the GNU General Public License version 2.
8*96ae6ea0SThomas Gleixner  *
9*96ae6ea0SThomas Gleixner  * ----------------------------------------------------------------------- */
10*96ae6ea0SThomas Gleixner 
11*96ae6ea0SThomas Gleixner /*
12*96ae6ea0SThomas Gleixner  * arch/i386/boot/video.h
13*96ae6ea0SThomas Gleixner  *
14*96ae6ea0SThomas Gleixner  * Header file for the real-mode video probing code
15*96ae6ea0SThomas Gleixner  */
16*96ae6ea0SThomas Gleixner 
17*96ae6ea0SThomas Gleixner #ifndef BOOT_VIDEO_H
18*96ae6ea0SThomas Gleixner #define BOOT_VIDEO_H
19*96ae6ea0SThomas Gleixner 
20*96ae6ea0SThomas Gleixner #include <linux/types.h>
21*96ae6ea0SThomas Gleixner 
22*96ae6ea0SThomas Gleixner /* Enable autodetection of SVGA adapters and modes. */
23*96ae6ea0SThomas Gleixner #undef CONFIG_VIDEO_SVGA
24*96ae6ea0SThomas Gleixner 
25*96ae6ea0SThomas Gleixner /* Enable autodetection of VESA modes */
26*96ae6ea0SThomas Gleixner #define CONFIG_VIDEO_VESA
27*96ae6ea0SThomas Gleixner 
28*96ae6ea0SThomas Gleixner /* Retain screen contents when switching modes */
29*96ae6ea0SThomas Gleixner #define CONFIG_VIDEO_RETAIN
30*96ae6ea0SThomas Gleixner 
31*96ae6ea0SThomas Gleixner /* Force 400 scan lines for standard modes (hack to fix bad BIOS behaviour */
32*96ae6ea0SThomas Gleixner #undef CONFIG_VIDEO_400_HACK
33*96ae6ea0SThomas Gleixner 
34*96ae6ea0SThomas Gleixner /* This code uses an extended set of video mode numbers. These include:
35*96ae6ea0SThomas Gleixner  * Aliases for standard modes
36*96ae6ea0SThomas Gleixner  *      NORMAL_VGA (-1)
37*96ae6ea0SThomas Gleixner  *      EXTENDED_VGA (-2)
38*96ae6ea0SThomas Gleixner  *      ASK_VGA (-3)
39*96ae6ea0SThomas Gleixner  * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
40*96ae6ea0SThomas Gleixner  * of compatibility when extending the table. These are between 0x00 and 0xff.
41*96ae6ea0SThomas Gleixner  */
42*96ae6ea0SThomas Gleixner #define VIDEO_FIRST_MENU 0x0000
43*96ae6ea0SThomas Gleixner 
44*96ae6ea0SThomas Gleixner /* Standard BIOS video modes (BIOS number + 0x0100) */
45*96ae6ea0SThomas Gleixner #define VIDEO_FIRST_BIOS 0x0100
46*96ae6ea0SThomas Gleixner 
47*96ae6ea0SThomas Gleixner /* VESA BIOS video modes (VESA number + 0x0200) */
48*96ae6ea0SThomas Gleixner #define VIDEO_FIRST_VESA 0x0200
49*96ae6ea0SThomas Gleixner 
50*96ae6ea0SThomas Gleixner /* Video7 special modes (BIOS number + 0x0900) */
51*96ae6ea0SThomas Gleixner #define VIDEO_FIRST_V7 0x0900
52*96ae6ea0SThomas Gleixner 
53*96ae6ea0SThomas Gleixner /* Special video modes */
54*96ae6ea0SThomas Gleixner #define VIDEO_FIRST_SPECIAL 0x0f00
55*96ae6ea0SThomas Gleixner #define VIDEO_80x25 0x0f00
56*96ae6ea0SThomas Gleixner #define VIDEO_8POINT 0x0f01
57*96ae6ea0SThomas Gleixner #define VIDEO_80x43 0x0f02
58*96ae6ea0SThomas Gleixner #define VIDEO_80x28 0x0f03
59*96ae6ea0SThomas Gleixner #define VIDEO_CURRENT_MODE 0x0f04
60*96ae6ea0SThomas Gleixner #define VIDEO_80x30 0x0f05
61*96ae6ea0SThomas Gleixner #define VIDEO_80x34 0x0f06
62*96ae6ea0SThomas Gleixner #define VIDEO_80x60 0x0f07
63*96ae6ea0SThomas Gleixner #define VIDEO_GFX_HACK 0x0f08
64*96ae6ea0SThomas Gleixner #define VIDEO_LAST_SPECIAL 0x0f09
65*96ae6ea0SThomas Gleixner 
66*96ae6ea0SThomas Gleixner /* Video modes given by resolution */
67*96ae6ea0SThomas Gleixner #define VIDEO_FIRST_RESOLUTION 0x1000
68*96ae6ea0SThomas Gleixner 
69*96ae6ea0SThomas Gleixner /* The "recalculate timings" flag */
70*96ae6ea0SThomas Gleixner #define VIDEO_RECALC 0x8000
71*96ae6ea0SThomas Gleixner 
72*96ae6ea0SThomas Gleixner /* Define DO_STORE according to CONFIG_VIDEO_RETAIN */
73*96ae6ea0SThomas Gleixner #ifdef CONFIG_VIDEO_RETAIN
74*96ae6ea0SThomas Gleixner void store_screen(void);
75*96ae6ea0SThomas Gleixner #define DO_STORE() store_screen()
76*96ae6ea0SThomas Gleixner #else
77*96ae6ea0SThomas Gleixner #define DO_STORE() ((void)0)
78*96ae6ea0SThomas Gleixner #endif /* CONFIG_VIDEO_RETAIN */
79*96ae6ea0SThomas Gleixner 
80*96ae6ea0SThomas Gleixner /*
81*96ae6ea0SThomas Gleixner  * Mode table structures
82*96ae6ea0SThomas Gleixner  */
83*96ae6ea0SThomas Gleixner 
84*96ae6ea0SThomas Gleixner struct mode_info {
85*96ae6ea0SThomas Gleixner 	u16 mode;		/* Mode number (vga= style) */
86*96ae6ea0SThomas Gleixner 	u8  x, y;		/* Width, height */
87*96ae6ea0SThomas Gleixner };
88*96ae6ea0SThomas Gleixner 
89*96ae6ea0SThomas Gleixner struct card_info {
90*96ae6ea0SThomas Gleixner 	const char *card_name;
91*96ae6ea0SThomas Gleixner 	int (*set_mode)(struct mode_info *mode);
92*96ae6ea0SThomas Gleixner 	int (*probe)(void);
93*96ae6ea0SThomas Gleixner 	struct mode_info *modes;
94*96ae6ea0SThomas Gleixner 	int nmodes;		/* Number of probed modes so far */
95*96ae6ea0SThomas Gleixner 	int unsafe;		/* Probing is unsafe, only do after "scan" */
96*96ae6ea0SThomas Gleixner 	u16 xmode_first;	/* Unprobed modes to try to call anyway */
97*96ae6ea0SThomas Gleixner 	u16 xmode_n;		/* Size of unprobed mode range */
98*96ae6ea0SThomas Gleixner };
99*96ae6ea0SThomas Gleixner 
100*96ae6ea0SThomas Gleixner #define __videocard struct card_info __attribute__((section(".videocards")))
101*96ae6ea0SThomas Gleixner extern struct card_info video_cards[], video_cards_end[];
102*96ae6ea0SThomas Gleixner 
103*96ae6ea0SThomas Gleixner int mode_defined(u16 mode);	/* video.c */
104*96ae6ea0SThomas Gleixner 
105*96ae6ea0SThomas Gleixner /* Basic video information */
106*96ae6ea0SThomas Gleixner #define ADAPTER_CGA	0	/* CGA/MDA/HGC */
107*96ae6ea0SThomas Gleixner #define ADAPTER_EGA	1
108*96ae6ea0SThomas Gleixner #define ADAPTER_VGA	2
109*96ae6ea0SThomas Gleixner 
110*96ae6ea0SThomas Gleixner extern int adapter;
111*96ae6ea0SThomas Gleixner extern u16 video_segment;
112*96ae6ea0SThomas Gleixner extern int force_x, force_y;	/* Don't query the BIOS for cols/rows */
113*96ae6ea0SThomas Gleixner extern int do_restore;		/* Restore screen contents */
114*96ae6ea0SThomas Gleixner extern int graphic_mode;	/* Graphics mode with linear frame buffer */
115*96ae6ea0SThomas Gleixner 
116*96ae6ea0SThomas Gleixner /*
117*96ae6ea0SThomas Gleixner  * int $0x10 is notorious for touching registers it shouldn't.
118*96ae6ea0SThomas Gleixner  * gcc doesn't like %ebp being clobbered, so define it as a push/pop
119*96ae6ea0SThomas Gleixner  * sequence here.
120*96ae6ea0SThomas Gleixner  *
121*96ae6ea0SThomas Gleixner  * A number of systems, including the original PC can clobber %bp in
122*96ae6ea0SThomas Gleixner  * certain circumstances, like when scrolling.  There exists at least
123*96ae6ea0SThomas Gleixner  * one Trident video card which could clobber DS under a set of
124*96ae6ea0SThomas Gleixner  * circumstances that we are unlikely to encounter (scrolling when
125*96ae6ea0SThomas Gleixner  * using an extended graphics mode of more than 800x600 pixels), but
126*96ae6ea0SThomas Gleixner  * it's cheap insurance to deal with that here.
127*96ae6ea0SThomas Gleixner  */
128*96ae6ea0SThomas Gleixner #define INT10 "pushl %%ebp; pushw %%ds; int $0x10; popw %%ds; popl %%ebp"
129*96ae6ea0SThomas Gleixner 
130*96ae6ea0SThomas Gleixner /* Accessing VGA indexed registers */
131*96ae6ea0SThomas Gleixner static inline u8 in_idx(u16 port, u8 index)
132*96ae6ea0SThomas Gleixner {
133*96ae6ea0SThomas Gleixner 	outb(index, port);
134*96ae6ea0SThomas Gleixner 	return inb(port+1);
135*96ae6ea0SThomas Gleixner }
136*96ae6ea0SThomas Gleixner 
137*96ae6ea0SThomas Gleixner static inline void out_idx(u8 v, u16 port, u8 index)
138*96ae6ea0SThomas Gleixner {
139*96ae6ea0SThomas Gleixner 	outw(index+(v << 8), port);
140*96ae6ea0SThomas Gleixner }
141*96ae6ea0SThomas Gleixner 
142*96ae6ea0SThomas Gleixner /* Writes a value to an indexed port and then reads the port again */
143*96ae6ea0SThomas Gleixner static inline u8 tst_idx(u8 v, u16 port, u8 index)
144*96ae6ea0SThomas Gleixner {
145*96ae6ea0SThomas Gleixner 	out_idx(port, index, v);
146*96ae6ea0SThomas Gleixner 	return in_idx(port, index);
147*96ae6ea0SThomas Gleixner }
148*96ae6ea0SThomas Gleixner 
149*96ae6ea0SThomas Gleixner /* Get the I/O port of the VGA CRTC */
150*96ae6ea0SThomas Gleixner u16 vga_crtc(void);		/* video-vga.c */
151*96ae6ea0SThomas Gleixner 
152*96ae6ea0SThomas Gleixner #endif /* BOOT_VIDEO_H */
153