msm: mdp: Add retire fence

Generate the retire fence with a +1 offset from the current
release timeline. This would mean that the retire fence of the
last frame is signaled when the current frame has transferred.

Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: mdss: expose MDP capabilities through sysfs

User space applications currently rely on special private ioctl to query
capabilities of MDP driver. As more capabilities are added it becomes
more difficult to have to extend and maintain header file compatibility.
Provide a sysfs node which can be queried for MDP capabilities.

Change-Id: I59efb29bf465083a1ef65c0419226788b44085b1
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>
msm: mdss: support uneven framebuffer split

The default split ratio is 50 percent if buffer resolution width is
greater than the max width that mixer can support. This even split may
not be desired for optimal smp allocation or other usecases.

CRs-fixed: 491728
Change-Id: I8ff3f7c1bd79daf1da9ebded0c561cf96db08b73
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
mdss: Fix writeback

Fix retire fence threshold for writeback.
Notify when writeback buf is not available.

Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: mdss: unmap user writeback buffers after session is terminated

Currently if buffers are provided to writeback driver through user space
ioctl, these are never unmapped and may cause leaks in memory. Also, we
can reuse the nodes which are already mapped until session is
terminated.

Change-Id: Ic786dfa735af529998bfc9467ac872b2badc0e31
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
msm: mdss: allow re-queue of writeback buffers

When a buffer has been properly processed, user space may choose to use
sync fence to acknowledge when buffer is complete. In such cases dequeue
is not not necessary, allow this use case by allowing client to re-queue
of writeback buffers as long as the buffer has been properly processed
already.

Change-Id: Ibac1eb9710477734e1ee2daf8136085d4439b0d4
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.

Change-Id: I439f99b6ec0b567f60c8ae1566c64d58ca301f9f
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
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: 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>
video: msm: mdss: am54272844ee: merge fixup
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: refactor performance calculations

Current logic could potentially lead to drop in performance (and
underflow) when multiple panels are there and both are updating mixer
configuration independently, as we may end up raising bus bandwidth for
another panel which may not be ready just yet, this is addressed by
updating performance configuration values until it's ready to switch
rather than updating values and performing these later (other panel
update could come in between).

Change-Id: Ib5077ecfd9390f67157067cb6c06106cb896868f
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: account for peak bandwidth due to SMP fetch

At beginning of vsync, all pipes can start fetching at the same time in
order to fill their allocated SMP blocks, which is usually only enough
to hold first few lines of the layer. Account for this behavior and
ensure that there is enough bandwidth to fill these in the blanking
period.

Change-Id: Ic23e31813fe67958f741d52ab504ed683d23dd45
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: add back bus factors for bandwidth calculations

Bus factors are needed to account for how system behaves. AB factors is
needed due to the way bus driver is calculating the bandwidth by
dividing it across 2x ports. IB factor is needed to account for DDR
inefficiency and get the correct throughput.

Change-Id: Iccf83dd25615de489d8e986c38a6d2e9175a965c
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: wait for ping pong during unblank kickoff

During panel unblank a kickoff is done to turn on the panel so that the
first update is not delayed. However since buffer sync and display
commit is not called on this, need to make sure that the update finishes
completely including the workqueue that signals the fences. Signaling
the sync fence can potentially cause timeline to be ahead and end up
signaling the acquire fences early leading to source tearing on command
mode panels.

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