The extension tag at offset 0 is not present in struct edid, add a helper for it to reduce the need to use u8 *.
Unified · Split
| @@ -1618,6 +1618,13 @@ static int edid_block_get_checksum(const void *_block) · 1617 unmodified lines | |||
| 1618 | return block->checksum; | 1618 | return block->checksum; |
| 1619 | } | 1619 | } |
| 1620 | 1620 | ||
| 1621 | static int edid_block_tag(const void *_block) | ||
| 1622 | { | ||
| 1623 | const u8 *block = _block; | ||
| 1624 | |||
| 1625 | return block[0]; | ||
| 1626 | } | ||
| 1627 | |||
| 1621 | static bool drm_edid_is_zero(const u8 *in_edid, int length) | 1628 | static bool drm_edid_is_zero(const u8 *in_edid, int length) |
| 1622 | { | 1629 | { |
| 1623 | if (memchr_inv(in_edid, 0, length)) | 1630 | 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 | |||
| 1710 | *edid_corrupt = true; | 1717 | *edid_corrupt = true; |
| 1711 | 1718 | ||
| 1712 | /* allow CEA to slide through, switches mangle this */ | 1719 | /* allow CEA to slide through, switches mangle this */ |
| 1713 | if (raw_edid[0] == CEA_EXT) { | 1720 | if (edid_block_tag(raw_edid) == CEA_EXT) { |
| 1714 | DRM_DEBUG("EDID checksum is invalid, remainder is %d\n", csum); | 1721 | DRM_DEBUG("EDID checksum is invalid, remainder is %d\n", csum); |
| 1715 | DRM_DEBUG("Assuming a KVM switch modified the CEA block but left the original checksum\n"); | 1722 | DRM_DEBUG("Assuming a KVM switch modified the CEA block but left the original checksum\n"); |
| 1716 | } else { | 1723 | } else { |
| @@ -1722,7 +1729,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, · 5 unmodified lines | |||
| 1722 | } | 1729 | } |
| 1723 | 1730 | ||
| 1724 | /* per-block-type checks */ | 1731 | /* per-block-type checks */ |
| 1725 | switch (raw_edid[0]) { | 1732 | switch (edid_block_tag(raw_edid)) { |
| 1726 | case 0: /* base */ | 1733 | case 0: /* base */ |
| 1727 | if (edid->version != 1) { | 1734 | if (edid->version != 1) { |
| 1728 | DRM_NOTE("EDID has major version %d, instead of 1\n", edid->version); | 1735 | 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 | |||
| 3366 | /* Find CEA extension */ | 3373 | /* Find CEA extension */ |
| 3367 | for (i = *ext_index; i < edid->extensions; i++) { | 3374 | for (i = *ext_index; i < edid->extensions; i++) { |
| 3368 | edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1); | 3375 | 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) |
| 3370 | break; | 3377 | break; |
| 3371 | } | 3378 | } |
| 3372 | 3379 | ||