ASoC: msm: qdsp6v2: Fix for invalid mem handle after ADSP SSR

Setup a voice call and end the call. Trigger ADSP SSR, then make another
voice call. The memory handle got from the first call is provided to CVD
for calibration data for the second call. The memory handle is not valid
after ADSP restarts.
To fix the issue, after ADSP SSR is triggered, set calibration memory
handle to zero. When starting a new call, send VSS_IMEMORY_CMD_MAP_PHYSICAL
to cvd to get a new memory handle. Use the new memory handle to register
calibration.

Change-Id: Ie89e16c8e64e1acc1c324d25bead93945d3282d4
CRs-fixed: 504113
Signed-off-by: Helen Zeng <xiaoyunz@codeaurora.org>
(cherry picked from commit b26b3db01240ed4bea0f294cadfe7d1c27a59cb9)

Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
ASoC: msm: qdsp6v2: Fix voice rx/tx mute after SSR

If SSR happens during device switch while voice call is in progress
then end voice call is not handled properly. Because of this
when next call comes start voice command is ignored and voice call
does not start. Update voc states appropriately to fix this issue.

CRs-Fixed: 509508
Change-Id: Icd55b7b39a1588df97fcd631498f32197c1c7a19
Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
(cherry picked from commit 8eef316076596c0706426bc4d062d7d6e77e1357)

Conflicts:

	sound/soc/msm/qdsp6v2/q6voice.c

Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
ASoC: msm: qdsp6v2: fix the crash issues due to NULL pointer

If adsp subsystem restart happens, ac and apr handles are not valid
any more. While recovering subsystem restart and reassign proper
handles protection from accessing NULL pointer is required.

Change-Id: I5e54671bb9d5d4222e7598fd4daffb05b4786d38
Signed-off-by: Fred Oh <fred@codeaurora.org>
(cherry picked from commit 68dd3179f2fa1c12d5c632a68ec9c0862578cae3)

Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
ASoC: wcd9320: Allow micbias 2 sharing

Currently wcd9320 driver assumes micbias 2 is dedicated to headset and ANC
microphones on headset.  Allow different microphones share the micbias 2 to
support hardware that have shared micbias configuration.

If micbias 2 is shared by mic biases other than headset mic, MBHC's ext
cable feature will be compromized and also headset removal can make more
pop noise.  If hardware has dedicated micbias 2 for headset, it's
recommanded to disable this feature.

Change-Id: I5d5e5c2feb406212dad6d211f49de49e64e1a888
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
arm/dt: msm8974: Configure whether micbias 2 is dedicated to headset

Configure micbias 2 sharing information through device tree so codec driver
can utilize this information for MBHC functionality.

The micbias 2 of msm8974 Liquid is shared by DMIC and headset mic.

CRs-Fixed: 470298
Change-Id: I642697e3a57f7be4cd5e707900e9680c98b821ef
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
ASoC: wcd9xxx: maintain micbias for headsets have threshold on mic

There are headsets that require to maintain  micbias while it's plugged
since mic of headsets have threshold to turn on mic.
Maintain micbias when this type of headset is detected in order to detect
headset button press.

CRs-fixed: 471512
Change-Id: If3caab97fe5187c91753756482ba425a3ba14118
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
ASoC: wcd9xxx: Reset Tapan codec post adsp subsystem restart

Exercise codec reset as part of ADSP subsystem restart handling
and also update codec and ASoC cache registers to defaults. This
is required to clean up codec state post ADSP restart.

CRs-Fixed: 485962
Change-Id: If1574372adaeda5d3a4a015ee580dfba5b161a52
Signed-off-by: Ravishankar Sarawadi <crsaraw@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
ASoC: wcd9xxx: use separate mutex for bandgap and clock get/put

Current bandgap and clock get/put uses the big codec lock which is widely
used by entire resource manager.  Embrace bandgap and clock resource
manager api with big codec lock can lead deadlock on certain device
switch case.  Introduce separate mutex only for bandgap and clock resource
manager api to be able to avoid mutex deadlock.

CRs-fixed: 501236
Change-Id: Ia9ee12d767c86ed3db2223f1a4721834b7d6768d
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
ASoC: wcd9xxx: don't acquire BCL from codec driver

Codec driver shouldn't acquire BCL lock especially from DAPM widget.
Otherwise mutex deadlock can happen in below scenario.
--
thread0                         | thread1
                                | *lock BCL
                                | power up DAPM widget B
                                |         snd_soc_dapm_sync()
DAPM widget A starts sync       |
*lock BCL                       |
--

Fix codec driver to hold codec->mutex instead of BCL and prevent possible
mutex deadlock.

CRs-fixed: 502427
Change-Id: Ibc4a70eba4824a384874244f36831e2d98c85d4b
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
ASoC: wcd9xxx: don't change clock frequency while bandgap/clock are on

After subsystem restart, codec drivers enable bandgap and clock if those
were enabled before subsystem restart to restore previous state.
The bandgap and clock enablement is followed by codec re-initialization
which includes master clock frequency change.
When master clock frequency changes while bandgap/clock are on, there is
chance to make hardware goes into bad state which results in audio mute
issue.

Change bandgap and clock enable sequence to guarantee that those are
enabled after master clock frequency changes completed.

CRs-fixed: 513412
Change-Id: I9bcd1ed55ec0bd7fe790caf0dd01bbe8b4c4c52c
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: Sunil Joseph <jsunil@codeaurora.org>
Merge "ASoC: msm: qdsp6v2: Fix for invalid mem handle after ADSP SSR"
Merge "ASoC: msm: qdsp6v2: Fix voice rx/tx mute after SSR"
Merge "ASoC: msm: qdsp6v2: fix the crash issues due to NULL pointer"
Merge "ASoC: wcd9320: Allow micbias 2 sharing"
Merge "arm/dt: msm8974: Configure whether micbias 2 is dedicated to headset"
Merge "ASoC: wcd9xxx: maintain micbias for headsets have threshold on mic"
Merge "ASoC: wcd9xxx: Reset Tapan codec post adsp subsystem restart"
Merge "ASoC: wcd9xxx: use separate mutex for bandgap and clock get/put"
Merge "ASoC: wcd9xxx: don't acquire BCL from codec driver"
Merge "ASoC: wcd9xxx: don't change clock frequency while bandgap/clock are on"