]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ASoC: Vendor drivers get a link's runtime by snd_soc_get_pcm_runtime()
authorMengdong Lin <mengdong.lin@linux.intel.com>
Wed, 18 Nov 2015 07:34:01 +0000 (02:34 -0500)
committerMark Brown <broonie@kernel.org>
Wed, 18 Nov 2015 18:32:24 +0000 (18:32 +0000)
Vendor drivers no longer access a DAI link's runtime by the link index
but by matching the link name via snd_soc_get_pcm_runtime(). We assume
each DAI link has a unique name.

This is preparation for changing runtimes from an array to a list later.

Vendor drivers changed:
sound/soc/fsl/fsl-asoc-card.c
sound/soc/fsl/imx-wm8962.c
sound/soc/pxa/mioa701_wm9713.c
sound/soc/samsung/bells.c
sound/soc/samsung/littlemill.c
sound/soc/samsung/odroidx2_max98090.c
sound/soc/samsung/snow.c
sound/soc/samsung/speyside.c
sound/soc/samsung/tobermory.c
sound/soc/tegra/tegra_wm8903

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/fsl-asoc-card.c
sound/soc/fsl/imx-wm8962.c
sound/soc/pxa/mioa701_wm9713.c
sound/soc/samsung/bells.c
sound/soc/samsung/littlemill.c
sound/soc/samsung/odroidx2_max98090.c
sound/soc/samsung/snow.c
sound/soc/samsung/speyside.c
sound/soc/samsung/tobermory.c
sound/soc/tegra/tegra_wm8903.c

index 1b05d1c5d9fd50fe32eb9b65f4da1340db9170e5..f4b6c53146d59b55ac5ca84ee53d826f74123387 100644 (file)
@@ -222,12 +222,15 @@ static int fsl_asoc_card_set_bias_level(struct snd_soc_card *card,
                                        enum snd_soc_bias_level level)
 {
        struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(card);
-       struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
        struct codec_priv *codec_priv = &priv->codec_priv;
        struct device *dev = card->dev;
        unsigned int pll_out;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec_dai = rtd->codec_dai;
        if (dapm->dev != codec_dai->dev)
                return 0;
 
index b38b98cae855d0d5529f00e50d379493a6d6f753..201a70d1027a4a91bddd6dbc6e8d304071b3dd8d 100644 (file)
@@ -69,13 +69,16 @@ static int imx_wm8962_set_bias_level(struct snd_soc_card *card,
                                        struct snd_soc_dapm_context *dapm,
                                        enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
        struct imx_priv *priv = &card_priv;
        struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
        struct device *dev = &priv->pdev->dev;
        unsigned int pll_out;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec_dai = rtd->codec_dai;
        if (dapm->dev != codec_dai->dev)
                return 0;
 
@@ -135,12 +138,15 @@ static int imx_wm8962_set_bias_level(struct snd_soc_card *card,
 
 static int imx_wm8962_late_probe(struct snd_soc_card *card)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
        struct imx_priv *priv = &card_priv;
        struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
        struct device *dev = &priv->pdev->dev;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec_dai = rtd->codec_dai;
        ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK,
                        data->clk_frequency, SND_SOC_CLOCK_IN);
        if (ret < 0)
index 29bc60e85e92898e585a57202ad2540f4be61cae..5c8f9db50a47a0315f0dba8065549a527dfc43c4 100644 (file)
@@ -81,8 +81,12 @@ static int rear_amp_power(struct snd_soc_codec *codec, int power)
 static int rear_amp_event(struct snd_soc_dapm_widget *widget,
                          struct snd_kcontrol *kctl, int event)
 {
-       struct snd_soc_codec *codec = widget->dapm->card->rtd[0].codec;
+       struct snd_soc_card *card = widget->dapm->card;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_codec *codec;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec = rtd->codec;
        return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event));
 }
 
index e5f05e62fa3c11f4fd3bf7f2465f353dd2b863c4..3dd246fa0059db268bb5d035829c85f78315f65e 100644 (file)
@@ -58,11 +58,16 @@ static int bells_set_bias_level(struct snd_soc_card *card,
                                struct snd_soc_dapm_context *dapm,
                                enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
-       struct snd_soc_codec *codec = codec_dai->codec;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
+       struct snd_soc_codec *codec;
        struct bells_drvdata *bells = card->drvdata;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+       codec_dai = rtd->codec_dai;
+       codec = codec_dai->codec;
+
        if (dapm->dev != codec_dai->dev)
                return 0;
 
@@ -99,11 +104,16 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
                                     struct snd_soc_dapm_context *dapm,
                                     enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
-       struct snd_soc_codec *codec = codec_dai->codec;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
+       struct snd_soc_codec *codec;
        struct bells_drvdata *bells = card->drvdata;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+       codec_dai = rtd->codec_dai;
+       codec = codec_dai->codec;
+
        if (dapm->dev != codec_dai->dev)
                return 0;
 
@@ -137,14 +147,22 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
 static int bells_late_probe(struct snd_soc_card *card)
 {
        struct bells_drvdata *bells = card->drvdata;
-       struct snd_soc_codec *wm0010 = card->rtd[DAI_AP_DSP].codec;
-       struct snd_soc_codec *codec = card->rtd[DAI_DSP_CODEC].codec;
-       struct snd_soc_dai *aif1_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_codec *wm0010;
+       struct snd_soc_codec *codec;
+       struct snd_soc_dai *aif1_dai;
        struct snd_soc_dai *aif2_dai;
        struct snd_soc_dai *aif3_dai;
        struct snd_soc_dai *wm9081_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_AP_DSP].name);
+       wm0010 = rtd->codec;
+
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name);
+       codec = rtd->codec;
+       aif1_dai = rtd->codec_dai;
+
        ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK,
                                       ARIZONA_CLK_SRC_FLL1,
                                       bells->sysclk_rate,
@@ -181,7 +199,8 @@ static int bells_late_probe(struct snd_soc_card *card)
                return ret;
        }
 
-       aif2_dai = card->rtd[DAI_CODEC_CP].cpu_dai;
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_CP].name);
+       aif2_dai = rtd->cpu_dai;
 
        ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0);
        if (ret != 0) {
@@ -192,8 +211,9 @@ static int bells_late_probe(struct snd_soc_card *card)
        if (card->num_rtd == DAI_CODEC_SUB)
                return 0;
 
-       aif3_dai = card->rtd[DAI_CODEC_SUB].cpu_dai;
-       wm9081_dai = card->rtd[DAI_CODEC_SUB].codec_dai;
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_SUB].name);
+       aif3_dai = rtd->cpu_dai;
+       wm9081_dai = rtd->codec_dai;
 
        ret = snd_soc_dai_set_sysclk(aif3_dai, ARIZONA_CLK_SYSCLK, 0, 0);
        if (ret != 0) {
index 31a820eb0ac37b52992cbc986a17ce11d3c42ca1..7cb204e649cabba1fb15c9f4ec9c02b0f9732789 100644 (file)
@@ -23,9 +23,13 @@ static int littlemill_set_bias_level(struct snd_soc_card *card,
                                          struct snd_soc_dapm_context *dapm,
                                          enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *aif1_dai = card->rtd[0].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *aif1_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       aif1_dai = rtd->codec_dai;
+
        if (dapm->dev != aif1_dai->dev)
                return 0;
 
@@ -66,9 +70,13 @@ static int littlemill_set_bias_level_post(struct snd_soc_card *card,
                                               struct snd_soc_dapm_context *dapm,
                                               enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *aif1_dai = card->rtd[0].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *aif1_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       aif1_dai = rtd->codec_dai;
+
        if (dapm->dev != aif1_dai->dev)
                return 0;
 
@@ -168,9 +176,13 @@ static int bbclk_ev(struct snd_soc_dapm_widget *w,
                    struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_card *card = w->dapm->card;
-       struct snd_soc_dai *aif2_dai = card->rtd[1].cpu_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *aif2_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+       aif2_dai = rtd->cpu_dai;
+
        switch (event) {
        case SND_SOC_DAPM_PRE_PMU:
                ret = snd_soc_dai_set_pll(aif2_dai, WM8994_FLL2,
@@ -245,11 +257,19 @@ static struct snd_soc_jack littlemill_headset;
 
 static int littlemill_late_probe(struct snd_soc_card *card)
 {
-       struct snd_soc_codec *codec = card->rtd[0].codec;
-       struct snd_soc_dai *aif1_dai = card->rtd[0].codec_dai;
-       struct snd_soc_dai *aif2_dai = card->rtd[1].cpu_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_codec *codec;
+       struct snd_soc_dai *aif1_dai;
+       struct snd_soc_dai *aif2_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec = rtd->codec;
+       aif1_dai = rtd->codec_dai;
+
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+       aif2_dai = rtd->cpu_dai;
+
        ret = snd_soc_dai_set_sysclk(aif1_dai, WM8994_SYSCLK_MCLK2,
                                     32768, SND_SOC_CLOCK_IN);
        if (ret < 0)
index 596f1180a3698627844a0e8746e8d64bf0441f47..04217279fe258934e4d1614f39816856a2eb5165 100644 (file)
@@ -25,10 +25,15 @@ static struct snd_soc_dai_link odroidx2_dai[];
 
 static int odroidx2_late_probe(struct snd_soc_card *card)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
-       struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
+       struct snd_soc_dai *cpu_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec_dai = rtd->codec_dai;
+       cpu_dai = rtd->cpu_dai;
+
        ret = snd_soc_dai_set_sysclk(codec_dai, 0, MAX98090_MCLK,
                                                SND_SOC_CLOCK_IN);
 
index 07ce2cfa484503af827c19c478d2f123830126d9..d8ac907bbb0d76c2df3ca9900b1ae05b1140faa2 100644 (file)
@@ -35,10 +35,15 @@ static struct snd_soc_dai_link snow_dai[] = {
 
 static int snow_late_probe(struct snd_soc_card *card)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
-       struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
+       struct snd_soc_dai *cpu_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec_dai = rtd->codec_dai;
+       cpu_dai = rtd->cpu_dai;
+
        /* Set the MCLK rate for the codec */
        ret = snd_soc_dai_set_sysclk(codec_dai, 0,
                                        FIN_PLL_RATE, SND_SOC_CLOCK_IN);
index d1ae21c5e25320e525a8431639e811e47c264a4e..083ef5e21b17f26b710de3bdf0c2523cf3e613f8 100644 (file)
@@ -25,9 +25,13 @@ static int speyside_set_bias_level(struct snd_soc_card *card,
                                   struct snd_soc_dapm_context *dapm,
                                   enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[1].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+       codec_dai = rtd->codec_dai;
+
        if (dapm->dev != codec_dai->dev)
                return 0;
 
@@ -57,9 +61,13 @@ static int speyside_set_bias_level_post(struct snd_soc_card *card,
                                        struct snd_soc_dapm_context *dapm,
                                        enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[1].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
+       codec_dai = rtd->codec_dai;
+
        if (dapm->dev != codec_dai->dev)
                return 0;
 
index 85ccfb7188cb2d4b36101f14d0fa3dc024436f6f..3310eda7cf53b378c646b7dcdf83d66eb6c06baf 100644 (file)
@@ -23,9 +23,13 @@ static int tobermory_set_bias_level(struct snd_soc_card *card,
                                          struct snd_soc_dapm_context *dapm,
                                          enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec_dai = rtd->codec_dai;
+
        if (dapm->dev != codec_dai->dev)
                return 0;
 
@@ -62,9 +66,13 @@ static int tobermory_set_bias_level_post(struct snd_soc_card *card,
                                               struct snd_soc_dapm_context *dapm,
                                               enum snd_soc_bias_level level)
 {
-       struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_dai *codec_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec_dai = rtd->codec_dai;
+
        if (dapm->dev != codec_dai->dev)
                return 0;
 
@@ -170,10 +178,15 @@ static struct snd_soc_jack_pin tobermory_headset_pins[] = {
 
 static int tobermory_late_probe(struct snd_soc_card *card)
 {
-       struct snd_soc_codec *codec = card->rtd[0].codec;
-       struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
+       struct snd_soc_pcm_runtime *rtd;
+       struct snd_soc_codec *codec;
+       struct snd_soc_dai *codec_dai;
        int ret;
 
+       rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
+       codec = rtd->codec;
+       codec_dai = rtd->codec_dai;
+
        ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK,
                                     32768, SND_SOC_CLOCK_IN);
        if (ret < 0)
index 21604009bc1a2df338e6696c83f78a3473174254..e485278e027a251189a16f77c3f24a2428bb2b7a 100644 (file)
@@ -199,7 +199,8 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
 
 static int tegra_wm8903_remove(struct snd_soc_card *card)
 {
-       struct snd_soc_pcm_runtime *rtd = &(card->rtd[0]);
+       struct snd_soc_pcm_runtime *rtd =
+               snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
        struct snd_soc_codec *codec = codec_dai->codec;
        struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);