blob: 7ff1b7b69d6cd6c106128c8c37e1efa69085cc88 [file] [log] [blame]
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -07001/*
Harshal Ahire5bbb5fb2021-01-28 18:23:14 +05302 * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -07003 * Not a Contribution.
4 *
5 * Copyright (C) 2013 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#define LOG_TAG "audio_hw_fm"
21/*#define LOG_NDEBUG 0*/
22#define LOG_NDDEBUG 0
23
24#include <errno.h>
25#include <math.h>
Weiyin Jiang2995f662019-04-17 14:25:12 +080026#include <log/log.h>
Vinay Vermaaddfa4a2018-04-29 14:03:38 +053027#include <unistd.h>
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070028
29#include "audio_hw.h"
30#include "platform.h"
31#include "platform_api.h"
32#include <stdlib.h>
33#include <cutils/str_parms.h>
Arun Mirpurie008ed22019-03-21 11:21:04 -070034#include <audio_extn.h>
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070035
Revathi Uddaraju1eac8b02017-05-18 17:13:33 +053036#ifdef DYNAMIC_LOG_ENABLED
37#include <log_xml_parser.h>
38#define LOG_MASK HAL_MOD_FILE_FM
39#include <log_utils.h>
40#endif
41
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070042#define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm"
43#define AUDIO_PARAMETER_KEY_FM_VOLUME "fm_volume"
Naresh Tanniru9e95c242014-12-08 16:49:22 +053044#define AUDIO_PARAMETER_KEY_REC_PLAY_CONC "rec_play_conc_on"
Dhananjay Kumareeb6b312016-01-25 19:45:19 +053045#define AUDIO_PARAMETER_KEY_FM_MUTE "fm_mute"
Yidong Huang7939a3b2018-01-23 17:32:30 +080046#define AUDIO_PARAMETER_KEY_FM_RESTORE_VOLUME "fm_restore_volume"
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +053047#define AUDIO_PARAMETER_KEY_FM_ROUTING "fm_routing"
Preetam Singh Ranawat3fcfa262018-12-17 17:08:30 +053048#define AUDIO_PARAMETER_KEY_FM_STATUS "fm_status"
Dhananjay Kumardf8aecf2015-10-01 13:38:37 +053049#define FM_LOOPBACK_DRAIN_TIME_MS 2
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070050
51static struct pcm_config pcm_config_fm = {
52 .channels = 2,
53 .rate = 48000,
54 .period_size = 256,
55 .period_count = 4,
56 .format = PCM_FORMAT_S16_LE,
57 .start_threshold = 0,
58 .stop_threshold = INT_MAX,
59 .avail_min = 0,
60};
61
62struct fm_module {
63 struct pcm *fm_pcm_rx;
64 struct pcm *fm_pcm_tx;
65 bool is_fm_running;
Dhananjay Kumareeb6b312016-01-25 19:45:19 +053066 bool is_fm_muted;
Ravi Kumar Alamandacb065742013-11-20 18:31:58 -080067 float fm_volume;
Dhanalakshmi Siddani7b4cb782014-05-30 11:20:27 +053068 bool restart_fm;
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +053069 audio_devices_t fm_device;
Dhananjay Kumare6293dd2017-05-25 17:25:30 +053070 card_status_t card_status;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070071};
72
73static struct fm_module fmmod = {
74 .fm_pcm_rx = NULL,
75 .fm_pcm_tx = NULL,
76 .fm_volume = 0,
77 .is_fm_running = 0,
Dhananjay Kumareeb6b312016-01-25 19:45:19 +053078 .is_fm_muted = 0,
Dhanalakshmi Siddani7b4cb782014-05-30 11:20:27 +053079 .restart_fm = 0,
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +053080 .fm_device = 0,
Dhananjay Kumare6293dd2017-05-25 17:25:30 +053081 .card_status = CARD_STATUS_ONLINE,
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070082};
83
Dhananjay Kumardf8aecf2015-10-01 13:38:37 +053084static int32_t fm_set_volume(struct audio_device *adev, float value, bool persist)
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070085{
86 int32_t vol, ret = 0;
87 struct mixer_ctl *ctl;
Harshal Ahire5bbb5fb2021-01-28 18:23:14 +053088 const char *mixer_ctl_name;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070089
Ravi Kumar Alamandacb065742013-11-20 18:31:58 -080090 ALOGV("%s: entry", __func__);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -070091 ALOGD("%s: (%f)\n", __func__, value);
92
Harshal Ahire5bbb5fb2021-01-28 18:23:14 +053093 mixer_ctl_name = platform_get_mixer_FM_RX_control(adev);
94 if (!mixer_ctl_name) {
95 ALOGE("%s: Could not get FM_RX mixer control",
96 __func__);
97 return -EINVAL;
98 }
99
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700100 if (value < 0.0) {
101 ALOGW("%s: (%f) Under 0.0, assuming 0.0\n", __func__, value);
102 value = 0.0;
103 } else if (value > 1.0) {
104 ALOGW("%s: (%f) Over 1.0, assuming 1.0\n", __func__, value);
105 value = 1.0;
106 }
107 vol = lrint((value * 0x2000) + 0.5);
Dhananjay Kumardf8aecf2015-10-01 13:38:37 +0530108 if (persist)
109 fmmod.fm_volume = value;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700110
Dhananjay Kumareeb6b312016-01-25 19:45:19 +0530111 if (fmmod.is_fm_muted == true && vol > 0) {
112 ALOGD("%s: fm is muted, applying '0' volume instead of '%d'.",
113 __func__, vol);
114 vol = 0;
115 }
116
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700117 if (!fmmod.is_fm_running) {
118 ALOGV("%s: FM not active, ignoring set_fm_volume call", __func__);
119 return -EIO;
120 }
121
122 ALOGD("%s: Setting FM volume to %d \n", __func__, vol);
123 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
124 if (!ctl) {
125 ALOGE("%s: Could not get ctl for mixer cmd - %s",
126 __func__, mixer_ctl_name);
127 return -EINVAL;
128 }
Ravi Kumar Alamandacb065742013-11-20 18:31:58 -0800129 mixer_ctl_set_value(ctl, 0, vol);
Ravi Kumar Alamandacb065742013-11-20 18:31:58 -0800130 ALOGV("%s: exit", __func__);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700131 return ret;
132}
133
134static int32_t fm_stop(struct audio_device *adev)
135{
Satya Krishna Pindiprolif1cd92b2016-04-14 19:05:23 +0530136 int32_t ret = 0;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700137 struct audio_usecase *uc_info;
138
139 ALOGD("%s: enter", __func__);
140 fmmod.is_fm_running = false;
141
142 /* 1. Close the PCM devices */
143 if (fmmod.fm_pcm_rx) {
144 pcm_close(fmmod.fm_pcm_rx);
145 fmmod.fm_pcm_rx = NULL;
146 }
147 if (fmmod.fm_pcm_tx) {
148 pcm_close(fmmod.fm_pcm_tx);
149 fmmod.fm_pcm_tx = NULL;
150 }
151
152 uc_info = get_usecase_from_list(adev, USECASE_AUDIO_PLAYBACK_FM);
153 if (uc_info == NULL) {
154 ALOGE("%s: Could not find the usecase (%d) in the list",
155 __func__, USECASE_VOICE_CALL);
156 return -EINVAL;
157 }
158
159 /* 2. Get and set stream specific mixer controls */
Haynes Mathew George1376ca62014-04-24 11:55:48 -0700160 disable_audio_route(adev, uc_info);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700161
162 /* 3. Disable the rx and tx devices */
Haynes Mathew George1376ca62014-04-24 11:55:48 -0700163 disable_snd_device(adev, uc_info->out_snd_device);
164 disable_snd_device(adev, uc_info->in_snd_device);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700165
166 list_remove(&uc_info->list);
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530167 free(uc_info->stream.out);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700168 free(uc_info);
169
170 ALOGD("%s: exit: status(%d)", __func__, ret);
171 return ret;
172}
173
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530174
175static int32_t fm_start(struct audio_device *adev, audio_devices_t outputDevices)
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700176{
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530177 struct stream_out *fm_out;
Satya Krishna Pindiprolif1cd92b2016-04-14 19:05:23 +0530178 int32_t ret = 0;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700179 struct audio_usecase *uc_info;
180 int32_t pcm_dev_rx_id, pcm_dev_tx_id;
181
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530182 ALOGD("%s: Start FM over output device %d ", __func__, outputDevices);
183
184 fm_out = (struct stream_out *)calloc(1, sizeof(struct stream_out));
185 if (!fm_out)
186 return -ENOMEM;
187
188 fm_out->sample_rate = 48000;
189 fm_out->format = AUDIO_FORMAT_PCM_16_BIT;
190 fm_out->usecase = USECASE_AUDIO_PLAYBACK_FM;
191 fm_out->config = pcm_config_fm;
Aniket Kumar Lata6bfa5162020-02-23 21:34:32 -0800192 list_init(&fm_out->device_list);
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800193 reassign_device_list(&fm_out->device_list, outputDevices, "");
Soumya Managoli6993b762018-06-28 16:04:57 +0530194 fmmod.is_fm_running = true;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700195
196 uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700197
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530198 if (!uc_info) {
199 free(fm_out);
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700200 return -ENOMEM;
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530201 }
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700202
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700203 uc_info->id = USECASE_AUDIO_PLAYBACK_FM;
204 uc_info->type = PCM_PLAYBACK;
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530205 uc_info->stream.out = fm_out;
Aniket Kumar Lata6bfa5162020-02-23 21:34:32 -0800206 list_init(&uc_info->device_list);
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800207 reassign_device_list(&uc_info->device_list, outputDevices, "");
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700208 uc_info->in_snd_device = SND_DEVICE_NONE;
209 uc_info->out_snd_device = SND_DEVICE_NONE;
210
211 list_add_tail(&adev->usecase_list, &uc_info->list);
212
213 select_devices(adev, USECASE_AUDIO_PLAYBACK_FM);
214
215 pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
216 pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
217
218 if (pcm_dev_rx_id < 0 || pcm_dev_tx_id < 0) {
219 ALOGE("%s: Invalid PCM devices (rx: %d tx: %d) for the usecase(%d)",
220 __func__, pcm_dev_rx_id, pcm_dev_tx_id, uc_info->id);
221 ret = -EIO;
222 goto exit;
223 }
224
225 ALOGV("%s: FM PCM devices (rx: %d tx: %d) for the usecase(%d)",
226 __func__, pcm_dev_rx_id, pcm_dev_tx_id, uc_info->id);
227
228 ALOGV("%s: Opening PCM playback device card_id(%d) device_id(%d)",
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800229 __func__, adev->snd_card, pcm_dev_rx_id);
230 fmmod.fm_pcm_rx = pcm_open(adev->snd_card,
231 pcm_dev_rx_id,
232 PCM_OUT, &pcm_config_fm);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700233 if (fmmod.fm_pcm_rx && !pcm_is_ready(fmmod.fm_pcm_rx)) {
234 ALOGE("%s: %s", __func__, pcm_get_error(fmmod.fm_pcm_rx));
235 ret = -EIO;
236 goto exit;
237 }
238
239 ALOGV("%s: Opening PCM capture device card_id(%d) device_id(%d)",
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800240 __func__, adev->snd_card, pcm_dev_tx_id);
241 fmmod.fm_pcm_tx = pcm_open(adev->snd_card,
242 pcm_dev_tx_id,
243 PCM_IN, &pcm_config_fm);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700244 if (fmmod.fm_pcm_tx && !pcm_is_ready(fmmod.fm_pcm_tx)) {
245 ALOGE("%s: %s", __func__, pcm_get_error(fmmod.fm_pcm_tx));
246 ret = -EIO;
247 goto exit;
248 }
249 pcm_start(fmmod.fm_pcm_rx);
250 pcm_start(fmmod.fm_pcm_tx);
251
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800252 fmmod.fm_device = get_device_types(&fm_out->device_list);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700253
254 ALOGD("%s: exit: status(%d)", __func__, ret);
255 return 0;
256
257exit:
258 fm_stop(adev);
259 ALOGE("%s: Problem in FM start: status(%d)", __func__, ret);
260 return ret;
261}
262
Arun Mirpurib1bec9c2019-01-29 16:42:45 -0800263void fm_get_parameters(struct str_parms *query, struct str_parms *reply)
Preetam Singh Ranawat3fcfa262018-12-17 17:08:30 +0530264{
265 int ret, val;
266 char value[32]={0};
267
268 ALOGV("%s: enter", __func__);
269 ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_FM_STATUS, value, sizeof(value));
270 if (ret >= 0) {
271 val = (fmmod.is_fm_running ? 1: 0);
272 str_parms_add_int(reply, AUDIO_PARAMETER_KEY_FM_STATUS, val);
273 }
274}
275
Arun Mirpurib1bec9c2019-01-29 16:42:45 -0800276void fm_set_parameters(struct audio_device *adev,
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700277 struct str_parms *parms)
278{
279 int ret, val;
280 char value[32]={0};
281 float vol =0.0;
282
283 ALOGV("%s: enter", __func__);
Dhanalakshmi Siddani7b4cb782014-05-30 11:20:27 +0530284 ret = str_parms_get_str(parms, "SND_CARD_STATUS", value, sizeof(value));
285 if (ret >= 0) {
286 char *snd_card_status = value+2;
287 if (strstr(snd_card_status, "OFFLINE")) {
Dhananjay Kumare6293dd2017-05-25 17:25:30 +0530288 fmmod.card_status = CARD_STATUS_OFFLINE;
Dhanalakshmi Siddani7b4cb782014-05-30 11:20:27 +0530289 }
290 else if (strstr(snd_card_status, "ONLINE")) {
Dhananjay Kumare6293dd2017-05-25 17:25:30 +0530291 fmmod.card_status = CARD_STATUS_ONLINE;
Dhanalakshmi Siddani7b4cb782014-05-30 11:20:27 +0530292 }
293 }
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700294 if(fmmod.is_fm_running) {
Dhananjay Kumare6293dd2017-05-25 17:25:30 +0530295 if (fmmod.card_status == CARD_STATUS_OFFLINE) {
Dhanalakshmi Siddani7b4cb782014-05-30 11:20:27 +0530296 ALOGD("sound card is OFFLINE, stop FM");
297 fm_stop(adev);
298 fmmod.restart_fm = 1;
299 }
300
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700301 ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
302 value, sizeof(value));
303 if (ret >= 0) {
304 val = atoi(value);
305 if(val > 0)
306 select_devices(adev, USECASE_AUDIO_PLAYBACK_FM);
307 }
308 }
Dhananjay Kumare6293dd2017-05-25 17:25:30 +0530309 if (fmmod.restart_fm && (fmmod.card_status == CARD_STATUS_ONLINE)) {
Dhanalakshmi Siddani7b4cb782014-05-30 11:20:27 +0530310 ALOGD("sound card is ONLINE, restart FM");
311 fmmod.restart_fm = 0;
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530312 fm_start(adev, fmmod.fm_device);
Dhanalakshmi Siddani7b4cb782014-05-30 11:20:27 +0530313 }
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700314
315 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HANDLE_FM,
316 value, sizeof(value));
317 if (ret >= 0) {
318 val = atoi(value);
319 ALOGD("%s: FM usecase", __func__);
320 if (val != 0) {
321 if(val & AUDIO_DEVICE_OUT_FM
Ravi Kumar Alamanda014b6b92014-04-22 15:19:13 -0700322 && fmmod.is_fm_running == false) {
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530323 audio_devices_t OutputDevice = val & ~AUDIO_DEVICE_OUT_FM;
324 fm_start(adev, OutputDevice);
Ravi Kumar Alamanda014b6b92014-04-22 15:19:13 -0700325 } else if (!(val & AUDIO_DEVICE_OUT_FM)
Dhananjay Kumardf8aecf2015-10-01 13:38:37 +0530326 && fmmod.is_fm_running == true) {
327 fm_set_volume(adev, 0, false);
328 usleep(FM_LOOPBACK_DRAIN_TIME_MS*1000);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700329 fm_stop(adev);
Dhananjay Kumardf8aecf2015-10-01 13:38:37 +0530330 }
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700331 }
332 }
333
Preetam Singh Ranawat0e4d9e02018-11-01 11:58:08 +0530334 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_FM_ROUTING,
335 value, sizeof(value));
336 if (ret >= 0 && fmmod.is_fm_running) {
337 val = atoi(value);
338 ALOGD("%s: FM usecase", __func__);
339 if (val != 0) {
340 if(val & AUDIO_DEVICE_OUT_FM) {
341 audio_devices_t OutputDevice = val & ~AUDIO_DEVICE_OUT_FM;
342 fm_set_volume(adev, 0, false);
343 fm_stop(adev);
344 fm_start(adev, OutputDevice);
345 }
346 }
347 }
348
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700349 memset(value, 0, sizeof(value));
350 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_FM_VOLUME,
351 value, sizeof(value));
352 if (ret >= 0) {
353 if (sscanf(value, "%f", &vol) != 1){
354 ALOGE("%s: error in retrieving fm volume", __func__);
355 ret = -EIO;
356 goto exit;
357 }
358 ALOGD("%s: set_fm_volume usecase", __func__);
Dhananjay Kumardf8aecf2015-10-01 13:38:37 +0530359 fm_set_volume(adev, vol, true);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700360 }
361
Dhananjay Kumareeb6b312016-01-25 19:45:19 +0530362 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_FM_MUTE,
363 value, sizeof(value));
364 if (ret >= 0) {
365 if (value[0] == '1')
366 fmmod.is_fm_muted = true;
367 else
368 fmmod.is_fm_muted = false;
369 ALOGV("%s: set_fm_volume from param mute", __func__);
370 fm_set_volume(adev, fmmod.fm_volume, false);
371 }
372
Yidong Huang7939a3b2018-01-23 17:32:30 +0800373 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_FM_RESTORE_VOLUME,
374 value, sizeof(value));
375 if (ret >= 0) {
376 if (value[0] == '1')
377 fm_set_volume(adev, fmmod.fm_volume, false);
378 ALOGV("%s: set_fm_volume from param restore volume", __func__);
379 }
380
Arun Mirpurie008ed22019-03-21 11:21:04 -0700381 if(audio_extn_is_record_play_concurrency_enabled()) {
382 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_REC_PLAY_CONC,
Naresh Tanniru9e95c242014-12-08 16:49:22 +0530383 value, sizeof(value));
Arun Mirpurie008ed22019-03-21 11:21:04 -0700384 if ((ret >= 0)
385 && (fmmod.is_fm_running == true)) {
Naresh Tanniru9e95c242014-12-08 16:49:22 +0530386
Arun Mirpurie008ed22019-03-21 11:21:04 -0700387 if (!strncmp("true", value, sizeof("true")))
388 ALOGD("Record play concurrency ON Forcing FM device reroute");
389 else
390 ALOGD("Record play concurrency OFF Forcing FM device reroute");
Naresh Tanniru9e95c242014-12-08 16:49:22 +0530391
Arun Mirpurie008ed22019-03-21 11:21:04 -0700392 select_devices(adev, USECASE_AUDIO_PLAYBACK_FM);
393 fm_set_volume(adev, fmmod.fm_volume, false);
394 }
Naresh Tanniru9e95c242014-12-08 16:49:22 +0530395 }
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700396exit:
397 ALOGV("%s: exit", __func__);
398}
Lakshman Chaluvaraju06677b42019-06-24 10:04:52 +0530399
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800400void audio_extn_fm_route_on_selected_device(struct audio_device *adev,
401 struct listnode *devices)
Lakshman Chaluvaraju06677b42019-06-24 10:04:52 +0530402{
403 struct listnode *node;
404 struct audio_usecase *usecase;
405
406 if (fmmod.is_fm_running) {
407 list_for_each(node, &adev->usecase_list) {
408 usecase = node_to_item(node, struct audio_usecase, list);
409 if (usecase->id == USECASE_AUDIO_PLAYBACK_FM) {
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800410 if (fmmod.fm_device != get_device_types(devices)) {
Lakshman Chaluvaraju06677b42019-06-24 10:04:52 +0530411 ALOGV("%s selected routing device %x current device %x"
412 "are different, reroute on selected device", __func__,
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800413 fmmod.fm_device, get_device_types(devices));
Lakshman Chaluvaraju06677b42019-06-24 10:04:52 +0530414 select_devices(adev, usecase->id);
415 }
416 }
417 }
418 }
419}