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

Commit fda16d2b authored by Soumya Managoli's avatar Soumya Managoli
Browse files

ASoC: wcd937x: Add flag to decide RX_MUTE for HPHL and EAR



Check if HPHL or EAR is enabled before sending RX_MUTE event.

Change-Id: I4ffc42a0d79c8edea77745a2f52361a4cf3dddaa
Signed-off-by: default avatarSoumya Managoli <quic_c_smanag@quicinc.com>
parent 928fe636
Loading
Loading
Loading
Loading
+35 −13
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#include <linux/module.h>
@@ -49,6 +50,8 @@ enum {
	HPH_COMP_DELAY,
	HPH_PA_DELAY,
	AMIC2_BCS_ENABLE,
        WCD_HPHL_EN,
        WCD_EAR_EN,
};

static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
@@ -834,6 +837,7 @@ static int wcd937x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
		set_bit(HPH_PA_DELAY, &wcd937x->status_mask);
		snd_soc_component_update_bits(component,
				WCD937X_DIGITAL_PDM_WD_CTL0, 0x17, 0x13);
		set_bit(WCD_HPHL_EN, &wcd937x->status_mask);
		break;
	case SND_SOC_DAPM_POST_PMU:
		/*
@@ -864,12 +868,14 @@ static int wcd937x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
				WCD937X_IRQ_HPHL_PDM_WD_INT);
		break;
	case SND_SOC_DAPM_PRE_PMD:
		if (!test_bit(WCD_EAR_EN, &wcd937x->status_mask)) {
			wcd_disable_irq(&wcd937x->irq_info,
				WCD937X_IRQ_HPHL_PDM_WD_INT);
		if (wcd937x->update_wcd_event)
			wcd937x->update_wcd_event(wcd937x->handle,
						WCD_BOLERO_EVT_RX_MUTE,
						(WCD_RX1 << 0x10 | 0x1));
		}
		blocking_notifier_call_chain(&wcd937x->mbhc->notifier,
					     WCD_EVENT_PRE_HPHL_PA_OFF,
					     &wcd937x->mbhc->wcd_mbhc);
@@ -900,6 +906,7 @@ static int wcd937x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
			     WCD_CLSH_EVENT_POST_PA,
			     WCD_CLSH_STATE_HPHL,
			     hph_mode);
		clear_bit(WCD_HPHL_EN, &wcd937x->status_mask);
		break;
	};
	return ret;
@@ -988,10 +995,12 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
			snd_soc_component_update_bits(component,
					WCD937X_DIGITAL_PDM_WD_CTL2,
					0x05, 0x05);
		else
		else {
			snd_soc_component_update_bits(component,
					WCD937X_DIGITAL_PDM_WD_CTL0,
					0x17, 0x13);
			set_bit(WCD_EAR_EN, &wcd937x->status_mask);
		}
		if (!wcd937x->comp1_enable)
			snd_soc_component_update_bits(component,
				WCD937X_ANA_EAR_COMPANDER_CTL, 0x80, 0x80);
@@ -1014,16 +1023,24 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
					WCD937X_IRQ_HPHL_PDM_WD_INT);
		break;
	case SND_SOC_DAPM_PRE_PMD:
		if (wcd937x->ear_rx_path & EAR_RX_PATH_AUX)
		if (wcd937x->ear_rx_path & EAR_RX_PATH_AUX) {
			wcd_disable_irq(&wcd937x->irq_info,
					WCD937X_IRQ_AUX_PDM_WD_INT);
		else
			if (wcd937x->update_wcd_event)
				wcd937x->update_wcd_event(wcd937x->handle,
					WCD_BOLERO_EVT_RX_MUTE,
					(WCD_RX1 << 0x10 | 0x1));
		}
		else {
			if(!test_bit(WCD_HPHL_EN, &wcd937x->status_mask)) {
				wcd_disable_irq(&wcd937x->irq_info,
					WCD937X_IRQ_HPHL_PDM_WD_INT);
				if (wcd937x->update_wcd_event)
					wcd937x->update_wcd_event(wcd937x->handle,
						WCD_BOLERO_EVT_RX_MUTE,
						(WCD_RX1 << 0x10 | 0x1));
			}
		}
		break;
	case SND_SOC_DAPM_POST_PMD:
		if (!wcd937x->comp1_enable)
@@ -1040,10 +1057,12 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
			snd_soc_component_update_bits(component,
					WCD937X_DIGITAL_PDM_WD_CTL2,
					0x05, 0x00);
		else
		else {
			snd_soc_component_update_bits(component,
					WCD937X_DIGITAL_PDM_WD_CTL0,
					0x17, 0x00);
			clear_bit(WCD_EAR_EN, &wcd937x->status_mask);
		}
		usleep_range(10000, 10010);
		/* disable EAR CnP FSM */
		snd_soc_component_update_bits(component,
@@ -1109,6 +1128,8 @@ static int wcd937x_enable_rx1(struct snd_soc_dapm_widget *w,
			wcd937x_rx_connect_port(component, COMP_L, true);
		break;
	case SND_SOC_DAPM_POST_PMD:
		if (!test_bit(WCD_HPHL_EN, &wcd937x->status_mask) &&
			!test_bit(WCD_EAR_EN, &wcd937x->status_mask)) {
			wcd937x_rx_connect_port(component, HPH_L, false);
			if (wcd937x->comp1_enable)
				wcd937x_rx_connect_port(component, COMP_L, false);
@@ -1116,6 +1137,7 @@ static int wcd937x_enable_rx1(struct snd_soc_dapm_widget *w,
			snd_soc_component_update_bits(component,
				WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
				0x01, 0x00);
		}
		break;
	};
	return 0;