Skip to content

Commit

Permalink
drm: Add helper to compare edids.
Browse files Browse the repository at this point in the history
Many drivers would benefit from using
drm helper to compare edid, rather
than bothering with own implementation.

v2: Added documentation for this function.

Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200630002700.5451-2-kunal1.joshi@intel.com
  • Loading branch information
Stanislav Lisovskiy authored and Maarten Lankhorst committed Jun 30, 2020
1 parent e9d636a commit 536faa4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
33 changes: 33 additions & 0 deletions drivers/gpu/drm/drm_edid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,39 @@ static bool drm_edid_is_zero(const u8 *in_edid, int length)
return true;
}

/**
* drm_edid_are_equal - compare two edid blobs.
* @edid1: pointer to first blob
* @edid2: pointer to second blob
* This helper can be used during probing to determine if
* edid had changed.
*/
bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2)
{
int edid1_len, edid2_len;
bool edid1_present = edid1 != NULL;
bool edid2_present = edid2 != NULL;

if (edid1_present != edid2_present)
return false;

if (edid1) {

edid1_len = EDID_LENGTH * (1 + edid1->extensions);
edid2_len = EDID_LENGTH * (1 + edid2->extensions);

if (edid1_len != edid2_len)
return false;

if (memcmp(edid1, edid2, edid1_len))
return false;
}

return true;
}
EXPORT_SYMBOL(drm_edid_are_equal);


/**
* drm_edid_block_valid - Sanity check the EDID block (base or extension)
* @raw_edid: pointer to raw EDID block
Expand Down
9 changes: 9 additions & 0 deletions include/drm/drm_edid.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,15 @@ drm_load_edid_firmware(struct drm_connector *connector)
}
#endif

/**
* drm_edid_are_equal - compare two edid blobs.
* @edid1: pointer to first blob
* @edid2: pointer to second blob
* This helper can be used during probing to determine if
* edid had changed.
*/
bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2);

int
drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
const struct drm_connector *connector,
Expand Down

0 comments on commit 536faa4

Please sign in to comment.