Skip to content

Commit

Permalink
drm/i915/vbt: Fix backlight parsing for VBT 234+
Browse files Browse the repository at this point in the history
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.

v2:
- missed that backlight_data->level is also obsolete

v3:
- s/backlight/brightness to better match specification
- using u16 to specify brightness level instead of a u32 : 16

BSpec: 20149
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201008211932.24989-1-jose.souza@intel.com
  • Loading branch information
José Roberto de Souza committed Oct 9, 2020
1 parent 63b9d9a commit d381baa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
30 changes: 28 additions & 2 deletions drivers/gpu/drm/i915/display/intel_bios.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv,
const struct bdb_lfp_backlight_data *backlight_data;
const struct lfp_backlight_data_entry *entry;
int panel_type = dev_priv->vbt.panel_type;
u16 level;

backlight_data = find_section(bdb, BDB_LVDS_BACKLIGHT);
if (!backlight_data)
Expand Down Expand Up @@ -459,14 +460,39 @@ 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 min_level;
bool scale;

level = backlight_data->brightness_level[panel_type].level;
min_level = backlight_data->brightness_min_level[panel_type].level;

if (bdb->version >= 236)
scale = backlight_data->brightness_precision_bits[panel_type] == 16;
else
scale = level > 255;

if (scale)
min_level = min_level / 255;

if (min_level > 255) {
drm_warn(&dev_priv->drm, "Brightness min level > 255\n");
level = 255;
}
dev_priv->vbt.backlight.min_brightness = min_level;
} else {
level = backlight_data->level[panel_type];
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",
dev_priv->vbt.backlight.pwm_freq_hz,
dev_priv->vbt.backlight.active_low_pwm ? "low" : "high",
dev_priv->vbt.backlight.min_brightness,
backlight_data->level[panel_type],
level,
dev_priv->vbt.backlight.controller);
}

Expand Down
12 changes: 10 additions & 2 deletions drivers/gpu/drm/i915/display/intel_vbt_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -792,11 +792,19 @@ struct lfp_backlight_control_method {
u8 controller:4;
} __packed;

struct lfp_brightness_level {
u16 level;
u16 reserved;
} __packed;

struct bdb_lfp_backlight_data {
u8 entry_size;
struct lfp_backlight_data_entry data[16];
u8 level[16];
u8 level[16]; /* Obsolete from 234+ */
struct lfp_backlight_control_method backlight_control[16];
struct lfp_brightness_level brightness_level[16]; /* 234+ */
struct lfp_brightness_level brightness_min_level[16]; /* 234+ */
u8 brightness_precision_bits[16]; /* 236+ */
} __packed;

/*
Expand Down

0 comments on commit d381baa

Please sign in to comment.