1 | /*␊ |
2 | * resolution.h␊ |
3 | * ␊ |
4 | *␉NOTE: I don't beleive this code is production ready / should be in trunk␊ |
5 | * Atleast, not in it's current state. ␊ |
6 | *␊ |
7 | * Created by Evan Lojewski on 3/4/10.␊ |
8 | * Copyright 2009. All rights reserved.␊ |
9 | *␊ |
10 | */␊ |
11 | #ifndef _RESOLUTION_H_␊ |
12 | #define _RESOLUTION_H_␊ |
13 | ␊ |
14 | //#include "libsaio.h"␊ |
15 | //#include "edid.h" //included␊ |
16 | #include "915resolution.h"␊ |
17 | ␊ |
18 | ␊ |
19 | void patchVideoBios()␊ |
20 | {␊ |
21 | ␉UInt32 x = 0, y = 0, bp = 0;␊ |
22 | ␉␊ |
23 | ␉verbose("Resolution:\n");␊ |
24 | ␉getResolution(&x, &y, &bp);␊ |
25 | ␉␊ |
26 | ␉if (x != 0 && y != 0 && bp != 0)␊ |
27 | ␉{␊ |
28 | ␉␉vbios_map * map;␊ |
29 | ␉␉␊ |
30 | ␉␉map = open_vbios(CT_UNKNOWN);␊ |
31 | ␉␉if(map)␊ |
32 | ␉␉{␊ |
33 | ␉␉␉unlock_vbios(map);␊ |
34 | ␊ |
35 | ␉␉␉set_mode(map, x, y, bp, 0, 0);␊ |
36 | ␊ |
37 | ␉␉␉relock_vbios(map);␊ |
38 | ␊ |
39 | ␉␉␉close_vbios(map);␊ |
40 | ␉␉}␊ |
41 | ␉}␊ |
42 | }␊ |
43 | ␊ |
44 | ␊ |
45 | /* Copied from 915 resolution created by steve tomljenovic␊ |
46 | *␊ |
47 | * This code is based on the techniques used in :␊ |
48 | *␊ |
49 | * - 855patch. Many thanks to Christian Zietz (czietz gmx net)␊ |
50 | * for demonstrating how to shadow the VBIOS into system RAM␊ |
51 | * and then modify it.␊ |
52 | *␊ |
53 | * - 1280patch by Andrew Tipton (andrewtipton null li).␊ |
54 | *␊ |
55 | * - 855resolution by Alain Poirier␊ |
56 | *␊ |
57 | * This source code is into the public domain.␊ |
58 | */␊ |
59 | ␊ |
60 | /**␊ |
61 | **␊ |
62 | **/␊ |
63 | ␊ |
64 | #define CONFIG_MECH_ONE_ADDR␉0xCF8␊ |
65 | #define CONFIG_MECH_ONE_DATA␉0xCFC␊ |
66 | ␊ |
67 | int freqs[] = { 60, 75, 85 };␊ |
68 | ␊ |
69 | UInt32 get_chipset_id(void)␊ |
70 | {␊ |
71 | ␉outl(CONFIG_MECH_ONE_ADDR, 0x80000000);␊ |
72 | ␉return inl(CONFIG_MECH_ONE_DATA);␊ |
73 | }␊ |
74 | ␊ |
75 | chipset_type get_chipset(UInt32 id)␊ |
76 | {␊ |
77 | ␉chipset_type type;␊ |
78 | ␉␉␊ |
79 | ␉switch (id) {␊ |
80 | ␉␉case 0x35758086:␊ |
81 | ␉␉␉type = CT_830;␊ |
82 | ␉␉␉break;␊ |
83 | ␉␉␉␊ |
84 | ␉␉case 0x25608086:␊ |
85 | ␉␉␉type = CT_845G;␊ |
86 | ␉␉␉break;␊ |
87 | ␉␉␉␊ |
88 | ␉␉case 0x35808086:␊ |
89 | ␉␉␉type = CT_855GM;␊ |
90 | ␉␉␉break;␊ |
91 | ␉␉␉␊ |
92 | ␉␉case 0x25708086:␊ |
93 | ␉␉␉type = CT_865G;␊ |
94 | ␉␉␉break;␊ |
95 | ␉␉␉␊ |
96 | ␉␉case 0x25808086:␊ |
97 | ␉␉␉type = CT_915G;␊ |
98 | ␉␉␉break;␊ |
99 | ␉␉␉␊ |
100 | ␉␉case 0x25908086:␊ |
101 | ␉␉␉type = CT_915GM;␊ |
102 | ␉␉␉break;␊ |
103 | ␉␉␉␊ |
104 | ␉␉case 0x27708086:␊ |
105 | ␉␉␉type = CT_945G;␊ |
106 | ␉␉␉break;␊ |
107 | ␉␉␉␊ |
108 | ␉␉case 0x27a08086:␊ |
109 | ␉␉␉type = CT_945GM;␊ |
110 | ␉␉␉break;␊ |
111 | ␉␉␉␊ |
112 | ␉␉case 0x27ac8086:␊ |
113 | ␉␉␉type = CT_945GME;␊ |
114 | ␉␉␉break;␊ |
115 | ␉␉␉␊ |
116 | ␉␉case 0x29708086:␊ |
117 | ␉␉␉type = CT_946GZ;␊ |
118 | ␉␉␉break;␊ |
119 | ␉␉␉␊ |
120 | ␉␉case 0x27748086:␊ |
121 | ␉␉␉type = CT_955X;␊ |
122 | ␉␉␉break;␊ |
123 | ␉␉␉␊ |
124 | ␉␉case 0x277c8086:␊ |
125 | ␉␉␉type = CT_975X;␊ |
126 | ␉␉␉break;␊ |
127 | ␊ |
128 | ␉␉case 0x29a08086:␊ |
129 | ␉␉␉type = CT_G965;␊ |
130 | ␉␉␉break;␊ |
131 | ␉␉␉␊ |
132 | ␉␉case 0x29908086:␊ |
133 | ␉␉␉type = CT_Q965;␊ |
134 | ␉␉␉break;␊ |
135 | ␉␉␉␊ |
136 | ␉␉case 0x81008086:␊ |
137 | ␉␉␉type = CT_500;␊ |
138 | ␉␉␉break;␊ |
139 | ␉␉␉␊ |
140 | ␉␉case 0x2e108086:␊ |
141 | ␉␉case 0X2e908086:␊ |
142 | ␉␉␉type = CT_B43;␊ |
143 | ␉␉␉break;␊ |
144 | ␊ |
145 | ␉␉case 0x2e208086:␊ |
146 | ␉␉␉type = CT_P45;␊ |
147 | ␉␉␉break;␊ |
148 | ␊ |
149 | ␉␉case 0x2e308086:␊ |
150 | ␉␉␉type = CT_G41;␊ |
151 | ␉␉␉break;␊ |
152 | ␉␉␉␉␉␊ |
153 | ␉␉case 0x29c08086:␊ |
154 | ␉␉␉type = CT_G31;␊ |
155 | ␉␉␉break;␊ |
156 | ␉␉␉␊ |
157 | ␉␉case 0x29208086:␊ |
158 | ␉␉␉type = CT_G45;␊ |
159 | ␉␉␉break;␊ |
160 | ␉␉␉␊ |
161 | ␉␉case 0xA0108086:␉// mobile␊ |
162 | ␉␉case 0xA0008086:␉// desktop␊ |
163 | ␉␉␉type = CT_3150;␊ |
164 | ␉␉␉break;␊ |
165 | ␉␉␉␊ |
166 | ␉␉case 0x2a008086:␊ |
167 | ␉␉␉type = CT_965GM;␊ |
168 | ␉␉␉break;␊ |
169 | ␉␉␉␊ |
170 | ␉␉case 0x29e08086:␊ |
171 | ␉␉␉type = CT_X48;␊ |
172 | ␉␉␉break;␉␉␉␊ |
173 | ␉␉␉␉␊ |
174 | ␉␉case 0x2a408086:␊ |
175 | ␉␉␉type = CT_GM45;␊ |
176 | ␉␉␉break;␊ |
177 | ␉␉␉␊ |
178 | ␉␉␉//␊ |
179 | ␉␉␉// Core processors␊ |
180 | ␉␉␉// http://pci-ids.ucw.cz/read/PC/8086␊ |
181 | ␉␉␉//␊ |
182 | ␉␉case 0x00408086: // Core Processor DRAM Controller␊ |
183 | ␉␉case 0x00448086: // Core Processor DRAM Controller␊ |
184 | ␉␉case 0x00488086: // Core Processor DRAM Controller␊ |
185 | ␉␉case 0x00698086: // Core Processor DRAM Controller␊ |
186 | ␉␉␉␊ |
187 | ␉␉case 0x01008086: // 2nd Generation Core Processor Family DRAM Controller␊ |
188 | ␉␉case 0x01048086: // 2nd Generation Core Processor Family DRAM Controller␊ |
189 | ␉␉case 0x01088086: // Xeon E3-1200 2nd Generation Core Processor Family DRAM Controller␊ |
190 | ␉␉case 0x010c8086: // Xeon E3-1200 2nd Generation Core Processor Family DRAM Controller␊ |
191 | ␊ |
192 | ␉␉case 0x01508086: // 3rd Generation Core Processor Family DRAM Controller␊ |
193 | ␉␉case 0x01548086: // 3rd Generation Core Processor Family DRAM Controller␊ |
194 | ␉␉case 0x01588086: // 3rd Generation Core Processor Family DRAM Controller␊ |
195 | ␉␉case 0x015c8086: // 3rd Generation Core Processor Family DRAM Controller␊ |
196 | ␉␉␉verbose(" core proc identified\n");␊ |
197 | ␉␉␉type = CT_CORE_PROC;␊ |
198 | ␉␉␉break;␊ |
199 | ␉␉␉␊ |
200 | ␉␉default:␊ |
201 | ␉␉␉if((id & 0x0000FFFF) == 0x00008086) // Intel chipset␊ |
202 | ␉␉␉{␊ |
203 | ␉␉␉␉//printf("Unknown chipset 0x%llX, please email id to meklort@gmail.com", id);␊ |
204 | ␉␉␉␉//getc();␊ |
205 | ␉␉␉␉type = CT_UNKNOWN_INTEL;␊ |
206 | ␉␉␉␉//type = CT_UNKNOWN;␊ |
207 | ␊ |
208 | ␉␉␉}␊ |
209 | ␉␉␉else␊ |
210 | ␉␉␉{␊ |
211 | ␉␉␉␉type = CT_UNKNOWN;␊ |
212 | ␉␉␉}␊ |
213 | ␉␉␉break;␊ |
214 | ␉}␊ |
215 | ␊ |
216 | ␉return type;␊ |
217 | }␊ |
218 | ␊ |
219 | vbios_resolution_type1 * map_type1_resolution(vbios_map * map, UInt16 res)␊ |
220 | {␊ |
221 | ␉vbios_resolution_type1 * ptr = ((vbios_resolution_type1*)(map->bios_ptr + res)); ␊ |
222 | ␉return ptr;␊ |
223 | }␊ |
224 | ␊ |
225 | vbios_resolution_type2 * map_type2_resolution(vbios_map * map, UInt16 res)␊ |
226 | {␊ |
227 | ␉vbios_resolution_type2 * ptr = ((vbios_resolution_type2*)(map->bios_ptr + res)); ␊ |
228 | ␉return ptr;␊ |
229 | }␊ |
230 | ␊ |
231 | vbios_resolution_type3 * map_type3_resolution(vbios_map * map, UInt16 res)␊ |
232 | {␊ |
233 | ␉vbios_resolution_type3 * ptr = ((vbios_resolution_type3*)(map->bios_ptr + res)); ␊ |
234 | ␉return ptr;␊ |
235 | }␊ |
236 | ␊ |
237 | char detect_bios_type(vbios_map * map, char modeline, int entry_size);␊ |
238 | char detect_bios_type(vbios_map * map, char modeline, int entry_size)␊ |
239 | {␊ |
240 | ␉UInt32 i;␊ |
241 | ␉UInt16 r1, r2;␊ |
242 | ␉␊ |
243 | ␉r1 = r2 = 32000;␊ |
244 | ␉␊ |
245 | ␉for (i=0; i < map->mode_table_size; i++)␊ |
246 | ␉{␊ |
247 | ␉␉if (map->mode_table[i].resolution <= r1)␊ |
248 | ␉␉{␊ |
249 | ␉␉␉r1 = map->mode_table[i].resolution;␊ |
250 | ␉␉}␊ |
251 | ␉␉else␊ |
252 | ␉␉{␊ |
253 | ␉␉␉if (map->mode_table[i].resolution <= r2)␊ |
254 | ␉␉␉{␊ |
255 | ␉␉␉␉r2 = map->mode_table[i].resolution;␊ |
256 | ␉␉␉}␊ |
257 | ␉␉}␊ |
258 | ␊ |
259 | ␉␉//printf("r1 = %d r2 = %d\n", r1, r2);␊ |
260 | ␉}␊ |
261 | ␉␊ |
262 | ␉return (r2-r1-6) % entry_size == 0;␊ |
263 | }␊ |
264 | ␊ |
265 | void close_vbios(vbios_map * map);␊ |
266 | ␊ |
267 | char detect_ati_bios_type(vbios_map * map)␊ |
268 | {␉␊ |
269 | ␉return map->mode_table_size % sizeof(ATOM_MODE_TIMING) == 0;␊ |
270 | }␊ |
271 | ␊ |
272 | ␊ |
273 | vbios_map * open_vbios(chipset_type forced_chipset)␊ |
274 | {␊ |
275 | ␉UInt32 z;␊ |
276 | ␉vbios_map * map = malloc(sizeof(vbios_map));␊ |
277 | ␉if (!map)␊ |
278 | ␉{␊ |
279 | ␉␉return 0;␊ |
280 | ␉}␊ |
281 | ␉for(z=0; z<sizeof(vbios_map); z++) ((char*)map)[z]=0;␊ |
282 | ␉/*␊ |
283 | ␉ * Determine chipset␊ |
284 | ␉ */␊ |
285 | ␉␊ |
286 | ␉if (forced_chipset == CT_UNKNOWN)␊ |
287 | ␉{␊ |
288 | ␉␉map->chipset_id = get_chipset_id();␊ |
289 | ␉␉map->chipset = get_chipset(map->chipset_id);␊ |
290 | ␉}␊ |
291 | ␉else if (forced_chipset != CT_UNKNOWN)␊ |
292 | ␉{␊ |
293 | ␉␉map->chipset = forced_chipset;␊ |
294 | ␉}␊ |
295 | ␉␊ |
296 | ␉␊ |
297 | ␉if (map->chipset == CT_UNKNOWN)␊ |
298 | ␉{␊ |
299 | ␉␉verbose(" Unknown chipset type: %08x.\n", map->chipset_id);␊ |
300 | ␉␉//verbose("915resolution only works with Intel 800/900 series graphic chipsets.\n");␊ |
301 | ␉␉//verbose("Chipset Id: %x\n", map->chipset_id);␊ |
302 | ␉␉close_vbios(map);␊ |
303 | ␉␉return 0;␊ |
304 | ␉}␊ |
305 | ␉else␊ |
306 | ␉{␊ |
307 | ␉␉verbose(" Detected chipset/proc id (DRAM controller): %08x\n", map->chipset_id);␊ |
308 | ␉}␊ |
309 | ␉␊ |
310 | ␉␊ |
311 | ␉verbose(" VBios: ");␊ |
312 | ␉/*␊ |
313 | ␉ * Map the video bios to memory␊ |
314 | ␉ */␊ |
315 | ␉map->bios_ptr=(char*)VBIOS_START;␊ |
316 | ␉␊ |
317 | ␉/*␊ |
318 | ␉ * check if we have ATI Radeon␊ |
319 | ␉ */␊ |
320 | ␉map->ati_tables.base = map->bios_ptr;␊ |
321 | ␉map->ati_tables.AtomRomHeader = (ATOM_ROM_HEADER *) (map->bios_ptr + *(unsigned short *) (map->bios_ptr + OFFSET_TO_POINTER_TO_ATOM_ROM_HEADER)); ␊ |
322 | ␉if (strcmp ((char *) map->ati_tables.AtomRomHeader->uaFirmWareSignature, "ATOM") == 0)␊ |
323 | ␉{␊ |
324 | ␉␉verbose("ATI");␊ |
325 | ␉␉// ATI Radeon Card␊ |
326 | ␉␉map->bios = BT_ATI_1;␊ |
327 | ␉␉␊ |
328 | ␉␉map->ati_tables.MasterDataTables = (unsigned short *) &((ATOM_MASTER_DATA_TABLE *) (map->bios_ptr + map->ati_tables.AtomRomHeader->usMasterDataTableOffset))->ListOfDataTables;␊ |
329 | ␉␉unsigned short std_vesa_offset = (unsigned short) ((ATOM_MASTER_LIST_OF_DATA_TABLES *)map->ati_tables.MasterDataTables)->StandardVESA_Timing;␊ |
330 | ␉␉ATOM_STANDARD_VESA_TIMING * std_vesa = (ATOM_STANDARD_VESA_TIMING *) (map->bios_ptr + std_vesa_offset);␊ |
331 | ␉␉␊ |
332 | ␉␉map->ati_mode_table = (char *) &std_vesa->aModeTimings;␊ |
333 | ␉␉if (map->ati_mode_table == 0)␊ |
334 | ␉␉{␊ |
335 | ␉␉␉printf("Unable to locate the mode table.\n");␊ |
336 | ␉␉␉printf("Please run the program 'dump_bios' as root and\n");␊ |
337 | ␉␉␉printf("email the file 'vbios.dmp' to stomljen@yahoo.com.\n");␊ |
338 | ␉␉␉printf("Chipset: %d\n", map->chipset);␊ |
339 | ␉␉␉close_vbios(map);␊ |
340 | ␉␉␉return 0;␊ |
341 | ␉␉}␊ |
342 | ␉␉map->mode_table_size = std_vesa->sHeader.usStructureSize - sizeof(ATOM_COMMON_TABLE_HEADER);␊ |
343 | ␉␉␊ |
344 | ␉␉if (!detect_ati_bios_type(map))␊ |
345 | ␉␉{␊ |
346 | ␉␉␉map->bios = BT_ATI_2;␊ |
347 | ␉␉}␊ |
348 | ␊ |
349 | ␉␉if (map->bios == BT_ATI_1)␊ |
350 | ␉␉{␊ |
351 | ␉␉␉verbose(", BT_ATI_1\n");␊ |
352 | ␉␉}␊ |
353 | ␉␉else␊ |
354 | ␉␉{␊ |
355 | ␉␉␉verbose(", BT_ATI_2\n");␊ |
356 | ␉␉}␊ |
357 | ␉}␊ |
358 | ␉else␊ |
359 | ␉{␊ |
360 | ␉␉␊ |
361 | ␉␉/*␊ |
362 | ␉␉ * check if we have NVIDIA␊ |
363 | ␉␉ */␊ |
364 | ␊ |
365 | ␉␉int i = 0;␊ |
366 | ␉␉while (i < 512)␊ |
367 | ␉␉{ // we don't need to look through the whole bios, just the first 512 bytes␊ |
368 | ␉␉␉if ((␉map->bios_ptr[i] == 'N') ␊ |
369 | ␉␉␉␉&& (map->bios_ptr[i+1] == 'V') ␊ |
370 | ␉␉␉␉&& (map->bios_ptr[i+2] == 'I') ␊ |
371 | ␉␉␉␉&& (map->bios_ptr[i+3] == 'D')) ␊ |
372 | ␉␉␉{␊ |
373 | ␉␉␉␉verbose("nVidia\n");␊ |
374 | ␉␉␉␉map->bios = BT_NVDA;␊ |
375 | ␉␉␉␉unsigned short nv_data_table_offset = 0;␊ |
376 | ␉␉␉␉unsigned short * nv_data_table;␊ |
377 | ␉␉␉␉NV_VESA_TABLE * std_vesa;␊ |
378 | ␉␉␉␉␊ |
379 | ␉␉␉␉int i = 0;␊ |
380 | ␊ |
381 | ␉␉␉␉while (i < 0x300)␊ |
382 | ␉␉␉␉{ //We don't need to look for the table in the whole bios, the 768 first bytes only␊ |
383 | ␉␉␉␉␉if ((␉map->bios_ptr[i] == 0x44) ␊ |
384 | ␉␉␉␉␉␉&& (map->bios_ptr[i+1] == 0x01) ␊ |
385 | ␉␉␉␉␉␉&& (map->bios_ptr[i+2] == 0x04) ␊ |
386 | ␉␉␉␉␉␉&& (map->bios_ptr[i+3] == 0x00))␊ |
387 | ␉␉␉␉␉{␊ |
388 | ␉␉␉␉␉␉nv_data_table_offset = (unsigned short) (map->bios_ptr[i+4] | (map->bios_ptr[i+5] << 8));␊ |
389 | ␉␉␉␉␉␉break;␊ |
390 | ␉␉␉␉␉}␊ |
391 | ␉␉␉␉␉i++;␊ |
392 | ␉␉␉␉}␊ |
393 | ␉␉␉␉␊ |
394 | ␉␉␉␉nv_data_table = (unsigned short *) (map->bios_ptr + (nv_data_table_offset + OFFSET_TO_VESA_TABLE_INDEX));␊ |
395 | ␉␉␉␉std_vesa = (NV_VESA_TABLE *) (map->bios_ptr + *nv_data_table);␊ |
396 | ␉␉␉␉␊ |
397 | ␉␉␉␉map->nv_mode_table = (char *) std_vesa->sModelines;␊ |
398 | ␉␉␉␉if (map->nv_mode_table == 0)␊ |
399 | ␉␉␉␉{␊ |
400 | ␉␉␉␉␉printf("Unable to locate the mode table.\n");␊ |
401 | ␉␉␉␉␉printf("Please run the program 'dump_bios' as root and\n");␊ |
402 | ␉␉␉␉␉printf("email the file 'vbios.dmp' to stomljen@yahoo.com.\n");␊ |
403 | ␉␉␉␉␉printf("Chipset: %s\n", map->chipset);␊ |
404 | ␉␉␉␉␉close_vbios(map);␊ |
405 | ␉␉␉␉␉return 0;␊ |
406 | ␉␉␉␉}␊ |
407 | ␉␉␉␉map->mode_table_size = std_vesa->sHeader.usTable_Size;␊ |
408 | ␉␉␉␉␊ |
409 | ␉␉␉␉break;␊ |
410 | ␉␉␉}␊ |
411 | ␉␉␉i++;␊ |
412 | ␉␉}␊ |
413 | ␉}␊ |
414 | ␉␊ |
415 | ␊ |
416 | ␉/*␊ |
417 | ␉ * check if we have Intel␊ |
418 | ␉ */␊ |
419 | ␊ |
420 | ␉/*if (map->chipset == CT_UNKNOWN && memmem(map->bios_ptr, VBIOS_SIZE, INTEL_SIGNATURE, strlen(INTEL_SIGNATURE))) {␊ |
421 | ␉ printf( "Intel chipset detected. However, 915resolution was unable to determine the chipset type.\n");␊ |
422 | ␊ |
423 | ␉ printf("Chipset Id: %x\n", map->chipset_id);␊ |
424 | ␊ |
425 | ␉ printf("Please report this problem to stomljen@yahoo.com\n");␊ |
426 | ␊ |
427 | ␉ close_vbios(map);␊ |
428 | ␉ return 0;␊ |
429 | ␉ }*/␊ |
430 | ␊ |
431 | ␉/*␊ |
432 | ␉ * check for others␊ |
433 | ␉ */␊ |
434 | ␉␊ |
435 | ␉/*␊ |
436 | ␉ * Figure out where the mode table is ␊ |
437 | ␉ */␊ |
438 | ␉if ((map->bios != BT_ATI_1) && (map->bios != BT_ATI_2) && (map->bios != BT_NVDA)) ␊ |
439 | ␉{␊ |
440 | ␉␉char* p = map->bios_ptr + 16;␊ |
441 | ␉␉char* limit = map->bios_ptr + VBIOS_SIZE - (3 * sizeof(vbios_mode));␊ |
442 | ␉␉␊ |
443 | ␉␉verbose("Other");␊ |
444 | ␉␉while (p < limit && map->mode_table == 0)␊ |
445 | ␉␉{␊ |
446 | ␉␉␉vbios_mode * mode_ptr = (vbios_mode *) p;␊ |
447 | ␉␉␉␊ |
448 | ␉␉␉if (((mode_ptr[0].mode & 0xf0) == 0x30) && ((mode_ptr[1].mode & 0xf0) == 0x30) &&␊ |
449 | ␉␉␉␉((mode_ptr[2].mode & 0xf0) == 0x30) && ((mode_ptr[3].mode & 0xf0) == 0x30))␊ |
450 | ␉␉␉{␊ |
451 | ␉␉␉␉map->mode_table = mode_ptr;␊ |
452 | ␉␉␉}␊ |
453 | ␉␉␉␊ |
454 | ␉␉␉p++;␊ |
455 | ␉␉}␊ |
456 | ␊ |
457 | ␉␉if (map->mode_table == 0)␊ |
458 | ␉␉{␊ |
459 | ␉␉␉close_vbios(map);␊ |
460 | ␉␉␉return 0;␊ |
461 | ␉␉}␊ |
462 | ␉}␊ |
463 | ␉␊ |
464 | ␉␊ |
465 | ␉/*␊ |
466 | ␉ * Determine size of mode table␊ |
467 | ␉ */␊ |
468 | ␉if ((map->bios != BT_ATI_1) && (map->bios != BT_ATI_2) && (map->bios != BT_NVDA))␊ |
469 | ␉{␊ |
470 | ␉␉vbios_mode * mode_ptr = map->mode_table;␊ |
471 | ␉␉␊ |
472 | ␉␉while (mode_ptr->mode != 0xff)␊ |
473 | ␉␉{␊ |
474 | ␉␉␉map->mode_table_size++;␊ |
475 | ␉␉␉mode_ptr++;␊ |
476 | ␉␉}␊ |
477 | ␉}␊ |
478 | ␉␊ |
479 | ␉/*␊ |
480 | ␉ * Figure out what type of bios we have␊ |
481 | ␉ * order of detection is important␊ |
482 | ␉ */␊ |
483 | ␉if ((map->bios != BT_ATI_1) && (map->bios != BT_ATI_2) && (map->bios != BT_NVDA))␊ |
484 | ␉{␊ |
485 | ␉␉if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type3)))␊ |
486 | ␉␉{␊ |
487 | ␉␉␉map->bios = BT_3;␊ |
488 | ␉␉␉verbose(", BT_3\n");␊ |
489 | ␉␉}␊ |
490 | ␉␉else if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type2)))␊ |
491 | ␉␉{␊ |
492 | ␉␉␉map->bios = BT_2;␊ |
493 | ␉␉␉verbose(", BT_2\n");␊ |
494 | ␉␉}␊ |
495 | ␉␉else if (detect_bios_type(map, FALSE, sizeof(vbios_resolution_type1)))␊ |
496 | ␉␉{␊ |
497 | ␉␉␉map->bios = BT_1;␊ |
498 | ␉␉␉verbose(", BT_1\n");␊ |
499 | ␉␉}␊ |
500 | ␉␉else {␊ |
501 | ␉␉␉verbose(" - unknown\n");␊ |
502 | ␉␉␉return 0;␊ |
503 | ␉␉}␊ |
504 | ␉}␊ |
505 | ␉␊ |
506 | ␉return map;␊ |
507 | }␊ |
508 | ␊ |
509 | void close_vbios(vbios_map * map)␊ |
510 | {␊ |
511 | ␉free(map);␊ |
512 | }␊ |
513 | ␊ |
514 | void unlock_vbios(vbios_map * map)␊ |
515 | {␊ |
516 | ␊ |
517 | ␉map->unlocked = TRUE;␊ |
518 | ␊ |
519 | ␉switch (map->chipset) {␊ |
520 | ␉␉case CT_UNKNOWN:␊ |
521 | ␉␉␉break;␊ |
522 | ␉␉case CT_830:␊ |
523 | ␉␉case CT_855GM:␊ |
524 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x8000005a);␊ |
525 | ␉␉␉map->b1 = inb(CONFIG_MECH_ONE_DATA + 2);␊ |
526 | ␉␉␉␊ |
527 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x8000005a);␊ |
528 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, 0x33);␊ |
529 | ␉␉␉break;␊ |
530 | ␉␉case CT_845G:␊ |
531 | ␉␉case CT_865G:␊ |
532 | ␉␉case CT_915G:␊ |
533 | ␉␉case CT_915GM:␊ |
534 | ␉␉case CT_945G:␊ |
535 | ␉␉case CT_945GM:␊ |
536 | ␉␉case CT_945GME:␊ |
537 | ␉␉case CT_946GZ:␊ |
538 | ␉␉case CT_G965:␊ |
539 | ␉␉case CT_Q965:␊ |
540 | ␉␉case CT_965GM:␊ |
541 | ␉␉case CT_975X:␊ |
542 | ␉␉case CT_P35:␊ |
543 | ␉␉case CT_955X:␊ |
544 | ␉␉case CT_X48:␊ |
545 | ␉␉case CT_B43:␊ |
546 | ␉␉case CT_Q45:␊ |
547 | ␉␉case CT_P45:␊ |
548 | ␉␉case CT_GM45:␊ |
549 | ␉␉case CT_G45:␊ |
550 | ␉␉case CT_G41:␊ |
551 | ␉␉case CT_G31:␊ |
552 | ␉␉case CT_500:␊ |
553 | ␉␉case CT_3150:␊ |
554 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000090);␊ |
555 | ␉␉␉map->b1 = inb(CONFIG_MECH_ONE_DATA + 1);␊ |
556 | ␉␉␉map->b2 = inb(CONFIG_MECH_ONE_DATA + 2);␊ |
557 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000090);␊ |
558 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 1, 0x33);␊ |
559 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, 0x33);␊ |
560 | ␉␉␉break;␊ |
561 | ␉␉case CT_CORE_PROC:␉ // Core procs - PAM regs are 80h - 86h␊ |
562 | ␉␉case CT_UNKNOWN_INTEL:␉// Assume newer intel chipset is the same as before␊ |
563 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000080);␊ |
564 | ␉␉␉map->b1 = inb(CONFIG_MECH_ONE_DATA + 1);␊ |
565 | ␉␉␉map->b2 = inb(CONFIG_MECH_ONE_DATA + 2);␊ |
566 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000080);␊ |
567 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 1, 0x33);␊ |
568 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, 0x33);␊ |
569 | ␉␉␉break;␊ |
570 | ␉␉default:␊ |
571 | ␉␉␉break;␊ |
572 | ␉}␊ |
573 | ␉␊ |
574 | #if DEBUG␊ |
575 | ␉{␊ |
576 | ␉␉UInt32 t = inl(CONFIG_MECH_ONE_DATA);␊ |
577 | ␉␉verbose("unlock PAM: (0x%08x)\n", t);␊ |
578 | ␉}␊ |
579 | #endif␊ |
580 | }␊ |
581 | ␊ |
582 | void relock_vbios(vbios_map * map)␊ |
583 | {␊ |
584 | ␉␊ |
585 | ␉map->unlocked = FALSE;␊ |
586 | ␉␊ |
587 | ␉switch (map->chipset)␊ |
588 | ␉{␊ |
589 | ␉␉case CT_UNKNOWN:␊ |
590 | ␉␉␉break;␊ |
591 | ␉␉case CT_830:␊ |
592 | ␉␉case CT_855GM:␊ |
593 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x8000005a);␊ |
594 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, 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_955X:␊ |
606 | ␉␉case CT_G45:␊ |
607 | ␉␉case CT_Q965:␊ |
608 | ␉␉case CT_965GM:␊ |
609 | ␉␉case CT_975X:␊ |
610 | ␉␉case CT_P35:␊ |
611 | ␉␉case CT_X48:␊ |
612 | ␉␉case CT_B43:␊ |
613 | ␉␉case CT_Q45:␊ |
614 | ␉␉case CT_P45:␊ |
615 | ␉␉case CT_GM45:␊ |
616 | ␉␉case CT_G41:␊ |
617 | ␉␉case CT_G31:␊ |
618 | ␉␉case CT_500:␊ |
619 | ␉␉case CT_3150:␊ |
620 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000090);␊ |
621 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 1, map->b1);␊ |
622 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, map->b2);␊ |
623 | ␉␉␉break;␊ |
624 | ␉␉case CT_CORE_PROC:␊ |
625 | ␉␉case CT_UNKNOWN_INTEL:␊ |
626 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000080);␊ |
627 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 1, map->b1);␊ |
628 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, map->b2);␊ |
629 | ␉␉default:␊ |
630 | ␉␉␉break;␊ |
631 | ␉}␊ |
632 | ␉␊ |
633 | #if DEBUG␊ |
634 | ␉{␊ |
635 | UInt32 t = inl(CONFIG_MECH_ONE_DATA);␊ |
636 | ␉␉verbose("relock PAM: (0x%08x)\n", t);␊ |
637 | ␉}␊ |
638 | #endif␊ |
639 | }␊ |
640 | ␊ |
641 | ␊ |
642 | int getMode(edid_mode *mode)␊ |
643 | {␊ |
644 | ␉char* edidInfo = readEDID();␊ |
645 | ␉␉␉␊ |
646 | ␉if(!edidInfo) return 1;␊ |
647 | //Slice␊ |
648 | ␉if(!fb_parse_edid((struct EDID *)edidInfo, mode) || !mode->h_active) ␊ |
649 | ␉{␊ |
650 | ␉␉free( edidInfo );␊ |
651 | ␉␉return 1;␊ |
652 | ␉}␊ |
653 | /*␉mode->pixel_clock = (edidInfo[55] << 8) | edidInfo[54];␊ |
654 | ␉mode->h_active = edidInfo[56] | ((edidInfo[58] & 0xF0) << 4);␊ |
655 | ␉mode->h_blanking = ((edidInfo[58] & 0x0F) << 8) | edidInfo[57];␊ |
656 | ␉mode->v_active = edidInfo[59] | ((edidInfo[61] & 0xF0) << 4);␊ |
657 | ␉mode->v_blanking = ((edidInfo[61] & 0x0F) << 8) | edidInfo[60];␊ |
658 | ␉mode->h_sync_offset = ((edidInfo[65] & 0xC0) >> 2) | edidInfo[62];␊ |
659 | ␉mode->h_sync_width = (edidInfo[65] & 0x30) | edidInfo[63];␊ |
660 | ␉mode->v_sync_offset = (edidInfo[65] & 0x0C) | ((edidInfo[64] & 0x0C) >> 2);␊ |
661 | ␉mode->v_sync_width = ((edidInfo[65] & 0x3) << 2) | (edidInfo[64] & 0x03);␊ |
662 | */␉␉␊ |
663 | ␊ |
664 | ␉free( edidInfo );␊ |
665 | ␉␉␊ |
666 | ␉return 0;␊ |
667 | ␉␉␊ |
668 | }␊ |
669 | ␊ |
670 | ␊ |
671 | static void gtf_timings(UInt32 x, UInt32 y, UInt32 freq,␊ |
672 | ␉␉␉␉␉␉unsigned long *clock,␊ |
673 | ␉␉␉␉␉␉UInt16 *hsyncstart, UInt16 *hsyncend, UInt16 *hblank,␊ |
674 | ␉␉␉␉␉␉UInt16 *vsyncstart, UInt16 *vsyncend, UInt16 *vblank)␊ |
675 | {␊ |
676 | ␉UInt32 hbl, vbl, vfreq;␊ |
677 | ␉␊ |
678 | ␉vbl = y + (y+1)/(20000.0/(11*freq) - 1) + 1.5;␊ |
679 | ␉vfreq = vbl * freq;␊ |
680 | ␉hbl = 16 * (int)(x * (30.0 - 300000.0 / vfreq) /␊ |
681 | ␉␉␉␉␉ + (70.0 + 300000.0 / vfreq) / 16.0 + 0.5);␊ |
682 | ␊ |
683 | ␉*vsyncstart = y;␊ |
684 | ␉*vsyncend = y + 3;␊ |
685 | ␉*vblank = vbl - 1;␊ |
686 | ␉*hsyncstart = x + hbl / 2 - (x + hbl + 50) / 100 * 8 - 1;␊ |
687 | ␉*hsyncend = x + hbl / 2 - 1;␊ |
688 | ␉*hblank = x + hbl - 1;␊ |
689 | ␉*clock = (x + hbl) * vfreq / 1000;␊ |
690 | }␊ |
691 | ␊ |
692 | void set_mode(vbios_map * map, /*UInt32 mode,*/ UInt32 x, UInt32 y, UInt32 bp, UInt32 htotal, UInt32 vtotal) {␊ |
693 | ␉UInt32 xprev, yprev;␊ |
694 | ␉UInt32 i = 0, j;␊ |
695 | ␉// patch first available mode␊ |
696 | ␉␊ |
697 | ␉//␉for (i=0; i < map->mode_table_size; i++) {␊ |
698 | ␉//␉␉if (map->mode_table[0].mode == mode) {␊ |
699 | ␉verbose(" Patching: ");␊ |
700 | ␉switch(map->bios) {␊ |
701 | ␉␉case BT_INTEL:␊ |
702 | ␉␉␉verbose("BT_INTEL - not supported\n");␊ |
703 | ␉␉␉return;␊ |
704 | ␊ |
705 | ␉␉case BT_1:␊ |
706 | ␉␉{␊ |
707 | ␉␉␉verbose("BT_1 patched.\n");␊ |
708 | ␉␉␉vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);␊ |
709 | ␉␉␉␊ |
710 | ␉␉␉if (bp)␊ |
711 | ␉␉␉{␊ |
712 | ␉␉␉␉map->mode_table[i].bits_per_pixel = (uint8_t)bp;␊ |
713 | ␉␉␉}␊ |
714 | ␉␉␉␊ |
715 | ␉␉␉res->x2 = (htotal?(((htotal-x) >> 8) & 0x0f) : (res->x2 & 0x0f)) | ((x >> 4) & 0xf0);␊ |
716 | ␉␉␉res->x1 = (x & 0xff);␊ |
717 | ␉␉␉␊ |
718 | ␉␉␉res->y2 = (vtotal?(((vtotal-y) >> 8) & 0x0f) : (res->y2 & 0x0f)) | ((y >> 4) & 0xf0);␊ |
719 | ␉␉␉res->y1 = (y & 0xff);␊ |
720 | ␉␉␉if (htotal)␊ |
721 | ␉␉␉{␊ |
722 | ␉␉␉␉res->x_total = ((htotal-x) & 0xff);␊ |
723 | ␉␉␉}␊ |
724 | ␉␉␉if (vtotal)␊ |
725 | ␉␉␉{␊ |
726 | ␉␉␉␉res->y_total = ((vtotal-y) & 0xff);␊ |
727 | ␉␉␉}␊ |
728 | ␉␉␉break;␊ |
729 | ␉␉}␊ |
730 | ␉␉case BT_2:␊ |
731 | ␉␉{␊ |
732 | ␉␉␉vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);␊ |
733 | ␉␉␉␊ |
734 | ␉␉␉res->xchars = (uint8_t)(x / 8);␊ |
735 | ␉␉␉res->ychars = (uint8_t)(y / 16 - 1);␊ |
736 | ␉␉␉xprev = res->modelines[0].x1;␊ |
737 | ␉␉␉yprev = res->modelines[0].y1;␊ |
738 | ␉␉␉␊ |
739 | ␉␉␉for(j=0; j < 3; j++) {␊ |
740 | ␉␉␉␉vbios_modeline_type2 * modeline = &res->modelines[j];␊ |
741 | ␉␉␉␉␊ |
742 | ␉␉␉␉if (modeline->x1 == xprev && modeline->y1 == yprev) {␊ |
743 | ␉␉␉␉␉modeline->x1 = modeline->x2 = (uint16_t)(x-1);␊ |
744 | ␉␉␉␉␉modeline->y1 = modeline->y2 = (uint16_t)(y-1);␊ |
745 | ␉␉␉␉␉␊ |
746 | ␉␉␉␉␉gtf_timings(x, y, freqs[j], &modeline->clock,␊ |
747 | ␉␉␉␉␉␉␉␉&modeline->hsyncstart, &modeline->hsyncend,␊ |
748 | ␉␉␉␉␉␉␉␉&modeline->hblank, &modeline->vsyncstart,␊ |
749 | ␉␉␉␉␉␉␉␉&modeline->vsyncend, &modeline->vblank);␊ |
750 | ␉␉␉␉␉␊ |
751 | ␉␉␉␉␉if (htotal)␊ |
752 | ␉␉␉␉␉{␊ |
753 | ␉␉␉␉␉␉modeline->htotal = (uint16_t)htotal;␊ |
754 | ␉␉␉␉␉}␊ |
755 | ␉␉␉␉␉else␊ |
756 | ␉␉␉␉␉{␊ |
757 | ␉␉␉␉␉␉modeline->htotal = modeline->hblank;␊ |
758 | ␉␉␉␉␉}␊ |
759 | ␉␉␉␉␉if (vtotal)␊ |
760 | ␉␉␉␉␉{␊ |
761 | ␉␉␉␉␉␉modeline->vtotal = (uint16_t)vtotal;␊ |
762 | ␉␉␉␉␉}␊ |
763 | ␉␉␉␉␉else␊ |
764 | ␉␉␉␉␉{␊ |
765 | ␉␉␉␉␉␉modeline->vtotal = modeline->vblank;␊ |
766 | ␉␉␉␉␉}␊ |
767 | ␉␉␉␉}␊ |
768 | ␉␉␉}␊ |
769 | ␉␉␉verbose("BT_1 patched.\n");␊ |
770 | ␉␉␉break;␊ |
771 | ␉␉}␊ |
772 | ␉␉case BT_3:␊ |
773 | ␉␉{␊ |
774 | ␉␉␉vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution);␊ |
775 | ␉␉␉␊ |
776 | ␉␉␉xprev = res->modelines[0].x1;␊ |
777 | ␉␉␉yprev = res->modelines[0].y1;␊ |
778 | ␉␉␉␊ |
779 | ␉␉␉for (j=0; j < 3; j++) {␊ |
780 | ␉␉␉␉vbios_modeline_type3 * modeline = &res->modelines[j];␊ |
781 | ␉␉␉␉␊ |
782 | ␉␉␉␉if (modeline->x1 == xprev && modeline->y1 == yprev) {␊ |
783 | ␉␉␉␉␉modeline->x1 = modeline->x2 = (uint16_t)(x-1);␊ |
784 | ␉␉␉␉␉modeline->y1 = modeline->y2 = (uint16_t)(y-1);␊ |
785 | ␉␉␉␉␉␊ |
786 | ␉␉␉␉␉gtf_timings(x, y, freqs[j], &modeline->clock,␊ |
787 | ␉␉␉␉␉␉␉␉&modeline->hsyncstart, &modeline->hsyncend,␊ |
788 | ␉␉␉␉␉␉␉␉&modeline->hblank, &modeline->vsyncstart,␊ |
789 | ␉␉␉␉␉␉␉␉&modeline->vsyncend, &modeline->vblank);␊ |
790 | ␉␉␉␉␉if (htotal)␊ |
791 | ␉␉␉␉␉{␊ |
792 | ␉␉␉␉␉␉modeline->htotal = (uint16_t)htotal;␊ |
793 | ␉␉␉␉␉}␊ |
794 | ␉␉␉␉␉else␊ |
795 | ␉␉␉␉␉{␊ |
796 | ␉␉␉␉␉␉modeline->htotal = modeline->hblank;␊ |
797 | ␉␉␉␉␉}␊ |
798 | ␉␉␉␉␉if (vtotal)␊ |
799 | ␉␉␉␉␉{␊ |
800 | ␉␉␉␉␉␉modeline->vtotal = (uint16_t)vtotal;␊ |
801 | ␉␉␉␉␉}␊ |
802 | ␉␉␉␉␉else␊ |
803 | ␉␉␉␉␉{␊ |
804 | ␉␉␉␉␉␉modeline->vtotal = modeline->vblank;␊ |
805 | ␉␉␉␉␉}␊ |
806 | ␉␉␉␉␉modeline->timing_h = (uint16_t)(y-1);␊ |
807 | ␉␉␉␉␉modeline->timing_v = (uint16_t)(x-1);␊ |
808 | ␉␉␉␉}␊ |
809 | ␉␉␉}␊ |
810 | ␉␉␉verbose("BT_3 patched.\n");␊ |
811 | ␉␉␉break;␊ |
812 | ␉␉}␊ |
813 | ␉␉case BT_ATI_1:␊ |
814 | ␉␉{␊ |
815 | ␉␉␉verbose("BT_ATI_1");␊ |
816 | ␉␉␉edid_mode mode;␊ |
817 | ␉␉␉␉␊ |
818 | ␉␉␉ATOM_MODE_TIMING *mode_timing = (ATOM_MODE_TIMING *) map->ati_mode_table;␊ |
819 | ␊ |
820 | ␉␉␉//if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force){␊ |
821 | ␉␉␉if (!getMode(&mode))␊ |
822 | ␉␉␉{␊ |
823 | ␉␉␉␉verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode 0 patched!\n", mode.h_active, mode.v_active);␊ |
824 | ␉␉␉␉mode_timing->usCRTC_H_Total = mode.h_active + mode.h_blanking;␊ |
825 | ␉␉␉␉mode_timing->usCRTC_H_Disp = mode.h_active;␊ |
826 | ␉␉␉␉mode_timing->usCRTC_H_SyncStart = mode.h_active + mode.h_sync_offset;␊ |
827 | ␉␉␉␉mode_timing->usCRTC_H_SyncWidth = mode.h_sync_width;␊ |
828 | ␉␉␉␉␉␊ |
829 | ␉␉␉␉mode_timing->usCRTC_V_Total = mode.v_active + mode.v_blanking;␊ |
830 | ␉␉␉␉mode_timing->usCRTC_V_Disp = mode.v_active;␊ |
831 | ␉␉␉␉mode_timing->usCRTC_V_SyncStart = mode.v_active + mode.v_sync_offset;␊ |
832 | ␉␉␉␉mode_timing->usCRTC_V_SyncWidth = mode.v_sync_width;␊ |
833 | ␊ |
834 | ␉␉␉␉mode_timing->usPixelClock = mode.pixel_clock;␊ |
835 | ␉␉␉}␊ |
836 | ␉␉␉else␊ |
837 | ␉␉␉{␊ |
838 | ␉␉␉␉verbose(" Edid not found or invalid - vbios not patched!\n");␊ |
839 | ␉␉␉}␊ |
840 | ␉␉␉/*else␊ |
841 | ␉␉␉{␊ |
842 | ␉␉␉␉vbios_modeline_type2 modeline;␊ |
843 | ␊ |
844 | ␉␉␉␉cvt_timings(x, y, freqs[0], &modeline.clock,␊ |
845 | ␉␉␉␉␉␉␉&modeline.hsyncstart, &modeline.hsyncend,␊ |
846 | ␉␉␉␉␉␉␉&modeline.hblank, &modeline.vsyncstart,␊ |
847 | ␉␉␉␉␉␉␉&modeline.vsyncend, &modeline.vblank, 0);␊ |
848 | ␊ |
849 | ␉␉␉␉mode_timing->usCRTC_H_Total = x + modeline.hblank;␊ |
850 | ␉␉␉␉mode_timing->usCRTC_H_Disp = x;␊ |
851 | ␉␉␉␉mode_timing->usCRTC_H_SyncStart = modeline.hsyncstart;␊ |
852 | ␉␉␉␉mode_timing->usCRTC_H_SyncWidth = modeline.hsyncend - modeline.hsyncstart;␊ |
853 | ␊ |
854 | ␉␉␉␉mode_timing->usCRTC_V_Total = y + modeline.vblank;␊ |
855 | ␉␉␉␉mode_timing->usCRTC_V_Disp = y;␊ |
856 | ␉␉␉␉mode_timing->usCRTC_V_SyncStart = modeline.vsyncstart;␊ |
857 | ␉␉␉␉mode_timing->usCRTC_V_SyncWidth = modeline.vsyncend - modeline.vsyncstart;␊ |
858 | ␉␉␉␉␉␉␉␉␉␉␉␉␊ |
859 | ␉␉␉␉mode_timing->usPixelClock = modeline.clock;␊ |
860 | ␉␉␉ }*/␊ |
861 | ␊ |
862 | ␉␉␉break;␊ |
863 | ␉␉}␊ |
864 | ␉␉case BT_ATI_2:␊ |
865 | ␉␉{␊ |
866 | ␉␉␉verbose("BT_ATI_2");␊ |
867 | ␉␉␉edid_mode mode;␊ |
868 | ␉␉␉␉␉␉␊ |
869 | ␉␉␉ATOM_DTD_FORMAT *mode_timing = (ATOM_DTD_FORMAT *) map->ati_mode_table;␊ |
870 | ␉␉␉␊ |
871 | ␉␉␉/*if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force) {*/␊ |
872 | ␉␉␉if (!getMode(&mode)) {␊ |
873 | ␉␉␉␉verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode 0 patched!\n", mode.h_active, mode.v_active);␊ |
874 | ␉␉␉␉mode_timing->usHBlanking_Time = mode.h_blanking;␊ |
875 | ␉␉␉␉mode_timing->usHActive = mode.h_active;␊ |
876 | ␉␉␉␉mode_timing->usHSyncOffset = mode.h_sync_offset;␊ |
877 | ␉␉␉␉mode_timing->usHSyncWidth = mode.h_sync_width;␊ |
878 | ␉␉␉␉␉␉␉␉␉␉␊ |
879 | ␉␉␉␉mode_timing->usVBlanking_Time = mode.v_blanking;␊ |
880 | ␉␉␉␉mode_timing->usVActive = mode.v_active;␊ |
881 | ␉␉␉␉mode_timing->usVSyncOffset = mode.v_sync_offset;␊ |
882 | ␉␉␉␉mode_timing->usVSyncWidth = mode.v_sync_width;␊ |
883 | ␉␉␉␉␉␉␉␉␉␉␊ |
884 | ␉␉␉␉mode_timing->usPixClk = mode.pixel_clock;␊ |
885 | ␉␉␉}␊ |
886 | ␉␉␉else␊ |
887 | ␉␉␉{␊ |
888 | ␉␉␉␉verbose(" Edid not found or invalid - vbios not patched!\n");␊ |
889 | ␉␉␉}␊ |
890 | ␉␉␉/*else␊ |
891 | ␉␉␉{␊ |
892 | ␉␉␉␉vbios_modeline_type2 modeline;␊ |
893 | ␉␉␉␊ |
894 | ␉␉␉␉cvt_timings(x, y, freqs[0], &modeline.clock,␊ |
895 | ␉␉␉␉␉␉␉&modeline.hsyncstart, &modeline.hsyncend,␊ |
896 | ␉␉␉␉␉␉␉&modeline.hblank, &modeline.vsyncstart,␊ |
897 | ␉␉␉␉␉␉␉&modeline.vsyncend, &modeline.vblank, 0);␊ |
898 | ␉␉␉␉␉␉␉␉␉␉␉␊ |
899 | ␉␉␉␉mode_timing->usHBlanking_Time = modeline.hblank;␊ |
900 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usHActive = x;␊ |
901 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usHSyncOffset = modeline.hsyncstart - x;␊ |
902 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usHSyncWidth = modeline.hsyncend - modeline.hsyncstart;␊ |
903 | ␉␉␉␉␉␉␉␉␉␉␉␊ |
904 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usVBlanking_Time = modeline.vblank;␊ |
905 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usVActive = y;␊ |
906 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usVSyncOffset = modeline.vsyncstart - y;␊ |
907 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usVSyncWidth = modeline.hsyncend - modeline.hsyncstart;␊ |
908 | ␉␉␉␉␉␉␉␉␉␉␉␊ |
909 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usPixClk = modeline.clock;␊ |
910 | ␉␉␉␉␉␉␉␉␉␉}*/␊ |
911 | ␊ |
912 | ␉␉␉break;␊ |
913 | ␉␉}␊ |
914 | ␉␉case BT_NVDA:␊ |
915 | ␉␉{␊ |
916 | ␉␉␉verbose("BT_NVDA");␊ |
917 | ␉␉␉edid_mode mode;␊ |
918 | ␉␉␉NV_MODELINE *mode_timing = (NV_MODELINE *) map->nv_mode_table;␊ |
919 | ␉␉␉␊ |
920 | ␉␉␉/*if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force) {*/␊ |
921 | ␉␉␉if (!getMode(&mode))␊ |
922 | ␉␉␉{␊ |
923 | ␉␉␉␉verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode %d patched!\n", mode.h_active, mode.v_active, i);␊ |
924 | ␉␉␉␉mode_timing[i].usH_Total = mode.h_active + mode.h_blanking;␊ |
925 | ␉␉␉␉mode_timing[i].usH_Active = mode.h_active;␊ |
926 | ␉␉␉␉mode_timing[i].usH_SyncStart = mode.h_active + mode.h_sync_offset;␊ |
927 | ␉␉␉␉mode_timing[i].usH_SyncEnd = mode.h_active + mode.h_sync_offset + mode.h_sync_width;␊ |
928 | ␉␉␉␉␊ |
929 | ␉␉␉␉mode_timing[i].usV_Total = mode.v_active + mode.v_blanking;␊ |
930 | ␉␉␉␉mode_timing[i].usV_Active = mode.v_active;␊ |
931 | ␉␉␉␉mode_timing[i].usV_SyncStart = mode.v_active + mode.v_sync_offset;␊ |
932 | ␉␉␉␉mode_timing[i].usV_SyncEnd = mode.v_active + mode.v_sync_offset + mode.v_sync_width;␊ |
933 | ␉␉␉␉␊ |
934 | ␉␉␉␉mode_timing[i].usPixel_Clock = mode.pixel_clock;␊ |
935 | ␉␉␉}␊ |
936 | ␉␉␉ else␊ |
937 | ␉␉␉{␊ |
938 | ␉␉␉␉verbose(" Edid not found or invalid - vbios not patched!\n");␊ |
939 | ␉␉␉}␊ |
940 | ␉␉␉/*else␊ |
941 | ␉␉␉ {␊ |
942 | ␉␉␉ vbios_modeline_type2 modeline;␊ |
943 | ␉␉␉ cvt_timings(x, y, freqs[0], &modeline.clock,␊ |
944 | ␉␉␉ &modeline.hsyncstart, &modeline.hsyncend,␊ |
945 | ␉␉␉ &modeline.hblank, &modeline.vsyncstart,␊ |
946 | ␉␉␉ &modeline.vsyncend, &modeline.vblank, 0);␊ |
947 | ␊ |
948 | ␉␉␉ mode_timing[i].usH_Total = x + modeline.hblank - 1;␊ |
949 | ␉␉␉ mode_timing[i].usH_Active = x;␊ |
950 | ␉␉␉ mode_timing[i].usH_SyncStart = modeline.hsyncstart - 1;␊ |
951 | ␉␉␉ mode_timing[i].usH_SyncEnd = modeline.hsyncend - 1;␊ |
952 | ␊ |
953 | ␉␉␉ mode_timing[i].usV_Total = y + modeline.vblank - 1;␊ |
954 | ␉␉␉ mode_timing[i].usV_Active = y;␊ |
955 | ␉␉␉ mode_timing[i].usV_SyncStart = modeline.vsyncstart - 1;␊ |
956 | ␉␉␉ mode_timing[i].usV_SyncEnd = modeline.vsyncend - 1;␊ |
957 | ␊ |
958 | ␉␉␉ mode_timing[i].usPixel_Clock = modeline.clock;␊ |
959 | ␉␉␉ }*/␊ |
960 | ␉␉␉break;␊ |
961 | ␉␉}␊ |
962 | ␉␉case BT_UNKNOWN:␊ |
963 | ␉␉{␊ |
964 | ␉␉␉verbose(" Unknown - vbios not patched\n");␊ |
965 | ␉␉␉break;␊ |
966 | ␉␉}␊ |
967 | ␉␉default:␊ |
968 | ␉␉␉break;␊ |
969 | ␉}␊ |
970 | ␉//␉␉}␊ |
971 | ␉//␉}␊ |
972 | }␊ |
973 | ␊ |
974 | #endif // _RESOLUTION_H_␊ |
975 | |