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,6 +759,32 @@ i965_media_h264_objects(VADriverContextP ctx, struct decode_state *decode_state) ...@@ -759,6 +759,32 @@ i965_media_h264_objects(VADriverContextP ctx, struct decode_state *decode_state)
i965_avc_ildb(ctx, decode_state); i965_avc_ildb(ctx, decode_state);
} }
static void
i965_media_h264_free_private_context(void **data)
{
struct i965_h264_context *i965_h264_context = *data;
int i;
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);
dri_bo_unreference(i965_h264_context->avc_it_data.bo);
dri_bo_unreference(i965_h264_context->avc_ildb_data.bo);
free(i965_h264_context);
*data = NULL;
for (i = 0; i < NUM_H264_AVC_KERNELS; i++) {
struct media_kernel *kernel = &h264_avc_kernels[i];
dri_bo_unreference(kernel->bo);
kernel->bo = NULL;
}
}
void void
i965_media_h264_decode_init(VADriverContextP ctx) i965_media_h264_decode_init(VADriverContextP ctx)
{ {
...@@ -766,10 +792,75 @@ i965_media_h264_decode_init(VADriverContextP ctx) ...@@ -766,10 +792,75 @@ i965_media_h264_decode_init(VADriverContextP 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; dri_bo *bo;
int i;
assert(media_state->private_context);
i965_h264_context = media_state->private_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;
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, 64);
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;
}
i965_h264_context->enable_avc_ildb = 0;
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, bo = dri_bo_alloc(i965->intel.bufmgr,
"avc it command mb info", "avc it command mb info",
...@@ -816,105 +907,4 @@ i965_media_h264_decode_init(VADriverContextP ctx) ...@@ -816,105 +907,4 @@ i965_media_h264_decode_init(VADriverContextP ctx)
sizeof(struct i965_vfe_state_ex), 32); sizeof(struct i965_vfe_state_ex), 32);
assert(bo); assert(bo);
media_state->extended_state.bo = bo; media_state->extended_state.bo = bo;
/* 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;
}
Bool
i965_media_h264_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;
int i;
i965_h264_context = calloc(1, sizeof(struct i965_h264_context));
/* 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])));
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, 64);
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;
}
i965_h264_context->enable_avc_ildb = 0;
media_state->private_context = i965_h264_context;
return True;
}
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;
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_data.bo);
dri_bo_unreference(i965_h264_context->avc_ildb_data.bo);
free(i965_h264_context);
media_state->private_context = NULL;
}
for (i = 0; i < NUM_H264_AVC_KERNELS; i++) {
struct media_kernel *kernel = &h264_avc_kernels[i];
dri_bo_unreference(kernel->bo);
kernel->bo = NULL;
}
return True;
} }
...@@ -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,81 +881,74 @@ i965_media_mpeg2_objects(VADriverContextP ctx, struct decode_state *decode_state ...@@ -881,81 +881,74 @@ 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);
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;
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_mpeg2_states_setup;
media_state->media_objects = i965_media_mpeg2_objects;
}
Bool
i965_media_mpeg2_init(VADriverContextP ctx)
{ {
struct i965_driver_data *i965 = i965_driver_data(ctx);
int i; int i;
/* 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);
if (IS_IRONLAKE(i965->intel.device_id))
mpeg2_vld_kernels = mpeg2_vld_kernels_gen5;
else
mpeg2_vld_kernels = mpeg2_vld_kernels_gen4;
for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) { for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) {
struct media_kernel *kernel = &mpeg2_vld_kernels[i]; struct media_kernel *kernel = &mpeg2_vld_kernels[i];
kernel->bo = dri_bo_alloc(i965->intel.bufmgr,
kernel->name, dri_bo_unreference(kernel->bo);
kernel->size, 64); kernel->bo = NULL;
assert(kernel->bo);
dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin);
} }
return True; mpeg2_vld_kernels = NULL;
} }
Bool void
i965_media_mpeg2_ternimate(VADriverContextP ctx) 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; int i;
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);
if (IS_IRONLAKE(i965->intel.device_id))
mpeg2_vld_kernels = mpeg2_vld_kernels_gen5;
else
mpeg2_vld_kernels = mpeg2_vld_kernels_gen4;
for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) {
struct media_kernel *kernel = &mpeg2_vld_kernels[i];
kernel->bo = dri_bo_alloc(i965->intel.bufmgr,
kernel->name,
kernel->size, 64);
assert(kernel->bo);
dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin);
}
for (i = 0; i < NUM_MPEG2_VLD_KERNELS; i++) { /* URB */
struct media_kernel *kernel = &mpeg2_vld_kernels[i]; media_state->urb.num_vfe_entries = 28;
media_state->urb.size_vfe_entry = 13;
dri_bo_unreference(kernel->bo); media_state->urb.num_cs_entries = 1;
kernel->bo = NULL; media_state->urb.size_cs_entry = 16;
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_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