gpu: ion: Add support for IOMMU in CP heap

ION clients allocating from a content protection
heap (cp heap) must be able to map the memory to
an IOMMU when IOMMU are being used.

Add callbacks to CP heap to support IOMMU mapping.

(cherry picked from commit 1c94f7be2d3fcd48978bd5276532beec184f5d74)

Change-Id: I81e726e98b8cc4b12fe8f4734c0da18a15968aee
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit c8652e6b9a8e477513cf1f10563182a400b7cc65)
gpu: ion: Do not allow cached IOMMU mappings.

Cached IOMMU mapping is not supported.

Add check for clients trying to map buffers
into IOMMU as cached and return error.

(cherry picked from commit 79e9ffa55afdf664990b2765de297f3d95e59612)

Change-Id: I92bde98a816afb2c3b231e91902b4443774c2b85
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 82836cc1818a9a428e5acfbb4f9b62f5892f75fe)
gpu: ion: Lower IOMMU heap priority

Video requires the IOMMU heap to be at a lower
priority so that video can try to allocate from
its MM carveout heap first and then if video needs
more memory and the MM heap is exhausted it will
automatically fall back on IOMMU heap.

Change the priority of the IOMMU heap so video
can fall back on IOMMU heap.

(cherry picked from commit 9e123f98ea133518adb5b1f4a53ccaa1c07cb568)

Change-Id: I696c292b0ad9d6b140247f32e2e22d72c5fd0000
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 1c94ada9be7922d8770c92cd79217ebf005fbf27)
(cherry picked from commit cb1cf4a5f754932b9c8e19eeaf90114a2b35c51b)
gpu: ion: Add missing argument to iommu map func

There exists one definition for ion_map_iommu
function when ION is enabled and one definition when
ION is disabled. The argument list for the definition used
when ION is disabled is missing the buffer_size argument causing
compilation error for targets that call this function without
ION enabled.

Add buffer_size argument to ion_map_iommu function
for targets that does not have ION enabled.

(cherry picked from commit 9a27d4c55b862eecc1c5eacb7fc0185957b851a0)

Change-Id: I135f748ef61ece79c2c61c1e1e2478bb7174c61c
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 70371b7cf9d0b280178c26dfbd95e649d2fbfdb9)
gpu: ion: Add API to do cache operations

Clients need to be able to do cache operations
on ION buffers in the kernel. Add API to
flush, invalidate, or invalidate and flush the
cache of an ION buffer.

(cherry picked from commit 41f8579a79c1a6513577465cd376fb5b1bf4cab2)

Change-Id: I9a00fec1bd891f730b448d06f10be07bd79b3011
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 74c2772e4e6b4ed695cd5b69c024c86a2bdcdd88)
gpu: ion: Allow smaller mappings

Clients using ION must be able to mmap a smaller
set of pages than what was allocated from the
IOMMU heap.

Add check that we don't try to map a page passed
the end of the vma.

(cherry picked from commit dbec7db15ddbf7d9b529077ffa61b9b2c30b33a0)

Change-Id: Iaf63a1099510ec4cdbcd294762b451037fe7784a
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 9c2eabefcb4e745b0c8f3bd90ee5fed742fc0e93)
(cherry picked from commit d2d1934c322f18e59e83eb501e8ad22f8e6ba648)
gpu: ion: Add cache operations to IOMMU heap

The IOMMU heap must support cache operations so that clients
can do cached allocations from the heap.

Add function to perform cache operations on memory
allocated from IOMMU heap.

(cherry picked from commit ef0107124e052b86ce883ee6b0c1488d26de0775)

Change-Id: I59a6c6949432cc783b4bd3d7bd212da35bfe73ff
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 398f5c2d05c5eb8a004bc9a3489e586b345b3d4e)
gpu: ion: Add map_dma support in IOMMU heap

IOMMU is missing support for ion_map_dma.
ION clients need support for this api.

Add functions to implement ion_map_dma and
ion_unmap_dma in the IOMMU heap.

(cherry picked from commit ab804b883a58c44df40e92940ac4dae3a91e7beb)

Change-Id: I2f2664b07d7a8c42ff8c915fa23ce159a84899ed
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit c78083f5a1e505325e3e355b36def763a5cd05c4)
gpu: ion: Delay unmapping from IOMMU.

Due to limitations in the multimedia architecure
clients might not know when a buffer can be unmapped
from the IOMMU. In addition, the multimedia architecture
causes unnecessary mappings/unmappings for the same buffers
which reduces framerates.

Add logic to delay unmapping from the IOMMU
until buffer memory is freed and unmap any outstanding
mappings to avoid virtual memory address space leak.

(cherry picked from commit b36765960a60150af1c0faea0e0535123d40f90e)

Change-Id: Ic19d79328c48ea5a22bc7ac7f0bd6c54fb9de543
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit d480e12d368915922b4f3d0b2dcd7d1852f2556a)
msm: Add new partition for IOMMU video domain

Video hardware requires its firmware address to be lower
than the the other addresses that it accesses. In addition
secure playback requires the end of the firmware address
range to be adjacent to the main memory used by the video
hardware.

Add a new partition and rename partitions to appropriate names
to enforce the order of the memory regions.

(cherry picked from commit ee365366b99d0f5f51ff27f9fe7637a792042417)

Change-Id: Ide78cddb45373b456d5efdc2b7c7fe65fd20b29d
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 3cbb57653580cd5dc30100cb6203c7d0e5c3141f)
msm: Define 4 domains for IOMMU

Define one domain each for video, camera,
display, and rotator. Having separate domains
makes programming the IOMMU by the different subsystems
more efficient.

(cherry picked from commit ab77b1b6341e20760ada76e1735614d64594bb0b)

Change-Id: I98aafb6f6ef578599f2745fccf21e0c94077a865
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 15e8a68f711f0091f0e9655135298a3c9fbfeac5)
msm: vidc: Remove duplicate header files

- Updated the header files in /include/media/msm to mirror the
  header files in drivers/video/msm/vidc/common/.
- Deleting header files in drivers/video/msm/vidc/common/ as we
  wish to use headers in /include/media/msm going forward.

Change-Id: I58f64e6168d3cc101394414400dd79b82c429ae4
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
(cherry picked from commit 3a7774b2d5e1b3e6967bc2456be77402cd51b239)

Conflicts:

	drivers/video/msm/vidc/common/init/vidc_init.h
	drivers/video/msm/vidc/common/vcd/vcd_api.h

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:
	drivers/video/msm/vidc/common/init/vidc_init.h
	drivers/video/msm/vidc/common/vcd/vcd_api.h
video: msm: Adding CSC support for other MDP blocks

Adding support for VG1, VG2, DMA_S and Overlay Mixer 1.

Change-Id: I95a5832a70fd893970e82dadcec1e11ed608d79c
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit fa1de67dbadc084aa9fd6afa5ab4fae335089334)
msm_fb: Add support for Polynomial Color Correction (PCC)

Add support for programming Polynomial Color Correction (PCC)
parameters on MDP. PCC is used for enhancing colors on display panel by
programming the display panel calibration parameters

Tested using fbtest and dummy calibration data

Change-Id: I57dae828365f02d560e932ed0f26aa76c819fd31
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
(cherry picked from commit 85153bdf335804c526746ab8d930087b658f3d50)

Conflicts:
	drivers/video/msm/mdp4_util.c
msm_fb: Add support for Area Reduced Gamma Correction (AR GC)

Provide API for programming Area Reduced Gamma Correction parameters.
AR GC is used for adjusting panel gamma behavior for R, G and B channels.

Tested using dummy AR-GC data from panel calibration and fbtest

Change-Id: I64e9f81510160ffaacb6927de1812dfd2a3e5436
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
(cherry picked from commit c7a7cc6dc79a6f60b0468efd0fb3964b1ebc7a70)

Conflicts:
	drivers/video/msm/mdp4_util.c
	drivers/video/msm/msm_fb.c
video:msm: Add support for updating Histogram LUT using MDP_PP ioctl

This adds the ability to write to the Histogram LUTs in the VG pipes, DMA_P
and DMA_S.

Change-Id: I548140d01aee5c2fd437aa218a307b4d1364dade
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 330b4ae84d423bee684af24a2e52b4d81831a37f)

Conflicts:
	drivers/video/msm/mdp.h
video:msm: Add IGC LUT functionality to PP IOCTL

This patch adds the functionality to write to the IGC Look Up
Tables (LUTs) in the MDP.

Change-Id: I4789820a56748b1a5e33ee4ca979e418170695a3
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit acde4b6510b352b97ca1dc7d3386c6696e8f10fb)

Conflicts:

	drivers/video/msm/mdp4_overlay.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mdp4_util.c
msm_fb: display: change perf level for 720p landscape video

New perf level 3 (128M mdp clk) is used to play 720p landscape video,
changed from previous perf level 2 (160M mdp clk), to save power.

Change-Id: Ie27de4d2e407513eeb4cfb8fba6dd535a45c1364
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
(cherry picked from commit e063a05cb7b869853ac7968c29acc0891b0d70f9)

Conflicts:
	drivers/video/msm/mdp4_overlay.c
msm_fb: display: fix underrun seen with big src coordinates

MDP underrun happens if combination of x + w or y + h exceeds 2048.
To handle such use cases add an offset to the source address instead.

Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
(cherry picked from commit fa559f6cb6c9a75beb48b594f952ccfe213c4234)

Conflicts:

	drivers/video/msm/mdp4_overlay.c

Change-Id: I41390def2f2d9a647707da86a3aee7362a127f8b
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm_fb: display: perform staging updates on a single vsync

Store all staging updates locally and write to hw on a single vsync
only when changes are detected, this allows a smooth transition
from using multiple overlays to framebuffer for UI

Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
(cherry picked from commit 94c8a2c7f32371057f094cac19aa1bb905e714f6)

Conflicts:

	drivers/video/msm/mdp4_overlay_dtv.c

Change-Id: I9deeaacfaafcf37f4feca0f537aff179b91fb988
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mdp4_overlay_dsi_video.c