ASoC: Intel: skl_hda_dsp_generic: use sof_hdmi_private to init HDMI
authorBrent Lu <brent.lu@intel.com>
Tue, 27 Aug 2024 12:32:11 +0000 (20:32 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 28 Aug 2024 12:02:02 +0000 (13:02 +0100)
Use sof_hdmi_private structure instead of a link list of
skl_hda_hdmi_pcm structure for HDMI dai link initialization since
hdac-hdmi support is removed.

Signed-off-by: Brent Lu <brent.lu@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://patch.msgid.link/20240827123215.258859-14-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/skl_hda_dsp_common.c
sound/soc/intel/boards/skl_hda_dsp_common.h
sound/soc/intel/boards/skl_hda_dsp_generic.c

index d1de772e9304fa4e49c9fd72e36782d98a8d0e35..5019bdfa5b456178471237ba7bbf9466f8cb892e 100644 (file)
 int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
 {
        struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
-       struct skl_hda_hdmi_pcm *pcm;
+       struct snd_soc_dai *dai;
        char dai_name[NAME_SIZE];
 
-       pcm = devm_kzalloc(card->dev, sizeof(*pcm), GFP_KERNEL);
-       if (!pcm)
-               return -ENOMEM;
-
        snprintf(dai_name, sizeof(dai_name), "intel-hdmi-hifi%d",
                 ctx->dai_index);
-       pcm->codec_dai = snd_soc_card_get_codec_dai(card, dai_name);
-       if (!pcm->codec_dai)
+       dai = snd_soc_card_get_codec_dai(card, dai_name);
+       if (!dai)
                return -EINVAL;
 
-       list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
+       ctx->hdmi.hdmi_comp = dai->component;
 
        return 0;
 }
@@ -148,18 +144,13 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 int skl_hda_hdmi_jack_init(struct snd_soc_card *card)
 {
        struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
-       struct snd_soc_component *component;
-       struct skl_hda_hdmi_pcm *pcm;
 
        /* HDMI disabled, do not create controls */
-       if (list_empty(&ctx->hdmi_pcm_list))
+       if (!ctx->hdmi.idisp_codec)
                return 0;
 
-       pcm = list_first_entry(&ctx->hdmi_pcm_list, struct skl_hda_hdmi_pcm,
-                              head);
-       component = pcm->codec_dai->component;
-       if (!component)
+       if (!ctx->hdmi.hdmi_comp)
                return -EINVAL;
 
-       return hda_dsp_hdmi_build_controls(card, component);
+       return hda_dsp_hdmi_build_controls(card, ctx->hdmi.hdmi_comp);
 }
index 8455f953f4b83498ed7b05b75f3791d8529627c1..40ffbccb2fe00c6c6d5e4a04f1ff578c89dc7e08 100644 (file)
 #include <sound/hda_codec.h>
 #include "../../codecs/hdac_hda.h"
 #include "hda_dsp_common.h"
+#include "sof_hdmi_common.h"
 
 #define HDA_DSP_MAX_BE_DAI_LINKS 8
 
-struct skl_hda_hdmi_pcm {
-       struct list_head head;
-       struct snd_soc_dai *codec_dai;
-};
-
 struct skl_hda_private {
        struct snd_soc_card card;
-       struct list_head hdmi_pcm_list;
+       struct sof_hdmi_private hdmi;
        int pcm_count;
        int dai_index;
        const char *platform_name;
-       bool idisp_codec;
        bool bt_offload_present;
        int ssp_bt;
 };
index 860a21915bce67eeba679f1216b2d7c41df36674..225867bb3310a25ab27b7e2b125df00eb012dd7d 100644 (file)
@@ -75,7 +75,7 @@ skl_hda_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link)
        link->platforms->name = ctx->platform_name;
        link->nonatomic = 1;
 
-       if (!ctx->idisp_codec)
+       if (!ctx->hdmi.idisp_codec)
                return 0;
 
        if (strstr(link->name, "HDMI")) {
@@ -98,7 +98,6 @@ skl_hda_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link)
 
 /* there are two routes per iDisp output */
 #define IDISP_ROUTE_COUNT      (IDISP_DAI_COUNT * 2)
-#define IDISP_CODEC_MASK       0x4
 
 #define HDA_CODEC_AUTOSUSPEND_DELAY_MS 1000
 
@@ -113,10 +112,9 @@ static int skl_hda_fill_card_info(struct device *dev, struct snd_soc_card *card,
 
        codec_mask = mach_params->codec_mask;
        codec_count = hweight_long(codec_mask);
-       ctx->idisp_codec = !!(codec_mask & IDISP_CODEC_MASK);
 
        if (!codec_count || codec_count > 2 ||
-           (codec_count == 2 && !ctx->idisp_codec))
+           (codec_count == 2 && !ctx->hdmi.idisp_codec))
                return -EINVAL;
 
        if (codec_mask == IDISP_CODEC_MASK) {
@@ -141,7 +139,7 @@ static int skl_hda_fill_card_info(struct device *dev, struct snd_soc_card *card,
                num_route = ARRAY_SIZE(skl_hda_map);
                card->dapm_widgets = skl_hda_widgets;
                card->num_dapm_widgets = ARRAY_SIZE(skl_hda_widgets);
-               if (!ctx->idisp_codec) {
+               if (!ctx->hdmi.idisp_codec) {
                        card->dapm_routes = &skl_hda_map[IDISP_ROUTE_COUNT];
                        num_route -= IDISP_ROUTE_COUNT;
                        for (i = 0; i < IDISP_DAI_COUNT; i++) {
@@ -218,8 +216,6 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
        if (!ctx)
                return -ENOMEM;
 
-       INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
-
        card = &ctx->card;
        card->name = "hda-dsp",
        card->owner = THIS_MODULE,
@@ -232,6 +228,9 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
 
        snd_soc_card_set_drvdata(card, ctx);
 
+       if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
+               ctx->hdmi.idisp_codec = true;
+
        if (hweight_long(mach->mach_params.bt_link_mask) == 1) {
                ctx->bt_offload_present = true;
                ctx->ssp_bt = fls(mach->mach_params.bt_link_mask) - 1;