Skip to content

Commit fdddf8c

Browse files
semihalf-majczak-lukaszjnikula
authored andcommitted
drm/i915/bdb: Fix version check
With patch "drm/i915/vbt: Fix backlight parsing for VBT 234+" the size of bdb_lfp_backlight_data structure has been increased, causing if-statement in the parse_lfp_backlight function that comapres this structure size to the one retrieved from BDB, always to fail for older revisions. This patch calculates expected size of the structure for a given BDB version and compares it with the value gathered from BDB. Tested on Chromebook Pixelbook (Nocturne) (reports bdb->version = 221) Fixes: d381baa ("drm/i915/vbt: Fix backlight parsing for VBT 234+") Tested-by: Lukasz Majczak <[email protected]> Signed-off-by: Lukasz Majczak <[email protected]> Reviewed-by: José Roberto de Souza <[email protected]> Signed-off-by: José Roberto de Souza <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 4378daf) Signed-off-by: Jani Nikula <[email protected]>
1 parent a532cde commit fdddf8c

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

drivers/gpu/drm/i915/display/intel_bios.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,23 @@ parse_lfp_backlight(struct drm_i915_private *i915,
451451
}
452452

453453
i915->vbt.backlight.type = INTEL_BACKLIGHT_DISPLAY_DDI;
454-
if (bdb->version >= 191 &&
455-
get_blocksize(backlight_data) >= sizeof(*backlight_data)) {
456-
const struct lfp_backlight_control_method *method;
454+
if (bdb->version >= 191) {
455+
size_t exp_size;
457456

458-
method = &backlight_data->backlight_control[panel_type];
459-
i915->vbt.backlight.type = method->type;
460-
i915->vbt.backlight.controller = method->controller;
457+
if (bdb->version >= 236)
458+
exp_size = sizeof(struct bdb_lfp_backlight_data);
459+
else if (bdb->version >= 234)
460+
exp_size = EXP_BDB_LFP_BL_DATA_SIZE_REV_234;
461+
else
462+
exp_size = EXP_BDB_LFP_BL_DATA_SIZE_REV_191;
463+
464+
if (get_blocksize(backlight_data) >= exp_size) {
465+
const struct lfp_backlight_control_method *method;
466+
467+
method = &backlight_data->backlight_control[panel_type];
468+
i915->vbt.backlight.type = method->type;
469+
i915->vbt.backlight.controller = method->controller;
470+
}
461471
}
462472

463473
i915->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz;

drivers/gpu/drm/i915/display/intel_vbt_defs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,11 @@ struct lfp_brightness_level {
814814
u16 reserved;
815815
} __packed;
816816

817+
#define EXP_BDB_LFP_BL_DATA_SIZE_REV_191 \
818+
offsetof(struct bdb_lfp_backlight_data, brightness_level)
819+
#define EXP_BDB_LFP_BL_DATA_SIZE_REV_234 \
820+
offsetof(struct bdb_lfp_backlight_data, brightness_precision_bits)
821+
817822
struct bdb_lfp_backlight_data {
818823
u8 entry_size;
819824
struct lfp_backlight_data_entry data[16];

0 commit comments

Comments
 (0)