OSDN Git Service

btfm: provide a way to query wcn3990 status
authorSatish Kodishala <skodisha@codeaurora.org>
Thu, 18 May 2017 13:49:30 +0000 (19:19 +0530)
committerGerrit - the friendly Code Review server <code-review@localhost>
Wed, 21 Jun 2017 05:48:27 +0000 (22:48 -0700)
provide a way to query wcn3990 status. Audio hal
uses this to cleanup its stack when BT is turned off
or SCO is disconnected during SCO devices selection.

CRs-Fixed: 2061191
Change-Id: I3c10559c6ca34692c7f147b5cc2f0101b0bfbbf9
Signed-off-by: Satish Kodishala <skodisha@codeaurora.org>
drivers/bluetooth/btfm_slim_codec.c

index 1faebb1..96be0e2 100644 (file)
@@ -26,6 +26,9 @@
 #include <sound/tlv.h>
 #include <btfm_slim.h>
 
+static int bt_soc_enable_status;
+
+
 static int btfm_slim_codec_write(struct snd_soc_codec *codec, unsigned int reg,
        unsigned int value)
 {
@@ -38,8 +41,31 @@ static unsigned int btfm_slim_codec_read(struct snd_soc_codec *codec,
        return 0;
 }
 
+static int bt_soc_status_get(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       ucontrol->value.integer.value[0] = bt_soc_enable_status;
+       return 1;
+}
+
+static int bt_soc_status_put(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       return 1;
+}
+
+static const struct snd_kcontrol_new status_controls[] = {
+       SOC_SINGLE_EXT("BT SOC status", 0, 0, 1, 0,
+                       bt_soc_status_get,
+                       bt_soc_status_put)
+
+};
+
+
 static int btfm_slim_codec_probe(struct snd_soc_codec *codec)
 {
+       snd_soc_add_codec_controls(codec, status_controls,
+                                  ARRAY_SIZE(status_controls));
        return 0;
 }
 
@@ -130,6 +156,7 @@ int btfm_slim_dai_prepare(struct snd_pcm_substream *substream,
        struct btfmslim *btfmslim = dai->dev->platform_data;
        struct btfmslim_ch *ch;
        uint8_t rxport, grp = false, nchan = 1;
+       bt_soc_enable_status = 0;
 
        BTFMSLIM_DBG("dai->name: %s, dai->id: %d, dai->rate: %d", dai->name,
                dai->id, dai->rate);
@@ -171,6 +198,10 @@ int btfm_slim_dai_prepare(struct snd_pcm_substream *substream,
        }
 
        ret = btfm_slim_enable_ch(btfmslim, ch, rxport, dai->rate, grp, nchan);
+
+       /* save the enable channel status */
+       if (ret == 0)
+               bt_soc_enable_status = 1;
        return ret;
 }