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

Commit 695f2ab6 authored by Laxminath Kasam's avatar Laxminath Kasam
Browse files

ASoC: msm8x16-wcd: Fix SSR mute issue on speaker



restore the cache values back of last state applied
in SSR recovery using snd_soc_cache_sync API. So
hardware codec configuration will be in sync with
userspace settings. And avoid any race condition
between the userspace updating dapm widgets and
SSR recovery updating any register value.

Change-Id: Ie2a986b5c6827b02aa3d5919cc69e7363155c45e
Signed-off-by: default avatarLaxminath Kasam <lkasam@codeaurora.org>
parent 9dc2bec8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -311,7 +311,7 @@ const u8 msm8x16_wcd_reg_readonly[MSM8X16_WCD_CACHE_SIZE] = {
		[MSM8X16_WCD_A_DIGITAL_CDC_DIG_CLK_CTL] = 1,
		/* To detect cajon codec */
		[MSM8X16_WCD_A_ANALOG_NCP_FBCTRL] = 1,

		[MSM8X16_WCD_A_ANALOG_MBHC_DET_CTL_1] = 1,
};

const u8 cajon_digital_reg[MSM8X16_WCD_CACHE_SIZE] = {
+10 −26
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -5254,8 +5254,6 @@ static int msm8x16_wcd_device_up(struct snd_soc_codec *codec)
{
	struct msm8x16_wcd_priv *msm8x16_wcd_priv =
		snd_soc_codec_get_drvdata(codec);
	const struct snd_soc_codec_driver *codec_drv = codec->driver;
	u32 reg;
	int ret = 0;

	dev_dbg(codec->dev, "%s: device up!\n", __func__);
@@ -5264,30 +5262,7 @@ static int msm8x16_wcd_device_up(struct snd_soc_codec *codec)

	clear_bit(BUS_DOWN, &msm8x16_wcd_priv->status_mask);

	for (reg = 0; reg < ARRAY_SIZE(msm8x16_wcd_reset_reg_defaults);
			reg++) {
		if (msm8x16_wcd_reg_readable[reg]) {
			if (get_codec_version(msm8x16_wcd_priv) != CAJON &&
					cajon_digital_reg[reg])
				continue;
			msm8x16_wcd_write(codec,
				reg, msm8x16_wcd_reset_reg_defaults[reg]);
		}
	}

	if (codec_drv->reg_cache_default) {
		pr_debug("%s: Update ASOC cache", __func__);
		kfree(codec->reg_cache);
		codec->reg_cache = kmemdup(codec_drv->reg_cache_default,
					   (codec_drv->reg_cache_size
					    * codec_drv->reg_word_size),
					   GFP_KERNEL);
		if (!codec->reg_cache) {
			pr_err("%s: Cache update failed!\n", __func__);
			mutex_unlock(&codec->mutex);
			return -ENOMEM;
		}
	}

	snd_soc_card_change_online_state(codec->component.card, 1);
	/* delay is required to make sure sound card state updated */
@@ -5296,6 +5271,15 @@ static int msm8x16_wcd_device_up(struct snd_soc_codec *codec)
	msm8x16_wcd_codec_init_reg(codec);
	msm8x16_wcd_update_reg_defaults(codec);

	codec->cache_sync = true;
	snd_soc_cache_sync(codec);
	codec->cache_sync = false;

	msm8x16_wcd_write(codec, MSM8X16_WCD_A_DIGITAL_INT_EN_SET,
				MSM8X16_WCD_A_DIGITAL_INT_EN_SET__POR);
	msm8x16_wcd_write(codec, MSM8X16_WCD_A_DIGITAL_INT_EN_CLR,
				MSM8X16_WCD_A_DIGITAL_INT_EN_CLR__POR);

	msm8x16_wcd_set_boost_v(codec);

	msm8x16_wcd_set_micb_v(codec);