Loading hal/audio_extn/a2dp.c +28 −0 Original line number Diff line number Diff line Loading @@ -1422,6 +1422,30 @@ static int reset_a2dp_enc_config_params() return ret; } static int reset_a2dp_dec_config_params() { struct mixer_ctl *ctl_dec_data = NULL; struct abr_dec_cfg_t dummy_reset_cfg; int ret = 0; if (a2dp.abr_config.is_abr_enabled) { ctl_dec_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_DEC_CONFIG_BLOCK); if (!ctl_dec_data) { ALOGE("%s: ERROR A2DP decoder config mixer control not identifed", __func__); return -EINVAL; } memset(&dummy_reset_cfg, 0x0, sizeof(dummy_reset_cfg)); ret = mixer_ctl_set_array(ctl_dec_data, (void *)&dummy_reset_cfg, sizeof(dummy_reset_cfg)); if (ret != 0) { ALOGE("%s: Failed to set dummy decoder config", __func__); return ret; } } return ret; } int audio_extn_a2dp_stop_playback() { int ret = 0; Loading @@ -1445,6 +1469,7 @@ int audio_extn_a2dp_stop_playback() else ALOGV("%s: stop steam to Bluetooth IPC lib successful", __func__); reset_a2dp_enc_config_params(); reset_a2dp_dec_config_params(); a2dp_reset_backend_cfg(); if (a2dp.abr_config.is_abr_enabled && a2dp.abr_config.abr_started) stop_abr(); Loading Loading @@ -1488,6 +1513,7 @@ int audio_extn_a2dp_set_parameters(struct str_parms *parms, bool *reconfig) if (audio_is_a2dp_out_device(val)) { ALOGV("%s: Received device disconnect request", __func__); reset_a2dp_enc_config_params(); reset_a2dp_dec_config_params(); close_a2dp_output(); } goto param_handled; Loading @@ -1513,6 +1539,7 @@ int audio_extn_a2dp_set_parameters(struct str_parms *parms, bool *reconfig) } } reset_a2dp_enc_config_params(); reset_a2dp_dec_config_params(); if (a2dp.audio_stream_suspend) { a2dp.audio_stream_suspend(); } Loading Loading @@ -1627,6 +1654,7 @@ void audio_extn_a2dp_init(void *adev) a2dp.is_handoff_in_progress = false; a2dp.is_aptx_dual_mono_supported = false; reset_a2dp_enc_config_params(); reset_a2dp_dec_config_params(); update_offload_codec_support(); } Loading hal/audio_extn/maxxaudio.c +100 −92 Original line number Diff line number Diff line Loading @@ -17,30 +17,32 @@ #define LOG_TAG "audio_hw_waves" /*#define LOG_NDEBUG 0*/ #include <stdlib.h> #include <dlfcn.h> #include <pthread.h> #include <unistd.h> #include <audio_hw.h> #include <cutils/str_parms.h> #include <dlfcn.h> #include <log/log.h> #include <audio_hw.h> #include <system/audio.h> #include <math.h> #include <platform_api.h> #include <pthread.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <system/audio.h> #include <unistd.h> #include "audio_extn.h" #include "maxxaudio.h" #define LIB_MA_PARAM "libmaqdspparams.so" #define LIB_MA_PARAM "libmaxxaudioqdsp.so" #define LIB_MA_PATH "vendor/lib/" #define PRESET_PATH "/vendor/etc/default.mps" #define PRESET_PATH "/vendor/etc" #define MPS_BASE_STRING "default" #define USER_PRESET_PATH "" #define CONFIG_PATH "/vendor/etc/maxx_conf.ini" #define CAL_PRESIST_STR "cal_persist" #define CAL_SAMPLERATE_STR "cal_samplerate" #define MA_QDSP_PARAM_INIT "maxxaudio_qdsp_parameters_initialize" #define MA_QDSP_PARAM_DEINIT "maxxaudio_qdsp_parameters_uninitialize" #define MA_QDSP_PARAM_INIT "maxxaudio_qdsp_initialize" #define MA_QDSP_PARAM_DEINIT "maxxaudio_qdsp_uninitialize" #define MA_QDSP_SET_LR_SWAP "maxxaudio_qdsp_set_lr_swap" #define MA_QDSP_SET_MODE "maxxaudio_qdsp_set_sound_mode" #define MA_QDSP_SET_VOL "maxxaudio_qdsp_set_volume" Loading @@ -50,7 +52,6 @@ #define SUPPORTED_USB 0x01 struct ma_audio_cal_settings { void *platform; int app_type; audio_devices_t device; }; Loading Loading @@ -78,34 +79,30 @@ typedef enum MA_CMD { } ma_cmd_t; typedef void *ma_audio_cal_handle_t; typedef int (*set_audio_cal_t)(const struct ma_audio_cal_settings *, const char *); typedef int (*set_audio_cal_t)(const char *); typedef bool (*ma_param_init_t)( ma_audio_cal_handle_t *, void *, const char *, const char *, const char *, set_audio_cal_t); typedef bool (*ma_param_init_t)(ma_audio_cal_handle_t *, const char *, const char *, const char *, set_audio_cal_t); typedef bool (*ma_param_deinit_t)(ma_audio_cal_handle_t); typedef bool (*ma_param_deinit_t)(ma_audio_cal_handle_t *); typedef bool (*ma_set_lr_swap_t)( ma_audio_cal_handle_t, typedef bool (*ma_set_lr_swap_t)(ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, bool); typedef bool (*ma_set_sound_mode_t)( ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, unsigned int); typedef bool (*ma_set_sound_mode_t)(ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, unsigned int); typedef bool (*ma_set_volume_t)( ma_audio_cal_handle_t, typedef bool (*ma_set_volume_t)(ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, double); typedef bool (*ma_set_volume_table_t)( ma_audio_cal_handle_t, typedef bool (*ma_set_volume_table_t)(ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, size_t, struct ma_state *); struct ma_platform_data { void *waves_handle; void *platform; pthread_mutex_t lock; ma_param_init_t ma_param_init; ma_param_deinit_t ma_param_deinit; Loading @@ -120,49 +117,42 @@ static uint16_t g_supported_dev = 0; static struct ma_state ma_cur_state_table[STREAM_MAX_TYPES]; static struct ma_platform_data *my_data = NULL; static int set_audio_cal( const struct ma_audio_cal_settings *audio_cal_settings, const char *audio_cal) static int set_audio_cal(const char *audio_cal) { ALOGV("set_audio_cal: %s", audio_cal); return platform_set_parameters(audio_cal_settings->platform, return platform_set_parameters(my_data->platform, str_parms_create_str(audio_cal)); } static bool ma_set_lr_swap_l( const struct ma_audio_cal_settings *audio_cal_settings, bool swap) const struct ma_audio_cal_settings *audio_cal_settings, bool swap) { return my_data->ma_set_lr_swap(g_ma_audio_cal_handle, audio_cal_settings, swap); return my_data->ma_set_lr_swap(g_ma_audio_cal_handle, audio_cal_settings, swap); } static bool ma_set_sound_mode_l( const struct ma_audio_cal_settings *audio_cal_settings, int sound_mode) const struct ma_audio_cal_settings *audio_cal_settings, int sound_mode) { return my_data->ma_set_sound_mode(g_ma_audio_cal_handle, audio_cal_settings, sound_mode); } static bool ma_set_volume_l( const struct ma_audio_cal_settings *audio_cal_settings, double volume) const struct ma_audio_cal_settings *audio_cal_settings, double volume) { return my_data->ma_set_volume(g_ma_audio_cal_handle, audio_cal_settings, volume); return my_data->ma_set_volume(g_ma_audio_cal_handle, audio_cal_settings, volume); } static bool ma_set_volume_table_l( const struct ma_audio_cal_settings *audio_cal_settings, size_t num_streams, struct ma_state *volume_table) { return my_data->ma_set_volume_table( g_ma_audio_cal_handle, audio_cal_settings, num_streams, return my_data->ma_set_volume_table(g_ma_audio_cal_handle, audio_cal_settings, num_streams, volume_table); } static inline bool valid_usecase(struct audio_usecase *usecase) Loading @@ -175,7 +165,7 @@ static inline bool valid_usecase(struct audio_usecase *usecase) /* support devices */ ((usecase->devices & AUDIO_DEVICE_OUT_SPEAKER) || (usecase->devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) || (usecase->devices & AUDIO_DEVICE_OUT_ALL_A2DP) || /* TODO: enable A2DP when it is ready */ (usecase->devices & AUDIO_DEVICE_OUT_ALL_USB))) return true; Loading Loading @@ -219,7 +209,6 @@ static bool check_and_send_all_audio_cal(struct audio_device *adev, ma_cmd_t cmd list_for_each(node, &adev->usecase_list) { usecase = node_to_item(node, struct audio_usecase, list); if (valid_usecase(usecase)) { ma_cal->platform = adev->platform; ma_cal->app_type = usecase->stream.out->app_type_cfg.app_type; ma_cal->device = usecase->stream.out->devices; ALOGV("%s: send usecase(%d) app_type(%d) device(%d)", Loading @@ -236,8 +225,8 @@ static bool check_and_send_all_audio_cal(struct audio_device *adev, ma_cmd_t cmd ALOGV("%s: send volume table === Start", __func__); for (i = 0; i < STREAM_MAX_TYPES; i++) ALOGV("%s: stream(%d) volume(%f) active(%s)", __func__, i, ma_cur_state_table[i].vol, ALOGV("%s: stream(%d) volume(%f) active(%s)", __func__, i, ma_cur_state_table[i].vol, ma_cur_state_table[i].active ? "T" : "F"); ALOGV("%s: send volume table === End", __func__); break; Loading @@ -258,7 +247,6 @@ static bool check_and_send_all_audio_cal(struct audio_device *adev, ma_cmd_t cmd default: ALOGE("%s: unsupported cmd %d", __func__, cmd); } } } free(ma_cal); Loading Loading @@ -294,10 +282,14 @@ static bool find_sup_dev(char *name) static void ma_set_swap_l(struct audio_device *adev, bool enable) { // do platform LR swap if it enables on Waves effect // but there is no Waves implementation if (!my_data) { ALOGE("%s: maxxaudio isn't initialized.", __func__); platform_check_and_set_swap_lr_channels(adev, enable); ALOGV("%s: maxxaudio isn't initialized.", __func__); return; } if (enable) check_and_send_all_audio_cal(adev, MA_CMD_SWAP_ENABLE); else Loading Loading @@ -350,7 +342,10 @@ void audio_extn_ma_init(void *platform) { ma_stream_type_t i = 0; int ret = 0; char lib_path[256]; char lib_path[128] = {0}; char mps_path[128] = {0}; struct snd_card_split *snd_split_handle = NULL; snd_split_handle = audio_extn_get_snd_card_split(); if (platform == NULL) { ALOGE("%s: platform is NULL", __func__); Loading @@ -366,6 +361,7 @@ void audio_extn_ma_init(void *platform) pthread_mutex_init(&my_data->lock, NULL); my_data->platform = platform; ret = snprintf(lib_path, sizeof(lib_path), "%s/%s", LIB_MA_PATH, LIB_MA_PARAM); if (ret < 0) { ALOGE("%s: snprintf failed for lib %s, ret %d", __func__, LIB_MA_PARAM, ret); Loading @@ -386,8 +382,8 @@ void audio_extn_ma_init(void *platform) goto error; } my_data->ma_param_deinit = (ma_param_deinit_t)dlsym(my_data->waves_handle, MA_QDSP_PARAM_DEINIT); my_data->ma_param_deinit = (ma_param_deinit_t)dlsym( my_data->waves_handle, MA_QDSP_PARAM_DEINIT); if (!my_data->ma_param_deinit) { ALOGE("%s: dlsym error %s for ma_param_deinit", __func__, dlerror()); goto error; Loading @@ -400,8 +396,8 @@ void audio_extn_ma_init(void *platform) goto error; } my_data->ma_set_sound_mode = (ma_set_sound_mode_t)dlsym(my_data->waves_handle, MA_QDSP_SET_MODE); my_data->ma_set_sound_mode = (ma_set_sound_mode_t)dlsym( my_data->waves_handle, MA_QDSP_SET_MODE); if (!my_data->ma_set_sound_mode) { ALOGE("%s: dlsym error %s for ma_set_sound_mode", __func__, dlerror()); goto error; Loading @@ -414,19 +410,30 @@ void audio_extn_ma_init(void *platform) goto error; } my_data->ma_set_volume_table = (ma_set_volume_table_t)dlsym(my_data->waves_handle, MA_QDSP_SET_VOLT); my_data->ma_set_volume_table = (ma_set_volume_table_t)dlsym( my_data->waves_handle, MA_QDSP_SET_VOLT); if (!my_data->ma_set_volume_table) { ALOGE("%s: dlsym error %s for ma_set_volume_table", __func__, dlerror()); goto error; } } /* get preset table */ if (snd_split_handle == NULL) { snprintf(mps_path, sizeof(mps_path), "%s/%s.mps", PRESET_PATH, MPS_BASE_STRING); } else { snprintf(mps_path, sizeof(mps_path), "%s/%s_%s.mps", PRESET_PATH, MPS_BASE_STRING, snd_split_handle->form_factor); } /* check file */ if (access(PRESET_PATH, F_OK) < 0) { ALOGW("%s: file %s isn't existed.", __func__, PRESET_PATH); if (access(mps_path, F_OK) < 0) { ALOGW("%s: file %s isn't existed.", __func__, mps_path); goto error; } } else ALOGD("%s: Loading mps file: %s", __func__, mps_path); /* TODO: check user preset table once the feature is enabled if (access(USER_PRESET_PATH, F_OK) < 0 ){ ALOGW("%s: file %s isn't existed.", __func__, USER_PRESET_PATH); Loading @@ -440,9 +447,8 @@ void audio_extn_ma_init(void *platform) /* init ma parameter */ if (my_data->ma_param_init(&g_ma_audio_cal_handle, platform, /* TODO: remove this on next version*/ PRESET_PATH, USER_PRESET_PATH, /* useless */ mps_path, USER_PRESET_PATH, /* unused */ CONFIG_PATH, &set_audio_cal)) { if (!g_ma_audio_cal_handle) { Loading Loading @@ -487,8 +493,8 @@ void audio_extn_ma_deinit() } // adev_init and adev lock held bool audio_extn_ma_set_state( struct audio_device *adev, int stream_type, float vol, bool active) bool audio_extn_ma_set_state(struct audio_device *adev, int stream_type, float vol, bool active) { bool ret = false; ma_stream_type_t stype = (ma_stream_type_t)stream_type; Loading @@ -497,7 +503,7 @@ bool audio_extn_ma_set_state( __func__, stream_type, vol, active ? "true" : "false"); if (!my_data) { ALOGE("%s: maxxaudio isn't initialized.", __func__); ALOGV("%s: maxxaudio isn't initialized.", __func__); return ret; } Loading @@ -519,7 +525,7 @@ bool audio_extn_ma_set_state( return ret; } void audio_extn_ma_set_device(struct audio_device *adev, struct audio_usecase *usecase) void audio_extn_ma_set_device(struct audio_usecase *usecase) { int i = 0; int u_index = -1; Loading @@ -540,7 +546,6 @@ void audio_extn_ma_set_device(struct audio_device *adev, struct audio_usecase *u /* update audio_cal and send it */ if (ma_cal != NULL){ ma_cal->platform = adev->platform; ma_cal->app_type = usecase->stream.out->app_type_cfg.app_type; ma_cal->device = usecase->stream.out->devices; ALOGV("%s: send usecase(%d) app_type(%d) device(%d)", Loading Loading @@ -571,7 +576,8 @@ void audio_extn_ma_set_device(struct audio_device *adev, struct audio_usecase *u } } void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *parms) void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *parms) { int ret; bool ret_b; Loading @@ -594,7 +600,8 @@ void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *p } // check connect status ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, sizeof(value)); ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, sizeof(value)); if (ret >= 0) { audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10); if (audio_is_usb_out_device(device)) { Loading @@ -607,7 +614,8 @@ void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *p } // check disconnect status ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, sizeof(value)); ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, sizeof(value)); if (ret >= 0) { audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10); if (audio_is_usb_out_device(device)) { Loading hal/audio_extn/maxxaudio.h +11 −9 Original line number Diff line number Diff line Loading @@ -21,15 +21,17 @@ #define audio_extn_ma_init(platform) (0) #define audio_extn_ma_deinit() (0) #define audio_extn_ma_set_state(adev, type, vol, active) (false) #define audio_extn_ma_set_device(adev, usecase) (0) #define audio_extn_ma_set_device(usecase) (0) #define audio_extn_ma_set_parameters(adev, param) (0) #define audio_extn_ma_supported_usb() (false) #else void audio_extn_ma_init(void *platform); void audio_extn_ma_deinit(); bool audio_extn_ma_set_state(struct audio_device *adev, int stream_type, float vol, bool active); void audio_extn_ma_set_device(struct audio_device *adev, struct audio_usecase *usecase); void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *parms); bool audio_extn_ma_set_state(struct audio_device *adev, int stream_type, float vol, bool active); void audio_extn_ma_set_device(struct audio_usecase *usecase); void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *parms); bool audio_extn_ma_supported_usb(); #endif /* MAXXAUDIO_QDSP_ENABLED */ Loading hal/audio_hw.c +4 −2 Original line number Diff line number Diff line Loading @@ -1464,7 +1464,7 @@ int select_devices(struct audio_device *adev, enable_audio_route(adev, usecase); audio_extn_ma_set_device(adev, usecase); audio_extn_ma_set_device(usecase); /* Applicable only on the targets that has external modem. * Enable device command should be sent to modem only after Loading Loading @@ -2602,7 +2602,7 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) out->devices = new_dev; if (output_drives_call(adev, out)) { if (!voice_is_in_call(adev)) { if (!voice_is_call_state_active(adev)) { if (adev->mode == AUDIO_MODE_IN_CALL) { adev->current_call_output = out; ret = voice_start_call(adev); Loading Loading @@ -5676,6 +5676,8 @@ static int adev_open(const hw_module_t *module, const char *name, } } adev->mic_break_enabled = property_get_bool("vendor.audio.mic_break", false); // commented as full set of app type cfg is sent from platform // audio_extn_utils_send_default_app_type_cfg(adev->platform, adev->mixer); audio_device_ref_count++; Loading hal/audio_hw.h +1 −0 Original line number Diff line number Diff line Loading @@ -328,6 +328,7 @@ struct audio_device { bool mic_muted; bool enable_voicerx; bool enable_hfp; bool mic_break_enabled; int snd_card; void *platform; Loading Loading
hal/audio_extn/a2dp.c +28 −0 Original line number Diff line number Diff line Loading @@ -1422,6 +1422,30 @@ static int reset_a2dp_enc_config_params() return ret; } static int reset_a2dp_dec_config_params() { struct mixer_ctl *ctl_dec_data = NULL; struct abr_dec_cfg_t dummy_reset_cfg; int ret = 0; if (a2dp.abr_config.is_abr_enabled) { ctl_dec_data = mixer_get_ctl_by_name(a2dp.adev->mixer, MIXER_DEC_CONFIG_BLOCK); if (!ctl_dec_data) { ALOGE("%s: ERROR A2DP decoder config mixer control not identifed", __func__); return -EINVAL; } memset(&dummy_reset_cfg, 0x0, sizeof(dummy_reset_cfg)); ret = mixer_ctl_set_array(ctl_dec_data, (void *)&dummy_reset_cfg, sizeof(dummy_reset_cfg)); if (ret != 0) { ALOGE("%s: Failed to set dummy decoder config", __func__); return ret; } } return ret; } int audio_extn_a2dp_stop_playback() { int ret = 0; Loading @@ -1445,6 +1469,7 @@ int audio_extn_a2dp_stop_playback() else ALOGV("%s: stop steam to Bluetooth IPC lib successful", __func__); reset_a2dp_enc_config_params(); reset_a2dp_dec_config_params(); a2dp_reset_backend_cfg(); if (a2dp.abr_config.is_abr_enabled && a2dp.abr_config.abr_started) stop_abr(); Loading Loading @@ -1488,6 +1513,7 @@ int audio_extn_a2dp_set_parameters(struct str_parms *parms, bool *reconfig) if (audio_is_a2dp_out_device(val)) { ALOGV("%s: Received device disconnect request", __func__); reset_a2dp_enc_config_params(); reset_a2dp_dec_config_params(); close_a2dp_output(); } goto param_handled; Loading @@ -1513,6 +1539,7 @@ int audio_extn_a2dp_set_parameters(struct str_parms *parms, bool *reconfig) } } reset_a2dp_enc_config_params(); reset_a2dp_dec_config_params(); if (a2dp.audio_stream_suspend) { a2dp.audio_stream_suspend(); } Loading Loading @@ -1627,6 +1654,7 @@ void audio_extn_a2dp_init(void *adev) a2dp.is_handoff_in_progress = false; a2dp.is_aptx_dual_mono_supported = false; reset_a2dp_enc_config_params(); reset_a2dp_dec_config_params(); update_offload_codec_support(); } Loading
hal/audio_extn/maxxaudio.c +100 −92 Original line number Diff line number Diff line Loading @@ -17,30 +17,32 @@ #define LOG_TAG "audio_hw_waves" /*#define LOG_NDEBUG 0*/ #include <stdlib.h> #include <dlfcn.h> #include <pthread.h> #include <unistd.h> #include <audio_hw.h> #include <cutils/str_parms.h> #include <dlfcn.h> #include <log/log.h> #include <audio_hw.h> #include <system/audio.h> #include <math.h> #include <platform_api.h> #include <pthread.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <system/audio.h> #include <unistd.h> #include "audio_extn.h" #include "maxxaudio.h" #define LIB_MA_PARAM "libmaqdspparams.so" #define LIB_MA_PARAM "libmaxxaudioqdsp.so" #define LIB_MA_PATH "vendor/lib/" #define PRESET_PATH "/vendor/etc/default.mps" #define PRESET_PATH "/vendor/etc" #define MPS_BASE_STRING "default" #define USER_PRESET_PATH "" #define CONFIG_PATH "/vendor/etc/maxx_conf.ini" #define CAL_PRESIST_STR "cal_persist" #define CAL_SAMPLERATE_STR "cal_samplerate" #define MA_QDSP_PARAM_INIT "maxxaudio_qdsp_parameters_initialize" #define MA_QDSP_PARAM_DEINIT "maxxaudio_qdsp_parameters_uninitialize" #define MA_QDSP_PARAM_INIT "maxxaudio_qdsp_initialize" #define MA_QDSP_PARAM_DEINIT "maxxaudio_qdsp_uninitialize" #define MA_QDSP_SET_LR_SWAP "maxxaudio_qdsp_set_lr_swap" #define MA_QDSP_SET_MODE "maxxaudio_qdsp_set_sound_mode" #define MA_QDSP_SET_VOL "maxxaudio_qdsp_set_volume" Loading @@ -50,7 +52,6 @@ #define SUPPORTED_USB 0x01 struct ma_audio_cal_settings { void *platform; int app_type; audio_devices_t device; }; Loading Loading @@ -78,34 +79,30 @@ typedef enum MA_CMD { } ma_cmd_t; typedef void *ma_audio_cal_handle_t; typedef int (*set_audio_cal_t)(const struct ma_audio_cal_settings *, const char *); typedef int (*set_audio_cal_t)(const char *); typedef bool (*ma_param_init_t)( ma_audio_cal_handle_t *, void *, const char *, const char *, const char *, set_audio_cal_t); typedef bool (*ma_param_init_t)(ma_audio_cal_handle_t *, const char *, const char *, const char *, set_audio_cal_t); typedef bool (*ma_param_deinit_t)(ma_audio_cal_handle_t); typedef bool (*ma_param_deinit_t)(ma_audio_cal_handle_t *); typedef bool (*ma_set_lr_swap_t)( ma_audio_cal_handle_t, typedef bool (*ma_set_lr_swap_t)(ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, bool); typedef bool (*ma_set_sound_mode_t)( ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, unsigned int); typedef bool (*ma_set_sound_mode_t)(ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, unsigned int); typedef bool (*ma_set_volume_t)( ma_audio_cal_handle_t, typedef bool (*ma_set_volume_t)(ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, double); typedef bool (*ma_set_volume_table_t)( ma_audio_cal_handle_t, typedef bool (*ma_set_volume_table_t)(ma_audio_cal_handle_t, const struct ma_audio_cal_settings *, size_t, struct ma_state *); struct ma_platform_data { void *waves_handle; void *platform; pthread_mutex_t lock; ma_param_init_t ma_param_init; ma_param_deinit_t ma_param_deinit; Loading @@ -120,49 +117,42 @@ static uint16_t g_supported_dev = 0; static struct ma_state ma_cur_state_table[STREAM_MAX_TYPES]; static struct ma_platform_data *my_data = NULL; static int set_audio_cal( const struct ma_audio_cal_settings *audio_cal_settings, const char *audio_cal) static int set_audio_cal(const char *audio_cal) { ALOGV("set_audio_cal: %s", audio_cal); return platform_set_parameters(audio_cal_settings->platform, return platform_set_parameters(my_data->platform, str_parms_create_str(audio_cal)); } static bool ma_set_lr_swap_l( const struct ma_audio_cal_settings *audio_cal_settings, bool swap) const struct ma_audio_cal_settings *audio_cal_settings, bool swap) { return my_data->ma_set_lr_swap(g_ma_audio_cal_handle, audio_cal_settings, swap); return my_data->ma_set_lr_swap(g_ma_audio_cal_handle, audio_cal_settings, swap); } static bool ma_set_sound_mode_l( const struct ma_audio_cal_settings *audio_cal_settings, int sound_mode) const struct ma_audio_cal_settings *audio_cal_settings, int sound_mode) { return my_data->ma_set_sound_mode(g_ma_audio_cal_handle, audio_cal_settings, sound_mode); } static bool ma_set_volume_l( const struct ma_audio_cal_settings *audio_cal_settings, double volume) const struct ma_audio_cal_settings *audio_cal_settings, double volume) { return my_data->ma_set_volume(g_ma_audio_cal_handle, audio_cal_settings, volume); return my_data->ma_set_volume(g_ma_audio_cal_handle, audio_cal_settings, volume); } static bool ma_set_volume_table_l( const struct ma_audio_cal_settings *audio_cal_settings, size_t num_streams, struct ma_state *volume_table) { return my_data->ma_set_volume_table( g_ma_audio_cal_handle, audio_cal_settings, num_streams, return my_data->ma_set_volume_table(g_ma_audio_cal_handle, audio_cal_settings, num_streams, volume_table); } static inline bool valid_usecase(struct audio_usecase *usecase) Loading @@ -175,7 +165,7 @@ static inline bool valid_usecase(struct audio_usecase *usecase) /* support devices */ ((usecase->devices & AUDIO_DEVICE_OUT_SPEAKER) || (usecase->devices & AUDIO_DEVICE_OUT_SPEAKER_SAFE) || (usecase->devices & AUDIO_DEVICE_OUT_ALL_A2DP) || /* TODO: enable A2DP when it is ready */ (usecase->devices & AUDIO_DEVICE_OUT_ALL_USB))) return true; Loading Loading @@ -219,7 +209,6 @@ static bool check_and_send_all_audio_cal(struct audio_device *adev, ma_cmd_t cmd list_for_each(node, &adev->usecase_list) { usecase = node_to_item(node, struct audio_usecase, list); if (valid_usecase(usecase)) { ma_cal->platform = adev->platform; ma_cal->app_type = usecase->stream.out->app_type_cfg.app_type; ma_cal->device = usecase->stream.out->devices; ALOGV("%s: send usecase(%d) app_type(%d) device(%d)", Loading @@ -236,8 +225,8 @@ static bool check_and_send_all_audio_cal(struct audio_device *adev, ma_cmd_t cmd ALOGV("%s: send volume table === Start", __func__); for (i = 0; i < STREAM_MAX_TYPES; i++) ALOGV("%s: stream(%d) volume(%f) active(%s)", __func__, i, ma_cur_state_table[i].vol, ALOGV("%s: stream(%d) volume(%f) active(%s)", __func__, i, ma_cur_state_table[i].vol, ma_cur_state_table[i].active ? "T" : "F"); ALOGV("%s: send volume table === End", __func__); break; Loading @@ -258,7 +247,6 @@ static bool check_and_send_all_audio_cal(struct audio_device *adev, ma_cmd_t cmd default: ALOGE("%s: unsupported cmd %d", __func__, cmd); } } } free(ma_cal); Loading Loading @@ -294,10 +282,14 @@ static bool find_sup_dev(char *name) static void ma_set_swap_l(struct audio_device *adev, bool enable) { // do platform LR swap if it enables on Waves effect // but there is no Waves implementation if (!my_data) { ALOGE("%s: maxxaudio isn't initialized.", __func__); platform_check_and_set_swap_lr_channels(adev, enable); ALOGV("%s: maxxaudio isn't initialized.", __func__); return; } if (enable) check_and_send_all_audio_cal(adev, MA_CMD_SWAP_ENABLE); else Loading Loading @@ -350,7 +342,10 @@ void audio_extn_ma_init(void *platform) { ma_stream_type_t i = 0; int ret = 0; char lib_path[256]; char lib_path[128] = {0}; char mps_path[128] = {0}; struct snd_card_split *snd_split_handle = NULL; snd_split_handle = audio_extn_get_snd_card_split(); if (platform == NULL) { ALOGE("%s: platform is NULL", __func__); Loading @@ -366,6 +361,7 @@ void audio_extn_ma_init(void *platform) pthread_mutex_init(&my_data->lock, NULL); my_data->platform = platform; ret = snprintf(lib_path, sizeof(lib_path), "%s/%s", LIB_MA_PATH, LIB_MA_PARAM); if (ret < 0) { ALOGE("%s: snprintf failed for lib %s, ret %d", __func__, LIB_MA_PARAM, ret); Loading @@ -386,8 +382,8 @@ void audio_extn_ma_init(void *platform) goto error; } my_data->ma_param_deinit = (ma_param_deinit_t)dlsym(my_data->waves_handle, MA_QDSP_PARAM_DEINIT); my_data->ma_param_deinit = (ma_param_deinit_t)dlsym( my_data->waves_handle, MA_QDSP_PARAM_DEINIT); if (!my_data->ma_param_deinit) { ALOGE("%s: dlsym error %s for ma_param_deinit", __func__, dlerror()); goto error; Loading @@ -400,8 +396,8 @@ void audio_extn_ma_init(void *platform) goto error; } my_data->ma_set_sound_mode = (ma_set_sound_mode_t)dlsym(my_data->waves_handle, MA_QDSP_SET_MODE); my_data->ma_set_sound_mode = (ma_set_sound_mode_t)dlsym( my_data->waves_handle, MA_QDSP_SET_MODE); if (!my_data->ma_set_sound_mode) { ALOGE("%s: dlsym error %s for ma_set_sound_mode", __func__, dlerror()); goto error; Loading @@ -414,19 +410,30 @@ void audio_extn_ma_init(void *platform) goto error; } my_data->ma_set_volume_table = (ma_set_volume_table_t)dlsym(my_data->waves_handle, MA_QDSP_SET_VOLT); my_data->ma_set_volume_table = (ma_set_volume_table_t)dlsym( my_data->waves_handle, MA_QDSP_SET_VOLT); if (!my_data->ma_set_volume_table) { ALOGE("%s: dlsym error %s for ma_set_volume_table", __func__, dlerror()); goto error; } } /* get preset table */ if (snd_split_handle == NULL) { snprintf(mps_path, sizeof(mps_path), "%s/%s.mps", PRESET_PATH, MPS_BASE_STRING); } else { snprintf(mps_path, sizeof(mps_path), "%s/%s_%s.mps", PRESET_PATH, MPS_BASE_STRING, snd_split_handle->form_factor); } /* check file */ if (access(PRESET_PATH, F_OK) < 0) { ALOGW("%s: file %s isn't existed.", __func__, PRESET_PATH); if (access(mps_path, F_OK) < 0) { ALOGW("%s: file %s isn't existed.", __func__, mps_path); goto error; } } else ALOGD("%s: Loading mps file: %s", __func__, mps_path); /* TODO: check user preset table once the feature is enabled if (access(USER_PRESET_PATH, F_OK) < 0 ){ ALOGW("%s: file %s isn't existed.", __func__, USER_PRESET_PATH); Loading @@ -440,9 +447,8 @@ void audio_extn_ma_init(void *platform) /* init ma parameter */ if (my_data->ma_param_init(&g_ma_audio_cal_handle, platform, /* TODO: remove this on next version*/ PRESET_PATH, USER_PRESET_PATH, /* useless */ mps_path, USER_PRESET_PATH, /* unused */ CONFIG_PATH, &set_audio_cal)) { if (!g_ma_audio_cal_handle) { Loading Loading @@ -487,8 +493,8 @@ void audio_extn_ma_deinit() } // adev_init and adev lock held bool audio_extn_ma_set_state( struct audio_device *adev, int stream_type, float vol, bool active) bool audio_extn_ma_set_state(struct audio_device *adev, int stream_type, float vol, bool active) { bool ret = false; ma_stream_type_t stype = (ma_stream_type_t)stream_type; Loading @@ -497,7 +503,7 @@ bool audio_extn_ma_set_state( __func__, stream_type, vol, active ? "true" : "false"); if (!my_data) { ALOGE("%s: maxxaudio isn't initialized.", __func__); ALOGV("%s: maxxaudio isn't initialized.", __func__); return ret; } Loading @@ -519,7 +525,7 @@ bool audio_extn_ma_set_state( return ret; } void audio_extn_ma_set_device(struct audio_device *adev, struct audio_usecase *usecase) void audio_extn_ma_set_device(struct audio_usecase *usecase) { int i = 0; int u_index = -1; Loading @@ -540,7 +546,6 @@ void audio_extn_ma_set_device(struct audio_device *adev, struct audio_usecase *u /* update audio_cal and send it */ if (ma_cal != NULL){ ma_cal->platform = adev->platform; ma_cal->app_type = usecase->stream.out->app_type_cfg.app_type; ma_cal->device = usecase->stream.out->devices; ALOGV("%s: send usecase(%d) app_type(%d) device(%d)", Loading Loading @@ -571,7 +576,8 @@ void audio_extn_ma_set_device(struct audio_device *adev, struct audio_usecase *u } } void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *parms) void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *parms) { int ret; bool ret_b; Loading @@ -594,7 +600,8 @@ void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *p } // check connect status ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, sizeof(value)); ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, sizeof(value)); if (ret >= 0) { audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10); if (audio_is_usb_out_device(device)) { Loading @@ -607,7 +614,8 @@ void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *p } // check disconnect status ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, sizeof(value)); ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, sizeof(value)); if (ret >= 0) { audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10); if (audio_is_usb_out_device(device)) { Loading
hal/audio_extn/maxxaudio.h +11 −9 Original line number Diff line number Diff line Loading @@ -21,15 +21,17 @@ #define audio_extn_ma_init(platform) (0) #define audio_extn_ma_deinit() (0) #define audio_extn_ma_set_state(adev, type, vol, active) (false) #define audio_extn_ma_set_device(adev, usecase) (0) #define audio_extn_ma_set_device(usecase) (0) #define audio_extn_ma_set_parameters(adev, param) (0) #define audio_extn_ma_supported_usb() (false) #else void audio_extn_ma_init(void *platform); void audio_extn_ma_deinit(); bool audio_extn_ma_set_state(struct audio_device *adev, int stream_type, float vol, bool active); void audio_extn_ma_set_device(struct audio_device *adev, struct audio_usecase *usecase); void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *parms); bool audio_extn_ma_set_state(struct audio_device *adev, int stream_type, float vol, bool active); void audio_extn_ma_set_device(struct audio_usecase *usecase); void audio_extn_ma_set_parameters(struct audio_device *adev, struct str_parms *parms); bool audio_extn_ma_supported_usb(); #endif /* MAXXAUDIO_QDSP_ENABLED */ Loading
hal/audio_hw.c +4 −2 Original line number Diff line number Diff line Loading @@ -1464,7 +1464,7 @@ int select_devices(struct audio_device *adev, enable_audio_route(adev, usecase); audio_extn_ma_set_device(adev, usecase); audio_extn_ma_set_device(usecase); /* Applicable only on the targets that has external modem. * Enable device command should be sent to modem only after Loading Loading @@ -2602,7 +2602,7 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) out->devices = new_dev; if (output_drives_call(adev, out)) { if (!voice_is_in_call(adev)) { if (!voice_is_call_state_active(adev)) { if (adev->mode == AUDIO_MODE_IN_CALL) { adev->current_call_output = out; ret = voice_start_call(adev); Loading Loading @@ -5676,6 +5676,8 @@ static int adev_open(const hw_module_t *module, const char *name, } } adev->mic_break_enabled = property_get_bool("vendor.audio.mic_break", false); // commented as full set of app type cfg is sent from platform // audio_extn_utils_send_default_app_type_cfg(adev->platform, adev->mixer); audio_device_ref_count++; Loading
hal/audio_hw.h +1 −0 Original line number Diff line number Diff line Loading @@ -328,6 +328,7 @@ struct audio_device { bool mic_muted; bool enable_voicerx; bool enable_hfp; bool mic_break_enabled; int snd_card; void *platform; Loading