gpu: pvr: fix locking on the HW recovery reset error path
[sgx.git] / pvr / pvr_debug.h
1 /**********************************************************************
2  *
3  * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful but, except
10  * as otherwise stated in writing, without any warranty; without even the
11  * implied warranty of merchantability or fitness for a particular purpose.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * The full GNU General Public License is included in this distribution in
19  * the file called "COPYING".
20  *
21  * Contact Information:
22  * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23  * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
24  *
25  ******************************************************************************/
26
27 #ifndef __PVR_DEBUG_H__
28 #define __PVR_DEBUG_H__
29
30 #include <linux/fs.h>
31
32 #include "img_types.h"
33
34 #define PVR_MAX_DEBUG_MESSAGE_LEN       512
35
36 #define DBGPRIV_FATAL                   0x01UL
37 #define DBGPRIV_ERROR                   0x02UL
38 #define DBGPRIV_WARNING                 0x04UL
39 #define DBGPRIV_MESSAGE                 0x08UL
40 #define DBGPRIV_VERBOSE                 0x10UL
41 #define DBGPRIV_CALLTRACE               0x20UL
42 #define DBGPRIV_ALLOC                   0x40UL
43 #define DBGPRIV_ALLLEVELS               (DBGPRIV_FATAL | DBGPRIV_ERROR |     \
44                                          DBGPRIV_WARNING | DBGPRIV_MESSAGE | \
45                                          DBGPRIV_VERBOSE)
46
47 #define PVR_DBG_FATAL                   DBGPRIV_FATAL
48 #define PVR_DBG_ERROR                   DBGPRIV_ERROR
49 #define PVR_DBG_WARNING                 DBGPRIV_WARNING
50 #define PVR_DBG_MESSAGE                 DBGPRIV_MESSAGE
51 #define PVR_DBG_VERBOSE                 DBGPRIV_VERBOSE
52 #define PVR_DBG_CALLTRACE               DBGPRIV_CALLTRACE
53 #define PVR_DBG_ALLOC                   DBGPRIV_ALLOC
54
55 #if defined(CONFIG_PVR_DEBUG)
56
57 #define PVR_ASSERT(EXPR)                                                     \
58         do {                                                                 \
59                 if (!(EXPR))                                                 \
60                         PVRSRVDebugAssertFail(__FILE__, __LINE__);           \
61         } while (0)
62
63 #define PVR_DPF(level, fmt, ...)                                             \
64         PVRSRVDebugPrintf(level, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
65
66 #define PVR_TRACE(fmt, ...)                                                  \
67         PVRSRVTrace(fmt, ##__VA_ARGS__)
68
69 void PVRSRVDebugAssertFail(const char *pszFile, u32 ui32Line);
70 void PVRSRVDebugPrintf(u32 ui32DebugLevel, const char *pszFileName,
71                        u32 ui32Line, const char *pszFormat, ...);
72 void PVRSRVTrace(const char *pszFormat, ...);
73
74 int PVRDebugProcSetLevel(struct file *file, const char __user *buffer,
75                          unsigned long count, void *data);
76 int PVRDebugProcGetLevel(char *page, char **start, off_t off, int count,
77                          int *eof, void *data);
78 void PVRDebugSetLevel(u32 uDebugLevel);
79
80 void pvr_dbg_init(void);
81 void pvr_dbg_cleanup(void);
82
83 #define PVR_DBG_BREAK
84
85 #else
86
87 #if defined(TIMING)
88
89 #define PVR_ASSERT(EXPR)                do { } while (0)
90 #define PVR_DPF(level, fmt, ...)        do { } while (0)
91 #define PVR_TRACE(fmt, ...)     \
92         PVRSRVTrace(fmt, ##__VA_ARGS__)
93 #define PVR_DBG_BREAK                   do { } while (0)
94
95 void PVRSRVTrace(const char *pszFormat, ...);
96
97 #else
98
99 #define PVR_ASSERT(EXPR)                do { } while (0)
100 #define PVR_DPF(level, fmt, ...)        do { } while (0)
101 #define PVR_TRACE(fmt, ...)             do { } while (0)
102 #define PVR_DBG_BREAK                   do { } while (0)
103
104 static inline void pvr_dbg_init(void) {};
105 static inline void pvr_dbg_cleanup(void) {};
106
107 #endif
108 #endif
109
110 #endif