From 281bd20437e6c5da04fa972b3a57503010e3e82b Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Mon, 1 Apr 2019 18:12:06 +0800 Subject: [PATCH] asoc: wcd938x: stop mbhc during ssr down Stop mbhc operations during ssr down to cancel any pending detection sequences. Change-Id: Iff054cf8b3099959a1be561bd937057258f57b81 Signed-off-by: Meng Wang --- asoc/codecs/wcd938x/wcd938x-mbhc.c | 28 ++++++++++++++++++++++++++-- asoc/codecs/wcd938x/wcd938x-mbhc.h | 8 +++++++- asoc/codecs/wcd938x/wcd938x.c | 2 ++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/asoc/codecs/wcd938x/wcd938x-mbhc.c b/asoc/codecs/wcd938x/wcd938x-mbhc.c index 6d9f500378bf..2516943ded62 100644 --- a/asoc/codecs/wcd938x/wcd938x-mbhc.c +++ b/asoc/codecs/wcd938x/wcd938x-mbhc.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ #include #include @@ -956,6 +956,31 @@ void wcd938x_mbhc_hs_detect_exit(struct snd_soc_component *component) } EXPORT_SYMBOL(wcd938x_mbhc_hs_detect_exit); +/* + * wcd938x_mbhc_ssr_down: stop mbhc during + * wcd938x subsystem restart + * mbhc: pointer to wcd937x_mbhc structure + * component: handle to snd_soc_component * + */ +void wcd938x_mbhc_ssr_down(struct wcd938x_mbhc *mbhc, + struct snd_soc_component *component) +{ + struct wcd_mbhc *wcd_mbhc = NULL; + + if (!mbhc || !component) + return; + + wcd_mbhc = &mbhc->wcd_mbhc; + if (!wcd_mbhc) { + dev_err(component->dev, "%s: wcd_mbhc is NULL\n", __func__); + return; + } + + wcd938x_mbhc_hs_detect_exit(component); + wcd_mbhc_deinit(wcd_mbhc); +} +EXPORT_SYMBOL(wcd938x_mbhc_ssr_down); + /* * wcd938x_mbhc_post_ssr_init: initialize mbhc for * wcd938x post subsystem restart @@ -979,7 +1004,6 @@ int wcd938x_mbhc_post_ssr_init(struct wcd938x_mbhc *mbhc, return -EINVAL; } - wcd_mbhc_deinit(wcd_mbhc); ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, WCD938X_ZDET_SUPPORTED); if (ret) { diff --git a/asoc/codecs/wcd938x/wcd938x-mbhc.h b/asoc/codecs/wcd938x/wcd938x-mbhc.h index cf4c60e0ae6d..e33a92c20e00 100644 --- a/asoc/codecs/wcd938x/wcd938x-mbhc.h +++ b/asoc/codecs/wcd938x/wcd938x-mbhc.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ #ifndef __WCD938X_MBHC_H__ #define __WCD938X_MBHC_H__ @@ -20,6 +20,8 @@ extern void wcd938x_mbhc_hs_detect_exit(struct snd_soc_component *component); extern int wcd938x_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg); extern void wcd938x_mbhc_deinit(struct snd_soc_component *component); +extern void wcd938x_mbhc_ssr_down(struct wcd938x_mbhc *mbhc, + struct snd_soc_component *component); extern int wcd938x_mbhc_post_ssr_init(struct wcd938x_mbhc *mbhc, struct snd_soc_component *component); extern int wcd938x_mbhc_get_impedance(struct wcd938x_mbhc *wcd938x_mbhc, @@ -43,6 +45,10 @@ static inline int wcd938x_mbhc_hs_detect(struct snd_soc_component *component, static inline void wcd938x_mbhc_deinit(struct snd_soc_component *component) { } +static inline void wcd938x_mbhc_ssr_down(struct wcd938x_mbhc *mbhc, + struct snd_soc_component *component) +{ +} static inline int wcd938x_mbhc_post_ssr_init(struct wcd938x_mbhc *mbhc, struct snd_soc_component *component) { diff --git a/asoc/codecs/wcd938x/wcd938x.c b/asoc/codecs/wcd938x/wcd938x.c index 882feff26bf7..4e8ab32e9e17 100644 --- a/asoc/codecs/wcd938x/wcd938x.c +++ b/asoc/codecs/wcd938x/wcd938x.c @@ -1516,6 +1516,8 @@ static int wcd938x_event_notify(struct notifier_block *block, 0x80, 0x00); break; case BOLERO_WCD_EVT_SSR_DOWN: + mbhc = &wcd938x->mbhc->wcd_mbhc; + wcd938x_mbhc_ssr_down(wcd938x->mbhc, component); wcd938x_reset_low(wcd938x->dev); break; case BOLERO_WCD_EVT_SSR_UP: