2 * File: drivers/video/omap_new/debug.c
4 * Debug support for the omapfb driver
6 * Copyright (C) 2004 Nokia Corporation
7 * Author: Imre Deak <imre.deak@nokia.com>
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.
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.
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.
24 #ifndef __OMAPFB_DEBUG_H
25 #define __OMAPFB_DEBUG_H
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
34 static int dbg_indent;
36 static char dbg_buf[DBG_BUF_SIZE];
37 static spinlock_t dbg_spinlock = SPIN_LOCK_UNLOCKED;
39 static inline void dbg_print(int level, const char *fmt, ...)
41 if (level <= OMAPFB_DBG) {
42 if (!MAX_DBG_MESSAGES || dbg_cnt < MAX_DBG_MESSAGES) {
47 spin_lock_irqsave(&dbg_spinlock, flags);
49 if (ind > MAX_DBG_INDENT_LEVEL)
50 ind = MAX_DBG_INDENT_LEVEL;
52 printk("%*s", ind * DBG_INDENT_SIZE, "");
54 vsnprintf(dbg_buf, sizeof(dbg_buf), fmt, args);
57 spin_unlock_irqrestore(&dbg_spinlock, flags);
62 #define DBGPRINT dbg_print
64 #define DBGENTER(level) do { \
65 dbg_print(level, "%s: Enter\n", __FUNCTION__); \
69 #define DBGLEAVE(level) do { \
71 dbg_print(level, "%s: Leave\n", __FUNCTION__); \
74 static inline void dump_dma_regs(int lch)
76 #define _R(x) __REG16(OMAP_DMA_##x(lch))
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));
95 #define DUMP_DMA_REGS(lch) dump_dma_regs(lch)
97 #else /* OMAPFB_DBG */
99 #define DBGPRINT(level, format, ...)
100 #define DBGENTER(level)
101 #define DBGLEAVE(level)
102 #define DUMP_DMA_REGS(lch)
104 #endif /* OMAPFB_DBG */
106 #endif /* __OMAPFB_DEBUG_H */