Merge tag 'asoc-fix-v5.19-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git...
authorTakashi Iwai <tiwai@suse.de>
Sat, 9 Jul 2022 16:23:54 +0000 (18:23 +0200)
committerTakashi Iwai <tiwai@suse.de>
Sat, 9 Jul 2022 16:23:54 +0000 (18:23 +0200)
ASoC: Fixes for v5.19

Quite a large batch due to things building up for a couple of weeks but
all driver specific apart from Marek's documentation fix.

21 files changed:
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
Documentation/sound/soc/dai.rst
sound/soc/codecs/arizona.c
sound/soc/codecs/cs47l92.c
sound/soc/codecs/max98396.c
sound/soc/codecs/rt5640.c
sound/soc/codecs/sgtl5000.c
sound/soc/codecs/sgtl5000.h
sound/soc/codecs/tas2764.c
sound/soc/codecs/tas2764.h
sound/soc/codecs/tlv320adcx140.c
sound/soc/codecs/wcd9335.c
sound/soc/codecs/wm5102.c
sound/soc/codecs/wm8998.c
sound/soc/generic/audio-graph-card2.c
sound/soc/intel/boards/sof_rt5682.c
sound/soc/intel/skylake/skl-nhlt.c
sound/soc/qcom/qdsp6/q6apm.c
sound/soc/ti/omap-mcbsp-priv.h
sound/soc/ti/omap-mcbsp-st.c
sound/soc/ti/omap-mcbsp.c

index e9a5330..ef18a57 100644 (file)
@@ -25,12 +25,12 @@ properties:
       - qcom,sc7280-lpass-cpu
 
   reg:
-    minItems: 2
+    minItems: 1
     maxItems: 6
     description: LPAIF core registers
 
   reg-names:
-    minItems: 2
+    minItems: 1
     maxItems: 6
 
   clocks:
@@ -42,12 +42,12 @@ properties:
     maxItems: 10
 
   interrupts:
-    minItems: 2
+    minItems: 1
     maxItems: 4
     description: LPAIF DMA buffer interrupt
 
   interrupt-names:
-    minItems: 2
+    minItems: 1
     maxItems: 4
 
   qcom,adsp:
index 009b07e..bf84313 100644 (file)
@@ -10,7 +10,7 @@ AC97
 ====
 
 AC97 is a five wire interface commonly found on many PC sound cards. It is
-now also popular in many portable devices. This DAI has a reset line and time
+now also popular in many portable devices. This DAI has a RESET line and time
 multiplexes its data on its SDATA_OUT (playback) and SDATA_IN (capture) lines.
 The bit clock (BCLK) is always driven by the CODEC (usually 12.288MHz) and the
 frame (FRAME) (usually 48kHz) is always driven by the controller. Each AC97
index e32871b..7434aee 100644 (file)
@@ -1760,8 +1760,8 @@ static bool arizona_aif_cfg_changed(struct snd_soc_component *component,
        if (bclk != (val & ARIZONA_AIF1_BCLK_FREQ_MASK))
                return true;
 
-       val = snd_soc_component_read(component, base + ARIZONA_AIF_TX_BCLK_RATE);
-       if (lrclk != (val & ARIZONA_AIF1TX_BCPF_MASK))
+       val = snd_soc_component_read(component, base + ARIZONA_AIF_RX_BCLK_RATE);
+       if (lrclk != (val & ARIZONA_AIF1RX_BCPF_MASK))
                return true;
 
        val = snd_soc_component_read(component, base + ARIZONA_AIF_FRAME_CTRL_1);
index a1b8dcd..444026b 100644 (file)
@@ -119,7 +119,13 @@ static int cs47l92_put_demux(struct snd_kcontrol *kcontrol,
 end:
        snd_soc_dapm_mutex_unlock(dapm);
 
-       return snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL);
+       ret = snd_soc_dapm_mux_update_power(dapm, kcontrol, mux, e, NULL);
+       if (ret < 0) {
+               dev_err(madera->dev, "Failed to update demux power state: %d\n", ret);
+               return ret;
+       }
+
+       return change;
 }
 
 static SOC_ENUM_SINGLE_DECL(cs47l92_outdemux_enum,
index 56eb62b..34db388 100644 (file)
@@ -342,12 +342,15 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 {
        struct snd_soc_component *component = codec_dai->component;
        struct max98396_priv *max98396 = snd_soc_component_get_drvdata(component);
-       unsigned int format = 0;
+       unsigned int format_mask, format = 0;
        unsigned int bclk_pol = 0;
        int ret, status;
        int reg;
        bool update = false;
 
+       format_mask = MAX98396_PCM_MODE_CFG_FORMAT_MASK |
+                     MAX98396_PCM_MODE_CFG_LRCLKEDGE;
+
        dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt);
 
        switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -395,7 +398,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
                ret = regmap_read(max98396->regmap, MAX98396_R2041_PCM_MODE_CFG, &reg);
                if (ret < 0)
                        return -EINVAL;
-               if (format != (reg & MAX98396_PCM_BCLKEDGE_BSEL_MASK)) {
+               if (format != (reg & format_mask)) {
                        update = true;
                } else {
                        ret = regmap_read(max98396->regmap,
@@ -412,8 +415,7 @@ static int max98396_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 
        regmap_update_bits(max98396->regmap,
                           MAX98396_R2041_PCM_MODE_CFG,
-                          MAX98396_PCM_BCLKEDGE_BSEL_MASK,
-                          format);
+                          format_mask, format);
 
        regmap_update_bits(max98396->regmap,
                           MAX98396_R2042_PCM_CLK_SETUP,
index 69c80d8..18b3da9 100644 (file)
@@ -1984,7 +1984,12 @@ static int rt5640_set_bias_level(struct snd_soc_component *component,
                snd_soc_component_write(component, RT5640_PWR_DIG2, 0x0000);
                snd_soc_component_write(component, RT5640_PWR_VOL, 0x0000);
                snd_soc_component_write(component, RT5640_PWR_MIXER, 0x0000);
-               snd_soc_component_write(component, RT5640_PWR_ANLG1, 0x0000);
+               if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER)
+                       snd_soc_component_write(component, RT5640_PWR_ANLG1,
+                               0x0018);
+               else
+                       snd_soc_component_write(component, RT5640_PWR_ANLG1,
+                               0x0000);
                snd_soc_component_write(component, RT5640_PWR_ANLG2, 0x0000);
                break;
 
@@ -2393,9 +2398,15 @@ static void rt5640_jack_work(struct work_struct *work)
 static irqreturn_t rt5640_irq(int irq, void *data)
 {
        struct rt5640_priv *rt5640 = data;
+       int delay = 0;
+
+       if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) {
+               cancel_delayed_work_sync(&rt5640->jack_work);
+               delay = 100;
+       }
 
        if (rt5640->jack)
-               queue_delayed_work(system_long_wq, &rt5640->jack_work, 0);
+               queue_delayed_work(system_long_wq, &rt5640->jack_work, delay);
 
        return IRQ_HANDLED;
 }
@@ -2580,6 +2591,12 @@ static void rt5640_enable_hda_jack_detect(
 
        snd_soc_component_update_bits(component, RT5640_DUMMY1, 0x400, 0x0);
 
+       snd_soc_component_update_bits(component, RT5640_PWR_ANLG1,
+               RT5640_PWR_VREF2, RT5640_PWR_VREF2);
+       usleep_range(10000, 15000);
+       snd_soc_component_update_bits(component, RT5640_PWR_ANLG1,
+               RT5640_PWR_FV2, RT5640_PWR_FV2);
+
        rt5640->jack = jack;
 
        ret = request_irq(rt5640->irq, rt5640_irq,
@@ -2696,16 +2713,13 @@ static int rt5640_probe(struct snd_soc_component *component)
 
        if (device_property_read_u32(component->dev,
                                     "realtek,jack-detect-source", &val) == 0) {
-               if (val <= RT5640_JD_SRC_GPIO4) {
+               if (val <= RT5640_JD_SRC_GPIO4)
                        rt5640->jd_src = val << RT5640_JD_SFT;
-               } else if (val == RT5640_JD_SRC_HDA_HEADER) {
+               else if (val == RT5640_JD_SRC_HDA_HEADER)
                        rt5640->jd_src = RT5640_JD_SRC_HDA_HEADER;
-                       snd_soc_component_update_bits(component, RT5640_DUMMY1,
-                               0x0300, 0x0);
-               } else {
+               else
                        dev_warn(component->dev, "Warning: Invalid jack-detect-source value: %d, leaving jack-detect disabled\n",
                                 val);
-               }
        }
 
        if (!device_property_read_bool(component->dev, "realtek,jack-detect-not-inverted"))
index 2aa48ae..3363d16 100644 (file)
@@ -1795,6 +1795,9 @@ static int sgtl5000_i2c_remove(struct i2c_client *client)
 {
        struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client);
 
+       regmap_write(sgtl5000->regmap, SGTL5000_CHIP_DIG_POWER, SGTL5000_DIG_POWER_DEFAULT);
+       regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, SGTL5000_ANA_POWER_DEFAULT);
+
        clk_disable_unprepare(sgtl5000->mclk);
        regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies);
        regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies);
@@ -1802,6 +1805,11 @@ static int sgtl5000_i2c_remove(struct i2c_client *client)
        return 0;
 }
 
+static void sgtl5000_i2c_shutdown(struct i2c_client *client)
+{
+       sgtl5000_i2c_remove(client);
+}
+
 static const struct i2c_device_id sgtl5000_id[] = {
        {"sgtl5000", 0},
        {},
@@ -1822,6 +1830,7 @@ static struct i2c_driver sgtl5000_i2c_driver = {
        },
        .probe_new = sgtl5000_i2c_probe,
        .remove = sgtl5000_i2c_remove,
+       .shutdown = sgtl5000_i2c_shutdown,
        .id_table = sgtl5000_id,
 };
 
index 56ec586..3a808c7 100644 (file)
@@ -80,6 +80,7 @@
 /*
  * SGTL5000_CHIP_DIG_POWER
  */
+#define SGTL5000_DIG_POWER_DEFAULT             0x0000
 #define SGTL5000_ADC_EN                                0x0040
 #define SGTL5000_DAC_EN                                0x0020
 #define SGTL5000_DAP_POWERUP                   0x0010
index d395fef..4cb788f 100644 (file)
@@ -42,10 +42,12 @@ static void tas2764_reset(struct tas2764_priv *tas2764)
                gpiod_set_value_cansleep(tas2764->reset_gpio, 0);
                msleep(20);
                gpiod_set_value_cansleep(tas2764->reset_gpio, 1);
+               usleep_range(1000, 2000);
        }
 
        snd_soc_component_write(tas2764->component, TAS2764_SW_RST,
                                TAS2764_RST);
+       usleep_range(1000, 2000);
 }
 
 static int tas2764_set_bias_level(struct snd_soc_component *component,
@@ -107,8 +109,10 @@ static int tas2764_codec_resume(struct snd_soc_component *component)
        struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
        int ret;
 
-       if (tas2764->sdz_gpio)
+       if (tas2764->sdz_gpio) {
                gpiod_set_value_cansleep(tas2764->sdz_gpio, 1);
+               usleep_range(1000, 2000);
+       }
 
        ret = snd_soc_component_update_bits(component, TAS2764_PWR_CTRL,
                                            TAS2764_PWR_CTRL_MASK,
@@ -131,7 +135,8 @@ static const char * const tas2764_ASI1_src[] = {
 };
 
 static SOC_ENUM_SINGLE_DECL(
-       tas2764_ASI1_src_enum, TAS2764_TDM_CFG2, 4, tas2764_ASI1_src);
+       tas2764_ASI1_src_enum, TAS2764_TDM_CFG2, TAS2764_TDM_CFG2_SCFG_SHIFT,
+       tas2764_ASI1_src);
 
 static const struct snd_kcontrol_new tas2764_asi1_mux =
        SOC_DAPM_ENUM("ASI1 Source", tas2764_ASI1_src_enum);
@@ -329,20 +334,22 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 {
        struct snd_soc_component *component = dai->component;
        struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
-       u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
-       int iface;
+       u8 tdm_rx_start_slot = 0, asi_cfg_0 = 0, asi_cfg_1 = 0;
        int ret;
 
        switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+       case SND_SOC_DAIFMT_NB_IF:
+               asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START;
+               fallthrough;
        case SND_SOC_DAIFMT_NB_NF:
                asi_cfg_1 = TAS2764_TDM_CFG1_RX_RISING;
                break;
+       case SND_SOC_DAIFMT_IB_IF:
+               asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START;
+               fallthrough;
        case SND_SOC_DAIFMT_IB_NF:
                asi_cfg_1 = TAS2764_TDM_CFG1_RX_FALLING;
                break;
-       default:
-               dev_err(tas2764->dev, "ASI format Inverse is not found\n");
-               return -EINVAL;
        }
 
        ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG1,
@@ -353,13 +360,13 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 
        switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
        case SND_SOC_DAIFMT_I2S:
+               asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START;
+               fallthrough;
        case SND_SOC_DAIFMT_DSP_A:
-               iface = TAS2764_TDM_CFG2_SCFG_I2S;
                tdm_rx_start_slot = 1;
                break;
        case SND_SOC_DAIFMT_DSP_B:
        case SND_SOC_DAIFMT_LEFT_J:
-               iface = TAS2764_TDM_CFG2_SCFG_LEFT_J;
                tdm_rx_start_slot = 0;
                break;
        default:
@@ -368,14 +375,15 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
                return -EINVAL;
        }
 
-       ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG1,
-                                           TAS2764_TDM_CFG1_MASK,
-                                           (tdm_rx_start_slot << TAS2764_TDM_CFG1_51_SHIFT));
+       ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG0,
+                                           TAS2764_TDM_CFG0_FRAME_START,
+                                           asi_cfg_0);
        if (ret < 0)
                return ret;
 
-       ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG2,
-                                           TAS2764_TDM_CFG2_SCFG_MASK, iface);
+       ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG1,
+                                           TAS2764_TDM_CFG1_MASK,
+                                           (tdm_rx_start_slot << TAS2764_TDM_CFG1_51_SHIFT));
        if (ret < 0)
                return ret;
 
@@ -501,8 +509,10 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
 
        tas2764->component = component;
 
-       if (tas2764->sdz_gpio)
+       if (tas2764->sdz_gpio) {
                gpiod_set_value_cansleep(tas2764->sdz_gpio, 1);
+               usleep_range(1000, 2000);
+       }
 
        tas2764_reset(tas2764);
 
@@ -526,12 +536,12 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
 }
 
 static DECLARE_TLV_DB_SCALE(tas2764_digital_tlv, 1100, 50, 0);
-static DECLARE_TLV_DB_SCALE(tas2764_playback_volume, -10000, 50, 0);
+static DECLARE_TLV_DB_SCALE(tas2764_playback_volume, -10050, 50, 1);
 
 static const struct snd_kcontrol_new tas2764_snd_controls[] = {
        SOC_SINGLE_TLV("Speaker Volume", TAS2764_DVC, 0,
                       TAS2764_DVC_MAX, 1, tas2764_playback_volume),
-       SOC_SINGLE_TLV("Amp Gain Volume", TAS2764_CHNL_0, 0, 0x14, 0,
+       SOC_SINGLE_TLV("Amp Gain Volume", TAS2764_CHNL_0, 1, 0x14, 0,
                       tas2764_digital_tlv),
 };
 
@@ -556,7 +566,7 @@ static const struct reg_default tas2764_reg_defaults[] = {
        { TAS2764_SW_RST, 0x00 },
        { TAS2764_PWR_CTRL, 0x1a },
        { TAS2764_DVC, 0x00 },
-       { TAS2764_CHNL_0, 0x00 },
+       { TAS2764_CHNL_0, 0x28 },
        { TAS2764_TDM_CFG0, 0x09 },
        { TAS2764_TDM_CFG1, 0x02 },
        { TAS2764_TDM_CFG2, 0x0a },
index 67d6fd9..f015f22 100644 (file)
@@ -47,6 +47,7 @@
 #define TAS2764_TDM_CFG0_MASK          GENMASK(3, 1)
 #define TAS2764_TDM_CFG0_44_1_48KHZ    BIT(3)
 #define TAS2764_TDM_CFG0_88_2_96KHZ    (BIT(3) | BIT(1))
+#define TAS2764_TDM_CFG0_FRAME_START   BIT(0)
 
 /* TDM Configuration Reg1 */
 #define TAS2764_TDM_CFG1               TAS2764_REG(0X0, 0x09)
 #define TAS2764_TDM_CFG2_RXS_16BITS    0x0
 #define TAS2764_TDM_CFG2_RXS_24BITS    BIT(0)
 #define TAS2764_TDM_CFG2_RXS_32BITS    BIT(1)
-#define TAS2764_TDM_CFG2_SCFG_MASK     GENMASK(5, 4)
-#define TAS2764_TDM_CFG2_SCFG_I2S      0x0
-#define TAS2764_TDM_CFG2_SCFG_LEFT_J   BIT(4)
-#define TAS2764_TDM_CFG2_SCFG_RIGHT_J  BIT(5)
+#define TAS2764_TDM_CFG2_SCFG_SHIFT    4
 
 /* TDM Configuration Reg3 */
 #define TAS2764_TDM_CFG3               TAS2764_REG(0X0, 0x0c)
index b55f0b8..0b72965 100644 (file)
@@ -33,7 +33,6 @@ struct adcx140_priv {
        bool micbias_vg;
 
        unsigned int dai_fmt;
-       unsigned int tdm_delay;
        unsigned int slot_width;
 };
 
@@ -792,12 +791,13 @@ static int adcx140_set_dai_tdm_slot(struct snd_soc_dai *codec_dai,
 {
        struct snd_soc_component *component = codec_dai->component;
        struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
-       unsigned int lsb;
 
-       /* TDM based on DSP mode requires slots to be adjacent */
-       lsb = __ffs(tx_mask);
-       if ((lsb + 1) != __fls(tx_mask)) {
-               dev_err(component->dev, "Invalid mask, slots must be adjacent\n");
+       /*
+        * The chip itself supports arbitrary masks, but the driver currently
+        * only supports adjacent slots beginning at the first slot.
+        */
+       if (tx_mask != GENMASK(__fls(tx_mask), 0)) {
+               dev_err(component->dev, "Only lower adjacent slots are supported\n");
                return -EINVAL;
        }
 
@@ -812,7 +812,6 @@ static int adcx140_set_dai_tdm_slot(struct snd_soc_dai *codec_dai,
                return -EINVAL;
        }
 
-       adcx140->tdm_delay = lsb;
        adcx140->slot_width = slot_width;
 
        return 0;
index d9f1352..3cb7a3e 100644 (file)
@@ -342,7 +342,7 @@ struct wcd9335_codec {
        struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY];
 
        unsigned int rx_port_value[WCD9335_RX_MAX];
-       unsigned int tx_port_value;
+       unsigned int tx_port_value[WCD9335_TX_MAX];
        int hph_l_gain;
        int hph_r_gain;
        u32 rx_bias_count;
@@ -1334,8 +1334,13 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kc,
 
        struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc);
        struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev);
+       struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc);
+       struct soc_mixer_control *mixer =
+                       (struct soc_mixer_control *)kc->private_value;
+       int dai_id = widget->shift;
+       int port_id = mixer->shift;
 
-       ucontrol->value.integer.value[0] = wcd->tx_port_value;
+       ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id] == dai_id;
 
        return 0;
 }
@@ -1358,12 +1363,12 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kc,
        case AIF2_CAP:
        case AIF3_CAP:
                /* only add to the list if value not set */
-               if (enable && !(wcd->tx_port_value & BIT(port_id))) {
-                       wcd->tx_port_value |= BIT(port_id);
+               if (enable && wcd->tx_port_value[port_id] != dai_id) {
+                       wcd->tx_port_value[port_id] = dai_id;
                        list_add_tail(&wcd->tx_chs[port_id].list,
                                        &wcd->dai[dai_id].slim_ch_list);
-               } else if (!enable && (wcd->tx_port_value & BIT(port_id))) {
-                       wcd->tx_port_value &= ~BIT(port_id);
+               } else if (!enable && wcd->tx_port_value[port_id] == dai_id) {
+                       wcd->tx_port_value[port_id] = -1;
                        list_del_init(&wcd->tx_chs[port_id].list);
                }
                break;
index da2f899..b034df4 100644 (file)
@@ -680,12 +680,17 @@ static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
        struct arizona *arizona = dev_get_drvdata(component->dev->parent);
+       uint16_t dac_comp_coeff = get_unaligned_be16(ucontrol->value.bytes.data);
+       int ret = 0;
 
        mutex_lock(&arizona->dac_comp_lock);
-       arizona->dac_comp_coeff = get_unaligned_be16(ucontrol->value.bytes.data);
+       if (arizona->dac_comp_coeff != dac_comp_coeff) {
+               arizona->dac_comp_coeff = dac_comp_coeff;
+               ret = 1;
+       }
        mutex_unlock(&arizona->dac_comp_lock);
 
-       return 0;
+       return ret;
 }
 
 static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol,
@@ -706,12 +711,20 @@ static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
        struct arizona *arizona = dev_get_drvdata(component->dev->parent);
+       struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value;
+       int ret = 0;
+
+       if (ucontrol->value.integer.value[0] > mc->max)
+               return -EINVAL;
 
        mutex_lock(&arizona->dac_comp_lock);
-       arizona->dac_comp_enabled = ucontrol->value.integer.value[0];
+       if (arizona->dac_comp_enabled != ucontrol->value.integer.value[0]) {
+               arizona->dac_comp_enabled = ucontrol->value.integer.value[0];
+               ret = 1;
+       }
        mutex_unlock(&arizona->dac_comp_lock);
 
-       return 0;
+       return ret;
 }
 
 static const char * const wm5102_osr_text[] = {
index 00b59fc..ab54811 100644 (file)
@@ -108,6 +108,7 @@ static int wm8998_inmux_put(struct snd_kcontrol *kcontrol,
        struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        unsigned int mode_reg, mode_index;
        unsigned int mux, inmode, src_val, mode_val;
+       int change, ret;
 
        mux = ucontrol->value.enumerated.item[0];
        if (mux > 1)
@@ -137,14 +138,20 @@ static int wm8998_inmux_put(struct snd_kcontrol *kcontrol,
        snd_soc_component_update_bits(component, mode_reg,
                                      ARIZONA_IN1_MODE_MASK, mode_val);
 
-       snd_soc_component_update_bits(component, e->reg,
-                                     ARIZONA_IN1L_SRC_MASK |
-                                     ARIZONA_IN1L_SRC_SE_MASK,
-                                     src_val);
+       change = snd_soc_component_update_bits(component, e->reg,
+                                              ARIZONA_IN1L_SRC_MASK |
+                                              ARIZONA_IN1L_SRC_SE_MASK,
+                                              src_val);
 
-       return snd_soc_dapm_mux_update_power(dapm, kcontrol,
-                                            ucontrol->value.enumerated.item[0],
-                                            e, NULL);
+       ret = snd_soc_dapm_mux_update_power(dapm, kcontrol,
+                                           ucontrol->value.enumerated.item[0],
+                                           e, NULL);
+       if (ret < 0) {
+               dev_err(arizona->dev, "Failed to update demux power state: %d\n", ret);
+               return ret;
+       }
+
+       return change;
 }
 
 static const char * const wm8998_inmux_texts[] = {
index 77ac405..d34b29a 100644 (file)
@@ -90,12 +90,12 @@ links indicates connection part of CPU side (= A).
                        ports@0 {
 (X) (A)                        mcpu:   port@0 { mcpu0_ep: endpoint { remote-endpoint = <&mcodec0_ep>; }; };
 (y)                            port@1 { mcpu1_ep: endpoint { remote-endpoint = <&cpu1_ep>; }; };
-(y)                            port@1 { mcpu2_ep: endpoint { remote-endpoint = <&cpu2_ep>; }; };
+(y)                            port@2 { mcpu2_ep: endpoint { remote-endpoint = <&cpu2_ep>; }; };
                        };
                        ports@1 {
 (X)                            port@0 { mcodec0_ep: endpoint { remote-endpoint = <&mcpu0_ep>; }; };
-(y)                            port@0 { mcodec1_ep: endpoint { remote-endpoint = <&codec1_ep>; }; };
-(y)                            port@1 { mcodec2_ep: endpoint { remote-endpoint = <&codec2_ep>; }; };
+(y)                            port@1 { mcodec1_ep: endpoint { remote-endpoint = <&codec1_ep>; }; };
+(y)                            port@2 { mcodec2_ep: endpoint { remote-endpoint = <&codec2_ep>; }; };
                        };
                };
        };
index 5d67a2c..4a90a0a 100644 (file)
@@ -69,11 +69,10 @@ static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
 
 static int is_legacy_cpu;
 
-static struct snd_soc_jack sof_hdmi[3];
-
 struct sof_hdmi_pcm {
        struct list_head head;
        struct snd_soc_dai *codec_dai;
+       struct snd_soc_jack hdmi_jack;
        int device;
 };
 
@@ -434,7 +433,6 @@ static int sof_card_late_probe(struct snd_soc_card *card)
        char jack_name[NAME_SIZE];
        struct sof_hdmi_pcm *pcm;
        int err;
-       int i = 0;
 
        /* HDMI is not supported by SOF on Baytrail/CherryTrail */
        if (is_legacy_cpu || !ctx->idisp_codec)
@@ -455,17 +453,15 @@ static int sof_card_late_probe(struct snd_soc_card *card)
                snprintf(jack_name, sizeof(jack_name),
                         "HDMI/DP, pcm=%d Jack", pcm->device);
                err = snd_soc_card_jack_new(card, jack_name,
-                                           SND_JACK_AVOUT, &sof_hdmi[i]);
+                                           SND_JACK_AVOUT, &pcm->hdmi_jack);
 
                if (err)
                        return err;
 
                err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
-                                         &sof_hdmi[i]);
+                                         &pcm->hdmi_jack);
                if (err < 0)
                        return err;
-
-               i++;
        }
 
        if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) {
index 2439a57..deb7b82 100644 (file)
@@ -99,7 +99,6 @@ static void skl_get_ssp_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks,
        struct nhlt_fmt_cfg *fmt_cfg;
        struct wav_fmt_ext *wav_fmt;
        unsigned long rate;
-       bool present = false;
        int rate_index = 0;
        u16 channels, bps;
        u8 clk_src;
@@ -112,9 +111,12 @@ static void skl_get_ssp_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks,
        if (fmt->fmt_count == 0)
                return;
 
+       fmt_cfg = (struct nhlt_fmt_cfg *)fmt->fmt_config;
        for (i = 0; i < fmt->fmt_count; i++) {
-               fmt_cfg = &fmt->fmt_config[i];
-               wav_fmt = &fmt_cfg->fmt_ext;
+               struct nhlt_fmt_cfg *saved_fmt_cfg = fmt_cfg;
+               bool present = false;
+
+               wav_fmt = &saved_fmt_cfg->fmt_ext;
 
                channels = wav_fmt->fmt.channels;
                bps = wav_fmt->fmt.bits_per_sample;
@@ -132,12 +134,18 @@ static void skl_get_ssp_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks,
                 * derive the rate.
                 */
                for (j = i; j < fmt->fmt_count; j++) {
-                       fmt_cfg = &fmt->fmt_config[j];
-                       wav_fmt = &fmt_cfg->fmt_ext;
+                       struct nhlt_fmt_cfg *tmp_fmt_cfg = fmt_cfg;
+
+                       wav_fmt = &tmp_fmt_cfg->fmt_ext;
                        if ((fs == wav_fmt->fmt.samples_per_sec) &&
-                          (bps == wav_fmt->fmt.bits_per_sample))
+                          (bps == wav_fmt->fmt.bits_per_sample)) {
                                channels = max_t(u16, channels,
                                                wav_fmt->fmt.channels);
+                               saved_fmt_cfg = tmp_fmt_cfg;
+                       }
+                       /* Move to the next nhlt_fmt_cfg */
+                       tmp_fmt_cfg = (struct nhlt_fmt_cfg *)(tmp_fmt_cfg->config.caps +
+                                                             tmp_fmt_cfg->config.size);
                }
 
                rate = channels * bps * fs;
@@ -153,8 +161,11 @@ static void skl_get_ssp_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks,
 
                /* Fill rate and parent for sclk/sclkfs */
                if (!present) {
+                       struct nhlt_fmt_cfg *first_fmt_cfg;
+
+                       first_fmt_cfg = (struct nhlt_fmt_cfg *)fmt->fmt_config;
                        i2s_config_ext = (struct skl_i2s_config_blob_ext *)
-                                               fmt->fmt_config[0].config.caps;
+                                               first_fmt_cfg->config.caps;
 
                        /* MCLK Divider Source Select */
                        if (is_legacy_blob(i2s_config_ext->hdr.sig)) {
@@ -168,6 +179,9 @@ static void skl_get_ssp_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks,
 
                        parent = skl_get_parent_clk(clk_src);
 
+                       /* Move to the next nhlt_fmt_cfg */
+                       fmt_cfg = (struct nhlt_fmt_cfg *)(fmt_cfg->config.caps +
+                                                         fmt_cfg->config.size);
                        /*
                         * Do not copy the config data if there is no parent
                         * clock available for this clock source select
@@ -176,9 +190,9 @@ static void skl_get_ssp_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks,
                                continue;
 
                        sclk[id].rate_cfg[rate_index].rate = rate;
-                       sclk[id].rate_cfg[rate_index].config = fmt_cfg;
+                       sclk[id].rate_cfg[rate_index].config = saved_fmt_cfg;
                        sclkfs[id].rate_cfg[rate_index].rate = rate;
-                       sclkfs[id].rate_cfg[rate_index].config = fmt_cfg;
+                       sclkfs[id].rate_cfg[rate_index].config = saved_fmt_cfg;
                        sclk[id].parent_name = parent->name;
                        sclkfs[id].parent_name = parent->name;
 
@@ -192,13 +206,13 @@ static void skl_get_mclk(struct skl_dev *skl, struct skl_ssp_clk *mclk,
 {
        struct skl_i2s_config_blob_ext *i2s_config_ext;
        struct skl_i2s_config_blob_legacy *i2s_config;
-       struct nhlt_specific_cfg *fmt_cfg;
+       struct nhlt_fmt_cfg *fmt_cfg;
        struct skl_clk_parent_src *parent;
        u32 clkdiv, div_ratio;
        u8 clk_src;
 
-       fmt_cfg = &fmt->fmt_config[0].config;
-       i2s_config_ext = (struct skl_i2s_config_blob_ext *)fmt_cfg->caps;
+       fmt_cfg = (struct nhlt_fmt_cfg *)fmt->fmt_config;
+       i2s_config_ext = (struct skl_i2s_config_blob_ext *)fmt_cfg->config.caps;
 
        /* MCLK Divider Source Select and divider */
        if (is_legacy_blob(i2s_config_ext->hdr.sig)) {
@@ -227,7 +241,7 @@ static void skl_get_mclk(struct skl_dev *skl, struct skl_ssp_clk *mclk,
                return;
 
        mclk[id].rate_cfg[0].rate = parent->rate/div_ratio;
-       mclk[id].rate_cfg[0].config = &fmt->fmt_config[0];
+       mclk[id].rate_cfg[0].config = fmt_cfg;
        mclk[id].parent_name = parent->name;
 }
 
index f424d7a..7940192 100644 (file)
@@ -75,6 +75,7 @@ static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui
        id = idr_alloc(&apm->graph_idr, graph, graph_id, graph_id + 1, GFP_KERNEL);
        if (id < 0) {
                dev_err(apm->dev, "Unable to allocate graph id (%d)\n", graph_id);
+               kfree(graph->graph);
                kfree(graph);
                mutex_unlock(&apm->lock);
                return ERR_PTR(id);
index 7865cda..da519ea 100644 (file)
@@ -316,8 +316,6 @@ static inline int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg,
 
 /* Sidetone specific API */
 int omap_mcbsp_st_init(struct platform_device *pdev);
-void omap_mcbsp_st_cleanup(struct platform_device *pdev);
-
 int omap_mcbsp_st_start(struct omap_mcbsp *mcbsp);
 int omap_mcbsp_st_stop(struct omap_mcbsp *mcbsp);
 
index 0bc7d26..7e8179c 100644 (file)
@@ -347,7 +347,7 @@ int omap_mcbsp_st_init(struct platform_device *pdev)
        if (!st_data)
                return -ENOMEM;
 
-       st_data->mcbsp_iclk = clk_get(mcbsp->dev, "ick");
+       st_data->mcbsp_iclk = devm_clk_get(mcbsp->dev, "ick");
        if (IS_ERR(st_data->mcbsp_iclk)) {
                dev_warn(mcbsp->dev,
                         "Failed to get ick, sidetone might be broken\n");
@@ -359,7 +359,7 @@ int omap_mcbsp_st_init(struct platform_device *pdev)
        if (!st_data->io_base_st)
                return -ENOMEM;
 
-       ret = sysfs_create_group(&mcbsp->dev->kobj, &sidetone_attr_group);
+       ret = devm_device_add_group(mcbsp->dev, &sidetone_attr_group);
        if (ret)
                return ret;
 
@@ -368,16 +368,6 @@ int omap_mcbsp_st_init(struct platform_device *pdev)
        return 0;
 }
 
-void omap_mcbsp_st_cleanup(struct platform_device *pdev)
-{
-       struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
-
-       if (mcbsp->st_data) {
-               sysfs_remove_group(&mcbsp->dev->kobj, &sidetone_attr_group);
-               clk_put(mcbsp->st_data->mcbsp_iclk);
-       }
-}
-
 static int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
                                    struct snd_ctl_elem_info *uinfo)
 {
index 4479d74..9933b33 100644 (file)
@@ -702,8 +702,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
                mcbsp->max_tx_thres = max_thres(mcbsp) - 0x10;
                mcbsp->max_rx_thres = max_thres(mcbsp) - 0x10;
 
-               ret = sysfs_create_group(&mcbsp->dev->kobj,
-                                        &additional_attr_group);
+               ret = devm_device_add_group(mcbsp->dev, &additional_attr_group);
                if (ret) {
                        dev_err(mcbsp->dev,
                                "Unable to create additional controls\n");
@@ -711,16 +710,7 @@ static int omap_mcbsp_init(struct platform_device *pdev)
                }
        }
 
-       ret = omap_mcbsp_st_init(pdev);
-       if (ret)
-               goto err_st;
-
-       return 0;
-
-err_st:
-       if (mcbsp->pdata->buffer_size)
-               sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
-       return ret;
+       return omap_mcbsp_st_init(pdev);
 }
 
 /*
@@ -1431,11 +1421,6 @@ static int asoc_mcbsp_remove(struct platform_device *pdev)
        if (cpu_latency_qos_request_active(&mcbsp->pm_qos_req))
                cpu_latency_qos_remove_request(&mcbsp->pm_qos_req);
 
-       if (mcbsp->pdata->buffer_size)
-               sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
-
-       omap_mcbsp_st_cleanup(pdev);
-
        return 0;
 }