[G45] Fix check for H.264 decoding support.
authorGwenole Beauchesne <gbeauchesne@splitted-desktop.com>
Thu, 27 Jan 2011 03:36:07 +0000 (11:36 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 27 Jan 2011 03:37:41 +0000 (11:37 +0800)
i965_drv_video.c
intel_batchbuffer.c
intel_driver.c
intel_driver.h

index 1591d68..ce2d4bd 100644 (file)
 
 #define HAS_VC1(ctx)    (IS_GEN6((ctx)->intel.device_id))
 
+/* Defined to 1 if GPU supports H.264 decoding */
+/* XXX: drop IS_IRONLAKE(ctx) check once G4X support is available */
+#define HAS_H264(ctx)   (IS_GEN6((ctx)->intel.device_id) || \
+                         (IS_IRONLAKE((ctx)->intel.device_id) && \
+                          (ctx)->intel.has_bsd))
+
 enum {
     I965_SURFACETYPE_RGBA = 1,
     I965_SURFACETYPE_YUV,
@@ -126,9 +132,12 @@ i965_QueryConfigProfiles(VADriverContextP ctx,
 
     profile_list[i++] = VAProfileMPEG2Simple;
     profile_list[i++] = VAProfileMPEG2Main;
-    profile_list[i++] = VAProfileH264Baseline;
-    profile_list[i++] = VAProfileH264Main;
-    profile_list[i++] = VAProfileH264High;
+
+    if (HAS_H264(i965)) {
+        profile_list[i++] = VAProfileH264Baseline;
+        profile_list[i++] = VAProfileH264Main;
+        profile_list[i++] = VAProfileH264High;
+    }
 
     if (HAS_VC1(i965)) {
         profile_list[i++] = VAProfileVC1Simple;
@@ -161,7 +170,8 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx,
     case VAProfileH264Baseline:
     case VAProfileH264Main:
     case VAProfileH264High:
-        entrypoint_list[n++] = VAEntrypointVLD;
+        if (HAS_H264(i965))
+            entrypoint_list[n++] = VAEntrypointVLD;
         break;
 
     case VAProfileVC1Simple:
@@ -267,7 +277,7 @@ i965_CreateConfig(VADriverContextP ctx,
     case VAProfileH264Baseline:
     case VAProfileH264Main:
     case VAProfileH264High:
-        if (VAEntrypointVLD == entrypoint) {
+        if (HAS_H264(i965) && VAEntrypointVLD == entrypoint) {
             vaStatus = VA_STATUS_SUCCESS;
         } else {
             vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
@@ -330,6 +340,7 @@ i965_CreateConfig(VADriverContextP ctx,
 VAStatus 
 i965_DestroyConfig(VADriverContextP ctx, VAConfigID config_id)
 {
+    struct intel_driver_data * const intel = intel_driver_data(ctx);
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct object_config *obj_config = CONFIG(config_id);
     VAStatus vaStatus;
@@ -755,18 +766,17 @@ i965_CreateContext(VADriverContextP ctx,
         return vaStatus;
     }
 
-    if (IS_GEN6(i965->intel.device_id))
+    switch (obj_config->profile) {
+    case VAProfileH264Baseline:
+    case VAProfileH264Main:
+    case VAProfileH264High:
+        if (!HAS_H264(i965))
+            return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
         render_state->interleaved_uv = 1;
-    else {
-        switch (obj_config->profile) {
-        case VAProfileH264Baseline:
-        case VAProfileH264Main:
-        case VAProfileH264High:
-            render_state->interleaved_uv = 1;
-            break;
-        default:
-            render_state->interleaved_uv = 0;
-        }
+        break;
+    default:
+        render_state->interleaved_uv = !!IS_GEN6(i965->intel.device_id);
+        break;
     }
 
     obj_context->context_id = contextID;
@@ -987,6 +997,7 @@ i965_BeginPicture(VADriverContextP ctx,
                   VAContextID context,
                   VASurfaceID render_target)
 {
+    struct intel_driver_data * const intel = intel_driver_data(ctx);
     struct i965_driver_data *i965 = i965_driver_data(ctx); 
     struct object_context *obj_context = CONTEXT(context);
     struct object_surface *obj_surface = SURFACE(render_target);
index 4988e9c..9d623f1 100644 (file)
@@ -67,12 +67,14 @@ intel_batchbuffer_init(struct intel_driver_data *intel)
     intel->batch->run = drm_intel_bo_mrb_exec;
     intel_batchbuffer_reset(intel->batch);
 
-    intel->batch_bcs = calloc(1, sizeof(*(intel->batch_bcs)));
-    assert(intel->batch_bcs);
-    intel->batch_bcs->intel = intel;
-    intel->batch_bcs->flag = I915_EXEC_BSD;
-    intel->batch_bcs->run = drm_intel_bo_mrb_exec;
-    intel_batchbuffer_reset(intel->batch_bcs);
+    if (intel->has_bsd) {
+        intel->batch_bcs = calloc(1, sizeof(*(intel->batch_bcs)));
+        assert(intel->batch_bcs);
+        intel->batch_bcs->intel = intel;
+        intel->batch_bcs->flag = I915_EXEC_BSD;
+        intel->batch_bcs->run = drm_intel_bo_mrb_exec;
+        intel_batchbuffer_reset(intel->batch_bcs);
+    }
 
     return True;
 }
index 6ab915c..bf7ecbe 100644 (file)
 static Bool
 intel_driver_get_param(struct intel_driver_data *intel, int param, int *value)
 {
-   int ret;
    struct drm_i915_getparam gp;
 
    gp.param = param;
    gp.value = value;
 
-   ret = drmCommandWriteRead(intel->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
-   assert(ret == 0);
-
-   return True;
+   return drmCommandWriteRead(intel->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)) == 0;
 }
 
 Bool 
@@ -55,6 +51,7 @@ intel_driver_init(VADriverContextP ctx)
 {
     struct intel_driver_data *intel = intel_driver_data(ctx);
     struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+    int has_exec2, has_bsd, has_blt;
 
     assert(dri_state);
     assert(dri_state->driConnectedFlag == VA_DRI2 || 
@@ -76,6 +73,13 @@ intel_driver_init(VADriverContextP ctx)
     pthread_mutex_init(&intel->ctxmutex, NULL);
 
     intel_driver_get_param(intel, I915_PARAM_CHIPSET_ID, &intel->device_id);
+    if (intel_driver_get_param(intel, I915_PARAM_HAS_EXECBUF2, &has_exec2))
+        intel->has_exec2 = has_exec2;
+    if (intel_driver_get_param(intel, I915_PARAM_HAS_BSD, &has_bsd))
+        intel->has_bsd = has_bsd;
+    if (intel_driver_get_param(intel, I915_PARAM_HAS_BLT, &has_blt))
+        intel->has_blt = has_blt;
+
     intel_memman_init(intel);
     intel_batchbuffer_init(intel);
 
index 436cccf..b3f7460 100644 (file)
@@ -92,6 +92,10 @@ struct intel_driver_data
     struct intel_batchbuffer *batch;
     struct intel_batchbuffer *batch_bcs;
     dri_bufmgr *bufmgr;
+
+    unsigned int has_exec2  : 1; /* Flag: has execbuffer2? */
+    unsigned int has_bsd    : 1; /* Flag: has bitstream decoder for H.264? */
+    unsigned int has_blt    : 1; /* Flag: has BLT unit? */
 };
 
 Bool intel_driver_init(VADriverContextP ctx);