xref: /linux/sound/pci/asihpi/hpidebug.c (revision 40818b6242513676c8adf30811fb7877b02005fb)
1719f82d3SEliot Blennerhassett /************************************************************************
2719f82d3SEliot Blennerhassett 
3719f82d3SEliot Blennerhassett     AudioScience HPI driver
4*40818b62SEliot Blennerhassett     Copyright (C) 1997-2011  AudioScience Inc. <support@audioscience.com>
5719f82d3SEliot Blennerhassett 
6719f82d3SEliot Blennerhassett     This program is free software; you can redistribute it and/or modify
7719f82d3SEliot Blennerhassett     it under the terms of version 2 of the GNU General Public License as
8719f82d3SEliot Blennerhassett     published by the Free Software Foundation;
9719f82d3SEliot Blennerhassett 
10719f82d3SEliot Blennerhassett     This program is distributed in the hope that it will be useful,
11719f82d3SEliot Blennerhassett     but WITHOUT ANY WARRANTY; without even the implied warranty of
12719f82d3SEliot Blennerhassett     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13719f82d3SEliot Blennerhassett     GNU General Public License for more details.
14719f82d3SEliot Blennerhassett 
15719f82d3SEliot Blennerhassett     You should have received a copy of the GNU General Public License
16719f82d3SEliot Blennerhassett     along with this program; if not, write to the Free Software
17719f82d3SEliot Blennerhassett     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18719f82d3SEliot Blennerhassett 
19719f82d3SEliot Blennerhassett Debug macro translation.
20719f82d3SEliot Blennerhassett 
21719f82d3SEliot Blennerhassett ************************************************************************/
22719f82d3SEliot Blennerhassett 
23719f82d3SEliot Blennerhassett #include "hpi_internal.h"
24719f82d3SEliot Blennerhassett #include "hpidebug.h"
25719f82d3SEliot Blennerhassett 
26719f82d3SEliot Blennerhassett /* Debug level; 0 quiet; 1 informative, 2 debug, 3 verbose debug.  */
27719f82d3SEliot Blennerhassett int hpi_debug_level = HPI_DEBUG_LEVEL_DEFAULT;
28719f82d3SEliot Blennerhassett 
29719f82d3SEliot Blennerhassett void hpi_debug_init(void)
30719f82d3SEliot Blennerhassett {
31719f82d3SEliot Blennerhassett 	printk(KERN_INFO "debug start\n");
32719f82d3SEliot Blennerhassett }
33719f82d3SEliot Blennerhassett 
34719f82d3SEliot Blennerhassett int hpi_debug_level_set(int level)
35719f82d3SEliot Blennerhassett {
36719f82d3SEliot Blennerhassett 	int old_level;
37719f82d3SEliot Blennerhassett 
38719f82d3SEliot Blennerhassett 	old_level = hpi_debug_level;
39719f82d3SEliot Blennerhassett 	hpi_debug_level = level;
40719f82d3SEliot Blennerhassett 	return old_level;
41719f82d3SEliot Blennerhassett }
42719f82d3SEliot Blennerhassett 
43719f82d3SEliot Blennerhassett int hpi_debug_level_get(void)
44719f82d3SEliot Blennerhassett {
45719f82d3SEliot Blennerhassett 	return hpi_debug_level;
46719f82d3SEliot Blennerhassett }
47719f82d3SEliot Blennerhassett 
48719f82d3SEliot Blennerhassett void hpi_debug_message(struct hpi_message *phm, char *sz_fileline)
49719f82d3SEliot Blennerhassett {
50719f82d3SEliot Blennerhassett 	if (phm) {
511528fbb5SEliot Blennerhassett 		printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version,
52f0dcad41SEliot Blennerhassett 			phm->adapter_index, phm->obj_index, phm->function,
53f0dcad41SEliot Blennerhassett 			phm->u.c.attribute);
54719f82d3SEliot Blennerhassett 	}
55719f82d3SEliot Blennerhassett 
56719f82d3SEliot Blennerhassett }
57719f82d3SEliot Blennerhassett 
58719f82d3SEliot Blennerhassett void hpi_debug_data(u16 *pdata, u32 len)
59719f82d3SEliot Blennerhassett {
60719f82d3SEliot Blennerhassett 	u32 i;
61719f82d3SEliot Blennerhassett 	int j;
62719f82d3SEliot Blennerhassett 	int k;
63719f82d3SEliot Blennerhassett 	int lines;
64719f82d3SEliot Blennerhassett 	int cols = 8;
65719f82d3SEliot Blennerhassett 
66719f82d3SEliot Blennerhassett 	lines = (len + cols - 1) / cols;
67719f82d3SEliot Blennerhassett 	if (lines > 8)
68719f82d3SEliot Blennerhassett 		lines = 8;
69719f82d3SEliot Blennerhassett 
70719f82d3SEliot Blennerhassett 	for (i = 0, j = 0; j < lines; j++) {
71719f82d3SEliot Blennerhassett 		printk(KERN_DEBUG "%p:", (pdata + i));
72719f82d3SEliot Blennerhassett 
73719f82d3SEliot Blennerhassett 		for (k = 0; k < cols && i < len; i++, k++)
74719f82d3SEliot Blennerhassett 			printk("%s%04x", k == 0 ? "" : " ", pdata[i]);
75719f82d3SEliot Blennerhassett 
76719f82d3SEliot Blennerhassett 		printk("\n");
77719f82d3SEliot Blennerhassett 	}
78719f82d3SEliot Blennerhassett }
79