blob: 99fa2b7b49732180c721184b5c6673664266ddec [file] [log] [blame]
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -08001/*
2 * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
5 * Copyright (C) 2010 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_dolby"
21/*#define LOG_NDEBUG 0*/
22#define LOG_NDDEBUG 0
23
24#include <errno.h>
25#include <cutils/properties.h>
26#include <stdlib.h>
27#include <dlfcn.h>
28#include <cutils/str_parms.h>
29#include <cutils/log.h>
30
31#include "audio_hw.h"
32#include "platform.h"
33#include "platform_api.h"
34#include "audio_extn.h"
35#include "sound/compress_params.h"
36
37#ifdef DS1_DOLBY_DDP_ENABLED
38
39#define AUDIO_PARAMETER_DDP_DEV "ddp_device"
40#define AUDIO_PARAMETER_DDP_CH_CAP "ddp_chancap"
41#define AUDIO_PARAMETER_DDP_MAX_OUT_CHAN "ddp_maxoutchan"
42#define AUDIO_PARAMETER_DDP_OUT_MODE "ddp_outmode"
43#define AUDIO_PARAMETER_DDP_OUT_LFE_ON "ddp_outlfeon"
44#define AUDIO_PARAMETER_DDP_COMP_MODE "ddp_compmode"
45#define AUDIO_PARAMETER_DDP_STEREO_MODE "ddp_stereomode"
46
47#define PARAM_ID_MAX_OUTPUT_CHANNELS 0x00010DE2
48#define PARAM_ID_CTL_RUNNING_MODE 0x0
49#define PARAM_ID_CTL_ERROR_CONCEAL 0x00010DE3
50#define PARAM_ID_CTL_ERROR_MAX_RPTS 0x00010DE4
51#define PARAM_ID_CNV_ERROR_CONCEAL 0x00010DE5
52#define PARAM_ID_CTL_SUBSTREAM_SELECT 0x00010DE6
53#define PARAM_ID_CTL_INPUT_MODE 0x0
54#define PARAM_ID_OUT_CTL_OUTMODE 0x00010DE0
55#define PARAM_ID_OUT_CTL_OUTLFE_ON 0x00010DE1
56#define PARAM_ID_OUT_CTL_COMPMODE 0x00010D74
57#define PARAM_ID_OUT_CTL_STEREO_MODE 0x00010D76
58#define PARAM_ID_OUT_CTL_DUAL_MODE 0x00010D75
59#define PARAM_ID_OUT_CTL_DRCSCALE_HIGH 0x00010D7A
60#define PARAM_ID_OUT_CTL_DRCSCALE_LOW 0x00010D79
61#define PARAM_ID_OUT_CTL_OUT_PCMSCALE 0x00010D78
62#define PARAM_ID_OUT_CTL_MDCT_BANDLIMIT 0x00010DE7
63#define PARAM_ID_OUT_CTL_DRC_SUPPRESS 0x00010DE8
64
65/* DS1-DDP Endp Params */
66#define DDP_ENDP_NUM_PARAMS 17
Krishnankutty Kolathappilly9b7e96b2014-02-14 14:45:49 -080067#define DDP_ENDP_NUM_DEVICES 23
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -080068static int ddp_endp_params_id[DDP_ENDP_NUM_PARAMS] = {
69 PARAM_ID_MAX_OUTPUT_CHANNELS, PARAM_ID_CTL_RUNNING_MODE,
70 PARAM_ID_CTL_ERROR_CONCEAL, PARAM_ID_CTL_ERROR_MAX_RPTS,
71 PARAM_ID_CNV_ERROR_CONCEAL, PARAM_ID_CTL_SUBSTREAM_SELECT,
72 PARAM_ID_CTL_INPUT_MODE, PARAM_ID_OUT_CTL_OUTMODE,
73 PARAM_ID_OUT_CTL_OUTLFE_ON, PARAM_ID_OUT_CTL_COMPMODE,
74 PARAM_ID_OUT_CTL_STEREO_MODE, PARAM_ID_OUT_CTL_DUAL_MODE,
75 PARAM_ID_OUT_CTL_DRCSCALE_HIGH, PARAM_ID_OUT_CTL_DRCSCALE_LOW,
76 PARAM_ID_OUT_CTL_OUT_PCMSCALE, PARAM_ID_OUT_CTL_MDCT_BANDLIMIT,
77 PARAM_ID_OUT_CTL_DRC_SUPPRESS
78};
79
80static struct ddp_endp_params {
81 int device;
82 int dev_ch_cap;
83 int param_val[DDP_ENDP_NUM_PARAMS];
84 bool is_param_valid[DDP_ENDP_NUM_PARAMS];
85} ddp_endp_params[DDP_ENDP_NUM_DEVICES] = {
86 {AUDIO_DEVICE_OUT_EARPIECE, 2,
87 {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
88 {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 } },
89 {AUDIO_DEVICE_OUT_SPEAKER, 2,
90 {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
91 {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
92 {AUDIO_DEVICE_OUT_WIRED_HEADSET, 2,
93 {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
94 {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
95 {AUDIO_DEVICE_OUT_WIRED_HEADPHONE, 2,
96 {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
97 {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
98 {AUDIO_DEVICE_OUT_BLUETOOTH_SCO, 2,
99 {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
100 {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
101 {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET, 2,
102 {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
103 {1, 0, 0, 0,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, 0, 0, 0, 0, 0, 0} },
146 {AUDIO_DEVICE_OUT_ANC_HEADPHONE, 2,
147 {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0},
148 {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
149 {AUDIO_DEVICE_OUT_PROXY, 2,
Krishnankutty Kolathappilly9b7e96b2014-02-14 14:45:49 -0800150 {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0},
151 {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
152 {AUDIO_DEVICE_OUT_PROXY, 6,
153 {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0},
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800154 {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} },
155};
156
157int update_ddp_endp_table(int device, int dev_ch_cap, int param_id,
158 int param_val)
159{
160 int idx = 0;
161 int param_idx = 0;
162 ALOGV("%s: dev 0x%x dev_ch_cap %d param_id 0x%x param_val %d",
163 __func__, device, dev_ch_cap , param_id, param_val);
164
165 for(idx=0; idx<DDP_ENDP_NUM_DEVICES; idx++) {
166 if(ddp_endp_params[idx].device == device) {
167 if(ddp_endp_params[idx].dev_ch_cap == dev_ch_cap) {
168 break;
169 }
170 }
171 }
172
173 if(idx>=DDP_ENDP_NUM_DEVICES) {
174 ALOGE("%s: device not available in DDP endp config table", __func__);
175 return -EINVAL;
176 }
177
178 for(param_idx=0; param_idx<DDP_ENDP_NUM_PARAMS; param_idx++) {
179 if (ddp_endp_params_id[param_idx] == param_id) {
180 break;
181 }
182 }
183
184 if(param_idx>=DDP_ENDP_NUM_PARAMS) {
185 ALOGE("param not available in DDP endp config table");
186 return -EINVAL;
187 }
188
189 ALOGV("ddp_endp_params[%d].param_val[%d] = %d", idx, param_idx, param_val);
190 ddp_endp_params[idx].param_val[param_idx] = param_val;
191 return 0;
192}
193
194void send_ddp_endp_params_stream(struct stream_out *out,
195 int device, int dev_ch_cap,
196 bool set_cache)
197{
198 int idx, i;
199 int ddp_endp_params_data[2*DDP_ENDP_NUM_PARAMS + 1];
200 int length = 0;
201 for(idx=0; idx<DDP_ENDP_NUM_DEVICES; idx++) {
202 if(ddp_endp_params[idx].device & device) {
203 if(ddp_endp_params[idx].dev_ch_cap == dev_ch_cap) {
204 break;
205 }
206 }
207 }
208 if(idx>=DDP_ENDP_NUM_DEVICES) {
209 ALOGE("device not available in DDP endp config table");
210 return;
211 }
212
213 length += 1; /* offset 0 is for num of parameter. increase offset by 1 */
214 for (i=0; i<DDP_ENDP_NUM_PARAMS; i++) {
215 if(ddp_endp_params[idx].is_param_valid[i]) {
216 ddp_endp_params_data[length++] = ddp_endp_params_id[i];
217 ddp_endp_params_data[length++] = ddp_endp_params[idx].param_val[i];
218 }
219 }
220 ddp_endp_params_data[0] = (length-1)/2;
221 if(length) {
222 char mixer_ctl_name[128];
223 struct audio_device *adev = out->dev;
224 struct mixer_ctl *ctl;
225 int pcm_device_id = platform_get_pcm_device_id(out->usecase,
226 PCM_PLAYBACK);
227 snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
228 "Audio Stream %d Dec Params", pcm_device_id);
229 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
230 if (!ctl) {
231 ALOGE("%s: Could not get ctl for mixer cmd - %s",
232 __func__, mixer_ctl_name);
233 return;
234 }
235 mixer_ctl_set_array(ctl, ddp_endp_params_data, length);
236 }
237 return;
238}
239
240void send_ddp_endp_params(struct audio_device *adev,
241 int ddp_dev, int dev_ch_cap)
242{
243 struct listnode *node;
244 struct audio_usecase *usecase;
245
246 list_for_each(node, &adev->usecase_list) {
247 usecase = node_to_item(node, struct audio_usecase, list);
248 if ((usecase->type == PCM_PLAYBACK) &&
249 (usecase->devices & ddp_dev) &&
250 (usecase->stream.out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
251 ((usecase->stream.out->format == AUDIO_FORMAT_AC3) ||
252 (usecase->stream.out->format == AUDIO_FORMAT_EAC3))) {
253 send_ddp_endp_params_stream(usecase->stream.out, ddp_dev,
254 dev_ch_cap, false /* set cache */);
255 }
256 }
257}
258
259void audio_extn_dolby_send_ddp_endp_params(struct audio_device *adev)
260{
261 struct listnode *node;
262 struct audio_usecase *usecase;
263 list_for_each(node, &adev->usecase_list) {
264 usecase = node_to_item(node, struct audio_usecase, list);
265 if ((usecase->type == PCM_PLAYBACK) &&
266 (usecase->devices & AUDIO_DEVICE_OUT_ALL) &&
267 (usecase->stream.out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
268 ((usecase->stream.out->format == AUDIO_FORMAT_AC3) ||
269 (usecase->stream.out->format == AUDIO_FORMAT_EAC3))) {
Krishnankutty Kolathappilly9b7e96b2014-02-14 14:45:49 -0800270 /*
271 * Use wfd /hdmi sink channel cap for dolby params if device is wfd
272 * or hdmi. Otherwise use stereo configuration
273 */
274 int channel_cap = usecase->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL ?
275 adev->cur_hdmi_channels :
276 usecase->devices & AUDIO_DEVICE_OUT_PROXY ?
277 adev->cur_wfd_channels : 2;
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800278 send_ddp_endp_params_stream(usecase->stream.out, usecase->devices,
Krishnankutty Kolathappilly9b7e96b2014-02-14 14:45:49 -0800279 channel_cap, false /* set cache */);
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800280 }
281 }
282}
283
284void audio_extn_ddp_set_parameters(struct audio_device *adev,
285 struct str_parms *parms)
286{
287 int ddp_dev, dev_ch_cap;
288 int val, ret;
289 char value[32]={0};
290 ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_DEV, value,
291 sizeof(value));
292 if (ret >= 0) {
293 ddp_dev = atoi(value);
294 if (!(AUDIO_DEVICE_OUT_ALL & ddp_dev))
295 return;
296 } else
297 return;
298
299 ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_CH_CAP, value,
300 sizeof(value));
301 if (ret >= 0) {
302 dev_ch_cap = atoi(value);
303 if ((dev_ch_cap != 2) && (dev_ch_cap != 6) && (dev_ch_cap != 8))
304 return;
305 } else
306 return;
307
308 ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_MAX_OUT_CHAN, value,
309 sizeof(value));
310 if (ret >= 0) {
311 val = atoi(value);
312 update_ddp_endp_table(ddp_dev, dev_ch_cap,
313 PARAM_ID_MAX_OUTPUT_CHANNELS, val);
314 }
315
316 ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_OUT_MODE, value,
317 sizeof(value));
318 if (ret >= 0) {
319 val = atoi(value);
320 update_ddp_endp_table(ddp_dev, dev_ch_cap,
321 PARAM_ID_OUT_CTL_OUTMODE, val);
322 }
323
324 ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_OUT_LFE_ON, value,
325 sizeof(value));
326 if (ret >= 0) {
327 val = atoi(value);
328 update_ddp_endp_table(ddp_dev, dev_ch_cap,
329 PARAM_ID_OUT_CTL_OUTLFE_ON, val);
330 }
331
332 ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_COMP_MODE, value,
333 sizeof(value));
334 if (ret >= 0) {
335 val = atoi(value);
336 update_ddp_endp_table(ddp_dev, dev_ch_cap,
337 PARAM_ID_OUT_CTL_COMPMODE, val);
338 }
339
340 ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_STEREO_MODE, value,
341 sizeof(value));
342 if (ret >= 0) {
343 val = atoi(value);
344 update_ddp_endp_table(ddp_dev, dev_ch_cap,
345 PARAM_ID_OUT_CTL_STEREO_MODE, val);
346 }
Krishnankutty Kolathappilly9b7e96b2014-02-14 14:45:49 -0800347 /* TODO: Do we need device channel caps here?
348 * We dont have that information as this is from dolby modules
349 */
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800350 send_ddp_endp_params(adev, ddp_dev, dev_ch_cap);
351}
352
353int audio_extn_dolby_get_snd_codec_id(struct audio_device *adev,
354 struct stream_out *out,
355 audio_format_t format)
356{
357 int id = 0;
Krishnankutty Kolathappilly9b7e96b2014-02-14 14:45:49 -0800358 /*
359 * Use wfd /hdmi sink channel cap for dolby params if device is wfd
360 * or hdmi. Otherwise use stereo configuration
361 */
362 int channel_cap = out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL ?
363 adev->cur_hdmi_channels :
364 out->devices & AUDIO_DEVICE_OUT_PROXY ?
365 adev->cur_wfd_channels : 2;
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800366
367 switch (format) {
368 case AUDIO_FORMAT_AC3:
369 id = SND_AUDIOCODEC_AC3;
370 send_ddp_endp_params_stream(out, out->devices,
Krishnankutty Kolathappilly9b7e96b2014-02-14 14:45:49 -0800371 channel_cap, true /* set_cache */);
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800372#ifndef DS1_DOLBY_DAP_ENABLED
373 audio_extn_dolby_set_dmid(adev);
374#endif
375 break;
376 case AUDIO_FORMAT_EAC3:
377 id = SND_AUDIOCODEC_EAC3;
378 send_ddp_endp_params_stream(out, out->devices,
Krishnankutty Kolathappilly9b7e96b2014-02-14 14:45:49 -0800379 channel_cap, true /* set_cache */);
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800380#ifndef DS1_DOLBY_DAP_ENABLED
381 audio_extn_dolby_set_dmid(adev);
382#endif
383 break;
384 default:
385 ALOGE("%s: Unsupported audio format :%x", __func__, format);
386 }
387
388 return id;
389}
390
391bool audio_extn_is_dolby_format(audio_format_t format)
392{
393 if (format == AUDIO_FORMAT_AC3 ||
394 format == AUDIO_FORMAT_EAC3)
395 return true;
396 else
397 return false;
398}
399
400#endif /* DS1_DOLBY_DDP_ENABLED */
401
402#ifdef DS1_DOLBY_DAP_ENABLED
403void audio_extn_dolby_set_endpoint(struct audio_device *adev)
404{
405 struct listnode *node;
406 struct audio_usecase *usecase;
407 struct mixer_ctl *ctl;
408 const char *mixer_ctl_name = "DS1 DAP Endpoint";
409 int endpoint = 0, ret;
410 bool send = false;
411
412 list_for_each(node, &adev->usecase_list) {
413 usecase = node_to_item(node, struct audio_usecase, list);
414 if ((usecase->type == PCM_PLAYBACK) &&
415 (usecase->id != USECASE_AUDIO_PLAYBACK_LOW_LATENCY)) {
416 endpoint |= usecase->devices & AUDIO_DEVICE_OUT_ALL;
417 send = true;
418 }
419 }
420 if (!send)
421 return;
422
423 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
424 if (!ctl) {
425 ALOGE("%s: Could not get ctl for mixer cmd - %s",
426 __func__, mixer_ctl_name);
427 return;
428 }
429 ret = mixer_ctl_set_value(ctl, 0, endpoint);
430 if (ret)
431 ALOGE("%s: Dolby set endpint cannot be set error:%d",__func__, ret);
432
433 return;
434}
435#endif /* DS1_DOLBY_DAP_ENABLED */
436
437
438#if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED)
439void audio_extn_dolby_set_dmid(struct audio_device *adev)
440{
441 struct listnode *node;
442 struct audio_usecase *usecase;
443 struct mixer_ctl *ctl;
444 const char *mixer_ctl_name = "DS1 Security";
445 char c_dmid[128] = {0};
446 int i_dmid, ret;
447 bool send = false;
448
449 list_for_each(node, &adev->usecase_list) {
450 usecase = node_to_item(node, struct audio_usecase, list);
Mingming Yin95a09432014-02-25 13:34:07 -0800451 if (usecase->type == PCM_PLAYBACK)
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800452 send = true;
453 }
454 if (!send)
455 return;
456
457 property_get("dmid",c_dmid,"0");
458 i_dmid = atoi(c_dmid);
459
460 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
461 if (!ctl) {
462 ALOGE("%s: Could not get ctl for mixer cmd - %s",
463 __func__, mixer_ctl_name);
464 return;
465 }
466 ALOGV("%s Dolby device manufacturer id is:%d",__func__,i_dmid);
467 ret = mixer_ctl_set_value(ctl, 0, i_dmid);
468 if (ret)
469 ALOGE("%s: Dolby DMID cannot be set error:%d",__func__, ret);
470
471 return;
472}
473#endif /* DS1_DOLBY_DDP_ENABLED || DS1_DOLBY_DAP_ENABLED */