1
2/*
3This file was originally part of the Linux Real-Mode Interface, or LRMI.
4There is nothing LRMI-specific here; this is all good, general VBE info.
5
6Copyright (C) 1996 by Josh Vanderhoof
7
8You are free to distribute and modify this file, as long as you
9do not remove this copyright notice and clearly label modified
10versions as being modified.
11
12This software has NO WARRANTY.  Use it at your own risk.
13*/
14
15#ifndef SAVAGEVBE_H
16#define SAVAGEVBE_H
17
18/*
19 *  Common BIOS functions
20 */
21
22#define BIOS_SET_VBE_MODE       0x4F02
23#define BIOS_GET_VBE_MODE       0x4F03
24#define BIOS_SVGA_STATE         0x4F04
25#define BIOS_LOG_SCANLINE       0x4F06
26#define BIOS_VBE_PM_SERVICE     0x4F10
27#define S3_EXTBIOS_INFO         0x4F14  /* S3 Extended BIOS services */
28#define BIOS_VBE_DDC            0x4F15
29
30/*************************************************************************
31 *     Defines for BIOS compliant with S3 (Mobile and Desktop) PCI Video
32 *     Bios External Interface Specification, Core Revision 3.02+
33 *
34 *     e.g. used by Trio3D, GX-3
35 *************************************************************************/
36
37#define S3_GET_SVGA_BUF          0x0000
38#define S3_SAVE_SVGA_STATE       0x0001
39#define S3_RESTORE_SVGA_STATE    0x0002
40/*
41 * For S3_EXTBIOS_INFO (0x4F14) services
42 */
43#define S3_VBE_INFO         0x0000  /* fn0: Query S3/VBE info */
44
45#define S3_SET_REFRESH      0x0001  /* fn1,sub0: Set Refresh Rate for Mode */
46#define S3_GET_REFRESH      0x0101  /* fn1,sub1: Get Refresh Rate for Mode */
47#define S3_QUERY_REFRESH    0x0201  /* fn1,sub2: Query Refresh Rates for Mode */
48
49#define S3_QUERY_MODELIST   0x0202  /* fn2,sub2: Query Mode List */
50#define S3_GET_EXT_MODEINFO 0x0302  /* fn2,sub3: Get Extended Mode Info */
51
52#define S3_QUERY_ATTACHED   0x0004  /* fn4,sub0: Query detected displays */
53
54#define S3_GET_ACTIVE_DISP  0x0103  /* fn3,sub1: Get Active Display */
55#define S3_SET_ACTIVE_DISP  0x0003  /* fn3,sub0: Set Active Display */
56#define S3_ALT_SET_ACTIVE_DISP  0x8003  /* fn8003,sub0: Alternate Set Active Display */
57
58#define S3_SET_TV_CONFIG    0x0007  /* fn7,sub0: Set TV Configuration */
59#define S3_GET_TV_CONFIG    0x0107  /* fn7,sub1: Get TV Configuration */
60
61
62#define BIOS_CRT1_ONLY              0x01
63#define BIOS_LCD_ONLY               0x02
64#define BIOS_TV_NTSC                0x04
65#define BIOS_TV_PAL                 0x08
66#define BIOS_TV_ONLY                0x0c
67#define BIOS_DVI_ONLY               0x20
68#define BIOS_DEVICE_MASK            (BIOS_CRT1_ONLY|BIOS_LCD_ONLY|BIOS_TV_ONLY|BIOS_DVI_ONLY)
69
70/* structures for vbe 2.0 */
71
72#ifndef __GNUC__
73#define __attribute__(a)
74#endif
75
76struct vbe_info_block
77	{
78	char vbe_signature[4];
79	short vbe_version;
80	unsigned short oem_string_off;
81	unsigned short oem_string_seg;
82	int capabilities;
83	unsigned short video_mode_list_off;
84	unsigned short video_mode_list_seg;
85	short total_memory;
86	short oem_software_rev;
87	unsigned short oem_vendor_name_off;
88	unsigned short oem_vendor_name_seg;
89	unsigned short oem_product_name_off;
90	unsigned short oem_product_name_seg;
91	unsigned short oem_product_rev_off;
92	unsigned short oem_product_rev_seg;
93	char reserved[222];
94	char oem_data[256];
95	} __attribute__ ((packed));
96
97#define VBE_ATTR_MODE_SUPPORTED 	(1 << 0)
98#define VBE_ATTR_TTY 	(1 << 2)
99#define VBE_ATTR_COLOR 	(1 << 3)
100#define VBE_ATTR_GRAPHICS 	(1 << 4)
101#define VBE_ATTR_NOT_VGA 	(1 << 5)
102#define VBE_ATTR_NOT_WINDOWED 	(1 << 6)
103#define VBE_ATTR_LINEAR 	(1 << 7)
104
105#define VBE_WIN_RELOCATABLE 	(1 << 0)
106#define VBE_WIN_READABLE 	(1 << 1)
107#define VBE_WIN_WRITEABLE 	(1 << 2)
108
109#define VBE_MODEL_TEXT 	0
110#define VBE_MODEL_CGA 	1
111#define VBE_MODEL_HERCULES 	2
112#define VBE_MODEL_PLANAR 	3
113#define VBE_MODEL_PACKED 	4
114#define VBE_MODEL_256 	5
115#define VBE_MODEL_RGB 	6
116#define VBE_MODEL_YUV 	7
117
118struct vbe_mode_info_block
119	{
120	unsigned short mode_attributes;
121	unsigned char win_a_attributes;
122	unsigned char win_b_attributes;
123	unsigned short win_granularity;
124	unsigned short win_size;
125	unsigned short win_a_segment;
126	unsigned short win_b_segment;
127	unsigned short win_func_ptr_off;
128	unsigned short win_func_ptr_seg;
129	unsigned short bytes_per_scanline;
130	unsigned short x_resolution;
131	unsigned short y_resolution;
132	unsigned char x_char_size;
133	unsigned char y_char_size;
134	unsigned char number_of_planes;
135	unsigned char bits_per_pixel;
136	unsigned char number_of_banks;
137	unsigned char memory_model;
138	unsigned char bank_size;
139	unsigned char number_of_image_pages;
140	unsigned char res1;
141	unsigned char red_mask_size;
142	unsigned char red_field_position;
143	unsigned char green_mask_size;
144	unsigned char green_field_position;
145	unsigned char blue_mask_size;
146	unsigned char blue_field_position;
147	unsigned char rsvd_mask_size;
148	unsigned char rsvd_field_position;
149	unsigned char direct_color_mode_info;
150	unsigned int phys_base_ptr;
151	unsigned int offscreen_mem_offset;
152	unsigned short offscreen_mem_size;
153	unsigned char res2[206];
154	} __attribute__ ((packed));
155
156struct vbe_palette_entry
157	{
158	unsigned char blue;
159	unsigned char green;
160	unsigned char red;
161	unsigned char align;
162	} __attribute__ ((packed));
163
164#endif /* SAVAGEVBE_H */
165