Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 1174