summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Chen <intervigil@gmail.com>2014-09-05 13:01:26 -0700
committerScott Mertz <scott@cyngn.com>2015-01-29 13:03:18 -0800
commit5f8e88092dfc751b1f0b1b12d9a6d37cac8ff335 (patch)
tree1a1e216536edeb29d4d8117f89237627a98922c4
parent05674d2866e62b9bf024d2b34f3ab9e35bc5de5a (diff)
downloadandroid_hardware_qcom_audio-5f8e88092dfc751b1f0b1b12d9a6d37cac8ff335.tar.gz
android_hardware_qcom_audio-5f8e88092dfc751b1f0b1b12d9a6d37cac8ff335.tar.bz2
android_hardware_qcom_audio-5f8e88092dfc751b1f0b1b12d9a6d37cac8ff335.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: I880e90a7e887f020517d89ba276199c700c0eeae
-rw-r--r--hal/msm8916/platform.c11
-rw-r--r--hal/msm8960/platform.c6
-rw-r--r--hal/msm8974/platform.c17
-rw-r--r--hal/platform_api.h1
-rw-r--r--hal/platform_info.c48
5 files changed, 80 insertions, 3 deletions
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index a71748ef..c9e4ba54 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -2593,3 +2593,14 @@ bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct
return false;
}
+
+int platform_set_snd_device_name(snd_device_t device, const char *name)
+{
+ if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) {
+ ALOGE("%s:: Invalid snd_device = %d", __func__, device);
+ return -EINVAL;
+ }
+
+ device_table[device] = strdup(name);
+ return 0;
+}
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index 6f955060..e9270674 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -1098,3 +1098,9 @@ uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info __unuse
{
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 489a2062..dfc01c2c 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -231,7 +231,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",
@@ -2785,3 +2785,18 @@ int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t p
done:
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 12d5e029..35d2abc3 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..727c5f48 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>
*/
@@ -236,6 +244,37 @@ static void process_bit_width(const XML_Char **attr)
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 +291,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 != DEVICE_NAME) && (section != BITWIDTH)) {
+ ALOGE("device tag only supported for acdb/backend/device/bitwidth names");
return;
}
@@ -284,6 +326,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;
}
}