msm: mdss: Set correct flush bit for writeback mixer.

Wrong flush bit is being set for writeback mixer which can cause
MDP hang/unexpected behaviour when the mixer is used in line mode.
This patch addresses the issue by setting the correct flush bit.

Change-Id: Ie0c2ee27b1f466164a8fb84f7daae9309b74d1d8
Signed-off-by: Vishnuvardhan Prodduturi <vproddut@codeaurora.org>
msm: mdss: increase height constraints for panel resolution

MDP is able to support higher resolution and is only limited in height
by the MDP clock rate. There is already check in place for the MDP clock
requirement, however need to update phase step calculation to handle
proper overflow conditions for these higher resolution according to
hardware constraints based on potential overflow while scaling with some
phase steps. At the same time hardware is able to handle some conditions
that are currently failed, so enable these to allow more cases that can
go through MDP.

Change-Id: I4c5a569e115302f05db7c525c0f8a76ed1738521
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Add support to halt pipe fetches

Add a utility to halt any pipe fetches and wait on it until all fetches
are completely halted. Use this utility during staging and un-staging
of the pipe.

Change-Id: Id865970063dffc2870be5fd2cf51b9711134dc89
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: remove interruptible timeout waits

Currently display driver contexts are not utilizing interruptible
wake-ups while using wait_for_completion_interruptible_timeout. This
can lead to incorrect context wake-up and un-predictable outcome. Since
there is already a timeout attached to these kind of context sleeps, it
is safe to replace them with wait_for_completion_timeout.

Change-Id: Ia528debf34aef0acdda2bea1219a128c200c3651
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: Make notify update waits interruptible

Wait for completion in notify update call are uninterruptible
causing excessive delay during suspend cases. Making them
interruptible.

Change-Id: I1a4ff6ce3e0add21d4e46a41372b076b277d10f5
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: refactor command mode vsync control logic

Current logic is prone to corner case when mdss_mdp_remove_vsync_handler
is called twice: once from mdss_mdp_cmd_stop and again from vsync ctrl
logic. Need to properly identify the second call and avoid resetting the
rdptr ticks which prevent from clocks being turned off properly.

Change-Id: I9eeebd0c16e67a249508980427c81fa2e339edec
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Return suspend without delay in NOTIFY UPDATE

NOTIFY_UPDATE returns Suspend after 4 seconds delay.
Delay would cause HISTOGRAM_STOP ioctl to be called late.

Return suspend case without setting timer for no delay.

Change-Id: I356086de96cab85cd203bf1ad529ecf0b3bbfce3
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: do proper error handling in case of rotator setup fail

When rotator setup fails, the session should only be finished internally
if it hasn't been reported to userspace. At the same time, need to
ensure that proper cleanup of rotator list is happening, through
internal release path.

Change-Id: I7a6f46261bf8783547de1c7f7fd6893916b25827
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: move rotator SMP reservation to rotator setup

Shared memory pool (SMP) blocks are limited, in some cases where there
are many overlay pipes used, we may not be able to get enough blocks for
rotator sessions. In such cases fall-back solution must be considered,
however for this to happen this would need to be identified during
rotator session setup. Move logic to do pipe resource reservation in
rotator setup if possible.

Change-Id: I223281fb51b81baf852cac415a8c61c0de35c2c4
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Add support to get/set secure flag via an ioctl

Add support to get/set secure flag for WB session through an ioctl.
This is required for WB clients such as AD/WFD, enabling them to modify
or query the secure flag depending on requirements e.g. secure video
playback when using AD.

Change-Id: I852b6f79b31b5ba027d9a5c11561c562023cb99f
Signed-off-by: Tatenda Chipeperekwa <tatendac@codeaurora.org>
msm: mdss: Fix race condition for vsync irq enable/disable

Disable and enable of vsync happens in separate thread, which
may lead to a race condition where enable/disable may
happen at the same time and resulting irq in disable state.
Add lock to properly synchronize the enabling/disabling
of vsync interrupts to fix race condition.

Change-Id: Ib52bea5ca7a3612c866a4a962f09725a77e40563
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: mdss: remove extra lock for ctl calls

Some ctl functions need only protection for mixer programming changes,
since all of these calls are made within ov_lock there is no need for
additional protection. Specially since ctl->lock is still held when
mixer configuration is safe to be changed.

Change-Id: I4f39e28f40ef18789a653d02346358b7ca7590c6
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: update pipe params on first update after suspend

Whenever panel is turned off, need to ensure that pipe is reprogrammed
fully when turned back on in case the pipes are not properly unset.

Change-Id: I6242b8f90695dd713c87924eb15306767b62803e
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: optimize MDP pipes cleanup

There are cases where pipe cleanup can happen without display commit.
This means that the pipe was never programmed to hardware, in these
cases the pipe can be cleaned up without the need of display commit
cycle to happen. Also there is no need to access hardware to release
resources such as SMPs since they have not been programmed yet.

Change-Id: I57a46471dc1fba4e45e55c3543940ba4fba0540a
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: Add support for macro tile formats

MDP now supports tile formats on APQ8084. Macro tile formats
are aligned with number of memory banks and access channels to
improve performance.

Change-Id: Ie566cc12b38f81d111f378f19883433bcc71fa48
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>
msm: mdss: Fix mdss_dsi_cmd_mdp_busy timeout error

Make MDSS clock ON before sending DCS command  to fix
mdss_dsi_cmd_mdp_busy timeout error.

Change-Id: I78a5931715f7a8803af77cd43c6191c225bcecd8
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: mdss: Detach mdss iommu on static screen

Detach mdss iommu on static screen and re-attach
on next commit to allow full power collapse of MDSS.
IOMMU driver keeps its vote for bus bandwidth for as
long as the MDP driver is attached to the IOMMU.
When MDP detaches from the IOMMU, IOMMU driver will
remove its vote for bus bandwidth.

Change-Id: I1e5c5c50bc157c3ebfc63e198e4608dad820a288
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: mdss: Modify SMP requirement for BWC decompression

BWC SMP buffer allocations are different from BWC fetch strides.
The Detile write of BWC is segmented into 16 algined segments for
every line buffer. This has to be taken into account and based on the
format the buffers need to be channeled.

Change-Id: I168014709bd81bfb189ce8cb3d1224f911838ba7
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
msm: mdss: synchronize wfd driver iommu mmap/munmap with mdss

Add clocks reference during wfd driver iommu mdp_mmap/mdp_munmap
to ensure iommu is in proper state while wfd driver map/un-map
any buffers.

Change-Id: Id1a24285b81d5047e5e9f002ade9694ea49be59d
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: mdss: call suspend and resume panel events during runtime triggers

Send a panel suspend/resume event to all the MDSS devices to ensure
proper handling of regulators and clocks during the suspend/resume
sequence.

Change-Id: I820f5e4113f599ba53d4fa4726e406f74872f95f
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>