ASoC: mediatek: mt8188: complete set_tdm_slot function

User can configures slot number of TDM mode via set_tdm_slot callback.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com
Link: https://lore.kernel.org/r/20230510035526.18137-3-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org
This commit is contained in:
Trevor Wu 2023-05-10 11:55:19 +08:00 committed by Mark Brown
parent 4db399793c
commit 2664c8790c
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -1909,6 +1909,10 @@ static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream,
if (!is_valid_etdm_dai(mst_dai_id))
return -EINVAL;
mst_etdm_data = afe_priv->dai_priv[mst_dai_id];
if (mst_etdm_data->slots)
channels = mst_etdm_data->slots;
ret = mtk_dai_etdm_mclk_configure(afe, mst_dai_id);
if (ret)
return ret;
@ -1918,7 +1922,6 @@ static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream,
if (ret)
return ret;
mst_etdm_data = afe_priv->dai_priv[mst_dai_id];
for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) {
slv_dai_id = mst_etdm_data->cowork_slv_id[i];
ret = mtk_dai_etdm_configure(afe, rate, channels,
@ -1931,6 +1934,12 @@ static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream,
return ret;
}
} else {
if (!is_valid_etdm_dai(dai->id))
return -EINVAL;
mst_etdm_data = afe_priv->dai_priv[dai->id];
if (mst_etdm_data->slots)
channels = mst_etdm_data->slots;
ret = mtk_dai_etdm_mclk_configure(afe, dai->id);
if (ret)
return ret;
@ -2073,10 +2082,16 @@ static int mtk_dai_etdm_set_tdm_slot(struct snd_soc_dai *dai,
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mt8188_afe_private *afe_priv = afe->platform_priv;
struct mtk_dai_etdm_priv *etdm_data;
int dai_id;
if (!is_valid_etdm_dai(dai->id))
if (is_cowork_mode(dai))
dai_id = get_etdm_cowork_master_id(dai);
else
dai_id = dai->id;
if (!is_valid_etdm_dai(dai_id))
return -EINVAL;
etdm_data = afe_priv->dai_priv[dai->id];
etdm_data = afe_priv->dai_priv[dai_id];
dev_dbg(dai->dev, "%s id %d slot_width %d\n",
__func__, dai->id, slot_width);