MMFMWK-7895 [MX8MQ] Enable Hantro video tiled and compression format.

Work around SetInfo() issue. Set to tiled default.

Signed-off-by: Song Bing <bing.song@nxp.com>
diff --git a/plugins/vpu/gstvpudec.c b/plugins/vpu/gstvpudec.c
index d399daa..c5742a9 100755
--- a/plugins/vpu/gstvpudec.c
+++ b/plugins/vpu/gstvpudec.c
@@ -397,9 +397,9 @@
             else if (IS_HANTRO() && drm_modifier == DRM_FORMAT_MOD_VSI_G2_TILED_COMPRESSED
                 && dec->vpu_dec_object->is_g2 == TRUE)
               dec->vpu_dec_object->drm_modifier = drm_modifier;
-           // else if (IS_HANTRO() && drm_modifier == DRM_FORMAT_MOD_VSI_G1_TILED
-           //     && dec->vpu_dec_object->is_g2 == FALSE)
-           //   dec->vpu_dec_object->drm_modifier = drm_modifier;
+            else if (IS_HANTRO() && drm_modifier == DRM_FORMAT_MOD_VSI_G1_TILED
+                && dec->vpu_dec_object->is_g2 == FALSE)
+              dec->vpu_dec_object->drm_modifier = drm_modifier;
             else {
               GST_WARNING_OBJECT (dec, "video sink can't support modifier: %lld",
                   DRM_FORMAT_MOD_AMPHION_TILED);
@@ -422,10 +422,11 @@
     }
   }
 
-  if (dec->vpu_dec_object->drm_modifier_pre != dec->vpu_dec_object->drm_modifier
-      && (dec->vpu_dec_object->drm_modifier == DRM_FORMAT_MOD_VSI_G1_TILED
-      || dec->vpu_dec_object->drm_modifier == DRM_FORMAT_MOD_VSI_G2_TILED_COMPRESSED)) {
-    int config_param = 1;
+  if (IS_HANTRO() && !dec->vpu_dec_object->implement_config)
+    dec->vpu_dec_object->drm_modifier = 0;
+  //FIXME: handle video track selection.
+  if (IS_HANTRO() && dec->vpu_dec_object->drm_modifier_pre != dec->vpu_dec_object->drm_modifier) {
+    int config_param = 0;
     GstVpuDecObject * vpu_dec_object = dec->vpu_dec_object;
     gint height_align;
     gint width_align;
@@ -436,34 +437,9 @@
     VPU_DecGetInitialInfo(dec->vpu_dec_object->handle, &(dec->vpu_dec_object->init_info));
     dec->vpu_dec_object->frame_size = dec->vpu_dec_object->init_info.nFrameSize;
 
-    width_align = DEFAULT_FRAME_BUFFER_ALIGNMENT_H_HANTRO_TILE;
-    if (vpu_dec_object->init_info.nPicWidth % width_align)
-      vpu_dec_object->video_align.padding_right = width_align \
-                                                  - vpu_dec_object->init_info.nPicWidth % width_align;
-    if (IS_HANTRO() && vpu_dec_object->is_g2 == TRUE)
-      height_align = DEFAULT_FRAME_BUFFER_ALIGNMENT_V_HANTRO;
-    else
-      height_align = DEFAULT_FRAME_BUFFER_ALIGNMENT_V;
-    if (vpu_dec_object->init_info.nInterlace)
-      height_align <<= 1;
-    if (vpu_dec_object->init_info.nPicHeight % height_align)
-      vpu_dec_object->video_align.padding_bottom = height_align \
-                                                   - vpu_dec_object->init_info.nPicHeight % height_align;
-
-    for (i = 0; i < GST_VIDEO_MAX_PLANES; i++)
-      vpu_dec_object->video_align.stride_align[i] = width_align - 1;
-
-    vpu_dec_object->width_paded = vpu_dec_object->init_info.nPicWidth \
-                                  + vpu_dec_object->video_align.padding_right;
-    vpu_dec_object->height_paded = vpu_dec_object->init_info.nPicHeight \
-                                   + vpu_dec_object->video_align.padding_bottom;
-
-    GST_DEBUG_OBJECT (vpu_dec_object, "width: %d height: %d paded width: %d paded height: %d\n", \
-        vpu_dec_object->init_info.nPicWidth, vpu_dec_object->init_info.nPicHeight, \
-        vpu_dec_object->width_paded, vpu_dec_object->height_paded);
-
     dec->vpu_dec_object->drm_modifier_pre = dec->vpu_dec_object->drm_modifier;
   }
+  GST_DEBUG_OBJECT (dec, "used modifier: %lld", dec->vpu_dec_object->drm_modifier);
 
   if (dec->vpu_dec_object->vpu_need_reconfig == FALSE
     && dec->vpu_dec_object->use_my_pool
diff --git a/plugins/vpu/gstvpudecobject.c b/plugins/vpu/gstvpudecobject.c
index b06ed62..545d168 100755
--- a/plugins/vpu/gstvpudecobject.c
+++ b/plugins/vpu/gstvpudecobject.c
@@ -19,6 +19,7 @@
  */
 
 #include <string.h>
+#include <libdrm/drm_fourcc.h>
 #include <gst/video/gstvideometa.h>
 #include <gst/video/gstvideohdr10meta.h>
 #include "gstimxcommon.h"
@@ -515,7 +516,21 @@
 
   open_param->nChromaInterleave = 0;
   open_param->nMapType = 0;
-  open_param->nTiled2LinearEnable = 0;
+  vpu_dec_object->implement_config = FALSE;
+  if ((IS_HANTRO() && (open_param->CodecFormat == VPU_V_HEVC
+        || open_param->CodecFormat == VPU_V_VP9
+        || open_param->CodecFormat == VPU_V_AVC))
+      || IS_AMPHION()) {
+    open_param->nTiled2LinearEnable = 1;
+    vpu_dec_object->implement_config = TRUE;
+    if (open_param->CodecFormat == VPU_V_HEVC
+        || open_param->CodecFormat == VPU_V_VP9)
+      vpu_dec_object->drm_modifier_pre = DRM_FORMAT_MOD_VSI_G2_TILED_COMPRESSED;
+    else
+      vpu_dec_object->drm_modifier_pre = DRM_FORMAT_MOD_VSI_G1_TILED;
+  } else {
+    open_param->nTiled2LinearEnable = 0;
+  }
   open_param->nEnableVideoCompressor = 1;
   vpu_dec_object->output_format_decided = GST_VIDEO_FORMAT_NV12;
   if (open_param->CodecFormat == VPU_V_MJPG) {
diff --git a/plugins/vpu/gstvpudecobject.h b/plugins/vpu/gstvpudecobject.h
index f07714b..8af2975 100755
--- a/plugins/vpu/gstvpudecobject.h
+++ b/plugins/vpu/gstvpudecobject.h
@@ -95,6 +95,7 @@
   gint vpu_hold_buffer;
   guint64 drm_modifier;
   guint64 drm_modifier_pre;
+  gboolean implement_config;
   gboolean use_new_tsm;
   gboolean use_my_pool;
   gboolean use_my_allocator;