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 | ␊ |
47 | bool gAutoResolution;␊ |
48 | ␊ |
49 | ␊ |
50 | typedef struct␊ |
51 | {␊ |
52 | ␉uint8_t width;␊ |
53 | ␉uint8_t height;␊ |
54 | } sAspect;␊ |
55 | ␊ |
56 | ␊ |
57 | typedef enum␊ |
58 | {␊ |
59 | ␉CT_UNKWN, CT_830, CT_845G, CT_855GM, CT_865G, ␊ |
60 | ␉CT_915G, CT_915GM, CT_945G, CT_945GM, CT_945GME, CT_946GZ, ␊ |
61 | ␉CT_955X, CT_G965, CT_Q965, CT_965GM, CT_975X, ␊ |
62 | ␉CT_P35, CT_X48, CT_B43, CT_Q45, CT_P45,␊ |
63 | ␉CT_GM45, CT_G41, CT_G31, CT_G45, CT_500␊ |
64 | } chipsetType;␊ |
65 | ␊ |
66 | ␊ |
67 | typedef enum␊ |
68 | {␊ |
69 | ␉BT_UNKWN, BT_1, BT_2, BT_3, BT_ATI_1, BT_ATI_2, BT_NVDA␊ |
70 | } biosType;␊ |
71 | ␊ |
72 | typedef struct␊ |
73 | {␊ |
74 | ␉uint32_t␉clock;␊ |
75 | ␉uint16_t␉x;␊ |
76 | ␉uint16_t␉hSyncStart;␊ |
77 | ␉uint16_t␉hSyncEnd;␊ |
78 | ␉uint16_t␉hTotal;␊ |
79 | ␉uint16_t␉y;␊ |
80 | ␉uint16_t␉vSyncStart;␊ |
81 | ␉uint16_t␉vSyncEnd;␊ |
82 | ␉uint16_t␉vTotal;␊ |
83 | } generic_modeline;␊ |
84 | ␊ |
85 | typedef struct sModeTable_␊ |
86 | {␊ |
87 | ␉uint8_t␉*␉pointer;␊ |
88 | ␉␊ |
89 | ␉uint8_t␉␉id;␊ |
90 | ␉uint32_t␉size;␊ |
91 | ␉uint32_t␉modeCount;␊ |
92 | ␉␊ |
93 | ␉uint8_t *␉backup;␊ |
94 | ␉␊ |
95 | ␉struct sModeTable_ *prev;␊ |
96 | ␉struct sModeTable_ *next;␊ |
97 | } sModeTable;␊ |
98 | ␉␊ |
99 | ␊ |
100 | ␊ |
101 | typedef struct␊ |
102 | {␊ |
103 | ␉uint32_t chipsetId;␊ |
104 | ␉chipsetType chipset;␊ |
105 | ␉biosType bios;␊ |
106 | ␉␊ |
107 | ␉uint8_t* biosBackupPtr;␊ |
108 | ␉uint8_t* biosPtr;␊ |
109 | ␉␊ |
110 | ␉sModeTable *modeTables;␊ |
111 | ␉␊ |
112 | ␉uint32_t currentX, currentY;␊ |
113 | ␉uint8_t b1, b2;␊ |
114 | ␉␊ |
115 | ␉bool hasSwitched;␊ |
116 | ␉␊ |
117 | ␉bool (*setMode)(sModeTable *,uint8_t,uint32_t*,uint32_t*);␊ |
118 | ␉␊ |
119 | ␉sAspect aspectRatio;␊ |
120 | ␉␊ |
121 | ␉uint8_t unlocked;␊ |
122 | } vBiosMap;␊ |
123 | ␊ |
124 | vBiosMap *map;␊ |
125 | ␊ |
126 | vBiosMap * openVbios(chipsetType type);␊ |
127 | void closeVbios (vBiosMap* map);␊ |
128 | ␊ |
129 | void unlockVbios(vBiosMap* map);␊ |
130 | void relockVbios(vBiosMap* map);␊ |
131 | ␊ |
132 | void saveVbios(vBiosMap* map);␊ |
133 | void restoreVbios(vBiosMap* map);␊ |
134 | ␊ |
135 | void saveTables(sModeTable * table);␊ |
136 | void restoreTables(vBiosMap * map, sModeTable * table);␊ |
137 | ␊ |
138 | void 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 | ␊ |
143 | sModeTable * intializeTables(vBiosMap * map, int tablesCount);␊ |
144 | ␊ |
145 | void patchVbios(vBiosMap* map, uint32_t x, uint32_t y, uint32_t bp, uint32_t hTotal, uint32_t vTotal);␊ |
146 | ␊ |
147 | #endif␊ |
148 | |