Chameleon

Chameleon Svn Source Tree

Root/branches/azimutz/Cleancut/i386/modules/IntelGraphicsEnabler/gma.c

1/**
2Original patch by nawcom
3http://forum.voodooprojects.org/index.php/topic,1029.msg4427.html#msg4427
4**/
5
6#include "libsa.h"
7#include "saio_internal.h"
8
9#include "bootstruct.h"
10#include "pci.h"
11#include "platform.h"
12#include "device_inject.h"
13#include "gma.h"
14
15#ifndef DEBUG_GMA
16#define DEBUG_GMA 0
17#endif
18
19#if DEBUG_GMA
20#define DBG(x...)printf(x)
21#else
22#define DBG(x...)
23#endif
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};
48uint8_t reg_TRUE[] = { 0x01 ,0x00 ,0x00 ,0x00 };
49uint8_t reg_FALSE[] = { 0x00,0x00,0x00,0x00 };
50
51static struct gma_gpu_t KnownGPUS[] = {
52{ 0x00000000, "Unknown"},
53{ 0x808627A2, "Mobile GMA950"},
54{ 0x808627AE, "Mobile GMA950"},
55{ 0x808627A6, "Mobile GMA950"},
56{ 0x80862772, "Desktop GMA950"}, //Azi: never worked with mine.
57{ 0x80862776, "Desktop GMA950"},
58{ 0x80862A02, "GMAX3100"},
59{ 0x80862A03, "GMAX3100"},
60{ 0x80862A12, "GMAX3100"},
61{ 0x80862A13, "GMAX3100"}
62};
63
64char *get_gma_model(uint32_t id) {
65int i=0;
66for(i = 0; i < (sizeof(KnownGPUS) / sizeof(KnownGPUS[0])); i++) {
67if(KnownGPUS[i].device == id)
68return KnownGPUS[i].name;
69}
70return KnownGPUS[0].name;
71}
72
73bool setup_gma_devprop(pci_dt_t *gma_dev)
74{
75//intlen;
76char *devicepath;
77volatile uint8_t *regs;
78uint32_t bar[7];
79char *model;
80uint8_t BuiltIn = 0x00;
81uint8_t ClassFix[4] = { 0x00, 0x00, 0x03, 0x00 };
82
83devicepath = get_pci_dev_path(gma_dev);
84
85bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);
86regs = (uint8_t *) (bar[0] & ~0x0f);
87
88model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);
89
90verbose("Intel %s [%04x:%04x] :: %s\n",
91model, gma_dev->vendor_id, gma_dev->device_id, devicepath);
92
93if (!string)
94string = devprop_create_string();
95struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));
96device = devprop_add_device(string, devicepath);
97
98if(!device)
99{
100printf("Failed initializing dev-prop string dev-entry, press any key...\n");
101
102getchar();
103return false;
104}
105
106devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));
107devprop_add_value(device, "device_type", (uint8_t*)"display", 8);
108
109if (model == (char *)"Mobile GMA950") {
110devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);
111devprop_add_value(device, "built-in", &BuiltIn, 1);
112devprop_add_value(device, "class-code", ClassFix, 4);
113} else if (model == (char *)"Desktop GMA950") {
114BuiltIn = 0x01;
115devprop_add_value(device, "built-in", &BuiltIn, 1);
116} else if (model == (char *)"GMAX3100") {
117devprop_add_value(device, "AAPL,HasPanel",GMAX3100_vals[0], 4);
118devprop_add_value(device, "AAPL,SelfRefreshSupported",GMAX3100_vals[1], 4);
119devprop_add_value(device, "AAPL,aux-power-connected",GMAX3100_vals[2], 4);
120devprop_add_value(device, "AAPL,backlight-control",GMAX3100_vals[3], 4);
121devprop_add_value(device, "AAPL00,blackscreen-preferences",GMAX3100_vals[4], 4);
122devprop_add_value(device, "AAPL01,BacklightIntensity",GMAX3100_vals[5], 4);
123devprop_add_value(device, "AAPL01,blackscreen-preferences",GMAX3100_vals[6], 4);
124devprop_add_value(device, "AAPL01,DataJustify",GMAX3100_vals[7], 4);
125devprop_add_value(device, "AAPL01,Depth",GMAX3100_vals[8], 4);
126devprop_add_value(device, "AAPL01,Dither",GMAX3100_vals[9], 4);
127devprop_add_value(device, "AAPL01,DualLink",GMAX3100_vals[10], 4);
128devprop_add_value(device, "AAPL01,Height",GMAX3100_vals[11], 4);
129devprop_add_value(device, "AAPL01,Interlace",GMAX3100_vals[12], 4);
130devprop_add_value(device, "AAPL01,Inverter",GMAX3100_vals[13], 4);
131devprop_add_value(device, "AAPL01,InverterCurrent",GMAX3100_vals[14], 4);
132devprop_add_value(device, "AAPL01,InverterCurrency",GMAX3100_vals[15], 4);
133devprop_add_value(device, "AAPL01,LinkFormat",GMAX3100_vals[16], 4);
134devprop_add_value(device, "AAPL01,LinkType",GMAX3100_vals[17], 4);
135devprop_add_value(device, "AAPL01,Pipe",GMAX3100_vals[18], 4);
136devprop_add_value(device, "AAPL01,PixelFormat",GMAX3100_vals[19], 4);
137devprop_add_value(device, "AAPL01,Refresh",GMAX3100_vals[20], 4);
138devprop_add_value(device, "AAPL01,Stretch",GMAX3100_vals[21], 4);
139}
140
141stringdata = malloc(sizeof(uint8_t) * string->length);
142if(!stringdata)
143{
144printf("no stringdata press a key...\n");
145getchar();
146return false;
147}
148
149memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
150stringlength = string->length;
151
152return true;
153}
154

Archive Download this file

Revision: 949