ASoC: Merge fixes

Pull in wm8731 fix.

Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Mark Brown 2022-04-08 12:22:10 +01:00
commit 3d5746a187
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
17 changed files with 208 additions and 63 deletions

View File

@ -179,6 +179,10 @@ struct snd_soc_component_driver {
struct snd_pcm_hw_params *params);
bool use_dai_pcm_id; /* use DAI link PCM ID as PCM device number */
int be_pcm_base; /* base device ID for all BE PCMs */
#ifdef CONFIG_DEBUG_FS
const char *debugfs_prefix;
#endif
};
struct snd_soc_component {

View File

@ -1206,9 +1206,16 @@ static int msm8916_wcd_digital_probe(struct platform_device *pdev)
dev_set_drvdata(dev, priv);
return devm_snd_soc_register_component(dev, &msm8916_wcd_digital,
ret = devm_snd_soc_register_component(dev, &msm8916_wcd_digital,
msm8916_wcd_digital_dai,
ARRAY_SIZE(msm8916_wcd_digital_dai));
if (ret)
goto err_mclk;
return 0;
err_mclk:
clk_disable_unprepare(priv->mclk);
err_clk:
clk_disable_unprepare(priv->ahbclk);
return ret;

View File

@ -489,7 +489,7 @@ static int rk817_platform_probe(struct platform_device *pdev)
rk817_codec_parse_dt_property(&pdev->dev, rk817_codec_data);
rk817_codec_data->mclk = clk_get(pdev->dev.parent, "mclk");
rk817_codec_data->mclk = devm_clk_get(pdev->dev.parent, "mclk");
if (IS_ERR(rk817_codec_data->mclk)) {
dev_dbg(&pdev->dev, "Unable to get mclk\n");
ret = -ENXIO;

View File

@ -1100,6 +1100,15 @@ void rt5682_jack_detect_handler(struct work_struct *work)
return;
}
if (rt5682->is_sdw) {
if (pm_runtime_status_suspended(rt5682->slave->dev.parent)) {
dev_dbg(&rt5682->slave->dev,
"%s: parent device is pm_runtime_status_suspended, skipping jack detection\n",
__func__);
return;
}
}
dapm = snd_soc_component_get_dapm(rt5682->component);
snd_soc_dapm_mutex_lock(dapm);

View File

@ -245,6 +245,13 @@ static void rt711_jack_detect_handler(struct work_struct *work)
if (!rt711->component->card->instantiated)
return;
if (pm_runtime_status_suspended(rt711->slave->dev.parent)) {
dev_dbg(&rt711->slave->dev,
"%s: parent device is pm_runtime_status_suspended, skipping jack detection\n",
__func__);
return;
}
reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT;
ret = regmap_read(rt711->regmap, reg, &jack_status);
if (ret < 0)

View File

@ -1274,29 +1274,7 @@ static int wcd934x_set_sido_input_src(struct wcd934x_codec *wcd, int sido_src)
if (sido_src == wcd->sido_input_src)
return 0;
if (sido_src == SIDO_SOURCE_INTERNAL) {
regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL,
WCD934X_ANA_BUCK_HI_ACCU_EN_MASK, 0);
usleep_range(100, 110);
regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL,
WCD934X_ANA_BUCK_HI_ACCU_PRE_ENX_MASK, 0x0);
usleep_range(100, 110);
regmap_update_bits(wcd->regmap, WCD934X_ANA_RCO,
WCD934X_ANA_RCO_BG_EN_MASK, 0);
usleep_range(100, 110);
regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL,
WCD934X_ANA_BUCK_PRE_EN1_MASK,
WCD934X_ANA_BUCK_PRE_EN1_ENABLE);
usleep_range(100, 110);
regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL,
WCD934X_ANA_BUCK_PRE_EN2_MASK,
WCD934X_ANA_BUCK_PRE_EN2_ENABLE);
usleep_range(100, 110);
regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL,
WCD934X_ANA_BUCK_HI_ACCU_EN_MASK,
WCD934X_ANA_BUCK_HI_ACCU_ENABLE);
usleep_range(100, 110);
} else if (sido_src == SIDO_SOURCE_RCO_BG) {
if (sido_src == SIDO_SOURCE_RCO_BG) {
regmap_update_bits(wcd->regmap, WCD934X_ANA_RCO,
WCD934X_ANA_RCO_BG_EN_MASK,
WCD934X_ANA_RCO_BG_ENABLE);
@ -1382,8 +1360,6 @@ static int wcd934x_disable_ana_bias_and_syclk(struct wcd934x_codec *wcd)
regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG,
WCD934X_EXT_CLK_BUF_EN_MASK |
WCD934X_MCLK_EN_MASK, 0x0);
wcd934x_set_sido_input_src(wcd, SIDO_SOURCE_INTERNAL);
regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS,
WCD934X_ANA_BIAS_EN_MASK, 0);
regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS,

View File

@ -372,7 +372,7 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq)
continue;
if (ratio == 1 && !support_1_1_ratio)
continue;
else if (ratio & 1)
if ((ratio & 1) && ratio > 1)
continue;
diff = abs((long)clk_rate - ratio * freq);

View File

@ -364,13 +364,15 @@ static int asoc_simple_set_tdm(struct snd_soc_dai *dai,
struct snd_pcm_hw_params *params)
{
int sample_bits = params_width(params);
int slot_width = simple_dai->slot_width;
int slot_count = simple_dai->slots;
int slot_width, slot_count;
int i, ret;
if (!simple_dai || !simple_dai->tdm_width_map)
return 0;
slot_width = simple_dai->slot_width;
slot_count = simple_dai->slots;
if (slot_width == 0)
slot_width = sample_bits;

View File

@ -27,9 +27,11 @@
#define SOF_ES8336_SSP_CODEC(quirk) ((quirk) & GENMASK(3, 0))
#define SOF_ES8336_SSP_CODEC_MASK (GENMASK(3, 0))
#define SOF_ES8336_TGL_GPIO_QUIRK BIT(4)
#define SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK BIT(4)
#define SOF_ES8336_ENABLE_DMIC BIT(5)
#define SOF_ES8336_JD_INVERTED BIT(6)
#define SOF_ES8336_HEADPHONE_GPIO BIT(7)
#define SOC_ES8336_HEADSET_MIC1 BIT(8)
static unsigned long quirk;
@ -39,7 +41,7 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override");
struct sof_es8336_private {
struct device *codec_dev;
struct gpio_desc *gpio_pa;
struct gpio_desc *gpio_speakers, *gpio_headphone;
struct snd_soc_jack jack;
struct list_head hdmi_pcm_list;
bool speaker_en;
@ -51,19 +53,31 @@ struct sof_hdmi_pcm {
int device;
};
static const struct acpi_gpio_params pa_enable_gpio = { 0, 0, true };
static const struct acpi_gpio_mapping acpi_es8336_gpios[] = {
{ "pa-enable-gpios", &pa_enable_gpio, 1 },
static const struct acpi_gpio_params enable_gpio0 = { 0, 0, true };
static const struct acpi_gpio_params enable_gpio1 = { 1, 0, true };
static const struct acpi_gpio_mapping acpi_speakers_enable_gpio0[] = {
{ "speakers-enable-gpios", &enable_gpio0, 1 },
{ }
};
static const struct acpi_gpio_params quirk_pa_enable_gpio = { 1, 0, true };
static const struct acpi_gpio_mapping quirk_acpi_es8336_gpios[] = {
{ "pa-enable-gpios", &quirk_pa_enable_gpio, 1 },
static const struct acpi_gpio_mapping acpi_speakers_enable_gpio1[] = {
{ "speakers-enable-gpios", &enable_gpio1, 1 },
};
static const struct acpi_gpio_mapping acpi_enable_both_gpios[] = {
{ "speakers-enable-gpios", &enable_gpio0, 1 },
{ "headphone-enable-gpios", &enable_gpio1, 1 },
{ }
};
static const struct acpi_gpio_mapping *gpio_mapping = acpi_es8336_gpios;
static const struct acpi_gpio_mapping acpi_enable_both_gpios_rev_order[] = {
{ "speakers-enable-gpios", &enable_gpio1, 1 },
{ "headphone-enable-gpios", &enable_gpio0, 1 },
{ }
};
static const struct acpi_gpio_mapping *gpio_mapping = acpi_speakers_enable_gpio0;
static void log_quirks(struct device *dev)
{
@ -71,10 +85,14 @@ static void log_quirks(struct device *dev)
dev_info(dev, "quirk SSP%ld\n", SOF_ES8336_SSP_CODEC(quirk));
if (quirk & SOF_ES8336_ENABLE_DMIC)
dev_info(dev, "quirk DMIC enabled\n");
if (quirk & SOF_ES8336_TGL_GPIO_QUIRK)
dev_info(dev, "quirk TGL GPIO enabled\n");
if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK)
dev_info(dev, "Speakers GPIO1 quirk enabled\n");
if (quirk & SOF_ES8336_HEADPHONE_GPIO)
dev_info(dev, "quirk headphone GPIO enabled\n");
if (quirk & SOF_ES8336_JD_INVERTED)
dev_info(dev, "quirk JD inverted enabled\n");
if (quirk & SOC_ES8336_HEADSET_MIC1)
dev_info(dev, "quirk headset at mic1 port enabled\n");
}
static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
@ -83,12 +101,23 @@ static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
struct snd_soc_card *card = w->dapm->card;
struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card);
if (SND_SOC_DAPM_EVENT_ON(event))
priv->speaker_en = false;
else
priv->speaker_en = true;
if (priv->speaker_en == !SND_SOC_DAPM_EVENT_ON(event))
return 0;
gpiod_set_value_cansleep(priv->gpio_pa, priv->speaker_en);
priv->speaker_en = !SND_SOC_DAPM_EVENT_ON(event);
if (SND_SOC_DAPM_EVENT_ON(event))
msleep(70);
gpiod_set_value_cansleep(priv->gpio_speakers, priv->speaker_en);
if (!(quirk & SOF_ES8336_HEADPHONE_GPIO))
return 0;
if (SND_SOC_DAPM_EVENT_ON(event))
msleep(70);
gpiod_set_value_cansleep(priv->gpio_headphone, priv->speaker_en);
return 0;
}
@ -114,18 +143,23 @@ static const struct snd_soc_dapm_route sof_es8316_audio_map[] = {
/*
* There is no separate speaker output instead the speakers are muxed to
* the HP outputs. The mux is controlled by the "Speaker Power" supply.
* the HP outputs. The mux is controlled Speaker and/or headphone switch.
*/
{"Speaker", NULL, "HPOL"},
{"Speaker", NULL, "HPOR"},
{"Speaker", NULL, "Speaker Power"},
};
static const struct snd_soc_dapm_route sof_es8316_intmic_in1_map[] = {
static const struct snd_soc_dapm_route sof_es8316_headset_mic2_map[] = {
{"MIC1", NULL, "Internal Mic"},
{"MIC2", NULL, "Headset Mic"},
};
static const struct snd_soc_dapm_route sof_es8316_headset_mic1_map[] = {
{"MIC2", NULL, "Internal Mic"},
{"MIC1", NULL, "Headset Mic"},
};
static const struct snd_soc_dapm_route dmic_map[] = {
/* digital mics */
{"DMic", NULL, "SoC DMIC"},
@ -199,8 +233,13 @@ static int sof_es8316_init(struct snd_soc_pcm_runtime *runtime)
card->dapm.idle_bias_off = true;
custom_map = sof_es8316_intmic_in1_map;
num_routes = ARRAY_SIZE(sof_es8316_intmic_in1_map);
if (quirk & SOC_ES8336_HEADSET_MIC1) {
custom_map = sof_es8316_headset_mic1_map;
num_routes = ARRAY_SIZE(sof_es8316_headset_mic1_map);
} else {
custom_map = sof_es8316_headset_mic2_map;
num_routes = ARRAY_SIZE(sof_es8316_headset_mic2_map);
}
ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes);
if (ret)
@ -233,8 +272,14 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id)
{
quirk = (unsigned long)id->driver_data;
if (quirk & SOF_ES8336_TGL_GPIO_QUIRK)
gpio_mapping = quirk_acpi_es8336_gpios;
if (quirk & SOF_ES8336_HEADPHONE_GPIO) {
if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK)
gpio_mapping = acpi_enable_both_gpios;
else
gpio_mapping = acpi_enable_both_gpios_rev_order;
} else if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) {
gpio_mapping = acpi_speakers_enable_gpio1;
}
return 1;
}
@ -257,7 +302,16 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = {
DMI_MATCH(DMI_SYS_VENDOR, "IP3 tech"),
DMI_MATCH(DMI_BOARD_NAME, "WN1"),
},
.driver_data = (void *)(SOF_ES8336_TGL_GPIO_QUIRK)
.driver_data = (void *)(SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK)
},
{
.callback = sof_es8336_quirk_cb,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "HUAWEI"),
DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"),
},
.driver_data = (void *)(SOF_ES8336_HEADPHONE_GPIO |
SOC_ES8336_HEADSET_MIC1)
},
{}
};
@ -585,10 +639,17 @@ static int sof_es8336_probe(struct platform_device *pdev)
if (ret)
dev_warn(codec_dev, "unable to add GPIO mapping table\n");
priv->gpio_pa = gpiod_get_optional(codec_dev, "pa-enable", GPIOD_OUT_LOW);
if (IS_ERR(priv->gpio_pa)) {
ret = dev_err_probe(dev, PTR_ERR(priv->gpio_pa),
"could not get pa-enable GPIO\n");
priv->gpio_speakers = gpiod_get_optional(codec_dev, "speakers-enable", GPIOD_OUT_LOW);
if (IS_ERR(priv->gpio_speakers)) {
ret = dev_err_probe(dev, PTR_ERR(priv->gpio_speakers),
"could not get speakers-enable GPIO\n");
goto err_put_codec;
}
priv->gpio_headphone = gpiod_get_optional(codec_dev, "headphone-enable", GPIOD_OUT_LOW);
if (IS_ERR(priv->gpio_headphone)) {
ret = dev_err_probe(dev, PTR_ERR(priv->gpio_headphone),
"could not get headphone-enable GPIO\n");
goto err_put_codec;
}
@ -604,7 +665,7 @@ static int sof_es8336_probe(struct platform_device *pdev)
ret = devm_snd_soc_register_card(dev, card);
if (ret) {
gpiod_put(priv->gpio_pa);
gpiod_put(priv->gpio_speakers);
dev_err(dev, "snd_soc_register_card failed: %d\n", ret);
goto err_put_codec;
}
@ -622,7 +683,7 @@ static int sof_es8336_remove(struct platform_device *pdev)
struct snd_soc_card *card = platform_get_drvdata(pdev);
struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card);
gpiod_put(priv->gpio_pa);
gpiod_put(priv->gpio_speakers);
device_remove_software_node(priv->codec_dev);
put_device(priv->codec_dev);

View File

@ -212,6 +212,19 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
SOF_SSP_BT_OFFLOAD_PRESENT),
},
{
.callback = sof_rt5682_quirk_cb,
.matches = {
DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98360_ALC5682I_I2S_AMP_SSP2"),
},
.driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) |
SOF_SPEAKER_AMP_PRESENT |
SOF_MAX98360A_SPEAKER_AMP_PRESENT |
SOF_RT5682_SSP_AMP(2) |
SOF_RT5682_NUM_HDMIDEV(4)),
},
{}
};

View File

@ -132,13 +132,13 @@ static const struct snd_soc_acpi_adr_device mx8373_1_adr[] = {
{
.adr = 0x000123019F837300ull,
.num_endpoints = 1,
.endpoints = &spk_l_endpoint,
.endpoints = &spk_r_endpoint,
.name_prefix = "Right"
},
{
.adr = 0x000127019F837300ull,
.num_endpoints = 1,
.endpoints = &spk_r_endpoint,
.endpoints = &spk_l_endpoint,
.name_prefix = "Left"
}
};

View File

@ -193,6 +193,9 @@ static const struct snd_soc_component_driver aiu_acodec_ctrl_component = {
.of_xlate_dai_name = aiu_acodec_of_xlate_dai_name,
.endianness = 1,
.non_legacy_dai_naming = 1,
#ifdef CONFIG_DEBUG_FS
.debugfs_prefix = "acodec",
#endif
};
int aiu_acodec_ctrl_register_component(struct device *dev)

View File

@ -140,6 +140,9 @@ static const struct snd_soc_component_driver aiu_hdmi_ctrl_component = {
.of_xlate_dai_name = aiu_hdmi_of_xlate_dai_name,
.endianness = 1,
.non_legacy_dai_naming = 1,
#ifdef CONFIG_DEBUG_FS
.debugfs_prefix = "hdmi",
#endif
};
int aiu_hdmi_ctrl_register_component(struct device *dev)

View File

@ -103,6 +103,9 @@ static const struct snd_soc_component_driver aiu_cpu_component = {
.pointer = aiu_fifo_pointer,
.probe = aiu_cpu_component_probe,
.remove = aiu_cpu_component_remove,
#ifdef CONFIG_DEBUG_FS
.debugfs_prefix = "cpu",
#endif
};
static struct snd_soc_dai_driver aiu_cpu_dai_drv[] = {

View File

@ -2587,6 +2587,11 @@ int snd_soc_component_initialize(struct snd_soc_component *component,
component->dev = dev;
component->driver = driver;
#ifdef CONFIG_DEBUG_FS
if (!component->debugfs_prefix)
component->debugfs_prefix = driver->debugfs_prefix;
#endif
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_component_initialize);

View File

@ -83,7 +83,14 @@ static const struct dmi_system_id sof_tplg_table[] = {
},
.driver_data = "sof-adl-max98357a-rt5682-2way.tplg",
},
{
.callback = sof_tplg_cb,
.matches = {
DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Brya"),
DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98360_ALC5682I_I2S_AMP_SSP2"),
},
.driver_data = "sof-adl-max98357a-rt5682.tplg",
},
{}
};

View File

@ -915,8 +915,10 @@ static int sof_control_load(struct snd_soc_component *scomp, int index,
return -ENOMEM;
scontrol->name = kstrdup(hdr->name, GFP_KERNEL);
if (!scontrol->name)
if (!scontrol->name) {
kfree(scontrol);
return -ENOMEM;
}
scontrol->scomp = scomp;
scontrol->access = kc->access;
@ -1081,6 +1083,46 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
return 0;
}
static void sof_disconnect_dai_widget(struct snd_soc_component *scomp,
struct snd_soc_dapm_widget *w)
{
struct snd_soc_card *card = scomp->card;
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_dai *cpu_dai;
int i;
if (!w->sname)
return;
list_for_each_entry(rtd, &card->rtd_list, list) {
/* does stream match DAI link ? */
if (!rtd->dai_link->stream_name ||
strcmp(w->sname, rtd->dai_link->stream_name))
continue;
switch (w->id) {
case snd_soc_dapm_dai_out:
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
if (cpu_dai->capture_widget == w) {
cpu_dai->capture_widget = NULL;
break;
}
}
break;
case snd_soc_dapm_dai_in:
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
if (cpu_dai->playback_widget == w) {
cpu_dai->playback_widget = NULL;
break;
}
}
break;
default:
break;
}
}
}
/* bind PCM ID to host component ID */
static int spcm_bind(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm,
int dir)
@ -1364,6 +1406,9 @@ static int sof_widget_unload(struct snd_soc_component *scomp,
if (dai)
list_del(&dai->list);
sof_disconnect_dai_widget(scomp, widget);
break;
default:
break;