struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
        struct snd_pcm_runtime *runtime = substream->runtime;
-       int memif_num = rtd->cpu_dai->id;
+       int memif_num = asoc_rtd_to_cpu(rtd, 0)->id;
        struct mtk_base_afe_memif *memif = &afe->memif[memif_num];
        const struct snd_pcm_hardware *mtk_afe_hardware = afe->mtk_afe_hardware;
        int ret;
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
-       struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
+       struct mtk_base_afe_memif *memif = &afe->memif[asoc_rtd_to_cpu(rtd, 0)->id];
        int irq_id;
 
        irq_id = memif->irq_usage;
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
-       int id = rtd->cpu_dai->id;
+       int id = asoc_rtd_to_cpu(rtd, 0)->id;
        struct mtk_base_afe_memif *memif = &afe->memif[id];
        int ret;
        unsigned int channels = params_channels(params);
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_pcm_runtime * const runtime = substream->runtime;
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
-       int id = rtd->cpu_dai->id;
+       int id = asoc_rtd_to_cpu(rtd, 0)->id;
        struct mtk_base_afe_memif *memif = &afe->memif[id];
        struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage];
        const struct mtk_base_irq_data *irq_data = irqs->irq_data;
 {
        struct snd_soc_pcm_runtime *rtd  = substream->private_data;
        struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
-       int id = rtd->cpu_dai->id;
+       int id = asoc_rtd_to_cpu(rtd, 0)->id;
        int pbuf_size;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
-       struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
+       struct mtk_base_afe_memif *memif = &afe->memif[asoc_rtd_to_cpu(rtd, 0)->id];
        const struct mtk_base_memif_data *memif_data = memif->data;
        struct regmap *regmap = afe->regmap;
        struct device *dev = afe->dev;
 
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        int fs;
 
-       if (rtd->cpu_dai->id != MT2701_MEMIF_ULBT)
+       if (asoc_rtd_to_cpu(rtd, 0)->id != MT2701_MEMIF_ULBT)
                fs = mt2701_afe_i2s_fs(rate);
        else
                fs = (rate == 16000 ? 1 : 0);
 
                                           struct snd_pcm_hw_params *params)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+       struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
        unsigned int mclk_rate;
        unsigned int rate = params_rate(params);
        unsigned int div_mclk_over_bck = rate > 192000 ? 2 : 4;
 
                                          struct snd_pcm_hw_params *params)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+       struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
        unsigned int mclk_rate;
        unsigned int rate = params_rate(params);
        unsigned int div_mclk_over_bck = rate > 192000 ? 2 : 4;
 
        struct snd_soc_component *component =
                snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
        struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
-       int id = rtd->cpu_dai->id;
+       int id = asoc_rtd_to_cpu(rtd, 0)->id;
 
        return mt6797_rate_transform(afe->dev, rate, id);
 }
 
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
        struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
-       struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
+       struct mtk_base_afe_memif *memif = &afe->memif[asoc_rtd_to_cpu(rtd, 0)->id];
        int fs;
 
        if (memif->data->id == MT8173_AFE_MEMIF_DAI ||
 
                                     struct snd_pcm_hw_params *params)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 
        return snd_soc_dai_set_sysclk(codec_dai, 0, params_rate(params) * 256,
                                      SND_SOC_CLOCK_IN);
 {
        int ret;
        struct snd_soc_card *card = runtime->card;
-       struct snd_soc_component *component = runtime->codec_dai->component;
+       struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
 
        /* enable jack detection */
        ret = snd_soc_card_jack_new(card, "Headphone", SND_JACK_HEADPHONE,
 
 static int mt8173_rt5650_rt5514_init(struct snd_soc_pcm_runtime *runtime)
 {
        struct snd_soc_card *card = runtime->card;
-       struct snd_soc_component *component = runtime->codec_dais[0]->component;
+       struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
        int ret;
 
        rt5645_sel_asrc_clk_src(component,
 
 static int mt8173_rt5650_rt5676_init(struct snd_soc_pcm_runtime *runtime)
 {
        struct snd_soc_card *card = runtime->card;
-       struct snd_soc_component *component = runtime->codec_dais[0]->component;
-       struct snd_soc_component *component_sub = runtime->codec_dais[1]->component;
+       struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
+       struct snd_soc_component *component_sub = asoc_rtd_to_codec(runtime, 1)->component;
        int ret;
 
        rt5645_sel_asrc_clk_src(component,
 
 static int mt8173_rt5650_init(struct snd_soc_pcm_runtime *runtime)
 {
        struct snd_soc_card *card = runtime->card;
-       struct snd_soc_component *component = runtime->codec_dais[0]->component;
-       const char *codec_capture_dai = runtime->codec_dais[1]->name;
+       struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
+       const char *codec_capture_dai = asoc_rtd_to_codec(runtime, 1)->name;
        int ret;
 
        rt5645_sel_asrc_clk_src(component,
        if (ret)
                return ret;
 
-       return hdmi_codec_set_jack_detect(rtd->codec_dai->component,
+       return hdmi_codec_set_jack_detect(asoc_rtd_to_codec(rtd, 0)->component,
                                          &mt8173_rt5650_hdmi_jack);
 }
 
 
        struct snd_soc_component *component =
                snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
        struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
-       int id = rtd->cpu_dai->id;
+       int id = asoc_rtd_to_cpu(rtd, 0)->id;
 
        return mt8183_rate_transform(afe->dev, rate, id);
 }
 
        unsigned int mclk_fs_ratio = 128;
        unsigned int mclk_fs = rate * mclk_fs_ratio;
 
-       return snd_soc_dai_set_sysclk(rtd->cpu_dai,
+       return snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0),
                                      0, mclk_fs, SND_SOC_CLOCK_OUT);
 }
 
        unsigned int freq;
        int ret = 0, j;
 
-       ret = snd_soc_dai_set_sysclk(rtd->cpu_dai, 0,
+       ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0), 0,
                                     mclk_fs, SND_SOC_CLOCK_OUT);
        if (ret < 0)
                dev_err(rtd->dev, "failed to set cpu dai sysclk\n");
 
        unsigned int mclk_fs_ratio = 128;
        unsigned int mclk_fs = rate * mclk_fs_ratio;
 
-       return snd_soc_dai_set_sysclk(rtd->cpu_dai,
+       return snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0),
                                      0, mclk_fs, SND_SOC_CLOCK_OUT);
 }