]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: intel/sdw_utils: move machine driver dai link helper functions
authorVijendar Mukunda <Vijendar.Mukunda@amd.com>
Thu, 1 Aug 2024 11:18:10 +0000 (16:48 +0530)
committerMark Brown <broonie@kernel.org>
Thu, 1 Aug 2024 11:44:13 +0000 (12:44 +0100)
Move machine driver dai link helper functions to common place holder,
So that it can be used by other platform machine driver.
Rename these functions with "asoc_sdw" tag as a prefix.

Link: https://github.com/thesofproject/linux/pull/5068
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://patch.msgid.link/20240801111821.18076-4-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc_sdw_utils.h
sound/soc/intel/boards/sof_sdw.c
sound/soc/sdw_utils/soc_sdw_utils.c

index 9d99a460ba27386364584870b99624636988ef4d..b3b6d6b7ce2f2a6884b0d40022c7cc0f40db4324 100644 (file)
@@ -117,6 +117,11 @@ struct asoc_sdw_codec_info *asoc_sdw_find_codec_info_acpi(const u8 *acpi_id);
 struct asoc_sdw_codec_info *asoc_sdw_find_codec_info_dai(const char *dai_name,
                                                         int *dai_index);
 
+struct snd_soc_dai_link *asoc_sdw_mc_find_codec_dai_used(struct snd_soc_card *card,
+                                                        const char *dai_name);
+
+void asoc_sdw_mc_dailink_exit_loop(struct snd_soc_card *card);
+
 int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd);
 
 /* DMIC support */
index 87f3e5aa1477259bacd2b0579471cec84b46ae61..07b1d6994304fa17c725f00d00f48b8073e35ea9 100644 (file)
@@ -1238,56 +1238,6 @@ static int sof_sdw_card_late_probe(struct snd_soc_card *card)
        return ret;
 }
 
-/* helper to get the link that the codec DAI is used */
-static struct snd_soc_dai_link *mc_find_codec_dai_used(struct snd_soc_card *card,
-                                                      const char *dai_name)
-{
-       struct snd_soc_dai_link *dai_link;
-       int i;
-       int j;
-
-       for_each_card_prelinks(card, i, dai_link) {
-               for (j = 0; j < dai_link->num_codecs; j++) {
-                       /* Check each codec in a link */
-                       if (!strcmp(dai_link->codecs[j].dai_name, dai_name))
-                               return dai_link;
-               }
-       }
-       return NULL;
-}
-
-static void mc_dailink_exit_loop(struct snd_soc_card *card)
-{
-       struct snd_soc_dai_link *dai_link;
-       struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
-       int ret;
-       int i, j;
-
-       for (i = 0; i < ctx->codec_info_list_count; i++) {
-               for (j = 0; j < codec_info_list[i].dai_num; j++) {
-                       codec_info_list[i].dais[j].rtd_init_done = false;
-                       /* Check each dai in codec_info_lis to see if it is used in the link */
-                       if (!codec_info_list[i].dais[j].exit)
-                               continue;
-                       /*
-                        * We don't need to call .exit function if there is no matched
-                        * dai link found.
-                        */
-                       dai_link = mc_find_codec_dai_used(card,
-                                                         codec_info_list[i].dais[j].dai_name);
-                       if (dai_link) {
-                               /* Do the .exit function if the codec dai is used in the link */
-                               ret = codec_info_list[i].dais[j].exit(card, dai_link);
-                               if (ret)
-                                       dev_warn(card->dev,
-                                                "codec exit failed %d\n",
-                                                ret);
-                               break;
-                       }
-               }
-       }
-}
-
 static int mc_probe(struct platform_device *pdev)
 {
        struct snd_soc_acpi_mach *mach = dev_get_platdata(&pdev->dev);
@@ -1368,7 +1318,7 @@ static int mc_probe(struct platform_device *pdev)
        ret = devm_snd_soc_register_card(card->dev, card);
        if (ret) {
                dev_err_probe(card->dev, ret, "snd_soc_register_card failed %d\n", ret);
-               mc_dailink_exit_loop(card);
+               asoc_sdw_mc_dailink_exit_loop(card);
                return ret;
        }
 
@@ -1381,7 +1331,7 @@ static void mc_remove(struct platform_device *pdev)
 {
        struct snd_soc_card *card = platform_get_drvdata(pdev);
 
-       mc_dailink_exit_loop(card);
+       asoc_sdw_mc_dailink_exit_loop(card);
 }
 
 static const struct platform_device_id mc_id_table[] = {
index a496b4eff6e3ad91222b6cb8a6ba42a21105144e..409a5014734951ff7e4969ebed5162e9ea04552d 100644 (file)
@@ -864,5 +864,57 @@ const char *asoc_sdw_get_codec_name(struct device *dev,
 }
 EXPORT_SYMBOL_NS(asoc_sdw_get_codec_name, SND_SOC_SDW_UTILS);
 
+/* helper to get the link that the codec DAI is used */
+struct snd_soc_dai_link *asoc_sdw_mc_find_codec_dai_used(struct snd_soc_card *card,
+                                                        const char *dai_name)
+{
+       struct snd_soc_dai_link *dai_link;
+       int i;
+       int j;
+
+       for_each_card_prelinks(card, i, dai_link) {
+               for (j = 0; j < dai_link->num_codecs; j++) {
+                       /* Check each codec in a link */
+                       if (!strcmp(dai_link->codecs[j].dai_name, dai_name))
+                               return dai_link;
+               }
+       }
+       return NULL;
+}
+EXPORT_SYMBOL_NS(asoc_sdw_mc_find_codec_dai_used, SND_SOC_SDW_UTILS);
+
+void asoc_sdw_mc_dailink_exit_loop(struct snd_soc_card *card)
+{
+       struct snd_soc_dai_link *dai_link;
+       struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
+       int ret;
+       int i, j;
+
+       for (i = 0; i < ctx->codec_info_list_count; i++) {
+               for (j = 0; j < codec_info_list[i].dai_num; j++) {
+                       codec_info_list[i].dais[j].rtd_init_done = false;
+                       /* Check each dai in codec_info_lis to see if it is used in the link */
+                       if (!codec_info_list[i].dais[j].exit)
+                               continue;
+                       /*
+                        * We don't need to call .exit function if there is no matched
+                        * dai link found.
+                        */
+                       dai_link = asoc_sdw_mc_find_codec_dai_used(card,
+                                                         codec_info_list[i].dais[j].dai_name);
+                       if (dai_link) {
+                               /* Do the .exit function if the codec dai is used in the link */
+                               ret = codec_info_list[i].dais[j].exit(card, dai_link);
+                               if (ret)
+                                       dev_warn(card->dev,
+                                                "codec exit failed %d\n",
+                                                ret);
+                               break;
+                       }
+               }
+       }
+}
+EXPORT_SYMBOL_NS(asoc_sdw_mc_dailink_exit_loop, SND_SOC_SDW_UTILS);
+
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("SoundWire ASoC helpers");