ASoC: rsnd: use mod base common method on DMA phase2

Renesas sound needs many devices
(SSI/SSIU/SRC/CTU/MIX/DVC/CMD/AudioDMAC/AudioDMACpp).
SSI/SRC/CTU/MIX/DVC are implemented as module.
SSI parent, SSIU are implemented as part of SSI
CMD is implemented as part of CTU/MIX/DVC
AudioDMAC/AudioDMACpp are implemented as part of SSI/SRC
It is nice sense that these all devices are implemented as mod.

DMA will be implemented as module. Then rsnd_dma_ops will be rebased
to rsnd_mod_ops, but these are similar, but different function.
This patch modify rsnd_dma_ops same style as rsnd_mod_ops.
This is prepare for final merge

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2015-10-26 08:42:46 +00:00 committed by Mark Brown
parent 940e947926
commit 76c80b5b3f
4 changed files with 58 additions and 28 deletions

View File

@ -52,9 +52,15 @@ struct rsnd_dma_ctrl {
struct rsnd_dma_ops {
char *name;
void (*start)(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
void (*stop)(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
void (*quit)(struct rsnd_dai_stream *io, struct rsnd_dma *dma);
void (*start)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
void (*stop)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
void (*quit)(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
};
#define rsnd_priv_to_dmac(p) ((struct rsnd_dma_ctrl *)(p)->dma)
@ -101,18 +107,23 @@ static void rsnd_dmaen_complete(void *data)
rsnd_mod_interrupt(mod, __rsnd_dmaen_complete);
}
static void rsnd_dmaen_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
static void rsnd_dmaen_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
dmaengine_terminate_all(dmaen->chan);
}
static void rsnd_dmaen_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
static void rsnd_dmaen_start(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
struct rsnd_mod *user_mod = dma->user_mod;
struct rsnd_priv *priv = rsnd_io_to_priv(io);
struct snd_pcm_substream *substream = io->substream;
struct device *dev = rsnd_priv_to_dev(priv);
struct dma_async_tx_descriptor *desc;
@ -229,7 +240,7 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io,
return 0;
rsnd_dma_attach_err:
rsnd_dma_quit(io, rsnd_mod_get(dma));
rsnd_dma_quit(rsnd_mod_get(dma), io, priv);
rsnd_dma_channel_err:
/*
@ -241,8 +252,11 @@ static int rsnd_dmaen_attach(struct rsnd_dai_stream *io,
return -EAGAIN;
}
static void rsnd_dmaen_quit(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
static void rsnd_dmaen_quit(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmaen *dmaen = rsnd_dma_to_dmaen(dma);
if (dmaen->chan)
@ -352,8 +366,11 @@ static u32 rsnd_dmapp_read(struct rsnd_dma *dma, u32 reg)
return ioread32(rsnd_dmapp_addr(dmac, dma, reg));
}
static void rsnd_dmapp_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
static void rsnd_dmapp_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
int i;
rsnd_dmapp_write(dma, 0, PDMACHCR);
@ -365,8 +382,11 @@ static void rsnd_dmapp_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
}
}
static void rsnd_dmapp_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma)
static void rsnd_dmapp_start(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma);
rsnd_dmapp_write(dma, dma->src_addr, PDMASAR);
@ -388,8 +408,6 @@ static int rsnd_dmapp_attach(struct rsnd_dai_stream *io,
dmac->dmapp_num++;
rsnd_dmapp_stop(io, dma);
dev_dbg(dev, "id/src/dst/chcr = %d/%pad/%pad/%08x\n",
dmapp->dmapp_id, &dma->src_addr, &dma->dst_addr, dmapp->chcr);
@ -609,30 +627,36 @@ static void rsnd_dma_of_path(struct rsnd_mod *this,
}
}
void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_mod *mod)
void rsnd_dma_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
dma->ops->stop(io, dma);
dma->ops->stop(mod, io, priv);
}
void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_mod *mod)
void rsnd_dma_start(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
dma->ops->start(io, dma);
dma->ops->start(mod, io, priv);
}
void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_mod *mod)
void rsnd_dma_quit(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv)
{
struct rsnd_dma *dma = rsnd_mod_to_dma(mod);
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv);
if (!dmac)
return;
dma->ops->quit(io, dma);
dma->ops->quit(mod, io, priv);
}
static struct rsnd_mod_ops rsnd_dma_ops = {

View File

@ -193,11 +193,17 @@ void rsnd_path_parse(struct rsnd_priv *priv,
/*
* R-Car DMA
*/
void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
void rsnd_dma_start(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
void rsnd_dma_stop(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
void rsnd_dma_quit(struct rsnd_mod *mod,
struct rsnd_dai_stream *io,
struct rsnd_priv *priv);
struct rsnd_mod *rsnd_dma_attach(struct rsnd_dai_stream *io,
struct rsnd_mod *mod, int id);
void rsnd_dma_quit(struct rsnd_dai_stream *io, struct rsnd_mod *mod);
int rsnd_dma_probe(struct platform_device *pdev,
const struct rsnd_of_data *of_data,
struct rsnd_priv *priv);

View File

@ -843,7 +843,7 @@ static int rsnd_src_remove_gen2(struct rsnd_mod *mod,
{
struct rsnd_src *src = rsnd_mod_to_src(mod);
rsnd_dma_quit(io, rsnd_src_to_dma(src));
rsnd_dma_quit(rsnd_src_to_dma(src), io, priv);
return 0;
}
@ -875,7 +875,7 @@ static int rsnd_src_start_gen2(struct rsnd_mod *mod,
{
struct rsnd_src *src = rsnd_mod_to_src(mod);
rsnd_dma_start(io, rsnd_src_to_dma(src));
rsnd_dma_start(rsnd_src_to_dma(src), io, priv);
return _rsnd_src_start_gen2(mod, io);
}
@ -889,7 +889,7 @@ static int rsnd_src_stop_gen2(struct rsnd_mod *mod,
ret = _rsnd_src_stop_gen2(mod);
rsnd_dma_stop(io, rsnd_src_to_dma(src));
rsnd_dma_stop(rsnd_src_to_dma(src), io, priv);
return ret;
}

View File

@ -596,7 +596,7 @@ static int rsnd_ssi_dma_remove(struct rsnd_mod *mod,
struct device *dev = rsnd_priv_to_dev(priv);
int irq = ssi->info->irq;
rsnd_dma_quit(io, rsnd_ssi_to_dma(ssi));
rsnd_dma_quit(rsnd_ssi_to_dma(ssi), io, priv);
/* PIO will request IRQ again */
devm_free_irq(dev, irq, mod);
@ -632,7 +632,7 @@ static int rsnd_ssi_dma_start(struct rsnd_mod *mod,
struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
struct rsnd_mod *dma = rsnd_ssi_to_dma(ssi);
rsnd_dma_start(io, dma);
rsnd_dma_start(dma, io, priv);
rsnd_ssi_start(mod, io, priv);
@ -648,7 +648,7 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod,
rsnd_ssi_stop(mod, io, priv);
rsnd_dma_stop(io, dma);
rsnd_dma_stop(dma, io, priv);
return 0;
}