|
31 | 31 | #include "rt5670.h"
|
32 | 32 | #include "rt5670-dsp.h"
|
33 | 33 |
|
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) |
46 | 47 |
|
47 | 48 | static unsigned long rt5670_quirk;
|
48 | 49 | static unsigned int quirk_override;
|
@@ -1447,6 +1448,33 @@ static int rt5670_hp_event(struct snd_soc_dapm_widget *w,
|
1447 | 1448 | return 0;
|
1448 | 1449 | }
|
1449 | 1450 |
|
| 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 | + |
1450 | 1478 | static int rt5670_bst1_event(struct snd_soc_dapm_widget *w,
|
1451 | 1479 | struct snd_kcontrol *kcontrol, int event)
|
1452 | 1480 | {
|
@@ -1860,7 +1888,9 @@ static const struct snd_soc_dapm_widget rt5670_specific_dapm_widgets[] = {
|
1860 | 1888 | };
|
1861 | 1889 |
|
1862 | 1890 | 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), |
1864 | 1894 | SND_SOC_DAPM_OUTPUT("SPOLP"),
|
1865 | 1895 | SND_SOC_DAPM_OUTPUT("SPOLN"),
|
1866 | 1896 | SND_SOC_DAPM_OUTPUT("SPORP"),
|
@@ -2857,14 +2887,14 @@ static const struct dmi_system_id dmi_platform_intel_quirks[] = {
|
2857 | 2887 | },
|
2858 | 2888 | {
|
2859 | 2889 | .callback = rt5670_quirk_cb,
|
2860 |
| - .ident = "Lenovo Thinkpad Tablet 10", |
| 2890 | + .ident = "Lenovo Miix 2 10", |
2861 | 2891 | .matches = {
|
2862 | 2892 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
|
2863 | 2893 | DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Miix 2 10"),
|
2864 | 2894 | },
|
2865 | 2895 | .driver_data = (unsigned long *)(RT5670_DMIC_EN |
|
2866 | 2896 | RT5670_DMIC1_IN2P |
|
2867 |
| - RT5670_DEV_GPIO | |
| 2897 | + RT5670_GPIO1_IS_EXT_SPK_EN | |
2868 | 2898 | RT5670_JD_MODE2),
|
2869 | 2899 | },
|
2870 | 2900 | {
|
@@ -2924,6 +2954,10 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
|
2924 | 2954 | rt5670->pdata.dev_gpio = true;
|
2925 | 2955 | dev_info(&i2c->dev, "quirk dev_gpio\n");
|
2926 | 2956 | }
|
| 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 | + } |
2927 | 2961 | if (rt5670_quirk & RT5670_IN2_DIFF) {
|
2928 | 2962 | rt5670->pdata.in2_diff = true;
|
2929 | 2963 | dev_info(&i2c->dev, "quirk IN2_DIFF\n");
|
@@ -3023,6 +3057,13 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
|
3023 | 3057 | RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT);
|
3024 | 3058 | }
|
3025 | 3059 |
|
| 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 | + |
3026 | 3067 | if (rt5670->pdata.jd_mode) {
|
3027 | 3068 | regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK,
|
3028 | 3069 | RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_RCCLK);
|
|
0 commit comments