Revert "msm: mdss: stop display commit thread only if it is running"

This reverts commit 8d3014ccb917ecf0274d3823a17ea8962daacdbf

Change-Id: I42c19f4f1d5a5c1d55297a97f85f88410a725b00
Signed-off-by: Panwar Vivek <vpanwa@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: 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: move mdss fudge factors to device-tree

MDSS has a common driver for multiple chip-sets. Each of these chip-sets
can have their own fudge factors for calculations of resource demand.
Move these pre-defined fudge factors to device-tree since they are
platform dependent.

Conflicts:

	Documentation/devicetree/bindings/fb/mdss-mdp.txt
	arch/arm/boot/dts/msmsamarium-mdss.dtsi
	drivers/video/msm/mdss/mdss.h

Change-Id: Ia558a2ad0a096b49cdabf41dd25cf30c843149c4
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: Move bus scale table implementation to device-tree

Bus scale table is chip-set dependent where number of paths per
bandwidth use-case can differ chip-set to chip-set. Current
implementation has a static table where it supports only one path per
use-case. Expand MDSS bus scaling implementation to accommodate
chip-sets where more than one path per use-case, i.e. apq8084, is
possible and move table initialization to device-tree so that every
chip-set configures its own table.

Conflicts:

	Documentation/devicetree/bindings/fb/mdss-mdp.txt
	arch/arm/boot/dts/apq8084-mdss.dtsi
	arch/arm/boot/dts/msm8226-mdss.dtsi
	arch/arm/boot/dts/msm8974-mdss.dtsi
	drivers/video/msm/mdss/mdss.h
	drivers/video/msm/mdss/mdss_mdp.c

Change-Id: Ia6f76654d129fe0ec1a7124aa87b16f96167fe84
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
ARM: dts: msm: Add flags for FDE/PFE support

Add following flags
- support-fde
- support-pfe

These flags are needed to be set on targets that support
FDE (full disk encryption) and PFE (per file encryption),
respectively.

Change-Id: Ieed9979e16901b8d8357389b9e375826ae156034
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
msm: mdss: add iommu attach in bus bandwidth control request

Add mdss_iommu_attach in mdss_bus_bandwidth_ctrl to
attach iommu on bus bandwidth enable request.
mdss_iommu_attach/mdss_iommu_dettach can happen in
separate thread, which may lead to a race condition
where attach/detach may happen at same time. Add lock
to properly synchronize the iommu attach/detach to
fix race condition.

Change-Id: I45c8ef1fa1fa1c2da9c6c3702bd007856e469b9d
Signed-off-by: Pawan Kumar <pavaku@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: Add SMP per pipe parameter into hw capabilites

Additional SMP parameter 'smp_mb_per_pipe' is required by
userspace as part of hardware capability made available
through sysfs node.

Pipes availablity for a use case can be computed taking these
values, based on which, composition decisions can be made.

Change-Id: I2d790506ca895357762e1eca098ea1734077a097
Signed-off-by: Mayank Chopra <makchopra@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: I247ef0cd3e0616de3e5ddd9599233af570e422a5
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: add mdp overlap and prefill bandwidth calculations

This patch implements a set of new equations proposed by h/w team to
calculate mdp bandwidth. MDP has bandwidth requests during both
blanking and active periods. During blanking area, mdp needs to fill
its internal buffers, such as latency buffer, outstanding buffer,
pingpong buffer, etc. This bandwidth is called prefill bandwidth and
it is determined by the total amount of bytes of buffers to be filled
and the total amount of blanking time available. The bandwidth for the
active peroid is called overlap bandwidth which is the max bandwidth
request of all overlapped regions. The final vote from mdp would be
the worst case of prefill bandwidth and overlap bandwidth.

Change-Id: Ib83caf6a3e15c33a2cd71d14e8413b1d9049de29
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: support mdp prefill bandwith for multiple platforms

To calculate mdp prefill bandwidth, mdp driver needs to get h/w
dependent buffer constants from device tree. Also add h/w feature
dependent logic.

Conflicts:

	drivers/video/msm/mdss/mdss.h

Change-Id: I8d56ec502a6fd56eaae5b65a326ef966be46f14b
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: reduce mdp prefill bandwidth vote for command mode panel

The current result of mdp prefill bandwidth calculation for command
mode is larger than what is actually needed for many use cases. This
is due to the fact that for command mode panels during prefill time,
there are less buffer prefill requirement or time constraint than that
of video panels. This patch makes adjustment accordingly based on the
updated equations by h/w team.

Change-Id: I06935a29d771202b3f8dc2c62cf948a8ecc81481
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: calculate prefill bandwidth using the worst case vbp

The blanking period of a panel is determined by vbp factor: vertical
back porch plus vsync pulse width. The larger vbp, the larger blanking
time, and the smaller prefill bandwidth request. When two or more
types of interfaces/panels are involved, although each panel has its
own vbp, there is an option to calculate the prefill bandwidth for
each panel with the worst case vbp of all panels. This way there is no
need to increase fudge factor to avoid underruns.

Change-Id: I60dda6ad41bbb353c58ef93cf97787c4da3929dc
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: add tile format condition for prefill bytes calculation

Latency buffer requires more lines to be prefilled for use cases that
supports tile format.

Change-Id: I552bade677822d47cdd5b43c01f795552e94b406
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: release mdp bandwidth voting for command mode when idle

There is no bandwidth usage for command mode panel if no new commit
comes, so mdp bandwidth request can be zero as soon as data transfer
to panel is done. This could bring power savings for use cases of
short transfer time relatively to long idle time (duty cycle) such as
partial update, and slow fps. When video mode panel is present, this
bandwidth cannot be released since the timing of this release is
unpredictable.

Change-Id: Ia67143aa421b7b8d8b1f359244dd397dab369b4a
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: update latency buffer bytes calculation for prefill bandwidth

This is a s/w change to reflect the new h/w update of latency buffer
byte calculation for prefill bandwidth. Previously this number of
latency buffer bytes is the amount of allocated smp bytes, however,
for some use cases this doesn't not match the bandwidth equation
result. So for the purpose of matching mdp prefill bandwidth
equations, a standalone calculation is needed.

Change-Id: Ic74599d2c2bfe9610ebc22dee137a0df7171dcb5
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: Copy IGC LUT data correctly to userspace

During IGC read operation, IGC LUT's data was copied to
userspace incorrectly because of swapping color components.

Fix component data swapping during IGC LUT data copy to
user space to provide the correct IGC LUT data to user space.

Change-Id: I301a3500f0e0c4bbf9f52affa66373585c72d987
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
mdss: Add newline to VSYNC timestamp for mdp3 driver

This makes sure that the userspace correctly interprets the end
of the vsync timestamp.

CRs-Fixed: 639039
Change-Id: I8a0810283a42a9c39a3c8fe36b862bbfd3ecdbea
Signed-off-by: Shivaraj Shetty <shivaraj@codeaurora.org>
mdss: mdp3: Remove extra call to clk_prepare

clk_prepare got moved inside mdp3_clk_update. Prior to this patch
unprepare would never be called successfully.

Change-Id: I28ab035b42d433f379d63748ac4f506a8575ea66
Signed-off-by: Terence Hampson <thampson@codeaurora.org>