Commit a3adec01 authored by Xiang, Haihao's avatar Xiang, Haihao

i965_drv_video: fix initialization function

parent 06d54f63
...@@ -283,8 +283,6 @@ i965_media_decode_picture(VADriverContextP ctx, ...@@ -283,8 +283,6 @@ i965_media_decode_picture(VADriverContextP ctx,
Bool Bool
i965_media_init(VADriverContextP ctx) i965_media_init(VADriverContextP ctx)
{ {
i965_media_mpeg2_init(ctx);
i965_media_h264_init(ctx);
return True; return True;
} }
...@@ -295,6 +293,9 @@ i965_media_terminate(VADriverContextP ctx) ...@@ -295,6 +293,9 @@ i965_media_terminate(VADriverContextP ctx)
struct i965_media_state *media_state = &i965->media_state; struct i965_media_state *media_state = &i965->media_state;
int i; int i;
assert(media_state->free_private_context);
media_state->free_private_context(&media_state->private_context);
for (i = 0; i < MAX_MEDIA_SURFACES; i++) { for (i = 0; i < MAX_MEDIA_SURFACES; i++) {
dri_bo_unreference(media_state->surface_state[i].bo); dri_bo_unreference(media_state->surface_state[i].bo);
media_state->surface_state[i].bo = NULL; media_state->surface_state[i].bo = NULL;
...@@ -318,8 +319,6 @@ i965_media_terminate(VADriverContextP ctx) ...@@ -318,8 +319,6 @@ i965_media_terminate(VADriverContextP ctx)
dri_bo_unreference(media_state->indirect_object.bo); dri_bo_unreference(media_state->indirect_object.bo);
media_state->indirect_object.bo = NULL; media_state->indirect_object.bo = NULL;
i965_media_mpeg2_ternimate(ctx);
i965_media_h264_ternimate(ctx);
return True; return True;
} }
...@@ -101,6 +101,7 @@ struct i965_media_state ...@@ -101,6 +101,7 @@ struct i965_media_state
void *private_context; void *private_context;
void (*media_states_setup)(VADriverContextP ctx, struct decode_state *decode_state); void (*media_states_setup)(VADriverContextP ctx, struct decode_state *decode_state);
void (*media_objects)(VADriverContextP ctx, struct decode_state *decode_state); void (*media_objects)(VADriverContextP ctx, struct decode_state *decode_state);
void (*free_private_context)(void **data);
}; };
Bool i965_media_init(VADriverContextP ctx); Bool i965_media_init(VADriverContextP ctx);
......
...@@ -759,103 +759,52 @@ i965_media_h264_objects(VADriverContextP ctx, struct decode_state *decode_state) ...@@ -759,103 +759,52 @@ i965_media_h264_objects(VADriverContextP ctx, struct decode_state *decode_state)
i965_avc_ildb(ctx, decode_state); i965_avc_ildb(ctx, decode_state);
} }
void static void
i965_media_h264_decode_init(VADriverContextP ctx) i965_media_h264_free_private_context(void **data)
{ {
struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_h264_context *i965_h264_context = *data;
struct i965_media_state *media_state = &i965->media_state; int i;
struct i965_h264_context *i965_h264_context;
dri_bo *bo;
assert(media_state->private_context); if (i965_h264_context == NULL)
i965_h264_context = media_state->private_context; return;
i965_avc_ildb_ternimate(&i965_h264_context->avc_ildb_context);
i965_avc_hw_scoreboard_ternimate(&i965_h264_context->avc_hw_scoreboard_context);
i965_avc_bsd_ternimate(&i965_h264_context->i965_avc_bsd_context);
dri_bo_unreference(i965_h264_context->avc_it_command_mb_info.bo); dri_bo_unreference(i965_h264_context->avc_it_command_mb_info.bo);
bo = dri_bo_alloc(i965->intel.bufmgr,
"avc it command mb info",
0x80000 * (1 + i965_h264_context->use_avc_hw_scoreboard), /* at least 522240 bytes */
0x1000);
assert(bo);
i965_h264_context->avc_it_command_mb_info.bo = bo;
dri_bo_unreference(i965_h264_context->avc_it_data.bo); dri_bo_unreference(i965_h264_context->avc_it_data.bo);
bo = dri_bo_alloc(i965->intel.bufmgr,
"avc it data",
0x1000000, /* at least 16711680 bytes */
4096);
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(i965_h264_context->avc_ildb_data.bo); dri_bo_unreference(i965_h264_context->avc_ildb_data.bo);
bo = dri_bo_alloc(i965->intel.bufmgr, free(i965_h264_context);
"AVC-ILDB Data Buffer", *data = NULL;
0x100000, /* at least 1044480 bytes */
64);
assert(bo);
i965_h264_context->avc_ildb_data.bo = bo;
/* bsd pipeline */
i965_avc_bsd_decode_init(ctx);
/* HW scoreboard */
i965_avc_hw_scoreboard_decode_init(ctx);
/* ILDB */
i965_avc_ildb_decode_init(ctx);
/* for Media pipeline */ for (i = 0; i < NUM_H264_AVC_KERNELS; i++) {
media_state->extended_state.enabled = 1; struct media_kernel *kernel = &h264_avc_kernels[i];
dri_bo_unreference(media_state->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;
/* URB */ dri_bo_unreference(kernel->bo);
if (IS_IRONLAKE(i965->intel.device_id)) { kernel->bo = NULL;
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;
} }
Bool void
i965_media_h264_init(VADriverContextP ctx) i965_media_h264_decode_init(VADriverContextP ctx)
{ {
struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state; struct i965_media_state *media_state = &i965->media_state;
struct i965_h264_context *i965_h264_context; struct i965_h264_context *i965_h264_context;
dri_bo *bo;
int i; int i;
i965_h264_context = calloc(1, sizeof(struct i965_h264_context)); i965_h264_context = media_state->private_context;
if (i965_h264_context == NULL) {
/* kernel */ /* kernel */
assert(NUM_H264_AVC_KERNELS == (sizeof(h264_avc_kernels_gen5) / assert(NUM_H264_AVC_KERNELS == (sizeof(h264_avc_kernels_gen5) /
sizeof(h264_avc_kernels_gen5[0]))); sizeof(h264_avc_kernels_gen5[0])));
assert(NUM_AVC_MC_INTERFACES == (sizeof(avc_mc_kernel_offset_gen5) / assert(NUM_AVC_MC_INTERFACES == (sizeof(avc_mc_kernel_offset_gen5) /
sizeof(avc_mc_kernel_offset_gen5[0]))); sizeof(avc_mc_kernel_offset_gen5[0])));
i965_h264_context = calloc(1, sizeof(struct i965_h264_context));
if (IS_IRONLAKE(i965->intel.device_id)) { if (IS_IRONLAKE(i965->intel.device_id)) {
h264_avc_kernels = h264_avc_kernels_gen5; h264_avc_kernels = h264_avc_kernels_gen5;
avc_mc_kernel_offset = avc_mc_kernel_offset_gen5; avc_mc_kernel_offset = avc_mc_kernel_offset_gen5;
...@@ -884,37 +833,78 @@ i965_media_h264_init(VADriverContextP ctx) ...@@ -884,37 +833,78 @@ i965_media_h264_init(VADriverContextP ctx)
i965_h264_context->fsid_list[i].frame_store_id = -1; i965_h264_context->fsid_list[i].frame_store_id = -1;
} }
i965_h264_context->enable_avc_ildb = 0;
media_state->private_context = i965_h264_context; media_state->private_context = i965_h264_context;
return True; media_state->free_private_context = i965_media_h264_free_private_context;
}
Bool /* URB */
i965_media_h264_ternimate(VADriverContextP ctx) if (IS_IRONLAKE(i965->intel.device_id)) {
{ media_state->urb.num_vfe_entries = 63;
struct i965_driver_data *i965 = i965_driver_data(ctx); } else {
struct i965_media_state *media_state = &i965->media_state; media_state->urb.num_vfe_entries = 23;
struct i965_h264_context *i965_h264_context; }
int i;
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;
}
i965_h264_context->enable_avc_ildb = 0;
if (media_state->private_context) {
i965_h264_context = (struct i965_h264_context *)media_state->private_context;
i965_avc_ildb_ternimate(&i965_h264_context->avc_ildb_context);
i965_avc_hw_scoreboard_ternimate(&i965_h264_context->avc_hw_scoreboard_context);
i965_avc_bsd_ternimate(&i965_h264_context->i965_avc_bsd_context);
dri_bo_unreference(i965_h264_context->avc_it_command_mb_info.bo); dri_bo_unreference(i965_h264_context->avc_it_command_mb_info.bo);
bo = dri_bo_alloc(i965->intel.bufmgr,
"avc it command mb info",
0x80000 * (1 + i965_h264_context->use_avc_hw_scoreboard), /* at least 522240 bytes */
0x1000);
assert(bo);
i965_h264_context->avc_it_command_mb_info.bo = bo;
dri_bo_unreference(i965_h264_context->avc_it_data.bo); dri_bo_unreference(i965_h264_context->avc_it_data.bo);
bo = dri_bo_alloc(i965->intel.bufmgr,
"avc it data",
0x1000000, /* at least 16711680 bytes */
4096);
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(i965_h264_context->avc_ildb_data.bo); dri_bo_unreference(i965_h264_context->avc_ildb_data.bo);
free(i965_h264_context); bo = dri_bo_alloc(i965->intel.bufmgr,
media_state->private_context = NULL; "AVC-ILDB Data Buffer",
} 0x100000, /* at least 1044480 bytes */
64);
assert(bo);
i965_h264_context->avc_ildb_data.bo = bo;
for (i = 0; i < NUM_H264_AVC_KERNELS; i++) { /* bsd pipeline */
struct media_kernel *kernel = &h264_avc_kernels[i]; i965_avc_bsd_decode_init(ctx);
dri_bo_unreference(kernel->bo); /* HW scoreboard */
kernel->bo = NULL; i965_avc_hw_scoreboard_decode_init(ctx);
}
return True; /* ILDB */
i965_avc_ildb_decode_init(ctx);
/* for Media pipeline */
media_state->extended_state.enabled = 1;
dri_bo_unreference(media_state->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;
} }
...@@ -60,8 +60,6 @@ struct i965_h264_context ...@@ -60,8 +60,6 @@ struct i965_h264_context
} fsid_list[16]; } fsid_list[16];
}; };
Bool i965_media_h264_init(VADriverContextP ctx);
Bool i965_media_h264_ternimate(VADriverContextP ctx);
void i965_media_h264_decode_init(VADriverContextP ctx); void i965_media_h264_decode_init(VADriverContextP ctx);
#endif /* _I965_MEDIA_H264_H_ */ #endif /* _I965_MEDIA_H264_H_ */
...@@ -881,47 +881,29 @@ i965_media_mpeg2_objects(VADriverContextP ctx, struct decode_state *decode_state ...@@ -881,47 +881,29 @@ i965_media_mpeg2_objects(VADriverContextP ctx, struct decode_state *decode_state
} }
} }
void static void
i965_media_mpeg2_decode_init(VADriverContextP ctx) i965_media_mpeg2_free_private_context(void **data)
{ {
struct i965_driver_data *i965 = i965_driver_data(ctx); int i;
struct i965_media_state *media_state = &i965->media_state;
dri_bo *bo;
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;
/* 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;
media_state->urb.vfe_start = 0; for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) {
media_state->urb.cs_start = media_state->urb.vfe_start + struct media_kernel *kernel = &mpeg2_vld_kernels[i];
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 */ dri_bo_unreference(kernel->bo);
media_state->media_states_setup = i965_media_mpeg2_states_setup; kernel->bo = NULL;
media_state->media_objects = i965_media_mpeg2_objects; }
mpeg2_vld_kernels = NULL;
} }
Bool void
i965_media_mpeg2_init(VADriverContextP ctx) i965_media_mpeg2_decode_init(VADriverContextP ctx)
{ {
struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
dri_bo *bo;
int i; int i;
if (mpeg2_vld_kernels == NULL) {
/* kernel */ /* kernel */
assert(NUM_MPEG2_VLD_KERNELS == (sizeof(mpeg2_vld_kernels_gen5) / assert(NUM_MPEG2_VLD_KERNELS == (sizeof(mpeg2_vld_kernels_gen5) /
sizeof(mpeg2_vld_kernels_gen5[0]))); sizeof(mpeg2_vld_kernels_gen5[0])));
...@@ -941,21 +923,32 @@ i965_media_mpeg2_init(VADriverContextP ctx) ...@@ -941,21 +923,32 @@ i965_media_mpeg2_init(VADriverContextP ctx)
dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin); dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin);
} }
return True; /* URB */
} media_state->urb.num_vfe_entries = 28;
media_state->urb.size_vfe_entry = 13;
Bool media_state->urb.num_cs_entries = 1;
i965_media_mpeg2_ternimate(VADriverContextP ctx) media_state->urb.size_cs_entry = 16;
{
int i;
for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) { media_state->urb.vfe_start = 0;
struct media_kernel *kernel = &mpeg2_vld_kernels[i]; 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)));
dri_bo_unreference(kernel->bo); /* hook functions */
kernel->bo = NULL; 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;
} }
return True; 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;
} }
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
struct decode_state; struct decode_state;
Bool i965_media_mpeg2_init(VADriverContextP ctx);
Bool i965_media_mpeg2_ternimate(VADriverContextP ctx);
void i965_media_mpeg2_decode_init(VADriverContextP ctx); void i965_media_mpeg2_decode_init(VADriverContextP ctx);
#endif /* _I965_MEDIA_MPEG2_H_ */ #endif /* _I965_MEDIA_MPEG2_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment