[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180619050527.GR25852@vkoul-mobl>
Date: Tue, 19 Jun 2018 10:35:27 +0530
From: Vinod <vkoul@...nel.org>
To: Rohit kumar <rohitkr@...eaurora.org>
Cc: lgirdwood@...il.com, broonie@...nel.org, robh+dt@...nel.org,
mark.rutland@....com, plai@...eaurora.org, bgoswami@...eaurora.org,
perex@...ex.cz, srinivas.kandagatla@...aro.org, tiwai@...e.com,
alsa-devel@...a-project.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [alsa-devel] [PATCH] ASoC: qcom: add sdm845 sound card support
On 18-06-18, 16:46, Rohit kumar wrote:
> +struct sdm845_snd_data {
> + struct snd_soc_card *card;
> + struct regulator *vdd_supply;
> + struct snd_soc_dai_link dai_link[];
> +};
> +
> +static struct mutex pri_mi2s_res_lock;
> +static struct mutex quat_tdm_res_lock;
any reason why the locks can't be part of sdm845_snd_data?
Also why do we need two locks ?
> +static atomic_t pri_mi2s_clk_count;
> +static atomic_t quat_tdm_clk_count;
Any specific reason for using atomic variables?
> +static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
> +
> +static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params)
> +{
> + struct snd_soc_pcm_runtime *rtd = substream->private_data;
> + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
> + int ret = 0;
> + int channels, slot_width;
> +
> + channels = params_channels(params);
> + if (channels < 1 || channels > 8) {
I though ch = 0 would be caught by framework and IIRC ASoC doesn't
support more than 8 channels
> + pr_err("%s: invalid param channels %d\n",
> + __func__, channels);
> + return -EINVAL;
> + }
> +
> + switch (params_format(params)) {
> + case SNDRV_PCM_FORMAT_S32_LE:
> + case SNDRV_PCM_FORMAT_S24_LE:
> + case SNDRV_PCM_FORMAT_S16_LE:
> + slot_width = 32;
> + break;
> + default:
> + pr_err("%s: invalid param format 0x%x\n",
> + __func__, params_format(params));
why not use dev_err, bonus you get device name printer with the logs :)
> +static int sdm845_snd_startup(struct snd_pcm_substream *substream)
> +{
> + unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
> + struct snd_soc_pcm_runtime *rtd = substream->private_data;
> + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
> +
> + pr_debug("%s: dai_id: 0x%x\n", __func__, cpu_dai->id);
It is good for debug but not very useful here, so removing it would be
good
> + switch (cpu_dai->id) {
> + case PRIMARY_MI2S_RX:
> + case PRIMARY_MI2S_TX:
> + mutex_lock(&pri_mi2s_res_lock);
> + if (atomic_inc_return(&pri_mi2s_clk_count) == 1) {
> + snd_soc_dai_set_sysclk(cpu_dai,
> + Q6AFE_LPASS_CLK_ID_MCLK_1,
> + DEFAULT_MCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
> + snd_soc_dai_set_sysclk(cpu_dai,
> + Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
> + DEFAULT_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
> + }
> + mutex_unlock(&pri_mi2s_res_lock);
why do we need locking here? Can you please explain that.
> + snd_soc_dai_set_fmt(cpu_dai, fmt);
> + break;
empty line after break helps in readability
> +static int sdm845_sbc_parse_of(struct snd_soc_card *card)
> +{
> + struct device *dev = card->dev;
> + struct snd_soc_dai_link *link;
> + struct device_node *np, *codec, *platform, *cpu, *node;
> + int ret, num_links;
> + struct sdm845_snd_data *data;
> +
> + ret = snd_soc_of_parse_card_name(card, "qcom,model");
> + if (ret) {
> + dev_err(dev, "Error parsing card name: %d\n", ret);
> + return ret;
> + }
> +
> + node = dev->of_node;
> +
> + /* DAPM routes */
> + if (of_property_read_bool(node, "qcom,audio-routing")) {
> + ret = snd_soc_of_parse_audio_routing(card,
> + "qcom,audio-routing");
> + if (ret)
> + return ret;
> + }
so if we dont find audio-routing, then? we seems to continue..
--
~Vinod
Powered by blists - more mailing lists