From: Zheng Yang Date: Mon, 24 Jul 2017 03:51:22 +0000 (+0800) Subject: drm/edid: improve cea_db_offsets compatibility X-Git-Tag: release-20171130_firefly~4^2~112 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=23e1058a945579f7a25f818d8fb5c41129979abe;p=firefly-linux-kernel-4.4.55.git 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 --- 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; }