• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * Authors:
25  *    Fei Jiang <fei.jiang@intel.com>
26  *
27  */
28 
29 #ifndef _PSB_DEBUG_H_
30 #define _PSB_DEBUG_H_
31 
32 #include <assert.h>
33 #include <string.h>
34 #include <stdio.h>
35 #include <stdarg.h>
36 #include <time.h>
37 #include <unistd.h>
38 #include "psb_buffer.h"
39 
40 /* #define VA_EMULATOR 1 */
41 
42 #ifdef DEBUG_TRACE
43 #ifndef ASSERT
44 #define ASSERT  assert
45 #endif
46 
47 #ifndef IMG_ASSERT
48 #define IMG_ASSERT  assert
49 #endif
50 
51 #else /* DEBUG_TRACE */
52 
53 #undef ASSERT
54 #undef IMG_ASSERT
55 #define ASSERT(x)
56 #define IMG_ASSERT(x)
57 
58 #endif /* DEBUG_TRACE */
59 
60 /****************************
61  * debug level structures
62  ****************************/
63 typedef enum
64 {
65     VIDEO_DEBUG_ERROR	    =   0x1,
66     VIDEO_DEBUG_WARNING	    =   0x2,
67     VIDEO_DEBUG_GENERAL	    =   0x4,
68     VIDEO_DEBUG_INIT        =   0x8,
69     VIDEO_DEBUG_ENTRY       =   0x10,
70     VIDEO_DECODE_DEBUG      =   0x100,
71     VIDEO_ENCODE_DEBUG      =   0x200,
72     VIDEO_DISPLAY_DEBUG     =   0x400,
73 
74     VIDEO_ENCODE_PDUMP     =   0x1000,
75     VIDEO_ENCODE_HEADER    =   0x2000,
76 } DEBUG_LEVEL;
77 
78 /****************************
79  * trace level structures
80  ****************************/
81 typedef enum
82 {
83     VABUF_TRACE		=   0x1,
84     CMDMSG_TRACE	=   0x2,
85     LLDMA_TRACE	    =   0x4,
86     AUXBUF_TRACE    =   0x8,
87 } TRACE_LEVEL;
88 
89 /****************************
90  * debug-trace option structures
91  ****************************/
92 typedef enum
93 {
94     TIME_DEBUG		=   0x1,
95     THREAD_DEBUG    =   0x2,
96     PRINT_TO_LOGCAT	=   0x10,
97     PRINT_TO_FILE   =   0x20,
98 } DEBUG_TRACE_OPTION;
99 
100 FILE *psb_video_debug_fp;
101 int  debug_fp_count;
102 int psb_video_debug_level;
103 int psb_video_debug_option;
104 
105 FILE *psb_video_trace_fp;
106 int psb_video_trace_level;
107 int psb_video_trace_option;
108 
109 FILE *psb_dump_vabuf_fp;
110 FILE *psb_dump_vabuf_verbose_fp;
111 FILE *psb_dump_yuvbuf_fp;
112 
113 int psb_video_dump_cmdbuf;
114 uint32_t g_hexdump_offset;
115 
116 void psb__debug_w(uint32_t val, char *fmt, uint32_t bit_to, uint32_t bit_from);
117 
118 #define DW(wd, sym, to, from) psb__debug_w(((uint32_t *)pasDmaList)[wd], "LLDMA: " #sym " = %d\n", to, from);
119 #define DWH(wd, sym, to, from) psb__debug_w(((uint32_t *)pasDmaList)[wd], "LLDMA: " #sym " = %08x\n", to, from);
120 
121 void psb__open_log(void);
122 void psb__close_log(void);
123 int psb_parse_config(char *env, char *env_value);
124 void drv_debug_msg(DEBUG_LEVEL debug_level, const char *msg, ...);
125 void psb__trace_message(const char *msg, ...);
126 
127 /*
128  * Dump contents of buffer object after command submission
129  */
130 void psb__debug_schedule_hexdump(const char *name, psb_buffer_p buf, uint32_t offset, uint32_t size);
131 void psb__hexdump(unsigned char *addr, int size);
132 
133 void debug_dump_cmdbuf(uint32_t *cmd_idx, uint32_t cmd_size_in_bytes);
134 
135 #define DEBUG_FAILURE           while(vaStatus) {drv_debug_msg(VIDEO_DEBUG_ERROR, "%s fails with '%d' at %s:%d\n", __FUNCTION__, vaStatus, __FILE__, __LINE__);break;}
136 #define DEBUG_FAILURE_RET       while(ret)      {drv_debug_msg(VIDEO_DEBUG_ERROR, "%s fails with '%s' at %s:%d\n", __FUNCTION__, strerror(ret < 0 ? -ret : ret), __FILE__, __LINE__);break;}
137 
138 #define DEBUG_FUNC_ENTER while(1) {drv_debug_msg(VIDEO_DEBUG_ENTRY, "%s enter.\n", __FUNCTION__); break;}
139 #define DEBUG_FUNC_EXIT while(1) {drv_debug_msg(VIDEO_DEBUG_ENTRY, "%s exit.\n", __FUNCTION__); break;}
140 
141 uint32_t debug_cmd_start[MAX_CMD_COUNT];
142 uint32_t debug_cmd_size[MAX_CMD_COUNT];
143 uint32_t debug_cmd_count;
144 uint32_t debug_lldma_count;
145 uint32_t debug_lldma_start;
146 
147 #define MAX_DUMP_COUNT  20
148 const char * debug_dump_name[MAX_DUMP_COUNT];
149 psb_buffer_p debug_dump_buf[MAX_DUMP_COUNT];
150 uint32_t     debug_dump_offset[MAX_DUMP_COUNT];
151 uint32_t     debug_dump_size[MAX_DUMP_COUNT];
152 uint32_t     debug_dump_count;
153 
154 int psb_cmdbuf_dump(unsigned int *buffer, int byte_size);
155 int psb__dump_va_buffers(object_buffer_p obj_buffer);
156 int psb__dump_va_buffers_verbose(object_buffer_p obj_buffer);
157 
158 #endif /* _PSB_DEBUG_H_ */
159