autotest: audio_helper - Setup ALSA RMS tests with amixer.

Currently the ALSA RMS tests are setup using CRAS utils and that
creates an unwilling dependency.  The change uses ALSA utils to setup
the test and eliminate the depenedncy.  However, different
boards/chipsets use different set of mixer controls so there will
be different setup sequences for different boards.

BUG=chromium:474910
TEST=Run autotest on various devices in the LAB.

Change-Id: Ifcb81d11b159fb2da89c3d0673124d98bed0962f
Reviewed-on: https://chromium-review.googlesource.com/286500
Commit-Ready: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
diff --git a/client/cros/audio/alsa_utils.py b/client/cros/audio/alsa_utils.py
index 52c25b7..cdb25dc 100644
--- a/client/cros/audio/alsa_utils.py
+++ b/client/cros/audio/alsa_utils.py
@@ -217,3 +217,24 @@
     args += ['-D', device]
     args += [output]
     return args
+
+
+def mixer_cmd(card_id, cmd):
+    '''Executes amixer command.
+
+    @param card_id: Soundcard ID.
+    @param cmd: Amixer command to execute.
+    @raise RuntimeError: If failed to execute command.
+
+    Amixer command like "set PCM 2dB+" with card_id 1 will be executed as:
+        amixer -c 1 set PCM 2dB+
+
+    Command output will be returned if any.
+    '''
+
+    cmd = AMIXER_PATH + ' -c %d ' % card_id + cmd
+    p = cmd_utils.popen(shlex.split(cmd), stdout=cmd_utils.PIPE)
+    output, _ = p.communicate()
+    if p.wait() != 0:
+        raise RuntimeError('amixer command failed')
+    return output