blob: 71b13fd61adeedb8a2496c11bc710f817b2f7442 [file] [log] [blame]
Xiaoyu Ye91553e62017-11-21 17:35:50 -08001/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -08002
3Redistribution and use in source and binary forms, with or without
4modification, are permitted provided that the following conditions are
5met:
6 * Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8 * Redistributions in binary form must reproduce the above
9 copyright notice, this list of conditions and the following
10 disclaimer in the documentation and/or other materials provided
11 with the distribution.
12 * Neither the name of The Linux Foundation nor the names of its
13 contributors may be used to endorse or promote products derived
14 from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
27
28#define LOG_TAG "audio_hw_hfp"
29/*#define LOG_NDEBUG 0*/
30#define LOG_NDDEBUG 0
31
32#include <errno.h>
33#include <math.h>
34#include <cutils/log.h>
35
36#include "audio_hw.h"
37#include "platform.h"
38#include "platform_api.h"
39#include <stdlib.h>
40#include <cutils/str_parms.h>
Derek Chencdd17c72014-11-24 12:39:14 -080041#include "audio_extn.h"
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080042
Revathi Uddaraju1eac8b02017-05-18 17:13:33 +053043#ifdef DYNAMIC_LOG_ENABLED
44#include <log_xml_parser.h>
45#define LOG_MASK HAL_MOD_FILE_HFP
46#include <log_utils.h>
47#endif
48
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080049#ifdef HFP_ENABLED
50#define AUDIO_PARAMETER_HFP_ENABLE "hfp_enable"
Vimal Puthanveed47e64852013-12-20 13:23:39 -080051#define AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE "hfp_set_sampling_rate"
Amit Shekhar967cab32014-02-07 17:03:21 -080052#define AUDIO_PARAMETER_KEY_HFP_VOLUME "hfp_volume"
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +053053#define AUDIO_PARAMETER_HFP_PCM_DEV_ID "hfp_pcm_dev_id"
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080054
Sudheer Papothi19e43d02014-07-16 02:34:41 +053055#ifdef PLATFORM_MSM8994
56#define HFP_RX_VOLUME "SEC AUXPCM LOOPBACK Volume"
Banajit Goswamida77c452015-10-14 20:45:22 -070057#elif defined PLATFORM_MSM8996
58#define HFP_RX_VOLUME "PRI AUXPCM LOOPBACK Volume"
Tanya Dixit6e3bccc2018-04-05 13:42:18 +053059#elif defined (PLATFORM_MSM8998) || defined (PLATFORM_MSMFALCON) || defined (PLATFORM_SDM845) || defined (PLATFORM_SDM710) || defined (PLATFORM_QCS605) || defined (PLATFORM_MSMNILE) || defined (PLATFORM_MSMSTEPPE)
Banajit Goswami4c0dff22016-03-04 18:31:22 -080060#define HFP_RX_VOLUME "SLIMBUS_7 LOOPBACK Volume"
Sudheer Papothi19e43d02014-07-16 02:34:41 +053061#else
62#define HFP_RX_VOLUME "Internal HFP RX Volume"
63#endif
64
Vimal Puthanveed584048b2013-12-11 17:00:50 -080065static int32_t start_hfp(struct audio_device *adev,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080066 struct str_parms *parms);
67
Vimal Puthanveed584048b2013-12-11 17:00:50 -080068static int32_t stop_hfp(struct audio_device *adev);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080069
70struct hfp_module {
71 struct pcm *hfp_sco_rx;
72 struct pcm *hfp_sco_tx;
73 struct pcm *hfp_pcm_rx;
74 struct pcm *hfp_pcm_tx;
75 bool is_hfp_running;
Amit Shekhar967cab32014-02-07 17:03:21 -080076 float hfp_volume;
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +053077 int32_t hfp_pcm_dev_id;
Vimal Puthanveed47e64852013-12-20 13:23:39 -080078 audio_usecase_t ucid;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080079};
80
81static struct hfp_module hfpmod = {
82 .hfp_sco_rx = NULL,
83 .hfp_sco_tx = NULL,
84 .hfp_pcm_rx = NULL,
85 .hfp_pcm_tx = NULL,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080086 .is_hfp_running = 0,
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +053087 .hfp_volume = 0,
88 .hfp_pcm_dev_id = HFP_ASM_RX_TX,
Vimal Puthanveed47e64852013-12-20 13:23:39 -080089 .ucid = USECASE_AUDIO_HFP_SCO,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080090};
91static struct pcm_config pcm_config_hfp = {
92 .channels = 1,
93 .rate = 8000,
94 .period_size = 240,
95 .period_count = 2,
96 .format = PCM_FORMAT_S16_LE,
97 .start_threshold = 0,
98 .stop_threshold = INT_MAX,
99 .avail_min = 0,
100};
101
Amit Shekhar967cab32014-02-07 17:03:21 -0800102static int32_t hfp_set_volume(struct audio_device *adev, float value)
103{
104 int32_t vol, ret = 0;
105 struct mixer_ctl *ctl;
Sudheer Papothi19e43d02014-07-16 02:34:41 +0530106 const char *mixer_ctl_name = HFP_RX_VOLUME;
Amit Shekhar967cab32014-02-07 17:03:21 -0800107
108 ALOGV("%s: entry", __func__);
109 ALOGD("%s: (%f)\n", __func__, value);
110
Satya Krishna Pindiproli3ed6d792014-09-09 15:32:25 +0530111 hfpmod.hfp_volume = value;
Amit Shekhar967cab32014-02-07 17:03:21 -0800112 if (value < 0.0) {
113 ALOGW("%s: (%f) Under 0.0, assuming 0.0\n", __func__, value);
114 value = 0.0;
115 } else {
116 value = ((value > 15.000000) ? 1.0 : (value / 15));
117 ALOGW("%s: Volume brought with in range (%f)\n", __func__, value);
118 }
119 vol = lrint((value * 0x2000) + 0.5);
Amit Shekhar967cab32014-02-07 17:03:21 -0800120
121 if (!hfpmod.is_hfp_running) {
122 ALOGV("%s: HFP not active, ignoring set_hfp_volume call", __func__);
123 return -EIO;
124 }
125
126 ALOGD("%s: Setting HFP volume to %d \n", __func__, vol);
127 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
128 if (!ctl) {
129 ALOGE("%s: Could not get ctl for mixer cmd - %s",
130 __func__, mixer_ctl_name);
131 return -EINVAL;
132 }
133 if(mixer_ctl_set_value(ctl, 0, vol) < 0) {
134 ALOGE("%s: Couldn't set HFP Volume: [%d]", __func__, vol);
135 return -EINVAL;
136 }
137
138 ALOGV("%s: exit", __func__);
139 return ret;
140}
141
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800142static int32_t start_hfp(struct audio_device *adev,
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700143 struct str_parms *parms __unused)
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800144{
Satya Krishna Pindiprolif1cd92b2016-04-14 19:05:23 +0530145 int32_t ret = 0;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800146 struct audio_usecase *uc_info;
147 int32_t pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, pcm_dev_asm_tx_id;
148
149 ALOGD("%s: enter", __func__);
150
151 uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700152
153 if (!uc_info)
154 return -ENOMEM;
155
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800156 uc_info->id = hfpmod.ucid;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800157 uc_info->type = PCM_HFP_CALL;
158 uc_info->stream.out = adev->primary_output;
159 uc_info->devices = adev->primary_output->devices;
160 uc_info->in_snd_device = SND_DEVICE_NONE;
161 uc_info->out_snd_device = SND_DEVICE_NONE;
162
163 list_add_tail(&adev->usecase_list, &uc_info->list);
164
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800165 select_devices(adev, hfpmod.ucid);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800166
Derek Chencdd17c72014-11-24 12:39:14 -0800167 if ((uc_info->out_snd_device != SND_DEVICE_NONE) ||
168 (uc_info->in_snd_device != SND_DEVICE_NONE)) {
169 if (audio_extn_ext_hw_plugin_usecase_start(adev->ext_hw_plugin, uc_info))
170 ALOGE("%s: failed to start ext hw plugin", __func__);
171 }
172
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800173 pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
174 pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530175 pcm_dev_asm_rx_id = hfpmod.hfp_pcm_dev_id;
176 pcm_dev_asm_tx_id = hfpmod.hfp_pcm_dev_id;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800177 if (pcm_dev_rx_id < 0 || pcm_dev_tx_id < 0 ||
178 pcm_dev_asm_rx_id < 0 || pcm_dev_asm_tx_id < 0 ) {
179 ALOGE("%s: Invalid PCM devices (rx: %d tx: %d asm: rx tx %d) for the usecase(%d)",
180 __func__, pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, uc_info->id);
181 ret = -EIO;
182 goto exit;
183 }
184
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530185 ALOGD("%s: HFP PCM devices (rx: %d tx: %d pcm dev id: %d) usecase(%d)",
186 __func__, pcm_dev_rx_id, pcm_dev_tx_id, hfpmod.hfp_pcm_dev_id, uc_info->id);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800187
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800188 hfpmod.hfp_sco_rx = pcm_open(adev->snd_card,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800189 pcm_dev_asm_rx_id,
190 PCM_OUT, &pcm_config_hfp);
191 if (hfpmod.hfp_sco_rx && !pcm_is_ready(hfpmod.hfp_sco_rx)) {
192 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_sco_rx));
193 ret = -EIO;
194 goto exit;
195 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530196
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800197 hfpmod.hfp_pcm_rx = pcm_open(adev->snd_card,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800198 pcm_dev_rx_id,
199 PCM_OUT, &pcm_config_hfp);
200 if (hfpmod.hfp_pcm_rx && !pcm_is_ready(hfpmod.hfp_pcm_rx)) {
201 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_pcm_rx));
202 ret = -EIO;
203 goto exit;
204 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530205
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800206 hfpmod.hfp_sco_tx = pcm_open(adev->snd_card,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800207 pcm_dev_asm_tx_id,
208 PCM_IN, &pcm_config_hfp);
209 if (hfpmod.hfp_sco_tx && !pcm_is_ready(hfpmod.hfp_sco_tx)) {
210 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_sco_tx));
211 ret = -EIO;
212 goto exit;
213 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530214
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800215 hfpmod.hfp_pcm_tx = pcm_open(adev->snd_card,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800216 pcm_dev_tx_id,
217 PCM_IN, &pcm_config_hfp);
218 if (hfpmod.hfp_pcm_tx && !pcm_is_ready(hfpmod.hfp_pcm_tx)) {
219 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_pcm_tx));
220 ret = -EIO;
221 goto exit;
222 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530223
Satya Krishna Pindiprolice903a02014-07-28 12:40:56 +0530224 if (pcm_start(hfpmod.hfp_sco_rx) < 0) {
225 ALOGE("%s: pcm start for hfp sco rx failed", __func__);
226 ret = -EINVAL;
227 goto exit;
228 }
229 if (pcm_start(hfpmod.hfp_sco_tx) < 0) {
230 ALOGE("%s: pcm start for hfp sco tx failed", __func__);
231 ret = -EINVAL;
232 goto exit;
233 }
234 if (pcm_start(hfpmod.hfp_pcm_rx) < 0) {
235 ALOGE("%s: pcm start for hfp pcm rx failed", __func__);
236 ret = -EINVAL;
237 goto exit;
238 }
239 if (pcm_start(hfpmod.hfp_pcm_tx) < 0) {
240 ALOGE("%s: pcm start for hfp pcm tx failed", __func__);
241 ret = -EINVAL;
242 goto exit;
243 }
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800244
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800245 hfpmod.is_hfp_running = true;
Amit Shekhar967cab32014-02-07 17:03:21 -0800246 hfp_set_volume(adev, hfpmod.hfp_volume);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800247
248 ALOGD("%s: exit: status(%d)", __func__, ret);
249 return 0;
250
251exit:
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800252 stop_hfp(adev);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800253 ALOGE("%s: Problem in HFP start: status(%d)", __func__, ret);
254 return ret;
255}
256
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800257static int32_t stop_hfp(struct audio_device *adev)
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800258{
Satya Krishna Pindiprolif1cd92b2016-04-14 19:05:23 +0530259 int32_t ret = 0;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800260 struct audio_usecase *uc_info;
261
262 ALOGD("%s: enter", __func__);
263 hfpmod.is_hfp_running = false;
264
265 /* 1. Close the PCM devices */
266 if (hfpmod.hfp_sco_rx) {
267 pcm_close(hfpmod.hfp_sco_rx);
268 hfpmod.hfp_sco_rx = NULL;
269 }
270 if (hfpmod.hfp_sco_tx) {
271 pcm_close(hfpmod.hfp_sco_tx);
272 hfpmod.hfp_sco_tx = NULL;
273 }
274 if (hfpmod.hfp_pcm_rx) {
275 pcm_close(hfpmod.hfp_pcm_rx);
276 hfpmod.hfp_pcm_rx = NULL;
277 }
278 if (hfpmod.hfp_pcm_tx) {
279 pcm_close(hfpmod.hfp_pcm_tx);
280 hfpmod.hfp_pcm_tx = NULL;
281 }
282
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800283 uc_info = get_usecase_from_list(adev, hfpmod.ucid);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800284 if (uc_info == NULL) {
285 ALOGE("%s: Could not find the usecase (%d) in the list",
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800286 __func__, hfpmod.ucid);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800287 return -EINVAL;
288 }
289
Derek Chencdd17c72014-11-24 12:39:14 -0800290 if ((uc_info->out_snd_device != SND_DEVICE_NONE) ||
291 (uc_info->in_snd_device != SND_DEVICE_NONE)) {
292 if (audio_extn_ext_hw_plugin_usecase_stop(adev->ext_hw_plugin, uc_info))
293 ALOGE("%s: failed to stop ext hw plugin", __func__);
294 }
295
Venkata Narendra Kumar Gutta1bbbf542014-09-04 19:11:25 +0530296 /* 2. Disable echo reference while stopping hfp */
Apoorv Raghuvanshi924b3022015-07-06 15:07:14 -0700297 platform_set_echo_reference(adev, false, uc_info->devices);
Venkata Narendra Kumar Gutta1bbbf542014-09-04 19:11:25 +0530298
299 /* 3. Get and set stream specific mixer controls */
Haynes Mathew George1376ca62014-04-24 11:55:48 -0700300 disable_audio_route(adev, uc_info);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800301
Venkata Narendra Kumar Gutta1bbbf542014-09-04 19:11:25 +0530302 /* 4. Disable the rx and tx devices */
Haynes Mathew George1376ca62014-04-24 11:55:48 -0700303 disable_snd_device(adev, uc_info->out_snd_device);
304 disable_snd_device(adev, uc_info->in_snd_device);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800305
306 list_remove(&uc_info->list);
307 free(uc_info);
308
309 ALOGD("%s: exit: status(%d)", __func__, ret);
310 return ret;
311}
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800312
Vimal Puthanveed37b4a1c2014-01-07 16:47:47 -0800313bool audio_extn_hfp_is_active(struct audio_device *adev)
314{
315 struct audio_usecase *hfp_usecase = NULL;
Vimal Puthanveed41fcff22014-01-23 15:56:53 -0800316 hfp_usecase = get_usecase_from_list(adev, hfpmod.ucid);
Vimal Puthanveed37b4a1c2014-01-07 16:47:47 -0800317
318 if (hfp_usecase != NULL)
319 return true;
320 else
321 return false;
322}
323
Dhanalakshmi Siddani823dc5a2016-09-28 14:47:26 +0530324int hfp_set_mic_mute(struct audio_device *adev, bool state)
325{
326 struct mixer_ctl *ctl;
327 const char *mixer_ctl_name = "HFP TX Mute";
Manish Dewangan338c50a2017-09-12 15:22:03 +0530328 long set_values[ ] = {0};
Dhanalakshmi Siddani823dc5a2016-09-28 14:47:26 +0530329
330 ALOGI("%s: enter, state=%d", __func__, state);
331
332 set_values[0] = state;
333 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
334 if (!ctl) {
335 ALOGE("%s: Could not get ctl for mixer cmd - %s",
336 __func__, mixer_ctl_name);
337 return -EINVAL;
338 }
339 mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
340 ALOGV("%s: exit", __func__);
341 return 0;
342}
343
Vimal Puthanveed41fcff22014-01-23 15:56:53 -0800344audio_usecase_t audio_extn_hfp_get_usecase()
345{
346 return hfpmod.ucid;
347}
348
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800349void audio_extn_hfp_set_parameters(struct audio_device *adev, struct str_parms *parms)
350{
351 int ret;
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800352 int rate;
Vimal Puthanveed21e5c762014-01-08 14:10:09 -0800353 int val;
Amit Shekhar967cab32014-02-07 17:03:21 -0800354 float vol;
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800355 char value[32]={0};
356
357 ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_ENABLE, value,
358 sizeof(value));
359 if (ret >= 0) {
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530360 if (!strncmp(value, "true", sizeof(value)) && !hfpmod.is_hfp_running)
361 ret = start_hfp(adev,parms);
362 else if (!strncmp(value, "false", sizeof(value)) && hfpmod.is_hfp_running)
363 stop_hfp(adev);
364 else
365 ALOGE("hfp_enable=%s is unsupported", value);
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800366 }
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800367 memset(value, 0, sizeof(value));
368 ret = str_parms_get_str(parms,AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE, value,
369 sizeof(value));
370 if (ret >= 0) {
371 rate = atoi(value);
372 if (rate == 8000){
373 hfpmod.ucid = USECASE_AUDIO_HFP_SCO;
374 pcm_config_hfp.rate = rate;
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700375 } else if (rate == 16000){
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800376 hfpmod.ucid = USECASE_AUDIO_HFP_SCO_WB;
377 pcm_config_hfp.rate = rate;
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700378 } else
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800379 ALOGE("Unsupported rate..");
380 }
Vimal Puthanveed21e5c762014-01-08 14:10:09 -0800381
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700382 if (hfpmod.is_hfp_running) {
Vimal Puthanveed21e5c762014-01-08 14:10:09 -0800383 memset(value, 0, sizeof(value));
384 ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
385 value, sizeof(value));
386 if (ret >= 0) {
387 val = atoi(value);
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700388 if (val > 0)
Vimal Puthanveed21e5c762014-01-08 14:10:09 -0800389 select_devices(adev, hfpmod.ucid);
390 }
391 }
Amit Shekhar967cab32014-02-07 17:03:21 -0800392
393 memset(value, 0, sizeof(value));
394 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HFP_VOLUME,
395 value, sizeof(value));
396 if (ret >= 0) {
397 if (sscanf(value, "%f", &vol) != 1){
398 ALOGE("%s: error in retrieving hfp volume", __func__);
399 ret = -EIO;
400 goto exit;
401 }
402 ALOGD("%s: set_hfp_volume usecase, Vol: [%f]", __func__, vol);
403 hfp_set_volume(adev, vol);
404 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530405
406 memset(value, 0, sizeof(value));
407 ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_PCM_DEV_ID, value, sizeof(value));
408 if (ret >= 0) {
409 hfpmod.hfp_pcm_dev_id = atoi(value);
410 ALOGD("Updating HFP_PCM_DEV_ID as %d from platform XML", hfpmod.hfp_pcm_dev_id);
411 str_parms_del(parms, AUDIO_PARAMETER_HFP_PCM_DEV_ID);
412 }
413
Amit Shekhar967cab32014-02-07 17:03:21 -0800414exit:
415 ALOGV("%s Exit",__func__);
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800416}
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800417#endif /*HFP_ENABLED*/