Patch "ASoC: es8316: Do not set rate constraints for unsupported MCLKs" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ASoC: es8316: Do not set rate constraints for unsupported MCLKs

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     asoc-es8316-do-not-set-rate-constraints-for-unsuppor.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d5bbb44e7d89b36feed6f880ec73360131779946
Author: Cristian Ciocaltea <cristian.ciocaltea@xxxxxxxxxxxxx>
Date:   Tue May 30 21:11:39 2023 +0300

    ASoC: es8316: Do not set rate constraints for unsupported MCLKs
    
    [ Upstream commit 60413129ee2b38a80347489270af7f6e1c1de4d0 ]
    
    When using the codec through the generic audio graph card, there are at
    least two calls of es8316_set_dai_sysclk(), with the effect of limiting
    the allowed sample rates according to the MCLK/LRCK ratios supported by
    the codec:
    
    1. During audio card setup, to set the initial MCLK - see
       asoc_simple_init_dai().
    
    2. Before opening a stream, to update MCLK, according to the stream
       sample rate and the multiplication factor - see
       asoc_simple_hw_params().
    
    In some cases the initial MCLK might be set to a frequency that doesn't
    match any of the supported ratios, e.g. 12287999 instead of 12288000,
    which is only 1 Hz below the supported clock, as that is what the
    hardware reports. This creates an empty list of rate constraints, which
    is further passed to snd_pcm_hw_constraint_list() via
    es8316_pcm_startup(), and causes the following error on the very first
    access of the sound card:
    
      $ speaker-test -D hw:Analog,0 -F S16_LE -c 2 -t wav
      Broken configuration for playback: no configurations available: Invalid argument
      Setting of hwparams failed: Invalid argument
    
    Note that all subsequent retries succeed thanks to the updated MCLK set
    at point 2 above, which uses a computed frequency value instead of a
    reading from the hardware registers. Normally this would have mitigated
    the issue, but es8316_pcm_startup() executes before the 2nd call to
    es8316_set_dai_sysclk(), hence it cannot make use of the updated
    constraints.
    
    Since es8316_pcm_hw_params() performs anyway a final validation of MCLK
    against the stream sample rate and the supported MCLK/LRCK ratios, fix
    the issue by ensuring that sysclk_constraints list is only set when at
    least one supported sample rate is autodetected by the codec.
    
    Fixes: b8b88b70875a ("ASoC: add es8316 codec driver")
    Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230530181140.483936-3-cristian.ciocaltea@xxxxxxxxxxxxx
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index 673aac91d717e..b36ccfc54cd69 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -369,13 +369,11 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 	int count = 0;
 
 	es8316->sysclk = freq;
+	es8316->sysclk_constraints.list = NULL;
+	es8316->sysclk_constraints.count = 0;
 
-	if (freq == 0) {
-		es8316->sysclk_constraints.list = NULL;
-		es8316->sysclk_constraints.count = 0;
-
+	if (freq == 0)
 		return 0;
-	}
 
 	ret = clk_set_rate(es8316->mclk, freq);
 	if (ret)
@@ -391,8 +389,10 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 			es8316->allowed_rates[count++] = freq / ratio;
 	}
 
-	es8316->sysclk_constraints.list = es8316->allowed_rates;
-	es8316->sysclk_constraints.count = count;
+	if (count) {
+		es8316->sysclk_constraints.list = es8316->allowed_rates;
+		es8316->sysclk_constraints.count = count;
+	}
 
 	return 0;
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux