cli: add ability to set audio volume

If the user passes in a third argument to the 'audio' CLI command, use
it as an integer to set the audio level.

BRANCH=storm
BUG=none
TEST=tried generating sounds using the CLI on storm, observed proper
     volume control.

Change-Id: I236d34405f20889275438e5fdc2381d6a7723b07
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/261078
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/src/debug/cli/audio.c b/src/debug/cli/audio.c
index 88b7dfa..8e20a1e 100644
--- a/src/debug/cli/audio.c
+++ b/src/debug/cli/audio.c
@@ -38,6 +38,13 @@
 		duration = MAX_DURATION_MS;
 	}
 
+	if (argc > 3) {
+		uint32_t volume = (uint32_t) strtoul(argv[3], 0, 10);
+
+		printf("Setting volume to %d\n", volume);
+		sound_set_volume(volume);
+	}
+
 	res = sound_start(freq);
 	if (!res) {
 		/* Nonblocking API must be used. */
@@ -65,8 +72,9 @@
 }
 
 U_BOOT_CMD(
-	   audio,	3,	1,
+	   audio,	4,	1,
 	   "rudimentary audio capabilities test",
-	   "<freq> <duration>  - play sound of <freq> Hz "
-	   "for <duration> milliseconds"
+	   "\n<freq> <duration> [<volume>]  - play sound of <freq> Hz for "
+	   "<duration>\n"
+	   "                                milliseconds at volume <volume>"
 );