Commit 00c7a010 authored by Jani Nikula's avatar Jani Nikula

drm/edid: make drm_edid_are_equal() more convenient for its single user

Repurpose drm_edid_are_equal() to be more helpful for its single user,
and rename drm_edid_eq(). Functionally deduce the length from the blob
size, not the blob data, making it more robust against any errors.
Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/1011a285d30babce3aabd8218abb7ece7dcf58a2.1713259151.git.jani.nikula@intel.comSigned-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent d7bf5fcc
...@@ -1820,30 +1820,20 @@ static bool edid_block_is_zero(const void *edid) ...@@ -1820,30 +1820,20 @@ static bool edid_block_is_zero(const void *edid)
return !memchr_inv(edid, 0, EDID_LENGTH); return !memchr_inv(edid, 0, EDID_LENGTH);
} }
/** static bool drm_edid_eq(const struct drm_edid *drm_edid,
* drm_edid_are_equal - compare two edid blobs. const void *raw_edid, size_t raw_edid_size)
* @edid1: pointer to first blob
* @edid2: pointer to second blob
* This helper can be used during probing to determine if
* edid had changed.
*/
static bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2)
{ {
int edid1_len, edid2_len; bool edid1_present = drm_edid && drm_edid->edid && drm_edid->size;
bool edid1_present = edid1 != NULL; bool edid2_present = raw_edid && raw_edid_size;
bool edid2_present = edid2 != NULL;
if (edid1_present != edid2_present) if (edid1_present != edid2_present)
return false; return false;
if (edid1) { if (edid1_present) {
edid1_len = edid_size(edid1); if (drm_edid->size != raw_edid_size)
edid2_len = edid_size(edid2);
if (edid1_len != edid2_len)
return false; return false;
if (memcmp(edid1, edid2, edid1_len)) if (memcmp(drm_edid->edid, raw_edid, drm_edid->size))
return false; return false;
} }
...@@ -6936,17 +6926,16 @@ static int _drm_edid_connector_property_update(struct drm_connector *connector, ...@@ -6936,17 +6926,16 @@ static int _drm_edid_connector_property_update(struct drm_connector *connector,
int ret; int ret;
if (connector->edid_blob_ptr) { if (connector->edid_blob_ptr) {
const struct edid *old_edid = connector->edid_blob_ptr->data; const void *old_edid = connector->edid_blob_ptr->data;
size_t old_edid_size = connector->edid_blob_ptr->length;
if (old_edid) { if (old_edid && !drm_edid_eq(drm_edid, old_edid, old_edid_size)) {
if (!drm_edid_are_equal(drm_edid ? drm_edid->edid : NULL, old_edid)) {
connector->epoch_counter++; connector->epoch_counter++;
drm_dbg_kms(dev, "[CONNECTOR:%d:%s] EDID changed, epoch counter %llu\n", drm_dbg_kms(dev, "[CONNECTOR:%d:%s] EDID changed, epoch counter %llu\n",
connector->base.id, connector->name, connector->base.id, connector->name,
connector->epoch_counter); connector->epoch_counter);
} }
} }
}
ret = drm_property_replace_global_blob(dev, ret = drm_property_replace_global_blob(dev,
&connector->edid_blob_ptr, &connector->edid_blob_ptr,
......
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