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