|
@@ -1,6 +1,6 @@
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
/*
|
|
|
- * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
|
|
|
+ * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
|
|
|
*/
|
|
|
|
|
|
#include <linux/module.h>
|
|
@@ -10,6 +10,7 @@
|
|
|
#include <linux/delay.h>
|
|
|
#include <linux/rpmsg.h>
|
|
|
#include <ipc/apr_tal.h>
|
|
|
+#include <linux/of_device.h>
|
|
|
|
|
|
enum apr_channel_state {
|
|
|
APR_CH_DISCONNECTED,
|
|
@@ -125,14 +126,13 @@ struct apr_svc_ch_dev *apr_tal_open(uint32_t clnt, uint32_t dest, uint32_t dl,
|
|
|
int rc = 0;
|
|
|
struct apr_svc_ch_dev *apr_ch = NULL;
|
|
|
|
|
|
- if ((clnt != APR_CLIENT_AUDIO) || (dest != APR_DEST_QDSP6) ||
|
|
|
+ if ((clnt != APR_CLIENT_AUDIO) || (dest >= APR_DEST_MAX) ||
|
|
|
(dl != APR_DL_SMD)) {
|
|
|
pr_err("%s: Invalid params, clnt:%d, dest:%d, dl:%d\n",
|
|
|
__func__, clnt, dest, dl);
|
|
|
return NULL;
|
|
|
}
|
|
|
-
|
|
|
- apr_ch = &apr_svc_ch[APR_DL_SMD][APR_DEST_QDSP6][APR_CLIENT_AUDIO];
|
|
|
+ apr_ch = &apr_svc_ch[dl][dest][clnt];
|
|
|
mutex_lock(&apr_ch->m_lock);
|
|
|
if (!apr_ch->handle) {
|
|
|
rc = wait_event_timeout(apr_ch->wait,
|
|
@@ -207,24 +207,46 @@ static int apr_tal_rpmsg_callback(struct rpmsg_device *rpdev,
|
|
|
static int apr_tal_rpmsg_probe(struct rpmsg_device *rpdev)
|
|
|
{
|
|
|
struct apr_svc_ch_dev *apr_ch = NULL;
|
|
|
+ int ret = 0;
|
|
|
+ const char* dest;
|
|
|
+
|
|
|
+ ret = of_property_read_string(rpdev->dev.parent->of_node,
|
|
|
+ "mbox-names", &dest);
|
|
|
+
|
|
|
+ if(ret < 0){
|
|
|
+ pr_err("%s no parent source pid found\n", __func__);
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
|
|
|
if (!strcmp(rpdev->id.name, "apr_audio_svc")) {
|
|
|
dev_info(&rpdev->dev, "%s: Channel[%s] state[Up]\n",
|
|
|
__func__, rpdev->id.name);
|
|
|
-
|
|
|
+ } else {
|
|
|
+ dev_err(&rpdev->dev, "%s, Invalid Channel [%s]\n",
|
|
|
+ __func__, rpdev->id.name);
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+ if(strstr(dest, "adsp")) {
|
|
|
apr_ch =
|
|
|
&apr_svc_ch[APR_DL_SMD][APR_DEST_QDSP6][APR_CLIENT_AUDIO];
|
|
|
apr_ch->handle = rpdev;
|
|
|
apr_ch->channel_state = APR_CH_CONNECTED;
|
|
|
dev_set_drvdata(&rpdev->dev, apr_ch);
|
|
|
wake_up(&apr_ch->wait);
|
|
|
+ } else if(strstr(dest, "mpss")) {
|
|
|
+ apr_ch =
|
|
|
+ &apr_svc_ch[APR_DL_SMD][APR_DEST_MODEM][APR_CLIENT_AUDIO];
|
|
|
+ apr_ch->handle = rpdev;
|
|
|
+ apr_ch->channel_state = APR_CH_CONNECTED;
|
|
|
+ dev_set_drvdata(&rpdev->dev, apr_ch);
|
|
|
+ wake_up(&apr_ch->wait);
|
|
|
} else {
|
|
|
- dev_err(&rpdev->dev, "%s, Invalid Channel [%s]\n",
|
|
|
- __func__, rpdev->id.name);
|
|
|
+ dev_err(&rpdev->dev, "%s, unsupported dest %s\n",
|
|
|
+ __func__, dest);
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
- return 0;
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
static void apr_tal_rpmsg_remove(struct rpmsg_device *rpdev)
|