blob: a114b30d1b56f52e6806a82d35cd62e72a94a227 [file] [log] [blame]
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -07001/*
Karthik Reddy Kattad633c542015-07-15 18:18:03 +05302 * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -07003 * Not a Contribution.
4 *
5 * Copyright (C) 2014 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_utils"
21/* #define LOG_NDEBUG 0 */
22
23#include <errno.h>
24#include <cutils/properties.h>
25#include <cutils/config_utils.h>
26#include <stdlib.h>
27#include <dlfcn.h>
28#include <cutils/str_parms.h>
29#include <cutils/log.h>
30#include <cutils/misc.h>
31
32#include "audio_hw.h"
33#include "platform.h"
34#include "platform_api.h"
35#include "audio_extn.h"
Narsinga Rao Chella212e2542014-11-17 19:57:04 -080036#include "voice.h"
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -070037
Ashish Jain81eb2a82015-05-13 10:52:34 +053038#ifdef AUDIO_EXTERNAL_HDMI_ENABLED
39#ifdef HDMI_PASSTHROUGH_ENABLED
40#include "audio_parsers.h"
41#endif
42#endif
43
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -070044#define AUDIO_OUTPUT_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_output_policy.conf"
45
46#define OUTPUTS_TAG "outputs"
47
48#define DYNAMIC_VALUE_TAG "dynamic"
49#define FLAGS_TAG "flags"
50#define FORMATS_TAG "formats"
51#define SAMPLING_RATES_TAG "sampling_rates"
52#define BIT_WIDTH_TAG "bit_width"
53#define APP_TYPE_TAG "app_type"
54
55#define STRING_TO_ENUM(string) { #string, string }
56#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
57
Ben Rombergera04fabc2014-11-14 12:16:03 -080058#define BASE_TABLE_SIZE 64
59#define MAX_BASEINDEX_LEN 256
60
Ashish Jain81eb2a82015-05-13 10:52:34 +053061#ifdef AUDIO_EXTERNAL_HDMI_ENABLED
62#define PROFESSIONAL (1<<0) /* 0 = consumer, 1 = professional */
63#define NON_LPCM (1<<1) /* 0 = audio, 1 = non-audio */
64#define SR_44100 (0<<0) /* 44.1kHz */
65#define SR_NOTID (1<<0) /* non indicated */
66#define SR_48000 (2<<0) /* 48kHz */
67#define SR_32000 (3<<0) /* 32kHz */
68#define SR_22050 (4<<0) /* 22.05kHz */
69#define SR_24000 (6<<0) /* 24kHz */
70#define SR_88200 (8<<0) /* 88.2kHz */
71#define SR_96000 (10<<0) /* 96kHz */
72#define SR_176400 (12<<0) /* 176.4kHz */
73#define SR_192000 (14<<0) /* 192kHz */
74
75#endif
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -070076struct string_to_enum {
77 const char *name;
78 uint32_t value;
79};
80
81const struct string_to_enum s_flag_name_to_enum_table[] = {
82 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_DIRECT),
vivek mehta0ea887a2015-08-26 14:01:20 -070083 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_DIRECT_PCM),
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -070084 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_PRIMARY),
85 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_FAST),
86 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_DEEP_BUFFER),
87 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD),
88 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_NON_BLOCKING),
Pradnya Chaphekar80a8cfb2014-10-20 16:17:01 -070089 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_HW_AV_SYNC),
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -070090#ifdef INCALL_MUSIC_ENABLED
91 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_INCALL_MUSIC),
92#endif
Mingming Yin497419f2015-07-01 16:57:32 -070093#ifdef HDMI_PASSTHROUGH_ENABLED
Pradnya Chaphekar80a8cfb2014-10-20 16:17:01 -070094 STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH),
Mingming Yin497419f2015-07-01 16:57:32 -070095#endif
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -070096};
97
98const struct string_to_enum s_format_name_to_enum_table[] = {
99 STRING_TO_ENUM(AUDIO_FORMAT_PCM_16_BIT),
100 STRING_TO_ENUM(AUDIO_FORMAT_PCM_8_BIT),
101 STRING_TO_ENUM(AUDIO_FORMAT_MP3),
102 STRING_TO_ENUM(AUDIO_FORMAT_AAC),
103 STRING_TO_ENUM(AUDIO_FORMAT_VORBIS),
Mingming Yinae3530f2014-07-03 16:50:18 -0700104 STRING_TO_ENUM(AUDIO_FORMAT_AMR_NB),
105 STRING_TO_ENUM(AUDIO_FORMAT_AMR_WB),
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700106 STRING_TO_ENUM(AUDIO_FORMAT_AC3),
Mingming Yinae3530f2014-07-03 16:50:18 -0700107 STRING_TO_ENUM(AUDIO_FORMAT_E_AC3),
Satya Krishna Pindiproli5d82d012015-08-12 18:21:25 +0530108#ifdef AUDIO_EXTN_FORMATS_ENABLED
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700109 STRING_TO_ENUM(AUDIO_FORMAT_DTS),
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700110 STRING_TO_ENUM(AUDIO_FORMAT_WMA),
111 STRING_TO_ENUM(AUDIO_FORMAT_WMA_PRO),
112 STRING_TO_ENUM(AUDIO_FORMAT_AAC_ADIF),
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700113 STRING_TO_ENUM(AUDIO_FORMAT_AMR_WB_PLUS),
114 STRING_TO_ENUM(AUDIO_FORMAT_EVRC),
115 STRING_TO_ENUM(AUDIO_FORMAT_EVRCB),
116 STRING_TO_ENUM(AUDIO_FORMAT_EVRCWB),
117 STRING_TO_ENUM(AUDIO_FORMAT_QCELP),
118 STRING_TO_ENUM(AUDIO_FORMAT_MP2),
119 STRING_TO_ENUM(AUDIO_FORMAT_EVRCNW),
120 STRING_TO_ENUM(AUDIO_FORMAT_PCM_16_BIT_OFFLOAD),
121 STRING_TO_ENUM(AUDIO_FORMAT_PCM_24_BIT_OFFLOAD),
Amit Shekhar6f461b12014-08-01 14:52:58 -0700122 STRING_TO_ENUM(AUDIO_FORMAT_FLAC),
Satya Krishna Pindiproli70471602015-04-24 19:12:43 +0530123 STRING_TO_ENUM(AUDIO_FORMAT_ALAC),
124 STRING_TO_ENUM(AUDIO_FORMAT_APE),
Pradnya Chaphekar80a8cfb2014-10-20 16:17:01 -0700125 STRING_TO_ENUM(AUDIO_FORMAT_E_AC3_JOC),
Alexy Josephcd8eaed2014-12-11 12:46:53 -0800126 STRING_TO_ENUM(AUDIO_FORMAT_AAC_LC),
127 STRING_TO_ENUM(AUDIO_FORMAT_AAC_HE_V1),
128 STRING_TO_ENUM(AUDIO_FORMAT_AAC_HE_V2),
Manish Dewangana6fc5442015-08-24 20:30:31 +0530129 STRING_TO_ENUM(AUDIO_FORMAT_AAC_ADTS),
130 STRING_TO_ENUM(AUDIO_FORMAT_AAC_SUB_LC),
131 STRING_TO_ENUM(AUDIO_FORMAT_AAC_SUB_HE_V1),
132 STRING_TO_ENUM(AUDIO_FORMAT_AAC_SUB_HE_V2),
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700133#endif
134};
135
Ben Rombergera04fabc2014-11-14 12:16:03 -0800136static char bTable[BASE_TABLE_SIZE] = {
137 'A','B','C','D','E','F','G','H','I','J','K','L',
138 'M','N','O','P','Q','R','S','T','U','V','W','X',
139 'Y','Z','a','b','c','d','e','f','g','h','i','j',
140 'k','l','m','n','o','p','q','r','s','t','u','v',
141 'w','x','y','z','0','1','2','3','4','5','6','7',
142 '8','9','+','/'
143};
144
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700145static uint32_t string_to_enum(const struct string_to_enum *table, size_t size,
146 const char *name)
147{
148 size_t i;
149 for (i = 0; i < size; i++) {
150 if (strcmp(table[i].name, name) == 0) {
151 ALOGV("%s found %s", __func__, table[i].name);
152 return table[i].value;
153 }
154 }
155 return 0;
156}
157
158static audio_output_flags_t parse_flag_names(char *name)
159{
160 uint32_t flag = 0;
161 char *flag_name = strtok(name, "|");
162 while (flag_name != NULL) {
163 if (strlen(flag_name) != 0) {
164 flag |= string_to_enum(s_flag_name_to_enum_table,
165 ARRAY_SIZE(s_flag_name_to_enum_table),
166 flag_name);
167 }
168 flag_name = strtok(NULL, "|");
169 }
170
171 ALOGV("parse_flag_names: flag - %d", flag);
172 return (audio_output_flags_t)flag;
173}
174
175static void parse_format_names(char *name, struct streams_output_cfg *so_info)
176{
177 struct stream_format *sf_info = NULL;
178 char *str = strtok(name, "|");
179
180 if (str != NULL && strcmp(str, DYNAMIC_VALUE_TAG) == 0)
181 return;
182
183 list_init(&so_info->format_list);
184 while (str != NULL) {
185 audio_format_t format = (audio_format_t)string_to_enum(s_format_name_to_enum_table,
186 ARRAY_SIZE(s_format_name_to_enum_table), str);
187 ALOGV("%s: format - %d", __func__, format);
188 if (format != 0) {
189 sf_info = (struct stream_format *)calloc(1, sizeof(struct stream_format));
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700190 if (sf_info == NULL)
191 break; /* return whatever was parsed */
192
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700193 sf_info->format = format;
194 list_add_tail(&so_info->format_list, &sf_info->list);
195 }
196 str = strtok(NULL, "|");
197 }
198}
199
Amit Shekhar6f461b12014-08-01 14:52:58 -0700200static void parse_sample_rate_names(char *name, struct streams_output_cfg *so_info)
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700201{
Amit Shekhar6f461b12014-08-01 14:52:58 -0700202 struct stream_sample_rate *ss_info = NULL;
203 uint32_t sample_rate = 48000;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700204 char *str = strtok(name, "|");
205
Amit Shekhar6f461b12014-08-01 14:52:58 -0700206 if (str != NULL && 0 == strcmp(str, DYNAMIC_VALUE_TAG))
207 return;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700208
Amit Shekhar6f461b12014-08-01 14:52:58 -0700209 list_init(&so_info->sample_rate_list);
210 while (str != NULL) {
211 sample_rate = (uint32_t)strtol(str, (char **)NULL, 10);
212 ALOGV("%s: sample_rate - %d", __func__, sample_rate);
213 if (0 != sample_rate) {
214 ss_info = (struct stream_sample_rate *)calloc(1, sizeof(struct stream_sample_rate));
Chaithanya Krishna Bacharajudb6236a2015-01-30 10:08:33 +0530215 if (ss_info == NULL)
216 break; /* return whatever was parsed */
217
Amit Shekhar6f461b12014-08-01 14:52:58 -0700218 ss_info->sample_rate = sample_rate;
219 list_add_tail(&so_info->sample_rate_list, &ss_info->list);
220 }
221 str = strtok(NULL, "|");
222 }
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700223}
224
225static int parse_bit_width_names(char *name)
226{
227 int bit_width = 16;
228 char *str = strtok(name, "|");
229
230 if (str != NULL && strcmp(str, DYNAMIC_VALUE_TAG))
231 bit_width = (int)strtol(str, (char **)NULL, 10);
232
233 ALOGV("%s: bit_width - %d", __func__, bit_width);
234 return bit_width;
235}
236
237static int parse_app_type_names(void *platform, char *name)
238{
Subhash Chandra Bose Naripeddy54274672014-03-10 14:51:02 -0700239 int app_type = platform_get_default_app_type(platform);
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700240 char *str = strtok(name, "|");
241
242 if (str != NULL && strcmp(str, DYNAMIC_VALUE_TAG))
243 app_type = (int)strtol(str, (char **)NULL, 10);
244
245 ALOGV("%s: app_type - %d", __func__, app_type);
246 return app_type;
247}
248
249static void update_streams_output_cfg_list(cnode *root, void *platform,
250 struct listnode *streams_output_cfg_list)
251{
252 cnode *node = root->first_child;
253 struct streams_output_cfg *so_info;
254
255 ALOGV("%s", __func__);
256 so_info = (struct streams_output_cfg *)calloc(1, sizeof(struct streams_output_cfg));
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700257
258 if (!so_info) {
259 ALOGE("failed to allocate mem for so_info list element");
260 return;
261 }
262
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700263 while (node) {
264 if (strcmp(node->name, FLAGS_TAG) == 0) {
265 so_info->flags = parse_flag_names((char *)node->value);
266 } else if (strcmp(node->name, FORMATS_TAG) == 0) {
267 parse_format_names((char *)node->value, so_info);
268 } else if (strcmp(node->name, SAMPLING_RATES_TAG) == 0) {
Amit Shekhar6f461b12014-08-01 14:52:58 -0700269 so_info->app_type_cfg.sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
270 parse_sample_rate_names((char *)node->value, so_info);
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700271 } else if (strcmp(node->name, BIT_WIDTH_TAG) == 0) {
272 so_info->app_type_cfg.bit_width = parse_bit_width_names((char *)node->value);
273 } else if (strcmp(node->name, APP_TYPE_TAG) == 0) {
274 so_info->app_type_cfg.app_type = parse_app_type_names(platform, (char *)node->value);
275 }
276 node = node->next;
277 }
278 list_add_tail(streams_output_cfg_list, &so_info->list);
279}
280
281static void load_output(cnode *root, void *platform,
282 struct listnode *streams_output_cfg_list)
283{
284 cnode *node = config_find(root, OUTPUTS_TAG);
285 if (node == NULL) {
286 ALOGE("%s: could not load output, node is NULL", __func__);
287 return;
288 }
289
290 node = node->first_child;
291 while (node) {
292 ALOGV("%s: loading output %s", __func__, node->name);
293 update_streams_output_cfg_list(node, platform, streams_output_cfg_list);
294 node = node->next;
295 }
296}
297
298static void send_app_type_cfg(void *platform, struct mixer *mixer,
299 struct listnode *streams_output_cfg_list)
300{
301 int app_type_cfg[MAX_LENGTH_MIXER_CONTROL_IN_INT] = {-1};
302 int length = 0, i, num_app_types = 0;
303 struct listnode *node;
304 bool update;
305 struct mixer_ctl *ctl = NULL;
306 const char *mixer_ctl_name = "App Type Config";
307 struct streams_output_cfg *so_info;
308
309 if (!mixer) {
310 ALOGE("%s: mixer is null",__func__);
311 return;
312 }
313 ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
314 if (!ctl) {
315 ALOGE("%s: Could not get ctl for mixer cmd - %s",__func__, mixer_ctl_name);
316 return;
317 }
318 if (streams_output_cfg_list == NULL) {
319 app_type_cfg[length++] = 1;
Subhash Chandra Bose Naripeddy54274672014-03-10 14:51:02 -0700320 app_type_cfg[length++] = platform_get_default_app_type(platform);
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700321 app_type_cfg[length++] = 48000;
322 app_type_cfg[length++] = 16;
323 mixer_ctl_set_array(ctl, app_type_cfg, length);
324 return;
325 }
326
327 app_type_cfg[length++] = num_app_types;
328 list_for_each(node, streams_output_cfg_list) {
329 so_info = node_to_item(node, struct streams_output_cfg, list);
330 update = true;
331 for (i=0; i<length; i=i+3) {
332 if (app_type_cfg[i+1] == -1)
333 break;
334 else if (app_type_cfg[i+1] == so_info->app_type_cfg.app_type) {
335 update = false;
336 break;
337 }
338 }
339 if (update && ((length + 3) <= MAX_LENGTH_MIXER_CONTROL_IN_INT)) {
340 num_app_types += 1 ;
341 app_type_cfg[length++] = so_info->app_type_cfg.app_type;
342 app_type_cfg[length++] = so_info->app_type_cfg.sample_rate;
343 app_type_cfg[length++] = so_info->app_type_cfg.bit_width;
344 }
345 }
346 ALOGV("%s: num_app_types: %d", __func__, num_app_types);
347 if (num_app_types) {
348 app_type_cfg[0] = num_app_types;
349 mixer_ctl_set_array(ctl, app_type_cfg, length);
350 }
351}
352
353void audio_extn_utils_update_streams_output_cfg_list(void *platform,
354 struct mixer *mixer,
355 struct listnode *streams_output_cfg_list)
356{
357 cnode *root;
358 char *data;
359
360 ALOGV("%s", __func__);
361 list_init(streams_output_cfg_list);
362 data = (char *)load_file(AUDIO_OUTPUT_POLICY_VENDOR_CONFIG_FILE, NULL);
363 if (data == NULL) {
364 send_app_type_cfg(platform, mixer, NULL);
365 ALOGE("%s: could not load output policy config file", __func__);
366 return;
367 }
368
369 root = config_node("", "");
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700370 if (root == NULL) {
371 ALOGE("cfg_list, NULL config root");
372 return;
373 }
374
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700375 config_load(root, data);
376 load_output(root, platform, streams_output_cfg_list);
377
378 send_app_type_cfg(platform, mixer, streams_output_cfg_list);
379}
380
381void audio_extn_utils_dump_streams_output_cfg_list(
382 struct listnode *streams_output_cfg_list)
383{
384 int i=0;
385 struct listnode *node_i, *node_j;
386 struct streams_output_cfg *so_info;
387 struct stream_format *sf_info;
Amit Shekhar6f461b12014-08-01 14:52:58 -0700388 struct stream_sample_rate *ss_info;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700389 ALOGV("%s", __func__);
390 list_for_each(node_i, streams_output_cfg_list) {
391 so_info = node_to_item(node_i, struct streams_output_cfg, list);
Amit Shekhar6f461b12014-08-01 14:52:58 -0700392 ALOGV("%s: flags-%d, output_sample_rate-%d, output_bit_width-%d, app_type-%d",
393 __func__, so_info->flags, so_info->app_type_cfg.sample_rate,
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700394 so_info->app_type_cfg.bit_width, so_info->app_type_cfg.app_type);
395 list_for_each(node_j, &so_info->format_list) {
396 sf_info = node_to_item(node_j, struct stream_format, list);
397 ALOGV("format-%x", sf_info->format);
398 }
Amit Shekhar6f461b12014-08-01 14:52:58 -0700399 list_for_each(node_j, &so_info->sample_rate_list) {
400 ss_info = node_to_item(node_j, struct stream_sample_rate, list);
401 ALOGV("sample rate-%d", ss_info->sample_rate);
402 }
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700403 }
404}
405
406void audio_extn_utils_release_streams_output_cfg_list(
407 struct listnode *streams_output_cfg_list)
408{
409 struct listnode *node_i, *node_j;
410 struct streams_output_cfg *so_info;
411 struct stream_format *sf_info;
412
413 ALOGV("%s", __func__);
414 while (!list_empty(streams_output_cfg_list)) {
415 node_i = list_head(streams_output_cfg_list);
416 so_info = node_to_item(node_i, struct streams_output_cfg, list);
417 while (!list_empty(&so_info->format_list)) {
418 node_j = list_head(&so_info->format_list);
419 list_remove(node_j);
420 free(node_to_item(node_j, struct stream_format, list));
421 }
Amit Shekhar6f461b12014-08-01 14:52:58 -0700422 while (!list_empty(&so_info->sample_rate_list)) {
423 node_j = list_head(&so_info->sample_rate_list);
424 list_remove(node_j);
425 free(node_to_item(node_j, struct stream_sample_rate, list));
426 }
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700427 list_remove(node_i);
428 free(node_to_item(node_i, struct streams_output_cfg, list));
429 }
430}
431
Amit Shekhar6f461b12014-08-01 14:52:58 -0700432static bool set_output_cfg(struct streams_output_cfg *so_info,
433 struct stream_app_type_cfg *app_type_cfg,
434 uint32_t sample_rate, uint32_t bit_width)
435 {
436 struct listnode *node_i;
437 struct stream_sample_rate *ss_info;
438 list_for_each(node_i, &so_info->sample_rate_list) {
439 ss_info = node_to_item(node_i, struct stream_sample_rate, list);
440 if ((sample_rate <= ss_info->sample_rate) &&
441 (bit_width == so_info->app_type_cfg.bit_width)) {
Pradnya Chaphekar80a8cfb2014-10-20 16:17:01 -0700442
Amit Shekhar6f461b12014-08-01 14:52:58 -0700443 app_type_cfg->app_type = so_info->app_type_cfg.app_type;
444 app_type_cfg->sample_rate = ss_info->sample_rate;
445 app_type_cfg->bit_width = so_info->app_type_cfg.bit_width;
446 ALOGV("%s app_type_cfg->app_type %d, app_type_cfg->sample_rate %d, app_type_cfg->bit_width %d",
447 __func__, app_type_cfg->app_type, app_type_cfg->sample_rate, app_type_cfg->bit_width);
448 return true;
449 }
450 }
451 /*
452 * Reiterate through the list assuming dafault sample rate.
453 * Handles scenario where input sample rate is higher
454 * than all sample rates in list for the input bit width.
455 */
456 sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
Apoorv Raghuvanshif59bb222015-02-18 12:23:23 -0800457
Amit Shekhar6f461b12014-08-01 14:52:58 -0700458 list_for_each(node_i, &so_info->sample_rate_list) {
459 ss_info = node_to_item(node_i, struct stream_sample_rate, list);
460 if ((sample_rate <= ss_info->sample_rate) &&
461 (bit_width == so_info->app_type_cfg.bit_width)) {
462 app_type_cfg->app_type = so_info->app_type_cfg.app_type;
463 app_type_cfg->sample_rate = sample_rate;
464 app_type_cfg->bit_width = so_info->app_type_cfg.bit_width;
Apoorv Raghuvanshif59bb222015-02-18 12:23:23 -0800465 ALOGV("%s Assuming sample rate. app_type_cfg->app_type %d, app_type_cfg->sample_rate %d, app_type_cfg->bit_width %d",
Amit Shekhar6f461b12014-08-01 14:52:58 -0700466 __func__, app_type_cfg->app_type, app_type_cfg->sample_rate, app_type_cfg->bit_width);
467 return true;
468 }
469 }
470 return false;
471}
472
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700473void audio_extn_utils_update_stream_app_type_cfg(void *platform,
474 struct listnode *streams_output_cfg_list,
Amit Shekhar1d896042014-10-03 13:16:09 -0700475 audio_devices_t devices,
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700476 audio_output_flags_t flags,
477 audio_format_t format,
Amit Shekhar6f461b12014-08-01 14:52:58 -0700478 uint32_t sample_rate,
479 uint32_t bit_width,
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700480 struct stream_app_type_cfg *app_type_cfg)
481{
Amit Shekhar6f461b12014-08-01 14:52:58 -0700482 struct listnode *node_i, *node_j, *node_k;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700483 struct streams_output_cfg *so_info;
484 struct stream_format *sf_info;
Amit Shekhar6f461b12014-08-01 14:52:58 -0700485 struct stream_sample_rate *ss_info;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700486
Amit Shekhar1d896042014-10-03 13:16:09 -0700487 if ((24 == bit_width) &&
488 (devices & AUDIO_DEVICE_OUT_SPEAKER)) {
Amit Shekhar5a39c912014-10-14 15:39:30 -0700489 int32_t bw = platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER);
490 if (-ENOSYS != bw)
491 bit_width = (uint32_t)bw;
Amit Shekhar1d896042014-10-03 13:16:09 -0700492 sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
493 ALOGI("%s Allowing 24-bit playback on speaker ONLY at default sampling rate", __func__);
494 }
495
496 ALOGV("%s: flags: %x, format: %x sample_rate %d",
497 __func__, flags, format, sample_rate);
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700498 list_for_each(node_i, streams_output_cfg_list) {
499 so_info = node_to_item(node_i, struct streams_output_cfg, list);
500 if (so_info->flags == flags) {
501 list_for_each(node_j, &so_info->format_list) {
502 sf_info = node_to_item(node_j, struct stream_format, list);
503 if (sf_info->format == format) {
Amit Shekhar6f461b12014-08-01 14:52:58 -0700504 if (set_output_cfg(so_info, app_type_cfg, sample_rate, bit_width))
505 return;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700506 }
507 }
508 }
509 }
510 list_for_each(node_i, streams_output_cfg_list) {
511 so_info = node_to_item(node_i, struct streams_output_cfg, list);
512 if (so_info->flags == AUDIO_OUTPUT_FLAG_PRIMARY) {
513 ALOGV("Compatible output profile not found.");
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700514 app_type_cfg->app_type = so_info->app_type_cfg.app_type;
515 app_type_cfg->sample_rate = so_info->app_type_cfg.sample_rate;
516 app_type_cfg->bit_width = so_info->app_type_cfg.bit_width;
Amit Shekhar6f461b12014-08-01 14:52:58 -0700517 ALOGV("%s Default to primary output: App type: %d sample_rate %d",
518 __func__, so_info->app_type_cfg.app_type, app_type_cfg->sample_rate);
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700519 return;
520 }
521 }
522 ALOGW("%s: App type could not be selected. Falling back to default", __func__);
Subhash Chandra Bose Naripeddy54274672014-03-10 14:51:02 -0700523 app_type_cfg->app_type = platform_get_default_app_type(platform);
Amit Shekhar6f461b12014-08-01 14:52:58 -0700524 app_type_cfg->sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700525 app_type_cfg->bit_width = 16;
526}
527
Ben Romberger1fafdde2015-09-09 19:43:15 -0700528int audio_extn_utils_send_app_type_cfg(struct audio_device *adev,
529 struct audio_usecase *usecase)
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700530{
531 char mixer_ctl_name[MAX_LENGTH_MIXER_CONTROL_IN_INT];
532 int app_type_cfg[MAX_LENGTH_MIXER_CONTROL_IN_INT], len = 0, rc;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700533 struct mixer_ctl *ctl;
534 int pcm_device_id, acdb_dev_id, snd_device = usecase->out_snd_device;
Preetam Singh Ranawata4a37d82014-09-25 16:56:38 +0530535 int32_t sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700536
537 ALOGV("%s", __func__);
538
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530539 if (usecase->type != PCM_PLAYBACK && usecase->type != PCM_CAPTURE) {
540 ALOGE("%s: not a playback or capture path, no need to cfg app type", __func__);
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700541 rc = 0;
542 goto exit_send_app_type_cfg;
543 }
544 if ((usecase->id != USECASE_AUDIO_PLAYBACK_DEEP_BUFFER) &&
545 (usecase->id != USECASE_AUDIO_PLAYBACK_LOW_LATENCY) &&
546 (usecase->id != USECASE_AUDIO_PLAYBACK_MULTI_CH) &&
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530547 (!is_offload_usecase(usecase->id)) &&
548 (usecase->type != PCM_CAPTURE)) {
Ben Romberger1fafdde2015-09-09 19:43:15 -0700549 ALOGV("%s: a rx/tx path where app type cfg is not required %d", __func__, usecase->id);
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700550 rc = 0;
551 goto exit_send_app_type_cfg;
552 }
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530553 if (usecase->type == PCM_PLAYBACK) {
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530554 snd_device = usecase->out_snd_device;
Ben Romberger1fafdde2015-09-09 19:43:15 -0700555 pcm_device_id = platform_get_pcm_device_id(usecase->id, PCM_PLAYBACK);
556 } else if (usecase->type == PCM_CAPTURE) {
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530557 snd_device = usecase->in_snd_device;
Ben Romberger1fafdde2015-09-09 19:43:15 -0700558 pcm_device_id = platform_get_pcm_device_id(usecase->id, PCM_CAPTURE);
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530559 }
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700560
561 snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
562 "Audio Stream %d App Type Cfg", pcm_device_id);
563
564 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
565 if (!ctl) {
566 ALOGE("%s: Could not get ctl for mixer cmd - %s", __func__,
567 mixer_ctl_name);
568 rc = -EINVAL;
569 goto exit_send_app_type_cfg;
570 }
571 snd_device = (snd_device == SND_DEVICE_OUT_SPEAKER) ?
572 audio_extn_get_spkr_prot_snd_device(snd_device) : snd_device;
573 acdb_dev_id = platform_get_snd_device_acdb_id(snd_device);
574 if (acdb_dev_id < 0) {
575 ALOGE("%s: Couldn't get the acdb dev id", __func__);
576 rc = -EINVAL;
577 goto exit_send_app_type_cfg;
578 }
Preetam Singh Ranawata4a37d82014-09-25 16:56:38 +0530579
Ben Romberger1fafdde2015-09-09 19:43:15 -0700580 if ((usecase->type == PCM_PLAYBACK) && (usecase->stream.out == NULL)) {
581 sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
582 app_type_cfg[len++] = platform_get_default_app_type(adev->platform);
583 app_type_cfg[len++] = acdb_dev_id;
584 app_type_cfg[len++] = sample_rate;
585 ALOGI("%s PLAYBACK app_type %d, acdb_dev_id %d, sample_rate %d",
586 __func__, platform_get_default_app_type(adev->platform), acdb_dev_id, sample_rate);
587 } else if (usecase->type == PCM_PLAYBACK) {
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530588 if ((24 == usecase->stream.out->bit_width) &&
589 (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
Dhananjay Kumar14170dd2015-08-28 13:24:16 +0530590 usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530591 } else if ((snd_device != SND_DEVICE_OUT_HEADPHONES_44_1 &&
592 usecase->stream.out->sample_rate == OUTPUT_SAMPLING_RATE_44100) ||
593 (usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) {
Dhananjay Kumar14170dd2015-08-28 13:24:16 +0530594 usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530595 }
Dhananjay Kumar14170dd2015-08-28 13:24:16 +0530596 sample_rate = usecase->stream.out->app_type_cfg.sample_rate;
Preetam Singh Ranawata4a37d82014-09-25 16:56:38 +0530597
Ben Romberger1fafdde2015-09-09 19:43:15 -0700598 app_type_cfg[len++] = usecase->stream.out->app_type_cfg.app_type;
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530599 app_type_cfg[len++] = acdb_dev_id;
Ben Romberger1fafdde2015-09-09 19:43:15 -0700600 if (((usecase->stream.out->format == AUDIO_FORMAT_E_AC3) ||
601 (usecase->stream.out->format == AUDIO_FORMAT_E_AC3_JOC))
Mingming Yin497419f2015-07-01 16:57:32 -0700602#ifdef HDMI_PASSTHROUGH_ENABLED
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530603 && (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH)
Mingming Yin497419f2015-07-01 16:57:32 -0700604#endif
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530605 )
606 app_type_cfg[len++] = sample_rate * 4;
607 else
608 app_type_cfg[len++] = sample_rate;
609 ALOGI("%s PLAYBACK app_type %d, acdb_dev_id %d, sample_rate %d",
Ben Romberger1fafdde2015-09-09 19:43:15 -0700610 __func__, usecase->stream.out->app_type_cfg.app_type, acdb_dev_id, sample_rate);
611 } else if (usecase->type == PCM_CAPTURE) {
612 app_type_cfg[len++] = platform_get_default_app_type(adev->platform);
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530613 app_type_cfg[len++] = acdb_dev_id;
Pradnya Chaphekar80a8cfb2014-10-20 16:17:01 -0700614 app_type_cfg[len++] = sample_rate;
Srikanth Uyyala9d551402015-08-25 16:03:42 +0530615 ALOGI("%s CAPTURE app_type %d, acdb_dev_id %d, sample_rate %d",
616 __func__, platform_get_default_app_type(adev->platform), acdb_dev_id, sample_rate);
617 }
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700618 mixer_ctl_set_array(ctl, app_type_cfg, len);
Subhash Chandra Bose Naripeddy19dc03b2014-03-10 14:43:05 -0700619 rc = 0;
620exit_send_app_type_cfg:
621 return rc;
622}
Subhash Chandra Bose Naripeddy54274672014-03-10 14:51:02 -0700623
624void audio_extn_utils_send_audio_calibration(struct audio_device *adev,
625 struct audio_usecase *usecase)
626{
627 int type = usecase->type;
628
629 if (type == PCM_PLAYBACK) {
630 struct stream_out *out = usecase->stream.out;
631 int snd_device = usecase->out_snd_device;
632 snd_device = (snd_device == SND_DEVICE_OUT_SPEAKER) ?
633 audio_extn_get_spkr_prot_snd_device(snd_device) : snd_device;
Preetam Singh Ranawat2d0e4632015-02-02 12:40:59 +0530634 platform_send_audio_calibration(adev->platform, usecase,
Subhash Chandra Bose Naripeddy54274672014-03-10 14:51:02 -0700635 out->app_type_cfg.app_type,
636 out->app_type_cfg.sample_rate);
637 }
638 if ((type == PCM_HFP_CALL) || (type == PCM_CAPTURE)) {
Preetam Singh Ranawat2d0e4632015-02-02 12:40:59 +0530639 /* when app type is default. the sample rate is not used to send cal */
640 platform_send_audio_calibration(adev->platform, usecase,
641 platform_get_default_app_type(adev->platform),
642 48000);
Subhash Chandra Bose Naripeddy54274672014-03-10 14:51:02 -0700643 }
644}
645
Ben Rombergera04fabc2014-11-14 12:16:03 -0800646// Base64 Encode and Decode
647// Not all features supported. This must be used only with following conditions.
648// Decode Modes: Support with and without padding
649// CRLF not handling. So no CRLF in string to decode.
650// Encode Modes: Supports only padding
651int b64decode(char *inp, int ilen, uint8_t* outp)
652{
653 int i, j, k, ii, num;
654 int rem, pcnt;
655 uint32_t res=0;
656 uint8_t getIndex[MAX_BASEINDEX_LEN];
657 uint8_t tmp, cflag;
658
659 if(inp == NULL || outp == NULL || ilen <= 0) {
660 ALOGE("[%s] received NULL pointer or zero length",__func__);
661 return -1;
662 }
663
664 memset(getIndex, MAX_BASEINDEX_LEN-1, sizeof(getIndex));
665 for(i=0;i<BASE_TABLE_SIZE;i++) {
666 getIndex[(uint8_t)bTable[i]] = (uint8_t)i;
667 }
668 getIndex[(uint8_t)'=']=0;
669
670 j=0;k=0;
671 num = ilen/4;
672 rem = ilen%4;
673 if(rem==0)
674 num = num-1;
675 cflag=0;
676 for(i=0; i<num; i++) {
677 res=0;
678 for(ii=0;ii<4;ii++) {
679 res = res << 6;
680 tmp = getIndex[(uint8_t)inp[j++]];
681 res = res | tmp;
682 cflag = cflag | tmp;
683 }
684 outp[k++] = (res >> 16)&0xFF;
685 outp[k++] = (res >> 8)&0xFF;
686 outp[k++] = res & 0xFF;
687 }
688
689 // Handle last bytes special
690 pcnt=0;
691 if(rem == 0) {
692 //With padding or full data
693 res = 0;
694 for(ii=0;ii<4;ii++) {
695 if(inp[j] == '=')
696 pcnt++;
697 res = res << 6;
698 tmp = getIndex[(uint8_t)inp[j++]];
699 res = res | tmp;
700 cflag = cflag | tmp;
701 }
702 outp[k++] = res >> 16;
703 if(pcnt == 2)
704 goto done;
705 outp[k++] = (res>>8)&0xFF;
706 if(pcnt == 1)
707 goto done;
708 outp[k++] = res&0xFF;
709 } else {
710 //without padding
711 res = 0;
712 for(i=0;i<rem;i++) {
713 res = res << 6;
714 tmp = getIndex[(uint8_t)inp[j++]];
715 res = res | tmp;
716 cflag = cflag | tmp;
717 }
718 for(i=rem;i<4;i++) {
719 res = res << 6;
720 pcnt++;
721 }
722 outp[k++] = res >> 16;
723 if(pcnt == 2)
724 goto done;
725 outp[k++] = (res>>8)&0xFF;
726 if(pcnt == 1)
727 goto done;
728 outp[k++] = res&0xFF;
729 }
730done:
731 if(cflag == 0xFF) {
732 ALOGE("[%s] base64 decode failed. Invalid character found %s",
733 __func__, inp);
734 return 0;
735 }
736 return k;
737}
738
739int b64encode(uint8_t *inp, int ilen, char* outp)
740{
741 int i,j,k, num;
742 int rem=0;
743 uint32_t res=0;
744
745 if(inp == NULL || outp == NULL || ilen<=0) {
746 ALOGE("[%s] received NULL pointer or zero input length",__func__);
747 return -1;
748 }
749
750 num = ilen/3;
751 rem = ilen%3;
752 j=0;k=0;
753 for(i=0; i<num; i++) {
754 //prepare index
755 res = inp[j++]<<16;
756 res = res | inp[j++]<<8;
757 res = res | inp[j++];
758 //get output map from index
759 outp[k++] = (char) bTable[(res>>18)&0x3F];
760 outp[k++] = (char) bTable[(res>>12)&0x3F];
761 outp[k++] = (char) bTable[(res>>6)&0x3F];
762 outp[k++] = (char) bTable[res&0x3F];
763 }
764
765 switch(rem) {
766 case 1:
767 res = inp[j++]<<16;
768 outp[k++] = (char) bTable[res>>18];
769 outp[k++] = (char) bTable[(res>>12)&0x3F];
770 //outp[k++] = '=';
771 //outp[k++] = '=';
772 break;
773 case 2:
774 res = inp[j++]<<16;
775 res = res | inp[j++]<<8;
776 outp[k++] = (char) bTable[res>>18];
777 outp[k++] = (char) bTable[(res>>12)&0x3F];
778 outp[k++] = (char) bTable[(res>>6)&0x3F];
779 //outp[k++] = '=';
780 break;
781 default:
782 break;
783 }
784done:
785 outp[k] = '\0';
786 return k;
787}
Ashish Jain81eb2a82015-05-13 10:52:34 +0530788
789#ifdef AUDIO_EXTERNAL_HDMI_ENABLED
790
791void get_default_compressed_channel_status(
792 unsigned char *channel_status)
793{
794 int32_t status = 0;
795 unsigned char bit_index;
796 memset(channel_status,0,24);
797
798 /* block start bit in preamble bit 3 */
799 channel_status[0] |= PROFESSIONAL;
800 //compre out
801 channel_status[0] |= NON_LPCM;
802 // sample rate; fixed 48K for default/transcode
803 channel_status[3] |= SR_48000;
804}
805
806#ifdef HDMI_PASSTHROUGH_ENABLED
807int32_t get_compressed_channel_status(void *audio_stream_data,
808 uint32_t audio_frame_size,
809 unsigned char *channel_status,
810 enum audio_parser_code_type codec_type)
811 // codec_type - AUDIO_PARSER_CODEC_AC3
812 // - AUDIO_PARSER_CODEC_DTS
813{
814 unsigned char *stream;
815 int ret = 0;
816 stream = (unsigned char *)audio_stream_data;
817
818 if (audio_stream_data == NULL || audio_frame_size == 0) {
819 ALOGW("no buffer to get channel status, return default for compress");
820 get_default_compressed_channel_status(channel_status);
821 return ret;
822 }
823
824 memset(channel_status,0,24);
825 if(init_audio_parser(stream, audio_frame_size, codec_type) == -1)
826 {
827 ALOGE("init audio parser failed");
828 return -1;
829 }
830 ret = get_channel_status(channel_status, codec_type);
831 return ret;
832
833}
834
835#endif
836
837void get_lpcm_channel_status(uint32_t sampleRate,
838 unsigned char *channel_status)
839{
840 int32_t status = 0;
841 unsigned char bit_index;
842 memset(channel_status,0,24);
843 /* block start bit in preamble bit 3 */
844 channel_status[0] |= PROFESSIONAL;
845 //LPCM OUT
846 channel_status[0] &= ~NON_LPCM;
847
848 switch (sampleRate) {
849 case 8000:
850 case 11025:
851 case 12000:
852 case 16000:
853 case 22050:
854 channel_status[3] |= SR_NOTID;
855 case 24000:
856 channel_status[3] |= SR_24000;
857 break;
858 case 32000:
859 channel_status[3] |= SR_32000;
860 break;
861 case 44100:
862 channel_status[3] |= SR_44100;
863 break;
864 case 48000:
865 channel_status[3] |= SR_48000;
866 break;
867 case 88200:
868 channel_status[3] |= SR_88200;
869 break;
870 case 96000:
871 channel_status[3] |= SR_96000;
872 break;
873 case 176400:
874 channel_status[3] |= SR_176400;
875 break;
876 case 192000:
877 channel_status[3] |= SR_192000;
878 break;
879 default:
880 ALOGV("Invalid sample_rate %u\n", sampleRate);
881 status = -1;
882 break;
883 }
884}
885
886void audio_utils_set_hdmi_channel_status(struct stream_out *out, char * buffer, size_t bytes)
887{
888 unsigned char channel_status[24]={0};
889 struct snd_aes_iec958 iec958;
890 const char *mixer_ctl_name = "IEC958 Playback PCM Stream";
891 struct mixer_ctl *ctl;
892 int i=0;
893#ifdef HDMI_PASSTHROUGH_ENABLED
894 if (audio_extn_is_dolby_format(out->format) &&
895 /*TODO:Extend code to support DTS passthrough*/
896 /*set compressed channel status bits*/
897 audio_extn_dolby_is_passthrough_stream(out->flags)){
898 get_compressed_channel_status(buffer, bytes, channel_status, AUDIO_PARSER_CODEC_AC3);
899 } else
900#endif
901 {
902 /*set channel status bit for LPCM*/
903 get_lpcm_channel_status(out->sample_rate, channel_status);
904 }
905
906 memcpy(iec958.status, channel_status,sizeof(iec958.status));
907 ctl = mixer_get_ctl_by_name(out->dev->mixer, mixer_ctl_name);
908 if (!ctl) {
909 ALOGE("%s: Could not get ctl for mixer cmd - %s",
910 __func__, mixer_ctl_name);
911 return;
912 }
913 if (mixer_ctl_set_array(ctl, &iec958, sizeof(iec958)) < 0) {
914 ALOGE("%s: Could not set channel status for ext HDMI ",
915 __func__);
916 return;
917 }
918
919}
920#endif