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