CRAS: rclient_unittest - remove unused variable

This actually fixes the warning in the clang 3.5 that
'base class 'RClientMessagesSuite' has a flexible array member'
Removing that variable fixes this problem.

BUG=chromium:342495
TEST=FEATURES="test" emerge-lumpy adhd passes.

Change-Id: I024afedbe19b1fb4e561076d883b896ce57af8bb
Reviewed-on: https://chromium-review.googlesource.com/185750
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
CRAS: audio_thread - Output number of callback timeouts.

When printing audio thread info, include the number of callback
timeouts.  This will be zero for all input streams, and indicates how
many times an output missed its fill deadline.

BUG=none
TEST=cras_test_client --dump_a

Change-Id: Ia52bb756e75e739d14f69adc95c857b2c843f3bb
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/185662
CRAS: audio_thread - Only skip mixing a stream if it is empty.

Don't skip mixing a stream just because it times out.  If there are
still some samples, mix them.

BUG=none
TEST=play music, youtube, and pandora.

Change-Id: I34249f5d6b865b72a45f3678c1770cfacd32af29
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/185665
CRAS: Add a property disable_emphasis to disable emphasis/deemphasis

Emphasis/Deemphasis is going to be removed in Chrome. In order to
align the behavior of dsp and chrome, we need to enable
emphasis/deemphasis if user is using an old chrome version to
calibrate config files, and disable it if user is using a new chrome
version to calibrate config files.
This patch adds a property disable_emphasis to drc to disable
emphasis/deemphasis.

CQ-DEPEND=CL:186340
BUG=chromium:340870
TEST=1. Prepare a audio raw file sweeping from 10Hz to 22000Hz.
     2. Modify parameters in drc_test so three drc filters will clip
       audio that is larger than 0dB. Specifically, modify RATIO to
       999, KNEE and THRESHOLD to 0, POST_GAIN to 0. Also, add
       drc->emphasis_disabled = 1;
     3. run drc_test and check the waveform of output. The magnitude
       at high frequency remains roughly the same if
       drc->emphasis_disabled = 1. The magnitude at high frequency
       will be lowered if drc->emphasis_disabled = 0.

Change-Id: I98ff15a88fd198d0239fe1fa3f324eb0875642ba
Reviewed-on: https://chromium-review.googlesource.com/186073
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
CRAS: Modify dsp.ini config files which use [drc]

This patch adds a switch emphasis_disabled at input_4 port of [drc] in dsp.ini files
of boards that use drc.

CQ-DEPEND=CL:186073
BUG=chromium:340870
TEST=Check audio playback is normal on daisy_spring board.

Change-Id: Ibed84ca85115ab0d601bc65db7303e5d0ed08919
Reviewed-on: https://chromium-review.googlesource.com/186340
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Add ucm and cras config for daisy_skate

It still needs device specific tuning but it's a good start

BUG=chrome-os-partner:25737
TEST=AudioJack test

Change-Id: If353dbf8448204fa4a10ce500052e56acf70a2c3
Reviewed-on: https://chromium-review.googlesource.com/185810
Reviewed-by: Katie Roberts-Hoffman <katierh@chromium.org>
Commit-Queue: Katie Roberts-Hoffman <katierh@chromium.org>
Tested-by: Katie Roberts-Hoffman <katierh@chromium.org>
UCM config: Add UCM config for zako

Set two flags for Zako: NoCreateDefaultOutputNode
and NoCreateDefaultInputNode to '1'.
Note that UCM parser requires at least one section of device,
the empty 'Headphone' device is put for that reason.

BUG=chrome-os-partner:25066
TEST=manual on zako

Change-Id: I3fbe81b8b9f1d662b09b7f1eb9263d10551b7224
Original-Change-Id: I8edd62e35a95c185ab4fa66682024120ef911abe
Reviewed-on: https://chromium-review.googlesource.com/183340
Reviewed-by: Mohammed Habibulla <moch@google.com>
Commit-Queue: Gediminas Ramanauskas <gedis@chromium.org>
Tested-by: Gediminas Ramanauskas <gedis@chromium.org>
CRAS: audio_thread - move message definitions to c file

These aren't used outside of audio_thread.c.

BUG=none
TEST=still compiles.

Change-Id: I226ac57ca924d55f539b27a99df36ad5c586c17d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/186302
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: dump audio debug info from client.

Instead of dumping audio thread debug info to syslog, pass it back to
the client through shared memory.  The extra data in shared memory isn't
protected or synchronized, but only one client at a time should ever
access it.

Change-Id: Ie5864b1a3f82a079ed1182b119b05c86976aadda
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/187006
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
CRAS: audio_thread - Add an event log.

Log certain interesting events that happen in the audio thread, add this
log to audio debug info.  Change the test client to print this log when
dumping audio info.

Change-Id: I1b93cfd36731f2ee8b6700faba44fb36ead161e6
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/187007
CRAS: audio_thread - Handle EINTR when waiting for streams.

If there select call in interrupted, retry it.  If there is an error
other than EINTR, break out of the waiting loop.

BUG=none
TEST=none

Change-Id: I3762ee6dca039a24236222dd6cb7df2f3bef44d7
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/187008
scripts: Initial commit for audio_tuning scripts

Add conf2ini2.py script to handle config file to ini file conversion.
The config file obtained from calibration webpage
http://audio-tuning.appspot.com should be converted to dsp.ini file
using this script.

BUG=chrome-os-partner:25940
TEST=run conf2ini2.py on config file generated by
  http://audio-tuning.appspot.com

Change-Id: I747952643def774090855f4fe63f9b7b3997bdc7
Reviewed-on: https://chromium-review.googlesource.com/186864
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
UCM daisy_spring: Modify EDID path for kernel 3.8

The EDID path is different when switch from kernel
3.4 to 3.8. This is causing problem that when external
monitor hotplugged, CRAS looked at incorrect path
trying to determine if the external monitor supports
audio output. As a result, it never report HDMI output
plug event to chrome to show on UI.

BUG=chromium:338927
TEST=Plug external monitor to daisy_spring, verify the
HDMI audio device is listed in UI and audio could
output to it.

Change-Id: I98ceb6c7120a599bdd08c962931178ee59329da4
Reviewed-on: https://chromium-review.googlesource.com/187620
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_jack: Add error log when EDID read timeout

When EDID read timeout happens for whatever reason,
log it so we can spot this in feedback log.

BUG=chromium:338927
TEST=None

Change-Id: I186fcbd3aa478807577cf3bbb6290233d7cc89b9
Reviewed-on: https://chromium-review.googlesource.com/187621
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_jack: ELD controls for HDMI/DP jack

For HDMI/DP jack, check if there is a ELD control for it.
This ELD control will be used to retrieve the name of the
connected external monitor in later changes.

BUG=chrome-os-partner:25101
TEST=Unittest. Test on Peppy, manual add log to verify
that we got an ELD control for each HDMI/DP alsa device.

Change-Id: I700c993450049697faf731c949484080d0b6abf4
Reviewed-on: https://chromium-review.googlesource.com/187100
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_jack: Refactor/rename EDID timer and callback

This refactor modifies the callback functions used for EDID
timer.  check_jack_edid() function is extracted so now it's
independent from the timers and callbacs. The new look allows
better integration with a later change adding poll and read
ELD mixer control.

The edid timer/retries/delay_cb and gpio change callback
are renamed to a more general name, so that they can be
reused in later change. E.g. 'edid_' prefix changed to
'display_info_'

BUG=chrome-os-partner:25101
TEST=Build and run on daisy, make sure the HDMI jack behavior
does not break.

Change-Id: I37e94fe00717803ade9a64c82755def2473575ff
Reviewed-on: https://chromium-review.googlesource.com/187419
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_jack: Poll ELD control

When HDMI jack plug event happens, the corresponding
ELD buffer will be updated after a delay. Reuse existing
timer callback to poll whether it is ready for read.

BUG=chrome-os-partner:25101
TEST=Manual test on Peppy, add log to verify that when
HDMI hotplug, the plug/unplug status is reported in a
few tries(within the max number of retries).

Change-Id: I1f28808443fe7177fc4cb9d6aed19bd1952b2e2f
Reviewed-on: https://chromium-review.googlesource.com/187101
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
CRAS alsa_jack: Add method to get monitor name from ELD

When ELD buffer ready, read the external monitor name
and update to the corresponding node. If the monitor name
fails to read, or at the unplug event, fallback to use
jack name.

BUG=chrome-os-partner:25101
TEST=gmerge adhd; Test on Peppy, verify the external monitor
name is displayed in audio device UI, instead of the jack
name "HDMI/DP ..."

Change-Id: I64e716c5ebe88780fc1c647c8f3f2a252f871574
Reviewed-on: https://chromium-review.googlesource.com/187102
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
CRAS client: Make sure client thread is stopped before closing socket.

Call cras_client_stop from cras_client_destroy: This stops the client
thread before shutting down the server socket.

Otherwise the client thread may detect an error, and reconnect to the
server, which causes recv in shutdown_and_close_socket to block
forever.

BUG=chromium:347997
TEST=In crosh, run
'while true; do cras_test_client --dump_server_info; done': this must
not hang (this should work on any platform, but used to hang on
daisy/daisy_spring).

Change-Id: I88bdc05fddc07fb055602d47b1c8dea0cbfb816e
Reviewed-on: https://chromium-review.googlesource.com/188449
Commit-Queue: <nicolas@boichat.ch>
Reviewed-by: <nicolas@boichat.ch>
Tested-by: <nicolas@boichat.ch>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>