Chameleon

Chameleon Svn Source Tree

Root/trunk/i386/libsaio/915resolution.h

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

Archive Download this file

Revision: 127