ASoC: msm: Fix delay in switching from WFD session

- When a running WFD session is paused/disconnected, there is
  a delay of about 10-15 seconds in switching audio from WFD
  sink to target.
- pcm_write is blocked because pausing/disconnecting the WFD
  session closes the backend DAI before a new link is established.
- Avoid closing afe if front end PCM session is still active.

CRs-Fixed: 444163
CRs-Fixed: 425512
Signed-off-by: Satya Krishna Pindiproli <satyak@codeaurora.org>
(cherry picked from commit e8b8455d0679f78075176b6e451d4c948c53afbe)

Change-Id: I0e222dcd6bc3b1792315dca23863073bf2c1fe83
Signed-off-by: Vivek Panwar <vpanwa@codeaurora.org>
(cherry picked from commit d43da77f91608882754005fd350aed3d46901a29)

Conflicts:

	sound/soc/msm/qdsp6/q6afe.c

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
ASoC: WCD9304: Make sure slimbus port disconnected before opening port

During rapid open and close of slimbus ports, it may happen that when
port open is performed, the port is not disconnected from the previous
open. This will cause inconsistent state and may result in failure to
playback audio. Fix by waiting for the slimbus port disconnect to happen
before opening the port.

CRs-fixed: 375689
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
(cherry picked from commit e66e4bb668eed6f5edb57d9bd64832fb3bda190c)

Change-Id: If22fe345c9a8be6bb5c5dab12a91014ee466feae
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
(cherry picked from commit 2596fb0af663df793afc26526eac19b9881aba54)

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
ASoC: WCD9304: Vote for runtime pm off after slimbus port disconnect

If the vote for pm runtime is done while codec shutdown, it is possible
that the runtime pm vote occurs even before the slimbus port for tx/rx
audio channel is disconnected. This can cause problem in audio playback/
record. Fix by moving the vote for runtime pm after slimbus port has
been disconnected

Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
(cherry picked from commit ac580a9afffccba20021366a6e670fc34b03e282)

Change-Id: I7cf7392ba0d28033b406da4df38c48f1aeb7b47f
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
(cherry picked from commit 7fdbb8e70f35e6d1fbe3c990187fcff7b510c051)

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
ASoC: WCD9304: Pull in fixes for slimbus connect/disconnect

Pull in all the recent codec driver changes for connect / disconnect
slimbus ports.

CRs-fixed: 398686
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
(cherry picked from commit c131e9fd7f091b931977bb5280c9071aabb3a3fd)

Change-Id: Iff0835c4ee5c6b30061904bd7e3d1dab5215845f
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
(cherry picked from commit dc32e0dc741187c0934c9e4360ab6f9fff42fba3)

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
ASoC: wcd9304: reconfig LDO_H_MODE_1 to the ldoh from board file.

The LDO_H_MODE_1 is reset bandgap off mode. This needs to be reconfigured
for audio mode.

CRs-Fixed: 378182
Change-Id: I7c335f26842ed0f3a29b9319dc866f33a3d032b5
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
(cherry picked from commit 63032b49f45f61660a46acd61bbf529d62ea4d36)

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
mfd: pm8xxx-spk: Fix gain value for speaker.

The speaker gain value is not being set properly.
Ignore the current value of speaker gain for setting the
new value as the previous gain is not relevant to the new
value to be set.

Change-Id: I347fbc4052ba479105abe46278763d3c8c27b8e2
CRs-Fixed: 390107
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
(cherry picked from commit bfff5e6559fa01bc62b3eb96c4800c2756c57408)

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
msm: audio: qdsp6v2: Add support for VOLTE

Update the number of supported voice networks
in the ACDB driver and change the voice driver
to support concurrent calibration for VOLTE,
VOIP & voice.

CRs-Fixed: 390493
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
(cherry picked from commit 047be789746e0339963151cc904a63d183a1df31)

Change-Id: Idbe05a42f6d380ac7b78b257230dd4a5a6921c2e
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit b23a9fcc78dab71dfb90256abbbd25b73873dab7)

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
ASoC: msm8960: Fix button detection voltage thresholds

Recent measurements indicate that the button threshold voltages
have changed. Adjust the button voltages accordingly

CRs-fixed: 390846
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
(cherry picked from commit b15d0e39310c93f859b51d382797784717935555)

Change-Id: Iff0f2c4c1ac0cb1722ae709d489c04aec48caa84
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 6b9591c5440a78ed340e074224cdc73c92ff2bb2)

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
ALSA: Extend sound jack to support upto 8 key events

ALSA sound jack currently only supports upto 6 key events on a single
jack. Extend sound jack to support upto 8 buttons

CRs-fixed: 390846
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
(cherry picked from commit 33cca1e3db8b961f898daa776b99621def9219d6)

Change-Id: I7ad1f683ec50acf443a4b471c2913fe54ea47a42
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit b2c309915fdfd4126f9d873120b5405d282df58f)

Signed-off-by: Satish Kamuju <skamuj@codeaurora.org>
Merge "ASoC: msm: Fix delay in switching from WFD session"
Merge "ASoC: WCD9304: Make sure slimbus port disconnected before opening port"
Merge "ASoC: WCD9304: Vote for runtime pm off after slimbus port disconnect"
Merge "ASoC: WCD9304: Pull in fixes for slimbus connect/disconnect"
Merge "ASoC: wcd9304: reconfig LDO_H_MODE_1 to the ldoh from board file."
Merge "mfd: pm8xxx-spk: Fix gain value for speaker."
Merge "msm: audio: qdsp6v2: Add support for VOLTE"
Merge "ASoC: msm8960: Fix button detection voltage thresholds"
Merge "ALSA: Extend sound jack to support upto 8 key events"
rcu: Fix day-one dyntick-idle stall-warning bug

Each grace period is supposed to have at least one callback waiting
for that grace period to complete.  However, if CONFIG_NO_HZ=n, an
extra callback-free grace period is no big problem -- it will chew up
a tiny bit of CPU time, but it will complete normally.  In contrast,
CONFIG_NO_HZ=y kernels have the potential for all the CPUs to go to
sleep indefinitely, in turn indefinitely delaying completion of the
callback-free grace period.  Given that nothing is waiting on this grace
period, this is also not a problem.

That is, unless RCU CPU stall warnings are also enabled, as they are
in recent kernels.  In this case, if a CPU wakes up after at least one
minute of inactivity, an RCU CPU stall warning will result.  The reason
that no one noticed until quite recently is that most systems have enough
OS noise that they will never remain absolutely idle for a full minute.
But there are some embedded systems with cut-down userspace configurations
that consistently get into this situation.

All this begs the question of exactly how a callback-free grace period
gets started in the first place.  This can happen due to the fact that
CPUs do not necessarily agree on which grace period is in progress.
If a CPU still believes that the grace period that just completed is
still ongoing, it will believe that it has callbacks that need to wait for
another grace period, never mind the fact that the grace period that they
were waiting for just completed.  This CPU can therefore erroneously
decide to start a new grace period.  Note that this can happen in
TREE_RCU and TREE_PREEMPT_RCU even on a single-CPU system:  Deadlock
considerations mean that the CPU that detected the end of the grace
period is not necessarily officially informed of this fact for some time.

Once this CPU notices that the earlier grace period completed, it will
invoke its callbacks.  It then won't have any callbacks left.  If no
other CPU has any callbacks, we now have a callback-free grace period.

This commit therefore makes CPUs check more carefully before starting a
new grace period.  This new check relies on an array of tail pointers
into each CPU's list of callbacks.  If the CPU is up to date on which
grace periods have completed, it checks to see if any callbacks follow
the RCU_DONE_TAIL segment, otherwise it checks to see if any callbacks
follow the RCU_WAIT_TAIL segment.  The reason that this works is that
the RCU_WAIT_TAIL segment will be promoted to the RCU_DONE_TAIL segment
as soon as the CPU is officially notified that the old grace period
has ended.

This change is to cpu_needs_another_gp(), which is called in a number
of places.  The only one that really matters is in rcu_start_gp(), where
the root rcu_node structure's ->lock is held, which prevents any
other CPU from starting or completing a grace period, so that the
comparison that determines whether the CPU is missing the completion
of a grace period is stable.

Change-Id: Ic77e2bbe865059aa6f363db284473e9adcf8797e
Reported-by: Becky Bruce <bgillbruce@gmail.com>
Reported-by: Subodh Nijsure <snijsure@grid-net.com>
Reported-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Tested-by: Paul Walmsley <paul@pwsan.com>  # OMAP3730, OMAP4430
Cc: stable@vger.kernel.org
Signed-off-by: Jin Hong <jinh@codeaurora.org>
msm: rpm_resources: Prevent power collapse with pending RPM ack

When a device is waiting on a RPM interrupt prevent RPM assisted power
collapse. Otherwise, the device waiting on RPM completion doesn't get
the completion event until after waking from from idle power collapse.

CRs-fixed: 403816
Change-Id: I9d2c7e4c3a89b402f9064af1443697026639645e
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>