Merge existing fixes from asoc/for-6.1 into new branch
authorMark Brown <broonie@kernel.org>
Mon, 17 Oct 2022 11:47:15 +0000 (12:47 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 17 Oct 2022 11:47:15 +0000 (12:47 +0100)
1  2 
sound/soc/codecs/mt6660.c
sound/soc/codecs/rt5682s.c
sound/soc/codecs/wm8962.c

index 554c33e8b62f4d57bafbebf572770f286d989500,b8369eeccc30223f30b78fb7e7794e2f27443f1a..cc2df5f7ea191e04bd9e39f3a66096cfc05f854b
@@@ -503,14 -503,14 +503,14 @@@ static int mt6660_i2c_probe(struct i2c_
                dev_err(chip->dev, "read chip revision fail\n");
                goto probe_fail;
        }
+       pm_runtime_set_active(chip->dev);
+       pm_runtime_enable(chip->dev);
  
        ret = devm_snd_soc_register_component(chip->dev,
                                               &mt6660_component_driver,
                                               &mt6660_codec_dai, 1);
-       if (!ret) {
-               pm_runtime_set_active(chip->dev);
-               pm_runtime_enable(chip->dev);
-       }
+       if (ret)
+               pm_runtime_disable(chip->dev);
  
        return ret;
  
@@@ -520,13 -520,14 +520,13 @@@ probe_fail
        return ret;
  }
  
 -static int mt6660_i2c_remove(struct i2c_client *client)
 +static void mt6660_i2c_remove(struct i2c_client *client)
  {
        struct mt6660_chip *chip = i2c_get_clientdata(client);
  
        pm_runtime_disable(chip->dev);
        pm_runtime_set_suspended(chip->dev);
        mutex_destroy(&chip->io_lock);
 -      return 0;
  }
  
  static int __maybe_unused mt6660_i2c_runtime_suspend(struct device *dev)
index 466a37f3500cd452bef6e542b80a22b40aa3a16d,5199d3bbaf0b996f3b1f4e7f069f97c500ca8131..80c673aa14db8f272fce209a36cf70a8ef3c48bd
@@@ -1981,7 -1981,7 +1981,7 @@@ static int rt5682s_set_tdm_slot(struct 
                unsigned int rx_mask, int slots, int slot_width)
  {
        struct snd_soc_component *component = dai->component;
-       unsigned int cl, val = 0;
+       unsigned int cl, val = 0, tx_slotnum;
  
        if (tx_mask || rx_mask)
                snd_soc_component_update_bits(component,
                snd_soc_component_update_bits(component,
                        RT5682S_TDM_ADDA_CTRL_2, RT5682S_TDM_EN, 0);
  
+       /* Tx slot configuration */
+       tx_slotnum = hweight_long(tx_mask);
+       if (tx_slotnum) {
+               if (tx_slotnum > slots) {
+                       dev_err(component->dev, "Invalid or oversized Tx slots.\n");
+                       return -EINVAL;
+               }
+               val |= (tx_slotnum - 1) << RT5682S_TDM_ADC_DL_SFT;
+       }
        switch (slots) {
        case 4:
                val |= RT5682S_TDM_TX_CH_4;
        }
  
        snd_soc_component_update_bits(component, RT5682S_TDM_CTRL,
-               RT5682S_TDM_TX_CH_MASK | RT5682S_TDM_RX_CH_MASK, val);
+               RT5682S_TDM_TX_CH_MASK | RT5682S_TDM_RX_CH_MASK |
+               RT5682S_TDM_ADC_DL_MASK, val);
  
        switch (slot_width) {
        case 8:
@@@ -3245,9 -3256,11 +3256,9 @@@ static void rt5682s_i2c_shutdown(struc
        rt5682s_reset(rt5682s);
  }
  
 -static int rt5682s_i2c_remove(struct i2c_client *client)
 +static void rt5682s_i2c_remove(struct i2c_client *client)
  {
        rt5682s_i2c_shutdown(client);
 -
 -      return 0;
  }
  
  static const struct of_device_id rt5682s_of_match[] = {
index 81049664387e147b44551501fd9bfc1a4ce26f0b,6df06fba43778f81a0638ebad0a8acd84fa8bbce..b4b4355c6728b0c4977bcd3f0b24006561c432bf
@@@ -1840,6 -1840,49 +1840,49 @@@ SOC_SINGLE_TLV("SPKOUTR Mixer DACR Volu
               4, 1, 0, inmix_tlv),
  };
  
+ static int tp_event(struct snd_soc_dapm_widget *w,
+                   struct snd_kcontrol *kcontrol, int event)
+ {
+       int ret, reg, val, mask;
+       struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+       ret = pm_runtime_resume_and_get(component->dev);
+       if (ret < 0) {
+               dev_err(component->dev, "Failed to resume device: %d\n", ret);
+               return ret;
+       }
+       reg = WM8962_ADDITIONAL_CONTROL_4;
+       if (!strcmp(w->name, "TEMP_HP")) {
+               mask = WM8962_TEMP_ENA_HP_MASK;
+               val = WM8962_TEMP_ENA_HP;
+       } else if (!strcmp(w->name, "TEMP_SPK")) {
+               mask = WM8962_TEMP_ENA_SPK_MASK;
+               val = WM8962_TEMP_ENA_SPK;
+       } else {
+               pm_runtime_put(component->dev);
+               return -EINVAL;
+       }
+       switch (event) {
+       case SND_SOC_DAPM_POST_PMD:
+               val = 0;
+               fallthrough;
+       case SND_SOC_DAPM_POST_PMU:
+               ret = snd_soc_component_update_bits(component, reg, mask, val);
+               break;
+       default:
+               WARN(1, "Invalid event %d\n", event);
+               pm_runtime_put(component->dev);
+               return -EINVAL;
+       }
+       pm_runtime_put(component->dev);
+       return 0;
+ }
  static int cp_event(struct snd_soc_dapm_widget *w,
                    struct snd_kcontrol *kcontrol, int event)
  {
@@@ -2140,8 -2183,10 +2183,10 @@@ SND_SOC_DAPM_SUPPLY("TOCLK", WM8962_ADD
  SND_SOC_DAPM_SUPPLY_S("DSP2", 1, WM8962_DSP2_POWER_MANAGEMENT,
                      WM8962_DSP2_ENA_SHIFT, 0, dsp2_event,
                      SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
- SND_SOC_DAPM_SUPPLY("TEMP_HP", WM8962_ADDITIONAL_CONTROL_4, 2, 0, NULL, 0),
- SND_SOC_DAPM_SUPPLY("TEMP_SPK", WM8962_ADDITIONAL_CONTROL_4, 1, 0, NULL, 0),
+ SND_SOC_DAPM_SUPPLY("TEMP_HP", SND_SOC_NOPM, 0, 0, tp_event,
+               SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
+ SND_SOC_DAPM_SUPPLY("TEMP_SPK", SND_SOC_NOPM, 0, 0, tp_event,
+               SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
  
  SND_SOC_DAPM_MIXER("INPGAL", WM8962_LEFT_INPUT_PGA_CONTROL, 4, 0,
                   inpgal, ARRAY_SIZE(inpgal)),
@@@ -3763,6 -3808,11 +3808,11 @@@ static int wm8962_i2c_probe(struct i2c_
        if (ret < 0)
                goto err_pm_runtime;
  
+       regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4,
+                           WM8962_TEMP_ENA_HP_MASK, 0);
+       regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4,
+                           WM8962_TEMP_ENA_SPK_MASK, 0);
        regcache_cache_only(wm8962->regmap, true);
  
        /* The drivers should power up as needed */
@@@ -3778,9 -3828,10 +3828,9 @@@ err
        return ret;
  }
  
 -static int wm8962_i2c_remove(struct i2c_client *client)
 +static void wm8962_i2c_remove(struct i2c_client *client)
  {
        pm_runtime_disable(&client->dev);
 -      return 0;
  }
  
  #ifdef CONFIG_PM