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)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
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>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
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
Change-Id: Ieb151185efd106041e28feedf4fa271ae4ba2666
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
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
CRs-Fixed: 399462
Change-Id: Ifad2be0fb5c3c96fa1515e114097a87d250fd62a
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
(cherry picked from commit f6044334ee63fe9553f5cce8aa65c172c88e1175)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
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>
Signed-off-by: Pravin Tamkhane <pravint@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.

Change-Id: I0e46b0b0c89f6b2e5beb3fc0ed18ebbb75dfa434
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
video: msm: Remove adjustment to MDP revision

Remove the modification of mdp_rev during mdp_probe. Not needed since
board files now have the correct MDP revision data.

CRs-Fixed: 417080
Change-Id: I553cb2a8e8de43b6c7b7976c3eca67d00a3cfe4f
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>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
msm_fb: display: Correct dtv pipe black out

This change corrects the register values to black out
the dtv base pipe.

Change-Id: I80fefab3cc6dd006edbb673f41ccfe983af2cc3a
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
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>
msm_fb: display: Proper pipes solidfill

For MPQ/hdmi as primary, solid fill the pipes only during suspend.
This change also take care of the solidfill of the pipes unset
during overlay and pan display at suspend.

CRs-Fixed: 421461
Change-Id: I15096df681cbd94ae3cea63ecbfe915e01b7387f
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
msm_fb: display: Fix blend configuration for command mode panels

For command mode panels, blend registers does not get configured
as per the use case. This leads to incorrect blending of layers
resulting in lower layers (eg. wallpaper or buttons in video
playback) to show above the upper ones, making overall user
experience to go bad. In order to resolve the issue, blend registers
are now configured properly by as per the use case.

CRs-Fixed: 410029
CRs-Fixed: 415553
Change-Id: Ibe7d594e0ad6a6f4d75ed2e59c7382c09b65d624
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm_fb: display: Add alpha enable check in blend

FIR and M/N scalar when used for downscaling, drops
alpha channel of the given layer. To notify this, alpha_drop flag
is updated accordingly. This flag need not be checked for layers
with no alpha plane. In some scenarios alpha_drop may get enabled
for the layers with no alpha plane and cause issues realted to blend
composition of layers. Check for setting alpha_drop only if source
ayer has alpha plane.

Change-Id: Ie64b30c045a78d0d68eb9efacc76902afae7850d
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm_fb: commit mixer stage for WFD during unset

Interfaces with Borderfill pipe as base layer needs to
be commited during unset which will reset the mixer cfg
structure. This is needed because overlay_commit will not
call stage commit as there is no buffer queued.

Change-Id: Ib3347e52ae437b20d5a85a09777f13aee2672edb
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
msm_fb: display: Do not use ION_IOMMU_UNMAP_DELAYED

Since iommu buffer will be un-mapped after two newer commits
had passed, there is no need to request iommu driver to further
delay un-mapping an iommu buffer.

Change-Id: I8cf8d406cf509908035d12c9a04f0add12f3c7c7
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm_fb: display: Removing extra disable irq in cmds_rx API's

Disable IRQ for DSI_CMD_TERM was already called in the isr.
Removing the extra call present in the cmds_rx API's.

Change-Id: I0000dd3166beb2a3b0c788327e1d7520e0c11a13
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm_fb: display: Add support for vsync driven composition on 7x30

This patch will queue multiple surfaces and commit those
surfaces into mdp at same instance so that surfaces will
be blended and displayed at same time for 7x30. Hardware vsync event
is delivered to the user space frame work via uevent. Both
queue and commit are controlled by frame work and synchonized
with vsync event. Therefore frame rate will match with vsync rate.

Change-Id: I2acb83f871f16c2278dc10cb958580a2826efe70
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
msm_fb: display: wake up system around vsync

To avoid frame drops due to power collapse,
wake up cpu right before vsync.

Change-Id: I63385eb329ae5e74cbac5256823fd3a213e0a0e1
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm_fb: display: change the location of wakeup timer call

There are two pathes (pan display and overlay commit) to commit
display buffer, so change the location of cpu timer wakup call to the
common pipe_commit function to make sure cpu get waked up around
vsync.

Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Change-Id: Idbe6049d740a7e17a6a90e28566f7a9c74e348f2