Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 2385