Skip to content

Commit

Permalink
ASoC: Intel: sof_sdw: use sof_hdmi_private to init HDMI
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Brent Lu <[email protected]>
Signed-off-by: Pierre-Louis Bossart <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
brentlu authored and broonie committed Oct 12, 2023
1 parent d8fc817 commit 5cfe9ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 36 deletions.
12 changes: 4 additions & 8 deletions sound/soc/intel/boards/sof_sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1757,7 +1755,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
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);
Expand All @@ -1769,7 +1767,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/intel/boards/sof_sdw_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down
30 changes: 4 additions & 26 deletions sound/soc/intel/boards/sof_sdw_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,25 @@
#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);
}

0 comments on commit 5cfe9ed

Please sign in to comment.