summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-01-11init: Add get_internal_ucm_suffix scriptHsin-Yu Chao
BSP will implement the get_internal_ucm_suffix script to read hardware specific info from VPD and pass it to CRAS through the --internal_ucm_suffix argument. BUG=chrome-os-partner:61501 TEST=Add fake /etc/cras/get_internal_ucm_suffix and run cras with --syslog_mask=7 to verify the fake suffix is used. Change-Id: I35c2ff1e2386aa41363b4efb2f5cd540173086d9 Reviewed-on: https://chromium-review.googlesource.com/425599 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2017-01-11CRAS: alsa_card - Add internal_ucm_suffixHsin-Yu Chao
There's requirement that one board image will run on multiple hardwares with different UCM config. With this change we can run CRAS with --internal_ucm_suffix arguemnt to pass in a string <suffix>, and different UCM config files will be installed under directory named as <card-name>.<suffix> so they can be loaded depend on this hardware specific string. BUG=chrome-os-partner:61501 TEST=Run CRAS with --internal_ucm_suffix=fake and --syslog_mask=7 to verify from syslog that this suffix is append to internal card name when loading UCM config. Change-Id: Ib6160e60a29a88f390abad32755e08a271b74f4d Reviewed-on: https://chromium-review.googlesource.com/425598 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>
2017-01-06CRAS: alsa_io - Add front and rear mic typesHsin-Yu Chao
Expose more DMIC types to UI so these input nodes can be handled differently. This commit introduces the 'position' field to differentiate nodes of the same type but different locations on the system, and also expose new nodes 'Front Mic' and 'Rear Mic' to UI. BUG=chrome-os-partner:59780 TEST=Manual modify UCM then use cras_test_client to verify DMICs are correctly displayed. Change-Id: I089562a7c374cb0bd4f5175c82937dfff0aef685 Reviewed-on: https://chromium-review.googlesource.com/425469 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-01-05CRAS: cras_iodev: initialize ramp_action variableDylan Reid
There was a compiler warning with gcc that it could be used uninitialized. Initializing the variable allows the removal of the is_ramping variable as a side effect. Change-Id: Ieb8b91ef7900048db609f63383257799d871dac6 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/424845 Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2017-01-05CRAS: min alsa-lib is 1.1.0Dylan Reid
The new timer APIs have been in use for a while, reflect that requirement in the makefile. Change-Id: I4c40bf6f62094b30e022fd05fcc215ba806e61bb Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/424844 Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2017-01-05cras_udev - Don't reuse dev variableDylan Reid
For readability, don't reassign the dev pointer with the parent dev pointer. Give the parent dev pointer its own name. Change-Id: Ieb1e636f0f38ff7b3cba3705f2cc053b607d8075 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/424843 Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2017-01-04CRAS: alsa_helper - Fix num_underrun countCheng-Yi Chiang
When snd_pcm_avail returns a number that equals buffer size, it should be counted as underrun as well although it might not be an underrun if total_written happens to be greater than zero. This is because audio_thread calls cras_iodev_output_underrun when hw_level and total_written are both zero. If we do not count the case where avail == buffer_size (that is, hw_level == 0) as an underrun, num_underrun dumped in audio thread log will be 0, while there is delay caused by cras_iodev_output_underrun. With this change, we can rely on num_underrun == 0 in audio thread log to examine that hw_level remains high enough. BUG=chromium:667674 TEST=check num_underruns is the same as number of times cras_iodev_output_underrun is called. Change-Id: I170753485b135e5170ff810830668a1b03ece04f Reviewed-on: https://chromium-review.googlesource.com/425054 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2017-01-04CRAS: ucm - Use "Speech" instead of "Voice" for UCM verb.Chinyue Chen
Use "Speech" as UCM verb and CRAS_STREAM_TYPE_SPEECH_RECOGNITION as stream type so that it's easier to tell them from "Voice Call" and CRAS_STREAM_TYPE_VOICE_COMMUNICATION. BUG=None TEST=make check Change-Id: I9fc9dcceef920ba8a831bfcc0a4c595d43692888 Reviewed-on: https://chromium-review.googlesource.com/424496 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2017-01-04ucm-config: squawks: Switch to mandatory UCMCheng-Yi Chiang
- Use mandatory UCM to specify jack for kernel 4.4. - Remove redundant 'Left Speaker Mixer Left DAC Switch' and 'Right Speaker Mixer Right DAC Switch' in initial sequence. - Remove 'HP Left Out Switch' and 'HP Right out Switch' because kernel 4.4 does not export such control. This can be added back when kernel support is ready. BUG=chromium:675006 TEST=check headphone / external mic works on squawks. TEST=check internal speaker / internal mic works on squawks. Note sometimes recording fail because of PLL unlocked issue. Change-Id: Id680d058bff6e1038e109d0ba32cf31e6e9d893b Reviewed-on: https://chromium-review.googlesource.com/422793 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-01-04CRAS: alsa_ucm - Add CaptureChannelMap for input deviceHsin-Yu Chao
There exists platform with input device that only a subset of channels are valid. Add the ability to UCM to specify desired capture channel map. For example if a stereo dmic has only the second channel valid, use "1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1" to indicate that the data at channel index 1 should be treated as front left and channel index 0 should be excluded. BUG=chrome-os-partner:59780 TEST=Test on Kevin, manual modify UCM to specify CaptureChannelMap "1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1" or "-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1" Execute 'cras_test_client --capture_file /tmp/1' and use Audacity to verify only one channel is has sound recorded while the other is not. Change-Id: I136115a38f989e9e6d8c56ec928fef4446bb51a9 Reviewed-on: https://chromium-review.googlesource.com/418420 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
2017-01-04CRAS: audio_area - Remove unused argumentHsin-Yu Chao
The purpose of the skip_zero argument has already been replaced by the work in commit da9e4afc so remove them. BUG=None TEST=unittest still pass Change-Id: I8fad0d1201943be413b7bc70ea965dc662e3040c Reviewed-on: https://chromium-review.googlesource.com/418419 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-30CRAS: alsa_io - Separate volume and mute opsCheng-Yi Chiang
Now that we have ramp in alsa_io, we should let ramp finish first and then set mute control after that. Putting volume and mute control together causes mute control to be turned to mute state before ramp is finished. 1. System state has mute = 1 and volume = 0 2. set_alsa_volume is called. It sees mute in system state is 1 so it set mute state to muted. To avoid above problem, we should separate set_volume and set_mute ops of alsa_io. This simplifies each ops. Now set_volume only changes volume, and set_mute only changes mute state. BUG=chromium:669662 TEST=make check TEST=On samus, check ramping down works fine when pressing volume down quickly and repeatedly until 0. TEST=On samus, play a sine tone in youtube. Press volume down until volume is the lowest but not zero. Press "down down down up" very quickly. There will be no pop noise. Change-Id: I722367f9577653b0b05f56965ea61038d227cc91 Reviewed-on: https://chromium-review.googlesource.com/423447 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-30CRAS: Ramping up/down for new stream and mute/unmute switchingCheng-Yi Chiang
Let alsa_io hold a cras_ramp member to control ramping. The start/update of cras_ramp is done in audio thread. The reset of cras_ramp is done in main thread when closing device. Ramping is used in these places: 1. When the sample from new stream is ready, ramping up. 2. When system mute state is changed from unmute to mute, ramp samples down. Set a callback in cras_ramp so the callback can set mute state on device after ramping is done. This process let device plays samples that are close to zero before it is turned to mute state. 3. When system mute state is changed from mute to unmute, starts ramping up samples and switch mute control to unmute state. This process let device plays samples that are close to zero after it is turned to unmute state. For example, when user mutes the system, the flow of 2 is: a. Mute state in cras_system_state changed. b. iodev_list asks audio thread to start ramping down. c. audio_thread gets the message and starts ramping down active devices. d. audio_thread updates ramped sample in cras_iodev_put_output_buffer in each output cycle. e. Ramping is done. audio_thread executes callback in cras_ramp to use cras_device_monitor_set_device_mute_state to ask main thread to set mute state on device. f. Main thread receives message and calls cras_iodev_set_mute on device to actually change device mute state using set_mute ops. BUG=chromium:669662 TEST=make check TEST=on samus, play sine tone in youtube, press mute and volume up repeatedly, observe the ramping up and down without pop noise. TEST=On samus, play a sine tone in youtube, change volume to somewhere close to 0 and press "down down down up" quickly. Observe there is pop noise at unmute. This is to be solved in the next patch. Change-Id: I71659edfa0a15d9aafa9db2e8b933c19ef48793f Reviewed-on: https://chromium-review.googlesource.com/415012 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-12-30CRAS: device_monitor - Add function to set mute stateCheng-Yi Chiang
Device monitor let audio thread request main thread to set mute state on a device. This is needed when audio thread finds that ramping is done, and mute/unmute is requested after that using callback in cras_ramp. BUG=chromium:669662 TEST=make check Change-Id: I34baace5898ccd2fbe5884f68fb24738ea0b0ac9 Reviewed-on: https://chromium-review.googlesource.com/422615 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-30CRAS: iodev - Wrap set_mute with a functionCheng-Yi Chiang
It will be cleaner for users to access set_mute from this interface. BUG=chromium:669662 TEST=make check Change-Id: I41dba8ba8fdba492b71cda3b09b4ca4703953b24 Reviewed-on: https://chromium-review.googlesource.com/422614 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-12-30CRAS: ramp - Add callback to call when ramping is doneCheng-Yi Chiang
Set callback and callback data at cras_ramp_start. When ramping is done, call that callback with data. This is to set mute control after ramping is done. BUG=chromium:669662 TEST=make check Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I24e7880917acfd982de1c11c030868248d5aa2ce Reviewed-on: https://chromium-review.googlesource.com/422613 Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-12-30CRAS: mix - Add ops to scale with incrementCheng-Yi Chiang
Add ops to scale a buffer starting from certain scaler and increase/descrease for every frame. BUG=chromium:669662 TEST=make check Change-Id: I1332167080aed94de23090fcfeedb75f5738bed5 Reviewed-on: https://chromium-review.googlesource.com/416471 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-12-30CRAS: ramp - Add a module for rampingCheng-Yi Chiang
Add cras_ramp module to handle ramping of data. 1. When device goes from mute to unmute, ramp the data from last scaler to 1. If there is no last scaler, start from 0. 2. When device goes from unmute to mute, ramp the data from last scaler to 0. If there is no last scaler, start from 1. For case 1, device will have smooth transition from mute to unmute. For case 2, ramp can not finish its full duration. This is because device samples are muted in cras_iodev_put_output_buffer. Also, device output switch is turned off right away. These need to be changed in the future so we can have smooth transition from unmute to mute. BUG=chromium:669662 TEST=make check Change-Id: I25173becd826053c4fa0b0a3bf9ff0d611352d15 Reviewed-on: https://chromium-review.googlesource.com/415750 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-12-28ucm-config: fievel: disable speaker & int micJeffy Chen
copy ucm config from veyron, and rename. delete speaker & int mic. BUG=chrome-os-partner:58861 TEST=check on fievel, no speaker & int mic Change-Id: I94ad50da2ced4ef93df9e1ccdfe69a42b84cee0d Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/423294 Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
2016-12-28ucm-config: veyron: use fully specified UCMJeffy Chen
BUG=chrome-os-partner:58861 TEST=check speaker/headphone on minnie Change-Id: I7ec8fb49036c3102dc9bdb99abcb82fdb69753fc Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/423293 Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
2016-12-28ucm-config: minnie: remove swap modeJeffy Chen
We now using software dsp to do it. BUG=chrome-os-partner:58861 TEST=None Change-Id: I77fbbb2796bd3fa01cf6e2ad3b6c5e0a12f86de6 Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/422619 Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
2016-12-22CRAS: alsa_jack - Move wait_for_dev_input_access to cras_utilCheng-Yi Chiang
Move wait_for_dev_input_access to cras_utils so we can overwrite it in unittest. BUG=None TEST=make check, run alsa_jack_unittest and see it finishes within 1 second instead of 40 seconds. Change-Id: Id0f293e9b5ee1d56c151d918314ea85ff936a3c9 Reviewed-on: https://chromium-review.googlesource.com/416091 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
2016-12-22CRAS: alsa_io - Do not turn off switch for volume zeroCheng-Yi Chiang
Setting volume goes through different path as set_mute. When the adjusted volume changes from 0 to nonzero or vice versa, and causes output switch to be turned off/on, ramp needs to be triggered beforhand. Since it is not easy to see if there is such a change, do not turn off switch for volume zero. Output will still be muted by cras_iodev_put_output_buffer. There will be no ramp of data in volume changes. BUG=chromium:669662 TEST=change volume between 0 and 1 on samus, observe there is no pop noise. Change-Id: Ib652eafe85ef1f94fbb439dcc6455ea8e044656f Reviewed-on: https://chromium-review.googlesource.com/415751 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
2016-12-21CRAS: system_state: Adjust current gain when limit changesCheng-Yi Chiang
When supported gain limit is changed, current gain should be updated too. BUG=chromium:673656 TEST=Use apprtc and switch between internal mic and headset mic. Check cras_test_client --dump_s and see capture gain is changed to be within limit. TEST=make check Change-Id: Ia5f551d6d92fdb7cc90370f933664ae7db407008 Reviewed-on: https://chromium-review.googlesource.com/422709 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-12-16ucm-config: veyron: add "Headphone Switch" controlJeffy Chen
We noticed some pop noise after switching output from headphone. It seems like adding "Headphone Switch" control like other platform would help. BUG=chrome-os-partner:57435 TEST=manually, no more pop noise Change-Id: I43b89200b9193c62f770f0659fcc7e5f7db3cc86 Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/419933 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-16CRAS: alsa_io - Implement output_underrun for alsa_ioCheng-Yi Chiang
Add output_underrun ops to cras_iodev to handle output underrun. The default behavior is to fill one block of zeros. Implement output_underrun ops for alsa_io. It first cleans up whole buffer with zeros. Then, it moves appl_ptr to min_cb_level + min_buffer_level ahead of hw_ptr. This is better than filling one block of zeros in a waking up cycle. BUG=chrome-os-partner:60497 TEST=cras_test_client --playback_f /usr/local/autotest/cros/audio/fix_440_16.raw Then press p and enter. There will be no noise. Change-Id: I8945d65088600be9d1479127a50a59057a5d6c62 Reviewed-on: https://chromium-review.googlesource.com/418607 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-16CRAS: iodev - Avoid repeated reset requestCheng-Yi Chiang
When severe underrun is triggered, audio thread will send multiple reset request in a short time, while main thread has not handle the first request yet. Add a flag in cras_iodev so we can ignore multiple reset request until device is actually opened. BUG=chrome-os-partner:60497 TEST=modify SEVERE_UNDERRUN_MS to 0.1 and trigger underrun by cras_test_client. Check messages and see there is only one reset request works. Change-Id: Ida091fa8f5f7fa31bf070317c302ea17e4e9fdac Reviewed-on: https://chromium-review.googlesource.com/419941 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-16CRAS: alsa_io - Set severe underrun threshold to five secondsCheng-Yi Chiang
As explained in the issue, severe underrun is only targeted for special case where bad dma driver makes hw_ptr jumps by a large distance and creates a severe underrun that can not be recovered by filling blocks of zeros. It should not be easily triggered by normal underrun or stressing system. BUG=chrome-os-partner:60497, chromium:662786 TEST=run balloon test in issue 60497, should not see resetting device. Change-Id: I78d13d428cf11b06dbec05454340abc376f2290e Reviewed-on: https://chromium-review.googlesource.com/418566 Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-16CRAS: client - Don't send partial corrupted buffer to clientHsin-Yu Chao
Add test cases for input client handling capture buffer in noremal scenario, beginning of buffer overrun, and in the middle of buffer underrun. BUG=chromium:673454 TEST=make check Change-Id: I7b3cea4d6a485a5cbf1dd7f1e0625e7615ed54d1 Reviewed-on: https://chromium-review.googlesource.com/419932 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-14CRAS: dev_stream - Remove unused variableHsin-Yu Chao
BUG=None TEST=None Change-Id: Ic9eab3da91c25709a0ccf9df5b8c9168529260ca Reviewed-on: https://chromium-review.googlesource.com/418131 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-14CRAS: client - Fix Chrome crash when input buffer overrunHsin-Yu Chao
When an input client hangs at processing the captured buffer, server side could encounter buffer overrun. When that happens and client later recovers from busy state, the read buffer would no longer be a whole captured chunk. Assuming Chrome processes the read buffer while it's in the middle of overrun, only partial of the buffer is consumed and that causes non-zero read offset. This makes Chrome crash at the next time it handles capture data because buffer pointer won't start from the beginning. BUG=chromium:673454 TEST=Run apprtc app on Kevin. Change-Id: I7ef61140081ec2e466fc8eace854ec02c065c6da Reviewed-on: https://chromium-review.googlesource.com/418130 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-12CRAS: UCM - Derive use case verb from cras_use_case_mgr.Chinyue Chen
The change eliminates the hard-coded use case verb and uses the corresponding verb of the selected use case in snd_use_case_xxx calls. BUG=chromium:643039 TEST=make check && verify correct playback on DUT Change-Id: Ide36b089abc62ae337387a1b48c364602aa2dcba Reviewed-on: https://chromium-review.googlesource.com/416532 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-09CRAS: UCM - Extract and expose ucm_set_use_case function.Chinyue Chen
The new ucm_set_ues_case function will be used later to change use case in run-time. It checks if the UCM config for the requested use case is availalble, and uses default use case if not. BUG=chromium:643039 TEST=make check Change-Id: I499e2be999ad74c2996ee26d56e42e39892a02ee Reviewed-on: https://chromium-review.googlesource.com/416531 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-08CRAS: UCM - Introduce cras_use_case_mgr wrapper.Chinyue Chen
The cras_use_case_mgr wraps the ALSA snd_use_case_mgr and can hold the selected use case for the ALSA card. The benefit is that the use case verb can be looked up from cras_use_case_mgr and doesn't need to be passed around or hard-coded. Following commits will make use of the new wrapper. BUG=chromium:643039 TEST=make check Change-Id: I0ffe94e6d635c8c0b62aa5f9ccc40bf49808d1a3 Reviewed-on: https://chromium-review.googlesource.com/415749 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-02CRAS: dbus_control - Add serial number for USB device for stable idMoja Hsu
Get additional sys attribute for "serial" which is serial number in udev. Add it into the stable_id_new calcuation and keep stable_id for backward compitable. BUG=chromium:661861 TEST=Plug 2 same type USB speakers into chromebook. execute "dbus-send --system --type=method_call --print-reply --dest=org.chromium.cras /org/chromium/cras org.chromium.cras.Control.GetNodes" Check if we have the same stable_id but different stable_id_new for the 2 speakers. pass make check for unit test. Change-Id: Iefefe383fd6143dd7c28fdba3cf3f3872c2dd726 Reviewed-on: https://chromium-review.googlesource.com/407723 Commit-Ready: Hsu Wei-Cheng <mojahsu@chromium.org> Tested-by: Hsu Wei-Cheng <mojahsu@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
2016-12-01CRAS: iodev_list - Retry if init device failedHsin-Yu Chao
There are cases that iodev fails to open and that results silent playback or recording to user. When this type of error happens, let iodev_list do a retry to open iodev because user has very few clue on what has happened. BUG=chromium:666405 TEST=Use hack patch to make USB iodev fail to open, check debug log to verify open dev retry is working when add new streams and select different output nodes. Change-Id: I5163f79c881d88b32f8c02045c1954e20118d44a Reviewed-on: https://chromium-review.googlesource.com/414854 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-01CRAS: iodev_list - Use fallback iodev at open iodev failureHsin-Yu Chao
When an iodev fails to open, an error is returned immediately by current implementation. That makes the new connected stream an orphan because it doesn't attach to any iodev. If it happens on a video app, video will hang because it needs to align with audio. For better user experience, this error case can be handled by enabling fallback device and move streams to it. After the change user will just hear nothing instead of seeing blocked video if audio device fails to open. It's also a better hint for user to guess this is more an audio issue and not related to video. BUG=chromium:666405 TEST=Unittest. Use hack patch to make a2dp iodev always fail to open and test: 1. select a2dp as output, play YouTube and see video doesn't hang. Select audio output to/from internal speaker to verify audio routes correctly and video playback is smooth. 2. select internal speaker as output, and play YouTUbe. From system tray select output node to a2dp to verify video plays smoothly. Switch output node back to speaker, verify audio plays and aligned to video. Change-Id: I12cf3000b79ed4fc93984c206335657912990518 Reviewed-on: https://chromium-review.googlesource.com/413790 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-12-01CRAS: iodev_list - Fix pinned stream checkHsin-Yu Chao
Need to check is_pinned flag of a rstream otherwise its member 'pinned_dev_idx' could collide with the index of fallback iodev. BUG=chromium:666405 TEST=None Change-Id: I973d2eb78e69f08b73e7ba819c5d7ada12969ade Reviewed-on: https://chromium-review.googlesource.com/413789 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-11-29CRAS: loopbacl_iodev - Fix get_buffer callbackHsin-Yu Chao
Get buffer should not return frames more than requrested. BUG=chromium:657510 TEST=cras_test_client --loopback_file /tmp/loopback Change-Id: Ie789cbff30ede279e63e67f5822c36ab8a8c4dc7 Reviewed-on: https://chromium-review.googlesource.com/414750 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-11-23CRAS: a2dp - Don't flush too much when buffer level is lowHsin-Yu Chao
The original strategy of flush_data() function is to encode PCM buffer to SBC format blocks whenever there's data and try writing the encoded data to A2DP socket. This could consume too much PCM buffer in one callback to cause buffer level drops below min_buffer_level so audio thread thinks it underruns. BUG=chromium:635426 TEST=unittest Change-Id: I2f294a397868132b8810edb4a91a98f269376212 Reviewed-on: https://chromium-review.googlesource.com/411647 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-23CRAS: use R_OK to test file read permissionYong Zhi
Use macros defined in unistd.h for how argument of int access(const char *file, int how) function. BUG=chrome-os-partner:59363 TEST=reboot and test headset plug status Change-Id: I62318948dd4e4f70fa869d7ce7f0f7d27ce8a706 Signed-off-by: Yong Zhi <yong.zhi@intel.com> Reviewed-on: https://chromium-review.googlesource.com/412203 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Sathyanarayana Nujella <sathyanarayana.nujella@intel.com> Tested-by: Anson Tseng <ansonfcu@gmail.com> Reviewed-by: Sathyanarayana Nujella <sathyanarayana.nujella@intel.com> Reviewed-by: Anson Tseng <ansonfcu@gmail.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-23CRAS: audio_thread - Log when input stream overrunsHsin-Yu Chao
Fix cras_shm_check_write_overrun() function in detecting when unread data is overwritten, and return the result so audio thread can ATLOG this problem. BUG=chromium:662886 TEST=Use 'cras_test_client --capture_file /tmp/1' and hit 'p','enter' a few times to emulate a bad client. Check audio dump to veriy there's AUDIO_OVERRUN logged. Change-Id: Ib5b90ce05d957487b29639dffbbe3067ab5f6915 Reviewed-on: https://chromium-review.googlesource.com/412428 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-23CRAS: client - Don't read repeated dataHsin-Yu Chao
CRAS client could handles multiple messages from server about capture data ready. We should check if the read offset of stream shm reaches write offset, to avoid reading repeated data. BUG=chromium:662886 TEST=Execute 'cras_test_client --capture_file /tmp/1' and then hit 'p', 'enter', 'p', 'enter'... repeat 10 times while making some sound to internal mic. Inspect the recorded /tmp/1 file using Audacity to verify there are no repeated samples, but with several short discontinuity instead. Change-Id: I40bf34cbae31f76bd013ec855a4d5ef4055399f2 Reviewed-on: https://chromium-review.googlesource.com/411668 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-23CRAS: alsa_io - Track number of severe underrunsCheng-Yi Chiang
Track number of severe underruns in alsa_io. User can see it through audio thread log. BUG=chromium:662786 TEST=with hack patch, cras_test_client --dump_a and see num_severe_underruns increased. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I02a644971bfcc43e7589c95a3f1ca6db750c75d4 Reviewed-on: https://chromium-review.googlesource.com/411644 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-23CRAS: main_message - Add newline in the end of fileCheng-Yi Chiang
BUG=None TEST=None Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: Ie5ff1060e6083f15ac67068611deadd25decc17a Reviewed-on: https://chromium-review.googlesource.com/411643 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
2016-11-23CRAS: device_monitor - Add device monitor to handle device requestCheng-Yi Chiang
Use device monitor to handle message from audio thread. When audio thread finds a device in bad state, it can send a message to main thread to reset a device properly from iodev_list. BUG=chromium:662786 TEST=make check TEST=With hack patch of severe underrun, check device reset upon severe underrun. Also check audio thread log. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: Iac6d3f688f40cfe434002064407363151857ec6b Reviewed-on: https://chromium-review.googlesource.com/411743 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-23CRAS: alsa_io - Propagate error for severe underrunCheng-Yi Chiang
Previously, cras_alsa_get_avail_frames masks underrun and only logs an error message. This patch sets a threshold for severe underrun. If severe underrun happens, the error should be propagated to audio thread. The following commit will reset the device so device can be recovered from severe underrun. BUG=chromium:662786 TEST=make check Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: Ib2a385a808936d0673590c0c0ab73c4ed97ada89 Reviewed-on: https://chromium-review.googlesource.com/411022 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-22CRAS: server_metrics - Fix a bug in sending messageCheng-Yi Chiang
The length in the message header should be length of the message. BUG=None TEST=use cras_test_client --playback <file> and press p to cause long delay. After the stream is removed, check debug message that handler has handle metric message. Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org> Change-Id: I8167358a39c9abaf5b62e246fb4c76cc76ecb37f Reviewed-on: https://chromium-review.googlesource.com/411742 Reviewed-by: Dylan Reid <dgreid@chromium.org>
2016-11-21Fix adhd to build with latest llvm.Manoj Gupta
Clang bug https://llvm.org/bugs/show_bug.cgi?id=31050 is fixed. So remove some unnecessary pointer casts that had to be added to avoid the following warning from clang. 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: If7e09a133c4d41f9a8197b435687fd8cb756b58a Reviewed-on: https://chromium-review.googlesource.com/413052 Commit-Ready: Manoj Gupta <manojgupta@chromium.org> Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Chinyue Chen <chinyue@chromium.org>
2016-11-20CRAS: audio_thread - Avoid using MIN macroHsin-Yu Chao
MIN() macro would make function called twice and sometimes that wastes a lot of computation. BUG=chromium:662886 TEST=None Change-Id: I800633caf152f1e13e03c29ff9e278ba5180a815 Reviewed-on: https://chromium-review.googlesource.com/409236 Commit-Ready: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>