xref: /haiku/headers/private/graphics/vesa/vesa.h (revision b2a75cf56cafe2cf4b9258311e1d331bd48ab081)
1a5ff23c7SAxel Dörfler /*
2bfd4c59bSAxel Dörfler  * Copyright 2004-2009, Axel Dörfler, axeld@pinc-software.de.
3b4c8ccc3SAxel Dörfler  * Distributed under the terms of the MIT License.
4a5ff23c7SAxel Dörfler  */
5a5ff23c7SAxel Dörfler #ifndef VESA_H
6a5ff23c7SAxel Dörfler #define VESA_H
7a5ff23c7SAxel Dörfler 
8a5ff23c7SAxel Dörfler 
9a5ff23c7SAxel Dörfler #include <SupportDefs.h>
10a5ff23c7SAxel Dörfler 
11a5ff23c7SAxel Dörfler 
12a5ff23c7SAxel Dörfler /* VBE info block structure */
13a5ff23c7SAxel Dörfler 
14a5ff23c7SAxel Dörfler #define VESA_SIGNATURE	'ASEV'
15a5ff23c7SAxel Dörfler #define VBE2_SIGNATURE	'2EBV'
16a5ff23c7SAxel Dörfler 
17a5ff23c7SAxel Dörfler struct vbe_info_block {
18a5ff23c7SAxel Dörfler 	// VBE 1.x fields
19a5ff23c7SAxel Dörfler 	uint32		signature;
20a5ff23c7SAxel Dörfler 	struct {
21a5ff23c7SAxel Dörfler 		uint8	minor;
22a5ff23c7SAxel Dörfler 		uint8	major;
23a5ff23c7SAxel Dörfler 	} version;
24a5ff23c7SAxel Dörfler 	uint32		oem_string;
25a5ff23c7SAxel Dörfler 	uint32		capabilities;
26a5ff23c7SAxel Dörfler 	uint32		mode_list;
27a5ff23c7SAxel Dörfler 	uint16		total_memory;	// in 64k blocks
28a5ff23c7SAxel Dörfler 	// VBE 2.0+ fields only
29a5ff23c7SAxel Dörfler 	// Note, the block is 256 bytes in size for VBE 1.x as well,
30a5ff23c7SAxel Dörfler 	// but doesn't define these fields. VBE 3 doesn't define
31a5ff23c7SAxel Dörfler 	// any additional fields.
32a5ff23c7SAxel Dörfler 	uint16		oem_software_revision;
33a5ff23c7SAxel Dörfler 	uint32		oem_vendor_name_string;
34a5ff23c7SAxel Dörfler 	uint32		oem_product_name_string;
35a5ff23c7SAxel Dörfler 	uint32		oem_product_revision_string;
36a5ff23c7SAxel Dörfler 	uint8		reserved[222];
37a5ff23c7SAxel Dörfler 	uint8		oem_data[256];
38a5ff23c7SAxel Dörfler } _PACKED;
39a5ff23c7SAxel Dörfler 
40bb693d77SAxel Dörfler // capabilities
41bb693d77SAxel Dörfler #define CAPABILITY_DAC_WIDTH			0x01
42*b2a75cf5SAxel Dörfler #define CAPABILITY_NOT_VGA_COMPATIBLE	0x02
43bb693d77SAxel Dörfler 
44a5ff23c7SAxel Dörfler 
45a5ff23c7SAxel Dörfler /* VBE mode info structure */
46a5ff23c7SAxel Dörfler 
47a5ff23c7SAxel Dörfler struct vbe_mode_info {
48a5ff23c7SAxel Dörfler 	uint16		attributes;
49a5ff23c7SAxel Dörfler 	uint8		window_a_attributes;
50a5ff23c7SAxel Dörfler 	uint8		window_b_attributes;
5113247f3aSAxel Dörfler 	uint16		window_granularity;
52a5ff23c7SAxel Dörfler 	uint16		window_size;
53a5ff23c7SAxel Dörfler 	uint16		window_a_segment;
54a5ff23c7SAxel Dörfler 	uint16		window_b_segment;
55a5ff23c7SAxel Dörfler 	uint32		window_function;	// real mode pointer
56a5ff23c7SAxel Dörfler 	uint16		bytes_per_row;
57a5ff23c7SAxel Dörfler 
58a5ff23c7SAxel Dörfler 	// VBE 1.2 and above
59a5ff23c7SAxel Dörfler 	uint16		width;
60a5ff23c7SAxel Dörfler 	uint16		height;
61a5ff23c7SAxel Dörfler 	uint8		char_width;
62a5ff23c7SAxel Dörfler 	uint8		char_height;
63a5ff23c7SAxel Dörfler 	uint8		num_planes;
64a5ff23c7SAxel Dörfler 	uint8		bits_per_pixel;
65a5ff23c7SAxel Dörfler 	uint8		num_banks;
66a5ff23c7SAxel Dörfler 	uint8		memory_model;
67a5ff23c7SAxel Dörfler 	uint8		bank_size;
68a5ff23c7SAxel Dörfler 	uint8		num_image_pages;
69a5ff23c7SAxel Dörfler 	uint8		_reserved0;
70a5ff23c7SAxel Dörfler 
71a5ff23c7SAxel Dörfler 	// direct color fields
72a5ff23c7SAxel Dörfler 	uint8		red_mask_size;
73a5ff23c7SAxel Dörfler 	uint8		red_field_position;
74a5ff23c7SAxel Dörfler 	uint8		green_mask_size;
75a5ff23c7SAxel Dörfler 	uint8		green_field_position;
76a5ff23c7SAxel Dörfler 	uint8		blue_mask_size;
77a5ff23c7SAxel Dörfler 	uint8		blue_field_position;
78a5ff23c7SAxel Dörfler 	uint8		reserved_mask_size;
79a5ff23c7SAxel Dörfler 	uint8		reserved_field_position;
80a5ff23c7SAxel Dörfler 	uint8		direct_color_mode_info;
81a5ff23c7SAxel Dörfler 
82a5ff23c7SAxel Dörfler 	// VBE 2.0 and above
83a5ff23c7SAxel Dörfler 	uint32		physical_base;
84a5ff23c7SAxel Dörfler 	uint32		_reserved1;
85a5ff23c7SAxel Dörfler 	uint16		_reserved2;
86a5ff23c7SAxel Dörfler 
87a5ff23c7SAxel Dörfler 	// VBE 3.0 and above
88a5ff23c7SAxel Dörfler 	uint16		linear_bytes_per_row;
89a5ff23c7SAxel Dörfler 	uint8		banked_num_image_pages;
90a5ff23c7SAxel Dörfler 	uint8		linear_num_image_pages;
91a5ff23c7SAxel Dörfler 
92a5ff23c7SAxel Dörfler 	uint8		linear_red_mask_size;
93a5ff23c7SAxel Dörfler 	uint8		linear_red_field_position;
94a5ff23c7SAxel Dörfler 	uint8		linear_green_mask_size;
95a5ff23c7SAxel Dörfler 	uint8		linear_green_field_position;
96a5ff23c7SAxel Dörfler 	uint8		linear_blue_mask_size;
97a5ff23c7SAxel Dörfler 	uint8		linear_blue_field_position;
98a5ff23c7SAxel Dörfler 	uint8		linear_reserved_mask_size;
99a5ff23c7SAxel Dörfler 	uint8		linear_reserved_field_position;
100a5ff23c7SAxel Dörfler 
101a5ff23c7SAxel Dörfler 	uint32		max_pixel_clock;		// in Hz
102a5ff23c7SAxel Dörfler 
103a5ff23c7SAxel Dörfler 	uint8		_reserved[189];
104a5ff23c7SAxel Dörfler } _PACKED;
105a5ff23c7SAxel Dörfler 
106a5ff23c7SAxel Dörfler // definitions of mode info attributes
107a5ff23c7SAxel Dörfler #define MODE_ATTR_AVAILABLE		1
108a5ff23c7SAxel Dörfler #define MODE_ATTR_COLOR_MODE	8
109a5ff23c7SAxel Dörfler #define MODE_ATTR_GRAPHICS_MODE	16
110a5ff23c7SAxel Dörfler #define MODE_ATTR_LINEAR_BUFFER	128
111a5ff23c7SAxel Dörfler 
112a5ff23c7SAxel Dörfler // memory models
113a5ff23c7SAxel Dörfler #define MODE_MEMORY_TEXT			0
114a5ff23c7SAxel Dörfler #define MODE_MEMORY_PLANAR			3
115a5ff23c7SAxel Dörfler #define MODE_MEMORY_PACKED_PIXEL	4
116a5ff23c7SAxel Dörfler #define MODE_MEMORY_DIRECT_COLOR	6
117a5ff23c7SAxel Dörfler #define MODE_MEMORY_YUV				7
118a5ff23c7SAxel Dörfler 
119a5ff23c7SAxel Dörfler // set mode flags
120a5ff23c7SAxel Dörfler #define SET_MODE_MASK				0x01ff
121a5ff23c7SAxel Dörfler #define SET_MODE_SPECIFY_CRTC		(1 << 11)
122a5ff23c7SAxel Dörfler #define SET_MODE_LINEAR_BUFFER		(1 << 14)
123a5ff23c7SAxel Dörfler #define SET_MODE_DONT_CLEAR_MEMORY	(1 << 15)
124a5ff23c7SAxel Dörfler 
125a5ff23c7SAxel Dörfler 
126b4c8ccc3SAxel Dörfler /* CRTC info block structure */
127b4c8ccc3SAxel Dörfler 
128b4c8ccc3SAxel Dörfler struct crtc_info_block {
129b4c8ccc3SAxel Dörfler 	uint16	horizontal_total;
130b4c8ccc3SAxel Dörfler 	uint16	horizontal_sync_start;
131b4c8ccc3SAxel Dörfler 	uint16	horizontal_sync_end;
132b4c8ccc3SAxel Dörfler 	uint16	vertical_total;
133b4c8ccc3SAxel Dörfler 	uint16	vertical_sync_start;
134b4c8ccc3SAxel Dörfler 	uint16	vertical_sync_end;
135b4c8ccc3SAxel Dörfler 	uint8	flags;
136b4c8ccc3SAxel Dörfler 	uint32	pixel_clock;		// in Hz
137b4c8ccc3SAxel Dörfler 	uint16	refresh_rate;		// in 0.01 Hz
138b4c8ccc3SAxel Dörfler 
139b4c8ccc3SAxel Dörfler 	uint8	_reserved[40];
140b4c8ccc3SAxel Dörfler } _PACKED;
141b4c8ccc3SAxel Dörfler 
142b4c8ccc3SAxel Dörfler #define CRTC_DOUBLE_SCAN		0x01
143b4c8ccc3SAxel Dörfler #define CRTC_INTERLACED			0x02
144b4c8ccc3SAxel Dörfler #define CRTC_NEGATIVE_HSYNC		0x04
145b4c8ccc3SAxel Dörfler #define CRTC_NEGATIVE_VSYNC		0x08
146b4c8ccc3SAxel Dörfler 
147b4c8ccc3SAxel Dörfler 
148bfd4c59bSAxel Dörfler /* Power Management */
149bfd4c59bSAxel Dörfler 
150bfd4c59bSAxel Dörfler #define DPMS_ON					0x00
151bfd4c59bSAxel Dörfler #define DPMS_STANDBY			0x01
152bfd4c59bSAxel Dörfler #define	DPMS_SUSPEND			0x02
153bfd4c59bSAxel Dörfler #define DPMS_OFF				0x04
154bfd4c59bSAxel Dörfler #define DPMS_REDUCED_ON			0x08
155bfd4c59bSAxel Dörfler 
156bfd4c59bSAxel Dörfler 
157a5ff23c7SAxel Dörfler /* VBE 3.0 protected mode interface
158a5ff23c7SAxel Dörfler  * The BIOS area can be scanned for the protected mode
159a5ff23c7SAxel Dörfler  * signature that identifies the structure below.
160a5ff23c7SAxel Dörfler  */
161a5ff23c7SAxel Dörfler 
162a5ff23c7SAxel Dörfler #define VBE_PM_SIGNATURE 'DIMP'
163a5ff23c7SAxel Dörfler 
164a5ff23c7SAxel Dörfler struct vbe_protected_mode_info {
165a5ff23c7SAxel Dörfler 	uint32		signature;
166a5ff23c7SAxel Dörfler 	int16		entry_offset;
167a5ff23c7SAxel Dörfler 	int16		init_offset;
168a5ff23c7SAxel Dörfler 	uint16		data_selector;
169a5ff23c7SAxel Dörfler 	uint16		a000_selector;
170a5ff23c7SAxel Dörfler 	uint16		b000_selector;
171a5ff23c7SAxel Dörfler 	uint16		b800_selector;
172a5ff23c7SAxel Dörfler 	uint16		c000_selector;
173a5ff23c7SAxel Dörfler 	uint8		in_protected_mode;
174a5ff23c7SAxel Dörfler 	uint8		checksum;
175a5ff23c7SAxel Dörfler } _PACKED;
176a5ff23c7SAxel Dörfler 
177a5ff23c7SAxel Dörfler #endif	/* VESA_H */
178