Revert "msm: vidc: add set ctrl for Dynamic Buffer mode"

This reverts commit 2f85590d46596be568fc67cbb3e9be6807d04252.
Revert "msm: vidc: read Dynamic Buffer mode capabilities"

This reverts commit f49b538601dc2b350cca6e036b414315b9ced4a8.
msm: vidc: read dynamic buffer mode capabilities

During session_init_done firmware will inform if
it supports dynamic buffer mode for output buffers.

Change-Id: I6b29f881f44c89b3821e68aff10511644771a6d1
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: Add support for V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB

V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB is the V4L2 standard version
of the vendor extension V4L2_CID_MPEG_VIDC_VIDEO_CIR_MBS. Driver needs
to support both versions as some of the clients use the standard
control.

Change-Id: Ib05f75f9c8eaa64dd08a548b71d1d2387aace9aa
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
msm: vidc: Add a control to disable the bit stream restrict flag

HFI_PROPERTY_PARAM_VENC_H264_VUI_BITSTREAM_RESTRC is set to true by
default in firmware, generating VUI which some decoders don't support.
This change provides an option to turn off the bitstream restrict
flag which, when used in conjunction with other VUI-related controls
being disabled, will prevent the encoder from generating VUI entirely.

Change-Id: Idb00d942bdd82b80001f9fda47a84aee231e4bdd
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

Conflicts:
	drivers/media/platform/msm/vidc/vidc_hfi_api.h
msm: vidc: Add control to preserve text quality

V4L2_CID_MPEG_VIDC_VIDEO_PRESERVE_TEXT_QUALITY allows the client to
tell the encoder to preserve the text quality whenever a given frame
contains text elements.  This reduces the amount of artifacts around the
text in the encoded frame.

Change-Id: If75ea580adaedc896d8a31410a194076f38b5179
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
msm: vidc: add set ctrl for dynamic buffer mode

set ctrl for dynamic buffer mode

Change-Id: Iafb9541bd185a474b169dfe17a5a278b930bdad6
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: move buffer handling inside msm_vidc

Dynamic buffer mode support will require buffer
handling support in vidc layer, rather than v4l2
layer.

Change-Id: I4732a09afc6b9dc279d7dbf28e362bf400e09cc9
Signed-off-by: Arun Menon <avmenon@codeaurora.org>

Conflicts:
	drivers/media/platform/msm/vidc/msm_v4l2_vidc.c
msm: vidc: cleanup vidc function to register o/p buf

This change modularizes map_and_register_buf function
used to add o/p buffer to registered buffer list.

Change-Id: I73c1d4b5c66f75fe4b1bce2c2bfc2277a6157e0a
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Revert "HAX: Match videodev headers to AOSP userspace"

This reverts commit 6d9a372698c123e3254734f405db936089ce21d0.
msm: vidc: dynamic buffer mode changes

Changes for dynamic buffer mode in prepare_buf, qbuf
and dqbuf.

Change-Id: I91aaf80f0177bcf2e18d3d26b41f5ea131334579
Signed-off-by: Arun Menon <avmenon@codeaurora.org>

Conflicts:
	include/linux/videodev2.h
msm: vidc: support for dynamic buffer mode

Includes changes to process release_frame_reference event
from firmware.

Change-Id: Ie3c014af255e09f6dac9b3b853c9994b97d830b6
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: flush dynamic buffers held in driver

A dynamic buffer whose reference is pending
with f/w and queued back by client, will be
held in the driver. During flush, f/w will
release the reference, but driver should not
queue back the buffer to f/w.

Change-Id: If6fea08645a186691d49beaaf7a51a75f4b3121e
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: add debugfs support for dynamic buffer mode

video driver debugfs will provide the following info
(a) buffer mode for each buffer type
(b) list of pending output dynamic buffers with
firmware and driver along with their ref count, fd
and address.

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

Query TZ before returning to video hal whether dynamic buffer
mode is supported or not for secure playback.

Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: Shalaj Jain <shalajj@codeaurora.org>
msm: vidc: send extradata size in ftb for dynamic buffer mode

In dynamic buffer mode, since  set_buffers is not called,
extradata buffer size should be set during ftb.
Without this change, firmware will assert if extra data
is enabled.

Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: fix setting of client buffer count

The client requested buffer count was not honoured
in specific case - when requested buffer count
was less than actual buffer count, but greater than
min buffer count. It would be set to the min buffer
count, which would fail playback.

Bug: 11067227

Signed-off-by: Arun Menon <avmenon@codeaurora.org>

Conflicts:
	drivers/media/platform/msm/vidc/msm_vdec.c
msm: vidc: Remove frame size setting on OUTPUT Port

Currently driver sets frame size to FW on both INPUT and OUTPUT ports.
1.4 FW version doesn't support frame size setting on OUTPUT port.
FW uses the size set on INPUT port for decoding. Hence removing
the frame size setting to FW.

Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: flush dynamic output buffers in reconfig

In dynamic buffer mode, if driver receives a
flush during reconfig, it should release all
buffers held in the kernel and not queued to
firmware. Without this change, the buffers held in
the kernel do not get flushed and video client
hangs waiting for release of output buffer

Bug: 10935330

Signed-off-by: Arun Menon <avmenon@codeaurora.org>
msm: vidc: fix a race condition in dynamic buffer handling

Fixes a race condition while ftb is queued to the driver
and release reference event for the same has been returned
from the firmware. Without this change, we would end up
having a buffer which is registered in the list but not
queued to firmware. As a result during flush this buffer is
not returned back to client after a flush and results in
video freeze.

b/11021131

Signed-off-by: Arun Menon <avmenon@codeaurora.org>