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 | ␉} else {␊ |
305 | ␉␉verbose(" Detected chipset/proc id (DRAM controller): %08x\n", map->chipset_id);␊ |
306 | ␉}␊ |
307 | ␉␊ |
308 | ␉␊ |
309 | ␉verbose(" VBios: ");␊ |
310 | ␉/*␊ |
311 | ␉ * Map the video bios to memory␊ |
312 | ␉ */␊ |
313 | ␉map->bios_ptr=(char*)VBIOS_START;␊ |
314 | ␉␊ |
315 | ␉/*␊ |
316 | ␉ * check if we have ATI Radeon␊ |
317 | ␉ */␊ |
318 | ␉map->ati_tables.base = map->bios_ptr;␊ |
319 | ␉map->ati_tables.AtomRomHeader = (ATOM_ROM_HEADER *) (map->bios_ptr + *(unsigned short *) (map->bios_ptr + OFFSET_TO_POINTER_TO_ATOM_ROM_HEADER)); ␊ |
320 | ␉if (strcmp ((char *) map->ati_tables.AtomRomHeader->uaFirmWareSignature, "ATOM") == 0)␊ |
321 | ␉{␊ |
322 | ␉␉verbose("ATI");␊ |
323 | ␉␉// ATI Radeon Card␊ |
324 | ␉␉map->bios = BT_ATI_1;␊ |
325 | ␉␉␊ |
326 | ␉␉map->ati_tables.MasterDataTables = (unsigned short *) &((ATOM_MASTER_DATA_TABLE *) (map->bios_ptr + map->ati_tables.AtomRomHeader->usMasterDataTableOffset))->ListOfDataTables;␊ |
327 | ␉␉unsigned short std_vesa_offset = (unsigned short) ((ATOM_MASTER_LIST_OF_DATA_TABLES *)map->ati_tables.MasterDataTables)->StandardVESA_Timing;␊ |
328 | ␉␉ATOM_STANDARD_VESA_TIMING * std_vesa = (ATOM_STANDARD_VESA_TIMING *) (map->bios_ptr + std_vesa_offset);␊ |
329 | ␉␉␊ |
330 | ␉␉map->ati_mode_table = (char *) &std_vesa->aModeTimings;␊ |
331 | ␉␉if (map->ati_mode_table == 0)␊ |
332 | ␉␉{␊ |
333 | ␉␉␉printf("Unable to locate the mode table.\n");␊ |
334 | ␉␉␉printf("Please run the program 'dump_bios' as root and\n");␊ |
335 | ␉␉␉printf("email the file 'vbios.dmp' to stomljen@yahoo.com.\n");␊ |
336 | ␉␉␉printf("Chipset: %d\n", map->chipset);␊ |
337 | ␉␉␉close_vbios(map);␊ |
338 | ␉␉␉return 0;␊ |
339 | ␉␉}␊ |
340 | ␉␉map->mode_table_size = std_vesa->sHeader.usStructureSize - sizeof(ATOM_COMMON_TABLE_HEADER);␊ |
341 | ␉␉␊ |
342 | ␉␉if (!detect_ati_bios_type(map))␊ |
343 | ␉␉{␊ |
344 | ␉␉␉map->bios = BT_ATI_2;␊ |
345 | ␉␉}␊ |
346 | ␊ |
347 | ␉␉if (map->bios == BT_ATI_1)␊ |
348 | ␉␉{␊ |
349 | ␉␉␉verbose(", BT_ATI_1\n");␊ |
350 | ␉␉} else {␊ |
351 | ␉␉␉verbose(", BT_ATI_2\n");␊ |
352 | ␉␉}␊ |
353 | ␉} else {␊ |
354 | ␉␉␊ |
355 | ␉␉/*␊ |
356 | ␉␉ * check if we have NVIDIA␊ |
357 | ␉␉ */␊ |
358 | ␊ |
359 | ␉␉int i = 0;␊ |
360 | ␉␉while (i < 512)␊ |
361 | ␉␉{ // we don't need to look through the whole bios, just the first 512 bytes␊ |
362 | ␉␉␉if ((␉map->bios_ptr[i] == 'N') ␊ |
363 | ␉␉␉␉&& (map->bios_ptr[i+1] == 'V') ␊ |
364 | ␉␉␉␉&& (map->bios_ptr[i+2] == 'I') ␊ |
365 | ␉␉␉␉&& (map->bios_ptr[i+3] == 'D')) ␊ |
366 | ␉␉␉{␊ |
367 | ␉␉␉␉verbose("nVidia\n");␊ |
368 | ␉␉␉␉map->bios = BT_NVDA;␊ |
369 | ␉␉␉␉unsigned short nv_data_table_offset = 0;␊ |
370 | ␉␉␉␉unsigned short * nv_data_table;␊ |
371 | ␉␉␉␉NV_VESA_TABLE * std_vesa;␊ |
372 | ␉␉␉␉␊ |
373 | ␉␉␉␉int i = 0;␊ |
374 | ␊ |
375 | ␉␉␉␉while (i < 0x300)␊ |
376 | ␉␉␉␉{ //We don't need to look for the table in the whole bios, the 768 first bytes only␊ |
377 | ␉␉␉␉␉if ((␉map->bios_ptr[i] == 0x44) ␊ |
378 | ␉␉␉␉␉␉&& (map->bios_ptr[i+1] == 0x01) ␊ |
379 | ␉␉␉␉␉␉&& (map->bios_ptr[i+2] == 0x04) ␊ |
380 | ␉␉␉␉␉␉&& (map->bios_ptr[i+3] == 0x00))␊ |
381 | ␉␉␉␉␉{␊ |
382 | ␉␉␉␉␉␉nv_data_table_offset = (unsigned short) (map->bios_ptr[i+4] | (map->bios_ptr[i+5] << 8));␊ |
383 | ␉␉␉␉␉␉break;␊ |
384 | ␉␉␉␉␉}␊ |
385 | ␉␉␉␉␉i++;␊ |
386 | ␉␉␉␉}␊ |
387 | ␉␉␉␉␊ |
388 | ␉␉␉␉nv_data_table = (unsigned short *) (map->bios_ptr + (nv_data_table_offset + OFFSET_TO_VESA_TABLE_INDEX));␊ |
389 | ␉␉␉␉std_vesa = (NV_VESA_TABLE *) (map->bios_ptr + *nv_data_table);␊ |
390 | ␉␉␉␉␊ |
391 | ␉␉␉␉map->nv_mode_table = (char *) std_vesa->sModelines;␊ |
392 | ␉␉␉␉if (map->nv_mode_table == 0)␊ |
393 | ␉␉␉␉{␊ |
394 | ␉␉␉␉␉printf("Unable to locate the mode table.\n");␊ |
395 | ␉␉␉␉␉printf("Please run the program 'dump_bios' as root and\n");␊ |
396 | ␉␉␉␉␉printf("email the file 'vbios.dmp' to stomljen@yahoo.com.\n");␊ |
397 | ␉␉␉␉␉printf("Chipset: %s\n", map->chipset);␊ |
398 | ␉␉␉␉␉close_vbios(map);␊ |
399 | ␉␉␉␉␉return 0;␊ |
400 | ␉␉␉␉}␊ |
401 | ␉␉␉␉map->mode_table_size = std_vesa->sHeader.usTable_Size;␊ |
402 | ␉␉␉␉␊ |
403 | ␉␉␉␉break;␊ |
404 | ␉␉␉}␊ |
405 | ␉␉␉i++;␊ |
406 | ␉␉}␊ |
407 | ␉}␊ |
408 | ␉␊ |
409 | ␊ |
410 | ␉/*␊ |
411 | ␉ * check if we have Intel␊ |
412 | ␉ */␊ |
413 | ␊ |
414 | ␉/*if (map->chipset == CT_UNKNOWN && memmem(map->bios_ptr, VBIOS_SIZE, INTEL_SIGNATURE, strlen(INTEL_SIGNATURE))) {␊ |
415 | ␉ printf( "Intel chipset detected. However, 915resolution was unable to determine the chipset type.\n");␊ |
416 | ␊ |
417 | ␉ printf("Chipset Id: %x\n", map->chipset_id);␊ |
418 | ␊ |
419 | ␉ printf("Please report this problem to stomljen@yahoo.com\n");␊ |
420 | ␊ |
421 | ␉ close_vbios(map);␊ |
422 | ␉ return 0;␊ |
423 | ␉ }*/␊ |
424 | ␊ |
425 | ␉/*␊ |
426 | ␉ * check for others␊ |
427 | ␉ */␊ |
428 | ␉␊ |
429 | ␉/*␊ |
430 | ␉ * Figure out where the mode table is ␊ |
431 | ␉ */␊ |
432 | ␉if ((map->bios != BT_ATI_1) && (map->bios != BT_ATI_2) && (map->bios != BT_NVDA)) ␊ |
433 | ␉{␊ |
434 | ␉␉char* p = map->bios_ptr + 16;␊ |
435 | ␉␉char* limit = map->bios_ptr + VBIOS_SIZE - (3 * sizeof(vbios_mode));␊ |
436 | ␉␉␊ |
437 | ␉␉verbose("Other");␊ |
438 | ␉␉while (p < limit && map->mode_table == 0)␊ |
439 | ␉␉{␊ |
440 | ␉␉␉vbios_mode * mode_ptr = (vbios_mode *) p;␊ |
441 | ␉␉␉␊ |
442 | ␉␉␉if (((mode_ptr[0].mode & 0xf0) == 0x30) && ((mode_ptr[1].mode & 0xf0) == 0x30) &&␊ |
443 | ␉␉␉␉((mode_ptr[2].mode & 0xf0) == 0x30) && ((mode_ptr[3].mode & 0xf0) == 0x30))␊ |
444 | ␉␉␉{␊ |
445 | ␉␉␉␉map->mode_table = mode_ptr;␊ |
446 | ␉␉␉}␊ |
447 | ␉␉␉␊ |
448 | ␉␉␉p++;␊ |
449 | ␉␉}␊ |
450 | ␊ |
451 | ␉␉if (map->mode_table == 0)␊ |
452 | ␉␉{␊ |
453 | ␉␉␉close_vbios(map);␊ |
454 | ␉␉␉return 0;␊ |
455 | ␉␉}␊ |
456 | ␉}␊ |
457 | ␉␊ |
458 | ␉␊ |
459 | ␉/*␊ |
460 | ␉ * Determine size of mode table␊ |
461 | ␉ */␊ |
462 | ␉if ((map->bios != BT_ATI_1) && (map->bios != BT_ATI_2) && (map->bios != BT_NVDA))␊ |
463 | ␉{␊ |
464 | ␉␉vbios_mode * mode_ptr = map->mode_table;␊ |
465 | ␉␉␊ |
466 | ␉␉while (mode_ptr->mode != 0xff)␊ |
467 | ␉␉{␊ |
468 | ␉␉␉map->mode_table_size++;␊ |
469 | ␉␉␉mode_ptr++;␊ |
470 | ␉␉}␊ |
471 | ␉}␊ |
472 | ␉␊ |
473 | ␉/*␊ |
474 | ␉ * Figure out what type of bios we have␊ |
475 | ␉ * order of detection is important␊ |
476 | ␉ */␊ |
477 | ␉if ((map->bios != BT_ATI_1) && (map->bios != BT_ATI_2) && (map->bios != BT_NVDA))␊ |
478 | ␉{␊ |
479 | ␉␉if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type3)))␊ |
480 | ␉␉{␊ |
481 | ␉␉␉map->bios = BT_3;␊ |
482 | ␉␉␉verbose(", BT_3\n");␊ |
483 | ␉␉}␊ |
484 | ␉␉else if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type2)))␊ |
485 | ␉␉{␊ |
486 | ␉␉␉map->bios = BT_2;␊ |
487 | ␉␉␉verbose(", BT_2\n");␊ |
488 | ␉␉}␊ |
489 | ␉␉else if (detect_bios_type(map, FALSE, sizeof(vbios_resolution_type1)))␊ |
490 | ␉␉{␊ |
491 | ␉␉␉map->bios = BT_1;␊ |
492 | ␉␉␉verbose(", BT_1\n");␊ |
493 | ␉␉}␊ |
494 | ␉␉else {␊ |
495 | ␉␉␉verbose(" - unknown\n");␊ |
496 | ␉␉␉return 0;␊ |
497 | ␉␉}␊ |
498 | ␉}␊ |
499 | ␉␊ |
500 | ␉return map;␊ |
501 | }␊ |
502 | ␊ |
503 | void close_vbios(vbios_map * map)␊ |
504 | {␊ |
505 | ␉free(map);␊ |
506 | }␊ |
507 | ␊ |
508 | void unlock_vbios(vbios_map * map)␊ |
509 | {␊ |
510 | ␊ |
511 | ␉map->unlocked = TRUE;␊ |
512 | ␊ |
513 | ␉switch (map->chipset) {␊ |
514 | ␉␉case CT_UNKNOWN:␊ |
515 | ␉␉␉break;␊ |
516 | ␉␉case CT_830:␊ |
517 | ␉␉case CT_855GM:␊ |
518 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x8000005a);␊ |
519 | ␉␉␉map->b1 = inb(CONFIG_MECH_ONE_DATA + 2);␊ |
520 | ␉␉␉␊ |
521 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x8000005a);␊ |
522 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, 0x33);␊ |
523 | ␉␉␉break;␊ |
524 | ␉␉case CT_845G:␊ |
525 | ␉␉case CT_865G:␊ |
526 | ␉␉case CT_915G:␊ |
527 | ␉␉case CT_915GM:␊ |
528 | ␉␉case CT_945G:␊ |
529 | ␉␉case CT_945GM:␊ |
530 | ␉␉case CT_945GME:␊ |
531 | ␉␉case CT_946GZ:␊ |
532 | ␉␉case CT_G965:␊ |
533 | ␉␉case CT_Q965:␊ |
534 | ␉␉case CT_965GM:␊ |
535 | ␉␉case CT_975X:␊ |
536 | ␉␉case CT_P35:␊ |
537 | ␉␉case CT_955X:␊ |
538 | ␉␉case CT_X48:␊ |
539 | ␉␉case CT_B43:␊ |
540 | ␉␉case CT_Q45:␊ |
541 | ␉␉case CT_P45:␊ |
542 | ␉␉case CT_GM45:␊ |
543 | ␉␉case CT_G45:␊ |
544 | ␉␉case CT_G41:␊ |
545 | ␉␉case CT_G31:␊ |
546 | ␉␉case CT_500:␊ |
547 | ␉␉case CT_3150:␊ |
548 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000090);␊ |
549 | ␉␉␉map->b1 = inb(CONFIG_MECH_ONE_DATA + 1);␊ |
550 | ␉␉␉map->b2 = inb(CONFIG_MECH_ONE_DATA + 2);␊ |
551 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000090);␊ |
552 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 1, 0x33);␊ |
553 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, 0x33);␊ |
554 | ␉␉␉break;␊ |
555 | ␉␉case CT_CORE_PROC:␉ // Core procs - PAM regs are 80h - 86h␊ |
556 | ␉␉case CT_UNKNOWN_INTEL:␉// Assume newer intel chipset is the same as before␊ |
557 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000080);␊ |
558 | ␉␉␉map->b1 = inb(CONFIG_MECH_ONE_DATA + 1);␊ |
559 | ␉␉␉map->b2 = inb(CONFIG_MECH_ONE_DATA + 2);␊ |
560 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000080);␊ |
561 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 1, 0x33);␊ |
562 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, 0x33);␊ |
563 | ␉␉␉break;␊ |
564 | ␉␉default:␊ |
565 | ␉␉␉break;␊ |
566 | ␉}␊ |
567 | ␉␊ |
568 | #if DEBUG␊ |
569 | ␉{␊ |
570 | ␉␉UInt32 t = inl(CONFIG_MECH_ONE_DATA);␊ |
571 | ␉␉verbose("unlock PAM: (0x%08x)\n", t);␊ |
572 | ␉}␊ |
573 | #endif␊ |
574 | }␊ |
575 | ␊ |
576 | void relock_vbios(vbios_map * map)␊ |
577 | {␊ |
578 | ␉␊ |
579 | ␉map->unlocked = FALSE;␊ |
580 | ␉␊ |
581 | ␉switch (map->chipset)␊ |
582 | ␉{␊ |
583 | ␉␉case CT_UNKNOWN:␊ |
584 | ␉␉␉break;␊ |
585 | ␉␉case CT_830:␊ |
586 | ␉␉case CT_855GM:␊ |
587 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x8000005a);␊ |
588 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, map->b1);␊ |
589 | ␉␉␉break;␊ |
590 | ␉␉case CT_845G:␊ |
591 | ␉␉case CT_865G:␊ |
592 | ␉␉case CT_915G:␊ |
593 | ␉␉case CT_915GM:␊ |
594 | ␉␉case CT_945G:␊ |
595 | ␉␉case CT_945GM:␊ |
596 | ␉␉case CT_945GME:␊ |
597 | ␉␉case CT_946GZ:␊ |
598 | ␉␉case CT_G965:␊ |
599 | ␉␉case CT_955X:␊ |
600 | ␉␉case CT_G45:␊ |
601 | ␉␉case CT_Q965:␊ |
602 | ␉␉case CT_965GM:␊ |
603 | ␉␉case CT_975X:␊ |
604 | ␉␉case CT_P35:␊ |
605 | ␉␉case CT_X48:␊ |
606 | ␉␉case CT_B43:␊ |
607 | ␉␉case CT_Q45:␊ |
608 | ␉␉case CT_P45:␊ |
609 | ␉␉case CT_GM45:␊ |
610 | ␉␉case CT_G41:␊ |
611 | ␉␉case CT_G31:␊ |
612 | ␉␉case CT_500:␊ |
613 | ␉␉case CT_3150:␊ |
614 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000090);␊ |
615 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 1, map->b1);␊ |
616 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, map->b2);␊ |
617 | ␉␉␉break;␊ |
618 | ␉␉case CT_CORE_PROC:␊ |
619 | ␉␉case CT_UNKNOWN_INTEL:␊ |
620 | ␉␉␉outl(CONFIG_MECH_ONE_ADDR, 0x80000080);␊ |
621 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 1, map->b1);␊ |
622 | ␉␉␉outb(CONFIG_MECH_ONE_DATA + 2, map->b2);␊ |
623 | ␉␉default:␊ |
624 | ␉␉␉break;␊ |
625 | ␉}␊ |
626 | ␉␊ |
627 | #if DEBUG␊ |
628 | ␉{␊ |
629 | UInt32 t = inl(CONFIG_MECH_ONE_DATA);␊ |
630 | ␉␉verbose("relock PAM: (0x%08x)\n", t);␊ |
631 | ␉}␊ |
632 | #endif␊ |
633 | }␊ |
634 | ␊ |
635 | ␊ |
636 | int getMode(edid_mode *mode)␊ |
637 | {␊ |
638 | ␉char* edidInfo = readEDID();␊ |
639 | ␉␉␉␊ |
640 | ␉if(!edidInfo) return 1;␊ |
641 | //Slice␊ |
642 | ␉if(!fb_parse_edid((struct EDID *)edidInfo, mode) || !mode->h_active) ␊ |
643 | ␉{␊ |
644 | ␉␉free( edidInfo );␊ |
645 | ␉␉return 1;␊ |
646 | ␉}␊ |
647 | /*␉mode->pixel_clock = (edidInfo[55] << 8) | edidInfo[54];␊ |
648 | ␉mode->h_active = edidInfo[56] | ((edidInfo[58] & 0xF0) << 4);␊ |
649 | ␉mode->h_blanking = ((edidInfo[58] & 0x0F) << 8) | edidInfo[57];␊ |
650 | ␉mode->v_active = edidInfo[59] | ((edidInfo[61] & 0xF0) << 4);␊ |
651 | ␉mode->v_blanking = ((edidInfo[61] & 0x0F) << 8) | edidInfo[60];␊ |
652 | ␉mode->h_sync_offset = ((edidInfo[65] & 0xC0) >> 2) | edidInfo[62];␊ |
653 | ␉mode->h_sync_width = (edidInfo[65] & 0x30) | edidInfo[63];␊ |
654 | ␉mode->v_sync_offset = (edidInfo[65] & 0x0C) | ((edidInfo[64] & 0x0C) >> 2);␊ |
655 | ␉mode->v_sync_width = ((edidInfo[65] & 0x3) << 2) | (edidInfo[64] & 0x03);␊ |
656 | */␉␉␊ |
657 | ␊ |
658 | ␉free( edidInfo );␊ |
659 | ␉␉␊ |
660 | ␉return 0;␊ |
661 | ␉␉␊ |
662 | }␊ |
663 | ␊ |
664 | ␊ |
665 | static void gtf_timings(UInt32 x, UInt32 y, UInt32 freq,␊ |
666 | ␉␉␉␉␉␉unsigned long *clock,␊ |
667 | ␉␉␉␉␉␉UInt16 *hsyncstart, UInt16 *hsyncend, UInt16 *hblank,␊ |
668 | ␉␉␉␉␉␉UInt16 *vsyncstart, UInt16 *vsyncend, UInt16 *vblank)␊ |
669 | {␊ |
670 | ␉UInt32 hbl, vbl, vfreq;␊ |
671 | ␉␊ |
672 | ␉vbl = y + (y+1)/(20000.0/(11*freq) - 1) + 1.5;␊ |
673 | ␉vfreq = vbl * freq;␊ |
674 | ␉hbl = 16 * (int)(x * (30.0 - 300000.0 / vfreq) /␊ |
675 | ␉␉␉␉␉ + (70.0 + 300000.0 / vfreq) / 16.0 + 0.5);␊ |
676 | ␊ |
677 | ␉*vsyncstart = y;␊ |
678 | ␉*vsyncend = y + 3;␊ |
679 | ␉*vblank = vbl - 1;␊ |
680 | ␉*hsyncstart = x + hbl / 2 - (x + hbl + 50) / 100 * 8 - 1;␊ |
681 | ␉*hsyncend = x + hbl / 2 - 1;␊ |
682 | ␉*hblank = x + hbl - 1;␊ |
683 | ␉*clock = (x + hbl) * vfreq / 1000;␊ |
684 | }␊ |
685 | ␊ |
686 | void set_mode(vbios_map * map, /*UInt32 mode,*/ UInt32 x, UInt32 y, UInt32 bp, UInt32 htotal, UInt32 vtotal) {␊ |
687 | ␉UInt32 xprev, yprev;␊ |
688 | ␉UInt32 i = 0, j;␊ |
689 | ␉// patch first available mode␊ |
690 | ␉␊ |
691 | ␉//␉for (i=0; i < map->mode_table_size; i++) {␊ |
692 | ␉//␉␉if (map->mode_table[0].mode == mode) {␊ |
693 | ␉verbose(" Patching: ");␊ |
694 | ␉switch(map->bios) {␊ |
695 | ␉␉case BT_INTEL:␊ |
696 | ␉␉␉verbose("BT_INTEL - not supported\n");␊ |
697 | ␉␉␉return;␊ |
698 | ␊ |
699 | ␉␉case BT_1:␊ |
700 | ␉␉{␊ |
701 | ␉␉␉verbose("BT_1 patched.\n");␊ |
702 | ␉␉␉vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);␊ |
703 | ␉␉␉␊ |
704 | ␉␉␉if (bp)␊ |
705 | ␉␉␉{␊ |
706 | ␉␉␉␉map->mode_table[i].bits_per_pixel = (uint8_t)bp;␊ |
707 | ␉␉␉}␊ |
708 | ␉␉␉␊ |
709 | ␉␉␉res->x2 = (htotal?(((htotal-x) >> 8) & 0x0f) : (res->x2 & 0x0f)) | ((x >> 4) & 0xf0);␊ |
710 | ␉␉␉res->x1 = (x & 0xff);␊ |
711 | ␉␉␉␊ |
712 | ␉␉␉res->y2 = (vtotal?(((vtotal-y) >> 8) & 0x0f) : (res->y2 & 0x0f)) | ((y >> 4) & 0xf0);␊ |
713 | ␉␉␉res->y1 = (y & 0xff);␊ |
714 | ␉␉␉if (htotal)␊ |
715 | ␉␉␉{␊ |
716 | ␉␉␉␉res->x_total = ((htotal-x) & 0xff);␊ |
717 | ␉␉␉}␊ |
718 | ␉␉␉if (vtotal)␊ |
719 | ␉␉␉{␊ |
720 | ␉␉␉␉res->y_total = ((vtotal-y) & 0xff);␊ |
721 | ␉␉␉}␊ |
722 | ␉␉␉break;␊ |
723 | ␉␉}␊ |
724 | ␉␉case BT_2:␊ |
725 | ␉␉{␊ |
726 | ␉␉␉vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);␊ |
727 | ␉␉␉␊ |
728 | ␉␉␉res->xchars = (uint8_t)(x / 8);␊ |
729 | ␉␉␉res->ychars = (uint8_t)(y / 16 - 1);␊ |
730 | ␉␉␉xprev = res->modelines[0].x1;␊ |
731 | ␉␉␉yprev = res->modelines[0].y1;␊ |
732 | ␉␉␉␊ |
733 | ␉␉␉for(j=0; j < 3; j++) {␊ |
734 | ␉␉␉␉vbios_modeline_type2 * modeline = &res->modelines[j];␊ |
735 | ␉␉␉␉␊ |
736 | ␉␉␉␉if (modeline->x1 == xprev && modeline->y1 == yprev) {␊ |
737 | ␉␉␉␉␉modeline->x1 = modeline->x2 = (uint16_t)(x-1);␊ |
738 | ␉␉␉␉␉modeline->y1 = modeline->y2 = (uint16_t)(y-1);␊ |
739 | ␉␉␉␉␉␊ |
740 | ␉␉␉␉␉gtf_timings(x, y, freqs[j], &modeline->clock,␊ |
741 | ␉␉␉␉␉␉␉␉&modeline->hsyncstart, &modeline->hsyncend,␊ |
742 | ␉␉␉␉␉␉␉␉&modeline->hblank, &modeline->vsyncstart,␊ |
743 | ␉␉␉␉␉␉␉␉&modeline->vsyncend, &modeline->vblank);␊ |
744 | ␉␉␉␉␉␊ |
745 | ␉␉␉␉␉if (htotal)␊ |
746 | ␉␉␉␉␉{␊ |
747 | ␉␉␉␉␉␉modeline->htotal = (uint16_t)htotal;␊ |
748 | ␉␉␉␉␉}␊ |
749 | ␉␉␉␉␉else␊ |
750 | ␉␉␉␉␉{␊ |
751 | ␉␉␉␉␉␉modeline->htotal = modeline->hblank;␊ |
752 | ␉␉␉␉␉}␊ |
753 | ␉␉␉␉␉if (vtotal)␊ |
754 | ␉␉␉␉␉{␊ |
755 | ␉␉␉␉␉␉modeline->vtotal = (uint16_t)vtotal;␊ |
756 | ␉␉␉␉␉}␊ |
757 | ␉␉␉␉␉else␊ |
758 | ␉␉␉␉␉{␊ |
759 | ␉␉␉␉␉␉modeline->vtotal = modeline->vblank;␊ |
760 | ␉␉␉␉␉}␊ |
761 | ␉␉␉␉}␊ |
762 | ␉␉␉}␊ |
763 | ␉␉␉verbose("BT_1 patched.\n");␊ |
764 | ␉␉␉break;␊ |
765 | ␉␉}␊ |
766 | ␉␉case BT_3:␊ |
767 | ␉␉{␊ |
768 | ␉␉␉vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution);␊ |
769 | ␉␉␉␊ |
770 | ␉␉␉xprev = res->modelines[0].x1;␊ |
771 | ␉␉␉yprev = res->modelines[0].y1;␊ |
772 | ␉␉␉␊ |
773 | ␉␉␉for (j=0; j < 3; j++) {␊ |
774 | ␉␉␉␉vbios_modeline_type3 * modeline = &res->modelines[j];␊ |
775 | ␉␉␉␉␊ |
776 | ␉␉␉␉if (modeline->x1 == xprev && modeline->y1 == yprev) {␊ |
777 | ␉␉␉␉␉modeline->x1 = modeline->x2 = (uint16_t)(x-1);␊ |
778 | ␉␉␉␉␉modeline->y1 = modeline->y2 = (uint16_t)(y-1);␊ |
779 | ␉␉␉␉␉␊ |
780 | ␉␉␉␉␉gtf_timings(x, y, freqs[j], &modeline->clock,␊ |
781 | ␉␉␉␉␉␉␉␉&modeline->hsyncstart, &modeline->hsyncend,␊ |
782 | ␉␉␉␉␉␉␉␉&modeline->hblank, &modeline->vsyncstart,␊ |
783 | ␉␉␉␉␉␉␉␉&modeline->vsyncend, &modeline->vblank);␊ |
784 | ␉␉␉␉␉if (htotal)␊ |
785 | ␉␉␉␉␉{␊ |
786 | ␉␉␉␉␉␉modeline->htotal = (uint16_t)htotal;␊ |
787 | ␉␉␉␉␉}␊ |
788 | ␉␉␉␉␉else␊ |
789 | ␉␉␉␉␉{␊ |
790 | ␉␉␉␉␉␉modeline->htotal = modeline->hblank;␊ |
791 | ␉␉␉␉␉}␊ |
792 | ␉␉␉␉␉if (vtotal)␊ |
793 | ␉␉␉␉␉{␊ |
794 | ␉␉␉␉␉␉modeline->vtotal = (uint16_t)vtotal;␊ |
795 | ␉␉␉␉␉}␊ |
796 | ␉␉␉␉␉else␊ |
797 | ␉␉␉␉␉{␊ |
798 | ␉␉␉␉␉␉modeline->vtotal = modeline->vblank;␊ |
799 | ␉␉␉␉␉}␊ |
800 | ␉␉␉␉␉modeline->timing_h = (uint16_t)(y-1);␊ |
801 | ␉␉␉␉␉modeline->timing_v = (uint16_t)(x-1);␊ |
802 | ␉␉␉␉}␊ |
803 | ␉␉␉}␊ |
804 | ␉␉␉verbose("BT_3 patched.\n");␊ |
805 | ␉␉␉break;␊ |
806 | ␉␉}␊ |
807 | ␉␉case BT_ATI_1:␊ |
808 | ␉␉{␊ |
809 | ␉␉␉verbose("BT_ATI_1");␊ |
810 | ␉␉␉edid_mode mode;␊ |
811 | ␉␉␉␉␊ |
812 | ␉␉␉ATOM_MODE_TIMING *mode_timing = (ATOM_MODE_TIMING *) map->ati_mode_table;␊ |
813 | ␊ |
814 | ␉␉␉//if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force){␊ |
815 | ␉␉␉if (!getMode(&mode))␊ |
816 | ␉␉␉{␊ |
817 | ␉␉␉␉verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode 0 patched!\n", mode.h_active, mode.v_active);␊ |
818 | ␉␉␉␉mode_timing->usCRTC_H_Total = mode.h_active + mode.h_blanking;␊ |
819 | ␉␉␉␉mode_timing->usCRTC_H_Disp = mode.h_active;␊ |
820 | ␉␉␉␉mode_timing->usCRTC_H_SyncStart = mode.h_active + mode.h_sync_offset;␊ |
821 | ␉␉␉␉mode_timing->usCRTC_H_SyncWidth = mode.h_sync_width;␊ |
822 | ␉␉␉␉␉␊ |
823 | ␉␉␉␉mode_timing->usCRTC_V_Total = mode.v_active + mode.v_blanking;␊ |
824 | ␉␉␉␉mode_timing->usCRTC_V_Disp = mode.v_active;␊ |
825 | ␉␉␉␉mode_timing->usCRTC_V_SyncStart = mode.v_active + mode.v_sync_offset;␊ |
826 | ␉␉␉␉mode_timing->usCRTC_V_SyncWidth = mode.v_sync_width;␊ |
827 | ␊ |
828 | ␉␉␉␉mode_timing->usPixelClock = mode.pixel_clock;␊ |
829 | ␉␉␉} else {␊ |
830 | ␉␉␉␉verbose(" Edid not found or invalid - vbios not patched!\n");␊ |
831 | ␉␉␉}␊ |
832 | ␉␉␉/*else␊ |
833 | ␉␉␉{␊ |
834 | ␉␉␉␉vbios_modeline_type2 modeline;␊ |
835 | ␊ |
836 | ␉␉␉␉cvt_timings(x, y, freqs[0], &modeline.clock,␊ |
837 | ␉␉␉␉␉␉␉&modeline.hsyncstart, &modeline.hsyncend,␊ |
838 | ␉␉␉␉␉␉␉&modeline.hblank, &modeline.vsyncstart,␊ |
839 | ␉␉␉␉␉␉␉&modeline.vsyncend, &modeline.vblank, 0);␊ |
840 | ␊ |
841 | ␉␉␉␉mode_timing->usCRTC_H_Total = x + modeline.hblank;␊ |
842 | ␉␉␉␉mode_timing->usCRTC_H_Disp = x;␊ |
843 | ␉␉␉␉mode_timing->usCRTC_H_SyncStart = modeline.hsyncstart;␊ |
844 | ␉␉␉␉mode_timing->usCRTC_H_SyncWidth = modeline.hsyncend - modeline.hsyncstart;␊ |
845 | ␊ |
846 | ␉␉␉␉mode_timing->usCRTC_V_Total = y + modeline.vblank;␊ |
847 | ␉␉␉␉mode_timing->usCRTC_V_Disp = y;␊ |
848 | ␉␉␉␉mode_timing->usCRTC_V_SyncStart = modeline.vsyncstart;␊ |
849 | ␉␉␉␉mode_timing->usCRTC_V_SyncWidth = modeline.vsyncend - modeline.vsyncstart;␊ |
850 | ␉␉␉␉␉␉␉␉␉␉␉␉␊ |
851 | ␉␉␉␉mode_timing->usPixelClock = modeline.clock;␊ |
852 | ␉␉␉ }*/␊ |
853 | ␊ |
854 | ␉␉␉break;␊ |
855 | ␉␉}␊ |
856 | ␉␉case BT_ATI_2:␊ |
857 | ␉␉{␊ |
858 | ␉␉␉verbose("BT_ATI_2");␊ |
859 | ␉␉␉edid_mode mode;␊ |
860 | ␉␉␉␉␉␉␊ |
861 | ␉␉␉ATOM_DTD_FORMAT *mode_timing = (ATOM_DTD_FORMAT *) map->ati_mode_table;␊ |
862 | ␉␉␉␊ |
863 | ␉␉␉/*if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force) {*/␊ |
864 | ␉␉␉if (!getMode(&mode)) {␊ |
865 | ␉␉␉␉verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode 0 patched!\n", mode.h_active, mode.v_active);␊ |
866 | ␉␉␉␉mode_timing->usHBlanking_Time = mode.h_blanking;␊ |
867 | ␉␉␉␉mode_timing->usHActive = mode.h_active;␊ |
868 | ␉␉␉␉mode_timing->usHSyncOffset = mode.h_sync_offset;␊ |
869 | ␉␉␉␉mode_timing->usHSyncWidth = mode.h_sync_width;␊ |
870 | ␉␉␉␉␉␉␉␉␉␉␊ |
871 | ␉␉␉␉mode_timing->usVBlanking_Time = mode.v_blanking;␊ |
872 | ␉␉␉␉mode_timing->usVActive = mode.v_active;␊ |
873 | ␉␉␉␉mode_timing->usVSyncOffset = mode.v_sync_offset;␊ |
874 | ␉␉␉␉mode_timing->usVSyncWidth = mode.v_sync_width;␊ |
875 | ␉␉␉␉␉␉␉␉␉␉␊ |
876 | ␉␉␉␉mode_timing->usPixClk = mode.pixel_clock;␊ |
877 | ␉␉␉} else {␊ |
878 | ␉␉␉␉verbose(" Edid not found or invalid - vbios not patched!\n");␊ |
879 | ␉␉␉}␊ |
880 | ␉␉␉/*else␊ |
881 | ␉␉␉{␊ |
882 | ␉␉␉␉vbios_modeline_type2 modeline;␊ |
883 | ␉␉␉␊ |
884 | ␉␉␉␉cvt_timings(x, y, freqs[0], &modeline.clock,␊ |
885 | ␉␉␉␉␉␉␉&modeline.hsyncstart, &modeline.hsyncend,␊ |
886 | ␉␉␉␉␉␉␉&modeline.hblank, &modeline.vsyncstart,␊ |
887 | ␉␉␉␉␉␉␉&modeline.vsyncend, &modeline.vblank, 0);␊ |
888 | ␉␉␉␉␉␉␉␉␉␉␉␊ |
889 | ␉␉␉␉mode_timing->usHBlanking_Time = modeline.hblank;␊ |
890 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usHActive = x;␊ |
891 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usHSyncOffset = modeline.hsyncstart - x;␊ |
892 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usHSyncWidth = modeline.hsyncend - modeline.hsyncstart;␊ |
893 | ␉␉␉␉␉␉␉␉␉␉␉␊ |
894 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usVBlanking_Time = modeline.vblank;␊ |
895 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usVActive = y;␊ |
896 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usVSyncOffset = modeline.vsyncstart - y;␊ |
897 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usVSyncWidth = modeline.hsyncend - modeline.hsyncstart;␊ |
898 | ␉␉␉␉␉␉␉␉␉␉␉␊ |
899 | ␉␉␉␉␉␉␉␉␉␉␉mode_timing->usPixClk = modeline.clock;␊ |
900 | ␉␉␉␉␉␉␉␉␉␉}*/␊ |
901 | ␊ |
902 | ␉␉␉break;␊ |
903 | ␉␉}␊ |
904 | ␉␉case BT_NVDA:␊ |
905 | ␉␉{␊ |
906 | ␉␉␉verbose("BT_NVDA");␊ |
907 | ␉␉␉edid_mode mode;␊ |
908 | ␉␉␉NV_MODELINE *mode_timing = (NV_MODELINE *) map->nv_mode_table;␊ |
909 | ␉␉␉␊ |
910 | ␉␉␉/*if (mode.pixel_clock && (mode.h_active == x) && (mode.v_active == y) && !force) {*/␊ |
911 | ␉␉␉if (!getMode(&mode))␊ |
912 | ␉␉␉{␊ |
913 | ␉␉␉␉verbose("\n Edid detailed timing descriptor found: %dx%d\n vbios mode %d patched!\n", mode.h_active, mode.v_active, i);␊ |
914 | ␉␉␉␉mode_timing[i].usH_Total = mode.h_active + mode.h_blanking;␊ |
915 | ␉␉␉␉mode_timing[i].usH_Active = mode.h_active;␊ |
916 | ␉␉␉␉mode_timing[i].usH_SyncStart = mode.h_active + mode.h_sync_offset;␊ |
917 | ␉␉␉␉mode_timing[i].usH_SyncEnd = mode.h_active + mode.h_sync_offset + mode.h_sync_width;␊ |
918 | ␉␉␉␉␊ |
919 | ␉␉␉␉mode_timing[i].usV_Total = mode.v_active + mode.v_blanking;␊ |
920 | ␉␉␉␉mode_timing[i].usV_Active = mode.v_active;␊ |
921 | ␉␉␉␉mode_timing[i].usV_SyncStart = mode.v_active + mode.v_sync_offset;␊ |
922 | ␉␉␉␉mode_timing[i].usV_SyncEnd = mode.v_active + mode.v_sync_offset + mode.v_sync_width;␊ |
923 | ␉␉␉␉␊ |
924 | ␉␉␉␉mode_timing[i].usPixel_Clock = mode.pixel_clock;␊ |
925 | ␉␉␉}␊ |
926 | ␉␉␉ else␊ |
927 | ␉␉␉{␊ |
928 | ␉␉␉␉verbose(" Edid not found or invalid - vbios not patched!\n");␊ |
929 | ␉␉␉}␊ |
930 | ␉␉␉/*else␊ |
931 | ␉␉␉ {␊ |
932 | ␉␉␉ vbios_modeline_type2 modeline;␊ |
933 | ␉␉␉ cvt_timings(x, y, freqs[0], &modeline.clock,␊ |
934 | ␉␉␉ &modeline.hsyncstart, &modeline.hsyncend,␊ |
935 | ␉␉␉ &modeline.hblank, &modeline.vsyncstart,␊ |
936 | ␉␉␉ &modeline.vsyncend, &modeline.vblank, 0);␊ |
937 | ␊ |
938 | ␉␉␉ mode_timing[i].usH_Total = x + modeline.hblank - 1;␊ |
939 | ␉␉␉ mode_timing[i].usH_Active = x;␊ |
940 | ␉␉␉ mode_timing[i].usH_SyncStart = modeline.hsyncstart - 1;␊ |
941 | ␉␉␉ mode_timing[i].usH_SyncEnd = modeline.hsyncend - 1;␊ |
942 | ␊ |
943 | ␉␉␉ mode_timing[i].usV_Total = y + modeline.vblank - 1;␊ |
944 | ␉␉␉ mode_timing[i].usV_Active = y;␊ |
945 | ␉␉␉ mode_timing[i].usV_SyncStart = modeline.vsyncstart - 1;␊ |
946 | ␉␉␉ mode_timing[i].usV_SyncEnd = modeline.vsyncend - 1;␊ |
947 | ␊ |
948 | ␉␉␉ mode_timing[i].usPixel_Clock = modeline.clock;␊ |
949 | ␉␉␉ }*/␊ |
950 | ␉␉␉break;␊ |
951 | ␉␉}␊ |
952 | ␉␉case BT_UNKNOWN:␊ |
953 | ␉␉{␊ |
954 | ␉␉␉verbose(" Unknown - vbios not patched\n");␊ |
955 | ␉␉␉break;␊ |
956 | ␉␉}␊ |
957 | ␉␉default:␊ |
958 | ␉␉␉break;␊ |
959 | ␉}␊ |
960 | ␉//␉␉}␊ |
961 | ␉//␉}␊ |
962 | }␊ |
963 | ␊ |
964 | #endif // _RESOLUTION_H_␊ |
965 | |