Load different video drivers according to video codecs

BZ: 98522

On the baytrail platform, there are two video decoder hardwares.
The Intel GEN will handle H264 and VC1 decode and VXD will
handle MPEG4, H263 and VP8 decode. GEN uses i965 driver and
VxD uses pvr driver. We have to load different drivers according
to the codec type of the video.

Use setenv before vaInitialize and unsetenv after it can work.
But there is one problem for thumbnail generation case,
multiple threads will call setenv/unsetenv. One thread just call set
env to pvr, but another thread maybe call set env to i915,
which will lead to previous thread didn't load correct library.

The solution here is to pass driver name through vaDisplay
in function vaGetDisplay, change vaDisplay from type unsigned int
to char * and set driver name to vaDisplay.
Take pvr_drv_video for example, need set vaDisplay=

Change-Id: I671fb8817e2f76eb8f4baaf8d63cdbc75ba90f77
Signed-off-by: Fei Jiang <fei.jiang@intel.com>
Reviewed-on: http://android.intel.com:8080/102308
Reviewed-by: Shi, PingX <pingx.shi@intel.com>
Tested-by: Shi, PingX <pingx.shi@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/videodecoder/VideoDecoderBase.cpp b/videodecoder/VideoDecoderBase.cpp
index bd9ffd4..b1e9541 100755
--- a/videodecoder/VideoDecoderBase.cpp
+++ b/videodecoder/VideoDecoderBase.cpp
@@ -739,29 +739,29 @@
     // Display is defined as "unsigned int"
     mDisplay = new Display;
+    if (profile >= VAProfileH264Baseline && profile <= VAProfileVC1Advanced) {
+        ITRACE("Using GEN driver");
+        mDisplay = "libva_driver_name=i965";
+    }
+    else {
+        ITRACE("Using PVR driver");
+        mDisplay = "libva_driver_name=pvr";
+    }
     mVADisplay = vaGetDisplay(mDisplay);
     if (mVADisplay == NULL) {
         ETRACE("vaGetDisplay failed.");
         return DECODE_DRIVER_FAIL;
-    ITRACE("load pvr driver.\n");
-    setenv("LIBVA_DRIVER_NAME", "pvr", 1);
     int majorVersion, minorVersion;
     vaStatus = vaInitialize(mVADisplay, &majorVersion, &minorVersion);
-    unsetenv("LIBVA_DRIVER_NAME");
     if (mConfigBuffer.frameRate > 45 && mVideoFormatInfo.height >= 1080) {
         // ugly workaround here
         // for fps > 45 and height > 1080, we will force to
@@ -943,7 +943,9 @@
     if (mDisplay) {
         delete mDisplay;
         mDisplay = NULL;
diff --git a/videodecoder/VideoDecoderBase.h b/videodecoder/VideoDecoderBase.h
index 048da3c..a1ad265 100644
--- a/videodecoder/VideoDecoderBase.h
+++ b/videodecoder/VideoDecoderBase.h
@@ -37,8 +37,12 @@
 #ifndef Display
+typedef char Display;
 typedef unsigned int Display;
 // TODO: check what is the best number. Must be at least 2 to support one backward reference frame.
 // Currently set to 8 to support 7 backward reference frames. This value is used for AVC frame reordering only.