audio_hal: restart fm during device switch if analog wsa presents

afe clock is not enabled when device switched from headset
to wsa speaker, then no sound can be heard from speaker

When device changes, stop the fm to ensure pcm device closed
and restart fm to get the pcm device opened and started, then
afe clock can be enabled

CRs-Fixed: 853022
Change-Id: Ib110ce726c5eb73dd0c51ccfe1c3bd12e6503dc5
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index ed3776c..efc2307 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -243,7 +243,20 @@
         if (ret >= 0) {
             val = atoi(value);
             if(val > 0)
-                select_devices(adev, USECASE_AUDIO_PLAYBACK_FM);
+                /*
+                 * Only when wsa does present and is in analog mode,
+                 * fm will stop/start here.
+                 * To-do: when the kernel codec type query change
+                 * is ready, enum of wsa mode should be checked here.
+                 * Currently, platform_get_wsa_mode will directly return
+                 * 1 when wsa is in analog mode.
+                 */
+                if (platform_get_wsa_mode(adev->platform) == 1) {
+                    fm_stop(adev);
+                    fm_start(adev);
+                } else {
+                    select_devices(adev, USECASE_AUDIO_PLAYBACK_FM);
+                }
         }
     }
     if (fmmod.restart_fm && (fmmod.scard_state == SND_CARD_STATE_ONLINE)) {