From 2ea956fe4ba6fe76702b021cfb1d39c80bcfc69a Mon Sep 17 00:00:00 2001 From: Ziyan Date: Fri, 29 Jan 2016 12:07:18 +0100 Subject: audio: select correct audio config at runtime (1/5) Change-Id: If9732081791ab68f028129c953b518196f31b09c --- audio/audio_hw.c | 15 ++- audio/audio_hw.h | 3 +- audio/tiny_hw_espresso.xml | 281 +++++++++++++++++++++++++++++++++++++++ audio/tiny_hw_espresso10.xml | 251 ++++++++++++++++++++++++++++++++++ audio/tiny_hw_espresso10wifi.xml | 229 +++++++++++++++++++++++++++++++ audio/tiny_hw_espressowifi.xml | 250 ++++++++++++++++++++++++++++++++++ espresso-common.mk | 7 + 7 files changed, 1031 insertions(+), 5 deletions(-) create mode 100644 audio/tiny_hw_espresso.xml create mode 100644 audio/tiny_hw_espresso10.xml create mode 100644 audio/tiny_hw_espresso10wifi.xml create mode 100644 audio/tiny_hw_espressowifi.xml diff --git a/audio/audio_hw.c b/audio/audio_hw.c index fff00d7..415cbd1 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -2993,14 +2993,23 @@ static int adev_config_parse(struct espresso_audio_device *adev) struct config_parse_state s; FILE *f; XML_Parser p; - char property[PROPERTY_VALUE_MAX]; + char device[16]; char file[80]; int ret = 0; bool eof = false; int len; - property_get("ro.product.device", property, "tiny_hw"); - snprintf(file, sizeof(file), "/system/etc/sound/%s", property); + f = fopen(DEVICE_VARIANT_SYSFS, "r"); + if (!f) { + ALOGE("Failed to open" DEVICE_VARIANT_SYSFS "\n"); + return -ENODEV; + } + if (fgets(device, 16, f) == NULL) { + ALOGE("Failed to read device variant\n"); + goto out; + } + fclose(f); + snprintf(file, sizeof(file), "/system/etc/sound/%s", device); ALOGV("Reading configuration from %s\n", file); f = fopen(file, "r"); diff --git a/audio/audio_hw.h b/audio/audio_hw.h index d2b2e0e..9be085b 100644 --- a/audio/audio_hw.h +++ b/audio/audio_hw.h @@ -65,8 +65,7 @@ #define VX_WB_SAMPLING_RATE 16000 /* product-specific defines */ -#define PRODUCT_DEVICE_PROPERTY "ro.product.device" -#define PRODUCT_NAME_PROPERTY "ro.product.name" +#define DEVICE_VARIANT_SYSFS "/sys/board_properties/type" #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) diff --git a/audio/tiny_hw_espresso.xml b/audio/tiny_hw_espresso.xml new file mode 100644 index 0000000..c61edb6 --- /dev/null +++ b/audio/tiny_hw_espresso.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/audio/tiny_hw_espresso10.xml b/audio/tiny_hw_espresso10.xml new file mode 100644 index 0000000..880b13f --- /dev/null +++ b/audio/tiny_hw_espresso10.xml @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/audio/tiny_hw_espresso10wifi.xml b/audio/tiny_hw_espresso10wifi.xml new file mode 100644 index 0000000..9d53df7 --- /dev/null +++ b/audio/tiny_hw_espresso10wifi.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/audio/tiny_hw_espressowifi.xml b/audio/tiny_hw_espressowifi.xml new file mode 100644 index 0000000..8cf5afa --- /dev/null +++ b/audio/tiny_hw_espressowifi.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/espresso-common.mk b/espresso-common.mk index 36831d6..9b58bfa 100644 --- a/espresso-common.mk +++ b/espresso-common.mk @@ -73,6 +73,13 @@ PRODUCT_COPY_FILES += \ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml +# Audio configs +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/audio/tiny_hw_espresso.xml:system/etc/sound/espresso \ + $(LOCAL_PATH)/audio/tiny_hw_espressowifi.xml:system/etc/sound/espressowifi \ + $(LOCAL_PATH)/audio/tiny_hw_espresso10.xml:system/etc/sound/espresso10 \ + $(LOCAL_PATH)/audio/tiny_hw_espresso10wifi.xml:system/etc/sound/espresso10wifi + # Keylayout PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/usr/keychars/espresso-gpio-keypad.kcm:system/usr/keychars/espresso-gpio-keypad.kcm \ -- cgit v1.1