ASoC: OMAP: Add support for mono audio links in McBSP DAI
authorJarkko Nikula <jarkko.nikula@nokia.com>
Tue, 25 Nov 2008 10:45:09 +0000 (12:45 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 25 Nov 2008 15:21:26 +0000 (15:21 +0000)
Patch adds support for mono audio links so that McBSP DAI can operate with
real mono codecs. In I2S, the signalling remains the same but only first
frame (left channel) is transmitting audio data and second frame having null
data. In DSP_A, only first frame is transmitted.

Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/omap/omap-mcbsp.c

index 252bc7ebb194db6a27abd4a56ca5ef09ff5f81e0..e8f1314762d7dc18be19d09d632d671f3fe12402 100644 (file)
@@ -203,7 +203,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
        struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
        struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
        int dma, bus_id = mcbsp_data->bus_id, id = cpu_dai->id;
-       int wlen;
+       int wlen, channels;
        unsigned long port;
 
        if (cpu_class_is_omap1()) {
@@ -232,12 +232,17 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
                return 0;
        }
 
-       switch (params_channels(params)) {
+       channels = params_channels(params);
+       switch (channels) {
        case 2:
-               /* Set 1 word per (McBPSP) frame and use dual-phase frames */
-               regs->rcr2      |= RFRLEN2(1 - 1) | RPHASE;
+               /* Use dual-phase frames */
+               regs->rcr2      |= RPHASE;
+               regs->xcr2      |= XPHASE;
+       case 1:
+               /* Set 1 word per (McBSP) frame */
+               regs->rcr2      |= RFRLEN2(1 - 1);
                regs->rcr1      |= RFRLEN1(1 - 1);
-               regs->xcr2      |= XFRLEN2(1 - 1) | XPHASE;
+               regs->xcr2      |= XFRLEN2(1 - 1);
                regs->xcr1      |= XFRLEN1(1 - 1);
                break;
        default:
@@ -266,8 +271,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
                regs->srgr1     |= FWID(wlen - 1);
                break;
        case SND_SOC_DAIFMT_DSP_A:
-               regs->srgr2     |= FPER(wlen * 2 - 1);
-               regs->srgr1     |= FWID(wlen * 2 - 2);
+               regs->srgr2     |= FPER(wlen * channels - 1);
+               regs->srgr1     |= FWID(wlen * channels - 2);
                break;
        }
 
@@ -457,13 +462,13 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
        .name = "omap-mcbsp-dai-"#link_id,                      \
        .id = (link_id),                                        \
        .playback = {                                           \
-               .channels_min = 2,                              \
+               .channels_min = 1,                              \
                .channels_max = 2,                              \
                .rates = OMAP_MCBSP_RATES,                      \
                .formats = SNDRV_PCM_FMTBIT_S16_LE,             \
        },                                                      \
        .capture = {                                            \
-               .channels_min = 2,                              \
+               .channels_min = 1,                              \
                .channels_max = 2,                              \
                .rates = OMAP_MCBSP_RATES,                      \
                .formats = SNDRV_PCM_FMTBIT_S16_LE,             \