]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - sound/soc/codecs/rt5640.c
Merge remote-tracking branches 'asoc/topic/rcar', 'asoc/topic/reg-default', 'asoc...
[karo-tx-linux.git] / sound / soc / codecs / rt5640.c
index 9bc78e57513d74e40c5a4f9bda59c34625b15715..a37223f7307adf8880ebfecee4414ba6449c25f4 100644 (file)
@@ -51,7 +51,7 @@ static const struct regmap_range_cfg rt5640_ranges[] = {
          .window_len = 0x1, },
 };
 
-static const struct reg_default init_list[] = {
+static const struct reg_sequence init_list[] = {
        {RT5640_PR_BASE + 0x3d, 0x3600},
        {RT5640_PR_BASE + 0x12, 0x0aa8},
        {RT5640_PR_BASE + 0x14, 0x0aaa},
@@ -459,10 +459,11 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
 {
        struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
        struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
-       int idx = -EINVAL;
-
-       idx = rl6231_calc_dmic_clk(rt5640->sysclk);
+       int idx, rate;
 
+       rate = rt5640->sysclk / rl6231_get_pre_div(rt5640->regmap,
+               RT5640_ADDA_CLK1, RT5640_I2S_PD1_SFT);
+       idx = rl6231_calc_dmic_clk(rate);
        if (idx < 0)
                dev_err(codec->dev, "Failed to set DMIC clock\n");
        else
@@ -984,6 +985,35 @@ static int rt5640_hp_event(struct snd_soc_dapm_widget *w,
        return 0;
 }
 
+static int rt5640_lout_event(struct snd_soc_dapm_widget *w,
+       struct snd_kcontrol *kcontrol, int event)
+{
+       struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+
+       switch (event) {
+       case SND_SOC_DAPM_POST_PMU:
+               hp_amp_power_on(codec);
+               snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
+                       RT5640_PWR_LM, RT5640_PWR_LM);
+               snd_soc_update_bits(codec, RT5640_OUTPUT,
+                       RT5640_L_MUTE | RT5640_R_MUTE, 0);
+               break;
+
+       case SND_SOC_DAPM_PRE_PMD:
+               snd_soc_update_bits(codec, RT5640_OUTPUT,
+                       RT5640_L_MUTE | RT5640_R_MUTE,
+                       RT5640_L_MUTE | RT5640_R_MUTE);
+               snd_soc_update_bits(codec, RT5640_PWR_ANLG1,
+                       RT5640_PWR_LM, 0);
+               break;
+
+       default:
+               return 0;
+       }
+
+       return 0;
+}
+
 static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w,
                           struct snd_kcontrol *kcontrol, int event)
 {
@@ -1179,13 +1209,16 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = {
                0, rt5640_spo_l_mix, ARRAY_SIZE(rt5640_spo_l_mix)),
        SND_SOC_DAPM_MIXER("SPOR MIX", SND_SOC_NOPM, 0,
                0, rt5640_spo_r_mix, ARRAY_SIZE(rt5640_spo_r_mix)),
-       SND_SOC_DAPM_MIXER("LOUT MIX", RT5640_PWR_ANLG1, RT5640_PWR_LM_BIT, 0,
+       SND_SOC_DAPM_MIXER("LOUT MIX", SND_SOC_NOPM, 0, 0,
                rt5640_lout_mix, ARRAY_SIZE(rt5640_lout_mix)),
        SND_SOC_DAPM_SUPPLY_S("Improve HP Amp Drv", 1, SND_SOC_NOPM,
                0, 0, rt5640_hp_power_event, SND_SOC_DAPM_POST_PMU),
        SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0,
                rt5640_hp_event,
                SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
+       SND_SOC_DAPM_PGA_S("LOUT amp", 1, SND_SOC_NOPM, 0, 0,
+               rt5640_lout_event,
+               SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
        SND_SOC_DAPM_SUPPLY("HP L Amp", RT5640_PWR_ANLG1,
                RT5640_PWR_HP_L_BIT, 0, NULL, 0),
        SND_SOC_DAPM_SUPPLY("HP R Amp", RT5640_PWR_ANLG1,
@@ -1500,8 +1533,10 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = {
        {"HP R Playback", "Switch", "HP Amp"},
        {"HPOL", NULL, "HP L Playback"},
        {"HPOR", NULL, "HP R Playback"},
-       {"LOUTL", NULL, "LOUT MIX"},
-       {"LOUTR", NULL, "LOUT MIX"},
+
+       {"LOUT amp", NULL, "LOUT MIX"},
+       {"LOUTL", NULL, "LOUT amp"},
+       {"LOUTR", NULL, "LOUT amp"},
 };
 
 static const struct snd_soc_dapm_route rt5640_specific_dapm_routes[] = {
@@ -2242,7 +2277,6 @@ static int rt5640_i2c_remove(struct i2c_client *i2c)
 static struct i2c_driver rt5640_i2c_driver = {
        .driver = {
                .name = "rt5640",
-               .owner = THIS_MODULE,
                .acpi_match_table = ACPI_PTR(rt5640_acpi_match),
                .of_match_table = of_match_ptr(rt5640_of_match),
        },