xref: /openbmc/linux/sound/soc/qcom/qdsp6/q6afe-dai.c (revision e4222bbd)
124c4cbcfSSrinivas Kandagatla // SPDX-License-Identifier: GPL-2.0
224c4cbcfSSrinivas Kandagatla // Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
324c4cbcfSSrinivas Kandagatla // Copyright (c) 2018, Linaro Limited
424c4cbcfSSrinivas Kandagatla 
524c4cbcfSSrinivas Kandagatla #include <linux/err.h>
624c4cbcfSSrinivas Kandagatla #include <linux/init.h>
724c4cbcfSSrinivas Kandagatla #include <linux/module.h>
824c4cbcfSSrinivas Kandagatla #include <linux/device.h>
924c4cbcfSSrinivas Kandagatla #include <linux/platform_device.h>
1024c4cbcfSSrinivas Kandagatla #include <linux/slab.h>
1124c4cbcfSSrinivas Kandagatla #include <sound/pcm.h>
1224c4cbcfSSrinivas Kandagatla #include <sound/soc.h>
1324c4cbcfSSrinivas Kandagatla #include <sound/pcm_params.h>
1495b6cd57SSrinivas Kandagatla #include "q6dsp-lpass-ports.h"
154c2be53fSSrinivas Kandagatla #include "q6dsp-common.h"
1624c4cbcfSSrinivas Kandagatla #include "q6afe.h"
1724c4cbcfSSrinivas Kandagatla 
181fdbcfa9SSrinivas Kandagatla 
1924c4cbcfSSrinivas Kandagatla struct q6afe_dai_priv_data {
2024c4cbcfSSrinivas Kandagatla 	uint32_t sd_line_mask;
210e66cf5cSSrinivas Kandagatla 	uint32_t sync_mode;
220e66cf5cSSrinivas Kandagatla 	uint32_t sync_src;
230e66cf5cSSrinivas Kandagatla 	uint32_t data_out_enable;
240e66cf5cSSrinivas Kandagatla 	uint32_t invert_sync;
250e66cf5cSSrinivas Kandagatla 	uint32_t data_delay;
260e66cf5cSSrinivas Kandagatla 	uint32_t data_align;
2724c4cbcfSSrinivas Kandagatla };
2824c4cbcfSSrinivas Kandagatla 
2924c4cbcfSSrinivas Kandagatla struct q6afe_dai_data {
3024c4cbcfSSrinivas Kandagatla 	struct q6afe_port *port[AFE_PORT_MAX];
3124c4cbcfSSrinivas Kandagatla 	struct q6afe_port_config port_config[AFE_PORT_MAX];
3224c4cbcfSSrinivas Kandagatla 	bool is_port_started[AFE_PORT_MAX];
3324c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_priv_data priv[AFE_PORT_MAX];
3424c4cbcfSSrinivas Kandagatla };
3524c4cbcfSSrinivas Kandagatla 
q6slim_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_soc_dai * dai)3624c4cbcfSSrinivas Kandagatla static int q6slim_hw_params(struct snd_pcm_substream *substream,
3724c4cbcfSSrinivas Kandagatla 			    struct snd_pcm_hw_params *params,
3824c4cbcfSSrinivas Kandagatla 			    struct snd_soc_dai *dai)
3924c4cbcfSSrinivas Kandagatla {
4024c4cbcfSSrinivas Kandagatla 
4124c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
4224c4cbcfSSrinivas Kandagatla 	struct q6afe_slim_cfg *slim = &dai_data->port_config[dai->id].slim;
4324c4cbcfSSrinivas Kandagatla 
4424c4cbcfSSrinivas Kandagatla 	slim->sample_rate = params_rate(params);
4524c4cbcfSSrinivas Kandagatla 
4624c4cbcfSSrinivas Kandagatla 	switch (params_format(params)) {
4724c4cbcfSSrinivas Kandagatla 	case SNDRV_PCM_FORMAT_S16_LE:
4824c4cbcfSSrinivas Kandagatla 	case SNDRV_PCM_FORMAT_SPECIAL:
4924c4cbcfSSrinivas Kandagatla 		slim->bit_width = 16;
5024c4cbcfSSrinivas Kandagatla 		break;
5124c4cbcfSSrinivas Kandagatla 	case SNDRV_PCM_FORMAT_S24_LE:
5224c4cbcfSSrinivas Kandagatla 		slim->bit_width = 24;
5324c4cbcfSSrinivas Kandagatla 		break;
5424c4cbcfSSrinivas Kandagatla 	case SNDRV_PCM_FORMAT_S32_LE:
5524c4cbcfSSrinivas Kandagatla 		slim->bit_width = 32;
5624c4cbcfSSrinivas Kandagatla 		break;
5724c4cbcfSSrinivas Kandagatla 	default:
5824c4cbcfSSrinivas Kandagatla 		pr_err("%s: format %d\n",
5924c4cbcfSSrinivas Kandagatla 			__func__, params_format(params));
6024c4cbcfSSrinivas Kandagatla 		return -EINVAL;
6124c4cbcfSSrinivas Kandagatla 	}
6224c4cbcfSSrinivas Kandagatla 
6324c4cbcfSSrinivas Kandagatla 	return 0;
6424c4cbcfSSrinivas Kandagatla }
6524c4cbcfSSrinivas Kandagatla 
q6hdmi_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_soc_dai * dai)6624c4cbcfSSrinivas Kandagatla static int q6hdmi_hw_params(struct snd_pcm_substream *substream,
6724c4cbcfSSrinivas Kandagatla 				struct snd_pcm_hw_params *params,
6824c4cbcfSSrinivas Kandagatla 				struct snd_soc_dai *dai)
6924c4cbcfSSrinivas Kandagatla {
7024c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
7124c4cbcfSSrinivas Kandagatla 	int channels = params_channels(params);
7224c4cbcfSSrinivas Kandagatla 	struct q6afe_hdmi_cfg *hdmi = &dai_data->port_config[dai->id].hdmi;
734c2be53fSSrinivas Kandagatla 	int ret;
7424c4cbcfSSrinivas Kandagatla 
7524c4cbcfSSrinivas Kandagatla 	hdmi->sample_rate = params_rate(params);
7624c4cbcfSSrinivas Kandagatla 	switch (params_format(params)) {
7724c4cbcfSSrinivas Kandagatla 	case SNDRV_PCM_FORMAT_S16_LE:
7824c4cbcfSSrinivas Kandagatla 		hdmi->bit_width = 16;
7924c4cbcfSSrinivas Kandagatla 		break;
8024c4cbcfSSrinivas Kandagatla 	case SNDRV_PCM_FORMAT_S24_LE:
8124c4cbcfSSrinivas Kandagatla 		hdmi->bit_width = 24;
8224c4cbcfSSrinivas Kandagatla 		break;
8324c4cbcfSSrinivas Kandagatla 	}
8424c4cbcfSSrinivas Kandagatla 
854c2be53fSSrinivas Kandagatla 	ret = q6dsp_get_channel_allocation(channels);
864c2be53fSSrinivas Kandagatla 	if (ret < 0)
874c2be53fSSrinivas Kandagatla 		return ret;
884c2be53fSSrinivas Kandagatla 
894c2be53fSSrinivas Kandagatla 	hdmi->channel_allocation = (u16) ret;
9024c4cbcfSSrinivas Kandagatla 
9124c4cbcfSSrinivas Kandagatla 	return 0;
9224c4cbcfSSrinivas Kandagatla }
9324c4cbcfSSrinivas Kandagatla 
q6i2s_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_soc_dai * dai)9424c4cbcfSSrinivas Kandagatla static int q6i2s_hw_params(struct snd_pcm_substream *substream,
9524c4cbcfSSrinivas Kandagatla 			   struct snd_pcm_hw_params *params,
9624c4cbcfSSrinivas Kandagatla 			   struct snd_soc_dai *dai)
9724c4cbcfSSrinivas Kandagatla {
9824c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
9924c4cbcfSSrinivas Kandagatla 	struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg;
10024c4cbcfSSrinivas Kandagatla 
10124c4cbcfSSrinivas Kandagatla 	i2s->sample_rate = params_rate(params);
10224c4cbcfSSrinivas Kandagatla 	i2s->bit_width = params_width(params);
10324c4cbcfSSrinivas Kandagatla 	i2s->num_channels = params_channels(params);
10424c4cbcfSSrinivas Kandagatla 	i2s->sd_line_mask = dai_data->priv[dai->id].sd_line_mask;
10524c4cbcfSSrinivas Kandagatla 
10624c4cbcfSSrinivas Kandagatla 	return 0;
10724c4cbcfSSrinivas Kandagatla }
10824c4cbcfSSrinivas Kandagatla 
q6i2s_set_fmt(struct snd_soc_dai * dai,unsigned int fmt)10924c4cbcfSSrinivas Kandagatla static int q6i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
11024c4cbcfSSrinivas Kandagatla {
11124c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
11224c4cbcfSSrinivas Kandagatla 	struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg;
11324c4cbcfSSrinivas Kandagatla 
11424c4cbcfSSrinivas Kandagatla 	i2s->fmt = fmt;
11524c4cbcfSSrinivas Kandagatla 
11624c4cbcfSSrinivas Kandagatla 	return 0;
11724c4cbcfSSrinivas Kandagatla }
11824c4cbcfSSrinivas Kandagatla 
q6tdm_set_tdm_slot(struct snd_soc_dai * dai,unsigned int tx_mask,unsigned int rx_mask,int slots,int slot_width)1190e66cf5cSSrinivas Kandagatla static int q6tdm_set_tdm_slot(struct snd_soc_dai *dai,
1200e66cf5cSSrinivas Kandagatla 				unsigned int tx_mask,
1210e66cf5cSSrinivas Kandagatla 				unsigned int rx_mask,
1220e66cf5cSSrinivas Kandagatla 				int slots, int slot_width)
1230e66cf5cSSrinivas Kandagatla {
1240e66cf5cSSrinivas Kandagatla 
1250e66cf5cSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
1260e66cf5cSSrinivas Kandagatla 	struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm;
1270e66cf5cSSrinivas Kandagatla 	unsigned int cap_mask;
1280e66cf5cSSrinivas Kandagatla 	int rc = 0;
1290e66cf5cSSrinivas Kandagatla 
1300e66cf5cSSrinivas Kandagatla 	/* HW only supports 16 and 32 bit slot width configuration */
1310e66cf5cSSrinivas Kandagatla 	if ((slot_width != 16) && (slot_width != 32)) {
1320e66cf5cSSrinivas Kandagatla 		dev_err(dai->dev, "%s: invalid slot_width %d\n",
1330e66cf5cSSrinivas Kandagatla 			__func__, slot_width);
1340e66cf5cSSrinivas Kandagatla 		return -EINVAL;
1350e66cf5cSSrinivas Kandagatla 	}
1360e66cf5cSSrinivas Kandagatla 
1370e66cf5cSSrinivas Kandagatla 	/* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
1380e66cf5cSSrinivas Kandagatla 	switch (slots) {
1390e66cf5cSSrinivas Kandagatla 	case 2:
1400e66cf5cSSrinivas Kandagatla 		cap_mask = 0x03;
1410e66cf5cSSrinivas Kandagatla 		break;
1420e66cf5cSSrinivas Kandagatla 	case 4:
1430e66cf5cSSrinivas Kandagatla 		cap_mask = 0x0F;
1440e66cf5cSSrinivas Kandagatla 		break;
1450e66cf5cSSrinivas Kandagatla 	case 8:
1460e66cf5cSSrinivas Kandagatla 		cap_mask = 0xFF;
1470e66cf5cSSrinivas Kandagatla 		break;
1480e66cf5cSSrinivas Kandagatla 	case 16:
1490e66cf5cSSrinivas Kandagatla 		cap_mask = 0xFFFF;
1500e66cf5cSSrinivas Kandagatla 		break;
1510e66cf5cSSrinivas Kandagatla 	default:
1520e66cf5cSSrinivas Kandagatla 		dev_err(dai->dev, "%s: invalid slots %d\n",
1530e66cf5cSSrinivas Kandagatla 			__func__, slots);
1540e66cf5cSSrinivas Kandagatla 		return -EINVAL;
1550e66cf5cSSrinivas Kandagatla 	}
1560e66cf5cSSrinivas Kandagatla 
1570e66cf5cSSrinivas Kandagatla 	switch (dai->id) {
1580e66cf5cSSrinivas Kandagatla 	case PRIMARY_TDM_RX_0 ... QUINARY_TDM_TX_7:
1590e66cf5cSSrinivas Kandagatla 		tdm->nslots_per_frame = slots;
1600e66cf5cSSrinivas Kandagatla 		tdm->slot_width = slot_width;
1610e66cf5cSSrinivas Kandagatla 		/* TDM RX dais ids are even and tx are odd */
16218bcac6eSPierre-Louis Bossart 		tdm->slot_mask = ((dai->id & 0x1) ? tx_mask : rx_mask) & cap_mask;
1630e66cf5cSSrinivas Kandagatla 		break;
1640e66cf5cSSrinivas Kandagatla 	default:
1650e66cf5cSSrinivas Kandagatla 		dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
1660e66cf5cSSrinivas Kandagatla 			__func__, dai->id);
1670e66cf5cSSrinivas Kandagatla 		return -EINVAL;
1680e66cf5cSSrinivas Kandagatla 	}
1690e66cf5cSSrinivas Kandagatla 
1700e66cf5cSSrinivas Kandagatla 	return rc;
1710e66cf5cSSrinivas Kandagatla }
1720e66cf5cSSrinivas Kandagatla 
q6tdm_set_channel_map(struct snd_soc_dai * dai,unsigned int tx_num,unsigned int * tx_slot,unsigned int rx_num,unsigned int * rx_slot)1730e66cf5cSSrinivas Kandagatla static int q6tdm_set_channel_map(struct snd_soc_dai *dai,
1740e66cf5cSSrinivas Kandagatla 				unsigned int tx_num, unsigned int *tx_slot,
1750e66cf5cSSrinivas Kandagatla 				unsigned int rx_num, unsigned int *rx_slot)
1760e66cf5cSSrinivas Kandagatla {
1770e66cf5cSSrinivas Kandagatla 
1780e66cf5cSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
1790e66cf5cSSrinivas Kandagatla 	struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm;
1800e66cf5cSSrinivas Kandagatla 	int rc = 0;
1810e66cf5cSSrinivas Kandagatla 	int i = 0;
1820e66cf5cSSrinivas Kandagatla 
1830e66cf5cSSrinivas Kandagatla 	switch (dai->id) {
1840e66cf5cSSrinivas Kandagatla 	case PRIMARY_TDM_RX_0 ... QUINARY_TDM_TX_7:
1850e66cf5cSSrinivas Kandagatla 		if (dai->id & 0x1) {
1860e66cf5cSSrinivas Kandagatla 			if (!tx_slot) {
1870e66cf5cSSrinivas Kandagatla 				dev_err(dai->dev, "tx slot not found\n");
1880e66cf5cSSrinivas Kandagatla 				return -EINVAL;
1890e66cf5cSSrinivas Kandagatla 			}
1900e66cf5cSSrinivas Kandagatla 			if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
1910e66cf5cSSrinivas Kandagatla 				dev_err(dai->dev, "invalid tx num %d\n",
1920e66cf5cSSrinivas Kandagatla 					tx_num);
1930e66cf5cSSrinivas Kandagatla 				return -EINVAL;
1940e66cf5cSSrinivas Kandagatla 			}
1950e66cf5cSSrinivas Kandagatla 
1960e66cf5cSSrinivas Kandagatla 			for (i = 0; i < tx_num; i++)
1970e66cf5cSSrinivas Kandagatla 				tdm->ch_mapping[i] = tx_slot[i];
1980e66cf5cSSrinivas Kandagatla 
1990e66cf5cSSrinivas Kandagatla 			for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
2000e66cf5cSSrinivas Kandagatla 				tdm->ch_mapping[i] = Q6AFE_CMAP_INVALID;
2010e66cf5cSSrinivas Kandagatla 
2020e66cf5cSSrinivas Kandagatla 			tdm->num_channels = tx_num;
2030e66cf5cSSrinivas Kandagatla 		} else {
2040e66cf5cSSrinivas Kandagatla 			/* rx */
2050e66cf5cSSrinivas Kandagatla 			if (!rx_slot) {
2060e66cf5cSSrinivas Kandagatla 				dev_err(dai->dev, "rx slot not found\n");
2070e66cf5cSSrinivas Kandagatla 				return -EINVAL;
2080e66cf5cSSrinivas Kandagatla 			}
2090e66cf5cSSrinivas Kandagatla 			if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
2100e66cf5cSSrinivas Kandagatla 				dev_err(dai->dev, "invalid rx num %d\n",
2110e66cf5cSSrinivas Kandagatla 					rx_num);
2120e66cf5cSSrinivas Kandagatla 				return -EINVAL;
2130e66cf5cSSrinivas Kandagatla 			}
2140e66cf5cSSrinivas Kandagatla 
2150e66cf5cSSrinivas Kandagatla 			for (i = 0; i < rx_num; i++)
2160e66cf5cSSrinivas Kandagatla 				tdm->ch_mapping[i] = rx_slot[i];
2170e66cf5cSSrinivas Kandagatla 
2180e66cf5cSSrinivas Kandagatla 			for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
2190e66cf5cSSrinivas Kandagatla 				tdm->ch_mapping[i] = Q6AFE_CMAP_INVALID;
2200e66cf5cSSrinivas Kandagatla 
2210e66cf5cSSrinivas Kandagatla 			tdm->num_channels = rx_num;
2220e66cf5cSSrinivas Kandagatla 		}
2230e66cf5cSSrinivas Kandagatla 
2240e66cf5cSSrinivas Kandagatla 		break;
2250e66cf5cSSrinivas Kandagatla 	default:
2260e66cf5cSSrinivas Kandagatla 		dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
2270e66cf5cSSrinivas Kandagatla 			__func__, dai->id);
2280e66cf5cSSrinivas Kandagatla 		return -EINVAL;
2290e66cf5cSSrinivas Kandagatla 	}
2300e66cf5cSSrinivas Kandagatla 
2310e66cf5cSSrinivas Kandagatla 	return rc;
2320e66cf5cSSrinivas Kandagatla }
2330e66cf5cSSrinivas Kandagatla 
q6tdm_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_soc_dai * dai)2340e66cf5cSSrinivas Kandagatla static int q6tdm_hw_params(struct snd_pcm_substream *substream,
2350e66cf5cSSrinivas Kandagatla 			   struct snd_pcm_hw_params *params,
2360e66cf5cSSrinivas Kandagatla 			   struct snd_soc_dai *dai)
2370e66cf5cSSrinivas Kandagatla {
2380e66cf5cSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
2390e66cf5cSSrinivas Kandagatla 	struct q6afe_tdm_cfg *tdm = &dai_data->port_config[dai->id].tdm;
2400e66cf5cSSrinivas Kandagatla 
2410e66cf5cSSrinivas Kandagatla 	tdm->bit_width = params_width(params);
2420e66cf5cSSrinivas Kandagatla 	tdm->sample_rate = params_rate(params);
2430e66cf5cSSrinivas Kandagatla 	tdm->num_channels = params_channels(params);
2440e66cf5cSSrinivas Kandagatla 	tdm->data_align_type = dai_data->priv[dai->id].data_align;
2450e66cf5cSSrinivas Kandagatla 	tdm->sync_src = dai_data->priv[dai->id].sync_src;
2460e66cf5cSSrinivas Kandagatla 	tdm->sync_mode = dai_data->priv[dai->id].sync_mode;
2470e66cf5cSSrinivas Kandagatla 
2480e66cf5cSSrinivas Kandagatla 	return 0;
2490e66cf5cSSrinivas Kandagatla }
2501fdbcfa9SSrinivas Kandagatla 
q6dma_set_channel_map(struct snd_soc_dai * dai,unsigned int tx_num,unsigned int * tx_ch_mask,unsigned int rx_num,unsigned int * rx_ch_mask)2511fdbcfa9SSrinivas Kandagatla static int q6dma_set_channel_map(struct snd_soc_dai *dai,
2521fdbcfa9SSrinivas Kandagatla 				 unsigned int tx_num, unsigned int *tx_ch_mask,
2531fdbcfa9SSrinivas Kandagatla 				 unsigned int rx_num, unsigned int *rx_ch_mask)
2541fdbcfa9SSrinivas Kandagatla {
2551fdbcfa9SSrinivas Kandagatla 
2561fdbcfa9SSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
2571fdbcfa9SSrinivas Kandagatla 	struct q6afe_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg;
2581fdbcfa9SSrinivas Kandagatla 	int ch_mask;
2591fdbcfa9SSrinivas Kandagatla 	int rc = 0;
2601fdbcfa9SSrinivas Kandagatla 
2611fdbcfa9SSrinivas Kandagatla 	switch (dai->id) {
2621fdbcfa9SSrinivas Kandagatla 	case WSA_CODEC_DMA_TX_0:
2631fdbcfa9SSrinivas Kandagatla 	case WSA_CODEC_DMA_TX_1:
2641fdbcfa9SSrinivas Kandagatla 	case WSA_CODEC_DMA_TX_2:
2651fdbcfa9SSrinivas Kandagatla 	case VA_CODEC_DMA_TX_0:
2661fdbcfa9SSrinivas Kandagatla 	case VA_CODEC_DMA_TX_1:
2671fdbcfa9SSrinivas Kandagatla 	case VA_CODEC_DMA_TX_2:
2681fdbcfa9SSrinivas Kandagatla 	case TX_CODEC_DMA_TX_0:
2691fdbcfa9SSrinivas Kandagatla 	case TX_CODEC_DMA_TX_1:
2701fdbcfa9SSrinivas Kandagatla 	case TX_CODEC_DMA_TX_2:
2711fdbcfa9SSrinivas Kandagatla 	case TX_CODEC_DMA_TX_3:
2721fdbcfa9SSrinivas Kandagatla 	case TX_CODEC_DMA_TX_4:
2731fdbcfa9SSrinivas Kandagatla 	case TX_CODEC_DMA_TX_5:
2741fdbcfa9SSrinivas Kandagatla 		if (!tx_ch_mask) {
2751fdbcfa9SSrinivas Kandagatla 			dev_err(dai->dev, "tx slot not found\n");
2761fdbcfa9SSrinivas Kandagatla 			return -EINVAL;
2771fdbcfa9SSrinivas Kandagatla 		}
2781fdbcfa9SSrinivas Kandagatla 
2791fdbcfa9SSrinivas Kandagatla 		if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
2801fdbcfa9SSrinivas Kandagatla 			dev_err(dai->dev, "invalid tx num %d\n",
2811fdbcfa9SSrinivas Kandagatla 				tx_num);
2821fdbcfa9SSrinivas Kandagatla 			return -EINVAL;
2831fdbcfa9SSrinivas Kandagatla 		}
2841fdbcfa9SSrinivas Kandagatla 		ch_mask = *tx_ch_mask;
2851fdbcfa9SSrinivas Kandagatla 
2861fdbcfa9SSrinivas Kandagatla 		break;
2871fdbcfa9SSrinivas Kandagatla 	case WSA_CODEC_DMA_RX_0:
2881fdbcfa9SSrinivas Kandagatla 	case WSA_CODEC_DMA_RX_1:
2891fdbcfa9SSrinivas Kandagatla 	case RX_CODEC_DMA_RX_0:
2901fdbcfa9SSrinivas Kandagatla 	case RX_CODEC_DMA_RX_1:
2911fdbcfa9SSrinivas Kandagatla 	case RX_CODEC_DMA_RX_2:
2921fdbcfa9SSrinivas Kandagatla 	case RX_CODEC_DMA_RX_3:
2931fdbcfa9SSrinivas Kandagatla 	case RX_CODEC_DMA_RX_4:
2941fdbcfa9SSrinivas Kandagatla 	case RX_CODEC_DMA_RX_5:
2951fdbcfa9SSrinivas Kandagatla 	case RX_CODEC_DMA_RX_6:
2961fdbcfa9SSrinivas Kandagatla 	case RX_CODEC_DMA_RX_7:
2971fdbcfa9SSrinivas Kandagatla 		/* rx */
2981fdbcfa9SSrinivas Kandagatla 		if (!rx_ch_mask) {
2991fdbcfa9SSrinivas Kandagatla 			dev_err(dai->dev, "rx slot not found\n");
3001fdbcfa9SSrinivas Kandagatla 			return -EINVAL;
3011fdbcfa9SSrinivas Kandagatla 		}
3021fdbcfa9SSrinivas Kandagatla 		if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
3031fdbcfa9SSrinivas Kandagatla 			dev_err(dai->dev, "invalid rx num %d\n",
3041fdbcfa9SSrinivas Kandagatla 				rx_num);
3051fdbcfa9SSrinivas Kandagatla 			return -EINVAL;
3061fdbcfa9SSrinivas Kandagatla 		}
3071fdbcfa9SSrinivas Kandagatla 		ch_mask = *rx_ch_mask;
3081fdbcfa9SSrinivas Kandagatla 
3091fdbcfa9SSrinivas Kandagatla 		break;
3101fdbcfa9SSrinivas Kandagatla 	default:
3111fdbcfa9SSrinivas Kandagatla 		dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
3121fdbcfa9SSrinivas Kandagatla 			__func__, dai->id);
3131fdbcfa9SSrinivas Kandagatla 		return -EINVAL;
3141fdbcfa9SSrinivas Kandagatla 	}
3151fdbcfa9SSrinivas Kandagatla 
3161fdbcfa9SSrinivas Kandagatla 	cfg->active_channels_mask = ch_mask;
3171fdbcfa9SSrinivas Kandagatla 
3181fdbcfa9SSrinivas Kandagatla 	return rc;
3191fdbcfa9SSrinivas Kandagatla }
3201fdbcfa9SSrinivas Kandagatla 
q6dma_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params,struct snd_soc_dai * dai)3211fdbcfa9SSrinivas Kandagatla static int q6dma_hw_params(struct snd_pcm_substream *substream,
3221fdbcfa9SSrinivas Kandagatla 			   struct snd_pcm_hw_params *params,
3231fdbcfa9SSrinivas Kandagatla 			   struct snd_soc_dai *dai)
3241fdbcfa9SSrinivas Kandagatla {
3251fdbcfa9SSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
3261fdbcfa9SSrinivas Kandagatla 	struct q6afe_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg;
3271fdbcfa9SSrinivas Kandagatla 
3281fdbcfa9SSrinivas Kandagatla 	cfg->bit_width = params_width(params);
3291fdbcfa9SSrinivas Kandagatla 	cfg->sample_rate = params_rate(params);
3301fdbcfa9SSrinivas Kandagatla 	cfg->num_channels = params_channels(params);
3311fdbcfa9SSrinivas Kandagatla 
3321fdbcfa9SSrinivas Kandagatla 	return 0;
3331fdbcfa9SSrinivas Kandagatla }
q6afe_dai_shutdown(struct snd_pcm_substream * substream,struct snd_soc_dai * dai)33424c4cbcfSSrinivas Kandagatla static void q6afe_dai_shutdown(struct snd_pcm_substream *substream,
33524c4cbcfSSrinivas Kandagatla 				struct snd_soc_dai *dai)
33624c4cbcfSSrinivas Kandagatla {
33724c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
33824c4cbcfSSrinivas Kandagatla 	int rc;
33924c4cbcfSSrinivas Kandagatla 
34011074318SSrinivas Kandagatla 	if (!dai_data->is_port_started[dai->id])
34111074318SSrinivas Kandagatla 		return;
34211074318SSrinivas Kandagatla 
34324c4cbcfSSrinivas Kandagatla 	rc = q6afe_port_stop(dai_data->port[dai->id]);
34424c4cbcfSSrinivas Kandagatla 	if (rc < 0)
34524c4cbcfSSrinivas Kandagatla 		dev_err(dai->dev, "fail to close AFE port (%d)\n", rc);
34624c4cbcfSSrinivas Kandagatla 
34724c4cbcfSSrinivas Kandagatla 	dai_data->is_port_started[dai->id] = false;
34824c4cbcfSSrinivas Kandagatla 
34924c4cbcfSSrinivas Kandagatla }
35024c4cbcfSSrinivas Kandagatla 
q6afe_dai_prepare(struct snd_pcm_substream * substream,struct snd_soc_dai * dai)35124c4cbcfSSrinivas Kandagatla static int q6afe_dai_prepare(struct snd_pcm_substream *substream,
35224c4cbcfSSrinivas Kandagatla 		struct snd_soc_dai *dai)
35324c4cbcfSSrinivas Kandagatla {
35424c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
35524c4cbcfSSrinivas Kandagatla 	int rc;
35624c4cbcfSSrinivas Kandagatla 
35724c4cbcfSSrinivas Kandagatla 	if (dai_data->is_port_started[dai->id]) {
35824c4cbcfSSrinivas Kandagatla 		/* stop the port and restart with new port config */
35924c4cbcfSSrinivas Kandagatla 		rc = q6afe_port_stop(dai_data->port[dai->id]);
36024c4cbcfSSrinivas Kandagatla 		if (rc < 0) {
36124c4cbcfSSrinivas Kandagatla 			dev_err(dai->dev, "fail to close AFE port (%d)\n", rc);
36224c4cbcfSSrinivas Kandagatla 			return rc;
36324c4cbcfSSrinivas Kandagatla 		}
36424c4cbcfSSrinivas Kandagatla 	}
36524c4cbcfSSrinivas Kandagatla 
366b916449cSSrinivas Kandagatla 	switch (dai->id) {
367b916449cSSrinivas Kandagatla 	case HDMI_RX:
36832d2c61bSRohit kumar 	case DISPLAY_PORT_RX:
36924c4cbcfSSrinivas Kandagatla 		q6afe_hdmi_port_prepare(dai_data->port[dai->id],
37024c4cbcfSSrinivas Kandagatla 					&dai_data->port_config[dai->id].hdmi);
371b916449cSSrinivas Kandagatla 		break;
372b916449cSSrinivas Kandagatla 	case SLIMBUS_0_RX ... SLIMBUS_6_TX:
37324c4cbcfSSrinivas Kandagatla 		q6afe_slim_port_prepare(dai_data->port[dai->id],
37424c4cbcfSSrinivas Kandagatla 					&dai_data->port_config[dai->id].slim);
375b916449cSSrinivas Kandagatla 		break;
37698e80779SGabriel David 	case QUINARY_MI2S_RX ... QUINARY_MI2S_TX:
377b916449cSSrinivas Kandagatla 	case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX:
378b916449cSSrinivas Kandagatla 		rc = q6afe_i2s_port_prepare(dai_data->port[dai->id],
379b916449cSSrinivas Kandagatla 			       &dai_data->port_config[dai->id].i2s_cfg);
380b916449cSSrinivas Kandagatla 		if (rc < 0) {
381b916449cSSrinivas Kandagatla 			dev_err(dai->dev, "fail to prepare AFE port %x\n",
382b916449cSSrinivas Kandagatla 				dai->id);
383b916449cSSrinivas Kandagatla 			return rc;
384b916449cSSrinivas Kandagatla 		}
385b916449cSSrinivas Kandagatla 		break;
3860e66cf5cSSrinivas Kandagatla 	case PRIMARY_TDM_RX_0 ... QUINARY_TDM_TX_7:
3870e66cf5cSSrinivas Kandagatla 		q6afe_tdm_port_prepare(dai_data->port[dai->id],
3880e66cf5cSSrinivas Kandagatla 					&dai_data->port_config[dai->id].tdm);
3890e66cf5cSSrinivas Kandagatla 		break;
3901fdbcfa9SSrinivas Kandagatla 	case WSA_CODEC_DMA_RX_0 ... RX_CODEC_DMA_RX_7:
3911fdbcfa9SSrinivas Kandagatla 		q6afe_cdc_dma_port_prepare(dai_data->port[dai->id],
3921fdbcfa9SSrinivas Kandagatla 					   &dai_data->port_config[dai->id].dma_cfg);
3931fdbcfa9SSrinivas Kandagatla 		break;
394b916449cSSrinivas Kandagatla 	default:
395b916449cSSrinivas Kandagatla 		return -EINVAL;
396b916449cSSrinivas Kandagatla 	}
39724c4cbcfSSrinivas Kandagatla 
39824c4cbcfSSrinivas Kandagatla 	rc = q6afe_port_start(dai_data->port[dai->id]);
39924c4cbcfSSrinivas Kandagatla 	if (rc < 0) {
40024c4cbcfSSrinivas Kandagatla 		dev_err(dai->dev, "fail to start AFE port %x\n", dai->id);
40124c4cbcfSSrinivas Kandagatla 		return rc;
40224c4cbcfSSrinivas Kandagatla 	}
40324c4cbcfSSrinivas Kandagatla 	dai_data->is_port_started[dai->id] = true;
40424c4cbcfSSrinivas Kandagatla 
40524c4cbcfSSrinivas Kandagatla 	return 0;
40624c4cbcfSSrinivas Kandagatla }
40724c4cbcfSSrinivas Kandagatla 
q6slim_set_channel_map(struct snd_soc_dai * dai,unsigned int tx_num,unsigned int * tx_slot,unsigned int rx_num,unsigned int * rx_slot)40824c4cbcfSSrinivas Kandagatla static int q6slim_set_channel_map(struct snd_soc_dai *dai,
40924c4cbcfSSrinivas Kandagatla 				unsigned int tx_num, unsigned int *tx_slot,
41024c4cbcfSSrinivas Kandagatla 				unsigned int rx_num, unsigned int *rx_slot)
41124c4cbcfSSrinivas Kandagatla {
41224c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
41324c4cbcfSSrinivas Kandagatla 	struct q6afe_port_config *pcfg = &dai_data->port_config[dai->id];
41424c4cbcfSSrinivas Kandagatla 	int i;
41524c4cbcfSSrinivas Kandagatla 
416f03d6b1bSSrinivas Kandagatla 	if (dai->id & 0x1) {
417f03d6b1bSSrinivas Kandagatla 		/* TX */
418f03d6b1bSSrinivas Kandagatla 		if (!tx_slot) {
419f03d6b1bSSrinivas Kandagatla 			pr_err("%s: tx slot not found\n", __func__);
420f03d6b1bSSrinivas Kandagatla 			return -EINVAL;
421f03d6b1bSSrinivas Kandagatla 		}
422f03d6b1bSSrinivas Kandagatla 
423f03d6b1bSSrinivas Kandagatla 		for (i = 0; i < tx_num; i++)
424f03d6b1bSSrinivas Kandagatla 			pcfg->slim.ch_mapping[i] = tx_slot[i];
425f03d6b1bSSrinivas Kandagatla 
426f03d6b1bSSrinivas Kandagatla 		pcfg->slim.num_channels = tx_num;
427f03d6b1bSSrinivas Kandagatla 
428f03d6b1bSSrinivas Kandagatla 
429f03d6b1bSSrinivas Kandagatla 	} else {
43024c4cbcfSSrinivas Kandagatla 		if (!rx_slot) {
43124c4cbcfSSrinivas Kandagatla 			pr_err("%s: rx slot not found\n", __func__);
43224c4cbcfSSrinivas Kandagatla 			return -EINVAL;
43324c4cbcfSSrinivas Kandagatla 		}
43424c4cbcfSSrinivas Kandagatla 
435f03d6b1bSSrinivas Kandagatla 		for (i = 0; i < rx_num; i++)
43624c4cbcfSSrinivas Kandagatla 			pcfg->slim.ch_mapping[i] =   rx_slot[i];
43724c4cbcfSSrinivas Kandagatla 
43824c4cbcfSSrinivas Kandagatla 		pcfg->slim.num_channels = rx_num;
43924c4cbcfSSrinivas Kandagatla 
440f03d6b1bSSrinivas Kandagatla 	}
44124c4cbcfSSrinivas Kandagatla 
44224c4cbcfSSrinivas Kandagatla 	return 0;
44324c4cbcfSSrinivas Kandagatla }
44424c4cbcfSSrinivas Kandagatla 
q6afe_mi2s_set_sysclk(struct snd_soc_dai * dai,int clk_id,unsigned int freq,int dir)44524c4cbcfSSrinivas Kandagatla static int q6afe_mi2s_set_sysclk(struct snd_soc_dai *dai,
44624c4cbcfSSrinivas Kandagatla 		int clk_id, unsigned int freq, int dir)
44724c4cbcfSSrinivas Kandagatla {
44824c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
44924c4cbcfSSrinivas Kandagatla 	struct q6afe_port *port = dai_data->port[dai->id];
45024c4cbcfSSrinivas Kandagatla 
45124c4cbcfSSrinivas Kandagatla 	switch (clk_id) {
45224c4cbcfSSrinivas Kandagatla 	case LPAIF_DIG_CLK:
45324c4cbcfSSrinivas Kandagatla 		return q6afe_port_set_sysclk(port, clk_id, 0, 5, freq, dir);
45424c4cbcfSSrinivas Kandagatla 	case LPAIF_BIT_CLK:
45524c4cbcfSSrinivas Kandagatla 	case LPAIF_OSR_CLK:
45624c4cbcfSSrinivas Kandagatla 		return q6afe_port_set_sysclk(port, clk_id,
45724c4cbcfSSrinivas Kandagatla 					     Q6AFE_LPASS_CLK_SRC_INTERNAL,
45824c4cbcfSSrinivas Kandagatla 					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
45924c4cbcfSSrinivas Kandagatla 					     freq, dir);
4600e66cf5cSSrinivas Kandagatla 	case Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT ... Q6AFE_LPASS_CLK_ID_QUI_MI2S_OSR:
4610e66cf5cSSrinivas Kandagatla 	case Q6AFE_LPASS_CLK_ID_MCLK_1 ... Q6AFE_LPASS_CLK_ID_INT_MCLK_1:
4621fdbcfa9SSrinivas Kandagatla 	case Q6AFE_LPASS_CLK_ID_WSA_CORE_MCLK ... Q6AFE_LPASS_CLK_ID_VA_CORE_2X_MCLK:
46324c4cbcfSSrinivas Kandagatla 		return q6afe_port_set_sysclk(port, clk_id,
46424c4cbcfSSrinivas Kandagatla 					     Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
46524c4cbcfSSrinivas Kandagatla 					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
46624c4cbcfSSrinivas Kandagatla 					     freq, dir);
4670e66cf5cSSrinivas Kandagatla 	case Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT ... Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT:
4680e66cf5cSSrinivas Kandagatla 		return q6afe_port_set_sysclk(port, clk_id,
4690e66cf5cSSrinivas Kandagatla 					     Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
4700e66cf5cSSrinivas Kandagatla 					     Q6AFE_LPASS_CLK_ROOT_DEFAULT,
4710e66cf5cSSrinivas Kandagatla 					     freq, dir);
47224c4cbcfSSrinivas Kandagatla 	}
47324c4cbcfSSrinivas Kandagatla 
47424c4cbcfSSrinivas Kandagatla 	return 0;
47524c4cbcfSSrinivas Kandagatla }
47624c4cbcfSSrinivas Kandagatla 
47724c4cbcfSSrinivas Kandagatla static const struct snd_soc_dapm_route q6afe_dapm_routes[] = {
47824c4cbcfSSrinivas Kandagatla 	{"HDMI Playback", NULL, "HDMI_RX"},
4794f3fcf5fSSrinivas Kandagatla 	{"DISPLAY_PORT_RX_0 Playback", NULL, "DISPLAY_PORT_RX"},
4809aa0cf79SSrinivas Kandagatla 	{"Slimbus Playback", NULL, "SLIMBUS_0_RX"},
48124c4cbcfSSrinivas Kandagatla 	{"Slimbus1 Playback", NULL, "SLIMBUS_1_RX"},
48224c4cbcfSSrinivas Kandagatla 	{"Slimbus2 Playback", NULL, "SLIMBUS_2_RX"},
48324c4cbcfSSrinivas Kandagatla 	{"Slimbus3 Playback", NULL, "SLIMBUS_3_RX"},
48424c4cbcfSSrinivas Kandagatla 	{"Slimbus4 Playback", NULL, "SLIMBUS_4_RX"},
48524c4cbcfSSrinivas Kandagatla 	{"Slimbus5 Playback", NULL, "SLIMBUS_5_RX"},
48624c4cbcfSSrinivas Kandagatla 	{"Slimbus6 Playback", NULL, "SLIMBUS_6_RX"},
48724c4cbcfSSrinivas Kandagatla 
488f03d6b1bSSrinivas Kandagatla 	{"SLIMBUS_0_TX", NULL, "Slimbus Capture"},
489f03d6b1bSSrinivas Kandagatla 	{"SLIMBUS_1_TX", NULL, "Slimbus1 Capture"},
490f03d6b1bSSrinivas Kandagatla 	{"SLIMBUS_2_TX", NULL, "Slimbus2 Capture"},
491f03d6b1bSSrinivas Kandagatla 	{"SLIMBUS_3_TX", NULL, "Slimbus3 Capture"},
492f03d6b1bSSrinivas Kandagatla 	{"SLIMBUS_4_TX", NULL, "Slimbus4 Capture"},
493f03d6b1bSSrinivas Kandagatla 	{"SLIMBUS_5_TX", NULL, "Slimbus5 Capture"},
494f03d6b1bSSrinivas Kandagatla 	{"SLIMBUS_6_TX", NULL, "Slimbus6 Capture"},
495f03d6b1bSSrinivas Kandagatla 
49624c4cbcfSSrinivas Kandagatla 	{"Primary MI2S Playback", NULL, "PRI_MI2S_RX"},
49724c4cbcfSSrinivas Kandagatla 	{"Secondary MI2S Playback", NULL, "SEC_MI2S_RX"},
49824c4cbcfSSrinivas Kandagatla 	{"Tertiary MI2S Playback", NULL, "TERT_MI2S_RX"},
49924c4cbcfSSrinivas Kandagatla 	{"Quaternary MI2S Playback", NULL, "QUAT_MI2S_RX"},
50098e80779SGabriel David 	{"Quinary MI2S Playback", NULL, "QUIN_MI2S_RX"},
50124c4cbcfSSrinivas Kandagatla 
5020e66cf5cSSrinivas Kandagatla 	{"Primary TDM0 Playback", NULL, "PRIMARY_TDM_RX_0"},
5030e66cf5cSSrinivas Kandagatla 	{"Primary TDM1 Playback", NULL, "PRIMARY_TDM_RX_1"},
5040e66cf5cSSrinivas Kandagatla 	{"Primary TDM2 Playback", NULL, "PRIMARY_TDM_RX_2"},
5050e66cf5cSSrinivas Kandagatla 	{"Primary TDM3 Playback", NULL, "PRIMARY_TDM_RX_3"},
5060e66cf5cSSrinivas Kandagatla 	{"Primary TDM4 Playback", NULL, "PRIMARY_TDM_RX_4"},
5070e66cf5cSSrinivas Kandagatla 	{"Primary TDM5 Playback", NULL, "PRIMARY_TDM_RX_5"},
5080e66cf5cSSrinivas Kandagatla 	{"Primary TDM6 Playback", NULL, "PRIMARY_TDM_RX_6"},
5090e66cf5cSSrinivas Kandagatla 	{"Primary TDM7 Playback", NULL, "PRIMARY_TDM_RX_7"},
5100e66cf5cSSrinivas Kandagatla 
5110e66cf5cSSrinivas Kandagatla 	{"Secondary TDM0 Playback", NULL, "SEC_TDM_RX_0"},
5120e66cf5cSSrinivas Kandagatla 	{"Secondary TDM1 Playback", NULL, "SEC_TDM_RX_1"},
5130e66cf5cSSrinivas Kandagatla 	{"Secondary TDM2 Playback", NULL, "SEC_TDM_RX_2"},
5140e66cf5cSSrinivas Kandagatla 	{"Secondary TDM3 Playback", NULL, "SEC_TDM_RX_3"},
5150e66cf5cSSrinivas Kandagatla 	{"Secondary TDM4 Playback", NULL, "SEC_TDM_RX_4"},
5160e66cf5cSSrinivas Kandagatla 	{"Secondary TDM5 Playback", NULL, "SEC_TDM_RX_5"},
5170e66cf5cSSrinivas Kandagatla 	{"Secondary TDM6 Playback", NULL, "SEC_TDM_RX_6"},
5180e66cf5cSSrinivas Kandagatla 	{"Secondary TDM7 Playback", NULL, "SEC_TDM_RX_7"},
5190e66cf5cSSrinivas Kandagatla 
5200e66cf5cSSrinivas Kandagatla 	{"Tertiary TDM0 Playback", NULL, "TERT_TDM_RX_0"},
5210e66cf5cSSrinivas Kandagatla 	{"Tertiary TDM1 Playback", NULL, "TERT_TDM_RX_1"},
5220e66cf5cSSrinivas Kandagatla 	{"Tertiary TDM2 Playback", NULL, "TERT_TDM_RX_2"},
5230e66cf5cSSrinivas Kandagatla 	{"Tertiary TDM3 Playback", NULL, "TERT_TDM_RX_3"},
5240e66cf5cSSrinivas Kandagatla 	{"Tertiary TDM4 Playback", NULL, "TERT_TDM_RX_4"},
5250e66cf5cSSrinivas Kandagatla 	{"Tertiary TDM5 Playback", NULL, "TERT_TDM_RX_5"},
5260e66cf5cSSrinivas Kandagatla 	{"Tertiary TDM6 Playback", NULL, "TERT_TDM_RX_6"},
5270e66cf5cSSrinivas Kandagatla 	{"Tertiary TDM7 Playback", NULL, "TERT_TDM_RX_7"},
5280e66cf5cSSrinivas Kandagatla 
5290e66cf5cSSrinivas Kandagatla 	{"Quaternary TDM0 Playback", NULL, "QUAT_TDM_RX_0"},
5300e66cf5cSSrinivas Kandagatla 	{"Quaternary TDM1 Playback", NULL, "QUAT_TDM_RX_1"},
5310e66cf5cSSrinivas Kandagatla 	{"Quaternary TDM2 Playback", NULL, "QUAT_TDM_RX_2"},
5320e66cf5cSSrinivas Kandagatla 	{"Quaternary TDM3 Playback", NULL, "QUAT_TDM_RX_3"},
5330e66cf5cSSrinivas Kandagatla 	{"Quaternary TDM4 Playback", NULL, "QUAT_TDM_RX_4"},
5340e66cf5cSSrinivas Kandagatla 	{"Quaternary TDM5 Playback", NULL, "QUAT_TDM_RX_5"},
5350e66cf5cSSrinivas Kandagatla 	{"Quaternary TDM6 Playback", NULL, "QUAT_TDM_RX_6"},
5360e66cf5cSSrinivas Kandagatla 	{"Quaternary TDM7 Playback", NULL, "QUAT_TDM_RX_7"},
5370e66cf5cSSrinivas Kandagatla 
5380e66cf5cSSrinivas Kandagatla 	{"Quinary TDM0 Playback", NULL, "QUIN_TDM_RX_0"},
5390e66cf5cSSrinivas Kandagatla 	{"Quinary TDM1 Playback", NULL, "QUIN_TDM_RX_1"},
5400e66cf5cSSrinivas Kandagatla 	{"Quinary TDM2 Playback", NULL, "QUIN_TDM_RX_2"},
5410e66cf5cSSrinivas Kandagatla 	{"Quinary TDM3 Playback", NULL, "QUIN_TDM_RX_3"},
5420e66cf5cSSrinivas Kandagatla 	{"Quinary TDM4 Playback", NULL, "QUIN_TDM_RX_4"},
5430e66cf5cSSrinivas Kandagatla 	{"Quinary TDM5 Playback", NULL, "QUIN_TDM_RX_5"},
5440e66cf5cSSrinivas Kandagatla 	{"Quinary TDM6 Playback", NULL, "QUIN_TDM_RX_6"},
5450e66cf5cSSrinivas Kandagatla 	{"Quinary TDM7 Playback", NULL, "QUIN_TDM_RX_7"},
5460e66cf5cSSrinivas Kandagatla 
5470e66cf5cSSrinivas Kandagatla 	{"PRIMARY_TDM_TX_0", NULL, "Primary TDM0 Capture"},
5480e66cf5cSSrinivas Kandagatla 	{"PRIMARY_TDM_TX_1", NULL, "Primary TDM1 Capture"},
5490e66cf5cSSrinivas Kandagatla 	{"PRIMARY_TDM_TX_2", NULL, "Primary TDM2 Capture"},
5500e66cf5cSSrinivas Kandagatla 	{"PRIMARY_TDM_TX_3", NULL, "Primary TDM3 Capture"},
5510e66cf5cSSrinivas Kandagatla 	{"PRIMARY_TDM_TX_4", NULL, "Primary TDM4 Capture"},
5520e66cf5cSSrinivas Kandagatla 	{"PRIMARY_TDM_TX_5", NULL, "Primary TDM5 Capture"},
5530e66cf5cSSrinivas Kandagatla 	{"PRIMARY_TDM_TX_6", NULL, "Primary TDM6 Capture"},
5540e66cf5cSSrinivas Kandagatla 	{"PRIMARY_TDM_TX_7", NULL, "Primary TDM7 Capture"},
5550e66cf5cSSrinivas Kandagatla 
5560e66cf5cSSrinivas Kandagatla 	{"SEC_TDM_TX_0", NULL, "Secondary TDM0 Capture"},
5570e66cf5cSSrinivas Kandagatla 	{"SEC_TDM_TX_1", NULL, "Secondary TDM1 Capture"},
5580e66cf5cSSrinivas Kandagatla 	{"SEC_TDM_TX_2", NULL, "Secondary TDM2 Capture"},
5590e66cf5cSSrinivas Kandagatla 	{"SEC_TDM_TX_3", NULL, "Secondary TDM3 Capture"},
5600e66cf5cSSrinivas Kandagatla 	{"SEC_TDM_TX_4", NULL, "Secondary TDM4 Capture"},
5610e66cf5cSSrinivas Kandagatla 	{"SEC_TDM_TX_5", NULL, "Secondary TDM5 Capture"},
5620e66cf5cSSrinivas Kandagatla 	{"SEC_TDM_TX_6", NULL, "Secondary TDM6 Capture"},
5630e66cf5cSSrinivas Kandagatla 	{"SEC_TDM_TX_7", NULL, "Secondary TDM7 Capture"},
5640e66cf5cSSrinivas Kandagatla 
5650e66cf5cSSrinivas Kandagatla 	{"TERT_TDM_TX_0", NULL, "Tertiary TDM0 Capture"},
5660e66cf5cSSrinivas Kandagatla 	{"TERT_TDM_TX_1", NULL, "Tertiary TDM1 Capture"},
5670e66cf5cSSrinivas Kandagatla 	{"TERT_TDM_TX_2", NULL, "Tertiary TDM2 Capture"},
5680e66cf5cSSrinivas Kandagatla 	{"TERT_TDM_TX_3", NULL, "Tertiary TDM3 Capture"},
5690e66cf5cSSrinivas Kandagatla 	{"TERT_TDM_TX_4", NULL, "Tertiary TDM4 Capture"},
5700e66cf5cSSrinivas Kandagatla 	{"TERT_TDM_TX_5", NULL, "Tertiary TDM5 Capture"},
5710e66cf5cSSrinivas Kandagatla 	{"TERT_TDM_TX_6", NULL, "Tertiary TDM6 Capture"},
5720e66cf5cSSrinivas Kandagatla 	{"TERT_TDM_TX_7", NULL, "Tertiary TDM7 Capture"},
5730e66cf5cSSrinivas Kandagatla 
5740e66cf5cSSrinivas Kandagatla 	{"QUAT_TDM_TX_0", NULL, "Quaternary TDM0 Capture"},
5750e66cf5cSSrinivas Kandagatla 	{"QUAT_TDM_TX_1", NULL, "Quaternary TDM1 Capture"},
5760e66cf5cSSrinivas Kandagatla 	{"QUAT_TDM_TX_2", NULL, "Quaternary TDM2 Capture"},
5770e66cf5cSSrinivas Kandagatla 	{"QUAT_TDM_TX_3", NULL, "Quaternary TDM3 Capture"},
5780e66cf5cSSrinivas Kandagatla 	{"QUAT_TDM_TX_4", NULL, "Quaternary TDM4 Capture"},
5790e66cf5cSSrinivas Kandagatla 	{"QUAT_TDM_TX_5", NULL, "Quaternary TDM5 Capture"},
5800e66cf5cSSrinivas Kandagatla 	{"QUAT_TDM_TX_6", NULL, "Quaternary TDM6 Capture"},
5810e66cf5cSSrinivas Kandagatla 	{"QUAT_TDM_TX_7", NULL, "Quaternary TDM7 Capture"},
5820e66cf5cSSrinivas Kandagatla 
5830e66cf5cSSrinivas Kandagatla 	{"QUIN_TDM_TX_0", NULL, "Quinary TDM0 Capture"},
5840e66cf5cSSrinivas Kandagatla 	{"QUIN_TDM_TX_1", NULL, "Quinary TDM1 Capture"},
5850e66cf5cSSrinivas Kandagatla 	{"QUIN_TDM_TX_2", NULL, "Quinary TDM2 Capture"},
5860e66cf5cSSrinivas Kandagatla 	{"QUIN_TDM_TX_3", NULL, "Quinary TDM3 Capture"},
5870e66cf5cSSrinivas Kandagatla 	{"QUIN_TDM_TX_4", NULL, "Quinary TDM4 Capture"},
5880e66cf5cSSrinivas Kandagatla 	{"QUIN_TDM_TX_5", NULL, "Quinary TDM5 Capture"},
5890e66cf5cSSrinivas Kandagatla 	{"QUIN_TDM_TX_6", NULL, "Quinary TDM6 Capture"},
5900e66cf5cSSrinivas Kandagatla 	{"QUIN_TDM_TX_7", NULL, "Quinary TDM7 Capture"},
5910e66cf5cSSrinivas Kandagatla 
59224c4cbcfSSrinivas Kandagatla 	{"TERT_MI2S_TX", NULL, "Tertiary MI2S Capture"},
59324c4cbcfSSrinivas Kandagatla 	{"PRI_MI2S_TX", NULL, "Primary MI2S Capture"},
59424c4cbcfSSrinivas Kandagatla 	{"SEC_MI2S_TX", NULL, "Secondary MI2S Capture"},
59524c4cbcfSSrinivas Kandagatla 	{"QUAT_MI2S_TX", NULL, "Quaternary MI2S Capture"},
59698e80779SGabriel David 	{"QUIN_MI2S_TX", NULL, "Quinary MI2S Capture"},
5971fdbcfa9SSrinivas Kandagatla 
5981fdbcfa9SSrinivas Kandagatla 	{"WSA_CODEC_DMA_RX_0 Playback", NULL, "WSA_CODEC_DMA_RX_0"},
5991fdbcfa9SSrinivas Kandagatla 	{"WSA_CODEC_DMA_TX_0", NULL, "WSA_CODEC_DMA_TX_0 Capture"},
6001fdbcfa9SSrinivas Kandagatla 	{"WSA_CODEC_DMA_RX_1 Playback", NULL, "WSA_CODEC_DMA_RX_1"},
6011fdbcfa9SSrinivas Kandagatla 	{"WSA_CODEC_DMA_TX_1", NULL, "WSA_CODEC_DMA_TX_1 Capture"},
6021fdbcfa9SSrinivas Kandagatla 	{"WSA_CODEC_DMA_TX_2", NULL, "WSA_CODEC_DMA_TX_2 Capture"},
6031fdbcfa9SSrinivas Kandagatla 	{"VA_CODEC_DMA_TX_0", NULL, "VA_CODEC_DMA_TX_0 Capture"},
6041fdbcfa9SSrinivas Kandagatla 	{"VA_CODEC_DMA_TX_1", NULL, "VA_CODEC_DMA_TX_1 Capture"},
6051fdbcfa9SSrinivas Kandagatla 	{"VA_CODEC_DMA_TX_2", NULL, "VA_CODEC_DMA_TX_2 Capture"},
6061fdbcfa9SSrinivas Kandagatla 	{"RX_CODEC_DMA_RX_0 Playback", NULL, "RX_CODEC_DMA_RX_0"},
6071fdbcfa9SSrinivas Kandagatla 	{"TX_CODEC_DMA_TX_0", NULL, "TX_CODEC_DMA_TX_0 Capture"},
6081fdbcfa9SSrinivas Kandagatla 	{"RX_CODEC_DMA_RX_1 Playback", NULL, "RX_CODEC_DMA_RX_1"},
6091fdbcfa9SSrinivas Kandagatla 	{"TX_CODEC_DMA_TX_1", NULL, "TX_CODEC_DMA_TX_1 Capture"},
6101fdbcfa9SSrinivas Kandagatla 	{"RX_CODEC_DMA_RX_2 Playback", NULL, "RX_CODEC_DMA_RX_2"},
6111fdbcfa9SSrinivas Kandagatla 	{"TX_CODEC_DMA_TX_2", NULL, "TX_CODEC_DMA_TX_2 Capture"},
6121fdbcfa9SSrinivas Kandagatla 	{"RX_CODEC_DMA_RX_3 Playback", NULL, "RX_CODEC_DMA_RX_3"},
6131fdbcfa9SSrinivas Kandagatla 	{"TX_CODEC_DMA_TX_3", NULL, "TX_CODEC_DMA_TX_3 Capture"},
6141fdbcfa9SSrinivas Kandagatla 	{"RX_CODEC_DMA_RX_4 Playback", NULL, "RX_CODEC_DMA_RX_4"},
6151fdbcfa9SSrinivas Kandagatla 	{"TX_CODEC_DMA_TX_4", NULL, "TX_CODEC_DMA_TX_4 Capture"},
6161fdbcfa9SSrinivas Kandagatla 	{"RX_CODEC_DMA_RX_5 Playback", NULL, "RX_CODEC_DMA_RX_5"},
6171fdbcfa9SSrinivas Kandagatla 	{"TX_CODEC_DMA_TX_5", NULL, "TX_CODEC_DMA_TX_5 Capture"},
6181fdbcfa9SSrinivas Kandagatla 	{"RX_CODEC_DMA_RX_6 Playback", NULL, "RX_CODEC_DMA_RX_6"},
6191fdbcfa9SSrinivas Kandagatla 	{"RX_CODEC_DMA_RX_7 Playback", NULL, "RX_CODEC_DMA_RX_7"},
62024c4cbcfSSrinivas Kandagatla };
62124c4cbcfSSrinivas Kandagatla 
msm_dai_q6_dai_probe(struct snd_soc_dai * dai)62224c4cbcfSSrinivas Kandagatla static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
62324c4cbcfSSrinivas Kandagatla {
62424c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
62524c4cbcfSSrinivas Kandagatla 	struct q6afe_port *port;
62624c4cbcfSSrinivas Kandagatla 
62724c4cbcfSSrinivas Kandagatla 	port = q6afe_port_get_from_id(dai->dev, dai->id);
62824c4cbcfSSrinivas Kandagatla 	if (IS_ERR(port)) {
62924c4cbcfSSrinivas Kandagatla 		dev_err(dai->dev, "Unable to get afe port\n");
63024c4cbcfSSrinivas Kandagatla 		return -EINVAL;
63124c4cbcfSSrinivas Kandagatla 	}
63224c4cbcfSSrinivas Kandagatla 	dai_data->port[dai->id] = port;
63324c4cbcfSSrinivas Kandagatla 
63424c4cbcfSSrinivas Kandagatla 	return 0;
63524c4cbcfSSrinivas Kandagatla }
63624c4cbcfSSrinivas Kandagatla 
msm_dai_q6_dai_remove(struct snd_soc_dai * dai)63724c4cbcfSSrinivas Kandagatla static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
63824c4cbcfSSrinivas Kandagatla {
63924c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
64024c4cbcfSSrinivas Kandagatla 
64124c4cbcfSSrinivas Kandagatla 	q6afe_port_put(dai_data->port[dai->id]);
64224c4cbcfSSrinivas Kandagatla 	dai_data->port[dai->id] = NULL;
64324c4cbcfSSrinivas Kandagatla 
64424c4cbcfSSrinivas Kandagatla 	return 0;
64524c4cbcfSSrinivas Kandagatla }
64624c4cbcfSSrinivas Kandagatla 
647*e4222bbdSKuninori Morimoto static const struct snd_soc_dai_ops q6hdmi_ops = {
648*e4222bbdSKuninori Morimoto 	.probe			= msm_dai_q6_dai_probe,
649*e4222bbdSKuninori Morimoto 	.remove			= msm_dai_q6_dai_remove,
650*e4222bbdSKuninori Morimoto 	.prepare		= q6afe_dai_prepare,
651*e4222bbdSKuninori Morimoto 	.hw_params		= q6hdmi_hw_params,
652*e4222bbdSKuninori Morimoto 	.shutdown		= q6afe_dai_shutdown,
653*e4222bbdSKuninori Morimoto };
654*e4222bbdSKuninori Morimoto 
655*e4222bbdSKuninori Morimoto static const struct snd_soc_dai_ops q6i2s_ops = {
656*e4222bbdSKuninori Morimoto 	.probe			= msm_dai_q6_dai_probe,
657*e4222bbdSKuninori Morimoto 	.remove			= msm_dai_q6_dai_remove,
658*e4222bbdSKuninori Morimoto 	.prepare		= q6afe_dai_prepare,
659*e4222bbdSKuninori Morimoto 	.hw_params		= q6i2s_hw_params,
660*e4222bbdSKuninori Morimoto 	.set_fmt		= q6i2s_set_fmt,
661*e4222bbdSKuninori Morimoto 	.shutdown		= q6afe_dai_shutdown,
662*e4222bbdSKuninori Morimoto 	.set_sysclk		= q6afe_mi2s_set_sysclk,
663*e4222bbdSKuninori Morimoto };
664*e4222bbdSKuninori Morimoto 
665*e4222bbdSKuninori Morimoto static const struct snd_soc_dai_ops q6slim_ops = {
666*e4222bbdSKuninori Morimoto 	.probe			= msm_dai_q6_dai_probe,
667*e4222bbdSKuninori Morimoto 	.remove			= msm_dai_q6_dai_remove,
668*e4222bbdSKuninori Morimoto 	.prepare		= q6afe_dai_prepare,
669*e4222bbdSKuninori Morimoto 	.hw_params		= q6slim_hw_params,
670*e4222bbdSKuninori Morimoto 	.shutdown		= q6afe_dai_shutdown,
671*e4222bbdSKuninori Morimoto 	.set_channel_map	= q6slim_set_channel_map,
672*e4222bbdSKuninori Morimoto };
673*e4222bbdSKuninori Morimoto 
674*e4222bbdSKuninori Morimoto static const struct snd_soc_dai_ops q6tdm_ops = {
675*e4222bbdSKuninori Morimoto 	.probe			= msm_dai_q6_dai_probe,
676*e4222bbdSKuninori Morimoto 	.remove			= msm_dai_q6_dai_remove,
677*e4222bbdSKuninori Morimoto 	.prepare		= q6afe_dai_prepare,
678*e4222bbdSKuninori Morimoto 	.shutdown		= q6afe_dai_shutdown,
679*e4222bbdSKuninori Morimoto 	.set_sysclk		= q6afe_mi2s_set_sysclk,
680*e4222bbdSKuninori Morimoto 	.set_tdm_slot		= q6tdm_set_tdm_slot,
681*e4222bbdSKuninori Morimoto 	.set_channel_map	= q6tdm_set_channel_map,
682*e4222bbdSKuninori Morimoto 	.hw_params		= q6tdm_hw_params,
683*e4222bbdSKuninori Morimoto };
684*e4222bbdSKuninori Morimoto 
685*e4222bbdSKuninori Morimoto static const struct snd_soc_dai_ops q6dma_ops = {
686*e4222bbdSKuninori Morimoto 	.probe			= msm_dai_q6_dai_probe,
687*e4222bbdSKuninori Morimoto 	.remove			= msm_dai_q6_dai_remove,
688*e4222bbdSKuninori Morimoto 	.prepare		= q6afe_dai_prepare,
689*e4222bbdSKuninori Morimoto 	.shutdown		= q6afe_dai_shutdown,
690*e4222bbdSKuninori Morimoto 	.set_sysclk		= q6afe_mi2s_set_sysclk,
691*e4222bbdSKuninori Morimoto 	.set_channel_map	= q6dma_set_channel_map,
692*e4222bbdSKuninori Morimoto 	.hw_params		= q6dma_hw_params,
693*e4222bbdSKuninori Morimoto };
694*e4222bbdSKuninori Morimoto 
69524c4cbcfSSrinivas Kandagatla static const struct snd_soc_dapm_widget q6afe_dai_widgets[] = {
69656235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("HDMI_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
69756235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SLIMBUS_0_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
69856235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SLIMBUS_1_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
69956235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SLIMBUS_2_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
70056235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SLIMBUS_3_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
70156235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SLIMBUS_4_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
70256235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SLIMBUS_5_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
70356235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SLIMBUS_6_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
70456235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SLIMBUS_0_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
70556235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SLIMBUS_1_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
70656235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SLIMBUS_2_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
70756235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SLIMBUS_3_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
70856235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SLIMBUS_4_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
70956235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SLIMBUS_5_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
71056235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SLIMBUS_6_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
71198e80779SGabriel David 	SND_SOC_DAPM_AIF_IN("QUIN_MI2S_RX", NULL,
71298e80779SGabriel David 						0, SND_SOC_NOPM, 0, 0),
71398e80779SGabriel David 	SND_SOC_DAPM_AIF_OUT("QUIN_MI2S_TX", NULL,
71498e80779SGabriel David 						0, SND_SOC_NOPM, 0, 0),
715e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_MI2S_RX", NULL,
71656235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
717e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_MI2S_TX", NULL,
71856235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
719e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_MI2S_RX", NULL,
72056235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
721e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_MI2S_TX", NULL,
72256235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
723e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_MI2S_RX", NULL,
72456235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
725e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_MI2S_TX", NULL,
72656235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
727e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_MI2S_RX_SD1",
72824c4cbcfSSrinivas Kandagatla 			"Secondary MI2S Playback SD1",
72956235e4bSSrinivas Kandagatla 			0, SND_SOC_NOPM, 0, 0),
730e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRI_MI2S_RX", NULL,
73156235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
732e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRI_MI2S_TX", NULL,
73356235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
7340e66cf5cSSrinivas Kandagatla 
735e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_0", NULL,
73656235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
737e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_1", NULL,
73856235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
739e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_2", NULL,
74056235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
741e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_3", NULL,
74256235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
743e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_4", NULL,
74456235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
745e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_5", NULL,
74656235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
747e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_6", NULL,
74856235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
749e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_7", NULL,
75056235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
751e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_0", NULL,
75256235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
753e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_1", NULL,
75456235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
755e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_2", NULL,
75656235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
757e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_3", NULL,
75856235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
759e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_4", NULL,
76056235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
761e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_5", NULL,
76256235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
763e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_6", NULL,
76456235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
765e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_7", NULL,
76656235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
7670e66cf5cSSrinivas Kandagatla 
768e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_0", NULL,
76956235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
770e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_1", NULL,
77156235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
772e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_2", NULL,
77356235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
774e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_3", NULL,
77556235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
776e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_4", NULL,
77756235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
778e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_5", NULL,
77956235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
780e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_6", NULL,
78156235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
782e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_7", NULL,
78356235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
784e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_0", NULL,
78556235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
786e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_1", NULL,
78756235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
788e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_2", NULL,
78956235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
790e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_3", NULL,
79156235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
792e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_4", NULL,
79356235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
794e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_5", NULL,
79556235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
796e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_6", NULL,
79756235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
798e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_7", NULL,
79956235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
8000e66cf5cSSrinivas Kandagatla 
801e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_0", NULL,
80256235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
803e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_1", NULL,
80456235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
805e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_2", NULL,
80656235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
807e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_3", NULL,
80856235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
809e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_4", NULL,
81056235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
811e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_5", NULL,
81256235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
813e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_6", NULL,
81456235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
815e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_7", NULL,
81656235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
817e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_0", NULL,
81856235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
819e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_1", NULL,
82056235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
821e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_2", NULL,
82256235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
823e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_3", NULL,
82456235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
825e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_4", NULL,
82656235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
827e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_5", NULL,
82856235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
829e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_6", NULL,
83056235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
831e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_7", NULL,
83256235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
8330e66cf5cSSrinivas Kandagatla 
834e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_0", NULL,
83556235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
836e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_1", NULL,
83756235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
838e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_2", NULL,
83956235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
840e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_3", NULL,
84156235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
842e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_4", NULL,
84356235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
844e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_5", NULL,
84556235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
846e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_6", NULL,
84756235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
848e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_7", NULL,
84956235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
850e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_0", NULL,
85156235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
852e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_1", NULL,
85356235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
854e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_2", NULL,
85556235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
856e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_3", NULL,
85756235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
858e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_4", NULL,
85956235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
860e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_5", NULL,
86156235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
862e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_6", NULL,
86356235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
864e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_7", NULL,
86556235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
8660e66cf5cSSrinivas Kandagatla 
867e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_0", NULL,
86856235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
869e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_1", NULL,
87056235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
871e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_2", NULL,
87256235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
873e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_3", NULL,
87456235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
875e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_4", NULL,
87656235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
877e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_5", NULL,
87856235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
879e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_6", NULL,
88056235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
881e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_7", NULL,
88256235e4bSSrinivas Kandagatla 			     0, SND_SOC_NOPM, 0, 0),
883e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_0", NULL,
88456235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
885e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_1", NULL,
88656235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
887e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_2", NULL,
88856235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
889e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_3", NULL,
89056235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
891e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_4", NULL,
89256235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
893e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_5", NULL,
89456235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
895e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_6", NULL,
89656235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
897e14856f6SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_7", NULL,
89856235e4bSSrinivas Kandagatla 						0, SND_SOC_NOPM, 0, 0),
89956235e4bSSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("DISPLAY_PORT_RX", "NULL", 0, SND_SOC_NOPM, 0, 0),
9001fdbcfa9SSrinivas Kandagatla 
9011fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("WSA_CODEC_DMA_RX_0", "NULL",
9021fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9031fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("WSA_CODEC_DMA_TX_0", "NULL",
9041fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9051fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("WSA_CODEC_DMA_RX_1", "NULL",
9061fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9071fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("WSA_CODEC_DMA_TX_1", "NULL",
9081fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9091fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("WSA_CODEC_DMA_TX_2", "NULL",
9101fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9111fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("VA_CODEC_DMA_TX_0", "NULL",
9121fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9131fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("VA_CODEC_DMA_TX_1", "NULL",
9141fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9151fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("VA_CODEC_DMA_TX_2", "NULL",
9161fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9171fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("RX_CODEC_DMA_RX_0", "NULL",
9181fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9191fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TX_CODEC_DMA_TX_0", "NULL",
9201fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9211fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("RX_CODEC_DMA_RX_1", "NULL",
9221fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9231fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TX_CODEC_DMA_TX_1", "NULL",
9241fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9251fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("RX_CODEC_DMA_RX_2", "NULL",
9261fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9271fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TX_CODEC_DMA_TX_2", "NULL",
9281fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9291fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("RX_CODEC_DMA_RX_3", "NULL",
9301fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9311fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TX_CODEC_DMA_TX_3", "NULL",
9321fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9331fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("RX_CODEC_DMA_RX_4", "NULL",
9341fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9351fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TX_CODEC_DMA_TX_4", "NULL",
9361fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9371fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("RX_CODEC_DMA_RX_5", "NULL",
9381fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9391fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_OUT("TX_CODEC_DMA_TX_5", "NULL",
9401fdbcfa9SSrinivas Kandagatla 		 0, SND_SOC_NOPM, 0, 0),
9411fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("RX_CODEC_DMA_RX_6", "NULL",
9421fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
9431fdbcfa9SSrinivas Kandagatla 	SND_SOC_DAPM_AIF_IN("RX_CODEC_DMA_RX_7", "NULL",
9441fdbcfa9SSrinivas Kandagatla 		0, SND_SOC_NOPM, 0, 0),
94524c4cbcfSSrinivas Kandagatla };
94624c4cbcfSSrinivas Kandagatla 
94724c4cbcfSSrinivas Kandagatla static const struct snd_soc_component_driver q6afe_dai_component = {
94824c4cbcfSSrinivas Kandagatla 	.name		= "q6afe-dai-component",
94924c4cbcfSSrinivas Kandagatla 	.dapm_widgets = q6afe_dai_widgets,
95024c4cbcfSSrinivas Kandagatla 	.num_dapm_widgets = ARRAY_SIZE(q6afe_dai_widgets),
95124c4cbcfSSrinivas Kandagatla 	.dapm_routes = q6afe_dapm_routes,
95224c4cbcfSSrinivas Kandagatla 	.num_dapm_routes = ARRAY_SIZE(q6afe_dapm_routes),
95395b6cd57SSrinivas Kandagatla 	.of_xlate_dai_name = q6dsp_audio_ports_of_xlate_dai_name,
95424c4cbcfSSrinivas Kandagatla 
95524c4cbcfSSrinivas Kandagatla };
95624c4cbcfSSrinivas Kandagatla 
of_q6afe_parse_dai_data(struct device * dev,struct q6afe_dai_data * data)95724c4cbcfSSrinivas Kandagatla static void of_q6afe_parse_dai_data(struct device *dev,
95824c4cbcfSSrinivas Kandagatla 				    struct q6afe_dai_data *data)
95924c4cbcfSSrinivas Kandagatla {
96024c4cbcfSSrinivas Kandagatla 	struct device_node *node;
96124c4cbcfSSrinivas Kandagatla 	int ret;
96224c4cbcfSSrinivas Kandagatla 
96324c4cbcfSSrinivas Kandagatla 	for_each_child_of_node(dev->of_node, node) {
96424c4cbcfSSrinivas Kandagatla 		unsigned int lines[Q6AFE_MAX_MI2S_LINES];
96524c4cbcfSSrinivas Kandagatla 		struct q6afe_dai_priv_data *priv;
96624c4cbcfSSrinivas Kandagatla 		int id, i, num_lines;
96724c4cbcfSSrinivas Kandagatla 
96824c4cbcfSSrinivas Kandagatla 		ret = of_property_read_u32(node, "reg", &id);
969b8110a87SDan Carpenter 		if (ret || id < 0 || id >= AFE_PORT_MAX) {
97024c4cbcfSSrinivas Kandagatla 			dev_err(dev, "valid dai id not found:%d\n", ret);
97124c4cbcfSSrinivas Kandagatla 			continue;
97224c4cbcfSSrinivas Kandagatla 		}
97324c4cbcfSSrinivas Kandagatla 
97424c4cbcfSSrinivas Kandagatla 		switch (id) {
97524c4cbcfSSrinivas Kandagatla 		/* MI2S specific properties */
97698e80779SGabriel David 		case QUINARY_MI2S_RX ... QUINARY_MI2S_TX:
97724c4cbcfSSrinivas Kandagatla 		case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX:
97824c4cbcfSSrinivas Kandagatla 			priv = &data->priv[id];
97924c4cbcfSSrinivas Kandagatla 			ret = of_property_read_variable_u32_array(node,
98024c4cbcfSSrinivas Kandagatla 							"qcom,sd-lines",
98124c4cbcfSSrinivas Kandagatla 							lines, 0,
98224c4cbcfSSrinivas Kandagatla 							Q6AFE_MAX_MI2S_LINES);
98324c4cbcfSSrinivas Kandagatla 			if (ret < 0)
98424c4cbcfSSrinivas Kandagatla 				num_lines = 0;
98524c4cbcfSSrinivas Kandagatla 			else
98624c4cbcfSSrinivas Kandagatla 				num_lines = ret;
98724c4cbcfSSrinivas Kandagatla 
98824c4cbcfSSrinivas Kandagatla 			priv->sd_line_mask = 0;
98924c4cbcfSSrinivas Kandagatla 
99024c4cbcfSSrinivas Kandagatla 			for (i = 0; i < num_lines; i++)
99124c4cbcfSSrinivas Kandagatla 				priv->sd_line_mask |= BIT(lines[i]);
99224c4cbcfSSrinivas Kandagatla 
99324c4cbcfSSrinivas Kandagatla 			break;
9940e66cf5cSSrinivas Kandagatla 		case PRIMARY_TDM_RX_0 ... QUINARY_TDM_TX_7:
9950e66cf5cSSrinivas Kandagatla 			priv = &data->priv[id];
9960e66cf5cSSrinivas Kandagatla 			ret = of_property_read_u32(node, "qcom,tdm-sync-mode",
9970e66cf5cSSrinivas Kandagatla 						   &priv->sync_mode);
9980e66cf5cSSrinivas Kandagatla 			if (ret) {
9990e66cf5cSSrinivas Kandagatla 				dev_err(dev, "No Sync mode from DT\n");
10000e66cf5cSSrinivas Kandagatla 				break;
10010e66cf5cSSrinivas Kandagatla 			}
10020e66cf5cSSrinivas Kandagatla 			ret = of_property_read_u32(node, "qcom,tdm-sync-src",
10030e66cf5cSSrinivas Kandagatla 						   &priv->sync_src);
10040e66cf5cSSrinivas Kandagatla 			if (ret) {
10050e66cf5cSSrinivas Kandagatla 				dev_err(dev, "No Sync Src from DT\n");
10060e66cf5cSSrinivas Kandagatla 				break;
10070e66cf5cSSrinivas Kandagatla 			}
10080e66cf5cSSrinivas Kandagatla 			ret = of_property_read_u32(node, "qcom,tdm-data-out",
10090e66cf5cSSrinivas Kandagatla 						   &priv->data_out_enable);
10100e66cf5cSSrinivas Kandagatla 			if (ret) {
10110e66cf5cSSrinivas Kandagatla 				dev_err(dev, "No Data out enable from DT\n");
10120e66cf5cSSrinivas Kandagatla 				break;
10130e66cf5cSSrinivas Kandagatla 			}
10140e66cf5cSSrinivas Kandagatla 			ret = of_property_read_u32(node, "qcom,tdm-invert-sync",
10150e66cf5cSSrinivas Kandagatla 						   &priv->invert_sync);
10160e66cf5cSSrinivas Kandagatla 			if (ret) {
10170e66cf5cSSrinivas Kandagatla 				dev_err(dev, "No Invert sync from DT\n");
10180e66cf5cSSrinivas Kandagatla 				break;
10190e66cf5cSSrinivas Kandagatla 			}
10200e66cf5cSSrinivas Kandagatla 			ret = of_property_read_u32(node, "qcom,tdm-data-delay",
10210e66cf5cSSrinivas Kandagatla 						   &priv->data_delay);
10220e66cf5cSSrinivas Kandagatla 			if (ret) {
10230e66cf5cSSrinivas Kandagatla 				dev_err(dev, "No Data Delay from DT\n");
10240e66cf5cSSrinivas Kandagatla 				break;
10250e66cf5cSSrinivas Kandagatla 			}
10260e66cf5cSSrinivas Kandagatla 			ret = of_property_read_u32(node, "qcom,tdm-data-align",
10270e66cf5cSSrinivas Kandagatla 						   &priv->data_align);
10280e66cf5cSSrinivas Kandagatla 			if (ret) {
10290e66cf5cSSrinivas Kandagatla 				dev_err(dev, "No Data align from DT\n");
10300e66cf5cSSrinivas Kandagatla 				break;
10310e66cf5cSSrinivas Kandagatla 			}
10320e66cf5cSSrinivas Kandagatla 			break;
103324c4cbcfSSrinivas Kandagatla 		default:
103424c4cbcfSSrinivas Kandagatla 			break;
103524c4cbcfSSrinivas Kandagatla 		}
103624c4cbcfSSrinivas Kandagatla 	}
103724c4cbcfSSrinivas Kandagatla }
103824c4cbcfSSrinivas Kandagatla 
q6afe_dai_dev_probe(struct platform_device * pdev)1039605fcb69SSrinivas Kandagatla static int q6afe_dai_dev_probe(struct platform_device *pdev)
104024c4cbcfSSrinivas Kandagatla {
104195b6cd57SSrinivas Kandagatla 	struct q6dsp_audio_port_dai_driver_config cfg;
104295b6cd57SSrinivas Kandagatla 	struct snd_soc_dai_driver *dais;
104324c4cbcfSSrinivas Kandagatla 	struct q6afe_dai_data *dai_data;
1044605fcb69SSrinivas Kandagatla 	struct device *dev = &pdev->dev;
104595b6cd57SSrinivas Kandagatla 	int num_dais;
104624c4cbcfSSrinivas Kandagatla 
1047605fcb69SSrinivas Kandagatla 	dai_data = devm_kzalloc(dev, sizeof(*dai_data), GFP_KERNEL);
104824c4cbcfSSrinivas Kandagatla 	if (!dai_data)
104924c4cbcfSSrinivas Kandagatla 		return -ENOMEM;
105024c4cbcfSSrinivas Kandagatla 
105124c4cbcfSSrinivas Kandagatla 	dev_set_drvdata(dev, dai_data);
105224c4cbcfSSrinivas Kandagatla 	of_q6afe_parse_dai_data(dev, dai_data);
105324c4cbcfSSrinivas Kandagatla 
105495b6cd57SSrinivas Kandagatla 	cfg.q6hdmi_ops = &q6hdmi_ops;
105595b6cd57SSrinivas Kandagatla 	cfg.q6slim_ops = &q6slim_ops;
105695b6cd57SSrinivas Kandagatla 	cfg.q6i2s_ops = &q6i2s_ops;
105795b6cd57SSrinivas Kandagatla 	cfg.q6tdm_ops = &q6tdm_ops;
105895b6cd57SSrinivas Kandagatla 	cfg.q6dma_ops = &q6dma_ops;
105995b6cd57SSrinivas Kandagatla 	dais = q6dsp_audio_ports_set_config(dev, &cfg, &num_dais);
106095b6cd57SSrinivas Kandagatla 
106195b6cd57SSrinivas Kandagatla 	return devm_snd_soc_register_component(dev, &q6afe_dai_component, dais, num_dais);
106224c4cbcfSSrinivas Kandagatla }
106324c4cbcfSSrinivas Kandagatla 
1064156d0273SSrinivas Kandagatla #ifdef CONFIG_OF
1065eb7cc9beSSrinivas Kandagatla static const struct of_device_id q6afe_dai_device_id[] = {
1066eb7cc9beSSrinivas Kandagatla 	{ .compatible = "qcom,q6afe-dais" },
1067eb7cc9beSSrinivas Kandagatla 	{},
1068eb7cc9beSSrinivas Kandagatla };
1069eb7cc9beSSrinivas Kandagatla MODULE_DEVICE_TABLE(of, q6afe_dai_device_id);
1070156d0273SSrinivas Kandagatla #endif
1071eb7cc9beSSrinivas Kandagatla 
107224c4cbcfSSrinivas Kandagatla static struct platform_driver q6afe_dai_platform_driver = {
107324c4cbcfSSrinivas Kandagatla 	.driver = {
107424c4cbcfSSrinivas Kandagatla 		.name = "q6afe-dai",
1075eb7cc9beSSrinivas Kandagatla 		.of_match_table = of_match_ptr(q6afe_dai_device_id),
107624c4cbcfSSrinivas Kandagatla 	},
107724c4cbcfSSrinivas Kandagatla 	.probe = q6afe_dai_dev_probe,
107824c4cbcfSSrinivas Kandagatla };
107924c4cbcfSSrinivas Kandagatla module_platform_driver(q6afe_dai_platform_driver);
108024c4cbcfSSrinivas Kandagatla 
1081b5377a76SColin Ian King MODULE_DESCRIPTION("Q6 Audio Frontend dai driver");
108224c4cbcfSSrinivas Kandagatla MODULE_LICENSE("GPL v2");
1083