Rev 5354 | Rev 6660 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5354 | Rev 6084 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | #define SLAVE_ADDR1 0x70 |
34 | #define SLAVE_ADDR1 0x70 |
35 | #define SLAVE_ADDR2 0x72 |
35 | #define SLAVE_ADDR2 0x72 |
Line 36... | Line 36... | ||
36 | 36 | ||
Line 37... | Line 37... | ||
37 | static int panel_type; |
37 | static int panel_type; |
38 | 38 | ||
39 | static void * |
39 | static const void * |
- | 40 | find_section(const void *_bdb, int section_id) |
|
40 | find_section(struct bdb_header *bdb, int section_id) |
41 | { |
41 | { |
42 | const struct bdb_header *bdb = _bdb; |
42 | u8 *base = (u8 *)bdb; |
43 | const u8 *base = _bdb; |
43 | int index = 0; |
44 | int index = 0; |
Line 44... | Line 45... | ||
44 | u16 total, current_size; |
45 | u32 total, current_size; |
45 | u8 current_id; |
46 | u8 current_id; |
46 | 47 | ||
Line 51... | Line 52... | ||
51 | /* walk the sections looking for section_id */ |
52 | /* walk the sections looking for section_id */ |
52 | while (index + 3 < total) { |
53 | while (index + 3 < total) { |
53 | current_id = *(base + index); |
54 | current_id = *(base + index); |
54 | index++; |
55 | index++; |
Line 55... | Line 56... | ||
55 | 56 | ||
56 | current_size = *((u16 *)(base + index)); |
57 | current_size = *((const u16 *)(base + index)); |
Line -... | Line 58... | ||
- | 58 | index += 2; |
|
- | 59 | ||
- | 60 | /* The MIPI Sequence Block v3+ has a separate size field. */ |
|
- | 61 | if (current_id == BDB_MIPI_SEQUENCE && *(base + index) >= 3) |
|
57 | index += 2; |
62 | current_size = *((const u32 *)(base + index + 1)); |
58 | 63 | ||
Line 59... | Line 64... | ||
59 | if (index + current_size > total) |
64 | if (index + current_size > total) |
60 | return NULL; |
65 | return NULL; |
Line 67... | Line 72... | ||
67 | 72 | ||
68 | return NULL; |
73 | return NULL; |
Line 69... | Line 74... | ||
69 | } |
74 | } |
70 | 75 | ||
71 | static u16 |
76 | static u16 |
72 | get_blocksize(void *p) |
77 | get_blocksize(const void *p) |
Line 73... | Line 78... | ||
73 | { |
78 | { |
74 | u16 *block_ptr, block_size; |
79 | u16 *block_ptr, block_size; |
Line 119... | Line 124... | ||
119 | panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1; |
124 | panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1; |
Line 120... | Line 125... | ||
120 | 125 | ||
121 | drm_mode_set_name(panel_fixed_mode); |
126 | drm_mode_set_name(panel_fixed_mode); |
Line 122... | Line -... | ||
122 | } |
- | |
123 | - | ||
124 | static bool |
- | |
125 | lvds_dvo_timing_equal_size(const struct lvds_dvo_timing *a, |
- | |
126 | const struct lvds_dvo_timing *b) |
- | |
127 | { |
- | |
128 | if (a->hactive_hi != b->hactive_hi || |
- | |
129 | a->hactive_lo != b->hactive_lo) |
- | |
130 | return false; |
- | |
131 | - | ||
132 | if (a->hsync_off_hi != b->hsync_off_hi || |
- | |
133 | a->hsync_off_lo != b->hsync_off_lo) |
- | |
134 | return false; |
- | |
135 | - | ||
136 | if (a->hsync_pulse_width != b->hsync_pulse_width) |
- | |
137 | return false; |
- | |
138 | - | ||
139 | if (a->hblank_hi != b->hblank_hi || |
- | |
140 | a->hblank_lo != b->hblank_lo) |
- | |
141 | return false; |
- | |
142 | - | ||
143 | if (a->vactive_hi != b->vactive_hi || |
- | |
144 | a->vactive_lo != b->vactive_lo) |
- | |
145 | return false; |
- | |
146 | - | ||
147 | if (a->vsync_off != b->vsync_off) |
- | |
148 | return false; |
- | |
149 | - | ||
150 | if (a->vsync_pulse_width != b->vsync_pulse_width) |
- | |
151 | return false; |
- | |
152 | - | ||
153 | if (a->vblank_hi != b->vblank_hi || |
- | |
154 | a->vblank_lo != b->vblank_lo) |
- | |
155 | return false; |
- | |
156 | - | ||
157 | return true; |
- | |
158 | } |
127 | } |
159 | 128 | ||
160 | static const struct lvds_dvo_timing * |
129 | static const struct lvds_dvo_timing * |
161 | get_lvds_dvo_timing(const struct bdb_lvds_lfp_data *lvds_lfp_data, |
130 | get_lvds_dvo_timing(const struct bdb_lvds_lfp_data *lvds_lfp_data, |
162 | const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs, |
131 | const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs, |
Line 202... | Line 171... | ||
202 | } |
171 | } |
Line 203... | Line 172... | ||
203 | 172 | ||
204 | /* Try to find integrated panel data */ |
173 | /* Try to find integrated panel data */ |
205 | static void |
174 | static void |
206 | parse_lfp_panel_data(struct drm_i915_private *dev_priv, |
175 | parse_lfp_panel_data(struct drm_i915_private *dev_priv, |
207 | struct bdb_header *bdb) |
176 | const struct bdb_header *bdb) |
208 | { |
177 | { |
209 | const struct bdb_lvds_options *lvds_options; |
178 | const struct bdb_lvds_options *lvds_options; |
210 | const struct bdb_lvds_lfp_data *lvds_lfp_data; |
179 | const struct bdb_lvds_lfp_data *lvds_lfp_data; |
211 | const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs; |
180 | const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs; |
212 | const struct lvds_dvo_timing *panel_dvo_timing; |
181 | const struct lvds_dvo_timing *panel_dvo_timing; |
213 | const struct lvds_fp_timing *fp_timing; |
182 | const struct lvds_fp_timing *fp_timing; |
214 | struct drm_display_mode *panel_fixed_mode; |
183 | struct drm_display_mode *panel_fixed_mode; |
Line 215... | Line 184... | ||
215 | int i, downclock, drrs_mode; |
184 | int drrs_mode; |
216 | 185 | ||
217 | lvds_options = find_section(bdb, BDB_LVDS_OPTIONS); |
186 | lvds_options = find_section(bdb, BDB_LVDS_OPTIONS); |
Line 269... | Line 238... | ||
269 | dev_priv->vbt.lfp_lvds_vbt_mode = panel_fixed_mode; |
238 | dev_priv->vbt.lfp_lvds_vbt_mode = panel_fixed_mode; |
Line 270... | Line 239... | ||
270 | 239 | ||
271 | DRM_DEBUG_KMS("Found panel mode in BIOS VBT tables:\n"); |
240 | DRM_DEBUG_KMS("Found panel mode in BIOS VBT tables:\n"); |
Line 272... | Line -... | ||
272 | drm_mode_debug_printmodeline(panel_fixed_mode); |
- | |
273 | - | ||
274 | /* |
- | |
275 | * Iterate over the LVDS panel timing info to find the lowest clock |
- | |
276 | * for the native resolution. |
- | |
277 | */ |
- | |
278 | downclock = panel_dvo_timing->clock; |
- | |
279 | for (i = 0; i < 16; i++) { |
- | |
280 | const struct lvds_dvo_timing *dvo_timing; |
- | |
281 | - | ||
282 | dvo_timing = get_lvds_dvo_timing(lvds_lfp_data, |
- | |
283 | lvds_lfp_data_ptrs, |
- | |
284 | i); |
- | |
285 | if (lvds_dvo_timing_equal_size(dvo_timing, panel_dvo_timing) && |
- | |
286 | dvo_timing->clock < downclock) |
- | |
287 | downclock = dvo_timing->clock; |
- | |
288 | } |
- | |
289 | - | ||
290 | if (downclock < panel_dvo_timing->clock && i915.lvds_downclock) { |
- | |
291 | dev_priv->lvds_downclock_avail = 1; |
- | |
292 | dev_priv->lvds_downclock = downclock * 10; |
- | |
293 | DRM_DEBUG_KMS("LVDS downclock is found in VBT. " |
- | |
294 | "Normal Clock %dKHz, downclock %dKHz\n", |
- | |
295 | panel_fixed_mode->clock, 10*downclock); |
- | |
296 | } |
241 | drm_mode_debug_printmodeline(panel_fixed_mode); |
297 | 242 | ||
298 | fp_timing = get_lvds_fp_timing(bdb, lvds_lfp_data, |
243 | fp_timing = get_lvds_fp_timing(bdb, lvds_lfp_data, |
299 | lvds_lfp_data_ptrs, |
244 | lvds_lfp_data_ptrs, |
300 | lvds_options->panel_type); |
245 | lvds_options->panel_type); |
Line 308... | Line 253... | ||
308 | } |
253 | } |
309 | } |
254 | } |
310 | } |
255 | } |
Line 311... | Line 256... | ||
311 | 256 | ||
312 | static void |
257 | static void |
- | 258 | parse_lfp_backlight(struct drm_i915_private *dev_priv, |
|
313 | parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb) |
259 | const struct bdb_header *bdb) |
314 | { |
260 | { |
315 | const struct bdb_lfp_backlight_data *backlight_data; |
261 | const struct bdb_lfp_backlight_data *backlight_data; |
Line 316... | Line 262... | ||
316 | const struct bdb_lfp_backlight_data_entry *entry; |
262 | const struct bdb_lfp_backlight_data_entry *entry; |
Line 346... | Line 292... | ||
346 | } |
292 | } |
Line 347... | Line 293... | ||
347 | 293 | ||
348 | /* Try to find sdvo panel data */ |
294 | /* Try to find sdvo panel data */ |
349 | static void |
295 | static void |
350 | parse_sdvo_panel_data(struct drm_i915_private *dev_priv, |
296 | parse_sdvo_panel_data(struct drm_i915_private *dev_priv, |
351 | struct bdb_header *bdb) |
297 | const struct bdb_header *bdb) |
352 | { |
298 | { |
353 | struct lvds_dvo_timing *dvo_timing; |
299 | const struct lvds_dvo_timing *dvo_timing; |
354 | struct drm_display_mode *panel_fixed_mode; |
300 | struct drm_display_mode *panel_fixed_mode; |
Line 355... | Line 301... | ||
355 | int index; |
301 | int index; |
356 | 302 | ||
357 | index = i915.vbt_sdvo_panel_type; |
303 | index = i915.vbt_sdvo_panel_type; |
358 | if (index == -2) { |
304 | if (index == -2) { |
359 | DRM_DEBUG_KMS("Ignore SDVO panel mode from BIOS VBT tables.\n"); |
305 | DRM_DEBUG_KMS("Ignore SDVO panel mode from BIOS VBT tables.\n"); |
Line 360... | Line 306... | ||
360 | return; |
306 | return; |
361 | } |
307 | } |
Line 362... | Line 308... | ||
362 | 308 | ||
363 | if (index == -1) { |
309 | if (index == -1) { |
364 | struct bdb_sdvo_lvds_options *sdvo_lvds_options; |
310 | const struct bdb_sdvo_lvds_options *sdvo_lvds_options; |
Line 400... | Line 346... | ||
400 | } |
346 | } |
401 | } |
347 | } |
Line 402... | Line 348... | ||
402 | 348 | ||
403 | static void |
349 | static void |
404 | parse_general_features(struct drm_i915_private *dev_priv, |
350 | parse_general_features(struct drm_i915_private *dev_priv, |
405 | struct bdb_header *bdb) |
351 | const struct bdb_header *bdb) |
406 | { |
352 | { |
407 | struct drm_device *dev = dev_priv->dev; |
353 | struct drm_device *dev = dev_priv->dev; |
Line 408... | Line 354... | ||
408 | struct bdb_general_features *general; |
354 | const struct bdb_general_features *general; |
409 | 355 | ||
410 | general = find_section(bdb, BDB_GENERAL_FEATURES); |
356 | general = find_section(bdb, BDB_GENERAL_FEATURES); |
411 | if (general) { |
357 | if (general) { |
Line 426... | Line 372... | ||
426 | } |
372 | } |
427 | } |
373 | } |
Line 428... | Line 374... | ||
428 | 374 | ||
429 | static void |
375 | static void |
430 | parse_general_definitions(struct drm_i915_private *dev_priv, |
376 | parse_general_definitions(struct drm_i915_private *dev_priv, |
431 | struct bdb_header *bdb) |
377 | const struct bdb_header *bdb) |
432 | { |
378 | { |
Line 433... | Line 379... | ||
433 | struct bdb_general_definitions *general; |
379 | const struct bdb_general_definitions *general; |
434 | 380 | ||
435 | general = find_section(bdb, BDB_GENERAL_DEFINITIONS); |
381 | general = find_section(bdb, BDB_GENERAL_DEFINITIONS); |
436 | if (general) { |
382 | if (general) { |
437 | u16 block_size = get_blocksize(general); |
383 | u16 block_size = get_blocksize(general); |
438 | if (block_size >= sizeof(*general)) { |
384 | if (block_size >= sizeof(*general)) { |
439 | int bus_pin = general->crt_ddc_gmbus_pin; |
385 | int bus_pin = general->crt_ddc_gmbus_pin; |
440 | DRM_DEBUG_KMS("crt_ddc_bus_pin: %d\n", bus_pin); |
386 | DRM_DEBUG_KMS("crt_ddc_bus_pin: %d\n", bus_pin); |
441 | if (intel_gmbus_is_port_valid(bus_pin)) |
387 | if (intel_gmbus_is_valid_pin(dev_priv, bus_pin)) |
442 | dev_priv->vbt.crt_ddc_pin = bus_pin; |
388 | dev_priv->vbt.crt_ddc_pin = bus_pin; |
443 | } else { |
389 | } else { |
444 | DRM_DEBUG_KMS("BDB_GD too small (%d). Invalid.\n", |
390 | DRM_DEBUG_KMS("BDB_GD too small (%d). Invalid.\n", |
445 | block_size); |
391 | block_size); |
446 | } |
392 | } |
Line -... | Line 393... | ||
- | 393 | } |
|
- | 394 | } |
|
- | 395 | ||
- | 396 | static const union child_device_config * |
|
- | 397 | child_device_ptr(const struct bdb_general_definitions *p_defs, int i) |
|
- | 398 | { |
|
447 | } |
399 | return (const void *) &p_defs->devices[i * p_defs->child_dev_size]; |
448 | } |
400 | } |
449 | 401 | ||
450 | static void |
402 | static void |
451 | parse_sdvo_device_mapping(struct drm_i915_private *dev_priv, |
403 | parse_sdvo_device_mapping(struct drm_i915_private *dev_priv, |
452 | struct bdb_header *bdb) |
404 | const struct bdb_header *bdb) |
453 | { |
405 | { |
454 | struct sdvo_device_mapping *p_mapping; |
406 | struct sdvo_device_mapping *p_mapping; |
455 | struct bdb_general_definitions *p_defs; |
407 | const struct bdb_general_definitions *p_defs; |
Line 456... | Line 408... | ||
456 | union child_device_config *p_child; |
408 | const struct old_child_dev_config *child; /* legacy */ |
457 | int i, child_device_num, count; |
409 | int i, child_device_num, count; |
458 | u16 block_size; |
410 | u16 block_size; |
459 | 411 | ||
460 | p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS); |
412 | p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS); |
461 | if (!p_defs) { |
- | |
- | 413 | if (!p_defs) { |
|
- | 414 | DRM_DEBUG_KMS("No general definition block is found, unable to construct sdvo mapping.\n"); |
|
462 | DRM_DEBUG_KMS("No general definition block is found, unable to construct sdvo mapping.\n"); |
415 | return; |
463 | return; |
416 | } |
464 | } |
417 | |
465 | /* judge whether the size of child device meets the requirements. |
418 | /* |
466 | * If the child device size obtained from general definition block |
419 | * Only parse SDVO mappings when the general definitions block child |
467 | * is different with sizeof(struct child_device_config), skip the |
- | |
468 | * parsing of sdvo device info |
420 | * device size matches that of the *legacy* child device config |
469 | */ |
421 | * struct. Thus, SDVO mapping will be skipped for newer VBT. |
470 | if (p_defs->child_dev_size != sizeof(*p_child)) { |
422 | */ |
471 | /* different child dev size . Ignore it */ |
423 | if (p_defs->child_dev_size != sizeof(*child)) { |
472 | DRM_DEBUG_KMS("different child size is found. Invalid.\n"); |
424 | DRM_DEBUG_KMS("Unsupported child device size for SDVO mapping.\n"); |
473 | return; |
425 | return; |
474 | } |
426 | } |
475 | /* get the block size of general definitions */ |
427 | /* get the block size of general definitions */ |
476 | block_size = get_blocksize(p_defs); |
428 | block_size = get_blocksize(p_defs); |
477 | /* get the number of child device */ |
429 | /* get the number of child device */ |
478 | child_device_num = (block_size - sizeof(*p_defs)) / |
430 | child_device_num = (block_size - sizeof(*p_defs)) / |
479 | sizeof(*p_child); |
431 | p_defs->child_dev_size; |
480 | count = 0; |
432 | count = 0; |
481 | for (i = 0; i < child_device_num; i++) { |
433 | for (i = 0; i < child_device_num; i++) { |
482 | p_child = &(p_defs->devices[i]); |
434 | child = &child_device_ptr(p_defs, i)->old; |
483 | if (!p_child->old.device_type) { |
435 | if (!child->device_type) { |
484 | /* skip the device block if device type is invalid */ |
436 | /* skip the device block if device type is invalid */ |
485 | continue; |
437 | continue; |
486 | } |
438 | } |
487 | if (p_child->old.slave_addr != SLAVE_ADDR1 && |
439 | if (child->slave_addr != SLAVE_ADDR1 && |
488 | p_child->old.slave_addr != SLAVE_ADDR2) { |
440 | child->slave_addr != SLAVE_ADDR2) { |
489 | /* |
441 | /* |
490 | * If the slave address is neither 0x70 nor 0x72, |
442 | * If the slave address is neither 0x70 nor 0x72, |
491 | * it is not a SDVO device. Skip it. |
443 | * it is not a SDVO device. Skip it. |
492 | */ |
444 | */ |
493 | continue; |
445 | continue; |
494 | } |
446 | } |
495 | if (p_child->old.dvo_port != DEVICE_PORT_DVOB && |
447 | if (child->dvo_port != DEVICE_PORT_DVOB && |
496 | p_child->old.dvo_port != DEVICE_PORT_DVOC) { |
448 | child->dvo_port != DEVICE_PORT_DVOC) { |
497 | /* skip the incorrect SDVO port */ |
449 | /* skip the incorrect SDVO port */ |
498 | DRM_DEBUG_KMS("Incorrect SDVO port. Skip it\n"); |
450 | DRM_DEBUG_KMS("Incorrect SDVO port. Skip it\n"); |
499 | continue; |
451 | continue; |
500 | } |
452 | } |
501 | DRM_DEBUG_KMS("the SDVO device with slave addr %2x is found on" |
453 | DRM_DEBUG_KMS("the SDVO device with slave addr %2x is found on" |
502 | " %s port\n", |
454 | " %s port\n", |
503 | p_child->old.slave_addr, |
455 | child->slave_addr, |
504 | (p_child->old.dvo_port == DEVICE_PORT_DVOB) ? |
456 | (child->dvo_port == DEVICE_PORT_DVOB) ? |
505 | "SDVOB" : "SDVOC"); |
457 | "SDVOB" : "SDVOC"); |
506 | p_mapping = &(dev_priv->sdvo_mappings[p_child->old.dvo_port - 1]); |
458 | p_mapping = &(dev_priv->sdvo_mappings[child->dvo_port - 1]); |
507 | if (!p_mapping->initialized) { |
459 | if (!p_mapping->initialized) { |
508 | p_mapping->dvo_port = p_child->old.dvo_port; |
460 | p_mapping->dvo_port = child->dvo_port; |
509 | p_mapping->slave_addr = p_child->old.slave_addr; |
461 | p_mapping->slave_addr = child->slave_addr; |
510 | p_mapping->dvo_wiring = p_child->old.dvo_wiring; |
462 | p_mapping->dvo_wiring = child->dvo_wiring; |
511 | p_mapping->ddc_pin = p_child->old.ddc_pin; |
463 | p_mapping->ddc_pin = child->ddc_pin; |
512 | p_mapping->i2c_pin = p_child->old.i2c_pin; |
464 | p_mapping->i2c_pin = child->i2c_pin; |
513 | p_mapping->initialized = 1; |
465 | p_mapping->initialized = 1; |
Line 519... | Line 471... | ||
519 | p_mapping->i2c_pin); |
471 | p_mapping->i2c_pin); |
520 | } else { |
472 | } else { |
521 | DRM_DEBUG_KMS("Maybe one SDVO port is shared by " |
473 | DRM_DEBUG_KMS("Maybe one SDVO port is shared by " |
522 | "two SDVO device.\n"); |
474 | "two SDVO device.\n"); |
523 | } |
475 | } |
524 | if (p_child->old.slave2_addr) { |
476 | if (child->slave2_addr) { |
525 | /* Maybe this is a SDVO device with multiple inputs */ |
477 | /* Maybe this is a SDVO device with multiple inputs */ |
526 | /* And the mapping info is not added */ |
478 | /* And the mapping info is not added */ |
527 | DRM_DEBUG_KMS("there exists the slave2_addr. Maybe this" |
479 | DRM_DEBUG_KMS("there exists the slave2_addr. Maybe this" |
528 | " is a SDVO device with multiple inputs.\n"); |
480 | " is a SDVO device with multiple inputs.\n"); |
529 | } |
481 | } |
Line 537... | Line 489... | ||
537 | return; |
489 | return; |
538 | } |
490 | } |
Line 539... | Line 491... | ||
539 | 491 | ||
540 | static void |
492 | static void |
541 | parse_driver_features(struct drm_i915_private *dev_priv, |
493 | parse_driver_features(struct drm_i915_private *dev_priv, |
542 | struct bdb_header *bdb) |
494 | const struct bdb_header *bdb) |
543 | { |
495 | { |
Line 544... | Line 496... | ||
544 | struct bdb_driver_features *driver; |
496 | const struct bdb_driver_features *driver; |
545 | 497 | ||
546 | driver = find_section(bdb, BDB_DRIVER_FEATURES); |
498 | driver = find_section(bdb, BDB_DRIVER_FEATURES); |
Line 563... | Line 515... | ||
563 | if (!driver->drrs_enabled) |
515 | if (!driver->drrs_enabled) |
564 | dev_priv->vbt.drrs_type = DRRS_NOT_SUPPORTED; |
516 | dev_priv->vbt.drrs_type = DRRS_NOT_SUPPORTED; |
565 | } |
517 | } |
Line 566... | Line 518... | ||
566 | 518 | ||
567 | static void |
519 | static void |
568 | parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb) |
520 | parse_edp(struct drm_i915_private *dev_priv, const struct bdb_header *bdb) |
569 | { |
521 | { |
570 | struct bdb_edp *edp; |
522 | const struct bdb_edp *edp; |
571 | struct edp_power_seq *edp_pps; |
523 | const struct edp_power_seq *edp_pps; |
Line 572... | Line 524... | ||
572 | struct edp_link_params *edp_link_params; |
524 | const struct edp_link_params *edp_link_params; |
573 | 525 | ||
574 | edp = find_section(bdb, BDB_EDP); |
526 | edp = find_section(bdb, BDB_EDP); |
575 | if (!edp) { |
527 | if (!edp) { |
Line 660... | Line 612... | ||
660 | default: |
612 | default: |
661 | DRM_DEBUG_KMS("VBT has unknown eDP voltage swing value %u\n", |
613 | DRM_DEBUG_KMS("VBT has unknown eDP voltage swing value %u\n", |
662 | edp_link_params->vswing); |
614 | edp_link_params->vswing); |
663 | break; |
615 | break; |
664 | } |
616 | } |
- | 617 | ||
- | 618 | if (bdb->version >= 173) { |
|
- | 619 | uint8_t vswing; |
|
- | 620 | ||
- | 621 | /* Don't read from VBT if module parameter has valid value*/ |
|
- | 622 | if (i915.edp_vswing) { |
|
- | 623 | dev_priv->edp_low_vswing = i915.edp_vswing == 1; |
|
- | 624 | } else { |
|
- | 625 | vswing = (edp->edp_vswing_preemph >> (panel_type * 4)) & 0xF; |
|
- | 626 | dev_priv->edp_low_vswing = vswing == 0; |
|
- | 627 | } |
|
- | 628 | } |
|
- | 629 | } |
|
- | 630 | ||
- | 631 | static void |
|
- | 632 | parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb) |
|
- | 633 | { |
|
- | 634 | const struct bdb_psr *psr; |
|
- | 635 | const struct psr_table *psr_table; |
|
- | 636 | ||
- | 637 | psr = find_section(bdb, BDB_PSR); |
|
- | 638 | if (!psr) { |
|
- | 639 | DRM_DEBUG_KMS("No PSR BDB found.\n"); |
|
- | 640 | return; |
|
- | 641 | } |
|
- | 642 | ||
- | 643 | psr_table = &psr->psr_table[panel_type]; |
|
- | 644 | ||
- | 645 | dev_priv->vbt.psr.full_link = psr_table->full_link; |
|
- | 646 | dev_priv->vbt.psr.require_aux_wakeup = psr_table->require_aux_to_wakeup; |
|
- | 647 | ||
- | 648 | /* Allowed VBT values goes from 0 to 15 */ |
|
- | 649 | dev_priv->vbt.psr.idle_frames = psr_table->idle_frames < 0 ? 0 : |
|
- | 650 | psr_table->idle_frames > 15 ? 15 : psr_table->idle_frames; |
|
- | 651 | ||
- | 652 | switch (psr_table->lines_to_wait) { |
|
- | 653 | case 0: |
|
- | 654 | dev_priv->vbt.psr.lines_to_wait = PSR_0_LINES_TO_WAIT; |
|
- | 655 | break; |
|
- | 656 | case 1: |
|
- | 657 | dev_priv->vbt.psr.lines_to_wait = PSR_1_LINE_TO_WAIT; |
|
- | 658 | break; |
|
- | 659 | case 2: |
|
- | 660 | dev_priv->vbt.psr.lines_to_wait = PSR_4_LINES_TO_WAIT; |
|
- | 661 | break; |
|
- | 662 | case 3: |
|
- | 663 | dev_priv->vbt.psr.lines_to_wait = PSR_8_LINES_TO_WAIT; |
|
- | 664 | break; |
|
- | 665 | default: |
|
- | 666 | DRM_DEBUG_KMS("VBT has unknown PSR lines to wait %u\n", |
|
- | 667 | psr_table->lines_to_wait); |
|
- | 668 | break; |
|
- | 669 | } |
|
- | 670 | ||
- | 671 | dev_priv->vbt.psr.tp1_wakeup_time = psr_table->tp1_wakeup_time; |
|
- | 672 | dev_priv->vbt.psr.tp2_tp3_wakeup_time = psr_table->tp2_tp3_wakeup_time; |
|
665 | } |
673 | } |
Line 666... | Line 674... | ||
666 | 674 | ||
667 | static u8 *goto_next_sequence(u8 *data, int *size) |
675 | static u8 *goto_next_sequence(u8 *data, int *size) |
668 | { |
676 | { |
Line 730... | Line 738... | ||
730 | *size = tmp; |
738 | *size = tmp; |
731 | return data; |
739 | return data; |
732 | } |
740 | } |
Line 733... | Line 741... | ||
733 | 741 | ||
734 | static void |
742 | static void |
735 | parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb) |
743 | parse_mipi(struct drm_i915_private *dev_priv, const struct bdb_header *bdb) |
736 | { |
744 | { |
737 | struct bdb_mipi_config *start; |
745 | const struct bdb_mipi_config *start; |
738 | struct bdb_mipi_sequence *sequence; |
746 | const struct bdb_mipi_sequence *sequence; |
739 | struct mipi_config *config; |
747 | const struct mipi_config *config; |
- | 748 | const struct mipi_pps_data *pps; |
|
740 | struct mipi_pps_data *pps; |
749 | u8 *data; |
741 | u8 *data, *seq_data; |
750 | const u8 *seq_data; |
742 | int i, panel_id, seq_size; |
751 | int i, panel_id, seq_size; |
Line 743... | Line 752... | ||
743 | u16 block_size; |
752 | u16 block_size; |
744 | 753 | ||
Line 792... | Line 801... | ||
792 | if (!sequence) { |
801 | if (!sequence) { |
793 | DRM_DEBUG_KMS("No MIPI Sequence found, parsing complete\n"); |
802 | DRM_DEBUG_KMS("No MIPI Sequence found, parsing complete\n"); |
794 | return; |
803 | return; |
795 | } |
804 | } |
Line -... | Line 805... | ||
- | 805 | ||
- | 806 | /* Fail gracefully for forward incompatible sequence block. */ |
|
- | 807 | if (sequence->version >= 3) { |
|
- | 808 | DRM_ERROR("Unable to parse MIPI Sequence Block v3+\n"); |
|
- | 809 | return; |
|
- | 810 | } |
|
796 | 811 | ||
Line 797... | Line 812... | ||
797 | DRM_DEBUG_DRIVER("Found MIPI sequence block\n"); |
812 | DRM_DEBUG_DRIVER("Found MIPI sequence block\n"); |
Line 798... | Line 813... | ||
798 | 813 | ||
Line 879... | Line 894... | ||
879 | /* error during parsing so set all pointers to null |
894 | /* error during parsing so set all pointers to null |
880 | * because of partial parsing */ |
895 | * because of partial parsing */ |
881 | memset(dev_priv->vbt.dsi.sequence, 0, sizeof(dev_priv->vbt.dsi.sequence)); |
896 | memset(dev_priv->vbt.dsi.sequence, 0, sizeof(dev_priv->vbt.dsi.sequence)); |
882 | } |
897 | } |
Line -... | Line 898... | ||
- | 898 | ||
- | 899 | static u8 translate_iboost(u8 val) |
|
- | 900 | { |
|
- | 901 | static const u8 mapping[] = { 1, 3, 7 }; /* See VBT spec */ |
|
- | 902 | ||
- | 903 | if (val >= ARRAY_SIZE(mapping)) { |
|
- | 904 | DRM_DEBUG_KMS("Unsupported I_boost value found in VBT (%d), display may not work properly\n", val); |
|
- | 905 | return 0; |
|
- | 906 | } |
|
- | 907 | return mapping[val]; |
|
- | 908 | } |
|
883 | 909 | ||
884 | static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port, |
910 | static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port, |
885 | struct bdb_header *bdb) |
911 | const struct bdb_header *bdb) |
886 | { |
912 | { |
887 | union child_device_config *it, *child = NULL; |
913 | union child_device_config *it, *child = NULL; |
888 | struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port]; |
914 | struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port]; |
889 | uint8_t hdmi_level_shift; |
915 | uint8_t hdmi_level_shift; |
890 | int i, j; |
916 | int i, j; |
891 | bool is_dvi, is_hdmi, is_dp, is_edp, is_crt; |
917 | bool is_dvi, is_hdmi, is_dp, is_edp, is_crt; |
892 | uint8_t aux_channel; |
918 | uint8_t aux_channel, ddc_pin; |
893 | /* Each DDI port can have more than one value on the "DVO Port" field, |
919 | /* Each DDI port can have more than one value on the "DVO Port" field, |
894 | * so look for all the possible values for each port and abort if more |
920 | * so look for all the possible values for each port and abort if more |
895 | * than one is found. */ |
921 | * than one is found. */ |
896 | int dvo_ports[][2] = { |
922 | int dvo_ports[][3] = { |
897 | {DVO_PORT_HDMIA, DVO_PORT_DPA}, |
923 | {DVO_PORT_HDMIA, DVO_PORT_DPA, -1}, |
898 | {DVO_PORT_HDMIB, DVO_PORT_DPB}, |
924 | {DVO_PORT_HDMIB, DVO_PORT_DPB, -1}, |
899 | {DVO_PORT_HDMIC, DVO_PORT_DPC}, |
925 | {DVO_PORT_HDMIC, DVO_PORT_DPC, -1}, |
900 | {DVO_PORT_HDMID, DVO_PORT_DPD}, |
926 | {DVO_PORT_HDMID, DVO_PORT_DPD, -1}, |
901 | {DVO_PORT_CRT, -1 /* Port E can only be DVO_PORT_CRT */ }, |
927 | {DVO_PORT_CRT, DVO_PORT_HDMIE, DVO_PORT_DPE}, |
Line 902... | Line 928... | ||
902 | }; |
928 | }; |
903 | 929 | ||
904 | /* Find the child device to use, abort if more than one found. */ |
930 | /* Find the child device to use, abort if more than one found. */ |
Line 905... | Line 931... | ||
905 | for (i = 0; i < dev_priv->vbt.child_dev_num; i++) { |
931 | for (i = 0; i < dev_priv->vbt.child_dev_num; i++) { |
906 | it = dev_priv->vbt.child_dev + i; |
932 | it = dev_priv->vbt.child_dev + i; |
907 | 933 | ||
Line 908... | Line 934... | ||
908 | for (j = 0; j < 2; j++) { |
934 | for (j = 0; j < 3; j++) { |
909 | if (dvo_ports[port][j] == -1) |
935 | if (dvo_ports[port][j] == -1) |
Line 921... | Line 947... | ||
921 | } |
947 | } |
922 | if (!child) |
948 | if (!child) |
923 | return; |
949 | return; |
Line 924... | Line 950... | ||
924 | 950 | ||
- | 951 | aux_channel = child->raw[25]; |
|
Line 925... | Line 952... | ||
925 | aux_channel = child->raw[25]; |
952 | ddc_pin = child->common.ddc_pin; |
926 | 953 | ||
927 | is_dvi = child->common.device_type & DEVICE_TYPE_TMDS_DVI_SIGNALING; |
954 | is_dvi = child->common.device_type & DEVICE_TYPE_TMDS_DVI_SIGNALING; |
928 | is_dp = child->common.device_type & DEVICE_TYPE_DISPLAYPORT_OUTPUT; |
955 | is_dp = child->common.device_type & DEVICE_TYPE_DISPLAYPORT_OUTPUT; |
Line 952... | Line 979... | ||
952 | port_name(port)); |
979 | port_name(port)); |
953 | if (is_edp && (port == PORT_B || port == PORT_C || port == PORT_E)) |
980 | if (is_edp && (port == PORT_B || port == PORT_C || port == PORT_E)) |
954 | DRM_DEBUG_KMS("Port %c is internal DP\n", port_name(port)); |
981 | DRM_DEBUG_KMS("Port %c is internal DP\n", port_name(port)); |
Line 955... | Line 982... | ||
955 | 982 | ||
- | 983 | if (is_dvi) { |
|
- | 984 | if (port == PORT_E) { |
|
- | 985 | info->alternate_ddc_pin = ddc_pin; |
|
- | 986 | /* if DDIE share ddc pin with other port, then |
|
- | 987 | * dvi/hdmi couldn't exist on the shared port. |
|
- | 988 | * Otherwise they share the same ddc bin and system |
|
- | 989 | * couldn't communicate with them seperately. */ |
|
- | 990 | if (ddc_pin == DDC_PIN_B) { |
|
- | 991 | dev_priv->vbt.ddi_port_info[PORT_B].supports_dvi = 0; |
|
- | 992 | dev_priv->vbt.ddi_port_info[PORT_B].supports_hdmi = 0; |
|
- | 993 | } else if (ddc_pin == DDC_PIN_C) { |
|
- | 994 | dev_priv->vbt.ddi_port_info[PORT_C].supports_dvi = 0; |
|
- | 995 | dev_priv->vbt.ddi_port_info[PORT_C].supports_hdmi = 0; |
|
- | 996 | } else if (ddc_pin == DDC_PIN_D) { |
|
- | 997 | dev_priv->vbt.ddi_port_info[PORT_D].supports_dvi = 0; |
|
- | 998 | dev_priv->vbt.ddi_port_info[PORT_D].supports_hdmi = 0; |
|
956 | if (is_dvi) { |
999 | } |
957 | if (child->common.ddc_pin == 0x05 && port != PORT_B) |
1000 | } else if (ddc_pin == DDC_PIN_B && port != PORT_B) |
958 | DRM_DEBUG_KMS("Unexpected DDC pin for port B\n"); |
1001 | DRM_DEBUG_KMS("Unexpected DDC pin for port B\n"); |
959 | if (child->common.ddc_pin == 0x04 && port != PORT_C) |
1002 | else if (ddc_pin == DDC_PIN_C && port != PORT_C) |
960 | DRM_DEBUG_KMS("Unexpected DDC pin for port C\n"); |
1003 | DRM_DEBUG_KMS("Unexpected DDC pin for port C\n"); |
961 | if (child->common.ddc_pin == 0x06 && port != PORT_D) |
1004 | else if (ddc_pin == DDC_PIN_D && port != PORT_D) |
962 | DRM_DEBUG_KMS("Unexpected DDC pin for port D\n"); |
1005 | DRM_DEBUG_KMS("Unexpected DDC pin for port D\n"); |
Line 963... | Line 1006... | ||
963 | } |
1006 | } |
- | 1007 | ||
- | 1008 | if (is_dp) { |
|
- | 1009 | if (port == PORT_E) { |
|
- | 1010 | info->alternate_aux_channel = aux_channel; |
|
- | 1011 | /* if DDIE share aux channel with other port, then |
|
- | 1012 | * DP couldn't exist on the shared port. Otherwise |
|
- | 1013 | * they share the same aux channel and system |
|
- | 1014 | * couldn't communicate with them seperately. */ |
|
- | 1015 | if (aux_channel == DP_AUX_A) |
|
- | 1016 | dev_priv->vbt.ddi_port_info[PORT_A].supports_dp = 0; |
|
- | 1017 | else if (aux_channel == DP_AUX_B) |
|
- | 1018 | dev_priv->vbt.ddi_port_info[PORT_B].supports_dp = 0; |
|
- | 1019 | else if (aux_channel == DP_AUX_C) |
|
- | 1020 | dev_priv->vbt.ddi_port_info[PORT_C].supports_dp = 0; |
|
- | 1021 | else if (aux_channel == DP_AUX_D) |
|
964 | 1022 | dev_priv->vbt.ddi_port_info[PORT_D].supports_dp = 0; |
|
965 | if (is_dp) { |
1023 | } |
966 | if (aux_channel == 0x40 && port != PORT_A) |
1024 | else if (aux_channel == DP_AUX_A && port != PORT_A) |
967 | DRM_DEBUG_KMS("Unexpected AUX channel for port A\n"); |
1025 | DRM_DEBUG_KMS("Unexpected AUX channel for port A\n"); |
968 | if (aux_channel == 0x10 && port != PORT_B) |
1026 | else if (aux_channel == DP_AUX_B && port != PORT_B) |
969 | DRM_DEBUG_KMS("Unexpected AUX channel for port B\n"); |
1027 | DRM_DEBUG_KMS("Unexpected AUX channel for port B\n"); |
970 | if (aux_channel == 0x20 && port != PORT_C) |
1028 | else if (aux_channel == DP_AUX_C && port != PORT_C) |
971 | DRM_DEBUG_KMS("Unexpected AUX channel for port C\n"); |
1029 | DRM_DEBUG_KMS("Unexpected AUX channel for port C\n"); |
972 | if (aux_channel == 0x30 && port != PORT_D) |
1030 | else if (aux_channel == DP_AUX_D && port != PORT_D) |
Line 973... | Line 1031... | ||
973 | DRM_DEBUG_KMS("Unexpected AUX channel for port D\n"); |
1031 | DRM_DEBUG_KMS("Unexpected AUX channel for port D\n"); |
974 | } |
1032 | } |
Line 979... | Line 1037... | ||
979 | DRM_DEBUG_KMS("VBT HDMI level shift for port %c: %d\n", |
1037 | DRM_DEBUG_KMS("VBT HDMI level shift for port %c: %d\n", |
980 | port_name(port), |
1038 | port_name(port), |
981 | hdmi_level_shift); |
1039 | hdmi_level_shift); |
982 | info->hdmi_level_shift = hdmi_level_shift; |
1040 | info->hdmi_level_shift = hdmi_level_shift; |
983 | } |
1041 | } |
- | 1042 | ||
- | 1043 | /* Parse the I_boost config for SKL and above */ |
|
- | 1044 | if (bdb->version >= 196 && (child->common.flags_1 & IBOOST_ENABLE)) { |
|
- | 1045 | info->dp_boost_level = translate_iboost(child->common.iboost_level & 0xF); |
|
- | 1046 | DRM_DEBUG_KMS("VBT (e)DP boost level for port %c: %d\n", |
|
- | 1047 | port_name(port), info->dp_boost_level); |
|
- | 1048 | info->hdmi_boost_level = translate_iboost(child->common.iboost_level >> 4); |
|
- | 1049 | DRM_DEBUG_KMS("VBT HDMI boost level for port %c: %d\n", |
|
- | 1050 | port_name(port), info->hdmi_boost_level); |
|
- | 1051 | } |
|
984 | } |
1052 | } |
Line 985... | Line 1053... | ||
985 | 1053 | ||
986 | static void parse_ddi_ports(struct drm_i915_private *dev_priv, |
1054 | static void parse_ddi_ports(struct drm_i915_private *dev_priv, |
987 | struct bdb_header *bdb) |
1055 | const struct bdb_header *bdb) |
988 | { |
1056 | { |
989 | struct drm_device *dev = dev_priv->dev; |
1057 | struct drm_device *dev = dev_priv->dev; |
Line 990... | Line 1058... | ||
990 | enum port port; |
1058 | enum port port; |
Line 1002... | Line 1070... | ||
1002 | parse_ddi_port(dev_priv, port, bdb); |
1070 | parse_ddi_port(dev_priv, port, bdb); |
1003 | } |
1071 | } |
Line 1004... | Line 1072... | ||
1004 | 1072 | ||
1005 | static void |
1073 | static void |
1006 | parse_device_mapping(struct drm_i915_private *dev_priv, |
1074 | parse_device_mapping(struct drm_i915_private *dev_priv, |
1007 | struct bdb_header *bdb) |
1075 | const struct bdb_header *bdb) |
1008 | { |
1076 | { |
- | 1077 | const struct bdb_general_definitions *p_defs; |
|
1009 | struct bdb_general_definitions *p_defs; |
1078 | const union child_device_config *p_child; |
1010 | union child_device_config *p_child, *child_dev_ptr; |
1079 | union child_device_config *child_dev_ptr; |
- | 1080 | int i, child_device_num, count; |
|
1011 | int i, child_device_num, count; |
1081 | u8 expected_size; |
Line 1012... | Line 1082... | ||
1012 | u16 block_size; |
1082 | u16 block_size; |
1013 | 1083 | ||
1014 | p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS); |
1084 | p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS); |
1015 | if (!p_defs) { |
1085 | if (!p_defs) { |
1016 | DRM_DEBUG_KMS("No general definition block is found, no devices defined.\n"); |
1086 | DRM_DEBUG_KMS("No general definition block is found, no devices defined.\n"); |
- | 1087 | return; |
|
1017 | return; |
1088 | } |
1018 | } |
1089 | if (bdb->version < 195) { |
- | 1090 | expected_size = sizeof(struct old_child_dev_config); |
|
- | 1091 | } else if (bdb->version == 195) { |
|
- | 1092 | expected_size = 37; |
|
- | 1093 | } else if (bdb->version <= 197) { |
|
- | 1094 | expected_size = 38; |
|
1019 | /* judge whether the size of child device meets the requirements. |
1095 | } else { |
- | 1096 | expected_size = 38; |
|
1020 | * If the child device size obtained from general definition block |
1097 | BUILD_BUG_ON(sizeof(*p_child) < 38); |
1021 | * is different with sizeof(struct child_device_config), skip the |
1098 | DRM_DEBUG_DRIVER("Expected child device config size for VBT version %u not known; assuming %u\n", |
- | 1099 | bdb->version, expected_size); |
|
- | 1100 | } |
|
1022 | * parsing of sdvo device info |
1101 | |
1023 | */ |
1102 | /* The legacy sized child device config is the minimum we need. */ |
1024 | if (p_defs->child_dev_size != sizeof(*p_child)) { |
1103 | if (p_defs->child_dev_size < sizeof(struct old_child_dev_config)) { |
1025 | /* different child dev size . Ignore it */ |
1104 | DRM_ERROR("Child device config size %u is too small.\n", |
1026 | DRM_DEBUG_KMS("different child size is found. Invalid.\n"); |
1105 | p_defs->child_dev_size); |
- | 1106 | return; |
|
- | 1107 | } |
|
- | 1108 | ||
- | 1109 | /* Flag an error for unexpected size, but continue anyway. */ |
|
- | 1110 | if (p_defs->child_dev_size != expected_size) |
|
- | 1111 | DRM_ERROR("Unexpected child device config size %u (expected %u for VBT version %u)\n", |
|
1027 | return; |
1112 | p_defs->child_dev_size, expected_size, bdb->version); |
1028 | } |
1113 | |
1029 | /* get the block size of general definitions */ |
1114 | /* get the block size of general definitions */ |
1030 | block_size = get_blocksize(p_defs); |
1115 | block_size = get_blocksize(p_defs); |
1031 | /* get the number of child device */ |
1116 | /* get the number of child device */ |
1032 | child_device_num = (block_size - sizeof(*p_defs)) / |
1117 | child_device_num = (block_size - sizeof(*p_defs)) / |
1033 | sizeof(*p_child); |
1118 | p_defs->child_dev_size; |
1034 | count = 0; |
1119 | count = 0; |
1035 | /* get the number of child device that is present */ |
1120 | /* get the number of child device that is present */ |
1036 | for (i = 0; i < child_device_num; i++) { |
1121 | for (i = 0; i < child_device_num; i++) { |
1037 | p_child = &(p_defs->devices[i]); |
1122 | p_child = child_device_ptr(p_defs, i); |
1038 | if (!p_child->common.device_type) { |
1123 | if (!p_child->common.device_type) { |
1039 | /* skip the device block if device type is invalid */ |
1124 | /* skip the device block if device type is invalid */ |
1040 | continue; |
1125 | continue; |
Line 1052... | Line 1137... | ||
1052 | } |
1137 | } |
Line 1053... | Line 1138... | ||
1053 | 1138 | ||
1054 | dev_priv->vbt.child_dev_num = count; |
1139 | dev_priv->vbt.child_dev_num = count; |
1055 | count = 0; |
1140 | count = 0; |
1056 | for (i = 0; i < child_device_num; i++) { |
1141 | for (i = 0; i < child_device_num; i++) { |
1057 | p_child = &(p_defs->devices[i]); |
1142 | p_child = child_device_ptr(p_defs, i); |
1058 | if (!p_child->common.device_type) { |
1143 | if (!p_child->common.device_type) { |
1059 | /* skip the device block if device type is invalid */ |
1144 | /* skip the device block if device type is invalid */ |
1060 | continue; |
1145 | continue; |
Line 1068... | Line 1153... | ||
1068 | dev_priv->vbt.dsi.port = p_child->common.dvo_port; |
1153 | dev_priv->vbt.dsi.port = p_child->common.dvo_port; |
1069 | } |
1154 | } |
Line 1070... | Line 1155... | ||
1070 | 1155 | ||
1071 | child_dev_ptr = dev_priv->vbt.child_dev + count; |
1156 | child_dev_ptr = dev_priv->vbt.child_dev + count; |
- | 1157 | count++; |
|
- | 1158 | ||
- | 1159 | /* |
|
- | 1160 | * Copy as much as we know (sizeof) and is available |
|
- | 1161 | * (child_dev_size) of the child device. Accessing the data must |
|
- | 1162 | * depend on VBT version. |
|
1072 | count++; |
1163 | */ |
1073 | memcpy((void *)child_dev_ptr, (void *)p_child, |
1164 | memcpy(child_dev_ptr, p_child, |
1074 | sizeof(*p_child)); |
1165 | min_t(size_t, p_defs->child_dev_size, sizeof(*p_child))); |
1075 | } |
1166 | } |
1076 | return; |
1167 | return; |
Line 1077... | Line 1168... | ||
1077 | } |
1168 | } |
1078 | 1169 | ||
1079 | static void |
1170 | static void |
1080 | init_vbt_defaults(struct drm_i915_private *dev_priv) |
1171 | init_vbt_defaults(struct drm_i915_private *dev_priv) |
1081 | { |
1172 | { |
Line 1082... | Line 1173... | ||
1082 | struct drm_device *dev = dev_priv->dev; |
1173 | struct drm_device *dev = dev_priv->dev; |
Line 1083... | Line 1174... | ||
1083 | enum port port; |
1174 | enum port port; |
1084 | 1175 | ||
Line 1085... | Line 1176... | ||
1085 | dev_priv->vbt.crt_ddc_pin = GMBUS_PORT_VGADDC; |
1176 | dev_priv->vbt.crt_ddc_pin = GMBUS_PIN_VGADDC; |
Line 1138... | Line 1229... | ||
1138 | }, |
1229 | }, |
1139 | }, |
1230 | }, |
1140 | { } |
1231 | { } |
1141 | }; |
1232 | }; |
Line 1142... | Line 1233... | ||
1142 | 1233 | ||
- | 1234 | static const struct bdb_header *validate_vbt(const void *base, |
|
1143 | static struct bdb_header *validate_vbt(char *base, size_t size, |
1235 | size_t size, |
1144 | struct vbt_header *vbt, |
1236 | const void *_vbt, |
1145 | const char *source) |
1237 | const char *source) |
1146 | { |
1238 | { |
1147 | size_t offset; |
1239 | size_t offset = _vbt - base; |
1148 | struct bdb_header *bdb; |
- | |
1149 | 1240 | const struct vbt_header *vbt = _vbt; |
|
1150 | if (vbt == NULL) { |
- | |
1151 | DRM_DEBUG_DRIVER("VBT signature missing\n"); |
- | |
1152 | return NULL; |
- | |
Line 1153... | Line -... | ||
1153 | } |
- | |
1154 | 1241 | const struct bdb_header *bdb; |
|
1155 | offset = (char *)vbt - base; |
1242 | |
1156 | if (offset + sizeof(struct vbt_header) > size) { |
1243 | if (offset + sizeof(struct vbt_header) > size) { |
1157 | DRM_DEBUG_DRIVER("VBT header incomplete\n"); |
1244 | DRM_DEBUG_DRIVER("VBT header incomplete\n"); |
Line 1167... | Line 1254... | ||
1167 | if (offset + sizeof(struct bdb_header) > size) { |
1254 | if (offset + sizeof(struct bdb_header) > size) { |
1168 | DRM_DEBUG_DRIVER("BDB header incomplete\n"); |
1255 | DRM_DEBUG_DRIVER("BDB header incomplete\n"); |
1169 | return NULL; |
1256 | return NULL; |
1170 | } |
1257 | } |
Line 1171... | Line 1258... | ||
1171 | 1258 | ||
1172 | bdb = (struct bdb_header *)(base + offset); |
1259 | bdb = base + offset; |
1173 | if (offset + bdb->bdb_size > size) { |
1260 | if (offset + bdb->bdb_size > size) { |
1174 | DRM_DEBUG_DRIVER("BDB incomplete\n"); |
1261 | DRM_DEBUG_DRIVER("BDB incomplete\n"); |
1175 | return NULL; |
1262 | return NULL; |
Line 1176... | Line 1263... | ||
1176 | } |
1263 | } |
1177 | 1264 | ||
1178 | DRM_DEBUG_KMS("Using VBT from %s: %20s\n", |
1265 | DRM_DEBUG_KMS("Using VBT from %s: %20s\n", |
1179 | source, vbt->signature); |
1266 | source, vbt->signature); |
Line -... | Line 1267... | ||
- | 1267 | return bdb; |
|
- | 1268 | } |
|
- | 1269 | ||
- | 1270 | static const struct bdb_header *find_vbt(void __iomem *bios, size_t size) |
|
- | 1271 | { |
|
- | 1272 | const struct bdb_header *bdb = NULL; |
|
- | 1273 | size_t i; |
|
- | 1274 | ||
- | 1275 | /* Scour memory looking for the VBT signature. */ |
|
- | 1276 | for (i = 0; i + 4 < size; i++) { |
|
- | 1277 | if (ioread32(bios + i) == *((const u32 *) "$VBT")) { |
|
- | 1278 | /* |
|
- | 1279 | * This is the one place where we explicitly discard the |
|
- | 1280 | * address space (__iomem) of the BIOS/VBT. From now on |
|
- | 1281 | * everything is based on 'base', and treated as regular |
|
- | 1282 | * memory. |
|
- | 1283 | */ |
|
- | 1284 | void *_bios = (void __force *) bios; |
|
- | 1285 | ||
- | 1286 | bdb = validate_vbt(_bios, size, _bios + i, "PCI ROM"); |
|
- | 1287 | break; |
|
- | 1288 | } |
|
- | 1289 | } |
|
- | 1290 | ||
1180 | return bdb; |
1291 | return bdb; |
1181 | } |
1292 | } |
1182 | 1293 | ||
1183 | /** |
1294 | /** |
1184 | * intel_parse_bios - find VBT and initialize settings from the BIOS |
1295 | * intel_parse_bios - find VBT and initialize settings from the BIOS |
Line 1192... | Line 1303... | ||
1192 | int |
1303 | int |
1193 | intel_parse_bios(struct drm_device *dev) |
1304 | intel_parse_bios(struct drm_device *dev) |
1194 | { |
1305 | { |
1195 | struct drm_i915_private *dev_priv = dev->dev_private; |
1306 | struct drm_i915_private *dev_priv = dev->dev_private; |
1196 | struct pci_dev *pdev = dev->pdev; |
1307 | struct pci_dev *pdev = dev->pdev; |
1197 | struct bdb_header *bdb = NULL; |
1308 | const struct bdb_header *bdb = NULL; |
1198 | u8 __iomem *bios = NULL; |
1309 | u8 __iomem *bios = NULL; |
Line 1199... | Line 1310... | ||
1199 | 1310 | ||
1200 | if (HAS_PCH_NOP(dev)) |
1311 | if (HAS_PCH_NOP(dev)) |
Line 1201... | Line 1312... | ||
1201 | return -ENODEV; |
1312 | return -ENODEV; |
Line 1202... | Line 1313... | ||
1202 | 1313 | ||
1203 | init_vbt_defaults(dev_priv); |
1314 | init_vbt_defaults(dev_priv); |
1204 | 1315 | ||
1205 | /* XXX Should this validation be moved to intel_opregion.c? */ |
1316 | /* XXX Should this validation be moved to intel_opregion.c? */ |
1206 | if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt) |
- | |
Line 1207... | Line 1317... | ||
1207 | bdb = validate_vbt((char *)dev_priv->opregion.header, OPREGION_SIZE, |
1317 | if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt) |
1208 | (struct vbt_header *)dev_priv->opregion.vbt, |
1318 | bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE, |
Line 1209... | Line 1319... | ||
1209 | "OpRegion"); |
1319 | dev_priv->opregion.vbt, "OpRegion"); |
1210 | 1320 | ||
1211 | if (bdb == NULL) { |
1321 | if (bdb == NULL) { |
Line 1212... | Line -... | ||
1212 | size_t i, size; |
- | |
1213 | - | ||
1214 | bios = pci_map_rom(pdev, &size); |
- | |
1215 | if (!bios) |
1322 | size_t size; |
1216 | return -1; |
- | |
1217 | - | ||
1218 | /* Scour memory looking for the VBT signature */ |
- | |
1219 | for (i = 0; i + 4 < size; i++) { |
- | |
1220 | if (memcmp(bios + i, "$VBT", 4) == 0) { |
- | |
1221 | bdb = validate_vbt(bios, size, |
- | |
1222 | (struct vbt_header *)(bios + i), |
1323 | |
1223 | "PCI ROM"); |
1324 | bios = pci_map_rom(pdev, &size); |
1224 | break; |
1325 | if (!bios) |
1225 | } |
1326 | return -1; |
1226 | } |
1327 | |
Line 1239... | Line 1340... | ||
1239 | parse_sdvo_panel_data(dev_priv, bdb); |
1340 | parse_sdvo_panel_data(dev_priv, bdb); |
1240 | parse_sdvo_device_mapping(dev_priv, bdb); |
1341 | parse_sdvo_device_mapping(dev_priv, bdb); |
1241 | parse_device_mapping(dev_priv, bdb); |
1342 | parse_device_mapping(dev_priv, bdb); |
1242 | parse_driver_features(dev_priv, bdb); |
1343 | parse_driver_features(dev_priv, bdb); |
1243 | parse_edp(dev_priv, bdb); |
1344 | parse_edp(dev_priv, bdb); |
- | 1345 | parse_psr(dev_priv, bdb); |
|
1244 | parse_mipi(dev_priv, bdb); |
1346 | parse_mipi(dev_priv, bdb); |
1245 | parse_ddi_ports(dev_priv, bdb); |
1347 | parse_ddi_ports(dev_priv, bdb); |
Line 1246... | Line 1348... | ||
1246 | 1348 | ||
1247 | if (bios) |
1349 | if (bios) |
Line 1248... | Line 1350... | ||
1248 | pci_unmap_rom(pdev, bios); |
1350 | pci_unmap_rom(pdev, bios); |
1249 | 1351 | ||
1250 | return 0; |
- | |
1251 | } |
- | |
1252 | - | ||
1253 | /* Ensure that vital registers have been initialised, even if the BIOS |
- | |
1254 | * is absent or just failing to do its job. |
- | |
1255 | */ |
- | |
1256 | void intel_setup_bios(struct drm_device *dev) |
- | |
1257 | { |
- | |
1258 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
1259 | - | ||
1260 | /* Set the Panel Power On/Off timings if uninitialized. */ |
- | |
1261 | if (!HAS_PCH_SPLIT(dev) && |
- | |
1262 | I915_READ(PP_ON_DELAYS) == 0 && I915_READ(PP_OFF_DELAYS) == 0) { |
- | |
1263 | /* Set T2 to 40ms and T5 to 200ms */ |
- | |
1264 | I915_WRITE(PP_ON_DELAYS, 0x019007d0); |
- | |
1265 | - | ||
1266 | /* Set T3 to 35ms and Tx to 200ms */ |
- | |
1267 | I915_WRITE(PP_OFF_DELAYS, 0x015e07d0); |
- |