Commit 395f23e9 authored by Mark Brown's avatar Mark Brown

ASoC: Intel: updates for 6.10 - part6

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

Last batch of cleanups from Brent Lu, with Chromebooks now supported
with fewer modular machine drivers.
parents a226d08a 3d84e070
......@@ -301,26 +301,21 @@ config SND_SOC_INTEL_DA7219_MAX98357A_GENERIC
tristate
select SND_SOC_DA7219
select SND_SOC_MAX98357A
select SND_SOC_MAX98390
select SND_SOC_DMIC
select SND_SOC_HDAC_HDMI
select SND_SOC_INTEL_HDA_DSP_COMMON
config SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON
tristate
select SND_SOC_INTEL_DA7219_MAX98357A_GENERIC
if SND_SOC_INTEL_APL
config SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH
tristate "Broxton with DA7219 and MAX98357A/MAX98390 in I2S Mode"
tristate "Broxton with DA7219 and MAX98357A in I2S Mode"
depends on I2C && ACPI
depends on MFD_INTEL_LPSS || COMPILE_TEST
depends on SND_HDA_CODEC_HDMI
select SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON
select SND_SOC_INTEL_DA7219_MAX98357A_GENERIC
help
This adds support for ASoC machine driver for Broxton-P platforms
with DA7219 + MAX98357A/MAX98390 I2S audio codec.
with DA7219 + MAX98357A I2S audio codec.
Say Y or m if you have such a device. This is a recommended option.
If unsure select "N".
......@@ -433,30 +428,21 @@ if SND_SOC_SOF_GEMINILAKE
config SND_SOC_INTEL_GLK_DA7219_MAX98357A_MACH
tristate "GLK with DA7219 and MAX98357A in I2S Mode"
depends on I2C && ACPI
depends on MFD_INTEL_LPSS || COMPILE_TEST
depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC
select SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON
imply SND_SOC_INTEL_SOF_DA7219_MACH
help
This adds support for ASoC machine driver for Geminilake platforms
with DA7219 + MAX98357A I2S audio codec.
with DA7219 + MAX98357A I2S audio codec. This option is deprecated
and please use SND_SOC_INTEL_SOF_DA7219_MACH instead.
Say Y or m if you have such a device. This is a recommended option.
If unsure select "N".
config SND_SOC_INTEL_GLK_RT5682_MAX98357A_MACH
tristate "GLK with RT5682 and MAX98357A in I2S Mode"
depends on I2C && ACPI
depends on MFD_INTEL_LPSS || COMPILE_TEST
depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC
select SND_SOC_RT5682_I2C
select SND_SOC_RT5682S
select SND_SOC_MAX98357A
select SND_SOC_DMIC
select SND_SOC_HDAC_HDMI
select SND_SOC_INTEL_HDA_DSP_COMMON
imply SND_SOC_INTEL_SOF_RT5682_MACH
help
This adds support for ASoC machine driver for Geminilake platforms
with RT5682 + MAX98357A I2S audio codec.
with RT5682 + MAX98357A I2S audio codec. This option is deprecated
and please use SND_SOC_INTEL_SOF_RT5682_MACH instead.
Say Y if you have such a device.
If unsure select "N".
......@@ -487,6 +473,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
depends on ((SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC) &&\
(MFD_INTEL_LPSS || COMPILE_TEST)) ||\
(SND_SOC_SOF_BAYTRAIL && (X86_INTEL_LPSS || COMPILE_TEST))
select SND_SOC_MAX98357A
select SND_SOC_MAX98373_I2C
select SND_SOC_MAX98390
select SND_SOC_RT1011
......@@ -584,12 +571,11 @@ if (SND_SOC_SOF_COMETLAKE && SND_SOC_SOF_HDA_LINK)
config SND_SOC_INTEL_CML_LP_DA7219_MAX98357A_MACH
tristate "CML_LP with DA7219 and MAX98357A in I2S Mode"
depends on I2C && ACPI
depends on MFD_INTEL_LPSS || COMPILE_TEST
select SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON
imply SND_SOC_INTEL_SOF_DA7219_MACH
help
This adds support for ASoC machine driver for Cometlake platforms
with DA7219 + MAX98357A I2S audio codec.
with DA7219 + MAX98357A I2S audio codec. This option is deprecated
and please use SND_SOC_INTEL_SOF_DA7219_MACH instead.
Say Y or m if you have such a device. This is a recommended option.
If unsure select "N".
......@@ -614,6 +600,7 @@ config SND_SOC_INTEL_SOF_DA7219_MACH
select SND_SOC_DA7219
select SND_SOC_MAX98357A
select SND_SOC_MAX98373_I2C
select SND_SOC_MAX98390
select SND_SOC_DMIC
select SND_SOC_INTEL_SOF_BOARD_HELPERS
select SND_SOC_INTEL_SOF_MAXIM_COMMON
......
......@@ -7,7 +7,6 @@ snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o
snd-soc-sst-bxt-rt298-objs := bxt_rt298.o
snd-soc-sst-sof-pcm512x-objs := sof_pcm512x.o
snd-soc-sst-sof-wm8804-objs := sof_wm8804.o
snd-soc-sst-glk-rt5682_max98357a-objs := glk_rt5682_max98357a.o
snd-soc-sst-bytcr-rt5640-objs := bytcr_rt5640.o
snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o
snd-soc-sst-bytcr-wm5102-objs := bytcr_wm5102.o
......@@ -52,11 +51,10 @@ obj-$(CONFIG_SND_SOC_INTEL_SOF_ES8336_MACH) += snd-soc-sof_es8336.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_NAU8825_MACH) += snd-soc-sof_nau8825.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_DA7219_MACH) += snd-soc-sof_da7219.o
obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-hsw-rt5640.o
obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON) += snd-soc-sst-bxt-da7219_max98357a.o
obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH) += snd-soc-sst-bxt-da7219_max98357a.o
obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_PCM512x_MACH) += snd-soc-sst-sof-pcm512x.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_WM8804_MACH) += snd-soc-sst-sof-wm8804.o
obj-$(CONFIG_SND_SOC_INTEL_GLK_RT5682_MAX98357A_MACH) += snd-soc-sst-glk-rt5682_max98357a.o
obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-bdw-rt286.o
obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5650_MACH) += snd-soc-sst-bdw-rt5650-mach.o
obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o
......
......@@ -24,14 +24,9 @@
#define BXT_DIALOG_CODEC_DAI "da7219-hifi"
#define BXT_MAXIM_CODEC_DAI "HiFi"
#define MAX98390_DEV0_NAME "i2c-MX98390:00"
#define MAX98390_DEV1_NAME "i2c-MX98390:01"
#define DUAL_CHANNEL 2
#define QUAD_CHANNEL 4
#define SPKAMP_MAX98357A 1
#define SPKAMP_MAX98390 2
static struct snd_soc_jack broxton_headset;
static struct snd_soc_jack broxton_hdmi[3];
......@@ -44,7 +39,6 @@ struct bxt_hdmi_pcm {
struct bxt_card_private {
struct list_head hdmi_pcm_list;
bool common_hdmi_codec_drv;
int spkamp;
};
enum {
......@@ -91,17 +85,9 @@ static const struct snd_kcontrol_new broxton_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
SOC_DAPM_PIN_SWITCH("Line Out"),
};
static const struct snd_kcontrol_new max98357a_controls[] = {
SOC_DAPM_PIN_SWITCH("Spk"),
};
static const struct snd_kcontrol_new max98390_controls[] = {
SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"),
};
static const struct snd_soc_dapm_widget broxton_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
......@@ -112,17 +98,9 @@ static const struct snd_soc_dapm_widget broxton_widgets[] = {
SND_SOC_DAPM_SPK("HDMI3", NULL),
SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
platform_clock_control, SND_SOC_DAPM_POST_PMD|SND_SOC_DAPM_PRE_PMU),
};
static const struct snd_soc_dapm_widget max98357a_widgets[] = {
SND_SOC_DAPM_SPK("Spk", NULL),
};
static const struct snd_soc_dapm_widget max98390_widgets[] = {
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};
static const struct snd_soc_dapm_route audio_map[] = {
/* HP jack connectors - unknown if we have jack detection */
{"Headphone Jack", NULL, "HPL"},
......@@ -153,20 +131,10 @@ static const struct snd_soc_dapm_route audio_map[] = {
{ "Headphone Jack", NULL, "Platform Clock" },
{ "Headset Mic", NULL, "Platform Clock" },
{ "Line Out", NULL, "Platform Clock" },
};
static const struct snd_soc_dapm_route max98357a_routes[] = {
/* speaker */
{"Spk", NULL, "Speaker"},
};
static const struct snd_soc_dapm_route max98390_routes[] = {
/* Speaker */
{"Left Spk", NULL, "Left BE_OUT"},
{"Right Spk", NULL, "Right BE_OUT"},
};
static const struct snd_soc_dapm_route broxton_map[] = {
{"HiFi Playback", NULL, "ssp5 Tx"},
{"ssp5 Tx", NULL, "codec0_out"},
......@@ -177,17 +145,6 @@ static const struct snd_soc_dapm_route broxton_map[] = {
{"ssp1 Rx", NULL, "Capture"},
};
static const struct snd_soc_dapm_route gemini_map[] = {
{"HiFi Playback", NULL, "ssp1 Tx"},
{"ssp1 Tx", NULL, "codec0_out"},
{"Playback", NULL, "ssp2 Tx"},
{"ssp2 Tx", NULL, "codec1_out"},
{"codec0_in", NULL, "ssp2 Rx"},
{"ssp2 Rx", NULL, "Capture"},
};
static struct snd_soc_jack_pin jack_pins[] = {
{
.pin = "Headphone Jack",
......@@ -231,10 +188,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
int clk_freq;
/* Configure sysclk for codec */
if (soc_intel_is_cml())
clk_freq = 24000000;
else
clk_freq = 19200000;
clk_freq = 19200000;
ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, clk_freq,
SND_SOC_CLOCK_IN);
......@@ -453,10 +407,6 @@ SND_SOC_DAILINK_DEF(ssp5_pin,
SND_SOC_DAILINK_DEF(ssp5_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("MX98357A:00",
BXT_MAXIM_CODEC_DAI)));
SND_SOC_DAILINK_DEF(max98390_codec,
DAILINK_COMP_ARRAY(
/* Left */ COMP_CODEC(MAX98390_DEV0_NAME, "max98390-aif1"),
/* Right */ COMP_CODEC(MAX98390_DEV1_NAME, "max98390-aif1")));
SND_SOC_DAILINK_DEF(ssp1_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
......@@ -654,76 +604,15 @@ static struct snd_soc_dai_link broxton_dais[] = {
},
};
static struct snd_soc_codec_conf max98390_codec_confs[] = {
{
.dlc = COMP_CODEC_CONF(MAX98390_DEV0_NAME),
.name_prefix = "Left",
},
{
.dlc = COMP_CODEC_CONF(MAX98390_DEV1_NAME),
.name_prefix = "Right",
},
};
#define NAME_SIZE 32
static int bxt_card_late_probe(struct snd_soc_card *card)
{
struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card);
struct bxt_hdmi_pcm *pcm;
struct snd_soc_component *component = NULL;
const struct snd_kcontrol_new *controls;
const struct snd_soc_dapm_widget *widgets;
const struct snd_soc_dapm_route *routes;
int num_controls, num_widgets, num_routes, err, i = 0;
int err, i = 0;
char jack_name[NAME_SIZE];
switch (ctx->spkamp) {
case SPKAMP_MAX98357A:
controls = max98357a_controls;
num_controls = ARRAY_SIZE(max98357a_controls);
widgets = max98357a_widgets;
num_widgets = ARRAY_SIZE(max98357a_widgets);
routes = max98357a_routes;
num_routes = ARRAY_SIZE(max98357a_routes);
break;
case SPKAMP_MAX98390:
controls = max98390_controls;
num_controls = ARRAY_SIZE(max98390_controls);
widgets = max98390_widgets;
num_widgets = ARRAY_SIZE(max98390_widgets);
routes = max98390_routes;
num_routes = ARRAY_SIZE(max98390_routes);
break;
default:
dev_err(card->dev, "Invalid speaker amplifier %d\n", ctx->spkamp);
return -EINVAL;
}
err = snd_soc_dapm_new_controls(&card->dapm, widgets, num_widgets);
if (err) {
dev_err(card->dev, "Fail to new widgets\n");
return err;
}
err = snd_soc_add_card_controls(card, controls, num_controls);
if (err) {
dev_err(card->dev, "Fail to add controls\n");
return err;
}
err = snd_soc_dapm_add_routes(&card->dapm, routes, num_routes);
if (err) {
dev_err(card->dev, "Fail to add routes\n");
return err;
}
if (soc_intel_is_glk())
snd_soc_dapm_add_routes(&card->dapm, gemini_map,
ARRAY_SIZE(gemini_map));
else
snd_soc_dapm_add_routes(&card->dapm, broxton_map,
ARRAY_SIZE(broxton_map));
if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;
......@@ -785,70 +674,8 @@ static int broxton_audio_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
if (acpi_dev_present("MX98390", NULL, -1))
ctx->spkamp = SPKAMP_MAX98390;
else
ctx->spkamp = SPKAMP_MAX98357A;
broxton_audio_card.dev = &pdev->dev;
snd_soc_card_set_drvdata(&broxton_audio_card, ctx);
if (soc_intel_is_glk()) {
unsigned int i;
broxton_audio_card.name = "glkda7219max";
/* Fixup the SSP entries for geminilake */
for (i = 0; i < ARRAY_SIZE(broxton_dais); i++) {
if (!broxton_dais[i].codecs->dai_name)
continue;
/* MAXIM_CODEC is connected to SSP1. */
if (!strcmp(broxton_dais[i].codecs->dai_name,
BXT_MAXIM_CODEC_DAI)) {
broxton_dais[i].name = "SSP1-Codec";
broxton_dais[i].cpus->dai_name = "SSP1 Pin";
}
/* DIALOG_CODE is connected to SSP2 */
else if (!strcmp(broxton_dais[i].codecs->dai_name,
BXT_DIALOG_CODEC_DAI)) {
broxton_dais[i].name = "SSP2-Codec";
broxton_dais[i].cpus->dai_name = "SSP2 Pin";
}
}
} else if (soc_intel_is_cml()) {
unsigned int i;
if (ctx->spkamp == SPKAMP_MAX98390) {
broxton_audio_card.name = "cml_max98390_da7219";
broxton_audio_card.codec_conf = max98390_codec_confs;
broxton_audio_card.num_configs = ARRAY_SIZE(max98390_codec_confs);
} else
broxton_audio_card.name = "cmlda7219max";
for (i = 0; i < ARRAY_SIZE(broxton_dais); i++) {
if (!broxton_dais[i].codecs->dai_name)
continue;
/* MAXIM_CODEC is connected to SSP1. */
if (!strcmp(broxton_dais[i].codecs->dai_name,
BXT_MAXIM_CODEC_DAI)) {
broxton_dais[i].name = "SSP1-Codec";
broxton_dais[i].cpus->dai_name = "SSP1 Pin";
if (ctx->spkamp == SPKAMP_MAX98390) {
broxton_dais[i].codecs = max98390_codec;
broxton_dais[i].num_codecs = ARRAY_SIZE(max98390_codec);
broxton_dais[i].dpcm_capture = 1;
}
}
/* DIALOG_CODEC is connected to SSP0 */
else if (!strcmp(broxton_dais[i].codecs->dai_name,
BXT_DIALOG_CODEC_DAI)) {
broxton_dais[i].name = "SSP0-Codec";
broxton_dais[i].cpus->dai_name = "SSP0 Pin";
}
}
}
/* override platform name, if required */
mach = pdev->dev.platform_data;
......@@ -866,8 +693,6 @@ static int broxton_audio_probe(struct platform_device *pdev)
static const struct platform_device_id bxt_board_ids[] = {
{ .name = "bxt_da7219_mx98357a" },
{ .name = "glk_da7219_mx98357a" },
{ .name = "cml_da7219_mx98357a" },
{ }
};
MODULE_DEVICE_TABLE(platform, bxt_board_ids);
......
This diff is collapsed.
......@@ -101,10 +101,12 @@ struct sof_da7219_private {
*
* @mclk: mclk clock data
* @is_legacy_cpu: true for BYT/CHT boards
* @mclk_en: true for mclk pin is connected
*/
struct sof_rt5682_private {
struct clk *mclk;
bool is_legacy_cpu;
bool mclk_en;
};
/*
......
......@@ -19,8 +19,10 @@
#include "sof_maxim_common.h"
/* Driver-specific board quirks: from bit 0 to 7 */
#define SOF_DA7219_JSL_BOARD BIT(0)
#define SOF_DA7219_MCLK_EN BIT(1)
#define SOF_DA7219_GLK_BOARD BIT(0)
#define SOF_DA7219_CML_BOARD BIT(1)
#define SOF_DA7219_JSL_BOARD BIT(2)
#define SOF_DA7219_MCLK_EN BIT(3)
#define DIALOG_CODEC_DAI "da7219-hifi"
......@@ -266,6 +268,9 @@ sof_card_dai_links_create(struct device *dev, struct snd_soc_card *card,
/* codec-specific fields for speaker amplifier */
switch (ctx->amp_type) {
case CODEC_MAX98357A:
max_98357a_dai_link(ctx->amp_link);
break;
case CODEC_MAX98360A:
max_98360a_dai_link(ctx->amp_link);
break;
......@@ -281,6 +286,9 @@ sof_card_dai_links_create(struct device *dev, struct snd_soc_card *card,
return -EINVAL;
}
break;
case CODEC_MAX98390:
max_98390_dai_link(dev, ctx->amp_link);
break;
default:
dev_err(dev, "invalid amp type %d\n", ctx->amp_type);
return -EINVAL;
......@@ -289,6 +297,22 @@ sof_card_dai_links_create(struct device *dev, struct snd_soc_card *card,
return 0;
}
#define GLK_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_AMP, \
SOF_LINK_CODEC, \
SOF_LINK_DMIC01, \
SOF_LINK_IDISP_HDMI, \
SOF_LINK_NONE, \
SOF_LINK_NONE, \
SOF_LINK_NONE)
#define CML_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_AMP, \
SOF_LINK_CODEC, \
SOF_LINK_DMIC01, \
SOF_LINK_IDISP_HDMI, \
SOF_LINK_DMIC16K, \
SOF_LINK_NONE, \
SOF_LINK_NONE)
#define JSL_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_AMP, \
SOF_LINK_CODEC, \
SOF_LINK_DMIC01, \
......@@ -301,6 +325,7 @@ static int audio_probe(struct platform_device *pdev)
{
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
struct sof_card_private *ctx;
char *card_name;
unsigned long board_quirk = 0;
int ret;
......@@ -317,7 +342,53 @@ static int audio_probe(struct platform_device *pdev)
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
ctx->hdmi.idisp_codec = true;
if (board_quirk & SOF_DA7219_JSL_BOARD) {
if (board_quirk & SOF_DA7219_GLK_BOARD) {
/* dmic16k not support */
ctx->dmic_be_num = 1;
/* overwrite the DAI link order for GLK boards */
ctx->link_order_overwrite = GLK_LINK_ORDER;
/* backward-compatible with existing devices */
switch (ctx->amp_type) {
case CODEC_MAX98357A:
card_name = devm_kstrdup(&pdev->dev, "glkda7219max",
GFP_KERNEL);
if (!card_name)
return -ENOMEM;
card_da7219.name = card_name;
break;
default:
break;
}
} else if (board_quirk & SOF_DA7219_CML_BOARD) {
/* overwrite the DAI link order for CML boards */
ctx->link_order_overwrite = CML_LINK_ORDER;
/* backward-compatible with existing devices */
switch (ctx->amp_type) {
case CODEC_MAX98357A:
card_name = devm_kstrdup(&pdev->dev, "cmlda7219max",
GFP_KERNEL);
if (!card_name)
return -ENOMEM;
card_da7219.name = card_name;
break;
case CODEC_MAX98390:
card_name = devm_kstrdup(&pdev->dev,
"cml_max98390_da7219",
GFP_KERNEL);
if (!card_name)
return -ENOMEM;
card_da7219.name = card_name;
break;
default:
break;
}
} else if (board_quirk & SOF_DA7219_JSL_BOARD) {
ctx->da7219.is_jsl_board = true;
/* overwrite the DAI link order for JSL boards */
......@@ -326,13 +397,20 @@ static int audio_probe(struct platform_device *pdev)
/* backward-compatible with existing devices */
switch (ctx->amp_type) {
case CODEC_MAX98360A:
card_da7219.name = devm_kstrdup(&pdev->dev,
"da7219max98360a",
GFP_KERNEL);
card_name = devm_kstrdup(&pdev->dev, "da7219max98360a",
GFP_KERNEL);
if (!card_name)
return -ENOMEM;
card_da7219.name = card_name;
break;
case CODEC_MAX98373:
card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max",
GFP_KERNEL);
card_name = devm_kstrdup(&pdev->dev, "da7219max",
GFP_KERNEL);
if (!card_name)
return -ENOMEM;
card_da7219.name = card_name;
break;
default:
break;
......@@ -352,6 +430,10 @@ static int audio_probe(struct platform_device *pdev)
case CODEC_MAX98373:
max_98373_set_codec_conf(&card_da7219);
break;
case CODEC_MAX98390:
max_98390_set_codec_conf(&pdev->dev, &card_da7219);
break;
case CODEC_MAX98357A:
case CODEC_MAX98360A:
case CODEC_NONE:
/* no codec conf required */
......@@ -374,6 +456,18 @@ static int audio_probe(struct platform_device *pdev)
}
static const struct platform_device_id board_ids[] = {
{
.name = "glk_da7219_def",
.driver_data = (kernel_ulong_t)(SOF_DA7219_GLK_BOARD |
SOF_SSP_PORT_CODEC(2) |
SOF_SSP_PORT_AMP(1)),
},
{
.name = "cml_da7219_def",
.driver_data = (kernel_ulong_t)(SOF_DA7219_CML_BOARD |
SOF_SSP_PORT_CODEC(0) |
SOF_SSP_PORT_AMP(1)),
},
{
.name = "jsl_da7219_def",
.driver_data = (kernel_ulong_t)(SOF_DA7219_JSL_BOARD |
......
......@@ -10,8 +10,23 @@
#include <sound/soc-dai.h>
#include <sound/soc-dapm.h>
#include <uapi/sound/asound.h>
#include "../common/soc-intel-quirks.h"
#include "sof_maxim_common.h"
/*
* Common structures and functions
*/
static const struct snd_kcontrol_new maxim_2spk_kcontrols[] = {
SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"),
};
static const struct snd_soc_dapm_widget maxim_2spk_widgets[] = {
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};
/* helper function to get the number of specific codec */
static unsigned int get_num_codecs(const char *hid)
{
......@@ -135,12 +150,40 @@ EXPORT_SYMBOL_NS(max_98373_ops, SND_SOC_INTEL_SOF_MAXIM_COMMON);
int max_98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
unsigned int num_codecs = get_num_codecs(MAX_98373_ACPI_HID);
int ret;
ret = snd_soc_dapm_add_routes(&card->dapm, max_98373_dapm_routes,
ARRAY_SIZE(max_98373_dapm_routes));
if (ret)
dev_err(rtd->dev, "Speaker map addition failed: %d\n", ret);
switch (num_codecs) {
case 2:
ret = snd_soc_dapm_new_controls(&card->dapm, maxim_2spk_widgets,
ARRAY_SIZE(maxim_2spk_widgets));
if (ret) {
dev_err(rtd->dev, "fail to add max98373 widgets, ret %d\n",
ret);
return ret;
}
ret = snd_soc_add_card_controls(card, maxim_2spk_kcontrols,
ARRAY_SIZE(maxim_2spk_kcontrols));
if (ret) {
dev_err(rtd->dev, "fail to add max98373 kcontrols, ret %d\n",
ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, max_98373_dapm_routes,
ARRAY_SIZE(max_98373_dapm_routes));
if (ret) {
dev_err(rtd->dev, "fail to add max98373 routes, ret %d\n",
ret);
return ret;
}
break;
default:
dev_err(rtd->dev, "max98373: invalid num_codecs %d\n", num_codecs);
return -EINVAL;
}
return ret;
}
EXPORT_SYMBOL_NS(max_98373_spk_codec_init, SND_SOC_INTEL_SOF_MAXIM_COMMON);
......@@ -177,6 +220,17 @@ static const struct snd_soc_dapm_route max_98390_tt_dapm_routes[] = {
{ "TR Spk", NULL, "Tweeter Right BE_OUT" },
};
static struct snd_soc_codec_conf max_98390_cml_codec_conf[] = {
{
.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
.name_prefix = "Left",
},
{
.dlc = COMP_CODEC_CONF(MAX_98390_DEV1_NAME),
.name_prefix = "Right",
},
};
static struct snd_soc_codec_conf max_98390_codec_conf[] = {
{
.dlc = COMP_CODEC_CONF(MAX_98390_DEV0_NAME),
......@@ -229,6 +283,7 @@ static int max_98390_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, ret;
......@@ -238,13 +293,24 @@ static int max_98390_hw_params(struct snd_pcm_substream *substream,
return -ENODEV;
}
ret = snd_soc_dai_set_tdm_slot(codec_dai, max_98390_tdm_mask[i].tx,
max_98390_tdm_mask[i].rx, 4,
params_width(params));
if (ret < 0) {
dev_err(codec_dai->dev, "fail to set tdm slot, ret %d\n",
ret);
return ret;
switch (dai_link->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_DSP_A:
case SND_SOC_DAIFMT_DSP_B:
/* 4-slot TDM */
ret = snd_soc_dai_set_tdm_slot(codec_dai,
max_98390_tdm_mask[i].tx,
max_98390_tdm_mask[i].rx,
4,
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;
......@@ -287,6 +353,22 @@ static int max_98390_init(struct snd_soc_pcm_runtime *rtd)
fallthrough;
case 2:
/* add regular speakers dapm route */
ret = snd_soc_dapm_new_controls(&card->dapm, maxim_2spk_widgets,
ARRAY_SIZE(maxim_2spk_widgets));
if (ret) {
dev_err(rtd->dev, "fail to add max98390 woofer widgets, ret %d\n",
ret);
return ret;
}
ret = snd_soc_add_card_controls(card, maxim_2spk_kcontrols,
ARRAY_SIZE(maxim_2spk_kcontrols));
if (ret) {
dev_err(rtd->dev, "fail to add max98390 woofer kcontrols, ret %d\n",
ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, max_98390_dapm_routes,
ARRAY_SIZE(max_98390_dapm_routes));
if (ret) {
......@@ -337,6 +419,10 @@ void max_98390_set_codec_conf(struct device *dev, struct snd_soc_card *card)
switch (num_codecs) {
case 2:
if (soc_intel_is_cml())
card->codec_conf = max_98390_cml_codec_conf;
fallthrough;
case 4:
card->num_configs = num_codecs;
break;
......
......@@ -140,15 +140,11 @@ static int sof_card_late_probe(struct snd_soc_card *card)
static const struct snd_kcontrol_new sof_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"),
};
static const struct snd_soc_dapm_widget sof_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};
static const struct snd_soc_dapm_route sof_map[] = {
......
......@@ -21,6 +21,17 @@
/*
* Common structures and functions
*/
static const struct snd_kcontrol_new realtek_2spk_kcontrols[] = {
SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"),
};
static const struct snd_soc_dapm_widget realtek_2spk_widgets[] = {
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};
static const struct snd_kcontrol_new realtek_4spk_kcontrols[] = {
SOC_DAPM_PIN_SWITCH("WL Ext Spk"),
SOC_DAPM_PIN_SWITCH("WR Ext Spk"),
......@@ -181,6 +192,22 @@ static int rt1011_init(struct snd_soc_pcm_runtime *rtd)
switch (num_codecs) {
case 2:
if (!soc_intel_is_cml()) {
ret = snd_soc_dapm_new_controls(&card->dapm, realtek_2spk_widgets,
ARRAY_SIZE(realtek_2spk_widgets));
if (ret) {
dev_err(rtd->dev, "fail to add rt1011 widgets, ret %d\n",
ret);
return ret;
}
ret = snd_soc_add_card_controls(card, realtek_2spk_kcontrols,
ARRAY_SIZE(realtek_2spk_kcontrols));
if (ret) {
dev_err(rtd->dev, "fail to add rt1011 kcontrols, ret %d\n",
ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, speaker_map_lr,
ARRAY_SIZE(speaker_map_lr));
if (ret) {
......@@ -357,6 +384,20 @@ static int rt1015p_init(struct snd_soc_pcm_runtime *rtd)
struct snd_soc_card *card = rtd->card;
int ret;
ret = snd_soc_dapm_new_controls(&card->dapm, realtek_2spk_widgets,
ARRAY_SIZE(realtek_2spk_widgets));
if (ret) {
dev_err(rtd->dev, "fail to add rt1015p widgets, ret %d\n", ret);
return ret;
}
ret = snd_soc_add_card_controls(card, realtek_2spk_kcontrols,
ARRAY_SIZE(realtek_2spk_kcontrols));
if (ret) {
dev_err(rtd->dev, "fail to add rt1015p kcontrols, ret %d\n", ret);
return ret;
}
if (rt1015p_get_num_codecs() == 1)
ret = snd_soc_dapm_add_routes(&card->dapm, rt1015p_1dev_dapm_routes,
ARRAY_SIZE(rt1015p_1dev_dapm_routes));
......@@ -486,8 +527,42 @@ static struct snd_soc_dai_link_component rt1015_components[] = {
static int speaker_codec_init_lr(struct snd_soc_pcm_runtime *rtd)
{
return snd_soc_dapm_add_routes(&rtd->card->dapm, speaker_map_lr,
ARRAY_SIZE(speaker_map_lr));
struct snd_soc_card *card = rtd->card;
unsigned int num_codecs = get_num_codecs(RT1015_ACPI_HID);
int ret;
switch (num_codecs) {
case 2:
ret = snd_soc_dapm_new_controls(&card->dapm, realtek_2spk_widgets,
ARRAY_SIZE(realtek_2spk_widgets));
if (ret) {
dev_err(rtd->dev, "fail to add rt1015 widgets, ret %d\n",
ret);
return ret;
}
ret = snd_soc_add_card_controls(card, realtek_2spk_kcontrols,
ARRAY_SIZE(realtek_2spk_kcontrols));
if (ret) {
dev_err(rtd->dev, "fail to add rt1015 kcontrols, ret %d\n",
ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&rtd->card->dapm, speaker_map_lr,
ARRAY_SIZE(speaker_map_lr));
if (ret) {
dev_err(rtd->dev, "fail to add rt1015 routes, ret %d\n",
ret);
return ret;
}
break;
default:
dev_err(rtd->dev, "rt1015: invalid num_codecs %d\n", num_codecs);
return -EINVAL;
}
return ret;
}
void sof_rt1015_codec_conf(struct snd_soc_card *card)
......@@ -624,6 +699,20 @@ static int rt1019p_init(struct snd_soc_pcm_runtime *rtd)
struct snd_soc_card *card = rtd->card;
int ret;
ret = snd_soc_dapm_new_controls(&card->dapm, realtek_2spk_widgets,
ARRAY_SIZE(realtek_2spk_widgets));
if (ret) {
dev_err(rtd->dev, "fail to add rt1019p widgets, ret %d\n", ret);
return ret;
}
ret = snd_soc_add_card_controls(card, realtek_2spk_kcontrols,
ARRAY_SIZE(realtek_2spk_kcontrols));
if (ret) {
dev_err(rtd->dev, "fail to add rt1019p kcontrols, ret %d\n", ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, rt1019p_dapm_routes,
ARRAY_SIZE(rt1019p_dapm_routes));
if (ret) {
......
This diff is collapsed.
......@@ -68,14 +68,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = {
},
{
.id = "DLGS7219",
.drv_name = "cml_da7219_mx98357a",
.drv_name = "cml_da7219_def",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &max98357a_spk_codecs,
.sof_tplg_filename = "sof-cml-da7219-max98357a.tplg",
},
{
.id = "DLGS7219",
.drv_name = "cml_da7219_mx98357a",
.drv_name = "cml_da7219_def",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &max98390_spk_codecs,
.sof_tplg_filename = "sof-cml-da7219-max98390.tplg",
......
......@@ -33,7 +33,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_glk_machines[] = {
},
{
.id = "DLGS7219",
.drv_name = "glk_da7219_mx98357a",
.drv_name = "glk_da7219_def",
.fw_filename = "intel/dsp_fw_glk.bin",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &glk_codecs,
......@@ -41,7 +41,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_glk_machines[] = {
},
{
.comp_ids = &glk_rt5682_rt5682s_hp,
.drv_name = "glk_rt5682_mx98357a",
.drv_name = "glk_rt5682_def",
.fw_filename = "intel/dsp_fw_glk.bin",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &glk_codecs,
......
......@@ -29,7 +29,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_icl_machines[] = {
},
{
.id = "10EC5682",
.drv_name = "sof_rt5682",
.drv_name = "icl_rt5682_def",
.sof_tplg_filename = "sof-icl-rt5682.tplg",
},
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment