public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org,
	pierre-louis.bossart@linux.intel.com,
	yung-chuan.liao@linux.intel.com, rander.wang@intel.com
Cc: alsa-devel@alsa-project.org, daniel.baluta@nxp.com,
	ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com
Subject: [PATCH 5/8] ASoC: SOF: sof-client: Add support IPC4 message sending
Date: Fri,  6 May 2022 16:26:44 +0300	[thread overview]
Message-ID: <20220506132647.18690-6-peter.ujfalusi@linux.intel.com> (raw)
In-Reply-To: <20220506132647.18690-1-peter.ujfalusi@linux.intel.com>

In order to be able to send an IPC4 message, the
sof_client_ipc_tx_message() needs to parse the tx message differently to
extract the size.

The IPC notification registration is done by providing the notification
type and the whole message is passed to the client when a match is found.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 sound/soc/sof/sof-client.c | 47 +++++++++++++++++++++++++++++++++-----
 1 file changed, 41 insertions(+), 6 deletions(-)

diff --git a/sound/soc/sof/sof-client.c b/sound/soc/sof/sof-client.c
index ce002815aa44..a664e0eb81fe 100644
--- a/sound/soc/sof/sof-client.c
+++ b/sound/soc/sof/sof-client.c
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <sound/sof/ipc4/header.h>
 #include "ops.h"
 #include "sof-client.h"
 #include "sof-priv.h"
@@ -245,10 +246,19 @@ EXPORT_SYMBOL_NS_GPL(sof_client_dev_unregister, SND_SOC_SOF_CLIENT);
 int sof_client_ipc_tx_message(struct sof_client_dev *cdev, void *ipc_msg,
 			      void *reply_data, size_t reply_bytes)
 {
-	struct sof_ipc_cmd_hdr *hdr = ipc_msg;
+	if (cdev->sdev->pdata->ipc_type == SOF_IPC) {
+		struct sof_ipc_cmd_hdr *hdr = ipc_msg;
 
-	return sof_ipc_tx_message(cdev->sdev->ipc, ipc_msg, hdr->size,
-				  reply_data, reply_bytes);
+		return sof_ipc_tx_message(cdev->sdev->ipc, ipc_msg, hdr->size,
+					  reply_data, reply_bytes);
+	} else if (cdev->sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
+		struct sof_ipc4_msg *msg = ipc_msg;
+
+		return sof_ipc_tx_message(cdev->sdev->ipc, ipc_msg, msg->data_size,
+					  reply_data, reply_bytes);
+	}
+
+	return -EINVAL;
 }
 EXPORT_SYMBOL_NS_GPL(sof_client_ipc_tx_message, SND_SOC_SOF_CLIENT);
 
@@ -358,9 +368,22 @@ EXPORT_SYMBOL_NS_GPL(sof_client_core_module_put, SND_SOC_SOF_CLIENT);
 /* IPC event handling */
 void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *msg_buf)
 {
-	struct sof_ipc_cmd_hdr *hdr = msg_buf;
-	u32 msg_type = hdr->cmd & SOF_GLB_TYPE_MASK;
 	struct sof_ipc_event_entry *event;
+	u32 msg_type;
+
+	if (sdev->pdata->ipc_type == SOF_IPC) {
+		struct sof_ipc_cmd_hdr *hdr = msg_buf;
+
+		msg_type = hdr->cmd & SOF_GLB_TYPE_MASK;
+	} else if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
+		struct sof_ipc4_msg *msg = msg_buf;
+
+		msg_type = SOF_IPC4_NOTIFICATION_TYPE_GET(msg->primary);
+	} else {
+		dev_dbg_once(sdev->dev, "%s: Not supported IPC version: %d\n",
+			     __func__, sdev->pdata->ipc_type);
+		return;
+	}
 
 	mutex_lock(&sdev->client_event_handler_mutex);
 
@@ -379,9 +402,21 @@ int sof_client_register_ipc_rx_handler(struct sof_client_dev *cdev,
 	struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
 	struct sof_ipc_event_entry *event;
 
-	if (!callback || !(ipc_msg_type & SOF_GLB_TYPE_MASK))
+	if (!callback)
 		return -EINVAL;
 
+	if (cdev->sdev->pdata->ipc_type == SOF_IPC) {
+		if (!(ipc_msg_type & SOF_GLB_TYPE_MASK))
+			return -EINVAL;
+	} else if (cdev->sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
+		if (!(ipc_msg_type & SOF_IPC4_NOTIFICATION_TYPE_MASK))
+			return -EINVAL;
+	} else {
+		dev_warn(sdev->dev, "%s: Not supported IPC version: %d\n",
+			 __func__, sdev->pdata->ipc_type);
+		return -EINVAL;
+	}
+
 	event = kmalloc(sizeof(*event), GFP_KERNEL);
 	if (!event)
 		return -ENOMEM;
-- 
2.36.0


  parent reply	other threads:[~2022-05-06 13:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 13:26 [PATCH 0/8] ASoC: SOF: sof-client: Update for different IPC versions Peter Ujfalusi
2022-05-06 13:26 ` [PATCH 1/8] ASoC: SOF: sof-client: Add API to get the maximum IPC payload size Peter Ujfalusi
2022-05-06 13:26 ` [PATCH 2/8] ASoC: SOF: ipc-msg-injector: Query " Peter Ujfalusi
2022-05-06 13:26 ` [PATCH 3/8] ASoC: SOF: sof-client-probes: " Peter Ujfalusi
2022-05-06 13:26 ` [PATCH 4/8] ASoC: SOF: sof-client: Add API to get the ipc_type Peter Ujfalusi
2022-05-06 13:26 ` Peter Ujfalusi [this message]
2022-05-06 13:26 ` [PATCH 6/8] ASoC: SOF: ipc-msg-injector: Separate the message sending Peter Ujfalusi
2022-05-06 13:26 ` [PATCH 7/8] ASoC: SOF: ipc-msg-injector: Add support for IPC4 messages Peter Ujfalusi
2022-05-06 13:26 ` [PATCH 8/8] ASoC: SOF: sof-client: IPC flood test can only work with SOF_IPC Peter Ujfalusi
2022-05-09 21:13 ` [PATCH 0/8] ASoC: SOF: sof-client: Update for different IPC versions Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220506132647.18690-6-peter.ujfalusi@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rander.wang@intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox