H264_Encoding: Fix the incorrect Qp setting under CBR when slice_header is passed

Fix the issue in
https://bugs.freedesktop.org/show_bug.cgi?id=83143

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Tested-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
(cherry picked from commit eca8e0065e3a04156e0817d3a5ac14f4df39d603)

Conflicts:

	src/gen6_mfc.c
	src/gen8_mfc.c
Move gen6 phantom slice function as common

Following haihao's suggestion, make gen6 phantom slice funcion can be
re-used by SNB+.

v1->v2: Remove an unnessary comment.

Signed-off-by: Zhong Li <zhong.li@intel.com>
Reviewed-by: Xiang Haihao <haihao.xiang@intel.com>
             Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit 5e30cc3093407ca2b4dbefa1da8a1262ff8ae7e9)
Add phantom slice support on IVB+

HW requires driver to add a phantom slice when FirstMbX and FirstMbY are
not 0, in order to avc decoding error concealment. Otherwise, GPU may hang.
This patch is a workround for bug: https://bugs.freedesktop.org/show_bug.cgi?id=81447

v1->v2: Follow haihao's suggestion to use common funcion of gen6 phantom slice.
v2->v3: Remove an extraneous newline.

Signed-off-by: Zhong Li <zhong.li@intel.com>
Reviewed-by: Xiang Haihao <haihao.xiang@intel.com>
             Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit 9672c5ab17c32f25ce1bbdb883abda689440b116)
Add multi quality levels encoding support for GEN7

Two encoding quality levels are support on GEN7.
Default quality level is set to be 1, which has better quality,
but higher gpu usage.
The second quality level is set to be 2, which has worse quality but
it has lower gpu usage.

Other platforms support for multi-quality-level will be added later.

v1->v2: 1. follow haihao's comments to init and check quality_level.
        2. remove CBR limitation for low quality level.

(Zhao Yakui helps to merge several patches on staging so that it can
be cherry-picked to master)

Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Enabling SNB avc encoding configuration

Signed-off-by: Zhong Li <zhong.li@intel.com>
(cherry picked from commit 3e531e7d640ef329151b2205c2e61a67fb80862d)
Enabling HSW avc encoding configuration

Signed-off-by: Zhong Li <zhong.li@intel.com>
(cherry picked from commit 1239853edc9c344a823d788c6df57da82eda25bf)
Enabling BDW avc encoding configuration

Signed-off-by: Zhong Li <zhong.li@intel.com>
(cherry picked from commit 739eb9c0c954eecaf17a24be336ca5054241a338)
Remove gen7 only limitation for encoding configuration

Since all generations from gen6 can support avc encoding configuration,
remove gen7 only limitation.
MVC also can be support with little change, but it is low priority,
it will be support when necessary and this function is stable.

Signed-off-by: Zhong Li <zhong.li@intel.com>
(cherry picked from commit f2178e267a67bdecab0a30502804c2ce5bccd0c2)
Add support for new VA buffer export APIs.

Implement va{Acquire,Release}BufferHandle() hooks so that to allow
VA surface or VA image buffer sharing with thirdparty APIs like EGL,
OpenCL, etc.

v2: made sure to sync bo before export, improved VA buffer type check.
v3: tracked internal resources on acquire, disposed them on release.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit 483bb130925182f2096cd9e6fa5dbae6a55e7764)
initial export_refcount for obj_buffer
(cherry picked from commit 11d01d01ce7ceedf19c74bdd8a07961b0fd8dd9b)
Factor out va{Get,Put}Image() implementations.

Use VA internal objects wherever possible for internal functions,
thus leaving VA object ids to the base interface implementation.
Robustify params validation earlier in there too.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit 78ad786967144c2947ac36eac9ee39b0c94778ef)
Report BUSY surface state accordingly.

Return VA_STATUS_ERROR_SURFACE_BUSY for key interfaces.

This covers for va{Get,Put}Image(), as originally mandated by the
VA-API specs; vaBeginPicture() as this is the entry-point to any
decode, encode or video processing operation; but also for plain
vaMapBuffer() operation.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit 62bfb507c8512af6529ee794848155bd7cd97fc6)
vpp: expose BGRA surface formats on Ivybridge and Haswell.

Allow for vaQuerySurfaceAttributes() to return BGRA and BGRX formats
for VPP on Ivybridge and Haswell. This is supported as both source
and target surface formats.

This fixes VA/EGL interop on Gen7 processors when a BGR[AX] surface
is exported into an EGLImage.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
i965_drv_video: factor out and robustify vendor string.

Move out generation of the vendor string to its specific helper function,
while also making it more robust and aware of possible overflows.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
i965_drv_video: add git commit id to VA driver version string.

v2: renamed i965_drv_version.h to intel_version.h, changed macro
  definition to INTEL_DRIVER_GIT_VERSION, and displayed the git
  version string only in "pre" version modes.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
build: fix make dist for packaging.

If the intel-gen4asm tool is not available, ship with the pre-built
EU kernels instead of trying to regenerate them. In particular, just
don't expose the build rules if intel-gen4asm is not installed.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Add one callback function for hw_codec_info to initialize hw_codec_info

V1->V2: Refine the call back function name from hw_codec_hook to preinit_hw_codec
And it is called after VADriverContext is fully initialized. This is based on the comment
from Gwenole Beauchesne.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit 33e62fda870dc5c9b482fb6a23260da9ae465806)
change the attribute of hw_codec_info so that it can be updated dynamically

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit 065db8289d3f38a923959f87d1b75767a0633e61)
Encoding: Add one hook callback function to detect encoding capabilitiy on Haswell

Some Haswell machine doesn't support the encoding. So it should be disabled.
Otherwise the driver can't report the supported capability correctly.

V1->V2: Minor update based on comment from Gwenole Beauchesne. For example:
use the bool tye and remove the hardcoded value

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit 23ae0f76ee5b3c097e6ae34182219cf44b09b82e)
Use the strncasecmp instead of strcasecmp to make it more robust

At the same time the extra string arrary is removed.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit 05ece0c3698f4f48c4141e8bd0608b9869d8ad0c)