hal: 64KHz clips are playing mute on HDMI

- 64KHz clips are playing mute on HDMI device
- The root cause of the issue is copp is getting
  configured at stream sample rate which is not
  supported by ADM(DSP)
- Fix contains mapping of sample rates to the
  closest match supported by HDMI device
- CRs-Fixed: 2107374

Change-Id: I918df1d7adcbbde00d82a47fc95b96d9b18fe334
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 45b02e3..50ab6f9 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -6708,6 +6708,9 @@
      } else
          *sample_rate = stream_sr;
 
+     if (snd_device == SND_DEVICE_OUT_HDMI)
+         *sample_rate = platform_get_supported_sampling_rate_on_hdmi(stream_sr);
+
      ALOGI("sn_device %d device sr %d stream sr %d copp sr %d", snd_device, device_sr, stream_sr
 , *sample_rate);
 
@@ -7811,6 +7814,48 @@
     return MAX_CODEC_BACKENDS;
 }
 
+int platform_get_supported_sampling_rate_on_hdmi(uint32_t stream_sr)
+{
+    int sample_rate;
+    switch (stream_sr){
+        case 8000:
+        case 11025:
+        case 16000:
+        case 22050:
+        case 32000:
+        case 48000:
+            sample_rate = 48000;
+            break;
+        case 44100:
+            sample_rate = 44100;
+            break;
+        case 64000:
+        case 96000:
+            sample_rate = 96000;
+            break;
+        case 88200:
+            sample_rate = 88200;
+            break;
+        case 176400:
+            sample_rate = 176400;
+            break;
+        case 192000:
+            sample_rate = 192000;
+            break;
+        case 352800:
+            sample_rate = 352800;
+            break;
+        case 384000:
+            sample_rate = 384000;
+            break;
+        case 144000:
+        default:
+            sample_rate = 48000;
+            break;
+    }
+    return sample_rate;
+}
+
 #if defined(PLATFORM_MSMFALCON)
 int platform_get_mmap_data_fd(void *platform, int fe_dev, int dir, int *fd,
                               uint32_t *size)