linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lubomir Rintel <lkundrak@v3.sk>
To: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	Lubomir Rintel <lkundrak@v3.sk>
Subject: [PATCH 05/11] ASoC: mmp-sspa: Add support for soc-generic-dmaengine-pcm
Date: Mon, 11 May 2020 23:01:28 +0200	[thread overview]
Message-ID: <20200511210134.1224532-6-lkundrak@v3.sk> (raw)
In-Reply-To: <20200511210134.1224532-1-lkundrak@v3.sk>

This makes the driver usable with the mmp_tdma drier via
soc-generic-dmaengine-pcm. This is conditionalized on DT node (support
for DT is added by a later patch).

A custom mmap callback that creates a NC mapping is used instead of the
default WC one, because with write-combining some bytes don't seem to
make it through for reasons unknown to me.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 sound/soc/pxa/mmp-sspa.c | 57 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c
index 421ffa9fa7b1..6e4b63d0c589 100644
--- a/sound/soc/pxa/mmp-sspa.c
+++ b/sound/soc/pxa/mmp-sspa.c
@@ -386,8 +386,54 @@ static struct snd_soc_dai_driver mmp_sspa_dai = {
 	.ops = &mmp_sspa_dai_ops,
 };
 
+#define MMP_PCM_INFO (SNDRV_PCM_INFO_MMAP |	\
+		SNDRV_PCM_INFO_MMAP_VALID |	\
+		SNDRV_PCM_INFO_INTERLEAVED |	\
+		SNDRV_PCM_INFO_PAUSE |		\
+		SNDRV_PCM_INFO_RESUME |		\
+		SNDRV_PCM_INFO_NO_PERIOD_WAKEUP)
+
+static const struct snd_pcm_hardware mmp_pcm_hardware[] = {
+	{
+		.info			= MMP_PCM_INFO,
+		.period_bytes_min	= 1024,
+		.period_bytes_max	= 2048,
+		.periods_min		= 2,
+		.periods_max		= 32,
+		.buffer_bytes_max	= 4096,
+		.fifo_size		= 32,
+	},
+	{
+		.info			= MMP_PCM_INFO,
+		.period_bytes_min	= 1024,
+		.period_bytes_max	= 2048,
+		.periods_min		= 2,
+		.periods_max		= 32,
+		.buffer_bytes_max	= 4096,
+		.fifo_size		= 32,
+	},
+};
+
+static const struct snd_dmaengine_pcm_config mmp_pcm_config = {
+	.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
+	.pcm_hardware = mmp_pcm_hardware,
+	.prealloc_buffer_size = 4096,
+};
+
+static int mmp_pcm_mmap(struct snd_soc_component *component,
+			struct snd_pcm_substream *substream,
+			struct vm_area_struct *vma)
+{
+	vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+	return remap_pfn_range(vma, vma->vm_start,
+		substream->dma_buffer.addr >> PAGE_SHIFT,
+		vma->vm_end - vma->vm_start, vma->vm_page_prot);
+}
+
 static const struct snd_soc_component_driver mmp_sspa_component = {
 	.name		= "mmp-sspa",
+	.mmap		= mmp_pcm_mmap,
 };
 
 static int asoc_mmp_sspa_probe(struct platform_device *pdev)
@@ -425,10 +471,21 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
 	priv->dai_fmt = (unsigned int) -1;
 	platform_set_drvdata(pdev, priv);
 
+	priv->playback_dma_data.maxburst = 4;
+	priv->capture_dma_data.maxburst = 4;
 	/* You know, these addresses are actually ignored. */
 	priv->playback_dma_data.addr = SSPA_TXD;
 	priv->capture_dma_data.addr = SSPA_RXD;
 
+	if (pdev->dev.of_node) {
+		int ret;
+
+		ret = devm_snd_dmaengine_pcm_register(&pdev->dev,
+						      &mmp_pcm_config, 0);
+		if (ret)
+			return ret;
+	}
+
 	return devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component,
 					       &mmp_sspa_dai, 1);
 }
-- 
2.26.2


  parent reply	other threads:[~2020-05-11 21:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 21:01 [PATCH 00/11] Make sound work on DT-based MMP2 machines Lubomir Rintel
2020-05-11 21:01 ` [PATCH 01/11] ASoC: mmp-sspa: Flip SNDRV_PCM_FMTBIT_S24_3LE on Lubomir Rintel
2020-05-12 16:45   ` Mark Brown
2020-05-19 19:52   ` Mark Brown
2020-05-11 21:01 ` [PATCH 02/11] ASoC: mmp-sspa: Drop S20_3LE case Lubomir Rintel
2020-05-11 21:01 ` [PATCH 03/11] ASoC: mmp-sspa: A trivial typo fix Lubomir Rintel
2020-05-11 21:01 ` [PATCH 04/11] ASoC: mmp-sspa: Get rid of dma_params and phys_base Lubomir Rintel
2020-05-11 21:01 ` Lubomir Rintel [this message]
2020-05-11 21:01 ` [PATCH 06/11] ASoC: mmp-sspa: Remove the embedded struct ssp_device Lubomir Rintel
2020-05-11 21:01 ` [PATCH 07/11] ASoC: mmp-sspa: Prepare/unprepare the clocks Lubomir Rintel
2020-05-12 12:45   ` Mark Brown
2020-05-12 15:36     ` Lubomir Rintel
2020-05-12 16:29       ` Mark Brown
2020-05-11 21:01 ` [PATCH 08/11] ASoC: mmp-sspa: Add support for the runtime power management Lubomir Rintel
2020-05-11 21:01 ` [PATCH 09/11] ASoC: mmp-sspa: Set appropriate bus format for given bit width Lubomir Rintel
2020-05-11 21:01 ` [PATCH 10/11] dt-bindings: sound: Add Marvell MMP SSPA binding Lubomir Rintel
2020-05-19 18:37   ` Rob Herring
2020-05-11 21:01 ` [PATCH 11/11] ASoC: mmp-sspa: Add Device Tree support Lubomir Rintel

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=20200511210134.1224532-6-lkundrak@v3.sk \
    --to=lkundrak@v3.sk \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    /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 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).