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: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, lgirdwood@gmail.com, tiwai@suse.de, plai@codeaurora.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 09/16] ASoC: qcom: audioreach: add q6apm-dai support Date: Thu, 15 Jul 2021 11:32:23 +0100 [thread overview] Message-ID: <90aafeb0-57dd-a309-e08f-a4ff31ad0853@linaro.org> (raw) In-Reply-To: <9b669a36-f9e4-bd90-7b02-e55fe5b99814@linux.intel.com> On 14/07/2021 17:59, Pierre-Louis Bossart wrote: > > >> +static void event_handler(uint32_t opcode, uint32_t token, >> + uint32_t *payload, void *priv) >> +{ >> + struct q6apm_dai_rtd *prtd = priv; >> + struct snd_pcm_substream *substream = prtd->substream; >> + >> + switch (opcode) { >> + case APM_CLIENT_EVENT_CMD_EOS_DONE: >> + prtd->state = Q6APM_STREAM_STOPPED; >> + break; >> + case APM_CLIENT_EVENT_DATA_WRITE_DONE: { >> + prtd->pcm_irq_pos += prtd->pcm_count; >> + snd_pcm_period_elapsed(substream); > > A comment on the relationship between data writes and periods would be nice. It looks like the code assumes the period and data transfers are identical, but periods can be chosen by applications, can't they? Yes, pcm_count is set to period size, so we get ack for each period. > >> + if (prtd->state == Q6APM_STREAM_RUNNING) { >> + q6apm_write_async(prtd->graph, >> + prtd->pcm_count, 0, 0, NO_TIMESTAMP); >> + } >> + >> + break; >> + } >> + case APM_CLIENT_EVENT_DATA_READ_DONE: >> + prtd->pcm_irq_pos += prtd->pcm_count; >> + snd_pcm_period_elapsed(substream); >> + if (prtd->state == Q6APM_STREAM_RUNNING) >> + q6apm_read(prtd->graph); >> + >> + break; >> + default: >> + break; >> + } >> +} > >> +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: >> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) >> + ret = q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, NO_TIMESTAMP); >> + break; >> + case SNDRV_PCM_TRIGGER_STOP: >> + prtd->state = Q6APM_STREAM_STOPPED; >> + //ret = q6apm_cmd_nowait(prtd->graph, CMD_EOS); >> + break; >> + case SNDRV_PCM_TRIGGER_SUSPEND: >> + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: >> + //ret = q6apm_cmd_nowait(prtd->graph, CMD_PAUSE); > > these // comments are odd, with a clear imbalance between suspend/resume and pause_push/pause_release... > is this intentional or a left-over from an experiment? Yes, I forgot to clean this up before sending out. > >> + break; >> + default: >> + ret = -EINVAL; >> + break; >> + } >> + >> + return ret; >> +} >> + >> +static int q6apm_dai_open(struct snd_soc_component *component, >> + struct snd_pcm_substream *substream) >> +{ >> + struct snd_pcm_runtime *runtime = substream->runtime; >> + struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; >> + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_prtd, 0); >> + struct q6apm_dai_rtd *prtd; >> + struct q6apm_dai_data *pdata; >> + struct device *dev = component->dev; >> + int ret; >> + int graph_id; >> + >> + graph_id = cpu_dai->driver->id; >> + >> + pdata = snd_soc_component_get_drvdata(component); >> + if (!pdata) { >> + dev_err(component->dev, "Drv data not found ..\n"); >> + return -EINVAL; >> + } >> + >> + prtd = kzalloc(sizeof(*prtd), GFP_KERNEL); >> + if (prtd == NULL) >> + return -ENOMEM; >> + >> + prtd->substream = substream; >> + >> + prtd->graph = q6apm_graph_open(dev, (q6apm_cb)event_handler, >> + prtd, graph_id); >> + if (IS_ERR(prtd->graph)) { >> + pr_info("%s: Could not allocate memory\n", __func__); >> + ret = PTR_ERR(prtd->graph); >> + kfree(prtd); >> + return ret; >> + } >> + >> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) >> + runtime->hw = q6apm_dai_hardware_playback; >> + else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) >> + runtime->hw = q6apm_dai_hardware_capture; >> + >> + /* Ensure that buffer size is a multiple of period size */ >> + ret = snd_pcm_hw_constraint_integer(runtime, >> + SNDRV_PCM_HW_PARAM_PERIODS); >> + if (ret < 0) >> + dev_err(dev, "snd_pcm_hw_constraint_integer failed\n"); >> + >> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { >> + ret = snd_pcm_hw_constraint_minmax(runtime, >> + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, >> + BUFFER_BYTES_MIN, BUFFER_BYTES_MAX); >> + if (ret < 0) { >> + dev_err(dev, "constraint for buffer bytes min max ret = %d\n", >> + ret); >> + } >> + } >> + >> + ret = snd_pcm_hw_constraint_step(runtime, 0, >> + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); >> + if (ret < 0) { >> + dev_err(dev, "constraint for period bytes step ret = %d\n", >> + ret); >> + } >> + ret = snd_pcm_hw_constraint_step(runtime, 0, >> + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); >> + if (ret < 0) { >> + dev_err(dev, "constraint for buffer bytes step ret = %d\n", >> + ret); >> + } > > dev_err() used but no return code sent? Ack. > >> + >> + runtime->private_data = prtd; >> + runtime->dma_bytes = BUFFER_BYTES_MAX; >> + if (pdata->sid < 0) >> + prtd->phys = substream->dma_buffer.addr; >> + else >> + prtd->phys = substream->dma_buffer.addr | (pdata->sid << 32); >> + >> + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); >> + >> + return 0; >> +} > >> +static int q6apm_dai_hw_params(struct snd_soc_component *component, >> + struct snd_pcm_substream *substream, >> + struct snd_pcm_hw_params *params) >> +{ >> + struct snd_pcm_runtime *runtime = substream->runtime; >> + struct q6apm_dai_rtd *prtd = runtime->private_data; >> + >> + prtd->pcm_size = params_buffer_bytes(params); >> + prtd->periods = params_periods(params); >> + >> + switch (params_format(params)) { >> + case SNDRV_PCM_FORMAT_S16_LE: >> + prtd->bits_per_sample = 16; >> + break; >> + case SNDRV_PCM_FORMAT_S24_LE: >> + prtd->bits_per_sample = 24; >> + break; > > default: > return -EINVAL > ? Ack, will do that in next spin. --srini > >> + } >> + >> + return 0; >> +} >> + >
WARNING: multiple messages have this Message-ID (diff)
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: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, tiwai@suse.de, plai@codeaurora.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 09/16] ASoC: qcom: audioreach: add q6apm-dai support Date: Thu, 15 Jul 2021 11:32:23 +0100 [thread overview] Message-ID: <90aafeb0-57dd-a309-e08f-a4ff31ad0853@linaro.org> (raw) In-Reply-To: <9b669a36-f9e4-bd90-7b02-e55fe5b99814@linux.intel.com> On 14/07/2021 17:59, Pierre-Louis Bossart wrote: > > >> +static void event_handler(uint32_t opcode, uint32_t token, >> + uint32_t *payload, void *priv) >> +{ >> + struct q6apm_dai_rtd *prtd = priv; >> + struct snd_pcm_substream *substream = prtd->substream; >> + >> + switch (opcode) { >> + case APM_CLIENT_EVENT_CMD_EOS_DONE: >> + prtd->state = Q6APM_STREAM_STOPPED; >> + break; >> + case APM_CLIENT_EVENT_DATA_WRITE_DONE: { >> + prtd->pcm_irq_pos += prtd->pcm_count; >> + snd_pcm_period_elapsed(substream); > > A comment on the relationship between data writes and periods would be nice. It looks like the code assumes the period and data transfers are identical, but periods can be chosen by applications, can't they? Yes, pcm_count is set to period size, so we get ack for each period. > >> + if (prtd->state == Q6APM_STREAM_RUNNING) { >> + q6apm_write_async(prtd->graph, >> + prtd->pcm_count, 0, 0, NO_TIMESTAMP); >> + } >> + >> + break; >> + } >> + case APM_CLIENT_EVENT_DATA_READ_DONE: >> + prtd->pcm_irq_pos += prtd->pcm_count; >> + snd_pcm_period_elapsed(substream); >> + if (prtd->state == Q6APM_STREAM_RUNNING) >> + q6apm_read(prtd->graph); >> + >> + break; >> + default: >> + break; >> + } >> +} > >> +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: >> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) >> + ret = q6apm_write_async(prtd->graph, prtd->pcm_count, 0, 0, NO_TIMESTAMP); >> + break; >> + case SNDRV_PCM_TRIGGER_STOP: >> + prtd->state = Q6APM_STREAM_STOPPED; >> + //ret = q6apm_cmd_nowait(prtd->graph, CMD_EOS); >> + break; >> + case SNDRV_PCM_TRIGGER_SUSPEND: >> + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: >> + //ret = q6apm_cmd_nowait(prtd->graph, CMD_PAUSE); > > these // comments are odd, with a clear imbalance between suspend/resume and pause_push/pause_release... > is this intentional or a left-over from an experiment? Yes, I forgot to clean this up before sending out. > >> + break; >> + default: >> + ret = -EINVAL; >> + break; >> + } >> + >> + return ret; >> +} >> + >> +static int q6apm_dai_open(struct snd_soc_component *component, >> + struct snd_pcm_substream *substream) >> +{ >> + struct snd_pcm_runtime *runtime = substream->runtime; >> + struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; >> + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_prtd, 0); >> + struct q6apm_dai_rtd *prtd; >> + struct q6apm_dai_data *pdata; >> + struct device *dev = component->dev; >> + int ret; >> + int graph_id; >> + >> + graph_id = cpu_dai->driver->id; >> + >> + pdata = snd_soc_component_get_drvdata(component); >> + if (!pdata) { >> + dev_err(component->dev, "Drv data not found ..\n"); >> + return -EINVAL; >> + } >> + >> + prtd = kzalloc(sizeof(*prtd), GFP_KERNEL); >> + if (prtd == NULL) >> + return -ENOMEM; >> + >> + prtd->substream = substream; >> + >> + prtd->graph = q6apm_graph_open(dev, (q6apm_cb)event_handler, >> + prtd, graph_id); >> + if (IS_ERR(prtd->graph)) { >> + pr_info("%s: Could not allocate memory\n", __func__); >> + ret = PTR_ERR(prtd->graph); >> + kfree(prtd); >> + return ret; >> + } >> + >> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) >> + runtime->hw = q6apm_dai_hardware_playback; >> + else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) >> + runtime->hw = q6apm_dai_hardware_capture; >> + >> + /* Ensure that buffer size is a multiple of period size */ >> + ret = snd_pcm_hw_constraint_integer(runtime, >> + SNDRV_PCM_HW_PARAM_PERIODS); >> + if (ret < 0) >> + dev_err(dev, "snd_pcm_hw_constraint_integer failed\n"); >> + >> + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { >> + ret = snd_pcm_hw_constraint_minmax(runtime, >> + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, >> + BUFFER_BYTES_MIN, BUFFER_BYTES_MAX); >> + if (ret < 0) { >> + dev_err(dev, "constraint for buffer bytes min max ret = %d\n", >> + ret); >> + } >> + } >> + >> + ret = snd_pcm_hw_constraint_step(runtime, 0, >> + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); >> + if (ret < 0) { >> + dev_err(dev, "constraint for period bytes step ret = %d\n", >> + ret); >> + } >> + ret = snd_pcm_hw_constraint_step(runtime, 0, >> + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32); >> + if (ret < 0) { >> + dev_err(dev, "constraint for buffer bytes step ret = %d\n", >> + ret); >> + } > > dev_err() used but no return code sent? Ack. > >> + >> + runtime->private_data = prtd; >> + runtime->dma_bytes = BUFFER_BYTES_MAX; >> + if (pdata->sid < 0) >> + prtd->phys = substream->dma_buffer.addr; >> + else >> + prtd->phys = substream->dma_buffer.addr | (pdata->sid << 32); >> + >> + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); >> + >> + return 0; >> +} > >> +static int q6apm_dai_hw_params(struct snd_soc_component *component, >> + struct snd_pcm_substream *substream, >> + struct snd_pcm_hw_params *params) >> +{ >> + struct snd_pcm_runtime *runtime = substream->runtime; >> + struct q6apm_dai_rtd *prtd = runtime->private_data; >> + >> + prtd->pcm_size = params_buffer_bytes(params); >> + prtd->periods = params_periods(params); >> + >> + switch (params_format(params)) { >> + case SNDRV_PCM_FORMAT_S16_LE: >> + prtd->bits_per_sample = 16; >> + break; >> + case SNDRV_PCM_FORMAT_S24_LE: >> + prtd->bits_per_sample = 24; >> + break; > > default: > return -EINVAL > ? Ack, will do that in next spin. --srini > >> + } >> + >> + return 0; >> +} >> + >
next prev parent reply other threads:[~2021-07-15 10:32 UTC|newest] Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-14 15:30 [PATCH v2 00/16] ASoC: qcom: Add AudioReach support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 01/16] soc: dt-bindings: qcom: add gpr bindings Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:05 ` Pierre-Louis Bossart 2021-07-14 16:05 ` Pierre-Louis Bossart 2021-07-14 15:30 ` [PATCH v2 02/16] soc: qcom: apr: make code more reuseable Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 20:36 ` kernel test robot 2021-07-14 20:36 ` kernel test robot 2021-07-14 20:36 ` kernel test robot 2021-07-14 15:30 ` [PATCH v2 03/16] soc: qcom: apr: Add GPR support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:20 ` Pierre-Louis Bossart 2021-07-14 16:20 ` Pierre-Louis Bossart 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 04/16] ASoC: qcom: dt-bindings: add bindings Audio Processing manager Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-28 17:36 ` Rob Herring 2021-07-28 17:36 ` Rob Herring 2021-07-29 9:18 ` Srinivas Kandagatla 2021-07-29 9:18 ` Srinivas Kandagatla 2021-07-29 11:13 ` Mark Brown 2021-07-29 11:13 ` Mark Brown 2021-07-30 11:06 ` Srinivas Kandagatla 2021-07-30 11:06 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 05/16] ASoC: qcom: audioreach: add basic pkt alloc support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:30 ` Pierre-Louis Bossart 2021-07-14 16:30 ` Pierre-Louis Bossart 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 06/16] ASoC: qcom: audioreach: add q6apm support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:40 ` Pierre-Louis Bossart 2021-07-14 16:40 ` Pierre-Louis Bossart 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-15 10:31 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 07/16] ASoC: qcom: audioreach: add module configuration command helpers Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:48 ` Pierre-Louis Bossart 2021-07-14 16:48 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 08/16] ASoC: qcom: audioreach: add topology support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 09/16] ASoC: qcom: audioreach: add q6apm-dai support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 16:59 ` Pierre-Louis Bossart 2021-07-14 16:59 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla [this message] 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 10/16] ASoC: qcom: audioreach: add bedai support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 17:03 ` Pierre-Louis Bossart 2021-07-14 17:03 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 11/16] ASoC: qcom: dt-bindings: add bindings for Proxy Resource Manager Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 12/16] ASoC: qcom: audioreach: add q6prm support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 17:09 ` Pierre-Louis Bossart 2021-07-14 17:09 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 7:40 ` kernel test robot 2021-07-15 7:40 ` kernel test robot 2021-07-15 7:40 ` kernel test robot 2021-07-14 15:30 ` [PATCH v2 13/16] ASoC: qcom: dt-bindings: add audioreach soundcard compatibles Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 14/16] ASoC: qcom: audioreach: add volume ctrl module support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 15/16] ASoC: qcom: audioreach: topology add dapm pga support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 15:30 ` [PATCH v2 16/16] ASoC: qcom: sm8250: Add audioreach support Srinivas Kandagatla 2021-07-14 15:30 ` Srinivas Kandagatla 2021-07-14 17:12 ` Pierre-Louis Bossart 2021-07-14 17:12 ` Pierre-Louis Bossart 2021-07-15 10:32 ` Srinivas Kandagatla 2021-07-15 10:32 ` 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=90aafeb0-57dd-a309-e08f-a4ff31ad0853@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=linux-kernel@vger.kernel.org \ --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: linkBe 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.