summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2016-11-19Fix adhd to build with latest llvm.Manoj Gupta
Fix clang error taking address of packed member 'update_count' of class or structure 'cras_server_state' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] BUG=chromium:665647 TEST=adhd now builds with clang Change-Id: Iebe113619a1b3ad59c189113ec4a53b9a5c430a2 Reviewed-on: https://chromium-review.googlesource.com/411960 Commit-Ready: Manoj Gupta <manojgupta@chromium.org> Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-16CRAS: iodev_list - remove unused functionsHsin-Yu Chao
BUG=None TEST=make check Change-Id: Ia1ee5da3faa215f0aad5f1df4025e3b9baad8409 Reviewed-on: https://chromium-review.googlesource.com/406207 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-10-26CRAS: Add --disable_profile option to control SDP profileYuji Sasaki
Google WiFi (Gale) is not capable to handle SCO audio stream due to HCI-UART limitation, so HSP/HFP had to be disabled. Command line option --disable_profile is added to cras executive, and option is given in cras.sh based on mosys platform name. BUG=chrome-os-partner:58573 TEST=Run on gale and sdptool browse, verify no HSP/HFP in SDP Signed-off-by: Yuji Sasaki <sasakiy@google.com> Change-Id: Icc2bc87ffaf6847608cd2793894c498f90fd9e46 Reviewed-on: https://chromium-review.googlesource.com/403111 Commit-Ready: Yuji Sasaki <sasakiy@chromium.org> Tested-by: Yuji Sasaki <sasakiy@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Yuji Sasaki <sasakiy@chromium.org>
2016-10-26CRAS: Support more stream types.Chinyue Chen
When a client opens a stream, CRAS can know from the stream type specified to configure audio hardware by using corresponding UCM config and apply DSP processing if needed. This is the very first step to support audio use cases in CRAS. BUG=chromium:643039 TEST=FEATURES="test" emerge-${BOARD} -v media-sound/adhd Change-Id: I998eb2fba0c3a92b0012940db36539c7865fd498 Reviewed-on: https://chromium-review.googlesource.com/398942 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-25CRAS: fix various warnings reported by valgrindHsin-Yu Chao
BUG=chromium:658162 TEST=emerge valgrind and deploy to DUT. On DUT do 'stop cras' and then 'valgrind /usr/bin/cras' and watch the output. Use cras_test_client to select input and output node, playback and record. Connect BT headset and test A2DP and HFP. Verify everthing above produces no valgrind warning. Change-Id: I8c1bd63f9b29427387dcac5388d5be129472e80c Reviewed-on: https://chromium-review.googlesource.com/401146 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-25CRAS: dsp_ini - Fix invalid memory accessHsin-Yu Chao
Using ARRAY_APPEND_ZERO could realloc the ini->plugins array inside insert_swap_lr_plugin() causing invalid access to old position of first sink. Example of valgrind output: ==24232== Invalid read of size 8 ==24232== at 0x139617: insert_swap_lr_plugin (cras_dsp_ini.c:280) ==24232== by 0x139617: cras_dsp_ini_create (cras_dsp_ini.c:351) ==24232== by 0x1385D3: cmd_reload_ini (cras_dsp.c:114) ==24232== by 0x110D99: main (cras.c:86) ==24232== Address 0x5711688 is 104 bytes inside a block of size 224 free'd ==24232== at 0x402C396: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==24232== by 0x1385D3: cmd_reload_ini (cras_dsp.c:114) ==24232== by 0x110D99: main (cras.c:86) ==24232== BUG=chromium:658162 TEST=Run cras with valgrind to verify no invalid memory access. Change-Id: Ib1eed807d84958aeec0a0fdb42eb5d855b9b272d Reviewed-on: https://chromium-review.googlesource.com/401145 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-24init: Remove logic for samusCheng-Yi Chiang
The config directory will be handled by get_device_config_dir installed from chromeos-bsp-samus. BUG=chromium:655546 TEST=on samus, check dsp can be loaded. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I0c47737e4e1996ffe4bacb31f28c149b2c33ba7d Reviewed-on: https://chromium-review.googlesource.com/398938 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-10-24CRAS: alsa_io - Enable ALSA implementation of no_stream opsCheng-Yi Chiang
ALSA no_stream ops can be enabled since we have verified that ALSA API related to snd_pcm_move and snd_pcm_forward run as expected. With no_stream ops, audio thread does not need to wake up periodically to fill zero when device is in free run state, that is, whole buffer is zero. The benefit is that the second stream can have delay as low as min_cb_level when devices resume normal run state. BUG=chromium:519942 TEST=make check. TEST=check speaker/headphone/USB headphone works on samus. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: Ibef58d1c43c1a8ff9ddcd25c99f6ff22be961064 Reviewed-on: https://chromium-review.googlesource.com/397138 Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-20CRAS: observer - Move suspend signal to observerHsin-Yu Chao
BUG=None TEST=Manual test playback audio across suspend/resume Change-Id: Id097287a5fbe99c2e60ab2865a673ad29dae7e44 Reviewed-on: https://chromium-review.googlesource.com/398690 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-10-20CRAS: iodev_list - Migrate to observer interfaceHsin-Yu Chao
Deprecates the old alert/callback interface of system_state changed event and move iodev_list to use the unified observer interface. This will make it easier for future changes to modify node volume changed API. BUG=None TEST=Manual test setting volume and mute still work. Change-Id: Ie3321661f031d25eef0e26a97c317dc5aeeb9217 Reviewed-on: https://chromium-review.googlesource.com/398689 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-10-20CRAS: dbus_control - Move to observer interfaceHsin-Yu Chao
This is a clean up CL to move dbus method/signal implementation to the unified observer interface. This makes it easier for future changes to modify node volume change API. BUG=None TEST=Manual test select audio node, set volume and mute still work. Change-Id: I28756e99a91316fc1ba67d8b1a690a8c42dab31a Reviewed-on: https://chromium-review.googlesource.com/398688 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-20CRAS: observer - Free removed observer clientHsin-Yu Chao
BUG=None TEST=None Change-Id: I507e2c1803a4e638b080ea6c2596afa1e3bd265e Reviewed-on: https://chromium-review.googlesource.com/398687 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-18CRAS: iodev_list - Accept stream connect when seeing -ENOENT errHsin-Yu Chao
If a stream connects while headset is being unplugged, there is a chance that open device got -ENOENT error and rejects the stream depend on the timing. CRAS should handle this type of error for non-pinned stream because connecting a new stream shouldn't be affected by the transient state of device switching. Fix this by checking the error code returned by init_device. The new stream will be attached to fallback device and move to a real device later when Chrome selects a valid audio node. BUG=chromium:627141 TEST=Use the script attached in the bug to emulate the unplug. Verify that input stream doesn't drop and successfully record sound. Change-Id: Ibb79d64ba8c2d6dd5e7c1dbf7cc20b3defb038c3 Reviewed-on: https://chromium-review.googlesource.com/400298 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-17CRAS client: Start stream audio thread before connectionJohn Muir
When the server sends the first data request to the client, it is important that the client is ready to respond instantly. This change ensures that this is the case by starting the stream's audio thread before the connection to the server has been established. If there is a problem with the server then the audio thread is stopped as per normal. BUG=None TEST=Unit tests updated. Audio playback works on new device. Audio playback and capture work on Samus. Change-Id: I0b1d96457d98601643da6516c0cf15ff2af351b1 Reviewed-on: https://chromium-review.googlesource.com/387135 Commit-Ready: John Muir <muirj@google.com> Tested-by: John Muir <muirj@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-17CRAS: Add files to .gitignore found during development.John Muir
Add a few files commonly found in the adhd directory or one of it's sub-directories during development (eg: after cros_workon_make --test adhd). BUG=None TEST=N/A Change-Id: I5ba43d9e56f0f25aefe30f1ca1bd7fed602abde0 Reviewed-on: https://chromium-review.googlesource.com/391050 Commit-Ready: John Muir <muirj@google.com> Tested-by: John Muir <muirj@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-13Revert "init: let minijail parent exit"Cheng-Yi Chiang
This reverts commit 2bfa009afc6a518121fbde9266e73a60f1edac02. The commit cause "start cras" "stop cras" "restart cras" stuck forever. BUG=chromium:655546 TEST="restart cras" runs fine. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: Id51ccd216cfb46c4ce3daaadc4456e568ef1c606 Reviewed-on: https://chromium-review.googlesource.com/397101 Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-10-13CRAS: iodev - Treat node volume zero as muteCheng-Yi Chiang
There are some device that does not have control to mute output. We should fill output buffer with zeros when adjusted node volume is zero. BUG=chrome-os-partner:57614 TEST=on board of interest in the issue, check output is muted when node volume is 0. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I3696bef89e0d5d25ff37ab945e37189b97c5c81c Reviewed-on: https://chromium-review.googlesource.com/397042 Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-10-13CRAS: linear_resampler - Add check in linear_resampler_createCheng-Yi Chiang
BUG=chromium:651171 TEST=on peach_pit, play youtube and vocaroo. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I0ab3286b44cadf44f8cf6e725a02487eb3143348 Reviewed-on: https://chromium-review.googlesource.com/397081 Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-10-13CRAS: dev_stream - Remove redundant converter checkCheng-Yi Chiang
After the commit 4da40ff CRAS: fmt_conv - Always create a format converter, There should always be converter in dev_stream. Remove the redundant check in dev_stream_create to avoid the misunderstanding that there might be no converter. BUG=chromium:651171 TEST=on peach_pit, play youtube and vocaroo Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I8c3d16ba392509a625e2494a318bde4b1454a870 Reviewed-on: https://chromium-review.googlesource.com/397080 Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-10-12CRAS: alsa_jack - Use different timeout for different type of jacks.Chinyue Chen
GPIO jack on some boards need long timeout for working correctly. However that affects HCTL jacks on some boards to wait too long. Use different timeout for each of them so both work happily. BUG=chromium:624819 TEST=Verified on big that HDMI node got selected soon after plugged in. Change-Id: Iebb7be897ed931d943233cf163bb61933b81eeb3 Reviewed-on: https://chromium-review.googlesource.com/394468 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-12init: let minijail parent exitMike Frysinger
We don't need minijail to monitor us when init can do it. BUG=None TEST=restarting cras doesn't leave minijail proc behind Change-Id: Iccc5f45e9dfa828eeb0f3c647bc018bae1fc8b67 Reviewed-on: https://chromium-review.googlesource.com/395786 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-11switch to /runMike Frysinger
While /var/run is normally a symlink to /run, switch to it directly in case the /var/run symlink gets corrupted. BUG=None TEST=precq is happy Change-Id: I51cff041cbdf613280dd8e2d2b67225615fc7fef Reviewed-on: https://chromium-review.googlesource.com/395709 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-11CRAS: iodev - Fix no stream playback state transitionHsin-Yu Chao
When the last output stream is removed, iodev transits to the NO_STREAM_RUN state if it was in NORMAL_RUN state. However this iodev may not started yet if the output stream was added and then removed right away. This bug causes failure for test audio_CrasOutputStress on Samus because its internal speaker open could take 150 ms long so that the 1st short life stream has destroyed already. And the incorrect state change causes the iodev never started, hence its buffer level accumulates to 65535. BUG=chromium:623868 TEST=test_that -b samus audio_CrasOutputStress should pass Change-Id: Iba282e1f09a3b611cd1d4c4021667fd91d8a2781 Reviewed-on: https://chromium-review.googlesource.com/394457 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-10CRAS: hfp - Use dummy timestamp for last buffer changeCheng-Yi Chiang
HFP device should use dummy timestamp for last buffer change, that is, use current time. HFP device does not consume or capture samples steadily, so it might happen that the timestamp for last buffer change was a long time ago, and it breaks how timestamp mechanism works for setting audio thread wake up time for device. The result is a busy waking loop in audio thread. We should use dummy timestamp like A2DP to avoid such problem. BUG=chrome-os-partner:57175 TEST=Use HSP on the board of interest in the issue. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I1489165dc134e058059b16b7346bffa0c135815f Reviewed-on: https://chromium-review.googlesource.com/394469 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: John Muir <muirj@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-10update OWNERSMike Frysinger
BUG=None TEST=None Change-Id: I5a01e5d0e3f85fe9d696bb26674746751a2e0202 Reviewed-on: https://chromium-review.googlesource.com/395687 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-05Revert "CRAS: alsa_jack: report jack status right away for hctl jack"Chinyue Chen
This reverts commit e8a04ef732f97405d91783ddfd3d64ca50ca16b1. The commit to report jack early does not work well on peppy after suspend/resume. BUG=chromium:651594 TEST=Test on peppy, play music, suspend/resume, plug external display and verify audio is working. Change-Id: I71d817cb2f7fc6e2581f534f4953b33ed635d2ab Reviewed-on: https://chromium-review.googlesource.com/393626 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
2016-10-01CRAS: file_wait - Use access() to check file existence.Chinyue Chen
The stat() call requires more permission and gets EACCES error when running under container. The simpler access() call provides the same functionality and works fine under container. BUG=b:31845554 TEST=Build audiohal and verify it connects to CRAS correctly. Change-Id: I3bdde8675b0b5c78ce9aed37f989db880a167210 Reviewed-on: https://chromium-review.googlesource.com/391431 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-01CRAS: libcras - Fix build errors on Android.Chinyue Chen
Add missing file, header, and definition for libcras to build cleanly. BUG=b:31845554 TEST=make under Android. Change-Id: I7cbd17503a260c78158868850be3ff49b2bd8c12 Reviewed-on: https://chromium-review.googlesource.com/391411 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-10-01CRAS: alsa_io - Check for set sample rate in UCMDylan Reid
If the UCM config specifies a sample rate, honor it. This is useful for devices where the sample rate must be limited beyond the limits from the driver. For example there can be valid rates for capture that make playback impossible. BUG=chrome-os-partner:57838 TEST=capture at 44100 and play at 48k on Kevin Change-Id: I8ab41eb4ad015d5b1163a16b617eacdeb31fe20e Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/389754 Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-10-01CRAS: alsa_io - Move supported format checkDylan Reid
The supported format check will need to be able to access UCM soon. Move it to after ucm is configured so that will be possible. BUG=chrome-os-partner:57838 TEST=alsa_io_unittest Change-Id: If41adfd2cba36da7a14c2254fc5df8ec636e3f11 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/389753 Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
2016-09-28CRAS: alsa_io - Use update_supported_formats from createDylan Reid
When creating a new device, use the update_supported_formats helper to remove some duplicate code. The update_supported_formats path will be modified in a later change and that should affect both users. BUG=chrome-os-partner:57838 TEST=alsa_io_unittest Change-Id: I5ec4875047ea1f59084112a2761cc80eb989f10b Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/389752
2016-09-27CRAS: ucm - Parse PlaybackRate and CaptureRateDylan Reid
Add the ability to parse these items from UCM. These will be used to limit the available Sample Rates on boards with complicated topologies that makes determining the rate programatically difficult. They are already used by PulseAudio for a similar purpose. BUG=chrome-os-partner:57838 TEST=updated unittest Change-Id: Id0cd18ee8f1f3f9ac182bf84b95de8f4197bb688 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/389751 Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-09-26CRAS: Set a default hotword model on iodev initBen Zhang
If a hotword device supports the en_us locale, then set it as the default model during iodev init. This helps avoid breaking audio on SKL when the hotword device is opened before any model is set. BUG=chrome-os-partner:48270 TEST=Verify en_us is set after boot on Chell Change-Id: I23532d0b119c6c0b8a5c0965ac7c08a2399b08c6 Signed-off-by: Ben Zhang <benzh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/388913 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-26CRAS: test_client: Show current hotword model nameBen Zhang
Add a column in cras_test_client --dump_server_info to show the selected hotword model name on any hotword node. BUG=chrome-os-partner:48270 TEST=Verify the correct model name is displayed on Chell after cras_test_client --set_hotword_model 7:0:en_us cras_test_client --set_hotword_model 7:0:en_gb Change-Id: Iabc4a6da31d90292ee0de48b54c19aac362bb434 Signed-off-by: Ben Zhang <benzh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/388912 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-26CRAS: dbus_control: Allow get/set hotword model via dbusBen Zhang
Similar to the cras_client interface, dbus method: GetNodes() returns a list of supported hotword models. SetHotwordModel() selects a hotword model. BUG=chrome-os-partner:48270 TEST=Verify Chrome HotwordService can get/set hotword models using CrasAudioHandler/CrasAudioClient with the added dbus messages. Verify Chrome receives the appropriate error code from SetHotwordModel dbus METHOD_RETURN when an invalid hotword model name is used. Change-Id: Ie1bdacbfa58f19908f2c98dfbc91e469396239a1 Signed-off-by: Ben Zhang <benzh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/388911 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-26CRAS: bt_device - Reset connected profiles when device is disconnectedCheng-Yi Chiang
On some devices, CRAS receives profile connected callback sooner than CRAS receives device connected message. This scenario might happens: 1. Device is added, but not connected yet. 2. CRAS receives profile connected callback, either from audio gateway for HSP/HFP, or endpoint for A2DP. 3. CRAS receives DBus message saying device is connected. We should not clear connected_profiles in 3 because they are valid. Instead, we should clear connected_profiles when device is disconnected and profiles are distroyed. BUG=chrome-os-partner:57226 TEST=Disconnect SX3868-3Y, reset SX3868-3Y, connected SX3868-3Y in the menu. Repeat the procedure for 10 times and they all work. TEST=Test HM1200, HM1100, IKBT74, Jabra Wireless, all work. Change-Id: Ie6ce1ddb5190823e5cfc5d8180f18fb0ce456177 Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/389113 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-26CRAS: bt_device: Start connection watcher after profile updateCheng-Yi Chiang
On some device, supported profiles do not present when device interface is first added. The connection watcher created for the first time will end up doing nothing because the supported profile is not updated yet. After several seconds, supported profile will be updated by property updates. We should start connection watcher to re-run the "try-to-connect-if-supported" sequence in connection watcher. BUG=chrome-os-partner:57226 TEST=connect with HM1200, IKBT74, HM1100, Jabra wireless headset all works. TEST=connect with SX3868-3Y, work most of the time, except for the issue where profile connected comes before device connected, which will be handled in the next CL. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: If21d265a939af968f5426583e35361abc6eb2eef Reviewed-on: https://chromium-review.googlesource.com/389112 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-26CRAS: dsp_ini: Add a swap_lr plugin before sink pluginCheng-Yi Chiang
Add a swap_lr plugin before sink plugin and handle the port changes. With this change, user does not need to change dsp.ini for left right swap function. BUG=chromium:645051 TEST=cras_test_client --swap_left_right 8:1:1 on samus and check left and right channel are swapped. There is no change in dsp ini file. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: Ifbb6823218d48bd87487d7d8f8d1b02a16bf9c8f Reviewed-on: https://chromium-review.googlesource.com/387588
2016-09-26CRAS: iodev - Add function to swap left and right channel using dspCheng-Yi Chiang
Add cras_iodev_dsp_set_swap_mode_for_node to swap left and right channel using dsp. It is used as the default implementation of set_swap_mode_for_node ops on alsa_io device. To use this function, there must be a swap_lr section in dsp.ini: [swap_lr] library=builtin label=swap_lr disable=swap_lr_disabled input_0={swap_lr:0} input_1={swap_lr:1} output_2={dst:1} output_3={dst:0} where {swap_lr:0}, {swap_lr:1} are the output ports of the block which was before output sink (usually eq2). cras_iodev_dsp_set_swap_mode_for_node must support two use cases: - User sets swap mode when device is not playing. - User sets swap mode when device is playing. In the first use case, cras_iodev_update_dsp sets swap_lr_disabled variable based on left_right_swapped on active node. For the second use case, we need to udpate dsp in cras_iodev_dsp_set_swap_mode_for_node so the change takes effect right away. It is fine to do so because pipeline in the context is protected by a mutex. BUG=chromium:645051 TEST=with modified dsp, check left right swap works using cras_test_client --swap_left_right n:m:1. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I78fa29f3bd9edbe59eda73242cc855aa8781bce0 Reviewed-on: https://chromium-review.googlesource.com/386703 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-26CRAS: dsp - Add function to set a boolean variableCheng-Yi Chiang
Rename cras_dsp_set_variable to cras_dsp_set_variable_string. Add cras_dsp_set_variable_boolean to set a boolean variable. Remove unused cras_dsp_sync declaration. BUG=chromium:645051 TEST=make check Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I6ef667629b5c170bb7cd854fc89c31aa2064aa03 Reviewed-on: https://chromium-review.googlesource.com/386702 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-26CRAS: dps_mod_builtin - Add a swap_lr built-in moduleCheng-Yi Chiang
This module swaps data on left and right channels. BUG=chromium:645051 TEST=Insert one swap_lr section in dsp.ini and check left and right channels are swapped. [swap_lr] library=builtin label=swap_lr input_0={swap_lr:0} input_1={swap_lr:1} output_2={dst:1} output_3={dst:0} Change-Id: I687e69bcc13375436f9535db97514b3a60580376 Reviewed-on: https://chromium-review.googlesource.com/386701 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-22ucm-config: cyan: Add speaker swap modeCheng-Yi Chiang
Set speaker swap mode like veyron_minnie. BUG=chromium:646037 TEST=cras_test_client --swap_left_right 8:1:1, then play left right channel testing video on youtube. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: Ibcc5d74169677bed6fcfda36ef42c44414472fae Reviewed-on: https://chromium-review.googlesource.com/385076 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-21CRAS: hfp_ag_profile - Start audio gateway in bt deviceCheng-Yi Chiang
On HFP/HSP only headset, cras_hfp_ag_start is called in cras_hfp_ag_slc_initialized when SetConfiguration is called from bluez. However, that does not mark HFP/HSP as connected, and cause connection watcher to fail after timeout because it thinks HFP/HSP is still not connected. Move cras_hfp_ag_start from cras_hfp_ag_slc_initialized to cras_bt_device_audio_gateway_initialized to unify the path to start audio gateway. With that, the HFP/HSP will be mark as connected and connection watcher will not fail. BUG=chromium:647468 TEST=Test with HM1100 (HFP only device), connection is not lost. TEST=Test with IKBT74 (A2DP and HFP), playback and record both work. Change-Id: I45029c2a9ab855bbf27bdd950fe5dc779b74fef8 Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/386603 Reviewed-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-10CRAS: Rename PeriodFrames to DmaPeriodMicrosecs.John Muir
Specify the period time instead of the period frames to allow for different sampling rates in the device. BUG=None TEST=Unit tests updated. Change-Id: I8d767449068a49ce80a16d992ed73219af70bdbc Reviewed-on: https://chromium-review.googlesource.com/366964 Commit-Ready: John Muir <muirj@google.com> Tested-by: John Muir <muirj@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-10CRAS: Add UCM flag to enable use of ALSA htimestamp.John Muir
Disable htimestamp by default, and require that a UCM flag is supplied in order to enable it. BUG=None TEST=Fully unittested. Change-Id: I73dc192e2b868bf4a6f49a39701e3790ea0acf48 Reviewed-on: https://chromium-review.googlesource.com/366962 Commit-Ready: John Muir <muirj@google.com> Tested-by: John Muir <muirj@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-10CRAS: Use the hardware timestamp with available/used frames.John Muir
The ALSA device drivers can provide a timestamp associated with the buffer read-pointer. This can be use to more accurately guage the time that the next buffer is required. Enable this functionality only when supported ALSA in the running kernel. BUG=None TEST=Unit tests pass. Verified on Samus (on kernel v3.14). Verified on new device (kernel v3.18 - htimestamp enabled). Verified a bluetooth device. Verified a USB device. Change-Id: I5bca36f7ad9a236e80b2e277ccc62ccc8c39905b Reviewed-on: https://chromium-review.googlesource.com/366961 Commit-Ready: John Muir <muirj@google.com> Tested-by: John Muir <muirj@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-09CRAS: empty_iodev: Update last_buffer_access for flush_buffer.John Muir
The flush_buffer function was missing a change to the last_buffer_access time stamp even though the buffer_level is changed. BUG=None TEST=Audio input while switching devices (from headset mic to device mic and back). Change-Id: I176d4e1fcb1f1601e779d45736232494bd5613ac Reviewed-on: https://chromium-review.googlesource.com/373704 Commit-Ready: John Muir <muirj@google.com> Tested-by: John Muir <muirj@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-09-07CRAS: alsa_io - Don't unmute a node when disabling an deviceHsin-Yu Chao
Some codecs have restriction that recording from headset mic and digital mic are mutually exclusive. That said, under certain condition unmute one of the mic would cause the other to record silence. There is a bug in CRAS when each mic is the only node on its parent iodev, these mics will unmute at initialization and causes problem. Fix this by doing the unmute task only at setting active node when enabling an iodev. BUG=chrome-os-partner:56967 TEST=Manual test on Kevin, boot device and repeat below steps: 1. cras_test_client --playback_file /dev/zero 2. Immediately ctrl+C to quit playback 3. cras_test_client --capture_file - and verify in step (3) the data would print out on screen immediately instead of hang for several seconds Change-Id: I25d6f9ca376e6707239c40f8eff20cb2601c3951 Reviewed-on: https://chromium-review.googlesource.com/381698 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-09-05CRAS: bt_device - Start A2DP and HFP when both are readyHsin-Yu Chao
There are cases that a headset connects A2DP but not HFP/HSP. Modify the connection watch logic in bt_device to check and wait for every supported profile(HFP, A2DP). If certain profile is not ready in a while, try connect it. BUG=chromium:543444 TEST=Use Motorola S10-HD headset, press the play/pause button while it's not connected. Verify that both HFP and A2DP will connect. Change-Id: I4d729dc4e7c6da1a78cf8e748b7b17ee9912f3d3 Reviewed-on: https://chromium-review.googlesource.com/377847 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-09-05CRAS: a2dp_endpoint - Rename and refactor start functionHsin-Yu Chao
Rename the start function of bt_endpoing to set_configuration which aligns with the corresponding BlueZ dbus method. Also adds additional layer to notify bt_device about a2dp connection is configured, this will allow future commit to defer the actual starting of A2DP audio until all supported profiles are connected. BUG=chromium:543444 TEST=None Change-Id: I32ccc6c49fd903706a3a138dc95be7458daf2ca7 Reviewed-on: https://chromium-review.googlesource.com/377846 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>