ASoC: Intel: sof_sdw: use sof_hdmi_private to init HDMI
authorBrent Lu <brent.lu@intel.com>
Thu, 12 Oct 2023 19:08:20 +0000 (15:08 -0400)
committerMark Brown <broonie@kernel.org>
Thu, 12 Oct 2023 19:27:59 +0000 (20:27 +0100)
Use sof_hdmi_private structure instead of a link list of sof_hdmi_pcm
structure for HDMI dai link initialization since hdac-hdmi support is
removed.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Brent Lu <brent.lu@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20231012190826.142619-18-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/sof_sdw.c
sound/soc/intel/boards/sof_sdw_common.h
sound/soc/intel/boards/sof_sdw_hdmi.c

index cb5d713..c5d555c 100644 (file)
@@ -1542,8 +1542,6 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
        return 0;
 }
 
-#define IDISP_CODEC_MASK       0x4
-
 static int sof_card_dai_links_create(struct snd_soc_card *card)
 {
        struct device *dev = card->dev;
@@ -1587,7 +1585,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
        }
 
        if (mach_params->codec_mask & IDISP_CODEC_MASK) {
-               ctx->idisp_codec = true;
+               ctx->hdmi.idisp_codec = true;
 
                if (sof_sdw_quirk & SOF_SDW_TGL_HDMI)
                        hdmi_num = SOF_TGL_HDMI_COUNT;
@@ -1757,7 +1755,7 @@ HDMI:
                name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", i + 1);
                cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d Pin", i + 1);
 
-               if (ctx->idisp_codec) {
+               if (ctx->hdmi.idisp_codec) {
                        codec_name = "ehdaudio0D2";
                        codec_dai_name = devm_kasprintf(dev, GFP_KERNEL,
                                                        "intel-hdmi-hifi%d", i + 1);
@@ -1769,7 +1767,7 @@ HDMI:
                ret = init_simple_dai_link(dev, dai_links + link_index, &be_id, name,
                                           1, 0, // HDMI only supports playback
                                           cpu_dai_name, codec_name, codec_dai_name,
-                                          sof_sdw_hdmi_init, NULL);
+                                          i == 0 ? sof_sdw_hdmi_init : NULL, NULL);
                if (ret)
                        return ret;
 
@@ -1814,7 +1812,7 @@ static int sof_sdw_card_late_probe(struct snd_soc_card *card)
                }
        }
 
-       if (ctx->idisp_codec)
+       if (ctx->hdmi.idisp_codec)
                ret = sof_sdw_hdmi_card_late_probe(card);
 
        return ret;
@@ -1893,8 +1891,6 @@ static int mc_probe(struct platform_device *pdev)
        if (!ctx)
                return -ENOMEM;
 
-       INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
-
        snd_soc_card_set_drvdata(card, ctx);
 
        dmi_check_system(sof_sdw_quirk_table);
index bfdeab4..e6b9852 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/bits.h>
 #include <linux/types.h>
 #include <sound/soc.h>
+#include "sof_hdmi_common.h"
 
 #define MAX_NO_PROPS 2
 #define MAX_HDMI_NUM 4
@@ -94,9 +95,8 @@ struct sof_sdw_codec_info {
 };
 
 struct mc_private {
-       struct list_head hdmi_pcm_list;
-       bool idisp_codec;
        struct snd_soc_jack sdw_headset;
+       struct sof_hdmi_private hdmi;
        struct device *headset_codec_dev; /* only one headset per card */
        struct device *amp_dev1, *amp_dev2;
        /* To store SDW Pin index for each SoundWire link */
index 7e07aa6..f34fabd 100644 (file)
 #include "sof_sdw_common.h"
 #include "hda_dsp_common.h"
 
-struct hdmi_pcm {
-       struct list_head head;
-       struct snd_soc_dai *codec_dai;
-       int device;
-};
-
 int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd)
 {
        struct mc_private *ctx = snd_soc_card_get_drvdata(rtd->card);
        struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
-       struct hdmi_pcm *pcm;
-
-       pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
-       if (!pcm)
-               return -ENOMEM;
 
-       /* dai_link id is 1:1 mapped to the PCM device */
-       pcm->device = rtd->dai_link->id;
-       pcm->codec_dai = dai;
-
-       list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
+       ctx->hdmi.hdmi_comp = dai->component;
 
        return 0;
 }
 
-#define NAME_SIZE      32
 int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card)
 {
        struct mc_private *ctx = snd_soc_card_get_drvdata(card);
-       struct hdmi_pcm *pcm;
-       struct snd_soc_component *component = NULL;
 
-       if (!ctx->idisp_codec)
+       if (!ctx->hdmi.idisp_codec)
                return 0;
 
-       if (list_empty(&ctx->hdmi_pcm_list))
+       if (!ctx->hdmi.hdmi_comp)
                return -EINVAL;
 
-       pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm,
-                              head);
-       component = pcm->codec_dai->component;
-
-       return hda_dsp_hdmi_build_controls(card, component);
+       return hda_dsp_hdmi_build_controls(card, ctx->hdmi.hdmi_comp);
 }