diff options
author | Maso Huang <maso.huang@mediatek.com> | 2023-10-24 06:50:19 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-10-24 15:26:49 +0300 |
commit | 0e20929434080aa87614fa0135c97bb9337ece27 (patch) | |
tree | b31270b52108cf7831e6f7ee222892341441fb0f /sound/soc/mediatek | |
parent | 0f10adb0ed0c0d74f8bc5facf2c70bc515210295 (diff) | |
download | linux-0e20929434080aa87614fa0135c97bb9337ece27.tar.xz |
ASoC: mediatek: mt7986: add sample rate checker
mt7986 only supports 8/12/16/24/32/48/96/192 kHz
Signed-off-by: Maso Huang <maso.huang@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20231024035019.11732-4-maso.huang@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/mediatek')
-rw-r--r-- | sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c index e523d33846fe..d57971413a04 100644 --- a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c +++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c @@ -237,12 +237,27 @@ static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { + unsigned int rate = params_rate(params); struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); - mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); - mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); - - return 0; + switch (rate) { + case 8000: + case 12000: + case 16000: + case 24000: + case 32000: + case 48000: + case 96000: + case 192000: + mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); + mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); + return 0; + default: + dev_err(afe->dev, + "Sample rate %d invalid. Supported rates: 8/12/16/24/32/48/96/192 kHz\n", + rate); + return -EINVAL; + } } static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd, |