2 * Copyright © 2006 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Eric Anholt <eric@anholt.net>
28 #include <drm/drm_dp_helper.h>
30 #include "display/intel_display.h"
31 #include "display/intel_display_types.h"
32 #include "display/intel_gmbus.h"
35 #include <linux/dmi.h>
37 #define _INTEL_BIOS_PRIVATE
38 #include "intel_vbt_defs.h"
41 * DOC: Video BIOS Table (VBT)
43 * The Video BIOS Table, or VBT, provides platform and board specific
44 * configuration information to the driver that is not discoverable or available
45 * through other means. The configuration is mostly related to display
46 * hardware. The VBT is available via the ACPI OpRegion or, on older systems, in
49 * The VBT consists of a VBT Header (defined as &struct vbt_header), a BDB
50 * Header (&struct bdb_header), and a number of BIOS Data Blocks (BDB) that
51 * contain the actual configuration information. The VBT Header, and thus the
52 * VBT, begins with "$VBT" signature. The VBT Header contains the offset of the
53 * BDB Header. The data blocks are concatenated after the BDB Header. The data
54 * blocks have a 1-byte Block ID, 2-byte Block Size, and Block Size bytes of
55 * data. (Block 53, the MIPI Sequence Block is an exception.)
57 * The driver parses the VBT during load. The relevant information is stored in
58 * driver private data for ease of use, and the actual VBT is not read after
62 /* Wrapper for VBT child device config */
63 struct display_device_data
{
64 struct child_device_config child
;
65 struct dsc_compression_parameters_entry
*dsc
;
66 struct list_head node
;
69 #define SLAVE_ADDR1 0x70
70 #define SLAVE_ADDR2 0x72
72 /* Get BDB block size given a pointer to Block ID. */
73 static u32
_get_blocksize(const u8
*block_base
)
75 /* The MIPI Sequence Block v3+ has a separate size field. */
76 if (*block_base
== BDB_MIPI_SEQUENCE
&& *(block_base
+ 3) >= 3)
77 return *((const u32
*)(block_base
+ 4));
79 return *((const u16
*)(block_base
+ 1));
82 /* Get BDB block size give a pointer to data after Block ID and Block Size. */
83 static u32
get_blocksize(const void *block_data
)
85 return _get_blocksize(block_data
- 3);
89 find_section(const void *_bdb
, enum bdb_block_id section_id
)
91 const struct bdb_header
*bdb
= _bdb
;
92 const u8
*base
= _bdb
;
94 u32 total
, current_size
;
95 enum bdb_block_id current_id
;
97 /* skip to first section */
98 index
+= bdb
->header_size
;
99 total
= bdb
->bdb_size
;
101 /* walk the sections looking for section_id */
102 while (index
+ 3 < total
) {
103 current_id
= *(base
+ index
);
104 current_size
= _get_blocksize(base
+ index
);
107 if (index
+ current_size
> total
)
110 if (current_id
== section_id
)
113 index
+= current_size
;
120 fill_detail_timing_data(struct drm_display_mode
*panel_fixed_mode
,
121 const struct lvds_dvo_timing
*dvo_timing
)
123 panel_fixed_mode
->hdisplay
= (dvo_timing
->hactive_hi
<< 8) |
124 dvo_timing
->hactive_lo
;
125 panel_fixed_mode
->hsync_start
= panel_fixed_mode
->hdisplay
+
126 ((dvo_timing
->hsync_off_hi
<< 8) | dvo_timing
->hsync_off_lo
);
127 panel_fixed_mode
->hsync_end
= panel_fixed_mode
->hsync_start
+
128 ((dvo_timing
->hsync_pulse_width_hi
<< 8) |
129 dvo_timing
->hsync_pulse_width_lo
);
130 panel_fixed_mode
->htotal
= panel_fixed_mode
->hdisplay
+
131 ((dvo_timing
->hblank_hi
<< 8) | dvo_timing
->hblank_lo
);
133 panel_fixed_mode
->vdisplay
= (dvo_timing
->vactive_hi
<< 8) |
134 dvo_timing
->vactive_lo
;
135 panel_fixed_mode
->vsync_start
= panel_fixed_mode
->vdisplay
+
136 ((dvo_timing
->vsync_off_hi
<< 4) | dvo_timing
->vsync_off_lo
);
137 panel_fixed_mode
->vsync_end
= panel_fixed_mode
->vsync_start
+
138 ((dvo_timing
->vsync_pulse_width_hi
<< 4) |
139 dvo_timing
->vsync_pulse_width_lo
);
140 panel_fixed_mode
->vtotal
= panel_fixed_mode
->vdisplay
+
141 ((dvo_timing
->vblank_hi
<< 8) | dvo_timing
->vblank_lo
);
142 panel_fixed_mode
->clock
= dvo_timing
->clock
* 10;
143 panel_fixed_mode
->type
= DRM_MODE_TYPE_PREFERRED
;
145 if (dvo_timing
->hsync_positive
)
146 panel_fixed_mode
->flags
|= DRM_MODE_FLAG_PHSYNC
;
148 panel_fixed_mode
->flags
|= DRM_MODE_FLAG_NHSYNC
;
150 if (dvo_timing
->vsync_positive
)
151 panel_fixed_mode
->flags
|= DRM_MODE_FLAG_PVSYNC
;
153 panel_fixed_mode
->flags
|= DRM_MODE_FLAG_NVSYNC
;
155 panel_fixed_mode
->width_mm
= (dvo_timing
->himage_hi
<< 8) |
156 dvo_timing
->himage_lo
;
157 panel_fixed_mode
->height_mm
= (dvo_timing
->vimage_hi
<< 8) |
158 dvo_timing
->vimage_lo
;
160 /* Some VBTs have bogus h/vtotal values */
161 if (panel_fixed_mode
->hsync_end
> panel_fixed_mode
->htotal
)
162 panel_fixed_mode
->htotal
= panel_fixed_mode
->hsync_end
+ 1;
163 if (panel_fixed_mode
->vsync_end
> panel_fixed_mode
->vtotal
)
164 panel_fixed_mode
->vtotal
= panel_fixed_mode
->vsync_end
+ 1;
166 drm_mode_set_name(panel_fixed_mode
);
169 static const struct lvds_dvo_timing
*
170 get_lvds_dvo_timing(const struct bdb_lvds_lfp_data
*lvds_lfp_data
,
171 const struct bdb_lvds_lfp_data_ptrs
*lvds_lfp_data_ptrs
,
175 * the size of fp_timing varies on the different platform.
176 * So calculate the DVO timing relative offset in LVDS data
177 * entry to get the DVO timing entry
181 lvds_lfp_data_ptrs
->ptr
[1].dvo_timing_offset
-
182 lvds_lfp_data_ptrs
->ptr
[0].dvo_timing_offset
;
183 int dvo_timing_offset
=
184 lvds_lfp_data_ptrs
->ptr
[0].dvo_timing_offset
-
185 lvds_lfp_data_ptrs
->ptr
[0].fp_timing_offset
;
186 char *entry
= (char *)lvds_lfp_data
->data
+ lfp_data_size
* index
;
188 return (struct lvds_dvo_timing
*)(entry
+ dvo_timing_offset
);
191 /* get lvds_fp_timing entry
192 * this function may return NULL if the corresponding entry is invalid
194 static const struct lvds_fp_timing
*
195 get_lvds_fp_timing(const struct bdb_header
*bdb
,
196 const struct bdb_lvds_lfp_data
*data
,
197 const struct bdb_lvds_lfp_data_ptrs
*ptrs
,
200 size_t data_ofs
= (const u8
*)data
- (const u8
*)bdb
;
201 u16 data_size
= ((const u16
*)data
)[-1]; /* stored in header */
204 if (index
>= ARRAY_SIZE(ptrs
->ptr
))
206 ofs
= ptrs
->ptr
[index
].fp_timing_offset
;
207 if (ofs
< data_ofs
||
208 ofs
+ sizeof(struct lvds_fp_timing
) > data_ofs
+ data_size
)
210 return (const struct lvds_fp_timing
*)((const u8
*)bdb
+ ofs
);
213 /* Parse general panel options */
215 parse_panel_options(struct drm_i915_private
*dev_priv
,
216 const struct bdb_header
*bdb
)
218 const struct bdb_lvds_options
*lvds_options
;
223 lvds_options
= find_section(bdb
, BDB_LVDS_OPTIONS
);
227 dev_priv
->vbt
.lvds_dither
= lvds_options
->pixel_dither
;
229 ret
= intel_opregion_get_panel_type(dev_priv
);
231 drm_WARN_ON(&dev_priv
->drm
, ret
> 0xf);
233 drm_dbg_kms(&dev_priv
->drm
, "Panel type: %d (OpRegion)\n",
236 if (lvds_options
->panel_type
> 0xf) {
237 drm_dbg_kms(&dev_priv
->drm
,
238 "Invalid VBT panel type 0x%x\n",
239 lvds_options
->panel_type
);
242 panel_type
= lvds_options
->panel_type
;
243 drm_dbg_kms(&dev_priv
->drm
, "Panel type: %d (VBT)\n",
247 dev_priv
->vbt
.panel_type
= panel_type
;
249 drrs_mode
= (lvds_options
->dps_panel_type_bits
250 >> (panel_type
* 2)) & MODE_MASK
;
252 * VBT has static DRRS = 0 and seamless DRRS = 2.
253 * The below piece of code is required to adjust vbt.drrs_type
254 * to match the enum drrs_support_type.
258 dev_priv
->vbt
.drrs_type
= STATIC_DRRS_SUPPORT
;
259 drm_dbg_kms(&dev_priv
->drm
, "DRRS supported mode is static\n");
262 dev_priv
->vbt
.drrs_type
= SEAMLESS_DRRS_SUPPORT
;
263 drm_dbg_kms(&dev_priv
->drm
,
264 "DRRS supported mode is seamless\n");
267 dev_priv
->vbt
.drrs_type
= DRRS_NOT_SUPPORTED
;
268 drm_dbg_kms(&dev_priv
->drm
,
269 "DRRS not supported (VBT input)\n");
274 /* Try to find integrated panel timing data */
276 parse_lfp_panel_dtd(struct drm_i915_private
*dev_priv
,
277 const struct bdb_header
*bdb
)
279 const struct bdb_lvds_lfp_data
*lvds_lfp_data
;
280 const struct bdb_lvds_lfp_data_ptrs
*lvds_lfp_data_ptrs
;
281 const struct lvds_dvo_timing
*panel_dvo_timing
;
282 const struct lvds_fp_timing
*fp_timing
;
283 struct drm_display_mode
*panel_fixed_mode
;
284 int panel_type
= dev_priv
->vbt
.panel_type
;
286 lvds_lfp_data
= find_section(bdb
, BDB_LVDS_LFP_DATA
);
290 lvds_lfp_data_ptrs
= find_section(bdb
, BDB_LVDS_LFP_DATA_PTRS
);
291 if (!lvds_lfp_data_ptrs
)
294 panel_dvo_timing
= get_lvds_dvo_timing(lvds_lfp_data
,
298 panel_fixed_mode
= kzalloc(sizeof(*panel_fixed_mode
), GFP_KERNEL
);
299 if (!panel_fixed_mode
)
302 fill_detail_timing_data(panel_fixed_mode
, panel_dvo_timing
);
304 dev_priv
->vbt
.lfp_lvds_vbt_mode
= panel_fixed_mode
;
306 drm_dbg_kms(&dev_priv
->drm
,
307 "Found panel mode in BIOS VBT legacy lfp table:\n");
308 drm_mode_debug_printmodeline(panel_fixed_mode
);
310 fp_timing
= get_lvds_fp_timing(bdb
, lvds_lfp_data
,
314 /* check the resolution, just to be sure */
315 if (fp_timing
->x_res
== panel_fixed_mode
->hdisplay
&&
316 fp_timing
->y_res
== panel_fixed_mode
->vdisplay
) {
317 dev_priv
->vbt
.bios_lvds_val
= fp_timing
->lvds_reg_val
;
318 drm_dbg_kms(&dev_priv
->drm
,
319 "VBT initial LVDS value %x\n",
320 dev_priv
->vbt
.bios_lvds_val
);
326 parse_generic_dtd(struct drm_i915_private
*dev_priv
,
327 const struct bdb_header
*bdb
)
329 const struct bdb_generic_dtd
*generic_dtd
;
330 const struct generic_dtd_entry
*dtd
;
331 struct drm_display_mode
*panel_fixed_mode
;
334 generic_dtd
= find_section(bdb
, BDB_GENERIC_DTD
);
338 if (generic_dtd
->gdtd_size
< sizeof(struct generic_dtd_entry
)) {
339 drm_err(&dev_priv
->drm
, "GDTD size %u is too small.\n",
340 generic_dtd
->gdtd_size
);
342 } else if (generic_dtd
->gdtd_size
!=
343 sizeof(struct generic_dtd_entry
)) {
344 drm_err(&dev_priv
->drm
, "Unexpected GDTD size %u\n",
345 generic_dtd
->gdtd_size
);
346 /* DTD has unknown fields, but keep going */
349 num_dtd
= (get_blocksize(generic_dtd
) -
350 sizeof(struct bdb_generic_dtd
)) / generic_dtd
->gdtd_size
;
351 if (dev_priv
->vbt
.panel_type
>= num_dtd
) {
352 drm_err(&dev_priv
->drm
,
353 "Panel type %d not found in table of %d DTD's\n",
354 dev_priv
->vbt
.panel_type
, num_dtd
);
358 dtd
= &generic_dtd
->dtd
[dev_priv
->vbt
.panel_type
];
360 panel_fixed_mode
= kzalloc(sizeof(*panel_fixed_mode
), GFP_KERNEL
);
361 if (!panel_fixed_mode
)
364 panel_fixed_mode
->hdisplay
= dtd
->hactive
;
365 panel_fixed_mode
->hsync_start
=
366 panel_fixed_mode
->hdisplay
+ dtd
->hfront_porch
;
367 panel_fixed_mode
->hsync_end
=
368 panel_fixed_mode
->hsync_start
+ dtd
->hsync
;
369 panel_fixed_mode
->htotal
=
370 panel_fixed_mode
->hdisplay
+ dtd
->hblank
;
372 panel_fixed_mode
->vdisplay
= dtd
->vactive
;
373 panel_fixed_mode
->vsync_start
=
374 panel_fixed_mode
->vdisplay
+ dtd
->vfront_porch
;
375 panel_fixed_mode
->vsync_end
=
376 panel_fixed_mode
->vsync_start
+ dtd
->vsync
;
377 panel_fixed_mode
->vtotal
=
378 panel_fixed_mode
->vdisplay
+ dtd
->vblank
;
380 panel_fixed_mode
->clock
= dtd
->pixel_clock
;
381 panel_fixed_mode
->width_mm
= dtd
->width_mm
;
382 panel_fixed_mode
->height_mm
= dtd
->height_mm
;
384 panel_fixed_mode
->type
= DRM_MODE_TYPE_PREFERRED
;
385 drm_mode_set_name(panel_fixed_mode
);
387 if (dtd
->hsync_positive_polarity
)
388 panel_fixed_mode
->flags
|= DRM_MODE_FLAG_PHSYNC
;
390 panel_fixed_mode
->flags
|= DRM_MODE_FLAG_NHSYNC
;
392 if (dtd
->vsync_positive_polarity
)
393 panel_fixed_mode
->flags
|= DRM_MODE_FLAG_PVSYNC
;
395 panel_fixed_mode
->flags
|= DRM_MODE_FLAG_NVSYNC
;
397 drm_dbg_kms(&dev_priv
->drm
,
398 "Found panel mode in BIOS VBT generic dtd table:\n");
399 drm_mode_debug_printmodeline(panel_fixed_mode
);
401 dev_priv
->vbt
.lfp_lvds_vbt_mode
= panel_fixed_mode
;
405 parse_panel_dtd(struct drm_i915_private
*dev_priv
,
406 const struct bdb_header
*bdb
)
409 * Older VBTs provided provided DTD information for internal displays
410 * through the "LFP panel DTD" block (42). As of VBT revision 229,
411 * that block is now deprecated and DTD information should be provided
412 * via a newer "generic DTD" block (58). Just to be safe, we'll
413 * try the new generic DTD block first on VBT >= 229, but still fall
414 * back to trying the old LFP block if that fails.
416 if (bdb
->version
>= 229)
417 parse_generic_dtd(dev_priv
, bdb
);
418 if (!dev_priv
->vbt
.lfp_lvds_vbt_mode
)
419 parse_lfp_panel_dtd(dev_priv
, bdb
);
423 parse_lfp_backlight(struct drm_i915_private
*dev_priv
,
424 const struct bdb_header
*bdb
)
426 const struct bdb_lfp_backlight_data
*backlight_data
;
427 const struct lfp_backlight_data_entry
*entry
;
428 int panel_type
= dev_priv
->vbt
.panel_type
;
431 backlight_data
= find_section(bdb
, BDB_LVDS_BACKLIGHT
);
435 if (backlight_data
->entry_size
!= sizeof(backlight_data
->data
[0])) {
436 drm_dbg_kms(&dev_priv
->drm
,
437 "Unsupported backlight data entry size %u\n",
438 backlight_data
->entry_size
);
442 entry
= &backlight_data
->data
[panel_type
];
444 dev_priv
->vbt
.backlight
.present
= entry
->type
== BDB_BACKLIGHT_TYPE_PWM
;
445 if (!dev_priv
->vbt
.backlight
.present
) {
446 drm_dbg_kms(&dev_priv
->drm
,
447 "PWM backlight not present in VBT (type %u)\n",
452 dev_priv
->vbt
.backlight
.type
= INTEL_BACKLIGHT_DISPLAY_DDI
;
453 if (bdb
->version
>= 191 &&
454 get_blocksize(backlight_data
) >= sizeof(*backlight_data
)) {
455 const struct lfp_backlight_control_method
*method
;
457 method
= &backlight_data
->backlight_control
[panel_type
];
458 dev_priv
->vbt
.backlight
.type
= method
->type
;
459 dev_priv
->vbt
.backlight
.controller
= method
->controller
;
462 dev_priv
->vbt
.backlight
.pwm_freq_hz
= entry
->pwm_freq_hz
;
463 dev_priv
->vbt
.backlight
.active_low_pwm
= entry
->active_low_pwm
;
465 if (bdb
->version
>= 234) {
469 level
= backlight_data
->brightness_level
[panel_type
].level
;
470 min_level
= backlight_data
->brightness_min_level
[panel_type
].level
;
472 if (bdb
->version
>= 236)
473 scale
= backlight_data
->brightness_precision_bits
[panel_type
] == 16;
478 min_level
= min_level
/ 255;
480 if (min_level
> 255) {
481 drm_warn(&dev_priv
->drm
, "Brightness min level > 255\n");
484 dev_priv
->vbt
.backlight
.min_brightness
= min_level
;
486 level
= backlight_data
->level
[panel_type
];
487 dev_priv
->vbt
.backlight
.min_brightness
= entry
->min_brightness
;
490 drm_dbg_kms(&dev_priv
->drm
,
491 "VBT backlight PWM modulation frequency %u Hz, "
492 "active %s, min brightness %u, level %u, controller %u\n",
493 dev_priv
->vbt
.backlight
.pwm_freq_hz
,
494 dev_priv
->vbt
.backlight
.active_low_pwm
? "low" : "high",
495 dev_priv
->vbt
.backlight
.min_brightness
,
497 dev_priv
->vbt
.backlight
.controller
);
500 /* Try to find sdvo panel data */
502 parse_sdvo_panel_data(struct drm_i915_private
*dev_priv
,
503 const struct bdb_header
*bdb
)
505 const struct bdb_sdvo_panel_dtds
*dtds
;
506 struct drm_display_mode
*panel_fixed_mode
;
509 index
= dev_priv
->params
.vbt_sdvo_panel_type
;
511 drm_dbg_kms(&dev_priv
->drm
,
512 "Ignore SDVO panel mode from BIOS VBT tables.\n");
517 const struct bdb_sdvo_lvds_options
*sdvo_lvds_options
;
519 sdvo_lvds_options
= find_section(bdb
, BDB_SDVO_LVDS_OPTIONS
);
520 if (!sdvo_lvds_options
)
523 index
= sdvo_lvds_options
->panel_type
;
526 dtds
= find_section(bdb
, BDB_SDVO_PANEL_DTDS
);
530 panel_fixed_mode
= kzalloc(sizeof(*panel_fixed_mode
), GFP_KERNEL
);
531 if (!panel_fixed_mode
)
534 fill_detail_timing_data(panel_fixed_mode
, &dtds
->dtds
[index
]);
536 dev_priv
->vbt
.sdvo_lvds_vbt_mode
= panel_fixed_mode
;
538 drm_dbg_kms(&dev_priv
->drm
,
539 "Found SDVO panel mode in BIOS VBT tables:\n");
540 drm_mode_debug_printmodeline(panel_fixed_mode
);
543 static int intel_bios_ssc_frequency(struct drm_i915_private
*dev_priv
,
546 switch (INTEL_GEN(dev_priv
)) {
548 return alternate
? 66667 : 48000;
551 return alternate
? 100000 : 96000;
553 return alternate
? 100000 : 120000;
558 parse_general_features(struct drm_i915_private
*dev_priv
,
559 const struct bdb_header
*bdb
)
561 const struct bdb_general_features
*general
;
563 general
= find_section(bdb
, BDB_GENERAL_FEATURES
);
567 dev_priv
->vbt
.int_tv_support
= general
->int_tv_support
;
568 /* int_crt_support can't be trusted on earlier platforms */
569 if (bdb
->version
>= 155 &&
570 (HAS_DDI(dev_priv
) || IS_VALLEYVIEW(dev_priv
)))
571 dev_priv
->vbt
.int_crt_support
= general
->int_crt_support
;
572 dev_priv
->vbt
.lvds_use_ssc
= general
->enable_ssc
;
573 dev_priv
->vbt
.lvds_ssc_freq
=
574 intel_bios_ssc_frequency(dev_priv
, general
->ssc_freq
);
575 dev_priv
->vbt
.display_clock_mode
= general
->display_clock_mode
;
576 dev_priv
->vbt
.fdi_rx_polarity_inverted
= general
->fdi_rx_polarity_inverted
;
577 if (bdb
->version
>= 181) {
578 dev_priv
->vbt
.orientation
= general
->rotate_180
?
579 DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP
:
580 DRM_MODE_PANEL_ORIENTATION_NORMAL
;
582 dev_priv
->vbt
.orientation
= DRM_MODE_PANEL_ORIENTATION_UNKNOWN
;
584 drm_dbg_kms(&dev_priv
->drm
,
585 "BDB_GENERAL_FEATURES int_tv_support %d int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d fdi_rx_polarity_inverted %d\n",
586 dev_priv
->vbt
.int_tv_support
,
587 dev_priv
->vbt
.int_crt_support
,
588 dev_priv
->vbt
.lvds_use_ssc
,
589 dev_priv
->vbt
.lvds_ssc_freq
,
590 dev_priv
->vbt
.display_clock_mode
,
591 dev_priv
->vbt
.fdi_rx_polarity_inverted
);
594 static const struct child_device_config
*
595 child_device_ptr(const struct bdb_general_definitions
*defs
, int i
)
597 return (const void *) &defs
->devices
[i
* defs
->child_dev_size
];
601 parse_sdvo_device_mapping(struct drm_i915_private
*dev_priv
, u8 bdb_version
)
603 struct sdvo_device_mapping
*mapping
;
604 const struct display_device_data
*devdata
;
605 const struct child_device_config
*child
;
609 * Only parse SDVO mappings on gens that could have SDVO. This isn't
610 * accurate and doesn't have to be, as long as it's not too strict.
612 if (!IS_GEN_RANGE(dev_priv
, 3, 7)) {
613 drm_dbg_kms(&dev_priv
->drm
, "Skipping SDVO device mapping\n");
617 list_for_each_entry(devdata
, &dev_priv
->vbt
.display_devices
, node
) {
618 child
= &devdata
->child
;
620 if (child
->slave_addr
!= SLAVE_ADDR1
&&
621 child
->slave_addr
!= SLAVE_ADDR2
) {
623 * If the slave address is neither 0x70 nor 0x72,
624 * it is not a SDVO device. Skip it.
628 if (child
->dvo_port
!= DEVICE_PORT_DVOB
&&
629 child
->dvo_port
!= DEVICE_PORT_DVOC
) {
630 /* skip the incorrect SDVO port */
631 drm_dbg_kms(&dev_priv
->drm
,
632 "Incorrect SDVO port. Skip it\n");
635 drm_dbg_kms(&dev_priv
->drm
,
636 "the SDVO device with slave addr %2x is found on"
639 (child
->dvo_port
== DEVICE_PORT_DVOB
) ?
641 mapping
= &dev_priv
->vbt
.sdvo_mappings
[child
->dvo_port
- 1];
642 if (!mapping
->initialized
) {
643 mapping
->dvo_port
= child
->dvo_port
;
644 mapping
->slave_addr
= child
->slave_addr
;
645 mapping
->dvo_wiring
= child
->dvo_wiring
;
646 mapping
->ddc_pin
= child
->ddc_pin
;
647 mapping
->i2c_pin
= child
->i2c_pin
;
648 mapping
->initialized
= 1;
649 drm_dbg_kms(&dev_priv
->drm
,
650 "SDVO device: dvo=%x, addr=%x, wiring=%d, ddc_pin=%d, i2c_pin=%d\n",
651 mapping
->dvo_port
, mapping
->slave_addr
,
652 mapping
->dvo_wiring
, mapping
->ddc_pin
,
655 drm_dbg_kms(&dev_priv
->drm
,
656 "Maybe one SDVO port is shared by "
657 "two SDVO device.\n");
659 if (child
->slave2_addr
) {
660 /* Maybe this is a SDVO device with multiple inputs */
661 /* And the mapping info is not added */
662 drm_dbg_kms(&dev_priv
->drm
,
663 "there exists the slave2_addr. Maybe this"
664 " is a SDVO device with multiple inputs.\n");
670 /* No SDVO device info is found */
671 drm_dbg_kms(&dev_priv
->drm
,
672 "No SDVO device info is found in VBT\n");
677 parse_driver_features(struct drm_i915_private
*dev_priv
,
678 const struct bdb_header
*bdb
)
680 const struct bdb_driver_features
*driver
;
682 driver
= find_section(bdb
, BDB_DRIVER_FEATURES
);
686 if (INTEL_GEN(dev_priv
) >= 5) {
688 * Note that we consider BDB_DRIVER_FEATURE_INT_SDVO_LVDS
689 * to mean "eDP". The VBT spec doesn't agree with that
690 * interpretation, but real world VBTs seem to.
692 if (driver
->lvds_config
!= BDB_DRIVER_FEATURE_INT_LVDS
)
693 dev_priv
->vbt
.int_lvds_support
= 0;
696 * FIXME it's not clear which BDB version has the LVDS config
697 * bits defined. Revision history in the VBT spec says:
698 * "0.92 | Add two definitions for VBT value of LVDS Active
699 * Config (00b and 11b values defined) | 06/13/2005"
700 * but does not the specify the BDB version.
702 * So far version 134 (on i945gm) is the oldest VBT observed
703 * in the wild with the bits correctly populated. Version
704 * 108 (on i85x) does not have the bits correctly populated.
706 if (bdb
->version
>= 134 &&
707 driver
->lvds_config
!= BDB_DRIVER_FEATURE_INT_LVDS
&&
708 driver
->lvds_config
!= BDB_DRIVER_FEATURE_INT_SDVO_LVDS
)
709 dev_priv
->vbt
.int_lvds_support
= 0;
712 if (bdb
->version
< 228) {
713 drm_dbg_kms(&dev_priv
->drm
, "DRRS State Enabled:%d\n",
714 driver
->drrs_enabled
);
716 * If DRRS is not supported, drrs_type has to be set to 0.
717 * This is because, VBT is configured in such a way that
718 * static DRRS is 0 and DRRS not supported is represented by
719 * driver->drrs_enabled=false
721 if (!driver
->drrs_enabled
)
722 dev_priv
->vbt
.drrs_type
= DRRS_NOT_SUPPORTED
;
724 dev_priv
->vbt
.psr
.enable
= driver
->psr_enabled
;
729 parse_power_conservation_features(struct drm_i915_private
*dev_priv
,
730 const struct bdb_header
*bdb
)
732 const struct bdb_lfp_power
*power
;
733 u8 panel_type
= dev_priv
->vbt
.panel_type
;
735 if (bdb
->version
< 228)
738 power
= find_section(bdb
, BDB_LFP_POWER
);
742 dev_priv
->vbt
.psr
.enable
= power
->psr
& BIT(panel_type
);
745 * If DRRS is not supported, drrs_type has to be set to 0.
746 * This is because, VBT is configured in such a way that
747 * static DRRS is 0 and DRRS not supported is represented by
748 * power->drrs & BIT(panel_type)=false
750 if (!(power
->drrs
& BIT(panel_type
)))
751 dev_priv
->vbt
.drrs_type
= DRRS_NOT_SUPPORTED
;
753 if (bdb
->version
>= 232)
754 dev_priv
->vbt
.edp
.hobl
= power
->hobl
& BIT(panel_type
);
758 parse_edp(struct drm_i915_private
*dev_priv
, const struct bdb_header
*bdb
)
760 const struct bdb_edp
*edp
;
761 const struct edp_power_seq
*edp_pps
;
762 const struct edp_fast_link_params
*edp_link_params
;
763 int panel_type
= dev_priv
->vbt
.panel_type
;
765 edp
= find_section(bdb
, BDB_EDP
);
769 switch ((edp
->color_depth
>> (panel_type
* 2)) & 3) {
771 dev_priv
->vbt
.edp
.bpp
= 18;
774 dev_priv
->vbt
.edp
.bpp
= 24;
777 dev_priv
->vbt
.edp
.bpp
= 30;
781 /* Get the eDP sequencing and link info */
782 edp_pps
= &edp
->power_seqs
[panel_type
];
783 edp_link_params
= &edp
->fast_link_params
[panel_type
];
785 dev_priv
->vbt
.edp
.pps
= *edp_pps
;
787 switch (edp_link_params
->rate
) {
789 dev_priv
->vbt
.edp
.rate
= DP_LINK_BW_1_62
;
792 dev_priv
->vbt
.edp
.rate
= DP_LINK_BW_2_7
;
795 drm_dbg_kms(&dev_priv
->drm
,
796 "VBT has unknown eDP link rate value %u\n",
797 edp_link_params
->rate
);
801 switch (edp_link_params
->lanes
) {
803 dev_priv
->vbt
.edp
.lanes
= 1;
806 dev_priv
->vbt
.edp
.lanes
= 2;
809 dev_priv
->vbt
.edp
.lanes
= 4;
812 drm_dbg_kms(&dev_priv
->drm
,
813 "VBT has unknown eDP lane count value %u\n",
814 edp_link_params
->lanes
);
818 switch (edp_link_params
->preemphasis
) {
819 case EDP_PREEMPHASIS_NONE
:
820 dev_priv
->vbt
.edp
.preemphasis
= DP_TRAIN_PRE_EMPH_LEVEL_0
;
822 case EDP_PREEMPHASIS_3_5dB
:
823 dev_priv
->vbt
.edp
.preemphasis
= DP_TRAIN_PRE_EMPH_LEVEL_1
;
825 case EDP_PREEMPHASIS_6dB
:
826 dev_priv
->vbt
.edp
.preemphasis
= DP_TRAIN_PRE_EMPH_LEVEL_2
;
828 case EDP_PREEMPHASIS_9_5dB
:
829 dev_priv
->vbt
.edp
.preemphasis
= DP_TRAIN_PRE_EMPH_LEVEL_3
;
832 drm_dbg_kms(&dev_priv
->drm
,
833 "VBT has unknown eDP pre-emphasis value %u\n",
834 edp_link_params
->preemphasis
);
838 switch (edp_link_params
->vswing
) {
839 case EDP_VSWING_0_4V
:
840 dev_priv
->vbt
.edp
.vswing
= DP_TRAIN_VOLTAGE_SWING_LEVEL_0
;
842 case EDP_VSWING_0_6V
:
843 dev_priv
->vbt
.edp
.vswing
= DP_TRAIN_VOLTAGE_SWING_LEVEL_1
;
845 case EDP_VSWING_0_8V
:
846 dev_priv
->vbt
.edp
.vswing
= DP_TRAIN_VOLTAGE_SWING_LEVEL_2
;
848 case EDP_VSWING_1_2V
:
849 dev_priv
->vbt
.edp
.vswing
= DP_TRAIN_VOLTAGE_SWING_LEVEL_3
;
852 drm_dbg_kms(&dev_priv
->drm
,
853 "VBT has unknown eDP voltage swing value %u\n",
854 edp_link_params
->vswing
);
858 if (bdb
->version
>= 173) {
861 /* Don't read from VBT if module parameter has valid value*/
862 if (dev_priv
->params
.edp_vswing
) {
863 dev_priv
->vbt
.edp
.low_vswing
=
864 dev_priv
->params
.edp_vswing
== 1;
866 vswing
= (edp
->edp_vswing_preemph
>> (panel_type
* 4)) & 0xF;
867 dev_priv
->vbt
.edp
.low_vswing
= vswing
== 0;
873 parse_psr(struct drm_i915_private
*dev_priv
, const struct bdb_header
*bdb
)
875 const struct bdb_psr
*psr
;
876 const struct psr_table
*psr_table
;
877 int panel_type
= dev_priv
->vbt
.panel_type
;
879 psr
= find_section(bdb
, BDB_PSR
);
881 drm_dbg_kms(&dev_priv
->drm
, "No PSR BDB found.\n");
885 psr_table
= &psr
->psr_table
[panel_type
];
887 dev_priv
->vbt
.psr
.full_link
= psr_table
->full_link
;
888 dev_priv
->vbt
.psr
.require_aux_wakeup
= psr_table
->require_aux_to_wakeup
;
890 /* Allowed VBT values goes from 0 to 15 */
891 dev_priv
->vbt
.psr
.idle_frames
= psr_table
->idle_frames
< 0 ? 0 :
892 psr_table
->idle_frames
> 15 ? 15 : psr_table
->idle_frames
;
894 switch (psr_table
->lines_to_wait
) {
896 dev_priv
->vbt
.psr
.lines_to_wait
= PSR_0_LINES_TO_WAIT
;
899 dev_priv
->vbt
.psr
.lines_to_wait
= PSR_1_LINE_TO_WAIT
;
902 dev_priv
->vbt
.psr
.lines_to_wait
= PSR_4_LINES_TO_WAIT
;
905 dev_priv
->vbt
.psr
.lines_to_wait
= PSR_8_LINES_TO_WAIT
;
908 drm_dbg_kms(&dev_priv
->drm
,
909 "VBT has unknown PSR lines to wait %u\n",
910 psr_table
->lines_to_wait
);
915 * New psr options 0=500us, 1=100us, 2=2500us, 3=0us
916 * Old decimal value is wake up time in multiples of 100 us.
918 if (bdb
->version
>= 205 &&
919 (IS_GEN9_BC(dev_priv
) || IS_GEMINILAKE(dev_priv
) ||
920 INTEL_GEN(dev_priv
) >= 10)) {
921 switch (psr_table
->tp1_wakeup_time
) {
923 dev_priv
->vbt
.psr
.tp1_wakeup_time_us
= 500;
926 dev_priv
->vbt
.psr
.tp1_wakeup_time_us
= 100;
929 dev_priv
->vbt
.psr
.tp1_wakeup_time_us
= 0;
932 drm_dbg_kms(&dev_priv
->drm
,
933 "VBT tp1 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
934 psr_table
->tp1_wakeup_time
);
937 dev_priv
->vbt
.psr
.tp1_wakeup_time_us
= 2500;
941 switch (psr_table
->tp2_tp3_wakeup_time
) {
943 dev_priv
->vbt
.psr
.tp2_tp3_wakeup_time_us
= 500;
946 dev_priv
->vbt
.psr
.tp2_tp3_wakeup_time_us
= 100;
949 dev_priv
->vbt
.psr
.tp2_tp3_wakeup_time_us
= 0;
952 drm_dbg_kms(&dev_priv
->drm
,
953 "VBT tp2_tp3 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
954 psr_table
->tp2_tp3_wakeup_time
);
957 dev_priv
->vbt
.psr
.tp2_tp3_wakeup_time_us
= 2500;
961 dev_priv
->vbt
.psr
.tp1_wakeup_time_us
= psr_table
->tp1_wakeup_time
* 100;
962 dev_priv
->vbt
.psr
.tp2_tp3_wakeup_time_us
= psr_table
->tp2_tp3_wakeup_time
* 100;
965 if (bdb
->version
>= 226) {
966 u32 wakeup_time
= psr
->psr2_tp2_tp3_wakeup_time
;
968 wakeup_time
= (wakeup_time
>> (2 * panel_type
)) & 0x3;
969 switch (wakeup_time
) {
984 dev_priv
->vbt
.psr
.psr2_tp2_tp3_wakeup_time_us
= wakeup_time
;
986 /* Reusing PSR1 wakeup time for PSR2 in older VBTs */
987 dev_priv
->vbt
.psr
.psr2_tp2_tp3_wakeup_time_us
= dev_priv
->vbt
.psr
.tp2_tp3_wakeup_time_us
;
991 static void parse_dsi_backlight_ports(struct drm_i915_private
*dev_priv
,
992 u16 version
, enum port port
)
994 if (!dev_priv
->vbt
.dsi
.config
->dual_link
|| version
< 197) {
995 dev_priv
->vbt
.dsi
.bl_ports
= BIT(port
);
996 if (dev_priv
->vbt
.dsi
.config
->cabc_supported
)
997 dev_priv
->vbt
.dsi
.cabc_ports
= BIT(port
);
1002 switch (dev_priv
->vbt
.dsi
.config
->dl_dcs_backlight_ports
) {
1004 dev_priv
->vbt
.dsi
.bl_ports
= BIT(PORT_A
);
1007 dev_priv
->vbt
.dsi
.bl_ports
= BIT(PORT_C
);
1010 case DL_DCS_PORT_A_AND_C
:
1011 dev_priv
->vbt
.dsi
.bl_ports
= BIT(PORT_A
) | BIT(PORT_C
);
1015 if (!dev_priv
->vbt
.dsi
.config
->cabc_supported
)
1018 switch (dev_priv
->vbt
.dsi
.config
->dl_dcs_cabc_ports
) {
1020 dev_priv
->vbt
.dsi
.cabc_ports
= BIT(PORT_A
);
1023 dev_priv
->vbt
.dsi
.cabc_ports
= BIT(PORT_C
);
1026 case DL_DCS_PORT_A_AND_C
:
1027 dev_priv
->vbt
.dsi
.cabc_ports
=
1028 BIT(PORT_A
) | BIT(PORT_C
);
1034 parse_mipi_config(struct drm_i915_private
*dev_priv
,
1035 const struct bdb_header
*bdb
)
1037 const struct bdb_mipi_config
*start
;
1038 const struct mipi_config
*config
;
1039 const struct mipi_pps_data
*pps
;
1040 int panel_type
= dev_priv
->vbt
.panel_type
;
1043 /* parse MIPI blocks only if LFP type is MIPI */
1044 if (!intel_bios_is_dsi_present(dev_priv
, &port
))
1047 /* Initialize this to undefined indicating no generic MIPI support */
1048 dev_priv
->vbt
.dsi
.panel_id
= MIPI_DSI_UNDEFINED_PANEL_ID
;
1050 /* Block #40 is already parsed and panel_fixed_mode is
1051 * stored in dev_priv->lfp_lvds_vbt_mode
1052 * resuse this when needed
1055 /* Parse #52 for panel index used from panel_type already
1058 start
= find_section(bdb
, BDB_MIPI_CONFIG
);
1060 drm_dbg_kms(&dev_priv
->drm
, "No MIPI config BDB found");
1064 drm_dbg(&dev_priv
->drm
, "Found MIPI Config block, panel index = %d\n",
1068 * get hold of the correct configuration block and pps data as per
1069 * the panel_type as index
1071 config
= &start
->config
[panel_type
];
1072 pps
= &start
->pps
[panel_type
];
1074 /* store as of now full data. Trim when we realise all is not needed */
1075 dev_priv
->vbt
.dsi
.config
= kmemdup(config
, sizeof(struct mipi_config
), GFP_KERNEL
);
1076 if (!dev_priv
->vbt
.dsi
.config
)
1079 dev_priv
->vbt
.dsi
.pps
= kmemdup(pps
, sizeof(struct mipi_pps_data
), GFP_KERNEL
);
1080 if (!dev_priv
->vbt
.dsi
.pps
) {
1081 kfree(dev_priv
->vbt
.dsi
.config
);
1085 parse_dsi_backlight_ports(dev_priv
, bdb
->version
, port
);
1087 /* FIXME is the 90 vs. 270 correct? */
1088 switch (config
->rotation
) {
1089 case ENABLE_ROTATION_0
:
1091 * Most (all?) VBTs claim 0 degrees despite having
1092 * an upside down panel, thus we do not trust this.
1094 dev_priv
->vbt
.dsi
.orientation
=
1095 DRM_MODE_PANEL_ORIENTATION_UNKNOWN
;
1097 case ENABLE_ROTATION_90
:
1098 dev_priv
->vbt
.dsi
.orientation
=
1099 DRM_MODE_PANEL_ORIENTATION_RIGHT_UP
;
1101 case ENABLE_ROTATION_180
:
1102 dev_priv
->vbt
.dsi
.orientation
=
1103 DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP
;
1105 case ENABLE_ROTATION_270
:
1106 dev_priv
->vbt
.dsi
.orientation
=
1107 DRM_MODE_PANEL_ORIENTATION_LEFT_UP
;
1111 /* We have mandatory mipi config blocks. Initialize as generic panel */
1112 dev_priv
->vbt
.dsi
.panel_id
= MIPI_DSI_GENERIC_PANEL_ID
;
1115 /* Find the sequence block and size for the given panel. */
1117 find_panel_sequence_block(const struct bdb_mipi_sequence
*sequence
,
1118 u16 panel_id
, u32
*seq_size
)
1120 u32 total
= get_blocksize(sequence
);
1121 const u8
*data
= &sequence
->data
[0];
1124 int header_size
= sequence
->version
>= 3 ? 5 : 3;
1128 /* skip new block size */
1129 if (sequence
->version
>= 3)
1132 for (i
= 0; i
< MAX_MIPI_CONFIGURATIONS
&& index
< total
; i
++) {
1133 if (index
+ header_size
> total
) {
1134 DRM_ERROR("Invalid sequence block (header)\n");
1138 current_id
= *(data
+ index
);
1139 if (sequence
->version
>= 3)
1140 current_size
= *((const u32
*)(data
+ index
+ 1));
1142 current_size
= *((const u16
*)(data
+ index
+ 1));
1144 index
+= header_size
;
1146 if (index
+ current_size
> total
) {
1147 DRM_ERROR("Invalid sequence block\n");
1151 if (current_id
== panel_id
) {
1152 *seq_size
= current_size
;
1153 return data
+ index
;
1156 index
+= current_size
;
1159 DRM_ERROR("Sequence block detected but no valid configuration\n");
1164 static int goto_next_sequence(const u8
*data
, int index
, int total
)
1168 /* Skip Sequence Byte. */
1169 for (index
= index
+ 1; index
< total
; index
+= len
) {
1170 u8 operation_byte
= *(data
+ index
);
1173 switch (operation_byte
) {
1174 case MIPI_SEQ_ELEM_END
:
1176 case MIPI_SEQ_ELEM_SEND_PKT
:
1177 if (index
+ 4 > total
)
1180 len
= *((const u16
*)(data
+ index
+ 2)) + 4;
1182 case MIPI_SEQ_ELEM_DELAY
:
1185 case MIPI_SEQ_ELEM_GPIO
:
1188 case MIPI_SEQ_ELEM_I2C
:
1189 if (index
+ 7 > total
)
1191 len
= *(data
+ index
+ 6) + 7;
1194 DRM_ERROR("Unknown operation byte\n");
1202 static int goto_next_sequence_v3(const u8
*data
, int index
, int total
)
1206 u32 size_of_sequence
;
1209 * Could skip sequence based on Size of Sequence alone, but also do some
1210 * checking on the structure.
1213 DRM_ERROR("Too small sequence size\n");
1217 /* Skip Sequence Byte. */
1221 * Size of Sequence. Excludes the Sequence Byte and the size itself,
1222 * includes MIPI_SEQ_ELEM_END byte, excludes the final MIPI_SEQ_END
1225 size_of_sequence
= *((const u32
*)(data
+ index
));
1228 seq_end
= index
+ size_of_sequence
;
1229 if (seq_end
> total
) {
1230 DRM_ERROR("Invalid sequence size\n");
1234 for (; index
< total
; index
+= len
) {
1235 u8 operation_byte
= *(data
+ index
);
1238 if (operation_byte
== MIPI_SEQ_ELEM_END
) {
1239 if (index
!= seq_end
) {
1240 DRM_ERROR("Invalid element structure\n");
1246 len
= *(data
+ index
);
1250 * FIXME: Would be nice to check elements like for v1/v2 in
1251 * goto_next_sequence() above.
1253 switch (operation_byte
) {
1254 case MIPI_SEQ_ELEM_SEND_PKT
:
1255 case MIPI_SEQ_ELEM_DELAY
:
1256 case MIPI_SEQ_ELEM_GPIO
:
1257 case MIPI_SEQ_ELEM_I2C
:
1258 case MIPI_SEQ_ELEM_SPI
:
1259 case MIPI_SEQ_ELEM_PMIC
:
1262 DRM_ERROR("Unknown operation byte %u\n",
1272 * Get len of pre-fixed deassert fragment from a v1 init OTP sequence,
1273 * skip all delay + gpio operands and stop at the first DSI packet op.
1275 static int get_init_otp_deassert_fragment_len(struct drm_i915_private
*dev_priv
)
1277 const u8
*data
= dev_priv
->vbt
.dsi
.sequence
[MIPI_SEQ_INIT_OTP
];
1280 if (drm_WARN_ON(&dev_priv
->drm
,
1281 !data
|| dev_priv
->vbt
.dsi
.seq_version
!= 1))
1284 /* index = 1 to skip sequence byte */
1285 for (index
= 1; data
[index
] != MIPI_SEQ_ELEM_END
; index
+= len
) {
1286 switch (data
[index
]) {
1287 case MIPI_SEQ_ELEM_SEND_PKT
:
1288 return index
== 1 ? 0 : index
;
1289 case MIPI_SEQ_ELEM_DELAY
:
1290 len
= 5; /* 1 byte for operand + uint32 */
1292 case MIPI_SEQ_ELEM_GPIO
:
1293 len
= 3; /* 1 byte for op, 1 for gpio_nr, 1 for value */
1304 * Some v1 VBT MIPI sequences do the deassert in the init OTP sequence.
1305 * The deassert must be done before calling intel_dsi_device_ready, so for
1306 * these devices we split the init OTP sequence into a deassert sequence and
1307 * the actual init OTP part.
1309 static void fixup_mipi_sequences(struct drm_i915_private
*dev_priv
)
1314 /* Limit this to VLV for now. */
1315 if (!IS_VALLEYVIEW(dev_priv
))
1318 /* Limit this to v1 vid-mode sequences */
1319 if (dev_priv
->vbt
.dsi
.config
->is_cmd_mode
||
1320 dev_priv
->vbt
.dsi
.seq_version
!= 1)
1323 /* Only do this if there are otp and assert seqs and no deassert seq */
1324 if (!dev_priv
->vbt
.dsi
.sequence
[MIPI_SEQ_INIT_OTP
] ||
1325 !dev_priv
->vbt
.dsi
.sequence
[MIPI_SEQ_ASSERT_RESET
] ||
1326 dev_priv
->vbt
.dsi
.sequence
[MIPI_SEQ_DEASSERT_RESET
])
1329 /* The deassert-sequence ends at the first DSI packet */
1330 len
= get_init_otp_deassert_fragment_len(dev_priv
);
1334 drm_dbg_kms(&dev_priv
->drm
,
1335 "Using init OTP fragment to deassert reset\n");
1337 /* Copy the fragment, update seq byte and terminate it */
1338 init_otp
= (u8
*)dev_priv
->vbt
.dsi
.sequence
[MIPI_SEQ_INIT_OTP
];
1339 dev_priv
->vbt
.dsi
.deassert_seq
= kmemdup(init_otp
, len
+ 1, GFP_KERNEL
);
1340 if (!dev_priv
->vbt
.dsi
.deassert_seq
)
1342 dev_priv
->vbt
.dsi
.deassert_seq
[0] = MIPI_SEQ_DEASSERT_RESET
;
1343 dev_priv
->vbt
.dsi
.deassert_seq
[len
] = MIPI_SEQ_ELEM_END
;
1344 /* Use the copy for deassert */
1345 dev_priv
->vbt
.dsi
.sequence
[MIPI_SEQ_DEASSERT_RESET
] =
1346 dev_priv
->vbt
.dsi
.deassert_seq
;
1347 /* Replace the last byte of the fragment with init OTP seq byte */
1348 init_otp
[len
- 1] = MIPI_SEQ_INIT_OTP
;
1349 /* And make MIPI_MIPI_SEQ_INIT_OTP point to it */
1350 dev_priv
->vbt
.dsi
.sequence
[MIPI_SEQ_INIT_OTP
] = init_otp
+ len
- 1;
1354 parse_mipi_sequence(struct drm_i915_private
*dev_priv
,
1355 const struct bdb_header
*bdb
)
1357 int panel_type
= dev_priv
->vbt
.panel_type
;
1358 const struct bdb_mipi_sequence
*sequence
;
1364 /* Only our generic panel driver uses the sequence block. */
1365 if (dev_priv
->vbt
.dsi
.panel_id
!= MIPI_DSI_GENERIC_PANEL_ID
)
1368 sequence
= find_section(bdb
, BDB_MIPI_SEQUENCE
);
1370 drm_dbg_kms(&dev_priv
->drm
,
1371 "No MIPI Sequence found, parsing complete\n");
1375 /* Fail gracefully for forward incompatible sequence block. */
1376 if (sequence
->version
>= 4) {
1377 drm_err(&dev_priv
->drm
,
1378 "Unable to parse MIPI Sequence Block v%u\n",
1383 drm_dbg(&dev_priv
->drm
, "Found MIPI sequence block v%u\n",
1386 seq_data
= find_panel_sequence_block(sequence
, panel_type
, &seq_size
);
1390 data
= kmemdup(seq_data
, seq_size
, GFP_KERNEL
);
1394 /* Parse the sequences, store pointers to each sequence. */
1396 u8 seq_id
= *(data
+ index
);
1397 if (seq_id
== MIPI_SEQ_END
)
1400 if (seq_id
>= MIPI_SEQ_MAX
) {
1401 drm_err(&dev_priv
->drm
, "Unknown sequence %u\n",
1406 /* Log about presence of sequences we won't run. */
1407 if (seq_id
== MIPI_SEQ_TEAR_ON
|| seq_id
== MIPI_SEQ_TEAR_OFF
)
1408 drm_dbg_kms(&dev_priv
->drm
,
1409 "Unsupported sequence %u\n", seq_id
);
1411 dev_priv
->vbt
.dsi
.sequence
[seq_id
] = data
+ index
;
1413 if (sequence
->version
>= 3)
1414 index
= goto_next_sequence_v3(data
, index
, seq_size
);
1416 index
= goto_next_sequence(data
, index
, seq_size
);
1418 drm_err(&dev_priv
->drm
, "Invalid sequence %u\n",
1424 dev_priv
->vbt
.dsi
.data
= data
;
1425 dev_priv
->vbt
.dsi
.size
= seq_size
;
1426 dev_priv
->vbt
.dsi
.seq_version
= sequence
->version
;
1428 fixup_mipi_sequences(dev_priv
);
1430 drm_dbg(&dev_priv
->drm
, "MIPI related VBT parsing complete\n");
1435 memset(dev_priv
->vbt
.dsi
.sequence
, 0, sizeof(dev_priv
->vbt
.dsi
.sequence
));
1439 parse_compression_parameters(struct drm_i915_private
*i915
,
1440 const struct bdb_header
*bdb
)
1442 const struct bdb_compression_parameters
*params
;
1443 struct display_device_data
*devdata
;
1444 const struct child_device_config
*child
;
1448 if (bdb
->version
< 198)
1451 params
= find_section(bdb
, BDB_COMPRESSION_PARAMETERS
);
1454 if (params
->entry_size
!= sizeof(params
->data
[0])) {
1455 drm_dbg_kms(&i915
->drm
,
1456 "VBT: unsupported compression param entry size\n");
1460 block_size
= get_blocksize(params
);
1461 if (block_size
< sizeof(*params
)) {
1462 drm_dbg_kms(&i915
->drm
,
1463 "VBT: expected 16 compression param entries\n");
1468 list_for_each_entry(devdata
, &i915
->vbt
.display_devices
, node
) {
1469 child
= &devdata
->child
;
1471 if (!child
->compression_enable
)
1475 drm_dbg_kms(&i915
->drm
,
1476 "VBT: compression params not available\n");
1480 if (child
->compression_method_cps
) {
1481 drm_dbg_kms(&i915
->drm
,
1482 "VBT: CPS compression not supported\n");
1486 index
= child
->compression_structure_index
;
1488 devdata
->dsc
= kmemdup(¶ms
->data
[index
],
1489 sizeof(*devdata
->dsc
), GFP_KERNEL
);
1493 static u8
translate_iboost(u8 val
)
1495 static const u8 mapping
[] = { 1, 3, 7 }; /* See VBT spec */
1497 if (val
>= ARRAY_SIZE(mapping
)) {
1498 DRM_DEBUG_KMS("Unsupported I_boost value found in VBT (%d), display may not work properly\n", val
);
1501 return mapping
[val
];
1504 static enum port
get_port_by_ddc_pin(struct drm_i915_private
*i915
, u8 ddc_pin
)
1506 const struct ddi_vbt_port_info
*info
;
1509 for_each_port(port
) {
1510 info
= &i915
->vbt
.ddi_port_info
[port
];
1512 if (info
->child
&& ddc_pin
== info
->alternate_ddc_pin
)
1519 static void sanitize_ddc_pin(struct drm_i915_private
*dev_priv
,
1522 struct ddi_vbt_port_info
*info
= &dev_priv
->vbt
.ddi_port_info
[port
];
1525 if (!info
->alternate_ddc_pin
)
1528 p
= get_port_by_ddc_pin(dev_priv
, info
->alternate_ddc_pin
);
1529 if (p
!= PORT_NONE
) {
1530 drm_dbg_kms(&dev_priv
->drm
,
1531 "port %c trying to use the same DDC pin (0x%x) as port %c, "
1532 "disabling port %c DVI/HDMI support\n",
1533 port_name(port
), info
->alternate_ddc_pin
,
1534 port_name(p
), port_name(p
));
1537 * If we have multiple ports supposedly sharing the
1538 * pin, then dvi/hdmi couldn't exist on the shared
1539 * port. Otherwise they share the same ddc bin and
1540 * system couldn't communicate with them separately.
1542 * Give inverse child device order the priority,
1543 * last one wins. Yes, there are real machines
1544 * (eg. Asrock B250M-HDV) where VBT has both
1545 * port A and port E with the same AUX ch and
1546 * we must pick port E :(
1548 info
= &dev_priv
->vbt
.ddi_port_info
[p
];
1550 info
->supports_dvi
= false;
1551 info
->supports_hdmi
= false;
1552 info
->alternate_ddc_pin
= 0;
1556 static enum port
get_port_by_aux_ch(struct drm_i915_private
*i915
, u8 aux_ch
)
1558 const struct ddi_vbt_port_info
*info
;
1561 for_each_port(port
) {
1562 info
= &i915
->vbt
.ddi_port_info
[port
];
1564 if (info
->child
&& aux_ch
== info
->alternate_aux_channel
)
1571 static void sanitize_aux_ch(struct drm_i915_private
*dev_priv
,
1574 struct ddi_vbt_port_info
*info
= &dev_priv
->vbt
.ddi_port_info
[port
];
1577 if (!info
->alternate_aux_channel
)
1580 p
= get_port_by_aux_ch(dev_priv
, info
->alternate_aux_channel
);
1581 if (p
!= PORT_NONE
) {
1582 drm_dbg_kms(&dev_priv
->drm
,
1583 "port %c trying to use the same AUX CH (0x%x) as port %c, "
1584 "disabling port %c DP support\n",
1585 port_name(port
), info
->alternate_aux_channel
,
1586 port_name(p
), port_name(p
));
1589 * If we have multiple ports supposedlt sharing the
1590 * aux channel, then DP couldn't exist on the shared
1591 * port. Otherwise they share the same aux channel
1592 * and system couldn't communicate with them separately.
1594 * Give inverse child device order the priority,
1595 * last one wins. Yes, there are real machines
1596 * (eg. Asrock B250M-HDV) where VBT has both
1597 * port A and port E with the same AUX ch and
1598 * we must pick port E :(
1600 info
= &dev_priv
->vbt
.ddi_port_info
[p
];
1602 info
->supports_dp
= false;
1603 info
->alternate_aux_channel
= 0;
1607 static const u8 cnp_ddc_pin_map
[] = {
1609 [DDC_BUS_DDI_B
] = GMBUS_PIN_1_BXT
,
1610 [DDC_BUS_DDI_C
] = GMBUS_PIN_2_BXT
,
1611 [DDC_BUS_DDI_D
] = GMBUS_PIN_4_CNP
, /* sic */
1612 [DDC_BUS_DDI_F
] = GMBUS_PIN_3_BXT
, /* sic */
1615 static const u8 icp_ddc_pin_map
[] = {
1616 [ICL_DDC_BUS_DDI_A
] = GMBUS_PIN_1_BXT
,
1617 [ICL_DDC_BUS_DDI_B
] = GMBUS_PIN_2_BXT
,
1618 [TGL_DDC_BUS_DDI_C
] = GMBUS_PIN_3_BXT
,
1619 [ICL_DDC_BUS_PORT_1
] = GMBUS_PIN_9_TC1_ICP
,
1620 [ICL_DDC_BUS_PORT_2
] = GMBUS_PIN_10_TC2_ICP
,
1621 [ICL_DDC_BUS_PORT_3
] = GMBUS_PIN_11_TC3_ICP
,
1622 [ICL_DDC_BUS_PORT_4
] = GMBUS_PIN_12_TC4_ICP
,
1623 [TGL_DDC_BUS_PORT_5
] = GMBUS_PIN_13_TC5_TGP
,
1624 [TGL_DDC_BUS_PORT_6
] = GMBUS_PIN_14_TC6_TGP
,
1627 static const u8 rkl_pch_tgp_ddc_pin_map
[] = {
1628 [ICL_DDC_BUS_DDI_A
] = GMBUS_PIN_1_BXT
,
1629 [ICL_DDC_BUS_DDI_B
] = GMBUS_PIN_2_BXT
,
1630 [RKL_DDC_BUS_DDI_D
] = GMBUS_PIN_9_TC1_ICP
,
1631 [RKL_DDC_BUS_DDI_E
] = GMBUS_PIN_10_TC2_ICP
,
1634 static const u8 gen9bc_tgp_ddc_pin_map
[] = {
1635 [DDC_BUS_DDI_B
] = GMBUS_PIN_2_BXT
,
1636 [DDC_BUS_DDI_C
] = GMBUS_PIN_9_TC1_ICP
,
1637 [DDC_BUS_DDI_D
] = GMBUS_PIN_10_TC2_ICP
,
1640 static u8
map_ddc_pin(struct drm_i915_private
*dev_priv
, u8 vbt_pin
)
1642 const u8
*ddc_pin_map
;
1645 if (INTEL_PCH_TYPE(dev_priv
) >= PCH_DG1
) {
1647 } else if (IS_ROCKETLAKE(dev_priv
) && INTEL_PCH_TYPE(dev_priv
) == PCH_TGP
) {
1648 ddc_pin_map
= rkl_pch_tgp_ddc_pin_map
;
1649 n_entries
= ARRAY_SIZE(rkl_pch_tgp_ddc_pin_map
);
1650 } else if (HAS_PCH_TGP(dev_priv
) && IS_GEN9_BC(dev_priv
)) {
1651 ddc_pin_map
= gen9bc_tgp_ddc_pin_map
;
1652 n_entries
= ARRAY_SIZE(gen9bc_tgp_ddc_pin_map
);
1653 } else if (INTEL_PCH_TYPE(dev_priv
) >= PCH_ICP
) {
1654 ddc_pin_map
= icp_ddc_pin_map
;
1655 n_entries
= ARRAY_SIZE(icp_ddc_pin_map
);
1656 } else if (HAS_PCH_CNP(dev_priv
)) {
1657 ddc_pin_map
= cnp_ddc_pin_map
;
1658 n_entries
= ARRAY_SIZE(cnp_ddc_pin_map
);
1660 /* Assuming direct map */
1664 if (vbt_pin
< n_entries
&& ddc_pin_map
[vbt_pin
] != 0)
1665 return ddc_pin_map
[vbt_pin
];
1667 drm_dbg_kms(&dev_priv
->drm
,
1668 "Ignoring alternate pin: VBT claims DDC pin %d, which is not valid for this platform\n",
1673 static enum port
__dvo_port_to_port(int n_ports
, int n_dvo
,
1674 const int port_mapping
[][3], u8 dvo_port
)
1679 for (port
= PORT_A
; port
< n_ports
; port
++) {
1680 for (i
= 0; i
< n_dvo
; i
++) {
1681 if (port_mapping
[port
][i
] == -1)
1684 if (dvo_port
== port_mapping
[port
][i
])
1692 static enum port
dvo_port_to_port(struct drm_i915_private
*dev_priv
,
1696 * Each DDI port can have more than one value on the "DVO Port" field,
1697 * so look for all the possible values for each port.
1699 static const int port_mapping
[][3] = {
1700 [PORT_A
] = { DVO_PORT_HDMIA
, DVO_PORT_DPA
, -1 },
1701 [PORT_B
] = { DVO_PORT_HDMIB
, DVO_PORT_DPB
, -1 },
1702 [PORT_C
] = { DVO_PORT_HDMIC
, DVO_PORT_DPC
, -1 },
1703 [PORT_D
] = { DVO_PORT_HDMID
, DVO_PORT_DPD
, -1 },
1704 [PORT_E
] = { DVO_PORT_HDMIE
, DVO_PORT_DPE
, DVO_PORT_CRT
},
1705 [PORT_F
] = { DVO_PORT_HDMIF
, DVO_PORT_DPF
, -1 },
1706 [PORT_G
] = { DVO_PORT_HDMIG
, DVO_PORT_DPG
, -1 },
1707 [PORT_H
] = { DVO_PORT_HDMIH
, DVO_PORT_DPH
, -1 },
1708 [PORT_I
] = { DVO_PORT_HDMII
, DVO_PORT_DPI
, -1 },
1711 * RKL VBT uses PHY based mapping. Combo PHYs A,B,C,D
1712 * map to DDI A,B,TC1,TC2 respectively.
1714 static const int rkl_port_mapping
[][3] = {
1715 [PORT_A
] = { DVO_PORT_HDMIA
, DVO_PORT_DPA
, -1 },
1716 [PORT_B
] = { DVO_PORT_HDMIB
, DVO_PORT_DPB
, -1 },
1718 [PORT_TC1
] = { DVO_PORT_HDMIC
, DVO_PORT_DPC
, -1 },
1719 [PORT_TC2
] = { DVO_PORT_HDMID
, DVO_PORT_DPD
, -1 },
1722 if (IS_DG1(dev_priv
) || IS_ROCKETLAKE(dev_priv
))
1723 return __dvo_port_to_port(ARRAY_SIZE(rkl_port_mapping
),
1724 ARRAY_SIZE(rkl_port_mapping
[0]),
1728 return __dvo_port_to_port(ARRAY_SIZE(port_mapping
),
1729 ARRAY_SIZE(port_mapping
[0]),
1734 static int parse_bdb_230_dp_max_link_rate(const int vbt_max_link_rate
)
1736 switch (vbt_max_link_rate
) {
1738 case BDB_230_VBT_DP_MAX_LINK_RATE_DEF
:
1740 case BDB_230_VBT_DP_MAX_LINK_RATE_UHBR20
:
1742 case BDB_230_VBT_DP_MAX_LINK_RATE_UHBR13P5
:
1744 case BDB_230_VBT_DP_MAX_LINK_RATE_UHBR10
:
1746 case BDB_230_VBT_DP_MAX_LINK_RATE_HBR3
:
1748 case BDB_230_VBT_DP_MAX_LINK_RATE_HBR2
:
1750 case BDB_230_VBT_DP_MAX_LINK_RATE_HBR
:
1752 case BDB_230_VBT_DP_MAX_LINK_RATE_LBR
:
1757 static int parse_bdb_216_dp_max_link_rate(const int vbt_max_link_rate
)
1759 switch (vbt_max_link_rate
) {
1761 case BDB_216_VBT_DP_MAX_LINK_RATE_HBR3
:
1763 case BDB_216_VBT_DP_MAX_LINK_RATE_HBR2
:
1765 case BDB_216_VBT_DP_MAX_LINK_RATE_HBR
:
1767 case BDB_216_VBT_DP_MAX_LINK_RATE_LBR
:
1772 static void parse_ddi_port(struct drm_i915_private
*dev_priv
,
1773 struct display_device_data
*devdata
,
1776 const struct child_device_config
*child
= &devdata
->child
;
1777 struct ddi_vbt_port_info
*info
;
1778 bool is_dvi
, is_hdmi
, is_dp
, is_edp
, is_crt
;
1781 port
= dvo_port_to_port(dev_priv
, child
->dvo_port
);
1782 if (port
== PORT_NONE
)
1785 info
= &dev_priv
->vbt
.ddi_port_info
[port
];
1788 drm_dbg_kms(&dev_priv
->drm
,
1789 "More than one child device for port %c in VBT, using the first.\n",
1794 is_dvi
= child
->device_type
& DEVICE_TYPE_TMDS_DVI_SIGNALING
;
1795 is_dp
= child
->device_type
& DEVICE_TYPE_DISPLAYPORT_OUTPUT
;
1796 is_crt
= child
->device_type
& DEVICE_TYPE_ANALOG_OUTPUT
;
1797 is_hdmi
= is_dvi
&& (child
->device_type
& DEVICE_TYPE_NOT_HDMI_OUTPUT
) == 0;
1798 is_edp
= is_dp
&& (child
->device_type
& DEVICE_TYPE_INTERNAL_CONNECTOR
);
1800 if (port
== PORT_A
&& is_dvi
&& INTEL_GEN(dev_priv
) < 12) {
1801 drm_dbg_kms(&dev_priv
->drm
,
1802 "VBT claims port A supports DVI%s, ignoring\n",
1803 is_hdmi
? "/HDMI" : "");
1808 info
->supports_dvi
= is_dvi
;
1809 info
->supports_hdmi
= is_hdmi
;
1810 info
->supports_dp
= is_dp
;
1811 info
->supports_edp
= is_edp
;
1813 if (bdb_version
>= 195)
1814 info
->supports_typec_usb
= child
->dp_usb_type_c
;
1816 if (bdb_version
>= 209)
1817 info
->supports_tbt
= child
->tbt
;
1819 drm_dbg_kms(&dev_priv
->drm
,
1820 "Port %c VBT info: CRT:%d DVI:%d HDMI:%d DP:%d eDP:%d LSPCON:%d USB-Type-C:%d TBT:%d DSC:%d\n",
1821 port_name(port
), is_crt
, is_dvi
, is_hdmi
, is_dp
, is_edp
,
1822 HAS_LSPCON(dev_priv
) && child
->lspcon
,
1823 info
->supports_typec_usb
, info
->supports_tbt
,
1824 devdata
->dsc
!= NULL
);
1829 ddc_pin
= map_ddc_pin(dev_priv
, child
->ddc_pin
);
1830 if (intel_gmbus_is_valid_pin(dev_priv
, ddc_pin
)) {
1831 info
->alternate_ddc_pin
= ddc_pin
;
1832 sanitize_ddc_pin(dev_priv
, port
);
1834 drm_dbg_kms(&dev_priv
->drm
,
1835 "Port %c has invalid DDC pin %d, "
1836 "sticking to defaults\n",
1837 port_name(port
), ddc_pin
);
1842 info
->alternate_aux_channel
= child
->aux_channel
;
1844 sanitize_aux_ch(dev_priv
, port
);
1847 if (bdb_version
>= 158) {
1848 /* The VBT HDMI level shift values match the table we have. */
1849 u8 hdmi_level_shift
= child
->hdmi_level_shifter_value
;
1850 drm_dbg_kms(&dev_priv
->drm
,
1851 "VBT HDMI level shift for port %c: %d\n",
1854 info
->hdmi_level_shift
= hdmi_level_shift
;
1855 info
->hdmi_level_shift_set
= true;
1858 if (bdb_version
>= 204) {
1861 switch (child
->hdmi_max_data_rate
) {
1863 MISSING_CASE(child
->hdmi_max_data_rate
);
1865 case HDMI_MAX_DATA_RATE_PLATFORM
:
1868 case HDMI_MAX_DATA_RATE_297
:
1869 max_tmds_clock
= 297000;
1871 case HDMI_MAX_DATA_RATE_165
:
1872 max_tmds_clock
= 165000;
1877 drm_dbg_kms(&dev_priv
->drm
,
1878 "VBT HDMI max TMDS clock for port %c: %d kHz\n",
1879 port_name(port
), max_tmds_clock
);
1880 info
->max_tmds_clock
= max_tmds_clock
;
1883 /* Parse the I_boost config for SKL and above */
1884 if (bdb_version
>= 196 && child
->iboost
) {
1885 info
->dp_boost_level
= translate_iboost(child
->dp_iboost_level
);
1886 drm_dbg_kms(&dev_priv
->drm
,
1887 "VBT (e)DP boost level for port %c: %d\n",
1888 port_name(port
), info
->dp_boost_level
);
1889 info
->hdmi_boost_level
= translate_iboost(child
->hdmi_iboost_level
);
1890 drm_dbg_kms(&dev_priv
->drm
,
1891 "VBT HDMI boost level for port %c: %d\n",
1892 port_name(port
), info
->hdmi_boost_level
);
1895 /* DP max link rate for CNL+ */
1896 if (bdb_version
>= 216) {
1897 if (bdb_version
>= 230)
1898 info
->dp_max_link_rate
= parse_bdb_230_dp_max_link_rate(child
->dp_max_link_rate
);
1900 info
->dp_max_link_rate
= parse_bdb_216_dp_max_link_rate(child
->dp_max_link_rate
);
1902 drm_dbg_kms(&dev_priv
->drm
,
1903 "VBT DP max link rate for port %c: %d\n",
1904 port_name(port
), info
->dp_max_link_rate
);
1907 info
->child
= child
;
1910 static void parse_ddi_ports(struct drm_i915_private
*dev_priv
, u8 bdb_version
)
1912 struct display_device_data
*devdata
;
1914 if (!HAS_DDI(dev_priv
) && !IS_CHERRYVIEW(dev_priv
))
1917 if (bdb_version
< 155)
1920 list_for_each_entry(devdata
, &dev_priv
->vbt
.display_devices
, node
)
1921 parse_ddi_port(dev_priv
, devdata
, bdb_version
);
1925 parse_general_definitions(struct drm_i915_private
*dev_priv
,
1926 const struct bdb_header
*bdb
)
1928 const struct bdb_general_definitions
*defs
;
1929 struct display_device_data
*devdata
;
1930 const struct child_device_config
*child
;
1931 int i
, child_device_num
;
1936 defs
= find_section(bdb
, BDB_GENERAL_DEFINITIONS
);
1938 drm_dbg_kms(&dev_priv
->drm
,
1939 "No general definition block is found, no devices defined.\n");
1943 block_size
= get_blocksize(defs
);
1944 if (block_size
< sizeof(*defs
)) {
1945 drm_dbg_kms(&dev_priv
->drm
,
1946 "General definitions block too small (%u)\n",
1951 bus_pin
= defs
->crt_ddc_gmbus_pin
;
1952 drm_dbg_kms(&dev_priv
->drm
, "crt_ddc_bus_pin: %d\n", bus_pin
);
1953 if (intel_gmbus_is_valid_pin(dev_priv
, bus_pin
))
1954 dev_priv
->vbt
.crt_ddc_pin
= bus_pin
;
1956 if (bdb
->version
< 106) {
1958 } else if (bdb
->version
< 111) {
1960 } else if (bdb
->version
< 195) {
1961 expected_size
= LEGACY_CHILD_DEVICE_CONFIG_SIZE
;
1962 } else if (bdb
->version
== 195) {
1964 } else if (bdb
->version
<= 215) {
1966 } else if (bdb
->version
<= 237) {
1969 expected_size
= sizeof(*child
);
1970 BUILD_BUG_ON(sizeof(*child
) < 39);
1971 drm_dbg(&dev_priv
->drm
,
1972 "Expected child device config size for VBT version %u not known; assuming %u\n",
1973 bdb
->version
, expected_size
);
1976 /* Flag an error for unexpected size, but continue anyway. */
1977 if (defs
->child_dev_size
!= expected_size
)
1978 drm_err(&dev_priv
->drm
,
1979 "Unexpected child device config size %u (expected %u for VBT version %u)\n",
1980 defs
->child_dev_size
, expected_size
, bdb
->version
);
1982 /* The legacy sized child device config is the minimum we need. */
1983 if (defs
->child_dev_size
< LEGACY_CHILD_DEVICE_CONFIG_SIZE
) {
1984 drm_dbg_kms(&dev_priv
->drm
,
1985 "Child device config size %u is too small.\n",
1986 defs
->child_dev_size
);
1990 /* get the number of child device */
1991 child_device_num
= (block_size
- sizeof(*defs
)) / defs
->child_dev_size
;
1993 for (i
= 0; i
< child_device_num
; i
++) {
1994 child
= child_device_ptr(defs
, i
);
1995 if (!child
->device_type
)
1998 drm_dbg_kms(&dev_priv
->drm
,
1999 "Found VBT child device with type 0x%x\n",
2000 child
->device_type
);
2002 devdata
= kzalloc(sizeof(*devdata
), GFP_KERNEL
);
2007 * Copy as much as we know (sizeof) and is available
2008 * (child_dev_size) of the child device config. Accessing the
2009 * data must depend on VBT version.
2011 memcpy(&devdata
->child
, child
,
2012 min_t(size_t, defs
->child_dev_size
, sizeof(*child
)));
2014 list_add_tail(&devdata
->node
, &dev_priv
->vbt
.display_devices
);
2017 if (list_empty(&dev_priv
->vbt
.display_devices
))
2018 drm_dbg_kms(&dev_priv
->drm
,
2019 "no child dev is parsed from VBT\n");
2022 /* Common defaults which may be overridden by VBT. */
2024 init_vbt_defaults(struct drm_i915_private
*dev_priv
)
2026 dev_priv
->vbt
.crt_ddc_pin
= GMBUS_PIN_VGADDC
;
2028 /* Default to having backlight */
2029 dev_priv
->vbt
.backlight
.present
= true;
2031 /* LFP panel data */
2032 dev_priv
->vbt
.lvds_dither
= 1;
2034 /* SDVO panel data */
2035 dev_priv
->vbt
.sdvo_lvds_vbt_mode
= NULL
;
2037 /* general features */
2038 dev_priv
->vbt
.int_tv_support
= 1;
2039 dev_priv
->vbt
.int_crt_support
= 1;
2041 /* driver features */
2042 dev_priv
->vbt
.int_lvds_support
= 1;
2044 /* Default to using SSC */
2045 dev_priv
->vbt
.lvds_use_ssc
= 1;
2047 * Core/SandyBridge/IvyBridge use alternative (120MHz) reference
2050 dev_priv
->vbt
.lvds_ssc_freq
= intel_bios_ssc_frequency(dev_priv
,
2051 !HAS_PCH_SPLIT(dev_priv
));
2052 drm_dbg_kms(&dev_priv
->drm
, "Set default to SSC at %d kHz\n",
2053 dev_priv
->vbt
.lvds_ssc_freq
);
2056 /* Defaults to initialize only if there is no VBT. */
2058 init_vbt_missing_defaults(struct drm_i915_private
*dev_priv
)
2062 for_each_port(port
) {
2063 struct ddi_vbt_port_info
*info
=
2064 &dev_priv
->vbt
.ddi_port_info
[port
];
2065 enum phy phy
= intel_port_to_phy(dev_priv
, port
);
2068 * VBT has the TypeC mode (native,TBT/USB) and we don't want
2071 if (intel_phy_is_tc(dev_priv
, phy
))
2074 info
->supports_dvi
= (port
!= PORT_A
&& port
!= PORT_E
);
2075 info
->supports_hdmi
= info
->supports_dvi
;
2076 info
->supports_dp
= (port
!= PORT_E
);
2077 info
->supports_edp
= (port
== PORT_A
);
2081 static const struct bdb_header
*get_bdb_header(const struct vbt_header
*vbt
)
2083 const void *_vbt
= vbt
;
2085 return _vbt
+ vbt
->bdb_offset
;
2089 * intel_bios_is_valid_vbt - does the given buffer contain a valid VBT
2090 * @buf: pointer to a buffer to validate
2091 * @size: size of the buffer
2093 * Returns true on valid VBT.
2095 bool intel_bios_is_valid_vbt(const void *buf
, size_t size
)
2097 const struct vbt_header
*vbt
= buf
;
2098 const struct bdb_header
*bdb
;
2103 if (sizeof(struct vbt_header
) > size
) {
2104 DRM_DEBUG_DRIVER("VBT header incomplete\n");
2108 if (memcmp(vbt
->signature
, "$VBT", 4)) {
2109 DRM_DEBUG_DRIVER("VBT invalid signature\n");
2113 if (vbt
->vbt_size
> size
) {
2114 DRM_DEBUG_DRIVER("VBT incomplete (vbt_size overflows)\n");
2118 size
= vbt
->vbt_size
;
2120 if (range_overflows_t(size_t,
2122 sizeof(struct bdb_header
),
2124 DRM_DEBUG_DRIVER("BDB header incomplete\n");
2128 bdb
= get_bdb_header(vbt
);
2129 if (range_overflows_t(size_t, vbt
->bdb_offset
, bdb
->bdb_size
, size
)) {
2130 DRM_DEBUG_DRIVER("BDB incomplete\n");
2137 static struct vbt_header
*oprom_get_vbt(struct drm_i915_private
*dev_priv
)
2139 struct pci_dev
*pdev
= dev_priv
->drm
.pdev
;
2140 void __iomem
*p
= NULL
, *oprom
;
2141 struct vbt_header
*vbt
;
2145 oprom
= pci_map_rom(pdev
, &size
);
2149 /* Scour memory looking for the VBT signature. */
2150 for (i
= 0; i
+ 4 < size
; i
+= 4) {
2151 if (ioread32(oprom
+ i
) != *((const u32
*)"$VBT"))
2160 goto err_unmap_oprom
;
2162 if (sizeof(struct vbt_header
) > size
) {
2163 drm_dbg(&dev_priv
->drm
, "VBT header incomplete\n");
2164 goto err_unmap_oprom
;
2167 vbt_size
= ioread16(p
+ offsetof(struct vbt_header
, vbt_size
));
2168 if (vbt_size
> size
) {
2169 drm_dbg(&dev_priv
->drm
,
2170 "VBT incomplete (vbt_size overflows)\n");
2171 goto err_unmap_oprom
;
2174 /* The rest will be validated by intel_bios_is_valid_vbt() */
2175 vbt
= kmalloc(vbt_size
, GFP_KERNEL
);
2177 goto err_unmap_oprom
;
2179 memcpy_fromio(vbt
, p
, vbt_size
);
2181 if (!intel_bios_is_valid_vbt(vbt
, vbt_size
))
2184 pci_unmap_rom(pdev
, oprom
);
2191 pci_unmap_rom(pdev
, oprom
);
2196 #define DRM_DMI_PRODUCT_VERSION 0x6
2198 static void parse_product_info(struct drm_i915_private
*dev_priv
)
2200 const char *product_ver
= dmi_get_system_info(DRM_DMI_PRODUCT_VERSION
);
2204 if (!strncmp(product_ver
, "ThinkPad X1", 11)) {
2205 DRM_DEBUG_KMS("dmi: %s, Bypassing TMDS_OE write\n", product_ver
);
2206 dev_priv
->bypass_tmds_oe
= true;
2213 * intel_bios_init - find VBT and initialize settings from the BIOS
2214 * @dev_priv: i915 device instance
2216 * Parse and initialize settings from the Video BIOS Tables (VBT). If the VBT
2217 * was not found in ACPI OpRegion, try to find it in PCI ROM first. Also
2218 * initialize some defaults if the VBT is not present at all.
2220 void intel_bios_init(struct drm_i915_private
*dev_priv
)
2222 const struct vbt_header
*vbt
= dev_priv
->opregion
.vbt
;
2223 struct vbt_header
*oprom_vbt
= NULL
;
2224 const struct bdb_header
*bdb
;
2226 INIT_LIST_HEAD(&dev_priv
->vbt
.display_devices
);
2228 if (!HAS_DISPLAY(dev_priv
)) {
2229 drm_dbg_kms(&dev_priv
->drm
,
2230 "Skipping VBT init due to disabled display.\n");
2234 init_vbt_defaults(dev_priv
);
2236 /* If the OpRegion does not have VBT, look in PCI ROM. */
2238 oprom_vbt
= oprom_get_vbt(dev_priv
);
2244 drm_dbg_kms(&dev_priv
->drm
, "Found valid VBT in PCI ROM\n");
2247 bdb
= get_bdb_header(vbt
);
2249 drm_dbg_kms(&dev_priv
->drm
,
2250 "VBT signature \"%.*s\", BDB version %d\n",
2251 (int)sizeof(vbt
->signature
), vbt
->signature
, bdb
->version
);
2253 /* Grab useful general definitions */
2254 parse_general_features(dev_priv
, bdb
);
2255 parse_general_definitions(dev_priv
, bdb
);
2256 parse_panel_options(dev_priv
, bdb
);
2257 parse_panel_dtd(dev_priv
, bdb
);
2258 parse_lfp_backlight(dev_priv
, bdb
);
2259 parse_sdvo_panel_data(dev_priv
, bdb
);
2260 parse_driver_features(dev_priv
, bdb
);
2261 parse_power_conservation_features(dev_priv
, bdb
);
2262 parse_edp(dev_priv
, bdb
);
2263 parse_psr(dev_priv
, bdb
);
2264 parse_mipi_config(dev_priv
, bdb
);
2265 parse_mipi_sequence(dev_priv
, bdb
);
2267 /* Depends on child device list */
2268 parse_compression_parameters(dev_priv
, bdb
);
2270 /* Further processing on pre-parsed data */
2271 parse_sdvo_device_mapping(dev_priv
, bdb
->version
);
2272 parse_ddi_ports(dev_priv
, bdb
->version
);
2274 parse_product_info(dev_priv
);
2278 drm_info(&dev_priv
->drm
,
2279 "Failed to find VBIOS tables (VBT)\n");
2280 init_vbt_missing_defaults(dev_priv
);
2287 * intel_bios_driver_remove - Free any resources allocated by intel_bios_init()
2288 * @dev_priv: i915 device instance
2290 void intel_bios_driver_remove(struct drm_i915_private
*dev_priv
)
2292 struct display_device_data
*devdata
, *n
;
2294 list_for_each_entry_safe(devdata
, n
, &dev_priv
->vbt
.display_devices
, node
) {
2295 list_del(&devdata
->node
);
2296 kfree(devdata
->dsc
);
2300 kfree(dev_priv
->vbt
.sdvo_lvds_vbt_mode
);
2301 dev_priv
->vbt
.sdvo_lvds_vbt_mode
= NULL
;
2302 kfree(dev_priv
->vbt
.lfp_lvds_vbt_mode
);
2303 dev_priv
->vbt
.lfp_lvds_vbt_mode
= NULL
;
2304 kfree(dev_priv
->vbt
.dsi
.data
);
2305 dev_priv
->vbt
.dsi
.data
= NULL
;
2306 kfree(dev_priv
->vbt
.dsi
.pps
);
2307 dev_priv
->vbt
.dsi
.pps
= NULL
;
2308 kfree(dev_priv
->vbt
.dsi
.config
);
2309 dev_priv
->vbt
.dsi
.config
= NULL
;
2310 kfree(dev_priv
->vbt
.dsi
.deassert_seq
);
2311 dev_priv
->vbt
.dsi
.deassert_seq
= NULL
;
2315 * intel_bios_is_tv_present - is integrated TV present in VBT
2316 * @dev_priv: i915 device instance
2318 * Return true if TV is present. If no child devices were parsed from VBT,
2319 * assume TV is present.
2321 bool intel_bios_is_tv_present(struct drm_i915_private
*dev_priv
)
2323 const struct display_device_data
*devdata
;
2324 const struct child_device_config
*child
;
2326 if (!dev_priv
->vbt
.int_tv_support
)
2329 if (list_empty(&dev_priv
->vbt
.display_devices
))
2332 list_for_each_entry(devdata
, &dev_priv
->vbt
.display_devices
, node
) {
2333 child
= &devdata
->child
;
2336 * If the device type is not TV, continue.
2338 switch (child
->device_type
) {
2339 case DEVICE_TYPE_INT_TV
:
2340 case DEVICE_TYPE_TV
:
2341 case DEVICE_TYPE_TV_SVIDEO_COMPOSITE
:
2346 /* Only when the addin_offset is non-zero, it is regarded
2349 if (child
->addin_offset
)
2357 * intel_bios_is_lvds_present - is LVDS present in VBT
2358 * @dev_priv: i915 device instance
2359 * @i2c_pin: i2c pin for LVDS if present
2361 * Return true if LVDS is present. If no child devices were parsed from VBT,
2362 * assume LVDS is present.
2364 bool intel_bios_is_lvds_present(struct drm_i915_private
*dev_priv
, u8
*i2c_pin
)
2366 const struct display_device_data
*devdata
;
2367 const struct child_device_config
*child
;
2369 if (list_empty(&dev_priv
->vbt
.display_devices
))
2372 list_for_each_entry(devdata
, &dev_priv
->vbt
.display_devices
, node
) {
2373 child
= &devdata
->child
;
2375 /* If the device type is not LFP, continue.
2376 * We have to check both the new identifiers as well as the
2377 * old for compatibility with some BIOSes.
2379 if (child
->device_type
!= DEVICE_TYPE_INT_LFP
&&
2380 child
->device_type
!= DEVICE_TYPE_LFP
)
2383 if (intel_gmbus_is_valid_pin(dev_priv
, child
->i2c_pin
))
2384 *i2c_pin
= child
->i2c_pin
;
2386 /* However, we cannot trust the BIOS writers to populate
2387 * the VBT correctly. Since LVDS requires additional
2388 * information from AIM blocks, a non-zero addin offset is
2389 * a good indicator that the LVDS is actually present.
2391 if (child
->addin_offset
)
2394 /* But even then some BIOS writers perform some black magic
2395 * and instantiate the device without reference to any
2396 * additional data. Trust that if the VBT was written into
2397 * the OpRegion then they have validated the LVDS's existence.
2399 if (dev_priv
->opregion
.vbt
)
2407 * intel_bios_is_port_present - is the specified digital port present
2408 * @dev_priv: i915 device instance
2409 * @port: port to check
2411 * Return true if the device in %port is present.
2413 bool intel_bios_is_port_present(struct drm_i915_private
*dev_priv
, enum port port
)
2415 const struct display_device_data
*devdata
;
2416 const struct child_device_config
*child
;
2417 static const struct {
2419 } port_mapping
[] = {
2420 [PORT_B
] = { DVO_PORT_DPB
, DVO_PORT_HDMIB
, },
2421 [PORT_C
] = { DVO_PORT_DPC
, DVO_PORT_HDMIC
, },
2422 [PORT_D
] = { DVO_PORT_DPD
, DVO_PORT_HDMID
, },
2423 [PORT_E
] = { DVO_PORT_DPE
, DVO_PORT_HDMIE
, },
2424 [PORT_F
] = { DVO_PORT_DPF
, DVO_PORT_HDMIF
, },
2427 if (HAS_DDI(dev_priv
)) {
2428 const struct ddi_vbt_port_info
*port_info
=
2429 &dev_priv
->vbt
.ddi_port_info
[port
];
2431 return port_info
->child
;
2434 /* FIXME maybe deal with port A as well? */
2435 if (drm_WARN_ON(&dev_priv
->drm
,
2436 port
== PORT_A
) || port
>= ARRAY_SIZE(port_mapping
))
2439 list_for_each_entry(devdata
, &dev_priv
->vbt
.display_devices
, node
) {
2440 child
= &devdata
->child
;
2442 if ((child
->dvo_port
== port_mapping
[port
].dp
||
2443 child
->dvo_port
== port_mapping
[port
].hdmi
) &&
2444 (child
->device_type
& (DEVICE_TYPE_TMDS_DVI_SIGNALING
|
2445 DEVICE_TYPE_DISPLAYPORT_OUTPUT
)))
2453 * intel_bios_is_port_edp - is the device in given port eDP
2454 * @dev_priv: i915 device instance
2455 * @port: port to check
2457 * Return true if the device in %port is eDP.
2459 bool intel_bios_is_port_edp(struct drm_i915_private
*dev_priv
, enum port port
)
2461 const struct display_device_data
*devdata
;
2462 const struct child_device_config
*child
;
2463 static const short port_mapping
[] = {
2464 [PORT_B
] = DVO_PORT_DPB
,
2465 [PORT_C
] = DVO_PORT_DPC
,
2466 [PORT_D
] = DVO_PORT_DPD
,
2467 [PORT_E
] = DVO_PORT_DPE
,
2468 [PORT_F
] = DVO_PORT_DPF
,
2471 if (HAS_DDI(dev_priv
))
2472 return dev_priv
->vbt
.ddi_port_info
[port
].supports_edp
;
2474 list_for_each_entry(devdata
, &dev_priv
->vbt
.display_devices
, node
) {
2475 child
= &devdata
->child
;
2477 if (child
->dvo_port
== port_mapping
[port
] &&
2478 (child
->device_type
& DEVICE_TYPE_eDP_BITS
) ==
2479 (DEVICE_TYPE_eDP
& DEVICE_TYPE_eDP_BITS
))
2486 static bool child_dev_is_dp_dual_mode(const struct child_device_config
*child
,
2489 static const struct {
2491 } port_mapping
[] = {
2493 * Buggy VBTs may declare DP ports as having
2494 * HDMI type dvo_port :( So let's check both.
2496 [PORT_B
] = { DVO_PORT_DPB
, DVO_PORT_HDMIB
, },
2497 [PORT_C
] = { DVO_PORT_DPC
, DVO_PORT_HDMIC
, },
2498 [PORT_D
] = { DVO_PORT_DPD
, DVO_PORT_HDMID
, },
2499 [PORT_E
] = { DVO_PORT_DPE
, DVO_PORT_HDMIE
, },
2500 [PORT_F
] = { DVO_PORT_DPF
, DVO_PORT_HDMIF
, },
2503 if (port
== PORT_A
|| port
>= ARRAY_SIZE(port_mapping
))
2506 if ((child
->device_type
& DEVICE_TYPE_DP_DUAL_MODE_BITS
) !=
2507 (DEVICE_TYPE_DP_DUAL_MODE
& DEVICE_TYPE_DP_DUAL_MODE_BITS
))
2510 if (child
->dvo_port
== port_mapping
[port
].dp
)
2513 /* Only accept a HDMI dvo_port as DP++ if it has an AUX channel */
2514 if (child
->dvo_port
== port_mapping
[port
].hdmi
&&
2515 child
->aux_channel
!= 0)
2521 bool intel_bios_is_port_dp_dual_mode(struct drm_i915_private
*dev_priv
,
2524 const struct display_device_data
*devdata
;
2526 list_for_each_entry(devdata
, &dev_priv
->vbt
.display_devices
, node
) {
2527 if (child_dev_is_dp_dual_mode(&devdata
->child
, port
))
2535 * intel_bios_is_dsi_present - is DSI present in VBT
2536 * @dev_priv: i915 device instance
2537 * @port: port for DSI if present
2539 * Return true if DSI is present, and return the port in %port.
2541 bool intel_bios_is_dsi_present(struct drm_i915_private
*dev_priv
,
2544 const struct display_device_data
*devdata
;
2545 const struct child_device_config
*child
;
2548 list_for_each_entry(devdata
, &dev_priv
->vbt
.display_devices
, node
) {
2549 child
= &devdata
->child
;
2551 if (!(child
->device_type
& DEVICE_TYPE_MIPI_OUTPUT
))
2554 dvo_port
= child
->dvo_port
;
2556 if (dvo_port
== DVO_PORT_MIPIA
||
2557 (dvo_port
== DVO_PORT_MIPIB
&& INTEL_GEN(dev_priv
) >= 11) ||
2558 (dvo_port
== DVO_PORT_MIPIC
&& INTEL_GEN(dev_priv
) < 11)) {
2560 *port
= dvo_port
- DVO_PORT_MIPIA
;
2562 } else if (dvo_port
== DVO_PORT_MIPIB
||
2563 dvo_port
== DVO_PORT_MIPIC
||
2564 dvo_port
== DVO_PORT_MIPID
) {
2565 drm_dbg_kms(&dev_priv
->drm
,
2566 "VBT has unsupported DSI port %c\n",
2567 port_name(dvo_port
- DVO_PORT_MIPIA
));
2574 static void fill_dsc(struct intel_crtc_state
*crtc_state
,
2575 struct dsc_compression_parameters_entry
*dsc
,
2578 struct drm_dsc_config
*vdsc_cfg
= &crtc_state
->dsc
.config
;
2581 vdsc_cfg
->dsc_version_major
= dsc
->version_major
;
2582 vdsc_cfg
->dsc_version_minor
= dsc
->version_minor
;
2584 if (dsc
->support_12bpc
&& dsc_max_bpc
>= 12)
2586 else if (dsc
->support_10bpc
&& dsc_max_bpc
>= 10)
2588 else if (dsc
->support_8bpc
&& dsc_max_bpc
>= 8)
2591 DRM_DEBUG_KMS("VBT: Unsupported BPC %d for DCS\n",
2594 crtc_state
->pipe_bpp
= bpc
* 3;
2596 crtc_state
->dsc
.compressed_bpp
= min(crtc_state
->pipe_bpp
,
2597 VBT_DSC_MAX_BPP(dsc
->max_bpp
));
2600 * FIXME: This is ugly, and slice count should take DSC engine
2601 * throughput etc. into account.
2603 * Also, per spec DSI supports 1, 2, 3 or 4 horizontal slices.
2605 if (dsc
->slices_per_line
& BIT(2)) {
2606 crtc_state
->dsc
.slice_count
= 4;
2607 } else if (dsc
->slices_per_line
& BIT(1)) {
2608 crtc_state
->dsc
.slice_count
= 2;
2611 if (!(dsc
->slices_per_line
& BIT(0)))
2612 DRM_DEBUG_KMS("VBT: Unsupported DSC slice count for DSI\n");
2614 crtc_state
->dsc
.slice_count
= 1;
2617 if (crtc_state
->hw
.adjusted_mode
.crtc_hdisplay
%
2618 crtc_state
->dsc
.slice_count
!= 0)
2619 DRM_DEBUG_KMS("VBT: DSC hdisplay %d not divisible by slice count %d\n",
2620 crtc_state
->hw
.adjusted_mode
.crtc_hdisplay
,
2621 crtc_state
->dsc
.slice_count
);
2624 * FIXME: Use VBT rc_buffer_block_size and rc_buffer_size for the
2625 * implementation specific physical rate buffer size. Currently we use
2626 * the required rate buffer model size calculated in
2627 * drm_dsc_compute_rc_parameters() according to VESA DSC Annex E.
2629 * The VBT rc_buffer_block_size and rc_buffer_size definitions
2630 * correspond to DP 1.4 DPCD offsets 0x62 and 0x63. The DP DSC
2631 * implementation should also use the DPCD (or perhaps VBT for eDP)
2632 * provided value for the buffer size.
2635 /* FIXME: DSI spec says bpc + 1 for this one */
2636 vdsc_cfg
->line_buf_depth
= VBT_DSC_LINE_BUFFER_DEPTH(dsc
->line_buffer_depth
);
2638 vdsc_cfg
->block_pred_enable
= dsc
->block_prediction_enable
;
2640 vdsc_cfg
->slice_height
= dsc
->slice_height
;
2643 /* FIXME: initially DSI specific */
2644 bool intel_bios_get_dsc_params(struct intel_encoder
*encoder
,
2645 struct intel_crtc_state
*crtc_state
,
2648 struct drm_i915_private
*i915
= to_i915(encoder
->base
.dev
);
2649 const struct display_device_data
*devdata
;
2650 const struct child_device_config
*child
;
2652 list_for_each_entry(devdata
, &i915
->vbt
.display_devices
, node
) {
2653 child
= &devdata
->child
;
2655 if (!(child
->device_type
& DEVICE_TYPE_MIPI_OUTPUT
))
2658 if (child
->dvo_port
- DVO_PORT_MIPIA
== encoder
->port
) {
2663 fill_dsc(crtc_state
, devdata
->dsc
, dsc_max_bpc
);
2673 * intel_bios_is_port_hpd_inverted - is HPD inverted for %port
2674 * @i915: i915 device instance
2675 * @port: port to check
2677 * Return true if HPD should be inverted for %port.
2680 intel_bios_is_port_hpd_inverted(const struct drm_i915_private
*i915
,
2683 const struct child_device_config
*child
=
2684 i915
->vbt
.ddi_port_info
[port
].child
;
2686 if (drm_WARN_ON_ONCE(&i915
->drm
, !IS_GEN9_LP(i915
)))
2689 return child
&& child
->hpd_invert
;
2693 * intel_bios_is_lspcon_present - if LSPCON is attached on %port
2694 * @i915: i915 device instance
2695 * @port: port to check
2697 * Return true if LSPCON is present on this port
2700 intel_bios_is_lspcon_present(const struct drm_i915_private
*i915
,
2703 const struct child_device_config
*child
=
2704 i915
->vbt
.ddi_port_info
[port
].child
;
2706 return HAS_LSPCON(i915
) && child
&& child
->lspcon
;
2709 enum aux_ch
intel_bios_port_aux_ch(struct drm_i915_private
*dev_priv
,
2712 const struct ddi_vbt_port_info
*info
=
2713 &dev_priv
->vbt
.ddi_port_info
[port
];
2716 if (!info
->alternate_aux_channel
) {
2717 aux_ch
= (enum aux_ch
)port
;
2719 drm_dbg_kms(&dev_priv
->drm
,
2720 "using AUX %c for port %c (platform default)\n",
2721 aux_ch_name(aux_ch
), port_name(port
));
2725 switch (info
->alternate_aux_channel
) {
2734 * RKL/DG1 VBT uses PHY based mapping. Combo PHYs A,B,C,D
2735 * map to DDI A,B,TC1,TC2 respectively.
2737 aux_ch
= (IS_DG1(dev_priv
) || IS_ROCKETLAKE(dev_priv
)) ?
2738 AUX_CH_USBC1
: AUX_CH_C
;
2741 aux_ch
= (IS_DG1(dev_priv
) || IS_ROCKETLAKE(dev_priv
)) ?
2742 AUX_CH_USBC2
: AUX_CH_D
;
2760 MISSING_CASE(info
->alternate_aux_channel
);
2765 drm_dbg_kms(&dev_priv
->drm
, "using AUX %c for port %c (VBT)\n",
2766 aux_ch_name(aux_ch
), port_name(port
));
2771 int intel_bios_max_tmds_clock(struct intel_encoder
*encoder
)
2773 struct drm_i915_private
*i915
= to_i915(encoder
->base
.dev
);
2775 return i915
->vbt
.ddi_port_info
[encoder
->port
].max_tmds_clock
;
2778 int intel_bios_hdmi_level_shift(struct intel_encoder
*encoder
)
2780 struct drm_i915_private
*i915
= to_i915(encoder
->base
.dev
);
2781 const struct ddi_vbt_port_info
*info
=
2782 &i915
->vbt
.ddi_port_info
[encoder
->port
];
2784 return info
->hdmi_level_shift_set
? info
->hdmi_level_shift
: -1;
2787 int intel_bios_dp_boost_level(struct intel_encoder
*encoder
)
2789 struct drm_i915_private
*i915
= to_i915(encoder
->base
.dev
);
2791 return i915
->vbt
.ddi_port_info
[encoder
->port
].dp_boost_level
;
2794 int intel_bios_hdmi_boost_level(struct intel_encoder
*encoder
)
2796 struct drm_i915_private
*i915
= to_i915(encoder
->base
.dev
);
2798 return i915
->vbt
.ddi_port_info
[encoder
->port
].hdmi_boost_level
;
2801 int intel_bios_dp_max_link_rate(struct intel_encoder
*encoder
)
2803 struct drm_i915_private
*i915
= to_i915(encoder
->base
.dev
);
2805 return i915
->vbt
.ddi_port_info
[encoder
->port
].dp_max_link_rate
;
2808 int intel_bios_alternate_ddc_pin(struct intel_encoder
*encoder
)
2810 struct drm_i915_private
*i915
= to_i915(encoder
->base
.dev
);
2812 return i915
->vbt
.ddi_port_info
[encoder
->port
].alternate_ddc_pin
;
2815 bool intel_bios_port_supports_dvi(struct drm_i915_private
*i915
, enum port port
)
2817 return i915
->vbt
.ddi_port_info
[port
].supports_dvi
;
2820 bool intel_bios_port_supports_hdmi(struct drm_i915_private
*i915
, enum port port
)
2822 return i915
->vbt
.ddi_port_info
[port
].supports_hdmi
;
2825 bool intel_bios_port_supports_dp(struct drm_i915_private
*i915
, enum port port
)
2827 return i915
->vbt
.ddi_port_info
[port
].supports_dp
;
2830 bool intel_bios_port_supports_typec_usb(struct drm_i915_private
*i915
,
2833 return i915
->vbt
.ddi_port_info
[port
].supports_typec_usb
;
2836 bool intel_bios_port_supports_tbt(struct drm_i915_private
*i915
, enum port port
)
2838 return i915
->vbt
.ddi_port_info
[port
].supports_tbt
;