ASoC: intel: sof_sdw: init all aggregated codecs
authorBard Liao <yung-chuan.liao@linux.intel.com>
Thu, 9 Apr 2020 18:58:20 +0000 (13:58 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 14 Apr 2020 13:34:06 +0000 (14:34 +0100)
Init codecs which belong to the same group id on all links.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200409185827.16255-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/sof_sdw.c

index a64dc56..6a1b51c 100644 (file)
@@ -411,25 +411,36 @@ static int create_codec_dai_name(struct device *dev,
 
 static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link,
                               struct snd_soc_dai_link *dai_links,
-                              bool playback)
+                              bool playback, int group_id)
 {
        int i;
 
-       for (i = 0; i < link->num_adr; i++) {
-               unsigned int part_id;
-               int codec_index;
-
-               part_id = SDW_PART_ID(link->adr_d[i].adr);
-               codec_index = find_codec_info_part(part_id);
+       do {
+               /*
+                * Initialize the codec. If codec is part of an aggregated
+                * group (group_id>0), initialize all codecs belonging to
+                * same group.
+                */
+               for (i = 0; i < link->num_adr; i++) {
+                       unsigned int part_id;
+                       int codec_index;
 
-               if (codec_index < 0)
-                       return codec_index;
+                       part_id = SDW_PART_ID(link->adr_d[i].adr);
+                       codec_index = find_codec_info_part(part_id);
 
-               if (codec_info_list[codec_index].init)
-                       codec_info_list[codec_index].init(link, dai_links,
-                                                &codec_info_list[codec_index],
-                                                playback);
-       }
+                       if (codec_index < 0)
+                               return codec_index;
+                       /* The group_id is > 0 iff the codec is aggregated */
+                       if (link->adr_d[i].endpoints->group_id != group_id)
+                               continue;
+                       if (codec_info_list[codec_index].init)
+                               codec_info_list[codec_index].init(link,
+                                               dai_links,
+                                               &codec_info_list[codec_index],
+                                               playback);
+               }
+               link++;
+       } while (link->mask && group_id);
 
        return 0;
 }
@@ -623,7 +634,7 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
                              NULL, &sdw_ops);
 
                ret = set_codec_init_func(link, dai_links + (*be_index)++,
-                                         playback);
+                                         playback, group_id);
                if (ret < 0) {
                        dev_err(dev, "failed to init codec %d", codec_index);
                        return ret;