summaryrefslogtreecommitdiff
path: root/sound/soc/sof/mediatek
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/sof/mediatek')
-rw-r--r--sound/soc/sof/mediatek/mt8186/Makefile2
-rw-r--r--sound/soc/sof/mediatek/mt8186/mt8186.c120
-rw-r--r--sound/soc/sof/mediatek/mt8195/Makefile2
-rw-r--r--sound/soc/sof/mediatek/mt8195/mt8195-clk.c3
-rw-r--r--sound/soc/sof/mediatek/mt8195/mt8195.c129
-rw-r--r--sound/soc/sof/mediatek/mtk-adsp-common.c131
-rw-r--r--sound/soc/sof/mediatek/mtk-adsp-common.h10
7 files changed, 179 insertions, 218 deletions
diff --git a/sound/soc/sof/mediatek/mt8186/Makefile b/sound/soc/sof/mediatek/mt8186/Makefile
index c1f5fc4e2495..022f415afac9 100644
--- a/sound/soc/sof/mediatek/mt8186/Makefile
+++ b/sound/soc/sof/mediatek/mt8186/Makefile
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
-snd-sof-mt8186-objs := mt8186.o mt8186-clk.o mt8186-loader.o
+snd-sof-mt8186-y := mt8186.o mt8186-clk.o mt8186-loader.o
obj-$(CONFIG_SND_SOC_SOF_MT8186) += snd-sof-mt8186.o
diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c
index 0d2d7d697de0..7ff080452cbe 100644
--- a/sound/soc/sof/mediatek/mt8186/mt8186.c
+++ b/sound/soc/sof/mediatek/mt8186/mt8186.c
@@ -22,7 +22,6 @@
#include <sound/sof/xtensa.h>
#include "../../ops.h"
#include "../../sof-of-dev.h"
-#include "../../sof-audio.h"
#include "../adsp_helper.h"
#include "../mtk-adsp-common.h"
#include "mt8186.h"
@@ -38,53 +37,9 @@ static int mt8186_get_window_offset(struct snd_sof_dev *sdev, u32 id)
return MBOX_OFFSET;
}
-static int mt8186_send_msg(struct snd_sof_dev *sdev,
- struct snd_sof_ipc_msg *msg)
-{
- struct adsp_priv *priv = sdev->pdata->hw_pdata;
-
- sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
- msg->msg_size);
-
- return mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_REQ, MTK_ADSP_IPC_OP_REQ);
-}
-
-static void mt8186_dsp_handle_reply(struct mtk_adsp_ipc *ipc)
-{
- struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc);
- unsigned long flags;
-
- spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
- snd_sof_ipc_process_reply(priv->sdev, 0);
- spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags);
-}
-
-static void mt8186_dsp_handle_request(struct mtk_adsp_ipc *ipc)
-{
- struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc);
- u32 p; /* panic code */
- int ret;
-
- /* Read the message from the debug box. */
- sof_mailbox_read(priv->sdev, priv->sdev->debug_box.offset + 4,
- &p, sizeof(p));
-
- /* Check to see if the message is a panic code 0x0dead*** */
- if ((p & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) {
- snd_sof_dsp_panic(priv->sdev, p, true);
- } else {
- snd_sof_ipc_msgs_rx(priv->sdev);
-
- /* tell DSP cmd is done */
- ret = mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_RSP, MTK_ADSP_IPC_OP_RSP);
- if (ret)
- dev_err(priv->dev, "request send ipc failed");
- }
-}
-
-static struct mtk_adsp_ipc_ops dsp_ops = {
- .handle_reply = mt8186_dsp_handle_reply,
- .handle_request = mt8186_dsp_handle_request,
+static const struct mtk_adsp_ipc_ops dsp_ops = {
+ .handle_reply = mtk_adsp_handle_reply,
+ .handle_request = mtk_adsp_handle_request,
};
static int platform_parse_resource(struct platform_device *pdev, void *data)
@@ -238,7 +193,7 @@ static int mt8186_run(struct snd_sof_dev *sdev)
static int mt8186_dsp_probe(struct snd_sof_dev *sdev)
{
- struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
+ struct platform_device *pdev = to_platform_device(sdev->dev);
struct adsp_priv *priv;
int ret;
@@ -381,54 +336,6 @@ static int mt8186_dsp_resume(struct snd_sof_dev *sdev)
return ret;
}
-/* on mt8186 there is 1 to 1 match between type and BAR idx */
-static int mt8186_get_bar_index(struct snd_sof_dev *sdev, u32 type)
-{
- return type;
-}
-
-static int mt8186_pcm_hw_params(struct snd_sof_dev *sdev,
- struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_sof_platform_stream_params *platform_params)
-{
- platform_params->cont_update_posn = 1;
-
- return 0;
-}
-
-static snd_pcm_uframes_t mt8186_pcm_pointer(struct snd_sof_dev *sdev,
- struct snd_pcm_substream *substream)
-{
- int ret;
- snd_pcm_uframes_t pos;
- struct snd_sof_pcm *spcm;
- struct sof_ipc_stream_posn posn;
- struct snd_sof_pcm_stream *stream;
- struct snd_soc_component *scomp = sdev->component;
- struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
-
- spcm = snd_sof_find_spcm_dai(scomp, rtd);
- if (!spcm) {
- dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n",
- rtd->dai_link->id);
- return 0;
- }
-
- stream = &spcm->stream[substream->stream];
- ret = snd_sof_ipc_msg_data(sdev, stream, &posn, sizeof(posn));
- if (ret < 0) {
- dev_warn(sdev->dev, "failed to read stream position: %d\n", ret);
- return 0;
- }
-
- memcpy(&stream->posn, &posn, sizeof(posn));
- pos = spcm->stream[substream->stream].posn.host_posn;
- pos = bytes_to_frames(substream->runtime, pos);
-
- return pos;
-}
-
static void mt8186_adsp_dump(struct snd_sof_dev *sdev, u32 flags)
{
u32 dbg_pc, dbg_data, dbg_inst, dbg_ls0stat, dbg_status, faultinfo;
@@ -481,7 +388,7 @@ static struct snd_soc_dai_driver mt8186_dai[] = {
};
/* mt8186 ops */
-static struct snd_sof_dsp_ops sof_mt8186_ops = {
+static const struct snd_sof_dsp_ops sof_mt8186_ops = {
/* probe and remove */
.probe = mt8186_dsp_probe,
.remove = mt8186_dsp_remove,
@@ -505,19 +412,19 @@ static struct snd_sof_dsp_ops sof_mt8186_ops = {
.read64 = sof_io_read64,
/* ipc */
- .send_msg = mt8186_send_msg,
+ .send_msg = mtk_adsp_send_msg,
.get_mailbox_offset = mt8186_get_mailbox_offset,
.get_window_offset = mt8186_get_window_offset,
.ipc_msg_data = sof_ipc_msg_data,
.set_stream_data_offset = sof_set_stream_data_offset,
/* misc */
- .get_bar_index = mt8186_get_bar_index,
+ .get_bar_index = mtk_adsp_get_bar_index,
/* stream callbacks */
.pcm_open = sof_stream_pcm_open,
- .pcm_hw_params = mt8186_pcm_hw_params,
- .pcm_pointer = mt8186_pcm_pointer,
+ .pcm_hw_params = mtk_adsp_stream_pcm_hw_params,
+ .pcm_pointer = mtk_adsp_stream_pcm_pointer,
.pcm_close = sof_stream_pcm_close,
/* firmware loading */
@@ -656,16 +563,17 @@ MODULE_DEVICE_TABLE(of, sof_of_mt8186_ids);
/* DT driver definition */
static struct platform_driver snd_sof_of_mt8186_driver = {
.probe = sof_of_probe,
- .remove_new = sof_of_remove,
+ .remove = sof_of_remove,
.shutdown = sof_of_shutdown,
.driver = {
.name = "sof-audio-of-mt8186",
- .pm = &sof_of_pm,
+ .pm = pm_ptr(&sof_of_pm),
.of_match_table = sof_of_mt8186_ids,
},
};
module_platform_driver(snd_sof_of_mt8186_driver);
-MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
-MODULE_IMPORT_NS(SND_SOC_SOF_MTK_COMMON);
MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("SOF support for MT8186/MT8188 platforms");
+MODULE_IMPORT_NS("SND_SOC_SOF_XTENSA");
+MODULE_IMPORT_NS("SND_SOC_SOF_MTK_COMMON");
diff --git a/sound/soc/sof/mediatek/mt8195/Makefile b/sound/soc/sof/mediatek/mt8195/Makefile
index afc4f21fccc5..f5eeda380b50 100644
--- a/sound/soc/sof/mediatek/mt8195/Makefile
+++ b/sound/soc/sof/mediatek/mt8195/Makefile
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
-snd-sof-mt8195-objs := mt8195.o mt8195-clk.o mt8195-loader.o
+snd-sof-mt8195-y := mt8195.o mt8195-clk.o mt8195-loader.o
obj-$(CONFIG_SND_SOC_SOF_MT8195) += snd-sof-mt8195.o
diff --git a/sound/soc/sof/mediatek/mt8195/mt8195-clk.c b/sound/soc/sof/mediatek/mt8195/mt8195-clk.c
index 7cffcad00f9b..2c2c4cd323fc 100644
--- a/sound/soc/sof/mediatek/mt8195/mt8195-clk.c
+++ b/sound/soc/sof/mediatek/mt8195/mt8195-clk.c
@@ -8,6 +8,7 @@
#include <linux/clk.h>
#include <linux/io.h>
+#include <linux/string_choices.h>
#include "mt8195.h"
#include "mt8195-clk.h"
#include "../adsp_helper.h"
@@ -114,7 +115,7 @@ static int adsp_default_clk_init(struct snd_sof_dev *sdev, bool enable)
struct adsp_priv *priv = sdev->pdata->hw_pdata;
int ret;
- dev_dbg(dev, "%s: %s\n", __func__, enable ? "on" : "off");
+ dev_dbg(dev, "%s: %s\n", __func__, str_on_off(enable));
if (enable) {
ret = clk_set_parent(priv->clk[CLK_TOP_ADSP],
diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c
index 8ee7ee246344..3b3582d74510 100644
--- a/sound/soc/sof/mediatek/mt8195/mt8195.c
+++ b/sound/soc/sof/mediatek/mt8195/mt8195.c
@@ -22,7 +22,6 @@
#include <sound/sof/xtensa.h>
#include "../../ops.h"
#include "../../sof-of-dev.h"
-#include "../../sof-audio.h"
#include "../adsp_helper.h"
#include "../mtk-adsp-common.h"
#include "mt8195.h"
@@ -38,53 +37,9 @@ static int mt8195_get_window_offset(struct snd_sof_dev *sdev, u32 id)
return MBOX_OFFSET;
}
-static int mt8195_send_msg(struct snd_sof_dev *sdev,
- struct snd_sof_ipc_msg *msg)
-{
- struct adsp_priv *priv = sdev->pdata->hw_pdata;
-
- sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
- msg->msg_size);
-
- return mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_REQ, MTK_ADSP_IPC_OP_REQ);
-}
-
-static void mt8195_dsp_handle_reply(struct mtk_adsp_ipc *ipc)
-{
- struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc);
- unsigned long flags;
-
- spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
- snd_sof_ipc_process_reply(priv->sdev, 0);
- spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags);
-}
-
-static void mt8195_dsp_handle_request(struct mtk_adsp_ipc *ipc)
-{
- struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc);
- u32 p; /* panic code */
- int ret;
-
- /* Read the message from the debug box. */
- sof_mailbox_read(priv->sdev, priv->sdev->debug_box.offset + 4,
- &p, sizeof(p));
-
- /* Check to see if the message is a panic code 0x0dead*** */
- if ((p & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) {
- snd_sof_dsp_panic(priv->sdev, p, true);
- } else {
- snd_sof_ipc_msgs_rx(priv->sdev);
-
- /* tell DSP cmd is done */
- ret = mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_RSP, MTK_ADSP_IPC_OP_RSP);
- if (ret)
- dev_err(priv->dev, "request send ipc failed");
- }
-}
-
-static struct mtk_adsp_ipc_ops dsp_ops = {
- .handle_reply = mt8195_dsp_handle_reply,
- .handle_request = mt8195_dsp_handle_request,
+static const struct mtk_adsp_ipc_ops dsp_ops = {
+ .handle_reply = mtk_adsp_handle_reply,
+ .handle_request = mtk_adsp_handle_request,
};
static int platform_parse_resource(struct platform_device *pdev, void *data)
@@ -228,7 +183,7 @@ static int mt8195_run(struct snd_sof_dev *sdev)
static int mt8195_dsp_probe(struct snd_sof_dev *sdev)
{
- struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
+ struct platform_device *pdev = to_platform_device(sdev->dev);
struct adsp_priv *priv;
int ret;
@@ -341,7 +296,7 @@ static int mt8195_dsp_shutdown(struct snd_sof_dev *sdev)
static void mt8195_dsp_remove(struct snd_sof_dev *sdev)
{
- struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
+ struct platform_device *pdev = to_platform_device(sdev->dev);
struct adsp_priv *priv = sdev->pdata->hw_pdata;
platform_device_unregister(priv->ipc_dev);
@@ -351,7 +306,7 @@ static void mt8195_dsp_remove(struct snd_sof_dev *sdev)
static int mt8195_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)
{
- struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev);
+ struct platform_device *pdev = to_platform_device(sdev->dev);
int ret;
u32 reset_sw, dbg_pc;
@@ -400,54 +355,6 @@ static int mt8195_dsp_resume(struct snd_sof_dev *sdev)
return ret;
}
-/* on mt8195 there is 1 to 1 match between type and BAR idx */
-static int mt8195_get_bar_index(struct snd_sof_dev *sdev, u32 type)
-{
- return type;
-}
-
-static int mt8195_pcm_hw_params(struct snd_sof_dev *sdev,
- struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_sof_platform_stream_params *platform_params)
-{
- platform_params->cont_update_posn = 1;
-
- return 0;
-}
-
-static snd_pcm_uframes_t mt8195_pcm_pointer(struct snd_sof_dev *sdev,
- struct snd_pcm_substream *substream)
-{
- int ret;
- snd_pcm_uframes_t pos;
- struct snd_sof_pcm *spcm;
- struct sof_ipc_stream_posn posn;
- struct snd_sof_pcm_stream *stream;
- struct snd_soc_component *scomp = sdev->component;
- struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
-
- spcm = snd_sof_find_spcm_dai(scomp, rtd);
- if (!spcm) {
- dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n",
- rtd->dai_link->id);
- return 0;
- }
-
- stream = &spcm->stream[substream->stream];
- ret = snd_sof_ipc_msg_data(sdev, stream, &posn, sizeof(posn));
- if (ret < 0) {
- dev_warn(sdev->dev, "failed to read stream position: %d\n", ret);
- return 0;
- }
-
- memcpy(&stream->posn, &posn, sizeof(posn));
- pos = spcm->stream[substream->stream].posn.host_posn;
- pos = bytes_to_frames(substream->runtime, pos);
-
- return pos;
-}
-
static void mt8195_adsp_dump(struct snd_sof_dev *sdev, u32 flags)
{
u32 dbg_pc, dbg_data, dbg_bus0, dbg_bus1, dbg_inst;
@@ -505,7 +412,7 @@ static struct snd_soc_dai_driver mt8195_dai[] = {
};
/* mt8195 ops */
-static struct snd_sof_dsp_ops sof_mt8195_ops = {
+static const struct snd_sof_dsp_ops sof_mt8195_ops = {
/* probe and remove */
.probe = mt8195_dsp_probe,
.remove = mt8195_dsp_remove,
@@ -529,19 +436,19 @@ static struct snd_sof_dsp_ops sof_mt8195_ops = {
.read64 = sof_io_read64,
/* ipc */
- .send_msg = mt8195_send_msg,
+ .send_msg = mtk_adsp_send_msg,
.get_mailbox_offset = mt8195_get_mailbox_offset,
.get_window_offset = mt8195_get_window_offset,
.ipc_msg_data = sof_ipc_msg_data,
.set_stream_data_offset = sof_set_stream_data_offset,
/* misc */
- .get_bar_index = mt8195_get_bar_index,
+ .get_bar_index = mtk_adsp_get_bar_index,
/* stream callbacks */
.pcm_open = sof_stream_pcm_open,
- .pcm_hw_params = mt8195_pcm_hw_params,
- .pcm_pointer = mt8195_pcm_pointer,
+ .pcm_hw_params = mtk_adsp_stream_pcm_hw_params,
+ .pcm_pointer = mtk_adsp_stream_pcm_pointer,
.pcm_close = sof_stream_pcm_close,
/* firmware loading */
@@ -573,7 +480,10 @@ static struct snd_sof_dsp_ops sof_mt8195_ops = {
static struct snd_sof_of_mach sof_mt8195_machs[] = {
{
.compatible = "google,tomato",
- .sof_tplg_filename = "sof-mt8195-mt6359-rt1019-rt5682-dts.tplg"
+ .sof_tplg_filename = "sof-mt8195-mt6359-rt1019-rt5682.tplg"
+ }, {
+ .compatible = "google,dojo",
+ .sof_tplg_filename = "sof-mt8195-mt6359-max98390-rt5682.tplg"
}, {
.compatible = "mediatek,mt8195",
.sof_tplg_filename = "sof-mt8195.tplg"
@@ -609,16 +519,17 @@ MODULE_DEVICE_TABLE(of, sof_of_mt8195_ids);
/* DT driver definition */
static struct platform_driver snd_sof_of_mt8195_driver = {
.probe = sof_of_probe,
- .remove_new = sof_of_remove,
+ .remove = sof_of_remove,
.shutdown = sof_of_shutdown,
.driver = {
.name = "sof-audio-of-mt8195",
- .pm = &sof_of_pm,
+ .pm = pm_ptr(&sof_of_pm),
.of_match_table = sof_of_mt8195_ids,
},
};
module_platform_driver(snd_sof_of_mt8195_driver);
-MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
-MODULE_IMPORT_NS(SND_SOC_SOF_MTK_COMMON);
MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("SOF support for MTL 8195 platforms");
+MODULE_IMPORT_NS("SND_SOC_SOF_XTENSA");
+MODULE_IMPORT_NS("SND_SOC_SOF_MTK_COMMON");
diff --git a/sound/soc/sof/mediatek/mtk-adsp-common.c b/sound/soc/sof/mediatek/mtk-adsp-common.c
index de8dbe27cd0d..01bbadb160ff 100644
--- a/sound/soc/sof/mediatek/mtk-adsp-common.c
+++ b/sound/soc/sof/mediatek/mtk-adsp-common.c
@@ -12,8 +12,11 @@
*/
#include <linux/module.h>
+#include <sound/asound.h>
#include <sound/sof/xtensa.h>
#include "../ops.h"
+#include "../sof-audio.h"
+#include "adsp_helper.h"
#include "mtk-adsp-common.h"
/**
@@ -81,4 +84,132 @@ void mtk_adsp_dump(struct snd_sof_dev *sdev, u32 flags)
}
EXPORT_SYMBOL(mtk_adsp_dump);
+/**
+ * mtk_adsp_send_msg - Send message to Audio DSP
+ * @sdev: SOF device
+ * @msg: SOF IPC Message to send
+ */
+int mtk_adsp_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
+{
+ struct adsp_priv *priv = sdev->pdata->hw_pdata;
+
+ sof_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
+ msg->msg_size);
+
+ return mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_REQ, MTK_ADSP_IPC_OP_REQ);
+}
+EXPORT_SYMBOL(mtk_adsp_send_msg);
+
+/**
+ * mtk_adsp_handle_reply - Handle reply from the Audio DSP through Mailbox
+ * @ipc: ADSP IPC handle
+ */
+void mtk_adsp_handle_reply(struct mtk_adsp_ipc *ipc)
+{
+ struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc);
+ unsigned long flags;
+
+ spin_lock_irqsave(&priv->sdev->ipc_lock, flags);
+ snd_sof_ipc_process_reply(priv->sdev, 0);
+ spin_unlock_irqrestore(&priv->sdev->ipc_lock, flags);
+}
+EXPORT_SYMBOL(mtk_adsp_handle_reply);
+
+/**
+ * mtk_adsp_handle_request - Handle request from the Audio DSP through Mailbox
+ * @ipc: ADSP IPC handle
+ */
+void mtk_adsp_handle_request(struct mtk_adsp_ipc *ipc)
+{
+ struct adsp_priv *priv = mtk_adsp_ipc_get_data(ipc);
+ u32 panic_code;
+ int ret;
+
+ /* Read the message from the debug box. */
+ sof_mailbox_read(priv->sdev, priv->sdev->debug_box.offset + 4,
+ &panic_code, sizeof(panic_code));
+
+ /* Check to see if the message is a panic code 0x0dead*** */
+ if ((panic_code & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) {
+ snd_sof_dsp_panic(priv->sdev, panic_code, true);
+ } else {
+ snd_sof_ipc_msgs_rx(priv->sdev);
+
+ /* Tell DSP cmd is done */
+ ret = mtk_adsp_ipc_send(priv->dsp_ipc, MTK_ADSP_IPC_RSP, MTK_ADSP_IPC_OP_RSP);
+ if (ret)
+ dev_err(priv->dev, "request send ipc failed");
+ }
+}
+EXPORT_SYMBOL(mtk_adsp_handle_request);
+
+/**
+ * mtk_adsp_get_bar_index - Map section type with BAR idx
+ * @sdev: SOF device
+ * @type: Section type as described by snd_sof_fw_blk_type
+ *
+ * MediaTek Audio DSPs have a 1:1 match between type and BAR idx
+ */
+int mtk_adsp_get_bar_index(struct snd_sof_dev *sdev, u32 type)
+{
+ return type;
+}
+EXPORT_SYMBOL(mtk_adsp_get_bar_index);
+
+/**
+ * mtk_adsp_stream_pcm_hw_params - Platform specific host stream hw params
+ * @sdev: SOF device
+ * @substream: PCM Substream
+ * @params: hw params
+ * @platform_params: Platform specific SOF stream parameters
+ */
+int mtk_adsp_stream_pcm_hw_params(struct snd_sof_dev *sdev,
+ struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_sof_platform_stream_params *platform_params)
+{
+ platform_params->cont_update_posn = 1;
+ return 0;
+}
+EXPORT_SYMBOL(mtk_adsp_stream_pcm_hw_params);
+
+/**
+ * mtk_adsp_stream_pcm_pointer - Get host stream pointer
+ * @sdev: SOF device
+ * @substream: PCM substream
+ */
+snd_pcm_uframes_t mtk_adsp_stream_pcm_pointer(struct snd_sof_dev *sdev,
+ struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
+ struct snd_soc_component *scomp = sdev->component;
+ struct snd_sof_pcm_stream *stream;
+ struct sof_ipc_stream_posn posn;
+ struct snd_sof_pcm *spcm;
+ snd_pcm_uframes_t pos;
+ int ret;
+
+ spcm = snd_sof_find_spcm_dai(scomp, rtd);
+ if (!spcm) {
+ dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n",
+ rtd->dai_link->id);
+ return 0;
+ }
+
+ stream = &spcm->stream[substream->stream];
+ ret = snd_sof_ipc_msg_data(sdev, stream, &posn, sizeof(posn));
+ if (ret < 0) {
+ dev_warn(sdev->dev, "failed to read stream position: %d\n", ret);
+ return 0;
+ }
+
+ memcpy(&stream->posn, &posn, sizeof(posn));
+ pos = spcm->stream[substream->stream].posn.host_posn;
+ pos = bytes_to_frames(substream->runtime, pos);
+
+ return pos;
+}
+EXPORT_SYMBOL(mtk_adsp_stream_pcm_pointer);
+
MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("SOF helpers for MTK ADSP platforms");
diff --git a/sound/soc/sof/mediatek/mtk-adsp-common.h b/sound/soc/sof/mediatek/mtk-adsp-common.h
index 612cff1f38f7..dc36b91d6779 100644
--- a/sound/soc/sof/mediatek/mtk-adsp-common.h
+++ b/sound/soc/sof/mediatek/mtk-adsp-common.h
@@ -7,4 +7,14 @@
#define MTK_ADSP_STACK_DUMP_SIZE 32
void mtk_adsp_dump(struct snd_sof_dev *sdev, u32 flags);
+int mtk_adsp_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
+void mtk_adsp_handle_reply(struct mtk_adsp_ipc *ipc);
+void mtk_adsp_handle_request(struct mtk_adsp_ipc *ipc);
+int mtk_adsp_get_bar_index(struct snd_sof_dev *sdev, u32 type);
+int mtk_adsp_stream_pcm_hw_params(struct snd_sof_dev *sdev,
+ struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_sof_platform_stream_params *platform_params);
+snd_pcm_uframes_t mtk_adsp_stream_pcm_pointer(struct snd_sof_dev *sdev,
+ struct snd_pcm_substream *substream);
#endif