hal: Enable direct playback support for AUDIO_FORMAT_PCM_FLOAT

-Add changes to support PCM_FLOAT format using direct track.
-For targets supporting true 32 bit, convert FLOAT pcm data
to 32 bit.
-Targets which dont support true 32 bit, convert FLOAT or
32 bit input to 24 bit Packed in HAL.

Change-Id: I8052c8b878bbd4d70c0453df054953d494773b0a
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index cd63143..83e560a 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -65,24 +65,12 @@
 #define COMPRESS_OFFLOAD_FRAGMENT_SIZE_FOR_AV_STREAMING (2 * 1024)
 #define COMPRESS_OFFLOAD_FRAGMENT_SIZE (32 * 1024)
 
-/* Used in calculating fragment size for pcm offload */
-#define PCM_OFFLOAD_BUFFER_DURATION 40 /* 40 millisecs */
-
-/* MAX PCM fragment size cannot be increased  further due
- * to flinger's cblk size of 1mb,and it has to be a multiple of
- * 24 - lcm of channels supported by DSP
- */
-#define MAX_PCM_OFFLOAD_FRAGMENT_SIZE (240 * 1024)
-#define MIN_PCM_OFFLOAD_FRAGMENT_SIZE 512
-
 /*
  * Offload buffer size for compress passthrough
  */
 #define MIN_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (2 * 1024)
 #define MAX_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (8 * 1024)
 
-#define DIV_ROUND_UP(x, y) (((x) + (y) - 1)/(y))
-#define ALIGN(x, y) ((y) * DIV_ROUND_UP((x), (y)))
 /*
  * This file will have a maximum of 38 bytes:
  *
@@ -205,6 +193,7 @@
 } codec_backend_cfg_t;
 
 static native_audio_prop na_props = {0, 0, 0};
+static bool supports_true_32_bit = false;
 typedef int (*acdb_send_gain_dep_cal_t)(int, int, int, int, int);
 
 struct platform_data {
@@ -3421,6 +3410,28 @@
         free(dptr);
 }
 
+static void true_32_bit_set_params(struct str_parms *parms,
+                                 char *value, int len)
+{
+    int ret = 0;
+
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TRUE_32_BIT,
+                            value,len);
+    if (ret >= 0) {
+        if (value && !strncmp(value, "true", sizeof("src")))
+            supports_true_32_bit = true;
+        else
+            supports_true_32_bit = false;
+        str_parms_del(parms, AUDIO_PARAMETER_KEY_TRUE_32_BIT);
+    }
+
+}
+
+bool platform_supports_true_32bit()
+{
+   return supports_true_32_bit;
+}
+
 static void perf_lock_set_params(struct platform_data *platform,
                           struct str_parms *parms,
                           char *value, int len)
@@ -3576,6 +3587,7 @@
     audio_extn_spkr_prot_set_parameters(parms, value, len);
     audio_extn_usb_set_sidetone_gain(parms, value, len);
     perf_lock_set_params(platform, parms, value, len);
+    true_32_bit_set_params(parms, value, len);
 done:
     ALOGV("%s: exit with code(%d)", __func__, ret);
     if(kv_pairs != NULL)
@@ -3961,35 +3973,6 @@
     return fragment_size;
 }
 
-uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info)
-{
-    uint32_t fragment_size = 0;
-    uint32_t bytes_per_sample;
-    uint32_t pcm_offload_time = PCM_OFFLOAD_BUFFER_DURATION;
-
-    bytes_per_sample = audio_bytes_per_sample(info->format);
-
-    //duration is set to 40 ms worth of stereo data at 48Khz
-    //with 16 bit per sample, modify this when the channel
-    //configuration is different
-    fragment_size = (pcm_offload_time
-                     * info->sample_rate
-                     * bytes_per_sample
-                     * popcount(info->channel_mask))/1000;
-    if(fragment_size < MIN_PCM_OFFLOAD_FRAGMENT_SIZE)
-        fragment_size = MIN_PCM_OFFLOAD_FRAGMENT_SIZE;
-    else if(fragment_size > MAX_PCM_OFFLOAD_FRAGMENT_SIZE)
-        fragment_size = MAX_PCM_OFFLOAD_FRAGMENT_SIZE;
-
-    // To have same PCM samples for all channels, the buffer size requires to
-    // be multiple of (number of channels * bytes per sample)
-    // For writes to succeed, the buffer must be written at address which is multiple of 32
-    fragment_size = ALIGN(fragment_size, ((bytes_per_sample) * popcount(info->channel_mask) * 32));
-
-    ALOGI("PCM offload Fragment size to %d bytes", fragment_size);
-    return fragment_size;
-}
-
 /*
  * configures afe with bit width and Sample Rate
  */