Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: apq8096: add slim support

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Srinivas Kandagatla and committed by
Mark Brown
9f11d233 93f97ff1

+70 -1
+70 -1
sound/soc/qcom/apq8096.c
··· 9 9 #include <sound/pcm.h> 10 10 #include "common.h" 11 11 12 + #define SLIM_MAX_TX_PORTS 16 13 + #define SLIM_MAX_RX_PORTS 16 14 + #define WCD9335_DEFAULT_MCLK_RATE 9600000 15 + 12 16 static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 13 17 struct snd_pcm_hw_params *params) 14 18 { ··· 27 23 return 0; 28 24 } 29 25 26 + static int msm_snd_hw_params(struct snd_pcm_substream *substream, 27 + struct snd_pcm_hw_params *params) 28 + { 29 + struct snd_soc_pcm_runtime *rtd = substream->private_data; 30 + struct snd_soc_dai *codec_dai = rtd->codec_dai; 31 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 32 + u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; 33 + u32 rx_ch_cnt = 0, tx_ch_cnt = 0; 34 + int ret = 0; 35 + 36 + ret = snd_soc_dai_get_channel_map(codec_dai, 37 + &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch); 38 + if (ret != 0 && ret != -ENOTSUPP) { 39 + pr_err("failed to get codec chan map, err:%d\n", ret); 40 + goto end; 41 + } else if (ret == -ENOTSUPP) { 42 + return 0; 43 + } 44 + 45 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 46 + ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, 47 + rx_ch_cnt, rx_ch); 48 + else 49 + ret = snd_soc_dai_set_channel_map(cpu_dai, tx_ch_cnt, tx_ch, 50 + 0, NULL); 51 + if (ret != 0 && ret != -ENOTSUPP) 52 + pr_err("Failed to set cpu chan map, err:%d\n", ret); 53 + else if (ret == -ENOTSUPP) 54 + ret = 0; 55 + end: 56 + return ret; 57 + } 58 + 59 + static struct snd_soc_ops apq8096_ops = { 60 + .hw_params = msm_snd_hw_params, 61 + }; 62 + 63 + static int apq8096_init(struct snd_soc_pcm_runtime *rtd) 64 + { 65 + struct snd_soc_dai *codec_dai = rtd->codec_dai; 66 + 67 + /* 68 + * Codec SLIMBUS configuration 69 + * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13 70 + * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13 71 + * TX14, TX15, TX16 72 + */ 73 + unsigned int rx_ch[SLIM_MAX_RX_PORTS] = {144, 145, 146, 147, 148, 149, 74 + 150, 151, 152, 153, 154, 155, 156}; 75 + unsigned int tx_ch[SLIM_MAX_TX_PORTS] = {128, 129, 130, 131, 132, 133, 76 + 134, 135, 136, 137, 138, 139, 77 + 140, 141, 142, 143}; 78 + 79 + snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), 80 + tx_ch, ARRAY_SIZE(rx_ch), rx_ch); 81 + 82 + snd_soc_dai_set_sysclk(codec_dai, 0, WCD9335_DEFAULT_MCLK_RATE, 83 + SNDRV_PCM_STREAM_PLAYBACK); 84 + 85 + return 0; 86 + } 87 + 30 88 static void apq8096_add_be_ops(struct snd_soc_card *card) 31 89 { 32 90 struct snd_soc_dai_link *link; 33 91 int i; 34 92 35 93 for_each_card_prelinks(card, i, link) { 36 - if (link->no_pcm == 1) 94 + if (link->no_pcm == 1) { 37 95 link->be_hw_params_fixup = apq8096_be_hw_params_fixup; 96 + link->init = apq8096_init; 97 + link->ops = &apq8096_ops; 98 + } 38 99 } 39 100 } 40 101