Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 2633