Loading hal/audio_extn/spkr_protection.c +9 −0 Original line number Diff line number Diff line Loading @@ -668,6 +668,15 @@ void audio_extn_spkr_prot_init(void *adev) handle.thermal_handle = NULL; handle.spkr_prot_enable = false; } if (handle.spkr_prot_enable) { char platform[PROPERTY_VALUE_MAX]; property_get("ro.board.platform", platform, ""); if (!strncmp("apq8084", platform, sizeof("apq8084"))) { platform_set_snd_device_backend(SND_DEVICE_OUT_VOICE_SPEAKER, "speaker-protected"); } } } int audio_extn_spkr_prot_get_acdb_id(snd_device_t snd_device) Loading hal/msm8916/platform.c +18 −0 Original line number Diff line number Diff line Loading @@ -2079,3 +2079,21 @@ bool platform_check_24_bit_support() { bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct audio_usecase *usecase) { return false; } int platform_get_usecase_index(const char * usecase __unused) { return -ENOSYS; } int platform_set_usecase_pcm_id(audio_usecase_t usecase __unused, int32_t type __unused, int32_t pcm_id __unused) { return -ENOSYS; } int platform_set_snd_device_backend(snd_device_t snd_device __unused, const char * backend __unused) { return -ENOSYS; } hal/msm8960/platform.c +16 −0 Original line number Diff line number Diff line Loading @@ -959,3 +959,19 @@ bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct return false; } int platform_get_usecase_index(const char * usecase __unused) { return -ENOSYS; } int platform_set_usecase_pcm_id(audio_usecase_t usecase __unused, int32_t type __unused, int32_t pcm_id __unused) { return -ENOSYS; } int platform_set_snd_device_backend(snd_device_t snd_device __unused, const char * backend __unused) { return -ENOSYS; } hal/msm8974/platform.c +134 −43 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ struct platform_data { struct csd_data *csd; }; static const int pcm_device_table[AUDIO_USECASE_MAX][2] = { static int pcm_device_table[AUDIO_USECASE_MAX][2] = { [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, DEEP_BUFFER_PCM_DEVICE}, [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, Loading Loading @@ -373,7 +373,7 @@ static int acdb_device_table[SND_DEVICE_MAX] = { [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE] = 120, }; struct snd_device_index { struct name_to_index { char name[100]; unsigned int index; }; Loading @@ -381,7 +381,7 @@ struct snd_device_index { #define TO_NAME_INDEX(X) #X, X /* Used to get index from parsed sting */ struct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = { static struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = { {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_EXTERNAL_1)}, Loading Loading @@ -461,6 +461,26 @@ struct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = { {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE)}, }; static char * backend_table[SND_DEVICE_MAX] = {0}; static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, {TO_NAME_INDEX(USECASE_VOICE_CALL)}, {TO_NAME_INDEX(USECASE_VOICE2_CALL)}, {TO_NAME_INDEX(USECASE_VOLTE_CALL)}, {TO_NAME_INDEX(USECASE_QCHAT_CALL)}, {TO_NAME_INDEX(USECASE_VOWLAN_CALL)}, {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK)}, {TO_NAME_INDEX(USECASE_INCALL_REC_DOWNLINK)}, {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK_AND_DOWNLINK)}, {TO_NAME_INDEX(USECASE_AUDIO_HFP_SCO)}, }; #define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) #define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) Loading Loading @@ -663,6 +683,30 @@ static bool platform_is_i2s_ext_modem(const char *snd_card_name, return plat_data->is_i2s_ext_modem; } static void set_platform_defaults(struct platform_data * my_data) { int32_t dev; for (dev = 0; dev < SND_DEVICE_MAX; dev++) { backend_table[dev] = NULL; } // TBD - do these go to the platform-info.xml file. // will help in avoiding strdups here backend_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco"); backend_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb"); backend_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco"); backend_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb"); backend_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi"); backend_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi"); backend_table[SND_DEVICE_OUT_AFE_PROXY] = strdup("afe-proxy"); backend_table[SND_DEVICE_OUT_USB_HEADSET] = strdup("usb-headphones"); backend_table[SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = strdup("speaker-and-usb-headphones"); backend_table[SND_DEVICE_IN_USB_HEADSET_MIC] = strdup("usb-headset-mic"); backend_table[SND_DEVICE_IN_CAPTURE_FM] = strdup("capture-fm"); backend_table[SND_DEVICE_OUT_TRANSMISSION_FM] = strdup("transmission-fm"); } void *platform_init(struct audio_device *adev) { char value[PROPERTY_VALUE_MAX]; Loading Loading @@ -823,6 +867,8 @@ void *platform_init(struct audio_device *adev) my_data->acdb_init(snd_card_name); } set_platform_defaults(my_data); /* Initialize ACDB ID's */ if (my_data->is_i2s_ext_modem) platform_info_init(PLATFORM_INFO_XML_PATH_I2S); Loading Loading @@ -853,6 +899,14 @@ void platform_deinit(void *platform) hw_info_deinit(my_data->hw_info); close_csd_client(my_data->csd); int32_t dev; for (dev = 0; dev < SND_DEVICE_MAX; dev++) { if (backend_table[dev]) { free(backend_table[dev]); backend_table[dev]= NULL; } } free(platform); /* deinit usb */ audio_extn_usb_deinit(); Loading Loading @@ -884,37 +938,16 @@ int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device, void platform_add_backend_name(char *mixer_path, snd_device_t snd_device) { if (snd_device == SND_DEVICE_IN_BT_SCO_MIC) strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB) strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); else if(snd_device == SND_DEVICE_OUT_BT_SCO) strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); else if(snd_device == SND_DEVICE_OUT_BT_SCO_WB) strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_HDMI) strlcat(mixer_path, " hdmi", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI) strcat(mixer_path, " speaker-and-hdmi"); else if (snd_device == SND_DEVICE_OUT_AFE_PROXY) strlcat(mixer_path, " afe-proxy", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_USB_HEADSET) strlcat(mixer_path, " usb-headphones", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET) strlcat(mixer_path, " speaker-and-usb-headphones", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_IN_USB_HEADSET_MIC) strlcat(mixer_path, " usb-headset-mic", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_IN_CAPTURE_FM) strlcat(mixer_path, " capture-fm", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_TRANSMISSION_FM) strlcat(mixer_path, " transmission-fm", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && audio_extn_spkr_prot_is_enabled() ) { char platform[PROPERTY_VALUE_MAX]; property_get("ro.board.platform", platform, ""); if (!strncmp("apq8084", platform, sizeof("apq8084"))) strlcat(mixer_path, " speaker-protected", MIXER_PATH_MAX_LENGTH); if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); return; } const char * suffix = backend_table[snd_device]; if (suffix != NULL) { strlcat(mixer_path, " ", MIXER_PATH_MAX_LENGTH); strlcat(mixer_path, suffix, MIXER_PATH_MAX_LENGTH); } } Loading @@ -928,25 +961,36 @@ int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) return device_id; } int platform_get_snd_device_index(char *snd_device_index_name) static int find_index(struct name_to_index * table, int32_t len, const char * name) { int ret = 0; int i; int32_t i; if (snd_device_index_name == NULL) { ALOGE("%s: snd_device_index_name is NULL", __func__); if (table == NULL) { ALOGE("%s: table is NULL", __func__); ret = -ENODEV; goto done; } for (i=0; i < SND_DEVICE_MAX; i++) { if(strcmp(snd_device_name_index[i].name, snd_device_index_name) == 0) { ret = snd_device_name_index[i].index; if (name == NULL) { ALOGE("null key"); ret = -ENODEV; goto done; } for (i=0; i < len; i++) { const char* tn = table[i].name; int32_t len = strlen(tn); if (strncmp(tn, name, len) == 0) { if (strlen(name) != len) { continue; // substring } ret = table[i].index; goto done; } } ALOGE("%s: Could not find index for snd_device_index_name = %s", __func__, snd_device_index_name); ALOGE("%s: Could not find index for name = %s", __func__, name); ret = -ENODEV; done: return ret; Loading Loading @@ -1009,6 +1053,16 @@ int platform_get_fluence_type(void *platform, char *value, uint32_t len) return ret; } int platform_get_snd_device_index(char *device_name) { return find_index(snd_device_name_index, SND_DEVICE_MAX, device_name); } int platform_get_usecase_index(const char *usecase_name) { return find_index(usecase_name_index, AUDIO_USECASE_MAX, usecase_name); } int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) { int ret = 0; Loading Loading @@ -2408,3 +2462,40 @@ bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct return false; } int platform_set_snd_device_backend(snd_device_t device, const char *backend) { int ret = 0; if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) { ALOGE("%s: Invalid snd_device = %d", __func__, device); ret = -EINVAL; goto done; } if (backend_table[device]) { free(backend_table[device]); } backend_table[device] = strdup(backend); done: return ret; } int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id) { int ret = 0; if ((usecase <= USECASE_INVALID) || (usecase >= AUDIO_USECASE_MAX)) { ALOGE("%s: invalid usecase case idx %d", __func__, usecase); ret = -EINVAL; goto done; } if ((type != 0) && (type != 1)) { ALOGE("%s: invalid usecase type", __func__); ret = -EINVAL; } pcm_device_table[usecase][type] = pcm_id; done: return ret; } hal/platform_api.h +5 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ int platform_update_usecase_from_source(int source, audio_usecase_t usecase); bool platform_listen_device_needs_event(snd_device_t snd_device); bool platform_listen_usecase_needs_event(audio_usecase_t uc_id); int platform_set_snd_device_backend(snd_device_t snd_device, const char * backend); /* From platform_info_parser.c */ int platform_info_init(const char *filename); Loading @@ -85,4 +87,7 @@ uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info); bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct audio_usecase *usecase); bool platform_check_24_bit_support(); int platform_get_usecase_index(const char * usecase); int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id); #endif // AUDIO_PLATFORM_API_H Loading
hal/audio_extn/spkr_protection.c +9 −0 Original line number Diff line number Diff line Loading @@ -668,6 +668,15 @@ void audio_extn_spkr_prot_init(void *adev) handle.thermal_handle = NULL; handle.spkr_prot_enable = false; } if (handle.spkr_prot_enable) { char platform[PROPERTY_VALUE_MAX]; property_get("ro.board.platform", platform, ""); if (!strncmp("apq8084", platform, sizeof("apq8084"))) { platform_set_snd_device_backend(SND_DEVICE_OUT_VOICE_SPEAKER, "speaker-protected"); } } } int audio_extn_spkr_prot_get_acdb_id(snd_device_t snd_device) Loading
hal/msm8916/platform.c +18 −0 Original line number Diff line number Diff line Loading @@ -2079,3 +2079,21 @@ bool platform_check_24_bit_support() { bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct audio_usecase *usecase) { return false; } int platform_get_usecase_index(const char * usecase __unused) { return -ENOSYS; } int platform_set_usecase_pcm_id(audio_usecase_t usecase __unused, int32_t type __unused, int32_t pcm_id __unused) { return -ENOSYS; } int platform_set_snd_device_backend(snd_device_t snd_device __unused, const char * backend __unused) { return -ENOSYS; }
hal/msm8960/platform.c +16 −0 Original line number Diff line number Diff line Loading @@ -959,3 +959,19 @@ bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct return false; } int platform_get_usecase_index(const char * usecase __unused) { return -ENOSYS; } int platform_set_usecase_pcm_id(audio_usecase_t usecase __unused, int32_t type __unused, int32_t pcm_id __unused) { return -ENOSYS; } int platform_set_snd_device_backend(snd_device_t snd_device __unused, const char * backend __unused) { return -ENOSYS; }
hal/msm8974/platform.c +134 −43 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ struct platform_data { struct csd_data *csd; }; static const int pcm_device_table[AUDIO_USECASE_MAX][2] = { static int pcm_device_table[AUDIO_USECASE_MAX][2] = { [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, DEEP_BUFFER_PCM_DEVICE}, [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, Loading Loading @@ -373,7 +373,7 @@ static int acdb_device_table[SND_DEVICE_MAX] = { [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE] = 120, }; struct snd_device_index { struct name_to_index { char name[100]; unsigned int index; }; Loading @@ -381,7 +381,7 @@ struct snd_device_index { #define TO_NAME_INDEX(X) #X, X /* Used to get index from parsed sting */ struct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = { static struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = { {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_EXTERNAL_1)}, Loading Loading @@ -461,6 +461,26 @@ struct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = { {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE)}, }; static char * backend_table[SND_DEVICE_MAX] = {0}; static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, {TO_NAME_INDEX(USECASE_VOICE_CALL)}, {TO_NAME_INDEX(USECASE_VOICE2_CALL)}, {TO_NAME_INDEX(USECASE_VOLTE_CALL)}, {TO_NAME_INDEX(USECASE_QCHAT_CALL)}, {TO_NAME_INDEX(USECASE_VOWLAN_CALL)}, {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK)}, {TO_NAME_INDEX(USECASE_INCALL_REC_DOWNLINK)}, {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK_AND_DOWNLINK)}, {TO_NAME_INDEX(USECASE_AUDIO_HFP_SCO)}, }; #define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) #define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) Loading Loading @@ -663,6 +683,30 @@ static bool platform_is_i2s_ext_modem(const char *snd_card_name, return plat_data->is_i2s_ext_modem; } static void set_platform_defaults(struct platform_data * my_data) { int32_t dev; for (dev = 0; dev < SND_DEVICE_MAX; dev++) { backend_table[dev] = NULL; } // TBD - do these go to the platform-info.xml file. // will help in avoiding strdups here backend_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco"); backend_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb"); backend_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco"); backend_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb"); backend_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi"); backend_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi"); backend_table[SND_DEVICE_OUT_AFE_PROXY] = strdup("afe-proxy"); backend_table[SND_DEVICE_OUT_USB_HEADSET] = strdup("usb-headphones"); backend_table[SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = strdup("speaker-and-usb-headphones"); backend_table[SND_DEVICE_IN_USB_HEADSET_MIC] = strdup("usb-headset-mic"); backend_table[SND_DEVICE_IN_CAPTURE_FM] = strdup("capture-fm"); backend_table[SND_DEVICE_OUT_TRANSMISSION_FM] = strdup("transmission-fm"); } void *platform_init(struct audio_device *adev) { char value[PROPERTY_VALUE_MAX]; Loading Loading @@ -823,6 +867,8 @@ void *platform_init(struct audio_device *adev) my_data->acdb_init(snd_card_name); } set_platform_defaults(my_data); /* Initialize ACDB ID's */ if (my_data->is_i2s_ext_modem) platform_info_init(PLATFORM_INFO_XML_PATH_I2S); Loading Loading @@ -853,6 +899,14 @@ void platform_deinit(void *platform) hw_info_deinit(my_data->hw_info); close_csd_client(my_data->csd); int32_t dev; for (dev = 0; dev < SND_DEVICE_MAX; dev++) { if (backend_table[dev]) { free(backend_table[dev]); backend_table[dev]= NULL; } } free(platform); /* deinit usb */ audio_extn_usb_deinit(); Loading Loading @@ -884,37 +938,16 @@ int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device, void platform_add_backend_name(char *mixer_path, snd_device_t snd_device) { if (snd_device == SND_DEVICE_IN_BT_SCO_MIC) strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB) strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); else if(snd_device == SND_DEVICE_OUT_BT_SCO) strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); else if(snd_device == SND_DEVICE_OUT_BT_SCO_WB) strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_HDMI) strlcat(mixer_path, " hdmi", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI) strcat(mixer_path, " speaker-and-hdmi"); else if (snd_device == SND_DEVICE_OUT_AFE_PROXY) strlcat(mixer_path, " afe-proxy", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_USB_HEADSET) strlcat(mixer_path, " usb-headphones", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET) strlcat(mixer_path, " speaker-and-usb-headphones", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_IN_USB_HEADSET_MIC) strlcat(mixer_path, " usb-headset-mic", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_IN_CAPTURE_FM) strlcat(mixer_path, " capture-fm", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_TRANSMISSION_FM) strlcat(mixer_path, " transmission-fm", MIXER_PATH_MAX_LENGTH); else if (snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && audio_extn_spkr_prot_is_enabled() ) { char platform[PROPERTY_VALUE_MAX]; property_get("ro.board.platform", platform, ""); if (!strncmp("apq8084", platform, sizeof("apq8084"))) strlcat(mixer_path, " speaker-protected", MIXER_PATH_MAX_LENGTH); if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); return; } const char * suffix = backend_table[snd_device]; if (suffix != NULL) { strlcat(mixer_path, " ", MIXER_PATH_MAX_LENGTH); strlcat(mixer_path, suffix, MIXER_PATH_MAX_LENGTH); } } Loading @@ -928,25 +961,36 @@ int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) return device_id; } int platform_get_snd_device_index(char *snd_device_index_name) static int find_index(struct name_to_index * table, int32_t len, const char * name) { int ret = 0; int i; int32_t i; if (snd_device_index_name == NULL) { ALOGE("%s: snd_device_index_name is NULL", __func__); if (table == NULL) { ALOGE("%s: table is NULL", __func__); ret = -ENODEV; goto done; } for (i=0; i < SND_DEVICE_MAX; i++) { if(strcmp(snd_device_name_index[i].name, snd_device_index_name) == 0) { ret = snd_device_name_index[i].index; if (name == NULL) { ALOGE("null key"); ret = -ENODEV; goto done; } for (i=0; i < len; i++) { const char* tn = table[i].name; int32_t len = strlen(tn); if (strncmp(tn, name, len) == 0) { if (strlen(name) != len) { continue; // substring } ret = table[i].index; goto done; } } ALOGE("%s: Could not find index for snd_device_index_name = %s", __func__, snd_device_index_name); ALOGE("%s: Could not find index for name = %s", __func__, name); ret = -ENODEV; done: return ret; Loading Loading @@ -1009,6 +1053,16 @@ int platform_get_fluence_type(void *platform, char *value, uint32_t len) return ret; } int platform_get_snd_device_index(char *device_name) { return find_index(snd_device_name_index, SND_DEVICE_MAX, device_name); } int platform_get_usecase_index(const char *usecase_name) { return find_index(usecase_name_index, AUDIO_USECASE_MAX, usecase_name); } int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) { int ret = 0; Loading Loading @@ -2408,3 +2462,40 @@ bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct return false; } int platform_set_snd_device_backend(snd_device_t device, const char *backend) { int ret = 0; if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) { ALOGE("%s: Invalid snd_device = %d", __func__, device); ret = -EINVAL; goto done; } if (backend_table[device]) { free(backend_table[device]); } backend_table[device] = strdup(backend); done: return ret; } int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id) { int ret = 0; if ((usecase <= USECASE_INVALID) || (usecase >= AUDIO_USECASE_MAX)) { ALOGE("%s: invalid usecase case idx %d", __func__, usecase); ret = -EINVAL; goto done; } if ((type != 0) && (type != 1)) { ALOGE("%s: invalid usecase type", __func__); ret = -EINVAL; } pcm_device_table[usecase][type] = pcm_id; done: return ret; }
hal/platform_api.h +5 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ int platform_update_usecase_from_source(int source, audio_usecase_t usecase); bool platform_listen_device_needs_event(snd_device_t snd_device); bool platform_listen_usecase_needs_event(audio_usecase_t uc_id); int platform_set_snd_device_backend(snd_device_t snd_device, const char * backend); /* From platform_info_parser.c */ int platform_info_init(const char *filename); Loading @@ -85,4 +87,7 @@ uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info); bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct audio_usecase *usecase); bool platform_check_24_bit_support(); int platform_get_usecase_index(const char * usecase); int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id); #endif // AUDIO_PLATFORM_API_H