aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl/mpc5200_dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/fsl/mpc5200_dma.c')
-rw-r--r--sound/soc/fsl/mpc5200_dma.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
index efec33a1c5bd..6096d22283e6 100644
--- a/sound/soc/fsl/mpc5200_dma.c
+++ b/sound/soc/fsl/mpc5200_dma.c
@@ -69,6 +69,23 @@ static void psc_dma_bcom_enqueue_next_buffer(struct psc_dma_stream *s)
69 69
70static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s) 70static void psc_dma_bcom_enqueue_tx(struct psc_dma_stream *s)
71{ 71{
72 if (s->appl_ptr > s->runtime->control->appl_ptr) {
73 /*
74 * In this case s->runtime->control->appl_ptr has wrapped around.
75 * Play the data to the end of the boundary, then wrap our own
76 * appl_ptr back around.
77 */
78 while (s->appl_ptr < s->runtime->boundary) {
79 if (bcom_queue_full(s->bcom_task))
80 return;
81
82 s->appl_ptr += s->period_size;
83
84 psc_dma_bcom_enqueue_next_buffer(s);
85 }
86 s->appl_ptr -= s->runtime->boundary;
87 }
88
72 while (s->appl_ptr < s->runtime->control->appl_ptr) { 89 while (s->appl_ptr < s->runtime->control->appl_ptr) {
73 90
74 if (bcom_queue_full(s->bcom_task)) 91 if (bcom_queue_full(s->bcom_task))
@@ -430,6 +447,7 @@ int mpc5200_audio_dma_create(struct of_device *op)
430 int size, irq, rc; 447 int size, irq, rc;
431 const __be32 *prop; 448 const __be32 *prop;
432 void __iomem *regs; 449 void __iomem *regs;
450 int ret;
433 451
434 /* Fetch the registers and IRQ of the PSC */ 452 /* Fetch the registers and IRQ of the PSC */
435 irq = irq_of_parse_and_map(op->node, 0); 453 irq = irq_of_parse_and_map(op->node, 0);
@@ -446,16 +464,19 @@ int mpc5200_audio_dma_create(struct of_device *op)
446 /* Allocate and initialize the driver private data */ 464 /* Allocate and initialize the driver private data */
447 psc_dma = kzalloc(sizeof *psc_dma, GFP_KERNEL); 465 psc_dma = kzalloc(sizeof *psc_dma, GFP_KERNEL);
448 if (!psc_dma) { 466 if (!psc_dma) {
449 iounmap(regs); 467 ret = -ENOMEM;
450 return -ENOMEM; 468 goto out_unmap;
451 } 469 }
452 470
453 /* Get the PSC ID */ 471 /* Get the PSC ID */
454 prop = of_get_property(op->node, "cell-index", &size); 472 prop = of_get_property(op->node, "cell-index", &size);
455 if (!prop || size < sizeof *prop) 473 if (!prop || size < sizeof *prop) {
456 return -ENODEV; 474 ret = -ENODEV;
475 goto out_free;
476 }
457 477
458 spin_lock_init(&psc_dma->lock); 478 spin_lock_init(&psc_dma->lock);
479 mutex_init(&psc_dma->mutex);
459 psc_dma->id = be32_to_cpu(*prop); 480 psc_dma->id = be32_to_cpu(*prop);
460 psc_dma->irq = irq; 481 psc_dma->irq = irq;
461 psc_dma->psc_regs = regs; 482 psc_dma->psc_regs = regs;
@@ -475,9 +496,8 @@ int mpc5200_audio_dma_create(struct of_device *op)
475 if (!psc_dma->capture.bcom_task || 496 if (!psc_dma->capture.bcom_task ||
476 !psc_dma->playback.bcom_task) { 497 !psc_dma->playback.bcom_task) {
477 dev_err(&op->dev, "Could not allocate bestcomm tasks\n"); 498 dev_err(&op->dev, "Could not allocate bestcomm tasks\n");
478 iounmap(regs); 499 ret = -ENODEV;
479 kfree(psc_dma); 500 goto out_free;
480 return -ENODEV;
481 } 501 }
482 502
483 /* Disable all interrupts and reset the PSC */ 503 /* Disable all interrupts and reset the PSC */
@@ -519,12 +539,8 @@ int mpc5200_audio_dma_create(struct of_device *op)
519 &psc_dma_bcom_irq_tx, IRQF_SHARED, 539 &psc_dma_bcom_irq_tx, IRQF_SHARED,
520 "psc-dma-playback", &psc_dma->playback); 540 "psc-dma-playback", &psc_dma->playback);
521 if (rc) { 541 if (rc) {
522 free_irq(psc_dma->irq, psc_dma); 542 ret = -ENODEV;
523 free_irq(psc_dma->capture.irq, 543 goto out_irq;
524 &psc_dma->capture);
525 free_irq(psc_dma->playback.irq,
526 &psc_dma->playback);
527 return -ENODEV;
528 } 544 }
529 545
530 /* Save what we've done so it can be found again later */ 546 /* Save what we've done so it can be found again later */
@@ -532,6 +548,15 @@ int mpc5200_audio_dma_create(struct of_device *op)
532 548
533 /* Tell the ASoC OF helpers about it */ 549 /* Tell the ASoC OF helpers about it */
534 return snd_soc_register_platform(&mpc5200_audio_dma_platform); 550 return snd_soc_register_platform(&mpc5200_audio_dma_platform);
551out_irq:
552 free_irq(psc_dma->irq, psc_dma);
553 free_irq(psc_dma->capture.irq, &psc_dma->capture);
554 free_irq(psc_dma->playback.irq, &psc_dma->playback);
555out_free:
556 kfree(psc_dma);
557out_unmap:
558 iounmap(regs);
559 return ret;
535} 560}
536EXPORT_SYMBOL_GPL(mpc5200_audio_dma_create); 561EXPORT_SYMBOL_GPL(mpc5200_audio_dma_create);
537 562