vidc:vdec: Clean extradata portion and invalidate whole buffer

This commit will ensure to clean the extradata portion in
output buffer changed by the CPU before sending the buffer
to Video hardware and invalidate the output buffer changed
by Video hardware before CPU access the buffer.

CRs-fixed: 366446
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
(cherry picked from commit ddd20e2ff4e5d2d4f11d9ad54d40175d35f724e7)

Change-Id: I85e6a287c4065b8cafdbabbb2e5d7f2e6d133ffe
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>

Conflicts:
	drivers/video/msm/vidc/common/dec/vdec.c
vidc: Move prediction scratch buffer to FW Heap.

The encoded output was corrupted for wvga and lower resolutions
during HFR. Moving the prediction scratch buffer from MM Heap to
FW Heap avoids this corruption.

CRs-Fixed: 353979
Signed-off-by: Arun Menon <menon@codeaurora.org>
(cherry picked from commit bf5fc96913ab970df5c060ec2c1937fe06c99295)

Change-Id: I5e053358c6dccf8c51fb6eef5dbd136a7507c943
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
vidc: Adjust core timeout based on input frame size

Video core is dropping certain IDR frames due to timeout.
This is resulting in video corruption. Computing the core
timeout based on input frame size and programming it for
each input frame fixes the issue.

CRs-fixed: 370570
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit 6084636fbf190de0add7a0fb192a26f695fbe402)

Change-Id: I3a973c19bafddea0afd34b0cf91004fd0f0016f5
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm:vidc: force constrained baseline profile for H264 BP encoding

Core is returning improper header information for H264 128kbps,
level-1b and baseline profile settings. Forcing the setting to
constrained baseline profile for normal baseline profile as
per the updated interface specification resolves the issue.

Change-Id: Ib106b17be9453cfd80264cc2167dda919893b1e2
CRs-Fixed: 371606
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit 2ed59cf2dac9f34d07e3e6870bf3d30076386aa7)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
vidc:1080p: Add check for supported video resolution

1080p core can support max resolution upto 1920x1280.
Some of the video clips have a resolution more than
the supported resolution. Changes were made to check
for the supported resolution and stop the playback if
they exceed

Change-Id: Ia3fa9c38eef60d23644e54873849d528377ff722
CRs-Fixed: 362228
Signed-off-by: Mohan Kumar Gubbihalli Lachma Naik <mgubbi@codeaurora.org>
(cherry picked from commit 302441aef1b949312ff05573c83645ef86f29594)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm: vidc: Use MM heap for prediction buffer during secure encode

We are incorrectly using the firmware heap to allocate prediction
buffers.  This violates an agreement between TZ and HLOS that only the
firmware will reside in the FW heap.  As such, move the buffer to MM
heap.

Change-Id: I2c91499c38043abfa21ae3443d3a8f22d6474eaa
CRs-fixed: 380161
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
vidc: 1080p: Handle flush for interlaced clips.

Video core expects one field per buffer for interlaced
clip playback.If a flush is issued we should reset the
need next field flag, so that new bitstream is processed
after flush is completed.
Reconfig flag shouldn't be reset in case of EOS.

Change-Id: Idf50a24c29e904a958b0b1e850813e2d9fc4346d
CRs-fixed: 382368
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
(cherry picked from commit f19f4d27088015842f9bd0945f62b34e90fd784d)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm: vidc: Correct calculation of yuv buffer size

Improper yuv buffer size is being calculated using frame
height directly, which is resulting into failures during
encoding if the frame height is not aligned to 16.
With this change, yuv buffer size calculation is done
properly by using scanlines in place of frame height.

CRs-Fixed: 378988
Signed-off-by: Deepak Verma <dverma@codeaurora.org>
(cherry picked from commit 3a2945ef2385ae934ab4df98f26651d132b7b4fc)

Change-Id: I4fec6befa7827c64eb3c528ea11d61937c12ed5f
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: vidc: error handling for ion_map_iommu calls.

Added a check for non-zero virtual address.
Without this change, when ion_map_iommu returns a
zero virtual address, video core continuous ahead
without error check and later target reset happens
when trying to do a ion_unmap_iommu on the above fd,
which was never mapped.

Change-Id: I7a90de0e3eb6cb53f0bb2af4a496b86a7d0b0719
Signed-off-by: Arun Menon <menon@codeaurora.org>
vidc: 1080p: Copy input frame tag to the output frame tag

In slice delivery mode, sometimes video hardware is giving
zero frame tag on output slices instead of input frame tag
value. This commit will fix the issue by copying the input
frame tag value to the output slice frame tag when video
hardware gives zero frame tag values.

Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
(cherry picked from commit 7baf72acea6d6409eac18713ab9c66f418ce5aa4)

Change-Id: Ica23a463771c9a9f84ae163db743fe5af4f4b82a
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
vidc: fix wrong number of slices in slice delivery mode

The slices completed is not matching with the expected number
of slices in frame done. The fix is available in July firmware
release and this commit will have the corresponding video driver
changes.

CRs-fixed: 380629
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
(cherry picked from commit 909aebf7bd4d89fb5acccd64b27349cf93a736e0)

Change-Id: I7bd0cc4a381039d892ce884189a2e76462f89a19
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm:vdec: Correct filled length of the output buffer

Filled length of the output buffer at FBD for videos
with frame height less than 96 was incorrect. With
this change, we get the proper filled length.

CRs-fixed: 395179
Signed-off-by: Deepak Verma <dverma@codeaurora.org>
(cherry picked from commit f01274b904a4899b13c64f35f2479a1080bfb2c4)

Change-Id: I20a8e63f3ff2efa297bf6cb5f99e1784232c0f43
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>

Conflicts:
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_properties.c
msm: vidc: suppress non-fatal error messages.

These messages are non-fatal and appear frequently
during video session. Hence suppressing them.

Change-Id: I6f8028f75037e72ebe28dc79151b1e9b4a236d98
CRs-Fixed: 389408
Signed-off-by: Arun Menon <menon@codeaurora.org>

Conflicts:
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c
vidc: Handle EOS with Codec config buffer.

Change will handle codec config buffer with EOS.
Video driver will make sure that the codec config buffer with
EOS will be requeued in case of reconfig and non-reconfig paths.

CRs-fixed: 399347
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
(cherry picked from commit 43b203869814fe5f0ddcb265a8f859aebdaa652f)

Change-Id: Iab4fc0f0a0fb370f052ea1f6eb9900c31b80d8dc
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: vidc: Reset data corrupt flag for non-H264 decoder

Core does not set display correctness flag on decoder
output buffers for non H264 video codec. With this change,
we reset the data corrupt flag for non-H264 codec.

CRs-Fixed: 397599
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit fde67e239d8ac3a1e983b7d82d0c37af47464138)

Change-Id: I961413acda5b772879de6bc26d0d6d4d60eafcd5
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
vidc: 1080p: Reset meta data offset to zero

For multi-resolution clips, the meta data offset used while
doing cache clean of meta data buffer is from the previous
resolution & resulting in kernel panic. Resetting the offset
to zero during meta data buffer initialization for new
resolution fixes the issue.

CRs-fixed: 386245
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit 16145bcbd6af8db0eebc0eedec1f01ee1b0b3635)

Change-Id: I0f241ce99df62f02c2440fe3700a70d6c13b1537
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Vidc: Treat Non-IDR frame type error as bit stream error

Hardware error is being generated from driver when video
core returns NON IDR frame type error during thumbnail
decoding. This change handles this error by treating
it as BIT_STREAM_ERR.

(cherry picked from commit df2e15c49775f68d0af4db030e59e070663e02ff)

Change-Id: I90eea1faf10b187493d33233fd268f25e10de57c
CRs-fixed: 414858
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
msm: vidc: Correct the decoder profile info assignment

Update the profile info in the sequence header with the
info which the core returns in the shared memory register.

(cherry picked from commit 5a60819aeb698b9d27937329bb5559a7a787a06e)

Change-Id: I13d88bdb59e7c712540452919a24ca599fe37dff
CRs-fixed: 408349
Signed-off-by: Shobhit Pandey <cshopan@codeaurora.org>
vidc: skip meta buffer header initialization in secure session

Accessing meta buffer allocated from secure heap causes EBI errors due to
permissions. Meta buffer header initialization not required in secure
session, skip to initialize.

(cherry picked from commit ad602ee37a66d0dd2e23991fbc6a65f3cb296c12)

Change-Id: I7f05af72bf637e97bc929ed8494717444cca5a4b
CRs-Fixed: 418217
Signed-off-by: Riaz Ur Rahaman <riazr@codeaurora.org>