ASoC: jz4752b: Capture fixes
authorMark Brown <broonie@kernel.org>
Wed, 19 Oct 2022 15:37:01 +0000 (16:37 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 19 Oct 2022 15:37:01 +0000 (16:37 +0100)
Merge series from Siarhei Volkau <lis8215@gmail.com>:

The patchset fixes:
 - Line In path stays powered off during capturing or
   bypass to mixer.
 - incorrectly represented dB values in alsamixer, et al.
 - incorrect represented Capture input selector in alsamixer
   in Playback tab.
 - wrong control selected as Capture Master

1  2 
sound/soc/codecs/mt6660.c
sound/soc/codecs/rt5682s.c
sound/soc/codecs/tlv320adc3xxx.c
sound/soc/codecs/wm8962.c
sound/soc/intel/boards/sof_sdw.c

@@@ -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,14 -520,13 +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)
@@@ -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:
@@@ -3256,11 -3245,9 +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[] = {
@@@ -1426,7 -1426,7 +1426,7 @@@ err_unprepare_mclk
        return ret;
  }
  
- static int __exit adc3xxx_i2c_remove(struct i2c_client *client)
+ static void __exit adc3xxx_i2c_remove(struct i2c_client *client)
  {
        struct adc3xxx *adc3xxx = i2c_get_clientdata(client);
  
                clk_disable_unprepare(adc3xxx->mclk);
        adc3xxx_free_gpio(adc3xxx);
        snd_soc_unregister_component(&client->dev);
-       return 0;
  }
  
  static const struct of_device_id tlv320adc3xxx_of_match[] = {
@@@ -1450,7 -1449,7 +1449,7 @@@ static struct i2c_driver adc3xxx_i2c_dr
                   .of_match_table = tlv320adc3xxx_of_match,
                  },
        .probe_new = adc3xxx_i2c_probe,
 -      .remove = adc3xxx_i2c_remove,
 +      .remove = __exit_p(adc3xxx_i2c_remove),
        .id_table = adc3xxx_i2c_id,
  };
  
@@@ -1840,49 -1840,6 +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)
  {
@@@ -2183,10 -2140,8 +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)),
@@@ -3808,11 -3763,6 +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 */
@@@ -3828,10 -3778,9 +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
@@@ -198,17 -198,6 +198,17 @@@ static const struct dmi_system_id sof_s
                        DMI_MATCH(DMI_SYS_VENDOR, "Intel(R) Client Systems"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "LAPBC"),
                },
 +              .driver_data = (void *)(SOF_SDW_TGL_HDMI |
 +                                      SOF_SDW_PCH_DMIC |
 +                                      RT711_JD1),
 +      },
 +      {
 +              /* NUC15 LAPBC710 skews */
 +              .callback = sof_sdw_quirk_cb,
 +              .matches = {
 +                      DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
 +                      DMI_MATCH(DMI_BOARD_NAME, "LAPBC710"),
 +              },
                .driver_data = (void *)(SOF_SDW_TGL_HDMI |
                                        SOF_SDW_PCH_DMIC |
                                        RT711_JD1),
                .callback = sof_sdw_quirk_cb,
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
+                       DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0AFF")
+               },
+               .driver_data = (void *)(SOF_SDW_TGL_HDMI |
+                                       RT711_JD2 |
+                                       SOF_SDW_FOUR_SPK),
+       },
+       {
+               .callback = sof_sdw_quirk_cb,
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
                        DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0B00")
                },
                .driver_data = (void *)(SOF_SDW_TGL_HDMI |