Chameleon

Chameleon Svn Source Tree

Root/branches/azimutz/Chazi/i386/libsaio/autoresolution.h

1
2/* Copied from 915 resolution created by steve tomljenovic
3 *
4 * This code is based on the techniques used in :
5 *
6 * - 855patch. Many thanks to Christian Zietz (czietz gmx net)
7 * for demonstrating how to shadow the VBIOS into system RAM
8 * and then modify it.
9 *
10 * - 1280patch by Andrew Tipton (andrewtipton null li).
11 *
12 * - 855resolution by Alain Poirier
13 *
14 * This source code is into the public domain.
15 */
16#ifndef __915_RESOLUTION_H
17#define __915_RESOLUTION_H
18
19//#define AUTORES_DEBUG 1 // enable AutoResolution debug - review!
20
21#include "edid.h"
22
23#if DEBUG
24#ifndef AUTORES_DEBUG
25#define AUTORES_DEBUG
26#endif
27#endif
28
29#ifdef AUTORES_DEBUG
30#define PRINT(a, b...) printf(a, ##b);
31#else
32#define PRINT(a, b...) verbose(a, ##b);
33#endif
34
35#define __packed __attribute__((packed))
36
37#define NEW(a) ((a *)(malloc(sizeof(a))))
38#define FREE(a) (free(a))
39
40#define VBIOS_START 0xc0000
41#define VBIOS_SIZE 0x10000
42
43#define FALSE 0
44#define TRUE 1
45
46
47bool gAutoResolution;
48
49
50typedef struct
51{
52uint8_t width;
53uint8_t height;
54} sAspect;
55
56
57typedef enum
58{
59CT_UNKWN, CT_830, CT_845G, CT_855GM, CT_865G,
60CT_915G, CT_915GM, CT_945G, CT_945GM, CT_945GME, CT_946GZ,
61CT_955X, CT_G965, CT_Q965, CT_965GM, CT_975X,
62CT_P35, CT_X48, CT_B43, CT_Q45, CT_P45,
63CT_GM45, CT_G41, CT_G31, CT_G45, CT_500
64} chipsetType;
65
66
67typedef enum
68{
69BT_UNKWN, BT_1, BT_2, BT_3, BT_ATI_1, BT_ATI_2, BT_NVDA
70} biosType;
71
72typedef struct
73{
74uint32_tclock;
75uint16_tx;
76uint16_thSyncStart;
77uint16_thSyncEnd;
78uint16_thTotal;
79uint16_ty;
80uint16_tvSyncStart;
81uint16_tvSyncEnd;
82uint16_tvTotal;
83} generic_modeline;
84
85typedef struct sModeTable_
86{
87uint8_t*pointer;
88
89uint8_tid;
90uint32_tsize;
91uint32_tmodeCount;
92
93uint8_t *backup;
94
95struct sModeTable_ *prev;
96struct sModeTable_ *next;
97} sModeTable;
98
99
100
101typedef struct
102{
103uint32_t chipsetId;
104chipsetType chipset;
105biosType bios;
106
107uint8_t* biosBackupPtr;
108uint8_t* biosPtr;
109
110sModeTable *modeTables;
111
112uint32_t currentX, currentY;
113uint8_t b1, b2;
114
115bool hasSwitched;
116
117bool (*setMode)(sModeTable *,uint8_t,uint32_t*,uint32_t*);
118
119sAspect aspectRatio;
120
121uint8_t unlocked;
122} vBiosMap;
123
124vBiosMap *map;
125
126vBiosMap * openVbios(chipsetType type);
127void closeVbios (vBiosMap* map);
128
129void unlockVbios(vBiosMap* map);
130void relockVbios(vBiosMap* map);
131
132void saveVbios(vBiosMap* map);
133void restoreVbios(vBiosMap* map);
134
135void saveTables(sModeTable * table);
136void restoreTables(vBiosMap * map, sModeTable * table);
137
138void gtfTimings(uint32_t x, uint32_t y, uint32_t freq,
139 uint32_t *clock,
140 uint16_t *hSyncStart, uint16_t *hSyncEnd, uint16_t *hBlank,
141 uint16_t *vSyncStart, uint16_t *vSyncEnd, uint16_t *vBlank);
142
143sModeTable * intializeTables(vBiosMap * map, int tablesCount);
144
145void patchVbios(vBiosMap* map, uint32_t x, uint32_t y, uint32_t bp, uint32_t hTotal, uint32_t vTotal);
146
147#endif
148

Archive Download this file

Revision: 474