From b6dda1e6be0218fae70c4bcefb93da66431630c5 Mon Sep 17 00:00:00 2001 From: Ramprasad Katkam Date: Tue, 23 Oct 2018 18:25:30 +0530 Subject: [PATCH] asoc: wcd937x: use swr device wakeup api Use device wakeup api exposed by soundwire to vote and unvote for soundwire master for mbhc operations. Change-Id: Id83c8d3fb2eb351133790f69af56e4981bcac543 Signed-off-by: Ramprasad Katkam --- asoc/codecs/wcd937x/internal.h | 3 +-- asoc/codecs/wcd937x/wcd937x-mbhc.c | 4 ++++ asoc/codecs/wcd937x/wcd937x.c | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/wcd937x/internal.h b/asoc/codecs/wcd937x/internal.h index 8e6928ad4c..ca401b43f2 100644 --- a/asoc/codecs/wcd937x/internal.h +++ b/asoc/codecs/wcd937x/internal.h @@ -70,7 +70,6 @@ struct wcd937x_priv { struct codec_port_info rx_port_mapping[MAX_PORT][MAX_CH_PER_PORT]; struct regulator_bulk_data *supplies; - struct notifier_block nblock; /* wcd callback to bolero */ void *handle; @@ -78,7 +77,7 @@ struct wcd937x_priv { int (*register_notifier)(void *handle, struct notifier_block *nblock, bool enable); - + int (*wakeup)(void *handle, bool enable); u32 version; /* Entry for version info */ struct snd_info_entry *entry; diff --git a/asoc/codecs/wcd937x/wcd937x-mbhc.c b/asoc/codecs/wcd937x/wcd937x-mbhc.c index 7ffa11744e..0703017a0d 100644 --- a/asoc/codecs/wcd937x/wcd937x-mbhc.c +++ b/asoc/codecs/wcd937x/wcd937x-mbhc.c @@ -240,6 +240,10 @@ static void wcd937x_mbhc_program_btn_thr(struct snd_soc_component *component, static bool wcd937x_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock) { + struct snd_soc_component *component = mbhc->component; + struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev); + + wcd937x->wakeup((void*)wcd937x, lock); return true; } diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index 8810fec525..45c990e1c3 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -2426,6 +2426,25 @@ struct wcd937x_pdata *wcd937x_populate_dt_data(struct device *dev) return pdata; } +static int wcd937x_wakeup(void *handle, bool enable) +{ + struct wcd937x_priv *priv; + + if (!handle) { + pr_err("%s: NULL handle\n", __func__); + return -EINVAL; + } + priv = (struct wcd937x_priv *)handle; + if (!priv->tx_swr_dev) { + pr_err("%s: tx swr dev is NULL\n", __func__); + return -EINVAL; + } + if (enable) + return swr_device_wakeup_vote(priv->tx_swr_dev); + else + return swr_device_wakeup_unvote(priv->tx_swr_dev); +} + static int wcd937x_bind(struct device *dev) { int ret = 0, i = 0; @@ -2495,6 +2514,7 @@ static int wcd937x_bind(struct device *dev) * as per HW requirement. */ usleep_range(5000, 5010); + wcd937x->wakeup = wcd937x_wakeup; ret = component_bind_all(dev, wcd937x); if (ret) {