msm_fb: display: Fix backlight issues during boot

Initialize backlight level to 0 in msm_fb probe to allow the
userspace/framework set the required backlight level. Allow backlight
settings always in msm_fb_set_backlight call.

Change-Id: Ic42b76e6b8886957856683ee0343afd383ef42c8
CRs-Fixed: 270638
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: display: Add backlight with first pan display after resume

Add backlight call with first pan display after resume operation
of framebuffer driver

CRs-Fixed: 323682
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
Change-Id: Ic27c2c9fe37b622bbd9ab5933ca45626decd53ae
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: Display: Add support for "Continuous Splash Screen" feature.

The image displayed on the screen by the android bootloader
driver should continue till the android animation shows up.
Delay the display initialization for MDP, display dependent clocks
and panel power on functions.

Change-Id: I6c82721eef55ad6ad0ea2312048af3648b932df0
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Chandan Uddaraju <chandanu@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: display: disable pan display and memory access to fb1 and fb2

The native fb1 and fb2 framebuffer memory is not used and not
allocated on the board file. So on the driver side, pan display ioctl
or other operations on fb1 or fb2 framebuffer memory is checked and
invalidated.

(cherry picked from commit ca61dbb1d9f0d8fe2c4d5871d9934379708c1091)

Change-Id: Ie3e85e20f5675f9cfe02c4587f0fe119e8d57e76
CRs-fixed: 357242
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
Remove if 0
msm_fb: display: Keep fb1 for MDP version < 4.0.2

For better memory usage, fb1 memory allocation is removed for
targets like 8960 which support BF pipe and true mirroring but
required for targets like 7x30 and 8660 which still needs fb1
for border fill.

CRs-fixed: 364669
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
(cherry picked from commit aa356f6c4d44965233c79d68bd293a258730d8c1)

Change-Id: I8585eba4aa4a5b466b1ca828453e1d473fc579be
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: display: detect if timing generator is on when do dma waiting

If the timing generator is not on, dma waiting won't return and system
crashes. So add TG on detection to avoid the issue.

CRs-fixed: 362503
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
(cherry picked from commit 1c2bee0158437f485c32f6750e8df3314ae9168b)

Change-Id: I4462b38635a974102c133a8abdfce7b04d33323a
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: display: extend mdp debugfs with force blt enable

Enabling mixer0 or mixer1 blt mode is a critical way to debug display
issues, so add debugfs interfaces to force blt mode enabled with adb
shell commands, instead hack the code and recompile kernel.

CRs-fixed: 362503
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
(cherry picked from commit add1ac8beb5af7bfbf311b6fd8ed253a92329f23)

Conflicts:

	drivers/video/msm/mdp4.h

Change-Id: I237eaf93a19fe0cb65050fbe7b8d4e9ddddb1603
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: display: Enable MDP clock's overlay block during panel on

MDP clock's overlay block is enabled during first update after panel
on currently. This is now moved to panel on to keep clock enabled
right from display on time.

Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
CRs-fixed: 368167
(cherry picked from commit 24502cb2cfd176d72cc6884dbeb375c7fb054766)

Change-Id: I6c23396cad4f9ec4d520d82c276bb079b48757cd
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: Check for Histogram NULL while queuing work

Don't queue the work if the user hasn't requested for the
histogram data

CRs-Fixed: 365729 363763
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
(cherry picked from commit ff42a9a426ab9a76d75a29464412807dd72ceb13)

Change-Id: If5e6a5ad525e895ff7c2f27666cc7a445c485cb4
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
video: msm: Check for multiple readers of histogram

Check to ensure that only one reader attempts to read one frame's worth of
data from a histogram block. Prevent the case where two readers attempt to
get data, but end up causing a loop where neither of them do.

CRs-Fixed: 361640
Change-Id: I48878d9fe02d96f306894ed9acc47bf41cd9984b
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
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>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
video: msm: Avoid waking readers on failed histogram copy

Avoid waking up the waiting histogram reader when the current histogram has
failed to copy. Additionally, clean up initialization of histogram
workqueue (was initialized twice).

CRs-Fixed: 361640
Change-Id: I376c0193b8e34aba5b0aef54feb9504f450ffff4
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
video: msm: Resolve post processing memory leaks

Allocate memory for post processing only once. Free post processing memory
when MDP is removed.

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

Change-Id: I14eacda2bd92c8f1fb89cfe4fdc1c9624b09a359
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: Handle multiple histogram reader errors during suspend/resume

If a histogram reader waits for completion in the do_histogram ioctl
and during this time the device is suspended, the complete for this
gets called from mdp_histogram_ctrl_all() in the panel_next_off()
sequence. This results in mgmt->hist not set to NULL. The subsequent
do_histogram ioctls after device resume fail due to multiple reader
failure condition since the histogram irq will be enabled now from
the same mdp_histogram_ctrl_all() during panel_next_on() sequence and
this by-passes mgmt->hist getting set to NULL that is present in
histogram_start() ioctl. Handle this scenario.

CRs-fixed: 363763
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
(cherry picked from commit a43f44b44ee221df11ad84b8536c1c8d5373cbaf)

Change-Id: If0a45a8215a969bf6f137e19f2536d6d4abce156
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: display: Add pre-multiplied alpha support for MDP4.

MDP4 blend logic differs from GPU blend implementation as MDP4
does not differentiate between layers with pre-multiplied alpha
with that to non pre-multiplied alpha layers. Check layers for
pre-multiplied alpha and change blend logic accordingly.

CRs-Fixed: 355755
CRs-Fixed: 361729
CRs-Fixed: 366441
Change-Id: Idf3fef57bc3cc31a221b83027f5f3fa64dee5ae7
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
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

Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
(cherry picked from commit 9f1453ec3eb2b22160d25148a45f1731a23d4c95)

Change-Id: I3941f8dda0bc0e0f3a466b8597a389091a6b22cc
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
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

Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
(cherry picked from commit eee66c6ffa18c954fa2583fdda66526f90bad40b)

Conflicts:

	drivers/video/msm/mipi_chimei_wuxga.c
	drivers/video/msm/mipi_tc358764_dsi2lvds.c

Change-Id: I35b5f6a9468d74792d1f90e752750a05e58bb4cd
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm_fb: display: switch blt mode on/off without turning off TG

Turning off dtv TG may cause blink. MDP requires h/w idle to change
blt mode, turning off TG can make sure mdp h/w is idle. If turning off
TG is not desired, one way to do is to check busy bits of overlay and
dmae and once they are both idle, the mode can be changed.

CRs-fixed: 363717
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
(cherry picked from commit 43da18d00abc2a61834b6650a49bf7edcf4f4df0)

Conflicts:

	drivers/video/msm/mdp4_overlay_dtv.c

Change-Id: I8aeea1439a83b71e5980080a5396cc9c9fa8556b
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
video: msm_fb: Increase display timeout to 2 seconds

One second time out for no frame update, as in current implementation,
does not allow CABL to reach minimum backlight level possible because
histograms dont get generated after one second. So increase time out
period to two seconds which seem to be sufficient for complete black to
complete white and vice versa transitions.

CRs-fixed: 370804
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 1bb4edf9242b0397975636a4442318713a53b5e6)

Change-Id: I298dbc94c32035bc7872341a028af979d74fe38f
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>