CRAS alsa_ucm: Make ucm config to speficy CaptureControl

Add CaptureControl to ucm config allows jacks to specify their
own capture gain control which is not in the general control
name list.

BUG=chromium-os:36309
TEST=make check; alsa_ucm_unittest;

Change-Id: I728ba93599585b8a6375d6e8e425ea6786561998
Reviewed-on: https://gerrit.chromium.org/gerrit/38728
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_jack: check CaptureControl for input ucm device

When a input jack is found with CaptureControl specified in
ucm config, looks up the mixer for the control name and set
to mixer_input of the jack.

BUG=chromium-os:36309
TEST=make check; alsa_jack_unittest;

Change-Id: I4784de0e409b05b2ebac0dd0de1c7bc824d5b6bf
Reviewed-on: https://gerrit.chromium.org/gerrit/38729
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_io: Use init_device_settings() to reset volume/capture gain

When iodev created or jack plugged/unplugged, we want playback
volume or capture gain to be reset. Use init_device_settings to
handle this task.

BUG=chromium-os:36309
TEST=None

Change-Id: I699c2626f997e45328a5b2d7db947a325c918090
Reviewed-on: https://gerrit.chromium.org/gerrit/38730
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_io: Add input node for input control of jack

At jack input plug event, updates the input node to hold the
active input mixer control specified in ucm config for the
jack.

BUG=chromium-os:36309
TEST=Manual, build and add debug message to test that when
jack plug/unplug happens, the input node changes accordingly.

Change-Id: I1779c548a40c9c3ce36282eaac301cece1d0e8ee
Reviewed-on: https://gerrit.chromium.org/gerrit/39079
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS alsa mixer: Extend cras_alsa_mixer_set_capture_dBFS

This change enables an additional capture control of the input
node to set capture gain to.  The additional capture control
is not specified in UCM config.

BUG=chromium-os:36309
TEST=Unit test, make check.

Change-Id: I04c99b0cafa9710d8dd155f6adf6b51500a05b59
Reviewed-on: https://gerrit.chromium.org/gerrit/39080
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
UCM config: change ucm config for Daisy

BUG=chromium-os:36309
TEST=Manual start hangout, ssh to Daisy and open alsamixer, can
see auto gain control changes 'MIC2' value.

Change-Id: Ie6e2ec5093468872e36da69b4dd5e2df131d0727
Reviewed-on: https://gerrit.chromium.org/gerrit/38731
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_mixer: Add mixer_input to get capture gain range

Consider the additional mixer input when getting capture
gain range.

BUG=chromium-os:36309
TEST=unittest. Manual test on daisy, when external mix is plugged
can see gtalk AGC chaging the 'MIC2' gain.

Change-Id: I02ffc7023288f5009ed4ebec80cab6d24b0a3825
Reviewed-on: https://gerrit.chromium.org/gerrit/39236
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS: Add array utility and unit tests.

We want to have an array which can grow in size because we don't know the
final size in advance. This is suitable for things where appending data is
needed but removing data is not needed. An example is parsing input files.

The advantage over linked list is that it uses less memory per element,
and it is faster to iterate over all elements.

BUG=chromium-os:36300
TEST=make check
Change-Id: I8b49d41e2bb3d601dba67b2871316af927825c28
Reviewed-on: https://gerrit.chromium.org/gerrit/38377
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: Add dumper utilities and unit tests.

A dumper is used to obtain human-readable text from a component for
debugging and informational purposes. The caller can pass different kinds
of dumpers to a component, and the text will go to different places.

Currently there are two dumpers, one goes to syslog and another goes to
a memory buffer.

BUG=chromium-os:36300
TEST=make check
Change-Id: Iee669e06b013517ca1c7f8ac69af4b5c081a051e
Reviewed-on: https://gerrit.chromium.org/gerrit/38378
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: DSP - Add expression parsing and evaluation functions and unit tests.

The expression facility will be used to determine whether a plugin needs
to be enabled. For example, if we have this line in the ini file for
the DRC plugin:

disable=(or disable_drc (equal? output_device "HDMI"))

then the plugin will be disabled when this expression is evaluated to
true (that is, when the variable "disable_drc" is true or the variable
"output_device" equals to "HDMI".

The expression syntax generally follows the syntax in the Scheme
programming language, but we only use a (very small) subset of it.

BUG=chromium-os:36300
TEST=make check
Change-Id: If57f4f0ba2863ef5ed2d7592d3563a6dd5bee05d
Reviewed-on: https://gerrit.chromium.org/gerrit/38379
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: DSP - Add dsp ini file parsing.

The ini file is a specification of input/output plugins and their connections.

BUG=chromium-os:36300
TEST=make check
Change-Id: I9d4c60ac3321cee052807d9c694dfbb55c402b86
Reviewed-on: https://gerrit.chromium.org/gerrit/38380
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: DSP - Add dsp modules.

A DSP module is an interface for a plugin implementation. Currently
there are two kinds of implementations: one is LADSPA modules (loaded
from a shared library), another is built-in modules (input/output
source/sink).

BUG=chromium-os:36300
TEST=make check
Change-Id: Ic282c65a2d47ddc43adaf14b41ad7b54cf306552
Reviewed-on: https://gerrit.chromium.org/gerrit/38382
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: DSP - Add dsp pipeline code.

A pipeline is a collection of dsp modules. The pipeline sends the audio
data through them for processing.

BUG=chromium-os:36300
TEST=make check
Change-Id: I5ef121ca6def235a88ac1cca68a22108e08f43da
Reviewed-on: https://gerrit.chromium.org/gerrit/38383
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: DSP - Add cras_dsp.c for dsp pipeline management.

It reads the specification from the ini file, creates and loads the
pipeline, and re-instantiate the pipelines when sampling rate changes.

BUG=chromium-os:36300
TEST=make check
Change-Id: If1ce5a941f90a4d24035dba0a685c4dadb0efd57
Reviewed-on: https://gerrit.chromium.org/gerrit/38384
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: Move cras_iodev_set_format() from cras_iodev_list.c to cras_iodev.c

We will allocate a dsp context in cras_iodev_set_format() in a later
change, and this change makes iodev_list have less dependency to test.

BUG=chromium-os:36300
TEST=make check
Change-Id: I1a45a3ea16a87bbb50006c10ddd1431ef4aa2276
Reviewed-on: https://gerrit.chromium.org/gerrit/39237
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: DSP - Apply dsp pipeline from alsa_io.

We apply input/output pipeline just after we finish other processing.

BUG=chromium-os:36300
TEST=make check. run on device and hear the difference.
Change-Id: I8108ea08e3fe1f9418e747200b2a6415edcc275d
Reviewed-on: https://gerrit.chromium.org/gerrit/38385
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: DSP - Add a command parameter to reload dsp configuration.

BUG=chromium-os:36300
TEST=modify dsp.ini and use cras_test_client --reload_dsp to reload it
Change-Id: I43a5286dae159aa8d3ea3b6bba0186393aee8750
Reviewed-on: https://gerrit.chromium.org/gerrit/38386
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
CRAS: D-Bus: use cras_tm

BUG=none
TEST=make check

Change-Id: I8023b524b22463cf5a74902d86280b338e9ce29f
Signed-off-by: Scott James Remnant <keybuk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39317
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CRAS: delay callback deletion until end of main loop

A callback function may remove multiple callback structures from the
linked list, including the next one in turn. To avoid use-after-free
bugs only flag a callback as deleted and cleanup later.

BUG=none
TEST=compiled, run and unit tests

Change-Id: I29b697206936f06e49f8e4e21fa5a3cb83148b1f
Signed-off-by: Scott James Remnant <keybuk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39315
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CRAS: D-Bus: thread-safety fixes for dbus tests

BUG=none
TEST=make check succeeds in loop for a day

Change-Id: Icdeab65cd3da7d33a315a3402547e14a14523553
Signed-off-by: Scott James Remnant <keybuk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39346
Reviewed-by: Dylan Reid <dgreid@chromium.org>