[Intel-gfx] [PATCH 1/3] drm/i915/vbt: Fix backlight parsing for VBT 234+
José Roberto de Souza
jose.souza at intel.com
Tue Sep 29 21:29:10 UTC 2020
Child min_brightness is obsolete from VBT 234+, instead the new
min_brightness field in the main structure should be used.
This new field is 16 bits wide, so backlight_precision_bits is needed
to check if value needs to be scaled down but it is only available in
VBT 236+ so working around it by using the also new backlight_level
in the main struct.
BSpec: 20149
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
drivers/gpu/drm/i915/display/intel_bios.c | 23 ++++++++++++++++++-
drivers/gpu/drm/i915/display/intel_vbt_defs.h | 10 +++++++-
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 4716484af62d..fa7a93f118f4 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -459,7 +459,28 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv,
dev_priv->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz;
dev_priv->vbt.backlight.active_low_pwm = entry->active_low_pwm;
- dev_priv->vbt.backlight.min_brightness = entry->min_brightness;
+
+ if (bdb->version >= 234) {
+ u16 level = backlight_data->backlight_min_level[panel_type].level;
+ bool scale = false;
+
+ if (bdb->version >= 236)
+ scale = backlight_data->backlight_precision_bits[panel_type] == 16;
+ else
+ scale = backlight_data->backlight_level[panel_type].level > 255;
+
+ if (scale)
+ level = level / 255;
+
+ if (level > 255) {
+ drm_warn(&dev_priv->drm, "Backlight min level > 255\n");
+ level = 255;
+ }
+ dev_priv->vbt.backlight.min_brightness = level;
+ } else {
+ dev_priv->vbt.backlight.min_brightness = entry->min_brightness;
+ }
+
drm_dbg_kms(&dev_priv->drm,
"VBT backlight PWM modulation frequency %u Hz, "
"active %s, min brightness %u, level %u, controller %u\n",
diff --git a/drivers/gpu/drm/i915/display/intel_vbt_defs.h b/drivers/gpu/drm/i915/display/intel_vbt_defs.h
index 54bcc6a6947c..12ec4c0781ce 100644
--- a/drivers/gpu/drm/i915/display/intel_vbt_defs.h
+++ b/drivers/gpu/drm/i915/display/intel_vbt_defs.h
@@ -782,7 +782,7 @@ struct lfp_backlight_data_entry {
u8 active_low_pwm:1;
u8 obsolete1:5;
u16 pwm_freq_hz;
- u8 min_brightness;
+ u8 min_brightness; /* Obsolete from 234+ */
u8 obsolete2;
u8 obsolete3;
} __packed;
@@ -792,11 +792,19 @@ struct lfp_backlight_control_method {
u8 controller:4;
} __packed;
+struct lfp_backlight_level {
+ u32 level : 16;
+ u32 reserved : 16;
+} __packed;
+
struct bdb_lfp_backlight_data {
u8 entry_size;
struct lfp_backlight_data_entry data[16];
u8 level[16];
struct lfp_backlight_control_method backlight_control[16];
+ struct lfp_backlight_level backlight_level[16]; /* 234+ */
+ struct lfp_backlight_level backlight_min_level[16]; /* 234+ */
+ u8 backlight_precision_bits[16]; /* 236+ */
} __packed;
/*
--
2.28.0
More information about the Intel-gfx
mailing list