Commit 58b2e382 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915/bios: Trust the LFP data pointers

Now that we've sufficiently validated the LFP data pointers we
can trust them.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220405173410.11436-6-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 514003e1
...@@ -397,44 +397,19 @@ fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode, ...@@ -397,44 +397,19 @@ fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
} }
static const struct lvds_dvo_timing * static const struct lvds_dvo_timing *
get_lvds_dvo_timing(const struct bdb_lvds_lfp_data *lvds_lfp_data, get_lvds_dvo_timing(const struct bdb_lvds_lfp_data *data,
const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs, const struct bdb_lvds_lfp_data_ptrs *ptrs,
int index) int index)
{ {
/* return (const void *)data + ptrs->ptr[index].dvo_timing.offset;
* the size of fp_timing varies on the different platform.
* So calculate the DVO timing relative offset in LVDS data
* entry to get the DVO timing entry
*/
int lfp_data_size =
lvds_lfp_data_ptrs->ptr[1].dvo_timing.offset -
lvds_lfp_data_ptrs->ptr[0].dvo_timing.offset;
int dvo_timing_offset =
lvds_lfp_data_ptrs->ptr[0].dvo_timing.offset -
lvds_lfp_data_ptrs->ptr[0].fp_timing.offset;
char *entry = (char *)lvds_lfp_data->data + lfp_data_size * index;
return (struct lvds_dvo_timing *)(entry + dvo_timing_offset);
} }
/* get lvds_fp_timing entry
* this function may return NULL if the corresponding entry is invalid
*/
static const struct lvds_fp_timing * static const struct lvds_fp_timing *
get_lvds_fp_timing(const struct bdb_lvds_lfp_data *data, get_lvds_fp_timing(const struct bdb_lvds_lfp_data *data,
const struct bdb_lvds_lfp_data_ptrs *ptrs, const struct bdb_lvds_lfp_data_ptrs *ptrs,
int index) int index)
{ {
u16 data_size = ((const u16 *)data)[-1]; /* stored in header */ return (const void *)data + ptrs->ptr[index].fp_timing.offset;
size_t ofs;
if (index >= ARRAY_SIZE(ptrs->ptr))
return NULL;
ofs = ptrs->ptr[index].fp_timing.offset;
if (ofs + sizeof(struct lvds_fp_timing) > data_size)
return NULL;
return (const struct lvds_fp_timing *)((const u8 *)data + ofs);
} }
/* Parse general panel options */ /* Parse general panel options */
...@@ -499,8 +474,7 @@ parse_panel_options(struct drm_i915_private *i915) ...@@ -499,8 +474,7 @@ parse_panel_options(struct drm_i915_private *i915)
/* Try to find integrated panel timing data */ /* Try to find integrated panel timing data */
static void static void
parse_lfp_panel_dtd(struct drm_i915_private *i915, parse_lfp_panel_dtd(struct drm_i915_private *i915)
const struct bdb_header *bdb)
{ {
const struct bdb_lvds_lfp_data *lvds_lfp_data; const struct bdb_lvds_lfp_data *lvds_lfp_data;
const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs; const struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
...@@ -536,7 +510,7 @@ parse_lfp_panel_dtd(struct drm_i915_private *i915, ...@@ -536,7 +510,7 @@ parse_lfp_panel_dtd(struct drm_i915_private *i915,
fp_timing = get_lvds_fp_timing(lvds_lfp_data, fp_timing = get_lvds_fp_timing(lvds_lfp_data,
lvds_lfp_data_ptrs, lvds_lfp_data_ptrs,
panel_type); panel_type);
if (fp_timing) {
/* check the resolution, just to be sure */ /* check the resolution, just to be sure */
if (fp_timing->x_res == panel_fixed_mode->hdisplay && if (fp_timing->x_res == panel_fixed_mode->hdisplay &&
fp_timing->y_res == panel_fixed_mode->vdisplay) { fp_timing->y_res == panel_fixed_mode->vdisplay) {
...@@ -545,7 +519,6 @@ parse_lfp_panel_dtd(struct drm_i915_private *i915, ...@@ -545,7 +519,6 @@ parse_lfp_panel_dtd(struct drm_i915_private *i915,
"VBT initial LVDS value %x\n", "VBT initial LVDS value %x\n",
i915->vbt.bios_lvds_val); i915->vbt.bios_lvds_val);
} }
}
} }
static void static void
...@@ -627,8 +600,7 @@ parse_generic_dtd(struct drm_i915_private *i915) ...@@ -627,8 +600,7 @@ parse_generic_dtd(struct drm_i915_private *i915)
} }
static void static void
parse_panel_dtd(struct drm_i915_private *i915, parse_panel_dtd(struct drm_i915_private *i915)
const struct bdb_header *bdb)
{ {
/* /*
* Older VBTs provided provided DTD information for internal displays * Older VBTs provided provided DTD information for internal displays
...@@ -641,7 +613,7 @@ parse_panel_dtd(struct drm_i915_private *i915, ...@@ -641,7 +613,7 @@ parse_panel_dtd(struct drm_i915_private *i915,
if (i915->vbt.version >= 229) if (i915->vbt.version >= 229)
parse_generic_dtd(i915); parse_generic_dtd(i915);
if (!i915->vbt.lfp_lvds_vbt_mode) if (!i915->vbt.lfp_lvds_vbt_mode)
parse_lfp_panel_dtd(i915, bdb); parse_lfp_panel_dtd(i915);
} }
static void static void
...@@ -2720,7 +2692,7 @@ void intel_bios_init(struct drm_i915_private *i915) ...@@ -2720,7 +2692,7 @@ void intel_bios_init(struct drm_i915_private *i915)
parse_general_features(i915); parse_general_features(i915);
parse_general_definitions(i915); parse_general_definitions(i915);
parse_panel_options(i915); parse_panel_options(i915);
parse_panel_dtd(i915, bdb); parse_panel_dtd(i915);
parse_lfp_backlight(i915); parse_lfp_backlight(i915);
parse_sdvo_panel_data(i915); parse_sdvo_panel_data(i915);
parse_driver_features(i915); parse_driver_features(i915);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment