From 23e1058a945579f7a25f818d8fb5c41129979abe Mon Sep 17 00:00:00 2001 From: Zheng Yang Date: Mon, 24 Jul 2017 11:51:22 +0800 Subject: [PATCH] drm/edid: improve cea_db_offsets compatibility The cea[2] is equal to the real value minus one in some sink edid, found on a Konka LCD TV. the last data block offset plus the payload length is equal to cea[2]. The end value need to plus one under this scene. Change-Id: I41b477559023ccd1cc4a5450dd9d35bed095f147 Signed-off-by: Zheng Yang --- drivers/gpu/drm/drm_edid.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 3cd00c1a67cf..7461348954ed 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3449,6 +3449,23 @@ cea_db_offsets(const u8 *cea, int *start, int *end) *end = 127; if (*end < 4 || *end > 127) return -ERANGE; + + /* + * XXX: cea[2] is equal to the real value minus one in some sink edid. + */ + if (*end != 4) { + int i; + + i = *start; + while (i < (*end) && + i + cea_db_payload_len(&(cea)[i]) < (*end)) + i += cea_db_payload_len(&(cea)[i]) + 1; + + if (cea_db_payload_len(&(cea)[i]) && + i + cea_db_payload_len(&(cea)[i]) == (*end)) + (*end)++; + } + return 0; } -- 2.34.1