Commit 4ba0f53c authored by Jani Nikula's avatar Jani Nikula

drm/edid: add edid_block_tag() helper to get the EDID extension tag

The extension tag at offset 0 is not present in struct edid, add a
helper for it to reduce the need to use u8 *.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/3f27c67db63c186a48e83fdee2d1ac8a17714e78.1648752228.git.jani.nikula@intel.com
parent 70e49ebe
......@@ -1618,6 +1618,13 @@ static int edid_block_get_checksum(const void *_block)
return block->checksum;
}
static int edid_block_tag(const void *_block)
{
const u8 *block = _block;
return block[0];
}
static bool drm_edid_is_zero(const u8 *in_edid, int length)
{
if (memchr_inv(in_edid, 0, length))
......@@ -1710,7 +1717,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
*edid_corrupt = true;
/* allow CEA to slide through, switches mangle this */
if (raw_edid[0] == CEA_EXT) {
if (edid_block_tag(raw_edid) == CEA_EXT) {
DRM_DEBUG("EDID checksum is invalid, remainder is %d\n", csum);
DRM_DEBUG("Assuming a KVM switch modified the CEA block but left the original checksum\n");
} else {
......@@ -1722,7 +1729,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
}
/* per-block-type checks */
switch (raw_edid[0]) {
switch (edid_block_tag(raw_edid)) {
case 0: /* base */
if (edid->version != 1) {
DRM_NOTE("EDID has major version %d, instead of 1\n", edid->version);
......@@ -3366,7 +3373,7 @@ const u8 *drm_find_edid_extension(const struct edid *edid,
/* Find CEA extension */
for (i = *ext_index; i < edid->extensions; i++) {
edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
if (edid_ext[0] == ext_id)
if (edid_block_tag(edid_ext) == ext_id)
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment