ASoC: apq8064: Fix button detection voltage thresholds

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

CRs-fixed: 432596
Change-Id: Ibee4db3b9c76df1d464dcad443f0f90d24751ee3
Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
USB: android: Fix adb device file closing bug

adb device file closing and config disabling can happen in
parallel during composition switch.  If adb device file
is closed prior to config disable, adb function driver request
android to disable configuration.  But this is not undone later
when adb device file is opened.  Due to this bug config remains
disabled after composition switch completion.  Fix this bug.

CRs-Fixed: 414360

Change-Id: Ia7b352c63d860028c02b8dd7a52522460557e6fd
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
power: pm8921-bms: fix fake battery emulation

With the recent split of functions to calculate and report state of
charge, the faking battery feature broke, it remained in the calculate
function.

Move the fake battery feature in the reporting function, where it really
belongs.

Change-Id: I6a3fcc3b233792d87ea4ac8fe2e155e10ca24e21
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
ondemand: Add support to consider other cpu load when scaling frequencies

Currently only current cpu load is considered when frequency scaling.
As a side effect of this when scheduler migrates a thread to a slower
core, the execution time increases unexpectedly.

The new algorithm not only considers current cpu load for frequency
scaling, but also takes into account load of other online cpus. The
treshold for this can be controlled using up_threshold_any_cpu_load.
When the up_threshold_any_cpu_load is crossed in any cpu then the
current cpu is set to sync_freq.

Also, when more than one cpu is online a two step ramp-up mechanism
is used. When the up_threshold_multi_core is crossed the cpu is ramped
up to optimal_freq which is less than policy->max and set to a power
friendly value.

Change-Id: I64bed1b142cde1f239e73aa1f78981c78aaf59ce
Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>
(cherry picked from commit d3ca78370df00ec7a5b6816321ea1a1a371f2850)
msm: gemini: Support upto 64mp encoding

Redesign the output ping pong mechanism to support
upto 64mp encoding using gemini hardware.

Change-Id: Id7801861e0fe119f61a02fb3409155f312a85d21
Signed-off-by: Sunid Wilson <sunidw@codeaurora.org>
msm: event_timer: Fix potential race condition

There is a possible race condition which could happen in the following
scenario:

Core 0 PC: lock_hrtimer_base

 lock_hrtimer_base
 hrtimer_get_remaining
 get_next_event_time
 msm_pm_idle_prepare
 msm_cpuidle_enter

Core 1 PC: generic_exec_single

 generic_exec_single
 smp_call_function_single
 setup_event_timer
 mdp_update_pm

If core0 idle thread runs before core1 has had the chance to make the
smp_call_function_single, then idle thread could end up spinning on
lock_hrtimer_base() since setup_event_timer adds an event to the event
queue but the smp cross call is the one that initializes the event timer.
So Core0 could spin on lock_hrtimer_base() since CPU1's SMP call won't be
handled as idle thread runs in noirq context.

To prevent this scenario make a change to the code flow to do the queue
operations and the timer operations on the same CPU. Meaning
setup_event_timer will only make an SMP cross call to re-organize the event
queue and reset the event timer all of which will be run on CPU0.

CRs-fixed: 425587
Change-Id: I53fc551d18f350c47e05a94976b56a5fd2e9050b
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
(cherry picked from commit e73869cb18ee79bd0b951fd7effd6565ce7ccfb4)
msm_fb: display: skip one vsync event after enabling mdp and vsync clk

Both mdp and mdp_vsync clks are disabled for command mode panel when
no new frames are being played. When they are re-enabled if new
requests come in, the first vsync event which is signaled by read
pointer interrupt arrives in a random time due to the sync between mdp
and panel, so skip it to maintain correct vsync timing.

Change-Id: I683b765e4a16d3d152b9270f5982234b94921f1e
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
(cherry picked from commit a4567ac320abe5d74b3c7decdbddba4bd8c57463)
msm_fb: display: add panel's late_init

Some panels need to be initialized after panel is on.
Add late_init to support this feature.

CRs-fixed: 433011
Change-Id: I73c623d1fe52363f070af79ce4bf7774cd84689e
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: acpuclock-krait: Don't vote for PLL regulators in power-collapse paths.

The HFPLL regulator votes are active-set-only votes. This allows
us to get away with not voting for the HFPLL regulators in the
power collapse path by allowing the sleep-set <-> active-set
transition in the RPM to take care of this for us. Thus:

1. In the power-collapse path, if a CPU or the L2 switches from
   an HFPLL source to a non HFPLL source, the regulator votes
   remain in place, but will be removed once apps transitions
   to its sleep set.
2. In the power-collapse path, if a CPU or the L2 switches from
   a non HFPLL source to a non HFPLL source, the regulator votes
   are already not present.
3. In the resume path, when apps transitions to its active set,
   the HFPLL regulators would be turned back on before the HFPLL
   source is reselected.

Change-Id: Ifc66aaf23d601654367792ff2fb2cc35580db241
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
(cherry picked from commit 3a78830598a34f67b48780b7e9e0f25f4448fd66)
msm: acpuclock-krait: Pre-emptively vote for the L2 HFPLL regulators

It is necessary that the L2 level computation and the setting
of the L2 rate happen atomically, so that the computed level
is still valid when the L2 rate is set. A spinlock protected
critical section is needed for these operations. However, the
votes for the HFPLLs necessitate invocation of the RPM
regulator APIs from a non-atomic context.

To solve this, we must first note that the problem only exists
when:
1. The L2 frequency is being switched away from an HFPLL source
   to a non-HFPLL source, or
   the L2 frequency is being switched away from a non-HFPLL
   source to an HFPLL source.
			--AND--
2. The CPU frequency switch (the cause of the L2 switch) is
   being performed as a result of cpufreq invoking the switch or
   hotplug onlining/offlining a core, since HFPLL regulator
   voting does not take place in the power-collapse and resume
   paths.

The solution is to pre-emptively vote for the L2 HFPLL regulators
if the target CPU frequency's required L2 level is sourced off of
an HFPLL. These votes are only removed after the spinlock
protected critical section completes, and only if the previous
CPU frequency's required L2 level was already sourced off of an
HFPLL source.

One further optimization is to disable only pre-emption, and
not interrupts in the afore-mentioned critical section.

Change-Id: I7b01f274f773ce513300ed3e4b074bae63e84c64
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
msm: rpm-regulator: Replace spinlocks with mutex locks

All calls of rpm_vreg_set_voltage() now take place in process
context.  Clock driver code on all targets has been written so
that atomic regulator control is no longer needed.

Refactor the rpm-regulator driver so that a mutex locks are used
in place of a spinlocks for sleep-selectable regulators which are
controlled via the rpm_vreg_set_voltage() function.

At the same time, move clk_prepare() and clk_unprepare calls in
the TCXO workaround so that these functions are correctly called
during each workaround invocation.  This is needed so that TCXO
isn't kept on forever after a single clk_prepare() call.

Change-Id: I07caed041dac6da073a0644271df2227b6c5a96e
Signed-off-by: David Collins <collinsd@codeaurora.org>
msm_fb: display: free borderfill pipe when ref_cnt reach 0

Borderfill pipe need to be kept as baselayer which is not
suppose to be freed at suspend. It only be freed when
ref_cnt reach 0 by "adb stop".

CRs-fixed: 429196
Change-Id: Ibffe7960cc194162d1ba71e8dc8636393938483f
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
usb: ks_bridge: Avoid allocating large buffers in atomic context

The current code allocates a new Rx buffer in Rx completion handler.
Rx buffers are freed after user space consumes them.  This results in
allocating larger buffers in atomic context which may fail some times.
Don't queue the Rx buffer immediately. Defer it till user space consumes
it and reuse the same buffer.  The test results indicate no throughput
degradation.  The Rx buffers will be freed when interface is suspended
or disconnected.

CRs-Fixed: 430595
Change-Id: I8e69e27df2e11b38497e0384a8edd87ecedcb24b
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
(cherry picked from commit 5c915c1949b79bc59d2b222bfcce02cd429619b2)
mm: make counts of CMA free pages correct

Both patches needed, second patch (among other things) fixes
a bug in the first.

commit 2139cbe627b8910ded55148f87ee10f7485408ed
Author: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Date:   Mon Oct 8 16:32:00 2012 -0700

    cma: fix counting of isolated pages

    Isolated free pages shouldn't be accounted to NR_FREE_PAGES counter.  Fix
    it by properly decreasing/increasing NR_FREE_PAGES counter in
    set_migratetype_isolate()/unset_migratetype_isolate() and removing counter
    adjustment for isolated pages from free_one_page() and split_free_page().

    Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
    Cc: Marek Szyprowski <m.szyprowski@samsung.com>
    Cc: Michal Nazarewicz <mina86@mina86.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Hugh Dickins <hughd@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [lbassel@codeaurora.org: backport from 3.7, small changes needed]
    Signed-off-by: Larry Bassel <lbassel@codeaurora.org>

commit d1ce749a0db12202b711d1aba1d29e823034648d
Author: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Date:   Mon Oct 8 16:32:02 2012 -0700

    cma: count free CMA pages

    Add NR_FREE_CMA_PAGES counter to be later used for checking watermark in
    __zone_watermark_ok().  For simplicity and to avoid #ifdef hell make this
    counter always available (not only when CONFIG_CMA=y).

    [akpm@linux-foundation.org: use conventional migratetype naming]
    Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
    Cc: Marek Szyprowski <m.szyprowski@samsung.com>
    Cc: Michal Nazarewicz <mina86@mina86.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Hugh Dickins <hughd@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [lbassel@codeaurora.org: backport from 3.7, small changes needed]
    Signed-off-by: Larry Bassel <lbassel@codeaurora.org>

Change-Id: I7d4f5fe0b6931192706337e0b730f43e7cccd031
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
mm: Use correct define for CMA features

CMA features may ifdef out parts of the code with
CONFIG_CMA. Older code uses CONFIG_DMA_CMA. Switch
to using the newer CONFIG_CMA to ensure the code gets
compiled when needed.

Change-Id: I3cae639797787b4926a6c5e057de973b66196707
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: Add support for external demux buffer allocation

demux input/output buffers were allocated internally by the driver,
for MPQ use-cases there's a need for user-space MPQ player to
allocate the buffers through ION driver and set them to demux
similar to the way other kinds of buffers are managed
in android multimedia stack for video

Change-Id: Ic28a279c0841fee12008cea7beac58f82409b9f9
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: Update calls to ION API

ION API was changed and the calls from dvb demux
needs to be updated accordingly

Change-Id: I8582d4cf544cf8fa4e52252bc8614f4866d6f774
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
tspp: Add option to inverse tsif signals

TSIF signals (clock, data, enable and sync) may be configured
to be inversed at TSPP unit input. This is useful in case
TSIF signals from external units need to be inversed.

Change-Id: I4f0bfdc58fb8658dbf10fe3805b8787f9d36aeca
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: mpq: Extended and unified parameters of demux module

Demux parameters were unified to have same semantics across
different demux plugins. Extended the parameters to add option
to invert the tsif clock signal.

Change-Id: I1b253d27353feb0b9c9214fcfafb8b257da6528e
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
media: dvb: dvb-core: Stall demux in PULL mode when events queue is full

In PULL mode demux should stall when output buffers are full until
there's free space for new data. The demux data events queue could
also get full and overflow if user is not reading data fast enough.
Added checking the fullness of data events queue when working in PULL
mode so that demux stalls in case it is full.

Change-Id: I3d2cb89a2e3c5fb8e1be4b1df9d7efbb8ca458e2
Signed-off-by: Hamad Kadmany <hkadmany@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>