Description: Avoid segfailt on unsupported platforms
 Call preinit_hw_codec callback after successful initialization to avoid segment
 fault issue on unsupported platforms.
Origin: upstream,
 http://cgit.freedesktop.org/vaapi/intel-driver/commit/?h=v1.4-branch&id=eb097b1a39b69af76b5575835255cb4653195c1c
Last-Update: 2014-11-10

diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index ba7c7be..e768537 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -5669,9 +5669,6 @@ i965_Init(VADriverContextP ctx)
             break;
     }
 
-    if (i965->codec_info->preinit_hw_codec)
-        i965->codec_info->preinit_hw_codec(ctx, i965->codec_info);
-
     if (i == ARRAY_ELEMS(i965_sub_ops)) {
         switch (i965->intel.device_id) {
 #undef CHIPSET
@@ -5697,6 +5694,9 @@ i965_Init(VADriverContextP ctx)
 
         i965->current_context_id = VA_INVALID_ID;
 
+        if (i965->codec_info && i965->codec_info->preinit_hw_codec)
+            i965->codec_info->preinit_hw_codec(ctx, i965->codec_info);
+
         return VA_STATUS_SUCCESS;
     } else {
         i--;
