1 | /*␊ |
2 | ␉Original patch by Nawcom␊ |
3 | ␉http://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 | #include "graphics.h"␊ |
14 | ␊ |
15 | #ifndef DEBUG_GMA␊ |
16 | #define DEBUG_GMA 0␊ |
17 | #endif␊ |
18 | ␊ |
19 | #if DEBUG_GMA␊ |
20 | #define DBG(x...)␉verbose(x)␊ |
21 | #else␊ |
22 | #define DBG(x...)␊ |
23 | #endif␊ |
24 | //Slice - correct all values, still not sure␊ |
25 | uint8_t GMAX3100_vals[23][4] = {␊ |
26 | ␉{ 0x01,0x00,0x00,0x00 },␉//0 "AAPL,HasPanel"␊ |
27 | ␉{ 0x01,0x00,0x00,0x00 },␉//1 "AAPL,SelfRefreshSupported"␊ |
28 | ␉{ 0x01,0x00,0x00,0x00 },␉//2 "AAPL,aux-power-connected"␊ |
29 | ␉{ 0x01,0x00,0x00,0x08 },␉//3 "AAPL,backlight-control"␊ |
30 | ␉{ 0x00,0x00,0x00,0x00 },␉//4 "AAPL00,blackscreen-preferences"␊ |
31 | ␉{ 0x56,0x00,0x00,0x08 },␉//5 "AAPL01,BacklightIntensity"␊ |
32 | ␉{ 0x00,0x00,0x00,0x00 },␉//6 "AAPL01,blackscreen-preferences"␊ |
33 | ␉{ 0x01,0x00,0x00,0x00 },␉//7 "AAPL01,DataJustify"␊ |
34 | ␉{ 0x20,0x00,0x00,0x00 },␉//8 "AAPL01,Depth"␊ |
35 | ␉{ 0x01,0x00,0x00,0x00 },␉//9 "AAPL01,Dither"␊ |
36 | ␉{ 0x20,0x03,0x00,0x00 },␉//10 "AAPL01,Height"␊ |
37 | ␉{ 0x00,0x00,0x00,0x00 },␉//11 "AAPL01,Interlace"␊ |
38 | ␉{ 0x00,0x00,0x00,0x00 },␉//12 "AAPL01,Inverter"␊ |
39 | ␉{ 0x08,0x52,0x00,0x00 },␉//13 "AAPL01,InverterCurrent"␊ |
40 | ␉{ 0x00,0x00,0x00,0x00 },␉//14 "AAPL01,LinkFormat"␊ |
41 | ␉{ 0x00,0x00,0x00,0x00 },␉//15 "AAPL01,LinkType"␊ |
42 | ␉{ 0x01,0x00,0x00,0x00 },␉//16 "AAPL01,Pipe"␊ |
43 | ␉{ 0x01,0x00,0x00,0x00 },␉//17 "AAPL01,PixelFormat"␊ |
44 | ␉{ 0x01,0x00,0x00,0x00 },␉//18 "AAPL01,Refresh"␊ |
45 | ␉{ 0x3B,0x00,0x00,0x00 },␉//19 "AAPL01,Stretch"␊ |
46 | ␉{ 0xc8,0x95,0x00,0x00 },␉//20 "AAPL01,InverterFrequency"␊ |
47 | ␉{ 0x6B,0x10,0x00,0x00 },␉//21 "subsystem-vendor-id"␊ |
48 | ␉{ 0xA2,0x00,0x00,0x00 }␉␉//22 "subsystem-id"␊ |
49 | };␊ |
50 | ␊ |
51 | uint8_t reg_TRUE[]␉= { 0x01, 0x00, 0x00, 0x00 };␊ |
52 | uint8_t reg_FALSE[] = { 0x00, 0x00, 0x00, 0x00 };␊ |
53 | ␊ |
54 | static struct gma_gpu_t KnownGPUS[] = {␊ |
55 | ␉{ 0x00000000, "Unknown"␉␉␉},␊ |
56 | ␉{ 0x808627A2, "Mobile GMA950"␉},␊ |
57 | ␉{ 0x808627AE, "Mobile GMA950"␉},␊ |
58 | ␉{ 0x808627A6, "Mobile GMA950"␉},␊ |
59 | ␉{ 0x8086A011, "Mobile GMA3150"␉},␊ |
60 | ␉{ 0x8086A012, "Mobile GMA3150"␉},␊ |
61 | ␉{ 0x80862772, "Desktop GMA950"␉},␊ |
62 | ␉{ 0x80862776, "Desktop GMA950"␉},␊ |
63 | //␉{ 0x8086A001, "Desktop GMA3150" },␊ |
64 | ␉{ 0x8086A001, "Mobile GMA3150"␉},␊ |
65 | ␉{ 0x8086A002, "Desktop GMA3150" },␊ |
66 | ␉{ 0x80862A02, "GMAX3100"␉␉},␊ |
67 | ␉{ 0x80862A03, "GMAX3100"␉␉},␊ |
68 | ␉{ 0x80862A12, "GMAX3100"␉␉},␊ |
69 | ␉{ 0x80862A13, "GMAX3100"␉␉},␊ |
70 | ␉{ 0x80862A42, "GMAX3100"␉␉},␊ |
71 | ␉{ 0x80862A43, "GMAX3100"␉␉},␊ |
72 | };␊ |
73 | ␊ |
74 | char *get_gma_model(uint32_t id) {␊ |
75 | ␉int i = 0;␊ |
76 | ␉␊ |
77 | ␉for (i = 0; i < (sizeof(KnownGPUS) / sizeof(KnownGPUS[0])); i++)␊ |
78 | ␉{␊ |
79 | ␉␉if (KnownGPUS[i].device == id)␊ |
80 | ␉␉␉return KnownGPUS[i].name;␊ |
81 | ␉}␊ |
82 | ␉return KnownGPUS[0].name;␊ |
83 | }␊ |
84 | ␊ |
85 | bool setup_gma_devprop(pci_dt_t *gma_dev)␊ |
86 | {␊ |
87 | ␉char␉␉␉␉␉*devicepath;␊ |
88 | ␉volatile uint8_t␉␉*regs;␊ |
89 | ␉uint32_t␉␉␉␉bar[7];␊ |
90 | ␉char␉␉␉␉␉*model;␊ |
91 | ␉uint8_t BuiltIn =␉␉0x00;␊ |
92 | ␉uint8_t ClassFix[4] =␉{ 0x00, 0x00, 0x03, 0x00 };␊ |
93 | ␉␊ |
94 | ␉devicepath = get_pci_dev_path(gma_dev);␊ |
95 | ␉␊ |
96 | ␉bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);␊ |
97 | ␉regs = (uint8_t *) (bar[0] & ~0x0f);␊ |
98 | ␉␊ |
99 | ␉model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);␊ |
100 | ␉␊ |
101 | ␉verbose("Intel %s [%04x:%04x] :: %s\n",␊ |
102 | ␉␉␉model, gma_dev->vendor_id, gma_dev->device_id, devicepath);␊ |
103 | ␉␊ |
104 | ␉if (!string)␊ |
105 | ␉␉string = devprop_create_string();␊ |
106 | ␉␊ |
107 | ␉struct DevPropDevice *device = malloc(sizeof(struct DevPropDevice));␊ |
108 | ␉device = devprop_add_device(string, devicepath);␊ |
109 | ␉␊ |
110 | ␉if (!device)␊ |
111 | ␉{␊ |
112 | ␉␉printf("Failed initializing dev-prop string dev-entry.\n");␊ |
113 | ␉␉pause();␊ |
114 | ␉␉return false;␊ |
115 | ␉}␊ |
116 | ␉␊ |
117 | ␉devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));␊ |
118 | ␉devprop_add_value(device, "device_type", (uint8_t*)"display", 8);␉␊ |
119 | ␉␊ |
120 | ␉if ((model == (char *)"Mobile GMA950")␊ |
121 | ␉␉|| (model == (char *)"Mobile GMA3150"))␊ |
122 | ␉{␊ |
123 | ␉␉devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);␊ |
124 | ␉␉devprop_add_value(device, "built-in", &BuiltIn, 1);␊ |
125 | ␉␉devprop_add_value(device, "class-code", ClassFix, 4);␊ |
126 | ␉}␊ |
127 | ␉else if ((model == (char *)"Desktop GMA950")␊ |
128 | ␉␉␉|| (model == (char *)"Desktop GMA3150"))␊ |
129 | ␉{␊ |
130 | ␉␉BuiltIn = 0x01;␊ |
131 | ␉␉devprop_add_value(device, "built-in", &BuiltIn, 1);␊ |
132 | ␉␉devprop_add_value(device, "class-code", ClassFix, 4);␊ |
133 | ␉}␊ |
134 | ␉else if (model == (char *)"GMAX3100")␊ |
135 | ␉{␊ |
136 | ␉␉BuiltIn = gDualLink;␊ |
137 | ␉␉devprop_add_value(device, "AAPL,HasPanel",GMAX3100_vals[0], 4);␊ |
138 | ␉␉devprop_add_value(device, "AAPL,SelfRefreshSupported",GMAX3100_vals[1], 4);␊ |
139 | ␉␉devprop_add_value(device, "AAPL,aux-power-connected",GMAX3100_vals[2], 4);␊ |
140 | ␉␉devprop_add_value(device, "AAPL,backlight-control",GMAX3100_vals[3], 4);␊ |
141 | ␉␉devprop_add_value(device, "AAPL00,blackscreen-preferences",GMAX3100_vals[4], 4);␊ |
142 | ␉␉devprop_add_value(device, "AAPL01,BacklightIntensity",GMAX3100_vals[5], 4);␊ |
143 | ␉␉devprop_add_value(device, "AAPL01,blackscreen-preferences",GMAX3100_vals[6], 4);␊ |
144 | ␉␉devprop_add_value(device, "AAPL01,DataJustify",GMAX3100_vals[7], 4);␊ |
145 | ␉␉devprop_add_value(device, "AAPL01,Depth",GMAX3100_vals[8], 4);␊ |
146 | ␉␉devprop_add_value(device, "AAPL01,Dither",GMAX3100_vals[9], 4);␊ |
147 | ␉␉devprop_add_value(device, "AAPL01,DualLink", &BuiltIn, 1);␉␉//GMAX3100_vals[10]␊ |
148 | ␉␉devprop_add_value(device, "AAPL01,Height",GMAX3100_vals[10], 4);␊ |
149 | ␉␉devprop_add_value(device, "AAPL01,Interlace",GMAX3100_vals[11], 4);␊ |
150 | ␉␉devprop_add_value(device, "AAPL01,Inverter",GMAX3100_vals[12], 4);␊ |
151 | ␉␉devprop_add_value(device, "AAPL01,InverterCurrent",GMAX3100_vals[13], 4);␊ |
152 | //␉␉devprop_add_value(device, "AAPL01,InverterCurrency",GMAX3100_vals[15], 4);␊ |
153 | ␉␉devprop_add_value(device, "AAPL01,LinkFormat",GMAX3100_vals[14], 4);␊ |
154 | ␉␉devprop_add_value(device, "AAPL01,LinkType",GMAX3100_vals[15], 4);␊ |
155 | ␉␉devprop_add_value(device, "AAPL01,Pipe",GMAX3100_vals[16], 4);␊ |
156 | ␉␉devprop_add_value(device, "AAPL01,PixelFormat",GMAX3100_vals[17], 4);␊ |
157 | ␉␉devprop_add_value(device, "AAPL01,Refresh",GMAX3100_vals[18], 4);␊ |
158 | ␉␉devprop_add_value(device, "AAPL01,Stretch",GMAX3100_vals[19], 4);␊ |
159 | ␉␉devprop_add_value(device, "AAPL01,InverterFrequency",GMAX3100_vals[20], 4);␊ |
160 | ␉␉devprop_add_value(device, "class-code",␉␉␉␉␉␉ClassFix, 4);␊ |
161 | ␉␉devprop_add_value(device, "subsystem-vendor-id", GMAX3100_vals[21], 4);␊ |
162 | ␉␉devprop_add_value(device, "subsystem-id", GMAX3100_vals[22], 4);␊ |
163 | ␉}␊ |
164 | ␉␊ |
165 | ␉stringdata = malloc(sizeof(uint8_t) * string->length);␊ |
166 | ␉if (!stringdata)␊ |
167 | ␉{␊ |
168 | ␉␉printf("No stringdata.\n");␊ |
169 | ␉␉pause();␊ |
170 | ␉␉return false;␊ |
171 | ␉}␊ |
172 | ␉␊ |
173 | ␉memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);␊ |
174 | ␉stringlength = string->length;␊ |
175 | ␉␊ |
176 | ␉return true;␊ |
177 | }␊ |
178 | |