Merge "asoc: codecs: bolero: Reduce hpf corner freq delay to 50ms"
diff --git a/asoc/codecs/bolero/bolero-cdc.c b/asoc/codecs/bolero/bolero-cdc.c
index 7bf6295..217fa5f 100644
--- a/asoc/codecs/bolero/bolero-cdc.c
+++ b/asoc/codecs/bolero/bolero-cdc.c
@@ -1049,13 +1049,11 @@
 {
 	struct bolero_priv *priv = dev_get_drvdata(dev->parent);
 
-	mutex_lock(&priv->clk_lock);
 	if (priv->lpass_core_hw_vote != NULL)
 		clk_disable_unprepare(priv->lpass_core_hw_vote);
 	else
 		dev_dbg(dev, "%s: Invalid lpass core hw node\n",
 			__func__);
-	mutex_unlock(&priv->clk_lock);
 	return 0;
 }
 EXPORT_SYMBOL(bolero_runtime_suspend);
diff --git a/asoc/codecs/bolero/va-macro.c b/asoc/codecs/bolero/va-macro.c
index 61bfa9a..8789fce 100644
--- a/asoc/codecs/bolero/va-macro.c
+++ b/asoc/codecs/bolero/va-macro.c
@@ -1632,7 +1632,7 @@
 	}
 
 	va_io_base = devm_ioremap(&pdev->dev, va_base_addr,
-				  VA_MAX_OFFSET);
+				  VA_MACRO_MAX_OFFSET);
 	if (!va_io_base) {
 		dev_err(&pdev->dev, "%s: ioremap failed\n", __func__);
 		return -EINVAL;
diff --git a/asoc/codecs/wcd-clsh.c b/asoc/codecs/wcd-clsh.c
index fd30148..0f403ac 100644
--- a/asoc/codecs/wcd-clsh.c
+++ b/asoc/codecs/wcd-clsh.c
@@ -219,6 +219,9 @@
 	if ((enable && (++clsh_d->flyback_users == 1)) ||
 	   (!enable && (--clsh_d->flyback_users == 0))) {
 		snd_soc_component_update_bits(component,
+				WCD9XXX_FLYBACK_VNEG_CTRL_1,
+				0xE0, 0xE0);
+		snd_soc_component_update_bits(component,
 				WCD9XXX_ANA_RX_SUPPLIES,
 				(1 << 6), (enable << 6));
 		/*
diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c
index beb4b17..0836bc0 100644
--- a/asoc/codecs/wcd937x/wcd937x.c
+++ b/asoc/codecs/wcd937x/wcd937x.c
@@ -567,6 +567,8 @@
 				WCD937X_DIGITAL_CDC_COMP_CTL_0,
 				0x02, 0x02);
 		usleep_range(5000, 5010);
+		snd_soc_component_update_bits(component, WCD937X_FLYBACK_EN,
+				0x04, 0x00);
 		wcd_cls_h_fsm(component, &wcd937x->clsh_info,
 			     WCD_CLSH_EVENT_PRE_DAC,
 			     WCD_CLSH_STATE_EAR,
@@ -942,6 +944,8 @@
 			     WCD_CLSH_EVENT_POST_PA,
 			     WCD_CLSH_STATE_EAR,
 			     hph_mode);
+		snd_soc_component_update_bits(component, WCD937X_FLYBACK_EN,
+				0x04, 0x04);
 		if (wcd937x->ear_rx_path & EAR_RX_PATH_AUX)
 			snd_soc_component_update_bits(component,
 					WCD937X_DIGITAL_PDM_WD_CTL2,
diff --git a/asoc/codecs/wcd938x/wcd938x.c b/asoc/codecs/wcd938x/wcd938x.c
index 8a5622f..882feff 100644
--- a/asoc/codecs/wcd938x/wcd938x.c
+++ b/asoc/codecs/wcd938x/wcd938x.c
@@ -532,6 +532,8 @@
 				WCD938X_DIGITAL_CDC_COMP_CTL_0, 0x02, 0x02);
 		/* 5 msec delay as per HW requirement */
 		usleep_range(5000, 5010);
+		snd_soc_component_update_bits(component, WCD938X_FLYBACK_EN,
+				0x04, 0x00);
 		wcd_cls_h_fsm(component, &wcd938x->clsh_info,
 			     WCD_CLSH_EVENT_PRE_DAC,
 			     WCD_CLSH_STATE_EAR,
@@ -824,6 +826,8 @@
 			     WCD_CLSH_EVENT_POST_PA,
 			     WCD_CLSH_STATE_EAR,
 			     hph_mode);
+		snd_soc_component_update_bits(component, WCD938X_FLYBACK_EN,
+				0x04, 0x04);
 		break;
 	};
 	return ret;
diff --git a/asoc/kona.c b/asoc/kona.c
index fd5c9a7..704951c 100644
--- a/asoc/kona.c
+++ b/asoc/kona.c
@@ -2297,7 +2297,7 @@
 {
 	int ch_num = cdc_dma_get_port_idx(kcontrol);
 
-	if (ch_num < 0) {
+	if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
 		pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
 		return ch_num;
 	}
@@ -2313,7 +2313,7 @@
 {
 	int ch_num = cdc_dma_get_port_idx(kcontrol);
 
-	if (ch_num < 0) {
+	if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
 		pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
 		return ch_num;
 	}
@@ -2330,7 +2330,7 @@
 {
 	int ch_num = cdc_dma_get_port_idx(kcontrol);
 
-	if (ch_num < 0) {
+	if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
 		pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
 		return ch_num;
 	}
@@ -2363,7 +2363,7 @@
 	int rc = 0;
 	int ch_num = cdc_dma_get_port_idx(kcontrol);
 
-	if (ch_num < 0) {
+	if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
 		pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
 		return ch_num;
 	}
@@ -2498,7 +2498,7 @@
 {
 	int ch_num = cdc_dma_get_port_idx(kcontrol);
 
-	if (ch_num < 0) {
+	if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
 		pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
 		return ch_num;
 	}
@@ -2516,7 +2516,7 @@
 {
 	int ch_num = cdc_dma_get_port_idx(kcontrol);
 
-	if (ch_num < 0) {
+	if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
 		pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
 		return ch_num;
 	}
diff --git a/asoc/msm-compress-q6-v2.c b/asoc/msm-compress-q6-v2.c
index c48e2c2..179a95e 100644
--- a/asoc/msm-compress-q6-v2.c
+++ b/asoc/msm-compress-q6-v2.c
@@ -363,12 +363,17 @@
 	}
 	rtd = cstream->private_data;
 	prtd = cstream->runtime->private_data;
-	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
 
-	if (!rtd || !component || !prtd || !prtd->audio_client) {
+	if (!rtd || !prtd || !prtd->audio_client) {
 		pr_err("%s: invalid rtd, prtd or audio client", __func__);
 		return rc;
 	}
+	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
+	if (!component) {
+		pr_err("%s: invalid component\n", __func__);
+		return rc;
+	}
+
 	pdata = snd_soc_component_get_drvdata(component);
 
 	if (prtd->compr_passthr != LEGACY_PCM) {
@@ -1810,12 +1815,16 @@
 	}
 	runtime = cstream->runtime;
 	soc_prtd = cstream->private_data;
-	component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
-	if (!runtime || !soc_prtd || !component) {
-		pr_err("%s runtime or soc_prtd or component is null\n",
+	if (!runtime || !soc_prtd) {
+		pr_err("%s runtime or soc_prtd is null\n",
 			__func__);
 		return 0;
 	}
+	component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
+	if (!component) {
+		pr_err("%s component is null\n", __func__);
+		return 0;
+	}
 	prtd = runtime->private_data;
 	if (!prtd) {
 		pr_err("%s prtd is null\n", __func__);
@@ -1913,12 +1922,16 @@
 	}
 	runtime = cstream->runtime;
 	soc_prtd = cstream->private_data;
-	component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
-	if (!runtime || !soc_prtd || !component) {
-		pr_err("%s runtime or soc_prtd or component is null\n",
-			__func__);
+	if (!runtime || !soc_prtd) {
+		pr_err("%s runtime or soc_prtd is null\n", __func__);
 		return 0;
 	}
+	component = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
+	if (!component) {
+		pr_err("%s component is null\n", __func__);
+		return 0;
+	}
+
 	prtd = runtime->private_data;
 	if (!prtd) {
 		pr_err("%s prtd is null\n", __func__);
diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c
index 71dbd0c..a087dd8 100644
--- a/asoc/msm-pcm-q6-v2.c
+++ b/asoc/msm-pcm-q6-v2.c
@@ -1604,7 +1604,7 @@
 	struct snd_soc_pcm_runtime *rtd = NULL;
 	struct msm_plat_data *pdata = NULL;
 	struct msm_pcm_channel_mixer *chmixer_pspd = NULL;
-	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_component *component = NULL;
 	u64 fe_id = 0;
 
 	pr_debug("%s", __func__);
@@ -1624,18 +1624,21 @@
 		/* update chmixer_pspd chmap cached with routing driver as well */
 		rtd = substream->private_data;
 		if (rtd) {
-			fe_id = rtd->dai_link->id;
-			pdata = (struct msm_plat_data *)
-					dev_get_drvdata(component->dev);
-			chmixer_pspd = pdata ?
-				pdata->chmixer_pspd[fe_id][SESSION_TYPE_RX] : NULL;
+			component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
+			if (component) {
+				fe_id = rtd->dai_link->id;
+				pdata = (struct msm_plat_data *)
+						dev_get_drvdata(component->dev);
+				chmixer_pspd = pdata ?
+					pdata->chmixer_pspd[fe_id][SESSION_TYPE_RX] : NULL;
 
-			if (chmixer_pspd && chmixer_pspd->enable) {
-				for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
-					chmixer_pspd->in_ch_map[i] = prtd->channel_map[i];
-				chmixer_pspd->override_in_ch_map = true;
-				msm_pcm_routing_set_channel_mixer_cfg(fe_id,
-						SESSION_TYPE_RX, chmixer_pspd);
+				if (chmixer_pspd && chmixer_pspd->enable) {
+					for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
+						chmixer_pspd->in_ch_map[i] = prtd->channel_map[i];
+					chmixer_pspd->override_in_ch_map = true;
+					msm_pcm_routing_set_channel_mixer_cfg(fe_id,
+							SESSION_TYPE_RX, chmixer_pspd);
+				}
 			}
 		}
 	}
diff --git a/asoc/msm-transcode-loopback-q6-v2.c b/asoc/msm-transcode-loopback-q6-v2.c
index 9980874..67bdc75 100644
--- a/asoc/msm-transcode-loopback-q6-v2.c
+++ b/asoc/msm-transcode-loopback-q6-v2.c
@@ -435,7 +435,15 @@
 	mutex_lock(&trans->lock);
 
 	rtd = snd_pcm_substream_chip(cstream);
+	if (!rtd) {
+		pr_err("%s: rtd is NULL\n", __func__);
+		return -EINVAL;
+	}
 	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
+	if (!component) {
+		pr_err("%s: component is NULL\n", __func__);
+		return -EINVAL;
+	}
 	pdata = snd_soc_component_get_drvdata(component);
 
 	if (cstream->direction == SND_COMPRESS_PLAYBACK) {
@@ -606,7 +614,15 @@
 	}
 
 	rtd = snd_pcm_substream_chip(cstream);
+	if (!rtd) {
+		pr_err("%s: rtd is NULL\n", __func__);
+		return -EINVAL;
+	}
 	component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
+	if (!component) {
+		pr_err("%s: component is NULL\n", __func__);
+		return -EINVAL;
+	}
 	pdata = snd_soc_component_get_drvdata(component);
 
 	prtd = cstream->runtime->private_data;
diff --git a/dsp/q6afe.c b/dsp/q6afe.c
index 3d5f5e8..fd66571 100644
--- a/dsp/q6afe.c
+++ b/dsp/q6afe.c
@@ -8827,6 +8827,12 @@
 		return -EINVAL;
 	}
 
+	ret = afe_q6_interface_prepare();
+	if(ret) {
+		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
+		return ret;
+	}
+
 	mutex_lock(&this_afe.afe_cmd_lock);
 
 	memset(cmd_ptr, 0, sizeof(hw_vote_cfg));
@@ -8902,6 +8908,12 @@
 						&hw_vote_cfg;
 	int ret = 0;
 
+	ret = afe_q6_interface_prepare();
+	if(ret) {
+		pr_err("%s: Q6 interface prepare failed %d\n", __func__, ret);
+		return ret;
+	}
+
 	mutex_lock(&this_afe.afe_cmd_lock);
 
 	memset(cmd_ptr, 0, sizeof(hw_vote_cfg));
diff --git a/include/asoc/wcd9xxx_registers.h b/include/asoc/wcd9xxx_registers.h
index cf3c408..731b72f 100644
--- a/include/asoc/wcd9xxx_registers.h
+++ b/include/asoc/wcd9xxx_registers.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 _WCD9XXX_REGISTERS_H
@@ -12,6 +12,7 @@
 #define WCD9XXX_ANA_HPH                             (WCD9XXX_BASE_ADDRESS+0x009)
 #define WCD9XXX_CLASSH_MODE_2                       (WCD9XXX_BASE_ADDRESS+0x098)
 #define WCD9XXX_CLASSH_MODE_3                       (WCD9XXX_BASE_ADDRESS+0x099)
+#define WCD9XXX_FLYBACK_VNEG_CTRL_1                 (WCD9XXX_BASE_ADDRESS+0x0A5)
 #define WCD9XXX_FLYBACK_VNEG_CTRL_4                 (WCD9XXX_BASE_ADDRESS+0x0A8)
 #define WCD9XXX_FLYBACK_VNEGDAC_CTRL_2              (WCD9XXX_BASE_ADDRESS+0x0AF)
 #define WCD9XXX_RX_BIAS_HPH_LOWPOWER                (WCD9XXX_BASE_ADDRESS+0x0BF)
diff --git a/ipc/apr.c b/ipc/apr.c
index 2e6d75f..fbb1f32 100644
--- a/ipc/apr.c
+++ b/ipc/apr.c
@@ -364,7 +364,8 @@
 	unsigned long flags;
 
 	if (!handle || !buf) {
-		pr_err("APR: Wrong parameters\n");
+		pr_err("APR: Wrong parameters for %s\n",
+				!handle ? "handle" : "buf");
 		return -EINVAL;
 	}
 	if (svc->need_reset) {