Skip to content

Commit 7dfb491

Browse files
morimotobroonie
authored andcommitted
ASoC: rsnd: update Audio DMA path search method
Current rsnd driver is assuming Audio DMAC / Audio DMAC peri peri are used from SSI/SSIU/SRC/DVC. But we will add CTU/MIX to this driver. Then, current DMA path searching method is not understandable, and good enough for this purpose. This patch update DMA path search method, more simply. Signed-off-by: Kuninori Morimoto <[email protected]> Tested-by: Keita Kobayashi <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 78edead commit 7dfb491

File tree

1 file changed

+53
-35
lines changed

1 file changed

+53
-35
lines changed

sound/soc/sh/rcar/dma.c

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static dma_addr_t rsnd_dma_addr(struct rsnd_dai_stream *io,
494494
return rsnd_gen2_dma_addr(io, mod, is_play, is_from);
495495
}
496496

497-
#define MOD_MAX 4 /* MEM/SSI/SRC/DVC */
497+
#define MOD_MAX (RSND_MOD_MAX + 1) /* +Memory */
498498
static void rsnd_dma_of_path(struct rsnd_dma *dma,
499499
struct rsnd_dai_stream *io,
500500
int is_play,
@@ -506,53 +506,71 @@ static void rsnd_dma_of_path(struct rsnd_dma *dma,
506506
struct rsnd_mod *src = rsnd_io_to_mod_src(io);
507507
struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
508508
struct rsnd_mod *mod[MOD_MAX];
509-
int i, index;
509+
struct rsnd_mod *mod_start, *mod_end;
510+
struct rsnd_priv *priv = rsnd_mod_to_priv(this);
511+
struct device *dev = rsnd_priv_to_dev(priv);
512+
int nr, i;
510513

514+
if (!ssi)
515+
return;
511516

512-
for (i = 0; i < MOD_MAX; i++)
517+
nr = 0;
518+
for (i = 0; i < MOD_MAX; i++) {
513519
mod[i] = NULL;
520+
nr += !!rsnd_io_to_mod(io, i);
521+
}
514522

515523
/*
516-
* in play case...
524+
* [S] -*-> [E]
525+
* [S] -*-> SRC -o-> [E]
526+
* [S] -*-> SRC -> DVC -o-> [E]
527+
* [S] -*-> SRC -> CTU -> MIX -> DVC -o-> [E]
528+
*
529+
* playback [S] = mem
530+
* [E] = SSI
517531
*
518-
* src -> dst
532+
* capture [S] = SSI
533+
* [E] = mem
519534
*
520-
* mem -> SSI
521-
* mem -> SRC -> SSI
522-
* mem -> SRC -> DVC -> SSI
535+
* -*-> Audio DMAC
536+
* -o-> Audio DMAC peri peri
523537
*/
524-
mod[0] = NULL; /* for "mem" */
525-
index = 1;
526-
for (i = 1; i < MOD_MAX; i++) {
527-
if (!src) {
528-
mod[i] = ssi;
529-
} else if (!dvc) {
530-
mod[i] = src;
531-
src = NULL;
532-
} else {
533-
if ((!is_play) && (this == src))
534-
this = dvc;
538+
mod_start = (is_play) ? NULL : ssi;
539+
mod_end = (is_play) ? ssi : NULL;
535540

536-
mod[i] = (is_play) ? src : dvc;
537-
i++;
538-
mod[i] = (is_play) ? dvc : src;
541+
mod[0] = mod_start;
542+
for (i = 1; i < nr; i++) {
543+
if (src) {
544+
mod[i] = src;
539545
src = NULL;
546+
} else if (dvc) {
547+
mod[i] = dvc;
540548
dvc = NULL;
541549
}
542-
543-
if (mod[i] == this)
544-
index = i;
545-
546-
if (mod[i] == ssi)
547-
break;
548550
}
551+
mod[i] = mod_end;
549552

550-
if (is_play) {
551-
*mod_from = mod[index - 1];
552-
*mod_to = mod[index];
553+
/*
554+
* | SSI | SRC |
555+
* -------------+-----+-----+
556+
* is_play | o | * |
557+
* !is_play | * | o |
558+
*/
559+
if ((this == ssi) == (is_play)) {
560+
*mod_from = mod[nr - 1];
561+
*mod_to = mod[nr];
553562
} else {
554-
*mod_from = mod[index];
555-
*mod_to = mod[index - 1];
563+
*mod_from = mod[0];
564+
*mod_to = mod[1];
565+
}
566+
567+
dev_dbg(dev, "module connection (this is %s[%d])\n",
568+
rsnd_mod_name(this), rsnd_mod_id(this));
569+
for (i = 0; i <= nr; i++) {
570+
dev_dbg(dev, " %s[%d]%s\n",
571+
rsnd_mod_name(mod[i]), rsnd_mod_id(mod[i]),
572+
(mod[i] == *mod_from) ? " from" :
573+
(mod[i] == *mod_to) ? " to" : "");
556574
}
557575
}
558576

@@ -580,8 +598,8 @@ void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
580598

581599
int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id)
582600
{
583-
struct rsnd_mod *mod_from;
584-
struct rsnd_mod *mod_to;
601+
struct rsnd_mod *mod_from = NULL;
602+
struct rsnd_mod *mod_to = NULL;
585603
struct rsnd_priv *priv = rsnd_io_to_priv(io);
586604
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
587605
struct device *dev = rsnd_priv_to_dev(priv);

0 commit comments

Comments
 (0)