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

Commit d06525fa authored by Vatsal Bucha's avatar Vatsal Bucha Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: Fix audio distortion issue during headset record



Audio is distorted during first 3 secs on headset record
while doing device switch from dmic to headset mic.
Disable BCS before slow insertion detection and enable it
afterwards to resolve the issue.

Change-Id: Ie5bc4b5292e5f69066760cab44d78989a74f13f4
Signed-off-by: default avatarVatsal Bucha <vbucha@codeaurora.org>
parent 731807e0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -214,6 +214,12 @@ static int bolero_cdc_update_wcd_event(void *handle, u16 event, u32 data)
				priv->component,
				BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST, data);
		break;
	case WCD_BOLERO_EVT_BCS_CLK_OFF:
		if (priv->macro_params[TX_MACRO].event_handler)
			priv->macro_params[TX_MACRO].event_handler(
				priv->component,
				BOLERO_MACRO_EVT_BCS_CLK_OFF, data);
		break;
	default:
		dev_err(priv->dev, "%s: Invalid event %d trigger from wcd\n",
			__func__, event);
+2 −1
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@ enum {
	BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET,
	BOLERO_MACRO_EVT_CLK_RESET,
	BOLERO_MACRO_EVT_REG_WAKE_IRQ,
	BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST
	BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST,
	BOLERO_MACRO_EVT_BCS_CLK_OFF
};

struct macro_ops {
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ enum {
	WCD_BOLERO_EVT_IMPED_TRUE,   /* for imped true */
	WCD_BOLERO_EVT_IMPED_FALSE,  /* for imped false */
	WCD_BOLERO_EVT_RX_COMPANDER_SOFT_RST,
	WCD_BOLERO_EVT_BCS_CLK_OFF,
};

struct wcd_ctrl_platform_data {
+17 −2
Original line number Diff line number Diff line
@@ -172,6 +172,8 @@ struct tx_macro_priv {
	int tx_clk_status;
	bool bcs_enable;
	int dec_mode[NUM_DECIMATORS];
	bool bcs_clk_en;
	bool hs_slow_insert_complete;
};

static bool tx_macro_get_data(struct snd_soc_component *component,
@@ -387,6 +389,15 @@ static int tx_macro_event_handler(struct snd_soc_component *component,
	case BOLERO_MACRO_EVT_CLK_RESET:
		bolero_rsc_clk_reset(tx_dev, TX_CORE_CLK);
		break;
	case BOLERO_MACRO_EVT_BCS_CLK_OFF:
		if (tx_priv->bcs_clk_en)
			snd_soc_component_update_bits(component,
				BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, data << 6);
		if (data)
			tx_priv->hs_slow_insert_complete = true;
		else
			tx_priv->hs_slow_insert_complete = false;
		break;
	}
	return 0;
}
@@ -902,8 +913,11 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
		if (tx_priv->bcs_enable) {
			snd_soc_component_update_bits(component, dec_cfg_reg,
					0x01, 0x01);
			tx_priv->bcs_clk_en = true;
			if (tx_priv->hs_slow_insert_complete)
				snd_soc_component_update_bits(component,
				BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, 0x40);
					BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40,
					0x40);
		}
		break;
	case SND_SOC_DAPM_PRE_PMD:
@@ -946,6 +960,7 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
					0x01, 0x00);
			snd_soc_component_update_bits(component,
				BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, 0x00);
			tx_priv->bcs_clk_en = false;
		}
		break;
	}
+11 −0
Original line number Diff line number Diff line
@@ -689,6 +689,13 @@ static void wcd_correct_swch_plug(struct work_struct *work)
	}

correct_plug_type:
	/*
	 * Callback to disable BCS slow insertion detection
	 */
	if (plug_type == MBHC_PLUG_TYPE_HEADSET ||
	    plug_type == MBHC_PLUG_TYPE_HEADPHONE)
		mbhc->mbhc_cb->bcs_enable(mbhc, false);

	timeout = jiffies + msecs_to_jiffies(HS_DETECT_PLUG_TIME_MS);
	while (!time_after(jiffies, timeout)) {
		if (mbhc->hs_detect_work_stop) {
@@ -833,6 +840,10 @@ static void wcd_correct_swch_plug(struct work_struct *work)
			wrk_complete = false;
		}
	}
	if ((plug_type == MBHC_PLUG_TYPE_HEADSET ||
	    plug_type == MBHC_PLUG_TYPE_HEADPHONE))
		mbhc->mbhc_cb->bcs_enable(mbhc, true);

	if (!wrk_complete) {
		/*
		 * If plug_tye is headset, we might have already reported either
Loading