All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Kuninori Morimoto <kuninori.morimoto.gx@gmail.com>
Cc: Simon <horms@verge.net.au>,
	Linux-ALSA <alsa-devel@alsa-project.org>,
	Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: Re: About snd_dmaengine_pcm_trigger()
Date: Wed, 05 Mar 2014 08:42:26 +0100	[thread overview]
Message-ID: <5316D562.3010901@metafoo.de> (raw)
In-Reply-To: <87eh2hql03.wl%kuninori.morimoto.gx@gmail.com>

On 03/05/2014 06:20 AM, Kuninori Morimoto wrote:
> Hi Mark, Lars and all
>
> I need your opinion
>
> Now, I'm working for ${LINUX}/sound/soc/sh/fsi and ${LINUX}/sound/soc/sh/rcar drirvers.
> These drivers are supporting DMAEngine transfer,
> but it is using original DMAEngine method,
> not using snd_dmaengine_pcm_trigger() or snd_dmaengine_pcm_register().
> I was requested to use it from Mark.
>
> The reason why I couldn't use it was our DMAEngine
> didn't have "cyclic" tranfer support which is used on
> dmaengine_pcm_prepare_and_submit()
> But now, I created cyclic support on our DMA driver (on my local PC at this point)
>
> Then, I noticed our drivers still can't use snd_dmaengine_pcm_xxx() method.
>
> 1st, our device needs PIO tranfer support too.
> Current PIO/DMA transfer are sharing many methods/functions.
> Code will become difficult to read if it is separated forcibly.
> (to using snd_dmaengine_pcm_xxx())

Ideally from a high level abstraction point of few PIO and DMA would be two 
completely separate components that can be used interchangeably. There might 
be hardware restrictions though that do not allow this.

>
> 2nd, our device DMA ON/OFF timing has relation ship to other register settings.
> Unfortunately, our device is picky, it needs like this
>
>                 HW init setting -> DMA ON -> HW start setting

What kind of HW init is this?

>
> It can be solved if snd_dmaengine_pcm_xxx() has callbacks,
> but many callbacks are needed...

You can wrap the snd_dmaengine_pcm functions in your pcm_ops callbacks, like 
this:

int sh_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
	init hw ...
	
	snd_dmaengine_pcm_trigger(substream, cmd);

	start hw ...
}

Each of the snd_dmaengine_pcm functions does pretty much one specific task. 
There is not much room for inserting callbacks.

>
> 3rd, our device needs special method on snd_pcm_ops
> int the future.
>

What kind of special ops?

>  From my point of view,
> our driver can replace to use "cyclic" DMA transfer
> instead of current original DMAEngine method.
> I guess, it is not difficult.
> But, using snd_dmaengine_pcm_xxx() is difficult.
>

I don't think using the snd_dmaengine_pcm helpers should be difficult, 
since, as I said, each of them perform one very specific task. If you'd 
directly call the dmaengine API you'd end up with pretty much the same code 
as the dmaengine PCM helpers. What's more of a challenge would be to use the 
generic dmaengine PCM driver.

I think the issue with the sound/soc/sh/ code is that there never was a 
clean separation between the DMA/PIO and the DAI configuration code. And 
especially with rcar you seem to be reimplementing a ASoC-like framework 
on-top of ASoC. Which makes it rather hard to reused generic code, since the 
generic code doesn't know about all the custom hooks and callbacks. The ASoC 
framework is not set in stone, if there is something missing to properly 
support your hardware you should try to extend the framework to support this 
rather than working around it in your drivers.

- Lars

  reply	other threads:[~2014-03-05  7:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05  5:20 About snd_dmaengine_pcm_trigger() Kuninori Morimoto
2014-03-05  7:42 ` Lars-Peter Clausen [this message]
2014-03-05  8:32   ` Kuninori Morimoto
2014-03-05  9:20     ` Lars-Peter Clausen
2014-03-06  0:22       ` Kuninori Morimoto
2014-03-06  4:36         ` Mark Brown
2014-03-06  4:39           ` Kuninori Morimoto
2014-03-11  4:47       ` Kuninori Morimoto
2014-03-11  9:47         ` Lars-Peter Clausen
2014-03-11  9:55           ` Mark Brown
2014-03-12  0:28             ` Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5316D562.3010901@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=horms@verge.net.au \
    --cc=kuninori.morimoto.gx@gmail.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.