msm_fb : Avoid wait for vsync when Timing Generator is off

Add checks for Timing Generator enable status before waiting
for vsync from it. This will avoid race conditions during
suspend-resume scenarios.

CRs-fixed: 406752

Signed-off-by: Pradeep Jilagam <pjilagam@codeaurora.org>
(cherry picked from commit 282a601efdb0a74b5f65a881f4e4b638d0ef9cee)

Change-Id: I9c0c2bf5e48f59c69c6928c15779b172e9ed2dc1
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
msm_fb: display: Make sysfs read request interruptible

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

Change-Id: I370ced4f271e5f1d2c248bed06131c0623d7223f
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
Signed-off-by: Padmanabhan Komanduru <pkomandu@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.

CRs-fixed: 406752
Change-Id: I773687220b868823a9e4bfdae74361ee6487c5c6
Signed-off-by: Pradeep Jilagam <pjilagam@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: display: Create sysfs entries in mdp_probe for MDP4 targets

vsync sysfs entries should be created in mdp_probe instead of
creating in panel on. This avoids waiting for the first event
control in framework

Change-Id: I3b6987555a2318f1bd36be253349611e051ca58d
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp.c
	drivers/video/msm/msm_fb.h
 msm_fb: display: Create sysfs entries in mdp_probe for MDP3
 targets

vsync sysfs entries should be created in mdp_probe instead of
creating in panel on. This avoids waiting for the first event
control in framework

Change-Id: I18b05b8d2a65d489afc6e3274ec8dc7a5b9a5f9a
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp_dma_dsi_video.c
	drivers/video/msm/mdp_dma_lcdc.c
msm-fb: Fix sysfs node creation in mdp_probe for MDP3 targets

-vsync_init null check not required for mdp3 target before
 creating sysfs node.
-Set vsync suspend and resume flags appropriately in mdp_on
 for mdp3.

CRs-Fixed: 393243
Change-Id: I3366df7385ca8e2ae15053c3e58332f8e32ce0cd
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: display: Buffer sync point support

Add MSMFB_BUFFER_SYNC ioctl for the communication of
the acquired and released fence fd between kernel and hwc.

Wait for acquired fence before pan display.
Release the previous released fence after pan display

Change-Id: I6534aed574a025d948581e70465f06a86b46c868
Signed-off-by: Ken Zhang <kenz@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
msm: display: add sync point support in overlay commit

Wait for fence signaled before commit, signal previous
fence after commit done. Same as pan display

Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c

Change-Id: Id48dbd2ad29ab951dc9955cc89fc8c52938c1ade
msm: display: make pan display as a non-blocking call

Schedule a workqueue, do the current job in the workqueue handler.
Block the second entry if the first one has not finished

Change-Id: I9466c7795bd9d6765f468bf30f4021802d904c36
Signed-off-by: Ken Zhang <kenz@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c

Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c

Conflicts:

	drivers/video/msm/msm_fb.c
msm_fb: display: Add MSMFB_OVERLAY_COMMIT ioctl.

MSMFB_OVERLAY_COMMIT ioctl is used to display on external.
This is used instead of the default PAN mechanism to avoid delays in that path.
This ioctl for external also waits for DMAE thus fixing tearing.

Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Arun Kumar K.R <akumarkr@codeaurora.org>
msm: display: add display commit ioctl

Display commit ioctl will do what pan_display
can do, addtionally has customized setting, such
as non-blocking call.

Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c
	include/linux/msm_mdp.h

Conflicts:

	include/linux/msm_mdp.h

Change-Id: Idda9900e0629311e6a705661113c1b09b9f8eb69
msm: display: buf sync enhancement

Support waiting for acquire fences in the buffer sync ioctl.

Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: fb: make the pan task interruptible
msm: display: allow fb open even in suspend state

resume might be coming later, allow fb open sucessfully, only
panel driver needs be delayed

Signed-off-by: Ken Zhang <kenz@codeaurora.org>

Conflicts:

	drivers/video/msm/mipi_dsi.c
	drivers/video/msm/msm_fb.c
msm: display: panel recovering from suspend

In suspend state, fb_open cannot turn on panel, need save this info
for resume.
In suspend state, blank setting needs be cached to be used at resuming.

Signed-off-by: Ken Zhang <kenz@codeaurora.org>

Conflicts:

	drivers/video/msm/msm_fb.c

Change-Id: I1f5b090db315e5f23f75aa6a2e52ed10f28d554b
msm: display: Do not create release fence in suspend

When in suspend state, display operation will be stopped,
fence will not be signaled

Signed-off-by: Ken Zhang <kenz@codeaurora.org>
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.

Change-Id: I0660080262b7e5895f5f558c0a9f71aa84b9aa99
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@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.

Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm: display: Increase timeout value for fence waiting

In some benchmark use case, graphic engine is extremely
busy, need increase the fence waiting timeout value.

Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm: display: check get_unused_fd_flags return val

Not checking the error code, which might be negative, will cause us to wrongly
reference fdt[fd] by using the error code, causing kernel panic in fd_install.

Change-Id: I1f8e68e74bdbdd5b81bc3450f7d93b5cd96c9439
Signed-off-by: Iliyan Malchev <malchev@google.com>

Conflicts:

	drivers/video/msm/msm_fb.c