Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/modules/Resolution/915resolution.h

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

Archive Download this file

Revision: 1622