ASoC: davinci-mcasp: Configure xxTDM, xxFMT and xxFMCT registers synchronously

These registers can be configured synchronously for playback and capture.
Furthermore when McASP is in master and sync mode the capture operation
needs the TX path to be configured in order to be able to provide the needed
clocks for the bus.
xxFMT and xxFMCT registers has been already configured for both TX and RX
other places in the driver.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
Peter Ujfalusi 2014-01-30 15:15:23 +02:00 committed by Mark Brown
parent 662ffae9ed
commit 2c56c4c27c

View File

@ -524,12 +524,18 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
return 0; return 0;
} }
static void mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream) static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream)
{ {
int i, active_slots; int i, active_slots;
u32 mask = 0; u32 mask = 0;
u32 busel = 0; u32 busel = 0;
if ((mcasp->tdm_slots < 2) || (mcasp->tdm_slots > 32)) {
dev_err(mcasp->dev, "tdm slot %d not supported\n",
mcasp->tdm_slots);
return -EINVAL;
}
active_slots = (mcasp->tdm_slots > 31) ? 32 : mcasp->tdm_slots; active_slots = (mcasp->tdm_slots > 31) ? 32 : mcasp->tdm_slots;
for (i = 0; i < active_slots; i++) for (i = 0; i < active_slots; i++)
mask |= (1 << i); mask |= (1 << i);
@ -539,35 +545,21 @@ static void mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream)
if (!mcasp->dat_port) if (!mcasp->dat_port)
busel = TXSEL; busel = TXSEL;
if (stream == SNDRV_PCM_STREAM_PLAYBACK) { mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask);
/* bit stream is MSB first with no delay */ mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD);
/* DSP_B mode */ mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG,
mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask); FSXMOD(mcasp->tdm_slots), FSXMOD(0x1FF));
mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD);
if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32)) mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask);
mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD);
FSXMOD(mcasp->tdm_slots), FSXMOD(0x1FF)); mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG,
else FSRMOD(mcasp->tdm_slots), FSRMOD(0x1FF));
printk(KERN_ERR "playback tdm slot %d not supported\n",
mcasp->tdm_slots);
} else {
/* bit stream is MSB first with no delay */
/* DSP_B mode */
mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD);
mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask);
if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32)) return 0;
mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG,
FSRMOD(mcasp->tdm_slots), FSRMOD(0x1FF));
else
printk(KERN_ERR "capture tdm slot %d not supported\n",
mcasp->tdm_slots);
}
} }
/* S/PDIF */ /* S/PDIF */
static void mcasp_dit_hw_param(struct davinci_mcasp *mcasp) static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp)
{ {
/* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0
and LSB first */ and LSB first */
@ -589,6 +581,8 @@ static void mcasp_dit_hw_param(struct davinci_mcasp *mcasp)
/* Enable the DIT */ /* Enable the DIT */
mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN); mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN);
return 0;
} }
static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
@ -605,6 +599,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
u8 slots = mcasp->tdm_slots; u8 slots = mcasp->tdm_slots;
u8 active_serializers; u8 active_serializers;
int channels; int channels;
int ret;
struct snd_interval *pcm_channels = hw_param_interval(params, struct snd_interval *pcm_channels = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_CHANNELS); SNDRV_PCM_HW_PARAM_CHANNELS);
channels = pcm_channels->min; channels = pcm_channels->min;
@ -619,9 +614,12 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
fifo_level = mcasp->rxnumevt * active_serializers; fifo_level = mcasp->rxnumevt * active_serializers;
if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE) if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE)
mcasp_dit_hw_param(mcasp); ret = mcasp_dit_hw_param(mcasp);
else else
mcasp_i2s_hw_param(mcasp, substream->stream); ret = mcasp_i2s_hw_param(mcasp, substream->stream);
if (ret)
return ret;
switch (params_format(params)) { switch (params_format(params)) {
case SNDRV_PCM_FORMAT_U8: case SNDRV_PCM_FORMAT_U8: