From: Herve Codina <herve.codina@bootlin.com>
To: Herve Codina <herve.codina@bootlin.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Qiang Zhao <qiang.zhao@nxp.com>,
Shengjiu Wang <shengjiu.wang@gmail.com>,
Xiubo Li <Xiubo.Lee@gmail.com>,
Fabio Estevam <festevam@gmail.com>,
Nicolin Chen <nicoleotsuka@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org,
linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [PATCH 05/10] ASoC: fsl: fsl_qmc_audio: Introduce qmc_audio_pcm_{read,write}_submit()
Date: Thu, 20 Jun 2024 10:42:52 +0200 [thread overview]
Message-ID: <20240620084300.397853-6-herve.codina@bootlin.com> (raw)
In-Reply-To: <20240620084300.397853-1-herve.codina@bootlin.com>
Submitting data to QMC channels is done in several places: transfer
completions and DAI start. The operation done is simple and consist in
one function call.
With the future introduction of support for non-interleaved mode,
submitting data will be more complex.
To avoid copy/paste of code in several places, introduce
qmc_audio_pcm_{read,write}_submit() whose goal is to handle this
data submission.
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
sound/soc/fsl/fsl_qmc_audio.c | 93 +++++++++++++++++------------------
1 file changed, 45 insertions(+), 48 deletions(-)
diff --git a/sound/soc/fsl/fsl_qmc_audio.c b/sound/soc/fsl/fsl_qmc_audio.c
index b07770257bad..36145f1ddbf1 100644
--- a/sound/soc/fsl/fsl_qmc_audio.c
+++ b/sound/soc/fsl/fsl_qmc_audio.c
@@ -90,11 +90,29 @@ static int qmc_audio_pcm_hw_params(struct snd_soc_component *component,
return 0;
}
+static void qmc_audio_pcm_write_complete(void *context);
+
+static int qmc_audio_pcm_write_submit(struct qmc_dai_prtd *prtd)
+{
+ int ret;
+
+ ret = qmc_chan_write_submit(prtd->qmc_dai->chan.qmc_chan,
+ prtd->ch_dma_addr_current, prtd->ch_dma_size,
+ qmc_audio_pcm_write_complete,
+ &prtd->qmc_dai->chan);
+ if (ret) {
+ dev_err(prtd->qmc_dai->dev, "write_submit failed %d\n",
+ ret);
+ return ret;
+ }
+
+ return 0;
+}
+
static void qmc_audio_pcm_write_complete(void *context)
{
struct qmc_dai_chan *chan = context;
struct qmc_dai_prtd *prtd;
- int ret;
prtd = chan->prtd_tx;
@@ -106,23 +124,33 @@ static void qmc_audio_pcm_write_complete(void *context)
if (prtd->ch_dma_addr_current >= prtd->ch_dma_addr_end)
prtd->ch_dma_addr_current = prtd->ch_dma_addr_start;
- ret = qmc_chan_write_submit(prtd->qmc_dai->chan.qmc_chan,
- prtd->ch_dma_addr_current, prtd->ch_dma_size,
- qmc_audio_pcm_write_complete,
- &prtd->qmc_dai->chan);
+ qmc_audio_pcm_write_submit(prtd);
+
+ snd_pcm_period_elapsed(prtd->substream);
+}
+
+static void qmc_audio_pcm_read_complete(void *context, size_t length, unsigned int flags);
+
+static int qmc_audio_pcm_read_submit(struct qmc_dai_prtd *prtd)
+{
+ int ret;
+
+ ret = qmc_chan_read_submit(prtd->qmc_dai->chan.qmc_chan,
+ prtd->ch_dma_addr_current, prtd->ch_dma_size,
+ qmc_audio_pcm_read_complete,
+ &prtd->qmc_dai->chan);
if (ret) {
- dev_err(prtd->qmc_dai->dev, "write_submit failed %d\n",
+ dev_err(prtd->qmc_dai->dev, "read_submit failed %d\n",
ret);
}
- snd_pcm_period_elapsed(prtd->substream);
+ return 0;
}
static void qmc_audio_pcm_read_complete(void *context, size_t length, unsigned int flags)
{
struct qmc_dai_chan *chan = context;
struct qmc_dai_prtd *prtd;
- int ret;
prtd = chan->prtd_rx;
@@ -139,14 +167,7 @@ static void qmc_audio_pcm_read_complete(void *context, size_t length, unsigned i
if (prtd->ch_dma_addr_current >= prtd->ch_dma_addr_end)
prtd->ch_dma_addr_current = prtd->ch_dma_addr_start;
- ret = qmc_chan_read_submit(prtd->qmc_dai->chan.qmc_chan,
- prtd->ch_dma_addr_current, prtd->ch_dma_size,
- qmc_audio_pcm_read_complete,
- &prtd->qmc_dai->chan);
- if (ret) {
- dev_err(prtd->qmc_dai->dev, "read_submit failed %d\n",
- ret);
- }
+ qmc_audio_pcm_read_submit(prtd);
snd_pcm_period_elapsed(prtd->substream);
}
@@ -168,15 +189,9 @@ static int qmc_audio_pcm_trigger(struct snd_soc_component *component,
prtd->qmc_dai->chan.prtd_tx = prtd;
/* Submit first chunk ... */
- ret = qmc_chan_write_submit(prtd->qmc_dai->chan.qmc_chan,
- prtd->ch_dma_addr_current, prtd->ch_dma_size,
- qmc_audio_pcm_write_complete,
- &prtd->qmc_dai->chan);
- if (ret) {
- dev_err(component->dev, "write_submit failed %d\n",
- ret);
+ ret = qmc_audio_pcm_write_submit(prtd);
+ if (ret)
return ret;
- }
/* ... prepare next one ... */
prtd->ch_dma_addr_current += prtd->ch_dma_size;
@@ -184,28 +199,16 @@ static int qmc_audio_pcm_trigger(struct snd_soc_component *component,
prtd->ch_dma_addr_current = prtd->ch_dma_addr_start;
/* ... and send it */
- ret = qmc_chan_write_submit(prtd->qmc_dai->chan.qmc_chan,
- prtd->ch_dma_addr_current, prtd->ch_dma_size,
- qmc_audio_pcm_write_complete,
- &prtd->qmc_dai->chan);
- if (ret) {
- dev_err(component->dev, "write_submit failed %d\n",
- ret);
+ ret = qmc_audio_pcm_write_submit(prtd);
+ if (ret)
return ret;
- }
} else {
prtd->qmc_dai->chan.prtd_rx = prtd;
/* Submit first chunk ... */
- ret = qmc_chan_read_submit(prtd->qmc_dai->chan.qmc_chan,
- prtd->ch_dma_addr_current, prtd->ch_dma_size,
- qmc_audio_pcm_read_complete,
- &prtd->qmc_dai->chan);
- if (ret) {
- dev_err(component->dev, "read_submit failed %d\n",
- ret);
+ ret = qmc_audio_pcm_read_submit(prtd);
+ if (ret)
return ret;
- }
/* ... prepare next one ... */
prtd->ch_dma_addr_current += prtd->ch_dma_size;
@@ -213,15 +216,9 @@ static int qmc_audio_pcm_trigger(struct snd_soc_component *component,
prtd->ch_dma_addr_current = prtd->ch_dma_addr_start;
/* ... and send it */
- ret = qmc_chan_read_submit(prtd->qmc_dai->chan.qmc_chan,
- prtd->ch_dma_addr_current, prtd->ch_dma_size,
- qmc_audio_pcm_read_complete,
- &prtd->qmc_dai->chan);
- if (ret) {
- dev_err(component->dev, "write_submit failed %d\n",
- ret);
+ ret = qmc_audio_pcm_read_submit(prtd);
+ if (ret)
return ret;
- }
}
break;
--
2.45.0
next prev parent reply other threads:[~2024-06-20 8:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 8:42 [PATCH 00/10] Add support for non-interleaved mode in qmc_audio Herve Codina
2024-06-20 8:42 ` [PATCH 01/10] ASoC: fsl: fsl_qmc_audio: Check devm_kasprintf() returned value Herve Codina
2024-06-20 8:42 ` [PATCH 02/10] ASoC: fsl: fsl_qmc_audio: Fix issues detected by checkpatch Herve Codina
2024-06-20 8:42 ` [PATCH 03/10] ASoC: fsl: fsl_qmc_audio: Split channel buffer and PCM pointer handling Herve Codina
2024-06-20 8:42 ` [PATCH 04/10] ASoC: fsl: fsl_qmc_audio: Identify the QMC channel involved in completion routines Herve Codina
2024-06-20 8:42 ` Herve Codina [this message]
2024-06-20 8:42 ` [PATCH 06/10] ASoC: fsl: fsl_qmc_audio: Introduce qmc_dai_constraints_interleaved() Herve Codina
2024-06-20 8:42 ` [PATCH 07/10] soc: fsl: cpm1: qmc: Introduce functions to get a channel from a phandle list Herve Codina
2024-06-20 8:42 ` [PATCH 08/10] soc: fsl: cpm1: qmc: Introduce qmc_chan_count_phandles() Herve Codina
2024-06-20 8:42 ` [PATCH 09/10] dt-bindings: sound: fsl,qmc-audio: Add support for multiple QMC channels per DAI Herve Codina
2024-06-27 21:25 ` Rob Herring (Arm)
2024-06-20 8:42 ` [PATCH 10/10] ASoC: fsl: fsl_qmc_audio: Add support for non-interleaved mode Herve Codina
2024-07-01 7:47 ` Herve Codina
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=20240620084300.397853-6-herve.codina@bootlin.com \
--to=herve.codina@bootlin.com \
--cc=Xiubo.Lee@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nicoleotsuka@gmail.com \
--cc=perex@perex.cz \
--cc=qiang.zhao@nxp.com \
--cc=robh@kernel.org \
--cc=shengjiu.wang@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tiwai@suse.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 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).