1 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/boot2/boot.c Chameleon-2.0-RC4-r684-mr2//i386/boot2/boot.c␊ |
2 | --- Chameleon-2.0-RC4-r684-src//i386/boot2/boot.c␉2009-11-22 17:31:14.000000000 +0100␊ |
3 | +++ Chameleon-2.0-RC4-r684-mr2//i386/boot2/boot.c␉2010-02-23 22:59:49.000000000 +0100␊ |
4 | @@ -57,6 +57,10 @@␊ |
5 | #include "libsa.h"␊ |
6 | #include "ramdisk.h"␊ |
7 | #include "gui.h"␊ |
8 | +#include "graphics.h"␊ |
9 | +#include "vbe.h"␊ |
10 | +#include "915resolution.h"␊ |
11 | +#include "edid.h"␊ |
12 | ␊ |
13 | long gBootMode; /* defaults to 0 == kBootModeNormal */␊ |
14 | BOOL gOverrideKernel;␊ |
15 | @@ -355,6 +359,45 @@␊ |
16 | ␉// Check if GUI=n switch is present in config file␊ |
17 | if ( getBoolForKey(kGUIKey, &useGUI, &bootInfo->bootConfig) && !useGUI )␊ |
18 | useGUI = FALSE;␊ |
19 | +␊ |
20 | +␉// Before initGui, patch the video bios with the correct resolution␊ |
21 | +␊ |
22 | +␉UInt32 x = 0, y = 0; ␊ |
23 | +␉UInt32 bp = 0;␊ |
24 | +␊ |
25 | + ␉// Read resolution from com.apple.Boot.plist, if any. Code taken from graphics.c␊ |
26 | + ␉unsigned long params[4];␊ |
27 | +␉int count;␊ |
28 | +␉params[3] = 0;␊ |
29 | +␉count = getNumberArrayFromProperty( kGraphicsModeKey, params, 4 );␊ |
30 | +␉if ( count < 3 ) {␊ |
31 | +␉␉//if there's no entry, read from edid␊ |
32 | +␉␉getResolution(&x, &y, &bp);␊ |
33 | +␉␉//printf("Values read from EDID.\n");␊ |
34 | +␉}␊ |
35 | +␉else {␊ |
36 | +␉␉x=params[0];␊ |
37 | +␉␉y=params[1];␊ |
38 | +␉␉bp=params[2];␊ |
39 | +␉␉if ( bp == 256 ) bp = 8;␊ |
40 | +␉␉if ( bp == 555 ) bp = 16;␊ |
41 | +␉␉if ( bp == 888 ) bp = 32;␊ |
42 | +␉␉//printf("Values read from Config file.\n");␊ |
43 | +␉}␊ |
44 | +␊ |
45 | +␊ |
46 | +␉if (x!=0 && y!=0) {␊ |
47 | +␉␉vbios_map * map;␊ |
48 | +␉␉map = open_vbios(CT_UNKWN);␊ |
49 | +␉␉unlock_vbios(map);␊ |
50 | +␉␉set_mode(map, x, y, bp, 0, 0);␊ |
51 | +␉␉relock_vbios(map);␊ |
52 | +␉␉close_vbios(map);␊ |
53 | +␉␉//printf("Patched first resolution mode to %dx%d.\n", x, y);␊ |
54 | +␉}␊ |
55 | +␉␉␊ |
56 | +␉//printf("Press any key to continue...");␊ |
57 | +␉//getc();␊ |
58 | ␉␉␊ |
59 | // Try initialising the GUI unless disabled␊ |
60 | if( useGUI )␊ |
61 | @@ -485,7 +528,7 @@␊ |
62 | ␉␉␉if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))␊ |
63 | ␉␉␉␉break;␊ |
64 | ␉␉␉␊ |
65 | -␉␉␉if (!forceresume && sleeptime+3<bvr->modTime)␊ |
66 | +␉␉␉if (!forceresume && ((sleeptime+3) < bvr->modTime))␊ |
67 | ␉␉␉{␊ |
68 | ␉␉␉␉printf ("Hibernate image is too old by %d seconds. Use ForceWake=y to override\n",bvr->modTime-sleeptime);␊ |
69 | ␉␉␉␉break;␊ |
70 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/boot2/graphics.c Chameleon-2.0-RC4-r684-mr2//i386/boot2/graphics.c␊ |
71 | --- Chameleon-2.0-RC4-r684-src//i386/boot2/graphics.c␉2009-11-22 17:31:14.000000000 +0100␊ |
72 | +++ Chameleon-2.0-RC4-r684-mr2//i386/boot2/graphics.c␉2010-02-23 23:02:14.000000000 +0100␊ |
73 | @@ -182,7 +182,7 @@␊ |
74 | // Return the VESA mode that matches the properties specified.␊ |
75 | // If a mode is not found, then return the "best" available mode.␊ |
76 | ␊ |
77 | -static unsigned short␊ |
78 | +unsigned short␊ |
79 | getVESAModeWithProperties( unsigned short width,␊ |
80 | unsigned short height,␊ |
81 | unsigned char bitsPerPixel,␊ |
82 | @@ -1068,7 +1068,7 @@␊ |
83 | //==========================================================================␊ |
84 | // getNumberArrayFromProperty␊ |
85 | ␊ |
86 | -static int␊ |
87 | +int␊ |
88 | getNumberArrayFromProperty( const char * propKey,␊ |
89 | unsigned long numbers[],␊ |
90 | unsigned long maxArrayCount )␊ |
91 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/boot2/graphics.h Chameleon-2.0-RC4-r684-mr2//i386/boot2/graphics.h␊ |
92 | --- Chameleon-2.0-RC4-r684-src//i386/boot2/graphics.h␉2009-11-22 17:31:14.000000000 +0100␊ |
93 | +++ Chameleon-2.0-RC4-r684-mr2//i386/boot2/graphics.h␉2010-02-22 23:02:37.000000000 +0100␊ |
94 | @@ -10,6 +10,7 @@␊ |
95 | #include "boot.h"␊ |
96 | #include "bootstruct.h"␊ |
97 | #include "graphic_utils.h"␊ |
98 | +#include "vbe.h"␊ |
99 | ␊ |
100 | ␊ |
101 | #ifndef __BOOT_GRAPHICS_H␊ |
102 | @@ -28,6 +29,8 @@␊ |
103 | void drawDataRectangle( unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned char * data );␊ |
104 | int convertImage( unsigned short width, unsigned short height, const unsigned char *imageData, unsigned char **newImageData );␊ |
105 | ␊ |
106 | +int getNumberArrayFromProperty( const char * propKey, unsigned long numbers[], unsigned long maxArrayCount );␊ |
107 | +␊ |
108 | int initGraphicsMode ();␊ |
109 | ␊ |
110 | void drawCheckerBoard();␊ |
111 | @@ -44,4 +47,14 @@␊ |
112 | char *getVBEModeInfoString();␊ |
113 | void getGraphicModeParams(unsigned long params[]);␊ |
114 | ␊ |
115 | -#endif /* !__BOOT_GRAPHICS_H */␊ |
116 | \ Manca newline alla fine del file␊ |
117 | +␊ |
118 | +unsigned short getVESAModeWithProperties( unsigned short width,␊ |
119 | +␉␉␉␉␉␉ unsigned short height,␊ |
120 | +␉␉␉␉␉␉ unsigned char bitsPerPixel,␊ |
121 | +␉␉␉␉␉␉ unsigned short attributesSet,␊ |
122 | +␉␉␉␉␉␉ unsigned short attributesClear,␊ |
123 | +␉␉␉␉␉␉ VBEModeInfoBlock * outModeInfo,␊ |
124 | +␉␉␉␉␉␉ unsigned short * vesaVersion );␊ |
125 | +␊ |
126 | +␊ |
127 | +#endif /* !__BOOT_GRAPHICS_H */␊ |
128 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/boot2/gui.c Chameleon-2.0-RC4-r684-mr2//i386/boot2/gui.c␊ |
129 | --- Chameleon-2.0-RC4-r684-src//i386/boot2/gui.c␉2009-11-22 17:31:14.000000000 +0100␊ |
130 | +++ Chameleon-2.0-RC4-r684-mr2//i386/boot2/gui.c␉2010-02-23 23:04:19.000000000 +0100␊ |
131 | @@ -11,6 +11,7 @@␊ |
132 | #include "gui.h"␊ |
133 | #include "appleboot.h"␊ |
134 | #include "vers.h"␊ |
135 | +#include "edid.h"␊ |
136 | ␊ |
137 | #ifdef EMBED_THEME␊ |
138 | #include "art.h"␊ |
139 | @@ -494,9 +495,11 @@␊ |
140 | ␊ |
141 | int initGUI()␊ |
142 | {␊ |
143 | -␉int val, len;␊ |
144 | +␉int len;␊ |
145 | ␉char dirspec[256];␊ |
146 | ␊ |
147 | +␉␊ |
148 | +␊ |
149 | #ifdef EMBED_THEME␊ |
150 | ␊ |
151 | ␉config_file_t *embedded = &bootInfo->themeDefault;␊ |
152 | @@ -504,12 +507,22 @@␊ |
153 | ␉// build xml dictionary for embedded theme.plist␊ |
154 | ␉ParseXMLFile( (char *) __theme_plist, &embedded->dictionary);␊ |
155 | ␊ |
156 | -␉// parse display size parameters␊ |
157 | -␉if(getIntForKey("screen_width", &val, &bootInfo->themeDefault))␊ |
158 | -␉␉screen_params[0] = val;␊ |
159 | -␉␊ |
160 | -␉if(getIntForKey("screen_height", &val, &bootInfo->themeDefault))␊ |
161 | -␉␉screen_params[1] = val;␊ |
162 | +␉// Read resolution from com.apple.Boot.plist, if not found, from edid.␊ |
163 | +␉int count;␊ |
164 | +␉screen_params[3] = 0;␊ |
165 | +␉count = getNumberArrayFromProperty( kGraphicsModeKey, screen_params, 4 );␊ |
166 | +␉if ( count < 3 ) {␊ |
167 | +␉␉getResolution(&screen_params[0], &screen_params[1], &screen_params[2]);␊ |
168 | +␉}␊ |
169 | +␉else {␊ |
170 | + if ( screen_params[2] == 256 ) screen_params[2] = 8;␊ |
171 | + if ( screen_params[2] == 555 ) screen_params[2] = 16;␊ |
172 | + if ( screen_params[2] == 888 ) screen_params[2] = 32;␊ |
173 | + }␊ |
174 | +␊ |
175 | +//printf("GetResol from initGui: %dx%d\n",screen_params[0],screen_params[1]);␊ |
176 | +//getc();␊ |
177 | +␊ |
178 | #else␊ |
179 | ␊ |
180 | ␉/*␊ |
181 | @@ -523,22 +536,12 @@␊ |
182 | // Initalizing GUI strucutre.␊ |
183 | bzero(&gui, sizeof(gui_t));␊ |
184 | ␉␊ |
185 | -␉screen_params[2] = 32;␊ |
186 | -␉␊ |
187 | ␉// find theme name in boot.plist␊ |
188 | ␉getValueForKey( "Theme", &theme_name, &len, &bootInfo->bootConfig );␊ |
189 | ␉␊ |
190 | ␉sprintf(dirspec, "/Extra/Themes/%s/theme.plist", theme_name);␊ |
191 | ␊ |
192 | -␉if ( !loadConfigFile(dirspec, &bootInfo->themeConfig) )␊ |
193 | -␉{␉␉␊ |
194 | -␉␉// parse display size parameters␊ |
195 | -␉␉if(getIntForKey("screen_width", &val, &bootInfo->themeConfig))␊ |
196 | -␉␉␉screen_params[0] = val;␊ |
197 | -␊ |
198 | -␉␉if(getIntForKey("screen_height", &val, &bootInfo->themeConfig))␊ |
199 | -␉␉␉screen_params[1] = val;␊ |
200 | -␉}␊ |
201 | +␉loadConfigFile(dirspec, &bootInfo->themeConfig);␊ |
202 | ␊ |
203 | ␉// find best matching vesa mode for our requested width & height␊ |
204 | ␉getGraphicModeParams(screen_params);␊ |
205 | @@ -1710,11 +1713,24 @@␊ |
206 | ␊ |
207 | void drawBootGraphics()␊ |
208 | {␊ |
209 | -␉int pos;␊ |
210 | ␉int length;␊ |
211 | ␉const char *dummyVal;␊ |
212 | ␉BOOL legacy_logo;␊ |
213 | ␉uint16_t x, y; ␊ |
214 | +␊ |
215 | +␉/** Read resolution from com.apple.Boot.plist, if not found, from edid **/␊ |
216 | +␉screen_params[3] = 0;␊ |
217 | +␉length = getNumberArrayFromProperty( kGraphicsModeKey, screen_params, 4 );␊ |
218 | +␉if ( length < 3 ) {␊ |
219 | +␉␉getResolution(&screen_params[0], &screen_params[1], &screen_params[2]);␊ |
220 | +␉}␊ |
221 | +␉else {␊ |
222 | + if ( screen_params[2] == 256 ) screen_params[2] = 8;␊ |
223 | + if ( screen_params[2] == 555 ) screen_params[2] = 16;␊ |
224 | + if ( screen_params[2] == 888 ) screen_params[2] = 32;␊ |
225 | + }␊ |
226 | +//printf("GetResol from drawBootGraphics: %dx%d\n",screen_params[0],screen_params[1]);␊ |
227 | +//getc();␊ |
228 | ␉␊ |
229 | ␉if (getBoolForKey("Legacy Logo", &legacy_logo, &bootInfo->bootConfig) && legacy_logo)␊ |
230 | ␉␉usePngImage = NO; ␊ |
231 | @@ -1722,19 +1738,6 @@␊ |
232 | ␉else if (bootImageData == NULL)␊ |
233 | ␉␉loadBootGraphics();␊ |
234 | ␉␉␊ |
235 | -␉// parse screen size parameters␊ |
236 | -␉if(getIntForKey("boot_width", &pos, &bootInfo->themeConfig))␊ |
237 | -␉␉screen_params[0] = pos;␊ |
238 | -␉else␊ |
239 | -␉␉screen_params[0] = DEFAULT_SCREEN_WIDTH;␊ |
240 | -␉␊ |
241 | -␉if(getIntForKey("boot_height", &pos, &bootInfo->themeConfig))␊ |
242 | -␉␉screen_params[1] = pos;␊ |
243 | -␉else␊ |
244 | -␉␉screen_params[1] = DEFAULT_SCREEN_HEIGHT;␊ |
245 | -␉␊ |
246 | -␉screen_params[2] = 32;␊ |
247 | -␉␊ |
248 | ␉gui.screen.width = screen_params[0];␊ |
249 | ␉gui.screen.height = screen_params[1];␊ |
250 | ␉␊ |
251 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/libsaio/915resolution.c Chameleon-2.0-RC4-r684-mr2//i386/libsaio/915resolution.c␊ |
252 | --- Chameleon-2.0-RC4-r684-src//i386/libsaio/915resolution.c␉1970-01-01 01:00:00.000000000 +0100␊ |
253 | +++ Chameleon-2.0-RC4-r684-mr2//i386/libsaio/915resolution.c␉2010-02-21 15:24:22.000000000 +0100␊ |
254 | @@ -0,0 +1,555 @@␊ |
255 | +/* Copied from 915 resolution created by steve tomljenovic␊ |
256 | + * This source code is into the public domain.␊ |
257 | + *␊ |
258 | + * Included to Chameleon RC3 by meklort␊ |
259 | + *␊ |
260 | + * Included to RC4 and edited by deviato to match more intel chipsets␊ |
261 | + *␊ |
262 | + */␊ |
263 | +␊ |
264 | +#include "libsaio.h"␊ |
265 | +#include "915resolution.h"␊ |
266 | +␊ |
267 | +char * chipset_type_names[] = {␊ |
268 | +␉"UNKNOWN", "830", "845G", "855GM", "865G", "915G", "915GM", "945G", "945GM", "945GME",␊ |
269 | +␉"946GZ", "G965", "Q965", "965GM", "G41", "G31", "G45", "GM45", "Optiplex", "500"␊ |
270 | +};␊ |
271 | +␊ |
272 | +char * bios_type_names[] = {"UNKNOWN", "TYPE 1", "TYPE 2", "TYPE 3"};␊ |
273 | +␊ |
274 | +int freqs[] = { 60, 75, 85 };␊ |
275 | +␊ |
276 | +UInt32 get_chipset_id(void) {␊ |
277 | +␉outl(0xcf8, 0x80000000);␊ |
278 | +␉return inl(0xcfc);␊ |
279 | +}␊ |
280 | +␊ |
281 | +chipset_type get_chipset(UInt32 id) {␊ |
282 | +␉chipset_type type;␊ |
283 | +␉␊ |
284 | +␉switch (id) {␊ |
285 | +␉␉case 0x35758086:␊ |
286 | +␉␉␉type = CT_830;␊ |
287 | +␉␉␉break;␊ |
288 | +␉␉␊ |
289 | +␉␉case 0x25608086:␊ |
290 | +␉␉␉type = CT_845G;␊ |
291 | +␉␉␉break;␊ |
292 | +␉␉␉␉␊ |
293 | +␉␉case 0x35808086:␊ |
294 | +␉␉␉type = CT_855GM;␊ |
295 | +␉␉␉break;␊ |
296 | +␉␉␉␉␊ |
297 | +␉␉case 0x25708086:␊ |
298 | +␉␉␉type = CT_865G;␊ |
299 | +␉␉␉break;␊ |
300 | +␉␉␊ |
301 | +␉␉case 0x25808086:␊ |
302 | +␉␉␉type = CT_915G;␊ |
303 | +␉␉␉break;␊ |
304 | +␉␉␉␊ |
305 | +␉␉case 0x25908086:␊ |
306 | +␉␉␉type = CT_915GM;␊ |
307 | +␉␉␉break;␊ |
308 | +␉␉␉␊ |
309 | +␉␉case 0x27708086:␊ |
310 | +␉␉␉type = CT_945G;␊ |
311 | +␉␉␉break;␊ |
312 | +␉␉␊ |
313 | +␉␉case 0x27a08086:␊ |
314 | +␉␉␉type = CT_945GM;␊ |
315 | +␉␉␉break;␊ |
316 | +␉␉␉␊ |
317 | +␉␉case 0x27ac8086:␊ |
318 | +␉␉␉type = CT_945GME;␊ |
319 | +␉␉␉break;␊ |
320 | +␉␉␉␊ |
321 | +␉␉case 0x29708086:␊ |
322 | +␉␉␉type = CT_946GZ;␊ |
323 | +␉␉␉break;␊ |
324 | +␉␉␉␊ |
325 | +␉␉case 0x29a08086:␊ |
326 | +␉␉␉type = CT_G965;␊ |
327 | +␉␉␉break;␊ |
328 | +␉␉␉␊ |
329 | +␉␉case 0x29908086:␊ |
330 | +␉␉␉type = CT_Q965;␊ |
331 | +␉␉␉break;␊ |
332 | +␉␉␉␊ |
333 | +␉␉case 0x2a008086:␊ |
334 | +␉␉␉type = CT_965GM;␊ |
335 | +␉␉␉break;␊ |
336 | +␉␉␉␊ |
337 | +␉␉case 0x2a408086:␊ |
338 | +␉␉␉type = CT_GM45;␊ |
339 | +␉␉␉break;␊ |
340 | +␊ |
341 | +␉␉case 0x2e108086:␊ |
342 | +␉␉␉type = CT_Optiplex;␊ |
343 | +␉␉␉break;␊ |
344 | +␊ |
345 | +␉␉case 0x2e308086:␊ |
346 | +␉␉␉type = CT_G41;␊ |
347 | +␉␉␉break;␊ |
348 | +␊ |
349 | +␉␉case 0x29c08086:␊ |
350 | +␉␉␉type = CT_G31;␊ |
351 | +␉␉␉break;␊ |
352 | +␊ |
353 | +␉␉case 0x2e208086:␊ |
354 | +␉␉␉type = CT_G45;␊ |
355 | +␉␉␉break;␊ |
356 | +␊ |
357 | +␉␉case 0x81008086:␊ |
358 | +␉␉␉type = CT_500;␊ |
359 | +␉␉␉break;␊ |
360 | +␉␉␉␊ |
361 | +␉␉␉␊ |
362 | +␉␉default:␊ |
363 | +␉␉␉type = CT_UNKWN;␊ |
364 | +␉␉␉break;␊ |
365 | +␉}␊ |
366 | +␉return type;␊ |
367 | +}␊ |
368 | +␊ |
369 | +vbios_resolution_type1 * map_type1_resolution(vbios_map * map, UInt16 res) {␊ |
370 | +␉vbios_resolution_type1 * ptr = ((vbios_resolution_type1*)(map->bios_ptr + res)); ␊ |
371 | +␉return ptr;␊ |
372 | +}␊ |
373 | +␊ |
374 | +vbios_resolution_type2 * map_type2_resolution(vbios_map * map, UInt16 res) {␊ |
375 | +␉vbios_resolution_type2 * ptr = ((vbios_resolution_type2*)(map->bios_ptr + res)); ␊ |
376 | +␉return ptr;␊ |
377 | +}␊ |
378 | +␊ |
379 | +vbios_resolution_type3 * map_type3_resolution(vbios_map * map, UInt16 res) {␊ |
380 | +␉vbios_resolution_type3 * ptr = ((vbios_resolution_type3*)(map->bios_ptr + res)); ␊ |
381 | +␉return ptr;␊ |
382 | +}␊ |
383 | +␊ |
384 | +char detect_bios_type(vbios_map * map, char modeline, int entry_size) {␊ |
385 | +␉UInt32 i;␊ |
386 | +␉UInt16 r1, r2;␊ |
387 | +␉ ␊ |
388 | +␉r1 = r2 = 32000;␊ |
389 | +␉␊ |
390 | +␉for (i=0; i < map->mode_table_size; i++) {␊ |
391 | +␉␉if (map->mode_table[i].resolution <= r1) {␊ |
392 | +␉␉␉r1 = map->mode_table[i].resolution;␊ |
393 | +␉␉}␊ |
394 | +␉␉else {␊ |
395 | +␉␉␉if (map->mode_table[i].resolution <= r2) {␊ |
396 | +␉␉␉␉r2 = map->mode_table[i].resolution;␊ |
397 | +␉␉␉}␊ |
398 | +␉␉}␊ |
399 | +␉␉␊ |
400 | +␉␉/*printf("r1 = %d r2 = %d\n", r1, r2);*/␊ |
401 | +␉}␊ |
402 | +␊ |
403 | +␉return (r2-r1-6) % entry_size == 0;␊ |
404 | +}␊ |
405 | +␊ |
406 | +void close_vbios(vbios_map * map);␊ |
407 | +␊ |
408 | +vbios_map * open_vbios(chipset_type forced_chipset) {␊ |
409 | +␉UInt32 z;␊ |
410 | +␉vbios_map * map = NEW(vbios_map);␊ |
411 | +␉for(z=0; z<sizeof(vbios_map); z++) ((char*)map)[z]=0;␊ |
412 | +␉␊ |
413 | +␉/*␊ |
414 | +␉ * Determine chipset␊ |
415 | +␉ */␊ |
416 | +␉␊ |
417 | +␉if (forced_chipset == CT_UNKWN) {␊ |
418 | +␉␉map->chipset_id = get_chipset_id();␊ |
419 | +␉␉map->chipset = get_chipset(map->chipset_id);␊ |
420 | +␉}␊ |
421 | +␉else if (forced_chipset != CT_UNKWN) {␊ |
422 | +␉␉map->chipset = forced_chipset;␊ |
423 | +␉}␊ |
424 | +␉else {␊ |
425 | +␉␉map->chipset = CT_915GM;␊ |
426 | +␉}␊ |
427 | +␉ ␊ |
428 | +␉/*␊ |
429 | +␉ * Map the video bios to memory␊ |
430 | +␉ */␊ |
431 | +␉␊ |
432 | +␉map->bios_ptr=(char*)VBIOS_START;␊ |
433 | +␉␊ |
434 | +␉/*␊ |
435 | +␉ * check if we have ATI Radeon␊ |
436 | +␉ */␊ |
437 | +␉ ␊ |
438 | +␉/*␊ |
439 | +␉ * check if we have NVIDIA␊ |
440 | +␉ */␊ |
441 | +␉ ␊ |
442 | +␉/*␊ |
443 | +␉ * check if we have Intel␊ |
444 | +␉ */␊ |
445 | +␉ ␊ |
446 | +␉/*␊ |
447 | +␉ * check for others␊ |
448 | +␉ */␊ |
449 | +␉␊ |
450 | +␉if (map->chipset == CT_UNKWN) {␊ |
451 | +␉␉printf("Unknown chipset type and unrecognized bios.\n");␊ |
452 | +␉␉printf("915resolution only works with Intel 800/900 series graphic chipsets.\n");␊ |
453 | +␉␊ |
454 | +␉␉printf("Chipset Id: %x\n", map->chipset_id);␊ |
455 | +␉␉close_vbios(map);␊ |
456 | +␉␉return 0;␊ |
457 | +␉}␊ |
458 | +␊ |
459 | +␉/*␊ |
460 | +␉ * Figure out where the mode table is ␊ |
461 | +␉ */␊ |
462 | +␉␊ |
463 | +␉{␊ |
464 | +␉␉char* p = map->bios_ptr + 16;␊ |
465 | +␉␉char* limit = map->bios_ptr + VBIOS_SIZE - (3 * sizeof(vbios_mode));␊ |
466 | +␉␉␉␊ |
467 | +␉␉while (p < limit && map->mode_table == 0) {␊ |
468 | +␉␉␉vbios_mode * mode_ptr = (vbios_mode *) p;␊ |
469 | +␉␉␉ ␊ |
470 | +␉␉␉if (((mode_ptr[0].mode & 0xf0) == 0x30) && ((mode_ptr[1].mode & 0xf0) == 0x30) &&␊ |
471 | +␉␉␉␉((mode_ptr[2].mode & 0xf0) == 0x30) && ((mode_ptr[3].mode & 0xf0) == 0x30)) {␊ |
472 | +␉␉␉␊ |
473 | +␉␉␉␉map->mode_table = mode_ptr;␊ |
474 | +␉␉␉}␊ |
475 | +␉␉␉ ␊ |
476 | +␉␉␉p++;␊ |
477 | +␉␉}␊ |
478 | +␉␉␊ |
479 | +␉␉if (map->mode_table == 0) {␊ |
480 | +␉␉␉printf("Unable to locate the mode table.\n");␊ |
481 | +␉␉␉printf("Please run the program 'dump_bios' as root and\n");␊ |
482 | +␉␉␉printf("email the file 'vbios.dmp' to stomljen@yahoo.com.\n");␊ |
483 | +␉␉␉printf("Chipset: %s\n", chipset_type_names[map->chipset]);␊ |
484 | +␉␉␉close_vbios(map);␊ |
485 | +␉␉␉return 0;␊ |
486 | +␉␉}␊ |
487 | +␉}␊ |
488 | +␉␊ |
489 | +␉/*␊ |
490 | +␉ * Determine size of mode table␊ |
491 | +␉ */␊ |
492 | +␉ ␊ |
493 | +␉{␊ |
494 | +␉␉vbios_mode * mode_ptr = map->mode_table;␊ |
495 | +␉␉␉␊ |
496 | +␉␉while (mode_ptr->mode != 0xff) {␊ |
497 | +␉␉␉map->mode_table_size++;␊ |
498 | +␉␉␉mode_ptr++;␊ |
499 | +␉␉}␊ |
500 | +␉}␊ |
501 | +␉␊ |
502 | +␉/*␊ |
503 | +␉ * Figure out what type of bios we have␊ |
504 | +␉ * order of detection is important␊ |
505 | +␉ */␊ |
506 | +␉␊ |
507 | +␉if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type3))) {␊ |
508 | +␉␉map->bios = BT_3;␊ |
509 | +␉}␊ |
510 | +␉else if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type2))) {␊ |
511 | +␉␉map->bios = BT_2;␊ |
512 | +␉}␊ |
513 | +␉else if (detect_bios_type(map, FALSE, sizeof(vbios_resolution_type1))) {␊ |
514 | +␉␉map->bios = BT_1;␊ |
515 | +␉}␊ |
516 | +␉else {␊ |
517 | +␉␉printf("Unable to determine bios type.\n");␊ |
518 | +␉␉printf("Please run the program 'dump_bios' as root and\n");␊ |
519 | +␉␉printf("email the file 'vbios.dmp' to stomljen@yahoo.com.\n");␊ |
520 | +␉␊ |
521 | +␉␉printf("Chipset: %s\n", chipset_type_names[map->chipset]);␊ |
522 | +␉␉printf("Mode Table Offset: $C0000 + $%x\n", ((UInt32)map->mode_table) - ((UInt32)map->bios_ptr));␊ |
523 | +␉␉printf("Mode Table Entries: %u\n", map->mode_table_size);␊ |
524 | +␉␉return 0;␊ |
525 | +␉}␊ |
526 | +␉␊ |
527 | +␉return map;␊ |
528 | +}␊ |
529 | +␊ |
530 | +void close_vbios(vbios_map * map) {␊ |
531 | +␉FREE(map);␊ |
532 | +}␊ |
533 | +␊ |
534 | +void unlock_vbios(vbios_map * map) {␊ |
535 | +␊ |
536 | +␉map->unlocked = TRUE;␊ |
537 | +␉ ␊ |
538 | +␉switch (map->chipset) {␊ |
539 | +␉␉case CT_UNKWN:␊ |
540 | +␉␉␉break;␊ |
541 | +␉␉case CT_830:␊ |
542 | +␉␉case CT_855GM:␊ |
543 | +␉␉␉outl(0xcf8, 0x8000005a);␊ |
544 | +␉␉␉map->b1 = inb(0xcfe);␊ |
545 | +␉␉␉␉␊ |
546 | +␉␉␉outl(0xcf8, 0x8000005a);␊ |
547 | +␉␉␉outb(0xcfe, 0x33);␊ |
548 | +␉␉␉break;␊ |
549 | +␉␉case CT_845G:␊ |
550 | +␉␉case CT_865G:␊ |
551 | +␉␉case CT_915G:␊ |
552 | +␉␉case CT_915GM:␊ |
553 | +␉␉case CT_945G:␊ |
554 | +␉␉case CT_945GM:␊ |
555 | +␉␉case CT_945GME:␊ |
556 | +␉␉case CT_946GZ:␊ |
557 | +␉␉case CT_G965:␊ |
558 | +␉␉case CT_Q965:␊ |
559 | +␉␉case CT_965GM:␊ |
560 | +␉␉case CT_GM45:␊ |
561 | +␉␉case CT_Optiplex:␊ |
562 | +␉␉case CT_G41:␊ |
563 | +␉␉case CT_G31:␊ |
564 | +␉␉case CT_G45:␊ |
565 | +␉␉case CT_500:␊ |
566 | +␉␉␉outl(0xcf8, 0x80000090);␊ |
567 | +␉␉␉map->b1 = inb(0xcfd);␊ |
568 | +␉␉␉map->b2 = inb(0xcfe);␊ |
569 | +␉␉␉␊ |
570 | +␉␉␉outl(0xcf8, 0x80000090);␊ |
571 | +␉␉␉outb(0xcfd, 0x33);␊ |
572 | +␉␉␉outb(0xcfe, 0x33);␊ |
573 | +␉␉break;␊ |
574 | +␉}␊ |
575 | +␉␊ |
576 | +␉#if DEBUG␊ |
577 | +␉{␊ |
578 | +␉␉UInt32 t = inl(0xcfc);␊ |
579 | +␉␉printf("unlock PAM: (0x%08x)\n", t);␊ |
580 | +␉}␊ |
581 | +#endif␊ |
582 | +}␊ |
583 | +␊ |
584 | +void relock_vbios(vbios_map * map) {␊ |
585 | +␊ |
586 | +␉map->unlocked = FALSE;␊ |
587 | +␉␊ |
588 | +␉switch (map->chipset) {␊ |
589 | +␉␉case CT_UNKWN:␊ |
590 | +␉␉␉break;␊ |
591 | +␉␉case CT_830:␊ |
592 | +␉␉case CT_855GM:␊ |
593 | +␉␉␉outl(0xcf8, 0x8000005a);␊ |
594 | +␉␉␉outb(0xcfe, map->b1);␊ |
595 | +␉␉␉break;␊ |
596 | +␉␉case CT_845G:␊ |
597 | +␉␉case CT_865G:␊ |
598 | +␉␉case CT_915G:␊ |
599 | +␉␉case CT_915GM:␊ |
600 | +␉␉case CT_945G:␊ |
601 | +␉␉case CT_945GM:␊ |
602 | +␉␉case CT_945GME:␊ |
603 | +␉␉case CT_946GZ:␊ |
604 | +␉␉case CT_G965:␊ |
605 | +␉␉case CT_Q965:␊ |
606 | +␉␉case CT_965GM:␊ |
607 | +␉␉case CT_GM45:␊ |
608 | +␉␉case CT_Optiplex:␊ |
609 | +␉␉case CT_G41:␊ |
610 | +␉␉case CT_G31:␊ |
611 | +␉␉case CT_G45:␊ |
612 | +␉␉case CT_500:␊ |
613 | +␉␉␉outl(0xcf8, 0x8000005a);␊ |
614 | +␉␉␉outb(0xcfd, map->b1);␊ |
615 | +␉␉␉outb(0xcfe, map->b2);␊ |
616 | +␉␉␉break;␊ |
617 | +␉}␊ |
618 | +␉␊ |
619 | +␉#if DEBUG␊ |
620 | +␉{␊ |
621 | + UInt32 t = inl(0xcfc);␊ |
622 | +␉␉printf("relock PAM: (0x%08x)\n", t);␊ |
623 | +␉}␊ |
624 | +␉#endif␊ |
625 | +}␊ |
626 | + ␊ |
627 | +␊ |
628 | +void list_modes(vbios_map *map, UInt32 raw) {␊ |
629 | + UInt32 i, x, y;␊ |
630 | +␉␊ |
631 | + for (i=0; i < map->mode_table_size; i++) {␊ |
632 | + switch(map->bios) {␊ |
633 | +␉␉␉case BT_1:␊ |
634 | + {␊ |
635 | + vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);␊ |
636 | + ␊ |
637 | + x = ((((UInt32) res->x2) & 0xf0) << 4) | res->x1;␊ |
638 | + y = ((((UInt32) res->y2) & 0xf0) << 4) | res->y1;␊ |
639 | + ␊ |
640 | + if (x != 0 && y != 0) {␊ |
641 | + printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);␊ |
642 | + }␊ |
643 | +␉␉␉␉␊ |
644 | +␉␉␉␉if (raw)␊ |
645 | +␉␉␉␉{␊ |
646 | + printf("Mode %02x (raw) :\n\t%02x %02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n", map->mode_table[i].mode, res->unknow1[0],res->unknow1[1], res->x1,res->x_total,res->x2,res->y1,res->y_total,res->y2);␊ |
647 | +␉␉␉␉}␊ |
648 | +␉␉␉␉␊ |
649 | + }␊ |
650 | +␉␉␉␉break;␊ |
651 | +␉␉␉case BT_2:␊ |
652 | + {␊ |
653 | + vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);␊ |
654 | + ␊ |
655 | + x = res->modelines[0].x1+1;␊ |
656 | + y = res->modelines[0].y1+1;␊ |
657 | +␉␉␉␉␊ |
658 | + if (x != 0 && y != 0) {␊ |
659 | + printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);␊ |
660 | + }␊ |
661 | + }␊ |
662 | +␉␉␉␉break;␊ |
663 | +␉␉␉case BT_3:␊ |
664 | + {␊ |
665 | + vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution);␊ |
666 | + ␊ |
667 | + x = res->modelines[0].x1+1;␊ |
668 | + y = res->modelines[0].y1+1;␊ |
669 | + ␊ |
670 | + if (x != 0 && y != 0) {␊ |
671 | + printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);␊ |
672 | + }␊ |
673 | + }␊ |
674 | +␉␉␉␉break;␊ |
675 | +␉␉␉case BT_UNKWN:␊ |
676 | +␉␉␉␉break;␊ |
677 | + }␊ |
678 | + }␊ |
679 | +}␊ |
680 | +␊ |
681 | +static void gtf_timings(UInt32 x, UInt32 y, UInt32 freq,␊ |
682 | +␉␉␉␉␉␉unsigned long *clock,␊ |
683 | +␉␉␉␉␉␉UInt16 *hsyncstart, UInt16 *hsyncend, UInt16 *hblank,␊ |
684 | +␉␉␉␉␉␉UInt16 *vsyncstart, UInt16 *vsyncend, UInt16 *vblank)␊ |
685 | +{␊ |
686 | +␉UInt32 hbl, vbl, vfreq;␊ |
687 | +␊ |
688 | +␉vbl = y + (y+1)/(20000.0/(11*freq) - 1) + 1.5;␊ |
689 | +␉vfreq = vbl * freq;␊ |
690 | +␉hbl = 16 * (int)(x * (30.0 - 300000.0 / vfreq) /␊ |
691 | +␉␉␉␉␉␉ + (70.0 + 300000.0 / vfreq) / 16.0 + 0.5);␊ |
692 | +␊ |
693 | +␉*vsyncstart = y;␊ |
694 | +␉*vsyncend = y + 3;␊ |
695 | +␉*vblank = vbl - 1;␊ |
696 | +␉*hsyncstart = x + hbl / 2 - (x + hbl + 50) / 100 * 8 - 1;␊ |
697 | +␉*hsyncend = x + hbl / 2 - 1;␊ |
698 | +␉*hblank = x + hbl - 1;␊ |
699 | +␉*clock = (x + hbl) * vfreq / 1000;␊ |
700 | +}␊ |
701 | +␊ |
702 | +void set_mode(vbios_map * map, /*UInt32 mode,*/ UInt32 x, UInt32 y, UInt32 bp, UInt32 htotal, UInt32 vtotal) {␊ |
703 | +␉UInt32 xprev, yprev;␊ |
704 | +␉UInt32 i = 0, j;␉// patch first available mode␊ |
705 | +␊ |
706 | +//␉for (i=0; i < map->mode_table_size; i++) {␊ |
707 | +//␉␉if (map->mode_table[0].mode == mode) {␊ |
708 | +␉␉␉switch(map->bios) {␊ |
709 | +␉␉␉␉case BT_1:␊ |
710 | +␉␉␉␉␉{␊ |
711 | +␉␉␉␉␉␉vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);␊ |
712 | +␉␉␉␉␉␉␊ |
713 | +␉␉␉␉␉␉if (bp) {␊ |
714 | +␉␉␉␉␉␉␉map->mode_table[i].bits_per_pixel = bp;␊ |
715 | +␉␉␉␉␉␉}␊ |
716 | +␉␉␉␉␉␉␊ |
717 | +␉␉␉␉␉␉res->x2 = (htotal?(((htotal-x) >> 8) & 0x0f) : (res->x2 & 0x0f)) | ((x >> 4) & 0xf0);␊ |
718 | +␉␉␉␉␉␉res->x1 = (x & 0xff);␊ |
719 | +␉␉␉␉␉␉␊ |
720 | +␉␉␉␉␉␉res->y2 = (vtotal?(((vtotal-y) >> 8) & 0x0f) : (res->y2 & 0x0f)) | ((y >> 4) & 0xf0);␊ |
721 | +␉␉␉␉␉␉res->y1 = (y & 0xff);␊ |
722 | +␉␉␉␉␉␉if (htotal)␊ |
723 | +␉␉␉␉␉␉␉res->x_total = ((htotal-x) & 0xff);␊ |
724 | +␉␉␉␉␉␉␊ |
725 | +␉␉␉␉␉␉if (vtotal)␊ |
726 | +␉␉␉␉␉␉␉res->y_total = ((vtotal-y) & 0xff);␊ |
727 | +␉␉␉␉␉}␊ |
728 | +␉␉␉␉␉break;␊ |
729 | +␉␉␉␉case BT_2:␊ |
730 | +␉␉␉␉␉{␊ |
731 | +␉␉␉␉␉␉vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);␊ |
732 | +␉␉␉␉␉␉␊ |
733 | +␉␉␉␉␉␉res->xchars = x / 8;␊ |
734 | +␉␉␉␉␉␉res->ychars = y / 16 - 1;␊ |
735 | +␉␉␉␉␉␉xprev = res->modelines[0].x1;␊ |
736 | +␉␉␉␉␉␉yprev = res->modelines[0].y1;␊ |
737 | +␉␉␉␉␉␉␊ |
738 | +␉␉␉␉␉␉for(j=0; j < 3; j++) {␊ |
739 | +␉␉␉␉␉␉␉vbios_modeline_type2 * modeline = &res->modelines[j];␊ |
740 | +␉␉␉␉␉␉␉␊ |
741 | +␉␉␉␉␉␉␉if (modeline->x1 == xprev && modeline->y1 == yprev) {␊ |
742 | +␉␉␉␉␉␉␉␉modeline->x1 = modeline->x2 = x-1;␊ |
743 | +␉␉␉␉␉␉␉␉modeline->y1 = modeline->y2 = y-1;␊ |
744 | +␉␉␉␉␊ |
745 | +␉␉␉␉␉␉␉␉gtf_timings(x, y, freqs[j], &modeline->clock,␊ |
746 | +␉␉␉␉␉␉␉␉␉␉␉&modeline->hsyncstart, &modeline->hsyncend,␊ |
747 | +␉␉␉␉␉␉␉␉␉␉␉&modeline->hblank, &modeline->vsyncstart,␊ |
748 | +␉␉␉␉␉␉␉␉␉␉␉&modeline->vsyncend, &modeline->vblank);␊ |
749 | +␉␉␉␉␉␉␉␉␊ |
750 | +␉␉␉␉␉␉␉␉if (htotal)␊ |
751 | +␉␉␉␉␉␉␉␉␉modeline->htotal = htotal;␊ |
752 | +␉␉␉␉␉␉␉␉else␊ |
753 | +␉␉␉␉␉␉␉␉␉modeline->htotal = modeline->hblank;␊ |
754 | +␉␉␉␉␉␉␉␉␊ |
755 | +␉␉␉␉␉␉␉␉if (vtotal)␊ |
756 | +␉␉␉␉␉␉␉␉␉modeline->vtotal = vtotal;␊ |
757 | +␉␉␉␉␉␉␉␉else␊ |
758 | +␉␉␉␉␉␉␉␉␉modeline->vtotal = modeline->vblank;␊ |
759 | +␉␉␉␉␉␉␉}␊ |
760 | +␉␉␉␉␉␉}␊ |
761 | +␉␉␉␉␉}␊ |
762 | +␉␉␉␉␉break;␊ |
763 | +␉␉␉␉case BT_3:␊ |
764 | +␉␉␉␉␉{␊ |
765 | +␉␉␉␉␉␉vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution);␊ |
766 | +␉␉␉␉␉␉␊ |
767 | +␉␉␉␉␉␉xprev = res->modelines[0].x1;␊ |
768 | +␉␉␉␉␉␉yprev = res->modelines[0].y1;␊ |
769 | +␉␉␉␉␊ |
770 | +␉␉␉␉␉␉for (j=0; j < 3; j++) {␊ |
771 | +␉␉␉␉␉␉␉vbios_modeline_type3 * modeline = &res->modelines[j];␊ |
772 | +␉␉␉␉␉␉␉ ␊ |
773 | +␉␉␉␉␉␉␉if (modeline->x1 == xprev && modeline->y1 == yprev) {␊ |
774 | +␉␉␉␉␉␉␉␉modeline->x1 = modeline->x2 = x-1;␊ |
775 | +␉␉␉␉␉␉␉␉modeline->y1 = modeline->y2 = y-1;␊ |
776 | +␉␉␉␉␉␉␉␉ ␊ |
777 | +␉␉␉␉␉␉␉␉gtf_timings(x, y, freqs[j], &modeline->clock,␊ |
778 | +␉␉␉␉␉␉␉␉␉␉␉&modeline->hsyncstart, &modeline->hsyncend,␊ |
779 | +␉␉␉␉␉␉␉␉␉␉␉&modeline->hblank, &modeline->vsyncstart,␊ |
780 | +␉␉␉␉␉␉␉␉␉␉␉&modeline->vsyncend, &modeline->vblank);␊ |
781 | +␉␉␉␉␉␉␉␉if (htotal)␊ |
782 | +␉␉␉␉␉␉␉␉␉modeline->htotal = htotal;␊ |
783 | +␉␉␉␉␉␉␉␉else␊ |
784 | +␉␉␉␉␉␉␉␉␉modeline->htotal = modeline->hblank;␊ |
785 | +␉␉␉␉␉␉␉␉if (vtotal)␊ |
786 | +␉␉␉␉␉␉␉␉␉modeline->vtotal = vtotal;␊ |
787 | +␉␉␉␉␉␉␉␉else␊ |
788 | +␉␉␉␉␉␉␉␉␉modeline->vtotal = modeline->vblank;␊ |
789 | +␉␉␉␉␉␉␊ |
790 | +␉␉␉␉␉␉␉␉modeline->timing_h = y-1;␊ |
791 | +␉␉␉␉␉␉␉␉modeline->timing_v = x-1;␊ |
792 | +␉␉␉␉␉␉␉}␊ |
793 | +␉␉␉␉␉␉}␊ |
794 | +␉␉␉␉␉}␊ |
795 | +␉␉␉␉␉break;␊ |
796 | +␉␉␉␉case BT_UNKWN:␊ |
797 | +␉␉␉␉␉break;␊ |
798 | +␉␉␉}␊ |
799 | +//␉␉}␊ |
800 | +//␉}␊ |
801 | +} ␊ |
802 | +␊ |
803 | +void display_map_info(vbios_map * map) {␊ |
804 | +␉printf("Chipset: %s\n", chipset_type_names[map->chipset]);␊ |
805 | +␉printf("BIOS: %s\n", bios_type_names[map->bios]);␊ |
806 | +␉␊ |
807 | +␉printf("Mode Table Offset: $C0000 + $%x\n", ((UInt32)map->mode_table) - ((UInt32)map->bios_ptr));␊ |
808 | +␉printf("Mode Table Entries: %u\n", map->mode_table_size);␊ |
809 | +}␊ |
810 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/libsaio/915resolution.h Chameleon-2.0-RC4-r684-mr2//i386/libsaio/915resolution.h␊ |
811 | --- Chameleon-2.0-RC4-r684-src//i386/libsaio/915resolution.h␉1970-01-01 01:00:00.000000000 +0100␊ |
812 | +++ Chameleon-2.0-RC4-r684-mr2//i386/libsaio/915resolution.h␉2010-02-21 15:24:22.000000000 +0100␊ |
813 | @@ -0,0 +1,140 @@␊ |
814 | +/* Copied from 915 resolution created by steve tomljenovic␊ |
815 | + * This source code is into the public domain.␊ |
816 | + *␊ |
817 | + * Included to Chameleon RC3 by meklort␊ |
818 | + *␊ |
819 | + * Included to RC4 and edited by deviato to match more intel chipsets␊ |
820 | + *␊ |
821 | + */␊ |
822 | +␊ |
823 | +#ifndef __915_RESOLUTION_H␊ |
824 | +#define __915_RESOLUTION_H␊ |
825 | +␊ |
826 | +#define NEW(a) ((a *)(malloc(sizeof(a))))␊ |
827 | +#define FREE(a) (free(a))␊ |
828 | +␊ |
829 | +#define VBIOS_START 0xc0000␊ |
830 | +#define VBIOS_SIZE 0x10000␊ |
831 | +␊ |
832 | +#define FALSE 0␊ |
833 | +#define TRUE 1␊ |
834 | +␊ |
835 | +#define MODE_TABLE_OFFSET_845G 617␊ |
836 | +␊ |
837 | +␊ |
838 | +#define ATI_SIGNATURE1 "ATI MOBILITY RADEON"␊ |
839 | +#define ATI_SIGNATURE2 "ATI Technologies Inc"␊ |
840 | +#define NVIDIA_SIGNATURE "NVIDIA Corp"␊ |
841 | +#define INTEL_SIGNATURE "Intel Corp"␊ |
842 | +␊ |
843 | +␊ |
844 | +␊ |
845 | +␊ |
846 | +typedef enum {␊ |
847 | +␉CT_UNKWN, CT_830, CT_845G, CT_855GM, CT_865G, CT_915G, CT_915GM, CT_945G, CT_945GM, CT_945GME,␊ |
848 | +␉CT_946GZ, CT_G965, CT_Q965, CT_965GM, CT_GM45, CT_Optiplex, CT_G41, CT_G31, CT_G45, CT_500␊ |
849 | +} chipset_type;␊ |
850 | +␊ |
851 | +␊ |
852 | +typedef enum {␊ |
853 | +␉BT_UNKWN, BT_1, BT_2, BT_3␊ |
854 | +} bios_type;␊ |
855 | +␊ |
856 | +␊ |
857 | +typedef struct {␊ |
858 | +␉UInt8 mode;␊ |
859 | +␉UInt8 bits_per_pixel;␊ |
860 | +␉UInt16 resolution;␊ |
861 | +␉UInt8 unknown;␊ |
862 | +} __attribute__((packed)) vbios_mode;␊ |
863 | +␊ |
864 | +typedef struct {␊ |
865 | +␉UInt8 unknow1[2];␊ |
866 | +␉UInt8 x1;␊ |
867 | +␉UInt8 x_total;␊ |
868 | +␉UInt8 x2;␊ |
869 | +␉UInt8 y1;␊ |
870 | +␉UInt8 y_total;␊ |
871 | +␉UInt8 y2;␊ |
872 | +} __attribute__((packed)) vbios_resolution_type1;␊ |
873 | +␊ |
874 | +typedef struct {␊ |
875 | +␉unsigned long clock;␊ |
876 | +␉␊ |
877 | +␉UInt16 x1;␊ |
878 | +␉UInt16 htotal;␊ |
879 | +␉UInt16 x2;␊ |
880 | +␉UInt16 hblank;␊ |
881 | +␉UInt16 hsyncstart;␊ |
882 | +␉UInt16 hsyncend;␊ |
883 | +␉UInt16 y1;␊ |
884 | + UInt16 vtotal;␊ |
885 | + UInt16 y2;␊ |
886 | +␉UInt16 vblank;␊ |
887 | +␉UInt16 vsyncstart;␊ |
888 | +␉UInt16 vsyncend;␊ |
889 | +} __attribute__((packed)) vbios_modeline_type2;␊ |
890 | +␊ |
891 | +typedef struct {␊ |
892 | +␉UInt8 xchars;␊ |
893 | +␉UInt8 ychars;␊ |
894 | +␉UInt8 unknown[4];␊ |
895 | +␉␊ |
896 | +␉vbios_modeline_type2 modelines[];␊ |
897 | +} __attribute__((packed)) vbios_resolution_type2;␊ |
898 | +␊ |
899 | +typedef struct {␊ |
900 | +␉unsigned long clock;␊ |
901 | +␉␊ |
902 | +␉UInt16 x1;␊ |
903 | +␉UInt16 htotal;␊ |
904 | +␉UInt16 x2;␊ |
905 | +␉UInt16 hblank;␊ |
906 | +␉UInt16 hsyncstart;␊ |
907 | +␉UInt16 hsyncend;␊ |
908 | +␉␊ |
909 | +␉UInt16 y1;␊ |
910 | +␉UInt16 vtotal;␊ |
911 | +␉UInt16 y2;␊ |
912 | +␉UInt16 vblank;␊ |
913 | +␉UInt16 vsyncstart;␊ |
914 | +␉UInt16 vsyncend;␊ |
915 | +␉␊ |
916 | +␉UInt16 timing_h;␊ |
917 | +␉UInt16 timing_v;␊ |
918 | +␉␊ |
919 | +␉UInt8 unknown[6];␊ |
920 | +} __attribute__((packed)) vbios_modeline_type3;␊ |
921 | +␊ |
922 | +typedef struct {␊ |
923 | +␉unsigned char unknown[6];␊ |
924 | +␉␊ |
925 | + vbios_modeline_type3 modelines[];␊ |
926 | +} __attribute__((packed)) vbios_resolution_type3;␊ |
927 | +␊ |
928 | +typedef struct {␊ |
929 | +␉UInt32 chipset_id;␊ |
930 | +␉chipset_type chipset;␊ |
931 | +␉bios_type bios;␊ |
932 | +␉␊ |
933 | +␉UInt32 bios_fd;␊ |
934 | +␉char* bios_ptr;␊ |
935 | +␉␊ |
936 | +␉vbios_mode * mode_table;␊ |
937 | +␉UInt32 mode_table_size;␊ |
938 | +␉UInt8 b1, b2;␊ |
939 | +␉␊ |
940 | +␉UInt8 unlocked;␊ |
941 | +} vbios_map;␊ |
942 | +␊ |
943 | +␊ |
944 | +␊ |
945 | +void display_map_info(vbios_map*);␊ |
946 | +vbios_map * open_vbios(chipset_type);␊ |
947 | +void close_vbios (vbios_map*);␊ |
948 | +void unlock_vbios(vbios_map*);␊ |
949 | +void relock_vbios(vbios_map*);␊ |
950 | +void set_mode(vbios_map*, UInt32, UInt32, UInt32, UInt32, UInt32);␊ |
951 | +void list_modes(vbios_map *map, UInt32 raw);␊ |
952 | +␊ |
953 | +#endif␊ |
954 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/libsaio/Makefile Chameleon-2.0-RC4-r684-mr2//i386/libsaio/Makefile␊ |
955 | --- Chameleon-2.0-RC4-r684-src//i386/libsaio/Makefile␉2009-11-22 17:31:14.000000000 +0100␊ |
956 | +++ Chameleon-2.0-RC4-r684-mr2//i386/libsaio/Makefile␉2010-02-21 15:24:22.000000000 +0100␊ |
957 | @@ -40,7 +40,7 @@␊ |
958 | ␉freq_detect.o platform.o dsdt_patcher.o \␊ |
959 | ␉smbios_patcher.o fake_efi.o ext2fs.o \␊ |
960 | ␉hpet.o spd.o usb.o pci_setup.o \␊ |
961 | -␉device_inject.o nvidia.o ati.o␊ |
962 | +␉device_inject.o nvidia.o ati.o 915resolution.o edid.o␊ |
963 | ␊ |
964 | ␊ |
965 | SAIO_EXTERN_OBJS = console.o␊ |
966 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/libsaio/edid.c Chameleon-2.0-RC4-r684-mr2//i386/libsaio/edid.c␊ |
967 | --- Chameleon-2.0-RC4-r684-src//i386/libsaio/edid.c␉1970-01-01 01:00:00.000000000 +0100␊ |
968 | +++ Chameleon-2.0-RC4-r684-mr2//i386/libsaio/edid.c␉2010-02-21 15:24:22.000000000 +0100␊ |
969 | @@ -0,0 +1,138 @@␊ |
970 | +/*␊ |
971 | + * edid.c␊ |
972 | + * ␊ |
973 | + *␊ |
974 | + * Created by Evan Lojewski on 12/1/09.␊ |
975 | + * Copyright 2009. All rights reserved.␊ |
976 | + *␊ |
977 | + */␊ |
978 | +␊ |
979 | +␊ |
980 | +#include "libsaio.h"␊ |
981 | +#include "edid.h"␊ |
982 | +#include "vbe.h"␊ |
983 | +//#include "graphics.h"␊ |
984 | +␊ |
985 | +static biosBuf_t bb;␊ |
986 | +␊ |
987 | +UInt32 xResolution = 0;␊ |
988 | +UInt32 yResolution = 0;␊ |
989 | +UInt32 bpResolution = 0;␊ |
990 | +␊ |
991 | +void getResolution(UInt32* x, UInt32* y, UInt32* bp)␊ |
992 | +{␊ |
993 | +␉if(!xResolution && !yResolution && !bpResolution)␊ |
994 | +␉{␊ |
995 | +␉␉␊ |
996 | +␉␉char* edidInfo = readEDID();␊ |
997 | +␉␉␊ |
998 | +␉␉if(!edidInfo) return;␊ |
999 | +␉␉␊ |
1000 | +␉␉// TODO: check *all* resolutions reported and eithe ruse the highest, or the native resolution (if there is a flag for that)␊ |
1001 | +␉␉xResolution = edidInfo[56] | ((edidInfo[58] & 0xF0) << 4);␊ |
1002 | +␉␉yResolution = edidInfo[59] | ((edidInfo[61] & 0xF0) << 4);␊ |
1003 | +␉␉␊ |
1004 | +␉␉␊ |
1005 | +␉␉//printf("H Active = %d", edidInfo[56] | ((edidInfo[58] & 0xF0) << 4) );␊ |
1006 | +␉␉//printf("V Active = %d", edidInfo[59] | ((edidInfo[61] & 0xF0) << 4) );␊ |
1007 | +␉␉␊ |
1008 | +␉␉␊ |
1009 | +␉␉bpResolution = 32;␉// assume 32bits␊ |
1010 | +␉␉␊ |
1011 | +␉␉␊ |
1012 | +␉␉free( edidInfo );␊ |
1013 | +␉␉␊ |
1014 | +␉␉if(!xResolution) xResolution = 1024; //DEFAULT_SCREEN_WIDTH;␊ |
1015 | +␉␉if(!yResolution) yResolution = 768; //DEFAULT_SCREEN_HEIGTH;␊ |
1016 | +␊ |
1017 | +␉}␊ |
1018 | +␊ |
1019 | +␉*x = xResolution;␊ |
1020 | +␉*y = yResolution;␊ |
1021 | +␉*bp = bpResolution;␊ |
1022 | +␊ |
1023 | +}␊ |
1024 | +␊ |
1025 | +char* readEDID()␊ |
1026 | +{␊ |
1027 | +␉SInt16 last_reported = -1;␊ |
1028 | +␉UInt8 edidInfo[EDID_BLOCK_SIZE];␊ |
1029 | +␊ |
1030 | +␉UInt8 pointer;␊ |
1031 | +␊ |
1032 | +␉UInt8 header1[] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};␊ |
1033 | +␉UInt8 header2[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};␊ |
1034 | +␉␊ |
1035 | +␉int status;␊ |
1036 | +␉unsigned int blocks_left = 1;␊ |
1037 | +␉␊ |
1038 | +␉do␊ |
1039 | +␉{␊ |
1040 | +␉␉// TODO: This currently only retrieves the *last* block, make the block buffer expand as needed / calculated from the first block␊ |
1041 | +␊ |
1042 | +␉␉bzero( edidInfo, EDID_BLOCK_SIZE);␊ |
1043 | +␊ |
1044 | +␉␉status = getEDID(edidInfo, blocks_left);␊ |
1045 | +␉␉␊ |
1046 | +␉␉␉␉//printf("Buffer location: 0x%X\n", SEG(buffer) << 16 | OFF(buffer));␊ |
1047 | +␊ |
1048 | +␉␉/*␊ |
1049 | +␉␉int j, i;␊ |
1050 | +␉␉for (j = 0; j < 8; j++) {␊ |
1051 | +␉␉␉for(i = 0; i < 16; i++) printf("0x%X ", edidInfo[((i+1) * (j + 1)) - 1]);␊ |
1052 | +␊ |
1053 | +␉␉}␊ |
1054 | +␉␉printf("\n");␊ |
1055 | +␉␉*/␊ |
1056 | +␉␉␊ |
1057 | +␉␉if(status == 0)␊ |
1058 | +␉␉{␊ |
1059 | +␉␉␉//if( edidInfo[0] == 0x00 || edidInfo[0] == 0xFF)␊ |
1060 | +␉␉␉if((memcmp(edidInfo, header1, sizeof(header1)) != 0) ||␊ |
1061 | +␉␉␉ (memcmp(edidInfo, header2, sizeof(header2)) != 0) )␊ |
1062 | +␉␉␉{␊ |
1063 | +␉␉␉␉blocks_left--;␊ |
1064 | +␉␉␉␉int reported = edidInfo[ EDID_V1_BLOCKS_TO_GO_OFFSET ];␊ |
1065 | +␉␉␉␉␊ |
1066 | +␉␉␉␉if ( reported > blocks_left )␊ |
1067 | +␉␉␉␉{␊ |
1068 | +␉␉␉␉␉␊ |
1069 | +␉␉␉␉␉printf("EDID claims %d more blocks left\n", reported);␊ |
1070 | +␉␉␉␉}␊ |
1071 | +␉␉␉␉␊ |
1072 | +␉␉␉␉if ( (last_reported <= reported && last_reported != -1)␊ |
1073 | +␉␉␉␉␉|| reported == 0xff␊ |
1074 | +␉␉␉␉␉/* 0xff frequently comes up in corrupt edids */␊ |
1075 | +␉␉␉␉␉//|| reported == MAGIC␊ |
1076 | +␉␉␉␉␉)␊ |
1077 | +␉␉␉␉{␊ |
1078 | +␉␉␉␉␉printf("Last reported %d\n", last_reported);␊ |
1079 | +␉␉␉␉␉printf( "EDID blocks left is wrong.\n"␊ |
1080 | +␉␉␉␉␉␉ "Your EDID is probably invalid.\n");␊ |
1081 | +␉␉␉␉␉return 0;␊ |
1082 | +␉␉␉␉}␊ |
1083 | +␉␉␉␉else␊ |
1084 | +␉␉␉␉{␊ |
1085 | +␉␉␉␉␉//printf("Reading EDID block\n");␊ |
1086 | +␉␉␉␉␉//printf("H Active = %d", edidInfo[56] | ((edidInfo[58] & 0xF0) << 4) );␊ |
1087 | +␉␉␉␉␉//printf("V Active = %d", edidInfo[59] | ((edidInfo[61] & 0xF0) << 4) );␊ |
1088 | +␊ |
1089 | +␉␉␉␉␉last_reported = reported;␊ |
1090 | +␉␉␉␉␉blocks_left = reported;␊ |
1091 | +␉␉␉␉}␊ |
1092 | +␉␉␉} ␊ |
1093 | +␉␉␉else␊ |
1094 | +␉␉␉{␊ |
1095 | +␉␉␉␉printf("Invalid block %d\n", blocks_left);␊ |
1096 | +␉␉␉␉printf("Header1 = %d", memcmp(edidInfo, header1, sizeof(header1)) );␊ |
1097 | +␉␉␉␉printf("Header2 = %d", memcmp(edidInfo, header2, sizeof(header2)) );␊ |
1098 | +␉␉␉␉return 0;␊ |
1099 | +␉␉␉}␊ |
1100 | +␉␉}␊ |
1101 | +␉␉blocks_left = 0;␉␊ |
1102 | +␉} while(blocks_left);␊ |
1103 | +␊ |
1104 | +␉UInt8* ret = malloc(sizeof(edidInfo));␊ |
1105 | +␉memcpy(ret, edidInfo, sizeof(edidInfo));␊ |
1106 | +␉return ret;␊ |
1107 | +}␊ |
1108 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/libsaio/edid.h Chameleon-2.0-RC4-r684-mr2//i386/libsaio/edid.h␊ |
1109 | --- Chameleon-2.0-RC4-r684-src//i386/libsaio/edid.h␉1970-01-01 01:00:00.000000000 +0100␊ |
1110 | +++ Chameleon-2.0-RC4-r684-mr2//i386/libsaio/edid.h␉2010-02-21 15:24:22.000000000 +0100␊ |
1111 | @@ -0,0 +1,22 @@␊ |
1112 | +/*␊ |
1113 | + * edid.h␊ |
1114 | + * ␊ |
1115 | + *␊ |
1116 | + * Created by Evan Lojewski on 12/1/09.␊ |
1117 | + * Copyright 2009. All rights reserved.␊ |
1118 | + *␊ |
1119 | + */␊ |
1120 | +␊ |
1121 | +␊ |
1122 | +#define EDID_BLOCK_SIZE␉128␊ |
1123 | +#define EDID_V1_BLOCKS_TO_GO_OFFSET 126␊ |
1124 | +␊ |
1125 | +#define SERVICE_REPORT_DDC␉0␊ |
1126 | +#define SERVICE_READ_EDID␉1␊ |
1127 | +#define SERVICE_LAST␉␉1 // Read VDIF has been removed from the spec.␊ |
1128 | +␊ |
1129 | +#define FUNC_GET_EDID␉␉0x4F15␊ |
1130 | +␊ |
1131 | +␊ |
1132 | +char* readEDID();␊ |
1133 | +void getResolution(UInt32* x, UInt32* y, UInt32* bp);␊ |
1134 | \ Manca newline alla fine del file␊ |
1135 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/libsaio/vbe.c Chameleon-2.0-RC4-r684-mr2//i386/libsaio/vbe.c␊ |
1136 | --- Chameleon-2.0-RC4-r684-src//i386/libsaio/vbe.c␉2009-11-22 17:31:14.000000000 +0100␊ |
1137 | +++ Chameleon-2.0-RC4-r684-mr2//i386/libsaio/vbe.c␉2010-02-21 15:24:22.000000000 +0100␊ |
1138 | @@ -74,6 +74,21 @@␊ |
1139 | return(bb.eax.r.h);␊ |
1140 | }␊ |
1141 | ␊ |
1142 | +int getEDID( void * edidBlock, UInt8 block)␊ |
1143 | +{␊ |
1144 | +␉bzero(&bb, sizeof(bb));␊ |
1145 | + bb.intno = 0x10;␊ |
1146 | + bb.eax.rr = funcGetEDID;␊ |
1147 | +␉bb.ebx.r.l= 0x01;␊ |
1148 | +␉bb.edx.rr = block;␊ |
1149 | +␊ |
1150 | + bb.es = SEG( edidBlock );␊ |
1151 | + bb.edi.rr = OFF( edidBlock );␊ |
1152 | +␊ |
1153 | + bios( &bb );␊ |
1154 | + return(bb.eax.r.h);␊ |
1155 | +}␊ |
1156 | +␊ |
1157 | int getVBEModeInfo( int mode, void * minfo_p )␊ |
1158 | {␊ |
1159 | bb.intno = 0x10;␊ |
1160 | diff -Naur Chameleon-2.0-RC4-r684-src//i386/libsaio/vbe.h Chameleon-2.0-RC4-r684-mr2//i386/libsaio/vbe.h␊ |
1161 | --- Chameleon-2.0-RC4-r684-src//i386/libsaio/vbe.h␉2009-11-22 17:31:14.000000000 +0100␊ |
1162 | +++ Chameleon-2.0-RC4-r684-mr2//i386/libsaio/vbe.h␉2010-02-21 15:24:22.000000000 +0100␊ |
1163 | @@ -68,7 +68,8 @@␊ |
1164 | funcGetSetPaletteFormat = 0x4F08,␊ |
1165 | funcGetSetPaletteData = 0x4F09,␊ |
1166 | funcGetProtModeInterdace = 0x4F0A,␊ |
1167 | - funcGetSetPixelClock = 0x4F0B␊ |
1168 | + funcGetSetPixelClock = 0x4F0B,␊ |
1169 | + funcGetEDID = 0x4F15␊ |
1170 | };␊ |
1171 | ␊ |
1172 | enum {␊ |
1173 | diff -Naur Chameleon-2.0-RC4-r684-src//version Chameleon-2.0-RC4-r684-mr2//version␊ |
1174 | --- Chameleon-2.0-RC4-r684-src//version␉2009-11-22 17:31:14.000000000 +0100␊ |
1175 | +++ Chameleon-2.0-RC4-r684-mr2//version␉2010-02-21 15:24:22.000000000 +0100␊ |
1176 | @@ -1 +1 @@␊ |
1177 | -2.0-RC4␊ |
1178 | \ Manca newline alla fine del file␊ |
1179 | +2.0-RC4-mr2␊ |
1180 | \ Manca newline alla fine del file␊ |
1181 | |