drm/i915/opregion: abstract getting the opregion VBT

Add a function to get the opregion VBT instead of accessing the opregion
structures directly.

Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/8205b8fa724f98bbf1f76c59e661909d874e843e.1704992868.git.jani.nikula@intel.com
This commit is contained in:
Jani Nikula 2024-01-11 19:21:16 +02:00
parent bb94644716
commit 37e2100312
3 changed files with 30 additions and 5 deletions

View file

@ -3073,7 +3073,7 @@ static struct vbt_header *oprom_get_vbt(struct drm_i915_private *i915)
*/
void intel_bios_init(struct drm_i915_private *i915)
{
const struct vbt_header *vbt = i915->display.opregion.vbt;
const struct vbt_header *vbt;
struct vbt_header *oprom_vbt = NULL;
const struct bdb_header *bdb;
@ -3088,6 +3088,8 @@ void intel_bios_init(struct drm_i915_private *i915)
init_vbt_defaults(i915);
vbt = intel_opregion_get_vbt(i915, NULL);
/*
* If the OpRegion does not have VBT, look in SPI flash through MMIO or
* PCI mapping
@ -3305,7 +3307,7 @@ bool intel_bios_is_lvds_present(struct drm_i915_private *i915, u8 *i2c_pin)
* additional data. Trust that if the VBT was written into
* the OpRegion then they have validated the LVDS's existence.
*/
if (i915->display.opregion.vbt)
if (intel_opregion_get_vbt(i915, NULL))
return true;
}
@ -3660,14 +3662,16 @@ void intel_bios_for_each_encoder(struct drm_i915_private *i915,
static int intel_bios_vbt_show(struct seq_file *m, void *unused)
{
struct drm_i915_private *i915 = m->private;
struct intel_opregion *opregion = &i915->display.opregion;
const void *vbt;
size_t vbt_size;
/*
* FIXME: VBT might originate from other places than opregion, and then
* this would be incorrect.
*/
if (opregion->vbt)
seq_write(m, opregion->vbt, opregion->vbt_size);
vbt = intel_opregion_get_vbt(i915, &vbt_size);
if (vbt)
seq_write(m, vbt, vbt_size);
return 0;
}

View file

@ -1132,6 +1132,19 @@ const struct drm_edid *intel_opregion_get_edid(struct intel_connector *intel_con
return drm_edid;
}
const void *intel_opregion_get_vbt(struct drm_i915_private *i915, size_t *size)
{
struct intel_opregion *opregion = &i915->display.opregion;
if (!opregion->vbt)
return NULL;
if (size)
*size = opregion->vbt_size;
return opregion->vbt;
}
bool intel_opregion_headless_sku(struct drm_i915_private *i915)
{
struct intel_opregion *opregion = &i915->display.opregion;

View file

@ -77,6 +77,8 @@ int intel_opregion_notify_adapter(struct drm_i915_private *dev_priv,
int intel_opregion_get_panel_type(struct drm_i915_private *dev_priv);
const struct drm_edid *intel_opregion_get_edid(struct intel_connector *connector);
const void *intel_opregion_get_vbt(struct drm_i915_private *i915, size_t *size);
bool intel_opregion_headless_sku(struct drm_i915_private *i915);
void intel_opregion_debugfs_register(struct drm_i915_private *i915);
@ -136,6 +138,12 @@ intel_opregion_get_edid(struct intel_connector *connector)
return NULL;
}
static inline const void *
intel_opregion_get_vbt(struct drm_i915_private *i915, size_t *size)
{
return NULL;
}
static inline bool intel_opregion_headless_sku(struct drm_i915_private *i915)
{
return false;