msm: mdss: Adjust writeback mixer offset

With new targets, number of interface layer mixers have increased.
This increases existing macro values. Even though writeback mixers
have not changed, their programming needs to be adjusted.

Change-Id: I71bb6e6988d4e2bf2f66e0ecbb7ff9672d21b8dc
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>
msm: mdss: Increase base fence timeout

The earlier value of 1 second caused unnecessary warnings on
heavy workloads by the GPU.

Change-Id: Ib4a5b098267251d5c63c4d8d2a2f51b339acc1d2
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: mdss: release all overlay resources on last fb release

There are cases where the last frame buffer reference is released from a
different pid than the one who originally allocated the resource.
In these cases we can still deallocate all resources currently allocated
as we know that all references on fb dev have been released.

Change-Id: Ice2ca8df765cb8c4537a89fec887cb125d820d7a
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
mdss: Validate sync timeline object before inc

An earlier commit - 4b7db574f061e13857e3780ceddd24ab0681628b
removed this by mistake. Restore this check.

Bug: 10953656
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
mdss: display: turn on mdp clocks after acquiring dsi lock

At command mode panel, mdp related clocks are turned on/off
frequently to save power.  It will be turned off after 4
vsync time if no kickoff happen.
MDSS_EVENT_DSI_CMDLIST_KOFF event will try to acquire lock
of dsi controller and it may take some times to complete it.
Therefore mdp clocks have to be turned on after acquire lock
of dsi controller instead of before.

Change-Id: Ied3de9f96fabbc06b43cad23ac54659c785012d3
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: mdss: calculate mdp ib bandwidth with overlap and smp factor

mdp ib request for multiple small layer use cases is too large because
currently it is the lump sum of all individual layer requests times a
constantant factor. Adding the logic to calculate the worst case of ib
requests for overlapped areas and the concurrent smp fetching for all
layers.

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

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_ctl.c
mdss: remove pan_idle from vsync control

Do not wait for previous commit to complete when
enabling/disabling vsync

Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: mdss: keep mdp clk on during overlay kick off

This will reduce the delay caused by turning on/off mdp clk multiple
times during kickoff. Currently during kickoff, mdp pipe registers and
flush registers are programmed each with mdp clk on/off. We only need
turn mdp clk on/off once to program those regs.

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

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_overlay.c
msm: mdss: create new vsync timeline for retire fences

Retire fence timeline should follow the actual panel vsync more closely.
In case of command mode the panel vsync can be different from buffer
release timeline. To handle the panel vsyncs better, create a new
timeline for the retire fence signaling.

Change-Id: If8a1eb717d733ca215275a8be4f0054091dbc147
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: split sync fence and display thread commit count

Sync fences should maintain a separate commit count from display thread.
Sync fences need the commit count in order to maintain proper timeline
and ensure the fences are created against right timeline. The display
thread on the other hand maintains number of commits that it should
handle. If we want to separate sync fences from display thread logic so
that sync fences can be released after asynchronously from display
thread then these need to be in separate variables.

Change-Id: I1303c49f2c56eb5b9a34c162a1896670d307a674
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: allow asynchronous acquire fence waits

Add optional flag to allow MDP driver to asynchronously wait for fences
instead of doing it at beginning of every commit. This allows the wait
to happen much later in the programming sequence so that, we can use
that time to do everything that is needed and have a smaller window
between the wait for fences and the next frame update.

Change-Id: Ib4f7601ed22670ba235ba86fe3389a5d54d685a9
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: increase retire fence timeline with retire count

Account for cases where multiple retire fences are acquire before
previous ones are signaled. It may happen that the next retire fence is
acquired before the current one has been signaled, we want to signal on
the next vsync instead of the current one.

Change-Id: Ieff3115f9b10ea1a917eebdb6a32e44bc2e71c73
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: null check for ctl pointer

display_commit may be called before overlay_on, which passes a null
ctl pointer. Adding a null check to avoid the crash.

Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
mdss: use a nonthreaded interrupt

Signed-off-by: Iliyan Malchev <malchev@google.com>
mdss: No pan idle for overlay vsync control

The other vsync control ioctl isn't used, make sure both ioctls
do not call the "pan_idle" function

Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: mdss: ctl null pointer checks after display commit waiting

After display commit, display thread is waiting for the commit done,
if shutdown happens during this waiting period, the ctl patch could be
nulled. Adding ctl pointer null checks could avoid crashes.

Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Bug: 11429494
msm: mdss: set writeback RGBX8888 output alpha to opaque

Even though the alpha channel on RGBX format should be ignored, even if
the pixel is picked up it should still have full alpha value so that
all pixels are shown. For this reason set the alpha value to 0xFF.

Change-Id: I2db531b1f6fb3035831195546645d58718cff87a
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Validate mixer/ctl are not null

mdss_mdp_wb_mixer_destroy could theoretically be
called with null mixer or ctl, which would cause
a null pointer dereference. Adding a check to
prevent this from happening.

Change-Id: I376c449daf05c8ca4ebb789d402575598ee59d86
CRs-Fixed: 551787
Signed-off-by: Casey Piper <cpiper@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
msm: mdss: Support multiple vsync handlers for CMD mode

Add support for multiple vsync handlers for command mode panels.

Change-Id: I21bf032ac20100dce252dcc09400ad2142a1dcf4
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: unregister command mode vsync handlers on stop

When command mode panel is being stopped, any vsync handlers that are
still pending should be removed before shutdown sequence. If this is
done afterwards VSYNC_TICKS update may cause the clock to continue
running after clocks have been shutdown and may lead to MDP hang.

Change-Id: I149390413326b21ddf608e7fe5a31b3a57abe50b
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>