This will allow us to remove some ocurrences of drm_edid_raw() and the
driver will reduce handling raw EDID data in favor of drm_edid helpers.

v7:
- instead of new files, move edid-related helpers to dm_helpers (Harry)

Signed-off-by: Melissa Wen <[email protected]>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c    | 16 ++++++++++++++++
 drivers/gpu/drm/amd/display/dc/dm_helpers.h      |  4 ++++
 .../gpu/drm/amd/display/dc/link/link_detection.c | 15 +--------------
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index c14d62e63c08..f3cc6ea11c6f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -983,6 +983,22 @@ dm_helpers_read_acpi_edid(struct amdgpu_dm_connector 
*aconnector)
        return drm_edid_read_custom(connector, dm_helpers_probe_acpi_edid, 
connector);
 }
 
+bool dm_helpers_is_same_edid(struct dc_sink *prev_sink,
+                            struct dc_sink *current_sink)
+{
+       struct dc_edid *old_edid = &prev_sink->dc_edid;
+       struct dc_edid *new_edid = &current_sink->dc_edid;
+
+       if (old_edid->length != new_edid->length)
+               return false;
+
+       if (new_edid->length == 0)
+               return false;
+
+       return (memcmp(old_edid->raw_edid,
+                      new_edid->raw_edid, new_edid->length) == 0);
+}
+
 enum dc_edid_status dm_helpers_read_local_edid(
                struct dc_context *ctx,
                struct dc_link *link,
diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h 
b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
index ce6a70368bd0..2fb445933350 100644
--- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h
+++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
@@ -62,6 +62,10 @@ void dm_helpers_free_gpu_mem(
 enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
                                               struct dc_sink *sink);
 
+/* Compare two EDIDs */
+bool dm_helpers_is_same_edid(struct dc_sink *prev_sink,
+                            struct dc_sink *current_sink);
+
 /*
  * Update DP branch info
  */
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c 
b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
index d2528e35ae0b..616540acc6ee 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -622,18 +622,6 @@ static bool detect_dp(struct dc_link *link,
        return true;
 }
 
-static bool is_same_edid(struct dc_edid *old_edid, struct dc_edid *new_edid)
-{
-       if (old_edid->length != new_edid->length)
-               return false;
-
-       if (new_edid->length == 0)
-               return false;
-
-       return (memcmp(old_edid->raw_edid,
-                      new_edid->raw_edid, new_edid->length) == 0);
-}
-
 static bool wait_for_entering_dp_alt_mode(struct dc_link *link)
 {
 
@@ -1214,8 +1202,7 @@ static bool detect_link_and_local_sink(struct dc_link 
*link,
                // Check if edid is the same
                if ((prev_sink) &&
                    (edid_status == EDID_THE_SAME || edid_status == EDID_OK))
-                       same_edid = is_same_edid(&prev_sink->dc_edid,
-                                                &sink->dc_edid);
+                       same_edid = dm_helpers_is_same_edid(prev_sink, sink);
 
                if (sink->edid_caps.panel_patch.skip_scdc_overwrite)
                        link->ctx->dc->debug.hdmi20_disable = true;
-- 
2.51.0

Reply via email to