If both of AZALIA_DEBUG and AZALIA_DEBUG_DOT are defined,

a DOT file for Graphviz representing the widget structure
is printed.
This commit is contained in:
kent 2007-02-05 13:52:26 +00:00
parent cb2e7baf50
commit 5dd4ff1479
2 changed files with 85 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: azalia.c,v 1.42 2006/11/16 01:33:08 christos Exp $ */ /* $NetBSD: azalia.c,v 1.43 2007/02/05 13:52:26 kent Exp $ */
/*- /*-
* Copyright (c) 2005 The NetBSD Foundation, Inc. * Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -48,7 +48,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: azalia.c,v 1.42 2006/11/16 01:33:08 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: azalia.c,v 1.43 2007/02/05 13:52:26 kent Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/device.h> #include <sys/device.h>
@ -1101,6 +1101,87 @@ azalia_codec_init(codec_t *this)
if (err) if (err)
return err; return err;
} }
#if defined(AZALIA_DEBUG) && defined(AZALIA_DEBUG_DOT)
DPRINTF(("-------- Graphviz DOT starts\n"));
if (this->name == NULL) {
DPRINTF(("digraph \"0x%4.4x/0x%4.4x (rev. %u.%u)\" {\n",
id >> 16, id & 0xffff,
COP_RID_REVISION(rev), COP_RID_STEPPING(rev)));
} else {
DPRINTF(("digraph \"%s (rev. %u.%u)\" {\n", this->name,
COP_RID_REVISION(rev), COP_RID_STEPPING(rev)));
}
FOR_EACH_WIDGET(this, i) {
const widget_t *w;
int j;
w = &this->w[i];
switch (w->type) {
case COP_AWTYPE_AUDIO_OUTPUT:
DPRINTF((" %s [shape=box,style=filled,fillcolor=\""
"#88ff88\"];\n", w->name));
break;
case COP_AWTYPE_AUDIO_INPUT:
DPRINTF((" %s [shape=box,style=filled,fillcolor=\""
"#ff8888\"];\n", w->name));
break;
case COP_AWTYPE_AUDIO_MIXER:
DPRINTF((" %s [shape=invhouse];\n", w->name));
break;
case COP_AWTYPE_AUDIO_SELECTOR:
DPRINTF((" %s [shape=invtrapezium];\n", w->name));
break;
case COP_AWTYPE_PIN_COMPLEX:
DPRINTF((" %s [label=\"%s\\ndevice=%s\",style=filled",
w->name, w->name, pin_devices[w->d.pin.device]));
if (w->d.pin.cap & COP_PINCAP_OUTPUT &&
w->d.pin.cap & COP_PINCAP_INPUT)
DPRINTF((",shape=doublecircle,fillcolor=\""
"#ffff88\"];\n"));
else if (w->d.pin.cap & COP_PINCAP_OUTPUT)
DPRINTF((",shape=circle,fillcolor=\"#88ff88\"];\n"));
else
DPRINTF((",shape=circle,fillcolor=\"#ff8888\"];\n"));
break;
}
if ((w->widgetcap & COP_AWCAP_CONNLIST) == 0)
continue;
for (j = 0; j < w->nconnections; j++) {
int src = w->connections[j];
if (!VALID_WIDGET_NID(src, this))
continue;
DPRINTF((" %s -> %s [sametail=%s];\n",
this->w[src].name, w->name, this->w[src].name));
}
}
DPRINTF((" {rank=min;"));
FOR_EACH_WIDGET(this, i) {
const widget_t *w;
w = &this->w[i];
switch (w->type) {
case COP_AWTYPE_AUDIO_OUTPUT:
case COP_AWTYPE_AUDIO_INPUT:
DPRINTF((" %s;", w->name));
break;
}
}
DPRINTF(("}\n"));
DPRINTF((" {rank=max;"));
FOR_EACH_WIDGET(this, i) {
const widget_t *w;
w = &this->w[i];
switch (w->type) {
case COP_AWTYPE_PIN_COMPLEX:
DPRINTF((" %s;", w->name));
break;
}
}
DPRINTF(("}\n"));
DPRINTF(("}\n"));
DPRINTF(("-------- Graphviz DOT ends\n"));
#endif /* AZALIA_DEBUG && AZALIA_DEBUG_DOT */
err = this->init_dacgroup(this); err = this->init_dacgroup(this);
if (err) if (err)

View File

@ -1,4 +1,4 @@
/* $NetBSD: azalia.h,v 1.14 2006/07/21 14:40:12 kent Exp $ */ /* $NetBSD: azalia.h,v 1.15 2007/02/05 13:52:27 kent Exp $ */
/*- /*-
* Copyright (c) 2005 The NetBSD Foundation, Inc. * Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -470,6 +470,7 @@ typedef struct {
/* #define AZALIA_DEBUG */ /* #define AZALIA_DEBUG */
/* #define AZALIA_DEBUG_DOT */
#ifdef AZALIA_DEBUG #ifdef AZALIA_DEBUG
# define DPRINTF(x) do { printf x; } while (0/*CONSTCOND*/) # define DPRINTF(x) do { printf x; } while (0/*CONSTCOND*/)
#else #else