]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/edid: add edid_block_tag() helper to get the EDID extension tag
authorJani Nikula <jani.nikula@intel.com>
Thu, 31 Mar 2022 18:45:00 +0000 (21:45 +0300)
committerJani Nikula <jani.nikula@intel.com>
Fri, 1 Apr 2022 14:44:40 +0000 (17:44 +0300)
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: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/3f27c67db63c186a48e83fdee2d1ac8a17714e78.1648752228.git.jani.nikula@intel.com
drivers/gpu/drm/drm_edid.c

index c9161989b2d2c27a1a5868ac63ff05602fdb43fe..e50b1917df71356b41c48a4745cb2302d9f63c8e 100644 (file)
@@ -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;
        }