From e40758bb09cfae53d11b6fa97844c903bbd252e8 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 7 Sep 2017 16:38:52 +0100 Subject: Fixup some minor code formatting issues Signed-off-by: Charles Keepax --- src/mixer.c | 2 +- utils/tinymix.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mixer.c b/src/mixer.c index d07797a..a9cc483 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -637,7 +637,7 @@ int mixer_ctl_get_array(const struct mixer_ctl *ctl, void *array, size_t count) void *source; size_t total_count; - if ((!ctl) || !count || !array) + if (!ctl || !count || !array) return -EINVAL; total_count = ctl->info.count; diff --git a/utils/tinymix.c b/utils/tinymix.c index 53b5285..beaab2a 100644 --- a/utils/tinymix.c +++ b/utils/tinymix.c @@ -168,7 +168,7 @@ static void tinymix_list_controls(struct mixer *mixer, int print_all) num_values = mixer_ctl_get_num_values(ctl); printf("%u\t%s\t%u\t%-40s", i, type, num_values, name); if (print_all) - tinymix_detail_control(mixer, name); + tinymix_detail_control(mixer, name); printf("\n"); } } @@ -265,7 +265,7 @@ static void tinymix_detail_control(struct mixer *mixer, const char *control) } static void tinymix_set_byte_ctl(struct mixer_ctl *ctl, - char **values, unsigned int num_values) + char **values, unsigned int num_values) { int ret; char *buf; -- cgit v1.2.3 From 9ed7df6bea6e996b7ff2e0d22898425f2ae0feee Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 7 Sep 2017 17:04:57 +0100 Subject: Pull mixer_ctl_get_value out of loop in tinymix_print_enum It is only required to obtain the value of the control once whilst processing tinymix_print_enum. This will significantly reduce the amount of IOCTLs sent for reading an enum control. Signed-off-by: Charles Keepax --- utils/tinymix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/tinymix.c b/utils/tinymix.c index beaab2a..834766b 100644 --- a/utils/tinymix.c +++ b/utils/tinymix.c @@ -177,14 +177,15 @@ static void tinymix_print_enum(struct mixer_ctl *ctl) { unsigned int num_enums; unsigned int i; + unsigned int value; const char *string; num_enums = mixer_ctl_get_num_enums(ctl); + value = mixer_ctl_get_value(ctl, 0); for (i = 0; i < num_enums; i++) { string = mixer_ctl_get_enum_string(ctl, i); - printf("%s%s", mixer_ctl_get_value(ctl, 0) == (int)i ? ", " : "", - string); + printf("%s%s", value == i ? ", " : "", string); } } -- cgit v1.2.3 From f8f7ef29b2095621263c748efd7570091d8dcc51 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Fri, 8 Sep 2017 16:58:20 +0100 Subject: Update output format for enumerated controls The current format of the data printed for enumeration controls is to list all the control values with no separator between them and to place a comma before the currently selected value. This format is hard to parse as a human and very difficult to parse automatically. Change this to separate individual values with a comma and mark the selected value with a right angle bracket. For example, the following output is given for the "AEC Loopback" control on one of our CODECs: HPOUT1LHPOUT1R, SPKOUTSPKDATLSPKDATR After the change this becomes: HPOUT1L, HPOUT1R, > SPKOUT, SPKDATL, SPKDATR, Signed-off-by: Charles Keepax --- utils/tinymix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/tinymix.c b/utils/tinymix.c index 834766b..ff019cd 100644 --- a/utils/tinymix.c +++ b/utils/tinymix.c @@ -185,7 +185,7 @@ static void tinymix_print_enum(struct mixer_ctl *ctl) for (i = 0; i < num_enums; i++) { string = mixer_ctl_get_enum_string(ctl, i); - printf("%s%s", value == i ? ", " : "", string); + printf("%s%s, ", value == i ? "> " : "", string); } } -- cgit v1.2.3