]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/video/omap/debug.h
FB: OMAP: Add support for framebuffer
[linux-2.6-omap-h63xx.git] / drivers / video / omap / debug.h
1 /*
2  * File: drivers/video/omap_new/debug.c
3  *
4  * Debug support for the omapfb driver
5  *
6  * Copyright (C) 2004 Nokia Corporation
7  * Author: Imre Deak <imre.deak@nokia.com>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation; either version 2 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  */
23
24 #ifndef __OMAPFB_DEBUG_H
25 #define __OMAPFB_DEBUG_H
26
27 #ifdef OMAPFB_DBG
28
29 #define DBG_BUF_SIZE            2048
30 #define MAX_DBG_INDENT_LEVEL    5
31 #define DBG_INDENT_SIZE         3
32 #define MAX_DBG_MESSAGES        0
33
34 static int dbg_indent;
35 static int dbg_cnt;
36 static char dbg_buf[DBG_BUF_SIZE];
37 static spinlock_t dbg_spinlock = SPIN_LOCK_UNLOCKED;
38
39 static inline void dbg_print(int level, const char *fmt, ...)
40 {
41         if (level <= OMAPFB_DBG) {
42                 if (!MAX_DBG_MESSAGES || dbg_cnt < MAX_DBG_MESSAGES) {
43                         va_list args;
44                         int     ind = dbg_indent;
45                         unsigned long flags;
46
47                         spin_lock_irqsave(&dbg_spinlock, flags);
48                         dbg_cnt++;
49                         if (ind > MAX_DBG_INDENT_LEVEL)
50                                 ind = MAX_DBG_INDENT_LEVEL;
51
52                         printk("%*s", ind * DBG_INDENT_SIZE, "");
53                         va_start(args, fmt);
54                         vsnprintf(dbg_buf, sizeof(dbg_buf), fmt, args);
55                         printk(dbg_buf);
56                         va_end(args);
57                         spin_unlock_irqrestore(&dbg_spinlock, flags);
58                 }
59         }
60 }
61
62 #define DBGPRINT        dbg_print
63
64 #define DBGENTER(level) do { \
65                 dbg_print(level, "%s: Enter\n", __FUNCTION__); \
66                 dbg_indent++; \
67         } while (0)
68
69 #define DBGLEAVE(level) do { \
70                 dbg_indent--; \
71                 dbg_print(level, "%s: Leave\n", __FUNCTION__); \
72         } while (0)
73
74 static inline void dump_dma_regs(int lch)
75 {
76 #define _R(x) __REG16(OMAP_DMA_##x(lch))
77
78         dbg_print(4, "\nCSDP  :%#06x CCR      :%#06x CSSA_U  :%#06x "
79                     "\nCDSA_L:%#06x CDSA_U   :%#06x CEN     :%#06x "
80                     "\nCFN   :%#06x CSFI     :%#06x CSEI    :%#06x "
81                     "\nCSAC  :%#06x CICR     :%#06x CSR     :%04x "
82                     "\nCSSA_L:%#06x CDAC     :%#06x CDEI    :%#06x "
83                     "\nCDFI  :%#06x COLOR_L  :%#06x COLOR_U :%#06x "
84                     "\nCCR2  :%#06x CLNK_CTRL:%#06x LCH_CTRL:%#06x\n",
85                     _R(CSDP), _R(CCR), _R(CSSA_U),
86                     _R(CDSA_L), _R(CDSA_U), _R(CEN),
87                     _R(CFN), _R(CSFI), _R(CSEI),
88                     _R(CSAC), _R(CICR), 0, /* _R(CSR), */
89                     _R(CSSA_L), _R(CDAC), _R(CDEI),
90                     _R(CDFI), _R(COLOR_L), _R(COLOR_U),
91                     _R(CCR2), _R(CLNK_CTRL), _R(LCH_CTRL));
92 #undef _R
93 }
94
95 #define DUMP_DMA_REGS(lch) dump_dma_regs(lch)
96
97 #else   /* OMAPFB_DBG */
98
99 #define DBGPRINT(level, format, ...)
100 #define DBGENTER(level)
101 #define DBGLEAVE(level)
102 #define DUMP_DMA_REGS(lch)
103
104 #endif  /* OMAPFB_DBG */
105
106 #endif /* __OMAPFB_DEBUG_H */