ASoC: wm8994: Allow microphone identification callback to be overridden
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 3 Dec 2012 07:14:37 +0000 (16:14 +0900)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 3 Dec 2012 07:35:00 +0000 (16:35 +0900)
Allow custom accessory identification mechanisms to make use of the MICDET
support in the device.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm8994.h
sound/soc/samsung/littlemill.c

index fdef56c1320b15612958e9278612a661b01ffd5d..82411009d401dc107a12e68fb35348dee4d38009 100644 (file)
@@ -3432,8 +3432,9 @@ static void wm8958_button_det(struct snd_soc_codec *codec, u16 status)
                            wm8994->btn_mask);
 }
 
-static void wm8958_mic_id(struct snd_soc_codec *codec, u16 status)
+static void wm8958_mic_id(void *data, u16 status)
 {
+       struct snd_soc_codec *codec = data;
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        /* Either nothing present or just starting detection */
@@ -3629,7 +3630,8 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work)
  * detection algorithm.
  */
 int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
-                     wm1811_micdet_cb cb, void *cb_data)
+                     wm1811_micdet_cb det_cb, void *det_cb_data,
+                     wm1811_mic_id_cb id_cb, void *id_cb_data)
 {
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
@@ -3649,14 +3651,22 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
 
                wm8994->micdet[0].jack = jack;
 
-               if (cb) {
-                       wm8994->micd_cb = cb;
-                       wm8994->micd_cb_data = cb_data;
+               if (det_cb) {
+                       wm8994->micd_cb = det_cb;
+                       wm8994->micd_cb_data = det_cb_data;
                } else {
                        wm8994->mic_detecting = true;
                        wm8994->jack_mic = false;
                }
 
+               if (id_cb) {
+                       wm8994->mic_id_cb = id_cb;
+                       wm8994->mic_id_cb_data = id_cb_data;
+               } else {
+                       wm8994->mic_id_cb = wm8958_mic_id;
+                       wm8994->mic_id_cb_data = codec;
+               }
+
                wm8958_micd_set_rate(codec);
 
                /* Detect microphones and short circuits by default */
@@ -3768,7 +3778,7 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
        }
 
        if (wm8994->mic_detecting)
-               wm8958_mic_id(codec, reg);
+               wm8994->mic_id_cb(wm8994->mic_id_cb_data, reg);
        else
                wm8958_button_det(codec, reg);
 
index 1a6bb4ed08f8f753844d07ae2ae684ecd5a47903..46a7bdb7d2550bf053712b83c0d54ef16e971ccf 100644 (file)
@@ -40,11 +40,13 @@ enum wm8994_vmid_mode {
 };
 
 typedef void (*wm1811_micdet_cb)(void *data);
+typedef void (*wm1811_mic_id_cb)(void *data, u16 status);
 
 int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
                      int micbias);
 int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
-                     wm1811_micdet_cb cb, void *cb_data);
+                     wm1811_micdet_cb cb, void *det_cb_data,
+                     wm1811_mic_id_cb id_cb, void *id_cb_data);
 
 int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode);
 
@@ -140,6 +142,8 @@ struct wm8994_priv {
        int micdet_irq;
        wm1811_micdet_cb micd_cb;
        void *micd_cb_data;
+       wm1811_mic_id_cb mic_id_cb;
+       void *mic_id_cb_data;
 
        int revision;
 
index ee52c8a007790972a62e9a84bdf196650a27e06b..7beb6d9b57a862d1eb0089c0d1af9db2d9793df6 100644 (file)
@@ -270,7 +270,7 @@ static int littlemill_late_probe(struct snd_soc_card *card)
                return ret;
 
        /* This will check device compatibility itself */
-       wm8958_mic_detect(codec, &littlemill_headset, NULL, NULL);
+       wm8958_mic_detect(codec, &littlemill_headset, NULL, NULL, NULL, NULL);
 
        /* As will this */
        wm8994_mic_detect(codec, &littlemill_headset, 1);