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