ASoC: sgtl5000: Allow 8kHz playback in codec slave mode

When trying to play a 8kHz file with codec in slave mode we get the following
error on a mx28evk:

$ aplay -Dhw:0,0 stereo_8k.wav
Playing WAVE 'stereo_8k.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
[   21.218647] sgtl5000 0-000a: PLL not supported in slave mode
[   21.224559] sgtl5000 0-000a: 128 ratio is not supported. SYS_MCLK needs to be 256, 384 or 512 * fs
[   21.233687] sgtl5000 0-000a: ASoC: can't set sgtl5000 hw params: -22
aplay: set_params:1123: Unable to install hw params:

This error happens because we are using 'sys_fs' instead of 'frame_rate' in the
valid ratio check.

Use the real'frame_rate' so that the ratio is correctly calculated and the
playback can run.

sgtl5000 codec manual states that in 'Synchronous SYS_MCLK input' mode that the
following SYS_CLK frequencies are allowed: 256*fs, 384*fs, 512*fs.

, where fs is the sampling frequency, which can be in the range of:
8, 11.025, 16, 22.5, 32, 44.1, 48, 96 kHz.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Fabio Estevam 2014-11-27 13:02:01 -02:00 коммит произвёл Mark Brown
Родитель d819ce965d
Коммит 2a4cfd1022
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -618,7 +618,7 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
* factor of freq = 96 kHz can only be 256, since mclk is in the range
* of 8 MHz - 27 MHz
*/
switch (sgtl5000->sysclk / sys_fs) {
switch (sgtl5000->sysclk / frame_rate) {
case 256:
clk_ctl |= SGTL5000_MCLK_FREQ_256FS <<
SGTL5000_MCLK_FREQ_SHIFT;
@ -641,7 +641,7 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
"PLL not supported in slave mode\n");
dev_err(codec->dev, "%d ratio is not supported. "
"SYS_MCLK needs to be 256, 384 or 512 * fs\n",
sgtl5000->sysclk / sys_fs);
sgtl5000->sysclk / frame_rate);
return -EINVAL;
}
}