Diff
Modified: trunk/sound/soc/blackfin/Kconfig (7378 => 7379)
--- trunk/sound/soc/blackfin/Kconfig 2009-09-18 00:16:04 UTC (rev 7378)
+++ trunk/sound/soc/blackfin/Kconfig 2009-09-18 02:23:34 UTC (rev 7379)
@@ -8,8 +8,8 @@
You will also need to select the audio interfaces to support below.
config SND_BF5XX_TDM
- tristate "SoC TDM Audio for the ADI BF5xx chip"
- depends on BLACKFIN && SND_SOC
+ tristate "SoC I2S(TDM mode) Audio for the ADI BF5xx chip"
+ depends on (BLACKFIN && SND_SOC)
help
Say Y or M if you want to add support for codecs attached to
the Blackfin SPORT (synchronous serial ports) interface in TDM
@@ -105,36 +105,13 @@
Say Y if you want to add support for SoC audio on BF5xx STAMP/EZKIT.
config SND_BF5XX_SOC_AD1938
- tristate "SoC AD1938 Audio support for Blackfin"
- depends on (SND_BF5XX_TDM || SND_BF5XX_I2S)
- select SND_BF5XX_SOC_TDM
- select SND_BF5XX_SOC_I2S
- select SND_SOC_AD1938
- help
- Say Y if you want to add support for AD1938 codec on Blackfin.
-choice
- prompt "Interface between Blackfin and AD1938"
- depends on SND_BF5XX_SOC_AD1938
- default SND_BF5XX_AD1938_TDM
- help
- There are two types of interface can be supportted on Blackfin
- Stamp: TDM and I2S. TDM support 8 channels. I2S only support 2 channels.
+ tristate "SoC AD1938 Audio support for Blackfin"
+ depends on SND_BF5XX_TDM
+ select SND_BF5XX_SOC_TDM
+ select SND_SOC_AD1938
+ help
+ Say Y if you want to add support for AD1938 codec on Blackfin.
-config SND_BF5XX_AD1938_TDM
- boolean "TDM interface"
- depends on SND_BF5XX_TDM
- help
- TDM supports 8 channels ouput
- If unsure, say Y.
-
-config SND_BF5XX_AD1938_I2S
- boolean "I2S interface"
- depends on SND_BF5XX_I2S
- help
- I2S support 2 channels ouput
- If unsure, say N.
-endchoice
-
config SND_BF5XX_SPORT_NUM
int "Set a SPORT for Sound chip"
depends on (SND_BF5XX_I2S || SND_BF5XX_AC97 || SND_BF5XX_TDM)
Modified: trunk/sound/soc/blackfin/bf5xx-ad1836.c (7378 => 7379)
--- trunk/sound/soc/blackfin/bf5xx-ad1836.c 2009-09-18 00:16:04 UTC (rev 7378)
+++ trunk/sound/soc/blackfin/bf5xx-ad1836.c 2009-09-18 02:23:34 UTC (rev 7379)
@@ -52,6 +52,7 @@
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
+ unsigned int channel_map[] = {0, 4, 1, 5, 2, 6, 3, 7};
int ret = 0;
/* set cpu DAI configuration */
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A |
@@ -65,8 +66,9 @@
if (ret < 0)
return ret;
- /* set cpu DAI slots, 8 channels, mask is defined as slot seq */
- ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x73625140, 8);
+ /* set cpu DAI channel mapping */
+ ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map),
+ channel_map, ARRAY_SIZE(channel_map), channel_map);
if (ret < 0)
return ret;
Modified: trunk/sound/soc/blackfin/bf5xx-ad1938.c (7378 => 7379)
--- trunk/sound/soc/blackfin/bf5xx-ad1938.c 2009-09-18 00:16:04 UTC (rev 7378)
+++ trunk/sound/soc/blackfin/bf5xx-ad1938.c 2009-09-18 02:23:34 UTC (rev 7379)
@@ -61,6 +61,7 @@
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
+ unsigned int channel_map[] = {0, 1, 2, 3, 4, 5, 6, 7};
int ret = 0;
/* set cpu DAI configuration */
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A |
@@ -74,13 +75,14 @@
if (ret < 0)
return ret;
- /* set cpu DAI slots, 8 channels, mask is defined as slot seq */
- ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x76543210, 8);
+ /* set codec DAI slots, 8 channels, all channels are enabled */
+ ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xFF, 8);
if (ret < 0)
return ret;
- /* set codec DAI slots, 8 channels, all channels are enabled */
- ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xFF, 8);
+ /* set cpu DAI channel mapping */
+ ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map),
+ channel_map, ARRAY_SIZE(channel_map), channel_map);
if (ret < 0)
return ret;
Modified: trunk/sound/soc/blackfin/bf5xx-tdm-pcm.c (7378 => 7379)
--- trunk/sound/soc/blackfin/bf5xx-tdm-pcm.c 2009-09-18 00:16:04 UTC (rev 7378)
+++ trunk/sound/soc/blackfin/bf5xx-tdm-pcm.c 2009-09-18 02:23:34 UTC (rev 7379)
@@ -189,11 +189,9 @@
dst = (unsigned int *)substream->runtime->dma_area;
dst += pos * 8;
-
while (count--) {
for (i = 0; i < substream->runtime->channels; i++)
- *(dst + (((tdm_port->slot_seq >>
- (4 * i)) & 0xF))) = *src++;
+ *(dst + tdm_port->tx_map[i]) = *src++;
dst += 8;
}
} else {
@@ -203,8 +201,7 @@
src += pos * 8;
while (count--) {
for (i = 0; i < substream->runtime->channels; i++)
- *dst++ = *(src + (((tdm_port->slot_seq >>
- (4 * i)) & 0xF)));
+ *dst++ = *(src + tdm_port->rx_map[i]);
src += 8;
}
}
Modified: trunk/sound/soc/blackfin/bf5xx-tdm.c (7378 => 7379)
--- trunk/sound/soc/blackfin/bf5xx-tdm.c 2009-09-18 00:16:04 UTC (rev 7378)
+++ trunk/sound/soc/blackfin/bf5xx-tdm.c 2009-09-18 02:23:34 UTC (rev 7379)
@@ -173,10 +173,37 @@
bf5xx_tdm.configured = 0;
}
-static int bf5xx_tdm_set_tdm_slot(struct snd_soc_dai *dai,
- unsigned int mask, int slots)
+static int bf5xx_tdm_set_channel_map(struct snd_soc_dai *dai,
+ unsigned int tx_num, unsigned int *tx_slot,
+ unsigned int rx_num, unsigned int *rx_slot)
{
- bf5xx_tdm.slot_seq = mask;
+ int i;
+ unsigned int slot;
+ unsigned int tx_mapped = 0, rx_mapped = 0;
+
+ if ((tx_num > BFIN_TDM_DAI_MAX_SLOTS) ||
+ (rx_num > BFIN_TDM_DAI_MAX_SLOTS))
+ return -EINVAL;
+
+ for (i = 0; i < tx_num; i++) {
+ slot = tx_slot[i];
+ if ((slot < BFIN_TDM_DAI_MAX_SLOTS) &&
+ (!(tx_mapped & (1 << slot)))) {
+ bf5xx_tdm.tx_map[i] = slot;
+ tx_mapped |= 1 << slot;
+ } else
+ return -EINVAL;
+ }
+ for (i = 0; i < rx_num; i++) {
+ slot = rx_slot[i];
+ if ((slot < BFIN_TDM_DAI_MAX_SLOTS) &&
+ (!(rx_mapped & (1 << slot)))) {
+ bf5xx_tdm.rx_map[i] = slot;
+ rx_mapped |= 1 << slot;
+ } else
+ return -EINVAL;
+ }
+
return 0;
}
@@ -234,7 +261,7 @@
.hw_params = bf5xx_tdm_hw_params,
.set_fmt = bf5xx_tdm_set_dai_fmt,
.shutdown = bf5xx_tdm_shutdown,
- .set_tdm_slot = bf5xx_tdm_set_tdm_slot,
+ .set_channel_map = bf5xx_tdm_set_channel_map,
};
struct snd_soc_dai bf5xx_tdm_dai = {
Modified: trunk/sound/soc/blackfin/bf5xx-tdm.h (7378 => 7379)
--- trunk/sound/soc/blackfin/bf5xx-tdm.h 2009-09-18 00:16:04 UTC (rev 7378)
+++ trunk/sound/soc/blackfin/bf5xx-tdm.h 2009-09-18 02:23:34 UTC (rev 7379)
@@ -9,13 +9,14 @@
#ifndef _BF5XX_TDM_H
#define _BF5XX_TDM_H
+#define BFIN_TDM_DAI_MAX_SLOTS 8
struct bf5xx_tdm_port {
u16 tcr1;
u16 rcr1;
u16 tcr2;
u16 rcr2;
- /* which slot used for the corresponding audio channel? */
- int slot_seq;
+ unsigned int tx_map[BFIN_TDM_DAI_MAX_SLOTS];
+ unsigned int rx_map[BFIN_TDM_DAI_MAX_SLOTS];
int configured;
};