blob: 95f463d62dd5e5c75ce8008a37bdc1adfcfba14c [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>
41
Revathi Uddaraju1eac8b02017-05-18 17:13:33 +053042#ifdef DYNAMIC_LOG_ENABLED
43#include <log_xml_parser.h>
44#define LOG_MASK HAL_MOD_FILE_HFP
45#include <log_utils.h>
46#endif
47
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080048#ifdef HFP_ENABLED
49#define AUDIO_PARAMETER_HFP_ENABLE "hfp_enable"
Vimal Puthanveed47e64852013-12-20 13:23:39 -080050#define AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE "hfp_set_sampling_rate"
Amit Shekhar967cab32014-02-07 17:03:21 -080051#define AUDIO_PARAMETER_KEY_HFP_VOLUME "hfp_volume"
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +053052#define AUDIO_PARAMETER_HFP_PCM_DEV_ID "hfp_pcm_dev_id"
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080053
Sudheer Papothi19e43d02014-07-16 02:34:41 +053054#ifdef PLATFORM_MSM8994
55#define HFP_RX_VOLUME "SEC AUXPCM LOOPBACK Volume"
Banajit Goswamida77c452015-10-14 20:45:22 -070056#elif defined PLATFORM_MSM8996
57#define HFP_RX_VOLUME "PRI AUXPCM LOOPBACK Volume"
Derek Chen3e5b30a2018-10-24 01:04:25 -070058#elif defined PLATFORM_AUTO
59#define HFP_RX_VOLUME "Playback 36 Volume"
Naresh Tannirucb5b5782018-10-12 20:42:07 +053060#elif defined (PLATFORM_MSM8998) || defined (PLATFORM_MSMFALCON) || defined (PLATFORM_SDM845) || defined (PLATFORM_SDM710) || defined (PLATFORM_QCS605) || defined (PLATFORM_MSMNILE) || defined (PLATFORM_MSMSTEPPE) || defined (PLATFORM_QCS405)
Banajit Goswami4c0dff22016-03-04 18:31:22 -080061#define HFP_RX_VOLUME "SLIMBUS_7 LOOPBACK Volume"
Sudheer Papothi19e43d02014-07-16 02:34:41 +053062#else
63#define HFP_RX_VOLUME "Internal HFP RX Volume"
64#endif
65
Vimal Puthanveed584048b2013-12-11 17:00:50 -080066static int32_t start_hfp(struct audio_device *adev,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080067 struct str_parms *parms);
68
Vimal Puthanveed584048b2013-12-11 17:00:50 -080069static int32_t stop_hfp(struct audio_device *adev);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080070
71struct hfp_module {
72 struct pcm *hfp_sco_rx;
73 struct pcm *hfp_sco_tx;
74 struct pcm *hfp_pcm_rx;
75 struct pcm *hfp_pcm_tx;
76 bool is_hfp_running;
Amit Shekhar967cab32014-02-07 17:03:21 -080077 float hfp_volume;
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +053078 int32_t hfp_pcm_dev_id;
Vimal Puthanveed47e64852013-12-20 13:23:39 -080079 audio_usecase_t ucid;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080080};
81
82static struct hfp_module hfpmod = {
83 .hfp_sco_rx = NULL,
84 .hfp_sco_tx = NULL,
85 .hfp_pcm_rx = NULL,
86 .hfp_pcm_tx = NULL,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080087 .is_hfp_running = 0,
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +053088 .hfp_volume = 0,
89 .hfp_pcm_dev_id = HFP_ASM_RX_TX,
Vimal Puthanveed47e64852013-12-20 13:23:39 -080090 .ucid = USECASE_AUDIO_HFP_SCO,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -080091};
92static struct pcm_config pcm_config_hfp = {
93 .channels = 1,
94 .rate = 8000,
95 .period_size = 240,
96 .period_count = 2,
97 .format = PCM_FORMAT_S16_LE,
98 .start_threshold = 0,
99 .stop_threshold = INT_MAX,
100 .avail_min = 0,
101};
102
Amit Shekhar967cab32014-02-07 17:03:21 -0800103static int32_t hfp_set_volume(struct audio_device *adev, float value)
104{
105 int32_t vol, ret = 0;
106 struct mixer_ctl *ctl;
Sudheer Papothi19e43d02014-07-16 02:34:41 +0530107 const char *mixer_ctl_name = HFP_RX_VOLUME;
Amit Shekhar967cab32014-02-07 17:03:21 -0800108
109 ALOGV("%s: entry", __func__);
110 ALOGD("%s: (%f)\n", __func__, value);
111
Satya Krishna Pindiproli3ed6d792014-09-09 15:32:25 +0530112 hfpmod.hfp_volume = value;
Amit Shekhar967cab32014-02-07 17:03:21 -0800113 if (value < 0.0) {
114 ALOGW("%s: (%f) Under 0.0, assuming 0.0\n", __func__, value);
115 value = 0.0;
116 } else {
117 value = ((value > 15.000000) ? 1.0 : (value / 15));
118 ALOGW("%s: Volume brought with in range (%f)\n", __func__, value);
119 }
120 vol = lrint((value * 0x2000) + 0.5);
Amit Shekhar967cab32014-02-07 17:03:21 -0800121
122 if (!hfpmod.is_hfp_running) {
123 ALOGV("%s: HFP not active, ignoring set_hfp_volume call", __func__);
124 return -EIO;
125 }
126
127 ALOGD("%s: Setting HFP volume to %d \n", __func__, vol);
128 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
129 if (!ctl) {
130 ALOGE("%s: Could not get ctl for mixer cmd - %s",
131 __func__, mixer_ctl_name);
132 return -EINVAL;
133 }
134 if(mixer_ctl_set_value(ctl, 0, vol) < 0) {
135 ALOGE("%s: Couldn't set HFP Volume: [%d]", __func__, vol);
136 return -EINVAL;
137 }
138
139 ALOGV("%s: exit", __func__);
140 return ret;
141}
142
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800143static int32_t start_hfp(struct audio_device *adev,
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700144 struct str_parms *parms __unused)
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800145{
Satya Krishna Pindiprolif1cd92b2016-04-14 19:05:23 +0530146 int32_t ret = 0;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800147 struct audio_usecase *uc_info;
148 int32_t pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, pcm_dev_asm_tx_id;
149
150 ALOGD("%s: enter", __func__);
151
152 uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700153
154 if (!uc_info)
155 return -ENOMEM;
156
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800157 uc_info->id = hfpmod.ucid;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800158 uc_info->type = PCM_HFP_CALL;
159 uc_info->stream.out = adev->primary_output;
160 uc_info->devices = adev->primary_output->devices;
161 uc_info->in_snd_device = SND_DEVICE_NONE;
162 uc_info->out_snd_device = SND_DEVICE_NONE;
163
164 list_add_tail(&adev->usecase_list, &uc_info->list);
165
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800166 select_devices(adev, hfpmod.ucid);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800167
168 pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
169 pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530170 pcm_dev_asm_rx_id = hfpmod.hfp_pcm_dev_id;
171 pcm_dev_asm_tx_id = hfpmod.hfp_pcm_dev_id;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800172 if (pcm_dev_rx_id < 0 || pcm_dev_tx_id < 0 ||
173 pcm_dev_asm_rx_id < 0 || pcm_dev_asm_tx_id < 0 ) {
174 ALOGE("%s: Invalid PCM devices (rx: %d tx: %d asm: rx tx %d) for the usecase(%d)",
175 __func__, pcm_dev_rx_id, pcm_dev_tx_id, pcm_dev_asm_rx_id, uc_info->id);
176 ret = -EIO;
177 goto exit;
178 }
179
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530180 ALOGD("%s: HFP PCM devices (rx: %d tx: %d pcm dev id: %d) usecase(%d)",
181 __func__, pcm_dev_rx_id, pcm_dev_tx_id, hfpmod.hfp_pcm_dev_id, uc_info->id);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800182
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800183 hfpmod.hfp_sco_rx = pcm_open(adev->snd_card,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800184 pcm_dev_asm_rx_id,
185 PCM_OUT, &pcm_config_hfp);
186 if (hfpmod.hfp_sco_rx && !pcm_is_ready(hfpmod.hfp_sco_rx)) {
187 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_sco_rx));
188 ret = -EIO;
189 goto exit;
190 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530191
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800192 hfpmod.hfp_pcm_rx = pcm_open(adev->snd_card,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800193 pcm_dev_rx_id,
194 PCM_OUT, &pcm_config_hfp);
195 if (hfpmod.hfp_pcm_rx && !pcm_is_ready(hfpmod.hfp_pcm_rx)) {
196 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_pcm_rx));
197 ret = -EIO;
198 goto exit;
199 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530200
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800201 hfpmod.hfp_sco_tx = pcm_open(adev->snd_card,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800202 pcm_dev_asm_tx_id,
203 PCM_IN, &pcm_config_hfp);
204 if (hfpmod.hfp_sco_tx && !pcm_is_ready(hfpmod.hfp_sco_tx)) {
205 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_sco_tx));
206 ret = -EIO;
207 goto exit;
208 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530209
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800210 hfpmod.hfp_pcm_tx = pcm_open(adev->snd_card,
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800211 pcm_dev_tx_id,
212 PCM_IN, &pcm_config_hfp);
213 if (hfpmod.hfp_pcm_tx && !pcm_is_ready(hfpmod.hfp_pcm_tx)) {
214 ALOGE("%s: %s", __func__, pcm_get_error(hfpmod.hfp_pcm_tx));
215 ret = -EIO;
216 goto exit;
217 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530218
Satya Krishna Pindiprolice903a02014-07-28 12:40:56 +0530219 if (pcm_start(hfpmod.hfp_sco_rx) < 0) {
220 ALOGE("%s: pcm start for hfp sco rx failed", __func__);
221 ret = -EINVAL;
222 goto exit;
223 }
224 if (pcm_start(hfpmod.hfp_sco_tx) < 0) {
225 ALOGE("%s: pcm start for hfp sco tx failed", __func__);
226 ret = -EINVAL;
227 goto exit;
228 }
229 if (pcm_start(hfpmod.hfp_pcm_rx) < 0) {
230 ALOGE("%s: pcm start for hfp pcm rx failed", __func__);
231 ret = -EINVAL;
232 goto exit;
233 }
234 if (pcm_start(hfpmod.hfp_pcm_tx) < 0) {
235 ALOGE("%s: pcm start for hfp pcm tx failed", __func__);
236 ret = -EINVAL;
237 goto exit;
238 }
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800239
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800240 hfpmod.is_hfp_running = true;
Amit Shekhar967cab32014-02-07 17:03:21 -0800241 hfp_set_volume(adev, hfpmod.hfp_volume);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800242
243 ALOGD("%s: exit: status(%d)", __func__, ret);
244 return 0;
245
246exit:
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800247 stop_hfp(adev);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800248 ALOGE("%s: Problem in HFP start: status(%d)", __func__, ret);
249 return ret;
250}
251
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800252static int32_t stop_hfp(struct audio_device *adev)
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800253{
Satya Krishna Pindiprolif1cd92b2016-04-14 19:05:23 +0530254 int32_t ret = 0;
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800255 struct audio_usecase *uc_info;
256
257 ALOGD("%s: enter", __func__);
258 hfpmod.is_hfp_running = false;
259
260 /* 1. Close the PCM devices */
261 if (hfpmod.hfp_sco_rx) {
262 pcm_close(hfpmod.hfp_sco_rx);
263 hfpmod.hfp_sco_rx = NULL;
264 }
265 if (hfpmod.hfp_sco_tx) {
266 pcm_close(hfpmod.hfp_sco_tx);
267 hfpmod.hfp_sco_tx = NULL;
268 }
269 if (hfpmod.hfp_pcm_rx) {
270 pcm_close(hfpmod.hfp_pcm_rx);
271 hfpmod.hfp_pcm_rx = NULL;
272 }
273 if (hfpmod.hfp_pcm_tx) {
274 pcm_close(hfpmod.hfp_pcm_tx);
275 hfpmod.hfp_pcm_tx = NULL;
276 }
277
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800278 uc_info = get_usecase_from_list(adev, hfpmod.ucid);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800279 if (uc_info == NULL) {
280 ALOGE("%s: Could not find the usecase (%d) in the list",
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800281 __func__, hfpmod.ucid);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800282 return -EINVAL;
283 }
284
Venkata Narendra Kumar Gutta1bbbf542014-09-04 19:11:25 +0530285 /* 2. Disable echo reference while stopping hfp */
Apoorv Raghuvanshi924b3022015-07-06 15:07:14 -0700286 platform_set_echo_reference(adev, false, uc_info->devices);
Venkata Narendra Kumar Gutta1bbbf542014-09-04 19:11:25 +0530287
288 /* 3. Get and set stream specific mixer controls */
Haynes Mathew George1376ca62014-04-24 11:55:48 -0700289 disable_audio_route(adev, uc_info);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800290
Venkata Narendra Kumar Gutta1bbbf542014-09-04 19:11:25 +0530291 /* 4. Disable the rx and tx devices */
Haynes Mathew George1376ca62014-04-24 11:55:48 -0700292 disable_snd_device(adev, uc_info->out_snd_device);
293 disable_snd_device(adev, uc_info->in_snd_device);
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800294
295 list_remove(&uc_info->list);
296 free(uc_info);
297
298 ALOGD("%s: exit: status(%d)", __func__, ret);
299 return ret;
300}
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800301
Vimal Puthanveed37b4a1c2014-01-07 16:47:47 -0800302bool audio_extn_hfp_is_active(struct audio_device *adev)
303{
304 struct audio_usecase *hfp_usecase = NULL;
Vimal Puthanveed41fcff22014-01-23 15:56:53 -0800305 hfp_usecase = get_usecase_from_list(adev, hfpmod.ucid);
Vimal Puthanveed37b4a1c2014-01-07 16:47:47 -0800306
307 if (hfp_usecase != NULL)
308 return true;
309 else
310 return false;
311}
312
Dhanalakshmi Siddani823dc5a2016-09-28 14:47:26 +0530313int hfp_set_mic_mute(struct audio_device *adev, bool state)
314{
315 struct mixer_ctl *ctl;
316 const char *mixer_ctl_name = "HFP TX Mute";
Manish Dewangan338c50a2017-09-12 15:22:03 +0530317 long set_values[ ] = {0};
Dhanalakshmi Siddani823dc5a2016-09-28 14:47:26 +0530318
319 ALOGI("%s: enter, state=%d", __func__, state);
320
321 set_values[0] = state;
322 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
323 if (!ctl) {
324 ALOGE("%s: Could not get ctl for mixer cmd - %s",
325 __func__, mixer_ctl_name);
326 return -EINVAL;
327 }
328 mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
329 ALOGV("%s: exit", __func__);
330 return 0;
331}
332
Vimal Puthanveed41fcff22014-01-23 15:56:53 -0800333audio_usecase_t audio_extn_hfp_get_usecase()
334{
335 return hfpmod.ucid;
336}
337
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800338void audio_extn_hfp_set_parameters(struct audio_device *adev, struct str_parms *parms)
339{
340 int ret;
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800341 int rate;
Vimal Puthanveed21e5c762014-01-08 14:10:09 -0800342 int val;
Amit Shekhar967cab32014-02-07 17:03:21 -0800343 float vol;
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800344 char value[32]={0};
345
346 ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_ENABLE, value,
347 sizeof(value));
348 if (ret >= 0) {
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530349 if (!strncmp(value, "true", sizeof(value)) && !hfpmod.is_hfp_running)
350 ret = start_hfp(adev,parms);
351 else if (!strncmp(value, "false", sizeof(value)) && hfpmod.is_hfp_running)
352 stop_hfp(adev);
353 else
354 ALOGE("hfp_enable=%s is unsupported", value);
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800355 }
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800356 memset(value, 0, sizeof(value));
357 ret = str_parms_get_str(parms,AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE, value,
358 sizeof(value));
359 if (ret >= 0) {
360 rate = atoi(value);
361 if (rate == 8000){
362 hfpmod.ucid = USECASE_AUDIO_HFP_SCO;
363 pcm_config_hfp.rate = rate;
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700364 } else if (rate == 16000){
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800365 hfpmod.ucid = USECASE_AUDIO_HFP_SCO_WB;
366 pcm_config_hfp.rate = rate;
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700367 } else
Vimal Puthanveed47e64852013-12-20 13:23:39 -0800368 ALOGE("Unsupported rate..");
369 }
Vimal Puthanveed21e5c762014-01-08 14:10:09 -0800370
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700371 if (hfpmod.is_hfp_running) {
Vimal Puthanveed21e5c762014-01-08 14:10:09 -0800372 memset(value, 0, sizeof(value));
373 ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
374 value, sizeof(value));
375 if (ret >= 0) {
376 val = atoi(value);
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700377 if (val > 0)
Vimal Puthanveed21e5c762014-01-08 14:10:09 -0800378 select_devices(adev, hfpmod.ucid);
379 }
380 }
Amit Shekhar967cab32014-02-07 17:03:21 -0800381
382 memset(value, 0, sizeof(value));
383 ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HFP_VOLUME,
384 value, sizeof(value));
385 if (ret >= 0) {
386 if (sscanf(value, "%f", &vol) != 1){
387 ALOGE("%s: error in retrieving hfp volume", __func__);
388 ret = -EIO;
389 goto exit;
390 }
391 ALOGD("%s: set_hfp_volume usecase, Vol: [%f]", __func__, vol);
392 hfp_set_volume(adev, vol);
393 }
Satya Krishna Pindiprolic6b0a742017-02-03 14:37:18 +0530394
395 memset(value, 0, sizeof(value));
396 ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_PCM_DEV_ID, value, sizeof(value));
397 if (ret >= 0) {
398 hfpmod.hfp_pcm_dev_id = atoi(value);
399 ALOGD("Updating HFP_PCM_DEV_ID as %d from platform XML", hfpmod.hfp_pcm_dev_id);
400 str_parms_del(parms, AUDIO_PARAMETER_HFP_PCM_DEV_ID);
401 }
402
Amit Shekhar967cab32014-02-07 17:03:21 -0800403exit:
404 ALOGV("%s Exit",__func__);
Vimal Puthanveed584048b2013-12-11 17:00:50 -0800405}
Vimal Puthanveed5b4d3f12013-11-05 15:57:39 -0800406#endif /*HFP_ENABLED*/