hal: audio: Add support to pick 32KHz and 144KHz sampling rate

Add support to pick 32kHz and 144KHz samplig rates for backend
configuration of passthrough usecases.

Do not update the bit width for passthrough usecases as output
will always operate at 16bit for passthrough usecases.

CRs-fixed: 1071692
Change-Id: I326cb9e906268566ecc4a7639804f06585b4004b
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index e554d86..dc933d3 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3987,7 +3987,11 @@
         out->compr_config.codec->ch_in =
                 audio_channel_count_from_out_mask(out->channel_mask);
         out->compr_config.codec->ch_out = out->compr_config.codec->ch_in;
-        out->bit_width = AUDIO_OUTPUT_BIT_WIDTH;
+        /* Update bit width only for non passthrough usecases.
+         * For passthrough usecases, the output will always be opened @16 bit
+         */
+        if (!audio_extn_passthru_is_passthrough_stream(out))
+            out->bit_width = AUDIO_OUTPUT_BIT_WIDTH;
         /*TODO: Do we need to change it for passthrough */
         out->compr_config.codec->format = SND_AUDIOSTREAMFORMAT_RAW;
 
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index d4f9710..fad2c04 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -4689,11 +4689,11 @@
      */
     // TODO: This has to be more dynamic based on policy file
 
-    if ((my_data->current_backend_cfg[backend_idx].samplerate_mixer_ctl) &&
+    if (passthrough_enabled || ((my_data->current_backend_cfg[backend_idx].samplerate_mixer_ctl) &&
         (sample_rate != my_data->current_backend_cfg[(int)backend_idx].sample_rate) &&
             (my_data->hifi_audio ||
             backend_idx == USB_AUDIO_RX_BACKEND ||
-            backend_idx == USB_AUDIO_TX_BACKEND)) {
+            backend_idx == USB_AUDIO_TX_BACKEND))) {
             /*
              * sample rate update is needed only for hifi audio enabled platforms
              */
@@ -4701,11 +4701,15 @@
             struct  mixer_ctl *ctl = NULL;
 
             switch (sample_rate) {
+            case 32000:
+                if (passthrough_enabled) {
+                    rate_str = "KHZ_32";
+                    break;
+                }
             case 8000:
             case 11025:
             case 16000:
             case 22050:
-            case 32000:
             case 48000:
                 rate_str = "KHZ_48";
                 break;
@@ -4731,6 +4735,11 @@
             case 384000:
                 rate_str = "KHZ_384";
                 break;
+            case 144000:
+                if (passthrough_enabled) {
+                    rate_str = "KHZ_144";
+                    break;
+                }
             default:
                 rate_str = "KHZ_48";
                 break;
@@ -5646,6 +5655,7 @@
         format = AAC;
         break;
     case AUDIO_FORMAT_E_AC3:
+    case AUDIO_FORMAT_E_AC3_JOC:
         ALOGV("%s:E_AC3", __func__);
         format = DOLBY_DIGITAL_PLUS;
         break;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index a73f13e..a0570f2 100755
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -4591,17 +4591,21 @@
         ret = 0;
     }
 
-    if ((my_data->current_backend_cfg[backend_idx].samplerate_mixer_ctl) &&
-        (sample_rate != my_data->current_backend_cfg[backend_idx].sample_rate)) {
+    if (passthrough_enabled || ((my_data->current_backend_cfg[backend_idx].samplerate_mixer_ctl) &&
+        (sample_rate != my_data->current_backend_cfg[backend_idx].sample_rate))) {
             char *rate_str = NULL;
             struct  mixer_ctl *ctl = NULL;
 
             switch (sample_rate) {
+            case 32000:
+                if (passthrough_enabled) {
+                    rate_str = "KHZ_32";
+                    break;
+                }
             case 8000:
             case 11025:
             case 16000:
             case 22050:
-            case 32000:
             case 48000:
                 rate_str = "KHZ_48";
                 break;
@@ -4627,7 +4631,12 @@
             case 384000:
                 rate_str = "KHZ_384";
                 break;
-            default:
+            case 144000:
+                if (passthrough_enabled) {
+                    rate_str = "KHZ_144";
+                    break;
+                }
+           default:
                 rate_str = "KHZ_48";
                 break;
             }
@@ -5493,6 +5502,7 @@
         format = AAC;
         break;
     case AUDIO_FORMAT_E_AC3:
+    case AUDIO_FORMAT_E_AC3_JOC:
         ALOGV("%s:E_AC3", __func__);
         format = DOLBY_DIGITAL_PLUS;
         break;