Skip to content

Commit 85ca6b1

Browse files
jwrdegoedebroonie
authored andcommitted
ASoC: rt5670: Add new gpio1_is_ext_spk_en quirk and enable it on the Lenovo Miix 2 10
The Lenovo Miix 2 10 has a keyboard dock with extra speakers in the dock. Rather then the ACL5672's GPIO1 pin being used as IRQ to the CPU, it is actually used to enable the amplifier for these speakers (the IRQ to the CPU comes directly from the jack-detect switch). Add a quirk for having an ext speaker-amplifier enable pin on GPIO1 and replace the Lenovo Miix 2 10's dmi_system_id table entry's wrong GPIO_DEV quirk (which needs to be renamed to GPIO1_IS_IRQ) with the new RT5670_GPIO1_IS_EXT_SPK_EN quirk, so that we enable the external speaker-amplifier as necessary. Also update the ident field for the dmi_system_id table entry, the Miix models are not Thinkpads. Fixes: 67e03ff ("ASoC: codecs: rt5670: add Thinkpad Tablet 10 quirk") Signed-off-by: Hans de Goede <[email protected]> BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1786723 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 5cacc6f commit 85ca6b1

File tree

2 files changed

+57
-15
lines changed

2 files changed

+57
-15
lines changed

include/sound/rt5670.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct rt5670_platform_data {
1212
int jd_mode;
1313
bool in2_diff;
1414
bool dev_gpio;
15+
bool gpio1_is_ext_spk_en;
1516

1617
bool dmic_en;
1718
unsigned int dmic1_data_pin;

sound/soc/codecs/rt5670.c

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@
3131
#include "rt5670.h"
3232
#include "rt5670-dsp.h"
3333

34-
#define RT5670_DEV_GPIO BIT(0)
35-
#define RT5670_IN2_DIFF BIT(1)
36-
#define RT5670_DMIC_EN BIT(2)
37-
#define RT5670_DMIC1_IN2P BIT(3)
38-
#define RT5670_DMIC1_GPIO6 BIT(4)
39-
#define RT5670_DMIC1_GPIO7 BIT(5)
40-
#define RT5670_DMIC2_INR BIT(6)
41-
#define RT5670_DMIC2_GPIO8 BIT(7)
42-
#define RT5670_DMIC3_GPIO5 BIT(8)
43-
#define RT5670_JD_MODE1 BIT(9)
44-
#define RT5670_JD_MODE2 BIT(10)
45-
#define RT5670_JD_MODE3 BIT(11)
34+
#define RT5670_DEV_GPIO BIT(0)
35+
#define RT5670_IN2_DIFF BIT(1)
36+
#define RT5670_DMIC_EN BIT(2)
37+
#define RT5670_DMIC1_IN2P BIT(3)
38+
#define RT5670_DMIC1_GPIO6 BIT(4)
39+
#define RT5670_DMIC1_GPIO7 BIT(5)
40+
#define RT5670_DMIC2_INR BIT(6)
41+
#define RT5670_DMIC2_GPIO8 BIT(7)
42+
#define RT5670_DMIC3_GPIO5 BIT(8)
43+
#define RT5670_JD_MODE1 BIT(9)
44+
#define RT5670_JD_MODE2 BIT(10)
45+
#define RT5670_JD_MODE3 BIT(11)
46+
#define RT5670_GPIO1_IS_EXT_SPK_EN BIT(12)
4647

4748
static unsigned long rt5670_quirk;
4849
static unsigned int quirk_override;
@@ -1447,6 +1448,33 @@ static int rt5670_hp_event(struct snd_soc_dapm_widget *w,
14471448
return 0;
14481449
}
14491450

1451+
static int rt5670_spk_event(struct snd_soc_dapm_widget *w,
1452+
struct snd_kcontrol *kcontrol, int event)
1453+
{
1454+
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1455+
struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component);
1456+
1457+
if (!rt5670->pdata.gpio1_is_ext_spk_en)
1458+
return 0;
1459+
1460+
switch (event) {
1461+
case SND_SOC_DAPM_POST_PMU:
1462+
regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2,
1463+
RT5670_GP1_OUT_MASK, RT5670_GP1_OUT_HI);
1464+
break;
1465+
1466+
case SND_SOC_DAPM_PRE_PMD:
1467+
regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2,
1468+
RT5670_GP1_OUT_MASK, RT5670_GP1_OUT_LO);
1469+
break;
1470+
1471+
default:
1472+
return 0;
1473+
}
1474+
1475+
return 0;
1476+
}
1477+
14501478
static int rt5670_bst1_event(struct snd_soc_dapm_widget *w,
14511479
struct snd_kcontrol *kcontrol, int event)
14521480
{
@@ -1860,7 +1888,9 @@ static const struct snd_soc_dapm_widget rt5670_specific_dapm_widgets[] = {
18601888
};
18611889

18621890
static const struct snd_soc_dapm_widget rt5672_specific_dapm_widgets[] = {
1863-
SND_SOC_DAPM_PGA("SPO Amp", SND_SOC_NOPM, 0, 0, NULL, 0),
1891+
SND_SOC_DAPM_PGA_E("SPO Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
1892+
rt5670_spk_event, SND_SOC_DAPM_PRE_PMD |
1893+
SND_SOC_DAPM_POST_PMU),
18641894
SND_SOC_DAPM_OUTPUT("SPOLP"),
18651895
SND_SOC_DAPM_OUTPUT("SPOLN"),
18661896
SND_SOC_DAPM_OUTPUT("SPORP"),
@@ -2857,14 +2887,14 @@ static const struct dmi_system_id dmi_platform_intel_quirks[] = {
28572887
},
28582888
{
28592889
.callback = rt5670_quirk_cb,
2860-
.ident = "Lenovo Thinkpad Tablet 10",
2890+
.ident = "Lenovo Miix 2 10",
28612891
.matches = {
28622892
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
28632893
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Miix 2 10"),
28642894
},
28652895
.driver_data = (unsigned long *)(RT5670_DMIC_EN |
28662896
RT5670_DMIC1_IN2P |
2867-
RT5670_DEV_GPIO |
2897+
RT5670_GPIO1_IS_EXT_SPK_EN |
28682898
RT5670_JD_MODE2),
28692899
},
28702900
{
@@ -2924,6 +2954,10 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
29242954
rt5670->pdata.dev_gpio = true;
29252955
dev_info(&i2c->dev, "quirk dev_gpio\n");
29262956
}
2957+
if (rt5670_quirk & RT5670_GPIO1_IS_EXT_SPK_EN) {
2958+
rt5670->pdata.gpio1_is_ext_spk_en = true;
2959+
dev_info(&i2c->dev, "quirk GPIO1 is external speaker enable\n");
2960+
}
29272961
if (rt5670_quirk & RT5670_IN2_DIFF) {
29282962
rt5670->pdata.in2_diff = true;
29292963
dev_info(&i2c->dev, "quirk IN2_DIFF\n");
@@ -3023,6 +3057,13 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
30233057
RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT);
30243058
}
30253059

3060+
if (rt5670->pdata.gpio1_is_ext_spk_en) {
3061+
regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1,
3062+
RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_GPIO1);
3063+
regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2,
3064+
RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT);
3065+
}
3066+
30263067
if (rt5670->pdata.jd_mode) {
30273068
regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK,
30283069
RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_RCCLK);

0 commit comments

Comments
 (0)