diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-01-21 18:26:56 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-01-21 18:26:56 +0100 |
commit | c0b225903e493ff30632bc7917beeaafc3c35b57 (patch) | |
tree | 07fe483f089007faaa6922413bd6ec82b760b053 | |
parent | 11d6dd6851a7c18b549530834947d5db4bf93749 (diff) | |
download | hda-emu-c0b225903e493ff30632bc7917beeaafc3c35b57.tar.gz |
Add -m option to route command for showing mute flags
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | hda-ctlsh.c | 5 | ||||
-rw-r--r-- | hda-emu.c | 52 | ||||
-rw-r--r-- | include/hda-types.h | 1 |
4 files changed, 55 insertions, 7 deletions
@@ -294,6 +294,10 @@ BASIC COMMANDS is passed, shows only the routes starting from the given NID. As default, both routes are shown. + The option -m makes the mute flag appearing in the routes. When + an input or an output amp is muted, the letter '|' appears in the + path. + * pm Simulate suspend/resume cycle. diff --git a/hda-ctlsh.c b/hda-ctlsh.c index 9093b07..5cb1875 100644 --- a/hda-ctlsh.c +++ b/hda-ctlsh.c @@ -467,6 +467,9 @@ static void show_routes(char *line) flags &= ~SHOW_DIR_IN; flags |= SHOW_DIR_OUT; break; + case 'm': + flags |= SHOW_MUTE; + break; default: hda_log(HDA_LOG_ERR, "Invalid route option\n"); usage("route"); @@ -835,7 +838,7 @@ static struct usage_table usage_str[] = { "Issue an unsolicited event", issue_unsol }, { "route", "route [-opts] numid", - "Show routes via the given widget; -a = show all, -x = show inactive pins too, -i|-o = set direction", + "Show routes via the given widget; -a = show all, -x = show inactive pins too, -i|-o = set direction, -m = show mute flags", show_routes }, { "option", "option variable [val]", "Get/set module option value", @@ -893,13 +893,51 @@ static const char *get_node_type_string(struct xhda_node *node) return names[type] ? names[type] : "\?\?\?"; } -static void show_route_lists(struct xhda_route_list *list) +static int get_muted(unsigned char *amp, unsigned int wcaps) +{ + if (wcaps & AC_WCAP_STEREO) + return (amp[0] & amp[1]) & 0x80; + else + return amp[0] & 0x80; +} + +static void show_route_lists(struct xhda_route_list *list, unsigned flags) { int i; + int show_mute = !!(flags & SHOW_MUTE); + for (; list; list = list->next) { hda_nid_t prev_nid = 0; for (i = 0; i < list->num_nodes; i++) { struct xhda_node *node = list->node[i]; + int in_mute = 0, out_mute = 0; + int idx = 0; + + if (i > 0) { + for (idx = 0; idx < node->num_nodes; idx++) { + if (node->node[idx] == prev_nid) + break; + } + if (idx >= node->num_nodes) + idx = 0; + } + + if (node->wcaps & AC_WCAP_IN_AMP) + in_mute = get_muted(&node->amp_in_vals.vals[idx][0], + node->wcaps); + if (node->wcaps & AC_WCAP_OUT_AMP) + out_mute = get_muted(&node->amp_out_vals.vals[0][0], + node->wcaps); + if (node_type(node) == AC_WID_PIN) { + if (!i) { + out_mute = in_mute; + in_mute = false; + } else { + in_mute = out_mute; + out_mute = false; + } + } + if (i > 0) { const char *path; if (node_type(node) == AC_WID_AUD_MIX) @@ -908,10 +946,12 @@ static void show_route_lists(struct xhda_route_list *list) path = " -> "; else path = " -x "; - hda_log(HDA_LOG_INFO, "%s", path); + hda_log(HDA_LOG_INFO, "%s%s", path, + show_mute ? (in_mute ? "|" : " ") : ""); } - hda_log(HDA_LOG_INFO, "%s[%02x]", - get_node_type_string(node), node->nid); + hda_log(HDA_LOG_INFO, "%s[%02x]%s", + get_node_type_string(node), node->nid, + show_mute ? (out_mute ? "|" : " ") : ""); prev_nid = node->nid; } hda_log(HDA_LOG_INFO, "\n"); @@ -925,7 +965,7 @@ void hda_show_routes(int nid, unsigned flags) if (flags & SHOW_DIR_IN) { list = hda_routes_connected_to(&proc, nid, flags); - show_route_lists(list); + show_route_lists(list, flags); had_list = list != NULL; hda_free_route_lists(list); } @@ -934,7 +974,7 @@ void hda_show_routes(int nid, unsigned flags) list = hda_routes_connected_from(&proc, nid, flags); if (list && had_list) hda_log(HDA_LOG_INFO, "\n"); - show_route_lists(list); + show_route_lists(list, flags); hda_free_route_lists(list); } } diff --git a/include/hda-types.h b/include/hda-types.h index 3754bca..325b223 100644 --- a/include/hda-types.h +++ b/include/hda-types.h @@ -143,6 +143,7 @@ void hda_free_route_lists(struct xhda_route_list *list); #define SHOW_DIR_OUT (1 << 1) #define SHOW_INACTIVE (1 << 2) #define SHOW_ALL (1 << 3) +#define SHOW_MUTE (1 << 4) void hda_show_routes(int nid, unsigned int flags); |