From 17e876795967c3c788555f27adec3759d8605a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 11 Dec 2021 14:19:37 +0100 Subject: [PATCH] intel_extreme: define bdb header values, check panel type. Change-Id: I2e5b61da9aecc11be13178a0b48211d172454d94 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4773 Reviewed-by: Adrien Destugues --- .../drivers/graphics/intel_extreme/bios.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/bios.cpp b/src/add-ons/kernel/drivers/graphics/intel_extreme/bios.cpp index eeeeacb762..8d4d9225fd 100644 --- a/src/add-ons/kernel/drivers/graphics/intel_extreme/bios.cpp +++ b/src/add-ons/kernel/drivers/graphics/intel_extreme/bios.cpp @@ -39,6 +39,12 @@ struct bdb_header { } __attribute__((packed)); +enum bdb_block_id { + BDB_LVDS_OPTIONS = 40, + BDB_LVDS_LFP_DATA_PTRS +}; + + // FIXME the struct definition for the bdb_header is not complete, so we rely // on direct access with hardcoded offsets to get the timings out of it. #define _PIXEL_CLOCK(x) (x[0] + (x[1] << 8)) * 10000 @@ -212,17 +218,22 @@ get_lvds_mode_from_bios(display_timing* panelTiming) int id = vbios.memory[start]; blockSize = vbios.ReadWord(start + 1) + 3; switch (id) { - case 40: // Item BDB_LVDS_OPTIONS + case BDB_LVDS_OPTIONS: { struct lvds_bdb1 *lvds1; lvds1 = (struct lvds_bdb1 *)(vbios.memory + start); panelType = lvds1->panel_type; + if (panelType > 0xf) { + TRACE((DEVICE_NAME ": invalid panel type %d\n", panelType)); + panelType = -1; + break; + } TRACE((DEVICE_NAME ": panel type: %d\n", panelType)); break; } - case 41: // Item BDB_LVDS_LFP_DATA_PTRS + case BDB_LVDS_LFP_DATA_PTRS: { - // First make sure we found block 40 and the panel type + // First make sure we found block BDB_LVDS_OPTIONS and the panel type if (panelType == -1) break;