Chameleon

Chameleon Svn Source Tree

Root/tags/2.0/i386/libsaio/gma.c

Source at commit 1808 created 12 years 3 months ago.
By blackosx, Revise layout of package installer 'Welcome' file so it looks cleaner. Change the copyright notice to begin from 2009 as seen in the Chameleon 2.0 r431 installer. Should this date be set earlier?
1/*
2Original patch by Nawcom
3http://forum.voodooprojects.org/index.php/topic,1029.0.html
4*/
5
6#include "libsa.h"
7#include "saio_internal.h"
8#include "bootstruct.h"
9#include "pci.h"
10#include "platform.h"
11#include "device_inject.h"
12#include "gma.h"
13
14#ifndef DEBUG_GMA
15#define DEBUG_GMA 0
16#endif
17
18#if DEBUG_GMA
19#define DBG(x...)printf(x)
20#else
21#define DBG(x...)
22#endif
23
24
25uint8_t GMAX3100_vals[22][4] = {
26{ 0x01,0x00,0x00,0x00 },
27{ 0x01,0x00,0x00,0x00 },
28{ 0x01,0x00,0x00,0x00 },
29{ 0x00,0x00,0x00,0x08 },
30{ 0x64,0x00,0x00,0x00 },
31{ 0x00,0x00,0x00,0x08 },
32{ 0x01,0x00,0x00,0x00 },
33{ 0x20,0x00,0x00,0x00 },
34{ 0x00,0x00,0x00,0x00 },
35{ 0x01,0x00,0x00,0x00 },
36{ 0x20,0x03,0x00,0x00 },
37{ 0x00,0x00,0x00,0x00 },
38{ 0x00,0x00,0x00,0x00 },
39{ 0x00,0x00,0x00,0x00 },
40{ 0x08,0x52,0x00,0x00 },
41{ 0x00,0x00,0x00,0x00 },
42{ 0x00,0x00,0x00,0x00 },
43{ 0x01,0x00,0x00,0x00 },
44{ 0x01,0x00,0x00,0x00 },
45{ 0x3B,0x00,0x00,0x00 },
46{ 0x00,0x00,0x00,0x00 }
47};
48
49uint8_t reg_TRUE[]= { 0x01, 0x00, 0x00, 0x00 };
50uint8_t reg_FALSE[] = { 0x00, 0x00, 0x00, 0x00 };
51
52static struct gma_gpu_t KnownGPUS[] = {
53{ 0x00000000, "Unknown"},
54{ 0x808627A2, "Mobile GMA950"},
55{ 0x808627AE, "Mobile GMA950"},
56{ 0x808627A6, "Mobile GMA950"},
57{ 0x8086A011, "Mobile GMA3150"},
58{ 0x8086A012, "Mobile GMA3150"},
59{ 0x80862772, "Desktop GMA950"},
60{ 0x80862776, "Desktop GMA950"},
61//{ 0x8086A001, "Desktop GMA3150" },
62{ 0x8086A001, "Mobile GMA3150"},
63{ 0x8086A002, "Desktop GMA3150" },
64{ 0x80862A02, "GMAX3100"},
65{ 0x80862A03, "GMAX3100"},
66{ 0x80862A12, "GMAX3100"},
67{ 0x80862A13, "GMAX3100"},
68{ 0x80862A42, "GMAX3100"},
69{ 0x80862A43, "GMAX3100"},
70};
71
72char *get_gma_model(uint32_t id) {
73int i = 0;
74
75for (i = 0; i < (sizeof(KnownGPUS) / sizeof(KnownGPUS[0])); i++)
76{
77if (KnownGPUS[i].device == id)
78return KnownGPUS[i].name;
79}
80return KnownGPUS[0].name;
81}
82
83bool setup_gma_devprop(pci_dt_t *gma_dev)
84{
85char*devicepath;
86volatile uint8_t*regs;
87uint32_tbar[7];
88char*model;
89uint8_t BuiltIn =0x00;
90uint8_t ClassFix[4] ={ 0x00, 0x00, 0x03, 0x00 };
91
92devicepath = get_pci_dev_path(gma_dev);
93
94bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);
95regs = (uint8_t *) (bar[0] & ~0x0f);
96
97model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);
98
99verbose("Intel %s [%04x:%04x] :: %s\n",
100model, gma_dev->vendor_id, gma_dev->device_id, devicepath);
101
102if (!string)
103string = devprop_create_string();
104
105struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));
106device = devprop_add_device(string, devicepath);
107
108if (!device)
109{
110printf("Failed initializing dev-prop string dev-entry.\n");
111pause();
112return false;
113}
114
115devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));
116devprop_add_value(device, "device_type", (uint8_t*)"display", 8);
117
118if ((model == (char *)"Mobile GMA950")
119|| (model == (char *)"Mobile GMA3150"))
120{
121devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);
122devprop_add_value(device, "built-in", &BuiltIn, 1);
123devprop_add_value(device, "class-code", ClassFix, 4);
124}
125else if ((model == (char *)"Desktop GMA950")
126|| (model == (char *)"Desktop GMA3150"))
127{
128BuiltIn = 0x01;
129devprop_add_value(device, "built-in", &BuiltIn, 1);
130devprop_add_value(device, "class-code", ClassFix, 4);
131}
132else if (model == (char *)"GMAX3100")
133{
134devprop_add_value(device, "AAPL,HasPanel",GMAX3100_vals[0], 4);
135devprop_add_value(device, "AAPL,SelfRefreshSupported",GMAX3100_vals[1], 4);
136devprop_add_value(device, "AAPL,aux-power-connected",GMAX3100_vals[2], 4);
137devprop_add_value(device, "AAPL,backlight-control",GMAX3100_vals[3], 4);
138devprop_add_value(device, "AAPL00,blackscreen-preferences", GMAX3100_vals[4], 4);
139devprop_add_value(device, "AAPL01,BacklightIntensity",GMAX3100_vals[5], 4);
140devprop_add_value(device, "AAPL01,blackscreen-preferences", GMAX3100_vals[6], 4);
141devprop_add_value(device, "AAPL01,DataJustify",GMAX3100_vals[7], 4);
142devprop_add_value(device, "AAPL01,Depth",GMAX3100_vals[8], 4);
143devprop_add_value(device, "AAPL01,Dither",GMAX3100_vals[9], 4);
144devprop_add_value(device, "AAPL01,DualLink",GMAX3100_vals[10], 4);
145devprop_add_value(device, "AAPL01,Height",GMAX3100_vals[11], 4);
146devprop_add_value(device, "AAPL01,Interlace",GMAX3100_vals[12], 4);
147devprop_add_value(device, "AAPL01,Inverter",GMAX3100_vals[13], 4);
148devprop_add_value(device, "AAPL01,InverterCurrent",GMAX3100_vals[14], 4);
149devprop_add_value(device, "AAPL01,InverterCurrency",GMAX3100_vals[15], 4);
150devprop_add_value(device, "AAPL01,LinkFormat",GMAX3100_vals[16], 4);
151devprop_add_value(device, "AAPL01,LinkType",GMAX3100_vals[17], 4);
152devprop_add_value(device, "AAPL01,Pipe",GMAX3100_vals[18], 4);
153devprop_add_value(device, "AAPL01,PixelFormat",GMAX3100_vals[19], 4);
154devprop_add_value(device, "AAPL01,Refresh",GMAX3100_vals[20], 4);
155devprop_add_value(device, "AAPL01,Stretch",GMAX3100_vals[21], 4);
156devprop_add_value(device, "class-code",ClassFix, 4);
157}
158
159stringdata = malloc(sizeof(uint8_t) * string->length);
160if (!stringdata)
161{
162printf("No stringdata.\n");
163pause();
164return false;
165}
166
167memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
168stringlength = string->length;
169
170return true;
171}
172

Archive Download this file

Revision: 1808