From 99959acf41c6258616958756b8fa4678f0d9ccb9 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 27 Mar 2012 14:55:23 +0800 Subject: [PATCH] Check the max resolution supported by hardware when create VA context It will avoid GPU hang when try to play unsupported large resolution videos. Signed-off-by: Xiang, Haihao (cherry picked from commit 546fdcfa2f4dd162fdd19187255a57272d4f1745) Conflicts: src/i965_drv_video.c src/i965_drv_video.h --- src/i965_drv_video.c | 14 ++++++++++++++ src/i965_drv_video.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index f177a75..495e4cf 100644 --- a/src/i965_drv_video.c +++ b/src/i965_drv_video.c @@ -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(); diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h index 1a0f97c..ceb693a 100644 --- a/src/i965_drv_video.h +++ b/src/i965_drv_video.h @@ -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; }; -- 2.7.4