On Thu, 2025-11-06 at 13:49 -0300, Melissa Wen wrote:
> 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.
> 
> Reviewed-by: Mario Limonciello <[email protected]>
> Signed-off-by: Melissa Wen <[email protected]>

Reviewed-by: Timur Kristóf <[email protected]>

> ---
>  .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 22 ++++++++++-------
> --
>  1 file changed, 12 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 c055841c3a8f..4333b02dc552 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
> @@ -34,6 +34,7 @@
>  #include <drm/drm_probe_helper.h>
>  #include <drm/amdgpu_drm.h>
>  #include <drm/drm_edid.h>
> +#include <drm/drm_eld.h>
>  #include <drm/drm_fixed.h>
>  
>  #include "dm_services.h"
> @@ -107,9 +108,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
>       struct edid *edid_buf = edid ? (struct edid *) edid-
> >raw_edid : NULL;
>       const struct drm_edid *drm_edid;
>       struct drm_edid_product_id product_id;
> -     struct cea_sad *sads;
> -     int sad_count = -1;
> -     int sadb_count = -1;
> +     int sad_count, sadb_count;
>       int i = 0;
>       uint8_t *sadb = NULL;
>       enum dc_edid_status result = EDID_OK;
> @@ -123,6 +122,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
>       if (!drm_edid_valid(drm_edid))
>               result = EDID_BAD_CHECKSUM;
>  
> +     drm_edid_connector_update(connector, drm_edid);
>       drm_edid_get_product_id(drm_edid, &product_id);
>  
>       edid_caps->manufacturer_id = product_id.manufacturer_name;
> @@ -140,7 +140,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
>  
>       apply_edid_quirks(dev, drm_edid, 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) {
>               drm_edid_free(drm_edid);
>               return result;
> @@ -148,12 +148,15 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
>  
>       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);
> @@ -168,7 +171,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
>       else
>               edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
>  
> -     kfree(sads);
>       kfree(sadb);
>       drm_edid_free(drm_edid);
>  

Reply via email to