video: msm: Finish histogram collection framework for MDP blocks

The patch "Add Histogram collection framework for MDP blocks" was included
on this branch; however, it was an incomplete version. The additions are
more histogram function pointers and better comment formatting.

Change-Id: Id5fb20f07f2c50eb678fd8f57238f4ef3d77acb0
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 7b8b64075ee4b61c15e28f3042672b26674e0b45)

Conflicts:
	drivers/video/msm/msm_fb.c
	drivers/video/msm/msm_fb.h
msm_fb: Increase backlight granularity from 15 to 255 levels

Currently number of backlight levels are set to 15, which causes
noticeable flicker when backlight level is changed from CABL
functionality in userspace. So to improve visual performance,
increase backlight granularity from current 15 levels to 255 levels.

This change is for msm8960 & apq8064 liquids which use Chimei panels.

CRs-fixed: 342485

Change-Id: I204f881d45fbcd4a419cc8e61c3bcb1f4d520f7e
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
(cherry picked from eee66c6ffa18c954fa2583fdda66526f90bad40b)
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm_fb: Increase PWM granularity to 255 levels for 8960 fluid

Currently 8960 fluid display panel only supports 100 levels for backlight.
Content Adaptive Backlight Control requires 255 levels of backlight for
optimal user experience with CABL turned on.

CRs-fixed: 342485

Change-Id: I02226a7790f2dd0144c1eb623c8177724e33a715
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
(cherry picked from commit 9f1453ec3eb2b22160d25148a45f1731a23d4c95)
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Clear previous histogram data on next startup

Clear the pointer to the userspace histogram struct when histogram is
started. Previously, when the histogram was stopped while a histogram read
was in progress, the pointer was not cleared, causing the next histogram
read to think that someone was already using the histogram.

CRs-Fixed: 361640
Change-Id: If09017149e98b35c49603372c554aa4c97f2de82
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 19e4b71f617e307cacf0be077e08bec5c37df290)
msm_fb: Add histogram support for MPQ 8064

Currently, there is no support for histogram on MPQ 8064. Add
support for histogram ioctls to support histogram testing.

CRs-fixed: 375580
Change-Id: I24ccf73c6ea6d230da4624ea196cba2d8195f8b2
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
(cherry picked from commit c8430bd159039340c5a50e6897b256631f5dc7bb)
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Move histogram disable to before panel off

Histogram expects the display to be on while running, thus moving its
disable call to before disabling the panel timing generator ensures this
assertion.

Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 67ddb9b38b1793c297ff431ef9f650f355c4abf2)

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_video.c
	drivers/video/msm/mdp4_overlay_lcdc.c

Change-Id: I308b3e0c24f0111fb8549d0a0ae025910d649b75
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay_dsi_video.c
	drivers/video/msm/mdp4_overlay_lcdc.c
msm_fb: Retain CSC values across suspend/resume sequence

CSC values pertaining to various H/W blocks are stored in a
global structure and will be re-applied during resume sequence.

CRs-Fixed: 376159
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
(cherry picked from commit c40f9f9bc1e83ce521759f03b6fd01d9699cd39f)

Conflicts:

	drivers/video/msm/mdp.h

Change-Id: Ieb151185efd106041e28feedf4fa271ae4ba2666
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Dynamically toggle histogram interrupt

Make histogram enable/disable functions also enable/disable the histogram
"interrupt enabled" bit on the MDP enabled interrupts register.

CRs-Fixed: 398556
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 1026832c51cbadeea9a717fa20fb42b6a7c5661f)

Conflicts:

	drivers/video/msm/mdp4.h

Change-Id: I56f811e88cf3fd44ae0a2df8a6e5de32ba9a0c1c
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Defer histogram reset to workqueue

Currently, when an underrun occurs, a reset request is sent to the
histogram hardware. This has been observed to cause a hang in the histogram
collection cycle. The fix for this hang is to instead rely on the existing
checks for histogram validity in the histgram read worker. When the
underrun occurs, the histogram is invalidated, which in turn causes the
histogram read worker to reset the histogram collection when it attempts to
read its contents.

Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 2dd5234c094157bf77781b8646ac9ad114f819b0)

Conflicts:

	drivers/video/msm/mdp.c

Change-Id: I66d33ddedef76fdcb6c4a3d8095c0e8ca695e33d
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Ensure idle state before enabling histogram

Disable interrupt, set state flags to false, cancel histogram collection,
and clear the workqueue before attempting to enable the histogram. This
guarantees that this is the only configuration of the histogram running.

Change-Id: I222932db40494724b3efdb2e5bea08a849095c1e
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 5e5f3b4ff8a4a0d980e02fa38c2b70fec7095e79)
msm_fb: configure LM1 and LM2 CSC coefficients with RGB2YUV for WFD

1) Initialise the LM1 and LM2 coefficients with RGB2YUV as WFD expects
these coefficients to be programmed.
2) LM2 is available from MDP ver 4.3, fix conditions accordingly

Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
(cherry picked from commit Ifad2be0fb5c3c96fa1515e114097a87d250fd62a)

Conflicts:

	drivers/video/msm/mdp.c

Change-Id: Ifad2be0fb5c3c96fa1515e114097a87d250fd62a
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c
video: msm: Enable mdp clock for histogram and histLUT

Enable the mdp clock for histogram and histogram LUT to ensure that the
clock remains enabled when they are being accessed.

Change-Id: Ic744f2ee96b64442f23ba19aa1c38552c0dad83a
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit e782ceab26e38590cd49a9bb273da1dbf1984ccd)
msm_fb: display: Add timeout for waiting on update

Content Adaptive BackLight userspace algo waits on UPDATE_NOTIFY to
get the screen updates. When turning off CABL, this blocking ioctl
causes the CABL threads to wait until next screen update, which may
take indefinite time.

Add timeout value to the wait_for_completion call, to make ioctl
call blocking for at most timeout value.

CRs-Fixed: 384026
Change-Id: I6715a36020c24ddd09823bd54d4321900429a6b9
Signed-off-by: Kinjal Bhavsar <kbhavsar@codeaurora.org>
(cherry picked from commit 1b6843a3a56e60e73305c66369f8ad806353e22d)
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Send ETIMEDOUT on update-notify timeout

Send the ETIMEDOUT errno when the update-notify wait_for_completion times
out. This is required to be able to properly handle the different failure
cases in the functions that use the update notify ioctl.

Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit b640c29b8b3b4a0733924a6e4ad0665d5218a7dc)

Conflicts:

	drivers/video/msm/msm_fb.c

Change-Id: I0e46b0b0c89f6b2e5beb3fc0ed18ebbb75dfa434
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Do not use disable_irq in the spin_lock_irqsave context

Both mdp_isr() and mdp_histogram_disable() uses the same
spin lock mdp_spin_lock variable.  One core waits for disabling
mdp_isr after acquiring mdp_spin_lock and other core in mdp_isr()
waits for spin lock mdp_spin_lock and dead lock between two cores.

Change-Id: I73a10494ab78e92fc88a348aed4f526091b51f89
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
(cherry picked from commit 946ca6389b8f8c70b62a2f1ab4d81b475395f7d8)
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msmfb: Add Enable/Disable flag definition

Fix compilation error, due to mm-core library supporting MDSS HW.

Change-Id: I50afc5e85129172e6b1774a0bc6b8ceff2aad45a
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm: Ensure droop detectors do not affect krait PLLs

The Droop detector mechanism present in Glitch-Free (GFMUX)
goes to nondeterministic state during frequent
standalone power collapse operation. It affects
Krait PLL output so that the PLL won't lock to
required frequency.

Since Droop detector isn't used, set sc_pdn (PLL_CLAMP)
permanently high to ensure droop detector is off and it
does not affect Krait PLL.

CRs-Fixed: 381144
Change-Id: I94ee03e0e9439c5195909a8646ff9e3c3f667893
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
(cherry picked from commit 06e444f9cd8106816a2874886cb4c165d4b03b81)

Conflicts:

	arch/arm/mach-msm/Kconfig
	arch/arm/mach-msm/Makefile

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

Conflicts:
	arch/arm/mach-msm/Kconfig
	arch/arm/mach-msm/Makefile
msm: platsmp: Update Krait reset sequence

The SMP CPU initialization code incorrectly applied the
KPSS 2.x CPU reset sequence to Krait Pass 3, even on
targets using KPSS 1.x. Modify the SMP code to apply the
KPSS 1.x reset sequence where appropriate, regardless of
the CPU version. Also incorporate updated register settings
to avoid having to later reconfigure the Krait PLL clamps.

CRs-Fixed: 431744
Change-Id: Ie18cf5b2e1a91ae574934e64a487ee27d70ea1a5
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit 986b5153852a01149ec967434b4a95acdb0ac5d9)

Conflicts:

	arch/arm/mach-msm/platsmp.c

Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
ARM: decompressor: avoid speculative prefetch from non-RAM areas

We setup identity MMU mappings across the entire 4GB of space, which
are permissionless because the domain is set to manager.

This unfortunately allows ARMv6 and later CPUs to speculatively
prefetch from the entire address space, which can cause undesirable
side effects if those regions contain devices.

As we setup the mappings with read/write permission, we can switch
the domain to client mode, and then use the XN bit for ARMv6 and
above to control speculative prefetch to non-RAM areas.

CRs-Fixed: 415757
Change-Id: I24bacf244b1e987e1b966eee64a2578cbdb12080
Reported-by: R Sricharan <r.sricharan@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
(cherry picked from commit 3463f07a22f288c6230aa8c230f623d9183c5a10)

Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: Ensure krait pll clamp is always set for CPU0

To turn off droop detectors in glitch free mux, the krait PLL clamp
is set permanently for secondary cores in platsmp secondary boot path.
Set the pll clamp for primary core as well.

Change-Id: I4b18e7781515c3c66ef629c3c8ca3457ca9b2874
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
(cherry picked from commit 8fd644a8f5f4fad013c502a4600f63374a464ccb)

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