ASoC: wcd9310: Reset OTHR_RESET_CTR before power down

There is a missing step to clear OTHR_RESET_CTR before power down.
It could cause a glitch and power hit without it. It has to be reset.

original gerrit is https://review-android.quicinc.com/#/c/191312/
This is cherry-pick gerrit by developer to jb_2.5

Change-Id: Id96070352480be6ea412844d4f71765e2df76afe
CRs-fixed: 420142
Signed-off-by: Fred Oh <fred@codeaurora.org>
ASoC: wcd9310: Update compander configuration sequence

Update compander configuration sequence for headphone path
to prevent the concurreny of ANC and compander in addition
to bypass the delay buffer for ANC and class G to avoid the
audio delay change between class G enabled and disable modes.

CRs-fixed: 456565
Change-Id: I561cb878906b9e31d8c1b04c145c533090f80f1f
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
ASoC: wcd9310: Update compander gain implementation

When compander is enabled, PA has no impact on the playback
path. In order to keep the output audio level consistently during
compander enabling and disabling so we have to apply the same
gain/attention in PA to digital gain to compensate the PA gain.

CRs-fixed: 456565
Change-Id: Idf760bac35b25aab419a23ce5803c68831850856
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
(cherry picked from commit 39828faf7eb408503d4d1fdd4473642e344496cf)
sched: pack small tasks
Date	Fri, 22 Mar 2013 13:25:52 +0100

During the creation of sched_domain, we define a pack buddy CPU for each CPU
when one is available. We want to pack at all levels where a group of CPU can
be power gated independently from others.
On a system that can't power gate a group of CPUs independently, the flag is
set at all sched_domain level and the buddy is set to -1. This is the default
behavior.
On a dual clusters / dual cores system which can power gate each core and
cluster independently, the buddy configuration will be :

      | Cluster 0   | Cluster 1   |
      | CPU0 | CPU1 | CPU2 | CPU3 |
-----------------------------------
buddy | CPU0 | CPU0 | CPU0 | CPU2 |
Small tasks tend to slip out of the periodic load balance so the best place
to choose to migrate them is during their wake up. The decision is in O(1) as
we only check again one buddy CPU

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Morten Rasmussen <morten.rasmussen@arm.com>
sched: secure access to other CPU statistics
Date	Fri, 22 Mar 2013 13:25:53 +0100

If a CPU accesses the runnable_avg_sum and runnable_avg_period fields of its
buddy CPU while the latter updates it, it can get the new version of a field
and the old version of the other one. This can generate erroneous decisions.
We don't want to use a lock mechanism for ensuring the coherency because of
the overhead in this critical path. The previous attempt can't ensure
coherency of both fields for 100% of the platform and use case as it will
depend of the toolchain and the platform architecture.
The runnable_avg_period of a runqueue tends to the max value in less than
345ms after plugging a CPU, which implies that we could use the max value
instead of reading runnable_avg_period after 345ms. During the starting phase,
we must ensure a minimum of coherency between the fields. A simple rule is
runnable_avg_sum <= runnable_avg_period.

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Morten Rasmussen <morten.rasmussen@arm.com>
sched: pack the idle load balance
Date	Fri, 22 Mar 2013 13:25:54 +0100

Look for an idle CPU close to the pack buddy CPU whenever possible.
The goal is to prevent the wake up of a CPU which doesn't share the power
domain of the pack buddy CPU.

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Morten Rasmussen <morten.rasmussen@arm.com>
modified for Mako hybrid kernel

Signed-off-by: faux123 <reioux@gmail.com>