audio: invoke CSD client APIs only for Fusion3 platform

- CSD client APIs are only used for Fusion3 platform.
  Always check platform_is_Fusion3() before invoking CSD APIs
- Miscellaneous fix for QCOM FM and ANC flags
  in AudioPolicyManagerALSA

Change-Id: I549b602cd782b737bf75a69e5cabd776547aa0ca
alsa-sound: fix typo

Change-Id: Idce1c52077b14a491cfa5156db16898d35094b79
alsa_sound: Initialize the mPfdProxy in constructor

The uninitialised variable of the proxy parameter PfdProxy in the
ALSADevice constructor is initialized to avoid unnecessary call to

(cherry picked from commit 6d812e2cba18aba1c40159b5e5194d225534235a)

sys_close::lib_close without the proxy session enabled.
CRs-Fixed: 428656

Change-Id: I6ab4f02af3aa67efdf90e61a04c7824df143c35e
alsa_sound: Set tunnel/lpa bit for playback over usb headset

-The tunnel/lpa bit was not being set in all scenarios when
 playback happens over usb headset.
-This resulte in no audio when trying to play the next tunnel
 mode clip.
-Fix by setting the lpa/tunnel bit if the device is usb and
 playback session is tunnel or lpa.

Change-Id: I6721a508e034c836a4aae5cc98cebb6236ee14d0
CRs-Fixed: 447677
alsa_sound: Fix for Audio routing to HDMI when BT connected

Currently when BT is connected Audio routes to HDMI when
HDMI is plugged in and expected behaviour is audio should
route to BT only as BT has higher priority than HDMI.This is
because route function is being called with HDMI device in
openOutputStream. Removing the route call will fix the issue.

Change-Id: I76933b7f19498023ad2739e6b0305d36a2c77bb6
CRs-Fixed: 451268
alsa-sound: AudioSessionOut optimization

- Skip memset(0) for tunnel mode playback in write()
- For LPA playback, call memset(0) only for partial buffers

Change-Id: Ia3cec99afa3bd9750298ebbe7aa6c5fc2ebed927
CRs-Fixed: 444041
alsa_sound: Fix usb headset record noise

-Issue: recording with USB headset has noise
-Fix: Increase the period size to 2048 so that
 number of times that the poll event executed is
 reduced which inturn matches proxy writes to DSP
 in real time

Change-Id: I5a566ce413f0c5c10cf30817b7b4095a2f45c6fa
CRs-Fixed: 426421
alsa-sound: Avoid use of extra bytes to signal seek processed

- A few bytes were reserved in the buffer written by the AudioSessionOut
  client to indicate a seek has been processed and there
  is no need to skip it.
- We won't need this method anymore and its expected the client
  take care of this.

Change-Id: Idfdeb3d41320e3e332424c13638c66ed200c0fee
alsa-sound: Use errno to check for error code of ioctl()

- ioctl() calls by definition must return -1 on failure with
  the error type set in errno.
- Therefore, the return value must not be used
  to check the error type for a failed drain ioctl().
- Use errno instead.

Change-Id: I4d6814bd0da678feaeef17bae83008d4c7376233
hardware/qcom/audio: fix memory leak in alsa_ucm.c file

 - Free the current device if no valid device is found in
   set_controls_of_usecase_for_all_devices function.

(cherry picked from commit c03520e5e6c9fe7ec35ddcb510a8ab53ebb023b5)

CRs-fixed: 421414
Change-Id: I759baaa8b3257950aa712fc2aaa28aa38a064a21
alsa_sound: Fix to prevent additioal doRouting call

- During an MO VoLTE call if BT is connected then
  no sound was heard on either side.
- When the Call state was updated for VoLTE,
  doRouting was called, which tried to set BT with
  A2DP profile as the device if BT was connected.
- Added a check to call doRouting only when an
  ACTIVE or HELD call's state is being changed.

Change-Id: I8422c024e52abd99836cadd15a2d5df9d36f2eea
CRs-fixed: 446294