Check the max resolution supported by hardware when create VA context
authorXiang, Haihao <haihao.xiang@intel.com>
Tue, 27 Mar 2012 06:55:23 +0000 (14:55 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Tue, 27 Mar 2012 07:02:07 +0000 (15:02 +0800)
It will avoid GPU hang when try to play unsupported large resolution
videos.

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

Conflicts:

src/i965_drv_video.c
src/i965_drv_video.h

src/i965_drv_video.c
src/i965_drv_video.h

index f177a75..495e4cf 100644 (file)
@@ -154,6 +154,8 @@ static struct hw_codec_info g4x_hw_codec_info = {
     .dec_hw_context_init = g4x_dec_hw_context_init,
     .enc_hw_context_init = NULL,
     .proc_hw_context_init = NULL,
+    .max_width = 2048,
+    .max_height = 2048,
 };
 
 extern struct hw_context *ironlake_dec_hw_context_init(VADriverContextP, struct object_config *);
@@ -161,6 +163,8 @@ static struct hw_codec_info ironlake_hw_codec_info = {
     .dec_hw_context_init = ironlake_dec_hw_context_init,
     .enc_hw_context_init = NULL,
     .proc_hw_context_init = i965_proc_context_init,
+    .max_width = 2048,
+    .max_height = 2048,
 };
 
 extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, struct object_config *);
@@ -169,6 +173,8 @@ static struct hw_codec_info gen6_hw_codec_info = {
     .dec_hw_context_init = gen6_dec_hw_context_init,
     .enc_hw_context_init = gen6_enc_hw_context_init,
     .proc_hw_context_init = i965_proc_context_init,
+    .max_width = 2048,
+    .max_height = 2048,
 };
 
 extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *);
@@ -177,6 +183,8 @@ static struct hw_codec_info gen7_hw_codec_info = {
     .dec_hw_context_init = gen7_dec_hw_context_init,
     .enc_hw_context_init = gen7_enc_hw_context_init,
     .proc_hw_context_init = i965_proc_context_init,
+    .max_width = 4096,
+    .max_height = 4096,
 };
 
 VAStatus 
@@ -977,6 +985,12 @@ i965_CreateContext(VADriverContextP ctx,
         return vaStatus;
     }
 
+    if (picture_width > i965->codec_info->max_width ||
+        picture_height > i965->codec_info->max_height) {
+        vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
+        return vaStatus;
+    }
+
     /* Validate flag */
     /* Validate picture dimensions */
     contextID = NEW_CONTEXT_ID();
index 1a0f97c..ceb693a 100644 (file)
@@ -249,6 +249,8 @@ struct hw_codec_info
     struct hw_context *(*dec_hw_context_init)(VADriverContextP, struct object_config *);
     struct hw_context *(*enc_hw_context_init)(VADriverContextP, struct object_config *);
     struct hw_context *(*proc_hw_context_init)(VADriverContextP, struct object_config *);
+    int max_width;
+    int max_height;
 };