audio: Force route call on HAL during device disconnection

- When a wired accessory is connected/disconnected,
  setDeviceConnectionState updates the current device
  only for active outputs and also makes the corresponding
  route call on Audio HAL when the current device is not
  same as the previous device for the active outputs. As
  inactive outputs are not updated in this case, sometimes
  audio policy fails to notify device change to HAL.
  Specific scenario is mentioned below

- If headset is inserted when touch tones are disabled
  and music is in progress, LPA/tunnelled output is updated
  with headset as its current device and also respective
  route call is made on audio HAL. But low latency output
  still has speaker as its current device because it is not
  active. Later, if music is paused and headset is removed,
  setOutputDevice does not make route call on Audio HAL
  when touch tones are played. This is because the current
  device and previous device are same(speaker) for low
  latency output. So Audio HAL tries to play the touch tone
  on headset when headset is not connected.

- Fix is to force route call on HAL after every device
  disconnection irrespective of current and previous device
  being same for the specific output

Change-Id: I80d799718c980d0422d4e5f7015fcf16f001fda9
CRs-Fixed: 627903
audio: Close the file descriptor in error scenarios

 -In the scenario where the USB headset and proxy device
  sample rate dont match, error was returned without
  closing the file descriptor .So, the next time USB
  headset is inserted , the /proc entries are not created
  which results in the USB headset playback not started
  as the capabilities cannot be read.
 - Closing the file descriptor in the error scenario fixes
  the issue.

Change-Id: Ie45327f04cc7fff6dbcbe1268a7f34793e89641b
audio: Force route on HAL when USB headset is disconnected

- 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 force routing audio to speaker as soon as usb
  headset is disconnected
- Added similar check for HDMI device too as it applies
  for HDMI disconnection scenario too

CRs-Fixed: 655403

Change-Id: I3d66654ebc1f324b08104b586f201540f7005dd2
 Audio: Revert hal changes to block pcm_close during SSR

 pcm driver supports pcm_close during SSR, so reverted
 HAL code to block pcm session close during SSR.

 CRs-Fixed: 663477

Change-Id: I752e3f4f55288f91294e090b974ba1367c27122d
Remove current msm7x30 audio HAL

This HAL is outdated & contains legacy code
Remove it so we can import the newest HAL from jb_2.5.3 branch
Import msm7630 audio HAL from jb_2.5.3 branch

Squashed import of the following CAF commits:

a0947f8 audio/msm7630: Initial commit for MR1 Audio bringup.
67550d7 audio: compile only if TARGET_USES_QCOM_MM_AUDIO set to true
51e24b7 msm7630 : Propagate the flag value to status
4642b91 Remove audio_poliy.conf from msm7630
b982f5a audio/8655: Enabling LPA playback by adding AudioSessionOutLPA class
fef3c65 audio/msm8655: Fix for AAC recording failure.
eeae23f msm7630 : Send proper channleMask for getInputProfile()
fe2acf4 Update copyright to The Linux Foundation
4931e2c audio/msm7630: Add usb audio hal profile.
04bcc5f audio/msm7630: Fix for volume change during voice call
58de776 7x30 : Port heap mask change to ion
c0a97d0 audio/msm7630: Fix the issue of voice call when HDMI connected
223c325 audio/msm7630: Fix to enable TTY device
387befb audio/msm7630: Add latency support for LPA
701b6c6 audio/msm7630: Fix for routing camcorded encoded clip audio to wired headset
a20c757 audio/msm7630: Fix for back to back VOIP calls failure
8f6be8a audio/msm7630 : Stability issue with LPA play back.

Signed-off-by: Michael Bestas <mikeioannina@gmail.com>
legacy/msm7x30: Use CM standard qcom naming

* Also add msm7x30 to the build barrier
audio/msm7x30: Fix build in CM

* Build without qcom audio calibration
* Hack for prebuilt libraries we don't have access to
* Little cleanup of makefile
audio/msm7x30: Fix log tags and disable debug logging

Change-Id: I4712b09c86e3a067b0c847661fa43828be6eee23
audio/msm7x30: Stop the log spam during VOIP calls

Change-Id: Idfe211b1fef6f2aeee51ebe7f1b6ce3f4a0787be
audio/msm7x30: disable logcat spam

Change-Id: I82ebb39e62f49c24f236cc9eeadbc303f8dbd823
audio/msm7x30: Fix for Echo in Gtalk

- Echo is observed in Gtalk.
- Audio HAL informs that clients that it handle the Echo
  cancellation and with AHAL client turns off the EC.
- EC is not supported in this PL remove it from getparam
CRs-Fixed: 427161

Change-Id: I62eba7ed7566045f61c34a51c8ac36029b8596ea
audio/msm7x30: Use q5v2_msm_audio_mvs_frame struct

Otherwise a packet size of 640, which 7x30 modem doesn't support,
will be used. 7x30 expects a packet size of 320.

Was changed in AudioHardware::AudioStreamOutDirect::write, but
seems to have been forgotten here.

Related kernel change: http://bit.ly/M7ZqMN

Change-Id: Ie89da836cbe27ea6b6cd10ef5c830ecc7020a624
legacy/msm7x30: Use audio policy from legacy/alsa_sound

* Clone of the legacy/alsa_sound audio policy HAL
audio/msm7x30: Only use earpiece when specified.

There are a few cases where the audio gets routed to earpiece, while it should
be at the speaker mode. To fix this, always default to speaker mode and only use
earpiece when it is specified.

Change-Id: I9fe2e54b20e2aa8aeac4b75b191a51790612f468
audio/msm7x30: fix a crash on audio initialize

Fixes crash on mediaserver if the device_count got from
audioalsa library is greater than DEVICE_COUNT in HAL

Change-Id: Ic5a29ddbee4f7b79ec944e6b48ef8272177659e6
audio/msm7x30: Add system property to toggle headset microphone.

Change-Id: Idb9782808f190da4a715a0c5597043f9c06134d8
audio/msm7x30: Allow devices with mono speaker to function.

If the device has both speakers, stereo will be used.

Change-Id: Ia73a00f09fff56d58f9cd9a29723251734353f83
audio/msm7x30: Allow devices with broadside dual mic to function.

If the device has both dual mics, endfire will be used.

Change-Id: Id6a197e85b159bb4f5452553e3b6a417bd1b9db4
legacy/msm7x30: Make sure to update voice volume when starting call.

Change-Id: I4f42d5d36c5d059e7877503d2ec6d0aad29778dc