Skip to content

Commit c921a2f

Browse files
committed
[WIP] ASoC: intel: boards: add max98390 support
4ch configuration, echo reference not confirmed yet Signed-off-by: Mac Chiang <mac.chiang@intel.com> Change-Id: I6d0076c114a610d6ce4f1f03b85ccff57ff36349
1 parent 2513c3d commit c921a2f

5 files changed

Lines changed: 152 additions & 2 deletions

File tree

sound/soc/intel/boards/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
470470
select SND_SOC_RT1015
471471
select SND_SOC_RT1015P
472472
select SND_SOC_RT5682_I2C
473+
select SND_SOC_MAX98390
473474
select SND_SOC_DMIC
474475
select SND_SOC_HDAC_HDMI
475476
select SND_SOC_INTEL_HDA_DSP_COMMON

sound/soc/intel/boards/sof_maxim_common.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const struct snd_soc_dapm_route max_98373_dapm_routes[] = {
1616
/* speaker */
1717
{ "Left Spk", NULL, "Left BE_OUT" },
1818
{ "Right Spk", NULL, "Right BE_OUT" },
19+
1920
};
2021
EXPORT_SYMBOL_NS(max_98373_dapm_routes, SND_SOC_INTEL_SOF_MAXIM_COMMON);
2122

@@ -133,6 +134,91 @@ void max_98373_set_codec_conf(struct snd_soc_card *card)
133134
}
134135
EXPORT_SYMBOL_NS(max_98373_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON);
135136

137+
/*
138+
* Maxim MAX98390
139+
*/
140+
141+
static struct snd_soc_codec_conf max_98390_codec_conf[] = {
142+
{
143+
.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
144+
.name_prefix = "Woofer Right",
145+
},
146+
{
147+
.dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME),
148+
.name_prefix = "Woofer Left",
149+
},
150+
{
151+
.dlc = COMP_CODEC_CONF(MAX_98390_DEV2_NAME),
152+
.name_prefix = "Tweeter Right",
153+
},
154+
{
155+
.dlc = COMP_CODEC_CONF(MAX_98390_DEV3_NAME),
156+
.name_prefix = "Tweeter Left",
157+
},
158+
};
159+
160+
struct snd_soc_dai_link_component max_98390_components[] = {
161+
{ /* For Woofer Right */
162+
.name = MAX_98390_DEV0_NAME,
163+
.dai_name = MAX_98390_CODEC_DAI,
164+
},
165+
{ /* For Woofer Left */
166+
.name = MAX_98390_DEV1_NAME,
167+
.dai_name = MAX_98390_CODEC_DAI,
168+
},
169+
{ /* For Tweeter Right */
170+
.name = MAX_98390_DEV2_NAME,
171+
.dai_name = MAX_98390_CODEC_DAI,
172+
},
173+
{ /* For Tweeter Left */
174+
.name = MAX_98390_DEV3_NAME,
175+
.dai_name = MAX_98390_CODEC_DAI,
176+
},
177+
178+
};
179+
EXPORT_SYMBOL_NS(max_98390_components, SND_SOC_INTEL_SOF_MAXIM_COMMON);
180+
181+
static int max_98390_hw_params(struct snd_pcm_substream *substream,
182+
struct snd_pcm_hw_params *params)
183+
{
184+
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
185+
struct snd_soc_dai *codec_dai;
186+
int j;
187+
188+
for_each_rtd_codec_dais(rtd, j, codec_dai) {
189+
if (!strcmp(codec_dai->component->name, MAX_98390_DEV0_NAME)) {
190+
/* DEV0 tdm slot configuration */
191+
snd_soc_dai_set_tdm_slot(codec_dai, 0x01, 1, 4, 32);
192+
}
193+
if (!strcmp(codec_dai->component->name, MAX_98390_DEV1_NAME)) {
194+
/* DEV1 tdm slot configuration */
195+
snd_soc_dai_set_tdm_slot(codec_dai, 0x02, 2, 4, 32);
196+
}
197+
if (!strcmp(codec_dai->component->name, MAX_98390_DEV2_NAME)) {
198+
/* DEVi2 tdm slot configuration */
199+
snd_soc_dai_set_tdm_slot(codec_dai, 0x04, 4, 4, 32);
200+
}
201+
if (!strcmp(codec_dai->component->name, MAX_98390_DEV3_NAME)) {
202+
/* DEV3 tdm slot configuration */
203+
snd_soc_dai_set_tdm_slot(codec_dai, 0x08, 8, 4, 32);
204+
}
205+
}
206+
return 0;
207+
}
208+
209+
struct snd_soc_ops max_98390_ops = {
210+
.hw_params = max_98390_hw_params,
211+
.trigger = max_98373_trigger,
212+
};
213+
EXPORT_SYMBOL_NS(max_98390_ops, SND_SOC_INTEL_SOF_MAXIM_COMMON);
214+
215+
void max_98390_set_codec_conf(struct snd_soc_card *card)
216+
{
217+
card->codec_conf = max_98390_codec_conf;
218+
card->num_configs = ARRAY_SIZE(max_98390_codec_conf);
219+
}
220+
EXPORT_SYMBOL_NS(max_98390_set_codec_conf, SND_SOC_INTEL_SOF_MAXIM_COMMON);
221+
136222
/*
137223
* Maxim MAX98357A/MAX98360A
138224
*/

sound/soc/intel/boards/sof_maxim_common.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd);
2424
void max_98373_set_codec_conf(struct snd_soc_card *card);
2525
int max_98373_trigger(struct snd_pcm_substream *substream, int cmd);
2626

27+
/*
28+
* Maxim MAX98390
29+
*/
30+
#define MAX_98390_CODEC_DAI "max98390-aif1"
31+
#define MAX_98390_DEV0_NAME "i2c-MX98390:00"
32+
#define MAX_98390_DEV1_NAME "i2c-MX98390:01"
33+
#define MAX_98390_DEV2_NAME "i2c-MX98390:02"
34+
#define MAX_98390_DEV3_NAME "i2c-MX98390:03"
35+
36+
extern struct snd_soc_dai_link_component max_98390_components[2];
37+
extern struct snd_soc_ops max_98390_ops;
38+
void max_98390_set_codec_conf(struct snd_soc_card *card);
39+
2740
/*
2841
* Maxim MAX98357A/MAX98360A
2942
*/

sound/soc/intel/boards/sof_rt5682.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#define SOF_RT1015P_SPEAKER_AMP_PRESENT BIT(16)
5050
#define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(17)
5151
#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(18)
52+
#define SOF_MAX98390_SPEAKER_AMP_PRESENT BIT(23)
5253

5354
/* BT audio offload: reserve 3 bits for future */
5455
#define SOF_BT_OFFLOAD_SSP_SHIFT 19
@@ -176,6 +177,19 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
176177
SOF_RT5682_SSP_AMP(2) |
177178
SOF_RT5682_NUM_HDMIDEV(4)),
178179
},
180+
{
181+
.callback = sof_rt5682_quirk_cb,
182+
.matches = {
183+
DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
184+
DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S"),
185+
},
186+
.driver_data = (void *)(SOF_RT5682_MCLK_EN |
187+
SOF_RT5682_SSP_CODEC(0) |
188+
SOF_SPEAKER_AMP_PRESENT |
189+
SOF_MAX98390_SPEAKER_AMP_PRESENT |
190+
SOF_RT5682_SSP_AMP(1) |
191+
SOF_RT5682_NUM_HDMIDEV(4)),
192+
},
179193
{}
180194
};
181195

@@ -451,14 +465,16 @@ static int sof_card_late_probe(struct snd_soc_card *card)
451465
i++;
452466
}
453467

454-
if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) {
468+
if ((sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) ||
469+
(sof_rt5682_quirk & SOF_MAX98390_SPEAKER_AMP_PRESENT)) {
455470
/* Disable Left and Right Spk pin after boot */
456471
snd_soc_dapm_disable_pin(dapm, "Left Spk");
457472
snd_soc_dapm_disable_pin(dapm, "Right Spk");
458473
err = snd_soc_dapm_sync(dapm);
459474
if (err < 0)
460475
return err;
461476
}
477+
462478
return hdac_hdmi_jack_port_init(component, &card->dapm);
463479
}
464480

@@ -745,6 +761,13 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
745761
} else if (sof_rt5682_quirk &
746762
SOF_RT1011_SPEAKER_AMP_PRESENT) {
747763
sof_rt1011_dai_link(&links[id]);
764+
} else if (sof_rt5682_quirk &
765+
SOF_MAX98390_SPEAKER_AMP_PRESENT) {
766+
links[id].codecs = max_98390_components;
767+
links[id].num_codecs = ARRAY_SIZE(max_98390_components);
768+
links[id].init = max_98373_spk_codec_init;
769+
links[id].ops = &max_98390_ops;
770+
// links[id].dpcm_capture = 1;
748771
} else {
749772
max_98357a_dai_link(&links[id]);
750773
}
@@ -881,7 +904,8 @@ static int sof_audio_probe(struct platform_device *pdev)
881904
sof_rt1011_codec_conf(&sof_audio_card_rt5682);
882905
else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT)
883906
sof_rt1015p_codec_conf(&sof_audio_card_rt5682);
884-
907+
else if (sof_rt5682_quirk & SOF_MAX98390_SPEAKER_AMP_PRESENT)
908+
max_98390_set_codec_conf(&sof_audio_card_rt5682);
885909
if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
886910
sof_audio_card_rt5682.num_links++;
887911

@@ -1007,6 +1031,18 @@ static const struct platform_device_id board_ids[] = {
10071031
SOF_RT5682_SSP_AMP(2) |
10081032
SOF_RT5682_NUM_HDMIDEV(4)),
10091033
},
1034+
{
1035+
.name = "adl_max98390_rt5682",
1036+
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
1037+
SOF_RT5682_SSP_CODEC(0) |
1038+
SOF_SPEAKER_AMP_PRESENT |
1039+
SOF_MAX98390_SPEAKER_AMP_PRESENT |
1040+
SOF_RT5682_SSP_AMP(1) |
1041+
SOF_RT5682_NUM_HDMIDEV(4) |
1042+
SOF_BT_OFFLOAD_SSP(2) |
1043+
SOF_SSP_BT_OFFLOAD_PRESENT),
1044+
},
1045+
10101046
{ }
10111047
};
10121048
MODULE_DEVICE_TABLE(platform, board_ids);
@@ -1026,6 +1062,7 @@ MODULE_DESCRIPTION("SOF Audio Machine driver");
10261062
MODULE_AUTHOR("Bard Liao <bard.liao@intel.com>");
10271063
MODULE_AUTHOR("Sathya Prakash M R <sathya.prakash.m.r@intel.com>");
10281064
MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
1065+
MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
10291066
MODULE_LICENSE("GPL v2");
10301067
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
10311068
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);

sound/soc/intel/common/soc-acpi-intel-adl-match.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ static const struct snd_soc_acpi_codecs adl_max98357a_amp = {
280280
.codecs = {"MX98357A"}
281281
};
282282

283+
static const struct snd_soc_acpi_codecs adl_max98390_amp = {
284+
.num_codecs = 1,
285+
.codecs = {"MX98390"}
286+
};
287+
283288
struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
284289
{
285290
.id = "10EC5682",
@@ -297,6 +302,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
297302
.sof_fw_filename = "sof-adl.ri",
298303
.sof_tplg_filename = "sof-adl-max98357a-rt5682.tplg",
299304
},
305+
{
306+
.id = "10EC5682",
307+
.drv_name = "adl_max98390_rt5682",
308+
.machine_quirk = snd_soc_acpi_codec_list,
309+
.quirk_data = &adl_max98390_amp,
310+
.sof_fw_filename = "sof-adl.ri",
311+
.sof_tplg_filename = "sof-adl-max98390-rt5682.tplg",
312+
},
300313
{},
301314
};
302315
EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);

0 commit comments

Comments
 (0)