Skip to content

Commit 2dcdf57

Browse files
Peter Ujfalusibroonie
authored andcommitted
dmaengine: omap: Add support for pause/resume in cyclic dma mode
The audio stack used omap_stop_dma/omap_start_dma to pause/resume the DMA. This method has been used for years on OMAP based products. We only allow pause/resume when the DMA has been configured in cyclic mode which is used by the audio stack. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Vinod Koul <vinod.koul@linux.intel.com> Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
1 parent ccffa38 commit 2dcdf57

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

‎drivers/dma/omap-dma.c‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct omap_chan {
3434
struct dma_slave_config cfg;
3535
unsigned dma_sig;
3636
bool cyclic;
37+
bool paused;
3738

3839
int dma_ch;
3940
struct omap_desc *desc;
@@ -470,11 +471,14 @@ static int omap_dma_terminate_all(struct omap_chan *c)
470471
*/
471472
if (c->desc) {
472473
c->desc = NULL;
473-
omap_stop_dma(c->dma_ch);
474+
/* Avoid stopping the dma twice */
475+
if (!c->paused)
476+
omap_stop_dma(c->dma_ch);
474477
}
475478

476479
if (c->cyclic) {
477480
c->cyclic = false;
481+
c->paused = false;
478482
omap_dma_unlink_lch(c->dma_ch, c->dma_ch);
479483
}
480484

@@ -487,14 +491,30 @@ static int omap_dma_terminate_all(struct omap_chan *c)
487491

488492
static int omap_dma_pause(struct omap_chan *c)
489493
{
490-
/* FIXME: not supported by platform private API */
491-
return -EINVAL;
494+
/* Pause/Resume only allowed with cyclic mode */
495+
if (!c->cyclic)
496+
return -EINVAL;
497+
498+
if (!c->paused) {
499+
omap_stop_dma(c->dma_ch);
500+
c->paused = true;
501+
}
502+
503+
return 0;
492504
}
493505

494506
static int omap_dma_resume(struct omap_chan *c)
495507
{
496-
/* FIXME: not supported by platform private API */
497-
return -EINVAL;
508+
/* Pause/Resume only allowed with cyclic mode */
509+
if (!c->cyclic)
510+
return -EINVAL;
511+
512+
if (c->paused) {
513+
omap_start_dma(c->dma_ch);
514+
c->paused = false;
515+
}
516+
517+
return 0;
498518
}
499519

500520
static int omap_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,

0 commit comments

Comments
 (0)