1 | /*␊ |
2 | Original 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 | ␊ |
21 | uint8_t HD3000_os_info[20] = {␊ |
22 | 0x30,0x49,0x01,0x11,0x11,0x11,0x08,0x00,0x00,0x01,␊ |
23 | 0xf0,0x1f,0x01,0x00,0x00,0x00,0x10,0x07,0x00,0x00␊ |
24 | };␊ |
25 | ␊ |
26 | uint8_t GMAX3100_vals[22][4] = {␊ |
27 | ␉{ 0x01,0x00,0x00,0x00 },␊ |
28 | ␉{ 0x01,0x00,0x00,0x00 }, ␊ |
29 | ␉{ 0x01,0x00,0x00,0x00 }, ␊ |
30 | ␉{ 0x00,0x00,0x00,0x08 },␉␊ |
31 | ␉{ 0x64,0x00,0x00,0x00 },␊ |
32 | ␉{ 0x00,0x00,0x00,0x08 },␊ |
33 | ␉{ 0x01,0x00,0x00,0x00 },␊ |
34 | ␉{ 0x20,0x00,0x00,0x00 }, ␊ |
35 | ␉{ 0x00,0x00,0x00,0x00 }, ␊ |
36 | ␉{ 0x01,0x00,0x00,0x00 }, ␊ |
37 | ␉{ 0x20,0x03,0x00,0x00 }, ␊ |
38 | ␉{ 0x00,0x00,0x00,0x00 }, ␊ |
39 | ␉{ 0x00,0x00,0x00,0x00 }, ␊ |
40 | ␉{ 0x00,0x00,0x00,0x00 }, ␊ |
41 | ␉{ 0x08,0x52,0x00,0x00 }, ␊ |
42 | ␉{ 0x00,0x00,0x00,0x00 }, ␊ |
43 | ␉{ 0x00,0x00,0x00,0x00 }, ␊ |
44 | ␉{ 0x01,0x00,0x00,0x00 }, ␊ |
45 | ␉{ 0x01,0x00,0x00,0x00 }, ␊ |
46 | ␉{ 0x3B,0x00,0x00,0x00 },␊ |
47 | ␉{ 0x00,0x00,0x00,0x00 }␊ |
48 | };␊ |
49 | uint8_t reg_TRUE[] = { 0x01 ,0x00 ,0x00 ,0x00 };␊ |
50 | uint8_t reg_FALSE[] = { 0x00,0x00,0x00,0x00 };␊ |
51 | ␊ |
52 | static 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, "Mobile GMA3150" },␊ |
62 | ␉{ 0x8086A002, "Desktop GMA3150" },␊ |
63 | ␉{ 0x80862A02, "GMAX3100" },␊ |
64 | ␉{ 0x80862A03, "GMAX3100" },␊ |
65 | ␉{ 0x80862A12, "GMAX3100" },␊ |
66 | ␉{ 0x80862A13, "GMAX3100" },␊ |
67 | ␉{ 0x80862A42, "GMAX3100" },␊ |
68 | ␉{ 0x80862A43, "GMAX3100" },␊ |
69 | { 0x80860102, "Intel HD Graphics 3000" },␊ |
70 | { 0x80860106, "Intel HD Graphics 3000" },␊ |
71 | { 0x8086010A, "Intel HD Graphics 3000" },␊ |
72 | { 0x80860112, "Intel HD Graphics 3000" },␊ |
73 | { 0x80860116, "Intel HD Graphics 3000" },␊ |
74 | { 0x80860122, "Intel HD Graphics 3000" },␊ |
75 | { 0x80860126, "Intel HD Graphics 3000" }␊ |
76 | };␊ |
77 | static char *get_gma_model(uint32_t id);␊ |
78 | ␊ |
79 | static char *get_gma_model(uint32_t id) {␊ |
80 | ␉␊ |
81 | ␉unsigned int i = 0;␊ |
82 | ␉␊ |
83 | ␉for(i = 0; i < (sizeof(KnownGPUS) / sizeof(KnownGPUS[0])); i++) {␊ |
84 | ␉␉if(KnownGPUS[i].device == id)␊ |
85 | ␉␉␉return KnownGPUS[i].name;␊ |
86 | ␉}␊ |
87 | ␉return KnownGPUS[0].name;␊ |
88 | }␊ |
89 | ␊ |
90 | bool setup_gma_devprop(pci_dt_t *gma_dev)␊ |
91 | {␊ |
92 | ␉//int␉len;␊ |
93 | #if UNUSED␊ |
94 | ␉volatile uint8_t *regs;␊ |
95 | #endif␊ |
96 | ␉uint32_t bar[7];␊ |
97 | ␉char *model;␊ |
98 | ␉uint8_t BuiltIn = 0x00;␊ |
99 | ␉uint8_t ClassFix[4] = { 0x00, 0x00, 0x03, 0x00 };␊ |
100 | ␊ |
101 | ␉bar[0] = pci_config_read32(gma_dev->dev.addr, 0x10);␊ |
102 | #if UNUSED␊ |
103 | ␉regs = (uint8_t *) (bar[0] & ~0x0f);␊ |
104 | #endif␊ |
105 | ␉model = get_gma_model((gma_dev->vendor_id << 16) | gma_dev->device_id);␊ |
106 | ␊ |
107 | ␉verbose("Intel %s [%04x:%04x]\n",␊ |
108 | ␉␉␉model, gma_dev->vendor_id, gma_dev->device_id);␊ |
109 | ␉␊ |
110 | ␉struct DevPropString *string = (struct DevPropString *)(uint32_t)get_env(envEFIString);␊ |
111 | ␉if (!string)␊ |
112 | {␊ |
113 | ␉␉string = devprop_create_string();␊ |
114 | if (!string) return false;␊ |
115 | safe_set_env(envEFIString,(uint32_t)string);␊ |
116 | ␉}␊ |
117 | ␉␊ |
118 | ␉struct DevPropDevice *device = devprop_add_device(string, gma_dev);␊ |
119 | ␉␊ |
120 | ␉if(!device)␊ |
121 | ␉{␊ |
122 | ␉␉printf("Failed initializing dev-prop string dev-entry, press any key...\n");␊ |
123 | ␉␉␊ |
124 | ␉␉getc();␊ |
125 | ␉␉return false;␊ |
126 | ␉}␊ |
127 | ␉␊ |
128 | ␉devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));␊ |
129 | ␉devprop_add_value(device, "device_type", (uint8_t*)"display", 8);␉␊ |
130 | ␊ |
131 | ␉if ((strcmp(model, "Mobile GMA950") == 0) ||␊ |
132 | ␉␉(strcmp(model, "Mobile GMA3150") == 0))␊ |
133 | ␉{␊ |
134 | ␉␉devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);␊ |
135 | ␉␉devprop_add_value(device, "built-in", &BuiltIn, 1);␊ |
136 | ␉␉devprop_add_value(device, "class-code", ClassFix, 4);␊ |
137 | ␉} ␊ |
138 | ␉else if ((strcmp(model, "Desktop GMA950")== 0) || ␊ |
139 | ␉␉␉ (strcmp(model, "Desktop GMA3150") == 0))␊ |
140 | ␉{␊ |
141 | ␉␉BuiltIn = 0x01;␊ |
142 | ␉␉devprop_add_value(device, "built-in", &BuiltIn, 1);␊ |
143 | ␉␉devprop_add_value(device, "class-code", ClassFix, 4);␊ |
144 | ␉}␊ |
145 | ␉else if ( strcmp(model, "GMAX3100") == 0 ) ␊ |
146 | ␉{␊ |
147 | ␉␉devprop_add_value(device, "AAPL,HasPanel",GMAX3100_vals[0], 4);␊ |
148 | ␉␉devprop_add_value(device, "AAPL,SelfRefreshSupported",GMAX3100_vals[1], 4);␊ |
149 | ␉␉devprop_add_value(device, "AAPL,aux-power-connected",GMAX3100_vals[2], 4);␊ |
150 | ␉␉devprop_add_value(device, "AAPL,backlight-control",GMAX3100_vals[3], 4);␊ |
151 | ␉␉devprop_add_value(device, "AAPL00,blackscreen-preferences",GMAX3100_vals[4], 4);␊ |
152 | ␉␉devprop_add_value(device, "AAPL01,BacklightIntensity",GMAX3100_vals[5], 4);␊ |
153 | ␉␉devprop_add_value(device, "AAPL01,blackscreen-preferences",GMAX3100_vals[6], 4);␊ |
154 | ␉␉devprop_add_value(device, "AAPL01,DataJustify",GMAX3100_vals[7], 4);␊ |
155 | ␉␉devprop_add_value(device, "AAPL01,Depth",GMAX3100_vals[8], 4);␊ |
156 | ␉␉devprop_add_value(device, "AAPL01,Dither",GMAX3100_vals[9], 4);␊ |
157 | ␉␉devprop_add_value(device, "AAPL01,DualLink",GMAX3100_vals[10], 4);␊ |
158 | ␉␉devprop_add_value(device, "AAPL01,Height",GMAX3100_vals[11], 4);␊ |
159 | ␉␉devprop_add_value(device, "AAPL01,Interlace",GMAX3100_vals[12], 4);␊ |
160 | ␉␉devprop_add_value(device, "AAPL01,Inverter",GMAX3100_vals[13], 4);␊ |
161 | ␉␉devprop_add_value(device, "AAPL01,InverterCurrent",GMAX3100_vals[14], 4);␊ |
162 | ␉␉devprop_add_value(device, "AAPL01,InverterCurrency",GMAX3100_vals[15], 4);␊ |
163 | ␉␉devprop_add_value(device, "AAPL01,LinkFormat",GMAX3100_vals[16], 4);␊ |
164 | ␉␉devprop_add_value(device, "AAPL01,LinkType",GMAX3100_vals[17], 4);␊ |
165 | ␉␉devprop_add_value(device, "AAPL01,Pipe",GMAX3100_vals[18], 4);␊ |
166 | ␉␉devprop_add_value(device, "AAPL01,PixelFormat",GMAX3100_vals[19], 4);␊ |
167 | ␉␉devprop_add_value(device, "AAPL01,Refresh",GMAX3100_vals[20], 4);␊ |
168 | ␉␉devprop_add_value(device, "AAPL01,Stretch",GMAX3100_vals[21], 4);␊ |
169 | ␉␉devprop_add_value(device, "class-code", ClassFix, 4);␊ |
170 | ␉}␊ |
171 | else if (strcmp(model, "Intel HD Graphics 3000") == 0)␊ |
172 | {␊ |
173 | devprop_add_value(device, "AAPL,os-info", HD3000_os_info, 20);␊ |
174 | }␉␊ |
175 | ␉return true;␊ |
176 | }␊ |
177 | |