msm: vidc: avoid re-initialize of v4l2 spin lock

The fh_lock and fh_list variables are initialized
during probe in video_register_device. This was
re-initialized again when a new video instance was
opened. Since all video instances shared the same
fh_lock and fh_list variable, this gave rise to a race
condition in the v4l2 video driver. Consider the
case of multiple video instances being opened simultaneously.
One video instance has acquired the fh_lock and
calls a v4l2 function which calls v4l2_event_subscribe.
During this time another video instance is opened
and it re-intializes the fh_lock, so the first
instance no longer holds the spin lock and hits
ASSERT in v4l2_event_subscribed. This change
fixes the race condition.

Change-Id: I7af98c8f091cb94e6118c9e2ea1ba5d5d44c6833
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: defer probe if iommu_group_find fails

v4l2 video driver probe needs to defer till
iommu domains probe has been called. Without this
change, v4l2 video driver probe will fail if
iommu domains probe is not invoked prior to it.

Change-Id: Idbc1a4c90e558952f41f51ec96fdd3e7974490cd
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: enable deferred probe support for Q6

Add support to defer probe for Q6 driver. Also fixes
a bug in venus hfi, whereby probe for venus hfi fails
if the core_id is not zero.

Change-Id: I67269107132bf352186fad1e177e4099cf9f4534
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: change interface for opening driver instance

This change will ensure that vidc clients specify the
core id as venus or q6 to open a driver session.
Without this change, sometimes due to driver probe deferral,
core_id_0 would be taken by q6 and vidc clients intending to open a
venus decode session ended up opening a q6 decode session.

Change-Id: I4f9c862b8057999e4db7ca75be493138737a58a8
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: wfd:Wait for one more vsync cycle, if VSG running out of input frames

If VSG running out of input frames, it will re-encode previous frames.
With this change, instead of encoding pervious frame VSG will push timer to
half of capturing frame rate. If it find new frame, it will be encoded
Otherwise will re-encode previous frame.

CRs-Fixed: 571771
Change-Id: Ie1c970b4e251c2165e77134b746c4ee0e3a90fba
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
msm: vidc: Disable clock gating for 8x26

There are stability issue observed on 8x26 with
inter-frame clock gating enabled so disable
interframe clock gating on 8x26.

Change-Id: I0e2b89a0ce36ed4d5f15903ffe68b7c7275719c9
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
msm: vidc: reduce clk frquency before disable

The change ensures that the clock frequency is reduced to min
before we disable it.
With just clk_disable, rpm still votes for high voltage on CX
as venus vote is not removed.
To unvote, the frequency is set to min.

CRs-Fixed: 574365
Change-Id: I8e0515b9816f8c451d545443573afaba611aafe7
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
msm: vidc: fix memory leak issue in dynamic buffer mode

While flushing output buffers held in v4l2 video
driver, i.e, with ref count equal to 2, the driver
was freeing the binfo structure. This would leak
the mapped output buffer memory. By avoiding
freeing of the binfo structure, the driver waits
for the release reference event from the firmware
to free and unmap the output buffer. Also move
initialization of dequeued flag for buffers to be
held in driver, till the time we queue this buffer
to firmware. By not doing so, the video driver can
enter a race condition, whereby, a output buffer could
be unmapped and freed before v4l2 client has called
dequeue on the buffer.

Change-Id: Ic95f13b9f4426574012539a76c0b87bedb8e805a
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: NULL terminate devicetree match table

Without NULL termination, of_dev_lookup() can run
off the end of the array and looking at invalid data.

Change-Id: Ib7d8b3afdc76d3f196d620d47eb77d4e0bc74d53
CRs-fixed: 582111
Signed-off-by: Sachin Shah <sachins@codeaurora.org>
msm: vidc: update max P frames num for encode

Remove the restriction on the max number of
P frame interval.

Change-Id: I637372d7b0d409602df251bad4a135b25514dc95
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: Change tz version for dynamic buffer feature support

Use scm api to check if tz version is atleast 1.1.0. The tz changes
for assigning hint on map rather than the lock call are present
from that version onwards, which is needed for dynamic buffer
feature support.

Change-Id: I8a463c206f610d5d599d392e2502de307bfb95c0
Signed-off-by: Shalaj Jain <shalajj@codeaurora.org>
[media] v4l2: Add VP8 QP min and max controls

The QP range is specific to every codec. These controls enable
VP8 drivers to define the supported range.

Change-Id: I7990aea15034776a33ae54699add244d694bf4ca
CRs-Fixed: 578892
Signed-off-by: Jorge Solano Altamirano <jsolano@codeaurora.org>
msm: vidc: added v4l2 control to set the color of concealed MBs.

The conceal color is set to be green by default, while some users
required it to be black.
Set it to be configurable by adding this v4l2 control.

Change-Id: I25565ee837c011f5875ce91bde23a169fbdb0709
Signed-off-by: Jia Meng <jmeng@codeaurora.org>