hal: add platform filter to distinguish among various internal codecs

Some platforms are internal codec but support TX BE bit width up to 24,
sample rate up to 192K and channel up to 8, it shouldn't configure them
to default value.

Add platform filter for these platforms to check that it should configure
them to requested or default value.

CRs-Fixed: 2623646
Change-Id: Ie79b7c886f42c9dca4dc786e3bc0517c6d464ad5
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index ed23aca..3cf4127 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -311,6 +311,7 @@
     bool gsm_mode_enabled;
     bool is_slimbus_interface;
     bool is_internal_codec;
+    bool is_default_be_config;
     int mono_speaker;
     bool voice_speaker_stereo;
     /* Audio calibration related functions */
@@ -1725,6 +1726,13 @@
          my_data->is_internal_codec = true;
          my_data->is_slimbus_interface = false;
      }
+
+    if (!strncmp(snd_card_name, "sdm670", strlen("sdm670")) ||
+        !strncmp(snd_card_name, "sdm660", strlen("sdm660")) ||
+        !strncmp(snd_card_name, "qcs605", strlen("qcs605")) ||
+        !strncmp(snd_card_name, "sdm439", strlen("sdm439"))) {
+        my_data->is_default_be_config = true;
+    }
 }
 
 static bool can_enable_mbdrc_on_device(snd_device_t snd_device)
@@ -3022,6 +3030,7 @@
 
     my_data->is_slimbus_interface = true;
     my_data->is_internal_codec = false;
+    my_data->is_default_be_config = false;
 
     my_data->hw_info = hw_info_init(snd_card_name);
     if (!my_data->hw_info) {
@@ -9667,7 +9676,9 @@
         bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
         sample_rate =  CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
         channels = CODEC_BACKEND_DEFAULT_TX_CHANNELS;
-    } else if (my_data->is_internal_codec && !audio_is_usb_in_device(snd_device)) {
+    } else if (my_data->is_internal_codec &&
+               my_data->is_default_be_config &&
+               !audio_is_usb_in_device(snd_device)) {
         sample_rate =  CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
         channels = CODEC_BACKEND_DEFAULT_TX_CHANNELS;
         if (in && in->bit_width == 24)
@@ -9698,6 +9709,11 @@
                     channels = uc_channels;
             }
         }
+        if ((sample_rate % INPUT_SAMPLING_RATE_11025 == 0) &&
+            (!audio_is_usb_in_device(snd_device))) {
+            ALOGV("%s:txbecf: afe: set sample rate to default Sample Rate(48k)",__func__);
+            sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+        }
     }
     if (backend_idx == USB_AUDIO_TX_BACKEND) {
         audio_extn_usb_is_config_supported(&bit_width, &sample_rate, &channels, false);
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index be138c0..6627112 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -315,6 +315,7 @@
 };
 #define INPUT_SAMPLING_RATE_DSD64       2822400
 #define INPUT_SAMPLING_RATE_DSD128      5644800
+#define INPUT_SAMPLING_RATE_11025       11025
 #define DEFAULT_OUTPUT_SAMPLING_RATE    48000
 #define OUTPUT_SAMPLING_RATE_44100      44100
 #define OUTPUT_SAMPLING_RATE_DSD64       176400