hal: update csd soft volume and mute controls

Update csd volume and mute controls with new apis which
takes ramp duration as a parameter. Set default mute
ramp duration to 20 ms.

Change-Id: Id8dcbc9bc12ac4e9c56962abc58b6bd1de0530a7
hal: fix listen and audio calibration concurency

- ACDB loader is maintaining the same calibration buffers
for both listen and audio. So there is a possibility that
the audio calibration buffers may be overwritten with listen
calibration soon after notifying the device busy state to
listen hal
- Avoid this issue by notifying listen hal before sending the
audio calibration so that listen hal can complete pushing its
calibration

Change-Id: I4d954b1287b59ee4e1510707db25f466d14dca97
hal: fix to handle voip issue when input stream starts first

- adev_open_output_stream() fails if the use case is already enabled.
Because of this, in case of VoIP, when the input stream is created
and started before creating Audio Track, then the output stream
creation fails.

- Fix this issue by giving exception for VoIP use case.

Change-Id: I5e7329d64075a09b99e5760a9050ace8c62a4e87
CRs-fixed: 651761
 Audio: Fix for audio loss on switching between speaker and USB headset

 - snd device reference count is not decremented when usb headset is
   unplugged, because touch tone is still active on usb headset.
   So when usb is plugged again device routing is not triggered as
   present and prev devices are same
 - Fix is to route audio to speaker as soon as usb headset is
   disconnected

   CRs-Fixed: 630425

Change-Id: Idfa37478fa19cd5a1c75c7e1d2f77b4dc02b311a
hal: Ensure all the mutexes are initialized

- Ensure all the mutex locks are initialized before using them,
  to avoid native crashes.

Change-Id: I7b6253f1d08a36a24d366d69004ce969d73c13e1
CRs-Fixed: 654375
hal: fix BT device switch issue for audio playback during VoIP call

- When VoIP call is active on non-BT device and if the music playback
tries to switch to BT device, it will continue to route to non-BT
device on which the VoIP call is active already.
- Fix the issue by not selecting VoIP devices for audio playback when
they are on different back ends.

Change-Id: Iff9251fcf02f897d9b1cdc17fcf27c262518ada8
CRs-fixed: 652129
policy_hal: remove VGS check for BT volume

-Currently voice volume is forced to MAX when VGS is set for BT.
 But VGS parameter is not used anymore in BT stack so it never
 set the value.
-Removed VGS check as this is deprecated and keep the behavior
 same as default policy.

Change-Id: I69de60987835cc7bfbf26e6b89eb39447423fd9d
  hal: Fix device disable/enable sequence

  In Skype call, observed no rx data when headset is inserted
  during call.

  During device switch from handset to headset, audio HAL is
  enabling the headset mixer controls first then disabling
  handset mixer controls leading to no audio during downlink
  as codec clock in 8916 is disabled due to the followed
  sequence.

  The current device switch logic doesn't make sure that all
  previous devices are disabled before enabling the selected
  devices. Fix this by changing the logic to disable all the
  previous devices first and enable the selected devices.

  CRs-Fixed: 648710

Change-Id: I0adfb62ea0ad8e2a2fe1a5473732e8bef61c492a
hal: Correct the V/I feedback PCM device for 8974

 * This got moved around after merging multisession Listen.

Change-Id: I3dcc1f1ccf1373819dcbfa296dcf781f66bae9af
hal: Add speaker backend case handling

* Some devices route their speakers through a different backend. Allow
  speaker use cases to be routed separately in this case.

Change-Id: I6bcaa4a0b72d2fc60ae02d4f49cfca0fdb55405f
Revert "audio: primary desc check for sonification"

 * Handled in libhardware_legacy now.

This reverts commit 01f7fcc7694b23b07c59de6c786ae5c3e715d212.
hal: Update BT sample rate for BT input device

-BT sample rate should be set before opening BT SCO output
 or input device. Currently it is set only for output device.
-Set sample rate for BT SCO input device also

Change-Id: I356557a727f5946ff3b4eb89ea16e4c16d84d21c
audio: use of audio_route_{apply/reset}_and_update_path APIs

1) Update enable/disable device and route to use the new APIs.
   With this change, mixer controls will be updated in the order
   listed in mixer paths XML file.
2) update_mixer is now an unused var.

Change-Id: Ic0a8874e4a2080347cfa0c2e66af606a08a207a7
CRs-Fixed: 581453
Revert "Revert "audio: primary desc check for sonification""

 * Voodoo. Sort this out later.

This reverts commit aef8ce5477cdf0c9117c8be7e9eb250326cad204.
hal: Set echo reference from mixer file

Set echo reference from mixer file.
Change-Id: I8b9d1209002ead0f82eb6052d41ab00ba41ce6a2
Revert "  hal: Fix device disable/enable sequence"

This reverts commit 8db53270733939a81e5fdda89de3c8c0eaf939e4.

Change-Id: Id6cf69819bc97bde73dbdcc007afe550b81668d1
hal: Correct PCM offload fragment size

- Correct the fragment size to use bytes instead of bits
  per sample
- Use 80ms as pcm offload buffer duration for video streaming
  usecases and 1 sec for video + audio usecases

Change-Id: Iec8e24c2b158368742a55710a46da94ce5d3c170
audio: Remove unused var 'update_mixer'

Remove update_mixer (as its unused) and change function
signatures wherever used.

Change-Id: I465ddc4bfeba714a7f0d14a7e319a3d1ddc62dbb
CRs-Fixed: 581453
Audiod: Priority change for AudioDaemon

- Device getting crash after preforming
  ADSP/LPASS SSR during compress playback

- Due to continous compress write calls
  to compress driver audio daemon not getting
  schduled which results system crash

- Change AudioDaemon priority from PRIORITY_AUDIO
  to PRIORITY_URGENT_AUDIO to make sure audio daemon
  scheduled prior to audio HAL

Change-Id: I0d7dff30908d4e1f727c1eb6af9e66ed74095148
hal: Fix VoIP Mute failure in SIP call during Voice call HOLD

- Unable to apply the mute in MT SIP call during Voice call
  in CALL_HOLD.
- Mute is only applied if the voice call state is INACTIVE.
  Thus when SIP call is made during Voice call in CALL_HOLD,
  the mute is not being reflected.
- Fix this issue by checking voice stream type to allow
  the mute to be applied.

Change-Id: I3af5225edd8e9a4123867b647de9405d5c4b9efc
CRs-Fixed: 642893