AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Melissa Wen <mwen@igalia.com>
To: harry.wentland@amd.com, sunpeng.li@amd.com,
	Rodrigo.Siqueira@amd.com, alexander.deucher@amd.com,
	christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com,
	daniel@ffwll.ch
Cc: Alex Hung <alex.hung@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	kernel-dev@igalia.com, Melissa Wen <mwen@igalia.com>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH v5 7/9] drm/amd/display: get SAD from drm_eld when parsing EDID caps
Date: Wed,  7 Aug 2024 19:25:09 -0100	[thread overview]
Message-ID: <20240807203207.2830-8-mwen@igalia.com> (raw)
In-Reply-To: <20240807203207.2830-1-mwen@igalia.com>

drm_edid_connector_update() updates display info, filling ELD with audio
info from Short-Audio Descriptors in the last step of
update_dislay_info(). Our goal is stopping using raw edid, so we can
extract SAD from drm_eld instead of access raw edid to get audio caps.

v5:
- squash with `don't give initial values for sad/b_count` (Alex H)
- add more informative commit description (Alex H)

Signed-off-by: Melissa Wen <mwen@igalia.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 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 89ffd36dafd3..036bc5423c12 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
@@ -97,9 +97,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 	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;
-	int sadb_count = -1;
+	int sad_count, sadb_count;
 	int i = 0;
 	uint8_t *sadb = NULL;
 
@@ -128,18 +126,21 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 
 	apply_edid_quirks(&product_id, edid_caps);
 
-	sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
+	sad_count = drm_eld_sad_count(connector->eld);
 	if (sad_count <= 0)
 		return result;
 
 	edid_caps->audio_mode_count = min(sad_count, DC_MAX_AUDIO_DESC_COUNT);
 	for (i = 0; i < edid_caps->audio_mode_count; ++i) {
-		struct cea_sad *sad = &sads[i];
+		struct cea_sad sad;
 
-		edid_caps->audio_modes[i].format_code = sad->format;
-		edid_caps->audio_modes[i].channel_count = sad->channels + 1;
-		edid_caps->audio_modes[i].sample_rate = sad->freq;
-		edid_caps->audio_modes[i].sample_size = sad->byte2;
+		if (drm_eld_sad_get(connector->eld, i, &sad) < 0)
+			continue;
+
+		edid_caps->audio_modes[i].format_code = sad.format;
+		edid_caps->audio_modes[i].channel_count = sad.channels + 1;
+		edid_caps->audio_modes[i].sample_rate = sad.freq;
+		edid_caps->audio_modes[i].sample_size = sad.byte2;
 	}
 
 	sadb_count = drm_edid_to_speaker_allocation((struct edid *) edid->raw_edid, &sadb);
@@ -154,7 +155,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 	else
 		edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
 
-	kfree(sads);
 	kfree(sadb);
 
 	return result;
-- 
2.43.0


  parent reply	other threads:[~2024-08-07 20:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07 20:25 [PATCH v5 0/9] drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid Melissa Wen
2024-08-07 20:25 ` [PATCH v5 1/9] " Melissa Wen
2024-08-07 20:25 ` [PATCH v5 2/9] drm/amd/display: switch to setting physical address directly Melissa Wen
2024-08-07 20:25 ` [PATCH v5 3/9] drm/amd/display: always call connector_update when parsing freesync_caps Melissa Wen
2024-08-07 20:25 ` [PATCH v5 4/9] drm/amd/display: remove redundant freesync parser for DP Melissa Wen
2024-08-07 20:25 ` [PATCH v5 5/9] drm/amd/display: use drm_edid_product_id for parsing EDID product info Melissa Wen
2024-08-07 20:25 ` [PATCH v5 6/9] drm/amd/display: parse display name from drm_eld Melissa Wen
2024-08-07 20:25 ` Melissa Wen [this message]
2024-08-07 20:25 ` [PATCH v5 8/9] drm/amd/display: get SADB from drm_eld when parsing EDID caps Melissa Wen
2024-08-07 20:25 ` [PATCH v5 9/9] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps Melissa Wen
2024-08-08  9:01 ` [PATCH v5 0/9] drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240807203207.2830-8-mwen@igalia.com \
    --to=mwen@igalia.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alex.hung@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=jani.nikula@linux.intel.com \
    --cc=kernel-dev@igalia.com \
    --cc=mario.limonciello@amd.com \
    --cc=sunpeng.li@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox