diff options
author | Xiang, Haihao <haihao.xiang@intel.com> | 2011-05-10 12:49:54 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2011-05-10 14:17:20 +0800 |
commit | 87a90c604eafc960aa702b059d11949cf10e69ba (patch) | |
tree | f1129dbf21bd9df7468b002f1738ce6bc4723ce3 /i965_drv_video | |
parent | f159aca32479e89c28291d6605b52e2e07daf923 (diff) |
i965_drv_video: create media_state per context
Also clean up some codes
Diffstat (limited to 'i965_drv_video')
25 files changed, 1414 insertions, 1491 deletions
diff --git a/i965_drv_video/gen6_mfc.c b/i965_drv_video/gen6_mfc.c index c4c9f48..4540697 100644 --- a/i965_drv_video/gen6_mfc.c +++ b/i965_drv_video/gen6_mfc.c @@ -36,6 +36,7 @@ #include "i965_defines.h" #include "i965_structs.h" #include "i965_drv_video.h" +#include "i965_encoder.h" static void gen6_mfc_pipe_mode_select(VADriverContextP ctx) @@ -68,38 +69,36 @@ gen6_mfc_pipe_mode_select(VADriverContextP ctx) } static void -gen6_mfc_surface_state(VADriverContextP ctx) +gen6_mfc_surface_state(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; BEGIN_BCS_BATCH(ctx, 6); OUT_BCS_BATCH(ctx, MFX_SURFACE_STATE | (6 - 2)); OUT_BCS_BATCH(ctx, 0); OUT_BCS_BATCH(ctx, - ((bcs_state->surface_state.height - 1) << 19) | - ((bcs_state->surface_state.width - 1) << 6)); + ((mfc_context->surface_state.height - 1) << 19) | + ((mfc_context->surface_state.width - 1) << 6)); OUT_BCS_BATCH(ctx, (MFX_SURFACE_PLANAR_420_8 << 28) | /* 420 planar YUV surface */ (1 << 27) | /* must be 1 for interleave U/V, hardware requirement */ (0 << 22) | /* surface object control state, FIXME??? */ - ((bcs_state->surface_state.w_pitch - 1) << 3) | /* pitch */ + ((mfc_context->surface_state.w_pitch - 1) << 3) | /* pitch */ (0 << 2) | /* must be 0 for interleave U/V */ (1 << 1) | /* must be y-tiled */ (I965_TILEWALK_YMAJOR << 0)); /* tile walk, TILEWALK_YMAJOR */ OUT_BCS_BATCH(ctx, (0 << 16) | /* must be 0 for interleave U/V */ - (bcs_state->surface_state.h_pitch)); /* y offset for U(cb) */ + (mfc_context->surface_state.h_pitch)); /* y offset for U(cb) */ OUT_BCS_BATCH(ctx, 0); ADVANCE_BCS_BATCH(ctx); } static void -gen6_mfc_pipe_buf_addr_state(VADriverContextP ctx) +gen6_mfc_pipe_buf_addr_state(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; int i; BEGIN_BCS_BATCH(ctx, 24); @@ -108,30 +107,30 @@ gen6_mfc_pipe_buf_addr_state(VADriverContextP ctx) OUT_BCS_BATCH(ctx, 0); /* pre output addr */ - OUT_BCS_RELOC(ctx, bcs_state->post_deblocking_output.bo, + OUT_BCS_RELOC(ctx, mfc_context->post_deblocking_output.bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0); /* post output addr */ - OUT_BCS_RELOC(ctx, bcs_state->uncompressed_picture_source.bo, + OUT_BCS_RELOC(ctx, mfc_context->uncompressed_picture_source.bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0); /* uncompressed data */ OUT_BCS_BATCH(ctx, 0); /* StreamOut data*/ - OUT_BCS_RELOC(ctx, bcs_state->intra_row_store_scratch_buffer.bo, + OUT_BCS_RELOC(ctx, mfc_context->intra_row_store_scratch_buffer.bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0); - OUT_BCS_RELOC(ctx, bcs_state->deblocking_filter_row_store_scratch_buffer.bo, + OUT_BCS_RELOC(ctx, mfc_context->deblocking_filter_row_store_scratch_buffer.bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0); /* 7..22 Reference pictures*/ - for (i = 0; i < ARRAY_ELEMS(bcs_state->reference_surfaces); i++) { - if ( bcs_state->reference_surfaces[i].bo != NULL) { - OUT_BCS_RELOC(ctx, bcs_state->reference_surfaces[i].bo, - I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, - 0); - } else { - OUT_BCS_BATCH(ctx, 0); - } + for (i = 0; i < ARRAY_ELEMS(mfc_context->reference_surfaces); i++) { + if ( mfc_context->reference_surfaces[i].bo != NULL) { + OUT_BCS_RELOC(ctx, mfc_context->reference_surfaces[i].bo, + I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, + 0); + } else { + OUT_BCS_BATCH(ctx, 0); + } } OUT_BCS_BATCH(ctx, 0); /* no block status */ @@ -139,10 +138,9 @@ gen6_mfc_pipe_buf_addr_state(VADriverContextP ctx) } static void -gen6_mfc_ind_obj_base_addr_state(VADriverContextP ctx) +gen6_mfc_ind_obj_base_addr_state(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; BEGIN_BCS_BATCH(ctx, 11); @@ -150,7 +148,7 @@ gen6_mfc_ind_obj_base_addr_state(VADriverContextP ctx) OUT_BCS_BATCH(ctx, 0); OUT_BCS_BATCH(ctx, 0); /* MFX Indirect MV Object Base Address */ - OUT_BCS_RELOC(ctx, media_state->vme_output.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); + OUT_BCS_RELOC(ctx, vme_context->vme_output.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); OUT_BCS_BATCH(ctx, 0); OUT_BCS_BATCH(ctx, 0); OUT_BCS_BATCH(ctx, 0); @@ -164,15 +162,14 @@ gen6_mfc_ind_obj_base_addr_state(VADriverContextP ctx) } static void -gen6_mfc_bsp_buf_base_addr_state(VADriverContextP ctx) +gen6_mfc_bsp_buf_base_addr_state(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; BEGIN_BCS_BATCH(ctx, 4); OUT_BCS_BATCH(ctx, MFX_BSP_BUF_BASE_ADDR_STATE | (4 - 2)); - OUT_BCS_RELOC(ctx, bcs_state->bsd_mpc_row_store_scratch_buffer.bo, + OUT_BCS_RELOC(ctx, mfc_context->bsd_mpc_row_store_scratch_buffer.bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0); OUT_BCS_BATCH(ctx, 0); @@ -182,13 +179,12 @@ gen6_mfc_bsp_buf_base_addr_state(VADriverContextP ctx) } static void -gen6_mfc_avc_img_state(VADriverContextP ctx) +gen6_mfc_avc_img_state(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; - int width_in_mbs = (bcs_state->surface_state.width + 15) / 16; - int height_in_mbs = (bcs_state->surface_state.height + 15) / 16; + int width_in_mbs = (mfc_context->surface_state.width + 15) / 16; + int height_in_mbs = (mfc_context->surface_state.height + 15) / 16; BEGIN_BCS_BATCH(ctx, 13); OUT_BCS_BATCH(ctx, MFX_AVC_IMG_STATE | (13 - 2)); @@ -229,7 +225,7 @@ gen6_mfc_avc_img_state(VADriverContextP ctx) OUT_BCS_BATCH(ctx, 0); /*Slice QP Delta for bitrate control*/ OUT_BCS_BATCH(ctx, 0); /*Slice QP Delta for bitrate control*/ OUT_BCS_BATCH(ctx, 0x8C000000); - OUT_BCS_BATCH(ctx, 0x00010000); + OUT_BCS_BATCH(ctx, 0x00010000); OUT_BCS_BATCH(ctx, 0); ADVANCE_BCS_BATCH(ctx); @@ -251,12 +247,12 @@ static void gen6_mfc_avc_directmode_state(VADriverContextP ctx) //TODO: current DMV just for test #if 0 - OUT_BCS_RELOC(ctx, bcs_state->direct_mv_buffers[0].bo, + OUT_BCS_RELOC(ctx, mfc_context->direct_mv_buffers[0].bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, 0); #else - //drm_intel_bo_pin(bcs_state->direct_mv_buffers[0].bo, 0x1000); - //OUT_BCS_BATCH(ctx, bcs_state->direct_mv_buffers[0].bo->offset); + //drm_intel_bo_pin(mfc_context->direct_mv_buffers[0].bo, 0x1000); + //OUT_BCS_BATCH(ctx, mfc_context->direct_mv_buffers[0].bo->offset); OUT_BCS_BATCH(ctx, 0); #endif @@ -271,10 +267,11 @@ static void gen6_mfc_avc_directmode_state(VADriverContextP ctx) ADVANCE_BCS_BATCH(ctx); } -static void gen6_mfc_avc_slice_state(VADriverContextP ctx, int intra_slice) +static void gen6_mfc_avc_slice_state(VADriverContextP ctx, + int intra_slice, + struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; BEGIN_BCS_BATCH(ctx, 11);; @@ -294,7 +291,7 @@ static void gen6_mfc_avc_slice_state(VADriverContextP ctx, int intra_slice) (26<<16) | /*Slice Quantization Parameter*/ 0x0202 ); OUT_BCS_BATCH(ctx, 0); /*First MB X&Y , the postion of current slice*/ - OUT_BCS_BATCH(ctx, ( ((bcs_state->surface_state.height+15)/16) << 16) ); + OUT_BCS_BATCH(ctx, ( ((mfc_context->surface_state.height+15)/16) << 16) ); OUT_BCS_BATCH(ctx, (0<<31) | /*RateControlCounterEnable = disable*/ @@ -308,9 +305,9 @@ static void gen6_mfc_avc_slice_state(VADriverContextP ctx, int intra_slice) (1<<13) | /*RBSP NAL TYPE*/ (0<<12) ); /*CabacZeroWordInsertionEnable*/ - OUT_BCS_RELOC(ctx, bcs_state->mfc_indirect_pak_bse_object.bo, + OUT_BCS_RELOC(ctx, mfc_context->mfc_indirect_pak_bse_object.bo, I915_GEM_DOMAIN_INSTRUCTION, I915_GEM_DOMAIN_INSTRUCTION, - bcs_state->mfc_indirect_pak_bse_object.offset); + mfc_context->mfc_indirect_pak_bse_object.offset); OUT_BCS_BATCH(ctx, 0); OUT_BCS_BATCH(ctx, 0); @@ -320,48 +317,48 @@ static void gen6_mfc_avc_slice_state(VADriverContextP ctx, int intra_slice) } static void gen6_mfc_avc_qm_state(VADriverContextP ctx) { - int i; + int i; BEGIN_BCS_BATCH(ctx, 58); - OUT_BCS_BATCH(ctx, MFX_AVC_QM_STATE | 56); - OUT_BCS_BATCH(ctx, 0xFF ) ; - for( i = 0; i < 56; i++) { - OUT_BCS_BATCH(ctx, 0x10101010); - } + OUT_BCS_BATCH(ctx, MFX_AVC_QM_STATE | 56); + OUT_BCS_BATCH(ctx, 0xFF ) ; + for( i = 0; i < 56; i++) { + OUT_BCS_BATCH(ctx, 0x10101010); + } - ADVANCE_BCS_BATCH(ctx); + ADVANCE_BCS_BATCH(ctx); } static void gen6_mfc_avc_fqm_state(VADriverContextP ctx) { - int i; + int i; - BEGIN_BCS_BATCH(ctx, 113); - OUT_BCS_BATCH(ctx, MFC_AVC_FQM_STATE | (113 - 2)); + BEGIN_BCS_BATCH(ctx, 113); + OUT_BCS_BATCH(ctx, MFC_AVC_FQM_STATE | (113 - 2)); - for(i = 0; i < 112;i++) { - OUT_BCS_BATCH(ctx, 0x10001000); - } + for(i = 0; i < 112;i++) { + OUT_BCS_BATCH(ctx, 0x10001000); + } - ADVANCE_BCS_BATCH(ctx); + ADVANCE_BCS_BATCH(ctx); } static void gen6_mfc_avc_ref_idx_state(VADriverContextP ctx) { - int i; + int i; - BEGIN_BCS_BATCH(ctx, 10); + BEGIN_BCS_BATCH(ctx, 10); - OUT_BCS_BATCH(ctx, MFX_AVC_REF_IDX_STATE | 8); - OUT_BCS_BATCH(ctx, 0); //Select L0 + OUT_BCS_BATCH(ctx, MFX_AVC_REF_IDX_STATE | 8); + OUT_BCS_BATCH(ctx, 0); //Select L0 - OUT_BCS_BATCH(ctx, 0x80808000); //Only 1 reference - for(i = 0; i < 7; i++) { - OUT_BCS_BATCH(ctx, 0x80808080); - } + OUT_BCS_BATCH(ctx, 0x80808000); //Only 1 reference + for(i = 0; i < 7; i++) { + OUT_BCS_BATCH(ctx, 0x80808080); + } - ADVANCE_BCS_BATCH(ctx); + ADVANCE_BCS_BATCH(ctx); } @@ -413,129 +410,129 @@ gen6_mfc_avc_pak_object_intra(VADriverContextP ctx, int x, int y, int end_mb, in ADVANCE_BCS_BATCH(ctx); - return len_in_dwords; + return len_in_dwords; } static int gen6_mfc_avc_pak_object_inter(VADriverContextP ctx, int x, int y, int end_mb, int qp, unsigned int offset) { - int len_in_dwords = 11; + int len_in_dwords = 11; BEGIN_BCS_BATCH(ctx, len_in_dwords); OUT_BCS_BATCH(ctx, MFC_AVC_PAK_OBJECT | (len_in_dwords - 2)); - OUT_BCS_BATCH(ctx, 32); /* 32 MV*/ - OUT_BCS_BATCH(ctx, offset); - - OUT_BCS_BATCH(ctx, - (1 << 24) | /* PackedMvNum, Debug*/ - (4 << 20) | /* 8 MV, SNB don't use it*/ - (1 << 19) | /* CbpDcY */ - (1 << 18) | /* CbpDcU */ - (1 << 17) | /* CbpDcV */ - (0 << 15) | /* Transform8x8Flag = 0*/ - (0 << 14) | /* Frame based*/ - (0 << 13) | /* Inter MB */ - (1 << 8) | /* MbType = P_L0_16x16 */ - (0 << 7) | /* MBZ for frame */ - (0 << 6) | /* MBZ */ - (2 << 4) | /* MBZ for inter*/ - (0 << 3) | /* MBZ */ - (0 << 2) | /* SkipMbFlag */ - (0 << 0)); /* InterMbMode */ - - OUT_BCS_BATCH(ctx, (0xFFFF<<16) | (y << 8) | x); /* Code Block Pattern for Y*/ - OUT_BCS_BATCH(ctx, 0x000F000F); /* Code Block Pattern */ - OUT_BCS_BATCH(ctx, (0 << 27) | (end_mb << 26) | qp); /* Last MB */ - - /*Stuff for Inter MB*/ - OUT_BCS_BATCH(ctx, 0x0); - OUT_BCS_BATCH(ctx, 0x0); - OUT_BCS_BATCH(ctx, 0x0); - - OUT_BCS_BATCH(ctx, 0xF0020000); /*MaxSizeInWord and TargetSzieInWord*/ - - ADVANCE_BCS_BATCH(ctx); - - return len_in_dwords; + OUT_BCS_BATCH(ctx, 32); /* 32 MV*/ + OUT_BCS_BATCH(ctx, offset); + + OUT_BCS_BATCH(ctx, + (1 << 24) | /* PackedMvNum, Debug*/ + (4 << 20) | /* 8 MV, SNB don't use it*/ + (1 << 19) | /* CbpDcY */ + (1 << 18) | /* CbpDcU */ + (1 << 17) | /* CbpDcV */ + (0 << 15) | /* Transform8x8Flag = 0*/ + (0 << 14) | /* Frame based*/ + (0 << 13) | /* Inter MB */ + (1 << 8) | /* MbType = P_L0_16x16 */ + (0 << 7) | /* MBZ for frame */ + (0 << 6) | /* MBZ */ + (2 << 4) | /* MBZ for inter*/ + (0 << 3) | /* MBZ */ + (0 << 2) | /* SkipMbFlag */ + (0 << 0)); /* InterMbMode */ + + OUT_BCS_BATCH(ctx, (0xFFFF<<16) | (y << 8) | x); /* Code Block Pattern for Y*/ + OUT_BCS_BATCH(ctx, 0x000F000F); /* Code Block Pattern */ + OUT_BCS_BATCH(ctx, (0 << 27) | (end_mb << 26) | qp); /* Last MB */ + + /*Stuff for Inter MB*/ + OUT_BCS_BATCH(ctx, 0x0); + OUT_BCS_BATCH(ctx, 0x0); + OUT_BCS_BATCH(ctx, 0x0); + + OUT_BCS_BATCH(ctx, 0xF0020000); /*MaxSizeInWord and TargetSzieInWord*/ + + ADVANCE_BCS_BATCH(ctx); + + return len_in_dwords; } -static void gen6_mfc_init(VADriverContextP ctx) +static void gen6_mfc_init(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; dri_bo *bo; int i; /*Encode common setup for MFC*/ - dri_bo_unreference(bcs_state->post_deblocking_output.bo); - bcs_state->post_deblocking_output.bo = NULL; + dri_bo_unreference(mfc_context->post_deblocking_output.bo); + mfc_context->post_deblocking_output.bo = NULL; - dri_bo_unreference(bcs_state->pre_deblocking_output.bo); - bcs_state->pre_deblocking_output.bo = NULL; + dri_bo_unreference(mfc_context->pre_deblocking_output.bo); + mfc_context->pre_deblocking_output.bo = NULL; - dri_bo_unreference(bcs_state->uncompressed_picture_source.bo); - bcs_state->uncompressed_picture_source.bo = NULL; + dri_bo_unreference(mfc_context->uncompressed_picture_source.bo); + mfc_context->uncompressed_picture_source.bo = NULL; - dri_bo_unreference(bcs_state->mfc_indirect_pak_bse_object.bo); - bcs_state->mfc_indirect_pak_bse_object.bo = NULL; + dri_bo_unreference(mfc_context->mfc_indirect_pak_bse_object.bo); + mfc_context->mfc_indirect_pak_bse_object.bo = NULL; for (i = 0; i < NUM_MFC_DMV_BUFFERS; i++){ - dri_bo_unreference(bcs_state->direct_mv_buffers[i].bo); - bcs_state->direct_mv_buffers[i].bo = NULL; + dri_bo_unreference(mfc_context->direct_mv_buffers[i].bo); + mfc_context->direct_mv_buffers[i].bo = NULL; } for (i = 0; i < MAX_MFC_REFERENCE_SURFACES; i++){ - if ( bcs_state->reference_surfaces[i].bo != NULL) - dri_bo_unreference( bcs_state->reference_surfaces[i].bo ); - bcs_state->reference_surfaces[i].bo = NULL; + if (mfc_context->reference_surfaces[i].bo != NULL) + dri_bo_unreference(mfc_context->reference_surfaces[i].bo); + mfc_context->reference_surfaces[i].bo = NULL; } - dri_bo_unreference(bcs_state->intra_row_store_scratch_buffer.bo); + dri_bo_unreference(mfc_context->intra_row_store_scratch_buffer.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "Buffer", 128 * 64, 64); assert(bo); - bcs_state->intra_row_store_scratch_buffer.bo = bo; + mfc_context->intra_row_store_scratch_buffer.bo = bo; - dri_bo_unreference(bcs_state->deblocking_filter_row_store_scratch_buffer.bo); + dri_bo_unreference(mfc_context->deblocking_filter_row_store_scratch_buffer.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "Buffer", 49152, /* 6 * 128 * 64 */ 64); assert(bo); - bcs_state->deblocking_filter_row_store_scratch_buffer.bo = bo; + mfc_context->deblocking_filter_row_store_scratch_buffer.bo = bo; - dri_bo_unreference(bcs_state->bsd_mpc_row_store_scratch_buffer.bo); + dri_bo_unreference(mfc_context->bsd_mpc_row_store_scratch_buffer.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "Buffer", 12288, /* 1.5 * 128 * 64 */ 0x1000); assert(bo); - bcs_state->bsd_mpc_row_store_scratch_buffer.bo = bo; + mfc_context->bsd_mpc_row_store_scratch_buffer.bo = bo; } -void gen6_mfc_avc_pipeline_programing(VADriverContextP ctx, void *obj) +void gen6_mfc_avc_pipeline_programing(VADriverContextP ctx, + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { - struct mfc_encode_state *encode_state = obj; - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; - int width_in_mbs = (bcs_state->surface_state.width + 15) / 16; - int height_in_mbs = (bcs_state->surface_state.height + 15) / 16; - int x,y; - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param->buffer; - VAEncSliceParameterBuffer *pSliceParameter = (VAEncSliceParameterBuffer *)encode_state->slice_params[0]->buffer; + VAEncSliceParameterBuffer *pSliceParameter = (VAEncSliceParameterBuffer *)encode_state->slice_params[0]->buffer; /* FIXME: multi slices */ unsigned int *msg = NULL, offset = 0; int emit_new_state = 1, object_len_in_bytes; int is_intra = pSliceParameter->slice_flags.bits.is_intra; + int width_in_mbs = (mfc_context->surface_state.width + 15) / 16; + int height_in_mbs = (mfc_context->surface_state.height + 15) / 16; + int x,y; intel_batchbuffer_start_atomic_bcs(ctx, 0x1000); if (is_intra) { - dri_bo_map(media_state->vme_output.bo , 1); - msg = (unsigned int *)media_state->vme_output.bo->virtual; + dri_bo_map(vme_context->vme_output.bo , 1); + msg = (unsigned int *)vme_context->vme_output.bo->virtual; } for (y = 0; y < height_in_mbs; y++) { @@ -546,20 +543,20 @@ void gen6_mfc_avc_pipeline_programing(VADriverContextP ctx, void *obj) if (emit_new_state) { intel_batchbuffer_emit_mi_flush_bcs(ctx); gen6_mfc_pipe_mode_select(ctx); - gen6_mfc_surface_state(ctx); - gen6_mfc_pipe_buf_addr_state(ctx); - gen6_mfc_ind_obj_base_addr_state(ctx); - gen6_mfc_bsp_buf_base_addr_state(ctx); - gen6_mfc_avc_img_state(ctx); + gen6_mfc_surface_state(ctx, gen6_encoder_context); + gen6_mfc_pipe_buf_addr_state(ctx, gen6_encoder_context); + gen6_mfc_ind_obj_base_addr_state(ctx, gen6_encoder_context); + gen6_mfc_bsp_buf_base_addr_state(ctx, gen6_encoder_context); + gen6_mfc_avc_img_state(ctx, gen6_encoder_context); gen6_mfc_avc_qm_state(ctx); gen6_mfc_avc_fqm_state(ctx); gen6_mfc_avc_ref_idx_state(ctx); /*gen6_mfc_avc_directmode_state(ctx);*/ - gen6_mfc_avc_slice_state(ctx, is_intra); + gen6_mfc_avc_slice_state(ctx, is_intra, gen6_encoder_context); /*gen6_mfc_avc_insert_object(ctx, 0);*/ emit_new_state = 0; } - + if (is_intra) { assert(msg); object_len_in_bytes = gen6_mfc_avc_pak_object_intra(ctx, x, y, last_mb, qp, msg); @@ -579,22 +576,22 @@ void gen6_mfc_avc_pipeline_programing(VADriverContextP ctx, void *obj) } if (is_intra) - dri_bo_unmap(media_state->vme_output.bo); + dri_bo_unmap(vme_context->vme_output.bo); intel_batchbuffer_end_atomic_bcs(ctx); } static VAStatus gen6_mfc_avc_prepare(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { - VAStatus vaStatus = VA_STATUS_SUCCESS; struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; struct object_surface *obj_surface; struct object_buffer *obj_buffer; dri_bo *bo; VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param->buffer; + VAStatus vaStatus = VA_STATUS_SUCCESS; /*Setup all the input&output object*/ obj_surface = SURFACE(pPicParameter->reconstructed_picture); @@ -617,42 +614,42 @@ static VAStatus gen6_mfc_avc_prepare(VADriverContextP ctx, assert(pitch == obj_surface->width); } - bcs_state->post_deblocking_output.bo = obj_surface->bo; - dri_bo_reference(bcs_state->post_deblocking_output.bo); + mfc_context->post_deblocking_output.bo = obj_surface->bo; + dri_bo_reference(mfc_context->post_deblocking_output.bo); - bcs_state->surface_state.width = obj_surface->orig_width; - bcs_state->surface_state.height = obj_surface->orig_height; - bcs_state->surface_state.w_pitch = obj_surface->width; - bcs_state->surface_state.h_pitch = obj_surface->height; + mfc_context->surface_state.width = obj_surface->orig_width; + mfc_context->surface_state.height = obj_surface->orig_height; + mfc_context->surface_state.w_pitch = obj_surface->width; + mfc_context->surface_state.h_pitch = obj_surface->height; obj_surface = SURFACE(pPicParameter->reference_picture); - assert(obj_surface); - if ( obj_surface->bo != NULL) { - bcs_state->reference_surfaces[0].bo = obj_surface->bo; - dri_bo_reference(obj_surface->bo); - } + assert(obj_surface); + if (obj_surface->bo != NULL) { + mfc_context->reference_surfaces[0].bo = obj_surface->bo; + dri_bo_reference(obj_surface->bo); + } obj_surface = SURFACE(encode_state->current_render_target); assert(obj_surface && obj_surface->bo); - bcs_state->uncompressed_picture_source.bo = obj_surface->bo; - dri_bo_reference(bcs_state->uncompressed_picture_source.bo); + mfc_context->uncompressed_picture_source.bo = obj_surface->bo; + dri_bo_reference(mfc_context->uncompressed_picture_source.bo); obj_buffer = BUFFER (pPicParameter->coded_buf); /* FIXME: fix this later */ bo = obj_buffer->buffer_store->bo; assert(bo); - bcs_state->mfc_indirect_pak_bse_object.bo = bo; - bcs_state->mfc_indirect_pak_bse_object.offset = ALIGN(sizeof(VACodedBufferSegment), 64); - dri_bo_reference(bcs_state->mfc_indirect_pak_bse_object.bo); + mfc_context->mfc_indirect_pak_bse_object.bo = bo; + mfc_context->mfc_indirect_pak_bse_object.offset = ALIGN(sizeof(VACodedBufferSegment), 64); + dri_bo_reference(mfc_context->mfc_indirect_pak_bse_object.bo); /*Programing bcs pipeline*/ - gen6_mfc_avc_pipeline_programing(ctx, encode_state); //filling the pipeline + gen6_mfc_avc_pipeline_programing(ctx, encode_state, gen6_encoder_context); //filling the pipeline return vaStatus; } static VAStatus gen6_mfc_run(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { intel_batchbuffer_flush_bcs(ctx); //run the pipeline @@ -660,12 +657,12 @@ static VAStatus gen6_mfc_run(VADriverContextP ctx, } static VAStatus gen6_mfc_stop(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { #if 0 struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_mfc_context *mfc_context = &gen6_encoder_context->mfc_context; VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param->buffer; @@ -679,38 +676,30 @@ static VAStatus gen6_mfc_stop(VADriverContextP ctx, return VA_STATUS_SUCCESS; } -static VAStatus +static VAStatus gen6_mfc_avc_encode_picture(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { - gen6_mfc_init(ctx); - gen6_mfc_avc_prepare(ctx, context, encode_state); - gen6_mfc_run(ctx, context, encode_state); - gen6_mfc_stop(ctx, context, encode_state); + gen6_mfc_init(ctx, gen6_encoder_context); + gen6_mfc_avc_prepare(ctx, encode_state, gen6_encoder_context); + gen6_mfc_run(ctx, encode_state, gen6_encoder_context); + gen6_mfc_stop(ctx, encode_state, gen6_encoder_context); return VA_STATUS_SUCCESS; } -VAStatus -gen6_mfc_pipeline(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) +VAStatus +gen6_mfc_pipeline(VADriverContextP ctx, + VAProfile profile, + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_context *obj_context = CONTEXT(context); - struct object_config *obj_config; - VAContextID config; VAStatus vaStatus; - assert(obj_context); - config = obj_context->config_id; - obj_config = CONFIG(config); - assert(obj_config); - - switch( obj_config->profile) { + switch (profile) { case VAProfileH264Baseline: - vaStatus = gen6_mfc_avc_encode_picture(ctx, context, &(obj_context->encode_state)); + vaStatus = gen6_mfc_avc_encode_picture(ctx, encode_state, gen6_encoder_context); break; /* FIXME: add for other profile */ @@ -719,6 +708,43 @@ gen6_mfc_pipeline(VADriverContextP ctx, break; } - return VA_STATUS_SUCCESS; + return vaStatus; } +Bool gen6_mfc_context_init(VADriverContextP ctx, struct gen6_mfc_context *mfc_context) +{ + return True; +} + +Bool gen6_mfc_context_destroy(struct gen6_mfc_context *mfc_context) +{ + int i; + + dri_bo_unreference(mfc_context->post_deblocking_output.bo); + mfc_context->post_deblocking_output.bo = NULL; + + dri_bo_unreference(mfc_context->pre_deblocking_output.bo); + mfc_context->pre_deblocking_output.bo = NULL; + + dri_bo_unreference(mfc_context->uncompressed_picture_source.bo); + mfc_context->uncompressed_picture_source.bo = NULL; + + dri_bo_unreference(mfc_context->mfc_indirect_pak_bse_object.bo); + mfc_context->mfc_indirect_pak_bse_object.bo = NULL; + + for (i = 0; i < NUM_MFC_DMV_BUFFERS; i++){ + dri_bo_unreference(mfc_context->direct_mv_buffers[i].bo); + mfc_context->direct_mv_buffers[i].bo = NULL; + } + + dri_bo_unreference(mfc_context->intra_row_store_scratch_buffer.bo); + mfc_context->intra_row_store_scratch_buffer.bo = NULL; + + dri_bo_unreference(mfc_context->deblocking_filter_row_store_scratch_buffer.bo); + mfc_context->deblocking_filter_row_store_scratch_buffer.bo = NULL; + + dri_bo_unreference(mfc_context->bsd_mpc_row_store_scratch_buffer.bo); + mfc_context->bsd_mpc_row_store_scratch_buffer.bo = NULL; + + return True; +} diff --git a/i965_drv_video/gen6_mfc.h b/i965_drv_video/gen6_mfc.h index d41b383..75bcf63 100644 --- a/i965_drv_video/gen6_mfc.h +++ b/i965_drv_video/gen6_mfc.h @@ -26,19 +26,20 @@ * */ -#ifndef _GEN6_MFC_BCS_H_ -#define _GEN6_MFC_BCS_H_ +#ifndef _GEN6_MFC_H_ +#define _GEN6_MFC_H_ #include <xf86drm.h> #include <drm.h> #include <i915_drm.h> #include <intel_bufmgr.h> -struct mfc_encode_state; +struct encode_state; #define MAX_MFC_REFERENCE_SURFACES 16 #define NUM_MFC_DMV_BUFFERS 34 -struct gen6_mfc_bcs_state + +struct gen6_mfc_context { struct { unsigned int width; @@ -94,8 +95,12 @@ struct gen6_mfc_bcs_state }direct_mv_buffers[NUM_MFC_DMV_BUFFERS]; //INTERNAL: 0-31 as input,32 and 33 as output }; -VAStatus gen6_mfc_pipeline(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state); +VAStatus +gen6_mfc_pipeline(VADriverContextP ctx, + VAProfile profile, + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context); +Bool gen6_mfc_context_init(VADriverContextP ctx, struct gen6_mfc_context *mfc_context); +Bool gen6_mfc_context_destroy(struct gen6_mfc_context *mfc_context); #endif /* _GEN6_MFC_BCS_H_ */ diff --git a/i965_drv_video/gen6_mfd.c b/i965_drv_video/gen6_mfd.c index b2f312e..78baaa4 100644 --- a/i965_drv_video/gen6_mfd.c +++ b/i965_drv_video/gen6_mfd.c @@ -55,11 +55,11 @@ static const uint32_t zigzag_direct[64] = { }; static void -gen6_mfd_avc_frame_store_index(VADriverContextP ctx, VAPictureParameterBufferH264 *pic_param) +gen6_mfd_avc_frame_store_index(VADriverContextP ctx, + VAPictureParameterBufferH264 *pic_param, + struct gen6_mfd_context *gen6_mfd_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context = (struct gen6_mfd_context *)media_state->private_context; int i, j; assert(ARRAY_ELEMS(gen6_mfd_context->reference_surface) == ARRAY_ELEMS(pic_param->ReferenceFrames)); @@ -239,12 +239,9 @@ gen6_mfd_init_avc_surface(VADriverContextP ctx, static void gen6_mfd_pipe_mode_select(VADriverContextP ctx, struct decode_state *decode_state, - int standard_select) + int standard_select, + struct gen6_mfd_context *gen6_mfd_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context = media_state->private_context; - assert(standard_select == MFX_FORMAT_MPEG2 || standard_select == MFX_FORMAT_AVC || standard_select == MFX_FORMAT_VC1); @@ -308,11 +305,10 @@ gen6_mfd_surface_state(VADriverContextP ctx, static void gen6_mfd_pipe_buf_addr_state(VADriverContextP ctx, struct decode_state *decode_state, - int standard_select) + int standard_select, + struct gen6_mfd_context *gen6_mfd_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context = media_state->private_context; int i; BEGIN_BCS_BATCH(ctx, 24); @@ -391,12 +387,9 @@ gen6_mfd_ind_obj_base_addr_state(VADriverContextP ctx, static void gen6_mfd_bsp_buf_base_addr_state(VADriverContextP ctx, struct decode_state *decode_state, - int standard_select) + int standard_select, + struct gen6_mfd_context *gen6_mfd_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context = media_state->private_context; - BEGIN_BCS_BATCH(ctx, 4); OUT_BCS_BATCH(ctx, MFX_BSP_BUF_BASE_ADDR_STATE | (4 - 2)); @@ -572,11 +565,10 @@ gen6_mfd_avc_qm_state(VADriverContextP ctx, struct decode_state *decode_state) static void gen6_mfd_avc_directmode_state(VADriverContextP ctx, VAPictureParameterBufferH264 *pic_param, - VASliceParameterBufferH264 *slice_param) + VASliceParameterBufferH264 *slice_param, + struct gen6_mfd_context *gen6_mfd_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context = media_state->private_context; struct object_surface *obj_surface; struct gen6_avc_surface *gen6_avc_surface; VAPictureH264 *va_pic; @@ -783,11 +775,9 @@ gen6_mfd_avc_phantom_slice_state(VADriverContextP ctx, VAPictureParameterBufferH static void gen6_mfd_avc_ref_idx_state(VADriverContextP ctx, VAPictureParameterBufferH264 *pic_param, - VASliceParameterBufferH264 *slice_param) + VASliceParameterBufferH264 *slice_param, + struct gen6_mfd_context *gen6_mfd_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context = media_state->private_context; int i, j, num_ref_list; struct { unsigned char bottom_idc:1; @@ -984,18 +974,18 @@ gen6_mfd_avc_phantom_slice(VADriverContextP ctx, VAPictureParameterBufferH264 *p } static void -gen6_mfd_avc_decode_init(VADriverContextP ctx, struct decode_state *decode_state) +gen6_mfd_avc_decode_init(VADriverContextP ctx, + struct decode_state *decode_state, + struct gen6_mfd_context *gen6_mfd_context) { VAPictureParameterBufferH264 *pic_param; VASliceParameterBufferH264 *slice_param; VAPictureH264 *va_pic; struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context; struct object_surface *obj_surface; dri_bo *bo; int i, j, enable_avc_ildb = 0; - + for (j = 0; j < decode_state->num_slice_params && enable_avc_ildb == 0; j++) { assert(decode_state->slice_params && decode_state->slice_params[j]->buffer); slice_param = (VASliceParameterBufferH264 *)decode_state->slice_params[j]->buffer; @@ -1020,19 +1010,7 @@ gen6_mfd_avc_decode_init(VADriverContextP ctx, struct decode_state *decode_state assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer; - gen6_mfd_context = media_state->private_context; - - if (gen6_mfd_context == NULL) { - gen6_mfd_context = calloc(1, sizeof(struct gen6_mfd_context)); - media_state->private_context = gen6_mfd_context; - - for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) { - gen6_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID; - gen6_mfd_context->reference_surface[i].frame_store_id = -1; - } - } - - gen6_mfd_avc_frame_store_index(ctx, pic_param); + gen6_mfd_avc_frame_store_index(ctx, pic_param, gen6_mfd_context); /* Current decoded picture */ va_pic = &pic_param->CurrPic; @@ -1110,7 +1088,9 @@ gen6_mfd_avc_decode_init(VADriverContextP ctx, struct decode_state *decode_state } static void -gen6_mfd_avc_decode_picture(VADriverContextP ctx, struct decode_state *decode_state) +gen6_mfd_avc_decode_picture(VADriverContextP ctx, + struct decode_state *decode_state, + struct gen6_mfd_context *gen6_mfd_context) { VAPictureParameterBufferH264 *pic_param; VASliceParameterBufferH264 *slice_param, *next_slice_param; @@ -1119,14 +1099,14 @@ gen6_mfd_avc_decode_picture(VADriverContextP ctx, struct decode_state *decode_st assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer; + gen6_mfd_avc_decode_init(ctx, decode_state, gen6_mfd_context); - gen6_mfd_avc_decode_init(ctx, decode_state); intel_batchbuffer_start_atomic_bcs(ctx, 0x1000); intel_batchbuffer_emit_mi_flush_bcs(ctx); - gen6_mfd_pipe_mode_select(ctx, decode_state, MFX_FORMAT_AVC); + gen6_mfd_pipe_mode_select(ctx, decode_state, MFX_FORMAT_AVC, gen6_mfd_context); gen6_mfd_surface_state(ctx, decode_state, MFX_FORMAT_AVC); - gen6_mfd_pipe_buf_addr_state(ctx, decode_state, MFX_FORMAT_AVC); - gen6_mfd_bsp_buf_base_addr_state(ctx, decode_state, MFX_FORMAT_AVC); + gen6_mfd_pipe_buf_addr_state(ctx, decode_state, MFX_FORMAT_AVC, gen6_mfd_context); + gen6_mfd_bsp_buf_base_addr_state(ctx, decode_state, MFX_FORMAT_AVC, gen6_mfd_context); gen6_mfd_avc_img_state(ctx, decode_state); gen6_mfd_avc_qm_state(ctx, decode_state); @@ -1154,9 +1134,9 @@ gen6_mfd_avc_decode_picture(VADriverContextP ctx, struct decode_state *decode_st if (i < decode_state->slice_params[j]->num_elements - 1) next_slice_param = slice_param + 1; - gen6_mfd_avc_directmode_state(ctx, pic_param, slice_param); + gen6_mfd_avc_directmode_state(ctx, pic_param, slice_param, gen6_mfd_context); gen6_mfd_avc_slice_state(ctx, pic_param, slice_param, next_slice_param); - gen6_mfd_avc_ref_idx_state(ctx, pic_param, slice_param); + gen6_mfd_avc_ref_idx_state(ctx, pic_param, slice_param, gen6_mfd_context); gen6_mfd_avc_weightoffset_state(ctx, pic_param, slice_param); gen6_mfd_avc_bsd_object(ctx, pic_param, slice_param, slice_data_bo); slice_param++; @@ -1169,29 +1149,18 @@ gen6_mfd_avc_decode_picture(VADriverContextP ctx, struct decode_state *decode_st } static void -gen6_mfd_mpeg2_decode_init(VADriverContextP ctx, struct decode_state *decode_state) +gen6_mfd_mpeg2_decode_init(VADriverContextP ctx, + struct decode_state *decode_state, + struct gen6_mfd_context *gen6_mfd_context) { VAPictureParameterBufferMPEG2 *pic_param; struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context; struct object_surface *obj_surface; int i; dri_bo *bo; assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer; - gen6_mfd_context = media_state->private_context; - - if (gen6_mfd_context == NULL) { - gen6_mfd_context = calloc(1, sizeof(struct gen6_mfd_context)); - media_state->private_context = gen6_mfd_context; - - for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) { - gen6_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID; - gen6_mfd_context->reference_surface[i].frame_store_id = -1; - } - } /* reference picture */ obj_surface = SURFACE(pic_param->forward_reference_picture); @@ -1363,7 +1332,9 @@ gen6_mfd_mpeg2_bsd_object(VADriverContextP ctx, } static void -gen6_mfd_mpeg2_decode_picture(VADriverContextP ctx, struct decode_state *decode_state) +gen6_mfd_mpeg2_decode_picture(VADriverContextP ctx, + struct decode_state *decode_state, + struct gen6_mfd_context *gen6_mfd_context) { VAPictureParameterBufferMPEG2 *pic_param; VASliceParameterBufferMPEG2 *slice_param, *next_slice_param; @@ -1373,13 +1344,13 @@ gen6_mfd_mpeg2_decode_picture(VADriverContextP ctx, struct decode_state *decode_ assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer; - gen6_mfd_mpeg2_decode_init(ctx, decode_state); + gen6_mfd_mpeg2_decode_init(ctx, decode_state, gen6_mfd_context); intel_batchbuffer_start_atomic_bcs(ctx, 0x1000); intel_batchbuffer_emit_mi_flush_bcs(ctx); - gen6_mfd_pipe_mode_select(ctx, decode_state, MFX_FORMAT_MPEG2); + gen6_mfd_pipe_mode_select(ctx, decode_state, MFX_FORMAT_MPEG2, gen6_mfd_context); gen6_mfd_surface_state(ctx, decode_state, MFX_FORMAT_MPEG2); - gen6_mfd_pipe_buf_addr_state(ctx, decode_state, MFX_FORMAT_MPEG2); - gen6_mfd_bsp_buf_base_addr_state(ctx, decode_state, MFX_FORMAT_MPEG2); + gen6_mfd_pipe_buf_addr_state(ctx, decode_state, MFX_FORMAT_MPEG2, gen6_mfd_context); + gen6_mfd_bsp_buf_base_addr_state(ctx, decode_state, MFX_FORMAT_MPEG2, gen6_mfd_context); gen6_mfd_mpeg2_pic_state(ctx, decode_state); gen6_mfd_mpeg2_qm_state(ctx, decode_state); @@ -1494,29 +1465,18 @@ gen6_mfd_init_vc1_surface(VADriverContextP ctx, } static void -gen6_mfd_vc1_decode_init(VADriverContextP ctx, struct decode_state *decode_state) +gen6_mfd_vc1_decode_init(VADriverContextP ctx, + struct decode_state *decode_state, + struct gen6_mfd_context *gen6_mfd_context) { VAPictureParameterBufferVC1 *pic_param; struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context; struct object_surface *obj_surface; int i; dri_bo *bo; assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer; - gen6_mfd_context = media_state->private_context; - - if (gen6_mfd_context == NULL) { - gen6_mfd_context = calloc(1, sizeof(struct gen6_mfd_context)); - media_state->private_context = gen6_mfd_context; - - for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) { - gen6_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID; - gen6_mfd_context->reference_surface[i].frame_store_id = -1; - } - } /* reference picture */ obj_surface = SURFACE(pic_param->forward_reference_picture); @@ -1605,8 +1565,7 @@ gen6_mfd_vc1_decode_init(VADriverContextP ctx, struct decode_state *decode_state int width_in_mbs = ALIGN(pic_param->coded_width, 16) / 16; int height_in_mbs = ALIGN(pic_param->coded_height, 16) / 16; int bitplane_width = ALIGN(width_in_mbs, 2) / 2; - int bitplane_height = height_in_mbs; - int src_w, src_h, dst_w, dst_h; + int src_w, src_h; uint8_t *src = NULL, *dst = NULL; assert(decode_state->bit_plane->buffer); @@ -2010,7 +1969,9 @@ gen6_mfd_vc1_bsd_object(VADriverContextP ctx, } static void -gen6_mfd_vc1_decode_picture(VADriverContextP ctx, struct decode_state *decode_state) +gen6_mfd_vc1_decode_picture(VADriverContextP ctx, + struct decode_state *decode_state, + struct gen6_mfd_context *gen6_mfd_context) { VAPictureParameterBufferVC1 *pic_param; VASliceParameterBufferVC1 *slice_param, *next_slice_param; @@ -2020,13 +1981,13 @@ gen6_mfd_vc1_decode_picture(VADriverContextP ctx, struct decode_state *decode_st assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer; - gen6_mfd_vc1_decode_init(ctx, decode_state); + gen6_mfd_vc1_decode_init(ctx, decode_state, gen6_mfd_context); intel_batchbuffer_start_atomic_bcs(ctx, 0x1000); intel_batchbuffer_emit_mi_flush_bcs(ctx); - gen6_mfd_pipe_mode_select(ctx, decode_state, MFX_FORMAT_VC1); + gen6_mfd_pipe_mode_select(ctx, decode_state, MFX_FORMAT_VC1, gen6_mfd_context); gen6_mfd_surface_state(ctx, decode_state, MFX_FORMAT_VC1); - gen6_mfd_pipe_buf_addr_state(ctx, decode_state, MFX_FORMAT_VC1); - gen6_mfd_bsp_buf_base_addr_state(ctx, decode_state, MFX_FORMAT_VC1); + gen6_mfd_pipe_buf_addr_state(ctx, decode_state, MFX_FORMAT_VC1, gen6_mfd_context); + gen6_mfd_bsp_buf_base_addr_state(ctx, decode_state, MFX_FORMAT_VC1, gen6_mfd_context); gen6_mfd_vc1_pic_state(ctx, decode_state); gen6_mfd_vc1_pred_pipe_state(ctx, decode_state); gen6_mfd_vc1_directmode_state(ctx, decode_state); @@ -2055,27 +2016,34 @@ gen6_mfd_vc1_decode_picture(VADriverContextP ctx, struct decode_state *decode_st intel_batchbuffer_flush_bcs(ctx); } -void +static void gen6_mfd_decode_picture(VADriverContextP ctx, VAProfile profile, - struct decode_state *decode_state) + union codec_state *codec_state, + struct hw_context *hw_context) + { + struct gen6_mfd_context *gen6_mfd_context = (struct gen6_mfd_context *)hw_context; + struct decode_state *decode_state = &codec_state->dec; + + assert(gen6_mfd_context); + switch (profile) { case VAProfileMPEG2Simple: case VAProfileMPEG2Main: - gen6_mfd_mpeg2_decode_picture(ctx, decode_state); + gen6_mfd_mpeg2_decode_picture(ctx, decode_state, gen6_mfd_context); break; case VAProfileH264Baseline: case VAProfileH264Main: case VAProfileH264High: - gen6_mfd_avc_decode_picture(ctx, decode_state); + gen6_mfd_avc_decode_picture(ctx, decode_state, gen6_mfd_context); break; case VAProfileVC1Simple: case VAProfileVC1Main: case VAProfileVC1Advanced: - gen6_mfd_vc1_decode_picture(ctx, decode_state); + gen6_mfd_vc1_decode_picture(ctx, decode_state, gen6_mfd_context); break; default: @@ -2084,45 +2052,48 @@ gen6_mfd_decode_picture(VADriverContextP ctx, } } -Bool -gen6_mfd_init(VADriverContextP ctx) +static void +gen6_mfd_context_destroy(void *hw_context) { - return True; -} + struct gen6_mfd_context *gen6_mfd_context = (struct gen6_mfd_context *)hw_context; -Bool -gen6_mfd_terminate(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct gen6_mfd_context *gen6_mfd_context = media_state->private_context; + dri_bo_unreference(gen6_mfd_context->post_deblocking_output.bo); + gen6_mfd_context->post_deblocking_output.bo = NULL; + + dri_bo_unreference(gen6_mfd_context->pre_deblocking_output.bo); + gen6_mfd_context->pre_deblocking_output.bo = NULL; + + dri_bo_unreference(gen6_mfd_context->intra_row_store_scratch_buffer.bo); + gen6_mfd_context->intra_row_store_scratch_buffer.bo = NULL; - if (gen6_mfd_context) { - dri_bo_unreference(gen6_mfd_context->post_deblocking_output.bo); - gen6_mfd_context->post_deblocking_output.bo = NULL; + dri_bo_unreference(gen6_mfd_context->deblocking_filter_row_store_scratch_buffer.bo); + gen6_mfd_context->deblocking_filter_row_store_scratch_buffer.bo = NULL; - dri_bo_unreference(gen6_mfd_context->pre_deblocking_output.bo); - gen6_mfd_context->pre_deblocking_output.bo = NULL; + dri_bo_unreference(gen6_mfd_context->bsd_mpc_row_store_scratch_buffer.bo); + gen6_mfd_context->bsd_mpc_row_store_scratch_buffer.bo = NULL; - dri_bo_unreference(gen6_mfd_context->intra_row_store_scratch_buffer.bo); - gen6_mfd_context->intra_row_store_scratch_buffer.bo = NULL; + dri_bo_unreference(gen6_mfd_context->mpr_row_store_scratch_buffer.bo); + gen6_mfd_context->mpr_row_store_scratch_buffer.bo = NULL; - dri_bo_unreference(gen6_mfd_context->deblocking_filter_row_store_scratch_buffer.bo); - gen6_mfd_context->deblocking_filter_row_store_scratch_buffer.bo = NULL; + dri_bo_unreference(gen6_mfd_context->bitplane_read_buffer.bo); + gen6_mfd_context->bitplane_read_buffer.bo = NULL; - dri_bo_unreference(gen6_mfd_context->bsd_mpc_row_store_scratch_buffer.bo); - gen6_mfd_context->bsd_mpc_row_store_scratch_buffer.bo = NULL; + free(gen6_mfd_context); +} - dri_bo_unreference(gen6_mfd_context->mpr_row_store_scratch_buffer.bo); - gen6_mfd_context->mpr_row_store_scratch_buffer.bo = NULL; +struct hw_context * +gen6_dec_hw_context_init(VADriverContextP ctx, VAProfile profile) +{ + struct gen6_mfd_context *gen6_mfd_context = calloc(1, sizeof(struct gen6_mfd_context)); + int i; - dri_bo_unreference(gen6_mfd_context->bitplane_read_buffer.bo); - gen6_mfd_context->bitplane_read_buffer.bo = NULL; + gen6_mfd_context->base.destroy = gen6_mfd_context_destroy; + gen6_mfd_context->base.run = gen6_mfd_decode_picture; - free(gen6_mfd_context); + for (i = 0; i < ARRAY_ELEMS(gen6_mfd_context->reference_surface); i++) { + gen6_mfd_context->reference_surface[i].surface_id = VA_INVALID_ID; + gen6_mfd_context->reference_surface[i].frame_store_id = -1; } - - media_state->private_context = NULL; - return True; + + return (struct hw_context *)gen6_mfd_context; } - diff --git a/i965_drv_video/gen6_mfd.h b/i965_drv_video/gen6_mfd.h index a39137e..31f7957 100644 --- a/i965_drv_video/gen6_mfd.h +++ b/i965_drv_video/gen6_mfd.h @@ -59,8 +59,12 @@ struct gen6_vc1_surface }; #define MAX_MFX_REFERENCE_SURFACES 16 +struct hw_context; + struct gen6_mfd_context { + struct hw_context base; + struct { VASurfaceID surface_id; int frame_store_id; @@ -102,11 +106,4 @@ struct gen6_mfd_context } bitplane_read_buffer; }; -struct decode_state; - -Bool gen6_mfd_init(VADriverContextP ctx); -Bool gen6_mfd_terminate(VADriverContextP ctx); -void gen6_mfd_decode_picture(VADriverContextP ctx, - VAProfile profile, - struct decode_state *decode_state); #endif /* _GEN6_MFD_H_ */ diff --git a/i965_drv_video/gen6_vme.c b/i965_drv_video/gen6_vme.c index ccf26bc..ff00a43 100644 --- a/i965_drv_video/gen6_vme.c +++ b/i965_drv_video/gen6_vme.c @@ -38,6 +38,7 @@ #include "i965_defines.h" #include "i965_drv_video.h" #include "gen6_vme.h" +#include "i965_encoder.h" #define VME_INTRA_SHADER 0 #define VME_INTER_SHADER 1 @@ -116,10 +117,11 @@ gen6_vme_set_source_surface_tiling(struct i965_surface_state2 *ss, unsigned int /* only used for VME source surface state */ static void gen6_vme_source_surface_state(VADriverContextP ctx, int index, - struct object_surface *obj_surface) + struct object_surface *obj_surface, + struct gen6_encoder_context *gen6_encoder_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; struct i965_surface_state2 *ss; dri_bo *bo; int w, h, w_pitch, h_pitch; @@ -169,16 +171,17 @@ static void gen6_vme_source_surface_state(VADriverContextP ctx, obj_surface->bo); assert(index < MAX_MEDIA_SURFACES_GEN6); - media_state->surface_state[index].bo = bo; + vme_context->surface_state[index].bo = bo; } static void gen6_vme_media_source_surface_state(VADriverContextP ctx, int index, - struct object_surface *obj_surface) + struct object_surface *obj_surface, + struct gen6_encoder_context *gen6_encoder_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; struct i965_surface_state *ss; dri_bo *bo; int w, h, w_pitch; @@ -216,40 +219,40 @@ gen6_vme_media_source_surface_state(VADriverContextP ctx, dri_bo_unmap(bo); assert(index < MAX_MEDIA_SURFACES_GEN6); - media_state->surface_state[index].bo = bo; + vme_context->surface_state[index].bo = bo; } static VAStatus gen6_vme_output_buffer_setup(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state, - int index) + struct encode_state *encode_state, + int index, + struct gen6_encoder_context *gen6_encoder_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; - struct object_context *obj_context = CONTEXT(context); + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; struct i965_surface_state *ss; dri_bo *bo; - int width_in_mbs = ALIGN(obj_context->picture_width, 16) / 16; - int height_in_mbs = ALIGN(obj_context->picture_height, 16) / 16; - int num_entries; + VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param->buffer; VAEncSliceParameterBuffer *pSliceParameter = (VAEncSliceParameterBuffer *)encode_state->slice_params[0]->buffer; int is_intra = pSliceParameter->slice_flags.bits.is_intra; + int width_in_mbs = pSequenceParameter->picture_width_in_mbs; + int height_in_mbs = pSequenceParameter->picture_height_in_mbs; + int num_entries; if ( is_intra ) { - media_state->vme_output.num_blocks = width_in_mbs * height_in_mbs; + vme_context->vme_output.num_blocks = width_in_mbs * height_in_mbs; } else { - media_state->vme_output.num_blocks = width_in_mbs * height_in_mbs * 4; + vme_context->vme_output.num_blocks = width_in_mbs * height_in_mbs * 4; } - media_state->vme_output.size_block = 16; /* an OWORD */ - media_state->vme_output.pitch = ALIGN(media_state->vme_output.size_block, 16); + vme_context->vme_output.size_block = 16; /* an OWORD */ + vme_context->vme_output.pitch = ALIGN(vme_context->vme_output.size_block, 16); bo = dri_bo_alloc(i965->intel.bufmgr, "VME output buffer", - media_state->vme_output.num_blocks * media_state->vme_output.pitch, + vme_context->vme_output.num_blocks * vme_context->vme_output.pitch, 0x1000); assert(bo); - media_state->vme_output.bo = bo; + vme_context->vme_output.bo = bo; bo = dri_bo_alloc(i965->intel.bufmgr, "VME output buffer state", @@ -262,37 +265,37 @@ gen6_vme_output_buffer_setup(VADriverContextP ctx, memset(ss, 0, sizeof(*ss)); /* always use 16 bytes as pitch on Sandy Bridge */ - num_entries = media_state->vme_output.num_blocks * media_state->vme_output.pitch / 16; + num_entries = vme_context->vme_output.num_blocks * vme_context->vme_output.pitch / 16; ss->ss0.render_cache_read_mode = 1; ss->ss0.surface_type = I965_SURFACE_BUFFER; - ss->ss1.base_addr = media_state->vme_output.bo->offset; + ss->ss1.base_addr = vme_context->vme_output.bo->offset; ss->ss2.width = ((num_entries - 1) & 0x7f); ss->ss2.height = (((num_entries - 1) >> 7) & 0x1fff); ss->ss3.depth = (((num_entries - 1) >> 20) & 0x7f); - ss->ss3.pitch = media_state->vme_output.pitch - 1; + ss->ss3.pitch = vme_context->vme_output.pitch - 1; dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0, offsetof(struct i965_surface_state, ss1), - media_state->vme_output.bo); + vme_context->vme_output.bo); dri_bo_unmap(bo); assert(index < MAX_MEDIA_SURFACES_GEN6); - media_state->surface_state[index].bo = bo; + vme_context->surface_state[index].bo = bo; return VA_STATUS_SUCCESS; } static VAStatus gen6_vme_surface_setup(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state, - int is_intra) + struct encode_state *encode_state, + int is_intra, + struct gen6_encoder_context *gen6_encoder_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; struct object_surface *obj_surface; unsigned int *binding_table; - dri_bo *bo = media_state->binding_table.bo; + dri_bo *bo = vme_context->binding_table.bo; int i; VAEncPictureParameterBufferH264 *pPicParameter = (VAEncPictureParameterBufferH264 *)encode_state->pic_param->buffer; @@ -300,14 +303,14 @@ static VAStatus gen6_vme_surface_setup(VADriverContextP ctx, /* current picture for encoding */ obj_surface = SURFACE(encode_state->current_render_target); assert(obj_surface); - gen6_vme_source_surface_state(ctx, 0, obj_surface); - gen6_vme_media_source_surface_state(ctx, 4, obj_surface); + gen6_vme_source_surface_state(ctx, 0, obj_surface, gen6_encoder_context); + gen6_vme_media_source_surface_state(ctx, 4, obj_surface, gen6_encoder_context); if ( ! is_intra ) { /* reference 0 */ obj_surface = SURFACE(pPicParameter->reference_picture); assert(obj_surface); - gen6_vme_source_surface_state(ctx, 1, obj_surface); + gen6_vme_source_surface_state(ctx, 1, obj_surface, gen6_encoder_context); /* reference 1, FIXME: */ // obj_surface = SURFACE(pPicParameter->reference_picture); // assert(obj_surface); @@ -315,7 +318,7 @@ static VAStatus gen6_vme_surface_setup(VADriverContextP ctx, } /* VME output */ - gen6_vme_output_buffer_setup(ctx, context, encode_state, 3); + gen6_vme_output_buffer_setup(ctx, encode_state, 3, gen6_encoder_context); /*Building binding table*/ dri_bo_map(bo, 1); @@ -324,32 +327,31 @@ static VAStatus gen6_vme_surface_setup(VADriverContextP ctx, memset(binding_table, 0, bo->size); for (i = 0; i < MAX_MEDIA_SURFACES_GEN6; i++) { - if (media_state->surface_state[i].bo) { - binding_table[i] = media_state->surface_state[i].bo->offset; + if (vme_context->surface_state[i].bo) { + binding_table[i] = vme_context->surface_state[i].bo->offset; dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0, i * sizeof(*binding_table), - media_state->surface_state[i].bo); + vme_context->surface_state[i].bo); } } - dri_bo_unmap(media_state->binding_table.bo); + dri_bo_unmap(vme_context->binding_table.bo); return VA_STATUS_SUCCESS; } static VAStatus gen6_vme_interface_setup(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; struct gen6_interface_descriptor_data *desc; int i; dri_bo *bo; - bo = media_state->idrt.bo; + bo = vme_context->idrt.bo; dri_bo_map(bo, 1); assert(bo->virtual); desc = bo->virtual; @@ -362,9 +364,9 @@ static VAStatus gen6_vme_interface_setup(VADriverContextP ctx, memset(desc, 0, sizeof(*desc)); desc->desc0.kernel_start_pointer = (kernel->bo->offset >> 6); desc->desc2.sampler_count = 1; /* FIXME: */ - desc->desc2.sampler_state_pointer = (media_state->vme_state.bo->offset >> 5); + desc->desc2.sampler_state_pointer = (vme_context->vme_state.bo->offset >> 5); desc->desc3.binding_table_entry_count = 1; /* FIXME: */ - desc->desc3.binding_table_pointer = (media_state->binding_table.bo->offset >> 5); + desc->desc3.binding_table_pointer = (vme_context->binding_table.bo->offset >> 5); desc->desc4.constant_urb_entry_read_offset = 0; desc->desc4.constant_urb_entry_read_length = CURBE_URB_ENTRY_LENGTH; @@ -379,13 +381,13 @@ static VAStatus gen6_vme_interface_setup(VADriverContextP ctx, I915_GEM_DOMAIN_INSTRUCTION, 0, (1 << 2), // i * sizeof(*desc) + offsetof(struct gen6_interface_descriptor_data, desc2), - media_state->vme_state.bo); + vme_context->vme_state.bo); /*binding table*/ dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 4, //One Entry i * sizeof(*desc) + offsetof(struct gen6_interface_descriptor_data, desc3), - media_state->binding_table.bo); + vme_context->binding_table.bo); desc++; } dri_bo_unmap(bo); @@ -394,42 +396,43 @@ static VAStatus gen6_vme_interface_setup(VADriverContextP ctx, } static VAStatus gen6_vme_constant_setup(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; unsigned char *constant_buffer; - dri_bo_map(media_state->curbe.bo, 1); - assert(media_state->curbe.bo->virtual); - constant_buffer = media_state->curbe.bo->virtual; + dri_bo_map(vme_context->curbe.bo, 1); + assert(vme_context->curbe.bo->virtual); + constant_buffer = vme_context->curbe.bo->virtual; /*TODO copy buffer into CURB*/ - dri_bo_unmap( media_state->curbe.bo); + dri_bo_unmap( vme_context->curbe.bo); return VA_STATUS_SUCCESS; } -static VAStatus gen6_vme_vme_state_setup(VADriverContextP ctx, VAContextID context, struct mfc_encode_state *encode_state, int is_intra) +static VAStatus gen6_vme_vme_state_setup(VADriverContextP ctx, + struct encode_state *encode_state, + int is_intra, + struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; unsigned int *vme_state_message; int i; //building VME state message - dri_bo_map(media_state->vme_state.bo, 1); - assert(media_state->vme_state.bo->virtual); - vme_state_message = (unsigned int *)media_state->vme_state.bo->virtual; + dri_bo_map(vme_context->vme_state.bo, 1); + assert(vme_context->vme_state.bo->virtual); + vme_state_message = (unsigned int *)vme_context->vme_state.bo->virtual; for(i = 0;i < 32; i++) { vme_state_message[i] = 0x11; } vme_state_message[16] = 0x42424242; //cost function LUT set 0 for Intra - dri_bo_unmap( media_state->vme_state.bo); + dri_bo_unmap( vme_context->vme_state.bo); return VA_STATUS_SUCCESS; } @@ -465,21 +468,20 @@ static void gen6_vme_state_base_address(VADriverContextP ctx) ADVANCE_BATCH(ctx); } -static void gen6_vme_vfe_state(VADriverContextP ctx) +static void gen6_vme_vfe_state(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; BEGIN_BATCH(ctx, 8); OUT_BATCH(ctx, CMD_MEDIA_VFE_STATE | 6); /*Gen6 CMD_MEDIA_STATE_POINTERS = CMD_MEDIA_STATE */ OUT_BATCH(ctx, 0); /*Scratch Space Base Pointer and Space*/ - OUT_BATCH(ctx, (media_state->vfe_state.max_num_threads << 16) - | (media_state->vfe_state.num_urb_entries << 8) - | (media_state->vfe_state.gpgpu_mode << 2) ); /*Maximum Number of Threads , Number of URB Entries, MEDIA Mode*/ + OUT_BATCH(ctx, (vme_context->vfe_state.max_num_threads << 16) + | (vme_context->vfe_state.num_urb_entries << 8) + | (vme_context->vfe_state.gpgpu_mode << 2) ); /*Maximum Number of Threads , Number of URB Entries, MEDIA Mode*/ OUT_BATCH(ctx, 0); /*Debug: Object ID*/ - OUT_BATCH(ctx, (media_state->vfe_state.urb_entry_size << 16) - | media_state->vfe_state.curbe_allocation_size); /*URB Entry Allocation Size , CURBE Allocation Size*/ + OUT_BATCH(ctx, (vme_context->vfe_state.urb_entry_size << 16) + | vme_context->vfe_state.curbe_allocation_size); /*URB Entry Allocation Size , CURBE Allocation Size*/ OUT_BATCH(ctx, 0); /*Disable Scoreboard*/ OUT_BATCH(ctx, 0); /*Disable Scoreboard*/ OUT_BATCH(ctx, 0); /*Disable Scoreboard*/ @@ -488,10 +490,9 @@ static void gen6_vme_vfe_state(VADriverContextP ctx) } -static void gen6_vme_curbe_load(VADriverContextP ctx) +static void gen6_vme_curbe_load(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; BEGIN_BATCH(ctx, 4); @@ -499,34 +500,32 @@ static void gen6_vme_curbe_load(VADriverContextP ctx) OUT_BATCH(ctx, 0); OUT_BATCH(ctx, CURBE_TOTAL_DATA_LENGTH); - OUT_RELOC(ctx, media_state->curbe.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); + OUT_RELOC(ctx, vme_context->curbe.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); ADVANCE_BATCH(ctx); } -static void gen6_vme_idrt(VADriverContextP ctx) +static void gen6_vme_idrt(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; BEGIN_BATCH(ctx, 4); OUT_BATCH(ctx, CMD_MEDIA_INTERFACE_LOAD | 2); OUT_BATCH(ctx, 0); OUT_BATCH(ctx, GEN6_VME_KERNEL_NUMBER * sizeof(struct gen6_interface_descriptor_data)); - OUT_RELOC(ctx, media_state->idrt.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); + OUT_RELOC(ctx, vme_context->idrt.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); ADVANCE_BATCH(ctx); } static int gen6_vme_media_object(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state, + struct encode_state *encode_state, int mb_x, int mb_y, int kernel) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_surface *obj_surface = SURFACE( encode_state->current_render_target); + struct object_surface *obj_surface = SURFACE(encode_state->current_render_target); int mb_width = ALIGN(obj_surface->orig_width, 16) / 16; int len_in_dowrds = 6 + 1; @@ -546,74 +545,73 @@ static int gen6_vme_media_object(VADriverContextP ctx, return len_in_dowrds * 4; } -static void gen6_vme_media_init(VADriverContextP ctx) +static void gen6_vme_media_init(VADriverContextP ctx, struct gen6_encoder_context *gen6_encoder_context) { int i; struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; + struct gen6_vme_context *vme_context = &gen6_encoder_context->vme_context; dri_bo *bo; /* constant buffer */ - dri_bo_unreference(media_state->curbe.bo); + dri_bo_unreference(vme_context->curbe.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "Buffer", CURBE_TOTAL_DATA_LENGTH, 64); assert(bo); - media_state->curbe.bo = bo; + vme_context->curbe.bo = bo; /* surface state */ for (i = 0; i < MAX_MEDIA_SURFACES_GEN6; i++) { - dri_bo_unreference(media_state->surface_state[i].bo); - media_state->surface_state[i].bo = NULL; + dri_bo_unreference(vme_context->surface_state[i].bo); + vme_context->surface_state[i].bo = NULL; } /* binding table */ - dri_bo_unreference(media_state->binding_table.bo); + dri_bo_unreference(vme_context->binding_table.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "Buffer", MAX_MEDIA_SURFACES_GEN6 * sizeof(unsigned int), 32); assert(bo); - media_state->binding_table.bo = bo; + vme_context->binding_table.bo = bo; /* interface descriptor remapping table */ - dri_bo_unreference(media_state->idrt.bo); + dri_bo_unreference(vme_context->idrt.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "Buffer", MAX_INTERFACE_DESC_GEN6 * sizeof(struct gen6_interface_descriptor_data), 16); assert(bo); - media_state->idrt.bo = bo; + vme_context->idrt.bo = bo; /* VME output buffer */ - dri_bo_unreference(media_state->vme_output.bo); - media_state->vme_output.bo = NULL; + dri_bo_unreference(vme_context->vme_output.bo); + vme_context->vme_output.bo = NULL; /* VME state */ - dri_bo_unreference(media_state->vme_state.bo); + dri_bo_unreference(vme_context->vme_state.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "Buffer", 1024*16, 64); assert(bo); - media_state->vme_state.bo = bo; + vme_context->vme_state.bo = bo; - media_state->vfe_state.max_num_threads = 60 - 1; - media_state->vfe_state.num_urb_entries = 16; - media_state->vfe_state.gpgpu_mode = 0; - media_state->vfe_state.urb_entry_size = 59 - 1; - media_state->vfe_state.curbe_allocation_size = CURBE_ALLOCATION_SIZE - 1; + vme_context->vfe_state.max_num_threads = 60 - 1; + vme_context->vfe_state.num_urb_entries = 16; + vme_context->vfe_state.gpgpu_mode = 0; + vme_context->vfe_state.urb_entry_size = 59 - 1; + vme_context->vfe_state.curbe_allocation_size = CURBE_ALLOCATION_SIZE - 1; } static void gen6_vme_pipeline_programing(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_context *obj_context = CONTEXT(context); - int width_in_mbs = (obj_context->picture_width + 15) / 16; - int height_in_mbs = (obj_context->picture_height + 15) / 16; - int x, y; - int emit_new_state = 1, object_len_in_bytes; VAEncSliceParameterBuffer *pSliceParameter = (VAEncSliceParameterBuffer *)encode_state->slice_params[0]->buffer; + VAEncSequenceParameterBufferH264 *pSequenceParameter = (VAEncSequenceParameterBufferH264 *)encode_state->seq_param->buffer; int is_intra = pSliceParameter->slice_flags.bits.is_intra; + int width_in_mbs = pSequenceParameter->picture_width_in_mbs; + int height_in_mbs = pSequenceParameter->picture_height_in_mbs; + int emit_new_state = 1, object_len_in_bytes; + int x, y; intel_batchbuffer_start_atomic(ctx, 0x1000); @@ -634,15 +632,15 @@ static void gen6_vme_pipeline_programing(VADriverContextP ctx, /*Step3: State commands configuring pipeline states*/ gen6_vme_state_base_address(ctx); - gen6_vme_vfe_state(ctx); - gen6_vme_curbe_load(ctx); - gen6_vme_idrt(ctx); + gen6_vme_vfe_state(ctx, gen6_encoder_context); + gen6_vme_curbe_load(ctx, gen6_encoder_context); + gen6_vme_idrt(ctx, gen6_encoder_context); emit_new_state = 0; } /*Step4: Primitive commands*/ - object_len_in_bytes = gen6_vme_media_object(ctx, context, encode_state, x, y, is_intra ? VME_INTRA_SHADER : VME_INTER_SHADER); + object_len_in_bytes = gen6_vme_media_object(ctx, encode_state, x, y, is_intra ? VME_INTRA_SHADER : VME_INTER_SHADER); if (intel_batchbuffer_check_free_space(ctx, object_len_in_bytes) == 0) { intel_batchbuffer_end_atomic(ctx); @@ -657,28 +655,28 @@ static void gen6_vme_pipeline_programing(VADriverContextP ctx, } static VAStatus gen6_vme_prepare(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { VAStatus vaStatus = VA_STATUS_SUCCESS; VAEncSliceParameterBuffer *pSliceParameter = (VAEncSliceParameterBuffer *)encode_state->slice_params[0]->buffer; int is_intra = pSliceParameter->slice_flags.bits.is_intra; /*Setup all the memory object*/ - gen6_vme_surface_setup(ctx, context, encode_state, is_intra); - gen6_vme_interface_setup(ctx, context, encode_state); - gen6_vme_constant_setup(ctx, context, encode_state); - gen6_vme_vme_state_setup(ctx, context, encode_state, is_intra); + gen6_vme_surface_setup(ctx, encode_state, is_intra, gen6_encoder_context); + gen6_vme_interface_setup(ctx, encode_state, gen6_encoder_context); + gen6_vme_constant_setup(ctx, encode_state, gen6_encoder_context); + gen6_vme_vme_state_setup(ctx, encode_state, is_intra, gen6_encoder_context); /*Programing media pipeline*/ - gen6_vme_pipeline_programing(ctx, context, encode_state); + gen6_vme_pipeline_programing(ctx, encode_state, gen6_encoder_context); return vaStatus; } static VAStatus gen6_vme_run(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { intel_batchbuffer_flush(ctx); @@ -686,25 +684,26 @@ static VAStatus gen6_vme_run(VADriverContextP ctx, } static VAStatus gen6_vme_stop(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { return VA_STATUS_SUCCESS; } -VAStatus gen6_vme_media_pipeline(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) +VAStatus gen6_vme_pipeline(VADriverContextP ctx, + VAProfile profile, + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context) { - gen6_vme_media_init(ctx); - gen6_vme_prepare(ctx, context, encode_state); - gen6_vme_run(ctx, context, encode_state); - gen6_vme_stop(ctx, context, encode_state); + gen6_vme_media_init(ctx, gen6_encoder_context); + gen6_vme_prepare(ctx, encode_state, gen6_encoder_context); + gen6_vme_run(ctx, encode_state, gen6_encoder_context); + gen6_vme_stop(ctx, encode_state, gen6_encoder_context); return VA_STATUS_SUCCESS; } -Bool gen6_vme_init(VADriverContextP ctx) +Bool gen6_vme_context_init(VADriverContextP ctx, struct gen6_vme_context *vme_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); int i; @@ -724,10 +723,30 @@ Bool gen6_vme_init(VADriverContextP ctx) return True; } -Bool gen6_vme_terminate(VADriverContextP ctx) +Bool gen6_vme_context_destroy(struct gen6_vme_context *vme_context) { int i; + for (i = 0; i < MAX_MEDIA_SURFACES_GEN6; i++) { + dri_bo_unreference(vme_context->surface_state[i].bo); + vme_context->surface_state[i].bo = NULL; + } + + dri_bo_unreference(vme_context->idrt.bo); + vme_context->idrt.bo = NULL; + + dri_bo_unreference(vme_context->binding_table.bo); + vme_context->binding_table.bo = NULL; + + dri_bo_unreference(vme_context->curbe.bo); + vme_context->curbe.bo = NULL; + + dri_bo_unreference(vme_context->vme_output.bo); + vme_context->vme_output.bo = NULL; + + dri_bo_unreference(vme_context->vme_state.bo); + vme_context->vme_state.bo = NULL; + for (i = 0; i < GEN6_VME_KERNEL_NUMBER; i++) { /*Load kernel into GPU memory*/ struct media_kernel *kernel = &gen6_vme_kernels[i]; diff --git a/i965_drv_video/gen6_vme.h b/i965_drv_video/gen6_vme.h index 57b23f1..a63bc18 100644 --- a/i965_drv_video/gen6_vme.h +++ b/i965_drv_video/gen6_vme.h @@ -26,8 +26,8 @@ * */ -#ifndef _GEN6_MEDIA_H_ -#define _GEN6_MEDIA_H_ +#ifndef _GEN6_VME_H_ +#define _GEN6_VME_H_ #include <xf86drm.h> #include <drm.h> @@ -38,9 +38,10 @@ #define MAX_INTERFACE_DESC_GEN6 32 #define MAX_MEDIA_SURFACES_GEN6 34 -struct mfc_encode_state; +struct encode_state; +struct gen6_encoder_context; -struct gen6_media_state +struct gen6_vme_context { struct { dri_bo *bo; @@ -78,10 +79,11 @@ struct gen6_media_state } vme_output; }; -VAStatus gen6_vme_media_pipeline(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state); -Bool gen6_vme_init(VADriverContextP ctx); -Bool gen6_vme_terminate(VADriverContextP ctx); +VAStatus gen6_vme_pipeline(VADriverContextP ctx, + VAProfile profile, + struct encode_state *encode_state, + struct gen6_encoder_context *gen6_encoder_context); +Bool gen6_vme_context_init(VADriverContextP ctx, struct gen6_vme_context *vme_context); +Bool gen6_vme_context_destroy(struct gen6_vme_context *vme_context); -#endif /* _GEN6_MEDIA_H_ */ +#endif /* _GEN6_VME_H_ */ diff --git a/i965_drv_video/i965_avc_bsd.c b/i965_drv_video/i965_avc_bsd.c index 89bd169..41fb8fc 100644 --- a/i965_drv_video/i965_avc_bsd.c +++ b/i965_drv_video/i965_avc_bsd.c @@ -61,11 +61,10 @@ i965_avc_bsd_free_avc_bsd_surface(void **data) static void i965_avc_bsd_init_avc_bsd_surface(VADriverContextP ctx, struct object_surface *obj_surface, - VAPictureParameterBufferH264 *pic_param) + VAPictureParameterBufferH264 *pic_param, + struct i965_h264_context *i965_h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_bsd_context *i965_avc_bsd_context = &i965_h264_context->i965_avc_bsd_context; struct i965_avc_bsd_surface *avc_bsd_surface = obj_surface->private_data; @@ -112,11 +111,10 @@ i965_bsd_ind_obj_base_address(VADriverContextP ctx, struct decode_state *decode_ } static void -i965_avc_bsd_img_state(VADriverContextP ctx, struct decode_state *decode_state) +i965_avc_bsd_img_state(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; int qm_present_flag; int img_struct; int mbaff_frame_flag; @@ -248,11 +246,9 @@ i965_avc_bsd_qm_state(VADriverContextP ctx, struct decode_state *decode_state) static void i965_avc_bsd_slice_state(VADriverContextP ctx, VAPictureParameterBufferH264 *pic_param, - VASliceParameterBufferH264 *slice_param) + VASliceParameterBufferH264 *slice_param, + struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; int present_flag, cmd_len, list, j; struct { unsigned char bottom_idc:1; @@ -420,19 +416,16 @@ i965_avc_bsd_slice_state(VADriverContextP ctx, static void i965_avc_bsd_buf_base_state(VADriverContextP ctx, VAPictureParameterBufferH264 *pic_param, - VASliceParameterBufferH264 *slice_param) + VASliceParameterBufferH264 *slice_param, + struct i965_h264_context *i965_h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context; struct i965_avc_bsd_context *i965_avc_bsd_context; int i, j; VAPictureH264 *va_pic; struct object_surface *obj_surface; struct i965_avc_bsd_surface *avc_bsd_surface; - assert(media_state->private_context); - i965_h264_context = (struct i965_h264_context *)media_state->private_context; i965_avc_bsd_context = &i965_h264_context->i965_avc_bsd_context; BEGIN_BCS_BATCH(ctx, 74); @@ -509,7 +502,7 @@ i965_avc_bsd_buf_base_state(VADriverContextP ctx, assert(obj_surface); obj_surface->flags &= ~SURFACE_REF_DIS_MASK; obj_surface->flags |= (pic_param->pic_fields.bits.reference_pic_flag ? SURFACE_REFERENCED : 0); - i965_avc_bsd_init_avc_bsd_surface(ctx, obj_surface, pic_param); + i965_avc_bsd_init_avc_bsd_surface(ctx, obj_surface, pic_param, i965_h264_context); avc_bsd_surface = obj_surface->private_data; if (obj_surface->bo == NULL) { @@ -601,7 +594,8 @@ g4x_avc_bsd_object(VADriverContextP ctx, struct decode_state *decode_state, VAPictureParameterBufferH264 *pic_param, VASliceParameterBufferH264 *slice_param, - int slice_index) + int slice_index, + struct i965_h264_context *i965_h264_context) { int width_in_mbs = pic_param->picture_width_in_mbs_minus1 + 1; int height_in_mbs = pic_param->picture_height_in_mbs_minus1 + 1; /* frame height */ @@ -728,15 +722,13 @@ ironlake_avc_bsd_object(VADriverContextP ctx, struct decode_state *decode_state, VAPictureParameterBufferH264 *pic_param, VASliceParameterBufferH264 *slice_param, - int slice_index) + int slice_index, + struct i965_h264_context *i965_h264_context) { int width_in_mbs = pic_param->picture_width_in_mbs_minus1 + 1; int height_in_mbs = pic_param->picture_height_in_mbs_minus1 + 1; /* frame height */ if (slice_param) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; int encrypted, counter_value; int slice_hor_pos, slice_ver_pos; int num_ref_idx_l0, num_ref_idx_l1; @@ -873,31 +865,32 @@ i965_avc_bsd_object(VADriverContextP ctx, struct decode_state *decode_state, VAPictureParameterBufferH264 *pic_param, VASliceParameterBufferH264 *slice_param, - int slice_index) + int slice_index, + struct i965_h264_context *i965_h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); if (IS_IRONLAKE(i965->intel.device_id)) - ironlake_avc_bsd_object(ctx, decode_state, pic_param, slice_param, slice_index); + ironlake_avc_bsd_object(ctx, decode_state, pic_param, slice_param, slice_index, i965_h264_context); else - g4x_avc_bsd_object(ctx, decode_state, pic_param, slice_param, slice_index); + g4x_avc_bsd_object(ctx, decode_state, pic_param, slice_param, slice_index, i965_h264_context); } static void i965_avc_bsd_phantom_slice(VADriverContextP ctx, struct decode_state *decode_state, - VAPictureParameterBufferH264 *pic_param) + VAPictureParameterBufferH264 *pic_param, + struct i965_h264_context *i965_h264_context) { - i965_avc_bsd_object(ctx, decode_state, pic_param, NULL, 0); + i965_avc_bsd_object(ctx, decode_state, pic_param, NULL, 0, i965_h264_context); } static void i965_avc_bsd_frame_store_index(VADriverContextP ctx, - VAPictureParameterBufferH264 *pic_param) + VAPictureParameterBufferH264 *pic_param, + struct i965_h264_context *i965_h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; int i, j; assert(ARRAY_ELEMS(i965_h264_context->fsid_list) == ARRAY_ELEMS(pic_param->ReferenceFrames)); @@ -1015,18 +1008,16 @@ i965_avc_bsd_frame_store_index(VADriverContextP ctx, } void -i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state) +i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state, void *h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; + struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)h264_context; VAPictureParameterBufferH264 *pic_param; VASliceParameterBufferH264 *slice_param; int i, j; assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer; - i965_avc_bsd_frame_store_index(ctx, pic_param); + i965_avc_bsd_frame_store_index(ctx, pic_param, i965_h264_context); i965_h264_context->enable_avc_ildb = 0; i965_h264_context->picture.i_flag = 1; @@ -1055,7 +1046,7 @@ i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state) intel_batchbuffer_start_atomic_bcs(ctx, 0x1000); - i965_avc_bsd_img_state(ctx, decode_state); + i965_avc_bsd_img_state(ctx, decode_state, i965_h264_context); i965_avc_bsd_qm_state(ctx, decode_state); for (j = 0; j < decode_state->num_slice_params; j++) { @@ -1078,25 +1069,24 @@ i965_avc_bsd_pipeline(VADriverContextP ctx, struct decode_state *decode_state) slice_param->slice_type != SLICE_TYPE_SI)) i965_h264_context->picture.i_flag = 0; - i965_avc_bsd_slice_state(ctx, pic_param, slice_param); - i965_avc_bsd_buf_base_state(ctx, pic_param, slice_param); - i965_avc_bsd_object(ctx, decode_state, pic_param, slice_param, j); + i965_avc_bsd_slice_state(ctx, pic_param, slice_param, i965_h264_context); + i965_avc_bsd_buf_base_state(ctx, pic_param, slice_param, i965_h264_context); + i965_avc_bsd_object(ctx, decode_state, pic_param, slice_param, j, i965_h264_context); slice_param++; } } - i965_avc_bsd_phantom_slice(ctx, decode_state, pic_param); + i965_avc_bsd_phantom_slice(ctx, decode_state, pic_param, i965_h264_context); intel_batchbuffer_emit_mi_flush_bcs(ctx); intel_batchbuffer_end_atomic_bcs(ctx); intel_batchbuffer_flush_bcs(ctx); } void -i965_avc_bsd_decode_init(VADriverContextP ctx) +i965_avc_bsd_decode_init(VADriverContextP ctx, void *h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; + struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)h264_context; struct i965_avc_bsd_context *i965_avc_bsd_context; dri_bo *bo; @@ -1118,10 +1108,6 @@ i965_avc_bsd_decode_init(VADriverContextP ctx) 64); assert(bo); i965_avc_bsd_context->mpr_row_store.bo = bo; - - if (!i965_avc_bsd_context->init) { - i965_avc_bsd_context->init = 1; - } } Bool diff --git a/i965_drv_video/i965_avc_bsd.h b/i965_drv_video/i965_avc_bsd.h index e064de8..25606ba 100644 --- a/i965_drv_video/i965_avc_bsd.h +++ b/i965_drv_video/i965_avc_bsd.h @@ -40,8 +40,6 @@ struct i965_avc_bsd_context struct { dri_bo *bo; } mpr_row_store; - - int init; }; struct i965_avc_bsd_surface @@ -52,8 +50,8 @@ struct i965_avc_bsd_surface int dmv_bottom_flag; }; -void i965_avc_bsd_pipeline(VADriverContextP, struct decode_state *); -void i965_avc_bsd_decode_init(VADriverContextP); +void i965_avc_bsd_pipeline(VADriverContextP, struct decode_state *, void *h264_context); +void i965_avc_bsd_decode_init(VADriverContextP, void *h264_context); Bool i965_avc_bsd_ternimate(struct i965_avc_bsd_context *); #endif /* __I965_AVC_BSD_H__ */ diff --git a/i965_drv_video/i965_avc_hw_scoreboard.c b/i965_drv_video/i965_avc_hw_scoreboard.c index 2398599..3dd9025 100644 --- a/i965_drv_video/i965_avc_hw_scoreboard.c +++ b/i965_drv_video/i965_avc_hw_scoreboard.c @@ -322,11 +322,9 @@ i965_avc_hw_scoreboard_pipeline_setup(VADriverContextP ctx, struct i965_avc_hw_s } void -i965_avc_hw_scoreboard(VADriverContextP ctx, struct decode_state *decode_state) +i965_avc_hw_scoreboard(VADriverContextP ctx, struct decode_state *decode_state, void *h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; + struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)h264_context; if (i965_h264_context->use_avc_hw_scoreboard) { struct i965_avc_hw_scoreboard_context *avc_hw_scoreboard_context = &i965_h264_context->avc_hw_scoreboard_context; @@ -352,11 +350,10 @@ i965_avc_hw_scoreboard(VADriverContextP ctx, struct decode_state *decode_state) } void -i965_avc_hw_scoreboard_decode_init(VADriverContextP ctx) +i965_avc_hw_scoreboard_decode_init(VADriverContextP ctx, void *h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; + struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)h264_context; if (i965_h264_context->use_avc_hw_scoreboard) { struct i965_avc_hw_scoreboard_context *avc_hw_scoreboard_context = &i965_h264_context->avc_hw_scoreboard_context; diff --git a/i965_drv_video/i965_avc_hw_scoreboard.h b/i965_drv_video/i965_avc_hw_scoreboard.h index 99c0a43..bca8831 100644 --- a/i965_drv_video/i965_avc_hw_scoreboard.h +++ b/i965_drv_video/i965_avc_hw_scoreboard.h @@ -77,8 +77,8 @@ struct i965_avc_hw_scoreboard_context } urb; }; -void i965_avc_hw_scoreboard(VADriverContextP, struct decode_state *); -void i965_avc_hw_scoreboard_decode_init(VADriverContextP); +void i965_avc_hw_scoreboard(VADriverContextP, struct decode_state *, void *h264_context); +void i965_avc_hw_scoreboard_decode_init(VADriverContextP, void *h264_context); Bool i965_avc_hw_scoreboard_ternimate(struct i965_avc_hw_scoreboard_context *); #endif /* __I965_AVC_HW_SCOREBOARD_H__ */ diff --git a/i965_drv_video/i965_avc_ildb.c b/i965_drv_video/i965_avc_ildb.c index a6be42b..44c3b53 100644 --- a/i965_drv_video/i965_avc_ildb.c +++ b/i965_drv_video/i965_avc_ildb.c @@ -129,11 +129,11 @@ extern struct media_kernel *h264_avc_kernels; static unsigned long *avc_ildb_kernel_offset = NULL; static void -i965_avc_ildb_surface_state(VADriverContextP ctx, struct decode_state *decode_state) +i965_avc_ildb_surface_state(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_h264_context *i965_h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; struct i965_surface_state *ss; struct object_surface *obj_surface; @@ -237,11 +237,8 @@ i965_avc_ildb_surface_state(VADriverContextP ctx, struct decode_state *decode_st } static void -i965_avc_ildb_binding_table(VADriverContextP ctx) +i965_avc_ildb_binding_table(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; unsigned int *binding_table; dri_bo *bo = avc_ildb_context->binding_table.bo; @@ -265,11 +262,8 @@ i965_avc_ildb_binding_table(VADriverContextP ctx) } static void -i965_avc_ildb_interface_descriptor_table(VADriverContextP ctx) +i965_avc_ildb_interface_descriptor_table(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; struct i965_interface_descriptor *desc; dri_bo *bo; @@ -311,11 +305,8 @@ i965_avc_ildb_interface_descriptor_table(VADriverContextP ctx) } static void -i965_avc_ildb_vfe_state(VADriverContextP ctx) +i965_avc_ildb_vfe_state(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; struct i965_vfe_state *vfe_state; dri_bo *bo; @@ -341,11 +332,11 @@ i965_avc_ildb_vfe_state(VADriverContextP ctx) } static void -i965_avc_ildb_upload_constants(VADriverContextP ctx, struct decode_state *decode_state) +i965_avc_ildb_upload_constants(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_h264_context *i965_h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; VAPictureParameterBufferH264 *pic_param; struct avc_ildb_root_input *root_input; @@ -395,13 +386,15 @@ i965_avc_ildb_upload_constants(VADriverContextP ctx, struct decode_state *decode } static void -i965_avc_ildb_states_setup(VADriverContextP ctx, struct decode_state *decode_state) +i965_avc_ildb_states_setup(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_h264_context *i965_h264_context) { - i965_avc_ildb_surface_state(ctx, decode_state); - i965_avc_ildb_binding_table(ctx); - i965_avc_ildb_interface_descriptor_table(ctx); - i965_avc_ildb_vfe_state(ctx); - i965_avc_ildb_upload_constants(ctx, decode_state); + i965_avc_ildb_surface_state(ctx, decode_state, i965_h264_context); + i965_avc_ildb_binding_table(ctx, i965_h264_context); + i965_avc_ildb_interface_descriptor_table(ctx, i965_h264_context); + i965_avc_ildb_vfe_state(ctx, i965_h264_context); + i965_avc_ildb_upload_constants(ctx, decode_state, i965_h264_context); } static void @@ -413,11 +406,9 @@ i965_avc_ildb_pipeline_select(VADriverContextP ctx) } static void -i965_avc_ildb_urb_layout(VADriverContextP ctx) +i965_avc_ildb_urb_layout(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; unsigned int vfe_fence, cs_fence; @@ -463,11 +454,8 @@ i965_avc_ildb_state_base_address(VADriverContextP ctx) } static void -i965_avc_ildb_state_pointers(VADriverContextP ctx) +i965_avc_ildb_state_pointers(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; BEGIN_BATCH(ctx, 3); @@ -478,11 +466,8 @@ i965_avc_ildb_state_pointers(VADriverContextP ctx) } static void -i965_avc_ildb_cs_urb_layout(VADriverContextP ctx) +i965_avc_ildb_cs_urb_layout(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; BEGIN_BATCH(ctx, 2); @@ -494,11 +479,8 @@ i965_avc_ildb_cs_urb_layout(VADriverContextP ctx) } static void -i965_avc_ildb_constant_buffer(VADriverContextP ctx) +i965_avc_ildb_constant_buffer(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; BEGIN_BATCH(ctx, 2); @@ -510,11 +492,8 @@ i965_avc_ildb_constant_buffer(VADriverContextP ctx) } static void -i965_avc_ildb_objects(VADriverContextP ctx) +i965_avc_ildb_objects(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context; BEGIN_BATCH(ctx, 6); @@ -547,37 +526,34 @@ i965_avc_ildb_objects(VADriverContextP ctx) } static void -i965_avc_ildb_pipeline_setup(VADriverContextP ctx) +i965_avc_ildb_pipeline_setup(VADriverContextP ctx, struct i965_h264_context *i965_h264_context) { intel_batchbuffer_emit_mi_flush(ctx); i965_avc_ildb_pipeline_select(ctx); i965_avc_ildb_state_base_address(ctx); - i965_avc_ildb_state_pointers(ctx); - i965_avc_ildb_urb_layout(ctx); - i965_avc_ildb_cs_urb_layout(ctx); - i965_avc_ildb_constant_buffer(ctx); - i965_avc_ildb_objects(ctx); + i965_avc_ildb_state_pointers(ctx, i965_h264_context); + i965_avc_ildb_urb_layout(ctx, i965_h264_context); + i965_avc_ildb_cs_urb_layout(ctx, i965_h264_context); + i965_avc_ildb_constant_buffer(ctx, i965_h264_context); + i965_avc_ildb_objects(ctx, i965_h264_context); } void -i965_avc_ildb(VADriverContextP ctx, struct decode_state *decode_state) +i965_avc_ildb(VADriverContextP ctx, struct decode_state *decode_state, void *h264_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; + struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)h264_context; if (i965_h264_context->enable_avc_ildb) { - i965_avc_ildb_states_setup(ctx, decode_state); - i965_avc_ildb_pipeline_setup(ctx); + i965_avc_ildb_states_setup(ctx, decode_state, i965_h264_context); + i965_avc_ildb_pipeline_setup(ctx, i965_h264_context); } } void -i965_avc_ildb_decode_init(VADriverContextP ctx) +i965_avc_ildb_decode_init(VADriverContextP ctx, void *h264_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)media_state->private_context; + struct i965_h264_context *i965_h264_context = (struct i965_h264_context *)h264_context; struct i965_avc_ildb_context *avc_ildb_context = &i965_h264_context->avc_ildb_context;; dri_bo *bo; int i; diff --git a/i965_drv_video/i965_avc_ildb.h b/i965_drv_video/i965_avc_ildb.h index d48bb50..ff16ac6 100644 --- a/i965_drv_video/i965_avc_ildb.h +++ b/i965_drv_video/i965_avc_ildb.h @@ -88,8 +88,8 @@ struct i965_avc_ildb_context int mbs_per_picture; }; -void i965_avc_ildb(VADriverContextP, struct decode_state *); -void i965_avc_ildb_decode_init(VADriverContextP); +void i965_avc_ildb(VADriverContextP, struct decode_state *, void *h264_context); +void i965_avc_ildb_decode_init(VADriverContextP, void *h264_context); Bool i965_avc_ildb_ternimate(struct i965_avc_ildb_context *); #endif /* __I965_AVC_ILDB_H__ */ diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c index 77801ba..8f353f1 100644 --- a/i965_drv_video/i965_drv_video.c +++ b/i965_drv_video/i965_drv_video.c @@ -37,11 +37,8 @@ #include "intel_driver.h" #include "intel_memman.h" #include "intel_batchbuffer.h" - -#include "i965_media.h" -#include "i965_drv_video.h" #include "i965_defines.h" -#include "i965_encoder.h" +#include "i965_drv_video.h" #define CONFIG_ID_OFFSET 0x01000000 #define CONTEXT_ID_OFFSET 0x02000000 @@ -132,6 +129,25 @@ get_subpic_format(const VAImageFormat *va_format) return NULL; } +extern struct hw_context *g4x_dec_hw_context_init(VADriverContextP, VAProfile); +static struct hw_codec_info g4x_hw_codec_info = { + .dec_hw_context_init = g4x_dec_hw_context_init, + .enc_hw_context_init = NULL, +}; + +extern struct hw_context *ironlake_dec_hw_context_init(VADriverContextP, VAProfile); +static struct hw_codec_info ironlake_hw_codec_info = { + .dec_hw_context_init = ironlake_dec_hw_context_init, + .enc_hw_context_init = NULL, +}; + +extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, VAProfile); +extern struct hw_context *gen6_enc_hw_context_init(VADriverContextP, VAProfile); +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, +}; + VAStatus i965_QueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, /* out */ @@ -362,7 +378,6 @@ 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; @@ -736,26 +751,38 @@ i965_destroy_context(struct object_heap *heap, struct object_base *obj) struct object_context *obj_context = (struct object_context *)obj; int i; - assert(obj_context->decode_state.num_slice_params <= obj_context->decode_state.max_slice_params); - assert(obj_context->decode_state.num_slice_datas <= obj_context->decode_state.max_slice_datas); + if (obj_context->hw_context) { + obj_context->hw_context->destroy(obj_context->hw_context); + obj_context->hw_context = NULL; + } + + if (obj_context->codec_type == CODEC_ENC) { + assert(obj_context->codec_state.enc.num_slice_params <= obj_context->codec_state.enc.max_slice_params); + i965_release_buffer_store(&obj_context->codec_state.enc.pic_param); + i965_release_buffer_store(&obj_context->codec_state.enc.seq_param); + } else { + assert(obj_context->codec_state.dec.num_slice_params <= obj_context->codec_state.dec.max_slice_params); + assert(obj_context->codec_state.dec.num_slice_datas <= obj_context->codec_state.dec.max_slice_datas); + + i965_release_buffer_store(&obj_context->codec_state.dec.pic_param); + i965_release_buffer_store(&obj_context->codec_state.dec.iq_matrix); + i965_release_buffer_store(&obj_context->codec_state.dec.bit_plane); - i965_release_buffer_store(&obj_context->decode_state.pic_param); - i965_release_buffer_store(&obj_context->decode_state.iq_matrix); - i965_release_buffer_store(&obj_context->decode_state.bit_plane); + for (i = 0; i < obj_context->codec_state.dec.num_slice_params; i++) + i965_release_buffer_store(&obj_context->codec_state.dec.slice_params[i]); - for (i = 0; i < obj_context->decode_state.num_slice_params; i++) - i965_release_buffer_store(&obj_context->decode_state.slice_params[i]); + for (i = 0; i < obj_context->codec_state.dec.num_slice_datas; i++) + i965_release_buffer_store(&obj_context->codec_state.dec.slice_datas[i]); - for (i = 0; i < obj_context->decode_state.num_slice_datas; i++) - i965_release_buffer_store(&obj_context->decode_state.slice_datas[i]); + free(obj_context->codec_state.dec.slice_params); + free(obj_context->codec_state.dec.slice_datas); + } - free(obj_context->decode_state.slice_params); - free(obj_context->decode_state.slice_datas); free(obj_context->render_targets); object_heap_free(heap, obj); } -VAStatus +VAStatus i965_CreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, @@ -812,6 +839,7 @@ i965_CreateContext(VADriverContextP ctx, obj_context->num_render_targets = num_render_targets; obj_context->render_targets = (VASurfaceID *)calloc(num_render_targets, sizeof(VASurfaceID)); + obj_context->hw_context = NULL; for(i = 0; i < num_render_targets; i++) { if (NULL == SURFACE(render_targets[i])) { @@ -824,18 +852,27 @@ i965_CreateContext(VADriverContextP ctx, if (VA_STATUS_SUCCESS == vaStatus) { if (VAEntrypointEncSlice == obj_config->entrypoint ) { /*encode routin only*/ - memset(&obj_context->encode_state, 0, sizeof(obj_context->encode_state)); - vaStatus = i965_encoder_create_context(ctx, config_id, picture_width, picture_height, - flag, render_targets, num_render_targets, obj_context); + obj_context->codec_type = CODEC_ENC; + memset(&obj_context->codec_state.enc, 0, sizeof(obj_context->codec_state.enc)); + obj_context->codec_state.enc.current_render_target = VA_INVALID_ID; + obj_context->codec_state.enc.max_slice_params = NUM_SLICES; + obj_context->codec_state.enc.slice_params = calloc(obj_context->codec_state.enc.max_slice_params, + sizeof(*obj_context->codec_state.enc.slice_params)); + assert(i965->codec_info->enc_hw_context_init); + obj_context->hw_context = i965->codec_info->enc_hw_context_init(ctx, obj_config->profile); } else { - memset(&obj_context->decode_state, 0, sizeof(obj_context->decode_state)); - obj_context->decode_state.current_render_target = -1; - obj_context->decode_state.max_slice_params = NUM_SLICES; - obj_context->decode_state.max_slice_datas = NUM_SLICES; - obj_context->decode_state.slice_params = calloc(obj_context->decode_state.max_slice_params, - sizeof(*obj_context->decode_state.slice_params)); - obj_context->decode_state.slice_datas = calloc(obj_context->decode_state.max_slice_datas, - sizeof(*obj_context->decode_state.slice_datas)); + obj_context->codec_type = CODEC_DEC; + memset(&obj_context->codec_state.dec, 0, sizeof(obj_context->codec_state.dec)); + obj_context->codec_state.dec.current_render_target = -1; + obj_context->codec_state.dec.max_slice_params = NUM_SLICES; + obj_context->codec_state.dec.max_slice_datas = NUM_SLICES; + obj_context->codec_state.dec.slice_params = calloc(obj_context->codec_state.dec.max_slice_params, + sizeof(*obj_context->codec_state.dec.slice_params)); + obj_context->codec_state.dec.slice_datas = calloc(obj_context->codec_state.dec.max_slice_datas, + sizeof(*obj_context->codec_state.dec.slice_datas)); + + assert(i965->codec_info->dec_hw_context_init); + obj_context->hw_context = i965->codec_info->dec_hw_context_init(ctx, obj_config->profile); } } @@ -852,19 +889,9 @@ i965_DestroyContext(VADriverContextP ctx, VAContextID context) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_context *obj_context = CONTEXT(context); - struct object_config *obj_config; - VAContextID config; assert(obj_context); - config = obj_context->config_id; - obj_config = CONFIG(config); - assert(obj_config); - - if (VAEntrypointEncSlice == obj_config->entrypoint ){ - i965_encoder_destroy_context(&i965->context_heap, (struct object_base *)obj_context); - } else { - i965_destroy_context(&i965->context_heap, (struct object_base *)obj_context); - } + i965_destroy_context(&i965->context_heap, (struct object_base *)obj_context); return VA_STATUS_SUCCESS; } @@ -1103,7 +1130,6 @@ 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); @@ -1118,11 +1144,6 @@ i965_BeginPicture(VADriverContextP ctx, obj_config = CONFIG(config); assert(obj_config); - if (VAEntrypointEncSlice == obj_config->entrypoint ){ - vaStatus = i965_encoder_begin_picture(ctx, context, render_target); - return vaStatus; - } - switch (obj_config->profile) { case VAProfileMPEG2Simple: case VAProfileMPEG2Main: @@ -1147,7 +1168,10 @@ i965_BeginPicture(VADriverContextP ctx, break; } - obj_context->decode_state.current_render_target = render_target; + if (obj_context->codec_type == CODEC_ENC) + obj_context->codec_state.enc.current_render_target = render_target; /*This is input new frame*/ + else + obj_context->codec_state.dec.current_render_target = render_target; return vaStatus; } @@ -1159,8 +1183,8 @@ i965_render_picture_parameter_buffer(VADriverContextP ctx, { assert(obj_buffer->buffer_store->bo == NULL); assert(obj_buffer->buffer_store->buffer); - i965_release_buffer_store(&obj_context->decode_state.pic_param); - i965_reference_buffer_store(&obj_context->decode_state.pic_param, + i965_release_buffer_store(&obj_context->codec_state.dec.pic_param); + i965_reference_buffer_store(&obj_context->codec_state.dec.pic_param, obj_buffer->buffer_store); return VA_STATUS_SUCCESS; @@ -1173,8 +1197,8 @@ i965_render_iq_matrix_buffer(VADriverContextP ctx, { assert(obj_buffer->buffer_store->bo == NULL); assert(obj_buffer->buffer_store->buffer); - i965_release_buffer_store(&obj_context->decode_state.iq_matrix); - i965_reference_buffer_store(&obj_context->decode_state.iq_matrix, + i965_release_buffer_store(&obj_context->codec_state.dec.iq_matrix); + i965_reference_buffer_store(&obj_context->codec_state.dec.iq_matrix, obj_buffer->buffer_store); return VA_STATUS_SUCCESS; @@ -1187,8 +1211,8 @@ i965_render_bit_plane_buffer(VADriverContextP ctx, { assert(obj_buffer->buffer_store->bo == NULL); assert(obj_buffer->buffer_store->buffer); - i965_release_buffer_store(&obj_context->decode_state.bit_plane); - i965_reference_buffer_store(&obj_context->decode_state.bit_plane, + i965_release_buffer_store(&obj_context->codec_state.dec.bit_plane); + i965_reference_buffer_store(&obj_context->codec_state.dec.bit_plane, obj_buffer->buffer_store); return VA_STATUS_SUCCESS; @@ -1202,17 +1226,17 @@ i965_render_slice_parameter_buffer(VADriverContextP ctx, assert(obj_buffer->buffer_store->bo == NULL); assert(obj_buffer->buffer_store->buffer); - if (obj_context->decode_state.num_slice_params == obj_context->decode_state.max_slice_params) { - obj_context->decode_state.slice_params = realloc(obj_context->decode_state.slice_params, - (obj_context->decode_state.max_slice_params + NUM_SLICES) * sizeof(*obj_context->decode_state.slice_params)); - memset(obj_context->decode_state.slice_params + obj_context->decode_state.max_slice_params, 0, NUM_SLICES * sizeof(*obj_context->decode_state.slice_params)); - obj_context->decode_state.max_slice_params += NUM_SLICES; + if (obj_context->codec_state.dec.num_slice_params == obj_context->codec_state.dec.max_slice_params) { + obj_context->codec_state.dec.slice_params = realloc(obj_context->codec_state.dec.slice_params, + (obj_context->codec_state.dec.max_slice_params + NUM_SLICES) * sizeof(*obj_context->codec_state.dec.slice_params)); + memset(obj_context->codec_state.dec.slice_params + obj_context->codec_state.dec.max_slice_params, 0, NUM_SLICES * sizeof(*obj_context->codec_state.dec.slice_params)); + obj_context->codec_state.dec.max_slice_params += NUM_SLICES; } - i965_release_buffer_store(&obj_context->decode_state.slice_params[obj_context->decode_state.num_slice_params]); - i965_reference_buffer_store(&obj_context->decode_state.slice_params[obj_context->decode_state.num_slice_params], + i965_release_buffer_store(&obj_context->codec_state.dec.slice_params[obj_context->codec_state.dec.num_slice_params]); + i965_reference_buffer_store(&obj_context->codec_state.dec.slice_params[obj_context->codec_state.dec.num_slice_params], obj_buffer->buffer_store); - obj_context->decode_state.num_slice_params++; + obj_context->codec_state.dec.num_slice_params++; return VA_STATUS_SUCCESS; } @@ -1225,45 +1249,31 @@ i965_render_slice_data_buffer(VADriverContextP ctx, assert(obj_buffer->buffer_store->buffer == NULL); assert(obj_buffer->buffer_store->bo); - if (obj_context->decode_state.num_slice_datas == obj_context->decode_state.max_slice_datas) { - obj_context->decode_state.slice_datas = realloc(obj_context->decode_state.slice_datas, - (obj_context->decode_state.max_slice_datas + NUM_SLICES) * sizeof(*obj_context->decode_state.slice_datas)); - memset(obj_context->decode_state.slice_datas + obj_context->decode_state.max_slice_datas, 0, NUM_SLICES * sizeof(*obj_context->decode_state.slice_datas)); - obj_context->decode_state.max_slice_datas += NUM_SLICES; + if (obj_context->codec_state.dec.num_slice_datas == obj_context->codec_state.dec.max_slice_datas) { + obj_context->codec_state.dec.slice_datas = realloc(obj_context->codec_state.dec.slice_datas, + (obj_context->codec_state.dec.max_slice_datas + NUM_SLICES) * sizeof(*obj_context->codec_state.dec.slice_datas)); + memset(obj_context->codec_state.dec.slice_datas + obj_context->codec_state.dec.max_slice_datas, 0, NUM_SLICES * sizeof(*obj_context->codec_state.dec.slice_datas)); + obj_context->codec_state.dec.max_slice_datas += NUM_SLICES; } - i965_release_buffer_store(&obj_context->decode_state.slice_datas[obj_context->decode_state.num_slice_datas]); - i965_reference_buffer_store(&obj_context->decode_state.slice_datas[obj_context->decode_state.num_slice_datas], + i965_release_buffer_store(&obj_context->codec_state.dec.slice_datas[obj_context->codec_state.dec.num_slice_datas]); + i965_reference_buffer_store(&obj_context->codec_state.dec.slice_datas[obj_context->codec_state.dec.num_slice_datas], obj_buffer->buffer_store); - obj_context->decode_state.num_slice_datas++; + obj_context->codec_state.dec.num_slice_datas++; return VA_STATUS_SUCCESS; } -VAStatus -i965_RenderPicture(VADriverContextP ctx, - VAContextID context, - VABufferID *buffers, - int num_buffers) +static VAStatus +i965_decoder_render_picture(VADriverContextP ctx, + VAContextID context, + VABufferID *buffers, + int num_buffers) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_context *obj_context; - struct object_config *obj_config; - VAContextID config; + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct object_context *obj_context = CONTEXT(context); + VAStatus vaStatus; int i; - VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; - - obj_context = CONTEXT(context); - assert(obj_context); - - config = obj_context->config_id; - obj_config = CONFIG(config); - assert(obj_config); - - if (VAEntrypointEncSlice == obj_config->entrypoint ){ - vaStatus = i965_encoder_render_picture(ctx, context, buffers, num_buffers); - return vaStatus; - } for (i = 0; i < num_buffers; i++) { struct object_buffer *obj_buffer = BUFFER(buffers[i]); @@ -1291,8 +1301,177 @@ i965_RenderPicture(VADriverContextP ctx, break; default: + vaStatus = VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; + break; + } + } + + return vaStatus; +} + +static VAStatus +i965_encoder_render_squence_parameter_buffer(VADriverContextP ctx, + struct object_context *obj_context, + struct object_buffer *obj_buffer) +{ + assert(obj_buffer->buffer_store->bo == NULL); + assert(obj_buffer->buffer_store->buffer); + i965_release_buffer_store(&obj_context->codec_state.enc.seq_param); + i965_reference_buffer_store(&obj_context->codec_state.enc.seq_param, + obj_buffer->buffer_store); + + return VA_STATUS_SUCCESS; +} + + +static VAStatus +i965_encoder_render_picture_parameter_buffer(VADriverContextP ctx, + struct object_context *obj_context, + struct object_buffer *obj_buffer) +{ + assert(obj_buffer->buffer_store->bo == NULL); + assert(obj_buffer->buffer_store->buffer); + i965_release_buffer_store(&obj_context->codec_state.enc.pic_param); + i965_reference_buffer_store(&obj_context->codec_state.enc.pic_param, + obj_buffer->buffer_store); + + return VA_STATUS_SUCCESS; +} + +static VAStatus +i965_encoder_render_slice_parameter_buffer(VADriverContextP ctx, + struct object_context *obj_context, + struct object_buffer *obj_buffer) +{ + if (obj_context->codec_state.enc.num_slice_params == obj_context->codec_state.enc.max_slice_params) { + obj_context->codec_state.enc.slice_params = realloc(obj_context->codec_state.enc.slice_params, + (obj_context->codec_state.enc.max_slice_params + NUM_SLICES) * sizeof(*obj_context->codec_state.enc.slice_params)); + memset(obj_context->codec_state.enc.slice_params + obj_context->codec_state.enc.max_slice_params, 0, NUM_SLICES * sizeof(*obj_context->codec_state.enc.slice_params)); + obj_context->codec_state.enc.max_slice_params += NUM_SLICES; + } + + i965_release_buffer_store(&obj_context->codec_state.enc.slice_params[obj_context->codec_state.enc.num_slice_params]); + i965_reference_buffer_store(&obj_context->codec_state.enc.slice_params[obj_context->codec_state.enc.num_slice_params], + obj_buffer->buffer_store); + obj_context->codec_state.enc.num_slice_params++; + + return VA_STATUS_SUCCESS; +} + +static VAStatus +i965_encoder_render_picture_control_buffer(VADriverContextP ctx, + struct object_context *obj_context, + struct object_buffer *obj_buffer) +{ + assert(obj_buffer->buffer_store->bo == NULL); + assert(obj_buffer->buffer_store->buffer); + i965_release_buffer_store(&obj_context->codec_state.enc.pic_control); + i965_reference_buffer_store(&obj_context->codec_state.enc.pic_control, + obj_buffer->buffer_store); + + return VA_STATUS_SUCCESS; +} + +static VAStatus +i965_encoder_render_qmatrix_buffer(VADriverContextP ctx, + struct object_context *obj_context, + struct object_buffer *obj_buffer) +{ + assert(obj_buffer->buffer_store->bo == NULL); + assert(obj_buffer->buffer_store->buffer); + i965_release_buffer_store(&obj_context->codec_state.enc.q_matrix); + i965_reference_buffer_store(&obj_context->codec_state.enc.iq_matrix, + obj_buffer->buffer_store); + + return VA_STATUS_SUCCESS; +} + +static VAStatus +i965_encoder_render_iqmatrix_buffer(VADriverContextP ctx, + struct object_context *obj_context, + struct object_buffer *obj_buffer) +{ + assert(obj_buffer->buffer_store->bo == NULL); + assert(obj_buffer->buffer_store->buffer); + i965_release_buffer_store(&obj_context->codec_state.enc.iq_matrix); + i965_reference_buffer_store(&obj_context->codec_state.enc.iq_matrix, + obj_buffer->buffer_store); + + return VA_STATUS_SUCCESS; +} + +static VAStatus +i965_encoder_render_picture(VADriverContextP ctx, + VAContextID context, + VABufferID *buffers, + int num_buffers) +{ + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct object_context *obj_context = CONTEXT(context); + VAStatus vaStatus; + int i; + + for (i = 0; i < num_buffers; i++) { + struct object_buffer *obj_buffer = BUFFER(buffers[i]); + assert(obj_buffer); + + switch (obj_buffer->type) { + case VAEncSequenceParameterBufferType: + vaStatus = i965_encoder_render_squence_parameter_buffer(ctx, obj_context, obj_buffer); + break; + + case VAEncPictureParameterBufferType: + vaStatus = i965_encoder_render_picture_parameter_buffer(ctx, obj_context, obj_buffer); + break; + + case VAEncSliceParameterBufferType: + vaStatus = i965_encoder_render_slice_parameter_buffer(ctx, obj_context, obj_buffer); + break; + + case VAPictureParameterBufferType: + vaStatus = i965_encoder_render_picture_control_buffer(ctx, obj_context, obj_buffer); + break; + + case VAQMatrixBufferType: + vaStatus = i965_encoder_render_qmatrix_buffer(ctx, obj_context, obj_buffer); + break; + + case VAIQMatrixBufferType: + vaStatus = i965_encoder_render_iqmatrix_buffer(ctx, obj_context, obj_buffer); + break; + + default: + vaStatus = VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; break; } + } + + return vaStatus; +} + +VAStatus +i965_RenderPicture(VADriverContextP ctx, + VAContextID context, + VABufferID *buffers, + int num_buffers) +{ + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct object_context *obj_context; + struct object_config *obj_config; + VAContextID config; + VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; + + obj_context = CONTEXT(context); + assert(obj_context); + + config = obj_context->config_id; + obj_config = CONFIG(config); + assert(obj_config); + + if (VAEntrypointEncSlice == obj_config->entrypoint ){ + vaStatus = i965_encoder_render_picture(ctx, context, buffers, num_buffers); + } else { + vaStatus = i965_decoder_render_picture(ctx, context, buffers, num_buffers); } return vaStatus; @@ -1312,26 +1491,43 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context) obj_config = CONFIG(config); assert(obj_config); - if (VAEntrypointEncSlice == obj_config->entrypoint ){ - return i965_encoder_end_picture(ctx, context); + if (obj_context->codec_type == CODEC_ENC) { + assert(VAEntrypointEncSlice == obj_config->entrypoint); + + assert(obj_context->codec_state.enc.pic_param); + assert(obj_context->codec_state.enc.seq_param); + assert(obj_context->codec_state.enc.num_slice_params >= 1); + } else { + assert(obj_context->codec_state.dec.pic_param); + assert(obj_context->codec_state.dec.num_slice_params >= 1); + assert(obj_context->codec_state.dec.num_slice_datas >= 1); + assert(obj_context->codec_state.dec.num_slice_params == obj_context->codec_state.dec.num_slice_datas); } - assert(obj_context->decode_state.pic_param); - assert(obj_context->decode_state.num_slice_params >= 1); - assert(obj_context->decode_state.num_slice_datas >= 1); - assert(obj_context->decode_state.num_slice_params == obj_context->decode_state.num_slice_datas); + assert(obj_context->hw_context->run); + obj_context->hw_context->run(ctx, obj_config->profile, &obj_context->codec_state, obj_context->hw_context); - i965_media_decode_picture(ctx, obj_config->profile, &obj_context->decode_state); - obj_context->decode_state.current_render_target = -1; - obj_context->decode_state.num_slice_params = 0; - obj_context->decode_state.num_slice_datas = 0; - i965_release_buffer_store(&obj_context->decode_state.pic_param); - i965_release_buffer_store(&obj_context->decode_state.iq_matrix); - i965_release_buffer_store(&obj_context->decode_state.bit_plane); + if (obj_context->codec_type == CODEC_ENC) { + obj_context->codec_state.enc.current_render_target = VA_INVALID_SURFACE; + obj_context->codec_state.enc.num_slice_params = 0; + i965_release_buffer_store(&obj_context->codec_state.enc.pic_param); + i965_release_buffer_store(&obj_context->codec_state.enc.seq_param); - for (i = 0; i < obj_context->decode_state.num_slice_params; i++) { - i965_release_buffer_store(&obj_context->decode_state.slice_params[i]); - i965_release_buffer_store(&obj_context->decode_state.slice_datas[i]); + for (i = 0; i < obj_context->codec_state.enc.num_slice_params; i++) { + i965_release_buffer_store(&obj_context->codec_state.enc.slice_params[i]); + } + } else { + obj_context->codec_state.dec.current_render_target = -1; + obj_context->codec_state.dec.num_slice_params = 0; + obj_context->codec_state.dec.num_slice_datas = 0; + i965_release_buffer_store(&obj_context->codec_state.dec.pic_param); + i965_release_buffer_store(&obj_context->codec_state.dec.iq_matrix); + i965_release_buffer_store(&obj_context->codec_state.dec.bit_plane); + + for (i = 0; i < obj_context->codec_state.dec.num_slice_params; i++) { + i965_release_buffer_store(&obj_context->codec_state.dec.slice_params[i]); + i965_release_buffer_store(&obj_context->codec_state.dec.slice_datas[i]); + } } return VA_STATUS_SUCCESS; @@ -1441,12 +1637,13 @@ i965_Init(VADriverContextP ctx) if (intel_driver_init(ctx) == False) return VA_STATUS_ERROR_UNKNOWN; - if (!IS_G4X(i965->intel.device_id) && - !IS_IRONLAKE(i965->intel.device_id) && - !IS_GEN6(i965->intel.device_id)) - return VA_STATUS_ERROR_UNKNOWN; - - if (i965_media_init(ctx) == False) + if (IS_G4X(i965->intel.device_id)) + i965->codec_info = &g4x_hw_codec_info; + else if (IS_IRONLAKE(i965->intel.device_id)) + i965->codec_info = &ironlake_hw_codec_info; + else if (IS_GEN6(i965->intel.device_id)) + i965->codec_info = &gen6_hw_codec_info; + else return VA_STATUS_ERROR_UNKNOWN; if (i965_post_processing_init(ctx) == False) @@ -1455,9 +1652,6 @@ i965_Init(VADriverContextP ctx) if (i965_render_init(ctx) == False) return VA_STATUS_ERROR_UNKNOWN; - if (HAS_ENCODER(i965) && (i965_encoder_init(ctx) == False)) - return VA_STATUS_ERROR_UNKNOWN; - return VA_STATUS_SUCCESS; } @@ -2113,18 +2307,12 @@ i965_Terminate(VADriverContextP ctx) { struct i965_driver_data *i965 = i965_driver_data(ctx); - if (HAS_ENCODER(i965) && (i965_encoder_terminate(ctx) == False)) - return VA_STATUS_ERROR_UNKNOWN; - if (i965_render_terminate(ctx) == False) return VA_STATUS_ERROR_UNKNOWN; if (i965_post_processing_terminate(ctx) == False) return VA_STATUS_ERROR_UNKNOWN; - if (i965_media_terminate(ctx) == False) - return VA_STATUS_ERROR_UNKNOWN; - if (intel_driver_terminate(ctx) == False) return VA_STATUS_ERROR_UNKNOWN; diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h index 20cb84e..96f692d 100644 --- a/i965_drv_video/i965_drv_video.h +++ b/i965_drv_video/i965_drv_video.h @@ -37,12 +37,8 @@ #include "intel_driver.h" -#include "i965_media.h" #include "i965_render.h" -#include "gen6_vme.h" -#include "gen6_mfc.h" - #define I965_MAX_PROFILES 11 #define I965_MAX_ENTRYPOINTS 5 #define I965_MAX_CONFIG_ATTRIBUTES 10 @@ -51,6 +47,15 @@ #define I965_MAX_DISPLAY_ATTRIBUTES 4 #define I965_STR_VENDOR "i965 Driver 0.1" +struct media_kernel +{ + char *name; + int interface; + unsigned int (*bin)[4]; + int size; + dri_bo *bo; +}; + struct buffer_store { unsigned char *buffer; @@ -84,8 +89,7 @@ struct decode_state int num_slice_datas; }; -//keeping mfc encoder's stuff here -struct mfc_encode_state +struct encode_state { struct buffer_store *seq_param; struct buffer_store *pic_param; @@ -98,6 +102,24 @@ struct mfc_encode_state int num_slice_params; }; +#define CODEC_DEC 0 +#define CODEC_ENC 1 + +union codec_state +{ + struct decode_state dec; + struct encode_state enc; +}; + +struct hw_context +{ + void (*run)(VADriverContextP ctx, + VAProfile profile, + union codec_state *codec_state, + struct hw_context *hw_context); + void (*destroy)(void *); +}; + struct object_context { struct object_base base; @@ -108,8 +130,9 @@ struct object_context int picture_width; int picture_height; int flags; - struct decode_state decode_state; - struct mfc_encode_state encode_state; + int codec_type; + union codec_state codec_state; + struct hw_context *hw_context; }; #define SURFACE_REFERENCED (1 << 0) @@ -175,6 +198,12 @@ struct object_subpic dri_bo *bo; }; +struct hw_codec_info +{ + struct hw_context *(*dec_hw_context_init)(VADriverContextP, VAProfile); + struct hw_context *(*enc_hw_context_init)(VADriverContextP, VAProfile); +}; + struct i965_driver_data { struct intel_driver_data intel; @@ -184,11 +213,9 @@ struct i965_driver_data struct object_heap buffer_heap; struct object_heap image_heap; struct object_heap subpic_heap; - struct i965_media_state media_state; struct i965_render_state render_state; + struct hw_codec_info *codec_info; void *pp_context; - struct gen6_media_state gen6_media_state; - struct gen6_mfc_bcs_state gen6_mfc_bcs_state; }; #define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap); diff --git a/i965_drv_video/i965_encoder.c b/i965_drv_video/i965_encoder.c index cb21344..09cef6f 100644 --- a/i965_drv_video/i965_encoder.c +++ b/i965_drv_video/i965_encoder.c @@ -40,346 +40,40 @@ #include "i965_drv_video.h" #include "i965_encoder.h" -extern void i965_reference_buffer_store(struct buffer_store **ptr, - struct buffer_store *buffer_store); -extern void i965_release_buffer_store(struct buffer_store **ptr); - -static VAStatus i965_encoder_render_squence_parameter_buffer(VADriverContextP ctx, - struct object_context *obj_context, - struct object_buffer *obj_buffer) -{ - assert(obj_buffer->buffer_store->bo == NULL); - assert(obj_buffer->buffer_store->buffer); - i965_release_buffer_store(&obj_context->encode_state.seq_param); - i965_reference_buffer_store(&obj_context->encode_state.seq_param, - obj_buffer->buffer_store); - - return VA_STATUS_SUCCESS; -} - - -static VAStatus i965_encoder_render_picture_parameter_buffer(VADriverContextP ctx, - struct object_context *obj_context, - struct object_buffer *obj_buffer) -{ - assert(obj_buffer->buffer_store->bo == NULL); - assert(obj_buffer->buffer_store->buffer); - i965_release_buffer_store(&obj_context->encode_state.pic_param); - i965_reference_buffer_store(&obj_context->encode_state.pic_param, - obj_buffer->buffer_store); - - return VA_STATUS_SUCCESS; -} - -static VAStatus i965_encoder_render_slice_parameter_buffer(VADriverContextP ctx, - struct object_context *obj_context, - struct object_buffer *obj_buffer) -{ - if (obj_context->encode_state.num_slice_params == obj_context->encode_state.max_slice_params) { - obj_context->encode_state.slice_params = realloc(obj_context->encode_state.slice_params, - (obj_context->encode_state.max_slice_params + NUM_SLICES) * sizeof(*obj_context->encode_state.slice_params)); - memset(obj_context->encode_state.slice_params + obj_context->encode_state.max_slice_params, 0, NUM_SLICES * sizeof(*obj_context->encode_state.slice_params)); - obj_context->encode_state.max_slice_params += NUM_SLICES; - } - - i965_release_buffer_store(&obj_context->encode_state.slice_params[obj_context->encode_state.num_slice_params]); - i965_reference_buffer_store(&obj_context->encode_state.slice_params[obj_context->encode_state.num_slice_params], - obj_buffer->buffer_store); - obj_context->encode_state.num_slice_params++; - - return VA_STATUS_SUCCESS; -} - -static void i965_encoder_render_picture_control_buffer(VADriverContextP ctx, - struct object_context *obj_context, - struct object_buffer *obj_buffer) -{ - assert(obj_buffer->buffer_store->bo == NULL); - assert(obj_buffer->buffer_store->buffer); - i965_release_buffer_store(&obj_context->encode_state.pic_control); - i965_reference_buffer_store(&obj_context->encode_state.pic_control, - obj_buffer->buffer_store); -} - -static void i965_encoder_render_qmatrix_buffer(VADriverContextP ctx, - struct object_context *obj_context, - struct object_buffer *obj_buffer) -{ - assert(obj_buffer->buffer_store->bo == NULL); - assert(obj_buffer->buffer_store->buffer); - i965_release_buffer_store(&obj_context->encode_state.q_matrix); - i965_reference_buffer_store(&obj_context->encode_state.iq_matrix, - obj_buffer->buffer_store); -} - -static void i965_encoder_render_iqmatrix_buffer(VADriverContextP ctx, - struct object_context *obj_context, - struct object_buffer *obj_buffer) -{ - assert(obj_buffer->buffer_store->bo == NULL); - assert(obj_buffer->buffer_store->buffer); - i965_release_buffer_store(&obj_context->encode_state.iq_matrix); - i965_reference_buffer_store(&obj_context->encode_state.iq_matrix, - obj_buffer->buffer_store); -} - -VAStatus i965_encoder_create_context(VADriverContextP ctx, - VAConfigID config_id, - int picture_width, - int picture_height, - int flag, - VASurfaceID *render_targets, - int num_render_targets, - struct object_context *obj_context) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_config *obj_config = CONFIG(config_id); - VAStatus vaStatus = VA_STATUS_SUCCESS; - - - if (NULL == obj_config) { - vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; - return vaStatus; - } - - if (NULL == obj_context) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - return vaStatus; - } - - if( VAProfileH264Baseline != obj_config->profile || - VAEntrypointEncSlice != obj_config->entrypoint) { - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; - return vaStatus; - } - - /*encdoe_state init */ - obj_context->encode_state.current_render_target = VA_INVALID_ID; - obj_context->encode_state.max_slice_params = NUM_SLICES; - obj_context->encode_state.slice_params = calloc(obj_context->encode_state.max_slice_params, - sizeof(*obj_context->encode_state.slice_params)); - - return vaStatus; -} - - -VAStatus i965_encoder_begin_picture(VADriverContextP ctx, - VAContextID context, - VASurfaceID render_target) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_context *obj_context = CONTEXT(context); - struct object_surface *obj_surface = SURFACE(render_target); - struct object_config *obj_config; - VAContextID config; - VAStatus vaStatus; - - assert(obj_context); - assert(obj_surface); - - config = obj_context->config_id; - obj_config = CONFIG(config); - assert(obj_config); - - if( VAProfileH264Baseline != obj_config->profile || - VAEntrypointEncSlice != obj_config->entrypoint){ - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; - }else{ - vaStatus = VA_STATUS_SUCCESS; - } - - obj_context->encode_state.current_render_target = render_target; /*This is input new frame*/ - - return vaStatus; -} - -VAStatus i965_encoder_render_picture(VADriverContextP ctx, - VAContextID context, - VABufferID *buffers, - int num_buffers) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_context *obj_context = CONTEXT(context); - struct object_config *obj_config; - VAContextID config; - VAStatus vaStatus; - int i; - - assert(obj_context); - config = obj_context->config_id; - obj_config = CONFIG(config); - assert(obj_config); - - - for (i = 0; i < num_buffers; i++) { - struct object_buffer *obj_buffer = BUFFER(buffers[i]); - assert(obj_buffer); - - switch (obj_buffer->type) { - case VAEncSequenceParameterBufferType: - i965_encoder_render_squence_parameter_buffer(ctx, obj_context, obj_buffer); - break; - - case VAEncPictureParameterBufferType: - i965_encoder_render_picture_parameter_buffer(ctx, obj_context, obj_buffer); - break; - - case VAEncSliceParameterBufferType: - i965_encoder_render_slice_parameter_buffer(ctx, obj_context, obj_buffer); - break; - - case VAPictureParameterBufferType: - i965_encoder_render_picture_control_buffer(ctx, obj_context, obj_buffer); - break; - - case VAQMatrixBufferType: - i965_encoder_render_qmatrix_buffer(ctx, obj_context, obj_buffer); - break; - - case VAIQMatrixBufferType: - i965_encoder_render_iqmatrix_buffer(ctx, obj_context, obj_buffer); - break; - - default: - break; - } - } - - vaStatus = VA_STATUS_SUCCESS; - return vaStatus; -} - -static VAStatus +static void gen6_encoder_end_picture(VADriverContextP ctx, - VAContextID context, - struct mfc_encode_state *encode_state) + VAProfile profile, + union codec_state *codec_state, + struct hw_context *hw_context) { + struct gen6_encoder_context *gen6_encoder_context = (struct gen6_encoder_context *)hw_context; + struct encode_state *encode_state = &codec_state->enc; VAStatus vaStatus; - vaStatus = gen6_vme_media_pipeline(ctx, context, encode_state); + vaStatus = gen6_vme_pipeline(ctx, profile, encode_state, gen6_encoder_context); if (vaStatus == VA_STATUS_SUCCESS) - vaStatus = gen6_mfc_pipeline(ctx, context, encode_state); - - return vaStatus; + gen6_mfc_pipeline(ctx, profile, encode_state, gen6_encoder_context); } - -VAStatus i965_encoder_end_picture(VADriverContextP ctx, VAContextID context) +static void +gen6_encoder_context_destroy(void *hw_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_context *obj_context = CONTEXT(context); - struct object_config *obj_config; - VAContextID config; - VAStatus vaStatus; - int i; - - assert(obj_context); - config = obj_context->config_id; - obj_config = CONFIG(config); - assert(obj_config); - - assert(obj_context->encode_state.pic_param); - assert(obj_context->encode_state.num_slice_params >= 1); - - if (IS_GEN6(i965->intel.device_id)) { - vaStatus = gen6_encoder_end_picture(ctx, context, &(obj_context->encode_state)); - } else { - /* add for other chipset */ - assert(0); - } + struct gen6_encoder_context *gen6_encoder_context = (struct gen6_encoder_context *)hw_context; - obj_context->encode_state.current_render_target = VA_INVALID_SURFACE; - obj_context->encode_state.num_slice_params = 0; - i965_release_buffer_store(&obj_context->encode_state.pic_param); - - for (i = 0; i < obj_context->encode_state.num_slice_params; i++) { - i965_release_buffer_store(&obj_context->encode_state.slice_params[i]); - } - - return VA_STATUS_SUCCESS; + gen6_mfc_context_destroy(&gen6_encoder_context->mfc_context); + gen6_vme_context_destroy(&gen6_encoder_context->vme_context); + free(gen6_encoder_context); } - -void i965_encoder_destroy_context(struct object_heap *heap, struct object_base *obj) +struct hw_context * +gen6_enc_hw_context_init(VADriverContextP ctx, VAProfile profile) { - struct object_context *obj_context = (struct object_context *)obj; - - assert(obj_context->encode_state.num_slice_params <= obj_context->encode_state.max_slice_params); - - i965_release_buffer_store(&obj_context->encode_state.pic_param); - i965_release_buffer_store(&obj_context->encode_state.seq_param); - - free(obj_context->render_targets); - object_heap_free(heap, obj); -} - -Bool i965_encoder_init(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - if (IS_GEN6(i965->intel.device_id)) { - gen6_vme_init(ctx); - } - - return True; -} - -Bool i965_encoder_terminate(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct gen6_media_state *media_state = &i965->gen6_media_state; - struct gen6_mfc_bcs_state *bcs_state = &i965->gen6_mfc_bcs_state; - int i; - - if (IS_GEN6(i965->intel.device_id)) { - gen6_vme_terminate(ctx); - } - - for (i = 0; i < MAX_MEDIA_SURFACES_GEN6; i++) { - dri_bo_unreference(media_state->surface_state[i].bo); - media_state->surface_state[i].bo = NULL; - } - - dri_bo_unreference(media_state->idrt.bo); - media_state->idrt.bo = NULL; - - dri_bo_unreference(media_state->binding_table.bo); - media_state->binding_table.bo = NULL; - - dri_bo_unreference(media_state->curbe.bo); - media_state->curbe.bo = NULL; - - dri_bo_unreference(media_state->vme_output.bo); - media_state->vme_output.bo = NULL; - - dri_bo_unreference(media_state->vme_state.bo); - media_state->vme_state.bo = NULL; - - dri_bo_unreference(bcs_state->post_deblocking_output.bo); - bcs_state->post_deblocking_output.bo = NULL; - - dri_bo_unreference(bcs_state->pre_deblocking_output.bo); - bcs_state->pre_deblocking_output.bo = NULL; - - dri_bo_unreference(bcs_state->uncompressed_picture_source.bo); - bcs_state->uncompressed_picture_source.bo = NULL; - - dri_bo_unreference(bcs_state->mfc_indirect_pak_bse_object.bo); - bcs_state->mfc_indirect_pak_bse_object.bo = NULL; - - for (i = 0; i < NUM_MFC_DMV_BUFFERS; i++){ - dri_bo_unreference(bcs_state->direct_mv_buffers[i].bo); - bcs_state->direct_mv_buffers[i].bo = NULL; - } - - dri_bo_unreference(bcs_state->intra_row_store_scratch_buffer.bo); - bcs_state->intra_row_store_scratch_buffer.bo = NULL; - - dri_bo_unreference(bcs_state->deblocking_filter_row_store_scratch_buffer.bo); - bcs_state->deblocking_filter_row_store_scratch_buffer.bo = NULL; + struct gen6_encoder_context *gen6_encoder_context = calloc(1, sizeof(struct gen6_encoder_context)); - dri_bo_unreference(bcs_state->bsd_mpc_row_store_scratch_buffer.bo); - bcs_state->bsd_mpc_row_store_scratch_buffer.bo = NULL; + gen6_encoder_context->base.destroy = gen6_encoder_context_destroy; + gen6_encoder_context->base.run = gen6_encoder_end_picture; + gen6_vme_context_init(ctx, &gen6_encoder_context->vme_context); + gen6_mfc_context_init(ctx, &gen6_encoder_context->mfc_context); - return True; + return (struct hw_context *)gen6_encoder_context; } diff --git a/i965_drv_video/i965_encoder.h b/i965_drv_video/i965_encoder.h index e1e0b16..555efe3 100644 --- a/i965_drv_video/i965_encoder.h +++ b/i965_drv_video/i965_encoder.h @@ -26,8 +26,8 @@ * */ -#ifndef _GEN6_MFC_H_ -#define _GEN6_MFC_H_ +#ifndef _I965_ENCODER_H_ +#define _I965_ENCODER_H_ #include <xf86drm.h> #include <drm.h> @@ -36,40 +36,16 @@ #include "i965_structs.h" #include "i965_drv_video.h" +#include "gen6_vme.h" +#include "gen6_mfc.h" -VAStatus i965_encoder_create_context( - VADriverContextP ctx, - VAConfigID config_id, - int picture_width, - int picture_height, - int flag, - VASurfaceID *render_targets, - int num_render_targets, - struct object_context *obj_context - ); +struct gen6_encoder_context +{ + struct hw_context base; + struct gen6_vme_context vme_context; + struct gen6_mfc_context mfc_context; +}; -VAStatus i965_encoder_begin_picture( - VADriverContextP ctx, - VAContextID context, - VASurfaceID render_target - ); - -VAStatus i965_encoder_render_picture(VADriverContextP ctx, - VAContextID context, - VABufferID *buffers, - int num_buffers - ); - -VAStatus i965_encoder_end_picture(VADriverContextP ctx, - VAContextID context - ); - - -void i965_encoder_destroy_context(struct object_heap *heap, struct object_base *obj); - -Bool i965_encoder_init(VADriverContextP ctx); -Bool i965_encoder_terminate(VADriverContextP ctx); - -#endif /* _GEN6_MFC_H_ */ +#endif /* _I965_ENCODER_H_ */ diff --git a/i965_drv_video/i965_media.c b/i965_drv_video/i965_media.c index 172dde5..8745488 100644 --- a/i965_drv_video/i965_media.c +++ b/i965_drv_video/i965_media.c @@ -28,6 +28,7 @@ */ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <assert.h> @@ -35,13 +36,12 @@ #include "intel_batchbuffer.h" #include "intel_driver.h" - #include "i965_defines.h" +#include "i965_drv_video.h" + +#include "i965_media.h" #include "i965_media_mpeg2.h" #include "i965_media_h264.h" -#include "gen6_mfd.h" -#include "i965_media.h" -#include "i965_drv_video.h" static void i965_media_pipeline_select(VADriverContextP ctx) @@ -52,13 +52,12 @@ i965_media_pipeline_select(VADriverContextP ctx) } static void -i965_media_urb_layout(VADriverContextP ctx) +i965_media_urb_layout(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; + struct i965_driver_data *i965 = i965_driver_data(ctx); unsigned int vfe_fence, cs_fence; - vfe_fence = media_state->urb.cs_start; + vfe_fence = media_context->urb.cs_start; cs_fence = URB_SIZE((&i965->intel)); BEGIN_BATCH(ctx, 3); @@ -71,10 +70,9 @@ i965_media_urb_layout(VADriverContextP ctx) } static void -i965_media_state_base_address(VADriverContextP ctx) +i965_media_state_base_address(VADriverContextP ctx, struct i965_media_context *media_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; if (IS_IRONLAKE(i965->intel.device_id)) { BEGIN_BATCH(ctx, 8); @@ -82,9 +80,9 @@ i965_media_state_base_address(VADriverContextP ctx) OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - if (media_state->indirect_object.bo) { - OUT_RELOC(ctx, media_state->indirect_object.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, - media_state->indirect_object.offset | BASE_ADDRESS_MODIFY); + if (media_context->indirect_object.bo) { + OUT_RELOC(ctx, media_context->indirect_object.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, + media_context->indirect_object.offset | BASE_ADDRESS_MODIFY); } else { OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); } @@ -100,9 +98,9 @@ i965_media_state_base_address(VADriverContextP ctx) OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - if (media_state->indirect_object.bo) { - OUT_RELOC(ctx, media_state->indirect_object.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, - media_state->indirect_object.offset | BASE_ADDRESS_MODIFY); + if (media_context->indirect_object.bo) { + OUT_RELOC(ctx, media_context->indirect_object.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, + media_context->indirect_object.offset | BASE_ADDRESS_MODIFY); } else { OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); } @@ -114,56 +112,47 @@ i965_media_state_base_address(VADriverContextP ctx) } static void -i965_media_state_pointers(VADriverContextP ctx) +i965_media_state_pointers(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - BEGIN_BATCH(ctx, 3); OUT_BATCH(ctx, CMD_MEDIA_STATE_POINTERS | 1); - if (media_state->extended_state.enabled) - OUT_RELOC(ctx, media_state->extended_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1); + if (media_context->extended_state.enabled) + OUT_RELOC(ctx, media_context->extended_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1); else OUT_BATCH(ctx, 0); - OUT_RELOC(ctx, media_state->vfe_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); + OUT_RELOC(ctx, media_context->vfe_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); ADVANCE_BATCH(ctx); } static void -i965_media_cs_urb_layout(VADriverContextP ctx) +i965_media_cs_urb_layout(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - BEGIN_BATCH(ctx, 2); OUT_BATCH(ctx, CMD_CS_URB_STATE | 0); OUT_BATCH(ctx, - ((media_state->urb.size_cs_entry - 1) << 4) | /* URB Entry Allocation Size */ - (media_state->urb.num_cs_entries << 0)); /* Number of URB Entries */ + ((media_context->urb.size_cs_entry - 1) << 4) | /* URB Entry Allocation Size */ + (media_context->urb.num_cs_entries << 0)); /* Number of URB Entries */ ADVANCE_BATCH(ctx); } static void -i965_media_pipeline_state(VADriverContextP ctx) +i965_media_pipeline_state(VADriverContextP ctx, struct i965_media_context *media_context) { - i965_media_state_base_address(ctx); - i965_media_state_pointers(ctx); - i965_media_cs_urb_layout(ctx); + i965_media_state_base_address(ctx, media_context); + i965_media_state_pointers(ctx, media_context); + i965_media_cs_urb_layout(ctx, media_context); } static void -i965_media_constant_buffer(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_constant_buffer(VADriverContextP ctx, struct decode_state *decode_state, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - BEGIN_BATCH(ctx, 2); OUT_BATCH(ctx, CMD_CONSTANT_BUFFER | (1 << 8) | (2 - 2)); - OUT_RELOC(ctx, media_state->curbe.bo, + OUT_RELOC(ctx, media_context->curbe.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, - media_state->urb.size_cs_entry - 1); + media_context->urb.size_cs_entry - 1); ADVANCE_BATCH(ctx); } @@ -182,82 +171,83 @@ i965_media_depth_buffer(VADriverContextP ctx) } static void -i965_media_pipeline_setup(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_pipeline_setup(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - intel_batchbuffer_start_atomic(ctx, 0x1000); - intel_batchbuffer_emit_mi_flush(ctx); /* step 1 */ + intel_batchbuffer_emit_mi_flush(ctx); /* step 1 */ i965_media_depth_buffer(ctx); - i965_media_pipeline_select(ctx); /* step 2 */ - i965_media_urb_layout(ctx); /* step 3 */ - i965_media_pipeline_state(ctx); /* step 4 */ - i965_media_constant_buffer(ctx, decode_state); /* step 5 */ - assert(media_state->media_objects); - media_state->media_objects(ctx, decode_state); /* step 6 */ + i965_media_pipeline_select(ctx); /* step 2 */ + i965_media_urb_layout(ctx, media_context); /* step 3 */ + i965_media_pipeline_state(ctx, media_context); /* step 4 */ + i965_media_constant_buffer(ctx, decode_state, media_context); /* step 5 */ + assert(media_context->media_objects); + media_context->media_objects(ctx, decode_state, media_context); /* step 6 */ intel_batchbuffer_end_atomic(ctx); } static void -i965_media_decode_init(VADriverContextP ctx, VAProfile profile, struct decode_state *decode_state) +i965_media_decode_init(VADriverContextP ctx, + VAProfile profile, + struct decode_state *decode_state, + struct i965_media_context *media_context) { int i; struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; dri_bo *bo; /* constant buffer */ - dri_bo_unreference(media_state->curbe.bo); + dri_bo_unreference(media_context->curbe.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "constant buffer", 4096, 64); assert(bo); - media_state->curbe.bo = bo; + media_context->curbe.bo = bo; /* surface state */ for (i = 0; i < MAX_MEDIA_SURFACES; i++) { - dri_bo_unreference(media_state->surface_state[i].bo); - media_state->surface_state[i].bo = NULL; + dri_bo_unreference(media_context->surface_state[i].bo); + media_context->surface_state[i].bo = NULL; } /* binding table */ - dri_bo_unreference(media_state->binding_table.bo); + dri_bo_unreference(media_context->binding_table.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "binding table", MAX_MEDIA_SURFACES * sizeof(unsigned int), 32); assert(bo); - media_state->binding_table.bo = bo; + media_context->binding_table.bo = bo; /* interface descriptor remapping table */ - dri_bo_unreference(media_state->idrt.bo); + dri_bo_unreference(media_context->idrt.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "interface discriptor", MAX_INTERFACE_DESC * sizeof(struct i965_interface_descriptor), 16); assert(bo); - media_state->idrt.bo = bo; + media_context->idrt.bo = bo; /* vfe state */ - dri_bo_unreference(media_state->vfe_state.bo); + dri_bo_unreference(media_context->vfe_state.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "vfe state", sizeof(struct i965_vfe_state), 32); assert(bo); - media_state->vfe_state.bo = bo; + media_context->vfe_state.bo = bo; /* extended state */ - media_state->extended_state.enabled = 0; + media_context->extended_state.enabled = 0; switch (profile) { case VAProfileMPEG2Simple: case VAProfileMPEG2Main: - i965_media_mpeg2_decode_init(ctx, decode_state); + i965_media_mpeg2_decode_init(ctx, decode_state, media_context); break; case VAProfileH264Baseline: case VAProfileH264Main: case VAProfileH264High: - i965_media_h264_decode_init(ctx, decode_state); + i965_media_h264_decode_init(ctx, decode_state, media_context); break; default: @@ -266,72 +256,111 @@ i965_media_decode_init(VADriverContextP ctx, VAProfile profile, struct decode_st } } -void +static void i965_media_decode_picture(VADriverContextP ctx, VAProfile profile, - struct decode_state *decode_state) + union codec_state *codec_state, + struct hw_context *hw_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - - if (IS_GEN6(i965->intel.device_id)) { - gen6_mfd_decode_picture(ctx, profile, decode_state); - return; - } + struct i965_media_context *media_context = (struct i965_media_context *)hw_context; + struct decode_state *decode_state = &codec_state->dec; - i965_media_decode_init(ctx, profile, decode_state); - assert(media_state->media_states_setup); - media_state->media_states_setup(ctx, decode_state); - i965_media_pipeline_setup(ctx, decode_state); + i965_media_decode_init(ctx, profile, decode_state, media_context); + assert(media_context->media_states_setup); + media_context->media_states_setup(ctx, decode_state, media_context); + i965_media_pipeline_setup(ctx, decode_state, media_context); } -Bool -i965_media_init(VADriverContextP ctx) +static void +i965_media_context_destroy(void *hw_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); + struct i965_media_context *media_context = (struct i965_media_context *)hw_context; + int i; + + if (media_context->free_private_context) + media_context->free_private_context(&media_context->private_context); + + for (i = 0; i < MAX_MEDIA_SURFACES; i++) { + dri_bo_unreference(media_context->surface_state[i].bo); + media_context->surface_state[i].bo = NULL; + } + + dri_bo_unreference(media_context->extended_state.bo); + media_context->extended_state.bo = NULL; + + dri_bo_unreference(media_context->vfe_state.bo); + media_context->vfe_state.bo = NULL; + + dri_bo_unreference(media_context->idrt.bo); + media_context->idrt.bo = NULL; + + dri_bo_unreference(media_context->binding_table.bo); + media_context->binding_table.bo = NULL; + + dri_bo_unreference(media_context->curbe.bo); + media_context->curbe.bo = NULL; - if (IS_GEN6(i965->intel.device_id)) - return gen6_mfd_init(ctx); + dri_bo_unreference(media_context->indirect_object.bo); + media_context->indirect_object.bo = NULL; - return True; + free(media_context); } -Bool -i965_media_terminate(VADriverContextP ctx) +struct hw_context * +g4x_dec_hw_context_init(VADriverContextP ctx, VAProfile profile) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - int i; + struct i965_media_context *media_context = calloc(1, sizeof(struct i965_media_context)); - if (IS_GEN6(i965->intel.device_id)) - return gen6_mfd_terminate(ctx); + media_context->base.destroy = i965_media_context_destroy; + media_context->base.run = i965_media_decode_picture; - if (media_state->free_private_context) - media_state->free_private_context(&media_state->private_context); + switch (profile) { + case VAProfileMPEG2Simple: + case VAProfileMPEG2Main: + i965_media_mpeg2_dec_context_init(ctx, media_context); + break; - for (i = 0; i < MAX_MEDIA_SURFACES; i++) { - dri_bo_unreference(media_state->surface_state[i].bo); - media_state->surface_state[i].bo = NULL; + case VAProfileH264Baseline: + case VAProfileH264Main: + case VAProfileH264High: + case VAProfileVC1Simple: + case VAProfileVC1Main: + case VAProfileVC1Advanced: + default: + assert(0); + break; } - - dri_bo_unreference(media_state->extended_state.bo); - media_state->extended_state.bo = NULL; - dri_bo_unreference(media_state->vfe_state.bo); - media_state->vfe_state.bo = NULL; + return (struct hw_context *)media_context; +} + +struct hw_context * +ironlake_dec_hw_context_init(VADriverContextP ctx, VAProfile profile) +{ + struct i965_media_context *media_context = calloc(1, sizeof(struct i965_media_context)); - dri_bo_unreference(media_state->idrt.bo); - media_state->idrt.bo = NULL; + media_context->base.destroy = i965_media_context_destroy; + media_context->base.run = i965_media_decode_picture; - dri_bo_unreference(media_state->binding_table.bo); - media_state->binding_table.bo = NULL; + switch (profile) { + case VAProfileMPEG2Simple: + case VAProfileMPEG2Main: + i965_media_mpeg2_dec_context_init(ctx, media_context); + break; - dri_bo_unreference(media_state->curbe.bo); - media_state->curbe.bo = NULL; + case VAProfileH264Baseline: + case VAProfileH264Main: + case VAProfileH264High: + i965_media_h264_dec_context_init(ctx, media_context); + break; - dri_bo_unreference(media_state->indirect_object.bo); - media_state->indirect_object.bo = NULL; + case VAProfileVC1Simple: + case VAProfileVC1Main: + case VAProfileVC1Advanced: + default: + assert(0); + break; + } - return True; + return (struct hw_context *)media_context; } - diff --git a/i965_drv_video/i965_media.h b/i965_drv_video/i965_media.h index 4ed3d4b..2bb6bb2 100644 --- a/i965_drv_video/i965_media.h +++ b/i965_drv_video/i965_media.h @@ -46,17 +46,10 @@ struct decode_state; -struct media_kernel +struct i965_media_context { - char *name; - int interface; - unsigned int (*bin)[4]; - int size; - dri_bo *bo; -}; + struct hw_context base; -struct i965_media_state -{ struct { dri_bo *bo; } surface_state[MAX_MEDIA_SURFACES]; @@ -99,14 +92,9 @@ struct i965_media_state } urb; void *private_context; - void (*media_states_setup)(VADriverContextP ctx, struct decode_state *decode_state); - void (*media_objects)(VADriverContextP ctx, struct decode_state *decode_state); + void (*media_states_setup)(VADriverContextP ctx, struct decode_state *decode_state, struct i965_media_context *media_context); + void (*media_objects)(VADriverContextP ctx, struct decode_state *decode_state, struct i965_media_context *media_context); void (*free_private_context)(void **data); }; -Bool i965_media_init(VADriverContextP ctx); -Bool i965_media_terminate(VADriverContextP ctx); -void i965_media_decode_picture(VADriverContextP ctx, - VAProfile profile, - struct decode_state *decode_state); #endif /* _I965_MEDIA_H_ */ diff --git a/i965_drv_video/i965_media_h264.c b/i965_drv_video/i965_media_h264.c index add774f..e739e52 100644 --- a/i965_drv_video/i965_media_h264.c +++ b/i965_drv_video/i965_media_h264.c @@ -292,10 +292,10 @@ i965_media_h264_surface_state(VADriverContextP ctx, Bool is_dst, int vert_line_stride, int vert_line_stride_ofs, - int format) + int format, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; + struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_surface_state *ss; dri_bo *bo; uint32_t write_domain, read_domain; @@ -333,15 +333,15 @@ i965_media_h264_surface_state(VADriverContextP ctx, dri_bo_unmap(bo); assert(index < MAX_MEDIA_SURFACES); - media_state->surface_state[index].bo = bo; + media_context->surface_state[index].bo = bo; } static void i965_media_h264_surfaces_setup(VADriverContextP ctx, - struct decode_state *decode_state) + struct decode_state *decode_state, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; + struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_h264_context *i965_h264_context; struct object_surface *obj_surface; VAPictureParameterBufferH264 *pic_param; @@ -349,8 +349,8 @@ i965_media_h264_surfaces_setup(VADriverContextP ctx, int i, j, w, h; int field_picture; - assert(media_state->private_context); - i965_h264_context = (struct i965_h264_context *)media_state->private_context; + assert(media_context->private_context); + i965_h264_context = (struct i965_h264_context *)media_context->private_context; assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer; @@ -368,13 +368,15 @@ i965_media_h264_surfaces_setup(VADriverContextP ctx, 1, field_picture, !!(va_pic->flags & VA_PICTURE_H264_BOTTOM_FIELD), - I965_SURFACEFORMAT_R8_SINT); /* Y */ + I965_SURFACEFORMAT_R8_SINT, /* Y */ + media_context); i965_media_h264_surface_state(ctx, 1, obj_surface, w * h, w / 4, h / 2 / (1 + field_picture), w, 1, field_picture, !!(va_pic->flags & VA_PICTURE_H264_BOTTOM_FIELD), - I965_SURFACEFORMAT_R8G8_SINT); /* INTERLEAVED U/V */ + I965_SURFACEFORMAT_R8G8_SINT, /* INTERLEAVED U/V */ + media_context); /* Reference Pictures */ for (i = 0; i < ARRAY_ELEMS(i965_h264_context->fsid_list); i++) { @@ -404,25 +406,25 @@ i965_media_h264_surfaces_setup(VADriverContextP ctx, 0, field_picture, !!(va_pic->flags & VA_PICTURE_H264_BOTTOM_FIELD), - I965_SURFACEFORMAT_R8_SINT); /* Y */ + I965_SURFACEFORMAT_R8_SINT, /* Y */ + media_context); i965_media_h264_surface_state(ctx, 18 + i, obj_surface, w * h, w / 4, h / 2 / (1 + field_picture), w, 0, field_picture, !!(va_pic->flags & VA_PICTURE_H264_BOTTOM_FIELD), - I965_SURFACEFORMAT_R8G8_SINT); /* INTERLEAVED U/V */ + I965_SURFACEFORMAT_R8G8_SINT, /* INTERLEAVED U/V */ + media_context); } } } static void -i965_media_h264_binding_table(VADriverContextP ctx) +i965_media_h264_binding_table(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; int i; unsigned int *binding_table; - dri_bo *bo = media_state->binding_table.bo; + dri_bo *bo = media_context->binding_table.bo; dri_bo_map(bo, 1); assert(bo->virtual); @@ -430,29 +432,27 @@ i965_media_h264_binding_table(VADriverContextP ctx) memset(binding_table, 0, bo->size); for (i = 0; i < MAX_MEDIA_SURFACES; i++) { - if (media_state->surface_state[i].bo) { - binding_table[i] = media_state->surface_state[i].bo->offset; + if (media_context->surface_state[i].bo) { + binding_table[i] = media_context->surface_state[i].bo->offset; dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0, i * sizeof(*binding_table), - media_state->surface_state[i].bo); + media_context->surface_state[i].bo); } } - dri_bo_unmap(media_state->binding_table.bo); + dri_bo_unmap(media_context->binding_table.bo); } static void -i965_media_h264_interface_descriptor_remap_table(VADriverContextP ctx) +i965_media_h264_interface_descriptor_remap_table(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_interface_descriptor *desc; int i; dri_bo *bo; - bo = media_state->idrt.bo; + bo = media_context->idrt.bo; dri_bo_map(bo, 1); assert(bo->virtual); desc = bo->virtual; @@ -466,7 +466,7 @@ i965_media_h264_interface_descriptor_remap_table(VADriverContextP ctx) desc->desc1.const_urb_entry_read_len = 2; desc->desc3.binding_table_entry_count = 0; desc->desc3.binding_table_pointer = - media_state->binding_table.bo->offset >> 5; /*reloc */ + media_context->binding_table.bo->offset >> 5; /*reloc */ dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, @@ -478,7 +478,7 @@ i965_media_h264_interface_descriptor_remap_table(VADriverContextP ctx) I915_GEM_DOMAIN_INSTRUCTION, 0, desc->desc3.binding_table_entry_count, i * sizeof(*desc) + offsetof(struct i965_interface_descriptor, desc3), - media_state->binding_table.bo); + media_context->binding_table.bo); desc++; } @@ -486,57 +486,54 @@ i965_media_h264_interface_descriptor_remap_table(VADriverContextP ctx) } static void -i965_media_h264_vfe_state(VADriverContextP ctx) +i965_media_h264_vfe_state(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_vfe_state *vfe_state; dri_bo *bo; - bo = media_state->vfe_state.bo; + bo = media_context->vfe_state.bo; dri_bo_map(bo, 1); assert(bo->virtual); vfe_state = bo->virtual; memset(vfe_state, 0, sizeof(*vfe_state)); vfe_state->vfe0.extend_vfe_state_present = 1; - vfe_state->vfe1.max_threads = media_state->urb.num_vfe_entries - 1; - vfe_state->vfe1.urb_entry_alloc_size = media_state->urb.size_vfe_entry - 1; - vfe_state->vfe1.num_urb_entries = media_state->urb.num_vfe_entries; + vfe_state->vfe1.max_threads = media_context->urb.num_vfe_entries - 1; + vfe_state->vfe1.urb_entry_alloc_size = media_context->urb.size_vfe_entry - 1; + vfe_state->vfe1.num_urb_entries = media_context->urb.num_vfe_entries; vfe_state->vfe1.vfe_mode = VFE_AVC_IT_MODE; vfe_state->vfe1.children_present = 0; vfe_state->vfe2.interface_descriptor_base = - media_state->idrt.bo->offset >> 4; /* reloc */ + media_context->idrt.bo->offset >> 4; /* reloc */ dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0, offsetof(struct i965_vfe_state, vfe2), - media_state->idrt.bo); + media_context->idrt.bo); dri_bo_unmap(bo); } static void i965_media_h264_vfe_state_extension(VADriverContextP ctx, - struct decode_state *decode_state) + struct decode_state *decode_state, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_h264_context *i965_h264_context; struct i965_vfe_state_ex *vfe_state_ex; VAPictureParameterBufferH264 *pic_param; int mbaff_frame_flag; - assert(media_state->private_context); - i965_h264_context = (struct i965_h264_context *)media_state->private_context; + assert(media_context->private_context); + i965_h264_context = (struct i965_h264_context *)media_context->private_context; assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer; mbaff_frame_flag = (pic_param->seq_fields.bits.mb_adaptive_frame_field_flag && !pic_param->pic_fields.bits.field_pic_flag); - assert(media_state->extended_state.bo); - dri_bo_map(media_state->extended_state.bo, 1); - assert(media_state->extended_state.bo->virtual); - vfe_state_ex = media_state->extended_state.bo->virtual; + assert(media_context->extended_state.bo); + dri_bo_map(media_context->extended_state.bo, 1); + assert(media_context->extended_state.bo->virtual); + vfe_state_ex = media_context->extended_state.bo->virtual; memset(vfe_state_ex, 0, sizeof(*vfe_state_ex)); /* @@ -643,27 +640,27 @@ i965_media_h264_vfe_state_extension(VADriverContextP ctx, vfe_state_ex->scoreboard2.delta_y7 = -2; } - dri_bo_unmap(media_state->extended_state.bo); + dri_bo_unmap(media_context->extended_state.bo); } static void -i965_media_h264_upload_constants(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_h264_upload_constants(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_h264_context *i965_h264_context; unsigned char *constant_buffer; VASliceParameterBufferH264 *slice_param; - assert(media_state->private_context); - i965_h264_context = (struct i965_h264_context *)media_state->private_context; + assert(media_context->private_context); + i965_h264_context = (struct i965_h264_context *)media_context->private_context; assert(decode_state->slice_params[0] && decode_state->slice_params[0]->buffer); slice_param = (VASliceParameterBufferH264 *)decode_state->slice_params[0]->buffer; - dri_bo_map(media_state->curbe.bo, 1); - assert(media_state->curbe.bo->virtual); - constant_buffer = media_state->curbe.bo->virtual; + dri_bo_map(media_context->curbe.bo, 1); + assert(media_context->curbe.bo->virtual); + constant_buffer = media_context->curbe.bo->virtual; /* HW solution for W=128 */ if (i965_h264_context->use_hw_w128) { @@ -684,41 +681,42 @@ i965_media_h264_upload_constants(VADriverContextP ctx, struct decode_state *deco } } - dri_bo_unmap(media_state->curbe.bo); + dri_bo_unmap(media_context->curbe.bo); } static void -i965_media_h264_states_setup(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_h264_states_setup(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_h264_context *i965_h264_context; - assert(media_state->private_context); - i965_h264_context = (struct i965_h264_context *)media_state->private_context; + assert(media_context->private_context); + i965_h264_context = (struct i965_h264_context *)media_context->private_context; - i965_avc_bsd_pipeline(ctx, decode_state); + i965_avc_bsd_pipeline(ctx, decode_state, i965_h264_context); - i965_avc_hw_scoreboard(ctx, decode_state); + if (i965_h264_context->use_avc_hw_scoreboard) + i965_avc_hw_scoreboard(ctx, decode_state, i965_h264_context); - i965_media_h264_surfaces_setup(ctx, decode_state); - i965_media_h264_binding_table(ctx); - i965_media_h264_interface_descriptor_remap_table(ctx); - i965_media_h264_vfe_state_extension(ctx, decode_state); - i965_media_h264_vfe_state(ctx); - i965_media_h264_upload_constants(ctx, decode_state); + i965_media_h264_surfaces_setup(ctx, decode_state, media_context); + i965_media_h264_binding_table(ctx, media_context); + i965_media_h264_interface_descriptor_remap_table(ctx, media_context); + i965_media_h264_vfe_state_extension(ctx, decode_state, media_context); + i965_media_h264_vfe_state(ctx, media_context); + i965_media_h264_upload_constants(ctx, decode_state, media_context); } static void -i965_media_h264_objects(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_h264_objects(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_h264_context *i965_h264_context; unsigned int *object_command; - assert(media_state->private_context); - i965_h264_context = (struct i965_h264_context *)media_state->private_context; + assert(media_context->private_context); + i965_h264_context = (struct i965_h264_context *)media_context->private_context; dri_bo_map(i965_h264_context->avc_it_command_mb_info.bo, True); assert(i965_h264_context->avc_it_command_mb_info.bo->virtual); @@ -742,7 +740,7 @@ i965_media_h264_objects(VADriverContextP ctx, struct decode_state *decode_state) intel_batchbuffer_end_atomic(ctx); intel_batchbuffer_flush(ctx); intel_batchbuffer_start_atomic(ctx, 0x1000); - i965_avc_ildb(ctx, decode_state); + i965_avc_ildb(ctx, decode_state, i965_h264_context); } static void @@ -772,80 +770,15 @@ i965_media_h264_free_private_context(void **data) } void -i965_media_h264_decode_init(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_h264_decode_init(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; - struct i965_h264_context *i965_h264_context; + struct i965_h264_context *i965_h264_context = media_context->private_context; dri_bo *bo; - int i; VAPictureParameterBufferH264 *pic_param; - i965_h264_context = media_state->private_context; - - if (i965_h264_context == NULL) { - /* kernel */ - assert(NUM_H264_AVC_KERNELS == (sizeof(h264_avc_kernels_gen5) / - sizeof(h264_avc_kernels_gen5[0]))); - assert(NUM_AVC_MC_INTERFACES == (sizeof(avc_mc_kernel_offset_gen5) / - sizeof(avc_mc_kernel_offset_gen5[0]))); - - i965_h264_context = calloc(1, sizeof(struct i965_h264_context)); - - if (IS_IRONLAKE(i965->intel.device_id)) { - h264_avc_kernels = h264_avc_kernels_gen5; - avc_mc_kernel_offset = avc_mc_kernel_offset_gen5; - intra_kernel_header = &intra_kernel_header_gen5; - i965_h264_context->use_avc_hw_scoreboard = 1; - i965_h264_context->use_hw_w128 = 1; - } else { - h264_avc_kernels = h264_avc_kernels_gen4; - avc_mc_kernel_offset = avc_mc_kernel_offset_gen4; - intra_kernel_header = &intra_kernel_header_gen4; - i965_h264_context->use_avc_hw_scoreboard = 0; - i965_h264_context->use_hw_w128 = 0; - } - - for (i = 0; i < NUM_H264_AVC_KERNELS; i++) { - struct media_kernel *kernel = &h264_avc_kernels[i]; - kernel->bo = dri_bo_alloc(i965->intel.bufmgr, - kernel->name, - kernel->size, 0x1000); - assert(kernel->bo); - dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin); - } - - for (i = 0; i < 16; i++) { - i965_h264_context->fsid_list[i].surface_id = VA_INVALID_ID; - i965_h264_context->fsid_list[i].frame_store_id = -1; - } - - media_state->private_context = i965_h264_context; - media_state->free_private_context = i965_media_h264_free_private_context; - - /* URB */ - if (IS_IRONLAKE(i965->intel.device_id)) { - media_state->urb.num_vfe_entries = 63; - } else { - media_state->urb.num_vfe_entries = 23; - } - - media_state->urb.size_vfe_entry = 16; - - media_state->urb.num_cs_entries = 1; - media_state->urb.size_cs_entry = 1; - - media_state->urb.vfe_start = 0; - media_state->urb.cs_start = media_state->urb.vfe_start + - media_state->urb.num_vfe_entries * media_state->urb.size_vfe_entry; - assert(media_state->urb.cs_start + - media_state->urb.num_cs_entries * media_state->urb.size_cs_entry <= URB_SIZE((&i965->intel))); - - /* hook functions */ - media_state->media_states_setup = i965_media_h264_states_setup; - media_state->media_objects = i965_media_h264_objects; - } - assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer; i965_h264_context->picture.width_in_mbs = ((pic_param->picture_width_in_mbs_minus1 + 1) & 0xff); @@ -874,10 +807,10 @@ i965_media_h264_decode_init(VADriverContextP ctx, struct decode_state *decode_st assert(bo); i965_h264_context->avc_it_data.bo = bo; i965_h264_context->avc_it_data.write_offset = 0; - dri_bo_unreference(media_state->indirect_object.bo); - media_state->indirect_object.bo = bo; - dri_bo_reference(media_state->indirect_object.bo); - media_state->indirect_object.offset = i965_h264_context->avc_it_data.write_offset; + dri_bo_unreference(media_context->indirect_object.bo); + media_context->indirect_object.bo = bo; + dri_bo_reference(media_context->indirect_object.bo); + media_context->indirect_object.offset = i965_h264_context->avc_it_data.write_offset; dri_bo_unreference(i965_h264_context->avc_ildb_data.bo); bo = dri_bo_alloc(i965->intel.bufmgr, @@ -888,20 +821,92 @@ i965_media_h264_decode_init(VADriverContextP ctx, struct decode_state *decode_st i965_h264_context->avc_ildb_data.bo = bo; /* bsd pipeline */ - i965_avc_bsd_decode_init(ctx); + i965_avc_bsd_decode_init(ctx, i965_h264_context); /* HW scoreboard */ - i965_avc_hw_scoreboard_decode_init(ctx); + if (i965_h264_context->use_avc_hw_scoreboard) + i965_avc_hw_scoreboard_decode_init(ctx, i965_h264_context); /* ILDB */ - i965_avc_ildb_decode_init(ctx); + i965_avc_ildb_decode_init(ctx, i965_h264_context); /* for Media pipeline */ - media_state->extended_state.enabled = 1; - dri_bo_unreference(media_state->extended_state.bo); + media_context->extended_state.enabled = 1; + dri_bo_unreference(media_context->extended_state.bo); bo = dri_bo_alloc(i965->intel.bufmgr, "extened vfe state", sizeof(struct i965_vfe_state_ex), 32); assert(bo); - media_state->extended_state.bo = bo; + media_context->extended_state.bo = bo; +} + +void +i965_media_h264_dec_context_init(VADriverContextP ctx, struct i965_media_context *media_context) +{ + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct i965_h264_context *i965_h264_context; + int i; + + i965_h264_context = calloc(1, sizeof(struct i965_h264_context)); + + /* kernel */ + if (h264_avc_kernels == NULL) { + assert(NUM_H264_AVC_KERNELS == (sizeof(h264_avc_kernels_gen5) / + sizeof(h264_avc_kernels_gen5[0]))); + assert(NUM_AVC_MC_INTERFACES == (sizeof(avc_mc_kernel_offset_gen5) / + sizeof(avc_mc_kernel_offset_gen5[0]))); + + if (IS_IRONLAKE(i965->intel.device_id)) { + h264_avc_kernels = h264_avc_kernels_gen5; + avc_mc_kernel_offset = avc_mc_kernel_offset_gen5; + intra_kernel_header = &intra_kernel_header_gen5; + i965_h264_context->use_avc_hw_scoreboard = 1; + i965_h264_context->use_hw_w128 = 1; + } else { + h264_avc_kernels = h264_avc_kernels_gen4; + avc_mc_kernel_offset = avc_mc_kernel_offset_gen4; + intra_kernel_header = &intra_kernel_header_gen4; + i965_h264_context->use_avc_hw_scoreboard = 0; + i965_h264_context->use_hw_w128 = 0; + } + + for (i = 0; i < NUM_H264_AVC_KERNELS; i++) { + struct media_kernel *kernel = &h264_avc_kernels[i]; + kernel->bo = dri_bo_alloc(i965->intel.bufmgr, + kernel->name, + kernel->size, 0x1000); + assert(kernel->bo); + dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin); + } + } + + for (i = 0; i < 16; i++) { + i965_h264_context->fsid_list[i].surface_id = VA_INVALID_ID; + i965_h264_context->fsid_list[i].frame_store_id = -1; + } + + media_context->private_context = i965_h264_context; + media_context->free_private_context = i965_media_h264_free_private_context; + + /* URB */ + if (IS_IRONLAKE(i965->intel.device_id)) { + media_context->urb.num_vfe_entries = 63; + } else { + media_context->urb.num_vfe_entries = 23; + } + + media_context->urb.size_vfe_entry = 16; + + media_context->urb.num_cs_entries = 1; + media_context->urb.size_cs_entry = 1; + + media_context->urb.vfe_start = 0; + media_context->urb.cs_start = media_context->urb.vfe_start + + media_context->urb.num_vfe_entries * media_context->urb.size_vfe_entry; + assert(media_context->urb.cs_start + + media_context->urb.num_cs_entries * media_context->urb.size_cs_entry <= URB_SIZE((&i965->intel))); + + /* hook functions */ + media_context->media_states_setup = i965_media_h264_states_setup; + media_context->media_objects = i965_media_h264_objects; } diff --git a/i965_drv_video/i965_media_h264.h b/i965_drv_video/i965_media_h264.h index d1b6214..3af7e8d 100644 --- a/i965_drv_video/i965_media_h264.h +++ b/i965_drv_video/i965_media_h264.h @@ -5,6 +5,9 @@ #include "i965_avc_hw_scoreboard.h" #include "i965_avc_ildb.h" +struct decode_state; +struct i965_media_context; + #define INST_UNIT_GEN4 16 #define INST_UNIT_GEN5 8 @@ -61,6 +64,7 @@ struct i965_h264_context } fsid_list[16]; }; -void i965_media_h264_decode_init(VADriverContextP ctx, struct decode_state *decode_state); +void i965_media_h264_decode_init(VADriverContextP ctx, struct decode_state *decode_state, struct i965_media_context *media_context); +void i965_media_h264_dec_context_init(VADriverContextP ctx, struct i965_media_context *media_context); #endif /* _I965_MEDIA_H264_H_ */ diff --git a/i965_drv_video/i965_media_mpeg2.c b/i965_drv_video/i965_media_mpeg2.c index 6b20d89..db02025 100644 --- a/i965_drv_video/i965_media_mpeg2.c +++ b/i965_drv_video/i965_media_mpeg2.c @@ -35,11 +35,11 @@ #include "intel_batchbuffer.h" #include "intel_driver.h" - #include "i965_defines.h" +#include "i965_drv_video.h" + #include "i965_media.h" #include "i965_media_mpeg2.h" -#include "i965_drv_video.h" #define SURFACE_TARGET 0 #define SURFACE_FORWARD 1 @@ -462,10 +462,10 @@ i965_media_mpeg2_surface_state(VADriverContextP ctx, int w, int h, Bool is_dst, int vert_line_stride, - int vert_line_stride_ofs) + int vert_line_stride_ofs, + struct i965_media_context *media_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_surface_state *ss; dri_bo *bo; uint32_t write_domain, read_domain; @@ -503,8 +503,8 @@ i965_media_mpeg2_surface_state(VADriverContextP ctx, dri_bo_unmap(bo); assert(index < MAX_MEDIA_SURFACES); -// assert(media_state->surface_state[index].bo == NULL); - media_state->surface_state[index].bo = bo; +// assert(media_context->surface_state[index].bo == NULL); + media_context->surface_state[index].bo = bo; } static void @@ -513,7 +513,8 @@ i965_media_mpeg2_surface_setup(VADriverContextP ctx, struct object_surface *obj_surface, Bool is_dst, int picture_structure, - int surface) + int surface, + struct i965_media_context *media_context) { int w = obj_surface->width; int h = obj_surface->height; @@ -529,64 +530,80 @@ i965_media_mpeg2_surface_setup(VADriverContextP ctx, if (picture_structure == MPEG_FRAME) { i965_media_mpeg2_surface_state(ctx, base_index + 0, obj_surface, - 0, w, h, - is_dst, 0, 0); + 0, w, h, + is_dst, 0, 0, + media_context); i965_media_mpeg2_surface_state(ctx, base_index + 1, obj_surface, - w * h, w / 2, h / 2, - is_dst, 0, 0); + w * h, w / 2, h / 2, + is_dst, 0, 0, + media_context); i965_media_mpeg2_surface_state(ctx, base_index + 2, obj_surface, - w * h + w * h / 4, w / 2, h / 2, - is_dst, 0, 0); + w * h + w * h / 4, w / 2, h / 2, + is_dst, 0, 0, + media_context); } else { if (surface == SURFACE_TARGET) { i965_media_mpeg2_surface_state(ctx, 3, obj_surface, - 0, w, h, - False, 0, 0); + 0, w, h, + False, 0, 0, + media_context); i965_media_mpeg2_surface_state(ctx, 10, obj_surface, - w * h, w / 2, h / 2, - False, 0, 0); + w * h, w / 2, h / 2, + False, 0, 0, + media_context); i965_media_mpeg2_surface_state(ctx, 11, obj_surface, - w * h + w * h / 4, w / 2, h / 2, - False, 0, 0); + w * h + w * h / 4, w / 2, h / 2, + False, 0, 0, + media_context); if (picture_structure == MPEG_TOP_FIELD) { i965_media_mpeg2_surface_state(ctx, base_index + 0, obj_surface, - 0, w, h, - True, 1, 0); + 0, w, h, + True, 1, 0, + media_context); i965_media_mpeg2_surface_state(ctx, base_index + 1, obj_surface, - w * h, w / 2, h / 2, - True, 1, 0); + w * h, w / 2, h / 2, + True, 1, 0, + media_context); i965_media_mpeg2_surface_state(ctx, base_index + 2, obj_surface, - w * h + w * h / 4, w / 2, h / 2, - True, 1, 0); + w * h + w * h / 4, w / 2, h / 2, + True, 1, 0, + media_context); } else { assert(picture_structure == MPEG_BOTTOM_FIELD); i965_media_mpeg2_surface_state(ctx, base_index + 0, obj_surface, - 0, w, h, - True, 1, 1); + 0, w, h, + True, 1, 1, + media_context); i965_media_mpeg2_surface_state(ctx, base_index + 1, obj_surface, - w * h, w / 2, h / 2, - True, 1, 1); + w * h, w / 2, h / 2, + True, 1, 1, + media_context); i965_media_mpeg2_surface_state(ctx, base_index + 2, obj_surface, - w * h + w * h / 4, w / 2, h / 2, - True, 1, 1); + w * h + w * h / 4, w / 2, h / 2, + True, 1, 1, + media_context); } } else { i965_media_mpeg2_surface_state(ctx, base_index + 0, obj_surface, - 0, w, h, - is_dst, 0, 0); + 0, w, h, + is_dst, 0, 0, + media_context); i965_media_mpeg2_surface_state(ctx, base_index + 1, obj_surface, - w * h, w / 2, h / 2, - is_dst, 0, 0); + w * h, w / 2, h / 2, + is_dst, 0, 0, + media_context); i965_media_mpeg2_surface_state(ctx, base_index + 2, obj_surface, - w * h + w * h / 4, w / 2, h / 2, - is_dst, 0, 0); + w * h + w * h / 4, w / 2, h / 2, + is_dst, 0, 0, + media_context); } } } void i965_media_mpeg2_surfaces_setup(VADriverContextP ctx, - struct decode_state *decode_state) + struct decode_state *decode_state, + struct i965_media_context *media_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_surface *obj_surface; @@ -598,37 +615,43 @@ i965_media_mpeg2_surfaces_setup(VADriverContextP ctx, obj_surface = SURFACE(decode_state->current_render_target); assert(obj_surface); i965_media_mpeg2_surface_setup(ctx, 0, obj_surface, True, - param->picture_coding_extension.bits.picture_structure, SURFACE_TARGET); + param->picture_coding_extension.bits.picture_structure, + SURFACE_TARGET, + media_context); obj_surface = SURFACE(param->forward_reference_picture); if (!obj_surface) { // assert(param->picture_coding_type == 1); /* I-picture */ } else { i965_media_mpeg2_surface_setup(ctx, 4, obj_surface, False, - param->picture_coding_extension.bits.picture_structure, SURFACE_FORWARD); + param->picture_coding_extension.bits.picture_structure, + SURFACE_FORWARD, + media_context); obj_surface = SURFACE(param->backward_reference_picture); if (!obj_surface) { assert(param->picture_coding_type == 2); /* P-picture */ obj_surface = SURFACE(param->forward_reference_picture); i965_media_mpeg2_surface_setup(ctx, 7, obj_surface, False, - param->picture_coding_extension.bits.picture_structure, SURFACE_BACKWARD); + param->picture_coding_extension.bits.picture_structure, + SURFACE_BACKWARD, + media_context); } else { assert(param->picture_coding_type == 3); /* B-picture */ i965_media_mpeg2_surface_setup(ctx, 7, obj_surface, False, - param->picture_coding_extension.bits.picture_structure, SURFACE_BIDIRECT); + param->picture_coding_extension.bits.picture_structure, + SURFACE_BIDIRECT, + media_context); } } } static void -i965_media_mpeg2_binding_table(VADriverContextP ctx) +i965_media_mpeg2_binding_table(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; int i; unsigned int *binding_table; - dri_bo *bo = media_state->binding_table.bo; + dri_bo *bo = media_context->binding_table.bo; dri_bo_map(bo, 1); assert(bo->virtual); @@ -636,58 +659,54 @@ i965_media_mpeg2_binding_table(VADriverContextP ctx) memset(binding_table, 0, bo->size); for (i = 0; i < MAX_MEDIA_SURFACES; i++) { - if (media_state->surface_state[i].bo) { - binding_table[i] = media_state->surface_state[i].bo->offset; + if (media_context->surface_state[i].bo) { + binding_table[i] = media_context->surface_state[i].bo->offset; dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0, i * sizeof(*binding_table), - media_state->surface_state[i].bo); + media_context->surface_state[i].bo); } } - dri_bo_unmap(media_state->binding_table.bo); + dri_bo_unmap(media_context->binding_table.bo); } static void -i965_media_mpeg2_vfe_state(VADriverContextP ctx) +i965_media_mpeg2_vfe_state(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_vfe_state *vfe_state; dri_bo *bo; - bo = media_state->vfe_state.bo; + bo = media_context->vfe_state.bo; dri_bo_map(bo, 1); assert(bo->virtual); vfe_state = bo->virtual; memset(vfe_state, 0, sizeof(*vfe_state)); vfe_state->vfe0.extend_vfe_state_present = 1; vfe_state->vfe1.vfe_mode = VFE_VLD_MODE; - vfe_state->vfe1.num_urb_entries = media_state->urb.num_vfe_entries; + vfe_state->vfe1.num_urb_entries = media_context->urb.num_vfe_entries; vfe_state->vfe1.children_present = 0; - vfe_state->vfe1.urb_entry_alloc_size = media_state->urb.size_vfe_entry - 1; - vfe_state->vfe1.max_threads = media_state->urb.num_vfe_entries - 1; + vfe_state->vfe1.urb_entry_alloc_size = media_context->urb.size_vfe_entry - 1; + vfe_state->vfe1.max_threads = media_context->urb.num_vfe_entries - 1; vfe_state->vfe2.interface_descriptor_base = - media_state->idrt.bo->offset >> 4; /* reloc */ + media_context->idrt.bo->offset >> 4; /* reloc */ dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0, offsetof(struct i965_vfe_state, vfe2), - media_state->idrt.bo); + media_context->idrt.bo); dri_bo_unmap(bo); } static void -i965_media_mpeg2_interface_descriptor_remap_table(VADriverContextP ctx) +i965_media_mpeg2_interface_descriptor_remap_table(VADriverContextP ctx, struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_interface_descriptor *desc; int i; dri_bo *bo; - bo = media_state->idrt.bo; + bo = media_context->idrt.bo; dri_bo_map(bo, 1); assert(bo->virtual); desc = bo->virtual; @@ -700,7 +719,7 @@ i965_media_mpeg2_interface_descriptor_remap_table(VADriverContextP ctx) desc->desc1.const_urb_entry_read_len = 30; desc->desc3.binding_table_entry_count = 0; desc->desc3.binding_table_pointer = - media_state->binding_table.bo->offset >> 5; /*reloc */ + media_context->binding_table.bo->offset >> 5; /*reloc */ dri_bo_emit_reloc(bo, I915_GEM_DOMAIN_INSTRUCTION, 0, @@ -712,7 +731,7 @@ i965_media_mpeg2_interface_descriptor_remap_table(VADriverContextP ctx) I915_GEM_DOMAIN_INSTRUCTION, 0, desc->desc3.binding_table_entry_count, i * sizeof(*desc) + offsetof(struct i965_interface_descriptor, desc3), - media_state->binding_table.bo); + media_context->binding_table.bo); desc++; } @@ -720,20 +739,20 @@ i965_media_mpeg2_interface_descriptor_remap_table(VADriverContextP ctx) } void -i965_media_mpeg2_vld_state(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_mpeg2_vld_state(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; struct i965_vld_state *vld_state; VAPictureParameterBufferMPEG2 *param; assert(decode_state->pic_param && decode_state->pic_param->buffer); param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer; - assert(media_state->extended_state.bo); - dri_bo_map(media_state->extended_state.bo, 1); - assert(media_state->extended_state.bo->virtual); - vld_state = media_state->extended_state.bo->virtual; + assert(media_context->extended_state.bo); + dri_bo_map(media_context->extended_state.bo, 1); + assert(media_context->extended_state.bo->virtual); + vld_state = media_context->extended_state.bo->virtual; memset(vld_state, 0, sizeof(*vld_state)); vld_state->vld0.f_code_0_0 = ((param->f_code >> 12) & 0xf); @@ -782,23 +801,23 @@ i965_media_mpeg2_vld_state(VADriverContextP ctx, struct decode_state *decode_sta vld_state->desc_remap_table0.index_7 = FIELD_BIDIRECT_16X8; } - dri_bo_unmap(media_state->extended_state.bo); + dri_bo_unmap(media_context->extended_state.bo); } static void -i965_media_mpeg2_upload_constants(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_mpeg2_upload_constants(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; int i, j; unsigned char *constant_buffer; unsigned char *qmx; unsigned int *lib_reloc; int lib_reloc_offset = 0; - dri_bo_map(media_state->curbe.bo, 1); - assert(media_state->curbe.bo->virtual); - constant_buffer = media_state->curbe.bo->virtual; + dri_bo_map(media_context->curbe.bo, 1); + assert(media_context->curbe.bo->virtual); + constant_buffer = media_context->curbe.bo->virtual; /* iq_matrix */ if (decode_state->iq_matrix && decode_state->iq_matrix->buffer) { @@ -836,29 +855,33 @@ i965_media_mpeg2_upload_constants(VADriverContextP ctx, struct decode_state *dec lib_reloc = (unsigned int *)(constant_buffer + lib_reloc_offset); for (i = 0; i < 8; i++) { lib_reloc[i] = mpeg2_vld_kernels[LIB_INTERFACE].bo->offset; - dri_bo_emit_reloc(media_state->curbe.bo, + dri_bo_emit_reloc(media_context->curbe.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0, lib_reloc_offset + i * sizeof(unsigned int), mpeg2_vld_kernels[LIB_INTERFACE].bo); } - dri_bo_unmap(media_state->curbe.bo); + dri_bo_unmap(media_context->curbe.bo); } static void -i965_media_mpeg2_states_setup(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_mpeg2_states_setup(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { - i965_media_mpeg2_surfaces_setup(ctx, decode_state); - i965_media_mpeg2_binding_table(ctx); - i965_media_mpeg2_interface_descriptor_remap_table(ctx); - i965_media_mpeg2_vld_state(ctx, decode_state); - i965_media_mpeg2_vfe_state(ctx); - i965_media_mpeg2_upload_constants(ctx, decode_state); + i965_media_mpeg2_surfaces_setup(ctx, decode_state, media_context); + i965_media_mpeg2_binding_table(ctx, media_context); + i965_media_mpeg2_interface_descriptor_remap_table(ctx, media_context); + i965_media_mpeg2_vld_state(ctx, decode_state, media_context); + i965_media_mpeg2_vfe_state(ctx, media_context); + i965_media_mpeg2_upload_constants(ctx, decode_state, media_context); } static void -i965_media_mpeg2_objects(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_mpeg2_objects(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { int i, j; VASliceParameterBufferMPEG2 *slice_param; @@ -906,14 +929,33 @@ i965_media_mpeg2_free_private_context(void **data) } void -i965_media_mpeg2_decode_init(VADriverContextP ctx, struct decode_state *decode_state) +i965_media_mpeg2_decode_init(VADriverContextP ctx, + struct decode_state *decode_state, + struct i965_media_context *media_context) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_media_state *media_state = &i965->media_state; dri_bo *bo; + + dri_bo_unreference(media_context->indirect_object.bo); + media_context->indirect_object.bo = NULL; + + media_context->extended_state.enabled = 1; + dri_bo_unreference(media_context->extended_state.bo); + bo = dri_bo_alloc(i965->intel.bufmgr, + "vld state", + sizeof(struct i965_vld_state), 32); + assert(bo); + media_context->extended_state.bo = bo; +} + +void +i965_media_mpeg2_dec_context_init(VADriverContextP ctx, struct i965_media_context *media_context) +{ + struct i965_driver_data *i965 = i965_driver_data(ctx); int i; + + /* kernel */ if (mpeg2_vld_kernels == NULL) { - /* kernel */ assert(NUM_MPEG2_VLD_KERNELS == (sizeof(mpeg2_vld_kernels_gen5) / sizeof(mpeg2_vld_kernels_gen5[0]))); assert(NUM_MPEG2_VLD_KERNELS <= MAX_INTERFACE_DESC); @@ -931,33 +973,24 @@ i965_media_mpeg2_decode_init(VADriverContextP ctx, struct decode_state *decode_s assert(kernel->bo); dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin); } + } - /* URB */ - media_state->urb.num_vfe_entries = 28; - media_state->urb.size_vfe_entry = 13; - - media_state->urb.num_cs_entries = 1; - media_state->urb.size_cs_entry = 16; + /* URB */ + media_context->urb.num_vfe_entries = 28; + media_context->urb.size_vfe_entry = 13; - media_state->urb.vfe_start = 0; - media_state->urb.cs_start = media_state->urb.vfe_start + - media_state->urb.num_vfe_entries * media_state->urb.size_vfe_entry; - assert(media_state->urb.cs_start + - media_state->urb.num_cs_entries * media_state->urb.size_cs_entry <= URB_SIZE((&i965->intel))); + media_context->urb.num_cs_entries = 1; + media_context->urb.size_cs_entry = 16; - /* hook functions */ - media_state->media_states_setup = i965_media_mpeg2_states_setup; - media_state->media_objects = i965_media_mpeg2_objects; - media_state->free_private_context = i965_media_mpeg2_free_private_context; - } + media_context->urb.vfe_start = 0; + media_context->urb.cs_start = media_context->urb.vfe_start + + media_context->urb.num_vfe_entries * media_context->urb.size_vfe_entry; + assert(media_context->urb.cs_start + + media_context->urb.num_cs_entries * media_context->urb.size_cs_entry <= URB_SIZE((&i965->intel))); - media_state->extended_state.enabled = 1; - media_state->indirect_object.bo = NULL; - dri_bo_unreference(media_state->extended_state.bo); - bo = dri_bo_alloc(i965->intel.bufmgr, - "vld state", - sizeof(struct i965_vld_state), 32); - assert(bo); - media_state->extended_state.bo = bo; + /* hook functions */ + media_context->media_states_setup = i965_media_mpeg2_states_setup; + media_context->media_objects = i965_media_mpeg2_objects; + media_context->private_context = i965_mpeg2_context; + media_context->free_private_context = i965_media_mpeg2_free_private_context; } - diff --git a/i965_drv_video/i965_media_mpeg2.h b/i965_drv_video/i965_media_mpeg2.h index 3a78ac3..7da9b78 100644 --- a/i965_drv_video/i965_media_mpeg2.h +++ b/i965_drv_video/i965_media_mpeg2.h @@ -35,10 +35,10 @@ #include <i915_drm.h> #include <intel_bufmgr.h> -#include "i965_structs.h" - struct decode_state; +struct i965_media_context; -void i965_media_mpeg2_decode_init(VADriverContextP ctx, struct decode_state * decode_state); +void i965_media_mpeg2_decode_init(VADriverContextP ctx, struct decode_state * decode_state, struct i965_media_context *media_context); +void i965_media_mpeg2_dec_context_init(VADriverContextP ctx, struct i965_media_context *media_context); #endif /* _I965_MEDIA_MPEG2_H_ */ diff --git a/i965_drv_video/i965_post_processing.c b/i965_drv_video/i965_post_processing.c index 29e02a2..b6db19a 100644 --- a/i965_drv_video/i965_post_processing.c +++ b/i965_drv_video/i965_post_processing.c @@ -35,8 +35,9 @@ #include "intel_batchbuffer.h" #include "intel_driver.h" - #include "i965_defines.h" +#include "i965_structs.h" + #include "i965_post_processing.h" #include "i965_render.h" #include "i965_drv_video.h" diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c index efed4c3..c34f6ae 100644 --- a/i965_drv_video/i965_render.c +++ b/i965_drv_video/i965_render.c @@ -41,10 +41,11 @@ #include "intel_batchbuffer.h" #include "intel_driver.h" - #include "i965_defines.h" -#include "i965_render.h" #include "i965_drv_video.h" +#include "i965_structs.h" + +#include "i965_render.h" #define SF_KERNEL_NUM_GRF 16 #define SF_MAX_THREADS 1 diff --git a/i965_drv_video/intel_batchbuffer.h b/i965_drv_video/intel_batchbuffer.h index 77174fe..6df8d45 100644 --- a/i965_drv_video/intel_batchbuffer.h +++ b/i965_drv_video/intel_batchbuffer.h @@ -23,7 +23,7 @@ struct intel_batchbuffer int (*run)(drm_intel_bo *bo, int used, drm_clip_rect_t *cliprects, int num_cliprects, - int DR4, int ring_flag); + int DR4, unsigned int ring_flag); }; Bool intel_batchbuffer_init(struct intel_driver_data *intel); |