From: Eero Nurkkala <eero.nurkkala@xxxxxxxxxx> apr_register() reminds of an AT modem interface, except that it's apparently not. Drop the passing of strings to simplify the code. In addition, renice some apr_register() internals. Signed-off-by: Eero Nurkkala <eero.nurkkala@xxxxxxxxxx> --- arch/arm/mach-msm/include/mach/qdsp6v2/apr.h | 2 +- arch/arm/mach-msm/qdsp6v2/apr.c | 118 +++++--------------------- arch/arm/mach-msm/qdsp6v2/apr_tal_debug.c | 21 +++-- arch/arm/mach-msm/qdsp6v2/q6adm.c | 10 ++- arch/arm/mach-msm/qdsp6v2/q6afe.c | 4 +- arch/arm/mach-msm/qdsp6v2/q6asm.c | 4 +- arch/arm/mach-msm/qdsp6v2/q6voice.c | 15 ++-- 7 files changed, 57 insertions(+), 117 deletions(-) diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/apr.h b/arch/arm/mach-msm/include/mach/qdsp6v2/apr.h index 5ea1ce7..b17ac5c 100644 --- a/arch/arm/mach-msm/include/mach/qdsp6v2/apr.h +++ b/arch/arm/mach-msm/include/mach/qdsp6v2/apr.h @@ -164,7 +164,7 @@ struct adsp_power_collapse { uint32_t power_collapse; }; -struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn, +struct apr_svc *apr_register(int dest_id, int svc_id, apr_fn svc_fn, uint32_t src_port, void *priv); inline int apr_fill_hdr(void *handle, uint32_t *buf, uint16_t src_port, uint16_t msg_type, uint16_t dest_port, diff --git a/arch/arm/mach-msm/qdsp6v2/apr.c b/arch/arm/mach-msm/qdsp6v2/apr.c index 3a8fac5..cd2d27c 100644 --- a/arch/arm/mach-msm/qdsp6v2/apr.c +++ b/arch/arm/mach-msm/qdsp6v2/apr.c @@ -213,106 +213,34 @@ static void apr_cb_func(void *buf, int len, void *priv) pr_err("APR: Rxed a packet for NULL callback\n"); } -struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn, +struct apr_svc *apr_register(int dest_id, int svc_id, apr_fn svc_fn, uint32_t src_port, void *priv) { - int client_id = 0; - int svc_idx = 0; - int svc_id = 0; - int dest_id = 0; + int client_id = APR_CLIENT_AUDIO; + int svc_idx; int temp_port = 0; struct apr_svc *svc = NULL; - if (!dest || !svc_name || !svc_fn) + if (!svc_fn) return NULL; - if (!strcmp(dest, "ADSP")) - dest_id = APR_DEST_QDSP6; - else if (!strcmp(dest, "MODEM")) { - dest_id = APR_DEST_MODEM; - } else { + if ((dest_id != APR_DEST_MODEM) && (dest_id != APR_DEST_QDSP6)) { pr_err("APR: wrong destination\n"); goto done; } - if (!strcmp(svc_name, "AFE")) { - client_id = APR_CLIENT_AUDIO; - svc_idx = 0; - svc_id = APR_SVC_AFE; - } else if (!strcmp(svc_name, "ASM")) { - client_id = APR_CLIENT_AUDIO; - svc_idx = 1; - svc_id = APR_SVC_ASM; - } else if (!strcmp(svc_name, "ADM")) { - client_id = APR_CLIENT_AUDIO; - svc_idx = 2; - svc_id = APR_SVC_ADM; - } else if (!strcmp(svc_name, "CORE")) { - client_id = APR_CLIENT_AUDIO; - svc_idx = 3; - svc_id = APR_SVC_ADSP_CORE; - } else if (!strcmp(svc_name, "TEST")) { - if (dest_id == APR_DEST_QDSP6) { - client_id = APR_CLIENT_AUDIO; - svc_idx = 4; - } else { - client_id = APR_CLIENT_VOICE; - svc_idx = 7; - } - svc_id = APR_SVC_TEST_CLIENT; - } else if (!strcmp(svc_name, "VSM")) { - client_id = APR_CLIENT_VOICE; - svc_idx = 0; - svc_id = APR_SVC_VSM; - } else if (!strcmp(svc_name, "VPM")) { - client_id = APR_CLIENT_VOICE; - svc_idx = 1; - svc_id = APR_SVC_VPM; - } else if (!strcmp(svc_name, "MVS")) { - client_id = APR_CLIENT_VOICE; - svc_idx = 2; - svc_id = APR_SVC_MVS; - } else if (!strcmp(svc_name, "MVM")) { - if (dest_id == APR_DEST_MODEM) { - client_id = APR_CLIENT_VOICE; - svc_idx = 3; - svc_id = APR_SVC_MVM; - } else { - client_id = APR_CLIENT_AUDIO; - svc_idx = 5; - svc_id = APR_SVC_ADSP_MVM; - } - } else if (!strcmp(svc_name, "CVS")) { - if (dest_id == APR_DEST_MODEM) { - client_id = APR_CLIENT_VOICE; - svc_idx = 4; - svc_id = APR_SVC_CVS; - } else { - client_id = APR_CLIENT_AUDIO; - svc_idx = 6; - svc_id = APR_SVC_ADSP_CVS; - } - } else if (!strcmp(svc_name, "CVP")) { - if (dest_id == APR_DEST_MODEM) { - client_id = APR_CLIENT_VOICE; - svc_idx = 5; - svc_id = APR_SVC_CVP; - } else { - client_id = APR_CLIENT_AUDIO; - svc_idx = 7; - svc_id = APR_SVC_ADSP_CVP; - } - } else if (!strcmp(svc_name, "SRD")) { - client_id = APR_CLIENT_VOICE; - svc_idx = 6; - svc_id = APR_SVC_SRD; - } else { - pr_err("APR: Wrong svc name\n"); + svc_idx = svc_id - APR_SVC_TEST_CLIENT; + if (svc_idx < 0 || svc_idx >= APR_SVC_MAX) { + pr_err("%s: APR: illegal svc\n", __func__); goto done; } - pr_debug("svc name = %s c_id = %d dest_id = %d\n", - svc_name, client_id, dest_id); + /* VSM, VPM, MVS, SRD are unused */ + if (dest_id == APR_DEST_MODEM) + client_id = APR_CLIENT_VOICE; + + pr_debug("c_id = %d dest_id = %d\n", client_id, dest_id); + mutex_lock(&q6.lock); if (q6.state == APR_Q6_NOIMG) { q6.pil = pil_get("q6"); @@ -336,13 +264,13 @@ struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn, } } mutex_unlock(&client[dest_id][client_id].m_lock); - mutex_lock(&client[dest_id][client_id].svc[svc_idx].m_lock); - client[dest_id][client_id].id = client_id; - client[dest_id][client_id].svc[svc_idx].priv = priv; - client[dest_id][client_id].svc[svc_idx].id = svc_id; - client[dest_id][client_id].svc[svc_idx].dest_id = dest_id; - client[dest_id][client_id].svc[svc_idx].client_id = client_id; svc = &client[dest_id][client_id].svc[svc_idx]; + mutex_lock(&svc->m_lock); + client[dest_id][client_id].id = client_id; + svc->priv = priv; + svc->id = svc_id; + svc->dest_id = dest_id; + svc->client_id = client_id; if (src_port != 0xFFFFFFFF) { temp_port = ((src_port >> 8) * 8) + (src_port & 0xFF); pr_info("port = %d t_port = %d\n", src_port, temp_port); @@ -352,16 +280,16 @@ struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn, svc->port_fn[temp_port] = svc_fn; svc->port_priv[temp_port] = priv; } else { - if (!client[dest_id][client_id].svc[svc_idx].fn) { + if (!svc->fn) { if (!svc->port_cnt && !svc->svc_cnt) client[dest_id][client_id].svc_cnt++; - client[dest_id][client_id].svc[svc_idx].fn = svc_fn; + svc->fn = svc_fn; if (svc->port_cnt) svc->svc_cnt++; } } - mutex_unlock(&client[dest_id][client_id].svc[svc_idx].m_lock); + mutex_unlock(&svc->m_lock); done: return svc; } diff --git a/arch/arm/mach-msm/qdsp6v2/apr_tal_debug.c b/arch/arm/mach-msm/qdsp6v2/apr_tal_debug.c index aaee4e4..dfc19a8 100644 --- a/arch/arm/mach-msm/qdsp6v2/apr_tal_debug.c +++ b/arch/arm/mach-msm/qdsp6v2/apr_tal_debug.c @@ -140,12 +140,16 @@ static ssize_t apr_debug_write(struct file *file, const char __user *buf, len--; } if (!strncmp(l_buf + 20, "open_q", 64)) { - apr_handle_q = apr_register("ADSP", "TEST", aprv2_debug_fn_q, - 0xFFFFFFFF, NULL); + apr_handle_q = apr_register(APR_DEST_QDSP6, + APR_SVC_TEST_CLIENT, + aprv2_debug_fn_q, + 0xFFFFFFFF, NULL); pr_info("Open_q %p\n", apr_handle_q); } else if (!strncmp(l_buf + 20, "open_m", 64)) { - apr_handle_m = apr_register("MODEM", "TEST", aprv2_debug_fn_m, - 0xFFFFFFFF, NULL); + apr_handle_m = apr_register(APR_DEST_MODEM, + APR_SVC_TEST_CLIENT, + aprv2_debug_fn_m, + 0xFFFFFFFF, NULL); pr_info("Open_m %p\n", apr_handle_m); } else if (!strncmp(l_buf + 20, "write_q", 64)) { struct apr_hdr *hdr; @@ -221,7 +225,8 @@ static ssize_t apr_debug_write(struct file *file, const char __user *buf, } else if (!strncmp(l_buf + 20, "dsp_ver", 64)) { struct apr_hdr *hdr; - apr_handle_q = apr_register("ADSP", "CORE", aprv2_core_fn_q, + apr_handle_q = apr_register(APR_DEST_QDSP6, APR_SVC_ADSP_CORE, + aprv2_core_fn_q, 0xFFFFFFFF, NULL); pr_info("Open_q %p\n", apr_handle_q); if (apr_handle_q) { @@ -241,7 +246,8 @@ static ssize_t apr_debug_write(struct file *file, const char __user *buf, } else if (!strncmp(l_buf + 20, "en_pwr_col", 64)) { struct adsp_power_collapse pc; - apr_handle_q = apr_register("ADSP", "CORE", aprv2_core_fn_q, + apr_handle_q = apr_register(APR_DEST_QDSP6, APR_SVC_ADSP_CORE, + aprv2_core_fn_q, 0xFFFFFFFF, NULL); pr_info("Open_q %p\n", apr_handle_q); if (apr_handle_q) { @@ -260,7 +266,8 @@ static ssize_t apr_debug_write(struct file *file, const char __user *buf, } else if (!strncmp(l_buf + 20, "dis_pwr_col", 64)) { struct adsp_power_collapse pc; - apr_handle_q = apr_register("ADSP", "CORE", aprv2_core_fn_q, + apr_handle_q = apr_register(APR_DEST_QDSP6, APR_SVC_ADSP_CORE, + aprv2_core_fn_q, 0xFFFFFFFF, NULL); pr_info("Open_q %p\n", apr_handle_q); if (apr_handle_q) { diff --git a/arch/arm/mach-msm/qdsp6v2/q6adm.c b/arch/arm/mach-msm/qdsp6v2/q6adm.c index 26f0f07..59059ab 100644 --- a/arch/arm/mach-msm/qdsp6v2/q6adm.c +++ b/arch/arm/mach-msm/qdsp6v2/q6adm.c @@ -178,8 +178,9 @@ int adm_open(int port_id, int session_id , int path, } if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); + this_adm.apr = apr_register(APR_DEST_QDSP6, APR_SVC_ADM, + adm_callback, 0xFFFFFFFF, + &this_adm); if (this_adm.apr == NULL) { pr_err("%s: Unable to register ADM\n", __func__); ret = -ENODEV; @@ -305,8 +306,9 @@ int adm_memory_map_regions(uint32_t *buf_add, uint32_t mempool_id, pr_info("%s\n", __func__); if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); + this_adm.apr = apr_register(APR_DEST_QDSP6, APR_SVC_ADM, + adm_callback, 0xFFFFFFFF, + &this_adm); if (this_adm.apr == NULL) { pr_err("%s: Unable to register ADM\n", __func__); ret = -ENODEV; diff --git a/arch/arm/mach-msm/qdsp6v2/q6afe.c b/arch/arm/mach-msm/qdsp6v2/q6afe.c index deec506..1bd0a73 100644 --- a/arch/arm/mach-msm/qdsp6v2/q6afe.c +++ b/arch/arm/mach-msm/qdsp6v2/q6afe.c @@ -75,8 +75,8 @@ int afe_open(u16 port_id, union afe_port_config *afe_config, int rate) pr_info("%s: %d %d\n", __func__, port_id, rate); if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); + this_afe.apr = apr_register(APR_DEST_QDSP6, APR_SVC_AFE, + afe_callback, 0xFFFFFFFF, &this_afe); pr_info("%s: Register AFE\n", __func__); if (this_afe.apr == NULL) { pr_err("%s: Unable to register AFE\n", __func__); diff --git a/arch/arm/mach-msm/qdsp6v2/q6asm.c b/arch/arm/mach-msm/qdsp6v2/q6asm.c index f918535..57f8894 100644 --- a/arch/arm/mach-msm/qdsp6v2/q6asm.c +++ b/arch/arm/mach-msm/qdsp6v2/q6asm.c @@ -210,7 +210,7 @@ struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv) ac->cb = cb; ac->priv = priv; ac->io_mode = SYNC_IO_MODE; - ac->apr = apr_register("ADSP", "ASM", \ + ac->apr = apr_register(APR_DEST_QDSP6, APR_SVC_ASM, \ (apr_fn)q6asm_callback,\ ((ac->session) << 8 | 0x0001),\ ac); @@ -221,7 +221,7 @@ struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv) } pr_debug("%s Registering the common port with APR\n", __func__); if (atomic_read(&this_mmap.ref_cnt) == 0) { - this_mmap.apr = apr_register("ADSP", "ASM", \ + this_mmap.apr = apr_register(APR_DEST_QDSP6, APR_SVC_ASM, \ (apr_fn)q6asm_mmapcallback,\ 0x0FFFFFFFF, &this_mmap); if (this_mmap.apr == NULL) { diff --git a/arch/arm/mach-msm/qdsp6v2/q6voice.c b/arch/arm/mach-msm/qdsp6v2/q6voice.c index 7aeb89e..9619eed 100644 --- a/arch/arm/mach-msm/qdsp6v2/q6voice.c +++ b/arch/arm/mach-msm/qdsp6v2/q6voice.c @@ -279,11 +279,12 @@ static int voice_apr_register(struct voice_data *v) pr_debug("start to register MVM callback\n"); if (v->voc_path == VOC_PATH_PASSIVE) { - apr_mvm = apr_register("MODEM", "MVM", + apr_mvm = apr_register(APR_DEST_MODEM, APR_SVC_MVM, modem_mvm_callback, 0xFFFFFFFF, v); } else { - apr_mvm = apr_register("ADSP", "MVM", + apr_mvm = apr_register(APR_DEST_QDSP6, + APR_SVC_ADSP_MVM, modem_mvm_callback, 0xFFFFFFFF, v); } @@ -301,11 +302,12 @@ static int voice_apr_register(struct voice_data *v) pr_debug("start to register CVS callback\n"); if (v->voc_path == VOC_PATH_PASSIVE) { - apr_cvs = apr_register("MODEM", "CVS", + apr_cvs = apr_register(APR_DEST_MODEM, APR_SVC_CVS, modem_cvs_callback, 0xFFFFFFFF, v); } else { - apr_cvs = apr_register("ADSP", "CVS", + apr_cvs = apr_register(APR_DEST_QDSP6, + APR_SVC_ADSP_CVS, modem_cvs_callback, 0xFFFFFFFF, v); } @@ -323,11 +325,12 @@ static int voice_apr_register(struct voice_data *v) pr_debug("start to register CVP callback\n"); if (v->voc_path == VOC_PATH_PASSIVE) { - apr_cvp = apr_register("MODEM", "CVP", + apr_cvp = apr_register(APR_DEST_MODEM, APR_SVC_CVP, modem_cvp_callback, 0xFFFFFFFF, v); } else { - apr_cvp = apr_register("ADSP", "CVP", + apr_cvp = apr_register(APR_DEST_QDSP6, + APR_SVC_ADSP_CVP, modem_cvp_callback, 0xFFFFFFFF, v); } -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html