Loading hal/audio_extn/audio_defs.h +8 −0 Original line number Diff line number Diff line Loading @@ -306,4 +306,12 @@ typedef enum { AUDIO_EXTN_PARAM_LICENSE_PARAMS, } audio_extn_param_id; typedef union { struct audio_out_render_window_param render_window_params; } audio_extn_loopback_param_payload; typedef enum { AUDIO_EXTN_PARAM_LOOPBACK_RENDER_WINDOW /* PARAM to set render window */ } audio_extn_loopback_param_id; #endif /* AUDIO_DEFS_H */ hal/audio_extn/audio_extn.c +27 −0 Original line number Diff line number Diff line Loading @@ -1522,6 +1522,33 @@ int audio_extn_out_set_param_data(struct stream_out *out, return ret; } #ifdef AUDIO_HW_LOOPBACK_ENABLED int audio_extn_hw_loopback_set_param_data(audio_patch_handle_t handle, audio_extn_loopback_param_id param_id, audio_extn_loopback_param_payload *payload) { int ret = -EINVAL; if (!payload) { ALOGE("%s:: Invalid Param",__func__); return ret; } ALOGD("%d: %s: param id is %d\n", __LINE__, __func__, param_id); switch(param_id) { case AUDIO_EXTN_PARAM_LOOPBACK_RENDER_WINDOW: ret = audio_extn_hw_loopback_set_render_window(handle, payload); break; default: ALOGE("%s: unsupported param id %d", __func__, param_id); break; } return ret; } #endif /* API to get playback stream specific config parameters */ int audio_extn_out_get_param_data(struct stream_out *out, audio_extn_param_id param_id, Loading hal/audio_extn/audio_extn.h +20 −0 Original line number Diff line number Diff line Loading @@ -1037,6 +1037,14 @@ int audio_extn_hw_loopback_set_audio_port_config(struct audio_hw_device *dev, const struct audio_port_config *config); int audio_extn_hw_loopback_get_audio_port(struct audio_hw_device *dev, struct audio_port *port_in); int audio_extn_hw_loopback_set_param_data(audio_patch_handle_t handle, audio_extn_loopback_param_id param_id, audio_extn_loopback_param_payload *payload); int audio_extn_hw_loopback_set_render_window(audio_patch_handle_t handle, struct audio_out_render_window_param *render_window); int audio_extn_hw_loopback_init(struct audio_device *adev); void audio_extn_hw_loopback_deinit(struct audio_device *adev); #else Loading Loading @@ -1064,6 +1072,18 @@ static int __unused audio_extn_hw_loopback_get_audio_port(struct audio_hw_device { return -ENOSYS; } static int __unused audio_extn_hw_loopback_set_param_data(audio_patch_handle_t handle __unused, audio_extn_loopback_param_id param_id __unused, audio_extn_loopback_param_payload *payload __unused) { return -ENOSYS; } static int __unused audio_extn_hw_loopback_set_render_window(audio_patch_handle_t handle __unused, struct audio_out_render_window_param *render_window __unused) { return -ENOSYS; } static int __unused audio_extn_hw_loopback_init(struct audio_device *adev __unused) { return -ENOSYS; Loading hal/audio_extn/hw_loopback.c +72 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,78 @@ int loopback_stream_cb(stream_callback_event_t event, void *param, void *cookie) return 0; } #ifdef SNDRV_COMPRESS_RENDER_WINDOW static loopback_patch_t *get_active_loopback_patch(audio_patch_handle_t handle) { int n = 0; int patch_index = -1; loopback_patch_t *active_loopback_patch = NULL; for (n=0; n < MAX_NUM_PATCHES; n++) { if (audio_loopback_mod->patch_db.num_patches > 0) { if (audio_loopback_mod->patch_db.loopback_patch[n].patch_handle_id == handle) { patch_index = n; break; } } else { ALOGE("%s, No active audio loopback patch", __func__); return active_loopback_patch; } } if ((patch_index > -1) && (patch_index < MAX_NUM_PATCHES)) active_loopback_patch = &(audio_loopback_mod->patch_db.loopback_patch[ patch_index]); else ALOGE("%s, Requested Patch handle does not exist", __func__); return active_loopback_patch; } int audio_extn_hw_loopback_set_render_window(audio_patch_handle_t handle, struct audio_out_render_window_param *render_window) { struct snd_compr_metadata metadata = {0}; int ret = 0; loopback_patch_t *active_loopback_patch = get_active_loopback_patch(handle); if (active_loopback_patch == NULL) { ALOGE("%s: Invalid patch handle", __func__); ret = -EINVAL; goto exit; } if (render_window == NULL) { ALOGE("%s: Invalid render_window", __func__); ret = -EINVAL; goto exit; } metadata.key = SNDRV_COMPRESS_RENDER_WINDOW; /*render window start value */ metadata.value[0] = 0xFFFFFFFF & render_window->render_ws; /* lsb */ metadata.value[1] = \ (0xFFFFFFFF00000000 & render_window->render_ws) >> 32; /* msb*/ /*render window end value */ metadata.value[2] = 0xFFFFFFFF & render_window->render_we; /* lsb */ metadata.value[3] = \ (0xFFFFFFFF00000000 & render_window->render_we) >> 32; /* msb*/ ret = compress_set_metadata(active_loopback_patch->sink_stream, &metadata); exit: return ret; } #else int audio_extn_hw_loopback_set_render_window(struct audio_hw_device *dev, audio_patch_handle_t handle __unused, struct audio_out_render_window_param *render_window __unused) { ALOGD("%s:: configuring render window not supported", __func__); return 0; } #endif #if defined SNDRV_COMPRESS_LATENCY_MODE static void transcode_loopback_util_set_latency_mode( loopback_patch_t *active_loopback_patch, Loading hal/audio_hw_extn_api.c +14 −1 Original line number Diff line number Diff line /* * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2017, 2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are Loading Loading @@ -423,6 +423,19 @@ static int qahwi_open_output_stream(struct audio_hw_device *dev, return ret; } int qahwi_loopback_set_param_data(audio_patch_handle_t handle, audio_extn_loopback_param_id param_id, void *payload) { int ret = 0; ret = audio_extn_hw_loopback_set_param_data( handle, param_id, (audio_extn_loopback_param_payload *)payload); return ret; } void qahwi_init(hw_device_t *device) { struct audio_device *adev = (struct audio_device *) device; Loading Loading
hal/audio_extn/audio_defs.h +8 −0 Original line number Diff line number Diff line Loading @@ -306,4 +306,12 @@ typedef enum { AUDIO_EXTN_PARAM_LICENSE_PARAMS, } audio_extn_param_id; typedef union { struct audio_out_render_window_param render_window_params; } audio_extn_loopback_param_payload; typedef enum { AUDIO_EXTN_PARAM_LOOPBACK_RENDER_WINDOW /* PARAM to set render window */ } audio_extn_loopback_param_id; #endif /* AUDIO_DEFS_H */
hal/audio_extn/audio_extn.c +27 −0 Original line number Diff line number Diff line Loading @@ -1522,6 +1522,33 @@ int audio_extn_out_set_param_data(struct stream_out *out, return ret; } #ifdef AUDIO_HW_LOOPBACK_ENABLED int audio_extn_hw_loopback_set_param_data(audio_patch_handle_t handle, audio_extn_loopback_param_id param_id, audio_extn_loopback_param_payload *payload) { int ret = -EINVAL; if (!payload) { ALOGE("%s:: Invalid Param",__func__); return ret; } ALOGD("%d: %s: param id is %d\n", __LINE__, __func__, param_id); switch(param_id) { case AUDIO_EXTN_PARAM_LOOPBACK_RENDER_WINDOW: ret = audio_extn_hw_loopback_set_render_window(handle, payload); break; default: ALOGE("%s: unsupported param id %d", __func__, param_id); break; } return ret; } #endif /* API to get playback stream specific config parameters */ int audio_extn_out_get_param_data(struct stream_out *out, audio_extn_param_id param_id, Loading
hal/audio_extn/audio_extn.h +20 −0 Original line number Diff line number Diff line Loading @@ -1037,6 +1037,14 @@ int audio_extn_hw_loopback_set_audio_port_config(struct audio_hw_device *dev, const struct audio_port_config *config); int audio_extn_hw_loopback_get_audio_port(struct audio_hw_device *dev, struct audio_port *port_in); int audio_extn_hw_loopback_set_param_data(audio_patch_handle_t handle, audio_extn_loopback_param_id param_id, audio_extn_loopback_param_payload *payload); int audio_extn_hw_loopback_set_render_window(audio_patch_handle_t handle, struct audio_out_render_window_param *render_window); int audio_extn_hw_loopback_init(struct audio_device *adev); void audio_extn_hw_loopback_deinit(struct audio_device *adev); #else Loading Loading @@ -1064,6 +1072,18 @@ static int __unused audio_extn_hw_loopback_get_audio_port(struct audio_hw_device { return -ENOSYS; } static int __unused audio_extn_hw_loopback_set_param_data(audio_patch_handle_t handle __unused, audio_extn_loopback_param_id param_id __unused, audio_extn_loopback_param_payload *payload __unused) { return -ENOSYS; } static int __unused audio_extn_hw_loopback_set_render_window(audio_patch_handle_t handle __unused, struct audio_out_render_window_param *render_window __unused) { return -ENOSYS; } static int __unused audio_extn_hw_loopback_init(struct audio_device *adev __unused) { return -ENOSYS; Loading
hal/audio_extn/hw_loopback.c +72 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,78 @@ int loopback_stream_cb(stream_callback_event_t event, void *param, void *cookie) return 0; } #ifdef SNDRV_COMPRESS_RENDER_WINDOW static loopback_patch_t *get_active_loopback_patch(audio_patch_handle_t handle) { int n = 0; int patch_index = -1; loopback_patch_t *active_loopback_patch = NULL; for (n=0; n < MAX_NUM_PATCHES; n++) { if (audio_loopback_mod->patch_db.num_patches > 0) { if (audio_loopback_mod->patch_db.loopback_patch[n].patch_handle_id == handle) { patch_index = n; break; } } else { ALOGE("%s, No active audio loopback patch", __func__); return active_loopback_patch; } } if ((patch_index > -1) && (patch_index < MAX_NUM_PATCHES)) active_loopback_patch = &(audio_loopback_mod->patch_db.loopback_patch[ patch_index]); else ALOGE("%s, Requested Patch handle does not exist", __func__); return active_loopback_patch; } int audio_extn_hw_loopback_set_render_window(audio_patch_handle_t handle, struct audio_out_render_window_param *render_window) { struct snd_compr_metadata metadata = {0}; int ret = 0; loopback_patch_t *active_loopback_patch = get_active_loopback_patch(handle); if (active_loopback_patch == NULL) { ALOGE("%s: Invalid patch handle", __func__); ret = -EINVAL; goto exit; } if (render_window == NULL) { ALOGE("%s: Invalid render_window", __func__); ret = -EINVAL; goto exit; } metadata.key = SNDRV_COMPRESS_RENDER_WINDOW; /*render window start value */ metadata.value[0] = 0xFFFFFFFF & render_window->render_ws; /* lsb */ metadata.value[1] = \ (0xFFFFFFFF00000000 & render_window->render_ws) >> 32; /* msb*/ /*render window end value */ metadata.value[2] = 0xFFFFFFFF & render_window->render_we; /* lsb */ metadata.value[3] = \ (0xFFFFFFFF00000000 & render_window->render_we) >> 32; /* msb*/ ret = compress_set_metadata(active_loopback_patch->sink_stream, &metadata); exit: return ret; } #else int audio_extn_hw_loopback_set_render_window(struct audio_hw_device *dev, audio_patch_handle_t handle __unused, struct audio_out_render_window_param *render_window __unused) { ALOGD("%s:: configuring render window not supported", __func__); return 0; } #endif #if defined SNDRV_COMPRESS_LATENCY_MODE static void transcode_loopback_util_set_latency_mode( loopback_patch_t *active_loopback_patch, Loading
hal/audio_hw_extn_api.c +14 −1 Original line number Diff line number Diff line /* * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2017, 2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are Loading Loading @@ -423,6 +423,19 @@ static int qahwi_open_output_stream(struct audio_hw_device *dev, return ret; } int qahwi_loopback_set_param_data(audio_patch_handle_t handle, audio_extn_loopback_param_id param_id, void *payload) { int ret = 0; ret = audio_extn_hw_loopback_set_param_data( handle, param_id, (audio_extn_loopback_param_payload *)payload); return ret; } void qahwi_init(hw_device_t *device) { struct audio_device *adev = (struct audio_device *) device; Loading