Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 693