aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2014-01-30 08:15:23 -0500
committerMark Brown <broonie@linaro.org>2014-01-31 10:51:20 -0500
commit2c56c4c27c59edfaa779da156f6a70a38bb1f2df (patch)
treea39c0cefc1873fb342cbf18096b2478095e7805d
parent662ffae9ed036bc82ff74c26dc731e2815431fcc (diff)
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>
-rw-r--r--sound/soc/davinci/davinci-mcasp.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 9ec456aaf80b..ae3e40a63e5e 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -524,12 +524,18 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
524 return 0; 524 return 0;
525} 525}
526 526
527static void mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream) 527static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream)
528{ 528{
529 int i, active_slots; 529 int i, active_slots;
530 u32 mask = 0; 530 u32 mask = 0;
531 u32 busel = 0; 531 u32 busel = 0;
532 532
533 if ((mcasp->tdm_slots < 2) || (mcasp->tdm_slots > 32)) {
534 dev_err(mcasp->dev, "tdm slot %d not supported\n",
535 mcasp->tdm_slots);
536 return -EINVAL;
537 }
538
533 active_slots = (mcasp->tdm_slots > 31) ? 32 : mcasp->tdm_slots; 539 active_slots = (mcasp->tdm_slots > 31) ? 32 : mcasp->tdm_slots;
534 for (i = 0; i < active_slots; i++) 540 for (i = 0; i < active_slots; i++)
535 mask |= (1 << i); 541 mask |= (1 << i);
@@ -539,35 +545,21 @@ static void mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream)
539 if (!mcasp->dat_port) 545 if (!mcasp->dat_port)
540 busel = TXSEL; 546 busel = TXSEL;
541 547
542 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 548 mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask);
543 /* bit stream is MSB first with no delay */ 549 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD);
544 /* DSP_B mode */ 550 mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG,
545 mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask); 551 FSXMOD(mcasp->tdm_slots), FSXMOD(0x1FF));
546 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD); 552
547 553 mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask);
548 if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32)) 554 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD);
549 mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, 555 mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG,
550 FSXMOD(mcasp->tdm_slots), FSXMOD(0x1FF)); 556 FSRMOD(mcasp->tdm_slots), FSRMOD(0x1FF));
551 else 557
552 printk(KERN_ERR "playback tdm slot %d not supported\n", 558 return 0;
553 mcasp->tdm_slots);
554 } else {
555 /* bit stream is MSB first with no delay */
556 /* DSP_B mode */
557 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD);
558 mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask);
559
560 if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32))
561 mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG,
562 FSRMOD(mcasp->tdm_slots), FSRMOD(0x1FF));
563 else
564 printk(KERN_ERR "capture tdm slot %d not supported\n",
565 mcasp->tdm_slots);
566 }
567} 559}
568 560
569/* S/PDIF */ 561/* S/PDIF */
570static void mcasp_dit_hw_param(struct davinci_mcasp *mcasp) 562static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp)
571{ 563{
572 /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 564 /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0
573 and LSB first */ 565 and LSB first */
@@ -589,6 +581,8 @@ static void mcasp_dit_hw_param(struct davinci_mcasp *mcasp)
589 581
590 /* Enable the DIT */ 582 /* Enable the DIT */
591 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN); 583 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN);
584
585 return 0;
592} 586}
593 587
594static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, 588static 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,
605 u8 slots = mcasp->tdm_slots; 599 u8 slots = mcasp->tdm_slots;
606 u8 active_serializers; 600 u8 active_serializers;
607 int channels; 601 int channels;
602 int ret;
608 struct snd_interval *pcm_channels = hw_param_interval(params, 603 struct snd_interval *pcm_channels = hw_param_interval(params,
609 SNDRV_PCM_HW_PARAM_CHANNELS); 604 SNDRV_PCM_HW_PARAM_CHANNELS);
610 channels = pcm_channels->min; 605 channels = pcm_channels->min;
@@ -619,9 +614,12 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
619 fifo_level = mcasp->rxnumevt * active_serializers; 614 fifo_level = mcasp->rxnumevt * active_serializers;
620 615
621 if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE) 616 if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE)
622 mcasp_dit_hw_param(mcasp); 617 ret = mcasp_dit_hw_param(mcasp);
623 else 618 else
624 mcasp_i2s_hw_param(mcasp, substream->stream); 619 ret = mcasp_i2s_hw_param(mcasp, substream->stream);
620
621 if (ret)
622 return ret;
625 623
626 switch (params_format(params)) { 624 switch (params_format(params)) {
627 case SNDRV_PCM_FORMAT_U8: 625 case SNDRV_PCM_FORMAT_U8: