Chameleon

Chameleon Svn Source Tree

Root/branches/azimutz/Chazi/i386/libsaio/gma.c

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

Archive Download this file

Revision: 495