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

Commit c5d8485c 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: Ic10a499b78a00d82802e37e282441f143f9165d2
Signed-off-by: default avatarVatsal Bucha <vbucha@codeaurora.org>
parent 1fcee5d3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -154,6 +154,12 @@ static int bolero_cdc_update_wcd_event(void *handle, u16 event, u32 data)
			priv->macro_params[RX_MACRO].event_handler(priv->codec,
				BOLERO_MACRO_EVT_IMPED_FALSE, 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->codec,
				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
@@ -47,7 +47,8 @@ enum {
	BOLERO_MACRO_EVT_SSR_UP,
	BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET,
	BOLERO_MACRO_EVT_CLK_RESET,
	BOLERO_MACRO_EVT_REG_WAKE_IRQ
	BOLERO_MACRO_EVT_REG_WAKE_IRQ,
	BOLERO_MACRO_EVT_BCS_CLK_OFF
};

struct macro_ops {
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ enum {
	WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
	WCD_BOLERO_EVT_IMPED_TRUE,   /* for imped true */
	WCD_BOLERO_EVT_IMPED_FALSE,  /* for imped false */
	WCD_BOLERO_EVT_BCS_CLK_OFF,
};

struct wcd_ctrl_platform_data {
+17 −2
Original line number Diff line number Diff line
@@ -161,6 +161,8 @@ struct tx_macro_priv {
			[TX_MACRO_CHILD_DEVICES_MAX];
	int child_count;
	bool bcs_enable;
	bool bcs_clk_en;
	bool hs_slow_insert_complete;
};

static bool tx_macro_get_data(struct snd_soc_codec *codec,
@@ -366,6 +368,15 @@ static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event,
	case BOLERO_MACRO_EVT_CLK_RESET:
		tx_macro_mclk_reset(tx_dev);
		break;
	case BOLERO_MACRO_EVT_BCS_CLK_OFF:
		if (tx_priv->bcs_clk_en)
			snd_soc_update_bits(codec,
				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;
}
@@ -755,8 +766,11 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
		if (tx_priv->bcs_enable) {
			snd_soc_update_bits(codec, dec_cfg_reg,
					0x01, 0x01);
			snd_soc_update_bits(codec, BOLERO_CDC_TX0_TX_PATH_SEC7,
					    0x40, 0x40);
			tx_priv->bcs_clk_en = true;
			if (tx_priv->hs_slow_insert_complete)
				snd_soc_update_bits(codec,
					BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40,
					0x40);
		}
		break;
	case SND_SOC_DAPM_PRE_PMD:
@@ -791,6 +805,7 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
					0x01, 0x00);
			snd_soc_update_bits(codec, 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
@@ -678,6 +678,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) {
@@ -821,6 +828,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