On 18-06-18, 16:46, Rohit kumar wrote:No specific reason, I will move it to sdm845_snd_data.
+struct sdm845_snd_data {any reason why the locks can't be part of 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;
Also why do we need two locks ?
Nothing as such. As we are using mutex to synchronize, we can make it non- atomic.
+static atomic_t pri_mi2s_clk_count;Any specific reason for using atomic variables?
+static atomic_t quat_tdm_clk_count;
+static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};I though ch = 0 would be caught by framework and IIRC ASoC doesn't
+
+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) {
support more than 8 channels
+ pr_err("%s: invalid param channels %d\n",why not use dev_err, bonus you get device name printer with the logs :)
+ __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));
+static int sdm845_snd_startup(struct snd_pcm_substream *substream)It is good for debug but not very useful here, so removing it would be
+{
+ 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);
good
So, we can have two usecases: one with primary mi2s rx and other with primary mi2s tx.+ switch (cpu_dai->id) {why do we need locking here? Can you please explain that.
+ 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);
+ snd_soc_dai_set_fmt(cpu_dai, fmt);empty line after break helps in readability
+ break;
Right. Its not mandatory to have qcom,audio-routing in device tree.+static int sdm845_sbc_parse_of(struct snd_soc_card *card)so if we dont find audio-routing, then? we seems to continue..
+{
+ 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;
+ }