MLK-17462-3: ASoC: imx-ak5558: support TDM mode

add fsl,tdm property, in tdm mode, the slot_width is fixed to
32 bit.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
This commit is contained in:
Shengjiu Wang 2018-01-26 13:52:33 +08:00 committed by Jason Liu
parent 55e8ac1bf4
commit bd63916ef6

View file

@ -25,6 +25,7 @@
struct imx_ak5558_data {
struct snd_soc_card card;
bool tdm_mode;
};
static struct snd_soc_dapm_widget imx_ak5558_dapm_widgets[] = {
@ -48,12 +49,17 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_card *card = rtd->card;
struct device *dev = card->dev;
struct imx_ak5558_data *data = snd_soc_card_get_drvdata(card);
unsigned int channels = params_channels(params);
unsigned int fmt;
int ret;
fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS;
if (data->tdm_mode)
fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS;
else
fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS;
ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
if (ret) {
@ -67,12 +73,30 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
return ret;
}
ret = snd_soc_dai_set_tdm_slot(cpu_dai,
if (data->tdm_mode) {
ret = snd_soc_dai_set_tdm_slot(cpu_dai,
BIT(channels) - 1, BIT(channels) - 1,
8, 32);
if (ret) {
dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
return ret;
}
ret = snd_soc_dai_set_tdm_slot(codec_dai,
BIT(channels) - 1, BIT(channels) - 1,
8, 32);
if (ret) {
dev_err(dev, "failed to set codec dai fmt: %d\n", ret);
return ret;
}
} else {
ret = snd_soc_dai_set_tdm_slot(cpu_dai,
BIT(channels) - 1, BIT(channels) - 1,
2, params_physical_width(params));
if (ret) {
dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
return ret;
if (ret) {
dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
return ret;
}
}
return ret;
@ -149,6 +173,9 @@ static int imx_ak5558_probe(struct platform_device *pdev)
goto fail;
}
if (of_find_property(pdev->dev.of_node, "fsl,tdm", NULL))
priv->tdm_mode = true;
imx_ak5558_dai.codec_of_node = codec_np;
imx_ak5558_dai.cpu_dai_name = dev_name(&cpu_pdev->dev);
imx_ak5558_dai.platform_of_node = cpu_np;