OSDN Git Service

ASoC: sof: use modern dai_link style
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 6 Jun 2019 04:19:24 +0000 (13:19 +0900)
committerMark Brown <broonie@kernel.org>
Thu, 6 Jun 2019 21:10:38 +0000 (22:10 +0100)
ASoC is now supporting modern style dai_link
(= snd_soc_dai_link_component) for CPU/Codec/Platform.
This patch switches to use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/nocodec.c
sound/soc/sof/topology.c

index f84b434..3d128e5 100644 (file)
@@ -21,6 +21,7 @@ static int sof_nocodec_bes_setup(struct device *dev,
                                 struct snd_soc_dai_link *links,
                                 int link_num, struct snd_soc_card *card)
 {
+       struct snd_soc_dai_link_component *dlc;
        int i;
 
        if (!ops || !links || !card)
@@ -28,17 +29,29 @@ static int sof_nocodec_bes_setup(struct device *dev,
 
        /* set up BE dai_links */
        for (i = 0; i < link_num; i++) {
+               dlc = devm_kzalloc(dev, 3 * sizeof(*dlc), GFP_KERNEL);
+               if (!dlc)
+                       return -ENOMEM;
+
                links[i].name = devm_kasprintf(dev, GFP_KERNEL,
                                               "NoCodec-%d", i);
                if (!links[i].name)
                        return -ENOMEM;
 
+               links[i].cpus = &dlc[0];
+               links[i].codecs = &dlc[1];
+               links[i].platforms = &dlc[2];
+
+               links[i].num_cpus = 1;
+               links[i].num_codecs = 1;
+               links[i].num_platforms = 1;
+
                links[i].id = i;
                links[i].no_pcm = 1;
-               links[i].cpu_dai_name = ops->drv[i].name;
-               links[i].platform_name = dev_name(dev);
-               links[i].codec_dai_name = "snd-soc-dummy-dai";
-               links[i].codec_name = "snd-soc-dummy";
+               links[i].cpus->dai_name = ops->drv[i].name;
+               links[i].platforms->name = dev_name(dev);
+               links[i].codecs->dai_name = "snd-soc-dummy-dai";
+               links[i].codecs->name = "snd-soc-dummy";
                links[i].dpcm_playback = 1;
                links[i].dpcm_capture = 1;
        }
index b969686..a13233a 100644 (file)
@@ -2639,7 +2639,6 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index,
                             struct sof_ipc_dai_config *config)
 {
        struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
-       struct snd_soc_dai_link_component dai_component;
        struct snd_soc_tplg_private *private = &cfg->priv;
        struct snd_soc_dai *dai;
        u32 size = sizeof(*config);
@@ -2650,7 +2649,6 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index,
        int ret;
 
        /* init IPC */
-       memset(&dai_component, 0, sizeof(dai_component));
        memset(&config->hda, 0, sizeof(struct sof_ipc_dai_hda_params));
        config->hdr.size = size;
 
@@ -2664,11 +2662,10 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index,
                return ret;
        }
 
-       dai_component.dai_name = link->cpu_dai_name;
-       dai = snd_soc_find_dai(&dai_component);
+       dai = snd_soc_find_dai(link->cpus);
        if (!dai) {
                dev_err(sdev->dev, "error: failed to find dai %s in %s",
-                       dai_component.dai_name, __func__);
+                       link->cpus->dai_name, __func__);
                return -EINVAL;
        }
 
@@ -2708,7 +2705,11 @@ static int sof_link_load(struct snd_soc_component *scomp, int index,
        int ret;
        int i = 0;
 
-       link->platform_name = dev_name(sdev->dev);
+       if (!link->platforms) {
+               dev_err(sdev->dev, "error: no platforms\n");
+               return -EINVAL;
+       }
+       link->platforms->name = dev_name(sdev->dev);
 
        /*
         * Set nonatomic property for FE dai links as their trigger action
@@ -2801,16 +2802,13 @@ static int sof_link_load(struct snd_soc_component *scomp, int index,
 static int sof_link_hda_unload(struct snd_sof_dev *sdev,
                               struct snd_soc_dai_link *link)
 {
-       struct snd_soc_dai_link_component dai_component;
        struct snd_soc_dai *dai;
        int ret = 0;
 
-       memset(&dai_component, 0, sizeof(dai_component));
-       dai_component.dai_name = link->cpu_dai_name;
-       dai = snd_soc_find_dai(&dai_component);
+       dai = snd_soc_find_dai(link->cpus);
        if (!dai) {
                dev_err(sdev->dev, "error: failed to find dai %s in %s",
-                       dai_component.dai_name, __func__);
+                       link->cpus->dai_name, __func__);
                return -EINVAL;
        }