Unverified Commit 2ea17630 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: Intel: boards: updates for 6.11

Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

More simplifications from Brent Lu for Chromebooks, Bard Liao for
SoundWire, and support for new Dell SKUs w/ Cirrus Logic codecs added
by Charles Keepax.
parents d8b3a77b 10853503
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -173,5 +173,6 @@ struct sof_dev_desc {

int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
int sof_dai_get_tdm_slots(struct snd_soc_pcm_runtime *rtd);

#endif
+0 −2
Original line number Diff line number Diff line
@@ -86,12 +86,10 @@ enum {
/*
 * sof_da7219_private: private data for da7219 machine driver
 *
 * @is_jsl_board: true for JSL boards
 * @mclk_en: true for mclk pin is connected
 * @pll_bypass: true for PLL bypass mode
 */
struct sof_da7219_private {
	bool is_jsl_board;
	bool mclk_en;
	bool pll_bypass;
};
+12 −43
Original line number Diff line number Diff line
@@ -178,42 +178,21 @@ static void da7219_codec_exit(struct snd_soc_pcm_runtime *rtd)
	snd_soc_component_set_jack(component, NULL, NULL);
}

static int max98373_hw_params(struct snd_pcm_substream *substream,
			      struct snd_pcm_hw_params *params)
static int card_late_probe(struct snd_soc_card *card)
{
	struct snd_soc_pcm_runtime *runtime = snd_soc_substream_to_rtd(substream);
	int ret, j;

	for (j = 0; j < runtime->dai_link->num_codecs; j++) {
		struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(runtime, j);

		if (!strcmp(codec_dai->component->name, MAX_98373_DEV0_NAME)) {
			/* vmon_slot_no = 0 imon_slot_no = 1 for TX slots */
			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 3, 4, 16);
			if (ret < 0) {
				dev_err(runtime->dev, "DEV0 TDM slot err:%d\n", ret);
				return ret;
			}
		}
		if (!strcmp(codec_dai->component->name, MAX_98373_DEV1_NAME)) {
			/* vmon_slot_no = 2 imon_slot_no = 3 for TX slots */
			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC, 3, 4, 16);
			if (ret < 0) {
				dev_err(runtime->dev, "DEV1 TDM slot err:%d\n", ret);
				return ret;
			}
		}
	}

	return 0;
	struct sof_card_private *ctx = snd_soc_card_get_drvdata(card);
	struct snd_soc_dapm_context *dapm = &card->dapm;
	int err;

	if (ctx->amp_type == CODEC_MAX98373) {
		/* Disable Left and Right Spk pin after boot */
		snd_soc_dapm_disable_pin(dapm, "Left Spk");
		snd_soc_dapm_disable_pin(dapm, "Right Spk");
		err = snd_soc_dapm_sync(dapm);
		if (err < 0)
			return err;
	}

static const struct snd_soc_ops max98373_ops = {
	.hw_params = max98373_hw_params,
};

static int card_late_probe(struct snd_soc_card *card)
{
	return sof_intel_board_card_late_probe(card);
}

@@ -276,14 +255,6 @@ sof_card_dai_links_create(struct device *dev, struct snd_soc_card *card,
		break;
	case CODEC_MAX98373:
		max_98373_dai_link(dev, ctx->amp_link);

		if (ctx->da7219.is_jsl_board) {
			ctx->amp_link->ops = &max98373_ops; /* use local ops */
		} else {
			/* TBD: implement the amp for later platform */
			dev_err(dev, "max98373 not support yet\n");
			return -EINVAL;
		}
		break;
	case CODEC_MAX98390:
		max_98390_dai_link(dev, ctx->amp_link);
@@ -388,8 +359,6 @@ static int audio_probe(struct platform_device *pdev)
			break;
		}
	} else if (board_quirk & SOF_DA7219_JSL_BOARD) {
		ctx->da7219.is_jsl_board = true;

		/* overwrite the DAI link order for JSL boards */
		ctx->link_order_overwrite = JSL_LINK_ORDER;

+72 −12
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <sound/soc-acpi.h>
#include <sound/soc-dai.h>
#include <sound/soc-dapm.h>
#include <sound/sof.h>
#include <uapi/sound/asound.h>
#include "../common/soc-intel-quirks.h"
#include "sof_maxim_common.h"
@@ -72,27 +73,86 @@ static struct snd_soc_dai_link_component max_98373_components[] = {
	},
};

/*
 * According to the definition of 'DAI Sel Mux' mixer in max98373.c, rx mask
 * should choose two channels from TDM slots, the LSB of rx mask is left channel
 * and the other one is right channel.
 *
 * For tx mask, each codec requires two channels: one for V-sense and the other
 * one for I-sense. Must match the device property "maxim,vmon-slot-no" and
 * "maxim,imon-slot-no" in ACPI table.
 */
static const struct {
	unsigned int tx;
	unsigned int rx;
} max_98373_tdm_mask[] = {
	{.tx = 0x03, .rx = 0x3},
	{.tx = 0x0c, .rx = 0x3},
};

static int max_98373_hw_params(struct snd_pcm_substream *substream,
			       struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
	struct snd_soc_dai_link *dai_link = rtd->dai_link;
	struct snd_soc_dai *codec_dai;
	int i;
	int tdm_slots;
	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 */
			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 */
			ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x0C, 3, 8, 32);
	for_each_rtd_codec_dais(rtd, i, codec_dai) {
		if (i >= ARRAY_SIZE(max_98373_tdm_mask)) {
			dev_err(codec_dai->dev, "only 2 amps are supported\n");
			return -EINVAL;
		}

		switch (dai_link->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
		case SND_SOC_DAIFMT_DSP_A:
		case SND_SOC_DAIFMT_DSP_B:
			/* get the tplg configured tdm slot number */
			tdm_slots = sof_dai_get_tdm_slots(rtd);
			if (tdm_slots <= 0) {
				dev_err(rtd->dev, "invalid tdm slots %d\n",
					tdm_slots);
				return -EINVAL;
			}

			/*
			 * check if tdm slot number is too small for channel
			 * allocation
			 */
			if (fls(max_98373_tdm_mask[i].tx) > tdm_slots) {
				dev_err(codec_dai->dev, "slot mismatch, tx %d slots %d\n",
					fls(max_98373_tdm_mask[i].tx), tdm_slots);
				return -EINVAL;
			}

			if (fls(max_98373_tdm_mask[i].rx) > tdm_slots) {
				dev_err(codec_dai->dev, "slot mismatch, rx %d slots %d\n",
					fls(max_98373_tdm_mask[i].rx), tdm_slots);
				return -EINVAL;
			}

			dev_dbg(codec_dai->dev, "set tdm slot: tx 0x%x rx 0x%x slots %d width %d\n",
				max_98373_tdm_mask[i].tx,
				max_98373_tdm_mask[i].rx,
				tdm_slots, params_width(params));

			ret = snd_soc_dai_set_tdm_slot(codec_dai,
						       max_98373_tdm_mask[i].tx,
						       max_98373_tdm_mask[i].rx,
						       tdm_slots,
						       params_width(params));
			if (ret < 0) {
				dev_err(codec_dai->dev, "fail to set tdm slot, ret %d\n",
					ret);
				return ret;
			}
			break;
		default:
			dev_dbg(codec_dai->dev, "codec is in I2S mode\n");
			break;
		}
	}
	return 0;
}
+22 −18
Original line number Diff line number Diff line
@@ -505,6 +505,22 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = {
		},
		.driver_data = (void *)(RT711_JD2),
	},
	{
		.callback = sof_sdw_quirk_cb,
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0CE3")
		},
		.driver_data = (void *)(SOF_SIDECAR_AMPS),
	},
	{
		.callback = sof_sdw_quirk_cb,
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0CE4")
		},
		.driver_data = (void *)(SOF_SIDECAR_AMPS),
	},
	{}
};

@@ -559,24 +575,6 @@ static const struct snd_kcontrol_new rt700_controls[] = {
	SOC_DAPM_PIN_SWITCH("Speaker"),
};

struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd,
					  const char * const dai_name[],
					  int num_dais)
{
	struct snd_soc_dai *dai;
	int index;
	int i;

	for (index = 0; index < num_dais; index++)
		for_each_rtd_codec_dais(rtd, i, dai)
			if (strstr(dai->name, dai_name[index])) {
				dev_dbg(rtd->card->dev, "get dai %s\n", dai->name);
				return dai;
			}

	return NULL;
}

/* these wrappers are only needed to avoid typecast compilation errors */
int sdw_startup(struct snd_pcm_substream *substream)
{
@@ -1077,6 +1075,8 @@ static struct sof_sdw_codec_info codec_info_list[] = {
				.dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID},
				.init = sof_sdw_cs_amp_init,
				.rtd_init = cs_spk_rtd_init,
				.controls = generic_spk_controls,
				.num_controls = ARRAY_SIZE(generic_spk_controls),
				.widgets = generic_spk_widgets,
				.num_widgets = ARRAY_SIZE(generic_spk_widgets),
			},
@@ -1112,6 +1112,8 @@ static struct sof_sdw_codec_info codec_info_list[] = {
				.dai_type = SOF_SDW_DAI_TYPE_JACK,
				.dailink = {SDW_JACK_OUT_DAI_ID, SDW_UNUSED_DAI_ID},
				.rtd_init = cs42l43_hs_rtd_init,
				.controls = generic_jack_controls,
				.num_controls = ARRAY_SIZE(generic_jack_controls),
				.widgets = generic_jack_widgets,
				.num_widgets = ARRAY_SIZE(generic_jack_widgets),
			},
@@ -1137,6 +1139,8 @@ static struct sof_sdw_codec_info codec_info_list[] = {
				.dailink = {SDW_AMP_OUT_DAI_ID, SDW_UNUSED_DAI_ID},
				.init = sof_sdw_cs42l43_spk_init,
				.rtd_init = cs42l43_spk_rtd_init,
				.controls = generic_spk_controls,
				.num_controls = ARRAY_SIZE(generic_spk_controls),
				.widgets = generic_spk_widgets,
				.num_widgets = ARRAY_SIZE(generic_spk_widgets),
				.quirk = SOF_CODEC_SPKR | SOF_SIDECAR_AMPS,
Loading