Chameleon

Chameleon Svn Source Tree

Root/branches/meklortOld/i386/modules/GraphicsEnabler/gma.c

Source at commit 1166 created 13 years 10 days ago.
By meklort, Fixed recent Makefile changes. Please do not use /Users/evan/SourceCode/tmp/chameleon/trunk or VPATH. the *only* time you should use /Users/evan/SourceCode/tmp/chameleon/trunk is when setting the SRCROOT variable. Also note that very soon make pkg is going to be removed. The pkg build script in trunk is very out of date. Instead please use the package maker at http://forge.voodooprojects.org/p/chameleonApplications/. Once this is ready for trunk it will be merged.
1/*
2Original patch by nawcom -> http://forum.voodooprojects.org/index.php/topic,1029.msg4427.html#msg4427
3*/
4#include "libsaio.h"
5#include "bootstruct.h"
6#include "pci.h"
7#include "platform.h"
8#include "device_inject.h"
9#include "gma.h"
10
11#ifndef DEBUG_GMA
12#define DEBUG_GMA 0
13#endif
14
15#if DEBUG_GMA
16#define DBG(x...)printf(x)
17#else
18#define DBG(x...)
19#endif
20
21uint8_t GMAX3100_vals[22][4] = {
22{ 0x01,0x00,0x00,0x00 },
23{ 0x01,0x00,0x00,0x00 },
24{ 0x01,0x00,0x00,0x00 },
25{ 0x00,0x00,0x00,0x08 },
26{ 0x64,0x00,0x00,0x00 },
27{ 0x00,0x00,0x00,0x08 },
28{ 0x01,0x00,0x00,0x00 },
29{ 0x20,0x00,0x00,0x00 },
30{ 0x00,0x00,0x00,0x00 },
31{ 0x01,0x00,0x00,0x00 },
32{ 0x20,0x03,0x00,0x00 },
33{ 0x00,0x00,0x00,0x00 },
34{ 0x00,0x00,0x00,0x00 },
35{ 0x00,0x00,0x00,0x00 },
36{ 0x08,0x52,0x00,0x00 },
37{ 0x00,0x00,0x00,0x00 },
38{ 0x00,0x00,0x00,0x00 },
39{ 0x01,0x00,0x00,0x00 },
40{ 0x01,0x00,0x00,0x00 },
41{ 0x3B,0x00,0x00,0x00 },
42{ 0x00,0x00,0x00,0x00 }
43};
44uint8_t reg_TRUE[] = { 0x01 ,0x00 ,0x00 ,0x00 };
45uint8_t reg_FALSE[] = { 0x00,0x00,0x00,0x00 };
46
47static struct gma_gpu_t KnownGPUS[] = {
48{ 0x00000000, "Unknown" },
49{ 0x808627A2, "Mobile GMA950" },
50{ 0x808627AE, "Mobile GMA950" },
51{ 0x808627A6, "Mobile GMA950" },
52{ 0x8086A011, "Mobile GMA3150" },
53{ 0x8086A012, "Mobile GMA3150" },
54{ 0x80862772, "Desktop GMA950" },
55{ 0x80862776, "Desktop GMA950" },
56//{ 0x8086A001, "Desktop GMA3150" },
57{ 0x8086A001, "Mobile GMA3150" },
58{ 0x8086A002, "Desktop GMA3150" },
59{ 0x80862A02, "GMAX3100" },
60{ 0x80862A03, "GMAX3100" },
61{ 0x80862A12, "GMAX3100" },
62{ 0x80862A13, "GMAX3100" },
63{ 0x80862A42, "GMAX3100" },
64{ 0x80862A43, "GMAX3100" },
65};
66
67char *get_gma_model(uint32_t id) {
68int i=0;
69for(i = 0; i < (sizeof(KnownGPUS) / sizeof(KnownGPUS[0])); i++) {
70if(KnownGPUS[i].device == id)
71return KnownGPUS[i].name;
72}
73return KnownGPUS[0].name;
74}
75
76bool setup_gma_devprop(pci_dt_t *gma_dev)
77{
78//intlen;
79char *devicepath;
80volatile uint8_t *regs;
81uint32_t bar[7];
82char *model;
83uint8_t BuiltIn = 0x00;
84uint8_t ClassFix[4] = { 0x00, 0x00, 0x03, 0x00 };
85
86devicepath = get_pci_dev_path(gma_dev);
87
88bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);
89regs = (uint8_t *) (bar[0] & ~0x0f);
90
91model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);
92
93verbose("Intel %s [%04x:%04x] :: %s\n",
94model, gma_dev->vendor_id, gma_dev->device_id, devicepath);
95
96if (!string)
97string = devprop_create_string();
98struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));
99device = devprop_add_device(string, devicepath);
100
101if(!device)
102{
103printf("Failed initializing dev-prop string dev-entry, press any key...\n");
104
105getc();
106return false;
107}
108
109devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));
110devprop_add_value(device, "device_type", (uint8_t*)"display", 8);
111
112if ((model == (char *)"Mobile GMA950") ||
113(model == (char *)"Mobile GMA3150"))
114{
115devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);
116devprop_add_value(device, "built-in", &BuiltIn, 1);
117devprop_add_value(device, "class-code", ClassFix, 4);
118}
119else if ((model == (char *)"Desktop GMA950") ||
120 (model == (char *)"Desktop GMA3150"))
121{
122BuiltIn = 0x01;
123devprop_add_value(device, "built-in", &BuiltIn, 1);
124devprop_add_value(device, "class-code", ClassFix, 4);
125}
126else if (model == (char *)"GMAX3100")
127{
128devprop_add_value(device, "AAPL,HasPanel",GMAX3100_vals[0], 4);
129devprop_add_value(device, "AAPL,SelfRefreshSupported",GMAX3100_vals[1], 4);
130devprop_add_value(device, "AAPL,aux-power-connected",GMAX3100_vals[2], 4);
131devprop_add_value(device, "AAPL,backlight-control",GMAX3100_vals[3], 4);
132devprop_add_value(device, "AAPL00,blackscreen-preferences",GMAX3100_vals[4], 4);
133devprop_add_value(device, "AAPL01,BacklightIntensity",GMAX3100_vals[5], 4);
134devprop_add_value(device, "AAPL01,blackscreen-preferences",GMAX3100_vals[6], 4);
135devprop_add_value(device, "AAPL01,DataJustify",GMAX3100_vals[7], 4);
136devprop_add_value(device, "AAPL01,Depth",GMAX3100_vals[8], 4);
137devprop_add_value(device, "AAPL01,Dither",GMAX3100_vals[9], 4);
138devprop_add_value(device, "AAPL01,DualLink",GMAX3100_vals[10], 4);
139devprop_add_value(device, "AAPL01,Height",GMAX3100_vals[11], 4);
140devprop_add_value(device, "AAPL01,Interlace",GMAX3100_vals[12], 4);
141devprop_add_value(device, "AAPL01,Inverter",GMAX3100_vals[13], 4);
142devprop_add_value(device, "AAPL01,InverterCurrent",GMAX3100_vals[14], 4);
143devprop_add_value(device, "AAPL01,InverterCurrency",GMAX3100_vals[15], 4);
144devprop_add_value(device, "AAPL01,LinkFormat",GMAX3100_vals[16], 4);
145devprop_add_value(device, "AAPL01,LinkType",GMAX3100_vals[17], 4);
146devprop_add_value(device, "AAPL01,Pipe",GMAX3100_vals[18], 4);
147devprop_add_value(device, "AAPL01,PixelFormat",GMAX3100_vals[19], 4);
148devprop_add_value(device, "AAPL01,Refresh",GMAX3100_vals[20], 4);
149devprop_add_value(device, "AAPL01,Stretch",GMAX3100_vals[21], 4);
150devprop_add_value(device, "class-code", ClassFix, 4);
151}
152
153stringdata = malloc(sizeof(uint8_t) * string->length);
154if(!stringdata)
155{
156printf("no stringdata press a key...\n");
157getc();
158return false;
159}
160
161memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
162stringlength = string->length;
163
164return true;
165}
166

Archive Download this file

Revision: 1166