On Thu, Jan 11, 2024 at 07:21:16PM +0200, Jani Nikula wrote: > Add a function to get the opregion VBT instead of accessing the opregion > structures directly. > > Cc: Radhakrishna Sripada <radhakrishna.sripada@xxxxxxxxx> > Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx> Looks clean, Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@xxxxxxxxx> > --- > drivers/gpu/drm/i915/display/intel_bios.c | 14 +++++++++----- > drivers/gpu/drm/i915/display/intel_opregion.c | 13 +++++++++++++ > drivers/gpu/drm/i915/display/intel_opregion.h | 8 ++++++++ > 3 files changed, 30 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c > index cf8e6f7bd490..5f04e495fd27 100644 > --- a/drivers/gpu/drm/i915/display/intel_bios.c > +++ b/drivers/gpu/drm/i915/display/intel_bios.c > @@ -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; > } > diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c > index 26c92ab4ee8a..8b9e820971cb 100644 > --- a/drivers/gpu/drm/i915/display/intel_opregion.c > +++ b/drivers/gpu/drm/i915/display/intel_opregion.c > @@ -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; > diff --git a/drivers/gpu/drm/i915/display/intel_opregion.h b/drivers/gpu/drm/i915/display/intel_opregion.h > index 7177f50ab0d3..9efadfb72584 100644 > --- a/drivers/gpu/drm/i915/display/intel_opregion.h > +++ b/drivers/gpu/drm/i915/display/intel_opregion.h > @@ -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; > -- > 2.39.2 >