Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/modules/Resolution/915resolution.h

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

Archive Download this file

Revision: 734