Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/modules/Resolution/915resolution.c

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

Archive Download this file

Revision: 1996