drm/edid: improve cea_db_offsets compatibility
authorZheng Yang <zhengyang@rock-chips.com>
Mon, 24 Jul 2017 03:51:22 +0000 (11:51 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 24 Jul 2017 08:50:01 +0000 (16:50 +0800)
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 <zhengyang@rock-chips.com>
drivers/gpu/drm/drm_edid.c

index 3cd00c1a67cfca84d5eabada2c97853d6c0c4dfb..7461348954ede0bedd9ae0d844316b0146efe54a 100644 (file)
@@ -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;
 }