Blaze: Adjust HP volume curve

Change Headphone max_volume to meet criteria.

BUG=chrome-os-partner:31161
TEST= measure volume dB by ODM

Signed-off-by: Benjamin Lu <benjaminl@nvidia.com>
Change-Id: Ic6c12e5167b9dce07a2076cc14594bf2d4f79cf1
Reviewed-on: https://chromium-review.googlesource.com/212230
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - Remove skip_mix flag

skip_mix flag is set only when shm is empty, and it wasn't
taking effect to skip any empty stream.  Before change d1b209c
cras_mix_add_stream() doesn't mix a stream if there's zero
frames in shm, but that logic no longer exists.
Clean up this flag and check the shm frames before mixing.

BUG=None
TEST=play youtube and drum machine webapp, execute 'cras_test_client
--playback_file -' at the same time, verify audio not drop.

Change-Id: Icf2562e668e7f28b22d009ce2e34bc5cc11b2803
Reviewed-on: https://chromium-review.googlesource.com/212270
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS: cras_iodev - Remove software_volume_scaler in cras_iodev

Removes software_volume_scaler in cras_iodev. The scaler will be looked
up when audio thread writes data to buffer in possibly_fill_audio.
By doing this we do not need to worry which the active node is when the
software_volume_scaler is set. The scaler will be determined by system
volume, active node volume and software_volume_needed flag.

BUG=chrome-os-partner:31101
TEST=make check
TEST=On nyan_big, connect to HDMI. Change volume to around 20%. Reboot.
Listen to HDMI audio and check volume is around 20%.

Change-Id: Idf2c414e87f9271cc7d46dd145d69774aa87391b
Reviewed-on: https://chromium-review.googlesource.com/212002
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
CRAS: iodev_list - select, rm, then select active dev should work

Fix the bug that when a device X is originally selected as active,
then removed from active list for any reason, select it back
will fail.

BUG=None
TEST=Call dbus-send with SetActiveOutputNode, RemoveActiveOutputNode
and then SetActiveOutputNode in order to the same node id, should
see the node selected as active by cras_test_client --dump_s

Change-Id: Ia6b5538f5ab68e774e8f1546d294dd546b686456
Reviewed-on: https://chromium-review.googlesource.com/212473
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS: unittest - write two streams one empty one full

Add test case to cover that when writing two streams, if
one stream becomes empty for some reason, it should be skipped
and proceed write the streams which have samples.

BUG=None
TEST=make check

Change-Id: If4960b63245cd79940e5e832d94220d9f3deb9a9
Reviewed-on: https://chromium-review.googlesource.com/212289
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Revert "CRAS: unittest - write two streams one empty one full"

This reverts commit c3722294fb9d1775839d753e53c563512847d512.

This unittest was added to test that when two streams added,
should skip mix the empty stream.  This turns out wrong and cause
problem on two output streams of different cb_threshold, the correct
solution is to skip write an empty stream only when it's empty after
fetch. Correct unittest will be added in later change.

BUG=chromium:404885
TEST=make check

Change-Id: I34542cf9c96426719829bd3a12d65eee3b0726b4
Reviewed-on: https://chromium-review.googlesource.com/213043
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Revert "CRAS: audio_thread - Remove skip_mix flag"

This reverts commit 3b9e7e54a4615c82d98f65021fb520df57d5ac66.

skip_mix flag was removed and replace by checking shm frames == zero
to fix bad client bug.  However this is causing a more severe problem
on two output streams of different cb_threshold, revert this commit
since keeping the skip_mix flag still looks like the best way to handle
these cases.

BUG=chromium:404885
TEST=Play html5 video and open local wav file.

Change-Id: Id262af7ac5e81d2363df1adc4dc35ecbd0156c79
Reviewed-on: https://chromium-review.googlesource.com/213044
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
CRAS: audio_thread - Don't mix stream with skip_mix = 1

When two output streams are added and one is held by a bad client
that never fills audio to shm, we should skip mixing it so that
the other streams won't be affected.

Note that this doesn't solve the bad client problem completely, but
makes the other streams have a much better quality.

BUG=chromium:404885
TEST=Play youtube and at the same time execute 'cras_test_client
--playback_file -'

Change-Id: Id3dc4c87f3c68c283406f69bf76f7350849a4f22
Reviewed-on: https://chromium-review.googlesource.com/213045
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Expresso: add eq and volume tuning

BUG=none
TEST=`emerge-expresso adhd` verify files are present

Change-Id: I4ba29c90bbc8603d6b206b473aa60f1fb64b895b
Signed-off-by: Pan Sheng-Liang <Sheng-Liang.Pan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/212235
Tested-by: Lucas Chen <lucas.chen@quantatw.com>
Reviewed-by: Yung Leem <yungleem@chromium.org>
Tested-by: David Wu <david_wu@quantatw.com>
Commit-Queue: David Wu <david_wu@quantatw.com>
CRAS: Remove min_cb_level.

min_db_level hasn't been used in a very long time, for input it is
totally ignored for output it was always set to cb_threshold anyways.

BUg=none
TEST=make check, and play audio on Blaze

Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: Fill stream_attached message with a pointer.

Pass a pointer to an audio format instead of copying the format.

BUG=none
TEST=make check

Change-Id: Ie1bcaa127b177566622b52aba9d2768e31a3e034
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: rclient - Rename remote format variable.

No functional change, just rename the variable from mfmt to
remote_format.  This variable holds the unpacked format from the
remote client.  Using this name will make the code more legible when
doing server-side format conversion.

BUG=none
TEST=none

Change-Id: I8c32311a19be126f1a3145c888e623a1bba3c40b
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: rstream - Remove unused flags variable.

After three years we haven't found a use for flags, remove it.

BUG=none
TEST=make check

Change-Id: I4a3e7af0c23a27d5fedac8f3a21bd5d7aa6580da
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: rstream - re-order struct

To keep the input/output shm variables together, put the format and
list members at the bottom.  Add a comment describing the members.

BUG=none
TEST=none

Change-Id: If2ea9d1cff4b8dc7bec45aee0dd3b0beb453ac6b
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - Add stream list for each device.

In later changes this list will be used instead of a thread-wide list
to track attached streams.

Change-Id: I07aed4dea9d6037c0d2ed0f03f3365adbc4d571e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - Keep list of attached streams per device.

Instead of keeping a list of attached streams in the audio thread
struct, keep a list per device.  This will allow for different streams
to be routed to different or multiple devices in later commits.

Change-Id: I7d3d8437c96f3496375864575c36dab0b7c45c81
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: mix - Re-order the checks in mix_add_stream.

Re-order the check for mute to be within the while loop.  This will
make mixing streams that require SRC on the server side simpler in a
later change.

Change-Id: I1b2ea5e542cfdec0e562e31cd70bd17276feb745
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - remove fd from io stream

The fd parameter was just used as a cache.  Remove that and instead
get it from the stream when needed.  This is done so that
cras_io_stream can have per-stream details removed.  Eventually
cras_io_stream will be used for a stream to device mapping, and the
same stream could be held by multiple devices.

BUG=none
TEST=unittest

Change-Id: I9f82d3af07c6f29270d3273105213cd652b1ce10
CRAS: fmt_conv - Move creation from client to fmt_conv.

Move the code that configures the format converter from cras_client
into the format conversion core.  This will allow for the server side
to reuse the same set up code when the SRC is added to it.

BUG=none
TEST=unittests, play two different formats of audio.

Change-Id: Ie0277ae66666ba70ae2c2cea7b067b3378f3da3e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - use mix_mute_buffer helper.

Replace meset with cras_mux_mute_buffer.  No functional change.

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