ASoC: msm: Register AFE APR during prepare
ALSA trigger function must be atomic. Therefore, removing the AFE APR
registering function to prepare since apr_register uses mutex
CRs-Fixed: 298122
Signed-off-by: Jay Wang <jaywang@codeaurora.org>
diff --git a/include/sound/q6afe.h b/include/sound/q6afe.h
index 133a065..182c4e9 100644
--- a/include/sound/q6afe.h
+++ b/include/sound/q6afe.h
@@ -65,4 +65,6 @@
u32 rate);
int afe_port_stop_nowait(int port_id);
int afe_apply_gain(u16 port_id, u16 gain);
+int afe_q6_interface_prepare(void);
+
#endif /* __Q6AFE_H__ */
diff --git a/sound/soc/msm/msm-dai-q6.c b/sound/soc/msm/msm-dai-q6.c
index 7dca4d4..a0a4a5b 100644
--- a/sound/soc/msm/msm-dai-q6.c
+++ b/sound/soc/msm/msm-dai-q6.c
@@ -242,6 +242,11 @@
dai_data->channels, DEFAULT_COPP_TOPOLOGY);
if (IS_ERR_VALUE(rc))
dev_err(dai->dev, "fail to open ADM\n");
+ else {
+ rc = afe_q6_interface_prepare();
+ if (IS_ERR_VALUE(rc))
+ dev_err(dai->dev, "fail to open AFE APR\n");
+ }
}
return rc;
diff --git a/sound/soc/msm/qdsp6/q6afe.c b/sound/soc/msm/qdsp6/q6afe.c
index 7157a8b..0accf3c 100644
--- a/sound/soc/msm/qdsp6/q6afe.c
+++ b/sound/soc/msm/qdsp6/q6afe.c
@@ -183,6 +183,24 @@
return ret_size;
}
+int afe_q6_interface_prepare(void)
+{
+ int ret = 0;
+
+ pr_debug("%s:", __func__);
+
+ if (this_afe.apr == NULL) {
+ this_afe.apr = apr_register("ADSP", "AFE", afe_callback,
+ 0xFFFFFFFF, &this_afe);
+ pr_debug("%s: Register AFE\n", __func__);
+ if (this_afe.apr == NULL) {
+ pr_err("%s: Unable to register AFE\n", __func__);
+ ret = -ENODEV;
+ }
+ }
+ return ret;
+}
+
int afe_port_start_nowait(u16 port_id, union afe_port_config *afe_config,
u32 rate) /* This function is no blocking */
{
@@ -199,14 +217,9 @@
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);
- pr_info("%s: Register AFE\n", __func__);
- if (this_afe.apr == NULL) {
- pr_err("%s: Unable to register AFE\n", __func__);
- ret = -ENODEV;
- return ret;
- }
+ pr_err("%s: AFE APR is not registered\n", __func__);
+ ret = -ENODEV;
+ return ret;
}
config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
@@ -281,16 +294,9 @@
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);
- pr_info("%s: Register AFE\n", __func__);
- if (this_afe.apr == NULL) {
- pr_err("%s: Unable to register AFE\n", __func__);
- ret = -ENODEV;
- return ret;
- }
- }
+ ret = afe_q6_interface_prepare();
+ if (ret != 0)
+ return ret;
config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
@@ -376,16 +382,11 @@
{
struct afe_loopback_command lb_cmd;
int ret = 0;
- if (this_afe.apr == NULL) {
- this_afe.apr = apr_register("ADSP", "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__);
- ret = -ENODEV;
- return ret;
- }
- }
+
+ ret = afe_q6_interface_prepare();
+ if (ret != 0)
+ return ret;
+
lb_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
APR_HDR_LEN(20), APR_PKT_VER);
lb_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
@@ -561,16 +562,9 @@
pr_info("%s: port_id=%d\n", __func__, port_id);
- if (this_afe.apr == NULL) {
- this_afe.apr = apr_register("ADSP", "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__);
- ret = -ENODEV;
- return ret;
- }
- }
+ ret = afe_q6_interface_prepare();
+ if (ret != 0)
+ return ret;
start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);