From: Rohit Kumar <rohitkr@codeaurora.org>
To: Vinod <vkoul@kernel.org>
Cc: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org,
mark.rutland@arm.com, plai@codeaurora.org,
bgoswami@codeaurora.org, perex@perex.cz,
srinivas.kandagatla@linaro.org, tiwai@suse.com,
alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [alsa-devel] [PATCH] ASoC: qcom: add sdm845 sound card support
Date: Tue, 19 Jun 2018 19:20:55 +0530 [thread overview]
Message-ID: <8562b574-3738-8983-53e7-64366590fad4@codeaurora.org> (raw)
In-Reply-To: <20180619050527.GR25852@vkoul-mobl>
Thanks Vinod for reviewing.
On 6/19/2018 10:35 AM, Vinod wrote:
> 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 ?
No specific reason, I will move it to sdm845_snd_data.
These locks are used to protect enable/disable of bit clocks. We have
Primary MI2S RX/TX
and Quaternary TDM RX/TX interfaces. For primary mi2s rx/tx, we have
single clock which is
synchronized with pri_mi2s_res_lock. For Quat TDM RX/TX, we are using
quat_tdm_res_lock.
We need two locks as we are protecting two different resources.
>
>> +static atomic_t pri_mi2s_clk_count;
>> +static atomic_t quat_tdm_clk_count;
> Any specific reason for using atomic variables?
Nothing as such. As we are using mutex to synchronize, we can make it
non- atomic.
Will do it in next-spin.
>
>> +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
OK. Will check and remove.
>> + 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 :)
Sure. Will change it.
>> +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
OK
>> + 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.
So, we can have two usecases: one with primary mi2s rx and other with
primary mi2s tx.
Lock is required to increment pri_mi2s_clk_count and enable clock so
that disable of one
usecase does not disable the clock.
>
>> + snd_soc_dai_set_fmt(cpu_dai, fmt);
>> + break;
> empty line after break helps in readability
Sure. Will add that change.
>> +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..
Right. Its not mandatory to have qcom,audio-routing in device tree.
Regards,
Rohit
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
next prev parent reply other threads:[~2018-06-19 13:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 11:16 Rohit kumar
2018-06-19 5:05 ` [alsa-devel] " Vinod
2018-06-19 13:50 ` Rohit Kumar [this message]
2018-06-19 16:22 ` Vinod
[not found] ` <f7891675-4c98-7fc6-b80f-840ada9a1c5b@codeaurora.org>
2018-06-20 9:31 ` Vinod
2018-06-20 9:53 ` Srinivas Kandagatla
2018-06-20 10:28 ` Vinod
2018-06-19 8:46 ` Srinivas Kandagatla
2018-06-19 13:58 ` [alsa-devel] " Rohit Kumar
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=8562b574-3738-8983-53e7-64366590fad4@codeaurora.org \
--to=rohitkr@codeaurora.org \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@codeaurora.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=perex@perex.cz \
--cc=plai@codeaurora.org \
--cc=robh+dt@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.com \
--cc=vkoul@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome