Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/Chameleon/i386/modules/Resolution/915resolution.h

Source at commit 296 created 12 years 10 months ago.
By ifabio, add i386 folder
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
17typedef struct _edid_mode {
18unsigned short pixel_clock;
19unsigned short h_active;
20unsigned short h_blanking;
21unsigned short v_active;
22unsigned short v_blanking;
23unsigned short h_sync_offset;
24unsigned short h_sync_width;
25unsigned short v_sync_offset;
26unsigned short v_sync_width;
27} edid_mode;
28
29
30
31void 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
72typedef struct {
73unsigned charucTable_Major;
74unsigned charucTable_Minor;
75unsigned charucTable_Rev;
76unsigned shortusTable_Size;
77} NV_COMMON_TABLE_HEADER;
78
79typedef struct {
80short reserved1;
81short reserved2;
82short reserved3;
83} NV_RESERVED;
84
85typedef struct {
86unsigned shortusPixel_Clock;
87unsigned shortusH_Active;
88NV_RESERVEDreserved1;
89unsigned shortusH_SyncStart;
90unsigned shortusH_SyncEnd;
91unsigned shortusH_Total;
92unsigned shortusV_Active;
93NV_RESERVEDreserved2;
94unsigned shortusV_SyncStart;
95unsigned shortusV_SyncEnd;
96unsigned shortusV_Total;
97unsigned shortreserved3;
98} NV_MODELINE;
99
100typedef struct {
101NV_COMMON_TABLE_HEADERsHeader;
102NV_MODELINE*sModelines;
103} NV_VESA_TABLE;
104
105/*---*/
106
107
108typedef enum {
109CT_UNKNOWN, CT_UNKNOWN_INTEL, CT_830, CT_845G, CT_855GM, CT_865G,
110CT_915G, CT_915GM, CT_945G, CT_945GM, CT_945GME, CT_946GZ,
111CT_955X, CT_G965, CT_Q965, CT_965GM, CT_975X,
112CT_P35, CT_X48, CT_B43, CT_Q45, CT_P45,
113CT_GM45, CT_G41, CT_G31, CT_G45, CT_500, CT_3150
114} chipset_type;
115
116
117
118typedef enum {
119BT_UNKNOWN, BT_1, BT_2, BT_3, BT_ATI_1, BT_ATI_2, BT_NVDA
120} bios_type;
121
122
123typedef struct {
124char *base;
125ATOM_ROM_HEADER *AtomRomHeader;
126unsigned short *MasterCommandTables;
127unsigned short *MasterDataTables;
128} bios_tables_t;
129
130typedef struct {
131UInt8 mode;
132UInt8 bits_per_pixel;
133UInt16 resolution;
134UInt8 unknown;
135} __attribute__((packed)) vbios_mode;
136
137typedef struct {
138UInt8 unknow1[2];
139UInt8 x1;
140UInt8 x_total;
141UInt8 x2;
142UInt8 y1;
143UInt8 y_total;
144UInt8 y2;
145} __attribute__((packed)) vbios_resolution_type1;
146
147typedef struct {
148unsigned long clock;
149
150UInt16 x1;
151UInt16 htotal;
152UInt16 x2;
153UInt16 hblank;
154UInt16 hsyncstart;
155UInt16 hsyncend;
156UInt16 y1;
157 UInt16 vtotal;
158 UInt16 y2;
159UInt16 vblank;
160UInt16 vsyncstart;
161UInt16 vsyncend;
162} __attribute__((packed)) vbios_modeline_type2;
163
164typedef struct {
165UInt8 xchars;
166UInt8 ychars;
167UInt8 unknown[4];
168
169vbios_modeline_type2 modelines[];
170} __attribute__((packed)) vbios_resolution_type2;
171
172typedef struct {
173unsigned long clock;
174
175UInt16 x1;
176UInt16 htotal;
177UInt16 x2;
178UInt16 hblank;
179UInt16 hsyncstart;
180UInt16 hsyncend;
181
182UInt16 y1;
183UInt16 vtotal;
184UInt16 y2;
185UInt16 vblank;
186UInt16 vsyncstart;
187UInt16 vsyncend;
188
189UInt16 timing_h;
190UInt16 timing_v;
191
192UInt8 unknown[6];
193} __attribute__((packed)) vbios_modeline_type3;
194
195typedef struct {
196unsigned char unknown[6];
197
198 vbios_modeline_type3 modelines[];
199} __attribute__((packed)) vbios_resolution_type3;
200
201typedef struct {
202UInt32 chipset_id;
203chipset_type chipset;
204bios_type bios;
205
206bios_tables_t ati_tables;
207
208
209UInt32 bios_fd;
210char* bios_ptr;
211
212vbios_mode * mode_table;
213char * ati_mode_table;
214char * nv_mode_table;
215
216UInt32 mode_table_size;
217UInt8 b1, b2;
218
219UInt8 unlocked;
220} vbios_map;
221
222
223
224vbios_map * open_vbios(chipset_type);
225void close_vbios (vbios_map*);
226void unlock_vbios(vbios_map*);
227void relock_vbios(vbios_map*);
228void set_mode(vbios_map*, UInt32, UInt32, UInt32, UInt32, UInt32);
229
230#endif //__RESOLUTION_H
231

Archive Download this file

Revision: 296