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,
Bool
i965_media_init(VADriverContextP ctx)
{
i965_media_mpeg2_init(ctx);
i965_media_h264_init(ctx);
return True;
}
......@@ -295,6 +293,9 @@ i965_media_terminate(VADriverContextP ctx)
struct i965_media_state *media_state = &i965->media_state;
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++) {
dri_bo_unreference(media_state->surface_state[i].bo);
media_state->surface_state[i].bo = NULL;
......@@ -318,8 +319,6 @@ i965_media_terminate(VADriverContextP ctx)
dri_bo_unreference(media_state->indirect_object.bo);
media_state->indirect_object.bo = NULL;
i965_media_mpeg2_ternimate(ctx);
i965_media_h264_ternimate(ctx);
return True;
}
......@@ -101,6 +101,7 @@ struct i965_media_state
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 (*free_private_context)(void **data);
};
Bool i965_media_init(VADriverContextP ctx);
......
......@@ -759,103 +759,52 @@ i965_media_h264_objects(VADriverContextP ctx, struct decode_state *decode_state)
i965_avc_ildb(ctx, decode_state);
}
void
i965_media_h264_decode_init(VADriverContextP ctx)
static void
i965_media_h264_free_private_context(void **data)
{
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;
dri_bo *bo;
struct i965_h264_context *i965_h264_context = *data;
int i;
assert(media_state->private_context);
i965_h264_context = media_state->private_context;
if (i965_h264_context == NULL)
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);
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);
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);
bo = dri_bo_alloc(i965->intel.bufmgr,
"AVC-ILDB Data Buffer",
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);
free(i965_h264_context);
*data = NULL;
/* 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;
for (i = 0; i < NUM_H264_AVC_KERNELS; i++) {
struct media_kernel *kernel = &h264_avc_kernels[i];
/* URB */
if (IS_IRONLAKE(i965->intel.device_id)) {
media_state->urb.num_vfe_entries = 63;
} else {
media_state->urb.num_vfe_entries = 23;
dri_bo_unreference(kernel->bo);
kernel->bo = NULL;
}
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
i965_media_h264_init(VADriverContextP ctx)
void
i965_media_h264_decode_init(VADriverContextP ctx)
{
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;
dri_bo *bo;
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 */
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;
......@@ -884,37 +833,78 @@ i965_media_h264_init(VADriverContextP ctx)
i965_h264_context->fsid_list[i].frame_store_id = -1;
}
i965_h264_context->enable_avc_ildb = 0;
media_state->private_context = i965_h264_context;
return True;
}
media_state->free_private_context = i965_media_h264_free_private_context;
Bool
i965_media_h264_ternimate(VADriverContextP ctx)
{
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;
int i;
/* 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;
}
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);
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);
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);
free(i965_h264_context);
media_state->private_context = NULL;
}
bo = dri_bo_alloc(i965->intel.bufmgr,
"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++) {
struct media_kernel *kernel = &h264_avc_kernels[i];
/* bsd pipeline */
i965_avc_bsd_decode_init(ctx);
dri_bo_unreference(kernel->bo);
kernel->bo = NULL;
}
/* HW scoreboard */
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
} 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);
#endif /* _I965_MEDIA_H264_H_ */
......@@ -881,47 +881,29 @@ i965_media_mpeg2_objects(VADriverContextP ctx, struct decode_state *decode_state
}
}
void
i965_media_mpeg2_decode_init(VADriverContextP ctx)
static void
i965_media_mpeg2_free_private_context(void **data)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
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;
int i;
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)));
for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) {
struct media_kernel *kernel = &mpeg2_vld_kernels[i];
/* hook functions */
media_state->media_states_setup = i965_media_mpeg2_states_setup;
media_state->media_objects = i965_media_mpeg2_objects;
dri_bo_unreference(kernel->bo);
kernel->bo = NULL;
}
mpeg2_vld_kernels = NULL;
}
Bool
i965_media_mpeg2_init(VADriverContextP ctx)
void
i965_media_mpeg2_decode_init(VADriverContextP ctx)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
dri_bo *bo;
int i;
if (mpeg2_vld_kernels == NULL) {
/* kernel */
assert(NUM_MPEG2_VLD_KERNELS == (sizeof(mpeg2_vld_kernels_gen5) /
sizeof(mpeg2_vld_kernels_gen5[0])));
......@@ -941,21 +923,32 @@ i965_media_mpeg2_init(VADriverContextP ctx)
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
i965_media_mpeg2_ternimate(VADriverContextP ctx)
{
int i;
media_state->urb.num_cs_entries = 1;
media_state->urb.size_cs_entry = 16;
for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) {
struct media_kernel *kernel = &mpeg2_vld_kernels[i];
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)));
dri_bo_unreference(kernel->bo);
kernel->bo = NULL;
/* 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;
}
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 @@
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);
#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