fuji: merge latest caf changes

* ion: Increase QSECOM heap to 6MB
* Add proper flags for secure/non-secure writeback buffers
* ion: Map everything into IOMMU with 64K pages.
msm: vidc: merge caf
msm: vidc: Adds API to request performance level.

Adds API to request for a particular performance
level from video core. This is needed for Wi-fi
display (WFD) to reduce end to end latency.

Change-Id: Ib4133b8cd62ccad286be1984f944911754b887c5
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit 3c51cb669e9ca03773444f69aa9c7fb6131cb726)

Conflicts:

	drivers/media/video/msm/wfd/enc-subdev.c
	drivers/video/msm/vidc/common/vcd/vcd_client_sm.c
	include/media/msm/vcd_property.h

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: vidc: Use pre-computed frame delta values in WFD use case

In WFD use case with frame skipping enabled, we wish to fool the core
into thinking that that the frames are coming at a consistent rate so
that we don't run into any issues with the core's rate control
mechanism.

The following change introduces a property that the client may set that
dictates what the timestamp delta between any two frames might be.

Change-Id: Iea3f97879227b7932543d3449d311758dc4a2f59
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit 806e8d1cf43de34ad38181a227bbcebb64a5fd9e)
vidc: send flush done if flush is issued in EoS while encoding

There is a race condition in encoder, when an input buffer
is received with an EoS flag but doesn't have an output
buffer to process that and if simultaneously flush is issued.
This is fixed by sending flush done if flush is issued in EoS.

CRs-Fixed: 353081
Change-Id: I925f49779ed5cb91bfab805ba4b7102c1e3f728b
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
vidc: Add extra cases for error handling in vidc init

Currently error conditions are not handled properly
if failures occur during irq request or while creating
work queue. With this commit these error conditions
are properly handled.

Change-Id: I618ca5c2a4f6bd09a3edd164a7867a90a9ed9f9a
CRs-Fixed: 355753
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit c9a9332a743459e44744e630f3e734e7788c477d)
(cherry picked from commit efb9b72a643d6e499e5e5b94c5cc1fe32b652851)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: vidc: Metadata memory release issue.

Metadata memory is not freed when there is
memory allocation failure in ddl open. Fixed
this issue by freeing the metadata memory.

CRs-Fixed: 353109
Change-Id: I3f6fd93498aea0ce78092bd3a28cf08625b0ca77
Signed-off-by: Anil Gahlot <anilg@codeaurora.org>
Signed-off-by: Mohan Kumar Gubbihalli Lachma Naik <mgubbi@codeaurora.org>
(cherry picked from commit af296715bd5db6c38997d1171d079331c8650287)
(cherry picked from commit 572e147402717bb0c77ecc807659d05a617e370f)
vidc: Check for proper buffer handle before free.

Check for proper buffer handle and client handle
before unmapping and freeing the buffer.

CRs-Fixed: 351100
Change-Id: I88f5e142839f12cc19360dbe26a8d4e6a7ec99de
Signed-off-by: Deepak Kotur <dkotur@codeaurora.org>
(cherry picked from commit 974a96c1634659213f7d226fa5092398ddd46398)
(cherry picked from commit 222e467f121840d69ff2701682bc7ece7420a502)

Conflicts:

	drivers/video/msm/vidc/common/dec/vdec.c
	drivers/video/msm/vidc/common/init/vidc_init.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit a46d7d966ce99a55a5806f48de50d407c1dbb77a)
vidc: Caching support for Video Encoder/Decoder.

Added support for cache flushing when the ion
buffers are allocated in cached mode for encoder
and decoder.

Change-Id: Iad44023108de41074eb2ce96bf0d0b89e2533812
Signed-off-by: Arun Menon <menon@codeaurora.org>
vidc: Migrate to ion_map_iommu() API.

Migrate video driver to use the ion_map_iommu() api,
this api provides the physical address if IOMMU is
not enabled.
If IOMMU is enabled in the system it provides the
virtual contigious address.

Change-Id: I0f6f7c50865cb3da88a0ee13425e3973037c846a
Signed-off-by: Arun Menon <menon@codeaurora.org>
vidc: Move shared memory to firmware heap

if smmu is enabled then the memory needs to be
mapped as cached for IOMMU heap, moving the
shared mmeory to firmware heap which does not
require cached mapping

Change-Id: Iac14169b1063bd2784ebf7df433614d68830e84a
Signed-off-by: Arun Menon <menon@codeaurora.org>
vidc: Move metadata shared input mem to firmware heap.

Metadata shared input is used to communicate between
the video code and video driver, hence make this buffer
as uncached and allocate it from firmware heap.

Change-Id: Iabcf6fdbdf6ebcae2fef60b9163a3dfa862624f6
Signed-off-by: Arun Menon <menon@codeaurora.org>
vidc: Migrate to new ION cache ops API

New cache ops API are provided thru ION interface
migrating the in kernel cache ops to use the
new cache ops API.

Change-Id: I18502d343c40fc0f36d979898939f0e601e2f685
Signed-off-by: Arun Menon <menon@codeaurora.org>
vidc: For CP2.0 do not program the iommu.

For CP2.0 do not call the ion_map_iommu api
use the ion_phys api to get the physical address

Change-Id: I67ebc8debf064afb78133afe75aee368b6394178
Signed-off-by: Arun Menon <menon@codeaurora.org>
msm: video: wfd: Fix array out of bounds and stale pointer issue

The following change fixes two issues.  The first being a stale pointer
in which the driver accesses memory that has already been freed.  The
second is an array out of bounds bug, where the venc-subdev iterates
VIDC_MAX_NUM_CLIENTS-times over an array whose size is only
VID_ENC_MAX_ENCODER_CLIENTS.

Change-Id: I35de18fd042181d9358f534908bb785dea630294
CRs-Fixed: 350398
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
(cherry picked from commit a6bde8d3a940446a3dae1124ab60c616938b9c52)

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

Conflicts:

	drivers/media/video/msm/wfd/wfd-ioctl.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: video: wfd: Disable multiple clients for wfd capture device

Explicitly check to see if the device is in use before allowing client
to open either of the wfd capture devices.

Change-Id: I70bd275c5e0f058b7905abe7b7639342d07fe0e2
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
CRs-Fixed: 350398
(cherry picked from commit d22c43a3a2b0448e5cba25950ece2ad3e90e9ec8)

Conflicts:

	drivers/media/video/msm/wfd/wfd-ioctl.c

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

Conflicts:

	drivers/media/video/msm/wfd/wfd-ioctl.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
video: msm: wfd: IOMMU migration

Migrate WFD to IOMMU APIs.  Commit contains following changes:
- Switch from allocate buffer model to use buffer model in order
  to have the flexibility to map buffers into seperate domains.
- Use the ION caching APIs to flush buffers in case they are cached.
  Earlier on, we used uncached buffers, hence we didn't have a need
  to flush.

Change-Id: I959027ee94a5d6074005f1de420c66cbe55db776
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
(cherry picked from commit 0807032a1e6c99cfc365324ec0550a553308092c)
(cherry picked from commit d7dfa4c700df06351c780a08f35167199ccef922)
msm: vidc: Downloads firmware using pil_get.

Downloads video codec firmware using pil_get
for secure sessions only. Firmware is not
downloaded using pil_get for non-secure
sessions.

Conflicts:

	drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c

Change-Id: I84b7a1d70ed1f505838930a192e5d1afdbfc54c1
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
vidc: Adjust core timeout based on current core frequency.

Core timeout value is calculated based on the current core
clock rate during video play back.

Change-Id: I52f38560eda71dd0eaf208da68b4c3f74955661b
CRs-fixed: 354069
Signed-off-by: Mohan Kumar Gubbihalli Lachma Naik <mgubbi@codeaurora.org>

Conflicts:

	drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker_api.h

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
vidc:1080p: Set video core timeout value for Thumbnail mode

Video core timeout value is set only for thumbnail mode.
For normal playback senario default value is set.

CRs-fixed: 367222
Signed-off-by: Mohan Kumar Gubbihalli Lachma Naik <mgubbi@codeaurora.org>
(cherry picked from commit 740d5ad28484b42ae675721a66a1bd93081712c8)
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>

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