blob: bcd3bda64523886a9bbf496cdc64dbc69bffa1b5 [file] [log] [blame]
Dhanalakshmi Siddani01e94a32020-02-04 22:16:05 +05301/*
2 * Copyright (C) 2014 NXP Semiconductors, All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 */
9
10#ifndef _DBGPRINT_H
11# define _DBGPRINT_H
12
13/* Debugging macro's. */
14# ifndef DEBUG
15# define DEBUG
16# endif
17
18# ifndef ASSERT
19//#define ASSERT
20# endif
21 //TODO wwwim
22# ifndef _ASSERT
23 #define _ASSERT(e)
24# endif
25
26# ifndef PREFIX
27# define PREFIX "tfa98xx: "
28# define DRIVER_NAME "tfa98xx"
29# endif
30
31#ifdef __KERNEL__
32
33# ifdef DEBUG
34# define _DEBUG(level, fmt, va...) do {\
35 if (unlikely(debug >= (level))) \
36 printk(KERN_INFO PREFIX "%s:%d: "fmt,\
37 __func__, __LINE__, ##va); \
38 } while (0);
39
40# else
41# define _DEBUG(level, fmt, va...) do {} while (0)
42# endif
43
44# define MSG(fmt, va...) printk(KERN_INFO PREFIX "%s:%d: "fmt,\
45 __func__, __LINE__, ##va)
46# define _ERRORMSG(fmt, va...) printk(KERN_ERR PREFIX "ERROR %s:%d: "fmt,\
47 __func__, __LINE__, ##va)
48
49
50# define DEBUG0(x...) MSG(x)
51# define DEBUG1(x...) _DEBUG(1, x)
52# define DEBUG2(x...) _DEBUG(2, x)
53# define DEBUG3(x...) _DEBUG(3, x)
54# define ERRORMSG(x...) _ERRORMSG(x)
55# define PRINT(x...) printk(x)
56# define PRINT_ERROR(x...) printk(KERN_INFO PREFIX " **ERROR** " x)
57# define PRINT_ASSERT(e) if (e) printk(KERN_ERR\
58 "PrintAssert:%s (%s:%d) error code:%d\n",\
59 __FUNCTION__, __FILE__, __LINE__, e)
60
61# define PRINT_ENTRY DEBUG2("+[%s]\n", __func__)
62# define PRINT_EXIT DEBUG2("-[%s]\n", __func__)
63
64# ifdef ASSERT
65# define assert(cond, action) do {\
66 if (unlikely(!(cond))) {
67 DEBUG0("Assert:\
68 %s\n", #cond); action; } } \
69 while (0)
70# else
71# define assert(cond, action) do { } while (0)
72# endif
73
74#else /* __KERNEL__ */
75#if defined(WIN32) || defined(_X64)
76#include <stdio.h>
77/* user mode */
78# ifdef DEBUG
79# define _DEBUGMSG(level, fmt, ...) printf(PREFIX "%s:%d: "fmt,\
80 __FUNCTION__, __LINE__, __VA_ARGS__)
81# else
82# define _DEBUGMSG(level, fmt, ...) do {} while (0)
83# endif
84
85# define _ERRORMSG(fmt, ...) printf(PREFIX "%s:%s:%d: "fmt, __FILE__,\
86 __FUNCTION__, __LINE__, __VA_ARGS__)
87
88# define DEBUG0(...) MSG(__VA_ARGS__)
89# define DEBUG1(...) _DEBUGMSG(1, __VA_ARGS__)
90# define DEBUG2(...) _DEBUGMSG(2, __VA_ARGS__)
91# define DEBUG3(...) _DEBUGMSG(3, __VA_ARGS__)
92# define ERRORMSG(fmt, ...) _ERRORMSG(fmt, __VA_ARGS__)
93# define PRINT(...) printf(__VA_ARGS__)
94/*
95# define PRINT(...) { FILE *stream; \
96 if((stream = freopen("nxp_tfa.txt", "ab+", stdout)) == NULL) exit(-1);\
97 printf(__VA_ARGS__); \
98 freopen( "CON", "ab+", stdout ); \
99 }
100*/
101# define PRINT_ERROR(...) fprintf(stderr, __VA_ARGS__)
102# define PRINT_FILE(file, ...) fprintf(file, __VA_ARGS__)
103# define PRINT_ASSERT(e) {\
104 if ((e))\
105 fprintf(stderr, "PrintAssert:%s (%s:%d)\
106 error code:%d\n", __FUNCTION__,\
107 __FILE__, __LINE__, e)\
108 }
109//# define PRINT_ASSERT(e) if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d) %s\n",__FUNCTION__,__FILE__,__LINE__, Tfa98xx_GetErrorString(e))
110
111#elif defined(__CODE_RED)
112#include "app_global.h"
113# ifdef DEBUG
114# define _DEBUG(level, fmt, va...) TB_TRACE_INF(TbTracePfx2("tfa",\
115 TB_FUNC, va))
116//printf(PREFIX "%s:%d: "fmt,__func__,__LINE__,##va);
117# else
118# define _DEBUG(level, fmt, va...) do {} while (0)
119# endif
120
121# define MSG(fmt, ...) TB_TRACE_INF(TbTracePfx2("tfa", TB_FUNC, __VA_ARGS__))
122//printf(PREFIX "%s:%s:%d: "fmt,__FILE__,__func__,__LINE__,##va)
123//TB_TRACE_INF(TbTracePfx2(APP_PFX,TB_FUNC,"path=%s, chan=%u, muted=%s, vol=%d\n",
124// path->isRecording ? "recording" : "playback",
125// i,
126// channelVol.currentMuteValue ? "YES" : "NO",
127// channelVol.currentVolumeValue
128// ));
129//# define _ERRORMSG(fmt,va...) TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,va))
130# define ERRORMSG(...) TB_TRACE_INF(TbTracePfx2("tfa", TB_FUNC, __VA_ARGS__))
131//fprintf(stderr, PREFIX "ERROR %s:%s:%d: "fmt,__FILE__,__func__,__LINE__, ##va)
132
133#define DEBUG0(x...) MSG(x)
134#define DEBUG1(x...) _DEBUG(1, x)
135#define DEBUG2(x...) _DEBUG(2, x)
136#define DEBUG3(x...) _DEBUG(3, x)
137//# define ERRORMSG(x...) _ERRORMSG(x)
138#define PRINT(x...) TB_TRACE_INF(TbTracePfx2("tfa", TB_FUNC, x))
139//printf(x)
140#define PRINT_ERROR(x...) TB_TRACE_INF(TbTracePfx2("tfa", TB_FUNC, x))
141//fprintf(stderr,__VA_ARGS__)
142#define PRINT_FILE(file, x...) TB_TRACE_INF(TbTracePfx2("tfa", TB_FUNC, x))
143//fprintf(file,__VA_ARGS__)
144#define PRINT_ASSERT(e)
145//TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,Tfa98xx_GetErrorString(e)))
146//if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d) %s\n",__FUNCTION__,__FILE__,__LINE__, Tfa98xx_GetErrorString(e))
147#else
148#include <stdio.h>
149/* user mode */
150# ifdef DEBUG
151# define _DEBUG(level, fmt, va...) printf(PREFIX "%s:%d: "fmt, __func__,\
152 __LINE__, ##va);
153# else
154# define _DEBUG(level, fmt, va...) do {} while (0)
155# endif
156
157# define MSG(fmt, va...) printf(PREFIX "%s:%s:%d: "fmt, __FILE__, __func__,\
158 __LINE__, ##va)
159# define _ERRORMSG(fmt, va...) fprintf(stderr, PREFIX "ERROR %s:%s:%d: "fmt,\
160 __FILE__, __func__, __LINE__, ##va)
161
162#define DEBUG0(x...) MSG(x)
163#define DEBUG1(x...) _DEBUG(1, x)
164#define DEBUG2(x...) _DEBUG(2, x)
165#define DEBUG3(x...) _DEBUG(3, x)
166#define ERRORMSG(x...) _ERRORMSG(x)
167#define PRINT(x...) printf(x)
168#define PRINT_ERROR(...) fprintf(stderr, __VA_ARGS__)
169#define PRINT_FILE(file, ...) fprintf(file, __VA_ARGS__)
170#define PRINT_ASSERT(e)if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d)\
171 error code:%d\n", __FUNCTION__, __FILE__, __LINE__, e)
172//# define PRINT_ASSERT(e) if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d) %s\n", __FUNCTION__, __FILE__, __LINE__, Tfa98xx_GetErrorString(e))
173
174
175#endif /* WIN32 */
176
177#endif /* user */
178
179#endif /* _DBGPRINT_H --------------- */