Root/
Source at commit 129 created 14 years 2 months ago. By diebuche, Patching my branch. Added typo fixes. | |
---|---|
1 | ␊ |
2 | /* Copied from 915 resolution created by steve tomljenovic␊ |
3 | *␊ |
4 | * This code is based on the techniques used in :␊ |
5 | *␊ |
6 | * - 855patch. Many thanks to Christian Zietz (czietz gmx net)␊ |
7 | * for demonstrating how to shadow the VBIOS into system RAM␊ |
8 | * and then modify it.␊ |
9 | *␊ |
10 | * - 1280patch by Andrew Tipton (andrewtipton null li).␊ |
11 | *␊ |
12 | * - 855resolution by Alain Poirier␊ |
13 | *␊ |
14 | * This source code is into the public domain.␊ |
15 | */␊ |
16 | #ifndef __915_RESOLUTION_H␊ |
17 | #define __915_RESOLUTION_H␊ |
18 | ␊ |
19 | #include "shortatombios.h"␊ |
20 | #include "edid.h"␊ |
21 | ␊ |
22 | #define NEW(a) ((a *)(malloc(sizeof(a))))␊ |
23 | #define FREE(a) (free(a))␊ |
24 | ␊ |
25 | #define VBIOS_START 0xc0000␊ |
26 | #define VBIOS_SIZE 0x10000␊ |
27 | ␊ |
28 | #define FALSE 0␊ |
29 | #define TRUE 1␊ |
30 | ␊ |
31 | #define MODE_TABLE_OFFSET_845G 617␊ |
32 | ␊ |
33 | ␊ |
34 | #define ATI_SIGNATURE1 "ATI MOBILITY RADEON"␊ |
35 | #define ATI_SIGNATURE2 "ATI Technologies Inc"␊ |
36 | #define NVIDIA_SIGNATURE "NVIDIA Corp"␊ |
37 | #define INTEL_SIGNATURE "Intel Corp"␊ |
38 | ␊ |
39 | typedef struct {␊ |
40 | ␉unsigned char width;␊ |
41 | ␉unsigned char height;␊ |
42 | } s_aspect;␊ |
43 | ␊ |
44 | /*␊ |
45 | * NVidia Defines and structures␊ |
46 | */␊ |
47 | ␊ |
48 | #define OFFSET_TO_VESA_TABLE_INDEX 2␊ |
49 | ␊ |
50 | typedef struct {␊ |
51 | ␉unsigned char␉ucTable_Major;␊ |
52 | ␉unsigned char␉ucTable_Minor;␊ |
53 | ␉unsigned char␉ucTable_Rev;␊ |
54 | ␉unsigned short␉usTable_Size;␊ |
55 | } NV_COMMON_TABLE_HEADER;␊ |
56 | ␊ |
57 | typedef struct {␊ |
58 | ␉unsigned short␉usPixel_Clock;␊ |
59 | ␉unsigned short␉usH_Active;␊ |
60 | ␉unsigned short usH_Active_minus_One;␊ |
61 | ␉unsigned short␉reserved1;␊ |
62 | ␉unsigned short usH_Active_minus_One_;␊ |
63 | ␉unsigned short␉usH_SyncStart;␊ |
64 | ␉unsigned short␉usH_SyncEnd;␊ |
65 | ␉unsigned short␉usH_Total;␊ |
66 | ␉unsigned short␉usV_Active;␊ |
67 | ␉unsigned short usV_Active_minus_One;␊ |
68 | ␉unsigned short␉reserved2;␊ |
69 | ␉unsigned short usV_Active_minus_One_;␊ |
70 | ␉unsigned short␉usV_SyncStart;␊ |
71 | ␉unsigned short␉usV_SyncEnd;␊ |
72 | ␉unsigned short␉usV_Total;␊ |
73 | ␉unsigned short␉reserved3;␊ |
74 | } NV_MODELINE;␊ |
75 | ␊ |
76 | typedef struct {␊ |
77 | ␉unsigned short h_disp;␊ |
78 | ␉unsigned short v_disp;␊ |
79 | ␉unsigned char h_blank;␊ |
80 | ␉unsigned char h_syncoffset;␊ |
81 | ␉unsigned char h_syncwidth;␊ |
82 | ␉unsigned char v_blank;␊ |
83 | ␉unsigned char v_syncwidth;␊ |
84 | } NV_MODELINE_2;␊ |
85 | ␊ |
86 | typedef struct {␊ |
87 | ␉NV_COMMON_TABLE_HEADER␉sHeader;␊ |
88 | ␉NV_MODELINE␉*␉␉␉sModelines;␊ |
89 | } NV_VESA_TABLE;␊ |
90 | ␊ |
91 | /*---*/␊ |
92 | ␊ |
93 | ␊ |
94 | typedef enum {␊ |
95 | ␉CT_UNKWN, CT_830, CT_845G, CT_855GM, CT_865G, ␊ |
96 | ␉CT_915G, CT_915GM, CT_945G, CT_945GM, CT_945GME, CT_946GZ, ␊ |
97 | ␉CT_955X, CT_G965, CT_Q965, CT_965GM, CT_975X, ␊ |
98 | ␉CT_P35, CT_X48, CT_B43, CT_Q45, CT_P45,␊ |
99 | ␉CT_GM45, CT_G41, CT_G31, CT_G45, CT_500␊ |
100 | } chipset_type;␊ |
101 | ␊ |
102 | ␊ |
103 | typedef enum {␊ |
104 | ␉BT_UNKWN, BT_1, BT_2, BT_3, BT_ATI_1, BT_ATI_2, BT_NVDA␊ |
105 | } bios_type;␊ |
106 | ␊ |
107 | typedef struct {␊ |
108 | unsigned char *base;␊ |
109 | ATOM_ROM_HEADER *AtomRomHeader;␊ |
110 | unsigned short *MasterCommandTables;␊ |
111 | unsigned short *MasterDataTables;␊ |
112 | } bios_tables_t;␊ |
113 | ␊ |
114 | typedef struct {␊ |
115 | ␉UInt8 mode;␊ |
116 | ␉UInt8 bits_per_pixel;␊ |
117 | ␉UInt16 resolution;␊ |
118 | ␉UInt8 unknown;␊ |
119 | } __attribute__((packed)) vbios_mode;␊ |
120 | ␊ |
121 | typedef struct {␊ |
122 | ␉UInt8 unknow1[2];␊ |
123 | ␉UInt8 x1;␊ |
124 | ␉UInt8 x_total;␊ |
125 | ␉UInt8 x2;␊ |
126 | ␉UInt8 y1;␊ |
127 | ␉UInt8 y_total;␊ |
128 | ␉UInt8 y2;␊ |
129 | } __attribute__((packed)) vbios_resolution_type1;␊ |
130 | ␊ |
131 | typedef struct {␊ |
132 | ␉unsigned long clock;␊ |
133 | ␉␊ |
134 | ␉UInt16 x1;␊ |
135 | ␉UInt16 htotal;␊ |
136 | ␉UInt16 x2;␊ |
137 | ␉UInt16 hblank;␊ |
138 | ␉UInt16 hsyncstart;␊ |
139 | ␉UInt16 hsyncend;␊ |
140 | ␉UInt16 y1;␊ |
141 | UInt16 vtotal;␊ |
142 | UInt16 y2;␊ |
143 | ␉UInt16 vblank;␊ |
144 | ␉UInt16 vsyncstart;␊ |
145 | ␉UInt16 vsyncend;␊ |
146 | } __attribute__((packed)) vbios_modeline_type2;␊ |
147 | ␊ |
148 | typedef struct {␊ |
149 | ␉UInt8 xchars;␊ |
150 | ␉UInt8 ychars;␊ |
151 | ␉UInt8 unknown[4];␊ |
152 | ␉␊ |
153 | ␉vbios_modeline_type2 modelines[];␊ |
154 | } __attribute__((packed)) vbios_resolution_type2;␊ |
155 | ␊ |
156 | typedef struct {␊ |
157 | ␉unsigned long clock;␊ |
158 | ␉␊ |
159 | ␉UInt16 x1;␊ |
160 | ␉UInt16 htotal;␊ |
161 | ␉UInt16 x2;␊ |
162 | ␉UInt16 hblank;␊ |
163 | ␉UInt16 hsyncstart;␊ |
164 | ␉UInt16 hsyncend;␊ |
165 | ␉␊ |
166 | ␉UInt16 y1;␊ |
167 | ␉UInt16 vtotal;␊ |
168 | ␉UInt16 y2;␊ |
169 | ␉UInt16 vblank;␊ |
170 | ␉UInt16 vsyncstart;␊ |
171 | ␉UInt16 vsyncend;␊ |
172 | ␉␊ |
173 | ␉UInt16 timing_h;␊ |
174 | ␉UInt16 timing_v;␊ |
175 | ␉␊ |
176 | ␉UInt8 unknown[6];␊ |
177 | } __attribute__((packed)) vbios_modeline_type3;␊ |
178 | ␊ |
179 | typedef struct {␊ |
180 | ␉unsigned char unknown[6];␊ |
181 | ␉␊ |
182 | vbios_modeline_type3 modelines[];␊ |
183 | } __attribute__((packed)) vbios_resolution_type3;␊ |
184 | ␊ |
185 | typedef struct {␊ |
186 | ␉UInt32 chipset_id;␊ |
187 | ␉chipset_type chipset;␊ |
188 | ␉bios_type bios;␊ |
189 | ␉␊ |
190 | ␉bios_tables_t ati_tables;␊ |
191 | ␉␊ |
192 | ␉UInt32 bios_fd;␊ |
193 | ␉unsigned char* bios_backup_ptr;␊ |
194 | ␉unsigned char* bios_ptr;␊ |
195 | ␉␊ |
196 | ␉vbios_mode * mode_table;␊ |
197 | ␉char * ati_mode_table;␊ |
198 | ␉char * nv_mode_table;␊ |
199 | ␉char * nv_mode_table_2;␊ |
200 | ␉␊ |
201 | ␉UInt32 mode_table_size;␊ |
202 | ␉UInt8 b1, b2;␊ |
203 | ␉␊ |
204 | ␉UInt8 unlocked;␊ |
205 | } vbios_map;␊ |
206 | ␊ |
207 | ␊ |
208 | ␊ |
209 | void display_map_info(vbios_map*);␊ |
210 | vbios_map * open_vbios(chipset_type);␊ |
211 | void close_vbios (vbios_map*);␊ |
212 | void unlock_vbios(vbios_map*);␊ |
213 | void relock_vbios(vbios_map*);␊ |
214 | void save_vbios(vbios_map*);␊ |
215 | void restore_vbios(vbios_map*);␊ |
216 | void set_mode(vbios_map*, UInt32, UInt32, UInt32, UInt32, UInt32);␊ |
217 | void list_modes(vbios_map *map, UInt32 raw);␊ |
218 | ␊ |
219 | #endif␊ |
220 |