[PATCH v5 5/9] drm/amd/display: use drm_edid_product_id for parsing EDID product info
Melissa Wen
mwen at igalia.com
Wed Aug 7 20:25:07 UTC 2024
Since [1], we can use drm_edid_product_id to get debug info from
drm_edid instead of directly parsing EDID.
[1] https://lore.kernel.org/dri-devel/cover.1712655867.git.jani.nikula@intel.com/
Signed-off-by: Melissa Wen <mwen at igalia.com>
---
.../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 37 ++++++++++---------
1 file changed, 19 insertions(+), 18 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 2e07ce2e89f4..1e454cfcaef2 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
@@ -45,16 +45,15 @@
#include "dm_helpers.h"
#include "ddc_service_types.h"
-static u32 edid_extract_panel_id(struct edid *edid)
+static u32 edid_extract_panel_id(struct drm_edid_product_id *product_id)
{
- return (u32)edid->mfg_id[0] << 24 |
- (u32)edid->mfg_id[1] << 16 |
- (u32)EDID_PRODUCT_ID(edid);
+ return (u32)be16_to_cpu(product_id->manufacturer_name) << 16 |
+ (u32)le16_to_cpu(product_id->product_code);
}
-static void apply_edid_quirks(struct edid *edid, struct dc_edid_caps *edid_caps)
+static void apply_edid_quirks(struct drm_edid_product_id *product_id, struct dc_edid_caps *edid_caps)
{
- uint32_t panel_id = edid_extract_panel_id(edid);
+ uint32_t panel_id = edid_extract_panel_id(product_id);
switch (panel_id) {
/* Workaround for some monitors which does not work well with FAMS */
@@ -94,6 +93,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
{
struct amdgpu_dm_connector *aconnector = link->priv;
struct drm_connector *connector = &aconnector->base;
+ const struct drm_edid *drm_edid = aconnector->drm_edid;
+ struct drm_edid_product_id product_id;
struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
struct cea_sad *sads;
int sad_count = -1;
@@ -109,13 +110,13 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
if (!drm_edid_is_valid(edid_buf))
result = EDID_BAD_CHECKSUM;
- edid_caps->manufacturer_id = (uint16_t) edid_buf->mfg_id[0] |
- ((uint16_t) edid_buf->mfg_id[1])<<8;
- edid_caps->product_id = (uint16_t) edid_buf->prod_code[0] |
- ((uint16_t) edid_buf->prod_code[1])<<8;
- edid_caps->serial_number = edid_buf->serial;
- edid_caps->manufacture_week = edid_buf->mfg_week;
- edid_caps->manufacture_year = edid_buf->mfg_year;
+ drm_edid_get_product_id(drm_edid, &product_id);
+
+ edid_caps->manufacturer_id = le16_to_cpu(product_id.manufacturer_name);
+ edid_caps->product_id = le16_to_cpu(product_id.product_code);
+ edid_caps->serial_number = le32_to_cpu(product_id.serial_number);
+ edid_caps->manufacture_week = product_id.week_of_manufacture;
+ edid_caps->manufacture_year = product_id.year_of_manufacture;
drm_edid_get_monitor_name(edid_buf,
edid_caps->display_name,
@@ -123,7 +124,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
edid_caps->edid_hdmi = connector->display_info.is_hdmi;
- apply_edid_quirks(edid_buf, edid_caps);
+ apply_edid_quirks(&product_id, edid_caps);
sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
if (sad_count <= 0)
@@ -909,9 +910,9 @@ enum dc_edid_status dm_helpers_read_local_edid(
* do check sum and retry to make sure read correct edid.
*/
do {
-
drm_edid = drm_edid_read_ddc(connector, ddc);
drm_edid_connector_update(connector, drm_edid);
+ aconnector->drm_edid = drm_edid;
/* DP Compliance Test 4.2.2.6 */
if (link->aux_mode && connector->edid_corrupt)
@@ -929,14 +930,14 @@ enum dc_edid_status dm_helpers_read_local_edid(
sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length);
- /* We don't need the original edid anymore */
- drm_edid_free(drm_edid);
-
edid_status = dm_helpers_parse_edid_caps(
link,
&sink->dc_edid,
&sink->edid_caps);
+ /* We don't need the original edid anymore */
+ drm_edid_free(drm_edid);
+
} while (edid_status == EDID_BAD_CHECKSUM && --retry > 0);
if (edid_status != EDID_OK)
--
2.43.0
More information about the dri-devel
mailing list