diff options
author | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2019-09-02 18:35:03 +0300 |
---|---|---|
committer | Oleksandr Suvorov <oleksandr.suvorov@toradex.com> | 2019-09-06 16:36:16 +0300 |
commit | f997df18c0e4c988de49e984329cefdf6e13ed86 (patch) | |
tree | e306dd1928786aff8a91f80ff7d35f3acd922fe1 /sound/soc/tegra/apalis-tk1.c | |
parent | 84ebbdcdbf191e829d33ac557bfff4276ee2849a (diff) |
apalis-tk1: fix record/playback for sgtl5000 codec
According to the manual [1], SYS_MCLK should base on SYS_FS, not on sample rate.
Calculating SYS_MCLK using sample rate only prevents playing/recording
samples with rate < 16 kHz:
---------------------------------------------------------------
root@apalis-tk1:~# aplay test-8k-sample.wav
Playing WAVE 'test-8k-sample.wav' : Signed 16 bit
[...] tegra-snd-apalis-tk1-sgtl5000 tegra-snd-apalis-tk1-sgtl5000.0: ASoC: machine hw_params failed: -22
Little Endian, Rate 8000 Hz, Stereo
aplay: set_params:1403: Unable to install hw params:
...
---------------------------------------------------------------
Using the helper from sgtl5000.h fixes this issue.
To keep determination of sys_fs solid, use a helper in device driver.
[1] https://www.nxp.com/docs/en/data-sheet/SGTL5000.pdf
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Diffstat (limited to 'sound/soc/tegra/apalis-tk1.c')
-rw-r--r-- | sound/soc/tegra/apalis-tk1.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/sound/soc/tegra/apalis-tk1.c b/sound/soc/tegra/apalis-tk1.c index 4f08b1d32980..6ca99a1ca67e 100644 --- a/sound/soc/tegra/apalis-tk1.c +++ b/sound/soc/tegra/apalis-tk1.c @@ -69,20 +69,10 @@ static int apalis_tk1_sgtl5000_hw_params(struct snd_pcm_substream *substream, int err; int rate; - /* sgtl5000 does not support 512*rate when in 96000 fs */ srate = params_rate(params); - switch (srate) { - case 96000: - mclk = 256 * srate; - break; - default: - mclk = 512 * srate; - break; - } - - /* Sgtl5000 sysclk should be >= 8MHz and <= 27M */ - if (mclk < 8000000 || mclk > 27000000) - return -EINVAL; + mclk = sgtl5000_srate_to_mclk(srate); + if (IS_ERR_VALUE(mclk)) + return mclk; if (pdata->i2s_param[HIFI_CODEC].is_i2s_master) i2s_daifmt = SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS; |