From f864a192e3de07c246c1f595085b657e825742bc Mon Sep 17 00:00:00 2001 From: Bincai Liu Date: Thu, 13 Feb 2025 23:19:44 +0800 Subject: [PATCH] soc/mediatek/mt8196: Support 512 bytes EDID Refine dptx_get_edid function to read extension edid to bring up 2.8k 120hz OLED panel. BRANCH=rauru BUG=b:392040003 TEST=check edp training pass and show log: EQ training pass Change-Id: If35782950ae02d892ea697580fa4991595c21533 Signed-off-by: Bincai Liu Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/86779 Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) --- src/soc/mediatek/common/dp/dptx_common.c | 29 ++++++++++++++++--- .../common/dp/include/soc/dptx_common.h | 4 ++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/soc/mediatek/common/dp/dptx_common.c b/src/soc/mediatek/common/dp/dptx_common.c index b43bf51ae1..ac8f4527c2 100644 --- a/src/soc/mediatek/common/dp/dptx_common.c +++ b/src/soc/mediatek/common/dp/dptx_common.c @@ -73,17 +73,38 @@ bool dptx_auxread_dpcd(struct mtk_dp *mtk_dp, u8 cmd, u32 dpcd_addr, int dptx_get_edid(struct mtk_dp *mtk_dp, struct edid *out) { int ret; - u8 edid[ONE_BLOCK_SIZE]; + u8 edid[EDID_BUF_SIZE]; u8 tmp = 0; + u8 extblock = 0; + size_t total_size; dptx_auxwrite_dpcd(mtk_dp, DP_AUX_I2C_WRITE, 0x50, 0x1, &tmp); - for (tmp = 0; tmp < ONE_BLOCK_SIZE / DP_AUX_MAX_PAYLOAD_BYTES; tmp++) + /* Read 1st block */ + for (tmp = 0; tmp < EDID_BLOCK_SIZE / DP_AUX_MAX_PAYLOAD_BYTES; tmp++) dptx_auxread_dpcd(mtk_dp, DP_AUX_I2C_READ, 0x50, DP_AUX_MAX_PAYLOAD_BYTES, - edid + tmp * 16); + edid + tmp * DP_AUX_MAX_PAYLOAD_BYTES); - ret = decode_edid(edid, ONE_BLOCK_SIZE, out); + extblock = edid[EDID_EXT_BLOCK_COUNT]; + total_size = EDID_BLOCK_SIZE * (1 + extblock); + + if (total_size > EDID_BUF_SIZE) { + printk(BIOS_WARNING, "The edid block size(%zu) is larger than %u bytes\n", + total_size, EDID_BUF_SIZE); + printk(BIOS_WARNING, "Read first %u bytes only\n", EDID_BUF_SIZE); + total_size = EDID_BUF_SIZE; + } + + if (total_size > EDID_BLOCK_SIZE) { + for (tmp = EDID_BLOCK_SIZE / DP_AUX_MAX_PAYLOAD_BYTES; + tmp < total_size / DP_AUX_MAX_PAYLOAD_BYTES; tmp++) + dptx_auxread_dpcd(mtk_dp, DP_AUX_I2C_READ, + 0x50, DP_AUX_MAX_PAYLOAD_BYTES, + edid + tmp * DP_AUX_MAX_PAYLOAD_BYTES); + } + + ret = decode_edid(edid, total_size, out); if (ret != EDID_CONFORMANT) { printk(BIOS_ERR, "failed to decode edid(%d).\n", ret); return -1; diff --git a/src/soc/mediatek/common/dp/include/soc/dptx_common.h b/src/soc/mediatek/common/dp/include/soc/dptx_common.h index d3f799187a..2ea070eca7 100644 --- a/src/soc/mediatek/common/dp/include/soc/dptx_common.h +++ b/src/soc/mediatek/common/dp/include/soc/dptx_common.h @@ -8,7 +8,8 @@ #define ENABLE_DPTX_EF_MODE 0x1 #define DPTX_AUX_SET_ENAHNCED_FRAME 0x80 -#define ONE_BLOCK_SIZE 128 +#define EDID_BLOCK_SIZE 128 +#define EDID_BUF_SIZE (EDID_BLOCK_SIZE * 4) #define DP_LINK_CONSTANT_N_VALUE 0x8000 #define DP_LINK_STATUS_SIZE 6 @@ -38,6 +39,7 @@ #define DP_EDP_14 0x03 #define DP_EDP_14a 0x04 #define DP_EDP_14b 0x05 +#define EDID_EXT_BLOCK_COUNT 0x7E /* Receiver Capability */ #define DP_DPCD_REV 0x000