Merge remote-tracking branches 'asoc/fix/rt5659', 'asoc/fix/sigmadsp', 'asoc/fix...
[cascardo/linux.git] / sound / soc / codecs / wm5110.c
index c364096..97c0f1e 100644 (file)
@@ -360,15 +360,13 @@ static int wm5110_hp_ev(struct snd_soc_dapm_widget *w,
 
 static int wm5110_clear_pga_volume(struct arizona *arizona, int output)
 {
-       struct reg_sequence clear_pga = {
-               ARIZONA_OUTPUT_PATH_CONFIG_1L + output * 4, 0x80
-       };
+       unsigned int reg = ARIZONA_OUTPUT_PATH_CONFIG_1L + output * 4;
        int ret;
 
-       ret = regmap_multi_reg_write_bypassed(arizona->regmap, &clear_pga, 1);
+       ret = regmap_write(arizona->regmap, reg, 0x80);
        if (ret)
                dev_err(arizona->dev, "Failed to clear PGA (0x%x): %d\n",
-                       clear_pga.reg, ret);
+                       reg, ret);
 
        return ret;
 }
@@ -439,18 +437,17 @@ static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-       struct snd_soc_card *card = dapm->card;
        int ret;
 
        /*
         * PGA Volume is also used as part of the enable sequence, so
         * usage of it should be avoided whilst that is running.
         */
-       mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
+       snd_soc_dapm_mutex_lock(dapm);
 
        ret = snd_soc_get_volsw_range(kcontrol, ucontrol);
 
-       mutex_unlock(&card->dapm_mutex);
+       snd_soc_dapm_mutex_unlock(dapm);
 
        return ret;
 }
@@ -460,18 +457,17 @@ static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-       struct snd_soc_card *card = dapm->card;
        int ret;
 
        /*
         * PGA Volume is also used as part of the enable sequence, so
         * usage of it should be avoided whilst that is running.
         */
-       mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
+       snd_soc_dapm_mutex_lock(dapm);
 
        ret = snd_soc_put_volsw_range(kcontrol, ucontrol);
 
-       mutex_unlock(&card->dapm_mutex);
+       snd_soc_dapm_mutex_unlock(dapm);
 
        return ret;
 }
@@ -2177,10 +2173,23 @@ static int wm5110_open(struct snd_compr_stream *stream)
        return wm_adsp_compr_open(&priv->core.adsp[n_adsp], stream);
 }
 
+static irqreturn_t wm5110_adsp2_irq(int irq, void *data)
+{
+       struct wm5110_priv *florida = data;
+       int ret;
+
+       ret = wm_adsp_compr_handle_irq(&florida->core.adsp[2]);
+       if (ret == -ENODEV)
+               return IRQ_NONE;
+
+       return IRQ_HANDLED;
+}
+
 static int wm5110_codec_probe(struct snd_soc_codec *codec)
 {
        struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
        struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
+       struct arizona *arizona = priv->core.arizona;
        int i, ret;
 
        priv->core.arizona->dapm = dapm;
@@ -2189,6 +2198,14 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec)
        arizona_init_gpio(codec);
        arizona_init_mono(codec);
 
+       ret = arizona_request_irq(arizona, ARIZONA_IRQ_DSP_IRQ1,
+                                 "ADSP2 Compressed IRQ", wm5110_adsp2_irq,
+                                 priv);
+       if (ret != 0) {
+               dev_err(codec->dev, "Failed to request DSP IRQ: %d\n", ret);
+               return ret;
+       }
+
        for (i = 0; i < WM5110_NUM_ADSP; ++i) {
                ret = wm_adsp2_codec_probe(&priv->core.adsp[i], codec);
                if (ret)
@@ -2209,12 +2226,15 @@ err_adsp2_codec_probe:
        for (--i; i >= 0; --i)
                wm_adsp2_codec_remove(&priv->core.adsp[i], codec);
 
+       arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, priv);
+
        return ret;
 }
 
 static int wm5110_codec_remove(struct snd_soc_codec *codec)
 {
        struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
+       struct arizona *arizona = priv->core.arizona;
        int i;
 
        for (i = 0; i < WM5110_NUM_ADSP; ++i)
@@ -2222,6 +2242,8 @@ static int wm5110_codec_remove(struct snd_soc_codec *codec)
 
        priv->core.arizona->dapm = NULL;
 
+       arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, priv);
+
        return 0;
 }
 
@@ -2273,6 +2295,8 @@ static struct snd_compr_ops wm5110_compr_ops = {
        .set_params = wm_adsp_compr_set_params,
        .get_caps = wm_adsp_compr_get_caps,
        .trigger = wm_adsp_compr_trigger,
+       .pointer = wm_adsp_compr_pointer,
+       .copy = wm_adsp_compr_copy,
 };
 
 static struct snd_soc_platform_driver wm5110_compr_platform = {
@@ -2358,6 +2382,7 @@ error:
 
 static int wm5110_remove(struct platform_device *pdev)
 {
+       snd_soc_unregister_platform(&pdev->dev);
        snd_soc_unregister_codec(&pdev->dev);
        pm_runtime_disable(&pdev->dev);