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

Commit bedce767 authored by Santosh Mardi's avatar Santosh Mardi Committed by Aviral Gupta
Browse files

ASoC: msm8x16-wcd: update for new Sub System Restart design.



Update codec driver to reduce the time for wait to check Q6 core
is ready.
Disable all sound end devices(headset, earpiece and speaker)
during codec down and codec up to reduce the noise output
during Sub System Restart time frame.

CRs-Fixed: 661491
Change-Id: I06f7124dda56bf867df32c3a03a63e1ee0e2bd94
Signed-off-by: default avatarSantosh Mardi <gsantosh@codeaurora.org>
parent f9e5104e
Loading
Loading
Loading
Loading
+37 −13
Original line number Diff line number Diff line
@@ -65,6 +65,12 @@
#define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH	64
#define TOMBAK_MCLK_CLK_9P6MHZ			9600000

/*
 *50 Milliseconds sufficient for DSP bring up in the modem
 * after Sub System Restart
 */
#define ADSP_STATE_READY_TIMEOUT_MS 50

enum {
	AIF1_PB = 0,
	AIF1_CAP,
@@ -187,7 +193,6 @@ struct msm8x16_wcd_spmi msm8x16_wcd_modules[MAX_MSM8X16_WCD_DEVICE];
static void *modem_state_notifier;

static struct snd_soc_codec *registered_codec;
#define ADSP_STATE_READY_TIMEOUT_MS 2000

static int get_spmi_msm8x16_wcd_device_info(u16 *reg,
			struct msm8x16_wcd_spmi **msm8x16_wcd)
@@ -2919,6 +2924,18 @@ static struct regulator *wcd8x16_wcd_codec_find_regulator(
static int msm8x16_wcd_device_down(struct snd_soc_codec *codec)
{
	dev_dbg(codec->dev, "%s: device down!\n", __func__);
	msm8x16_wcd_write(codec,
		MSM8X16_WCD_A_ANALOG_TX_1_EN, 0x3);
	msm8x16_wcd_write(codec,
		MSM8X16_WCD_A_ANALOG_TX_2_EN, 0x3);
	msm8x16_wcd_write(codec,
		MSM8X16_WCD_A_ANALOG_RX_HPH_L_PA_DAC_CTL, 0x20);
	msm8x16_wcd_write(codec,
		MSM8X16_WCD_A_ANALOG_RX_HPH_R_PA_DAC_CTL, 0x20);
	msm8x16_wcd_write(codec,
		MSM8X16_WCD_A_ANALOG_RX_EAR_CTL, 0x12);
	msm8x16_wcd_write(codec,
		MSM8X16_WCD_A_ANALOG_SPKR_DAC_CTL, 0x93);

	msm8x16_wcd_write(codec, MSM8X16_WCD_A_DIGITAL_PERPH_RESET_CTL4, 0x1);
	msm8x16_wcd_write(codec, MSM8X16_WCD_A_ANALOG_PERPH_RESET_CTL4, 0x1);
@@ -2982,6 +2999,9 @@ static int modem_state_callback(struct notifier_block *nb, unsigned long value,
		dev_dbg(registered_codec->dev,
			"ADSP is about to power up. bring up codec\n");

		if (!q6core_is_adsp_ready()) {
			dev_dbg(registered_codec->dev,
				"ADSP isn't ready\n");
			timeout = jiffies +
				  msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
			while (!(timedout = time_after(jiffies, timeout))) {
@@ -2991,12 +3011,16 @@ static int modem_state_callback(struct notifier_block *nb, unsigned long value,
				} else {
					dev_dbg(registered_codec->dev,
						"ADSP is ready\n");
				msm8x16_wcd_device_up(registered_codec);
					break;
				}
			}
		} else {
			dev_dbg(registered_codec->dev,
				"%s: DSP is ready\n", __func__);
		}

		msm8x16_wcd_device_up(registered_codec);
	}
	return NOTIFY_OK;
}