From d32c5e5592d0f100f85731ce98cd31757cda9fb0 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Fri, 8 Nov 2013 16:38:43 +0800 Subject: ENGR00286961-4 ASoC: fsl_ssi: add monaural audio support We use SSI's normal mode to trick I2S signal by fetching data only from one side of time slot so that we can purely get or put the monaural audio data. Acked-by: Wang Shengjiu Signed-off-by: Nicolin Chen --- sound/soc/fsl/fsl_ssi.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 6d7ea1f1c402..68d84f0af67e 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -461,6 +461,8 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, snd_pcm_format_width(params_format(hw_params)); u32 wl = CCSR_SSI_SxCCR_WL(sample_size); int enabled = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN; + unsigned int channels = params_channels(hw_params); + static u8 i2s_mode; int ret; /* @@ -495,6 +497,20 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, else write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl); + /* Save i2s mode configuration so that we can restore it later */ + switch (read_ssi(&ssi->scr) & CCSR_SSI_SCR_I2S_MODE_MASK) { + case CCSR_SSI_SCR_I2S_MODE_SLAVE: + case CCSR_SSI_SCR_I2S_MODE_MASTER: + i2s_mode = read_ssi(&ssi->scr) & CCSR_SSI_SCR_I2S_MODE_MASK; + default: + break; + } + + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_NET, + channels == 1 ? 0 : CCSR_SSI_SCR_NET); + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_I2S_MODE_MASK, + channels == 1 ? 0 : i2s_mode); + return 0; } @@ -820,14 +836,13 @@ static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { static struct snd_soc_dai_driver fsl_ssi_dai_template = { .probe = fsl_ssi_dai_probe, .playback = { - /* The SSI does not support monaural audio. */ - .channels_min = 2, + .channels_min = 1, .channels_max = 2, .rates = FSLSSI_I2S_RATES, .formats = FSLSSI_I2S_FORMATS, }, .capture = { - .channels_min = 2, + .channels_min = 1, .channels_max = 2, .rates = FSLSSI_I2S_RATES, .formats = FSLSSI_I2S_FORMATS, -- cgit v1.2.3