hardware/intel/libva
Revisión | cfed3696b6eff33f7bab16c91a61738ae52b34d0 (tree) |
---|---|
Tiempo | 2016-05-14 01:51:16 |
Autor | peng.chen <peng.c.chen@inte...> |
Commiter | Sean V Kelley |
add the support of multiple context tracing
Libva has a limited tracing function before. If more than one context is created
in one instance, then this tracing can't work and output wrong log messages.
This patch fixes this problem. Tracing is possible while multiple contexts are
being used.
Each log file name is suffixed by thread id. This file has all log message from
this thread. Each surface or codedbuf dump file name is suffixed by context id.
This file has all surface or codedbuf data of this context.
Signed-off-by: peng.chen <peng.c.chen@intel.com>
Reviewed-by: Sean V Kelley <sean.v.kelley@intel.com>
Tested-by: Daniel Charles <daniel.charles@intel.com>
@@ -740,10 +740,16 @@ VAStatus vaDestroyConfig ( | ||
740 | 740 | ) |
741 | 741 | { |
742 | 742 | VADriverContextP ctx; |
743 | + VAStatus vaStatus = VA_STATUS_SUCCESS; | |
744 | + | |
743 | 745 | CHECK_DISPLAY(dpy); |
744 | 746 | ctx = CTX(dpy); |
745 | 747 | |
746 | - return ctx->vtable->vaDestroyConfig ( ctx, config_id ); | |
748 | + vaStatus = ctx->vtable->vaDestroyConfig ( ctx, config_id ); | |
749 | + | |
750 | + VA_TRACE_ALL(va_TraceDestroyConfig, dpy, config_id); | |
751 | + | |
752 | + return vaStatus; | |
747 | 753 | } |
748 | 754 | |
749 | 755 | VAStatus vaQueryConfigAttributes ( |
@@ -1015,10 +1021,16 @@ VAStatus vaDestroyContext ( | ||
1015 | 1021 | ) |
1016 | 1022 | { |
1017 | 1023 | VADriverContextP ctx; |
1024 | + VAStatus vaStatus; | |
1025 | + | |
1018 | 1026 | CHECK_DISPLAY(dpy); |
1019 | 1027 | ctx = CTX(dpy); |
1020 | 1028 | |
1021 | - return ctx->vtable->vaDestroyContext( ctx, context ); | |
1029 | + vaStatus = ctx->vtable->vaDestroyContext( ctx, context ); | |
1030 | + | |
1031 | + VA_TRACE_ALL(va_TraceDestroyContext, dpy, context); | |
1032 | + | |
1033 | + return vaStatus; | |
1022 | 1034 | } |
1023 | 1035 | |
1024 | 1036 | VAStatus vaCreateBuffer ( |
@@ -46,6 +46,8 @@ | ||
46 | 46 | #include <unistd.h> |
47 | 47 | #include <sys/types.h> |
48 | 48 | #include <sys/stat.h> |
49 | +#include <sys/syscall.h> | |
50 | +#include <pthread.h> | |
49 | 51 | #include <unistd.h> |
50 | 52 | #include <time.h> |
51 | 53 | #include <errno.h> |
@@ -66,16 +68,49 @@ | ||
66 | 68 | /* LIBVA_TRACE */ |
67 | 69 | int trace_flag = 0; |
68 | 70 | |
71 | +#define MAX_TRACE_CTX_NUM 64 | |
72 | +#define TRACE_CTX_ID_MASK (MAX_TRACE_CTX_NUM - 1) | |
73 | + | |
74 | +#define MAX_TRACE_THREAD_NUM 64 | |
75 | + | |
76 | +#define MAX_TRACE_BUF_INFO_HASH_SIZE 1024 // 1<<10 | |
77 | +#define MAX_TRACE_BUF_INFO_HASH_LEVEL 3 | |
78 | +#define TRACE_BUF_INFO_HASH_ID_MASK (MAX_TRACE_BUF_INFO_HASH_SIZE - 1) | |
79 | + | |
80 | +struct trace_buf_info { | |
81 | + int valid; | |
82 | + | |
83 | + VABufferID buf_id; | |
84 | + VAContextID ctx_id; | |
85 | +}; | |
86 | + | |
87 | +struct trace_buf_manager { | |
88 | + struct trace_buf_info *pbuf_info[MAX_TRACE_BUF_INFO_HASH_LEVEL]; | |
89 | +}; | |
90 | + | |
91 | +struct trace_log_file { | |
92 | + pid_t thread_id; | |
93 | + int used; | |
94 | + | |
95 | + char *fn_log; | |
96 | + FILE *fp_log; | |
97 | +}; | |
98 | + | |
99 | +struct trace_log_files_manager { | |
100 | + int num; | |
101 | + | |
102 | + struct trace_log_file log_file[MAX_TRACE_THREAD_NUM]; | |
103 | +}; | |
104 | + | |
69 | 105 | /* per context settings */ |
70 | 106 | struct trace_context { |
71 | - /* LIBVA_TRACE */ | |
72 | - FILE *trace_fp_log; /* save the log into a file */ | |
73 | - char *trace_log_fn; /* file name */ | |
74 | - | |
107 | + struct trace_log_file *plog_file; | |
108 | + struct trace_log_file *plog_file_list[MAX_TRACE_THREAD_NUM]; | |
109 | + | |
75 | 110 | /* LIBVA_TRACE_CODEDBUF */ |
76 | 111 | FILE *trace_fp_codedbuf; /* save the encode result into a file */ |
77 | 112 | char *trace_codedbuf_fn; /* file name */ |
78 | - | |
113 | + | |
79 | 114 | /* LIBVA_TRACE_SURFACE */ |
80 | 115 | FILE *trace_fp_surface; /* save the surface YUV into a file */ |
81 | 116 | char *trace_surface_fn; /* file name */ |
@@ -99,15 +134,97 @@ struct trace_context { | ||
99 | 134 | unsigned int trace_frame_height; /* current frame height */ |
100 | 135 | |
101 | 136 | unsigned int pts; /* IVF header information */ |
137 | + | |
138 | + pid_t created_thd_id; | |
102 | 139 | }; |
103 | 140 | |
104 | -#define TRACE_CTX(dpy) ((struct trace_context *)((VADisplayContextP)dpy)->vatrace) | |
141 | +struct trace_config_info { | |
142 | + int valid; | |
143 | + VAConfigID config_id; | |
105 | 144 | |
106 | -#define DPY2TRACECTX(dpy) \ | |
107 | - struct trace_context *trace_ctx = TRACE_CTX(dpy); \ | |
108 | - \ | |
109 | - if (trace_ctx == NULL) \ | |
110 | - return; \ | |
145 | + VAProfile trace_profile; | |
146 | + VAEntrypoint trace_entrypoint; | |
147 | + | |
148 | + pid_t created_thd_id; | |
149 | +}; | |
150 | + | |
151 | +struct va_trace { | |
152 | + struct trace_context *ptra_ctx[MAX_TRACE_CTX_NUM + 1]; | |
153 | + int context_num; | |
154 | + struct trace_buf_manager buf_manager; | |
155 | + struct trace_log_files_manager log_files_manager; | |
156 | + struct trace_config_info config_info[MAX_TRACE_CTX_NUM]; | |
157 | + | |
158 | + char *fn_log_env; | |
159 | + char *fn_codedbuf_env; | |
160 | + char *fn_surface_env; | |
161 | + | |
162 | + pthread_mutex_t resource_mutex; | |
163 | + pthread_mutex_t context_mutex; | |
164 | +}; | |
165 | + | |
166 | +#define LOCK_RESOURCE(pva_trace) \ | |
167 | + if(pva_trace) \ | |
168 | + pthread_mutex_lock(&pva_trace->resource_mutex) | |
169 | + | |
170 | +#define UNLOCK_RESOURCE(pva_trace) \ | |
171 | + if(pva_trace) \ | |
172 | + pthread_mutex_unlock(&pva_trace->resource_mutex) | |
173 | + | |
174 | +#define LOCK_CONTEXT(pva_trace) \ | |
175 | + if(pva_trace) \ | |
176 | + pthread_mutex_lock(&pva_trace->context_mutex) | |
177 | + | |
178 | +#define UNLOCK_CONTEXT(pva_trace) \ | |
179 | + if(pva_trace) \ | |
180 | + pthread_mutex_unlock(&pva_trace->context_mutex) | |
181 | + | |
182 | +#define DPY2TRACECTX(dpy, context, buf_id) \ | |
183 | + struct va_trace *pva_trace = NULL; \ | |
184 | + struct trace_context *trace_ctx = NULL; \ | |
185 | + int ctx_id = context; \ | |
186 | + \ | |
187 | + pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); \ | |
188 | + if(!pva_trace) \ | |
189 | + return; \ | |
190 | + \ | |
191 | + if(ctx_id == VA_INVALID_ID) { \ | |
192 | + if(buf_id != VA_INVALID_ID) \ | |
193 | + ctx_id = get_ctx_by_buf(pva_trace, buf_id); \ | |
194 | + else \ | |
195 | + return; \ | |
196 | + } \ | |
197 | + \ | |
198 | + if (ctx_id != VA_INVALID_ID) { \ | |
199 | + int temp_idx = get_valid_ctx_idx(pva_trace, ctx_id); \ | |
200 | + if(temp_idx < MAX_TRACE_CTX_NUM) \ | |
201 | + trace_ctx = pva_trace->ptra_ctx[temp_idx]; \ | |
202 | + } \ | |
203 | + \ | |
204 | + if(!trace_ctx \ | |
205 | + || trace_ctx->trace_context != context) { \ | |
206 | + return; \ | |
207 | + } \ | |
208 | + refresh_log_file(pva_trace, trace_ctx) | |
209 | + | |
210 | +#define DPY2TRACE_VIRCTX(dpy) \ | |
211 | + struct va_trace *pva_trace = NULL; \ | |
212 | + struct trace_context *trace_ctx = NULL; \ | |
213 | + \ | |
214 | + pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); \ | |
215 | + if(!pva_trace) \ | |
216 | + return; \ | |
217 | + \ | |
218 | + LOCK_CONTEXT(pva_trace); \ | |
219 | + trace_ctx = pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM]; \ | |
220 | + if(!trace_ctx) { \ | |
221 | + UNLOCK_CONTEXT(pva_trace); \ | |
222 | + return; \ | |
223 | + } \ | |
224 | + refresh_log_file(pva_trace, trace_ctx) | |
225 | + | |
226 | +#define DPY2TRACE_VIRCTX_EXIT(pva_trace) \ | |
227 | + UNLOCK_CONTEXT(pva_trace) | |
111 | 228 | |
112 | 229 | #define TRACE_FUNCNAME(idx) va_TraceMsg(trace_ctx, "==========%s\n", __func__); |
113 | 230 |
@@ -144,63 +261,507 @@ VAStatus vaUnlockSurface(VADisplay dpy, | ||
144 | 261 | VASurfaceID surface |
145 | 262 | ); |
146 | 263 | |
147 | -#define FILE_NAME_SUFFIX(env_value) \ | |
148 | -do { \ | |
149 | - int tmp = strnlen(env_value, sizeof(env_value)); \ | |
150 | - int left = sizeof(env_value) - tmp; \ | |
151 | - \ | |
152 | - snprintf(env_value+tmp, \ | |
153 | - left, \ | |
154 | - ".%04d.%08lx", \ | |
155 | - suffix, \ | |
156 | - (unsigned long)trace_ctx); \ | |
157 | -} while (0) | |
264 | +static int get_valid_config_idx( | |
265 | + struct va_trace *pva_trace, | |
266 | + VAConfigID config_id) | |
267 | +{ | |
268 | + struct trace_config_info *pconfig_info; | |
269 | + int idx = MAX_TRACE_CTX_NUM; | |
270 | + | |
271 | + LOCK_RESOURCE(pva_trace); | |
272 | + | |
273 | + pconfig_info = pva_trace->config_info; | |
274 | + idx = config_id & TRACE_CTX_ID_MASK; | |
275 | + if(!pconfig_info[idx].valid | |
276 | + || pconfig_info[idx].config_id != config_id) | |
277 | + idx = MAX_TRACE_CTX_NUM; | |
278 | + | |
279 | + UNLOCK_RESOURCE(pva_trace); | |
280 | + | |
281 | + return idx; | |
282 | +} | |
283 | + | |
284 | +static void add_trace_config_info( | |
285 | + struct va_trace *pva_trace, | |
286 | + VAConfigID config_id, | |
287 | + VAProfile profile, | |
288 | + VAEntrypoint entrypoint) | |
289 | +{ | |
290 | + struct trace_config_info *pconfig_info; | |
291 | + int idx = 0; | |
292 | + pid_t thd_id = syscall(__NR_gettid); | |
293 | + | |
294 | + LOCK_RESOURCE(pva_trace); | |
295 | + | |
296 | + idx = config_id & TRACE_CTX_ID_MASK; | |
297 | + pconfig_info = &pva_trace->config_info[idx]; | |
298 | + if(!pconfig_info->valid || | |
299 | + pconfig_info->config_id == config_id) { | |
300 | + pconfig_info->valid = 1; | |
301 | + pconfig_info->config_id = config_id; | |
302 | + pconfig_info->trace_profile = profile; | |
303 | + pconfig_info->trace_entrypoint = entrypoint; | |
304 | + pconfig_info->created_thd_id = thd_id; | |
305 | + } | |
306 | + | |
307 | + UNLOCK_RESOURCE(pva_trace); | |
308 | +} | |
309 | + | |
310 | +static void delete_trace_config_info( | |
311 | + struct va_trace *pva_trace, | |
312 | + VAConfigID config_id) | |
313 | +{ | |
314 | + struct trace_config_info *pconfig_info; | |
315 | + int idx = 0; | |
316 | + pid_t thd_id = syscall(__NR_gettid); | |
317 | + | |
318 | + LOCK_RESOURCE(pva_trace); | |
319 | + | |
320 | + idx = config_id & TRACE_CTX_ID_MASK; | |
321 | + pconfig_info = &pva_trace->config_info[idx]; | |
322 | + if(pconfig_info->valid && | |
323 | + pconfig_info->config_id == config_id && | |
324 | + pconfig_info->created_thd_id == thd_id) { | |
325 | + pconfig_info->valid = 0; | |
326 | + } | |
327 | + | |
328 | + UNLOCK_RESOURCE(pva_trace); | |
329 | +} | |
330 | + | |
331 | +static VAContextID get_ctx_by_buf( | |
332 | + struct va_trace *pva_trace, | |
333 | + VABufferID buf_id) | |
334 | +{ | |
335 | + struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager; | |
336 | + struct trace_buf_info *pbuf_info = pbuf_mgr->pbuf_info[0]; | |
337 | + VAContextID context = VA_INVALID_ID; | |
338 | + int i = 0, idx = 0, valid = 0; | |
339 | + | |
340 | + LOCK_RESOURCE(pva_trace); | |
341 | + | |
342 | + idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK; | |
343 | + for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) { | |
344 | + pbuf_info = pbuf_mgr->pbuf_info[i]; | |
345 | + if(!pbuf_info) | |
346 | + break; | |
347 | + | |
348 | + if(pbuf_info[idx].valid | |
349 | + && pbuf_info[idx].buf_id == buf_id) { | |
350 | + context = pbuf_info[idx].ctx_id; | |
351 | + break; | |
352 | + } | |
353 | + } | |
354 | + | |
355 | + UNLOCK_RESOURCE(pva_trace); | |
356 | + | |
357 | + return context; | |
358 | +} | |
359 | + | |
360 | +static void add_trace_buf_info( | |
361 | + struct va_trace *pva_trace, | |
362 | + VAContextID context, | |
363 | + VABufferID buf_id) | |
364 | +{ | |
365 | + struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager; | |
366 | + struct trace_buf_info *pbuf_info = NULL; | |
367 | + int i = 0, idx = 0; | |
368 | + | |
369 | + LOCK_RESOURCE(pva_trace); | |
370 | + | |
371 | + idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK; | |
372 | + for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) { | |
373 | + pbuf_info = pbuf_mgr->pbuf_info[i]; | |
374 | + if(!pbuf_info) { | |
375 | + pbuf_info = (struct trace_buf_info *)calloc( | |
376 | + sizeof(struct trace_buf_info) * MAX_TRACE_BUF_INFO_HASH_SIZE, | |
377 | + 1); | |
378 | + if(!pbuf_info) | |
379 | + break; | |
380 | + | |
381 | + pbuf_mgr->pbuf_info[i] = pbuf_info; | |
382 | + } | |
383 | + | |
384 | + if(pbuf_info[idx].valid | |
385 | + && pbuf_info[idx].buf_id != buf_id) | |
386 | + continue; | |
387 | + | |
388 | + pbuf_info[idx].buf_id = buf_id; | |
389 | + pbuf_info[idx].ctx_id = context; | |
390 | + pbuf_info[idx].valid = 1; | |
391 | + break; | |
392 | + } | |
393 | + | |
394 | + if(i >= MAX_TRACE_BUF_INFO_HASH_LEVEL) | |
395 | + va_errorMessage("Add buf info failed\n"); | |
396 | + | |
397 | + UNLOCK_RESOURCE(pva_trace); | |
398 | +} | |
399 | + | |
400 | +static void delete_trace_buf_info( | |
401 | + struct va_trace *pva_trace, | |
402 | + VABufferID buf_id) | |
403 | +{ | |
404 | + struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager; | |
405 | + struct trace_buf_info *pbuf_info = NULL; | |
406 | + int i = 0, idx = 0; | |
407 | + | |
408 | + LOCK_RESOURCE(pva_trace); | |
409 | + | |
410 | + idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK; | |
411 | + for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) { | |
412 | + pbuf_info = pbuf_mgr->pbuf_info[i]; | |
413 | + if(!pbuf_info) | |
414 | + break; | |
415 | + | |
416 | + if(pbuf_info[idx].valid | |
417 | + && pbuf_info[idx].buf_id == buf_id) { | |
418 | + pbuf_info[idx].valid = 0; | |
419 | + break; | |
420 | + } | |
421 | + } | |
422 | + | |
423 | + UNLOCK_RESOURCE(pva_trace); | |
424 | +} | |
425 | + | |
426 | +/* | |
427 | +static void delete_trace_all_context_buf( | |
428 | + struct va_trace *pva_trace, | |
429 | + VAContextID context) | |
430 | +{ | |
431 | + struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager; | |
432 | + struct trace_buf_info *pbuf_info = NULL; | |
433 | + int i = 0, j = 0; | |
434 | + | |
435 | + LOCK_RESOURCE(pva_trace); | |
436 | + | |
437 | + for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) { | |
438 | + pbuf_info = pbuf_mgr->pbuf_info[i]; | |
439 | + if(!pbuf_info) | |
440 | + break; | |
441 | + | |
442 | + for(j = 0;j < MAX_TRACE_BUF_INFO_HASH_SIZE;j++) | |
443 | + if(pbuf_info[j].valid | |
444 | + && pbuf_info[j].ctx_id == context) | |
445 | + pbuf_info[j].valid = 0; | |
446 | + } | |
447 | + | |
448 | + UNLOCK_RESOURCE(pva_trace); | |
449 | +} | |
450 | +*/ | |
451 | + | |
452 | +static int get_free_ctx_idx( | |
453 | + struct va_trace *pva_trace, | |
454 | + VAContextID context) | |
455 | +{ | |
456 | + int idx = MAX_TRACE_CTX_NUM; | |
457 | + int i = 0; | |
458 | + | |
459 | + LOCK_RESOURCE(pva_trace); | |
460 | + | |
461 | + i = context & TRACE_CTX_ID_MASK; | |
462 | + if(!pva_trace->ptra_ctx[i] | |
463 | + || pva_trace->ptra_ctx[i]->trace_context == context) | |
464 | + idx = i; | |
465 | + | |
466 | + UNLOCK_RESOURCE(pva_trace); | |
467 | + | |
468 | + return idx; | |
469 | +} | |
470 | + | |
471 | +static int get_valid_ctx_idx( | |
472 | + struct va_trace *pva_trace, | |
473 | + VAContextID context) | |
474 | +{ | |
475 | + int idx = MAX_TRACE_CTX_NUM; | |
476 | + int i = 0; | |
477 | + | |
478 | + LOCK_RESOURCE(pva_trace); | |
479 | + | |
480 | + i = context & TRACE_CTX_ID_MASK; | |
481 | + if(pva_trace->ptra_ctx[i] | |
482 | + && pva_trace->ptra_ctx[i]->trace_context == context) | |
483 | + idx = i; | |
484 | + | |
485 | + UNLOCK_RESOURCE(pva_trace); | |
486 | + | |
487 | + return idx; | |
488 | +} | |
489 | + | |
490 | +static void FILE_NAME_SUFFIX( | |
491 | + char *env_value, | |
492 | + int max_size, | |
493 | + char *suffix_str, | |
494 | + unsigned int suffix_handle) | |
495 | +{ | |
496 | + int tmp = strnlen(env_value, max_size); | |
497 | + int left = max_size - tmp; | |
498 | + struct timeval tv; | |
499 | + int size = strlen(suffix_str); | |
500 | + | |
501 | + if(left < (size + 8 + 10)) | |
502 | + return; | |
503 | + | |
504 | + if(gettimeofday(&tv, NULL) == 0) { | |
505 | + sprintf(env_value + tmp, | |
506 | + ".%02d%02d%02d.", | |
507 | + (unsigned int)(tv.tv_sec/3600)%24, | |
508 | + (unsigned int)(tv.tv_sec/60)%60, | |
509 | + (unsigned int)tv.tv_sec%60); | |
510 | + | |
511 | + tmp += 8; | |
512 | + left -= 8; | |
513 | + } | |
514 | + | |
515 | + if(suffix_str) { | |
516 | + strcat(env_value + tmp, | |
517 | + suffix_str); | |
518 | + | |
519 | + tmp += size; | |
520 | + left -= size; | |
521 | + } | |
522 | + | |
523 | + if(suffix_handle) { | |
524 | + sprintf(env_value + tmp, | |
525 | + "0x%08x", | |
526 | + suffix_handle); | |
527 | + } | |
528 | +} | |
529 | + | |
530 | +static int open_tracing_specil_file( | |
531 | + struct va_trace *pva_trace, | |
532 | + struct trace_context *ptra_ctx, | |
533 | + int type) // 0: codedbuf, 1: surface | |
534 | +{ | |
535 | + char *fn_env = type == 0 ? | |
536 | + pva_trace->fn_codedbuf_env : pva_trace->fn_surface_env; | |
537 | + char env_value[1024]; | |
538 | + FILE *fp = NULL; | |
539 | + | |
540 | + strncpy(env_value, fn_env, 1024); | |
541 | + FILE_NAME_SUFFIX(env_value, 1024, | |
542 | + "ctx-", (unsigned int)ptra_ctx->trace_context); | |
543 | + | |
544 | + fn_env = strdup(env_value); | |
545 | + if(!fn_env) | |
546 | + return -1; | |
547 | + | |
548 | + fp = fopen(fn_env, "w"); | |
549 | + if(!fp) { | |
550 | + free(fn_env); | |
551 | + | |
552 | + return -1; | |
553 | + } | |
554 | + | |
555 | + if(type == 0) { | |
556 | + ptra_ctx->trace_codedbuf_fn = fn_env; | |
557 | + ptra_ctx->trace_fp_codedbuf = fp; | |
558 | + va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save codedbuf into %s\n", | |
559 | + fn_env); | |
560 | + } | |
561 | + else { | |
562 | + ptra_ctx->trace_surface_fn = fn_env; | |
563 | + ptra_ctx->trace_fp_surface = fp; | |
564 | + va_infoMessage("LIBVA_TRACE_SURFACE is on, save surface into %s\n", | |
565 | + fn_env); | |
566 | + } | |
567 | + | |
568 | + return 0; | |
569 | +} | |
570 | + | |
571 | +static int open_tracing_log_file( | |
572 | + struct va_trace *pva_trace, | |
573 | + struct trace_log_file *plog_file, | |
574 | + pid_t thd_id) | |
575 | +{ | |
576 | + FILE *pfp = NULL; | |
577 | + int new_fn_flag = 0; | |
578 | + | |
579 | + if(plog_file->used && plog_file->thread_id != thd_id) { | |
580 | + va_errorMessage("Try to open a busy log file occupied by other thread\n"); | |
581 | + | |
582 | + return -1; | |
583 | + } | |
584 | + | |
585 | + if(plog_file->thread_id != thd_id) { | |
586 | + char env_value[1024]; | |
587 | + | |
588 | + strncpy(env_value, pva_trace->fn_log_env, 1024); | |
589 | + FILE_NAME_SUFFIX(env_value, 1024, | |
590 | + "thd-", (unsigned int)thd_id); | |
591 | + | |
592 | + if(plog_file->fn_log) | |
593 | + free(plog_file->fn_log); | |
594 | + | |
595 | + plog_file->fn_log = strdup(env_value); | |
596 | + if(!plog_file->fn_log) | |
597 | + goto FAIL; | |
598 | + | |
599 | + new_fn_flag = 1; | |
600 | + } | |
601 | + | |
602 | + if(!plog_file->used) { | |
603 | + if(new_fn_flag) | |
604 | + pfp = fopen(plog_file->fn_log, "w"); | |
605 | + else | |
606 | + pfp = fopen(plog_file->fn_log, "a"); | |
607 | + | |
608 | + if(!pfp) | |
609 | + goto FAIL; | |
610 | + | |
611 | + va_infoMessage("%s %s for the thread 0x%08x\n", | |
612 | + new_fn_flag ? "Open new log file" : "Append to log file", | |
613 | + plog_file->fn_log, thd_id); | |
614 | + | |
615 | + plog_file->fp_log = pfp; | |
616 | + plog_file->thread_id = thd_id; | |
617 | + } | |
618 | + | |
619 | + plog_file->used++; | |
620 | + return 0; | |
621 | + | |
622 | +FAIL: | |
623 | + if(plog_file->fn_log) { | |
624 | + free(plog_file->fn_log); | |
625 | + plog_file->fn_log = NULL; | |
626 | + } | |
627 | + | |
628 | + return -1; | |
629 | +} | |
630 | + | |
631 | +static int get_log_file_idx_by_thd( | |
632 | + struct trace_log_files_manager *plog_files_mgr, | |
633 | + pid_t thd_id) | |
634 | +{ | |
635 | + struct trace_log_file *plog_file = plog_files_mgr->log_file; | |
636 | + int first_free_idx = MAX_TRACE_THREAD_NUM; | |
637 | + int i = 0; | |
638 | + | |
639 | + for(i = 0;i < MAX_TRACE_THREAD_NUM;i++) { | |
640 | + if(plog_file[i].thread_id == thd_id) | |
641 | + break; | |
642 | + else if(!plog_file[i].used && | |
643 | + first_free_idx >= MAX_TRACE_THREAD_NUM) | |
644 | + first_free_idx = i; | |
645 | + } | |
646 | + | |
647 | + if(i >= MAX_TRACE_THREAD_NUM) | |
648 | + i = first_free_idx; | |
649 | + | |
650 | + return i; | |
651 | +} | |
652 | + | |
653 | +static struct trace_log_file *start_tracing2log_file( | |
654 | + struct va_trace *pva_trace) | |
655 | +{ | |
656 | + struct trace_log_files_manager *plog_files_mgr = NULL; | |
657 | + struct trace_log_file *plog_file = NULL; | |
658 | + pid_t thd_id = syscall(__NR_gettid); | |
659 | + int i = 0; | |
660 | + | |
661 | + LOCK_RESOURCE(pva_trace); | |
662 | + | |
663 | + plog_files_mgr = &pva_trace->log_files_manager; | |
664 | + i = get_log_file_idx_by_thd(plog_files_mgr, thd_id); | |
665 | + if(i < MAX_TRACE_THREAD_NUM) { | |
666 | + plog_file = &plog_files_mgr->log_file[i]; | |
667 | + if(open_tracing_log_file(pva_trace, plog_file, thd_id) < 0) { | |
668 | + plog_file = NULL; | |
669 | + } | |
670 | + } | |
671 | + | |
672 | + UNLOCK_RESOURCE(pva_trace); | |
673 | + return plog_file; | |
674 | +} | |
675 | + | |
676 | +static void stop_tracing2log_file( | |
677 | + struct va_trace *pva_trace, | |
678 | + struct trace_log_file *plog_file) | |
679 | +{ | |
680 | + LOCK_RESOURCE(pva_trace); | |
681 | + | |
682 | + if(--plog_file->used <= 0) { | |
683 | + if(plog_file->fp_log) { | |
684 | + fclose(plog_file->fp_log); | |
685 | + plog_file->fp_log = NULL; | |
686 | + } | |
687 | + } | |
688 | + | |
689 | + UNLOCK_RESOURCE(pva_trace); | |
690 | +} | |
691 | + | |
692 | +static void refresh_log_file( | |
693 | + struct va_trace *pva_trace, | |
694 | + struct trace_context *ptra_ctx) | |
695 | +{ | |
696 | + struct trace_log_file *plog_file = NULL; | |
697 | + pid_t thd_id = syscall(__NR_gettid); | |
698 | + int i = 0; | |
699 | + | |
700 | + plog_file = ptra_ctx->plog_file; | |
701 | + if(plog_file && plog_file->thread_id != thd_id) { | |
702 | + plog_file = start_tracing2log_file(pva_trace); | |
703 | + if(plog_file) { | |
704 | + int first_free_idx = -1; | |
705 | + | |
706 | + ptra_ctx->plog_file = plog_file; | |
707 | + | |
708 | + for(i = 0;i < MAX_TRACE_THREAD_NUM;i++) { | |
709 | + if(!ptra_ctx->plog_file_list[i]){ | |
710 | + if(first_free_idx < 0) | |
711 | + first_free_idx = i; | |
712 | + } | |
713 | + else if(ptra_ctx->plog_file_list[i]->thread_id == thd_id) | |
714 | + break; | |
715 | + } | |
716 | + | |
717 | + if(i > MAX_TRACE_THREAD_NUM | |
718 | + && first_free_idx >= 0) | |
719 | + ptra_ctx->plog_file_list[first_free_idx] = plog_file; | |
720 | + } | |
721 | + } | |
722 | +} | |
158 | 723 | |
159 | 724 | void va_TraceInit(VADisplay dpy) |
160 | 725 | { |
161 | 726 | char env_value[1024]; |
162 | 727 | unsigned short suffix = 0xffff & ((unsigned int)time(NULL)); |
163 | 728 | int trace_index = 0; |
164 | - FILE *tmp; | |
729 | + FILE *tmp; | |
730 | + struct va_trace *pva_trace = calloc(sizeof(struct va_trace), 1); | |
165 | 731 | struct trace_context *trace_ctx = calloc(sizeof(struct trace_context), 1); |
166 | 732 | |
167 | - if (trace_ctx == NULL) | |
733 | + if (pva_trace == NULL || trace_ctx == NULL) | |
168 | 734 | return; |
169 | - | |
735 | + | |
170 | 736 | if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) { |
171 | - FILE_NAME_SUFFIX(env_value); | |
172 | - trace_ctx->trace_log_fn = strdup(env_value); | |
173 | - | |
174 | - tmp = fopen(env_value, "w"); | |
175 | - if (tmp) { | |
176 | - trace_ctx->trace_fp_log = tmp; | |
177 | - va_infoMessage("LIBVA_TRACE is on, save log into %s\n", trace_ctx->trace_log_fn); | |
737 | + pva_trace->fn_log_env = strdup(env_value); | |
738 | + trace_ctx->plog_file = start_tracing2log_file(pva_trace); | |
739 | + if(trace_ctx->plog_file) { | |
740 | + trace_ctx->plog_file_list[0] = trace_ctx->plog_file; | |
178 | 741 | trace_flag = VA_TRACE_FLAG_LOG; |
179 | - } else | |
742 | + | |
743 | + va_infoMessage("LIBVA_TRACE is on, save log into %s\n", | |
744 | + trace_ctx->plog_file->fn_log); | |
745 | + } | |
746 | + else | |
180 | 747 | va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno)); |
181 | 748 | } |
182 | 749 | |
183 | 750 | /* may re-get the global settings for multiple context */ |
184 | 751 | if ((trace_flag & VA_TRACE_FLAG_LOG) && (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0)) { |
185 | 752 | trace_flag |= VA_TRACE_FLAG_BUFDATA; |
753 | + | |
186 | 754 | va_infoMessage("LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n"); |
187 | 755 | } |
188 | 756 | |
189 | 757 | /* per-context setting */ |
190 | 758 | if (va_parseConfig("LIBVA_TRACE_CODEDBUF", &env_value[0]) == 0) { |
191 | - FILE_NAME_SUFFIX(env_value); | |
192 | - trace_ctx->trace_codedbuf_fn = strdup(env_value); | |
193 | - va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save codedbuf into log file %s\n", | |
194 | - trace_ctx->trace_codedbuf_fn); | |
759 | + pva_trace->fn_codedbuf_env = strdup(env_value); | |
195 | 760 | trace_flag |= VA_TRACE_FLAG_CODEDBUF; |
196 | 761 | } |
197 | 762 | |
198 | 763 | if (va_parseConfig("LIBVA_TRACE_SURFACE", &env_value[0]) == 0) { |
199 | - FILE_NAME_SUFFIX(env_value); | |
200 | - trace_ctx->trace_surface_fn = strdup(env_value); | |
201 | - | |
202 | - va_infoMessage("LIBVA_TRACE_SURFACE is on, save surface into %s\n", | |
203 | - trace_ctx->trace_surface_fn); | |
764 | + pva_trace->fn_surface_env = strdup(env_value); | |
204 | 765 | |
205 | 766 | /* for surface data dump, it is time-consume, and may |
206 | 767 | * cause some side-effect, so only trace the needed surfaces |
@@ -234,58 +795,119 @@ void va_TraceInit(VADisplay dpy) | ||
234 | 795 | } |
235 | 796 | } |
236 | 797 | |
237 | - ((VADisplayContextP)dpy)->vatrace = trace_ctx; | |
238 | -} | |
798 | + pthread_mutex_init(&pva_trace->resource_mutex, NULL); | |
799 | + pthread_mutex_init(&pva_trace->context_mutex, NULL); | |
800 | + | |
801 | + trace_ctx->trace_context = VA_INVALID_ID; | |
802 | + pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM] = trace_ctx; | |
239 | 803 | |
804 | + ((VADisplayContextP)dpy)->vatrace = (void *)pva_trace; | |
805 | + | |
806 | + if(!trace_flag) | |
807 | + va_TraceEnd(dpy); | |
808 | +} | |
240 | 809 | |
241 | 810 | void va_TraceEnd(VADisplay dpy) |
242 | 811 | { |
243 | - DPY2TRACECTX(dpy); | |
244 | - | |
245 | - if (trace_ctx->trace_fp_log) | |
246 | - fclose(trace_ctx->trace_fp_log); | |
247 | - | |
248 | - if (trace_ctx->trace_fp_codedbuf) | |
249 | - fclose(trace_ctx->trace_fp_codedbuf); | |
250 | - | |
251 | - if (trace_ctx->trace_fp_surface) | |
252 | - fclose(trace_ctx->trace_fp_surface); | |
812 | + struct va_trace *pva_trace = NULL; | |
813 | + int i = 0, j = 0; | |
253 | 814 | |
254 | - if (trace_ctx->trace_log_fn) | |
255 | - free(trace_ctx->trace_log_fn); | |
256 | - | |
257 | - if (trace_ctx->trace_codedbuf_fn) | |
258 | - free(trace_ctx->trace_codedbuf_fn); | |
259 | - | |
260 | - if (trace_ctx->trace_surface_fn) | |
261 | - free(trace_ctx->trace_surface_fn); | |
262 | - | |
263 | - free(trace_ctx); | |
815 | + pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); | |
816 | + if(!pva_trace) | |
817 | + return; | |
818 | + | |
819 | + if(pva_trace->fn_log_env) | |
820 | + free(pva_trace->fn_log_env); | |
821 | + | |
822 | + if(pva_trace->fn_codedbuf_env) | |
823 | + free(pva_trace->fn_codedbuf_env); | |
824 | + | |
825 | + if(pva_trace->fn_surface_env) | |
826 | + free(pva_trace->fn_surface_env); | |
827 | + | |
828 | + for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) | |
829 | + if(pva_trace->buf_manager.pbuf_info[i]) | |
830 | + free(pva_trace->buf_manager.pbuf_info[i]); | |
831 | + | |
832 | + for(i = 0;i < MAX_TRACE_THREAD_NUM;i++) { | |
833 | + struct trace_log_file *plog_file = NULL; | |
834 | + | |
835 | + if(pva_trace->log_files_manager.num <= 0) | |
836 | + break; | |
837 | + | |
838 | + plog_file = &pva_trace->log_files_manager.log_file[i]; | |
839 | + if(plog_file) { | |
840 | + if(plog_file->fn_log) | |
841 | + free(plog_file->fn_log); | |
842 | + | |
843 | + if(plog_file->fp_log) | |
844 | + fclose(plog_file->fp_log); | |
845 | + | |
846 | + pva_trace->log_files_manager.num--; | |
847 | + } | |
848 | + } | |
849 | + | |
850 | + for(i = 0;i < MAX_TRACE_CTX_NUM;i++) { | |
851 | + struct trace_context *trace_ctx = NULL; | |
852 | + | |
853 | + if(pva_trace->context_num <= 0) | |
854 | + break; | |
855 | + | |
856 | + trace_ctx = pva_trace->ptra_ctx[i]; | |
857 | + if(trace_ctx) { | |
858 | + if(trace_ctx->trace_codedbuf_fn) | |
859 | + free(trace_ctx->trace_codedbuf_fn); | |
860 | + | |
861 | + if(trace_ctx->trace_fp_codedbuf) | |
862 | + fclose(trace_ctx->trace_fp_codedbuf); | |
863 | + | |
864 | + if(trace_ctx->trace_surface_fn) | |
865 | + free(trace_ctx->trace_surface_fn); | |
866 | + | |
867 | + if(trace_ctx->trace_fp_surface) | |
868 | + fclose(trace_ctx->trace_fp_surface); | |
869 | + | |
870 | + free(pva_trace->ptra_ctx[i]); | |
871 | + pva_trace->context_num--; | |
872 | + } | |
873 | + } | |
874 | + free(pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM]); | |
875 | + | |
876 | + free(pva_trace); | |
264 | 877 | ((VADisplayContextP)dpy)->vatrace = NULL; |
265 | 878 | } |
266 | 879 | |
267 | 880 | static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...) |
268 | 881 | { |
882 | + FILE *fp = NULL; | |
269 | 883 | va_list args; |
270 | 884 | |
271 | - if (!(trace_flag & VA_TRACE_FLAG_LOG)) | |
885 | + if (!(trace_flag & VA_TRACE_FLAG_LOG) | |
886 | + || !trace_ctx->plog_file) | |
272 | 887 | return; |
273 | 888 | |
889 | + fp = trace_ctx->plog_file->fp_log; | |
274 | 890 | if (msg) { |
275 | 891 | struct timeval tv; |
276 | 892 | |
277 | 893 | if (gettimeofday(&tv, NULL) == 0) |
278 | - fprintf(trace_ctx->trace_fp_log, "[%04d.%06d] ", | |
279 | - (unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec); | |
894 | + fprintf(fp, "[%04d.%06d]", | |
895 | + (unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec); | |
896 | + | |
897 | + if(trace_ctx->trace_context != VA_INVALID_ID) | |
898 | + fprintf(fp, | |
899 | + "[ctx 0x%08x]", trace_ctx->trace_context); | |
900 | + else | |
901 | + fprintf(fp, "[ctx none]"); | |
902 | + | |
280 | 903 | va_start(args, msg); |
281 | - vfprintf(trace_ctx->trace_fp_log, msg, args); | |
904 | + vfprintf(fp, msg, args); | |
282 | 905 | va_end(args); |
283 | 906 | } else |
284 | - fflush(trace_ctx->trace_fp_log); | |
907 | + fflush(fp); | |
285 | 908 | } |
286 | 909 | |
287 | - | |
288 | -static void va_TraceSurface(VADisplay dpy) | |
910 | +static void va_TraceSurface(VADisplay dpy, VAContextID context) | |
289 | 911 | { |
290 | 912 | unsigned int i, j; |
291 | 913 | unsigned int fourcc; /* following are output argument */ |
@@ -300,7 +922,7 @@ static void va_TraceSurface(VADisplay dpy) | ||
300 | 922 | unsigned char *Y_data, *UV_data, *tmp; |
301 | 923 | VAStatus va_status; |
302 | 924 | unsigned char check_sum = 0; |
303 | - DPY2TRACECTX(dpy); | |
925 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
304 | 926 | |
305 | 927 | if (!trace_ctx->trace_fp_surface) |
306 | 928 | return; |
@@ -364,6 +986,8 @@ static void va_TraceSurface(VADisplay dpy) | ||
364 | 986 | } |
365 | 987 | } |
366 | 988 | |
989 | + fflush(trace_ctx->trace_fp_surface); | |
990 | + | |
367 | 991 | vaUnlockSurface(dpy, trace_ctx->trace_rendertarget); |
368 | 992 | |
369 | 993 | va_TraceMsg(trace_ctx, NULL); |
@@ -376,16 +1000,19 @@ void va_TraceInitialize ( | ||
376 | 1000 | int *minor_version /* out */ |
377 | 1001 | ) |
378 | 1002 | { |
379 | - DPY2TRACECTX(dpy); | |
1003 | + DPY2TRACE_VIRCTX(dpy); | |
380 | 1004 | TRACE_FUNCNAME(idx); |
1005 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
381 | 1006 | } |
382 | 1007 | |
383 | 1008 | void va_TraceTerminate ( |
384 | 1009 | VADisplay dpy |
385 | 1010 | ) |
386 | 1011 | { |
387 | - DPY2TRACECTX(dpy); | |
1012 | + DPY2TRACE_VIRCTX(dpy); | |
388 | 1013 | TRACE_FUNCNAME(idx); |
1014 | + va_TraceMsg(trace_ctx, NULL); | |
1015 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
389 | 1016 | } |
390 | 1017 | |
391 | 1018 |
@@ -399,8 +1026,8 @@ void va_TraceCreateConfig( | ||
399 | 1026 | ) |
400 | 1027 | { |
401 | 1028 | int i; |
402 | - int encode, decode, jpeg; | |
403 | - DPY2TRACECTX(dpy); | |
1029 | + | |
1030 | + DPY2TRACE_VIRCTX(dpy); | |
404 | 1031 | |
405 | 1032 | TRACE_FUNCNAME(idx); |
406 | 1033 |
@@ -415,42 +1042,26 @@ void va_TraceCreateConfig( | ||
415 | 1042 | } |
416 | 1043 | va_TraceMsg(trace_ctx, NULL); |
417 | 1044 | |
418 | - trace_ctx->trace_profile = profile; | |
419 | - trace_ctx->trace_entrypoint = entrypoint; | |
1045 | + add_trace_config_info(pva_trace, *config_id, profile, entrypoint); | |
420 | 1046 | |
421 | - /* avoid to create so many empty files */ | |
422 | - encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice); | |
423 | - decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD); | |
424 | - jpeg = (trace_ctx->trace_entrypoint == VAEntrypointEncPicture); | |
425 | - if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE)) || | |
426 | - (decode && (trace_flag & VA_TRACE_FLAG_SURFACE_DECODE)) || | |
427 | - (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) { | |
428 | - FILE *tmp = fopen(trace_ctx->trace_surface_fn, "w"); | |
429 | - | |
430 | - if (tmp) | |
431 | - trace_ctx->trace_fp_surface = tmp; | |
432 | - else { | |
433 | - va_errorMessage("Open file %s failed (%s)\n", | |
434 | - trace_ctx->trace_surface_fn, | |
435 | - strerror(errno)); | |
436 | - trace_ctx->trace_fp_surface = NULL; | |
437 | - trace_flag &= ~(VA_TRACE_FLAG_SURFACE); | |
438 | - } | |
439 | - } | |
1047 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
1048 | +} | |
440 | 1049 | |
441 | - if (encode && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) { | |
442 | - FILE *tmp = fopen(trace_ctx->trace_codedbuf_fn, "w"); | |
443 | - | |
444 | - if (tmp) | |
445 | - trace_ctx->trace_fp_codedbuf = tmp; | |
446 | - else { | |
447 | - va_errorMessage("Open file %s failed (%s)\n", | |
448 | - trace_ctx->trace_codedbuf_fn, | |
449 | - strerror(errno)); | |
450 | - trace_ctx->trace_fp_codedbuf = NULL; | |
451 | - trace_flag &= ~VA_TRACE_FLAG_CODEDBUF; | |
452 | - } | |
453 | - } | |
1050 | +void va_TraceDestroyConfig ( | |
1051 | + VADisplay dpy, | |
1052 | + VAConfigID config_id | |
1053 | +) | |
1054 | +{ | |
1055 | + DPY2TRACE_VIRCTX(dpy); | |
1056 | + | |
1057 | + TRACE_FUNCNAME(idx); | |
1058 | + | |
1059 | + va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config_id); | |
1060 | + va_TraceMsg(trace_ctx, NULL); | |
1061 | + | |
1062 | + delete_trace_config_info(pva_trace, config_id); | |
1063 | + | |
1064 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
454 | 1065 | } |
455 | 1066 | |
456 | 1067 | static void va_TraceSurfaceAttributes( |
@@ -532,7 +1143,7 @@ void va_TraceCreateSurfaces( | ||
532 | 1143 | ) |
533 | 1144 | { |
534 | 1145 | int i; |
535 | - DPY2TRACECTX(dpy); | |
1146 | + DPY2TRACE_VIRCTX(dpy); | |
536 | 1147 | |
537 | 1148 | TRACE_FUNCNAME(idx); |
538 | 1149 |
@@ -549,8 +1160,9 @@ void va_TraceCreateSurfaces( | ||
549 | 1160 | va_TraceSurfaceAttributes(trace_ctx, attrib_list, &num_attribs); |
550 | 1161 | |
551 | 1162 | va_TraceMsg(trace_ctx, NULL); |
552 | -} | |
553 | 1163 | |
1164 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
1165 | +} | |
554 | 1166 | |
555 | 1167 | void va_TraceDestroySurfaces( |
556 | 1168 | VADisplay dpy, |
@@ -559,7 +1171,7 @@ void va_TraceDestroySurfaces( | ||
559 | 1171 | ) |
560 | 1172 | { |
561 | 1173 | int i; |
562 | - DPY2TRACECTX(dpy); | |
1174 | + DPY2TRACE_VIRCTX(dpy); | |
563 | 1175 | |
564 | 1176 | TRACE_FUNCNAME(idx); |
565 | 1177 |
@@ -569,9 +1181,72 @@ void va_TraceDestroySurfaces( | ||
569 | 1181 | } |
570 | 1182 | |
571 | 1183 | va_TraceMsg(trace_ctx, NULL); |
1184 | + | |
1185 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
572 | 1186 | } |
573 | 1187 | |
574 | 1188 | |
1189 | +static void internal_TraceUpdateContext ( | |
1190 | + struct va_trace *pva_trace, | |
1191 | + int tra_ctx_idx, | |
1192 | + struct trace_context *new_trace_ctx, | |
1193 | + VAContextID context, | |
1194 | + int destroy_flag | |
1195 | +) | |
1196 | +{ | |
1197 | + struct trace_context *trace_ctx = NULL; | |
1198 | + int i = 0, delete = 1; | |
1199 | + pid_t thd_id = syscall(__NR_gettid); | |
1200 | + | |
1201 | + if(tra_ctx_idx >= MAX_TRACE_CTX_NUM) | |
1202 | + return; | |
1203 | + | |
1204 | + LOCK_RESOURCE(pva_trace); | |
1205 | + | |
1206 | + trace_ctx = pva_trace->ptra_ctx[tra_ctx_idx]; | |
1207 | + if(trace_ctx) { | |
1208 | + if(!new_trace_ctx && | |
1209 | + trace_ctx->created_thd_id != thd_id | |
1210 | + && !destroy_flag) { | |
1211 | + delete = 0; | |
1212 | + } | |
1213 | + else { | |
1214 | + pva_trace->context_num--; | |
1215 | + pva_trace->ptra_ctx[tra_ctx_idx] = NULL; | |
1216 | + } | |
1217 | + } | |
1218 | + | |
1219 | + if(new_trace_ctx) { | |
1220 | + new_trace_ctx->created_thd_id = thd_id; | |
1221 | + pva_trace->ptra_ctx[tra_ctx_idx] = new_trace_ctx; | |
1222 | + pva_trace->context_num++; | |
1223 | + } | |
1224 | + | |
1225 | + UNLOCK_RESOURCE(pva_trace); | |
1226 | + | |
1227 | + if(trace_ctx && delete) { | |
1228 | + for(i = 0;i < MAX_TRACE_THREAD_NUM;i++) | |
1229 | + if(trace_ctx->plog_file_list[i]) | |
1230 | + stop_tracing2log_file(pva_trace, trace_ctx->plog_file_list[i]); | |
1231 | + | |
1232 | + if(trace_ctx->trace_codedbuf_fn) | |
1233 | + free(trace_ctx->trace_codedbuf_fn); | |
1234 | + | |
1235 | + if(trace_ctx->trace_fp_codedbuf) | |
1236 | + fclose(trace_ctx->trace_fp_codedbuf); | |
1237 | + | |
1238 | + if(trace_ctx->trace_surface_fn) | |
1239 | + free(trace_ctx->trace_surface_fn); | |
1240 | + | |
1241 | + if(trace_ctx->trace_fp_surface) | |
1242 | + fclose(trace_ctx->trace_fp_surface); | |
1243 | + | |
1244 | + //delete_trace_all_context_buf(pva_trace, context); | |
1245 | + | |
1246 | + free(trace_ctx); | |
1247 | + } | |
1248 | +} | |
1249 | + | |
575 | 1250 | void va_TraceCreateContext( |
576 | 1251 | VADisplay dpy, |
577 | 1252 | VAConfigID config_id, |
@@ -583,11 +1258,69 @@ void va_TraceCreateContext( | ||
583 | 1258 | VAContextID *context /* out */ |
584 | 1259 | ) |
585 | 1260 | { |
1261 | + struct va_trace *pva_trace = NULL; | |
1262 | + struct trace_context *trace_ctx = NULL; | |
1263 | + int tra_ctx_id = 0; | |
1264 | + int encode = 0, decode = 0, jpeg = 0; | |
586 | 1265 | int i; |
587 | - DPY2TRACECTX(dpy); | |
588 | 1266 | |
589 | - TRACE_FUNCNAME(idx); | |
1267 | + pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); | |
1268 | + if(!context | |
1269 | + || *context == VA_INVALID_ID | |
1270 | + || !pva_trace) { | |
1271 | + va_errorMessage("Invalid context id 0x%08x\n", | |
1272 | + context == NULL ? 0 : (int)*context); | |
1273 | + return; | |
1274 | + } | |
1275 | + | |
1276 | + LOCK_CONTEXT(pva_trace); | |
1277 | + | |
1278 | + tra_ctx_id = get_free_ctx_idx(pva_trace, *context); | |
1279 | + if(tra_ctx_id >= MAX_TRACE_CTX_NUM) { | |
1280 | + va_errorMessage("Can't get trace context for ctx 0x%08x\n", | |
1281 | + *context); | |
1282 | + | |
1283 | + goto FAIL; | |
1284 | + } | |
1285 | + | |
1286 | + trace_ctx = calloc(sizeof(struct trace_context), 1); | |
1287 | + if(trace_ctx == NULL) { | |
1288 | + va_errorMessage("Allocate trace context failed for ctx 0x%08x\n", | |
1289 | + *context); | |
1290 | + | |
1291 | + goto FAIL; | |
1292 | + } | |
590 | 1293 | |
1294 | + i = get_valid_config_idx(pva_trace, config_id); | |
1295 | + if(i >= MAX_TRACE_CTX_NUM) { | |
1296 | + va_errorMessage("Can't get trace config id for ctx 0x%08x cfg %x\n", | |
1297 | + *context, config_id); | |
1298 | + | |
1299 | + goto FAIL; | |
1300 | + } | |
1301 | + trace_ctx->trace_profile = pva_trace->config_info[i].trace_profile; | |
1302 | + trace_ctx->trace_entrypoint = pva_trace->config_info[i].trace_entrypoint; | |
1303 | + | |
1304 | + if(trace_flag & VA_TRACE_FLAG_LOG) { | |
1305 | + trace_ctx->plog_file = start_tracing2log_file(pva_trace); | |
1306 | + if(!trace_ctx->plog_file) { | |
1307 | + va_errorMessage("Can't get trace log file for ctx 0x%08x\n", | |
1308 | + *context); | |
1309 | + | |
1310 | + goto FAIL; | |
1311 | + } | |
1312 | + else | |
1313 | + va_infoMessage("Save context 0x%08x into log file %s\n", *context, | |
1314 | + trace_ctx->plog_file->fn_log); | |
1315 | + | |
1316 | + trace_ctx->plog_file_list[0] = trace_ctx->plog_file; | |
1317 | + } | |
1318 | + | |
1319 | + trace_ctx->trace_context = *context; | |
1320 | + TRACE_FUNCNAME(idx); | |
1321 | + va_TraceMsg(trace_ctx, "\tcontext = 0x%08x trace_flag 0x%x\n", *context, trace_flag); | |
1322 | + va_TraceMsg(trace_ctx, "\tprofile = %d entrypoint = %d\n", trace_ctx->trace_profile, | |
1323 | + trace_ctx->trace_entrypoint); | |
591 | 1324 | va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config_id); |
592 | 1325 | va_TraceMsg(trace_ctx, "\twidth = %d\n", picture_width); |
593 | 1326 | va_TraceMsg(trace_ctx, "\theight = %d\n", picture_height); |
@@ -597,12 +1330,7 @@ void va_TraceCreateContext( | ||
597 | 1330 | for (i=0; i<num_render_targets; i++) |
598 | 1331 | va_TraceMsg(trace_ctx, "\t\trender_targets[%d] = 0x%08x\n", i, render_targets[i]); |
599 | 1332 | } |
600 | - if (context) { | |
601 | - va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", *context); | |
602 | - trace_ctx->trace_context = *context; | |
603 | - } else | |
604 | - trace_ctx->trace_context = VA_INVALID_ID; | |
605 | - | |
1333 | + | |
606 | 1334 | trace_ctx->trace_frame_no = 0; |
607 | 1335 | trace_ctx->trace_slice_no = 0; |
608 | 1336 |
@@ -613,8 +1341,74 @@ void va_TraceCreateContext( | ||
613 | 1341 | trace_ctx->trace_surface_width = picture_width; |
614 | 1342 | if (trace_ctx->trace_surface_height == 0) |
615 | 1343 | trace_ctx->trace_surface_height = picture_height; |
1344 | + | |
1345 | + /* avoid to create so many empty files */ | |
1346 | + encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice); | |
1347 | + decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD); | |
1348 | + jpeg = (trace_ctx->trace_entrypoint == VAEntrypointEncPicture); | |
1349 | + if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE)) || | |
1350 | + (decode && (trace_flag & VA_TRACE_FLAG_SURFACE_DECODE)) || | |
1351 | + (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) { | |
1352 | + if(open_tracing_specil_file(pva_trace, trace_ctx, 1) < 0) { | |
1353 | + va_errorMessage("Open surface fail failed for ctx 0x%08x\n", *context); | |
1354 | + | |
1355 | + trace_flag &= ~(VA_TRACE_FLAG_SURFACE); | |
1356 | + } | |
1357 | + } | |
1358 | + | |
1359 | + if (encode && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) { | |
1360 | + if(open_tracing_specil_file(pva_trace, trace_ctx, 0) < 0) { | |
1361 | + va_errorMessage("Open codedbuf fail failed for ctx 0x%08x\n", *context); | |
1362 | + | |
1363 | + trace_flag &= ~(VA_TRACE_FLAG_CODEDBUF); | |
1364 | + } | |
1365 | + } | |
1366 | + | |
1367 | + internal_TraceUpdateContext(pva_trace, tra_ctx_id, trace_ctx, *context, 0); | |
1368 | + | |
1369 | + UNLOCK_CONTEXT(pva_trace); | |
1370 | + return; | |
1371 | + | |
1372 | +FAIL: | |
1373 | + internal_TraceUpdateContext(pva_trace, tra_ctx_id, NULL, *context, 1); | |
1374 | + | |
1375 | + UNLOCK_CONTEXT(pva_trace); | |
1376 | + | |
1377 | + if(trace_ctx) | |
1378 | + free(trace_ctx); | |
616 | 1379 | } |
617 | 1380 | |
1381 | +void va_TraceDestroyContext ( | |
1382 | + VADisplay dpy, | |
1383 | + VAContextID context | |
1384 | +) | |
1385 | +{ | |
1386 | + struct va_trace *pva_trace = NULL; | |
1387 | + struct trace_context *trace_ctx = NULL; | |
1388 | + int ctx_id = 0; | |
1389 | + | |
1390 | + pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); | |
1391 | + | |
1392 | + if(!pva_trace) | |
1393 | + return; | |
1394 | + | |
1395 | + LOCK_CONTEXT(pva_trace); | |
1396 | + | |
1397 | + ctx_id = get_valid_ctx_idx(pva_trace, context); | |
1398 | + if(ctx_id < MAX_TRACE_CTX_NUM) { | |
1399 | + trace_ctx = pva_trace->ptra_ctx[ctx_id]; | |
1400 | + | |
1401 | + if(trace_ctx) { | |
1402 | + refresh_log_file(pva_trace, trace_ctx); | |
1403 | + | |
1404 | + internal_TraceUpdateContext(pva_trace, | |
1405 | + get_valid_ctx_idx(pva_trace, context), | |
1406 | + NULL, context, 0); | |
1407 | + } | |
1408 | + } | |
1409 | + | |
1410 | + UNLOCK_CONTEXT(pva_trace); | |
1411 | +} | |
618 | 1412 | |
619 | 1413 | static char * buffer_type_to_string(int type) |
620 | 1414 | { |
@@ -657,7 +1451,9 @@ void va_TraceCreateBuffer ( | ||
657 | 1451 | VABufferID *buf_id /* out */ |
658 | 1452 | ) |
659 | 1453 | { |
660 | - DPY2TRACECTX(dpy); | |
1454 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1455 | + | |
1456 | + add_trace_buf_info(pva_trace, context, *buf_id); | |
661 | 1457 | |
662 | 1458 | /* only trace CodedBuffer */ |
663 | 1459 | if (type != VAEncCodedBufferType) |
@@ -685,10 +1481,12 @@ void va_TraceDestroyBuffer ( | ||
685 | 1481 | VACodedBufferSegment *buf_list; |
686 | 1482 | int i = 0; |
687 | 1483 | |
688 | - DPY2TRACECTX(dpy); | |
1484 | + DPY2TRACECTX(dpy, VA_INVALID_ID, buf_id); | |
689 | 1485 | |
690 | 1486 | vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements); |
691 | - | |
1487 | + | |
1488 | + delete_trace_buf_info(pva_trace, buf_id); | |
1489 | + | |
692 | 1490 | /* only trace CodedBuffer */ |
693 | 1491 | if (type != VAEncCodedBufferType) |
694 | 1492 | return; |
@@ -753,6 +1551,8 @@ static void va_TraceCodedBufferIVFHeader(struct trace_context *trace_ctx, void * | ||
753 | 1551 | mem_put_le32(header+8, 0); |
754 | 1552 | fwrite(header, 1, 12, trace_ctx->trace_fp_codedbuf); |
755 | 1553 | trace_ctx->pts++; |
1554 | + | |
1555 | + fflush(trace_ctx->trace_fp_codedbuf); | |
756 | 1556 | } |
757 | 1557 | |
758 | 1558 | void va_TraceMapBuffer ( |
@@ -767,11 +1567,11 @@ void va_TraceMapBuffer ( | ||
767 | 1567 | |
768 | 1568 | VACodedBufferSegment *buf_list; |
769 | 1569 | int i = 0; |
770 | - | |
771 | - DPY2TRACECTX(dpy); | |
1570 | + | |
1571 | + DPY2TRACECTX(dpy, VA_INVALID_ID, buf_id); | |
772 | 1572 | |
773 | 1573 | vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements); |
774 | - | |
1574 | + | |
775 | 1575 | /* only trace CodedBuffer */ |
776 | 1576 | if (type != VAEncCodedBufferType) |
777 | 1577 | return; |
@@ -800,6 +1600,8 @@ void va_TraceMapBuffer ( | ||
800 | 1600 | if (trace_ctx->trace_fp_codedbuf) { |
801 | 1601 | va_TraceMsg(trace_ctx, "\tDump the content to file\n"); |
802 | 1602 | fwrite(buf_list->buf, buf_list->size, 1, trace_ctx->trace_fp_codedbuf); |
1603 | + | |
1604 | + fflush(trace_ctx->trace_fp_codedbuf); | |
803 | 1605 | } |
804 | 1606 | |
805 | 1607 | buf_list = buf_list->next; |
@@ -819,23 +1621,27 @@ static void va_TraceVABuffers( | ||
819 | 1621 | { |
820 | 1622 | unsigned int i; |
821 | 1623 | unsigned char *p = pbuf; |
1624 | + FILE *fp = NULL; | |
822 | 1625 | |
823 | - DPY2TRACECTX(dpy); | |
1626 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
824 | 1627 | |
825 | - va_TraceMsg(trace_ctx, "--%s\n", buffer_type_to_string(type)); | |
1628 | + va_TraceMsg(trace_ctx, "--%s\n", buffer_type_to_string(type)); | |
826 | 1629 | |
827 | - if ((trace_flag & VA_TRACE_FLAG_BUFDATA) && trace_ctx->trace_fp_log) { | |
1630 | + if(trace_ctx->plog_file) | |
1631 | + fp = trace_ctx->plog_file->fp_log; | |
1632 | + | |
1633 | + if ((trace_flag & VA_TRACE_FLAG_BUFDATA) && fp) { | |
828 | 1634 | for (i=0; i<size; i++) { |
829 | 1635 | unsigned char value = p[i]; |
830 | 1636 | |
831 | 1637 | if (i==0) |
832 | - fprintf(trace_ctx->trace_fp_log, "\t\t0x%04x:", i); | |
1638 | + fprintf(fp, "\t\t0x%04x:", i); | |
833 | 1639 | else if ((i%16) == 0) |
834 | - fprintf(trace_ctx->trace_fp_log, "\n\t\t0x%04x:", i); | |
1640 | + fprintf(fp, "\n\t\t0x%04x:", i); | |
835 | 1641 | |
836 | - fprintf(trace_ctx->trace_fp_log, " %02x", value); | |
1642 | + fprintf(fp, " %02x", value); | |
837 | 1643 | } |
838 | - fprintf(trace_ctx->trace_fp_log, "\n"); | |
1644 | + fprintf(fp, "\n"); | |
839 | 1645 | } |
840 | 1646 | |
841 | 1647 | va_TraceMsg(trace_ctx, NULL); |
@@ -854,7 +1660,7 @@ static void va_TraceVAPictureParameterBufferMPEG2( | ||
854 | 1660 | void *data) |
855 | 1661 | { |
856 | 1662 | VAPictureParameterBufferMPEG2 *p=(VAPictureParameterBufferMPEG2 *)data; |
857 | - DPY2TRACECTX(dpy); | |
1663 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
858 | 1664 | |
859 | 1665 | va_TraceMsg(trace_ctx,"VAPictureParameterBufferMPEG2\n"); |
860 | 1666 |
@@ -893,7 +1699,7 @@ static void va_TraceVAIQMatrixBufferMPEG2( | ||
893 | 1699 | void *data) |
894 | 1700 | { |
895 | 1701 | VAIQMatrixBufferMPEG2 *p=(VAIQMatrixBufferMPEG2 *)data; |
896 | - DPY2TRACECTX(dpy); | |
1702 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
897 | 1703 | |
898 | 1704 | va_TraceMsg(trace_ctx,"VAIQMatrixBufferMPEG2\n"); |
899 | 1705 |
@@ -922,7 +1728,7 @@ static void va_TraceVASliceParameterBufferMPEG2( | ||
922 | 1728 | { |
923 | 1729 | VASliceParameterBufferMPEG2 *p=(VASliceParameterBufferMPEG2 *)data; |
924 | 1730 | |
925 | - DPY2TRACECTX(dpy); | |
1731 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
926 | 1732 | |
927 | 1733 | trace_ctx->trace_slice_no++; |
928 | 1734 |
@@ -954,7 +1760,7 @@ static void va_TraceVAPictureParameterBufferJPEG( | ||
954 | 1760 | { |
955 | 1761 | int i; |
956 | 1762 | VAPictureParameterBufferJPEGBaseline *p=(VAPictureParameterBufferJPEGBaseline *)data; |
957 | - DPY2TRACECTX(dpy); | |
1763 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
958 | 1764 | |
959 | 1765 | va_TraceMsg(trace_ctx,"*VAPictureParameterBufferJPEG\n"); |
960 | 1766 | va_TraceMsg(trace_ctx,"\tpicture_width = %u\n", p->picture_width); |
@@ -980,7 +1786,7 @@ static void va_TraceVAIQMatrixBufferJPEG( | ||
980 | 1786 | int i, j; |
981 | 1787 | static char tmp[1024]; |
982 | 1788 | VAIQMatrixBufferJPEGBaseline *p=(VAIQMatrixBufferJPEGBaseline *)data; |
983 | - DPY2TRACECTX(dpy); | |
1789 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
984 | 1790 | va_TraceMsg(trace_ctx,"*VAIQMatrixParameterBufferJPEG\n"); |
985 | 1791 | va_TraceMsg(trace_ctx,"\tload_quantiser_table =\n"); |
986 | 1792 | for (i = 0; i < 4; ++i) { |
@@ -1007,7 +1813,7 @@ static void va_TraceVASliceParameterBufferJPEG( | ||
1007 | 1813 | { |
1008 | 1814 | int i; |
1009 | 1815 | VASliceParameterBufferJPEGBaseline *p=(VASliceParameterBufferJPEGBaseline *)data; |
1010 | - DPY2TRACECTX(dpy); | |
1816 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1011 | 1817 | va_TraceMsg(trace_ctx,"*VASliceParameterBufferJPEG\n"); |
1012 | 1818 | va_TraceMsg(trace_ctx,"\tslice_data_size = %u\n", p->slice_data_size); |
1013 | 1819 | va_TraceMsg(trace_ctx,"\tslice_data_offset = %u\n", p->slice_data_offset); |
@@ -1036,7 +1842,7 @@ static void va_TraceVAHuffmanTableBufferJPEG( | ||
1036 | 1842 | int i, j; |
1037 | 1843 | static char tmp[1024]; |
1038 | 1844 | VAHuffmanTableBufferJPEGBaseline *p=(VAHuffmanTableBufferJPEGBaseline *)data; |
1039 | - DPY2TRACECTX(dpy); | |
1845 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1040 | 1846 | va_TraceMsg(trace_ctx,"*VAHuffmanTableBufferJPEG\n"); |
1041 | 1847 | |
1042 | 1848 | for (i = 0; i < 2; ++i) { |
@@ -1082,7 +1888,7 @@ static void va_TraceVAPictureParameterBufferMPEG4( | ||
1082 | 1888 | int i; |
1083 | 1889 | VAPictureParameterBufferMPEG4 *p=(VAPictureParameterBufferMPEG4 *)data; |
1084 | 1890 | |
1085 | - DPY2TRACECTX(dpy); | |
1891 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1086 | 1892 | |
1087 | 1893 | va_TraceMsg(trace_ctx,"*VAPictureParameterBufferMPEG4\n"); |
1088 | 1894 | va_TraceMsg(trace_ctx,"\tvop_width = %d\n", p->vop_width); |
@@ -1141,7 +1947,7 @@ static void va_TraceVAIQMatrixBufferMPEG4( | ||
1141 | 1947 | { |
1142 | 1948 | int i; |
1143 | 1949 | VAIQMatrixBufferMPEG4 *p=(VAIQMatrixBufferMPEG4 *)data; |
1144 | - DPY2TRACECTX(dpy); | |
1950 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1145 | 1951 | |
1146 | 1952 | va_TraceMsg(trace_ctx,"VAIQMatrixBufferMPEG4\n"); |
1147 | 1953 |
@@ -1169,7 +1975,7 @@ static void va_TraceVAEncSequenceParameterBufferMPEG4( | ||
1169 | 1975 | void *data) |
1170 | 1976 | { |
1171 | 1977 | VAEncSequenceParameterBufferMPEG4 *p = (VAEncSequenceParameterBufferMPEG4 *)data; |
1172 | - DPY2TRACECTX(dpy); | |
1978 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1173 | 1979 | |
1174 | 1980 | va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferMPEG4\n"); |
1175 | 1981 |
@@ -1199,7 +2005,7 @@ static void va_TraceVAEncPictureParameterBufferMPEG4( | ||
1199 | 2005 | void *data) |
1200 | 2006 | { |
1201 | 2007 | VAEncPictureParameterBufferMPEG4 *p = (VAEncPictureParameterBufferMPEG4 *)data; |
1202 | - DPY2TRACECTX(dpy); | |
2008 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1203 | 2009 | |
1204 | 2010 | va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferMPEG4\n"); |
1205 | 2011 | va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture); |
@@ -1227,7 +2033,7 @@ static void va_TraceVASliceParameterBufferMPEG4( | ||
1227 | 2033 | { |
1228 | 2034 | VASliceParameterBufferMPEG4 *p=(VASliceParameterBufferMPEG4 *)data; |
1229 | 2035 | |
1230 | - DPY2TRACECTX(dpy); | |
2036 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1231 | 2037 | |
1232 | 2038 | trace_ctx->trace_slice_no++; |
1233 | 2039 |
@@ -1271,7 +2077,7 @@ static void va_TraceVAPictureParameterBufferHEVC( | ||
1271 | 2077 | int i; |
1272 | 2078 | VAPictureParameterBufferHEVC *p = (VAPictureParameterBufferHEVC*)data; |
1273 | 2079 | |
1274 | - DPY2TRACECTX(dpy); | |
2080 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1275 | 2081 | |
1276 | 2082 | va_TraceMsg(trace_ctx, "VAPictureParameterBufferHEVC\n"); |
1277 | 2083 |
@@ -1397,7 +2203,7 @@ static void va_TraceVASliceParameterBufferHEVC( | ||
1397 | 2203 | int i,j; |
1398 | 2204 | VASliceParameterBufferHEVC* p = (VASliceParameterBufferHEVC*)data; |
1399 | 2205 | |
1400 | - DPY2TRACECTX(dpy); | |
2206 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1401 | 2207 | |
1402 | 2208 | trace_ctx->trace_slice_no++; |
1403 | 2209 | trace_ctx->trace_slice_size = p->slice_data_size; |
@@ -1484,7 +2290,7 @@ static void va_TraceVAIQMatrixBufferHEVC( | ||
1484 | 2290 | int i, j; |
1485 | 2291 | VAIQMatrixBufferHEVC* p = (VAIQMatrixBufferHEVC* )data; |
1486 | 2292 | |
1487 | - DPY2TRACECTX(dpy); | |
2293 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1488 | 2294 | |
1489 | 2295 | va_TraceMsg(trace_ctx, "VAIQMatrixBufferHEVC\n"); |
1490 | 2296 |
@@ -1547,7 +2353,7 @@ static void va_TraceVAEncSequenceParameterBufferHEVC( | ||
1547 | 2353 | { |
1548 | 2354 | VAEncSequenceParameterBufferHEVC *p = (VAEncSequenceParameterBufferHEVC *)data; |
1549 | 2355 | |
1550 | - DPY2TRACECTX(dpy); | |
2356 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1551 | 2357 | |
1552 | 2358 | if(!p) |
1553 | 2359 | return; |
@@ -1620,7 +2426,7 @@ static void va_TraceVAEncPictureParameterBufferHEVC( | ||
1620 | 2426 | int i; |
1621 | 2427 | VAEncPictureParameterBufferHEVC *p = (VAEncPictureParameterBufferHEVC *)data; |
1622 | 2428 | |
1623 | - DPY2TRACECTX(dpy); | |
2429 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1624 | 2430 | |
1625 | 2431 | if(!p) |
1626 | 2432 | return; |
@@ -1700,7 +2506,7 @@ static void va_TraceVAEncSliceParameterBufferHEVC( | ||
1700 | 2506 | int i; |
1701 | 2507 | VAEncSliceParameterBufferHEVC *p = (VAEncSliceParameterBufferHEVC *)data; |
1702 | 2508 | |
1703 | - DPY2TRACECTX(dpy); | |
2509 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1704 | 2510 | |
1705 | 2511 | if(!p) |
1706 | 2512 | return; |
@@ -1789,7 +2595,7 @@ static void va_TraceVAPictureParameterBufferH264( | ||
1789 | 2595 | int i; |
1790 | 2596 | VAPictureParameterBufferH264 *p = (VAPictureParameterBufferH264*)data; |
1791 | 2597 | |
1792 | - DPY2TRACECTX(dpy); | |
2598 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1793 | 2599 | |
1794 | 2600 | va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferH264\n"); |
1795 | 2601 |
@@ -1860,7 +2666,7 @@ static void va_TraceVASliceParameterBufferH264( | ||
1860 | 2666 | { |
1861 | 2667 | int i; |
1862 | 2668 | VASliceParameterBufferH264* p = (VASliceParameterBufferH264*)data; |
1863 | - DPY2TRACECTX(dpy); | |
2669 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1864 | 2670 | |
1865 | 2671 | trace_ctx->trace_slice_no++; |
1866 | 2672 | trace_ctx->trace_slice_size = p->slice_data_size; |
@@ -1954,18 +2760,22 @@ static void va_TraceVAIQMatrixBufferH264( | ||
1954 | 2760 | { |
1955 | 2761 | int i, j; |
1956 | 2762 | VAIQMatrixBufferH264* p = (VAIQMatrixBufferH264* )data; |
2763 | + FILE *fp = NULL; | |
2764 | + | |
2765 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
1957 | 2766 | |
1958 | - DPY2TRACECTX(dpy); | |
2767 | + if(trace_ctx->plog_file) | |
2768 | + fp = trace_ctx->plog_file->fp_log; | |
1959 | 2769 | |
1960 | 2770 | va_TraceMsg(trace_ctx, "\t--VAIQMatrixBufferH264\n"); |
1961 | 2771 | |
1962 | 2772 | va_TraceMsg(trace_ctx, "\tScalingList4x4[6][16]=\n"); |
1963 | 2773 | for (i = 0; i < 6; i++) { |
1964 | 2774 | for (j = 0; j < 16; j++) { |
1965 | - if (trace_ctx->trace_fp_log) { | |
1966 | - fprintf(trace_ctx->trace_fp_log, "\t%d", p->ScalingList4x4[i][j]); | |
2775 | + if (fp) { | |
2776 | + fprintf(fp, "\t%d", p->ScalingList4x4[i][j]); | |
1967 | 2777 | if ((j + 1) % 8 == 0) |
1968 | - fprintf(trace_ctx->trace_fp_log, "\n"); | |
2778 | + fprintf(fp, "\n"); | |
1969 | 2779 | } |
1970 | 2780 | } |
1971 | 2781 | } |
@@ -1973,10 +2783,10 @@ static void va_TraceVAIQMatrixBufferH264( | ||
1973 | 2783 | va_TraceMsg(trace_ctx, "\tScalingList8x8[2][64]=\n"); |
1974 | 2784 | for (i = 0; i < 2; i++) { |
1975 | 2785 | for (j = 0; j < 64; j++) { |
1976 | - if (trace_ctx->trace_fp_log) { | |
1977 | - fprintf(trace_ctx->trace_fp_log,"\t%d", p->ScalingList8x8[i][j]); | |
2786 | + if (fp) { | |
2787 | + fprintf(fp,"\t%d", p->ScalingList8x8[i][j]); | |
1978 | 2788 | if ((j + 1) % 8 == 0) |
1979 | - fprintf(trace_ctx->trace_fp_log, "\n"); | |
2789 | + fprintf(fp, "\n"); | |
1980 | 2790 | } |
1981 | 2791 | } |
1982 | 2792 | } |
@@ -1996,7 +2806,7 @@ static void va_TraceVAEncSequenceParameterBufferH264( | ||
1996 | 2806 | void *data) |
1997 | 2807 | { |
1998 | 2808 | VAEncSequenceParameterBufferH264 *p = (VAEncSequenceParameterBufferH264 *)data; |
1999 | - DPY2TRACECTX(dpy); | |
2809 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2000 | 2810 | unsigned int i; |
2001 | 2811 | |
2002 | 2812 | va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferH264\n"); |
@@ -2059,7 +2869,7 @@ static void va_TraceVAEncPictureParameterBufferH264( | ||
2059 | 2869 | void *data) |
2060 | 2870 | { |
2061 | 2871 | VAEncPictureParameterBufferH264 *p = (VAEncPictureParameterBufferH264 *)data; |
2062 | - DPY2TRACECTX(dpy); | |
2872 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2063 | 2873 | int i; |
2064 | 2874 | |
2065 | 2875 | va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferH264\n"); |
@@ -2122,7 +2932,7 @@ static void va_TraceVAEncSliceParameterBuffer( | ||
2122 | 2932 | void *data) |
2123 | 2933 | { |
2124 | 2934 | VAEncSliceParameterBuffer* p = (VAEncSliceParameterBuffer*)data; |
2125 | - DPY2TRACECTX(dpy); | |
2935 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2126 | 2936 | |
2127 | 2937 | va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBuffer\n"); |
2128 | 2938 |
@@ -2147,7 +2957,7 @@ static void va_TraceVAEncSliceParameterBufferH264( | ||
2147 | 2957 | void *data) |
2148 | 2958 | { |
2149 | 2959 | VAEncSliceParameterBufferH264* p = (VAEncSliceParameterBufferH264*)data; |
2150 | - DPY2TRACECTX(dpy); | |
2960 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2151 | 2961 | int i; |
2152 | 2962 | |
2153 | 2963 | if (!p) |
@@ -2265,7 +3075,7 @@ static void va_TraceVAEncPackedHeaderParameterBufferType( | ||
2265 | 3075 | void *data) |
2266 | 3076 | { |
2267 | 3077 | VAEncPackedHeaderParameterBuffer* p = (VAEncPackedHeaderParameterBuffer*)data; |
2268 | - DPY2TRACECTX(dpy); | |
3078 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2269 | 3079 | int i; |
2270 | 3080 | |
2271 | 3081 | if (!p) |
@@ -2289,7 +3099,7 @@ static void va_TraceVAEncMiscParameterBuffer( | ||
2289 | 3099 | void *data) |
2290 | 3100 | { |
2291 | 3101 | VAEncMiscParameterBuffer* tmp = (VAEncMiscParameterBuffer*)data; |
2292 | - DPY2TRACECTX(dpy); | |
3102 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2293 | 3103 | |
2294 | 3104 | switch (tmp->type) { |
2295 | 3105 | case VAEncMiscParameterTypeFrameRate: |
@@ -2373,7 +3183,7 @@ static void va_TraceVAPictureParameterBufferVC1( | ||
2373 | 3183 | ) |
2374 | 3184 | { |
2375 | 3185 | VAPictureParameterBufferVC1* p = (VAPictureParameterBufferVC1*)data; |
2376 | - DPY2TRACECTX(dpy); | |
3186 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2377 | 3187 | |
2378 | 3188 | va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVC1\n"); |
2379 | 3189 |
@@ -2478,7 +3288,7 @@ static void va_TraceVASliceParameterBufferVC1( | ||
2478 | 3288 | ) |
2479 | 3289 | { |
2480 | 3290 | VASliceParameterBufferVC1 *p = (VASliceParameterBufferVC1*)data; |
2481 | - DPY2TRACECTX(dpy); | |
3291 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2482 | 3292 | |
2483 | 3293 | trace_ctx->trace_slice_no++; |
2484 | 3294 | trace_ctx->trace_slice_size = p->slice_data_size; |
@@ -2503,7 +3313,7 @@ static void va_TraceVAPictureParameterBufferVP8( | ||
2503 | 3313 | { |
2504 | 3314 | char tmp[1024]; |
2505 | 3315 | VAPictureParameterBufferVP8 *p = (VAPictureParameterBufferVP8 *)data; |
2506 | - DPY2TRACECTX(dpy); | |
3316 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2507 | 3317 | int i,j; |
2508 | 3318 | |
2509 | 3319 | va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVP8\n"); |
@@ -2578,7 +3388,7 @@ static void va_TraceVASliceParameterBufferVP8( | ||
2578 | 3388 | void *data) |
2579 | 3389 | { |
2580 | 3390 | VASliceParameterBufferVP8 *p = (VASliceParameterBufferVP8 *)data; |
2581 | - DPY2TRACECTX(dpy); | |
3391 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2582 | 3392 | int i; |
2583 | 3393 | |
2584 | 3394 | va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferVP8\n"); |
@@ -2608,7 +3418,7 @@ static void va_TraceVAIQMatrixBufferVP8( | ||
2608 | 3418 | { |
2609 | 3419 | char tmp[1024]; |
2610 | 3420 | VAIQMatrixBufferVP8 *p = (VAIQMatrixBufferVP8 *)data; |
2611 | - DPY2TRACECTX(dpy); | |
3421 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2612 | 3422 | int i,j; |
2613 | 3423 | |
2614 | 3424 | va_TraceMsg(trace_ctx, "\t--VAIQMatrixBufferVP8\n"); |
@@ -2636,7 +3446,7 @@ static void va_TraceVAProbabilityBufferVP8( | ||
2636 | 3446 | { |
2637 | 3447 | char tmp[1024]; |
2638 | 3448 | VAProbabilityDataBufferVP8 *p = (VAProbabilityDataBufferVP8 *)data; |
2639 | - DPY2TRACECTX(dpy); | |
3449 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2640 | 3450 | int i,j,k,l; |
2641 | 3451 | |
2642 | 3452 | va_TraceMsg(trace_ctx, "\t--VAProbabilityDataBufferVP8\n"); |
@@ -2665,7 +3475,7 @@ static void va_TraceVAEncSequenceParameterBufferVP8( | ||
2665 | 3475 | void *data) |
2666 | 3476 | { |
2667 | 3477 | VAEncSequenceParameterBufferVP8 *p = (VAEncSequenceParameterBufferVP8 *)data; |
2668 | - DPY2TRACECTX(dpy); | |
3478 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2669 | 3479 | int i; |
2670 | 3480 | |
2671 | 3481 | va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferVP8\n"); |
@@ -2699,7 +3509,7 @@ static void va_TraceVAPictureParameterBufferVP9( | ||
2699 | 3509 | void *data) |
2700 | 3510 | { |
2701 | 3511 | VADecPictureParameterBufferVP9 *p = (VADecPictureParameterBufferVP9 *)data; |
2702 | - DPY2TRACECTX(dpy); | |
3512 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2703 | 3513 | int i,j; |
2704 | 3514 | |
2705 | 3515 | va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVP9\n"); |
@@ -2765,7 +3575,7 @@ static void va_TraceVAEncPictureParameterBufferVP8( | ||
2765 | 3575 | void *data) |
2766 | 3576 | { |
2767 | 3577 | VAEncPictureParameterBufferVP8 *p = (VAEncPictureParameterBufferVP8 *)data; |
2768 | - DPY2TRACECTX(dpy); | |
3578 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2769 | 3579 | int i; |
2770 | 3580 | |
2771 | 3581 | va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferVP8\n"); |
@@ -2834,7 +3644,7 @@ static void va_TraceVASliceParameterBufferVP9( | ||
2834 | 3644 | { |
2835 | 3645 | |
2836 | 3646 | VASliceParameterBufferVP9 *p = (VASliceParameterBufferVP9 *)data; |
2837 | - DPY2TRACECTX(dpy); | |
3647 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2838 | 3648 | int i, j; |
2839 | 3649 | |
2840 | 3650 | va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferVP9\n"); |
@@ -2870,7 +3680,7 @@ void va_TraceBeginPicture( | ||
2870 | 3680 | VASurfaceID render_target |
2871 | 3681 | ) |
2872 | 3682 | { |
2873 | - DPY2TRACECTX(dpy); | |
3683 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2874 | 3684 | |
2875 | 3685 | TRACE_FUNCNAME(idx); |
2876 | 3686 |
@@ -2951,7 +3761,7 @@ static void va_TraceVAEncSequenceParameterBufferH263( | ||
2951 | 3761 | void *data) |
2952 | 3762 | { |
2953 | 3763 | VAEncSequenceParameterBufferH263 *p = (VAEncSequenceParameterBufferH263 *)data; |
2954 | - DPY2TRACECTX(dpy); | |
3764 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2955 | 3765 | |
2956 | 3766 | va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferH263\n"); |
2957 | 3767 |
@@ -2976,7 +3786,7 @@ static void va_TraceVAEncPictureParameterBufferH263( | ||
2976 | 3786 | void *data) |
2977 | 3787 | { |
2978 | 3788 | VAEncPictureParameterBufferH263 *p = (VAEncPictureParameterBufferH263 *)data; |
2979 | - DPY2TRACECTX(dpy); | |
3789 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
2980 | 3790 | |
2981 | 3791 | va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferH263\n"); |
2982 | 3792 | va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture); |
@@ -3002,7 +3812,7 @@ static void va_TraceVAEncPictureParameterBufferJPEG( | ||
3002 | 3812 | VAEncPictureParameterBufferJPEG *p = (VAEncPictureParameterBufferJPEG *)data; |
3003 | 3813 | int i; |
3004 | 3814 | |
3005 | - DPY2TRACECTX(dpy); | |
3815 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3006 | 3816 | |
3007 | 3817 | va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferJPEG\n"); |
3008 | 3818 | va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture); |
@@ -3044,7 +3854,7 @@ static void va_TraceVAEncQMatrixBufferJPEG( | ||
3044 | 3854 | void *data) |
3045 | 3855 | { |
3046 | 3856 | VAQMatrixBufferJPEG *p = (VAQMatrixBufferJPEG *)data; |
3047 | - DPY2TRACECTX(dpy); | |
3857 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3048 | 3858 | |
3049 | 3859 | va_TraceMsg(trace_ctx, "\t--VAQMatrixBufferJPEG\n"); |
3050 | 3860 | va_TraceMsg(trace_ctx, "\tload_lum_quantiser_matrix = %d", p->load_lum_quantiser_matrix); |
@@ -3086,7 +3896,7 @@ static void va_TraceVAEncSliceParameterBufferJPEG( | ||
3086 | 3896 | VAEncSliceParameterBufferJPEG *p = (VAEncSliceParameterBufferJPEG *)data; |
3087 | 3897 | int i; |
3088 | 3898 | |
3089 | - DPY2TRACECTX(dpy); | |
3899 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3090 | 3900 | |
3091 | 3901 | va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBufferJPEG\n"); |
3092 | 3902 | va_TraceMsg(trace_ctx, "\trestart_interval = 0x%04x\n", p->restart_interval); |
@@ -3286,7 +4096,7 @@ static void va_TraceHEVCBuf( | ||
3286 | 4096 | void *pbuf |
3287 | 4097 | ) |
3288 | 4098 | { |
3289 | - DPY2TRACECTX(dpy); | |
4099 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3290 | 4100 | |
3291 | 4101 | switch (type) { |
3292 | 4102 | case VAPictureParameterBufferType: |
@@ -3326,7 +4136,7 @@ static void va_TraceH264Buf( | ||
3326 | 4136 | void *pbuf |
3327 | 4137 | ) |
3328 | 4138 | { |
3329 | - DPY2TRACECTX(dpy); | |
4139 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3330 | 4140 | |
3331 | 4141 | switch (type) { |
3332 | 4142 | case VAPictureParameterBufferType: |
@@ -3398,7 +4208,7 @@ static void va_TraceVP8Buf( | ||
3398 | 4208 | void *pbuf |
3399 | 4209 | ) |
3400 | 4210 | { |
3401 | - DPY2TRACECTX(dpy); | |
4211 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3402 | 4212 | |
3403 | 4213 | switch (type) { |
3404 | 4214 | case VAPictureParameterBufferType: |
@@ -3462,7 +4272,7 @@ static void va_TraceVP9Buf( | ||
3462 | 4272 | void *pbuf |
3463 | 4273 | ) |
3464 | 4274 | { |
3465 | - DPY2TRACECTX(dpy); | |
4275 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3466 | 4276 | |
3467 | 4277 | switch (type) { |
3468 | 4278 | case VAPictureParameterBufferType: |
@@ -3487,7 +4297,7 @@ static void va_TraceVC1Buf( | ||
3487 | 4297 | void *pbuf |
3488 | 4298 | ) |
3489 | 4299 | { |
3490 | - DPY2TRACECTX(dpy); | |
4300 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3491 | 4301 | |
3492 | 4302 | switch (type) { |
3493 | 4303 | case VAPictureParameterBufferType: |
@@ -3547,7 +4357,7 @@ va_TraceProcFilterParameterBufferDeinterlacing( | ||
3547 | 4357 | { |
3548 | 4358 | VAProcFilterParameterBufferDeinterlacing *deint = (VAProcFilterParameterBufferDeinterlacing *)base; |
3549 | 4359 | |
3550 | - DPY2TRACECTX(dpy); | |
4360 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3551 | 4361 | |
3552 | 4362 | va_TraceMsg(trace_ctx, "\t type = %d\n", deint->type); |
3553 | 4363 | va_TraceMsg(trace_ctx, "\t algorithm = %d\n", deint->algorithm); |
@@ -3563,7 +4373,7 @@ va_TraceProcFilterParameterBufferColorBalance( | ||
3563 | 4373 | { |
3564 | 4374 | VAProcFilterParameterBufferColorBalance *color_balance = (VAProcFilterParameterBufferColorBalance *)base; |
3565 | 4375 | |
3566 | - DPY2TRACECTX(dpy); | |
4376 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3567 | 4377 | |
3568 | 4378 | va_TraceMsg(trace_ctx, "\t type = %d\n", color_balance->type); |
3569 | 4379 | va_TraceMsg(trace_ctx, "\t attrib = %d\n", color_balance->attrib); |
@@ -3577,7 +4387,7 @@ va_TraceProcFilterParameterBufferBase( | ||
3577 | 4387 | VAProcFilterParameterBufferBase *base |
3578 | 4388 | ) |
3579 | 4389 | { |
3580 | - DPY2TRACECTX(dpy); | |
4390 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3581 | 4391 | |
3582 | 4392 | va_TraceMsg(trace_ctx, "\t type = %d\n", base->type); |
3583 | 4393 | } |
@@ -3596,7 +4406,7 @@ va_TraceProcFilterParameterBuffer( | ||
3596 | 4406 | VAProcFilterParameterBufferBase *base_filter = NULL; |
3597 | 4407 | int i; |
3598 | 4408 | |
3599 | - DPY2TRACECTX(dpy); | |
4409 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3600 | 4410 | |
3601 | 4411 | if (num_filters == 0 || filters == NULL) { |
3602 | 4412 | va_TraceMsg(trace_ctx, "\t num_filters = %d\n", num_filters); |
@@ -3661,7 +4471,7 @@ va_TraceVAProcPipelineParameterBuffer( | ||
3661 | 4471 | VAProcPipelineParameterBuffer *p = (VAProcPipelineParameterBuffer *)data; |
3662 | 4472 | int i; |
3663 | 4473 | |
3664 | - DPY2TRACECTX(dpy); | |
4474 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3665 | 4475 | |
3666 | 4476 | va_TraceMsg(trace_ctx, "\t--VAProcPipelineParameterBuffer\n"); |
3667 | 4477 |
@@ -3746,7 +4556,7 @@ va_TraceNoneBuf( | ||
3746 | 4556 | void *pbuf |
3747 | 4557 | ) |
3748 | 4558 | { |
3749 | - DPY2TRACECTX(dpy); | |
4559 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3750 | 4560 | |
3751 | 4561 | switch (type) { |
3752 | 4562 | case VAProcPipelineParameterBufferType: |
@@ -3769,7 +4579,7 @@ void va_TraceRenderPicture( | ||
3769 | 4579 | unsigned int size; |
3770 | 4580 | unsigned int num_elements; |
3771 | 4581 | int i; |
3772 | - DPY2TRACECTX(dpy); | |
4582 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3773 | 4583 | |
3774 | 4584 | TRACE_FUNCNAME(idx); |
3775 | 4585 |
@@ -3893,7 +4703,7 @@ void va_TraceEndPicture( | ||
3893 | 4703 | ) |
3894 | 4704 | { |
3895 | 4705 | int encode, decode, jpeg; |
3896 | - DPY2TRACECTX(dpy); | |
4706 | + DPY2TRACECTX(dpy, context, VA_INVALID_ID); | |
3897 | 4707 | |
3898 | 4708 | TRACE_FUNCNAME(idx); |
3899 | 4709 |
@@ -3908,12 +4718,12 @@ void va_TraceEndPicture( | ||
3908 | 4718 | /* trace encode source surface, can do it before HW completes rendering */ |
3909 | 4719 | if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE))|| |
3910 | 4720 | (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) |
3911 | - va_TraceSurface(dpy); | |
4721 | + va_TraceSurface(dpy, context); | |
3912 | 4722 | |
3913 | 4723 | /* trace decoded surface, do it after HW completes rendering */ |
3914 | 4724 | if (decode && ((trace_flag & VA_TRACE_FLAG_SURFACE_DECODE))) { |
3915 | 4725 | vaSyncSurface(dpy, trace_ctx->trace_rendertarget); |
3916 | - va_TraceSurface(dpy); | |
4726 | + va_TraceSurface(dpy, context); | |
3917 | 4727 | } |
3918 | 4728 | |
3919 | 4729 | va_TraceMsg(trace_ctx, NULL); |
@@ -3925,12 +4735,14 @@ void va_TraceSyncSurface( | ||
3925 | 4735 | VASurfaceID render_target |
3926 | 4736 | ) |
3927 | 4737 | { |
3928 | - DPY2TRACECTX(dpy); | |
4738 | + DPY2TRACE_VIRCTX(dpy); | |
3929 | 4739 | |
3930 | 4740 | TRACE_FUNCNAME(idx); |
3931 | 4741 | |
3932 | 4742 | va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target); |
3933 | 4743 | va_TraceMsg(trace_ctx, NULL); |
4744 | + | |
4745 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
3934 | 4746 | } |
3935 | 4747 | |
3936 | 4748 | void va_TraceQuerySurfaceAttributes( |
@@ -3940,7 +4752,7 @@ void va_TraceQuerySurfaceAttributes( | ||
3940 | 4752 | unsigned int *num_attribs |
3941 | 4753 | ) |
3942 | 4754 | { |
3943 | - DPY2TRACECTX(dpy); | |
4755 | + DPY2TRACE_VIRCTX(dpy); | |
3944 | 4756 | |
3945 | 4757 | TRACE_FUNCNAME(idx); |
3946 | 4758 | va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config); |
@@ -3948,6 +4760,7 @@ void va_TraceQuerySurfaceAttributes( | ||
3948 | 4760 | |
3949 | 4761 | va_TraceMsg(trace_ctx, NULL); |
3950 | 4762 | |
4763 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
3951 | 4764 | } |
3952 | 4765 | |
3953 | 4766 |
@@ -3957,7 +4770,7 @@ void va_TraceQuerySurfaceStatus( | ||
3957 | 4770 | VASurfaceStatus *status /* out */ |
3958 | 4771 | ) |
3959 | 4772 | { |
3960 | - DPY2TRACECTX(dpy); | |
4773 | + DPY2TRACE_VIRCTX(dpy); | |
3961 | 4774 | |
3962 | 4775 | TRACE_FUNCNAME(idx); |
3963 | 4776 |
@@ -3965,6 +4778,8 @@ void va_TraceQuerySurfaceStatus( | ||
3965 | 4778 | if (status) |
3966 | 4779 | va_TraceMsg(trace_ctx, "\tstatus = 0x%08x\n", *status); |
3967 | 4780 | va_TraceMsg(trace_ctx, NULL); |
4781 | + | |
4782 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
3968 | 4783 | } |
3969 | 4784 | |
3970 | 4785 |
@@ -3975,7 +4790,7 @@ void va_TraceQuerySurfaceError( | ||
3975 | 4790 | void **error_info /*out*/ |
3976 | 4791 | ) |
3977 | 4792 | { |
3978 | - DPY2TRACECTX(dpy); | |
4793 | + DPY2TRACE_VIRCTX(dpy); | |
3979 | 4794 | |
3980 | 4795 | TRACE_FUNCNAME(idx); |
3981 | 4796 | va_TraceMsg(trace_ctx, "\tsurface = 0x%08x\n", surface); |
@@ -3990,6 +4805,8 @@ void va_TraceQuerySurfaceError( | ||
3990 | 4805 | } |
3991 | 4806 | } |
3992 | 4807 | va_TraceMsg(trace_ctx, NULL); |
4808 | + | |
4809 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
3993 | 4810 | } |
3994 | 4811 | |
3995 | 4812 | void va_TraceMaxNumDisplayAttributes ( |
@@ -3997,12 +4814,14 @@ void va_TraceMaxNumDisplayAttributes ( | ||
3997 | 4814 | int number |
3998 | 4815 | ) |
3999 | 4816 | { |
4000 | - DPY2TRACECTX(dpy); | |
4817 | + DPY2TRACE_VIRCTX(dpy); | |
4001 | 4818 | |
4002 | 4819 | TRACE_FUNCNAME(idx); |
4003 | 4820 | |
4004 | 4821 | va_TraceMsg(trace_ctx, "\tmax_display_attributes = %d\n", number); |
4005 | 4822 | va_TraceMsg(trace_ctx, NULL); |
4823 | + | |
4824 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
4006 | 4825 | } |
4007 | 4826 | |
4008 | 4827 | void va_TraceQueryDisplayAttributes ( |
@@ -4012,12 +4831,12 @@ void va_TraceQueryDisplayAttributes ( | ||
4012 | 4831 | ) |
4013 | 4832 | { |
4014 | 4833 | int i; |
4015 | - | |
4016 | - DPY2TRACECTX(dpy); | |
4017 | - | |
4834 | + | |
4018 | 4835 | if (attr_list == NULL || num_attributes == NULL) |
4019 | 4836 | return; |
4020 | 4837 | |
4838 | + DPY2TRACE_VIRCTX(dpy); | |
4839 | + | |
4021 | 4840 | va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", *num_attributes); |
4022 | 4841 | |
4023 | 4842 | for (i=0; i<*num_attributes; i++) { |
@@ -4029,23 +4848,24 @@ void va_TraceQueryDisplayAttributes ( | ||
4029 | 4848 | va_TraceMsg(trace_ctx, "\t flags = %d\n", attr_list[i].flags); |
4030 | 4849 | } |
4031 | 4850 | va_TraceMsg(trace_ctx, NULL); |
4851 | + | |
4852 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
4032 | 4853 | } |
4033 | 4854 | |
4034 | 4855 | |
4035 | 4856 | static void va_TraceDisplayAttributes ( |
4036 | - VADisplay dpy, | |
4857 | + struct trace_context *trace_ctx, | |
4037 | 4858 | VADisplayAttribute *attr_list, |
4038 | 4859 | int num_attributes |
4039 | 4860 | ) |
4040 | 4861 | { |
4041 | 4862 | int i; |
4042 | - | |
4043 | - DPY2TRACECTX(dpy); | |
4044 | - | |
4045 | - va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", num_attributes); | |
4863 | + | |
4046 | 4864 | if (attr_list == NULL) |
4047 | 4865 | return; |
4048 | - | |
4866 | + | |
4867 | + va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", num_attributes); | |
4868 | + | |
4049 | 4869 | for (i=0; i<num_attributes; i++) { |
4050 | 4870 | va_TraceMsg(trace_ctx, "\tattr_list[%d] =\n"); |
4051 | 4871 | va_TraceMsg(trace_ctx, "\t typ = 0x%08x\n", attr_list[i].type); |
@@ -4064,11 +4884,13 @@ void va_TraceGetDisplayAttributes ( | ||
4064 | 4884 | int num_attributes |
4065 | 4885 | ) |
4066 | 4886 | { |
4067 | - DPY2TRACECTX(dpy); | |
4887 | + DPY2TRACE_VIRCTX(dpy); | |
4068 | 4888 | |
4069 | 4889 | TRACE_FUNCNAME(idx); |
4070 | 4890 | |
4071 | - va_TraceDisplayAttributes (dpy, attr_list, num_attributes); | |
4891 | + va_TraceDisplayAttributes (trace_ctx, attr_list, num_attributes); | |
4892 | + | |
4893 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
4072 | 4894 | } |
4073 | 4895 | |
4074 | 4896 | void va_TraceSetDisplayAttributes ( |
@@ -4077,11 +4899,13 @@ void va_TraceSetDisplayAttributes ( | ||
4077 | 4899 | int num_attributes |
4078 | 4900 | ) |
4079 | 4901 | { |
4080 | - DPY2TRACECTX(dpy); | |
4902 | + DPY2TRACE_VIRCTX(dpy); | |
4081 | 4903 | |
4082 | 4904 | TRACE_FUNCNAME(idx); |
4083 | 4905 | |
4084 | - va_TraceDisplayAttributes (dpy, attr_list, num_attributes); | |
4906 | + va_TraceDisplayAttributes (trace_ctx, attr_list, num_attributes); | |
4907 | + | |
4908 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
4085 | 4909 | } |
4086 | 4910 | |
4087 | 4911 |
@@ -4102,7 +4926,7 @@ void va_TracePutSurface ( | ||
4102 | 4926 | unsigned int flags /* de-interlacing flags */ |
4103 | 4927 | ) |
4104 | 4928 | { |
4105 | - DPY2TRACECTX(dpy); | |
4929 | + DPY2TRACE_VIRCTX(dpy); | |
4106 | 4930 | |
4107 | 4931 | TRACE_FUNCNAME(idx); |
4108 | 4932 |
@@ -4120,4 +4944,6 @@ void va_TracePutSurface ( | ||
4120 | 4944 | va_TraceMsg(trace_ctx, "\tnumber_cliprects = %d\n", number_cliprects); |
4121 | 4945 | va_TraceMsg(trace_ctx, "\tflags = 0x%08x\n", flags); |
4122 | 4946 | va_TraceMsg(trace_ctx, NULL); |
4947 | + | |
4948 | + DPY2TRACE_VIRCTX_EXIT(pva_trace); | |
4123 | 4949 | } |
@@ -78,6 +78,12 @@ void va_TraceCreateConfig( | ||
78 | 78 | ); |
79 | 79 | |
80 | 80 | DLL_HIDDEN |
81 | +void va_TraceDestroyConfig ( | |
82 | + VADisplay dpy, | |
83 | + VAConfigID config_id | |
84 | +); | |
85 | + | |
86 | +DLL_HIDDEN | |
81 | 87 | void va_TraceCreateSurfaces( |
82 | 88 | VADisplay dpy, |
83 | 89 | int width, |
@@ -109,6 +115,12 @@ void va_TraceCreateContext( | ||
109 | 115 | ); |
110 | 116 | |
111 | 117 | DLL_HIDDEN |
118 | +void va_TraceDestroyContext ( | |
119 | + VADisplay dpy, | |
120 | + VAContextID context | |
121 | +); | |
122 | + | |
123 | +DLL_HIDDEN | |
112 | 124 | void va_TraceCreateBuffer ( |
113 | 125 | VADisplay dpy, |
114 | 126 | VAContextID context, /* in */ |