CRAS: jack - Check direction when looking for a value

This will allow the Mic and Headphone Jack to be the same in a future
commit.  This is needed for boards that use the new Watson headset
detect chip.

BUG=none
TEST=plug/unplug on Pinky with new headset changes merged.

Change-Id: I6f84e3140ffd6e0793d4a71edd040efe08d0ff5e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/229964
CRAS: jack - Look for headset jacks

Allow Headset combo jacks that report separate mic and headphone
events on the same input device.  This is needed to support Pinky and
Ryu with the 227e headset chip.

BUG=none
TEST=plug/unplug headset on Pinky.

Change-Id: Ibf464f52760047b35d5209439bd3beded5ff223f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/229965
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
veyron: Use Headset Jack.

After the ts3a227e headset detect chip is used, there will be one jack
that reports both the mic and headphone plug/unplug state.

Change-Id: Ic8a34ea9abebaaf5bd4cd9e3971ab7d23ce38c54
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/229966
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
CRAS: audio_thread - fix line too long.

Change-Id: I158a1dc9f41b1f9f89c5db095e52b1aa5841d55d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231567
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
Candy: Add candy dsp.ini

BUG=chrome-os-partner:31814
TEST=listen to music with the configuration in the system

Change-Id: Id5bf19589382d64c567da19e0bdd19f509312107
Reviewed-on: https://chromium-review.googlesource.com/231174
Reviewed-by: Yung Leem <yungleem@chromium.org>
Commit-Queue: Huki Huang <huki.huang@intel.com>
Tested-by: Huki Huang <huki.huang@intel.com>
CRAS: audio_thread_unittest - testing stream and device manipulation.

This testing suite verifies the basic handling of adding and removing
streams on multiple devices.  This is a base for adding tests for
pinned-streams API.

BUG=None
TEST=make && make check

Change-Id: I4aa311536911533237478ff63d6935377a254588
Reviewed-on: https://chromium-review.googlesource.com/229742
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
CRAS: rstream - Don't allow loopback streams

Loopback streams are broken.  They will be replaced by a new method
that doesn't involve a stream type next week.  Drop the streams
explicitly for now and return EINVAL.

BUG=chromium:435847
TEST=try to add loopback with test_client, nothing crashes.

Change-Id: I83589f5cd3390f4ee07eda7286e201a3ca957db1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231582
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
CRAS: dsp - Lower print for no enabled dsp.

This is very common, as only built in devices will have a dsp
configured.  Lower the priority to info so it doesn't appear in all
the logs.

Change-Id: I69c60e62737282bb7ff2d6630b124a1dd84903aa
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231568
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
CRAS: iodev - add buffer pointer to put buffer

Passing the buffer pointer back to iodev will allow the DSP
application to be moved here.

BUG=none
TEST=play/record audio on Panther and Samus

Change-Id: I69f5b6894e364bc89e06444e79bc016f0b722e2d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231569
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: move dsp application to cras_iodev.c

Applying the DSP from iodev will later allow for audio thread to not
worry if the audio format is changed during processing.

BUG=none
TEST=pla/record audio on Big and Samus.

Change-Id: I5eeafb9120757aec4595635d8b7a16183b7a8df1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231570
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: Move get_dsp_delay to cras_iodev.c

This will allow the audio_thread to be free of direct dsp access.

BUG=none
TEST=play audio on panther and samus

Change-Id: I47cd7ff5cff9038e570d9906c23ae363a6689212
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231571
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: Allow DSP pipeline to change number of channels.

Some new input processing, such as beamforming will reduce the number
of input channels.  Change the DSP pipeline to support this.

BUG=none
TEST=play/record audio on Panther.

Change-Id: I22b7f76aeb29ee314a2ca988336170434ef52ae1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231572
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: remove DSP stubs from audio_thread UT

The DSP code has been moved to iodev, not needed in the audio thread
unit test.

BUG=none
TEST=none

Change-Id: I9757371cdad50d279d3cc02d0c05ffcee8a1a1f2
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231573
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: Add external format to iodev.

This changes iodev to track the format visible to the audio thread
separately from the format the hardware is actually configured to.
This will allow for a DSP module top change the format for use cases
such as beam forming.

BUG=none
TEST=none

Change-Id: Iee1652976c695ecd06030df013a8723ac74f8e77
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231574
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: iodev - Allow DSP to modify number of channels.

When setting up the iodev format, if there is a DSP applied, check if
it wants to modify the number of channels when processing.  This
allows for use cases such as a beam former that takes in 2 or more
channels and produces mono output.

BUG=none
TEST=none

Change-Id: I3ea51a13c5bc63faecc0093dba09cc08d022fa89
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231575
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: iodev UT - add put_buffer tests

Change-Id: If2ec60419a8ae4a83266ec1f781967ff5af613d0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231683
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: audio_thread UT - Remove more unused functions.

These has been moved to iodev.

BUG=none
TEST=this is a test.

Change-Id: I3b463ffe413b664a152b6fd3a845cbe4812a740d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231713
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: Be more precise with frames_to_time.

This adds a variant of frames_to_time that accepts a double for the
sample rate.  doing this will provide more accurate times for each
sleep interval.

BUG=chromium:436251
TEST=capture with show_latency for a really long time.

Change-Id: I77f9b411f2e4401a27e44d0c7fb0463078e96b97
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231712
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Samus: disable the left speaker.

Since the left speaker will occasionally hiss, route both channels to
the right speaker.  This can be reverted once the left speaker hiss
issue is fixed.

BUG=none
TEST=play 5.1 channel audio, check only right speaker works, and that
headphones are unaffected.

Change-Id: I0c9f2d6f517f933edef52df2e78fcd5af0a4a2e1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231715
Reviewed-by: Ben Zhang <benzh@chromium.org>
CRAS: fmt_conv - don't restrict in and out to s16le

Allow both the input and output to be non-s16le.  This will be useful
when playing to hardware that only support 24 or 32 bit samples such
as many USB DACS.

BUG=none
TEST=added unit test

Change-Id: Ia6858345958ec2febc716beea56b47868b5706e3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232080
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>