All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mohammad Rafi Shaik <quic_mohs@quicinc.com>
To: <krzysztof.kozlowski+dt@linaro.org>, <agross@kernel.org>,
	<andersson@kernel.org>, <lgirdwood@gmail.com>,
	<broonie@kernel.org>, <robh+dt@kernel.org>,
	<quic_plai@quicinc.com>, <bgoswami@quicinc.com>,
	<srinivas.kandagatla@linaro.org>, <quic_rohkumar@quicinc.com>,
	<linux-arm-msm@vger.kernel.org>, <alsa-devel@alsa-project.org>,
	<linux-kernel@vger.kernel.org>, <swboyd@chromium.org>,
	<judyhsiao@chromium.org>, <devicetree@vger.kernel.org>,
	<konrad.dybcio@linaro.org>
Cc: Mohammad Rafi Shaik <quic_mohs@quicinc.com>
Subject: [PATCH 10/14] ASoC: q6dsp: q6apm-dai: Add trigger/pointer compress DAI callbacks
Date: Wed, 1 Feb 2023 19:19:43 +0530	[thread overview]
Message-ID: <20230201134947.1638197-11-quic_mohs@quicinc.com> (raw)
In-Reply-To: <20230201134947.1638197-1-quic_mohs@quicinc.com>

Add q6apm trigger and pointer compress DAI callbacks to support
compress offload playback.

Signed-off-by: Mohammad Rafi Shaik <quic_mohs@quicinc.com>
Co-developed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/qcom/qdsp6/q6apm-dai.c | 68 ++++++++++++++++++++++++++++++++
 sound/soc/qcom/qdsp6/q6apm.h     |  1 +
 2 files changed, 69 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c
index 54e1aca61e4c..f43b60742e2f 100644
--- a/sound/soc/qcom/qdsp6/q6apm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
@@ -556,11 +556,79 @@ static int q6apm_dai_compr_get_codec_caps(struct snd_soc_component *component,
 
 	return 0;
 }
+
+static int q6apm_dai_compr_pointer(struct snd_soc_component *component,
+				   struct snd_compr_stream *stream,
+				   struct snd_compr_tstamp *tstamp)
+{
+	struct snd_compr_runtime *runtime = stream->runtime;
+	struct q6apm_dai_rtd *prtd = runtime->private_data;
+	unsigned long flags;
+
+	spin_lock_irqsave(&prtd->lock, flags);
+	tstamp->copied_total = prtd->copied_total;
+	tstamp->byte_offset = prtd->copied_total % prtd->pcm_size;
+	spin_unlock_irqrestore(&prtd->lock, flags);
+
+	return 0;
+}
+
+int q6apm_dai_compr_trigger(struct snd_soc_component *component,
+			    struct snd_compr_stream *stream, int cmd)
+{
+	struct snd_compr_runtime *runtime = stream->runtime;
+	struct q6apm_dai_rtd *prtd = runtime->private_data;
+	int ret = 0;
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+		ret = q6apm_write_async_compr(prtd->graph, prtd->pcm_count, 0, 0, NO_TIMESTAMP);
+		break;
+	case SNDRV_PCM_TRIGGER_STOP:
+		break;
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		break;
+	case SND_COMPR_TRIGGER_NEXT_TRACK:
+		prtd->next_track = true;
+		prtd->next_track_stream_id = (prtd->graph->id == 1 ? 2 : 1);
+		break;
+	case SND_COMPR_TRIGGER_DRAIN:
+	case SND_COMPR_TRIGGER_PARTIAL_DRAIN:
+		prtd->notify_on_drain = true;
+		break;
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+int q6apm_dai_compr_ack(struct snd_soc_component *component, struct snd_compr_stream *stream,
+			size_t count)
+{
+	struct snd_compr_runtime *runtime = stream->runtime;
+	struct q6apm_dai_rtd *prtd = runtime->private_data;
+	unsigned long flags;
+
+	spin_lock_irqsave(&prtd->lock, flags);
+	prtd->bytes_received += count;
+	spin_unlock_irqrestore(&prtd->lock, flags);
+
+	return count;
+}
+
 static const struct snd_compress_ops q6apm_dai_compress_ops = {
 	.open		= q6apm_dai_compr_open,
 	.free		= q6apm_dai_compr_free,
 	.get_caps	= q6apm_dai_compr_get_caps,
 	.get_codec_caps	= q6apm_dai_compr_get_codec_caps,
+	.pointer	= q6apm_dai_compr_pointer,
+	.trigger	= q6apm_dai_compr_trigger,
+	.ack		= q6apm_dai_compr_ack,
 };
 
 static const struct snd_soc_component_driver q6apm_fe_dai_component = {
diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h
index 630c2bca0f06..e0247e6e4fd2 100644
--- a/sound/soc/qcom/qdsp6/q6apm.h
+++ b/sound/soc/qcom/qdsp6/q6apm.h
@@ -46,6 +46,7 @@
 
 #define APM_MAX_SESSIONS			8
 #define APM_LAST_BUFFER_FLAG			BIT(30)
+#define NO_TIMESTAMP				0xFF00
 
 struct q6apm {
 	struct device *dev;
-- 
2.25.1


  parent reply	other threads:[~2023-02-01 13:53 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 13:49 [PATCH 00/14] Add support for compress offload and gapless playback Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 01/14] ALSA: compress: Update compress set params for " Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 02/14] ASoC: qcom: SC7280: audioreach: Add sc7280 hardware param fixup callback Mohammad Rafi Shaik
2023-02-01 14:40   ` Mark Brown
2023-02-01 14:40     ` Mark Brown
2023-02-03  6:33     ` Mohammad Rafi Shaik
2023-02-03  6:33       ` Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 03/14] ASoC: q6dsp: audioreach: Add placeholder decoder for compress playback Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 04/14] ASoC: q6dsp: audioreach: Add support for compress offload commands Mohammad Rafi Shaik
2023-02-01 15:18   ` kernel test robot
2023-02-01 15:18     ` kernel test robot
2023-02-01 13:49 ` [PATCH 05/14] ASoC: q6dsp: audioreach: Add support to set compress params Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 06/14] ASoC: q6dsp: audioreach: Add support for sending real module ID to ADSP Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 07/14] ASoC: q6dsp: q6apm-dai: Add async compress write support Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 08/14] ASoC: q6dsp: q6apm-dai: Add open/free compress DAI callbacks Mohammad Rafi Shaik
2023-02-01 16:09   ` kernel test robot
2023-02-01 16:09     ` kernel test robot
2023-02-01 13:49 ` [PATCH 09/14] ASoC: q6dsp: q6apm-dai: Add compress DAI and codec caps get callbacks Mohammad Rafi Shaik
2023-02-01 13:49 ` Mohammad Rafi Shaik [this message]
2023-02-01 16:50   ` [PATCH 10/14] ASoC: q6dsp: q6apm-dai: Add trigger/pointer compress DAI callbacks kernel test robot
2023-02-01 16:50     ` kernel test robot
2023-02-01 13:49 ` [PATCH 11/14] ASoC: q6dsp: q6apm-dai: Add compress set params and metadata " Mohammad Rafi Shaik
2023-02-01 15:18   ` kernel test robot
2023-02-01 15:18     ` kernel test robot
2023-02-01 13:49 ` [PATCH 12/14] ASoC: q6dsp: q6apm-dai: Add mmap and copy compress " Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 13/14] ASoC: qdsp6: audioreach: Add MP3, AAC and FLAC compress format support Mohammad Rafi Shaik
2023-02-01 13:49 ` [PATCH 14/14] ASoC: q6dsp: audioreach: Add gapless feature support Mohammad Rafi Shaik

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=20230201134947.1638197-11-quic_mohs@quicinc.com \
    --to=quic_mohs@quicinc.com \
    --cc=agross@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=bgoswami@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=judyhsiao@chromium.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_plai@quicinc.com \
    --cc=quic_rohkumar@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=swboyd@chromium.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 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.