diff options
Diffstat (limited to 'sound/soc/blackfin/bf5xx-tdm.c')
-rw-r--r-- | sound/soc/blackfin/bf5xx-tdm.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/sound/soc/blackfin/bf5xx-tdm.c b/sound/soc/blackfin/bf5xx-tdm.c index ff546e91a22e..4b360124083e 100644 --- a/sound/soc/blackfin/bf5xx-tdm.c +++ b/sound/soc/blackfin/bf5xx-tdm.c | |||
@@ -46,14 +46,6 @@ | |||
46 | #include "bf5xx-sport.h" | 46 | #include "bf5xx-sport.h" |
47 | #include "bf5xx-tdm.h" | 47 | #include "bf5xx-tdm.h" |
48 | 48 | ||
49 | struct bf5xx_tdm_port { | ||
50 | u16 tcr1; | ||
51 | u16 rcr1; | ||
52 | u16 tcr2; | ||
53 | u16 rcr2; | ||
54 | int configured; | ||
55 | }; | ||
56 | |||
57 | static struct bf5xx_tdm_port bf5xx_tdm; | 49 | static struct bf5xx_tdm_port bf5xx_tdm; |
58 | static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; | 50 | static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; |
59 | 51 | ||
@@ -181,6 +173,40 @@ static void bf5xx_tdm_shutdown(struct snd_pcm_substream *substream, | |||
181 | bf5xx_tdm.configured = 0; | 173 | bf5xx_tdm.configured = 0; |
182 | } | 174 | } |
183 | 175 | ||
176 | static int bf5xx_tdm_set_channel_map(struct snd_soc_dai *dai, | ||
177 | unsigned int tx_num, unsigned int *tx_slot, | ||
178 | unsigned int rx_num, unsigned int *rx_slot) | ||
179 | { | ||
180 | int i; | ||
181 | unsigned int slot; | ||
182 | unsigned int tx_mapped = 0, rx_mapped = 0; | ||
183 | |||
184 | if ((tx_num > BFIN_TDM_DAI_MAX_SLOTS) || | ||
185 | (rx_num > BFIN_TDM_DAI_MAX_SLOTS)) | ||
186 | return -EINVAL; | ||
187 | |||
188 | for (i = 0; i < tx_num; i++) { | ||
189 | slot = tx_slot[i]; | ||
190 | if ((slot < BFIN_TDM_DAI_MAX_SLOTS) && | ||
191 | (!(tx_mapped & (1 << slot)))) { | ||
192 | bf5xx_tdm.tx_map[i] = slot; | ||
193 | tx_mapped |= 1 << slot; | ||
194 | } else | ||
195 | return -EINVAL; | ||
196 | } | ||
197 | for (i = 0; i < rx_num; i++) { | ||
198 | slot = rx_slot[i]; | ||
199 | if ((slot < BFIN_TDM_DAI_MAX_SLOTS) && | ||
200 | (!(rx_mapped & (1 << slot)))) { | ||
201 | bf5xx_tdm.rx_map[i] = slot; | ||
202 | rx_mapped |= 1 << slot; | ||
203 | } else | ||
204 | return -EINVAL; | ||
205 | } | ||
206 | |||
207 | return 0; | ||
208 | } | ||
209 | |||
184 | #ifdef CONFIG_PM | 210 | #ifdef CONFIG_PM |
185 | static int bf5xx_tdm_suspend(struct snd_soc_dai *dai) | 211 | static int bf5xx_tdm_suspend(struct snd_soc_dai *dai) |
186 | { | 212 | { |
@@ -235,6 +261,7 @@ static struct snd_soc_dai_ops bf5xx_tdm_dai_ops = { | |||
235 | .hw_params = bf5xx_tdm_hw_params, | 261 | .hw_params = bf5xx_tdm_hw_params, |
236 | .set_fmt = bf5xx_tdm_set_dai_fmt, | 262 | .set_fmt = bf5xx_tdm_set_dai_fmt, |
237 | .shutdown = bf5xx_tdm_shutdown, | 263 | .shutdown = bf5xx_tdm_shutdown, |
264 | .set_channel_map = bf5xx_tdm_set_channel_map, | ||
238 | }; | 265 | }; |
239 | 266 | ||
240 | struct snd_soc_dai bf5xx_tdm_dai = { | 267 | struct snd_soc_dai bf5xx_tdm_dai = { |
@@ -300,6 +327,8 @@ static int __devinit bfin_tdm_probe(struct platform_device *pdev) | |||
300 | pr_err("Failed to register DAI: %d\n", ret); | 327 | pr_err("Failed to register DAI: %d\n", ret); |
301 | goto sport_config_err; | 328 | goto sport_config_err; |
302 | } | 329 | } |
330 | |||
331 | sport_handle->private_data = &bf5xx_tdm; | ||
303 | return 0; | 332 | return 0; |
304 | 333 | ||
305 | sport_config_err: | 334 | sport_config_err: |