For a pipe configuration, if no supported audio frequencies are found, then start reducing the audio channels and try assess the sad audio frequency list again. Bspec: 67768 Signed-off-by: Vinod Govindapillai <vinod.govindapillai@xxxxxxxxx> --- drivers/gpu/drm/i915/display/intel_audio.c | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c index e84101ef9531..14fabbcbf5da 100644 --- a/drivers/gpu/drm/i915/display/intel_audio.c +++ b/drivers/gpu/drm/i915/display/intel_audio.c @@ -766,16 +766,28 @@ static void intel_audio_compute_sad(struct drm_i915_private *i915, int avail_overhead, int req_overhead, struct cea_sad *sad) { - u8 sad_channels = sad->channels + 1; + u8 channels; u8 sad_freq; - sad_freq = intel_audio_get_pruned_audfreq(i915, line_freq_khz, - hblank_slots_lanes, - avail_overhead, - req_overhead, sad_channels, - sad->freq); + /* + * If we don't find any supported audio frequencies for a channel, + * reduce the channel and try + */ + for (channels = sad->channels + 1; channels >= 1; channels--) { + sad_freq = intel_audio_get_pruned_audfreq(i915, line_freq_khz, + hblank_slots_lanes, + avail_overhead, + req_overhead, + channels, + sad->freq); + + /* Supported frequencies exist! No need to proceed further */ + if (sad_freq) + break; + } sad->freq = sad_freq; + sad->channels = channels ? channels - 1 : 0; } bool intel_audio_compute_eld_config(struct drm_connector_state *conn_state, @@ -793,19 +805,23 @@ bool intel_audio_compute_eld_config(struct drm_connector_state *conn_state, for (int i = 0; i < drm_eld_sad_count(eld); i++) { struct cea_sad sad; u8 sad_freq; + u8 sad_channels; if (drm_eld_sad_get(eld, i, &sad)) continue; sad_freq = sad.freq; + sad_channels = sad.channels; intel_audio_compute_sad(i915, line_freq_khz, hblank_slots_lanes, avail_overhead, req_overhead, &sad); /* Update the eld with new sad data if any changes in the list */ - if (sad_freq != sad.freq) { + if (sad_freq != sad.freq || sad_channels != sad.channels) { drm_eld_sad_set(eld, i, &sad); - drm_dbg_kms(&i915->drm, "sad updated. Pruned freq list: 0x%x\n", sad.freq); + drm_dbg_kms(&i915->drm, + "SAD updated. Freq: 0x%x(0x%x) Channels: %d(%d)\n", + sad.freq, sad_freq, sad.channels, sad_channels); } } -- 2.34.1