1 | /*␊ |
2 | * resolution.h␊ |
3 | * ␊ |
4 | *␊ |
5 | * Created by Evan Lojewski on 3/4/10.␊ |
6 | * Copyright 2009. All rights reserved.␊ |
7 | *␊ |
8 | */␊ |
9 | ␊ |
10 | ␊ |
11 | #ifndef __RESOLUTION_H␊ |
12 | #define __RESOLUTION_H␊ |
13 | ␊ |
14 | #include "shortatombios.h"␊ |
15 | #include "edid.h"␊ |
16 | ␊ |
17 | ␊ |
18 | void patchVideoBios();␊ |
19 | ␊ |
20 | ␊ |
21 | ␊ |
22 | /* Copied from 915 resolution created by steve tomljenovic␊ |
23 | *␊ |
24 | * This code is based on the techniques used in :␊ |
25 | *␊ |
26 | * - 855patch. Many thanks to Christian Zietz (czietz gmx net)␊ |
27 | * for demonstrating how to shadow the VBIOS into system RAM␊ |
28 | * and then modify it.␊ |
29 | *␊ |
30 | * - 1280patch by Andrew Tipton (andrewtipton null li).␊ |
31 | *␊ |
32 | * - 855resolution by Alain Poirier␊ |
33 | *␊ |
34 | * This source code is into the public domain.␊ |
35 | */␊ |
36 | ␊ |
37 | #define VBIOS_START 0xc0000␊ |
38 | #define VBIOS_SIZE 0x10000␊ |
39 | ␊ |
40 | #define FALSE 0␊ |
41 | #define TRUE 1␊ |
42 | ␊ |
43 | #define MODE_TABLE_OFFSET_845G 617␊ |
44 | ␊ |
45 | ␊ |
46 | #define ATI_SIGNATURE1 "ATI MOBILITY RADEON"␊ |
47 | #define ATI_SIGNATURE2 "ATI Technologies Inc"␊ |
48 | #define NVIDIA_SIGNATURE "NVIDIA Corp"␊ |
49 | #define INTEL_SIGNATURE "Intel Corp"␊ |
50 | ␊ |
51 | ␊ |
52 | ␊ |
53 | /*␊ |
54 | * NVidia Defines and structures␊ |
55 | */␊ |
56 | ␊ |
57 | #define OFFSET_TO_VESA_TABLE_INDEX 2␊ |
58 | ␊ |
59 | typedef struct {␊ |
60 | ␉unsigned char␉ucTable_Major;␊ |
61 | ␉unsigned char␉ucTable_Minor;␊ |
62 | ␉unsigned char␉ucTable_Rev;␊ |
63 | ␉unsigned short␉usTable_Size;␊ |
64 | } NV_COMMON_TABLE_HEADER;␊ |
65 | ␊ |
66 | typedef struct {␊ |
67 | ␉short reserved1;␊ |
68 | ␉short reserved2;␊ |
69 | ␉short reserved3;␊ |
70 | } NV_RESERVED;␊ |
71 | ␊ |
72 | typedef struct {␊ |
73 | ␉unsigned short␉usPixel_Clock;␊ |
74 | ␉unsigned short␉usH_Active;␊ |
75 | ␉NV_RESERVED␉␉reserved1;␊ |
76 | ␉unsigned short␉usH_SyncStart;␊ |
77 | ␉unsigned short␉usH_SyncEnd;␊ |
78 | ␉unsigned short␉usH_Total;␊ |
79 | ␉unsigned short␉usV_Active;␊ |
80 | ␉NV_RESERVED␉␉reserved2;␊ |
81 | ␉unsigned short␉usV_SyncStart;␊ |
82 | ␉unsigned short␉usV_SyncEnd;␊ |
83 | ␉unsigned short␉usV_Total;␊ |
84 | ␉unsigned short␉reserved3;␊ |
85 | } NV_MODELINE;␊ |
86 | ␊ |
87 | typedef struct {␊ |
88 | ␉NV_COMMON_TABLE_HEADER␉sHeader;␊ |
89 | ␉NV_MODELINE␉*␉␉␉sModelines;␊ |
90 | } NV_VESA_TABLE;␊ |
91 | ␊ |
92 | /*---*/␊ |
93 | ␊ |
94 | ␊ |
95 | typedef enum {␊ |
96 | ␉CT_UNKWN, CT_UNKWN_INTEL, CT_830, CT_845G, CT_855GM, CT_865G, ␊ |
97 | ␉CT_915G, CT_915GM, CT_945G, CT_945GM, CT_945GME, CT_946GZ, ␊ |
98 | ␉CT_955X, CT_G965, CT_Q965, CT_965GM, CT_975X, ␊ |
99 | ␉CT_P35, CT_X48, CT_B43, CT_Q45, CT_P45,␊ |
100 | ␉CT_GM45, CT_G41, CT_G31, CT_G45, CT_500, CT_3150␊ |
101 | } chipset_type;␊ |
102 | ␊ |
103 | ␊ |
104 | ␊ |
105 | typedef enum {␊ |
106 | ␉BT_UNKWN, BT_1, BT_2, BT_3, BT_ATI_1, BT_ATI_2, BT_NVDA, BT_INTEL␊ |
107 | } bios_type;␊ |
108 | ␊ |
109 | ␊ |
110 | typedef struct {␊ |
111 | ␉char *base;␊ |
112 | ␉ATOM_ROM_HEADER *AtomRomHeader;␊ |
113 | ␉unsigned short *MasterCommandTables;␊ |
114 | ␉unsigned short *MasterDataTables;␊ |
115 | } bios_tables_t;␊ |
116 | ␊ |
117 | typedef struct {␊ |
118 | ␉UInt8 mode;␊ |
119 | ␉UInt8 bits_per_pixel;␊ |
120 | ␉UInt16 resolution;␊ |
121 | ␉UInt8 unknown;␊ |
122 | } __attribute__((packed)) vbios_mode;␊ |
123 | ␊ |
124 | typedef struct {␊ |
125 | ␉UInt8 unknow1[2];␊ |
126 | ␉UInt8 x1;␊ |
127 | ␉UInt8 x_total;␊ |
128 | ␉UInt8 x2;␊ |
129 | ␉UInt8 y1;␊ |
130 | ␉UInt8 y_total;␊ |
131 | ␉UInt8 y2;␊ |
132 | } __attribute__((packed)) vbios_resolution_type1;␊ |
133 | ␊ |
134 | typedef struct {␊ |
135 | ␉unsigned long clock;␊ |
136 | ␉␊ |
137 | ␉UInt16 x1;␊ |
138 | ␉UInt16 htotal;␊ |
139 | ␉UInt16 x2;␊ |
140 | ␉UInt16 hblank;␊ |
141 | ␉UInt16 hsyncstart;␊ |
142 | ␉UInt16 hsyncend;␊ |
143 | ␉UInt16 y1;␊ |
144 | UInt16 vtotal;␊ |
145 | UInt16 y2;␊ |
146 | ␉UInt16 vblank;␊ |
147 | ␉UInt16 vsyncstart;␊ |
148 | ␉UInt16 vsyncend;␊ |
149 | } __attribute__((packed)) vbios_modeline_type2;␊ |
150 | ␊ |
151 | typedef struct {␊ |
152 | ␉UInt8 xchars;␊ |
153 | ␉UInt8 ychars;␊ |
154 | ␉UInt8 unknown[4];␊ |
155 | ␉␊ |
156 | ␉vbios_modeline_type2 modelines[];␊ |
157 | } __attribute__((packed)) vbios_resolution_type2;␊ |
158 | ␊ |
159 | typedef struct {␊ |
160 | ␉unsigned long clock;␊ |
161 | ␉␊ |
162 | ␉UInt16 x1;␊ |
163 | ␉UInt16 htotal;␊ |
164 | ␉UInt16 x2;␊ |
165 | ␉UInt16 hblank;␊ |
166 | ␉UInt16 hsyncstart;␊ |
167 | ␉UInt16 hsyncend;␊ |
168 | ␉␊ |
169 | ␉UInt16 y1;␊ |
170 | ␉UInt16 vtotal;␊ |
171 | ␉UInt16 y2;␊ |
172 | ␉UInt16 vblank;␊ |
173 | ␉UInt16 vsyncstart;␊ |
174 | ␉UInt16 vsyncend;␊ |
175 | ␉␊ |
176 | ␉UInt16 timing_h;␊ |
177 | ␉UInt16 timing_v;␊ |
178 | ␉␊ |
179 | ␉UInt8 unknown[6];␊ |
180 | } __attribute__((packed)) vbios_modeline_type3;␊ |
181 | ␊ |
182 | typedef struct {␊ |
183 | ␉unsigned char unknown[6];␊ |
184 | ␉␊ |
185 | vbios_modeline_type3 modelines[];␊ |
186 | } __attribute__((packed)) vbios_resolution_type3;␊ |
187 | ␊ |
188 | typedef struct {␊ |
189 | ␉UInt32 chipset_id;␊ |
190 | ␉chipset_type chipset;␊ |
191 | ␉bios_type bios;␊ |
192 | ␉␊ |
193 | ␉bios_tables_t ati_tables;␊ |
194 | ␊ |
195 | ␉␊ |
196 | ␉UInt32 bios_fd;␊ |
197 | ␉char* bios_ptr;␊ |
198 | ␉␊ |
199 | ␉vbios_mode * mode_table;␊ |
200 | ␉char * ati_mode_table;␊ |
201 | ␉char * nv_mode_table;␊ |
202 | ␊ |
203 | ␉UInt32 mode_table_size;␊ |
204 | ␉UInt8 b1, b2;␊ |
205 | ␉␊ |
206 | ␉UInt8 unlocked;␊ |
207 | } vbios_map;␊ |
208 | ␊ |
209 | ␊ |
210 | ␊ |
211 | vbios_map * open_vbios(chipset_type);␊ |
212 | void close_vbios (vbios_map*);␊ |
213 | void unlock_vbios(vbios_map*);␊ |
214 | void relock_vbios(vbios_map*);␊ |
215 | void set_mode(vbios_map*, UInt32, UInt32, UInt32, UInt32, UInt32);␊ |
216 | ␊ |
217 | #endif //__RESOLUTION_H␊ |
218 | |