Skip to content

Commit 3b3ed47

Browse files
brentlubroonie
authored andcommitted
ASoC: Intel: sof_maxim_common: support MAX98390 on cml boards
Add support for 2xMAX98390 speaker amplifier running in I2S mode for existing cml boards. 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/20240426152529.38345-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d2d377f commit 3b3ed47

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

sound/soc/intel/boards/sof_maxim_common.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <sound/soc-dai.h>
1111
#include <sound/soc-dapm.h>
1212
#include <uapi/sound/asound.h>
13+
#include "../common/soc-intel-quirks.h"
1314
#include "sof_maxim_common.h"
1415

1516
/*
@@ -219,6 +220,17 @@ static const struct snd_soc_dapm_route max_98390_tt_dapm_routes[] = {
219220
{ "TR Spk", NULL, "Tweeter Right BE_OUT" },
220221
};
221222

223+
static struct snd_soc_codec_conf max_98390_cml_codec_conf[] = {
224+
{
225+
.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
226+
.name_prefix = "Left",
227+
},
228+
{
229+
.dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME),
230+
.name_prefix = "Right",
231+
},
232+
};
233+
222234
static struct snd_soc_codec_conf max_98390_codec_conf[] = {
223235
{
224236
.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
@@ -271,6 +283,7 @@ static int max_98390_hw_params(struct snd_pcm_substream *substream,
271283
struct snd_pcm_hw_params *params)
272284
{
273285
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
286+
struct snd_soc_dai_link *dai_link = rtd->dai_link;
274287
struct snd_soc_dai *codec_dai;
275288
int i, ret;
276289

@@ -280,13 +293,24 @@ static int max_98390_hw_params(struct snd_pcm_substream *substream,
280293
return -ENODEV;
281294
}
282295

283-
ret = snd_soc_dai_set_tdm_slot(codec_dai, max_98390_tdm_mask[i].tx,
284-
max_98390_tdm_mask[i].rx, 4,
285-
params_width(params));
286-
if (ret < 0) {
287-
dev_err(codec_dai->dev, "fail to set tdm slot, ret %d\n",
288-
ret);
289-
return ret;
296+
switch (dai_link->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
297+
case SND_SOC_DAIFMT_DSP_A:
298+
case SND_SOC_DAIFMT_DSP_B:
299+
/* 4-slot TDM */
300+
ret = snd_soc_dai_set_tdm_slot(codec_dai,
301+
max_98390_tdm_mask[i].tx,
302+
max_98390_tdm_mask[i].rx,
303+
4,
304+
params_width(params));
305+
if (ret < 0) {
306+
dev_err(codec_dai->dev, "fail to set tdm slot, ret %d\n",
307+
ret);
308+
return ret;
309+
}
310+
break;
311+
default:
312+
dev_dbg(codec_dai->dev, "codec is in I2S mode\n");
313+
break;
290314
}
291315
}
292316
return 0;
@@ -395,6 +419,10 @@ void max_98390_set_codec_conf(struct device *dev, struct snd_soc_card *card)
395419

396420
switch (num_codecs) {
397421
case 2:
422+
if (soc_intel_is_cml())
423+
card->codec_conf = max_98390_cml_codec_conf;
424+
425+
fallthrough;
398426
case 4:
399427
card->num_configs = num_codecs;
400428
break;

0 commit comments

Comments
 (0)