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.
This commit is contained in:
Mark Brown 2024-04-30 23:35:08 +09:00
commit 395f23e920
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
13 changed files with 461 additions and 1016 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -1,693 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright(c) 2018 Intel Corporation.
/*
* Intel Geminilake I2S Machine Driver with MAX98357A & RT5682 Codecs
*
* Modified from:
* Intel Apollolake I2S Machine driver
*/
#include <linux/input.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "../../codecs/rt5682.h"
#include "../../codecs/rt5682s.h"
#include "../../codecs/hdac_hdmi.h"
#include "hda_dsp_common.h"
/* The platform clock outputs 19.2Mhz clock to codec as I2S MCLK */
#define GLK_PLAT_CLK_FREQ 19200000
#define RT5682_PLL_FREQ (48000 * 512)
#define RT5682_DAI_NAME "rt5682-aif1"
#define RT5682S_DAI_NAME "rt5682s-aif1"
#define GLK_MAXIM_CODEC_DAI "HiFi"
#define RT5682_DEV0_NAME "i2c-10EC5682:00"
#define RT5682S_DEV0_NAME "i2c-RTL5682:00"
#define MAXIM_DEV0_NAME "MX98357A:00"
#define DUAL_CHANNEL 2
#define QUAD_CHANNEL 4
#define NAME_SIZE 32
static struct snd_soc_jack geminilake_hdmi[3];
struct glk_hdmi_pcm {
struct list_head head;
struct snd_soc_dai *codec_dai;
int device;
};
struct glk_card_private {
struct snd_soc_jack geminilake_headset;
struct list_head hdmi_pcm_list;
bool common_hdmi_codec_drv;
int is_rt5682s;
};
enum {
GLK_DPCM_AUDIO_PB = 0,
GLK_DPCM_AUDIO_CP,
GLK_DPCM_AUDIO_HS_PB,
GLK_DPCM_AUDIO_ECHO_REF_CP,
GLK_DPCM_AUDIO_REF_CP,
GLK_DPCM_AUDIO_DMIC_CP,
GLK_DPCM_AUDIO_HDMI1_PB,
GLK_DPCM_AUDIO_HDMI2_PB,
GLK_DPCM_AUDIO_HDMI3_PB,
};
static const struct snd_kcontrol_new geminilake_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
SOC_DAPM_PIN_SWITCH("Spk"),
};
static const struct snd_soc_dapm_widget geminilake_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_SPK("Spk", NULL),
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
SND_SOC_DAPM_SPK("HDMI1", NULL),
SND_SOC_DAPM_SPK("HDMI2", NULL),
SND_SOC_DAPM_SPK("HDMI3", NULL),
};
static struct snd_soc_jack_pin jack_pins[] = {
{
.pin = "Headphone Jack",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "Headset Mic",
.mask = SND_JACK_MICROPHONE,
},
};
static const struct snd_soc_dapm_route geminilake_map[] = {
/* HP jack connectors - unknown if we have jack detection */
{ "Headphone Jack", NULL, "HPOL" },
{ "Headphone Jack", NULL, "HPOR" },
/* speaker */
{ "Spk", NULL, "Speaker" },
/* other jacks */
{ "IN1P", NULL, "Headset Mic" },
/* digital mics */
{ "DMic", NULL, "SoC DMIC" },
/* CODEC BE connections */
{ "HiFi Playback", NULL, "ssp1 Tx" },
{ "ssp1 Tx", NULL, "codec0_out" },
{ "AIF1 Playback", NULL, "ssp2 Tx" },
{ "ssp2 Tx", NULL, "codec1_out" },
{ "codec0_in", NULL, "ssp2 Rx" },
{ "ssp2 Rx", NULL, "AIF1 Capture" },
{ "HDMI1", NULL, "hif5-0 Output" },
{ "HDMI2", NULL, "hif6-0 Output" },
{ "HDMI2", NULL, "hif7-0 Output" },
{ "hifi3", NULL, "iDisp3 Tx" },
{ "iDisp3 Tx", NULL, "iDisp3_out" },
{ "hifi2", NULL, "iDisp2 Tx" },
{ "iDisp2 Tx", NULL, "iDisp2_out" },
{ "hifi1", NULL, "iDisp1 Tx" },
{ "iDisp1 Tx", NULL, "iDisp1_out" },
/* DMIC */
{ "dmic01_hifi", NULL, "DMIC01 Rx" },
{ "DMIC01 Rx", NULL, "DMIC AIF" },
};
static int geminilake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
struct snd_interval *rate = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_RATE);
struct snd_interval *chan = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_CHANNELS);
struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
/* The ADSP will convert the FE rate to 48k, stereo */
rate->min = rate->max = 48000;
chan->min = chan->max = DUAL_CHANNEL;
/* set SSP to 24 bit */
snd_mask_none(fmt);
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
return 0;
}
static int geminilake_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
{
struct glk_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
struct snd_soc_jack *jack;
int pll_id, pll_source, clk_id, ret;
if (ctx->is_rt5682s) {
pll_id = RT5682S_PLL2;
pll_source = RT5682S_PLL_S_MCLK;
clk_id = RT5682S_SCLK_S_PLL2;
} else {
pll_id = RT5682_PLL1;
pll_source = RT5682_PLL1_S_MCLK;
clk_id = RT5682_SCLK_S_PLL1;
}
ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source,
GLK_PLAT_CLK_FREQ, RT5682_PLL_FREQ);
if (ret < 0) {
dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
return ret;
}
/* Configure sysclk for codec */
ret = snd_soc_dai_set_sysclk(codec_dai, clk_id,
RT5682_PLL_FREQ, SND_SOC_CLOCK_IN);
if (ret < 0)
dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
/*
* Headset buttons map to the google Reference headset.
* These can be configured by userspace.
*/
ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT,
&ctx->geminilake_headset,
jack_pins,
ARRAY_SIZE(jack_pins));
if (ret) {
dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
return ret;
}
jack = &ctx->geminilake_headset;
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
ret = snd_soc_component_set_jack(component, jack, NULL);
if (ret) {
dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
return ret;
}
return ret;
};
static int geminilake_rt5682_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 *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
int ret;
/* Set valid bitmask & configuration for I2S in 24 bit */
ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x0, 0x0, 2, 24);
if (ret < 0) {
dev_err(rtd->dev, "set TDM slot err:%d\n", ret);
return ret;
}
return ret;
}
static struct snd_soc_ops geminilake_rt5682_ops = {
.hw_params = geminilake_rt5682_hw_params,
};
static int geminilake_hdmi_init(struct snd_soc_pcm_runtime *rtd)
{
struct glk_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
struct glk_hdmi_pcm *pcm;
pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL);
if (!pcm)
return -ENOMEM;
pcm->device = GLK_DPCM_AUDIO_HDMI1_PB + dai->id;
pcm->codec_dai = dai;
list_add_tail(&pcm->head, &ctx->hdmi_pcm_list);
return 0;
}
static int geminilake_rt5682_fe_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component = snd_soc_rtd_to_cpu(rtd, 0)->component;
struct snd_soc_dapm_context *dapm;
int ret;
dapm = snd_soc_component_get_dapm(component);
ret = snd_soc_dapm_ignore_suspend(dapm, "Reference Capture");
if (ret) {
dev_err(rtd->dev, "Ref Cap ignore suspend failed %d\n", ret);
return ret;
}
return ret;
}
static const unsigned int rates[] = {
48000,
};
static const struct snd_pcm_hw_constraint_list constraints_rates = {
.count = ARRAY_SIZE(rates),
.list = rates,
.mask = 0,
};
static unsigned int channels_quad[] = {
QUAD_CHANNEL,
};
static struct snd_pcm_hw_constraint_list constraints_channels_quad = {
.count = ARRAY_SIZE(channels_quad),
.list = channels_quad,
.mask = 0,
};
static int geminilake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
struct snd_interval *chan = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_CHANNELS);
/*
* set BE channel constraint as user FE channels
*/
chan->min = chan->max = 4;
return 0;
}
static int geminilake_dmic_startup(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL;
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
&constraints_channels_quad);
return snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, &constraints_rates);
}
static const struct snd_soc_ops geminilake_dmic_ops = {
.startup = geminilake_dmic_startup,
};
static const unsigned int rates_16000[] = {
16000,
};
static const struct snd_pcm_hw_constraint_list constraints_16000 = {
.count = ARRAY_SIZE(rates_16000),
.list = rates_16000,
};
static int geminilake_refcap_startup(struct snd_pcm_substream *substream)
{
return snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_16000);
};
static const struct snd_soc_ops geminilake_refcap_ops = {
.startup = geminilake_refcap_startup,
};
SND_SOC_DAILINK_DEF(dummy,
DAILINK_COMP_ARRAY(COMP_DUMMY()));
SND_SOC_DAILINK_DEF(system,
DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
SND_SOC_DAILINK_DEF(system2,
DAILINK_COMP_ARRAY(COMP_CPU("System Pin2")));
SND_SOC_DAILINK_DEF(echoref,
DAILINK_COMP_ARRAY(COMP_CPU("Echoref Pin")));
SND_SOC_DAILINK_DEF(reference,
DAILINK_COMP_ARRAY(COMP_CPU("Reference Pin")));
SND_SOC_DAILINK_DEF(dmic,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC Pin")));
SND_SOC_DAILINK_DEF(hdmi1,
DAILINK_COMP_ARRAY(COMP_CPU("HDMI1 Pin")));
SND_SOC_DAILINK_DEF(hdmi2,
DAILINK_COMP_ARRAY(COMP_CPU("HDMI2 Pin")));
SND_SOC_DAILINK_DEF(hdmi3,
DAILINK_COMP_ARRAY(COMP_CPU("HDMI3 Pin")));
SND_SOC_DAILINK_DEF(ssp1_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
SND_SOC_DAILINK_DEF(ssp1_codec,
DAILINK_COMP_ARRAY(COMP_CODEC(MAXIM_DEV0_NAME,
GLK_MAXIM_CODEC_DAI)));
SND_SOC_DAILINK_DEF(ssp2_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SSP2 Pin")));
SND_SOC_DAILINK_DEF(ssp2_codec_5682,
DAILINK_COMP_ARRAY(COMP_CODEC(RT5682_DEV0_NAME,
RT5682_DAI_NAME)));
SND_SOC_DAILINK_DEF(ssp2_codec_5682s,
DAILINK_COMP_ARRAY(COMP_CODEC(RT5682S_DEV0_NAME,
RT5682S_DAI_NAME)));
SND_SOC_DAILINK_DEF(dmic_pin,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
SND_SOC_DAILINK_DEF(dmic_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
SND_SOC_DAILINK_DEF(idisp1_pin,
DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
SND_SOC_DAILINK_DEF(idisp1_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
SND_SOC_DAILINK_DEF(idisp2_pin,
DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
SND_SOC_DAILINK_DEF(idisp2_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
SND_SOC_DAILINK_DEF(idisp3_pin,
DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
SND_SOC_DAILINK_DEF(idisp3_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
SND_SOC_DAILINK_DEF(platform,
DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:0e.0")));
/* geminilake digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link geminilake_dais[] = {
/* Front End DAI links */
[GLK_DPCM_AUDIO_PB] = {
.name = "Glk Audio Port",
.stream_name = "Audio",
.dynamic = 1,
.nonatomic = 1,
.init = geminilake_rt5682_fe_init,
.trigger = {
SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
.dpcm_playback = 1,
SND_SOC_DAILINK_REG(system, dummy, platform),
},
[GLK_DPCM_AUDIO_CP] = {
.name = "Glk Audio Capture Port",
.stream_name = "Audio Record",
.dynamic = 1,
.nonatomic = 1,
.trigger = {
SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
.dpcm_capture = 1,
SND_SOC_DAILINK_REG(system, dummy, platform),
},
[GLK_DPCM_AUDIO_HS_PB] = {
.name = "Glk Audio Headset Playback",
.stream_name = "Headset Audio",
.dpcm_playback = 1,
.nonatomic = 1,
.dynamic = 1,
SND_SOC_DAILINK_REG(system2, dummy, platform),
},
[GLK_DPCM_AUDIO_ECHO_REF_CP] = {
.name = "Glk Audio Echo Reference cap",
.stream_name = "Echoreference Capture",
.init = NULL,
.dpcm_capture = 1,
.nonatomic = 1,
.dynamic = 1,
SND_SOC_DAILINK_REG(echoref, dummy, platform),
},
[GLK_DPCM_AUDIO_REF_CP] = {
.name = "Glk Audio Reference cap",
.stream_name = "Refcap",
.init = NULL,
.dpcm_capture = 1,
.nonatomic = 1,
.dynamic = 1,
.ops = &geminilake_refcap_ops,
SND_SOC_DAILINK_REG(reference, dummy, platform),
},
[GLK_DPCM_AUDIO_DMIC_CP] = {
.name = "Glk Audio DMIC cap",
.stream_name = "dmiccap",
.init = NULL,
.dpcm_capture = 1,
.nonatomic = 1,
.dynamic = 1,
.ops = &geminilake_dmic_ops,
SND_SOC_DAILINK_REG(dmic, dummy, platform),
},
[GLK_DPCM_AUDIO_HDMI1_PB] = {
.name = "Glk HDMI Port1",
.stream_name = "Hdmi1",
.dpcm_playback = 1,
.init = NULL,
.trigger = {
SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
.nonatomic = 1,
.dynamic = 1,
SND_SOC_DAILINK_REG(hdmi1, dummy, platform),
},
[GLK_DPCM_AUDIO_HDMI2_PB] = {
.name = "Glk HDMI Port2",
.stream_name = "Hdmi2",
.dpcm_playback = 1,
.init = NULL,
.trigger = {
SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
.nonatomic = 1,
.dynamic = 1,
SND_SOC_DAILINK_REG(hdmi2, dummy, platform),
},
[GLK_DPCM_AUDIO_HDMI3_PB] = {
.name = "Glk HDMI Port3",
.stream_name = "Hdmi3",
.trigger = {
SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
.dpcm_playback = 1,
.init = NULL,
.nonatomic = 1,
.dynamic = 1,
SND_SOC_DAILINK_REG(hdmi3, dummy, platform),
},
/* Back End DAI links */
{
/* SSP1 - Codec */
.name = "SSP1-Codec",
.id = 0,
.no_pcm = 1,
.dai_fmt = SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBC_CFC,
.ignore_pmdown_time = 1,
.be_hw_params_fixup = geminilake_ssp_fixup,
.dpcm_playback = 1,
SND_SOC_DAILINK_REG(ssp1_pin, ssp1_codec, platform),
},
{
/* SSP2 - Codec */
.name = "SSP2-Codec",
.id = 1,
.no_pcm = 1,
.init = geminilake_rt5682_codec_init,
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBC_CFC,
.ignore_pmdown_time = 1,
.be_hw_params_fixup = geminilake_ssp_fixup,
.ops = &geminilake_rt5682_ops,
.dpcm_playback = 1,
.dpcm_capture = 1,
SND_SOC_DAILINK_REG(ssp2_pin, ssp2_codec_5682, platform),
},
{
.name = "dmic01",
.id = 2,
.ignore_suspend = 1,
.be_hw_params_fixup = geminilake_dmic_fixup,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
},
{
.name = "iDisp1",
.id = 3,
.init = geminilake_hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
},
{
.name = "iDisp2",
.id = 4,
.init = geminilake_hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
},
{
.name = "iDisp3",
.id = 5,
.init = geminilake_hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
},
};
static int glk_card_late_probe(struct snd_soc_card *card)
{
struct glk_card_private *ctx = snd_soc_card_get_drvdata(card);
struct snd_soc_component *component = NULL;
char jack_name[NAME_SIZE];
struct glk_hdmi_pcm *pcm;
int err;
int i = 0;
if (list_empty(&ctx->hdmi_pcm_list))
return -EINVAL;
if (ctx->common_hdmi_codec_drv) {
pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm,
head);
component = pcm->codec_dai->component;
return hda_dsp_hdmi_build_controls(card, component);
}
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name,
SND_JACK_AVOUT, &geminilake_hdmi[i]);
if (err)
return err;
err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
&geminilake_hdmi[i]);
if (err < 0)
return err;
i++;
}
return hdac_hdmi_jack_port_init(component, &card->dapm);
}
/* geminilake audio machine driver for SPT + RT5682 */
static struct snd_soc_card glk_audio_card_rt5682_m98357a = {
.name = "glkrt5682max",
.owner = THIS_MODULE,
.dai_link = geminilake_dais,
.num_links = ARRAY_SIZE(geminilake_dais),
.controls = geminilake_controls,
.num_controls = ARRAY_SIZE(geminilake_controls),
.dapm_widgets = geminilake_widgets,
.num_dapm_widgets = ARRAY_SIZE(geminilake_widgets),
.dapm_routes = geminilake_map,
.num_dapm_routes = ARRAY_SIZE(geminilake_map),
.fully_routed = true,
.late_probe = glk_card_late_probe,
};
static int geminilake_audio_probe(struct platform_device *pdev)
{
struct glk_card_private *ctx;
struct snd_soc_acpi_mach *mach;
const char *platform_name;
struct snd_soc_card *card;
int ret, i;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
/* Detect the headset codec variant */
if (acpi_dev_present("RTL5682", NULL, -1)) {
/* ALC5682I-VS is detected */
ctx->is_rt5682s = 1;
for (i = 0; i < glk_audio_card_rt5682_m98357a.num_links; i++) {
if (strcmp(geminilake_dais[i].name, "SSP2-Codec"))
continue;
/* update the dai link to use rt5682s codec */
geminilake_dais[i].codecs = ssp2_codec_5682s;
geminilake_dais[i].num_codecs = ARRAY_SIZE(ssp2_codec_5682s);
break;
}
}
INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
card = &glk_audio_card_rt5682_m98357a;
card->dev = &pdev->dev;
snd_soc_card_set_drvdata(card, ctx);
if (!snd_soc_acpi_sof_parent(&pdev->dev))
card->disable_route_checks = true;
/* override platform name, if required */
mach = pdev->dev.platform_data;
platform_name = mach->mach_params.platform;
ret = snd_soc_fixup_dai_links_platform_name(card, platform_name);
if (ret)
return ret;
ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv;
return devm_snd_soc_register_card(&pdev->dev, card);
}
static const struct platform_device_id glk_board_ids[] = {
{
.name = "glk_rt5682_mx98357a",
.driver_data =
(kernel_ulong_t)&glk_audio_card_rt5682_m98357a,
},
{ }
};
MODULE_DEVICE_TABLE(platform, glk_board_ids);
static struct platform_driver geminilake_audio = {
.probe = geminilake_audio_probe,
.driver = {
.name = "glk_rt5682_max98357a",
.pm = &snd_soc_pm_ops,
},
.id_table = glk_board_ids,
};
module_platform_driver(geminilake_audio)
/* Module information */
MODULE_DESCRIPTION("Geminilake Audio Machine driver-RT5682 & MAX98357A in I2S mode");
MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);

View File

@ -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;
};
/*

View File

@ -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 |

View File

@ -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;

View File

@ -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[] = {

View File

@ -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) {

View File

@ -30,7 +30,6 @@
/* Driver-specific board quirks: from bit 0 to 7 */
#define SOF_RT5682_MCLK_EN BIT(0)
#define SOF_RT5682_MCLK_BYTCHT_EN BIT(1)
/* Default: MCLK on, MCLK 19.2M, SSP0 */
static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
@ -77,15 +76,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
SOF_SSP_PORT_CODEC(0) |
SOF_SSP_PORT_AMP(1)),
},
{
.callback = sof_rt5682_quirk_cb,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
DMI_MATCH(DMI_PRODUCT_NAME, "Ice Lake Client"),
},
.driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_SSP_PORT_CODEC(0)),
},
{
.callback = sof_rt5682_quirk_cb,
.matches = {
@ -165,7 +155,7 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
int extra_jack_data;
int ret, mclk_freq;
if (sof_rt5682_quirk & SOF_RT5682_MCLK_EN) {
if (ctx->rt5682.mclk_en) {
mclk_freq = sof_dai_get_mclk(rtd);
if (mclk_freq <= 0) {
dev_err(rtd->dev, "invalid mclk freq %d\n", mclk_freq);
@ -206,7 +196,7 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd)
}
}
if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
if (ctx->rt5682.is_legacy_cpu) {
/*
* The firmware might enable the clock at
* boot (this information may or may not
@ -278,8 +268,8 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
int pll_id, pll_source, pll_in, pll_out, clk_id, ret;
if (sof_rt5682_quirk & SOF_RT5682_MCLK_EN) {
if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
if (ctx->rt5682.mclk_en) {
if (ctx->rt5682.is_legacy_cpu) {
ret = clk_prepare_enable(ctx->rt5682.mclk);
if (ret < 0) {
dev_err(rtd->dev,
@ -327,36 +317,12 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
}
pll_in = params_rate(params) * 50;
}
switch (ctx->codec_type) {
case CODEC_RT5650:
pll_id = 0; /* not used in codec driver */
clk_id = RT5645_SCLK_S_PLL1;
break;
case CODEC_RT5682:
pll_id = RT5682_PLL1;
clk_id = RT5682_SCLK_S_PLL1;
break;
case CODEC_RT5682S:
/*
* For MCLK = 24.576MHz and sample rate = 96KHz case, use PLL1 We don't test
* pll_out or params_rate() here since rt5682s PLL2 doesn't support 24.576MHz
* input, so we have no choice but to use PLL1. Besides, we will not use PLL at
* all if pll_in == pll_out. ex, MCLK = 24.576Mhz and sample rate = 48KHz
*/
if (pll_in == 24576000) {
pll_id = RT5682S_PLL1;
clk_id = RT5682S_SCLK_S_PLL1;
} else {
pll_id = RT5682S_PLL2;
clk_id = RT5682S_SCLK_S_PLL2;
/* get the tplg configured bclk. */
pll_in = sof_dai_get_bclk(rtd);
if (pll_in <= 0) {
dev_err(rtd->dev, "invalid bclk freq %d\n", pll_in);
return -EINVAL;
}
break;
default:
dev_err(rtd->dev, "invalid codec type %d\n", ctx->codec_type);
return -EINVAL;
}
pll_out = params_rate(params) * 512;
@ -379,6 +345,40 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
}
} else {
switch (ctx->codec_type) {
case CODEC_RT5650:
pll_id = 0; /* not used in codec driver */
clk_id = RT5645_SCLK_S_PLL1;
break;
case CODEC_RT5682:
pll_id = RT5682_PLL1;
clk_id = RT5682_SCLK_S_PLL1;
break;
case CODEC_RT5682S:
/* check plla_table and pllb_table in rt5682s.c */
switch (pll_in) {
case 3072000:
case 24576000:
/*
* For MCLK = 24.576MHz and sample rate = 96KHz case, use PLL1 We don't test
* pll_out or params_rate() here since rt5682s PLL2 doesn't support 24.576MHz
* input, so we have no choice but to use PLL1. Besides, we will not use PLL at
* all if pll_in == pll_out. ex, MCLK = 24.576Mhz and sample rate = 48KHz
*/
pll_id = RT5682S_PLL1;
clk_id = RT5682S_SCLK_S_PLL1;
break;
default:
pll_id = RT5682S_PLL2;
clk_id = RT5682S_SCLK_S_PLL2;
break;
}
break;
default:
dev_err(rtd->dev, "invalid codec type %d\n", ctx->codec_type);
return -EINVAL;
}
/* Configure pll for codec */
ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, pll_in,
pll_out);
@ -431,16 +431,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[] = {
@ -452,6 +447,17 @@ static const struct snd_soc_dapm_route sof_map[] = {
{ "IN1P", NULL, "Headset Mic" },
};
static const struct snd_kcontrol_new rt5650_spk_kcontrols[] = {
SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"),
};
static const struct snd_soc_dapm_widget rt5650_spk_widgets[] = {
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};
static const struct snd_soc_dapm_route rt5650_spk_dapm_routes[] = {
/* speaker */
{ "Left Spk", NULL, "SPOL" },
@ -463,6 +469,22 @@ static int rt5650_spk_init(struct snd_soc_pcm_runtime *rtd)
struct snd_soc_card *card = rtd->card;
int ret;
ret = snd_soc_dapm_new_controls(&card->dapm, rt5650_spk_widgets,
ARRAY_SIZE(rt5650_spk_widgets));
if (ret) {
dev_err(rtd->dev, "fail to add rt5650 spk widgets, ret %d\n",
ret);
return ret;
}
ret = snd_soc_add_card_controls(card, rt5650_spk_kcontrols,
ARRAY_SIZE(rt5650_spk_kcontrols));
if (ret) {
dev_err(rtd->dev, "fail to add rt5650 spk kcontrols, ret %d\n",
ret);
return ret;
}
ret = snd_soc_dapm_add_routes(&card->dapm, rt5650_spk_dapm_routes,
ARRAY_SIZE(rt5650_spk_dapm_routes));
if (ret)
@ -613,12 +635,19 @@ 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)
static int sof_audio_probe(struct platform_device *pdev)
{
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
struct sof_card_private *ctx;
char *card_name;
bool is_legacy_cpu = false;
int ret;
if (pdev->id_entry && pdev->id_entry->driver_data)
@ -626,15 +655,6 @@ static int sof_audio_probe(struct platform_device *pdev)
dmi_check_system(sof_rt5682_quirk_table);
if (soc_intel_is_byt() || soc_intel_is_cht()) {
is_legacy_cpu = true;
/* default quirk for legacy cpu */
sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
SOF_RT5682_MCLK_BYTCHT_EN |
SOF_SSP_PORT_CODEC(2);
}
dev_dbg(&pdev->dev, "sof_rt5682_quirk = %lx\n", sof_rt5682_quirk);
/* initialize ctx with board quirk */
@ -654,43 +674,71 @@ static int sof_audio_probe(struct platform_device *pdev)
ctx->amp_type = CODEC_RT5650;
}
if (ctx->amp_type == CODEC_RT1011 && soc_intel_is_cml()) {
/* backward-compatible with existing cml devices */
card_name = devm_kstrdup(&pdev->dev, "cml_rt1011_rt5682",
GFP_KERNEL);
if (!card_name)
return -ENOMEM;
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
ctx->hdmi.idisp_codec = true;
sof_audio_card_rt5682.name = card_name;
}
if (is_legacy_cpu) {
if (soc_intel_is_byt() || soc_intel_is_cht()) {
ctx->rt5682.is_legacy_cpu = true;
ctx->dmic_be_num = 0;
/* HDMI is not supported by SOF on Baytrail/CherryTrail */
ctx->hdmi_num = 0;
} else {
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
ctx->hdmi.idisp_codec = true;
} else if (soc_intel_is_glk()) {
/* 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, "glkrt5682max",
GFP_KERNEL);
if (!card_name)
return -ENOMEM;
sof_audio_card_rt5682.name = card_name;
break;
default:
break;
}
} else if (soc_intel_is_cml()) {
/* backward-compatible with existing devices */
switch (ctx->amp_type) {
case CODEC_RT1011:
card_name = devm_kstrdup(&pdev->dev, "cml_rt1011_rt5682",
GFP_KERNEL);
if (!card_name)
return -ENOMEM;
sof_audio_card_rt5682.name = card_name;
break;
default:
break;
}
}
/* need to get main clock from pmc */
if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) {
ctx->rt5682.mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
if (IS_ERR(ctx->rt5682.mclk)) {
ret = PTR_ERR(ctx->rt5682.mclk);
if (sof_rt5682_quirk & SOF_RT5682_MCLK_EN) {
ctx->rt5682.mclk_en = true;
dev_err(&pdev->dev,
"Failed to get MCLK from pmc_plt_clk_3: %d\n",
ret);
return ret;
}
/* need to get main clock from pmc */
if (ctx->rt5682.is_legacy_cpu) {
ctx->rt5682.mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
if (IS_ERR(ctx->rt5682.mclk)) {
ret = PTR_ERR(ctx->rt5682.mclk);
ret = clk_prepare_enable(ctx->rt5682.mclk);
if (ret < 0) {
dev_err(&pdev->dev,
"could not configure MCLK state");
return ret;
dev_err(&pdev->dev,
"Failed to get MCLK from pmc_plt_clk_3: %d\n",
ret);
return ret;
}
ret = clk_prepare_enable(ctx->rt5682.mclk);
if (ret < 0) {
dev_err(&pdev->dev,
"could not configure MCLK state");
return ret;
}
}
}
@ -745,6 +793,19 @@ static int sof_audio_probe(struct platform_device *pdev)
static const struct platform_device_id board_ids[] = {
{
.name = "sof_rt5682",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_SSP_PORT_CODEC(2)),
},
{
.name = "glk_rt5682_def",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_SSP_PORT_CODEC(2) |
SOF_SSP_PORT_AMP(1)),
},
{
.name = "icl_rt5682_def",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_SSP_PORT_CODEC(0)),
},
{
.name = "cml_rt5682_def",

View File

@ -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",

View File

@ -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,

View File

@ -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",
},
{