blob: 2ff7e54b29c336288095a3bb1413d956d878e904 [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
Zheng Zhang0b679502016-11-29 19:31:22 +0800262 audio_extn_tfa_98xx_set_mode_bt();
263
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800264 select_devices(adev, hfpmod.ucid);
265
266 pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
267 pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
268 pcm_dev_asm_rx_id = HFP_ASM_RX_TX;
269 pcm_dev_asm_tx_id = HFP_ASM_RX_TX;
270 if (pcm_dev_rx_id < 0 || pcm_dev_tx_id < 0 ||
271 pcm_dev_asm_rx_id < 0 || pcm_dev_asm_tx_id < 0 ) {
272 ALOGE("%s: Invalid PCM devices (rx: %d tx: %d asm: rx tx %d) for the usecase(%d)",
273 __func__, pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, uc_info->id);
274 ret = -EIO;
275 goto exit;
276 }
277
278 ALOGV("%s: HFP PCM devices (hfp rx tx: %d pcm rx tx: %d) for the usecase(%d)",
279 __func__, pcm_dev_rx_id, pcm_dev_tx_id, uc_info->id);
280
281 ALOGV("%s: Opening PCM playback device card_id(%d) device_id(%d)",
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700282 __func__, adev->snd_card, pcm_dev_rx_id);
283 hfpmod.hfp_sco_rx = pcm_open(adev->snd_card,
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800284 pcm_dev_asm_rx_id,
285 PCM_OUT, &pcm_config_hfp);
286 if (hfpmod.hfp_sco_rx && !pcm_is_ready(hfpmod.hfp_sco_rx)) {
287 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_sco_rx));
288 ret = -EIO;
289 goto exit;
290 }
291 ALOGD("%s: Opening PCM capture device card_id(%d) device_id(%d)",
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700292 __func__, adev->snd_card, pcm_dev_tx_id);
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800293
294 if (audio_extn_tfa_98xx_is_supported() == false) {
295 hfpmod.hfp_pcm_rx = pcm_open(adev->snd_card,
296 pcm_dev_rx_id,
297 PCM_OUT, &pcm_config_hfp);
298 if (hfpmod.hfp_pcm_rx && !pcm_is_ready(hfpmod.hfp_pcm_rx)) {
299 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_pcm_rx));
300 ret = -EIO;
301 goto exit;
302 }
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800303 }
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700304 hfpmod.hfp_sco_tx = pcm_open(adev->snd_card,
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800305 pcm_dev_asm_tx_id,
306 PCM_IN, &pcm_config_hfp);
307 if (hfpmod.hfp_sco_tx && !pcm_is_ready(hfpmod.hfp_sco_tx)) {
308 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_sco_tx));
309 ret = -EIO;
310 goto exit;
311 }
312 ALOGV("%s: Opening PCM capture device card_id(%d) device_id(%d)",
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700313 __func__, adev->snd_card, pcm_dev_tx_id);
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800314
315 if (audio_extn_tfa_98xx_is_supported() == false) {
316 hfpmod.hfp_pcm_tx = pcm_open(adev->snd_card,
317 pcm_dev_tx_id,
318 PCM_IN, &pcm_config_hfp);
319 if (hfpmod.hfp_pcm_tx && !pcm_is_ready(hfpmod.hfp_pcm_tx)) {
320 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_pcm_tx));
321 ret = -EIO;
322 goto exit;
323 }
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800324 }
325 pcm_start(hfpmod.hfp_sco_rx);
326 pcm_start(hfpmod.hfp_sco_tx);
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800327 if (audio_extn_tfa_98xx_is_supported() == false) {
328 pcm_start(hfpmod.hfp_pcm_rx);
329 pcm_start(hfpmod.hfp_pcm_tx);
330 }
331
332 audio_extn_tfa_98xx_enable_speaker();
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800333
334 hfpmod.is_hfp_running = true;
335 hfp_set_volume(adev, hfpmod.hfp_volume);
336
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800337 /* Set mic volume by mute status, we don't provide set mic volume in phone app, only
338 provide mute and unmute. */
339 audio_extn_hfp_set_mic_mute(adev, adev->mic_muted);
340
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800341 ALOGD("%s: exit: status(%d)", __func__, ret);
342 return 0;
343
344exit:
345 stop_hfp(adev);
346 ALOGE("%s: Problem in HFP start: status(%d)", __func__, ret);
347 return ret;
348}
349
350static int32_t stop_hfp(struct audio_device *adev)
351{
352 int32_t i, ret = 0;
353 struct audio_usecase *uc_info;
354
355 ALOGD("%s: enter", __func__);
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800356 hfpmod.is_hfp_running = false;
357
358 /* 1. Close the PCM devices */
359 if (hfpmod.hfp_sco_rx) {
360 pcm_close(hfpmod.hfp_sco_rx);
361 hfpmod.hfp_sco_rx = NULL;
362 }
363 if (hfpmod.hfp_sco_tx) {
364 pcm_close(hfpmod.hfp_sco_tx);
365 hfpmod.hfp_sco_tx = NULL;
366 }
367 if (hfpmod.hfp_pcm_rx) {
368 pcm_close(hfpmod.hfp_pcm_rx);
369 hfpmod.hfp_pcm_rx = NULL;
370 }
371 if (hfpmod.hfp_pcm_tx) {
372 pcm_close(hfpmod.hfp_pcm_tx);
373 hfpmod.hfp_pcm_tx = NULL;
374 }
375
376 uc_info = get_usecase_from_list(adev, hfpmod.ucid);
377 if (uc_info == NULL) {
378 ALOGE("%s: Could not find the usecase (%d) in the list",
379 __func__, hfpmod.ucid);
380 return -EINVAL;
381 }
382
383 /* 2. Get and set stream specific mixer controls */
384 disable_audio_route(adev, uc_info);
385
386 /* 3. Disable the rx and tx devices */
387 disable_snd_device(adev, uc_info->out_snd_device);
388 disable_snd_device(adev, uc_info->in_snd_device);
389
Uday Kishore Pasupuletia1f48052015-09-08 22:49:18 +0900390 /* Disable the echo reference for HFP Tx */
391 platform_set_echo_reference(adev, false, AUDIO_DEVICE_NONE);
392
393 /* Set the unmute Tx mixer control */
394 if (voice_get_mic_mute(adev)) {
395 platform_set_mic_mute(adev->platform, false);
396 ALOGD("%s: unMute HFP Tx", __func__);
397 }
398 adev->enable_hfp = false;
399
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800400 list_remove(&uc_info->list);
401 free(uc_info);
402
403 ALOGD("%s: exit: status(%d)", __func__, ret);
404 return ret;
405}
406
407bool audio_extn_hfp_is_active(struct audio_device *adev)
408{
409 struct audio_usecase *hfp_usecase = NULL;
410 hfp_usecase = get_usecase_from_list(adev, hfpmod.ucid);
411
412 if (hfp_usecase != NULL)
413 return true;
414 else
415 return false;
416}
417
418audio_usecase_t audio_extn_hfp_get_usecase()
419{
420 return hfpmod.ucid;
421}
422
423void audio_extn_hfp_set_parameters(struct audio_device *adev, struct str_parms *parms)
424{
425 int ret;
426 int rate;
427 int val;
428 float vol;
Surendar karka56631b52016-07-13 15:08:39 -0700429 char value[AUDIO_PARAMATER_HFP_VALUE_MAX] = {0, };
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800430
431 ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_ENABLE, value,
432 sizeof(value));
433 if (ret >= 0) {
434 if (!strncmp(value,"true",sizeof(value)))
435 ret = start_hfp(adev,parms);
436 else
437 stop_hfp(adev);
438 }
439 memset(value, 0, sizeof(value));
440 ret = str_parms_get_str(parms,AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE, value,
441 sizeof(value));
442 if (ret >= 0) {
443 rate = atoi(value);
444 if (rate == 8000){
445 hfpmod.ucid = USECASE_AUDIO_HFP_SCO;
446 pcm_config_hfp.rate = rate;
447 } else if (rate == 16000){
448 hfpmod.ucid = USECASE_AUDIO_HFP_SCO_WB;
449 pcm_config_hfp.rate = rate;
450 } else
451 ALOGE("Unsupported rate..");
452 }
453
454 if (hfpmod.is_hfp_running) {
455 memset(value, 0, sizeof(value));
456 ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
457 value, sizeof(value));
458 if (ret >= 0) {
459 val = atoi(value);
460 if (val > 0)
461 select_devices(adev, hfpmod.ucid);
462 }
463 }
464
465 memset(value, 0, sizeof(value));
Surendar karka56631b52016-07-13 15:08:39 -0700466 ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_VOL_MIXER_CTL,
467 value, sizeof(value));
468 if (ret >= 0) {
469 ALOGD("%s: mixer ctl name: %s", __func__, value);
470 strcpy(hfpmod.hfp_vol_mixer_ctl, value);
471 str_parms_del(parms, AUDIO_PARAMETER_HFP_VOL_MIXER_CTL);
472 }
473
474 memset(value, 0, sizeof(value));
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800475 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HFP_VOLUME,
476 value, sizeof(value));
477 if (ret >= 0) {
478 if (sscanf(value, "%f", &vol) != 1){
479 ALOGE("%s: error in retrieving hfp volume", __func__);
480 ret = -EIO;
481 goto exit;
482 }
483 ALOGD("%s: set_hfp_volume usecase, Vol: [%f]", __func__, vol);
484 hfp_set_volume(adev, vol);
485 }
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800486
487 memset(value, 0, sizeof(value));
488 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HFP_MIC_VOLUME,
489 value, sizeof(value));
490 if (ret >= 0) {
491 if (sscanf(value, "%f", &vol) != 1){
492 ALOGE("%s: error in retrieving hfp mic volume", __func__);
493 ret = -EIO;
494 goto exit;
495 }
496 ALOGD("%s: set_hfp_mic_volume usecase, Vol: [%f]", __func__, vol);
497 hfp_set_mic_volume(adev, vol);
498 }
499
Ravi Kumar Alamanda8e6e98f2013-11-05 15:57:39 -0800500exit:
501 ALOGV("%s Exit",__func__);
502}