Config the media chroma surface in the binding table for Haswell
authorZhao Yakui <yakui.zhao@intel.com>
Fri, 20 Jul 2012 01:19:35 +0000 (21:19 -0400)
committerXiang, Haihao <haihao.xiang@intel.com>
Tue, 23 Oct 2012 05:50:28 +0000 (13:50 +0800)
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
src/gen6_vme.h
src/gen75_vme.c
src/i965_gpe_utils.c
src/i965_gpe_utils.h

index c79770d..9231523 100644 (file)
@@ -76,6 +76,11 @@ struct gen6_vme_context
                                     struct i965_buffer_surface *buffer_surface,
                                     unsigned long binding_table_offset,
                                     unsigned long surface_state_offset);
+    void (*vme_media_chroma_surface_setup)(VADriverContextP ctx,
+                                            struct i965_gpe_context *gpe_context,
+                                            struct object_surface *obj_surface,
+                                            unsigned long binding_table_offset,
+                                            unsigned long surface_state_offset);
 };
 
 Bool gen75_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *encoder_context);
index 0c52677..c076e4f 100644 (file)
@@ -128,6 +128,21 @@ gen75_vme_media_source_surface_state(VADriverContextP ctx,
 }
 
 static void
+gen75_vme_media_chroma_source_surface_state(VADriverContextP ctx,
+                                    int index,
+                                    struct object_surface *obj_surface,
+                                    struct intel_encoder_context *encoder_context)
+{
+    struct gen6_vme_context *vme_context = encoder_context->vme_context;
+
+    vme_context->vme_media_chroma_surface_setup(ctx,
+                                            &vme_context->gpe_context,
+                                            obj_surface,
+                                            BINDING_TABLE_OFFSET(index),
+                                            SURFACE_STATE_OFFSET(index));
+}
+
+static void
 gen75_vme_output_buffer_setup(VADriverContextP ctx,
                              struct encode_state *encode_state,
                              int index,
@@ -205,6 +220,7 @@ gen75_vme_surface_setup(VADriverContextP ctx,
     assert(obj_surface);
     gen75_vme_source_surface_state(ctx, 0, obj_surface, encoder_context);
     gen75_vme_media_source_surface_state(ctx, 4, obj_surface, encoder_context);
+    gen75_vme_media_chroma_source_surface_state(ctx, 6, obj_surface, encoder_context);
 
     if (!is_intra) {
         /* reference 0 */
@@ -619,6 +635,7 @@ Bool gen75_vme_context_init(VADriverContextP ctx, struct intel_encoder_context *
         vme_context->vme_surface2_setup = gen7_gpe_surface2_setup;
         vme_context->vme_media_rw_surface_setup = gen7_gpe_media_rw_surface_setup;
         vme_context->vme_buffer_suface_setup = gen7_gpe_buffer_suface_setup;
+        vme_context->vme_media_chroma_surface_setup = gen75_gpe_media_chroma_surface_setup;
 
     encoder_context->vme_context = vme_context;
     encoder_context->vme_context_destroy = gen75_vme_context_destroy;
index 54958da..546e5ba 100644 (file)
@@ -544,6 +544,35 @@ gen7_gpe_set_media_rw_surface_state(VADriverContextP ctx,
     gen7_gpe_set_surface_tiling(ss, tiling);
 }
 
+static void
+gen75_gpe_set_media_chroma_surface_state(VADriverContextP ctx,
+                                    struct object_surface *obj_surface,
+                                    struct gen7_surface_state *ss)
+{
+    int w, h, w_pitch;
+    unsigned int tiling, swizzle;
+    int cbcr_offset;
+
+    dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
+    w = obj_surface->orig_width;
+    h = obj_surface->orig_height;
+    w_pitch = obj_surface->width;
+
+    cbcr_offset = obj_surface->height * obj_surface->width;
+    memset(ss, 0, sizeof(*ss));
+    /* ss0 */
+    ss->ss0.surface_type = I965_SURFACE_2D;
+    ss->ss0.surface_format = I965_SURFACEFORMAT_R8_UNORM;
+    /* ss1 */
+    ss->ss1.base_addr = obj_surface->bo->offset + cbcr_offset;
+    /* ss2 */
+    ss->ss2.width = w / 4 - 1;  /* in DWORDs for media read & write message */
+    ss->ss2.height = (obj_surface->height / 2) -1;
+    /* ss3 */
+    ss->ss3.pitch = w_pitch - 1;
+    gen7_gpe_set_surface_tiling(ss, tiling);
+}
+
 void
 gen7_gpe_media_rw_surface_setup(VADriverContextP ctx,
                                 struct i965_gpe_context *gpe_context,
@@ -570,6 +599,36 @@ gen7_gpe_media_rw_surface_setup(VADriverContextP ctx,
     dri_bo_unmap(bo);
 }
 
+void
+gen75_gpe_media_chroma_surface_setup(VADriverContextP ctx,
+                                struct i965_gpe_context *gpe_context,
+                                struct object_surface *obj_surface,
+                                unsigned long binding_table_offset,
+                                unsigned long surface_state_offset)
+{
+    struct gen7_surface_state *ss;
+    dri_bo *bo;
+    int cbcr_offset;
+
+       assert(obj_surface->fourcc == VA_FOURCC('N', 'V', '1', '2'));
+    bo = gpe_context->surface_state_binding_table.bo;
+    dri_bo_map(bo, True);
+    assert(bo->virtual);
+
+    cbcr_offset = obj_surface->height * obj_surface->width;
+    ss = (struct gen7_surface_state *)((char *)bo->virtual + surface_state_offset);
+    gen75_gpe_set_media_chroma_surface_state(ctx, obj_surface, ss);
+    dri_bo_emit_reloc(bo,
+                      I915_GEM_DOMAIN_RENDER, 0,
+                      cbcr_offset,
+                      surface_state_offset + offsetof(struct gen7_surface_state, ss1),
+                      obj_surface->bo);
+
+    *((unsigned int *)((char *)bo->virtual + binding_table_offset)) = surface_state_offset;
+    dri_bo_unmap(bo);
+}
+
+
 static void
 gen7_gpe_set_buffer_surface_state(VADriverContextP ctx,
                                   struct i965_buffer_surface *buffer_surface,
index 09f28a6..3ebb3cb 100644 (file)
@@ -115,4 +115,9 @@ void gen7_gpe_buffer_suface_setup(VADriverContextP ctx,
                                   struct i965_buffer_surface *buffer_surface,
                                   unsigned long binding_table_offset,
                                   unsigned long surface_state_offset);
+void gen75_gpe_media_chroma_surface_setup(VADriverContextP ctx,
+                                     struct i965_gpe_context *gpe_context,
+                                     struct object_surface *obj_surface,
+                                     unsigned long binding_table_offset,
+                                     unsigned long surface_state_offset);
 #endif /* _I965_GPE_UTILS_H_ */