ASoC: Factor out analogue platform data from WM8993
Mark Brown [Wed, 30 Sep 2009 13:16:11 +0000 (14:16 +0100)]
This is also shared with newer CODECs.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

sound/soc/codecs/wm8993.c
sound/soc/codecs/wm_hubs.c
sound/soc/codecs/wm_hubs.h

index 6b32a28..dac3977 100644 (file)
@@ -1572,33 +1572,15 @@ static int wm8993_i2c_probe(struct i2c_client *i2c,
        /* Use automatic clock configuration */
        snd_soc_update_bits(codec, WM8993_CLOCKING_4, WM8993_SR_MODE, 0);
 
-       if (!wm8993->pdata.lineout1_diff)
-               snd_soc_update_bits(codec, WM8993_LINE_MIXER1,
-                                   WM8993_LINEOUT1_MODE,
-                                   WM8993_LINEOUT1_MODE);
-       if (!wm8993->pdata.lineout2_diff)
-               snd_soc_update_bits(codec, WM8993_LINE_MIXER2,
-                                   WM8993_LINEOUT2_MODE,
-                                   WM8993_LINEOUT2_MODE);
-
-       if (wm8993->pdata.lineout1fb)
-               snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL,
-                                   WM8993_LINEOUT1_FB, WM8993_LINEOUT1_FB);
-
-       if (wm8993->pdata.lineout2fb)
-               snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL,
-                                   WM8993_LINEOUT2_FB, WM8993_LINEOUT2_FB);
-
-       /* Apply the microphone bias/detection configuration - the
-        * platform data is directly applicable to the register. */
-       snd_soc_update_bits(codec, WM8993_MICBIAS,
-                           WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK |
-                           WM8993_MICB1_LVL | WM8993_MICB2_LVL,
-                           wm8993->pdata.jd_scthr << WM8993_JD_SCTHR_SHIFT |
-                           wm8993->pdata.jd_thr << WM8993_JD_THR_SHIFT |
-                           wm8993->pdata.micbias1_lvl |
-                           wm8993->pdata.micbias1_lvl << 1);
-
+       wm_hubs_handle_analogue_pdata(codec, wm8993->pdata.lineout1_diff,
+                                     wm8993->pdata.lineout2_diff,
+                                     wm8993->pdata.lineout1fb,
+                                     wm8993->pdata.lineout2fb,
+                                     wm8993->pdata.jd_scthr,
+                                     wm8993->pdata.jd_thr,
+                                     wm8993->pdata.micbias1_lvl,
+                                     wm8993->pdata.micbias2_lvl);
+                            
        ret = wm8993_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
        if (ret != 0)
                goto err;
index e542027..810a563 100644 (file)
@@ -738,6 +738,41 @@ int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec,
 }
 EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes);
 
+int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec,
+                                 int lineout1_diff, int lineout2_diff,
+                                 int lineout1fb, int lineout2fb,
+                                 int jd_scthr, int jd_thr, int micbias1_lvl,
+                                 int micbias2_lvl)
+{
+       if (!lineout1_diff)
+               snd_soc_update_bits(codec, WM8993_LINE_MIXER1,
+                                   WM8993_LINEOUT1_MODE,
+                                   WM8993_LINEOUT1_MODE);
+       if (!lineout2_diff)
+               snd_soc_update_bits(codec, WM8993_LINE_MIXER2,
+                                   WM8993_LINEOUT2_MODE,
+                                   WM8993_LINEOUT2_MODE);
+
+       if (lineout1fb)
+               snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL,
+                                   WM8993_LINEOUT1_FB, WM8993_LINEOUT1_FB);
+
+       if (lineout2fb)
+               snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL,
+                                   WM8993_LINEOUT2_FB, WM8993_LINEOUT2_FB);
+
+       snd_soc_update_bits(codec, WM8993_MICBIAS,
+                           WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK |
+                           WM8993_MICB1_LVL | WM8993_MICB2_LVL,
+                           jd_scthr << WM8993_JD_SCTHR_SHIFT |
+                           jd_thr << WM8993_JD_THR_SHIFT |
+                           micbias1_lvl |
+                           micbias2_lvl << WM8993_MICB2_LVL_SHIFT);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata);
+
 MODULE_DESCRIPTION("Shared support for Wolfson hubs products");
 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
 MODULE_LICENSE("GPL");
index ec09cb6..36d3fba 100644 (file)
@@ -20,5 +20,10 @@ extern const unsigned int wm_hubs_spkmix_tlv[];
 
 extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *);
 extern int wm_hubs_add_analogue_routes(struct snd_soc_codec *, int, int);
+extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *,
+                                        int lineout1_diff, int lineout2_diff,
+                                        int lineout1fb, int lineout2fb,
+                                        int jd_scthr, int jd_thr,
+                                        int micbias1_lvl, int micbias2_lvl);
 
 #endif