[Intel-gfx] [PATCH] drm/i915/bios: use a flag for vbt hdmi level shift presence
Jani Nikula
jani.nikula at intel.com
Tue Nov 5 13:59:57 UTC 2019
On Tue, 05 Nov 2019, Ville Syrjälä <ville.syrjala at linux.intel.com> wrote:
> On Tue, Nov 05, 2019 at 03:39:00PM +0200, Jani Nikula wrote:
>> The pre-initialized magic value is a bit silly, switch to a flag
>> instead. While at it, clean up the validity checks. No functional
>> changes apart from the added checks.
>>
>> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
>> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
>> ---
>> drivers/gpu/drm/i915/display/intel_bios.c | 10 +---------
>> drivers/gpu/drm/i915/display/intel_ddi.c | 19 +++++++++++--------
>> drivers/gpu/drm/i915/i915_drv.h | 8 ++------
>> 3 files changed, 14 insertions(+), 23 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
>> index a03f56b7b4ef..c19b234bebe6 100644
>> --- a/drivers/gpu/drm/i915/display/intel_bios.c
>> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
>> @@ -1509,6 +1509,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv,
>> port_name(port),
>> hdmi_level_shift);
>> info->hdmi_level_shift = hdmi_level_shift;
>> + info->hdmi_level_shift_set = true;
>> }
>>
>> if (bdb_version >= 204) {
>> @@ -1692,8 +1693,6 @@ parse_general_definitions(struct drm_i915_private *dev_priv,
>> static void
>> init_vbt_defaults(struct drm_i915_private *dev_priv)
>> {
>> - enum port port;
>> -
>> dev_priv->vbt.crt_ddc_pin = GMBUS_PIN_VGADDC;
>>
>> /* Default to having backlight */
>> @@ -1721,13 +1720,6 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
>> dev_priv->vbt.lvds_ssc_freq = intel_bios_ssc_frequency(dev_priv,
>> !HAS_PCH_SPLIT(dev_priv));
>> DRM_DEBUG_KMS("Set default to SSC at %d kHz\n", dev_priv->vbt.lvds_ssc_freq);
>> -
>> - for_each_port(port) {
>> - struct ddi_vbt_port_info *info =
>> - &dev_priv->vbt.ddi_port_info[port];
>> -
>> - info->hdmi_level_shift = HDMI_LEVEL_SHIFT_UNKNOWN;
>> - }
>> }
>>
>> /* Defaults to initialize only if there is no VBT. */
>> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
>> index c91521bcf06a..ec51f6971b16 100644
>> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
>> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
>> @@ -888,11 +888,10 @@ icl_get_combo_buf_trans(struct drm_i915_private *dev_priv, int type, int rate,
>>
>> static int intel_ddi_hdmi_level(struct drm_i915_private *dev_priv, enum port port)
>> {
>> + struct ddi_vbt_port_info *port_info = &dev_priv->vbt.ddi_port_info[port];
>> int n_entries, level, default_entry;
>> enum phy phy = intel_port_to_phy(dev_priv, port);
>>
>> - level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift;
>> -
>> if (INTEL_GEN(dev_priv) >= 12) {
>> if (intel_phy_is_combo(dev_priv, phy))
>> icl_get_combo_buf_trans(dev_priv, INTEL_OUTPUT_HDMI,
>> @@ -927,14 +926,18 @@ static int intel_ddi_hdmi_level(struct drm_i915_private *dev_priv, enum port por
>> return 0;
>> }
>>
>> - /* Choose a good default if VBT is badly populated */
>> - if (level == HDMI_LEVEL_SHIFT_UNKNOWN || level >= n_entries)
>> - level = default_entry;
>> -
>> if (WARN_ON_ONCE(n_entries == 0))
>> return 0;
>> - if (WARN_ON_ONCE(level >= n_entries))
>> - level = n_entries - 1;
>> +
>> + if (WARN_ON_ONCE(default_entry >= n_entries))
>> + default_entry = n_entries - 1;
>> +
>> + if (port_info->hdmi_level_shift_set &&
>> + !WARN_ON_ONCE(port_info->hdmi_level_shift >= n_entries)) {
>> + level = port_info->hdmi_level_shift;
>> + } else {
>> + level = default_entry;
>> + }
>
> I'd probably simplify that to something like:
>
> if (level_shift_set)
> level = level_shift;
> else
> level = default;
> if (WARN_ON_ONCE(level >= n_entries))
> level = n_entries - 1;
I wanted to add the distinction between the default_entry being bogus
and the VBT being bogus.
BR,
Jani.
>
> Either way:
> Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
>>
>> return level;
>> }
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>> index 7e0f67babe20..67bdfe6de3fa 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -627,13 +627,9 @@ struct ddi_vbt_port_info {
>>
>> int max_tmds_clock;
>>
>> - /*
>> - * This is an index in the HDMI/DVI DDI buffer translation table.
>> - * The special value HDMI_LEVEL_SHIFT_UNKNOWN means the VBT didn't
>> - * populate this field.
>> - */
>> -#define HDMI_LEVEL_SHIFT_UNKNOWN 0xff
>> + /* This is an index in the HDMI/DVI DDI buffer translation table. */
>> u8 hdmi_level_shift;
>> + u8 hdmi_level_shift_set:1;
>>
>> u8 supports_dvi:1;
>> u8 supports_hdmi:1;
>> --
>> 2.20.1
--
Jani Nikula, Intel Open Source Graphics Center
More information about the Intel-gfx
mailing list