Chameleon

Chameleon Svn Source Tree

Root/branches/Chimera/i386/modules/Resolution/915resolution.c

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

Archive Download this file

Revision: 2250