1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
/*
* Copyright © 2007 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Zhenyu Wang <zhenyu.z.wang@intel.com>
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "i830.h"
#define SUBSYS_ANY (~0)
#define DMIID_DIR "/sys/class/dmi/id/"
#define DMIID_FILE(x) (DMIID_DIR # x)
typedef struct {
int chipType;
int subsysVendor;
int subsysCard;
void (*hook)(I830Ptr);
} i830_quirk, *i830_quirk_ptr;
enum i830_dmi_data_t {
bios_vendor,
bios_version,
bios_date,
sys_vendor,
product_name,
product_version,
product_serial,
product_uuid,
board_vendor,
board_name,
board_version,
board_serial,
board_asset_tag,
chassis_vendor,
chassis_type,
chassis_version,
chassis_serial,
chassis_asset_tag,
dmi_data_max,
};
static char *i830_dmi_data[dmi_data_max];
#define I830_DMI_FIELD_FUNC(field) \
static void i830_dmi_store_##field(void) \
{\
FILE *f = NULL;\
f = fopen(DMIID_FILE(field), "r");\
if (f == NULL) { i830_dmi_data[field] = NULL; return;}\
fread(i830_dmi_data[field], 64, 1, f);\
fclose(f);\
}
I830_DMI_FIELD_FUNC(bios_vendor);
I830_DMI_FIELD_FUNC(bios_version);
I830_DMI_FIELD_FUNC(bios_date);
I830_DMI_FIELD_FUNC(sys_vendor);
I830_DMI_FIELD_FUNC(product_name);
I830_DMI_FIELD_FUNC(product_version);
I830_DMI_FIELD_FUNC(product_serial);
I830_DMI_FIELD_FUNC(product_uuid);
I830_DMI_FIELD_FUNC(board_vendor);
I830_DMI_FIELD_FUNC(board_name);
I830_DMI_FIELD_FUNC(board_version);
I830_DMI_FIELD_FUNC(board_serial);
I830_DMI_FIELD_FUNC(board_asset_tag);
I830_DMI_FIELD_FUNC(chassis_vendor);
I830_DMI_FIELD_FUNC(chassis_type);
I830_DMI_FIELD_FUNC(chassis_version);
I830_DMI_FIELD_FUNC(chassis_serial);
I830_DMI_FIELD_FUNC(chassis_asset_tag);
static int i830_dmi_scan(void)
{
int i;
for (i = 0; i < dmi_data_max; i++) {
i830_dmi_data[i] = xcalloc(64, sizeof(char));
if (!i830_dmi_data[i]) {
int j;
for (j = 0; j < i; j++)
xfree(i830_dmi_data[j]);
return -1;
}
}
i830_dmi_store_bios_vendor();
i830_dmi_store_bios_version();
i830_dmi_store_bios_date();
i830_dmi_store_sys_vendor();
i830_dmi_store_product_name();
i830_dmi_store_product_version();
i830_dmi_store_product_serial();
i830_dmi_store_product_uuid();
i830_dmi_store_board_vendor();
i830_dmi_store_board_name();
i830_dmi_store_board_version();
i830_dmi_store_board_serial();
i830_dmi_store_board_asset_tag();
i830_dmi_store_chassis_vendor();
i830_dmi_store_chassis_type();
i830_dmi_store_chassis_version();
i830_dmi_store_chassis_serial();
i830_dmi_store_chassis_asset_tag();
return 0;
}
#define DMIID_DUMP(field) \
ErrorF("\t" # field ": %s", i830_dmi_data[field] ?\
i830_dmi_data[field] : "unknown")
static void i830_dmi_dump(void)
{
ErrorF("i830_dmi_dump:\n");
DMIID_DUMP(bios_vendor);
DMIID_DUMP(bios_version);
DMIID_DUMP(bios_date);
DMIID_DUMP(sys_vendor);
DMIID_DUMP(product_name);
DMIID_DUMP(product_version);
DMIID_DUMP(product_serial);
DMIID_DUMP(product_uuid);
DMIID_DUMP(board_vendor);
DMIID_DUMP(board_name);
DMIID_DUMP(board_version);
DMIID_DUMP(board_serial);
DMIID_DUMP(board_asset_tag);
DMIID_DUMP(chassis_vendor);
DMIID_DUMP(chassis_type);
DMIID_DUMP(chassis_version);
DMIID_DUMP(chassis_serial);
DMIID_DUMP(chassis_asset_tag);
}
static void quirk_pipea_force (I830Ptr pI830)
{
pI830->quirk_flag |= QUIRK_PIPEA_FORCE;
}
static void quirk_ignore_tv (I830Ptr pI830)
{
pI830->quirk_flag |= QUIRK_IGNORE_TV;
}
static void quirk_ignore_lvds (I830Ptr pI830)
{
pI830->quirk_flag |= QUIRK_IGNORE_LVDS;
}
static void quirk_mac_mini (I830Ptr pI830)
{
pI830->quirk_flag |= QUIRK_IGNORE_MACMINI_LVDS;
}
/* keep this list sorted by OEM, then by chip ID */
static i830_quirk i830_quirk_list[] = {
/* Aopen mini pc */
{ PCI_CHIP_I945_GM, 0xa0a0, SUBSYS_ANY, quirk_ignore_lvds },
{ PCI_CHIP_I965_GM, 0xa0a0, SUBSYS_ANY, quirk_ignore_lvds },
{ PCI_CHIP_I965_GM, 0x8086, 0x1999, quirk_ignore_lvds },
/* Apple Mac mini has no lvds, but macbook pro does */
{ PCI_CHIP_I945_GM, 0x8086, 0x7270, quirk_mac_mini },
/* Clevo M720R has no tv output */
{ PCI_CHIP_I965_GM, 0x1558, 0x0721, quirk_ignore_tv },
/* Dell Latitude X1 */
{ PCI_CHIP_I915_GM, 0x1028, 0x01a3, quirk_ignore_tv },
/* Dell XPS 1330 */
{ PCI_CHIP_I965_GM, 0x1028, 0x0209, quirk_ignore_tv },
/* Lenovo X60s has no TV output */
{ PCI_CHIP_I945_GM, 0x17aa, 0x201a, quirk_ignore_tv },
/* Lenovo T61 has no TV output */
{ PCI_CHIP_I965_GM, 0x17aa, 0x20b5, quirk_ignore_tv },
/* Lenovo 3000 v200 */
{ PCI_CHIP_I965_GM, 0x17aa, 0x3c18, quirk_ignore_tv },
/* Panasonic Toughbook CF-Y4 has no TV output */
{ PCI_CHIP_I915_GM, 0x10f7, 0x8338, quirk_ignore_tv },
/* Panasonic Toughbook CF-Y7 has no TV output */
{ PCI_CHIP_I965_GM, 0x10f7, 0x8338, quirk_ignore_tv },
/* Toshiba Satellite U300 has no TV output */
{ PCI_CHIP_I965_GM, 0x1179, 0xff50, quirk_ignore_tv },
/* Samsung Q35 has no TV output */
{ PCI_CHIP_I945_GM, 0x144d, 0xc504, quirk_ignore_tv },
/* Samsung Q45 has no TV output */
{ PCI_CHIP_I965_GM, 0x144d, 0xc510, quirk_ignore_tv },
/* Dell Inspiron 510m needs pipe A force quirk */
{ PCI_CHIP_I855_GM, 0x1028, 0x0164, quirk_pipea_force },
/* ThinkPad X40 needs pipe A force quirk */
{ PCI_CHIP_I855_GM, 0x1014, 0x0557, quirk_pipea_force },
{ 0, 0, 0, NULL },
};
void i830_fixup_devices(ScrnInfoPtr scrn)
{
I830Ptr pI830 = I830PTR(scrn);
i830_quirk_ptr p = i830_quirk_list;
int i, ret;
ret = i830_dmi_scan();
if (0)
i830_dmi_dump();
while (p && p->chipType != 0) {
if (DEVICE_ID(pI830->PciInfo) == p->chipType &&
SUBVENDOR_ID(pI830->PciInfo) == p->subsysVendor &&
(SUBSYS_ID(pI830->PciInfo) == p->subsysCard ||
p->subsysCard == SUBSYS_ANY))
p->hook(pI830);
++p;
}
if (!ret) {
for (i = 0; i < dmi_data_max; i++)
xfree(i830_dmi_data[i]);
}
}
|