aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChangoh Heo <changoh.heo@samsung.com>2011-07-26 16:01:55 -0700
committerSimon Wilson <simonwilson@google.com>2011-08-09 11:01:58 -0700
commitdf8ae90855392812518bb9da233a0fefc21d5297 (patch)
tree9a83df76b3bd3d299bca12cd1fd5bb954ae33426
parent7de3eaf3508c0c4104da12f5c6caa6147101ac1b (diff)
tinymix: print mixer values when no mixer control is specified
Change-Id: Ia7a34033262316e2b8034782af5f59e013dd77f3
-rw-r--r--tinymix.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/tinymix.c b/tinymix.c
index 3fc2e41..3b778e1 100644
--- a/tinymix.c
+++ b/tinymix.c
@@ -32,9 +32,11 @@
#include <ctype.h>
static void tinymix_list_controls(struct mixer *mixer);
-static void tinymix_detail_control(struct mixer *mixer, unsigned int id);
+static void tinymix_detail_control(struct mixer *mixer, unsigned int id,
+ int print_all);
static void tinymix_set_value(struct mixer *mixer, unsigned int id,
char *value);
+static void tinymix_print_enum(struct mixer_ctl *ctl, int print_all);
int main(int argc, char **argv)
{
@@ -49,7 +51,7 @@ int main(int argc, char **argv)
if (argc == 1)
tinymix_list_controls(mixer);
else if (argc == 2)
- tinymix_detail_control(mixer, atoi(argv[1]));
+ tinymix_detail_control(mixer, atoi(argv[1]), 1);
else if (argc == 3)
tinymix_set_value(mixer, atoi(argv[1]), argv[2]);
else
@@ -72,19 +74,19 @@ static void tinymix_list_controls(struct mixer *mixer)
printf("Number of controls: %d\n", num_ctls);
- printf("ctl\ttype\tnum\tname\n");
+ printf("ctl\ttype\tnum\t%-40s value\n", "name");
for (i = 0; i < num_ctls; i++) {
ctl = mixer_get_ctl(mixer, i);
mixer_ctl_get_name(ctl, buffer, sizeof(buffer));
type = mixer_ctl_get_type_string(ctl);
num_values = mixer_ctl_get_num_values(ctl);
-
- printf("%d\t%s\t%d\t%s\n", i, type, num_values, buffer);
+ printf("%d\t%s\t%d\t%-40s", i, type, num_values, buffer);
+ tinymix_detail_control(mixer, i, 0);
}
}
-static void tinymix_print_enum(struct mixer_ctl *ctl)
+static void tinymix_print_enum(struct mixer_ctl *ctl, int print_all)
{
unsigned int num_enums;
char buffer[256];
@@ -94,12 +96,16 @@ static void tinymix_print_enum(struct mixer_ctl *ctl)
for (i = 0; i < num_enums; i++) {
mixer_ctl_get_enum_string(ctl, i, buffer, sizeof(buffer));
- printf("\t%s%s", mixer_ctl_get_value(ctl, 0) == (int)i ? ">" : "",
- buffer);
+ if (print_all)
+ printf("\t%s%s", mixer_ctl_get_value(ctl, 0) == (int)i ? ">" : "",
+ buffer);
+ else if (mixer_ctl_get_value(ctl, 0) == (int)i)
+ printf(" %-s", buffer);
}
}
-static void tinymix_detail_control(struct mixer *mixer, unsigned int id)
+static void tinymix_detail_control(struct mixer *mixer, unsigned int id,
+ int print_all)
{
struct mixer_ctl *ctl;
enum mixer_ctl_type type;
@@ -119,7 +125,9 @@ static void tinymix_detail_control(struct mixer *mixer, unsigned int id)
type = mixer_ctl_get_type(ctl);
num_values = mixer_ctl_get_num_values(ctl);
- printf("%s:", buffer);
+ if (print_all)
+ printf("%s:", buffer);
+
for (i = 0; i < num_values; i++) {
switch (type)
{
@@ -130,17 +138,20 @@ static void tinymix_detail_control(struct mixer *mixer, unsigned int id)
printf(" %s", mixer_ctl_get_value(ctl, i) ? "On" : "Off");
break;
case MIXER_CTL_TYPE_ENUM:
- tinymix_print_enum(ctl);
+ tinymix_print_enum(ctl, print_all);
break;
default:
printf(" unknown");
break;
};
}
- if (type == MIXER_CTL_TYPE_INT) {
- min = mixer_ctl_get_range_min(ctl);
- max = mixer_ctl_get_range_max(ctl);
- printf(" (range %d->%d)", min, max);
+
+ if (print_all) {
+ if (type == MIXER_CTL_TYPE_INT) {
+ min = mixer_ctl_get_range_min(ctl);
+ max = mixer_ctl_get_range_max(ctl);
+ printf(" (range %d->%d)", min, max);
+ }
}
printf("\n");
}