diff options
author | Ethan Chen <intervigil@gmail.com> | 2014-09-05 13:01:26 -0700 |
---|---|---|
committer | Rashed Abdel-Tawab <rashed@linux.com> | 2015-10-09 18:28:17 -0400 |
commit | 8cced8fc980ec27d05ec39f20586d58f84d64e8c (patch) | |
tree | e64f770bcb97bfd77c03c85310054107d0d777b6 | |
parent | 8f5e1715f5792a2f33f1f01a54d367fd2ec63f66 (diff) | |
download | hardware_qcom_audio-8cced8fc980ec27d05ec39f20586d58f84d64e8c.tar.gz hardware_qcom_audio-8cced8fc980ec27d05ec39f20586d58f84d64e8c.tar.bz2 hardware_qcom_audio-8cced8fc980ec27d05ec39f20586d58f84d64e8c.zip |
audio: Extend platform parser to allow device name aliasing
* Supported sections now include device names
* This allows for aliasing device names to a custom name
Change-Id: I891704995a77d7a0a3ebea12dca883ee57eba501
-rw-r--r-- | hal/msm8960/platform.c | 6 | ||||
-rw-r--r-- | hal/msm8974/platform.c | 17 | ||||
-rw-r--r-- | hal/platform_api.h | 1 | ||||
-rw-r--r-- | hal/platform_info.c | 49 |
4 files changed, 70 insertions, 3 deletions
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c index 2a826abf..1659061d 100644 --- a/hal/msm8960/platform.c +++ b/hal/msm8960/platform.c @@ -1150,3 +1150,9 @@ int platform_set_device_params(struct stream_out *out __unused, { return 0; } + +int platform_set_snd_device_name(snd_device_t snd_device __unused, + const char * name __unused) +{ + return -ENOSYS; +} diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index dfb924df..cd1a1fd3 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -276,7 +276,7 @@ static int pcm_device_table[AUDIO_USECASE_MAX][2] = { }; /* Array to store sound devices */ -static const char * const device_table[SND_DEVICE_MAX] = { +static char * device_table[SND_DEVICE_MAX] = { [SND_DEVICE_NONE] = "none", /* Playback sound devices */ [SND_DEVICE_OUT_HANDSET] = "handset", @@ -3704,3 +3704,18 @@ int platform_set_device_params(struct stream_out *out, int param, int value) end: return ret; } + +int platform_set_snd_device_name(snd_device_t device, const char *name) +{ + int ret = 0; + + if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) { + ALOGE("%s:: Invalid snd_device = %d", __func__, device); + ret = -EINVAL; + goto done; + } + + device_table[device] = strdup(name); +done: + return ret; +} diff --git a/hal/platform_api.h b/hal/platform_api.h index ea24f792..14ca7cf9 100644 --- a/hal/platform_api.h +++ b/hal/platform_api.h @@ -82,6 +82,7 @@ bool platform_sound_trigger_device_needs_event(snd_device_t snd_device); bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id); int platform_set_snd_device_backend(snd_device_t snd_device, const char * backend); +int platform_set_snd_device_name(snd_device_t snd_device, const char * name); /* From platform_info_parser.c */ int platform_info_init(const char *filename); diff --git a/hal/platform_info.c b/hal/platform_info.c index a176177a..9f78939b 100644 --- a/hal/platform_info.c +++ b/hal/platform_info.c @@ -46,6 +46,7 @@ typedef enum { BITWIDTH, PCM_ID, BACKEND_NAME, + DEVICE_NAME, } section_t; typedef void (* section_process_fn)(const XML_Char **attr); @@ -54,6 +55,7 @@ static void process_acdb_id(const XML_Char **attr); static void process_bit_width(const XML_Char **attr); static void process_pcm_id(const XML_Char **attr); static void process_backend_name(const XML_Char **attr); +static void process_device_name(const XML_Char **attr); static void process_root(const XML_Char **attr); static section_process_fn section_table[] = { @@ -62,6 +64,7 @@ static section_process_fn section_table[] = { [BITWIDTH] = process_bit_width, [PCM_ID] = process_pcm_id, [BACKEND_NAME] = process_backend_name, + [DEVICE_NAME] = process_device_name, }; static section_t section; @@ -83,6 +86,11 @@ static section_t section; * ... * ... * </pcm_ids> + * <device_names> + * <device name="???" alias="???"/> + * ... + * ... + * </device_names> * </audio_platform_info> */ @@ -237,6 +245,38 @@ done: return; } +static void process_device_name(const XML_Char **attr) +{ + int index; + + if (strcmp(attr[0], "name") != 0) { + ALOGE("%s: 'name' not found, no alias set!", __func__); + goto done; + } + + index = platform_get_snd_device_index((char *)attr[1]); + if (index < 0) { + ALOGE("%s: Device %s in platform info xml not found, no alias set!", + __func__, attr[1]); + goto done; + } + + if (strcmp(attr[2], "alias") != 0) { + ALOGE("%s: Device %s in platform info xml has no alias, no alias set!", + __func__, attr[1]); + goto done; + } + + if (platform_set_snd_device_name(index, attr[3]) < 0) { + ALOGE("%s: Device %s, alias %s was not set!", + __func__, attr[1], attr[3]); + goto done; + } + +done: + return; +} + static void start_tag(void *userdata __unused, const XML_Char *tag_name, const XML_Char **attr) { @@ -252,9 +292,12 @@ static void start_tag(void *userdata __unused, const XML_Char *tag_name, section = PCM_ID; } else if (strcmp(tag_name, "backend_names") == 0) { section = BACKEND_NAME; + } else if (strcmp(tag_name, "device_names") == 0) { + section = DEVICE_NAME; } else if (strcmp(tag_name, "device") == 0) { - if ((section != ACDB) && (section != BACKEND_NAME) && (section != BITWIDTH)) { - ALOGE("device tag only supported for acdb/backend names"); + if ((section != ACDB) && (section != BACKEND_NAME) + && (section != BITWIDTH) && (section != DEVICE_NAME)) { + ALOGE("device tag only supported for acdb/backend/device names"); return; } @@ -284,6 +327,8 @@ static void end_tag(void *userdata __unused, const XML_Char *tag_name) section = ROOT; } else if (strcmp(tag_name, "backend_names") == 0) { section = ROOT; + } else if (strcmp(tag_name, "device_names") == 0) { + section = ROOT; } } |