hal: Offload enhancements

 * Bring in commits from audio-caf to add support for more offload
   formats, gapless offload, PCM offload, and 24-bit playback.

hal : Send drain to the driver if next track returns error

-Partial drain is send to the driver after next track ioctl.
-If next track times out or returns any error then call drain.
-Partial drain will not  be executed if next track fails.

CRs-Fixed: 594977

hal: Add static internal function at the top of the file

-Add check_and_set_gapless_mode and get_offload_buffer_size functions
 at the begining of hal file.

audio: Changes to support AV streaming in offload path

- Widevine sends ADTS data, set ADTS based on the parameter
- Set offload fragment size 2k for all video streaming

 audio: Increase the period size for USB audio

 -During USB audio playback, breaks are heard .This is
  primarily due to overruns of USB buffer from the audio
  HAL.
 -By increasing the period size of USB buffer we are
  avoiding overruns .

  CRs-Fixed: 574897

hal: Add support for PCM in offload path

- Translate PCM Offload format to pcm codec id
- Set 16/24 sub format id in compress params format
- Calculate offload fragment size for pcm
- Move offload calculation functions to platform file
- Update audio policy manager isOffloadSupported
  for pcm offload profile. Use audio.offload.pcm.enable

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

hal: Support for FLAC 24 bit format in offload path

- Add flac in supported codecs list
- Set FLAC codec specific parameters
- Set fragment size based on bit width and sampling rate
  for flac.
- Configure backend to 24/16 bit based on the current
  usecases running

hal: Featureize FLAC offload support

 * Not all devices will have this code in the DSP, let alone the kernel.
 * Featurize it, but leave the codec bit width and sample rate controls
   in place so that 24-bit PCM offload still works.

hal: Offload bugfixes

 * Always reset the bit width and sample rate if any active offload
   stream is different. Failure to do this can crash the DSP, and
   certain limitations come into play when a high samplerate is used
   such as effects being unavailable.
 * Don't send errors to the framework when the timestamp query fails
   before the stream is up and running.

hal: Fix the samplerate/bitwidth comparison

hal: Avoid unnecessary rerouting for sample rate changes

 * The backend codec supports just a few sample rates directly,
   so make sure that we base our decision to reroute on this
   value instead of the actual sample rate of the stream.

hal: Reduce the deep buffer period count.

-Deep buffer period count in the driver is 8. This adds to latency
 of 160ms. This also results in the common block to have 8 buffers.
-The total latency used for AV sync is 320ms. AV sync issues are
 seen due to this big latency
-Reduce the deep buffer cound from 8 to 4. This would reduce the
 latency.

Change-Id: I28c8729cf35790857e8cc7146f98a52b36dfef79
CRs-Fixed: 598792