Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 2129