alsa_sound: A2DP playback changes on jellybean

-Re-design for A2DP playback for changes. Data is read from
 proxy port and written to A2DP HAL. A2DP output is opened
 and configured from 8960 AHAL.

Change-Id: Icb373f882a99ff2a091e32a902811226ada77140
(cherry picked from commit 7c733664750e8c0ba45e8282f5195d536db00520)

alsa_sound: Fix for no audio on A2DP after pause and resume

- No audio is heard on A2DP headset after resuming audio playback
  after pause for more than 5sec.
- On long pause, the output stream is set to standby and the A2DP
  playback thread is suspended. But while resuming the playback,
  A2DP thread is not restarted which results no audio on A2DP.
- Fixed the issue by starting A2DP playback on first write to
  audio HAL on resume.

(cherry picked from commit d3ae028c373135615cfeeef0d670fe27693f9d99)

Change-Id: I2c1ddf751630b459d59d9e2e7d3bcca94c7d4330

alsa_sound: Fix for audio not routed through WiFi display

- DEVICE_OUT_PROXY is overwritten by A2DP device
- Switch to A2DP device only when DEVICE_OUT_PROXY is not set

(cherry picked from commit 2361761fb4ee2417cf84e73125f875936d6a285f)

Change-Id: Iea5e9934a4939bd71575faca4fd9c3627b48f7fc

alsa_sound: Fix for audio loss during BT power ON/OFF

 -Currently when BT headset is powered off audio HAL does not
  stop A2DP playback thread as we are calling suspendA2DPplayback
  in standby function which is causing audio loss when BT is
  conencted back. This is because dorouting is not called when
  BT is reconnected and is not teared down path previously
 -Fixed by calling stopA2DPplaybcak in standby function which
  will stop A2DP playback and called dorouting again when BT is
  connected again.

CRs-fixed: 391103
(cherry picked from commit 015e6f3bafafb516c4b1c8684d194d279cc47ab9)
(cherry picked from commit f5ca1b342591e21ff8a879ce14d593d6f250b14d)

Change-Id: I8493229e79ea0633ec11599bcd78792015e599ab

audio/alsa_sound: Fix for audio routing to speaker after BT voice call drop

Steps to reproduce :
1. Connect and pair BT.
2. Make a MO Voice call.
3. Play Music. (Both voice call and music is routed to BT SCO)
4. Disconnect the Voice call.
5. Music resumes in speaker

Root cause of the problem :
When phoneState get changed, A2DP suspend flag should be updated first. Speaker was selected

How to fix the CR :
check for device and output changes with proper order

Change-Id: I5043b6807fa48145ded7a268223074a8cf693f69
CRs-Fixed: 392743
(cherry picked from commit 45c2afae5e720fa6c676812db1a7c26cb6899b35)

alsa_sound:Fix for LPA clips audio loss during BT power ON/OFF

-mRouteAudioToA2dp should not set to true in standby function
 which will close all A2DP streams.
-This is taken care  in stopA2dpplayback function so removed in standby.

Change-Id: I61f1b901261cab7ebad9d17491fb8158835aeba1
CRs-Fixed: 391103
(cherry picked from commit 709dd53cae31c31c501accb47026ed9fd00d5c68)

alsa_sound:Fix for voice+Music playback over BT

- Issue: Start Music playback,initiate MO/MT call,disconnect call
  and music should resume but Music plaback resumes and stops after
  1 or 2 secs.
- Rootcause is because of standby function called after 3 secs of voice call
  end which in turn calls stopA2dpPlayback function
- Fix: Deal with lowlatency use cases over BT seperately.

Change-Id: I79d65f72dffbdb32c1859fba6b3607c8afe5eb52
CRs-Fixed: 398060
(cherry picked from commit 76841ce85e73f3e333adf321d615cf4eec383e7f)
(cherry picked from commit fc8e6b8efddd690656fcb3c15c43196c7176067a)

alsa_sound: Fix for no audio in BT after standby is called.

When BT is connected, and there is no audio for three seconds,
standby is called. But pcm device close was bypassed in the case,
when BT device was connected. Due to this mRouteAudioToA2dp was not
getting set to true in subsequent playback and hence a2DpPlayback
was never getting started.

Make a fix to close pcm device even when BT device is connected

Change-Id: Ice455455063179c82640b9fef9fdab7c002b615c
CRs-Fixed: 409889
(cherry picked from commit 41d8544b953cc5f0f3d8ac0316df60ff631811fc)

alsa_sound: Fix for no audio in music+ringtone concurrency on A2DP

- While playing audio on A2DP, if we go to settings and select a
  ringtone, the audio is lost. Expected behavior is that the ringtone
  should be heard on both A2DP and Speaker and music playback muted.
- While A2DP playback thread is reading data from proxy, if the
  device switch is done from A2DP to A2DP+Speaker, the proxy device
  is disabled and re-enabled which results bad state the A2DP playback
  thread.
- Fixed by stopping A2dp playback and resuming after the routing is
  complete.

Change-Id: I413540404d173a6c0d15c7704ee6e2efeab0887e
CRs-Fixed: 392353

alsa_sound: Shush the logging

Change-Id: Ib6bdafc600b66489868b0b18846446bb08cc8426
audio/msm8660: Fix for Mute not working in VoIP call

- In VoIp call mute option is not working
- Due to wrong device selection, PCM recording path is selected, instead
  of MVS Tx path, for VoIP tx.
- Enable MVS Tx path for VoIP uplink.

CRs-Fixed: 406977
(cherry picked from commit 9941ecfadc64514f4de8f4962b238d623aac52ce)

Change-Id: I5e2525938107a0c6a7115038d85419c4b886d5fe
(cherry picked from commit b4f3bad309e6fd0a9b39c10a64ef3bcb1141b373)
Merge "audio/msm8660: Fix for Mute not working in VoIP call" into jellybean
alsa_sound: Re-add DOCK_USBAUDIO.

Change-Id: I7d8054c8e08a4607425dce61e461e11474f224a3
alsa_sound: Re-add HTC_AUDIO, SAMSUNG_AUDIO, and USE_A2220

Left out in Ib6bdafc600b66489868b0b18846446bb08cc8426's refactoring.
Fixes d2 speakerphone caller echo.
audio/msm8660: Add channel mask for voice call recording

- Voice call record is failed to record.
- In channel mask uplink and downlink entry is missing
- Add uplink/downlink in channel mask and voice call
  in global configuration.

CRs-Fixed: 382736
(cherry picked from commit 505ac6f14f1b70fb0f52bbf53c0ca844ae66d271)

Change-Id: Id3a1d5346b07addb0d44add3cd030c75e5c9e3d0
audio/msm7627a: Fix for audio routing to headset and earpiece

- Audio is being heard on target speaker even when
headset/headphone is connected to the device
- TTY mode variable is not initialized to off by
default in constructor. With the garbage value while
in call trying to set TTY devices.
- Set TTY mode variable to off by default in constructor

Change-Id: If0bbf97ff674643c89c7cc163a5b5c0b157ec9e6
CRs-Fixed: 379340
audio/msm7627a: Fix for voice call audio routing to earpiece

- Voice call audio is being heard on speaker even when
earpiece is connected to the device.
- Earpiece is default attached device to target. Entry for
earpiece as global attached output device is missing.
- Add earpiece as global attached output device in
audio policy config file.

Change-Id: I80903bd37efd79e7836a9ebd46b039b8d8f151d1
CRs-Fixed: 379340
audio/msm7627a: Fix for voip call failure on speaker.

-Voip call on speaker fails.
-Speaker device is not made available in audio_policy.conf file
 this is a side effect to earlier fix.
-Make both the speaker and earpiece available in policy conf file.

(cherry picked from commit 21d8c479999368d4366ab535c60a13a6118ceb89)

Change-Id: Ic839f3ef54e359bc382da54715b02980fde1aa08
audio/msm7627a: Fix for Mute not working in VoIP call

- In VoIp call mute option is not working
- Due to wrong device selection, PCM recording path is selected, instead
 of MVS Tx path, for VoIP tx.
- Enable MVS Tx path for VoIP uplink.

CRs-Fixed: 390742
(cherry picked from commit 833bca91f6f3e7bfdbb7ff9f8773fe49ef531614)

Change-Id: I282f5c27b4461c623cb0736926d4e317ee038a33
Merge "audio/msm7x30: Add channel mask for voice call recording" into jellybean
Merge "audio/msm7x30: Add missing volume offset value" into jellybean
alsa_sound: Do not stop A2DP playback if routing to input devices

-Issues: No audio playback on A2DP headset during VOIP(Skype) call
-Causes: Skype uses built-in Mic/A2DP as I/O devices, A2DP playback
 is closed while switching device to built-in Mic.
-Fixes: in doRouting(), do not stop A2DP playback if routing to
 input devices.

Change-Id: Iefada0764c04622a082ab50adff24cc160a97dd8
CRs-fixed: 407888
alsa_sound: Fix for music freeze on FWD from BT

- While audio playback on a2dp, press NEXT on
  A2DP headset. This results in UI freeze for
  5sec
- Fixed the issue by alternating sequence of
  closing PCM and Proxy drivers.

Change-Id: I7bebd420c166ce76afe873732f260741c55dff99
CRs-fixed: 405332
alsa_sound: Fix for LPA Audio loss during BT on/off

-Issue:If LPA playback started on speaker and connect/disconnect
 BT multiple times results audio loss. This happens because of
 stopA2DPplayback called with NULL usecase
-Fixed by assign right usecase to mUseCase if it is not already assigned

Change-Id: I95c28ed159684f7b653d14284514d4969666bd75
hardware/alsa_sound: Synchronize voice path setup

Block the policy manager until the voice path is setup. This is
done to prevent telephony from signaling call connect before the
entire voice path is established.

Change-Id: I25f6ca3199d9818f0e36a05bc0364a8c28e75650
CRs-fixed: 402673
Hardware/alsa_sound: Set the BT volume based on VGS

When VGS is set, we expect volume change to be performed on
BT device. Otherwise, volume change is applied by DSP

Change-Id: I76c3fde90b5e879278e94610e8af4abd07615cf0
CRs-Fixed: 366872
msm7x27a: Add missing wired headphone route

Change-Id: I2667701d27aa65a3d50cc98fb693af1bdfde3637
msm7x30: fix FM audio routing

Makes FM radio work with non Sony headsets without mic

Change-Id: I557b99fe136db7956157ccac53e3574febdbfdf3
Merge "msm7x27a: Add missing wired headphone route" into jellybean