aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorOder Chiou <oder_chiou@realtek.com>2014-09-17 03:12:33 -0400
committerMark Brown <broonie@kernel.org>2014-09-17 13:05:12 -0400
commit48561afef401876b4b0e35a303d89884c10fe468 (patch)
tree1d802a8e116577b73c013bd7bcdab2dc79b709e9 /sound
parent44caf7648064502fd1d37d18443ae92c064ebadd (diff)
ASoC: rt5677: Add the TDM function
The patch adds the TDM function. Signed-off-by: Oder Chiou <oder_chiou@realtek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/rt5677.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 02bc8bd7caeb..1d4719f5fe75 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -3107,6 +3107,59 @@ static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
3107 return 0; 3107 return 0;
3108} 3108}
3109 3109
3110static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
3111 unsigned int rx_mask, int slots, int slot_width)
3112{
3113 struct snd_soc_codec *codec = dai->codec;
3114 unsigned int val = 0;
3115
3116 if (rx_mask || tx_mask)
3117 val |= (1 << 12);
3118
3119 switch (slots) {
3120 case 4:
3121 val |= (1 << 10);
3122 break;
3123 case 6:
3124 val |= (2 << 10);
3125 break;
3126 case 8:
3127 val |= (3 << 10);
3128 break;
3129 case 2:
3130 default:
3131 break;
3132 }
3133
3134 switch (slot_width) {
3135 case 20:
3136 val |= (1 << 8);
3137 break;
3138 case 24:
3139 val |= (2 << 8);
3140 break;
3141 case 32:
3142 val |= (3 << 8);
3143 break;
3144 case 16:
3145 default:
3146 break;
3147 }
3148
3149 switch (dai->id) {
3150 case RT5677_AIF1:
3151 snd_soc_update_bits(codec, RT5677_TDM1_CTRL1, 0x1f00, val);
3152 break;
3153 case RT5677_AIF2:
3154 snd_soc_update_bits(codec, RT5677_TDM2_CTRL1, 0x1f00, val);
3155 break;
3156 default:
3157 break;
3158 }
3159
3160 return 0;
3161}
3162
3110static int rt5677_set_bias_level(struct snd_soc_codec *codec, 3163static int rt5677_set_bias_level(struct snd_soc_codec *codec,
3111 enum snd_soc_bias_level level) 3164 enum snd_soc_bias_level level)
3112{ 3165{
@@ -3357,6 +3410,7 @@ static struct snd_soc_dai_ops rt5677_aif_dai_ops = {
3357 .set_fmt = rt5677_set_dai_fmt, 3410 .set_fmt = rt5677_set_dai_fmt,
3358 .set_sysclk = rt5677_set_dai_sysclk, 3411 .set_sysclk = rt5677_set_dai_sysclk,
3359 .set_pll = rt5677_set_dai_pll, 3412 .set_pll = rt5677_set_dai_pll,
3413 .set_tdm_slot = rt5677_set_tdm_slot,
3360}; 3414};
3361 3415
3362static struct snd_soc_dai_driver rt5677_dai[] = { 3416static struct snd_soc_dai_driver rt5677_dai[] = {