factory-default: Update Link aound.state for new driver.

BUG=chrome-os-partner:9260
TEST=Boot link with the new driver, listen to and record audio.

Change-Id: I9e559ab1c0cd3eb5427fab277cea5e572fad92e1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: alsa mixer: match substrings of output names.

Use strstr instead of strcmp so that the name "Headphone" matches "Front
Headphone Jack".

BUG=none.
TEST=run on link check that headphone volume control works.
Signed-off-by: Dylan Reid <dgreid@chromium.org>

Change-Id: I32359995b8a9665c5ae806d5974f99dc9a2067d5
Add volume curves for stout and butterfly.

Volume control did not work correctly on stout and butterfly due to dB
scale mismatch. These volume curves are based on the stumpy volume
curve, but scaled to stout + butterfly dB scale.

BUG=chrome-os-partner:10515
TEST=Adjust volume slider on butterfly + stout platforms, verified that
audio does not become muted early and that volume scale is reasonable on
both speaker and headphone jack.

Change-Id: Id6c7d27aac5afaec141933c7e9ad24ef61d93fc7
CRAS: alsa jack - fix device index lookup.

ARRAY_SIZE returns strlen+1 because of null so subtract that one.

BUG=none
TEST=alsa_jack_unittest

Change-Id: I07c9442dd6f2aaaf141ad59b8922787e019b9e2e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Merge "CRAS: alsa jack - fix device index lookup."
Merge "factory-default: Update Link aound.state for new driver."
Only do hardware setup when control device is available

Only do the device add and alsactl setup on startup when the control
device has been added. The way udev handles this is by posting both an
add and a change event when the device is being added, so we only want
to do this on the change event.

However, to make things complicated, if cras is started after the device is
available, i.e. if cras is restarted, then we will only see the add events.
The way this is handled is that udev will set a SOUND_INITALIZED=1 attribute
on the main card node for those cases, so we check for that in the add path
and if that's seen, then we do the device addition and hardware reset there.

This has been tested on daisy, and seems to remove the race where we sometimes
try to do the hardware reset before the control node is available.

Note that this changes system setup on all platforms a bit; ALSA devices will no
longer be registered until the corresponding control device has been registered
(and reported stable through the above method).

BUG=chrome-os-partner:10957
TEST=boot system, make sure audio works and make sure /var/log/messages has an entry for:
set_factory_default: init card '0' to factory default from the last boot.

Change-Id: I798a0f438d94a415979da8e92ef7c988bb510bee
Merge "CRAS: alsa mixer: match substrings of output names."
Merge "Only do hardware setup when control device is available"
CRAS: udev - add card device when it changes and SOUND_INITIALIZED is set.

Instead of waiting for a change event on ControlCN, wait for a change
event on cardN.  Make sure that when this change event happens that the
SOUND_INITIALIZED udev flag is set.
/lib/udev/rules.d/78-sound-card.rules ensures that this change event
happens with SOUND_INITIALIZED set to "1".

The change on the control node was happening on daisy but nowhere else,
causing sound not to work on all x86 platforms.

BUG=chromium-os:32424
TEST=reboot and play audio on lumpy and daisy.

Change-Id: If2e20ddb9acd21fe643ca8e58d567f19bcdbb932
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS:fix clang build.

One warning was preventing building cras with clang.

BUG=none
TEST=CC=clang USE=clang emerge-lumpy adhd

Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: remove redundant call to connect_wait.

Remove call to check_server_connected_wait() from thread_add_stream().
It is called just before invoking thread_add_stream() from
handle_command_message().

BUG=none.
TEST=run chrome against cras, play a few video files, make sure sound
works.

Change-Id: I142e3857b4c4814e55b35dd095410e0bbbc091c1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: Remove now unused function.

connect_wait() was used by GAVD, but no longer, so remove it.

BUG=none.
TEST=still compiles.

Change-Id: I8c286b30e74dc7061932b5554b64d2bcb8c142c2
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: alsaplug - Support S24_LE and S32_LE formats.

Add support for other PCM formats to the alsa plugin.  Remove that
stored value of bits per sample, it will be different for different
formats.

BUG=chrome-os-partner:9552
TEST='aplay PCM_32bit.wav'

Change-Id: I76df2407dee1df5a049299d93aa7e22a0b2bf829
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: alsa plug: relax hw params constraints.

No need to be so restrictive, all possible combinations of hw params
will work.  Reduce the restraints to just basic bounds checks for buffer
sizes.

BUG=chrome-os-partner:11272
TEST=aplay 441.wav, aplay 48k.wav, arecord -f cd, acrecord -f dat on
  both daisy and stumpy.

Change-Id: Ic8ef475c1894eb2343697f405145e5489eb8c1e3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: test_client - remove unused parameter.

Stream type was always set to default, remove it.

BUG=none.
TEST=none.

Change-Id: Idaf3d87b1f772b77f8f5c8dab5edfc64487de09f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: test_client - add --help.

Adds --help to list the possible arguments.

BUG=none.
TEST='cras_test_client --help'

Change-Id: I549ad82e59406b3077035151325aa494666c0f46
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: test_client - add --capture_gain argument.

Add argument to set capture gain for the system.  The argument is given
in dB*100, so 2500 = 25dB.

BUG=none
TEST='cras_test_client --capture_gain 2500'
'cras_test_client --dump_server_info'
check that gain is 25dB.

Change-Id: I72c1ee02a937bf988f83cbaf7889436736d72934
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: test_client - add return value checking

Adds checking the return value of open for playback files and capture files.

BUG=chromium-os:32549
TEST='cras_test_client --playback_file <file_name>'
When you do not have permissions to access the file

Change-Id: Ic98a83bcc0107ebdd996ad5fd08dff6c6d37f637
factory-default: Set Mic Capture volume for stumpy/lumpy.

Default to setting the Mic Capture gains to +20dB for stumpy and lumpy.
The main capture volume is adjusted by the AGC and can be used to
attenuate this, but it can't be used to gain more than 12dB.  Setting
these higher moves the default capture gain to a more useable range.

BUG=chromium-os:30670
TEST=desktopui_AudioVideoFeedback

Change-Id: Ie6f03852e63ab385802b6e0bc38f64ad1d0650d3
Signed-off-by: Dylan Reid <dgreid@chromium.org>