blob: 9306894caa815c6729761957443b3f1163feecd8 [file] [log] [blame]
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "audio_hw_hfp"
18/*#define LOG_NDEBUG 0*/
19#define LOG_NDDEBUG 0
20
21#include <errno.h>
22#include <math.h>
23#include <cutils/log.h>
24
25#include "audio_hw.h"
26#include "platform.h"
27#include "platform_api.h"
28#include <stdlib.h>
29#include <cutils/str_parms.h>
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -080030#include "audio_extn/tfa_98xx.h"
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080031
Surendar karka56631b52016-07-13 15:08:39 -070032#define AUDIO_PARAMETER_HFP_ENABLE "hfp_enable"
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080033#define AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE "hfp_set_sampling_rate"
Surendar karka56631b52016-07-13 15:08:39 -070034#define AUDIO_PARAMETER_KEY_HFP_VOLUME "hfp_volume"
35#define AUDIO_PARAMETER_HFP_VOL_MIXER_CTL "hfp_vol_mixer_ctl"
36#define AUDIO_PARAMATER_HFP_VALUE_MAX 128
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080037
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -080038#define AUDIO_PARAMETER_KEY_HFP_MIC_VOLUME "hfp_mic_volume"
39#define PLAYBACK_VOLUME_MAX 0x2000
40#define CAPTURE_VOLUME_DEFAULT (15.0)
41
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080042static int32_t start_hfp(struct audio_device *adev,
43 struct str_parms *parms);
44
45static int32_t stop_hfp(struct audio_device *adev);
46
47struct hfp_module {
48 struct pcm *hfp_sco_rx;
49 struct pcm *hfp_sco_tx;
50 struct pcm *hfp_pcm_rx;
51 struct pcm *hfp_pcm_tx;
52 float hfp_volume;
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -080053 float mic_volume;
Surendar karka56631b52016-07-13 15:08:39 -070054 char hfp_vol_mixer_ctl[AUDIO_PARAMATER_HFP_VALUE_MAX];
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080055 bool is_hfp_running;
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -080056 bool mic_mute;
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080057 audio_usecase_t ucid;
58};
59
60static struct hfp_module hfpmod = {
61 .hfp_sco_rx = NULL,
62 .hfp_sco_tx = NULL,
63 .hfp_pcm_rx = NULL,
64 .hfp_pcm_tx = NULL,
65 .hfp_volume = 0,
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -080066 .mic_volume = CAPTURE_VOLUME_DEFAULT,
Surendar karka56631b52016-07-13 15:08:39 -070067 .hfp_vol_mixer_ctl = {0, },
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080068 .is_hfp_running = 0,
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -080069 .mic_mute = 0,
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080070 .ucid = USECASE_AUDIO_HFP_SCO,
71};
72static struct pcm_config pcm_config_hfp = {
73 .channels = 1,
74 .rate = 8000,
75 .period_size = 240,
76 .period_count = 2,
77 .format = PCM_FORMAT_S16_LE,
78 .start_threshold = 0,
79 .stop_threshold = INT_MAX,
80 .avail_min = 0,
81};
82
83static int32_t hfp_set_volume(struct audio_device *adev, float value)
84{
85 int32_t vol, ret = 0;
86 struct mixer_ctl *ctl;
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080087
88 ALOGV("%s: entry", __func__);
89 ALOGD("%s: (%f)\n", __func__, value);
90
Tom Cherry122b2412016-11-17 17:07:54 -080091 hfpmod.hfp_volume = value;
92
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -080093 if (value < 0.0) {
94 ALOGW("%s: (%f) Under 0.0, assuming 0.0\n", __func__, value);
95 value = 0.0;
96 } else {
97 value = ((value > 15.000000) ? 1.0 : (value / 15));
98 ALOGW("%s: Volume brought with in range (%f)\n", __func__, value);
99 }
100 vol = lrint((value * 0x2000) + 0.5);
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800101
102 if (!hfpmod.is_hfp_running) {
103 ALOGV("%s: HFP not active, ignoring set_hfp_volume call", __func__);
104 return -EIO;
105 }
106
107 ALOGD("%s: Setting HFP volume to %d \n", __func__, vol);
Surendar karka56631b52016-07-13 15:08:39 -0700108 if (0 == hfpmod.hfp_vol_mixer_ctl[0]) {
109#ifdef EXTERNAL_BT_SUPPORTED
110 strcpy(hfpmod.hfp_vol_mixer_ctl, "PRI AUXPCM LOOPBACK Volume");
111#else
112 strcpy(hfpmod.hfp_vol_mixer_ctl, "Internal HFP RX Volume");
113#endif
114 ALOGW("%s: Defaulting hfp mixer control to: %s",
115 __func__, hfpmod.hfp_vol_mixer_ctl);
116 }
117 ctl = mixer_get_ctl_by_name(adev->mixer, hfpmod.hfp_vol_mixer_ctl);
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800118 if (!ctl) {
119 ALOGE("%s: Could not get ctl for mixer cmd - %s",
Surendar karka56631b52016-07-13 15:08:39 -0700120 __func__, hfpmod.hfp_vol_mixer_ctl);
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800121 return -EINVAL;
122 }
123 if(mixer_ctl_set_value(ctl, 0, vol) < 0) {
124 ALOGE("%s: Couldn't set HFP Volume: [%d]", __func__, vol);
125 return -EINVAL;
126 }
127
128 ALOGV("%s: exit", __func__);
129 return ret;
130}
131
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800132
133/*Set mic volume to value.
134*
135* This interface is used for mic volume control, set mic volume as value(range 0 ~ 15).
136*/
137static int hfp_set_mic_volume(struct audio_device *adev, float value)
138{
139 int volume, ret = 0;
140 char mixer_ctl_name[128];
141 struct mixer_ctl *ctl;
142 int pcm_device_id = HFP_ASM_RX_TX;
143
144 if (!hfpmod.is_hfp_running) {
145 ALOGE("%s: HFP not active, ignoring set_hfp_mic_volume call", __func__);
146 return -EIO;
147 }
148
149 if (value < 0.0) {
150 ALOGW("%s: (%f) Under 0.0, assuming 0.0\n", __func__, value);
151 value = 0.0;
152 } else if (value > CAPTURE_VOLUME_DEFAULT) {
153 value = CAPTURE_VOLUME_DEFAULT;
154 ALOGW("%s: Volume brought within range (%f)\n", __func__, value);
155 }
156
157 value = value / CAPTURE_VOLUME_DEFAULT;
158 memset(mixer_ctl_name, 0, sizeof(mixer_ctl_name));
159 snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
160 "Playback %d Volume", pcm_device_id);
161 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
162 if (!ctl) {
163 ALOGE("%s: Could not get ctl for mixer cmd - %s",
164 __func__, mixer_ctl_name);
165 return -EINVAL;
166 }
167 volume = (int)(value * PLAYBACK_VOLUME_MAX);
168
169 ALOGD("%s: Setting volume to %d (%s)\n", __func__, volume, mixer_ctl_name);
170 if (mixer_ctl_set_value(ctl, 0, volume) < 0) {
171 ALOGE("%s: Couldn't set HFP Volume: [%d]", __func__, volume);
172 return -EINVAL;
173 }
174
175 return ret;
176}
177
178static float hfp_get_mic_volume(struct audio_device *adev)
179{
180 int volume, ret = 0;
181 char mixer_ctl_name[128];
182 struct mixer_ctl *ctl;
183 int pcm_device_id = HFP_ASM_RX_TX;
184 float value = 0.0;
185
186 if (!hfpmod.is_hfp_running) {
187 ALOGE("%s: HFP not active, ignoring set_hfp_mic_volume call", __func__);
188 return -EIO;
189 }
190
191 memset(mixer_ctl_name, 0, sizeof(mixer_ctl_name));
192 snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
193 "Playback %d Volume", pcm_device_id);
194 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
195 if (!ctl) {
196 ALOGE("%s: Could not get ctl for mixer cmd - %s",
197 __func__, mixer_ctl_name);
198 return -EINVAL;
199 }
200
201 volume = mixer_ctl_get_value(ctl, 0);
202 if ( volume < 0) {
203 ALOGE("%s: Couldn't set HFP Volume: [%d]", __func__, volume);
204 return -EINVAL;
205 }
206 ALOGD("%s: getting mic volume %d \n", __func__, volume);
207
208 value = (volume / PLAYBACK_VOLUME_MAX) * CAPTURE_VOLUME_DEFAULT;
209 if (value < 0.0) {
210 ALOGW("%s: (%f) Under 0.0, assuming 0.0\n", __func__, value);
211 value = 0.0;
212 } else if (value > CAPTURE_VOLUME_DEFAULT) {
213 value = CAPTURE_VOLUME_DEFAULT;
214 ALOGW("%s: Volume brought within range (%f)\n", __func__, value);
215 }
216
217 return value;
218}
219
220/*Set mic mute state.
221*
222* This interface is used for mic mute state control
223*/
224int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state)
225{
226 int rc = 0;
227
228 if (state == hfpmod.mic_mute)
229 return rc;
230
231 if (state == true) {
232 hfpmod.mic_volume = hfp_get_mic_volume(adev);
233 }
234 rc = hfp_set_mic_volume(adev, (state == true) ? 0.0 : hfpmod.mic_volume);
235 adev->voice.mic_mute = state;
236 hfpmod.mic_mute = state;
237 ALOGD("%s: Setting mute state %d, rc %d\n", __func__, state, rc);
238 return rc;
239}
240
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800241static int32_t start_hfp(struct audio_device *adev,
Haynes Mathew Georgecc9649b2014-06-10 15:08:39 -0700242 struct str_parms *parms __unused)
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800243{
244 int32_t i, ret = 0;
245 struct audio_usecase *uc_info;
246 int32_t pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, pcm_dev_asm_tx_id;
247
248 ALOGD("%s: enter", __func__);
Uday Kishore Pasupuleti76297192015-09-18 08:39:43 -0700249 adev->enable_hfp = true;
Uday Kishore Pasupuletia1f48052015-09-08 22:49:18 +0900250 platform_set_mic_mute(adev->platform, false);
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800251
252 uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
253 uc_info->id = hfpmod.ucid;
254 uc_info->type = PCM_HFP_CALL;
255 uc_info->stream.out = adev->primary_output;
256 uc_info->devices = adev->primary_output->devices;
257 uc_info->in_snd_device = SND_DEVICE_NONE;
258 uc_info->out_snd_device = SND_DEVICE_NONE;
259
260 list_add_tail(&adev->usecase_list, &uc_info->list);
261
262 select_devices(adev, hfpmod.ucid);
263
264 pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
265 pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
266 pcm_dev_asm_rx_id = HFP_ASM_RX_TX;
267 pcm_dev_asm_tx_id = HFP_ASM_RX_TX;
268 if (pcm_dev_rx_id < 0 || pcm_dev_tx_id < 0 ||
269 pcm_dev_asm_rx_id < 0 || pcm_dev_asm_tx_id < 0 ) {
270 ALOGE("%s: Invalid PCM devices (rx: %d tx: %d asm: rx tx %d) for the usecase(%d)",
271 __func__, pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, uc_info->id);
272 ret = -EIO;
273 goto exit;
274 }
275
276 ALOGV("%s: HFP PCM devices (hfp rx tx: %d pcm rx tx: %d) for the usecase(%d)",
277 __func__, pcm_dev_rx_id, pcm_dev_tx_id, uc_info->id);
278
279 ALOGV("%s: Opening PCM playback device card_id(%d) device_id(%d)",
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700280 __func__, adev->snd_card, pcm_dev_rx_id);
281 hfpmod.hfp_sco_rx = pcm_open(adev->snd_card,
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800282 pcm_dev_asm_rx_id,
283 PCM_OUT, &pcm_config_hfp);
284 if (hfpmod.hfp_sco_rx && !pcm_is_ready(hfpmod.hfp_sco_rx)) {
285 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_sco_rx));
286 ret = -EIO;
287 goto exit;
288 }
289 ALOGD("%s: Opening PCM capture device card_id(%d) device_id(%d)",
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700290 __func__, adev->snd_card, pcm_dev_tx_id);
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800291
292 if (audio_extn_tfa_98xx_is_supported() == false) {
293 hfpmod.hfp_pcm_rx = pcm_open(adev->snd_card,
294 pcm_dev_rx_id,
295 PCM_OUT, &pcm_config_hfp);
296 if (hfpmod.hfp_pcm_rx && !pcm_is_ready(hfpmod.hfp_pcm_rx)) {
297 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_pcm_rx));
298 ret = -EIO;
299 goto exit;
300 }
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800301 }
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700302 hfpmod.hfp_sco_tx = pcm_open(adev->snd_card,
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800303 pcm_dev_asm_tx_id,
304 PCM_IN, &pcm_config_hfp);
305 if (hfpmod.hfp_sco_tx && !pcm_is_ready(hfpmod.hfp_sco_tx)) {
306 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_sco_tx));
307 ret = -EIO;
308 goto exit;
309 }
310 ALOGV("%s: Opening PCM capture device card_id(%d) device_id(%d)",
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700311 __func__, adev->snd_card, pcm_dev_tx_id);
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800312
313 if (audio_extn_tfa_98xx_is_supported() == false) {
314 hfpmod.hfp_pcm_tx = pcm_open(adev->snd_card,
315 pcm_dev_tx_id,
316 PCM_IN, &pcm_config_hfp);
317 if (hfpmod.hfp_pcm_tx && !pcm_is_ready(hfpmod.hfp_pcm_tx)) {
318 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_pcm_tx));
319 ret = -EIO;
320 goto exit;
321 }
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800322 }
323 pcm_start(hfpmod.hfp_sco_rx);
324 pcm_start(hfpmod.hfp_sco_tx);
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800325 if (audio_extn_tfa_98xx_is_supported() == false) {
326 pcm_start(hfpmod.hfp_pcm_rx);
327 pcm_start(hfpmod.hfp_pcm_tx);
328 }
329
330 audio_extn_tfa_98xx_enable_speaker();
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800331
332 hfpmod.is_hfp_running = true;
333 hfp_set_volume(adev, hfpmod.hfp_volume);
334
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800335 /* Set mic volume by mute status, we don't provide set mic volume in phone app, only
336 provide mute and unmute. */
337 audio_extn_hfp_set_mic_mute(adev, adev->mic_muted);
338
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800339 ALOGD("%s: exit: status(%d)", __func__, ret);
340 return 0;
341
342exit:
343 stop_hfp(adev);
344 ALOGE("%s: Problem in HFP start: status(%d)", __func__, ret);
345 return ret;
346}
347
348static int32_t stop_hfp(struct audio_device *adev)
349{
350 int32_t i, ret = 0;
351 struct audio_usecase *uc_info;
352
353 ALOGD("%s: enter", __func__);
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800354 hfpmod.is_hfp_running = false;
355
356 /* 1. Close the PCM devices */
357 if (hfpmod.hfp_sco_rx) {
358 pcm_close(hfpmod.hfp_sco_rx);
359 hfpmod.hfp_sco_rx = NULL;
360 }
361 if (hfpmod.hfp_sco_tx) {
362 pcm_close(hfpmod.hfp_sco_tx);
363 hfpmod.hfp_sco_tx = NULL;
364 }
365 if (hfpmod.hfp_pcm_rx) {
366 pcm_close(hfpmod.hfp_pcm_rx);
367 hfpmod.hfp_pcm_rx = NULL;
368 }
369 if (hfpmod.hfp_pcm_tx) {
370 pcm_close(hfpmod.hfp_pcm_tx);
371 hfpmod.hfp_pcm_tx = NULL;
372 }
373
374 uc_info = get_usecase_from_list(adev, hfpmod.ucid);
375 if (uc_info == NULL) {
376 ALOGE("%s: Could not find the usecase (%d) in the list",
377 __func__, hfpmod.ucid);
378 return -EINVAL;
379 }
380
381 /* 2. Get and set stream specific mixer controls */
382 disable_audio_route(adev, uc_info);
383
384 /* 3. Disable the rx and tx devices */
385 disable_snd_device(adev, uc_info->out_snd_device);
386 disable_snd_device(adev, uc_info->in_snd_device);
387
Uday Kishore Pasupuletia1f48052015-09-08 22:49:18 +0900388 /* Disable the echo reference for HFP Tx */
389 platform_set_echo_reference(adev, false, AUDIO_DEVICE_NONE);
390
391 /* Set the unmute Tx mixer control */
392 if (voice_get_mic_mute(adev)) {
393 platform_set_mic_mute(adev->platform, false);
394 ALOGD("%s: unMute HFP Tx", __func__);
395 }
396 adev->enable_hfp = false;
397
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800398 list_remove(&uc_info->list);
399 free(uc_info);
400
401 ALOGD("%s: exit: status(%d)", __func__, ret);
402 return ret;
403}
404
405bool audio_extn_hfp_is_active(struct audio_device *adev)
406{
407 struct audio_usecase *hfp_usecase = NULL;
408 hfp_usecase = get_usecase_from_list(adev, hfpmod.ucid);
409
410 if (hfp_usecase != NULL)
411 return true;
412 else
413 return false;
414}
415
416audio_usecase_t audio_extn_hfp_get_usecase()
417{
418 return hfpmod.ucid;
419}
420
421void audio_extn_hfp_set_parameters(struct audio_device *adev, struct str_parms *parms)
422{
423 int ret;
424 int rate;
425 int val;
426 float vol;
Surendar karka56631b52016-07-13 15:08:39 -0700427 char value[AUDIO_PARAMATER_HFP_VALUE_MAX] = {0, };
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800428
429 ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_ENABLE, value,
430 sizeof(value));
431 if (ret >= 0) {
432 if (!strncmp(value,"true",sizeof(value)))
433 ret = start_hfp(adev,parms);
434 else
435 stop_hfp(adev);
436 }
437 memset(value, 0, sizeof(value));
438 ret = str_parms_get_str(parms,AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE, value,
439 sizeof(value));
440 if (ret >= 0) {
441 rate = atoi(value);
442 if (rate == 8000){
443 hfpmod.ucid = USECASE_AUDIO_HFP_SCO;
444 pcm_config_hfp.rate = rate;
445 } else if (rate == 16000){
446 hfpmod.ucid = USECASE_AUDIO_HFP_SCO_WB;
447 pcm_config_hfp.rate = rate;
448 } else
449 ALOGE("Unsupported rate..");
450 }
451
452 if (hfpmod.is_hfp_running) {
453 memset(value, 0, sizeof(value));
454 ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
455 value, sizeof(value));
456 if (ret >= 0) {
457 val = atoi(value);
458 if (val > 0)
459 select_devices(adev, hfpmod.ucid);
460 }
461 }
462
463 memset(value, 0, sizeof(value));
Surendar karka56631b52016-07-13 15:08:39 -0700464 ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_VOL_MIXER_CTL,
465 value, sizeof(value));
466 if (ret >= 0) {
467 ALOGD("%s: mixer ctl name: %s", __func__, value);
468 strcpy(hfpmod.hfp_vol_mixer_ctl, value);
469 str_parms_del(parms, AUDIO_PARAMETER_HFP_VOL_MIXER_CTL);
470 }
471
472 memset(value, 0, sizeof(value));
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800473 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HFP_VOLUME,
474 value, sizeof(value));
475 if (ret >= 0) {
476 if (sscanf(value, "%f", &vol) != 1){
477 ALOGE("%s: error in retrieving hfp volume", __func__);
478 ret = -EIO;
479 goto exit;
480 }
481 ALOGD("%s: set_hfp_volume usecase, Vol: [%f]", __func__, vol);
482 hfp_set_volume(adev, vol);
483 }
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800484
485 memset(value, 0, sizeof(value));
486 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HFP_MIC_VOLUME,
487 value, sizeof(value));
488 if (ret >= 0) {
489 if (sscanf(value, "%f", &vol) != 1){
490 ALOGE("%s: error in retrieving hfp mic volume", __func__);
491 ret = -EIO;
492 goto exit;
493 }
494 ALOGD("%s: set_hfp_mic_volume usecase, Vol: [%f]", __func__, vol);
495 hfp_set_mic_volume(adev, vol);
496 }
497
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800498exit:
499 ALOGV("%s Exit",__func__);
500}