Commit 6c9b3db7 authored by Jani Nikula's avatar Jani Nikula

drm/edid: add function for checking drm_edid validity

We've lacked a function for immutable validity check on drm_edid. Add
one.
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/f96188f64e9f7f3deff348d08296609353b12316.1666614699.git.jani.nikula@intel.com
parent b16c9e6c
......@@ -2040,6 +2040,36 @@ bool drm_edid_is_valid(struct edid *edid)
}
EXPORT_SYMBOL(drm_edid_is_valid);
/**
* drm_edid_valid - sanity check EDID data
* @drm_edid: EDID data
*
* Sanity check an EDID. Cross check block count against allocated size and
* checksum the blocks.
*
* Return: True if the EDID data is valid, false otherwise.
*/
bool drm_edid_valid(const struct drm_edid *drm_edid)
{
int i;
if (!drm_edid)
return false;
if (edid_size_by_blocks(__drm_edid_block_count(drm_edid)) != drm_edid->size)
return false;
for (i = 0; i < drm_edid_block_count(drm_edid); i++) {
const void *block = drm_edid_block_data(drm_edid, i);
if (!edid_block_valid(block, i == 0))
return false;
}
return true;
}
EXPORT_SYMBOL(drm_edid_valid);
static struct edid *edid_filter_invalid_blocks(struct edid *edid,
size_t *alloc_size)
{
......
......@@ -606,6 +606,7 @@ drm_display_mode_from_cea_vic(struct drm_device *dev,
const struct drm_edid *drm_edid_alloc(const void *edid, size_t size);
const struct drm_edid *drm_edid_dup(const struct drm_edid *drm_edid);
void drm_edid_free(const struct drm_edid *drm_edid);
bool drm_edid_valid(const struct drm_edid *drm_edid);
const struct edid *drm_edid_raw(const struct drm_edid *drm_edid);
const struct drm_edid *drm_edid_read(struct drm_connector *connector);
const struct drm_edid *drm_edid_read_ddc(struct drm_connector *connector,
......
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