* [PATCH v3] ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller
@ 2015-06-02 20:09 Jyri Sarha
2015-06-09 14:52 ` Peter Ujfalusi
[not found] ` <e5dbf0a5fbb101792fd106461929c4b814dffc06.1433275670.git.jsarha-l0cyMroinI0@public.gmane.org>
0 siblings, 2 replies; 3+ messages in thread
From: Jyri Sarha @ 2015-06-02 20:09 UTC (permalink / raw)
To: alsa-devel, devicetree, linux-omap
Cc: peter.ujfalusi, broonie, liam.r.girdwood, bcousson, misael.lopez,
Jyri Sarha
Find the configured DMA controller by asking for a DMA channel in the
probe phase and releasing it right after. The controller device can be
found via the dma_chan struct and the controller is recognized from
the compatible property of its device node. The patch assumes EDMA if
there is no device node.
Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
Changes since v2:
- Print only one error message if DMA "probing" fails
and none in case of -EPROBE_DEFER
Changes since first patch version:
- Change enum names from MCASP_?DMA to PCM_?DMA
- Return PCM_EDMA if !mcasp->dev->of_node
- Do not ignore possible error code returned by
davinci_mcasp_get_dma_type()
sound/soc/davinci/davinci-mcasp.c | 70 +++++++++++++++++++++++++++++++++------
1 file changed, 60 insertions(+), 10 deletions(-)
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index d793494..a73cd57 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -1565,6 +1565,49 @@ static int davinci_mcasp_init_ch_constraints(struct davinci_mcasp *mcasp)
return ret;
}
+enum {
+ PCM_EDMA,
+ PCM_SDMA,
+};
+static const char *sdma_prefix = "ti,omap";
+
+static int davinci_mcasp_get_dma_type(struct davinci_mcasp *mcasp)
+{
+ struct dma_chan *chan;
+ const char *tmp;
+ int ret = PCM_EDMA;
+
+ if (!mcasp->dev->of_node)
+ return PCM_EDMA;
+
+ tmp = mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data;
+ chan = dma_request_slave_channel_reason(mcasp->dev, tmp);
+ if (IS_ERR(chan)) {
+ if (PTR_ERR(chan) != -EPROBE_DEFER)
+ dev_err(mcasp->dev,
+ "Can't verify DMA configuration (%ld)\n",
+ PTR_ERR(chan));
+ return PTR_ERR(chan);
+ }
+ BUG_ON(!chan->device || !chan->device->dev);
+
+ if (chan->device->dev->of_node)
+ ret = of_property_read_string(chan->device->dev->of_node,
+ "compatible", &tmp);
+ else
+ dev_dbg(mcasp->dev, "DMA controller has no of-node\n");
+
+ dma_release_channel(chan);
+ if (ret)
+ return ret;
+
+ dev_dbg(mcasp->dev, "DMA controller compatible = \"%s\"\n", tmp);
+ if (!strncmp(tmp, sdma_prefix, strlen(sdma_prefix)))
+ return PCM_SDMA;
+
+ return PCM_EDMA;
+}
+
static int davinci_mcasp_probe(struct platform_device *pdev)
{
struct snd_dmaengine_dai_dma_data *dma_data;
@@ -1763,27 +1806,34 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
if (ret != 0)
goto err;
- switch (mcasp->version) {
+ ret = davinci_mcasp_get_dma_type(mcasp);
+ switch (ret) {
+ case PCM_EDMA:
#if IS_BUILTIN(CONFIG_SND_EDMA_SOC) || \
(IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
IS_MODULE(CONFIG_SND_EDMA_SOC))
- case MCASP_VERSION_1:
- case MCASP_VERSION_2:
- case MCASP_VERSION_3:
ret = edma_pcm_platform_register(&pdev->dev);
- break;
+#else
+ dev_err(&pdev->dev, "Missing SND_EDMA_SOC\n");
+ ret = -EINVAL;
+ goto err;
#endif
+ break;
+ case PCM_SDMA:
#if IS_BUILTIN(CONFIG_SND_OMAP_SOC) || \
(IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
IS_MODULE(CONFIG_SND_OMAP_SOC))
- case MCASP_VERSION_4:
ret = omap_pcm_platform_register(&pdev->dev);
- break;
+#else
+ dev_err(&pdev->dev, "Missing SND_SDMA_SOC\n");
+ ret = -EINVAL;
+ goto err;
#endif
+ break;
default:
- dev_err(&pdev->dev, "Invalid McASP version: %d\n",
- mcasp->version);
- ret = -EINVAL;
+ dev_err(&pdev->dev, "No DMA controller found (%d)\n", ret);
+ case -EPROBE_DEFER:
+ goto err;
break;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller
2015-06-02 20:09 [PATCH v3] ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller Jyri Sarha
@ 2015-06-09 14:52 ` Peter Ujfalusi
[not found] ` <e5dbf0a5fbb101792fd106461929c4b814dffc06.1433275670.git.jsarha-l0cyMroinI0@public.gmane.org>
1 sibling, 0 replies; 3+ messages in thread
From: Peter Ujfalusi @ 2015-06-09 14:52 UTC (permalink / raw)
To: Jyri Sarha, alsa-devel, devicetree, linux-omap
Cc: broonie, liam.r.girdwood, bcousson, misael.lopez
On 06/02/2015 11:09 PM, Jyri Sarha wrote:
> Find the configured DMA controller by asking for a DMA channel in the
> probe phase and releasing it right after. The controller device can be
> found via the dma_chan struct and the controller is recognized from
> the compatible property of its device node. The patch assumes EDMA if
> there is no device node.
Thanks Jyri,
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>
> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> ---
> Changes since v2:
> - Print only one error message if DMA "probing" fails
> and none in case of -EPROBE_DEFER
>
> Changes since first patch version:
> - Change enum names from MCASP_?DMA to PCM_?DMA
> - Return PCM_EDMA if !mcasp->dev->of_node
> - Do not ignore possible error code returned by
> davinci_mcasp_get_dma_type()
>
> sound/soc/davinci/davinci-mcasp.c | 70 +++++++++++++++++++++++++++++++++------
> 1 file changed, 60 insertions(+), 10 deletions(-)
>
> diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
> index d793494..a73cd57 100644
> --- a/sound/soc/davinci/davinci-mcasp.c
> +++ b/sound/soc/davinci/davinci-mcasp.c
> @@ -1565,6 +1565,49 @@ static int davinci_mcasp_init_ch_constraints(struct davinci_mcasp *mcasp)
> return ret;
> }
>
> +enum {
> + PCM_EDMA,
> + PCM_SDMA,
> +};
> +static const char *sdma_prefix = "ti,omap";
> +
> +static int davinci_mcasp_get_dma_type(struct davinci_mcasp *mcasp)
> +{
> + struct dma_chan *chan;
> + const char *tmp;
> + int ret = PCM_EDMA;
> +
> + if (!mcasp->dev->of_node)
> + return PCM_EDMA;
> +
> + tmp = mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data;
> + chan = dma_request_slave_channel_reason(mcasp->dev, tmp);
> + if (IS_ERR(chan)) {
> + if (PTR_ERR(chan) != -EPROBE_DEFER)
> + dev_err(mcasp->dev,
> + "Can't verify DMA configuration (%ld)\n",
> + PTR_ERR(chan));
> + return PTR_ERR(chan);
> + }
> + BUG_ON(!chan->device || !chan->device->dev);
> +
> + if (chan->device->dev->of_node)
> + ret = of_property_read_string(chan->device->dev->of_node,
> + "compatible", &tmp);
> + else
> + dev_dbg(mcasp->dev, "DMA controller has no of-node\n");
> +
> + dma_release_channel(chan);
> + if (ret)
> + return ret;
> +
> + dev_dbg(mcasp->dev, "DMA controller compatible = \"%s\"\n", tmp);
> + if (!strncmp(tmp, sdma_prefix, strlen(sdma_prefix)))
> + return PCM_SDMA;
> +
> + return PCM_EDMA;
> +}
> +
> static int davinci_mcasp_probe(struct platform_device *pdev)
> {
> struct snd_dmaengine_dai_dma_data *dma_data;
> @@ -1763,27 +1806,34 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
> if (ret != 0)
> goto err;
>
> - switch (mcasp->version) {
> + ret = davinci_mcasp_get_dma_type(mcasp);
> + switch (ret) {
> + case PCM_EDMA:
> #if IS_BUILTIN(CONFIG_SND_EDMA_SOC) || \
> (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
> IS_MODULE(CONFIG_SND_EDMA_SOC))
> - case MCASP_VERSION_1:
> - case MCASP_VERSION_2:
> - case MCASP_VERSION_3:
> ret = edma_pcm_platform_register(&pdev->dev);
> - break;
> +#else
> + dev_err(&pdev->dev, "Missing SND_EDMA_SOC\n");
> + ret = -EINVAL;
> + goto err;
> #endif
> + break;
> + case PCM_SDMA:
> #if IS_BUILTIN(CONFIG_SND_OMAP_SOC) || \
> (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
> IS_MODULE(CONFIG_SND_OMAP_SOC))
> - case MCASP_VERSION_4:
> ret = omap_pcm_platform_register(&pdev->dev);
> - break;
> +#else
> + dev_err(&pdev->dev, "Missing SND_SDMA_SOC\n");
> + ret = -EINVAL;
> + goto err;
> #endif
> + break;
> default:
> - dev_err(&pdev->dev, "Invalid McASP version: %d\n",
> - mcasp->version);
> - ret = -EINVAL;
> + dev_err(&pdev->dev, "No DMA controller found (%d)\n", ret);
> + case -EPROBE_DEFER:
> + goto err;
> break;
> }
>
>
--
Péter
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller
[not found] ` <e5dbf0a5fbb101792fd106461929c4b814dffc06.1433275670.git.jsarha-l0cyMroinI0@public.gmane.org>
@ 2015-06-09 18:01 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2015-06-09 18:01 UTC (permalink / raw)
To: Jyri Sarha
Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA, peter.ujfalusi-l0cyMroinI0,
liam.r.girdwood-VuQAYsv1563Yd54FQh9/CA,
bcousson-rdvid1DuHRBWk0Htik3J/w, misael.lopez-l0cyMroinI0
[-- Attachment #1: Type: text/plain, Size: 392 bytes --]
On Tue, Jun 02, 2015 at 11:09:34PM +0300, Jyri Sarha wrote:
> Find the configured DMA controller by asking for a DMA channel in the
> probe phase and releasing it right after. The controller device can be
> found via the dma_chan struct and the controller is recognized from
> the compatible property of its device node. The patch assumes EDMA if
> there is no device node.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-09 18:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-02 20:09 [PATCH v3] ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller Jyri Sarha
2015-06-09 14:52 ` Peter Ujfalusi
[not found] ` <e5dbf0a5fbb101792fd106461929c4b814dffc06.1433275670.git.jsarha-l0cyMroinI0@public.gmane.org>
2015-06-09 18:01 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).