video: msm: Maintain histogram LUT state through suspend resume

Make sure LUT state is maintained after suspend resume. Required to ensure
HistLUT and backlight scale are in sync.

CRs-Fixed: 476491
Change-Id: Icc999aa0b04cad93ceed334426f61b71cbdd0a13
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c

Conflicts:
	drivers/video/msm/mdp.c
video: msm: Initialize HistLUT with last saved LUT

Set HistLUT to last value written to LUT when MDP is turned on. Assumes
that last LUT corresponds to last BL scale value sent.

CRs-Fixed: 475149
Change-Id: I7383666c2d1f3d8800c5f25e2ef648568eb33a74
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
msm_fb: display: add mdp clock control to histogram enable/disable

Add mdp clock control to histogram enable and disable block to
prevent system from crashing when accessing register with mdp
clocks off.

Change-Id: Ide808b332b5456f3fc639fcbb0d03d5cad0e387f
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: display: Limit dynamic fps feature only to MIPI video panels.

As dynamic fps feature is supported only for MIPI video panels,
return -EINVAL if sysfs node is written for panels other than
MIPI video. This change also removes world writable permissions
for sysfs node.

Change-Id: I72260e6032cb8a758b0457c36a808263a981260f
Signed-off-by: Vishnuvardhan Prodduturi <vproddut@codeaurora.org>
msm_fb: display: no native frame buffer memory operations

Since we don't use pan_display, the native frame buffer memory is not
necessary any more. This is driver change, mainly disabling memory
operations that are associated with native frame buffers.

CRs-fixed: 458938
Change-Id: If33bff32ee1d9228ff8a74ca09961a0f10f1fcdd
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: hdmi: HDMI resume delay

Remove the delay in HDMI resume sequence by not waiting for HPD
to be switched on. HDMI panel will not be turned on by default
when the device resumes and would instead be turned on by HPD
sense if it is still connected.

CRs-Fixed: 440559
Change-Id: Id276dddbcebf9226e9688aa1b5dad4b281545b21
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>

Conflicts:
	drivers/video/msm/hdmi_msm.c
msm: msm_fb: remove mmio access through mmap

Disable access to mm io and add
appropriate range checks to ensure valid accesses
through framebuffer mmap. This prevents illegal
access into memory.

CRs-Fixed: 474706
Change-Id: If25166f2732433ef967e99c716440030b567aae9
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
msm_fb: Fail fb2 open if called during suspend

At present, if msm_fb_open() for fb2 is called during suspend,
we increment the ref_count for fb2 and return success without
turning on the writeback pipeline. This causes the WFD client
think that fb2 is successfully opened whereas fb2_open should
not successful during suspend. Hence, return error if msm_fb_open()
is called for fb2 during suspend.

CRs-fixed: 475310
Change-Id: I73167a120a64ac18c5789ccc9cf7faad14b50b94
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: Set backlight to zero during adb shell stop scenario

During framework reboot (adb shell stop/start), the backlight
value might be non-zero after adb shell stop. In such cases,
during adb shell start, we see momentary garbled screen due to
panel-init pattern since backlight is ON. Hence, set backlight
to zero during adb shell stop. Also, store the latest backlight
value before adb shell stop so that backlight can be set soon
after first frame update after adb shell start.

CRs-fixed: 479316
Change-Id: I2a98c2599f5f3fadf516da2df06556f52fe50a2e
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: display: allow backlight update after first update

bl_updated is set to non zero at pan_display if unset_bl_level
is not zero. And unset_bl_level is not updated unless bl_updated
is zero. There is a situation that bl_updated stay as zero after
first pan display due to unset_bl_level is still zero which
prevents back light from being changed until next pan display
even though unset_bl_level changed. This patch break up this loop
and allow back light being changed right after first pan display.

CRs-fixed: 471983
Change-Id: I75504206853517672f968e8ea8fc6782a282e326
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

Conflicts:
	drivers/video/msm/msm_fb.c
msm_fb: display: update var in display commit

Need the value of var in display commit to update the double buffers.
If not, double buffering doesn't work in minui (eg. recovery and off-charger
mode)

Change-Id: I1fba52243cc781f18742131759245911d32c9b18
Signed-off-by: Devin Kim <dojip.kim@lge.com>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm_fb: hdmi: Update frame rate on resolution change

On resolution change, we need to update the frame rate as well.
Video mode programming in HDMI can also be based on frame rate.

CRs-Fixed: 461486
Change-Id: I4cf1192796482ec0aa7aa130297f740c96115e08
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>

Conflicts:
	drivers/video/msm/external_common.c
msm_fb: Check for panel power on after Unblank.

In Overlay_play , panel power on check was at wrong place
it has to be after Unblank.

Change-Id: If910f83ef57499b5f771bc7d3d1bdfa814d5c019
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
msm: display: reduce timeline to 1 for smart panel

For smart display, dsi command and wfd, since it has its
own buffer, the input buffer can be released once the
display commit finishes, hence the fence threshold for
creation can be smaller. This patch reduce the timeline
from 2 to 1 for samrt panels. Also, it needs to
wait4dmap/wait4ov after kicked off. Otherwise, tearing may
happen.

Change-Id: I9eca871d8d863ef23b1d67b6e1e9cffea40ae4a6
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

Conflicts:
	drivers/video/msm/msm_fb.c
msm_fb: Set timeline threshold for command mode to 2

For command mode panel, timeline threshold is 1 and we return
commit ioctl on DMA_P interrupt. This causes fps to drop
since sometimes overlay is kickoff just after vsync interrupt
causing DMA_P wait time more than 1 vsync period. Hence, increase
timeline to 2 and return commit ioctl on vsync interrupt.

CRs-fixed: 457153
CRs-fixed: 452269
Change-Id: Ic7385631fdeb25f269306d284c94fdf43cade3d1
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: hdmi: HDMI suspend resume event handling

This change makes sure that we do the proper HDMI ON settings at resume
and also send the events to user-space about current status of HPD after
resume.

CRs-Fixed: 422372
Change-Id: I8ca79fd07840b3227c9472588853b0ca2749760b
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>

Conflicts:
	drivers/video/msm/hdmi_msm.c
	drivers/video/msm/hdmi_msm.h
msm_fb: hdmi: Use common header for resolution modes