1 /*********************************************************************
2 * debug.c - dsp patch manager library - debug functions
4 * Copyright (C) 2000 Rui Sousa
5 *********************************************************************
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
20 *********************************************************************
25 #include "../emu10k1-include/dsp.h"
26 #include "../emu10k1-include/list.h"
27 #include "../emu10k1-include/internal.h"
28 #include <sys/soundcard.h>
30 const char gpr_types
[6][10]={
39 extern char dsp_in_name
[DSP_NUM_INPUTS
][DSP_LINE_NAME_SIZE
];
40 extern char dsp_out_name
[DSP_NUM_OUTPUTS
][DSP_LINE_NAME_SIZE
] ;
42 extern char *oss_mixer_name
[SOUND_MIXER_NRDEVICES
];
43 extern char dsp_in_name
[DSP_NUM_INPUTS
][DSP_LINE_NAME_SIZE
];
44 extern char dsp_out_name
[DSP_NUM_OUTPUTS
][DSP_LINE_NAME_SIZE
];
45 int get_control_gpr_info(struct dsp_patch_manager
*mgr
, const char *patch_name
, const char *gpr_name
,
50 addr
= find_control_gpr_addr(mgr
, patch_name
, gpr_name
);
54 memcpy(gpr
, &mgr
->gpr
[addr
- GPR_BASE
], sizeof(struct dsp_gpr
));
59 static void print_patch_control_gprs(struct dsp_patch_manager
*mgr
, __u32
* used
)
63 for (i
= 0; i
< DSP_NUM_GPRS
; i
++)
64 if (mgr
->gpr
[i
].type
== GPR_TYPE_CONTROL
&& test_bit(i
, used
)) {
65 printf(" name: %s\n", mgr
->gpr
[i
].name
);
66 printf(" addr: %#04x\n", mgr
->gpr
[i
].addr
);
67 if (mgr
->gpr
[i
].mixer_id
< SOUND_MIXER_NRDEVICES
)
68 printf(" mixer: %s_%c\n", oss_mixer_name
[mgr
->gpr
[i
].mixer_id
],
69 mgr
->gpr
[i
].mixer_ch
? 'r': 'l');
71 printf(" value: %#010x (%#010x - %#010x)\n\n", mgr
->gpr
[i
].value
,
72 mgr
->gpr
[i
].min_val
, mgr
->gpr
[i
].max_val
);
77 int dsp_print_control_gprs_patch( struct dsp_patch_manager
*mgr
, const char *patch_name
)
79 struct dsp_patch
*patch
=NULL
;
81 if( dsp_find_patch(mgr
, patch_name
,&patch
) < 0)
83 printf("Control GPR's:\n");
85 printf(" Patch: %s %d\n", patch
->name
, patch
->id
);
87 printf(" Patch: %s\n", patch
->name
);
89 print_patch_control_gprs(mgr
, patch
->gpr_used
);
93 void dsp_print_control_gpr_list(struct dsp_patch_manager
*mgr
)
95 struct dsp_rpatch
*rpatch
;
96 struct dsp_patch
*patch
;
97 struct list_head
*entry
;
102 printf("Control GPR's:\n");
105 list_for_each(entry
, &mgr
->ipatch_list
) {
106 patch
= list_entry(entry
, struct dsp_patch
, list
);
108 printf(" Patch: %s %d\n", patch
->name
, patch
->id
);
110 printf(" Patch: %s\n", patch
->name
);
111 print_patch_control_gprs(mgr
, patch
->gpr_used
);
114 rpatch
= &mgr
->rpatch
;
115 printf(" Patch: %s\n", rpatch
->name
);
116 print_patch_control_gprs(mgr
, rpatch
->gpr_used
);
119 list_for_each(entry
, &mgr
->opatch_list
) {
120 patch
= list_entry(entry
, struct dsp_patch
, list
);
122 printf(" Patch: %s %d\n", patch
->name
, patch
->id
);
124 printf(" Patch: %s\n", patch
->name
);
126 print_patch_control_gprs(mgr
, patch
->gpr_used
);
130 void dsp_print_route_list(struct dsp_patch_manager
*mgr
)
132 struct dsp_rpatch
*rpatch
;
138 rpatch
= &mgr
->rpatch
;
140 printf("\n Routes:\n");
142 for (j
= 0; j
< DSP_NUM_INPUTS
; j
++)
143 for (i
= 0; i
< DSP_NUM_OUTPUTS
; i
++)
144 if (test_bit(j
, &rpatch
->route
[i
]))
145 printf(" %s:%s\n", dsp_in_name
[j
], dsp_out_name
[i
]);
146 else if (test_bit(j
, &rpatch
->route_v
[i
]))
147 printf(" %s:%s (with volume control)\n", dsp_in_name
[j
], dsp_out_name
[i
]);
151 void print_patch_code(__u32
* code
, __u32 start
, __u32 size
)
155 printf("\n code:\n");
156 printf(" start: %#05x\n size: %#05x\n", start
, size
);
157 for (i
= 0; i
< size
/ 2; i
++) {
159 (" %#05x %#010x %#010x %2d %#05x %#05x %#05x %#05x\n",
160 DSP_CODE_BASE
+ start
+ 2 * i
, code
[i
* 2 + 1],
161 code
[i
* 2], (code
[i
* 2 + 1] >> 20) & 0xf,
162 (code
[i
* 2 + 1] >> 10) & 0x3ff, code
[i
* 2 + 1] & 0x3ff,
163 (code
[i
* 2] >> 10) & 0x3ff, code
[i
* 2] & 0x3ff);
167 void print_patch_gprs(struct dsp_patch_manager
*mgr
, __u32
* used
, __u32
* input
, int io
)
172 for (i
= 0; i
< DSP_NUM_GPRS
; i
++)
173 if (test_bit(i
, used
)) {
175 printf(" addr: %#05x", GPR_BASE
+ i
);
176 printf(" usage: %#04x", mgr
->gpr
[i
].usage
);
177 printf(" type: %s", gpr_types
[mgr
->gpr
[i
].type
]);
179 if (mgr
->gpr
[i
].type
== GPR_TYPE_CONTROL
) {
180 printf("\n name: %-24s", mgr
->gpr
[i
].name
);
181 if (mgr
->gpr
[i
].mixer_id
< SOUND_MIXER_NRDEVICES
)
182 printf(" mixer: %s_%c", oss_mixer_name
[mgr
->gpr
[i
].mixer_id
],
183 mgr
->gpr
[i
].mixer_ch
? 'r': 'l');
184 printf("\n range: %#010x - %#010x", mgr
->gpr
[i
].min_val
, mgr
->gpr
[i
].max_val
);
188 if (mgr
->gpr
[i
].type
== GPR_TYPE_IO
) {
189 if (test_bit(i
, input
))
194 printf(" line: %s", dsp_in_name
[mgr
->gpr
[i
].line
] );
196 printf(" line: %s", dsp_out_name
[mgr
->gpr
[i
].line
] );
200 if (mgr
->gpr
[i
].type
== GPR_TYPE_CONTROL
||
201 mgr
->gpr
[i
].type
== GPR_TYPE_STATIC
|| mgr
->gpr
[i
].type
== GPR_TYPE_CONSTANT
)
202 printf(" value: %#010x", mgr
->gpr
[i
].value
);
208 void print_patch_tram(struct dsp_patch_manager
*mgr
, struct dsp_patch
*patch
)
212 if (patch
->tramb_isize
|| patch
->tramb_esize
|| patch
->traml_isize
|| patch
->traml_esize
)
213 printf("\n tram:\n");
215 if (patch
->tramb_isize
|| patch
->tramb_esize
)
216 printf(" blocks:\n");
218 if (patch
->tramb_isize
)
219 printf(" internal: %#07x - %#07x\n", patch
->tramb_istart
,
220 patch
->tramb_istart
+ patch
->tramb_isize
);
222 if (patch
->tramb_esize
)
223 printf(" external: %#07x - %#07x\n", patch
->tramb_estart
,
224 patch
->tramb_estart
+ patch
->tramb_esize
);
226 if (patch
->traml_isize
|| patch
->traml_esize
)
229 if (patch
->traml_isize
) {
230 printf(" data internal: %#05x - %#05x\n",
231 TRAML_IDATA_BASE
+ patch
->traml_istart
,
232 TRAML_IDATA_BASE
+ patch
->traml_istart
+ patch
->traml_isize
- 1);
234 printf(" address internal: %#05x - %#05x\n",
235 TRAML_IADDR_BASE
+ patch
->traml_istart
,
236 TRAML_IADDR_BASE
+ patch
->traml_istart
+ patch
->traml_isize
- 1);
238 for (i
= 0; i
< patch
->traml_isize
; i
++)
239 printf(" %#05x %#06x type: %s Align bit: %s\n",
240 TRAML_IADDR_BASE
+ patch
->traml_istart
+ i
,
241 patch
->traml_iaddr
[i
] & 0xfffff,
242 (patch
->traml_iaddr
[i
]& TANKMEMADDRREG_READ
)?"Read, ":"Write,",
243 (patch
->traml_iaddr
[i
]& TANKMEMADDRREG_ALIGN
)?"1":"0");
246 if (patch
->traml_esize
) {
247 printf(" data external: %#05x - %#05x\n",
248 TRAML_EDATA_BASE
+ patch
->traml_estart
,
249 TRAML_EDATA_BASE
+ patch
->traml_estart
+ patch
->traml_esize
- 1);
251 printf(" address external: %#05x - %#05x\n",
252 TRAML_EADDR_BASE
+ patch
->traml_estart
,
253 TRAML_EADDR_BASE
+ patch
->traml_estart
+ patch
->traml_esize
- 1);
255 for (i
= 0; i
< patch
->traml_esize
; i
++)
256 printf(" %#05x %#07x type: %s Align bit:%s \n",
257 TRAML_EADDR_BASE
+ patch
->traml_estart
+ i
,
258 patch
->traml_eaddr
[i
] & 0xfffff,
259 (patch
->traml_eaddr
[i
]& TANKMEMADDRREG_READ
)?"Read, ":"Write,",
260 (patch
->traml_eaddr
[i
]& TANKMEMADDRREG_ALIGN
)?"1":"0");
264 void print_in_patch(struct dsp_patch_manager
*mgr
, struct dsp_patch
*patch
)
267 printf("\n Name: %s", patch
->name
);
269 printf(" %d", patch
->id
);
272 //printf(" input line :");
274 for( i
=0;i
<DSP_NUM_INPUTS
;i
++)
275 if(test_bit(i
,&patch
->input
))
276 printf(" \"%s\" ",dsp_in_name
[i
]);
278 //for now, this is useless
280 printf(" output line:");
281 for(i=0;i<DSP_NUM_OUTPUTS;i++)
282 if(test_bit(i,&patch->output))
283 printf(" \"%s\" ",dsp_in_name[i]);
287 print_patch_gprs(mgr
, patch
->gpr_used
, patch
->gpr_input
,1);
288 print_patch_code(patch
->code
, patch
->code_start
, patch
->code_size
);
289 print_patch_tram(mgr
, patch
);
292 void print_out_patch(struct dsp_patch_manager
*mgr
, struct dsp_patch
*patch
)
295 printf("\n Name: %s", patch
->name
);
297 printf(" %d", patch
->id
);
300 printf(" input line :");
301 for( i
=0;i
<DSP_NUM_INPUTS
;i
++)
302 if(test_bit(i
,&patch
->input
))
303 printf(" \"%s\" ",dsp_out_name
[i
]);
306 printf(" output line:");
307 for(i
=0;i
<DSP_NUM_OUTPUTS
;i
++)
308 if(test_bit(i
,&patch
->output
))
309 printf(" \"%s\" ",dsp_out_name
[i
]);
312 print_patch_gprs(mgr
, patch
->gpr_used
, patch
->gpr_input
,0);
313 print_patch_code(patch
->code
, patch
->code_start
, patch
->code_size
);
314 print_patch_tram(mgr
, patch
);
316 void print_summary(struct dsp_patch_manager
*mgr
)
319 int i
,j
=DSP_NUM_GPRS
,k
=-1;
321 for (i
= 0; i
< DSP_NUM_GPRS
; i
++) {
322 if (mgr
->gpr
[i
].type
== GPR_TYPE_NULL
)
331 GPRS: %d (last used is %d)
341 mgr
->code_free_start
/2, j
,k
,
342 mgr
->traml_ifree_start
, mgr
->tramb_ifree_start
,
343 mgr
->traml_efree_start
, mgr
->tramb_efree_start
);
346 void print_debug(struct dsp_patch_manager
*mgr
)
348 struct dsp_rpatch
*rpatch
;
349 struct dsp_patch
*patch
;
350 struct list_head
*entry
;
354 printf("\nInput patches:\n");
356 list_for_each(entry
, &mgr
->ipatch_list
) {
357 patch
= list_entry(entry
, struct dsp_patch
, list
);
358 print_in_patch(mgr
, patch
);
362 rpatch
= &mgr
->rpatch
;
364 printf("\nRouting patch:\n");
366 print_patch_gprs(mgr
, rpatch
->gpr_used
, rpatch
->gpr_input
,2);
367 dsp_print_route_list(mgr
);
368 print_patch_code(rpatch
->code
, rpatch
->code_start
, rpatch
->code_size
);
370 printf("\nOutput patches:\n");
372 list_for_each(entry
, &mgr
->opatch_list
) {
373 patch
= list_entry(entry
, struct dsp_patch
, list
);
374 print_out_patch(mgr
, patch
);
379 void dsp_print_patch_list(struct dsp_patch_manager
*mgr
)
381 struct dsp_patch
*patch
;
382 struct list_head
*entry
;
388 printf("Input patches Attached to:\n");
389 printf("------------- -----------\n");
390 if (!list_empty(&mgr
->ipatch_list
)) {
391 list_for_each(entry
, &mgr
->ipatch_list
) {
392 patch
= list_entry(entry
, struct dsp_patch
, list
);
395 sprintf(tmp
," %d", patch
->id
);
396 printf("%s%s%n", patch
->name
,tmp
,&j
);
397 j
=DSP_PATCH_NAME_SIZE
- j
;
398 printf("%*s",j
, " " );
399 for(i
=0;i
<DSP_NUM_OUTPUTS
;i
++)
400 if(test_bit(i
,&patch
->output
))
401 printf("\"%s\" ",dsp_in_name
[i
]);
407 printf("\nOutput patches Attached to:\n");
408 printf("-------------- -----------\n");
409 if (!list_empty(&mgr
->opatch_list
)) {
410 list_for_each(entry
, &mgr
->opatch_list
) {
411 patch
= list_entry(entry
, struct dsp_patch
, list
);
414 sprintf(tmp
," %d", patch
->id
);
415 printf("%s%s%n", patch
->name
,tmp
,&j
);
416 j
=DSP_PATCH_NAME_SIZE
- j
;
417 printf("%*s",j
, " " );
419 for(i
=0;i
<DSP_NUM_OUTPUTS
;i
++)
420 if(test_bit(i
,&patch
->output
))
421 printf("\"%s\" ",dsp_out_name
[i
]);
427 void dsp_set_debug(struct dsp_patch_manager
*mgr
)
435 void dsp_print_oss_mixers(void)
439 printf("OSS Mixers:\n");
441 for (i
= 0; i
< SOUND_MIXER_NRDEVICES
; i
++)
442 printf(" %s\n", oss_mixer_name
[i
]);