Unverified Commit 4775073b authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: Intel: Link handling rework and fixes

Merge series from Peter Ujfalusi <peter.ujfalusi@linux.intel.com>:

SOF board updates for 6.8 including few small fix and the majority is to add
generic helpers for codec, amp, BT offload, HDMI-In and DAI link generation
among various machine drivers.
parents b2b6b2d8 8fa1116e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -93,8 +93,12 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
		 * when codec is runtime suspended. Codec needs clock for jack
		 * detection and button press.
		 */
		snd_soc_dai_set_sysclk(codec_dai, RT5670_SCLK_S_RCCLK,
		ret = snd_soc_dai_set_sysclk(codec_dai, RT5670_SCLK_S_RCCLK,
					     48000 * 512, SND_SOC_CLOCK_IN);
		if (ret < 0) {
			dev_err(card->dev, "failed to set codec sysclk: %d\n", ret);
			return ret;
		}

		if (ctx->mclk)
			clk_disable_unprepare(ctx->mclk);
+330 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
// Copyright(c) 2023 Intel Corporation. All rights reserved.

#include <sound/soc.h>
#include "../common/soc-intel-quirks.h"
#include "hda_dsp_common.h"
#include "sof_board_helpers.h"

@@ -86,6 +87,55 @@ static struct snd_soc_dai_link_component platform_component[] = {
	}
};

int sof_intel_board_set_codec_link(struct device *dev,
				   struct snd_soc_dai_link *link, int be_id,
				   enum sof_ssp_codec codec_type, int ssp_codec)
{
	struct snd_soc_dai_link_component *cpus;

	dev_dbg(dev, "link %d: codec %s, ssp %d\n", be_id,
		sof_ssp_get_codec_name(codec_type), ssp_codec);

	/* link name */
	link->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_codec);
	if (!link->name)
		return -ENOMEM;

	/* cpus */
	cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
			    GFP_KERNEL);
	if (!cpus)
		return -ENOMEM;

	if (soc_intel_is_byt() || soc_intel_is_cht()) {
		/* backward-compatibility for BYT/CHT boards */
		cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "ssp%d-port",
						ssp_codec);
	} else {
		cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin",
						ssp_codec);
	}
	if (!cpus->dai_name)
		return -ENOMEM;

	link->cpus = cpus;
	link->num_cpus = 1;

	/* codecs - caller to handle */

	/* platforms */
	link->platforms = platform_component;
	link->num_platforms = ARRAY_SIZE(platform_component);

	link->id = be_id;
	link->no_pcm = 1;
	link->dpcm_capture = 1;
	link->dpcm_playback = 1;

	return 0;
}
EXPORT_SYMBOL_NS(sof_intel_board_set_codec_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

int sof_intel_board_set_dmic_link(struct device *dev,
				  struct snd_soc_dai_link *link, int be_id,
				  enum sof_dmic_be_type be_type)
@@ -198,7 +248,287 @@ int sof_intel_board_set_intel_hdmi_link(struct device *dev,
}
EXPORT_SYMBOL_NS(sof_intel_board_set_intel_hdmi_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

int sof_intel_board_set_ssp_amp_link(struct device *dev,
				     struct snd_soc_dai_link *link, int be_id,
				     enum sof_ssp_codec amp_type, int ssp_amp)
{
	struct snd_soc_dai_link_component *cpus;

	dev_dbg(dev, "link %d: ssp amp %s, ssp %d\n", be_id,
		sof_ssp_get_codec_name(amp_type), ssp_amp);

	/* link name */
	link->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_amp);
	if (!link->name)
		return -ENOMEM;

	/* cpus */
	cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
			    GFP_KERNEL);
	if (!cpus)
		return -ENOMEM;

	cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_amp);
	if (!cpus->dai_name)
		return -ENOMEM;

	link->cpus = cpus;
	link->num_cpus = 1;

	/* codecs - caller to handle */

	/* platforms */
	link->platforms = platform_component;
	link->num_platforms = ARRAY_SIZE(platform_component);

	link->id = be_id;
	link->no_pcm = 1;
	link->dpcm_capture = 1; /* feedback stream or firmware-generated echo reference */
	link->dpcm_playback = 1;

	return 0;
}
EXPORT_SYMBOL_NS(sof_intel_board_set_ssp_amp_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

int sof_intel_board_set_bt_link(struct device *dev,
				struct snd_soc_dai_link *link, int be_id,
				int ssp_bt)
{
	struct snd_soc_dai_link_component *cpus;

	dev_dbg(dev, "link %d: bt offload, ssp %d\n", be_id, ssp_bt);

	/* link name */
	link->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", ssp_bt);
	if (!link->name)
		return -ENOMEM;

	/* cpus */
	cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
			    GFP_KERNEL);
	if (!cpus)
		return -ENOMEM;

	cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_bt);
	if (!cpus->dai_name)
		return -ENOMEM;

	link->cpus = cpus;
	link->num_cpus = 1;

	/* codecs */
	link->codecs = &snd_soc_dummy_dlc;
	link->num_codecs = 1;

	/* platforms */
	link->platforms = platform_component;
	link->num_platforms = ARRAY_SIZE(platform_component);

	link->id = be_id;
	link->no_pcm = 1;
	link->dpcm_capture = 1;
	link->dpcm_playback = 1;

	return 0;
}
EXPORT_SYMBOL_NS(sof_intel_board_set_bt_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

int sof_intel_board_set_hdmi_in_link(struct device *dev,
				     struct snd_soc_dai_link *link, int be_id,
				     int ssp_hdmi)
{
	struct snd_soc_dai_link_component *cpus;

	dev_dbg(dev, "link %d: hdmi-in, ssp %d\n", be_id, ssp_hdmi);

	/* link name */
	link->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-HDMI", ssp_hdmi);
	if (!link->name)
		return -ENOMEM;

	/* cpus */
	cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
			    GFP_KERNEL);
	if (!cpus)
		return -ENOMEM;

	cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_hdmi);
	if (!cpus->dai_name)
		return -ENOMEM;

	link->cpus = cpus;
	link->num_cpus = 1;

	/* codecs */
	link->codecs = &snd_soc_dummy_dlc;
	link->num_codecs = 1;

	/* platforms */
	link->platforms = platform_component;
	link->num_platforms = ARRAY_SIZE(platform_component);

	link->id = be_id;
	link->no_pcm = 1;
	link->dpcm_capture = 1;

	return 0;
}
EXPORT_SYMBOL_NS(sof_intel_board_set_hdmi_in_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

static int calculate_num_links(struct sof_card_private *ctx)
{
	int num_links = 0;

	/* headphone codec */
	if (ctx->codec_type != CODEC_NONE)
		num_links++;

	/* dmic01 and dmic16k */
	if (ctx->dmic_be_num > 0)
		num_links++;

	if (ctx->dmic_be_num > 1)
		num_links++;

	/* idisp HDMI */
	num_links += ctx->hdmi_num;

	/* speaker amp */
	if (ctx->amp_type != CODEC_NONE)
		num_links++;

	/* BT audio offload */
	if (ctx->bt_offload_present)
		num_links++;

	/* HDMI-In */
	num_links += hweight32(ctx->ssp_mask_hdmi_in);

	return num_links;
}

int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
				 struct sof_card_private *ctx)
{
	struct snd_soc_dai_link *links;
	int num_links;
	int i;
	int idx = 0;
	int ret;
	int ssp_hdmi_in = 0;

	num_links = calculate_num_links(ctx);

	links = devm_kcalloc(dev, num_links, sizeof(struct snd_soc_dai_link),
			     GFP_KERNEL);
	if (!links)
		return -ENOMEM;

	/* headphone codec */
	if (ctx->codec_type != CODEC_NONE) {
		ret = sof_intel_board_set_codec_link(dev, &links[idx], idx,
						     ctx->codec_type,
						     ctx->ssp_codec);
		if (ret) {
			dev_err(dev, "fail to set codec link, ret %d\n", ret);
			return ret;
		}

		ctx->codec_link = &links[idx];
		idx++;
	}

	/* dmic01 and dmic16k */
	if (ctx->dmic_be_num > 0) {
		/* at least we have dmic01 */
		ret = sof_intel_board_set_dmic_link(dev, &links[idx], idx,
						    SOF_DMIC_01);
		if (ret) {
			dev_err(dev, "fail to set dmic01 link, ret %d\n", ret);
			return ret;
		}

		idx++;
	}

	if (ctx->dmic_be_num > 1) {
		/* set up 2 BE links at most */
		ret = sof_intel_board_set_dmic_link(dev, &links[idx], idx,
						    SOF_DMIC_16K);
		if (ret) {
			dev_err(dev, "fail to set dmic16k link, ret %d\n", ret);
			return ret;
		}

		idx++;
	}

	/* idisp HDMI */
	for (i = 1; i <= ctx->hdmi_num; i++) {
		ret = sof_intel_board_set_intel_hdmi_link(dev, &links[idx], idx,
							  i,
							  ctx->hdmi.idisp_codec);
		if (ret) {
			dev_err(dev, "fail to set hdmi link, ret %d\n", ret);
			return ret;
		}

		idx++;
	}

	/* speaker amp */
	if (ctx->amp_type != CODEC_NONE) {
		ret = sof_intel_board_set_ssp_amp_link(dev, &links[idx], idx,
						       ctx->amp_type,
						       ctx->ssp_amp);
		if (ret) {
			dev_err(dev, "fail to set amp link, ret %d\n", ret);
			return ret;
		}

		ctx->amp_link = &links[idx];
		idx++;
	}

	/* BT audio offload */
	if (ctx->bt_offload_present) {
		ret = sof_intel_board_set_bt_link(dev, &links[idx], idx,
						  ctx->ssp_bt);
		if (ret) {
			dev_err(dev, "fail to set bt link, ret %d\n", ret);
			return ret;
		}

		idx++;
	}

	/* HDMI-In */
	for_each_set_bit(ssp_hdmi_in, &ctx->ssp_mask_hdmi_in, 32) {
		ret = sof_intel_board_set_hdmi_in_link(dev, &links[idx], idx,
						       ssp_hdmi_in);
		if (ret) {
			dev_err(dev, "fail to set hdmi-in link, ret %d\n", ret);
			return ret;
		}

		idx++;
	}

	if (idx != num_links) {
		dev_err(dev, "link number mismatch, idx %d, num_links %d\n", idx,
			num_links);
		return -EINVAL;
	}

	card->dai_link = links;
	card->num_links = num_links;

	return 0;
}
EXPORT_SYMBOL_NS(sof_intel_board_set_dai_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

MODULE_DESCRIPTION("ASoC Intel SOF Machine Driver Board Helpers");
MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
+31 −0
Original line number Diff line number Diff line
@@ -30,6 +30,13 @@ struct sof_rt5682_private {
 * @amp_type: type of speaker amplifier
 * @dmic_be_num: number of Intel PCH DMIC BE link
 * @hdmi_num: number of Intel HDMI BE link
 * @ssp_codec: ssp port number of headphone BE link
 * @ssp_amp: ssp port number of speaker BE link
 * @ssp_bt: ssp port number of BT offload BE link
 * @ssp_mask_hdmi_in: ssp port mask of HDMI-IN BE link
 * @bt_offload_present: true to create BT offload BE link
 * @codec_link: pointer to headset codec dai link
 * @amp_link: pointer to speaker amplifier dai link
 * @rt5682: private data for rt5682 machine driver
 */
struct sof_card_private {
@@ -42,6 +49,16 @@ struct sof_card_private {
	int dmic_be_num;
	int hdmi_num;

	int ssp_codec;
	int ssp_amp;
	int ssp_bt;
	unsigned long ssp_mask_hdmi_in;

	bool bt_offload_present;

	struct snd_soc_dai_link *codec_link;
	struct snd_soc_dai_link *amp_link;

	union {
		struct sof_rt5682_private rt5682;
	};
@@ -53,12 +70,26 @@ enum sof_dmic_be_type {
};

int sof_intel_board_card_late_probe(struct snd_soc_card *card);
int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
				 struct sof_card_private *ctx);

int sof_intel_board_set_codec_link(struct device *dev,
				   struct snd_soc_dai_link *link, int be_id,
				   enum sof_ssp_codec codec_type, int ssp_codec);
int sof_intel_board_set_dmic_link(struct device *dev,
				  struct snd_soc_dai_link *link, int be_id,
				  enum sof_dmic_be_type be_type);
int sof_intel_board_set_intel_hdmi_link(struct device *dev,
					struct snd_soc_dai_link *link, int be_id,
					int hdmi_id, bool idisp_codec);
int sof_intel_board_set_ssp_amp_link(struct device *dev,
				     struct snd_soc_dai_link *link, int be_id,
				     enum sof_ssp_codec amp_type, int ssp_amp);
int sof_intel_board_set_bt_link(struct device *dev,
				struct snd_soc_dai_link *link, int be_id,
				int ssp_bt);
int sof_intel_board_set_hdmi_in_link(struct device *dev,
				     struct snd_soc_dai_link *link, int be_id,
				     int ssp_hdmi);

#endif /* __SOF_INTEL_BOARD_HELPERS_H */
+63 −166
Original line number Diff line number Diff line
@@ -138,13 +138,6 @@ static const struct snd_soc_ops sof_cs42l42_ops = {
	.hw_params = sof_cs42l42_hw_params,
};

static struct snd_soc_dai_link_component platform_component[] = {
	{
		/* name might be overridden during probe */
		.name = "0000:00:1f.3"
	}
};

static int sof_card_late_probe(struct snd_soc_card *card)
{
	return sof_intel_board_card_late_probe(card);
@@ -189,147 +182,11 @@ static struct snd_soc_dai_link_component cs42l42_component[] = {
	}
};

static int create_spk_amp_dai_links(struct device *dev,
				    struct snd_soc_dai_link *links,
				    struct snd_soc_dai_link_component *cpus,
				    int *id, enum sof_ssp_codec amp_type,
				    int ssp_amp)
{
	int ret = 0;

	/* speaker amp */
	if (amp_type == CODEC_NONE)
		return 0;

	links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
					 ssp_amp);
	if (!links[*id].name) {
		ret = -ENOMEM;
		goto devm_err;
	}

	links[*id].id = *id;

	switch (amp_type) {
	case CODEC_MAX98357A:
		max_98357a_dai_link(&links[*id]);
		break;
	case CODEC_MAX98360A:
		max_98360a_dai_link(&links[*id]);
		break;
	default:
		dev_err(dev, "invalid amp type %d\n", amp_type);
		return -EINVAL;
	}

	links[*id].platforms = platform_component;
	links[*id].num_platforms = ARRAY_SIZE(platform_component);
	links[*id].dpcm_playback = 1;
	/* firmware-generated echo reference */
	links[*id].dpcm_capture = 1;

	links[*id].no_pcm = 1;
	links[*id].cpus = &cpus[*id];
	links[*id].num_cpus = 1;

	links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
						   "SSP%d Pin", ssp_amp);
	if (!links[*id].cpus->dai_name) {
		ret = -ENOMEM;
		goto devm_err;
	}

	(*id)++;

devm_err:
	return ret;
}

static int create_hp_codec_dai_links(struct device *dev,
				     struct snd_soc_dai_link *links,
				     struct snd_soc_dai_link_component *cpus,
				     int *id, int ssp_codec)
{
	/* codec SSP */
	links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec",
					 ssp_codec);
	if (!links[*id].name)
		goto devm_err;

	links[*id].id = *id;
	links[*id].codecs = cs42l42_component;
	links[*id].num_codecs = ARRAY_SIZE(cs42l42_component);
	links[*id].platforms = platform_component;
	links[*id].num_platforms = ARRAY_SIZE(platform_component);
	links[*id].init = sof_cs42l42_init;
	links[*id].exit = sof_cs42l42_exit;
	links[*id].ops = &sof_cs42l42_ops;
	links[*id].dpcm_playback = 1;
	links[*id].dpcm_capture = 1;
	links[*id].no_pcm = 1;
	links[*id].cpus = &cpus[*id];
	links[*id].num_cpus = 1;

	links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
						   "SSP%d Pin",
						   ssp_codec);
	if (!links[*id].cpus->dai_name)
		goto devm_err;

	(*id)++;

	return 0;

devm_err:
	return -ENOMEM;
}

static int create_bt_offload_dai_links(struct device *dev,
				       struct snd_soc_dai_link *links,
				       struct snd_soc_dai_link_component *cpus,
				       int *id, int ssp_bt)
{
	/* bt offload */
	if (!(sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT))
		return 0;

	links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT",
					 ssp_bt);
	if (!links[*id].name)
		goto devm_err;

	links[*id].id = *id;
	links[*id].codecs = &snd_soc_dummy_dlc;
	links[*id].num_codecs = 1;
	links[*id].platforms = platform_component;
	links[*id].num_platforms = ARRAY_SIZE(platform_component);

	links[*id].dpcm_playback = 1;
	links[*id].dpcm_capture = 1;
	links[*id].no_pcm = 1;
	links[*id].cpus = &cpus[*id];
	links[*id].num_cpus = 1;

	links[*id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
						   "SSP%d Pin",
						   ssp_bt);
	if (!links[*id].cpus->dai_name)
		goto devm_err;

	(*id)++;

	return 0;

devm_err:
	return -ENOMEM;
}

static struct snd_soc_dai_link *
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
			  int ssp_codec, int ssp_amp, int ssp_bt,
			  int dmic_be_num, int hdmi_num, bool idisp_codec)
{
	struct snd_soc_dai_link_component *cpus;
	struct snd_soc_dai_link *links;
	int ret;
	int id = 0;
@@ -338,9 +195,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,

	links = devm_kcalloc(dev, sof_audio_card_cs42l42.num_links,
			    sizeof(struct snd_soc_dai_link), GFP_KERNEL);
	cpus = devm_kcalloc(dev, sof_audio_card_cs42l42.num_links,
			    sizeof(struct snd_soc_dai_link_component), GFP_KERNEL);
	if (!links || !cpus)
	if (!links)
		goto devm_err;

	link_seq = (sof_cs42l42_quirk & SOF_CS42L42_DAILINK_MASK) >> SOF_CS42L42_DAILINK_SHIFT;
@@ -350,21 +205,53 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,

		switch (link_type) {
		case LINK_HP:
			ret = create_hp_codec_dai_links(dev, links, cpus, &id, ssp_codec);
			if (ret < 0) {
			ret = sof_intel_board_set_codec_link(dev, &links[id], id,
							     CODEC_CS42L42,
							     ssp_codec);
			if (ret) {
				dev_err(dev, "fail to create hp codec dai links, ret %d\n",
					ret);
				goto devm_err;
			}

			/* codec-specific fields */
			links[id].codecs = cs42l42_component;
			links[id].num_codecs = ARRAY_SIZE(cs42l42_component);
			links[id].init = sof_cs42l42_init;
			links[id].exit = sof_cs42l42_exit;
			links[id].ops = &sof_cs42l42_ops;

			id++;
			break;
		case LINK_SPK:
			ret = create_spk_amp_dai_links(dev, links, cpus, &id,
						       amp_type, ssp_amp);
			if (ret < 0) {
			if (amp_type != CODEC_NONE) {
				ret = sof_intel_board_set_ssp_amp_link(dev,
								       &links[id],
								       id,
								       amp_type,
								       ssp_amp);
				if (ret) {
					dev_err(dev, "fail to create spk amp dai links, ret %d\n",
						ret);
					goto devm_err;
				}

				/* codec-specific fields */
				switch (amp_type) {
				case CODEC_MAX98357A:
					max_98357a_dai_link(&links[id]);
					break;
				case CODEC_MAX98360A:
					max_98360a_dai_link(&links[id]);
					break;
				default:
					dev_err(dev, "invalid amp type %d\n",
						amp_type);
					goto devm_err;
				}

				id++;
			}
			break;
		case LINK_DMIC:
			if (dmic_be_num > 0) {
@@ -413,12 +300,18 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
			}
			break;
		case LINK_BT:
			ret = create_bt_offload_dai_links(dev, links, cpus, &id, ssp_bt);
			if (ret < 0) {
			if (sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT) {
				ret = sof_intel_board_set_bt_link(dev,
								  &links[id], id,
								  ssp_bt);
				if (ret) {
					dev_err(dev, "fail to create bt offload dai links, ret %d\n",
						ret);
					goto devm_err;
				}

				id++;
			}
			break;
		case LINK_NONE:
			/* caught here if it's not used as terminator in macro */
@@ -440,7 +333,7 @@ static int sof_audio_probe(struct platform_device *pdev)
	struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
	struct snd_soc_dai_link *dai_links;
	struct sof_card_private *ctx;
	int ret, ssp_bt, ssp_amp, ssp_codec;
	int ret;

	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
	if (!ctx)
@@ -469,25 +362,29 @@ static int sof_audio_probe(struct platform_device *pdev)

	dev_dbg(&pdev->dev, "sof_cs42l42_quirk = %lx\n", sof_cs42l42_quirk);

	ssp_bt = (sof_cs42l42_quirk & SOF_CS42L42_SSP_BT_MASK) >>
	/* port number of peripherals attached to ssp interface */
	ctx->ssp_bt = (sof_cs42l42_quirk & SOF_CS42L42_SSP_BT_MASK) >>
			SOF_CS42L42_SSP_BT_SHIFT;

	ssp_amp = (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >>
	ctx->ssp_amp = (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >>
			SOF_CS42L42_SSP_AMP_SHIFT;

	ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK;
	ctx->ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK;

	/* compute number of dai links */
	sof_audio_card_cs42l42.num_links = 1 + ctx->dmic_be_num + ctx->hdmi_num;

	if (ctx->amp_type != CODEC_NONE)
		sof_audio_card_cs42l42.num_links++;
	if (sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT)
	if (sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT) {
		ctx->bt_offload_present = true;
		sof_audio_card_cs42l42.num_links++;
	}

	dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type,
					      ssp_codec, ssp_amp, ssp_bt,
					      ctx->dmic_be_num, ctx->hdmi_num,
					      ctx->ssp_codec, ctx->ssp_amp,
					      ctx->ssp_bt, ctx->dmic_be_num,
					      ctx->hdmi_num,
					      ctx->hdmi.idisp_codec);
	if (!dai_links)
		return -ENOMEM;
+9 −4
Original line number Diff line number Diff line
@@ -61,16 +61,21 @@ static int max_98373_hw_params(struct snd_pcm_substream *substream,
{
	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
	struct snd_soc_dai *codec_dai;
	int ret = 0;
	int j;

	for_each_rtd_codec_dais(rtd, j, codec_dai) {
		if (!strcmp(codec_dai->component->name, MAX_98373_DEV0_NAME)) {
			/* DEV0 tdm slot configuration */
			snd_soc_dai_set_tdm_slot(codec_dai, 0x03, 3, 8, 32);
		}
		if (!strcmp(codec_dai->component->name, MAX_98373_DEV1_NAME)) {
			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x03, 3, 8, 32);
		} else if (!strcmp(codec_dai->component->name, MAX_98373_DEV1_NAME)) {
			/* DEV1 tdm slot configuration */
			snd_soc_dai_set_tdm_slot(codec_dai, 0x0C, 3, 8, 32);
			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x0C, 3, 8, 32);
		}
		if (ret < 0) {
			dev_err(codec_dai->dev, "fail to set tdm slot, ret %d\n",
				ret);
			return ret;
		}
	}
	return 0;
Loading