Chameleon

Chameleon Svn Source Tree

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

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

Archive Download this file

Revision: 734