Root/
Source at commit 2054 created 11 years 10 months ago. By zef, Fixed source indent. | |
---|---|
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 | } chipset_type;␊ |
117 | ␊ |
118 | ␊ |
119 | ␊ |
120 | typedef enum {␊ |
121 | ␉BT_UNKNOWN, BT_1, BT_2, BT_3, BT_ATI_1, BT_ATI_2, BT_NVDA, BT_INTEL␊ |
122 | } bios_type;␊ |
123 | ␊ |
124 | ␊ |
125 | typedef struct {␊ |
126 | ␉char *base;␊ |
127 | ␉ATOM_ROM_HEADER *AtomRomHeader;␊ |
128 | ␉unsigned short *MasterCommandTables;␊ |
129 | ␉unsigned short *MasterDataTables;␊ |
130 | } bios_tables_t;␊ |
131 | ␊ |
132 | typedef struct {␊ |
133 | ␉UInt8 mode;␊ |
134 | ␉UInt8 bits_per_pixel;␊ |
135 | ␉UInt16 resolution;␊ |
136 | ␉UInt8 unknown;␊ |
137 | } __attribute__((packed)) vbios_mode;␊ |
138 | ␊ |
139 | typedef struct {␊ |
140 | ␉UInt8 unknow1[2];␊ |
141 | ␉UInt8 x1;␊ |
142 | ␉UInt8 x_total;␊ |
143 | ␉UInt8 x2;␊ |
144 | ␉UInt8 y1;␊ |
145 | ␉UInt8 y_total;␊ |
146 | ␉UInt8 y2;␊ |
147 | } __attribute__((packed)) vbios_resolution_type1;␊ |
148 | ␊ |
149 | typedef struct {␊ |
150 | ␉unsigned long clock;␊ |
151 | ␉␊ |
152 | ␉UInt16 x1;␊ |
153 | ␉UInt16 htotal;␊ |
154 | ␉UInt16 x2;␊ |
155 | ␉UInt16 hblank;␊ |
156 | ␉UInt16 hsyncstart;␊ |
157 | ␉UInt16 hsyncend;␊ |
158 | ␉UInt16 y1;␊ |
159 | UInt16 vtotal;␊ |
160 | UInt16 y2;␊ |
161 | ␉UInt16 vblank;␊ |
162 | ␉UInt16 vsyncstart;␊ |
163 | ␉UInt16 vsyncend;␊ |
164 | } __attribute__((packed)) vbios_modeline_type2;␊ |
165 | ␊ |
166 | typedef struct {␊ |
167 | ␉UInt8 xchars;␊ |
168 | ␉UInt8 ychars;␊ |
169 | ␉UInt8 unknown[4];␊ |
170 | ␉␊ |
171 | ␉vbios_modeline_type2 modelines[];␊ |
172 | } __attribute__((packed)) vbios_resolution_type2;␊ |
173 | ␊ |
174 | typedef struct {␊ |
175 | ␉unsigned long clock;␊ |
176 | ␉␊ |
177 | ␉UInt16 x1;␊ |
178 | ␉UInt16 htotal;␊ |
179 | ␉UInt16 x2;␊ |
180 | ␉UInt16 hblank;␊ |
181 | ␉UInt16 hsyncstart;␊ |
182 | ␉UInt16 hsyncend;␊ |
183 | ␉␊ |
184 | ␉UInt16 y1;␊ |
185 | ␉UInt16 vtotal;␊ |
186 | ␉UInt16 y2;␊ |
187 | ␉UInt16 vblank;␊ |
188 | ␉UInt16 vsyncstart;␊ |
189 | ␉UInt16 vsyncend;␊ |
190 | ␉␊ |
191 | ␉UInt16 timing_h;␊ |
192 | ␉UInt16 timing_v;␊ |
193 | ␉␊ |
194 | ␉UInt8 unknown[6];␊ |
195 | } __attribute__((packed)) vbios_modeline_type3;␊ |
196 | ␊ |
197 | typedef struct {␊ |
198 | ␉unsigned char unknown[6];␊ |
199 | ␉␊ |
200 | vbios_modeline_type3 modelines[];␊ |
201 | } __attribute__((packed)) vbios_resolution_type3;␊ |
202 | ␊ |
203 | typedef struct {␊ |
204 | ␉UInt32 chipset_id;␊ |
205 | ␉chipset_type chipset;␊ |
206 | ␉bios_type bios;␊ |
207 | ␉␊ |
208 | ␉bios_tables_t ati_tables;␊ |
209 | ␊ |
210 | ␉␊ |
211 | ␉UInt32 bios_fd;␊ |
212 | ␉char* bios_ptr;␊ |
213 | ␉␊ |
214 | ␉vbios_mode * mode_table;␊ |
215 | ␉char * ati_mode_table;␊ |
216 | ␉char * nv_mode_table;␊ |
217 | ␊ |
218 | ␉UInt32 mode_table_size;␊ |
219 | ␉UInt8 b1, b2;␊ |
220 | ␉␊ |
221 | ␉UInt8 unlocked;␊ |
222 | } vbios_map;␊ |
223 | ␊ |
224 | ␊ |
225 | ␊ |
226 | vbios_map * open_vbios(chipset_type);␊ |
227 | void close_vbios (vbios_map*);␊ |
228 | void unlock_vbios(vbios_map*);␊ |
229 | void relock_vbios(vbios_map*);␊ |
230 | void set_mode(vbios_map*, UInt32, UInt32, UInt32, UInt32, UInt32);␊ |
231 | ␊ |
232 | #endif //__RESOLUTION_H␊ |
233 |