msm: display: add more checking to ensure display is idle

Before execute operation on display, make sure it is complete idle
Because non-blocking display update has been introduced, need make sure
display update has finished in all entrances except the ones for
initialization.

(cherry picked from commit 43d62bf4b61cbaf52677126a4899ff8b489cdd76)

Change-Id: I18bee54c950404bea7ab89c9575c888e4c015935
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: display: add mutex for display driver entries

In some cases, display driver is called by multiple threads, this
will cause re-entrance problem. For example, one thread is
calling display commit, the other turns off the display. In order
to serialize the operation, mutex is added to most APIs.
Only the ones for initialization won't be added.

(cherry picked from commit 12c51684416bf5cc14d645fb741eea8d3d6627fa)

Change-Id: I84359d2e89930b61f5a0641b5e3078f9846c60ab
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
msm: display: sync point error handling

Increase timeout value for fence waiting
Handle file handle error in fence creation

Change-Id: I46db344172795998fd03a1676f90d9dcbd19d0a6
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: display: display idle checking update

msm_fb_blank_sub might be called for UNBLANK from
display update work queue, which is at commit state.
Idle detection is invalid in this situation
Add detection for external snd earlyuspend/resume interface.

Change-Id: I1b08d10c9c494b9b3df5e95c4a54036877d5653f
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm_fb: call complete for no_update timer after power flag is set

In Suspend case, after we complete for no_update timer and before
we set power down flag to false we might recyle the CABL sequence
which might cause do_hist to fail till resume

CRs-Fixed: 434491
Change-Id: I51f9f0d9edb26c7671d44162f55c01acdde8f3d7
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
bcmdhd: Do not deref null ptr in p2p code.
Fix crash when bluetooth is turned off while connecting.

When msm_gpiomux_get() fails, do not attempt to msm_gpiomux_put() on the
failing index.
Do not allow multiple gpio refs in configure_*_gpios().

bluetooth_platform_data.bluetooth_power() is called for every write to the
bluetooth rfkill sys file, which in turn results in an arbitrary number of
calls to configure_*_gpios().  The gpiomux objects are reference counted,
so we cannot allow arbitrary gets and puts.

Fix this by only allowing one gpiomux reference in configure_*_gpios().

Change-Id: I650c28825cc1195a1b5353c9aee2ca2d9e15ec5d
msm: acpuclock-8x60: Drop "slowest" frequency table

The voltage data in this table is not used. It applied only to
a handful of internal part samples that were never distributed.
Remove it, since it is neither maintained nor useful.

Change-Id: I2a08bd0287a400cfb65666dc3445fd5441d784d1
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: acpuclock-8x60: Optimize CPU voltages on 1.7GHz parts

Hardware characterization shows that these parts can operate reliably
at lower voltages than were previously used. Update the tables to
take advantage of the power savings.

Change-Id: I6aca2da89e343c1588579e7183a0ce375cb9a821
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: acpuclock: Fix error path in multicore targets

Several acpuclock drivers have inherited the same error path bug in
acpuclk_set_rate(). If an invalid cpu is passed as an argument to
these functions, they should return immediately instead of jumping to
the 'out' label, which attempts to unlock a mutex which has never
been acquired.

Change-Id: I47b9709605673a5200caf73a2f2a5086fde63efe
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: spm: Allow setting of voltages across cpus

The original intent of disallowing voltage set across cpus is to prevent
setting of voltages on a core when its idle thread. The cpufreq
framework ensures that the frequency changes and hence the voltage
changes happens on the respective cpus. By allowing setting of voltages
from others cpus, the secondary cores can be brought out of reset by the
non-primary CPUs after boot and thereby help mitigate any thermal issues
associated wth multicores.

The regulator framework that calls into msm_spm_set_vdd provides the
necessary access restrictions to prevent simultaneous calls into
msm_spm_set_vdd.And hence the spinlocks around the set_vdd calls have
been removed.

Change-Id: Ie60673d4b65953a0a8f9ec9bafb82399f692a7b5
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm_fb: display: add sysfs and clock control to smart panel

Both vsync enabled and disabled are controlled by framework
through ioctl. Driver reports vsync event to framework via
sysfs. Meanwhile, mdp related clocks are enabled by frame
work at vsync enabled request and disabled by driver if there
is no any display update within specifid vsync period.

Change-Id: Ice5be3a6db5930b95bdd2f718d9256bf73936e23
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_cmd.c
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>

Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm_fb: display: turn mdp clock on at pipe_commit

mdp clock is controlled by frame work. There has
possibility that mdp clock had been turned off while
frame update still happen. In this case update
thread may stuck at wait4vsync since there has no
mdp clcok to trigger vsync interrupt. This patch
will enable mdp clock at pipe commit when mdp clock
is tunred off so that frame update can be completed.

Change-Id: I2d31b9a4b6f0cb9dd36516a80931988e23e8a545
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_cmd.c

Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_cmd.c
msm_fb: display: Make sysfs read request interruptible

Change blocking sysfs read request to be interruptible and protect
vsync timestamp value to prevent corruption.

(cherry picked from commit 9da7f0167abb5a78e38bc3907786181845b04d58)

Change-Id: I816ebc1235f2efdb15fe3620d57cf8152d4734ed
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm_fb: display: Send current timestamp if vsync time not available

Send current kernel timestamp if vsyncs timestamp is zero. This
happens if the kernel hasnt yet received the vsync interrupt.

(cherry picked from commit baba51f9b7e861309f79af3cdefa33b0da0834f4)

Change-Id: I248d2939bb6c7f14bfe379f0f7e923ad1ebcd433
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm_fb : Add timeout while waiting for vsync event

Avoid eternal wait for vsync event when client tries to
read the corresponding sysfs entry. This will avoid hangs when
client tries to read in corner cases where the Timing
Generator or the clock or IRQ gets disabled.

(cherry picked from commit c0ab36eaa7f3457e2137ede0fd5a89a493db9e20)

Change-Id: I2291c35f14397973d42dc3200cb43626699276bc
CRs-fixed: 406752
Signed-off-by: Pradeep Jilagam <pjilagam@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm_fb: display: Send current timestamp in case of timeout

On timeout while waiting for the vsync, send the current
timestamp to the userspace. This resolves the infinite
wait seen during the bootup.

Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
Change-Id: I0d7b8750becfbb4e5c5e47b29ded6395627e8862
video: msm: Update blend configuration during BLT for DSI video

 * Blend configuration was not updated during BLT, which is active during
   video playback. This was causing display artifacts when pulling the
   notification shade or changing orientation.

Change-Id: Ie84a994f80289c7819cde49700bda5df2bbba0bf
Merge remote branch 'upstream/cm-10.1' into android-msm-3.0-jb-mr1

Conflicts:
	arch/arm/mach-msm/acpuclock-8x60.c
	arch/arm/mach-msm/spm.c
	arch/arm/mach-msm/spm.h
	lge/lge_board/i_skt/platform_i_skt_bt.c