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

Archive Download this file

Revision: 2323