30 #include <drm/i915_drm.h>
34 #define SLAVE_ADDR1 0x70
35 #define SLAVE_ADDR2 0x72
40 find_section(
struct bdb_header *bdb,
int section_id)
44 u16 total, current_size;
52 while (index < total) {
53 current_id = *(base +
index);
55 current_size = *((
u16 *)(base + index));
57 if (current_id == section_id)
59 index += current_size;
66 get_blocksize(
void *
p)
70 block_ptr = (
u16 *)((
char *)p - 2);
71 block_size = *block_ptr;
96 panel_fixed_mode->
clock = dvo_timing->
clock * 10;
166 lvds_lfp_data_ptrs->
ptr[1].dvo_timing_offset -
167 lvds_lfp_data_ptrs->
ptr[0].dvo_timing_offset;
169 lvds_lfp_data_ptrs->
ptr[0].dvo_timing_offset -
170 lvds_lfp_data_ptrs->
ptr[0].fp_timing_offset;
171 char *
entry = (
char *)lvds_lfp_data->
data + lfp_data_size * index;
180 get_lvds_fp_timing(
const struct bdb_header *bdb,
185 size_t data_ofs = (
const u8 *)data - (
const u8 *)bdb;
191 ofs = ptrs->
ptr[
index].fp_timing_offset;
192 if (ofs < data_ofs ||
226 if (!lvds_lfp_data_ptrs)
231 panel_dvo_timing = get_lvds_dvo_timing(lvds_lfp_data,
235 panel_fixed_mode = kzalloc(
sizeof(*panel_fixed_mode),
GFP_KERNEL);
236 if (!panel_fixed_mode)
239 fill_detail_timing_data(panel_fixed_mode, panel_dvo_timing);
243 DRM_DEBUG_KMS(
"Found panel mode in BIOS VBT tables:\n");
250 downclock = panel_dvo_timing->
clock;
251 for (i = 0; i < 16; i++) {
254 dvo_timing = get_lvds_dvo_timing(lvds_lfp_data,
257 if (lvds_dvo_timing_equal_size(dvo_timing, panel_dvo_timing) &&
258 dvo_timing->
clock < downclock)
259 downclock = dvo_timing->
clock;
262 if (downclock < panel_dvo_timing->
clock && i915_lvds_downclock) {
265 DRM_DEBUG_KMS(
"LVDS downclock is found in VBT. "
266 "Normal Clock %dKHz, downclock %dKHz\n",
267 panel_fixed_mode->
clock, 10*downclock);
270 fp_timing = get_lvds_fp_timing(bdb, lvds_lfp_data,
278 DRM_DEBUG_KMS(
"VBT initial LVDS value %x\n",
293 index = i915_vbt_sdvo_panel_type;
295 DRM_DEBUG_KMS(
"Ignore SDVO panel mode from BIOS VBT tables.\n");
303 if (!sdvo_lvds_options)
313 panel_fixed_mode = kzalloc(
sizeof(*panel_fixed_mode),
GFP_KERNEL);
314 if (!panel_fixed_mode)
317 fill_detail_timing_data(panel_fixed_mode, dvo_timing + index);
321 DRM_DEBUG_KMS(
"Found SDVO panel mode in BIOS VBT tables:\n");
330 return alternate ? 66 : 48;
333 return alternate ? 100 : 96;
335 return alternate ? 100 : 120;
352 intel_bios_ssc_frequency(dev, general->
ssc_freq);
354 DRM_DEBUG_KMS(
"BDB_GENERAL_FEATURES int_tv_support %d int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d\n",
371 u16 block_size = get_blocksize(general);
372 if (block_size >=
sizeof(*general)) {
374 DRM_DEBUG_KMS(
"crt_ddc_bus_pin: %d\n", bus_pin);
378 DRM_DEBUG_KMS(
"BDB_GD too small (%d). Invalid.\n",
391 int i, child_device_num,
count;
396 DRM_DEBUG_KMS(
"No general definition block is found, unable to construct sdvo mapping.\n");
406 DRM_DEBUG_KMS(
"different child size is found. Invalid.\n");
410 block_size = get_blocksize(p_defs);
412 child_device_num = (block_size -
sizeof(*p_defs)) /
415 for (i = 0; i < child_device_num; i++) {
432 DRM_DEBUG_KMS(
"Incorrect SDVO port. Skip it\n");
435 DRM_DEBUG_KMS(
"the SDVO device with slave addr %2x is found on"
448 DRM_DEBUG_KMS(
"SDVO device: dvo=%x, addr=%x, wiring=%d, ddc_pin=%d, i2c_pin=%d\n",
455 DRM_DEBUG_KMS(
"Maybe one SDVO port is shared by "
456 "two SDVO device.\n");
461 DRM_DEBUG_KMS(
"there exists the slave2_addr. Maybe this"
462 " is a SDVO device with multiple inputs.\n");
469 DRM_DEBUG_KMS(
"No SDVO device info is found in VBT\n");
487 dev_priv->
edp.support = 1;
500 edp = find_section(bdb,
BDB_EDP);
503 DRM_DEBUG_KMS(
"No eDP BDB found but eDP panel supported.\n");
509 dev_priv->
edp.bpp = 18;
512 dev_priv->
edp.bpp = 24;
515 dev_priv->
edp.bpp = 30;
523 dev_priv->
edp.pps = *edp_pps;
527 switch (edp_link_params->
lanes) {
529 dev_priv->
edp.lanes = 1;
532 dev_priv->
edp.lanes = 2;
536 dev_priv->
edp.lanes = 4;
553 switch (edp_link_params->
vswing) {
575 int i, child_device_num,
count;
580 DRM_DEBUG_KMS(
"No general definition block is found, no devices defined.\n");
590 DRM_DEBUG_KMS(
"different child size is found. Invalid.\n");
594 block_size = get_blocksize(p_defs);
596 child_device_num = (block_size -
sizeof(*p_defs)) /
600 for (i = 0; i < child_device_num; i++) {
609 DRM_DEBUG_KMS(
"no child dev is parsed from VBT\n");
614 DRM_DEBUG_KMS(
"No memory space for child device\n");
620 for (i = 0; i < child_device_num; i++) {
628 memcpy((
void *)child_dev_ptr, (
void *)p_child,
655 DRM_DEBUG_KMS(
"Set default to SSC at %dMHz\n", dev_priv->
lvds_ssc_freq);
660 DRM_DEBUG_KMS(
"Falling back to manually reading VBT from "
661 "VBIOS ROM for %s\n",
666 static const struct dmi_system_id intel_no_opregion_vbt[] = {
668 .callback = intel_no_opregion_vbt_callback,
669 .ident =
"ThinkCentre A57",
695 init_vbt_defaults(dev_priv);
701 DRM_DEBUG_KMS(
"Using VBT from OpRegion: %20s\n",
718 for (i = 0; i + 4 <
size; i++) {
719 if (!
memcmp(bios + i,
"$VBT", 4)) {
726 DRM_DEBUG_DRIVER(
"VBT signature missing\n");
735 parse_general_features(dev_priv, bdb);
736 parse_general_definitions(dev_priv, bdb);
737 parse_lfp_panel_data(dev_priv, bdb);
738 parse_sdvo_panel_data(dev_priv, bdb);
739 parse_sdvo_device_mapping(dev_priv, bdb);
740 parse_device_mapping(dev_priv, bdb);
741 parse_driver_features(dev_priv, bdb);
742 parse_edp(dev_priv, bdb);