From 93d4d2db902cbffdbecbb68de953a8a7bfff79f6 Mon Sep 17 00:00:00 2001 From: Ben Romberger Date: Wed, 19 Oct 2011 23:04:02 -0700 Subject: [PATCH] msm: audio: qdsp6v2: Change RTAC to remove ADM devices correctly This creates a separate function in Real-Time Audio Calibration (RTAC) to remove popp's from all ADM devices. This also removes popp information from the RTAC remove ADM device function and calls that function from ADM close. Change-Id: I6aed7717a789cdbce5ce39b42d945853a7524418 CRs-fixed: 306716 Signed-off-by: Ben Romberger --- arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h | 3 +- arch/arm/mach-msm/qdsp6v2/rtac.c | 52 +++++++++++-------- sound/soc/msm/qdsp6/q6adm.c | 2 + sound/soc/msm/qdsp6/q6asm.c | 1 + 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h b/arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h index 3d3653b0038..f5bea3150fd 100644 --- a/arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h +++ b/arch/arm/mach-msm/include/mach/qdsp6v2/rtac.h @@ -20,7 +20,8 @@ #define RTAC_VOICE_MODES 2 void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id); -void rtac_remove_adm_device(u32 port_id, u32 popp_id); +void rtac_remove_adm_device(u32 port_id); +void rtac_remove_popp_from_adm_devices(u32 popp_id); void rtac_add_voice(u32 cvs_handle, u32 cvp_handle, u32 rx_afe_port, u32 tx_afe_port, u32 session_id); void rtac_remove_voice(u32 cvs_handle); diff --git a/arch/arm/mach-msm/qdsp6v2/rtac.c b/arch/arm/mach-msm/qdsp6v2/rtac.c index 948c66e9633..98232094068 100644 --- a/arch/arm/mach-msm/qdsp6v2/rtac.c +++ b/arch/arm/mach-msm/qdsp6v2/rtac.c @@ -28,7 +28,8 @@ #ifndef CONFIG_RTAC void rtac_add_adm_device(u32 port_id, u32 copp_id, u32 path_id, u32 popp_id) {} -void rtac_remove_adm_device(u32 port_id, u32 popp_id) {} +void rtac_remove_adm_device(u32 port_id) {} +void rtac_remove_popp_from_adm_devices(u32 popp_id) {} void rtac_set_adm_handle(void *handle) {} bool rtac_make_adm_callback(uint32_t *payload, u32 payload_size) {return false; } @@ -222,44 +223,49 @@ static void shift_popp(u32 copp_idx, u32 popp_idx) } } -void rtac_remove_adm_device(u32 port_id, u32 popp_id) +void rtac_remove_adm_device(u32 port_id) { - s32 i, j; - pr_debug("%s: port_id = %d, popp_id = %d\n", __func__, port_id, - popp_id); + s32 i; + pr_debug("%s: port_id = %d\n", __func__, port_id); mutex_lock(&rtac_adm_mutex); /* look for device */ for (i = 0; i < rtac_adm_data.num_of_dev; i++) { if (rtac_adm_data.device[i].afe_port == port_id) { - if (rtac_adm_data.device[i].num_of_popp == 1) { - memset(&rtac_adm_data.device[i], 0, - sizeof(rtac_adm_data.device[i])); - rtac_adm_data.num_of_dev--; - } else { - for (j = 0; j < - rtac_adm_data.device[i].num_of_popp; j++) { - if (rtac_adm_data.device[i].popp[j] == - popp_id) { - rtac_adm_data.device[i].popp[j] - = 0; - rtac_adm_data.device[i].num_of_popp--; - shift_popp(i, j); - goto done; - } - } - } + memset(&rtac_adm_data.device[i], 0, + sizeof(rtac_adm_data.device[i])); + rtac_adm_data.num_of_dev--; + if (rtac_adm_data.num_of_dev >= 1) { shift_adm_devices(i); break; } } } -done: + mutex_unlock(&rtac_adm_mutex); return; } +void rtac_remove_popp_from_adm_devices(u32 popp_id) +{ + s32 i, j; + pr_debug("%s: popp_id = %d\n", __func__, popp_id); + + mutex_lock(&rtac_adm_mutex); + + for (i = 0; i < rtac_adm_data.num_of_dev; i++) { + for (j = 0; j < rtac_adm_data.device[i].num_of_popp; j++) { + if (rtac_adm_data.device[i].popp[j] == popp_id) { + rtac_adm_data.device[i].popp[j] = 0; + rtac_adm_data.device[i].num_of_popp--; + shift_popp(i, j); + } + } + } + + mutex_unlock(&rtac_adm_mutex); +} /* Voice Info */ static void set_rtac_voice_data(int idx, u32 cvs_handle, u32 cvp_handle, diff --git a/sound/soc/msm/qdsp6/q6adm.c b/sound/soc/msm/qdsp6/q6adm.c index 51be3371f9f..ee6116acbf4 100644 --- a/sound/soc/msm/qdsp6/q6adm.c +++ b/sound/soc/msm/qdsp6/q6adm.c @@ -609,6 +609,8 @@ int adm_close(int port_id) ret = -EINVAL; goto fail_cmd; } + + rtac_remove_adm_device(port_id); } fail_cmd: diff --git a/sound/soc/msm/qdsp6/q6asm.c b/sound/soc/msm/qdsp6/q6asm.c index 1272949a72b..9fcee70d266 100644 --- a/sound/soc/msm/qdsp6/q6asm.c +++ b/sound/soc/msm/qdsp6/q6asm.c @@ -205,6 +205,7 @@ static int q6asm_session_alloc(struct audio_client *ac) static void q6asm_session_free(struct audio_client *ac) { pr_debug("%s: sessionid[%d]\n", __func__, ac->session); + rtac_remove_popp_from_adm_devices(ac->session); mutex_lock(&session_lock); session[ac->session] = 0; mutex_unlock(&session_lock);