devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	bjorn.andersson@linaro.org, broonie@kernel.org, robh@kernel.org
Cc: plai@codeaurora.org, tiwai@suse.de, devicetree@vger.kernel.org,
	perex@perex.cz, alsa-devel@alsa-project.org, lgirdwood@gmail.com,
	bgoswami@codeaurora.org
Subject: Re: [PATCH v8 19/22] ASoC: qdsp6: audioreach: add q6apm-dai support
Date: Tue, 28 Sep 2021 10:33:19 +0100	[thread overview]
Message-ID: <c12ac2f5-bc53-ac0c-6ed0-f748a62015ac@linaro.org> (raw)
In-Reply-To: <20605122-e6b4-1b5f-003a-96a74306f984@linux.intel.com>



On 27/09/2021 17:25, Pierre-Louis Bossart wrote:
> 
>> +static int q6apm_dai_prepare(struct snd_soc_component *component,
>> +			     struct snd_pcm_substream *substream)
>> +{
>> +	struct snd_pcm_runtime *runtime = substream->runtime;
>> +	struct q6apm_dai_rtd *prtd = runtime->private_data;
>> +	struct audioreach_module_config cfg;
>> +	struct device *dev = component->dev;
>> +	struct q6apm_dai_data *pdata;
>> +	int ret;
>> +
>> +	pdata = snd_soc_component_get_drvdata(component);
>> +	if (!pdata)
>> +		return -EINVAL;
>> +
>> +	if (!prtd || !prtd->graph) {
>> +		dev_err(dev, "%s: private data null or audio client freed\n", __func__);
>> +		return -EINVAL;
>> +	}
>> +
>> +	cfg.direction = substream->stream;
>> +	cfg.sample_rate = runtime->rate;
>> +	cfg.num_channels = runtime->channels;
>> +	cfg.bit_width = prtd->bits_per_sample;
>> +
>> +	prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
>> +	prtd->pos = 0;
>> +	/* rate and channels are sent to audio driver */
>> +	ret = q6apm_graph_media_format_shmem(prtd->graph, &cfg);
>> +	if (ret < 0) {
>> +		dev_err(dev, "%s: q6apm_open_write failed\n", __func__);
>> +		return ret;
>> +	}
>> +
>> +	ret = q6apm_graph_media_format_pcm(prtd->graph, &cfg);
>> +	if (ret < 0)
>> +		dev_err(dev, "%s: CMD Format block failed\n", __func__);
>> +
>> +	ret = q6apm_map_memory_regions(prtd->graph, substream->stream, prtd->phys,
>> +				       (prtd->pcm_size / prtd->periods), prtd->periods);
>> +
>> +	if (ret < 0) {
>> +		dev_err(dev, "Audio Start: Buffer Allocation failed rc = %d\n",	ret);
>> +		return -ENOMEM;
>> +	}
>> +
>> +	ret = q6apm_graph_prepare(prtd->graph);
>> +	if (ret) {
>> +		dev_err(dev, "Failed to prepare Graph %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	ret = q6apm_graph_start(prtd->graph);
>> +	if (ret) {
>> +		dev_err(dev, "Failed to Start Graph %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
>> +		int i;
>> +		/* Queue the buffers for Capture ONLY after graph is started */
>> +		for (i = 0; i < runtime->periods; i++)
>> +			q6apm_read(prtd->graph);
>> +
>> +	}
>> +
>> +	prtd->state = Q6APM_STREAM_RUNNING;
> 
> you should probably explain why a stream moves to the 'RUNNING' state in
> a .prepare() callback, instead of TRIGGER_START?

Sure, will add a comment,

--srini
> 
>> +
>> +	return 0;
>> +}
>> +
>> +static int q6apm_dai_trigger(struct snd_soc_component *component,
>> +			     struct snd_pcm_substream *substream, int cmd)
>> +{
>> +	struct snd_pcm_runtime *runtime = substream->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:
>> +		 /* start writing buffers for playback only as we already queued capture buffers */
>> +		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
>> +			ret = q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, 0);
>> +		break;
>> +	case SNDRV_PCM_TRIGGER_STOP:
>> +		/* TODO support be handled via SoftPause Module */
>> +		prtd->state = Q6APM_STREAM_STOPPED;
>> +		break;
>> +	case SNDRV_PCM_TRIGGER_SUSPEND:
>> +	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>> +		break;
>> +	default:
>> +		ret = -EINVAL;
>> +		break;
>> +	}
>> +
>> +	return ret;
>> +}
> 

  reply	other threads:[~2021-09-28  9:33 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 13:55 [PATCH v8 00/22] ASoC: qcom: Add AudioReach support Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 01/22] soc: dt-bindings: qcom: apr: convert to yaml Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 02/22] soc: dt-bindings: qcom: apr: deprecate qcom,apr-domain property Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 03/22] soc: qcom: apr: make code more reuseable Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 04/22] soc: dt-bindings: qcom: add gpr bindings Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 05/22] soc: qcom: apr: Add GPR support Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 06/22] ASoC: dt-bindings: move LPASS dai related bindings out of q6afe Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 07/22] ASoC: dt-bindings: move LPASS clocks " Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 08/22] ASoC: dt-bindings: rename q6afe.h to q6dsp-lpass-ports.h Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 09/22] ASoC: qdsp6: q6afe-dai: move lpass audio ports to common file Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 10/22] ASoC: qdsp6: q6afe-clocks: move audio-clocks " Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 11/22] ASoC: dt-bindings: q6dsp: add q6apm-lpass-dai compatible Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 12/22] ASoC: dt-bindings: lpass-clocks: add q6prm clocks compatible Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 13/22] ASoC: dt-bindings: add q6apm digital audio stream bindings Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 14/22] ASoC: qdsp6: audioreach: add basic pkt alloc support Srinivas Kandagatla
2021-09-27 16:08   ` Pierre-Louis Bossart
2021-09-28 10:10     ` Srinivas Kandagatla
2021-09-28  8:00   ` Amadeusz Sławiński
2021-09-28  9:31     ` Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 15/22] ASoC: qdsp6: audioreach: add q6apm support Srinivas Kandagatla
2021-09-28  8:23   ` Amadeusz Sławiński
2021-09-28  9:31     ` Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 16/22] ASoC: qdsp6: audioreach: add module configuration command helpers Srinivas Kandagatla
2021-09-27 16:16   ` Pierre-Louis Bossart
2021-09-28 10:21     ` Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 17/22] ASoC: qdsp6: audioreach: add Kconfig and Makefile Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 18/22] ASoC: qdsp6: audioreach: add topology support Srinivas Kandagatla
2021-09-27 16:21   ` Pierre-Louis Bossart
2021-09-28  9:34     ` Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 19/22] ASoC: qdsp6: audioreach: add q6apm-dai support Srinivas Kandagatla
2021-09-27 16:25   ` Pierre-Louis Bossart
2021-09-28  9:33     ` Srinivas Kandagatla [this message]
2021-09-27 13:55 ` [PATCH v8 20/22] ASoC: qdsp6: audioreach: add q6apm lpass dai support Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 21/22] ASoC: qdsp6: audioreach: add q6prm support Srinivas Kandagatla
2021-09-27 13:55 ` [PATCH v8 22/22] ASoC: qdsp6: audioreach: add support for q6prm-clocks Srinivas Kandagatla
2021-09-27 16:32 ` [PATCH v8 00/22] ASoC: qcom: Add AudioReach support Pierre-Louis Bossart
2021-09-28  3:19 ` Bjorn Andersson
2021-09-28  3:20 ` (subset) " Bjorn Andersson
2021-09-28  8:47   ` Srinivas Kandagatla

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=c12ac2f5-bc53-ac0c-6ed0-f748a62015ac@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=plai@codeaurora.org \
    --cc=robh@kernel.org \
    --cc=tiwai@suse.de \
    /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).