hal: Add QAP extention
Add new source file in audio_extn folder Change-Id: If62e948f74f5e9e933704b5b6e061471d3a62a38
This commit is contained in:
parent
f81da24f70
commit
d2f10ba3e8
|
@ -210,12 +210,14 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_QAF)),true)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Hardware specific feature
|
# Hardware specific feature
|
||||||
ifeq ($(strip $(BOARD_SUPPORTS_QAHW)),true)
|
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_QAP)),true)
|
||||||
LOCAL_CFLAGS += -DAUDIO_HW_EXTN_API_ENABLED
|
LOCAL_CFLAGS += -DQAP_EXTN_ENABLED -Wno-tautological-pointer-compare
|
||||||
LOCAL_SRC_FILES += audio_hw_extn_api.c
|
LOCAL_SRC_FILES += audio_extn/qap.c
|
||||||
|
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/qap_wrapper/
|
||||||
|
LOCAL_HEADER_LIBRARIES += audio_qaf_headers
|
||||||
|
LOCAL_SHARED_LIBRARIES += libqap_wrapper liblog
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Hardware specific feature
|
|
||||||
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_LISTEN)),true)
|
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_LISTEN)),true)
|
||||||
LOCAL_CFLAGS += -DAUDIO_LISTEN_ENABLED
|
LOCAL_CFLAGS += -DAUDIO_LISTEN_ENABLED
|
||||||
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-listen
|
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-listen
|
||||||
|
|
|
@ -5141,6 +5141,8 @@ void audio_extn_set_parameters(struct audio_device *adev,
|
||||||
audio_extn_passthru_set_parameters(adev, parms);
|
audio_extn_passthru_set_parameters(adev, parms);
|
||||||
audio_extn_ext_disp_set_parameters(adev, parms);
|
audio_extn_ext_disp_set_parameters(adev, parms);
|
||||||
audio_extn_qaf_set_parameters(adev, parms);
|
audio_extn_qaf_set_parameters(adev, parms);
|
||||||
|
if (audio_extn_qap_is_enabled())
|
||||||
|
audio_extn_qap_set_parameters(adev, parms);
|
||||||
if (adev->offload_effects_set_parameters != NULL)
|
if (adev->offload_effects_set_parameters != NULL)
|
||||||
adev->offload_effects_set_parameters(parms);
|
adev->offload_effects_set_parameters(parms);
|
||||||
audio_extn_set_aptx_dec_bt_addr(adev, parms);
|
audio_extn_set_aptx_dec_bt_addr(adev, parms);
|
||||||
|
|
|
@ -910,6 +910,59 @@ bool audio_extn_is_qaf_stream(struct stream_out *out);
|
||||||
#define audio_extn_is_qaf_stream(out) (0)
|
#define audio_extn_is_qaf_stream(out) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef QAP_EXTN_ENABLED
|
||||||
|
/*
|
||||||
|
* Helper funtion to know if HAL QAP extention is enabled or not.
|
||||||
|
*/
|
||||||
|
bool audio_extn_qap_is_enabled();
|
||||||
|
/*
|
||||||
|
* QAP HAL extention init, called during bootup/HAL device open.
|
||||||
|
* QAP library will be loaded in this funtion.
|
||||||
|
*/
|
||||||
|
int audio_extn_qap_init(struct audio_device *adev);
|
||||||
|
void audio_extn_qap_deinit();
|
||||||
|
/*
|
||||||
|
* if HAL QAP is enabled and inited succesfully then all then this funtion
|
||||||
|
* gets called for all the open_output_stream requests, in other words
|
||||||
|
* the core audio_hw->open_output_stream is overridden by this funtion
|
||||||
|
*/
|
||||||
|
int audio_extn_qap_open_output_stream(struct audio_hw_device *dev,
|
||||||
|
audio_io_handle_t handle,
|
||||||
|
audio_devices_t devices,
|
||||||
|
audio_output_flags_t flags,
|
||||||
|
struct audio_config *config,
|
||||||
|
struct audio_stream_out **stream_out,
|
||||||
|
const char *address __unused);
|
||||||
|
void audio_extn_qap_close_output_stream(struct audio_hw_device *dev __unused,
|
||||||
|
struct audio_stream_out *stream);
|
||||||
|
/*
|
||||||
|
* this funtion is how HAL QAP extention gets to know the device connection/disconnection
|
||||||
|
*/
|
||||||
|
int audio_extn_qap_set_parameters(struct audio_device *adev, struct str_parms *parms);
|
||||||
|
int audio_extn_qap_out_set_param_data(struct stream_out *out,
|
||||||
|
audio_extn_param_id param_id,
|
||||||
|
audio_extn_param_payload *payload);
|
||||||
|
int audio_extn_qap_out_get_param_data(struct stream_out *out,
|
||||||
|
audio_extn_param_id param_id,
|
||||||
|
audio_extn_param_payload *payload);
|
||||||
|
/*
|
||||||
|
* helper funtion.
|
||||||
|
*/
|
||||||
|
bool audio_extn_is_qap_stream(struct stream_out *out);
|
||||||
|
#else
|
||||||
|
#define audio_extn_qap_is_enabled() (0)
|
||||||
|
#define audio_extn_qap_deinit() (0)
|
||||||
|
#define audio_extn_qap_close_output_stream adev_close_output_stream
|
||||||
|
#define audio_extn_qap_open_output_stream adev_open_output_stream
|
||||||
|
#define audio_extn_qap_init(adev) (0)
|
||||||
|
#define audio_extn_qap_set_parameters(adev, parms) (0)
|
||||||
|
#define audio_extn_qap_out_set_param_data(out, param_id, payload) (0)
|
||||||
|
#define audio_extn_qap_out_get_param_data(out, param_id, payload) (0)
|
||||||
|
#define audio_extn_is_qap_stream(out) (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef AUDIO_EXTN_BT_HAL_ENABLED
|
#ifdef AUDIO_EXTN_BT_HAL_ENABLED
|
||||||
int audio_extn_bt_hal_load(void **handle);
|
int audio_extn_bt_hal_load(void **handle);
|
||||||
int audio_extn_bt_hal_open_output_stream(void *handle, int in_rate, audio_channel_mask_t channel_mask, int bit_width);
|
int audio_extn_bt_hal_open_output_stream(void *handle, int in_rate, audio_channel_mask_t channel_mask, int bit_width);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8915,6 +8915,8 @@ static int adev_close(hw_device_t *device)
|
||||||
audio_extn_utils_release_streams_cfg_lists(
|
audio_extn_utils_release_streams_cfg_lists(
|
||||||
&adev->streams_output_cfg_list,
|
&adev->streams_output_cfg_list,
|
||||||
&adev->streams_input_cfg_list);
|
&adev->streams_input_cfg_list);
|
||||||
|
if (audio_extn_qap_is_enabled())
|
||||||
|
audio_extn_qap_deinit();
|
||||||
if (audio_extn_qaf_is_enabled())
|
if (audio_extn_qaf_is_enabled())
|
||||||
audio_extn_qaf_deinit();
|
audio_extn_qaf_deinit();
|
||||||
audio_route_free(adev->audio_route);
|
audio_route_free(adev->audio_route);
|
||||||
|
@ -9195,6 +9197,20 @@ static int adev_open(const hw_module_t *module, const char *name,
|
||||||
}
|
}
|
||||||
|
|
||||||
adev->extspk = audio_extn_extspk_init(adev);
|
adev->extspk = audio_extn_extspk_init(adev);
|
||||||
|
if (audio_extn_qap_is_enabled()) {
|
||||||
|
ret = audio_extn_qap_init(adev);
|
||||||
|
if (ret < 0) {
|
||||||
|
pthread_mutex_destroy(&adev->lock);
|
||||||
|
free(adev);
|
||||||
|
adev = NULL;
|
||||||
|
ALOGE("%s: Failed to init platform data, aborting.", __func__);
|
||||||
|
*device = NULL;
|
||||||
|
pthread_mutex_unlock(&adev_init_lock);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
adev->device.open_output_stream = audio_extn_qap_open_output_stream;
|
||||||
|
adev->device.close_output_stream = audio_extn_qap_close_output_stream;
|
||||||
|
}
|
||||||
|
|
||||||
if (audio_extn_qaf_is_enabled()) {
|
if (audio_extn_qaf_is_enabled()) {
|
||||||
ret = audio_extn_qaf_init(adev);
|
ret = audio_extn_qaf_init(adev);
|
||||||
|
|
|
@ -378,6 +378,7 @@ struct stream_out {
|
||||||
card_status_t card_status;
|
card_status_t card_status;
|
||||||
|
|
||||||
void* qaf_stream_handle;
|
void* qaf_stream_handle;
|
||||||
|
void* qap_stream_handle;
|
||||||
pthread_cond_t qaf_offload_cond;
|
pthread_cond_t qaf_offload_cond;
|
||||||
pthread_t qaf_offload_thread;
|
pthread_t qaf_offload_thread;
|
||||||
struct listnode qaf_offload_cmd_list;
|
struct listnode qaf_offload_cmd_list;
|
||||||
|
|
|
@ -353,9 +353,11 @@ int async_callback(qahw_stream_callback_event_t event, void *param,
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case QAHW_STREAM_CBK_EVENT_WRITE_READY:
|
case QAHW_STREAM_CBK_EVENT_WRITE_READY:
|
||||||
fprintf(log_file, "stream %d: received event - QAHW_STREAM_CBK_EVENT_WRITE_READY\n", params->stream_index);
|
fprintf(log_file, "stream %d: received event - QAHW_STREAM_CBK_EVENT_WRITE_READY\n", params->stream_index);
|
||||||
|
|
||||||
pthread_mutex_lock(¶ms->write_lock);
|
pthread_mutex_lock(¶ms->write_lock);
|
||||||
pthread_cond_signal(¶ms->write_cond);
|
pthread_cond_signal(¶ms->write_cond);
|
||||||
pthread_mutex_unlock(¶ms->write_lock);
|
pthread_mutex_unlock(¶ms->write_lock);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case QAHW_STREAM_CBK_EVENT_DRAIN_READY:
|
case QAHW_STREAM_CBK_EVENT_DRAIN_READY:
|
||||||
fprintf(log_file, "stream %d: received event - QAHW_STREAM_CBK_EVENT_DRAIN_READY\n", params->stream_index);
|
fprintf(log_file, "stream %d: received event - QAHW_STREAM_CBK_EVENT_DRAIN_READY\n", params->stream_index);
|
||||||
|
@ -534,7 +536,7 @@ int write_to_hal(qahw_stream_handle_t* out_handle, char *data, size_t bytes, voi
|
||||||
stream_config *stream_params = (stream_config*) params_ptr;
|
stream_config *stream_params = (stream_config*) params_ptr;
|
||||||
|
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
pthread_mutex_lock(&stream_params->write_lock);
|
|
||||||
qahw_out_buffer_t out_buf;
|
qahw_out_buffer_t out_buf;
|
||||||
|
|
||||||
memset(&out_buf,0, sizeof(qahw_out_buffer_t));
|
memset(&out_buf,0, sizeof(qahw_out_buffer_t));
|
||||||
|
@ -545,13 +547,14 @@ int write_to_hal(qahw_stream_handle_t* out_handle, char *data, size_t bytes, voi
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(log_file, "stream %d: writing data to hal failed (ret = %zd)\n", stream_params->stream_index, ret);
|
fprintf(log_file, "stream %d: writing data to hal failed (ret = %zd)\n", stream_params->stream_index, ret);
|
||||||
} else if ((ret != bytes) && (!stop_playback)) {
|
} else if ((ret != bytes) && (!stop_playback)) {
|
||||||
|
pthread_mutex_lock(&stream_params->write_lock);
|
||||||
fprintf(log_file, "stream %d: provided bytes %zd, written bytes %d\n",stream_params->stream_index, bytes, ret);
|
fprintf(log_file, "stream %d: provided bytes %zd, written bytes %d\n",stream_params->stream_index, bytes, ret);
|
||||||
fprintf(log_file, "stream %d: waiting for event write ready\n", stream_params->stream_index);
|
fprintf(log_file, "stream %d: waiting for event write ready\n", stream_params->stream_index);
|
||||||
pthread_cond_wait(&stream_params->write_cond, &stream_params->write_lock);
|
pthread_cond_wait(&stream_params->write_cond, &stream_params->write_lock);
|
||||||
fprintf(log_file, "stream %d: out of wait for event write ready\n", stream_params->stream_index);
|
fprintf(log_file, "stream %d: out of wait for event write ready\n", stream_params->stream_index);
|
||||||
|
pthread_mutex_unlock(&stream_params->write_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&stream_params->write_lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue