Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2958a62 authored by Ramprasad Katkam's avatar Ramprasad Katkam Committed by Meng Wang
Browse files

asoc: wcd937x: stop mbhc during ssr down



Stop mbhc operations during ssr down to cancel
any pending detection sequences.

Change-Id: I6aa8c61c2cc74fc08adf57c58673acaa753ac322
Signed-off-by: default avatarRamprasad Katkam <katkam@codeaurora.org>
parent 63f48155
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
// 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 <linux/module.h>
#include <linux/init.h>
@@ -974,6 +974,31 @@ void wcd937x_mbhc_hs_detect_exit(struct snd_soc_component *component)
}
EXPORT_SYMBOL(wcd937x_mbhc_hs_detect_exit);

/*
 * wcd937x_mbhc_ssr_down: stop mbhc during
 * wcd937x subsystem restart
 * @mbhc: pointer to wcd937x_mbhc structure
 * @component: handle to snd_soc_component *
 */
void wcd937x_mbhc_ssr_down(struct wcd937x_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 == NULL) {
		dev_err(component->dev, "%s: wcd_mbhc is NULL\n", __func__);
		return;
	}

	wcd937x_mbhc_hs_detect_exit(component);
	wcd_mbhc_deinit(wcd_mbhc);
}
EXPORT_SYMBOL(wcd937x_mbhc_ssr_down);

/*
 * wcd937x_mbhc_post_ssr_init: initialize mbhc for
 * wcd937x post subsystem restart
@@ -997,8 +1022,6 @@ int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc,
		return -EINVAL;
	}

	wcd937x_mbhc_hs_detect_exit(component);
	wcd_mbhc_deinit(wcd_mbhc);
	snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH,
				0x20, 0x20);
	ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids,
+8 −2
Original line number Diff line number Diff line
/* 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 __WCD937X_MBHC_H__
#define __WCD937X_MBHC_H__
@@ -21,6 +21,8 @@ extern int wcd937x_mbhc_hs_detect(struct snd_soc_component *component,
extern void wcd937x_mbhc_deinit(struct snd_soc_component *component);
extern int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc,
				    struct snd_soc_component *component);
extern void wcd937x_mbhc_ssr_down(struct wcd937x_mbhc *mbhc,
				    struct snd_soc_component *component);
extern int wcd937x_mbhc_get_impedance(struct wcd937x_mbhc *wcd937x_mbhc,
				    uint32_t *zl, uint32_t *zr);
#else
@@ -47,7 +49,11 @@ static inline int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc,
{
	return 0;
}

static inline void wcd937x_mbhc_ssr_down(struct wcd937x_mbhc *mbhc,
					   struct snd_soc_component *component)
{
	return 0;
}
static inline int wcd937x_mbhc_get_impedance(struct wcd937x_mbhc *wcd937x_mbhc,
					   uint32_t *zl, uint32_t *zr)
{
+3 −1
Original line number Diff line number Diff line
// 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 <linux/module.h>
@@ -1422,6 +1422,8 @@ static int wcd937x_event_notify(struct notifier_block *block,
					0x80, 0x00);
		break;
	case BOLERO_WCD_EVT_SSR_DOWN:
		mbhc = &wcd937x->mbhc->wcd_mbhc;
		wcd937x_mbhc_ssr_down(wcd937x->mbhc, component);
		wcd937x_reset_low(wcd937x->dev);
		break;
	case BOLERO_WCD_EVT_SSR_UP: