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