mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 09:14:19 +08:00
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: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/f96188f64e9f7f3deff348d08296609353b12316.1666614699.git.jani.nikula@intel.com
This commit is contained in:
parent
b16c9e6c7d
commit
6c9b3db70a
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user