From 6b93e2c23bb066814a3b68181b16364d7955ab11 Mon Sep 17 00:00:00 2001 From: Prasad Kumpatla Date: Mon, 26 Jul 2021 20:15:06 +0530 Subject: [PATCH] asoc: common: add support for tdm slots configuration add support for the tdm slots configuration from dt. Change-Id: I9fc9f81c4793c1b9eefe326af2db5259f35a2a4f Signed-off-by: Prasad Kumpatla --- asoc/msm_common.c | 20 +++++++++++++++++--- asoc/msm_common.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/asoc/msm_common.c b/asoc/msm_common.c index 515bc96e81..176e1eb523 100644 --- a/asoc/msm_common.c +++ b/asoc/msm_common.c @@ -45,7 +45,7 @@ struct snd_card_pdata { #define MAX_CODEC_DAI 8 #define TDM_SLOT_WIDTH_BITS 32 -#define TDM_MAX_SLOTS 4 +#define TDM_MAX_SLOTS 8 static struct attribute device_state_attr = { .name = "state", @@ -280,7 +280,7 @@ int msm_common_snd_hw_params(struct snd_pcm_substream *substream, { int ret = 0; int slot_width = TDM_SLOT_WIDTH_BITS; - int slots = TDM_MAX_SLOTS; + int slots; unsigned int rate; struct snd_soc_pcm_runtime *rtd = substream->private_data; const char *stream_name = rtd->dai_link->stream_name; @@ -293,6 +293,7 @@ int msm_common_snd_hw_params(struct snd_pcm_substream *substream, mutex_lock(&pdata->lock[index]); if (pdata->mi2s_gpio_p[index]) { if ((strnstr(stream_name, "TDM", strlen(stream_name)))) { + slots = pdata->tdm_max_slots; rate = params_rate(params); tdm_clk_cfg.clk_id = get_intf_clk_id(index); @@ -409,7 +410,7 @@ void msm_common_snd_shutdown(struct snd_pcm_substream *substream) int msm_common_snd_init(struct platform_device *pdev, struct snd_soc_card *card) { struct msm_common_pdata *common_pdata = NULL; - int count; + int count, ret = 0; common_pdata = kcalloc(1, sizeof(struct msm_common_pdata), GFP_KERNEL); if (!common_pdata) @@ -420,6 +421,19 @@ int msm_common_snd_init(struct platform_device *pdev, struct snd_soc_card *card) atomic_set(&common_pdata->mi2s_gpio_ref_cnt[count], 0); } + ret = of_property_read_u32(pdev->dev.of_node, "qcom,tdm-max-slots", + &common_pdata->tdm_max_slots); + if (ret) { + dev_info(&pdev->dev, "%s: No DT match for tdm max slots\n", + __func__); + } + if ((common_pdata->tdm_max_slots <= 0) || (common_pdata->tdm_max_slots > + TDM_MAX_SLOTS)) { + common_pdata->tdm_max_slots = TDM_MAX_SLOTS; + dev_info(&pdev->dev, "%s: Using default tdm max slot: %d\n", + __func__, common_pdata->tdm_max_slots); + } + common_pdata->mi2s_gpio_p[PRI_MI2S_TDM_AUXPCM] = of_parse_phandle(pdev->dev.of_node, "qcom,pri-mi2s-gpios", 0); common_pdata->mi2s_gpio_p[SEC_MI2S_TDM_AUXPCM] = of_parse_phandle(pdev->dev.of_node, diff --git a/asoc/msm_common.h b/asoc/msm_common.h index 0484c549ac..7a091f3c6d 100644 --- a/asoc/msm_common.h +++ b/asoc/msm_common.h @@ -38,6 +38,7 @@ struct msm_common_pdata { uint32_t num_aud_devs; struct device_node *mi2s_gpio_p[MI2S_TDM_AUXPCM_MAX]; struct mutex lock[MI2S_TDM_AUXPCM_MAX]; + u32 tdm_max_slots; /* Max TDM slots used */ atomic_t mi2s_gpio_ref_cnt[MI2S_TDM_AUXPCM_MAX]; };