summaryrefslogtreecommitdiff
path: root/driver/xf86-video-intel/src/i830_quirks.c
blob: 285856933ecf47a67dbad4a3a292ac8d8c0a7fa2 (plain)
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
/*
 * 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)(intel_screen_private *);
} 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;\
    int ret;\
    f = fopen(DMIID_FILE(field), "r");\
    if (f == NULL) {\
	free(i830_dmi_data[field]); i830_dmi_data[field] = NULL;\
	return;\
    }\
    ret = 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 void i830_dmi_scan(void)
{
    int i;

    for (i = 0; i < dmi_data_max; i++) {
	i830_dmi_data[i] = calloc(64, sizeof(char));
	if (!i830_dmi_data[i]) {
	    int j;
	    for (j = 0; j < i; j++) {
		free(i830_dmi_data[j]);
		i830_dmi_data[i] = NULL;
	    }
	    return;
	}
    }

    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();
}

#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);
}

/*
 * Old chips have undocumented panel fitting registers.  Some of them actually
 * work; this quirk indicates that.
 */
static void quirk_pfit_safe (intel_screen_private *intel)
{
    intel->quirk_flag |= QUIRK_PFIT_SAFE;
}

/*
 * Some machines hose the display regs regardless of the ACPI DOS
 * setting, so we need to reset modes at ACPI event time.
 */
static void quirk_reset_modes (intel_screen_private *intel)
{
    intel->quirk_flag |= QUIRK_RESET_MODES;
}

static void quirk_pipea_force (intel_screen_private *intel)
{
    intel->quirk_flag |= QUIRK_PIPEA_FORCE;
}

static void quirk_ignore_tv (intel_screen_private *intel)
{
    intel->quirk_flag |= QUIRK_IGNORE_TV;
}

static void quirk_ignore_lvds (intel_screen_private *intel)
{
    intel->quirk_flag |= QUIRK_IGNORE_LVDS;
}

static void quirk_ignore_crt (intel_screen_private *intel)
{
    intel->quirk_flag |= QUIRK_IGNORE_CRT;
}

static void quirk_mac_mini (intel_screen_private *intel)
{
    intel->quirk_flag |= QUIRK_IGNORE_MACMINI_LVDS;
}

static void quirk_lenovo_tv_dmi (intel_screen_private *intel)
{
    /* X60, X60s has no TV output.
     * Z61 has S-video TV output.
     * And they have same subsys ids...
     *
     * http://www-307.ibm.com/pc/support/site.wss/MIGR-45120.html
     * http://www.thinkwiki.org/wiki/List_of_DMI_IDs
     */
    if (!i830_dmi_data[bios_version]) {
	ErrorF("Failed to load DMI info, X60 TV quirk not applied.\n");
	return;
    }
    if (!strncmp(i830_dmi_data[bios_version], "7B", 2) || /* X60, X60s */
	    !strncmp(i830_dmi_data[bios_version], "7E", 2)) /* R60e */
	intel->quirk_flag |= QUIRK_IGNORE_TV;
}

static void quirk_msi_lvds_dmi (intel_screen_private *intel)
{
   /* MSI IM-945GSE-A has no TV output, nor a LVDS connection.
    */
   if (!i830_dmi_data[board_name]) {
       ErrorF("Failed to load DMI info, MSI LVDS quirk not applied.\n");
       return;
   }
   if (!strncmp(i830_dmi_data[board_name],"A9830IMS",8)) {
       intel->quirk_flag |= QUIRK_IGNORE_LVDS;
       intel->quirk_flag |= QUIRK_IGNORE_TV;
   }
}

static void quirk_ibase_lvds (intel_screen_private *intel)
{
   if (!i830_dmi_data[board_name]) {
       ErrorF("Failed to load DMI info, iBase LVDS quirk not applied.\n");
       return;
   }
   if (!strncmp(i830_dmi_data[board_name], "i855-W83627HF", 13)) {
       intel->quirk_flag |= QUIRK_IGNORE_LVDS;
   }
}

static void quirk_ivch_dvob (intel_screen_private *intel)
{
	intel->quirk_flag |= QUIRK_IVCH_NEED_DVOB;
}

/* For broken hw/bios for incorrect acpi _LID state that
   can't be fixed with customed DSDT or other way */
static void quirk_broken_acpi_lid (intel_screen_private *intel)
{
	intel->quirk_flag |= QUIRK_BROKEN_ACPI_LID;
}

/* keep this list sorted by OEM, then by chip ID */
static i830_quirk i830_quirk_list[] = {
    /* Aopen mini pc */
    { PCI_CHIP_I915_GM, 0xa0a0, SUBSYS_ANY, quirk_ignore_lvds },
    { PCI_CHIP_I945_GM, 0xa0a0, SUBSYS_ANY, quirk_ignore_lvds },
    { PCI_CHIP_I965_GM, 0xa0a0, SUBSYS_ANY, quirk_ignore_lvds },
    { PCI_CHIP_GM45_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 },

    /* Transtec Senyo 610 mini pc */
    { PCI_CHIP_I965_GM, 0x1509, 0x2f15, quirk_ignore_lvds },

    /* 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 Latitude X1 / D630 (LP: #197740) */
    { PCI_CHIP_I915_GM, 0x1028, 0x01f9, quirk_ignore_tv },
    /* Dell XPS 1330 */
    { PCI_CHIP_I965_GM, 0x1028, 0x0209, quirk_ignore_tv },
    /* Dell Inspiron 1535 */
    { PCI_CHIP_I965_GM, 0x1028, 0x0254, quirk_ignore_tv },
    /* Dell Inspiron 1735 */
    { PCI_CHIP_I965_GM, 0x1028, 0x0256, quirk_ignore_tv },
    /* Dell Inspiron 1318 */
    { PCI_CHIP_I965_GM, 0x1028, 0x0286, quirk_ignore_tv },
    /* Dell Vostro A840 (LP: #235155) */
    { PCI_CHIP_I965_GM, 0x1028, 0x0298, quirk_ignore_tv },
    /* Dell Studio Hybrid */
    { PCI_CHIP_I965_GM, 0x1028, 0x0279, quirk_ignore_lvds },

    /* Lenovo Napa TV (use dmi)*/
    { PCI_CHIP_I945_GM, 0x17aa, SUBSYS_ANY, quirk_lenovo_tv_dmi },
    /* Lenovo 3000 v200 */
    { PCI_CHIP_I965_GM, 0x17aa, 0x3c18, quirk_ignore_tv },

    /* MSI IM-945GSE-A has no LVDS or TV (use dmi) */
    { PCI_CHIP_I945_GME, 0x8086, 0x27ae, quirk_msi_lvds_dmi },

    /* 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 },
    /* Toshiba i830M laptop (fix bug 11148) */
    { PCI_CHIP_I830_M, 0x1179, 0xff00, quirk_ivch_dvob },

    /* Motion Computing M1200 reported on irc */
    { PCI_CHIP_I830_M, 0x14c0, 0x0012, quirk_ivch_dvob },

    /* 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 },

    /* HP Compaq nx6110 has no TV output */
    { PCI_CHIP_I915_GM, 0x103c, 0x099c, quirk_ignore_tv },
    /* HP Compaq nx6310 has no TV output */
    { PCI_CHIP_I945_GM, 0x103c, 0x30aa, quirk_ignore_tv },
    /* HP Compaq 6730s has no TV output */
    { PCI_CHIP_GM45_GM, 0x103c, 0x30e8, quirk_ignore_tv },
    /* HP Compaq 2730p needs pipe A force quirk (LP: #291555) */
    { PCI_CHIP_GM45_GM, 0x103c, 0x30eb, quirk_pipea_force },
    /* HP Mini needs pipe A force quirk (LP: #322104) */
    { PCI_CHIP_I945_GME,0x103c, 0x361a, quirk_pipea_force },
    /* HP Mini 5101 needs pipe A force quirk */
    { PCI_CHIP_I945_GME,0x103c, 0x3632, quirk_pipea_force },

    /* Thinkpad R31 needs pipe A force quirk */
    { PCI_CHIP_I830_M, 0x1014, 0x0505, quirk_pipea_force },
    /* Dell Latitude D400 needs pipe A force quirk (LP: #228519) */
    { PCI_CHIP_I855_GM, 0x1028, 0x0139, quirk_pipea_force },
    /* Dell Latitude D500 needs pipe A force quirk */
    { PCI_CHIP_I855_GM, 0x1028, 0x0152, quirk_pipea_force },
    /* Dell Latitude D505 needs pipe A force quirk (LP: #235643) */
    { PCI_CHIP_I855_GM, 0x1028, 0x0163, quirk_pipea_force },
    /* Dell Latitude X300 needs pipe A force quirk */
    { PCI_CHIP_I855_GM, 0x1028, 0x014f, quirk_pipea_force },
    /* Dell Inspiron 510m needs pipe A force quirk */
    { PCI_CHIP_I855_GM, 0x1028, 0x0164, quirk_pipea_force },
    /* Toshiba Satellite A30 needs pipe A force quirk */
    { PCI_CHIP_I855_GM, 0x1179, 0xff00 , quirk_pipea_force },
    /* Toshiba Protege R-205, S-209 needs pipe A force quirk */
    { PCI_CHIP_I915_GM, 0x1179, 0x0001, quirk_pipea_force },
    /* Intel 855GM hardware (See LP: #216490) */
    { PCI_CHIP_I855_GM, 0x1028, 0x00c8, quirk_pipea_force },
    /* Intel 855GM hardware (See Novell Bugzilla #406123) */
    { PCI_CHIP_I855_GM, 0x10cf, 0x1215, quirk_pipea_force },
    /* HP Pavilion ze4944ea needs pipe A force quirk (See LP: #242389) */
    { PCI_CHIP_I855_GM, 0x103c, 0x3084, quirk_pipea_force },

    { PCI_CHIP_I855_GM, 0x161f, 0x2030, quirk_pfit_safe },

    /* ThinkPad X30 needs pipe A force quirk (LP: #304614) */
    { PCI_CHIP_I830_M,  0x1014, 0x0513, quirk_pipea_force },
    /* ThinkPad X40 needs pipe A force quirk */
    { PCI_CHIP_I855_GM, 0x1014, 0x0557, quirk_pipea_force },

    /* ThinkPad T60 needs pipe A force quirk (bug #16494) */
    { PCI_CHIP_I945_GM, 0x17aa, 0x201a, quirk_pipea_force },

    /* Sony vaio PCG-r600HFP (fix bug 13722) */
    { PCI_CHIP_I830_M, 0x104d, 0x8100, quirk_ivch_dvob },
    /* Sony vaio VGN-SZ4MN (See LP: #212163) */
    { PCI_CHIP_I830_M, 0x104d, 0x81e6, quirk_pipea_force },
    /* Sony VGC-LT71DB has no VGA output (bug #17395) */
    { PCI_CHIP_I965_GM, 0x104d, 0x9018, quirk_ignore_crt },

    /* Quanta Gigabyte W251U (See LP: #244242) */
    { PCI_CHIP_I945_GM, 0x152d, 0x0755, quirk_pipea_force },

    /* Ordi Enduro UW31 (See LP: #152416) */
    { PCI_CHIP_I945_GM, 0x1584, 0x9900, quirk_ignore_tv },

    /* Dell Latitude D500 needs reset modes quirk */
    { PCI_CHIP_I855_GM, 0x1028, 0x0152, quirk_reset_modes },

    /* Littlebit Sepia X35 (rebranded Asus Z37E) (See LP: #201257) */
    { PCI_CHIP_I965_GM, 0x1043, 0x8265, quirk_ignore_tv },

    /* 855 & before need to leave pipe A & dpll A up */
    { PCI_CHIP_I855_GM, SUBSYS_ANY, SUBSYS_ANY, quirk_pipea_force },
    { PCI_CHIP_845_G, SUBSYS_ANY, SUBSYS_ANY, quirk_pipea_force },

    /* Asus Eee Box has no LVDS */
    { PCI_CHIP_I945_GME, 0x1043, 0x1252, quirk_ignore_lvds },

    /* #19239: Mirrus Centrino laptop */
    { PCI_CHIP_I915_GM, 0x1584, 0x9800, quirk_broken_acpi_lid },

    /* #19529: iBase MB890 board */
    { PCI_CHIP_I855_GM, 0x8086, 0x3582, quirk_ibase_lvds },

    { 0, 0, 0, NULL },
};

void i830_fixup_devices(ScrnInfoPtr scrn)
{
    intel_screen_private *intel = intel_get_screen_private(scrn);
    i830_quirk_ptr p = i830_quirk_list;
    int i;

    i830_dmi_scan();

    if (0)
	i830_dmi_dump();

    while (p && p->chipType != 0) {
	if (DEVICE_ID(intel->PciInfo) == p->chipType &&
	    (SUBVENDOR_ID(intel->PciInfo) == p->subsysVendor ||
	     p->subsysVendor == SUBSYS_ANY) &&
	    (SUBSYS_ID(intel->PciInfo) == p->subsysCard ||
	     p->subsysCard == SUBSYS_ANY))
	    p->hook(intel);
	++p;
    }

    for (i = 0; i < dmi_data_max; i++)
	if (i830_dmi_data[i])
	    free(i830_dmi_data[i]);
}