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>
Revert "Revert "msm: mdss: Detach mdss iommu on static screen""

This reverts commit 994b5a0347066cd415a42c42772c251fd79e095a.
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: Reset pipe's mfd parameter during pipe free

There is a corner case with dma pipe. If its set call
fails as line mode (for mdp) and is configured
subsequently as block mode (for rotation), mfd parameter
of the dma pipe structure does not get reset during set
failure cleanup. This causes unnecessary force dma
cleanup call in rotatorp lay which gets hang and
results in rotator fence timeout.

Change-Id: Ia090e9eebf43ab6e28a2746f8fe57e2c3da34e59
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: mdss: remove panel type check for split display case.

Split display flag is derived from dsi controller configuration
specified at dtsi. Therefore no need to add checking panel
type at FB registration.

Change-Id: I5b60656c1f5724bdc358d743b8d7600d5beba0b3
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: mdss: On sharing dma pipe increment pipe ref_cnt

When DMA pipe is being shared and if mdss_mdp_pipe_map is called,
there could be a race condition when the pipe being shared
is unmapped, will lead to map failure as map is used for operations
on pipe which are already having positive ref_cnt.
This can result in potential map failure and attempt to free of
unmapped pipe resulting in crash.

Hence in this scenario of shared pipe usage atomic_inc should
be used instead of mdss_mdp_pipe_map.

CRs-Fixed: 590736
Change-Id: Ibaba20ac96662b5cd8aba3585f10d9cfe6e72d22
Signed-off-by: Justin Philip <jphili@codeaurora.org>
msm: mdss: hdmi: Added gpio for ddc mux selection

Added a gpio for Display Data Channel (ddc) mux selection.

Change-Id: Idbe8a6d1aa033885d7e11b27a74bdca37d3b23f5
Signed-off-by: Zohaib Alam <zalam@codeaurora.org>
msm: mdss: Check extra mmb allocated to a pipe

If set call to a pipe changes smp configuration such that
calculated no. of  mmb blocks are less than allocated mmb
blocks, fail this set call. This ensures pipe disconnection
and smp configuration is possible in next commit cycle.
Also, check that no extra mmb is left allocated to any plane
when pipe's format changes. If so, fail the set call to let
correct smp configuration happen in next commit cycle.

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

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_pipe.c
msm: mdss: Control histogram intr and clk in suspend cases

Histogram interrupts, and clocks used to handle interrupts, need to be
enabled in sync with histogram requests. To ensure that these interrupts
and clocks are disabled when screen is suspended or not updating, a control
structure is introduced that allows for these resources to be gated by
specifying transitions from when they should and should not be active.

CRs-Fixed: 568049
Change-Id: I77a50085ee38de597092c273c7ce9974c7bb29c3
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
ARM: dts: msm: support qseecom bus scaling in msm8226

To support qseecom bus scaling, ab & ib values are changed to set four
bandwidth levels: "INACTIVE, LOW, MEDIUM and HIGH" with corresponding
bus bandwidth of {0M, 0M, 150M, 492M}; and the flag of support-bus-scaling
is also set to one.

Signed-off-by: Zhen Kong <zkong@codeaurora.org>
ARM: dts: msm: Remove support for obsoleted speed bins for msm8226

Previously, there used to be a redundancy scheme where multiple speed
bins mapped to the same frequency. This reduancy scheme was never used
and is obsoleted to free resources.

Conflicts:
	arch/arm/boot/dts/qcom/msm8226-v2.dtsi
	arch/arm/boot/dts/qcom/msm8926.dtsi

Change-Id: I9ca3c4e0a809d1563a3d786521e3b54e54e06af5
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
mdp: mdss: Tune bandwidth and clock based on ROI

Calculate bandwidth and MDP clock requirement considering
the ROI submitted for a frame. When doing partial frame update
for smart panels, the data actually fetched for a pipe is not
always the full resolution of the buffer programmed. Use the
ROI passed to find out the region of fetching and calculate the
bandwidth and clock values accordingly.

Change-Id: I01f24f8fd9a42a2c4d705b8eb0a7658e79884175
Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdss_mdp.h
	drivers/video/msm/mdss/mdss_mdp_ctl.c
	drivers/video/msm/mdss/mdss_mdp_overlay.c
	drivers/video/msm/mdss/mdss_mdp_pipe.c
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.

Conflicts:

	Documentation/devicetree/bindings/fb/mdss-mdp.txt
	drivers/video/msm/mdss/mdss_mdp_pipe.c
	include/uapi/linux/msm_mdp.h

Change-Id: Ie566cc12b38f81d111f378f19883433bcc71fa48
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>

Conflicts:
	Documentation/devicetree/bindings/fb/mdss-mdp.txt
msm: mdss: hdmi: hdcp encryption enablement

For hdmi as primary case, enable encryption after
hdcp authentication passes. That is to avoid black
screen before authentication finishes.

Change-Id: I956066369dd7bae5794fe4c2751712293924cf54
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
mdss: display: Add support for variable refresh rate

Add support for variable refresh rate by changing the
VFP immediately and programming it to MDP TG and
DSI registers.

Change-Id: I186e80cf38d42f4224afedadda96cc613ae68470
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm: mdss: hdmi: turn on DDC when turn on hdmi

When HDMI is primary and at display timeout, DDC is turned off.
When resume, there is no hpd interrupt, need turn on DDC
for HDCP and EDID when turning on HDMI.

Change-Id: I2c6a8212261ca1f8dee5c6823670e221b6c83b5c
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm: mdss: Update wr mem fields with correct names

wr mem start and continue were incorrectly named in
the documentation and dtsi files. Changing the names
to wr-mem-start and wr-mem-continue to more accurately
reflect the fields.

Change-Id: If2cdd410fd50a4690dcb6c87cb0b9f4818848848
CRs-Fixed: 578028
Signed-off-by: Casey Piper <cpiper@codeaurora.org>
msm: mdss: Do not program DSI PLL registers from DSI controller

MDSS DSI driver currently programs certain DSI PLL registers as
part of the DSI PHY off sequence. This is incorrect and could
lead to some unexpected errors such as DSI PLL getting turned off
while the branch clocks are still on. Fix this by removing all
such register programming.

Change-Id: Ie1e88cd18de6b8ef8804f7a2b34b8b8282166c96
CRs-Fixed: 509801
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: mdss: dsi-1 as master clock controller at split display case

During split display case, both dsi controllers share the same
dsi pll(dsi0) dsi-0 clock need to be enabled before dsi-1 and disabled
in the reverse order. This mechanism helps using a unified clock control
logic.

Change-Id: I9fe0095b0427c9c2b7fd84c3179bc8364049cce4
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: mdss: Dynamically change writeback path OT

Writeback path when used for WFD is processed at 1px/clk
whereas when used for rotator, it is processed at 4px/clk.
To ensure that writeback during WFD doesn't slow down,
reduce the WB block rotator OT to different number depending
on different target.

Change-Id: I6f37557756d0c8c5037bbd251637ed872d872f74
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>

Conflicts:
	Documentation/devicetree/bindings/fb/mdss-mdp.txt