aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/davinci/davinci-mcasp.c48
-rw-r--r--sound/soc/davinci/davinci-mcasp.h1
2 files changed, 25 insertions, 24 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index eb46dc69248f..aa063a4e7b0c 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -37,6 +37,8 @@
37#include "davinci-pcm.h" 37#include "davinci-pcm.h"
38#include "davinci-mcasp.h" 38#include "davinci-mcasp.h"
39 39
40#define MCASP_MAX_AFIFO_DEPTH 64
41
40struct davinci_mcasp_context { 42struct davinci_mcasp_context {
41 u32 txfmtctl; 43 u32 txfmtctl;
42 u32 rxfmtctl; 44 u32 rxfmtctl;
@@ -469,9 +471,9 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
469 int i; 471 int i;
470 u8 tx_ser = 0; 472 u8 tx_ser = 0;
471 u8 rx_ser = 0; 473 u8 rx_ser = 0;
472 u8 ser;
473 u8 slots = mcasp->tdm_slots; 474 u8 slots = mcasp->tdm_slots;
474 u8 max_active_serializers = (channels + slots - 1) / slots; 475 u8 max_active_serializers = (channels + slots - 1) / slots;
476 u8 active_serializers, numevt;
475 u32 reg; 477 u32 reg;
476 /* Default configuration */ 478 /* Default configuration */
477 if (mcasp->version != MCASP_VERSION_4) 479 if (mcasp->version != MCASP_VERSION_4)
@@ -505,36 +507,34 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
505 } 507 }
506 } 508 }
507 509
508 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 510 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
509 ser = tx_ser; 511 active_serializers = tx_ser;
510 else 512 numevt = mcasp->txnumevt;
511 ser = rx_ser; 513 reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET;
514 } else {
515 active_serializers = rx_ser;
516 numevt = mcasp->rxnumevt;
517 reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET;
518 }
512 519
513 if (ser < max_active_serializers) { 520 if (active_serializers < max_active_serializers) {
514 dev_warn(mcasp->dev, "stream has more channels (%d) than are " 521 dev_warn(mcasp->dev, "stream has more channels (%d) than are "
515 "enabled in mcasp (%d)\n", channels, ser * slots); 522 "enabled in mcasp (%d)\n", channels,
523 active_serializers * slots);
516 return -EINVAL; 524 return -EINVAL;
517 } 525 }
518 526
519 if (mcasp->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) { 527 /* AFIFO is not in use */
520 if (mcasp->txnumevt * tx_ser > 64) 528 if (!numevt)
521 mcasp->txnumevt = 1; 529 return 0;
522
523 reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET;
524 mcasp_mod_bits(mcasp, reg, tx_ser, NUMDMA_MASK);
525 mcasp_mod_bits(mcasp, reg, ((mcasp->txnumevt * tx_ser) << 8),
526 NUMEVT_MASK);
527 }
528 530
529 if (mcasp->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { 531 if (numevt * active_serializers > MCASP_MAX_AFIFO_DEPTH)
530 if (mcasp->rxnumevt * rx_ser > 64) 532 numevt = active_serializers;
531 mcasp->rxnumevt = 1;
532 533
533 reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; 534 /* Configure the AFIFO */
534 mcasp_mod_bits(mcasp, reg, rx_ser, NUMDMA_MASK); 535 numevt *= active_serializers;
535 mcasp_mod_bits(mcasp, reg, ((mcasp->rxnumevt * rx_ser) << 8), 536 mcasp_mod_bits(mcasp, reg, active_serializers, NUMDMA_MASK);
536 NUMEVT_MASK); 537 mcasp_mod_bits(mcasp, reg, NUMEVT(numevt), NUMEVT_MASK);
537 }
538 538
539 return 0; 539 return 0;
540} 540}
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h
index 8fed757d6087..98fbc451892a 100644
--- a/sound/soc/davinci/davinci-mcasp.h
+++ b/sound/soc/davinci/davinci-mcasp.h
@@ -283,6 +283,7 @@
283 */ 283 */
284#define FIFO_ENABLE BIT(16) 284#define FIFO_ENABLE BIT(16)
285#define NUMEVT_MASK (0xFF << 8) 285#define NUMEVT_MASK (0xFF << 8)
286#define NUMEVT(x) (((x) & 0xFF) << 8)
286#define NUMDMA_MASK (0xFF) 287#define NUMDMA_MASK (0xFF)
287 288
288#endif /* DAVINCI_MCASP_H */ 289#endif /* DAVINCI_MCASP_H */