History

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 *.

Jani Nikula committed 4 years ago

Commit 4ba0f531 parent 70e49eb1 file · +10 −3Browse files

Unified · Split

drivers/gpu/drm/drm_edid.c+10−3
@@ -1618,6 +1618,13 @@ static int edid_block_get_checksum(const void *_block) · 1617 unmodified lines
16181618 return block->checksum;
16191619 }
16201620
1621+static int edid_block_tag(const void *_block)
1622+{
1623+ const u8 *block = _block;
1624+
1625+ return block[0];
1626+}
1627+
16211628 static bool drm_edid_is_zero(const u8 *in_edid, int length)
16221629 {
16231630 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, · 86 unmodified lines
17101717 *edid_corrupt = true;
17111718
17121719 /* allow CEA to slide through, switches mangle this */
1713− if (raw_edid[0] == CEA_EXT) {
1720+ if (edid_block_tag(raw_edid) == CEA_EXT) {
17141721 DRM_DEBUG("EDID checksum is invalid, remainder is %d\n", csum);
17151722 DRM_DEBUG("Assuming a KVM switch modified the CEA block but left the original checksum\n");
17161723 } else {
@@ -1722,7 +1729,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, · 5 unmodified lines
17221729 }
17231730
17241731 /* per-block-type checks */
1725− switch (raw_edid[0]) {
1732+ switch (edid_block_tag(raw_edid)) {
17261733 case 0: /* base */
17271734 if (edid->version != 1) {
17281735 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, · 1637 unmodified lines
33663373 /* Find CEA extension */
33673374 for (i = *ext_index; i < edid->extensions; i++) {
33683375 edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
3369− if (edid_ext[0] == ext_id)
3376+ if (edid_block_tag(edid_ext) == ext_id)
33703377 break;
33713378 }
33723379