linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	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 10/16] ASoC: qcom: audioreach: add bedai support
Date: Wed, 14 Jul 2021 12:03:31 -0500	[thread overview]
Message-ID: <cb2636b9-e88f-76c3-129a-5cbb2cd017b2@linux.intel.com> (raw)
In-Reply-To: <20210714153039.28373-11-srinivas.kandagatla@linaro.org>



> +static int q6dma_hw_params(struct snd_pcm_substream *substream,
> +			   struct snd_pcm_hw_params *params,
> +			   struct snd_soc_dai *dai)
> +{
> +	struct q6apm_bedai_data *dai_data = dev_get_drvdata(dai->dev);
> +	struct q6apm_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg;
> +
> +	cfg->bit_width = params_width(params);
> +	cfg->sample_rate = params_rate(params);
> +	cfg->num_channels = params_channels(params);
> +
> +	switch (params_format(params)) {
> +	case SNDRV_PCM_FORMAT_S16_LE:
> +		dai_data->bits_per_sample[dai->id] = 16;
> +		break;
> +	case SNDRV_PCM_FORMAT_S24_LE:
> +		dai_data->bits_per_sample[dai->id] = 24;
> +		break;

default:
    return -EINVAL;

?

> +	}
> +
> +	return 0;
> +}
> +
> +static void q6apm_bedai_shutdown(struct snd_pcm_substream *substream,
> +				struct snd_soc_dai *dai)
> +{
> +	struct q6apm_bedai_data *dai_data = dev_get_drvdata(dai->dev);
> +	int rc;
> +
> +	if (!dai_data->is_port_started[dai->id])
> +		return;
> +	rc = q6apm_graph_stop(dai_data->graph[dai->id]);
> +	if (rc < 0)
> +		dev_err(dai->dev, "fail to close APM port (%d)\n", rc);
> +
> +	q6apm_graph_close(dai_data->graph[dai->id]);
> +	dai_data->is_port_started[dai->id] = false;

difficult to follow, this mixes '!start', 'stop', 'close'


> +
> +}
> +
> +static int q6apm_bedai_prepare(struct snd_pcm_substream *substream,
> +			       struct snd_soc_dai *dai)
> +{
> +	struct q6apm_bedai_data *dai_data = dev_get_drvdata(dai->dev);
> +	struct q6apm_cdc_dma_cfg *cfg = &dai_data->port_config[dai->id].dma_cfg;
> +	int graph_id = dai->id;
> +	int rc;
> +	int ret;
> +	struct q6apm_graph *graph;
> +
> +	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> +		graph = q6apm_graph_open(dai->dev, NULL, dai->dev, graph_id);
> +		if (IS_ERR(graph)) {
> +			dev_err(dai->dev, "Failed to open graph (%d)\n",
> +				graph_id);
> +			ret = PTR_ERR(graph);
> +			return ret;
> +		}
> +		dai_data->graph[graph_id] = graph;
> +	}
> +
> +	rc = q6apm_graph_media_format_pcm(dai_data->graph[dai->id],
> +					  substream->stream, cfg->sample_rate,
> +					  cfg->num_channels, NULL, cfg->bit_width);
> +
> +	rc = q6apm_graph_prepare(dai_data->graph[dai->id]);

any good static analyzer would tell you you didn't test rc before overriding it..

this looks rather questionable.

> +	rc = q6apm_graph_start(dai_data->graph[dai->id]);
> +	if (rc < 0) {
> +		dev_err(dai->dev, "fail to start APM port %x\n", dai->id);
> +		return rc;
> +	}
> +	dai_data->is_port_started[dai->id] = true;
> +
> +	return 0;
> +}
 

  reply	other threads:[~2021-07-14 17:14 UTC|newest]

Thread overview: 40+ 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 ` [PATCH v2 01/16] soc: dt-bindings: qcom: add gpr bindings Srinivas Kandagatla
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 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 16:20   ` Pierre-Louis Bossart
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-28 17:36   ` Rob Herring
2021-07-29  9:18     ` Srinivas Kandagatla
2021-07-29 11:13       ` Mark Brown
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 16:30   ` Pierre-Louis Bossart
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 16:40   ` Pierre-Louis Bossart
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 16:48   ` Pierre-Louis Bossart
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 ` [PATCH v2 09/16] ASoC: qcom: audioreach: add q6apm-dai support Srinivas Kandagatla
2021-07-14 16:59   ` Pierre-Louis Bossart
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 17:03   ` Pierre-Louis Bossart [this message]
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 ` [PATCH v2 12/16] ASoC: qcom: audioreach: add q6prm support Srinivas Kandagatla
2021-07-14 17:09   ` Pierre-Louis Bossart
2021-07-15 10:32     ` Srinivas Kandagatla
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 ` [PATCH v2 14/16] ASoC: qcom: audioreach: add volume ctrl module support 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 ` [PATCH v2 16/16] ASoC: qcom: sm8250: Add audioreach support Srinivas Kandagatla
2021-07-14 17:12   ` Pierre-Louis Bossart
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=cb2636b9-e88f-76c3-129a-5cbb2cd017b2@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --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=plai@codeaurora.org \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.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).