Skip to content
Permalink
Browse files
ASoC: SOF: Make Intel IPC stream ops generic
This operations should be generic as there is nothing Intel
specific. This works well for NXP i.MX8 stream IPC ops.

We start by moving sof/intel/intel-ipc.c into sof/stream-ipc.c and
rename the functions to be generic.

Notice that we use newly introduced snd_sof_dsp_mailbox_read.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Bud Liviu-Alexandru <budliviu@gmail.com>
  • Loading branch information
dbaluta authored and Potochi committed Aug 12, 2021
1 parent 1ef43f2 commit 528e0d295d43df85228b384d839f70d190060f03
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 60 deletions.
@@ -1,9 +1,8 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)

snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\
control.o trace.o utils.o sof-audio.o

snd-sof-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += sof-probes.o
control.o trace.o utils.o sof-audio.o stream-ipc.o
snd-sof-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += probe.o compress.o

snd-sof-pci-objs := sof-pci-dev.o
snd-sof-acpi-objs := sof-acpi-dev.o
@@ -3,8 +3,6 @@
snd-sof-acpi-intel-byt-objs := byt.o
snd-sof-acpi-intel-bdw-objs := bdw.o

snd-sof-intel-ipc-objs := intel-ipc.o

snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-trace.o \
hda-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o \
hda-dai.o hda-bus.o \
@@ -18,7 +16,6 @@ snd-sof-intel-atom-objs := atom.o
obj-$(CONFIG_SND_SOC_SOF_INTEL_ATOM_HIFI_EP) += snd-sof-intel-atom.o
obj-$(CONFIG_SND_SOC_SOF_BAYTRAIL) += snd-sof-acpi-intel-byt.o
obj-$(CONFIG_SND_SOC_SOF_BROADWELL) += snd-sof-acpi-intel-bdw.o
obj-$(CONFIG_SND_SOC_SOF_INTEL_HIFI_EP_IPC) += snd-sof-intel-ipc.o
obj-$(CONFIG_SND_SOC_SOF_HDA_COMMON) += snd-sof-intel-hda-common.o
obj-$(CONFIG_SND_SOC_SOF_HDA) += snd-sof-intel-hda.o

@@ -635,8 +635,8 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = {
.get_mailbox_offset = bdw_get_mailbox_offset,
.get_window_offset = bdw_get_window_offset,

.ipc_msg_data = intel_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params,
.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,

/* machine driver */
.machine_select = bdw_machine_select,
@@ -651,8 +651,8 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = {
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,

/* stream callbacks */
.pcm_open = intel_pcm_open,
.pcm_close = intel_pcm_close,
.pcm_open = sof_stream_pcm_open,
.pcm_close = sof_stream_pcm_close,

/* Module loading */
.load_module = snd_sof_parse_module_memcpy,
@@ -249,8 +249,8 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
.get_mailbox_offset = atom_get_mailbox_offset,
.get_window_offset = atom_get_window_offset,

.ipc_msg_data = intel_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params,
.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,

/* machine driver */
.machine_select = atom_machine_select,
@@ -265,8 +265,8 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,

/* stream callbacks */
.pcm_open = intel_pcm_open,
.pcm_close = intel_pcm_close,
.pcm_open = sof_stream_pcm_open,
.pcm_close = sof_stream_pcm_close,

/* module loading */
.load_module = snd_sof_parse_module_memcpy,
@@ -331,8 +331,8 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
.get_mailbox_offset = atom_get_mailbox_offset,
.get_window_offset = atom_get_window_offset,

.ipc_msg_data = intel_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params,
.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,

/* machine driver */
.machine_select = atom_machine_select,
@@ -347,8 +347,8 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,

/* stream callbacks */
.pcm_open = intel_pcm_open,
.pcm_close = intel_pcm_close,
.pcm_open = sof_stream_pcm_open,
.pcm_close = sof_stream_pcm_close,

/* module loading */
.load_module = snd_sof_parse_module_memcpy,
@@ -166,8 +166,8 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
.get_mailbox_offset = atom_get_mailbox_offset,
.get_window_offset = atom_get_window_offset,

.ipc_msg_data = intel_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params,
.ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = sof_ipc_pcm_params,

/* machine driver */
.machine_select = atom_machine_select,
@@ -182,8 +182,8 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,

/* stream callbacks */
.pcm_open = intel_pcm_open,
.pcm_close = intel_pcm_close,
.pcm_open = sof_stream_pcm_open,
.pcm_close = sof_stream_pcm_close,

/* module loading */
.load_module = snd_sof_parse_module_memcpy,
@@ -603,17 +603,17 @@ int sof_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,

int sof_fw_ready(struct snd_sof_dev *sdev, u32 msg_id);

int intel_ipc_msg_data(struct snd_sof_dev *sdev,
void sof_ipc_msg_data(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
void *p, size_t sz);
int sof_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
void *p, size_t sz);
int intel_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply);

int intel_pcm_open(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);
int intel_pcm_close(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);
const struct sof_ipc_pcm_params_reply *reply);

int sof_stream_pcm_open(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);
int sof_stream_pcm_close(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);

int sof_machine_check(struct snd_sof_dev *sdev);
#endif
@@ -7,7 +7,7 @@
//
// Authors: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>

/* Intel-specific SOF IPC code */
/* Generic SOF IPC stream code */

#include <linux/device.h>
#include <linux/export.h>
@@ -17,39 +17,37 @@
#include <sound/pcm.h>
#include <sound/sof/stream.h>

#include "../ops.h"
#include "../sof-priv.h"
#include "ops.h"
#include "sof-priv.h"

struct intel_stream {
struct sof_stream {
size_t posn_offset;
};

/* Mailbox-based Intel IPC implementation */
int intel_ipc_msg_data(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
void *p, size_t sz)
/* Generic IPC mailbox implementation */
void sof_ipc_msg_data(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
void *p, size_t sz)
{
if (!substream || !sdev->stream_box.size) {
sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
snd_sof_dsp_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
} else {
struct intel_stream *stream = substream->runtime->private_data;
struct sof_stream *stream = substream->runtime->private_data;

/* The stream might already be closed */
if (!stream)
return -ESTRPIPE;

sof_mailbox_read(sdev, stream->posn_offset, p, sz);
if (stream)
snd_sof_dsp_mailbox_read(sdev, stream->posn_offset, p, sz);
}

return 0;
}
EXPORT_SYMBOL_NS(intel_ipc_msg_data, SND_SOC_SOF_INTEL_HIFI_EP_IPC);
EXPORT_SYMBOL(sof_ipc_msg_data);

int intel_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
int sof_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
{
struct intel_stream *stream = substream->runtime->private_data;
struct sof_stream *stream = substream->runtime->private_data;
size_t posn_offset = reply->posn_offset;

/* check if offset is overflow or it is not aligned */
@@ -64,12 +62,12 @@ int intel_ipc_pcm_params(struct snd_sof_dev *sdev,

return 0;
}
EXPORT_SYMBOL_NS(intel_ipc_pcm_params, SND_SOC_SOF_INTEL_HIFI_EP_IPC);
EXPORT_SYMBOL(sof_ipc_pcm_params);

int intel_pcm_open(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream)
int sof_stream_pcm_open(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream)
{
struct intel_stream *stream = kmalloc(sizeof(*stream), GFP_KERNEL);
struct sof_stream *stream = kmalloc(sizeof(*stream), GFP_KERNEL);

if (!stream)
return -ENOMEM;
@@ -86,18 +84,18 @@ int intel_pcm_open(struct snd_sof_dev *sdev,

return 0;
}
EXPORT_SYMBOL_NS(intel_pcm_open, SND_SOC_SOF_INTEL_HIFI_EP_IPC);
EXPORT_SYMBOL(sof_stream_pcm_open);

int intel_pcm_close(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream)
int sof_stream_pcm_close(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream)
{
struct intel_stream *stream = substream->runtime->private_data;
struct sof_stream *stream = substream->runtime->private_data;

substream->runtime->private_data = NULL;
kfree(stream);

return 0;
}
EXPORT_SYMBOL_NS(intel_pcm_close, SND_SOC_SOF_INTEL_HIFI_EP_IPC);
EXPORT_SYMBOL(sof_stream_pcm_close);

MODULE_LICENSE("Dual BSD/GPL");

0 comments on commit 528e0d2

Please sign in to comment.