cpufreq: Fix policy getting stuck when user & kernel min/max don't overlap

Every __cpufreq_set_policy starts with checking the new policy min/max has
some overlap with the current policy min/max. This works out fine until we
end up with the policy min/max being set to a range that doesn't overlap
with the user policy min/max. Once we get into this situation, the check at
the start of __cpufreq_set_policy fails and prevents us from getting out of
this state.

This only happens when one of the CPUFREQ_ADJUST/CPUFREQ_INCOMPATIBLE
notifiers called inside __cpufreq_set_policy pick a min/max outside the
range of user policy min/max.

The real intent of the check at the start of __cpufreq_set_policy is to
make sure userspace can't set user policy min > user policy max. Since
__cpufreq_set_policy always gets called only with current user policy
min/max except when the actual user space policy min/max is changed, we can
fix the issue by simply checking the new policy min/max against current
user policy min/max.

Change-Id: Iaac805825e64d7985c41fb9052bd96baacdf3d6f
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
cpufreq: Add Input Boost feature to the cpu-boost driver

On incoming input events boost the frequency of all online cpus
for at least input_boost_ms ms. This is accomplished by changing
the policy->min of all the online cpus to input_boost_freq.

Change-Id: Idb0ab75d68ae4ceff259cbbaaec1a9bb3bc871d3
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
cpufreq: Disable cpu-boost by default

Disable cpu-boost by default, so that it can be turned ON only by
setting the module parameter boost_ms through command prompt when
required.

Change-Id: Ia9bc280892f65ed1d2e8051d1951e51922ad13db
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
cpufreq: ondemand: fix timer-related list corruption in store_powersave_bias()

The dbs_timer_init() call in store_powersave_bias() re-initializes the
dbs_info workqueue, call on dbs_timer_exit() to ensure
outstanding work is cleared prior to making this call. Also, grab the
percpu timer_mutex lock to avoid race conditions with respect to the
dbs timer.

Change-Id: I79f3d43eeb51d2d8e21edd0fe043d6583333951f
Signed-off-by: Osvaldo Banuelos <osvaldob@codeaurora.org>
ondemand: add sysfs entry for down_diff_multi_core

This change adds sysfs entry for the ondemand governor's attribute
down_differential_multi_core. This is required to be able to program
this knob to attain better perf/power for use cases like camcorder.

CRs-fixed: 561456
Change-Id: Ib7c1223215c6b714c286c231ed37f3abfae741c6
Signed-off-by: Krishna Vanka <kvanka@codeaurora.org>
defconfig: Update based on android recommended configs

Change-Id: I983ac93315d52c23640a2777be08ee2f588ac66f
ASoC: msm: Disable gapless offload playback by default

Add a flag to platform private data to enable/disable gapless
playback. The platform data is updated by mixer control.
If gapless playback is disabled ignore next track and handle
partial drain as full drain. The stream is opened in gapless
mode based on the paltform data.

Change-Id: I36cea976bcb53f50069653aec4f0f8cc869f491a
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>

Conflicts:

	sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
ALSA: compress: Memset timestamp structure to zero.

snd_compr_tstamp is initialized using aggregate initialization
that does not zero out the padded bytes. Initialize timestamp
structure to zero using memset to avoid this.

CRs-Fixed: 568717
Change-Id: I7a7d188705161f06201f1a1f2945bb6acd633d5d
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ASoC: wcd9xxx: Maintain micbias for headsets with 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.

Change-Id: Ie5079aedc4876c56a79f2b3639e75ceacc82cd16
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>

Conflicts:
	sound/soc/codecs/wcd9306.c
ASoC: wcd9xxx: Don't change button threshold registers

If registers which effect button detection are changed
when mbhc is still in recovering state, sometimes release
interrupt is not getting triggered.So don't modify registers
which effect button detection.

CRs-Fixed: 576855
Change-Id: I307ea4a112d81fecfe23eb58733913b4453284cd
Signed-off-by: Yeleswarapu, Nagaradhesh <nagaradh@codeaurora.org>
ASoC: wcd9xxx: Account for inconsistency in dce_z during button press

It is observed that dce gnd recalibration value will change
during button press. Currently dce_z is recalibrated only during
first button press. But this would cause issues in further button
detection due to the measurement inconsistancies in dce_z.
Fix this by recalibrating everytime during button press.

Change-Id: I425a3c57f669d8467170d8c0b78a997c4c0708ec
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
wcd9306: Fix compile with CONFIG_SND_SOC_TPA6165A2 enabled

Change-Id: Ifc220c94c5f488a079c1332c1a63a8b7291d1703
ASoC: wcd9xxx: Notify mbhc when TX3 path is enabled

On Tapan, ADC2/3 both being the same, it is possible that
polling noise can be captured in the recorded audio when
IN3 path is used for the recording with headset inserted.
Notify MBHC when IN3/TX3 path is enabled so that micbias
source can be switched to VDDIO to avoid polling noise to
be captured in the recorded audio.

CRs-fixed: 573616
Change-Id: I7db0ff91021e069bcc510d1d9cdbc8f2b0ee72c7
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
ASoC: wcd9xxx: Do not use current source if micbias is already enabled

Some targets share the same micbias for handset mic and headset mic.
When any recording is in progress from handset mic and if headset
is inserted, we shouldn't be using current source for the detection
as the micbias is already enabled. Check if micbias is already enabled
or not and if it is already enabled, detect the headset insertion using
micbias not with current source.

Change-Id: I269c2320ed735fa07f6b77ebffe4d2a1a8163da9
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
ASoC: msm: qdsp6v2: Fix APR de-register issues during session close

APR de-register should get called for all open streams. The
change handles a case where de-register is not called.

CRs-fixed: 584533
Change-Id: Ied50b68cdf675583e1451954f7ddf40e9c4f53df
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
ASoC: msm: Add routing controls from MM6 to MM8 to MI2S_RX_AUDIO

Add the routing between QUAT_MI2S_RX and Multimedia6-8 for
multi tunnel playback.

Change-Id: I6b8494d057cabd306c45a262b74a54ecdecce66d
CRs-fixed: 566756
Signed-off-by: Damir Didjusto <damird@codeaurora.org>
ASoC: msm: Add support for RTAC version 1.1

Add support for RTAC v1.1 which includes POPP topology.
To support backwards compatibility an ADM RTAC v1.0
structure is created as well as a 1.1.

Change-Id: Ia87109263f4176534043d6eaceddd24f9f83cfec
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
ASoC: msm: qdsp6v2: update default channel mapping

- Update default 5.1 and 7.1 channel mapping in q6adm.c
  for compress offload multi-channel playback.
- Update default 5.1 and 7.1 channel mapping in q6asm.c
  for PCM format multi-channel playback.
- Channel mapping can be overwritten by mixer controls
  passed from user space/HAL.

Change-Id: I168277f08790773411b7965784143318f72df64b
CRs-Fixed: 582601
Signed-off-by: Mingming Yin <mingming@codeaurora.org>
ASoC: msm: qdsp6v2: enhance multi-channel playback support

-Add multi-channel playback support for non standard
 channel mappings such as 3-ch, 4-ch, 5-ch, and 7-ch

Change-Id: I712ef28e9fdb2e35b59dd5fbbaddd9d38a2bad69
Signed-off-by: Mingming Yin <mingming@codeaurora.org>
ASoC: msm8x10-wcd: Fix bug in DMIC configuration

For TX MUX inputs, either ADCs or DMICs can be selected depending on the
selection from application. Fix the bug in current code where input to
TX MUX is always selected as ADC, due to which DMIC is not functional.

CRs-fixed: 585675
Change-Id: Ib1db353f90ee09764621009ed6e446d15c238f97
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>