Limit the minimum pitch for linear surface
authorXiang, Haihao <haihao.xiang@intel.com>
Fri, 9 May 2014 08:16:05 +0000 (16:16 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Mon, 26 May 2014 04:17:17 +0000 (12:17 +0800)
pitch must be 64 at least for linear surface for most functions on IVB/HSW/BDW
such VEBOX, Data port media read/write

https://bugs.freedesktop.org/show_bug.cgi?id=72522

Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
(cherry picked from commit 57db5c2524f4e3cb6ae2301bddfdf1c40cdbb626)

src/i965_device_info.c
src/i965_drv_video.c
src/i965_drv_video.h

index f040592..f7ce226 100644 (file)
@@ -40,6 +40,8 @@ static const struct hw_codec_info g4x_hw_codec_info = {
 
     .max_width = 2048,
     .max_height = 2048,
+    .min_linear_wpitch = 16,
+    .min_linear_hpitch = 16,
 
     .has_mpeg2_decoding = 1,
 
@@ -58,6 +60,8 @@ static const struct hw_codec_info ilk_hw_codec_info = {
 
     .max_width = 2048,
     .max_height = 2048,
+    .min_linear_wpitch = 16,
+    .min_linear_hpitch = 16,
 
     .has_mpeg2_decoding = 1,
     .has_h264_decoding = 1,
@@ -78,6 +82,8 @@ static const struct hw_codec_info snb_hw_codec_info = {
 
     .max_width = 2048,
     .max_height = 2048,
+    .min_linear_wpitch = 16,
+    .min_linear_hpitch = 16,
 
     .has_mpeg2_decoding = 1,
     .has_h264_decoding = 1,
@@ -106,6 +112,8 @@ static const struct hw_codec_info ivb_hw_codec_info = {
 
     .max_width = 4096,
     .max_height = 4096,
+    .min_linear_wpitch = 64,
+    .min_linear_hpitch = 16,
 
     .has_mpeg2_decoding = 1,
     .has_mpeg2_encoding = 1,
@@ -138,6 +146,8 @@ static const struct hw_codec_info hsw_hw_codec_info = {
 
     .max_width = 4096,
     .max_height = 4096,
+    .min_linear_wpitch = 64,
+    .min_linear_hpitch = 16,
 
     .has_mpeg2_decoding = 1,
     .has_mpeg2_encoding = 1,
@@ -174,6 +184,8 @@ static const struct hw_codec_info bdw_hw_codec_info = {
 
     .max_width = 4096,
     .max_height = 4096,
+    .min_linear_wpitch = 64,
+    .min_linear_hpitch = 16,
 
     .has_mpeg2_decoding = 1,
     .has_mpeg2_encoding = 1,
index 96ca997..bf15208 100755 (executable)
@@ -955,8 +955,10 @@ i965_CreateSurfaces2(
            obj_surface->obj_subpic[j] = NULL;
         }
 
-        obj_surface->width = ALIGN(width, 16);
-        obj_surface->height = ALIGN(height, 16);
+        assert(i965->codec_info->min_linear_wpitch);
+        assert(i965->codec_info->min_linear_hpitch);
+        obj_surface->width = ALIGN(width, i965->codec_info->min_linear_wpitch);
+        obj_surface->height = ALIGN(height, i965->codec_info->min_linear_hpitch);
         obj_surface->flags = SURFACE_REFERENCED;
         obj_surface->fourcc = 0;
         obj_surface->bo = NULL;
@@ -2606,7 +2608,7 @@ i965_CreateImage(VADriverContextP ctx,
     image->image_id       = image_id;
     image->buf            = VA_INVALID_ID;
 
-    awidth = ALIGN(width, 64);
+    awidth = ALIGN(width, i965->codec_info->min_linear_wpitch);
 
     if ((format->fourcc == VA_FOURCC_YV12) ||
                (format->fourcc == VA_FOURCC_I420)) {
@@ -2615,7 +2617,7 @@ i965_CreateImage(VADriverContextP ctx,
        }
     }
 
-    aheight = ALIGN(height, 16);
+    aheight = ALIGN(height, i965->codec_info->min_linear_hpitch);
     size    = awidth * aheight;
     size2    = (awidth / 2) * (aheight / 2);
 
@@ -2952,7 +2954,7 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
 
         case VA_FOURCC_YUY2:
         case VA_FOURCC_UYVY:
-            obj_surface->width = ALIGN(obj_surface->orig_width * 2, 16);
+            obj_surface->width = ALIGN(obj_surface->orig_width * 2, i965->codec_info->min_linear_wpitch);
             obj_surface->y_cb_offset = 0;
             obj_surface->y_cr_offset = 0;
             obj_surface->cb_cr_width = obj_surface->orig_width / 2;
@@ -2965,7 +2967,7 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
         case VA_FOURCC_RGBX:
         case VA_FOURCC_BGRA:
         case VA_FOURCC_BGRX:
-            obj_surface->width = ALIGN(obj_surface->orig_width * 4, 16);
+            obj_surface->width = ALIGN(obj_surface->orig_width * 4, i965->codec_info->min_linear_wpitch);
             region_width = obj_surface->width;
             region_height = obj_surface->height;
             break;
index 856b478..900aed9 100644 (file)
@@ -291,6 +291,8 @@ struct hw_codec_info
 
     int max_width;
     int max_height;
+    int min_linear_wpitch;
+    int min_linear_hpitch;
 
     unsigned int has_mpeg2_decoding:1;
     unsigned int has_mpeg2_encoding:1;