Commit 99f11b65 authored by Mark Brown's avatar Mark Brown

Merge series "Introduce new SOF helpers" from Daniel Baluta <daniel.baluta@oss.nxp.com>

Daniel Baluta <daniel.baluta@nxp.com>:

From: Daniel Baluta <daniel.baluta@nxp.com>

This patchseries adds new helpers in order to reduce code duplication
and prepare for compress audio support with SOF.

Bud Liviu-Alexandru (1):
  ASoC: SOF: Make Intel IPC stream ops generic

Daniel Baluta (3):
  ASoC: SOF: Introduce snd_sof_mailbox_read / snd_sof_mailbox_write
    callbacks
  ASoC: SOF: imx: Use newly introduced generic IPC stream ops
  ASoC: SOF: Introduce fragment elapsed notification API

 sound/soc/sof/Kconfig                         |  4 ++
 sound/soc/sof/Makefile                        |  3 +-
 sound/soc/sof/compress.c                      | 51 +++++++++++++++++++
 sound/soc/sof/imx/Kconfig                     |  2 +
 sound/soc/sof/imx/imx8.c                      | 39 +++++++-------
 sound/soc/sof/imx/imx8m.c                     | 26 ++++------
 sound/soc/sof/intel/Makefile                  |  3 --
 sound/soc/sof/intel/apl.c                     |  4 ++
 sound/soc/sof/intel/bdw.c                     | 12 +++--
 sound/soc/sof/intel/byt.c                     | 24 ++++++---
 sound/soc/sof/intel/cnl.c                     |  4 ++
 sound/soc/sof/intel/icl.c                     |  4 ++
 sound/soc/sof/intel/pci-tng.c                 | 12 +++--
 sound/soc/sof/intel/tgl.c                     |  4 ++
 sound/soc/sof/ipc.c                           |  6 ++-
 sound/soc/sof/ops.h                           | 15 ++++++
 sound/soc/sof/pcm.c                           |  7 ++-
 sound/soc/sof/sof-audio.h                     | 11 +++-
 sound/soc/sof/sof-priv.h                      | 28 ++++++----
 .../sof/{intel/intel-ipc.c => stream-ipc.c}   | 50 +++++++++---------
 sound/soc/sof/topology.c                      |  6 ++-
 21 files changed, 218 insertions(+), 97 deletions(-)
 create mode 100644 sound/soc/sof/compress.c
 rename sound/soc/sof/{intel/intel-ipc.c => stream-ipc.c} (58%)

--
2.27.0
parents 1cfd7c2e 858f7a5c
...@@ -46,6 +46,10 @@ config SND_SOC_SOF_OF ...@@ -46,6 +46,10 @@ config SND_SOC_SOF_OF
required to enable i.MX8 devices. required to enable i.MX8 devices.
Say Y if you need this option. If unsure select "N". Say Y if you need this option. If unsure select "N".
config SND_SOC_SOF_COMPRESS
tristate
select SND_SOC_COMPRESS
config SND_SOC_SOF_DEBUG_PROBES config SND_SOC_SOF_DEBUG_PROBES
bool "SOF enable data probing" bool "SOF enable data probing"
select SND_SOC_COMPRESS select SND_SOC_COMPRESS
......
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) # 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\ 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 control.o trace.o utils.o sof-audio.o stream-ipc.o
snd-sof-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += sof-probes.o snd-sof-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += sof-probes.o
snd-sof-$(CONFIG_SND_SOC_SOF_COMPRESS) += compress.o
snd-sof-pci-objs := sof-pci-dev.o snd-sof-pci-objs := sof-pci-dev.o
snd-sof-acpi-objs := sof-acpi-dev.o snd-sof-acpi-objs := sof-acpi-dev.o
......
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
//
// Copyright 2021 NXP
//
// Author: Daniel Baluta <daniel.baluta@nxp.com>
#include <sound/soc.h>
#include <sound/sof.h>
#include <sound/compress_driver.h>
#include "sof-audio.h"
#include "sof-priv.h"
static void snd_sof_compr_fragment_elapsed_work(struct work_struct *work)
{
struct snd_sof_pcm_stream *sps =
container_of(work, struct snd_sof_pcm_stream,
period_elapsed_work);
snd_compr_fragment_elapsed(sps->cstream);
}
void snd_sof_compr_init_elapsed_work(struct work_struct *work)
{
INIT_WORK(work, snd_sof_compr_fragment_elapsed_work);
}
/*
* sof compr fragment elapse, this could be called in irq thread context
*/
void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream)
{
struct snd_soc_component *component;
struct snd_soc_pcm_runtime *rtd;
struct snd_sof_pcm *spcm;
if (!cstream)
return;
rtd = cstream->private_data;
component = snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
spcm = snd_sof_find_spcm_dai(component, rtd);
if (!spcm) {
dev_err(component->dev,
"fragment elapsed called for unknown stream!\n");
return;
}
/* use the same workqueue-based solution as for PCM, cf. snd_sof_pcm_elapsed */
schedule_work(&spcm->stream[cstream->direction].period_elapsed_work);
}
...@@ -38,6 +38,7 @@ config SND_SOC_SOF_IMX8 ...@@ -38,6 +38,7 @@ config SND_SOC_SOF_IMX8
tristate tristate
select SND_SOC_SOF_IMX_COMMON select SND_SOC_SOF_IMX_COMMON
select SND_SOC_SOF_XTENSA select SND_SOC_SOF_XTENSA
select SND_SOC_SOF_COMPRESS
help help
This option is not user-selectable but automagically handled by This option is not user-selectable but automagically handled by
'select' statements at a higher level. 'select' statements at a higher level.
...@@ -54,6 +55,7 @@ config SND_SOC_SOF_IMX8M ...@@ -54,6 +55,7 @@ config SND_SOC_SOF_IMX8M
tristate tristate
select SND_SOC_SOF_IMX_COMMON select SND_SOC_SOF_IMX_COMMON
select SND_SOC_SOF_XTENSA select SND_SOC_SOF_XTENSA
select SND_SOC_SOF_COMPRESS
help help
This option is not user-selectable but automagically handled by This option is not user-selectable but automagically handled by
'select' statements at a higher level. 'select' statements at a higher level.
......
...@@ -369,21 +369,6 @@ static int imx8_get_bar_index(struct snd_sof_dev *sdev, u32 type) ...@@ -369,21 +369,6 @@ static int imx8_get_bar_index(struct snd_sof_dev *sdev, u32 type)
return type; return type;
} }
static int imx8_ipc_msg_data(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
void *p, size_t sz)
{
sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
return 0;
}
static int imx8_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
{
return 0;
}
static struct snd_soc_dai_driver imx8_dai[] = { static struct snd_soc_dai_driver imx8_dai[] = {
{ {
.name = "esai0", .name = "esai0",
...@@ -421,14 +406,18 @@ struct snd_sof_dsp_ops sof_imx8_ops = { ...@@ -421,14 +406,18 @@ struct snd_sof_dsp_ops sof_imx8_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* ipc */ /* ipc */
.send_msg = imx8_send_msg, .send_msg = imx8_send_msg,
.fw_ready = sof_fw_ready, .fw_ready = sof_fw_ready,
.get_mailbox_offset = imx8_get_mailbox_offset, .get_mailbox_offset = imx8_get_mailbox_offset,
.get_window_offset = imx8_get_window_offset, .get_window_offset = imx8_get_window_offset,
.ipc_msg_data = imx8_ipc_msg_data, .ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = imx8_ipc_pcm_params, .ipc_pcm_params = sof_ipc_pcm_params,
/* module loading */ /* module loading */
.load_module = snd_sof_parse_module_memcpy, .load_module = snd_sof_parse_module_memcpy,
...@@ -440,6 +429,10 @@ struct snd_sof_dsp_ops sof_imx8_ops = { ...@@ -440,6 +429,10 @@ struct snd_sof_dsp_ops sof_imx8_ops = {
.dbg_dump = imx8_dump, .dbg_dump = imx8_dump,
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
/* stream callbacks */
.pcm_open = sof_stream_pcm_open,
.pcm_close = sof_stream_pcm_close,
/* Firmware ops */ /* Firmware ops */
.dsp_arch_ops = &sof_xtensa_arch_ops, .dsp_arch_ops = &sof_xtensa_arch_ops,
...@@ -468,14 +461,18 @@ struct snd_sof_dsp_ops sof_imx8x_ops = { ...@@ -468,14 +461,18 @@ struct snd_sof_dsp_ops sof_imx8x_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* ipc */ /* ipc */
.send_msg = imx8_send_msg, .send_msg = imx8_send_msg,
.fw_ready = sof_fw_ready, .fw_ready = sof_fw_ready,
.get_mailbox_offset = imx8_get_mailbox_offset, .get_mailbox_offset = imx8_get_mailbox_offset,
.get_window_offset = imx8_get_window_offset, .get_window_offset = imx8_get_window_offset,
.ipc_msg_data = imx8_ipc_msg_data, .ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = imx8_ipc_pcm_params, .ipc_pcm_params = sof_ipc_pcm_params,
/* module loading */ /* module loading */
.load_module = snd_sof_parse_module_memcpy, .load_module = snd_sof_parse_module_memcpy,
...@@ -487,6 +484,10 @@ struct snd_sof_dsp_ops sof_imx8x_ops = { ...@@ -487,6 +484,10 @@ struct snd_sof_dsp_ops sof_imx8x_ops = {
.dbg_dump = imx8_dump, .dbg_dump = imx8_dump,
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
/* stream callbacks */
.pcm_open = sof_stream_pcm_open,
.pcm_close = sof_stream_pcm_close,
/* Firmware ops */ /* Firmware ops */
.dsp_arch_ops = &sof_xtensa_arch_ops, .dsp_arch_ops = &sof_xtensa_arch_ops,
......
...@@ -232,21 +232,6 @@ static int imx8m_get_bar_index(struct snd_sof_dev *sdev, u32 type) ...@@ -232,21 +232,6 @@ static int imx8m_get_bar_index(struct snd_sof_dev *sdev, u32 type)
return type; return type;
} }
static int imx8m_ipc_msg_data(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
void *p, size_t sz)
{
sof_mailbox_read(sdev, sdev->dsp_box.offset, p, sz);
return 0;
}
static int imx8m_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
{
return 0;
}
static struct snd_soc_dai_driver imx8m_dai[] = { static struct snd_soc_dai_driver imx8m_dai[] = {
{ {
.name = "sai1", .name = "sai1",
...@@ -284,14 +269,18 @@ struct snd_sof_dsp_ops sof_imx8m_ops = { ...@@ -284,14 +269,18 @@ struct snd_sof_dsp_ops sof_imx8m_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* ipc */ /* ipc */
.send_msg = imx8m_send_msg, .send_msg = imx8m_send_msg,
.fw_ready = sof_fw_ready, .fw_ready = sof_fw_ready,
.get_mailbox_offset = imx8m_get_mailbox_offset, .get_mailbox_offset = imx8m_get_mailbox_offset,
.get_window_offset = imx8m_get_window_offset, .get_window_offset = imx8m_get_window_offset,
.ipc_msg_data = imx8m_ipc_msg_data, .ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = imx8m_ipc_pcm_params, .ipc_pcm_params = sof_ipc_pcm_params,
/* module loading */ /* module loading */
.load_module = snd_sof_parse_module_memcpy, .load_module = snd_sof_parse_module_memcpy,
...@@ -303,6 +292,9 @@ struct snd_sof_dsp_ops sof_imx8m_ops = { ...@@ -303,6 +292,9 @@ struct snd_sof_dsp_ops sof_imx8m_ops = {
.dbg_dump = imx8_dump, .dbg_dump = imx8_dump,
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
/* stream callbacks */
.pcm_open = sof_stream_pcm_open,
.pcm_close = sof_stream_pcm_close,
/* Firmware ops */ /* Firmware ops */
.dsp_arch_ops = &sof_xtensa_arch_ops, .dsp_arch_ops = &sof_xtensa_arch_ops,
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
snd-sof-acpi-intel-byt-objs := byt.o snd-sof-acpi-intel-byt-objs := byt.o
snd-sof-acpi-intel-bdw-objs := bdw.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 \ 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-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o \
hda-dai.o hda-bus.o \ hda-dai.o hda-bus.o \
...@@ -18,7 +16,6 @@ snd-sof-intel-atom-objs := atom.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_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_BAYTRAIL) += snd-sof-acpi-intel-byt.o
obj-$(CONFIG_SND_SOC_SOF_BROADWELL) += snd-sof-acpi-intel-bdw.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_COMMON) += snd-sof-intel-hda-common.o
obj-$(CONFIG_SND_SOC_SOF_HDA) += snd-sof-intel-hda.o obj-$(CONFIG_SND_SOC_SOF_HDA) += snd-sof-intel-hda.o
......
...@@ -42,6 +42,10 @@ const struct snd_sof_dsp_ops sof_apl_ops = { ...@@ -42,6 +42,10 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* doorbell */ /* doorbell */
.irq_thread = hda_dsp_ipc_irq_thread, .irq_thread = hda_dsp_ipc_irq_thread,
......
...@@ -616,14 +616,18 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = { ...@@ -616,14 +616,18 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* ipc */ /* ipc */
.send_msg = bdw_send_msg, .send_msg = bdw_send_msg,
.fw_ready = sof_fw_ready, .fw_ready = sof_fw_ready,
.get_mailbox_offset = bdw_get_mailbox_offset, .get_mailbox_offset = bdw_get_mailbox_offset,
.get_window_offset = bdw_get_window_offset, .get_window_offset = bdw_get_window_offset,
.ipc_msg_data = intel_ipc_msg_data, .ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params, .ipc_pcm_params = sof_ipc_pcm_params,
/* machine driver */ /* machine driver */
.machine_select = bdw_machine_select, .machine_select = bdw_machine_select,
...@@ -638,8 +642,8 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = { ...@@ -638,8 +642,8 @@ static const struct snd_sof_dsp_ops sof_bdw_ops = {
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
/* stream callbacks */ /* stream callbacks */
.pcm_open = intel_pcm_open, .pcm_open = sof_stream_pcm_open,
.pcm_close = intel_pcm_close, .pcm_close = sof_stream_pcm_close,
/* Module loading */ /* Module loading */
.load_module = snd_sof_parse_module_memcpy, .load_module = snd_sof_parse_module_memcpy,
......
...@@ -226,6 +226,10 @@ static const struct snd_sof_dsp_ops sof_byt_ops = { ...@@ -226,6 +226,10 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* doorbell */ /* doorbell */
.irq_handler = atom_irq_handler, .irq_handler = atom_irq_handler,
.irq_thread = atom_irq_thread, .irq_thread = atom_irq_thread,
...@@ -236,8 +240,8 @@ static const struct snd_sof_dsp_ops sof_byt_ops = { ...@@ -236,8 +240,8 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
.get_mailbox_offset = atom_get_mailbox_offset, .get_mailbox_offset = atom_get_mailbox_offset,
.get_window_offset = atom_get_window_offset, .get_window_offset = atom_get_window_offset,
.ipc_msg_data = intel_ipc_msg_data, .ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params, .ipc_pcm_params = sof_ipc_pcm_params,
/* machine driver */ /* machine driver */
.machine_select = atom_machine_select, .machine_select = atom_machine_select,
...@@ -252,8 +256,8 @@ static const struct snd_sof_dsp_ops sof_byt_ops = { ...@@ -252,8 +256,8 @@ static const struct snd_sof_dsp_ops sof_byt_ops = {
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
/* stream callbacks */ /* stream callbacks */
.pcm_open = intel_pcm_open, .pcm_open = sof_stream_pcm_open,
.pcm_close = intel_pcm_close, .pcm_close = sof_stream_pcm_close,
/* module loading */ /* module loading */
.load_module = snd_sof_parse_module_memcpy, .load_module = snd_sof_parse_module_memcpy,
...@@ -304,6 +308,10 @@ static const struct snd_sof_dsp_ops sof_cht_ops = { ...@@ -304,6 +308,10 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* doorbell */ /* doorbell */
.irq_handler = atom_irq_handler, .irq_handler = atom_irq_handler,
.irq_thread = atom_irq_thread, .irq_thread = atom_irq_thread,
...@@ -314,8 +322,8 @@ static const struct snd_sof_dsp_ops sof_cht_ops = { ...@@ -314,8 +322,8 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
.get_mailbox_offset = atom_get_mailbox_offset, .get_mailbox_offset = atom_get_mailbox_offset,
.get_window_offset = atom_get_window_offset, .get_window_offset = atom_get_window_offset,
.ipc_msg_data = intel_ipc_msg_data, .ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params, .ipc_pcm_params = sof_ipc_pcm_params,
/* machine driver */ /* machine driver */
.machine_select = atom_machine_select, .machine_select = atom_machine_select,
...@@ -330,8 +338,8 @@ static const struct snd_sof_dsp_ops sof_cht_ops = { ...@@ -330,8 +338,8 @@ static const struct snd_sof_dsp_ops sof_cht_ops = {
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
/* stream callbacks */ /* stream callbacks */
.pcm_open = intel_pcm_open, .pcm_open = sof_stream_pcm_open,
.pcm_close = intel_pcm_close, .pcm_close = sof_stream_pcm_close,
/* module loading */ /* module loading */
.load_module = snd_sof_parse_module_memcpy, .load_module = snd_sof_parse_module_memcpy,
......
...@@ -247,6 +247,10 @@ const struct snd_sof_dsp_ops sof_cnl_ops = { ...@@ -247,6 +247,10 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* doorbell */ /* doorbell */
.irq_thread = cnl_ipc_irq_thread, .irq_thread = cnl_ipc_irq_thread,
......
...@@ -41,6 +41,10 @@ const struct snd_sof_dsp_ops sof_icl_ops = { ...@@ -41,6 +41,10 @@ const struct snd_sof_dsp_ops sof_icl_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* doorbell */ /* doorbell */
.irq_thread = cnl_ipc_irq_thread, .irq_thread = cnl_ipc_irq_thread,
......
...@@ -142,6 +142,10 @@ const struct snd_sof_dsp_ops sof_tng_ops = { ...@@ -142,6 +142,10 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* doorbell */ /* doorbell */
.irq_handler = atom_irq_handler, .irq_handler = atom_irq_handler,
.irq_thread = atom_irq_thread, .irq_thread = atom_irq_thread,
...@@ -152,8 +156,8 @@ const struct snd_sof_dsp_ops sof_tng_ops = { ...@@ -152,8 +156,8 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
.get_mailbox_offset = atom_get_mailbox_offset, .get_mailbox_offset = atom_get_mailbox_offset,
.get_window_offset = atom_get_window_offset, .get_window_offset = atom_get_window_offset,
.ipc_msg_data = intel_ipc_msg_data, .ipc_msg_data = sof_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params, .ipc_pcm_params = sof_ipc_pcm_params,
/* machine driver */ /* machine driver */
.machine_select = atom_machine_select, .machine_select = atom_machine_select,
...@@ -168,8 +172,8 @@ const struct snd_sof_dsp_ops sof_tng_ops = { ...@@ -168,8 +172,8 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
.debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem,
/* stream callbacks */ /* stream callbacks */
.pcm_open = intel_pcm_open, .pcm_open = sof_stream_pcm_open,
.pcm_close = intel_pcm_close, .pcm_close = sof_stream_pcm_close,
/* module loading */ /* module loading */
.load_module = snd_sof_parse_module_memcpy, .load_module = snd_sof_parse_module_memcpy,
......
...@@ -37,6 +37,10 @@ const struct snd_sof_dsp_ops sof_tgl_ops = { ...@@ -37,6 +37,10 @@ const struct snd_sof_dsp_ops sof_tgl_ops = {
.block_read = sof_block_read, .block_read = sof_block_read,
.block_write = sof_block_write, .block_write = sof_block_write,
/* Mailbox IO */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,
/* doorbell */ /* doorbell */
.irq_thread = cnl_ipc_irq_thread, .irq_thread = cnl_ipc_irq_thread,
......
...@@ -545,8 +545,10 @@ static void ipc_period_elapsed(struct snd_sof_dev *sdev, u32 msg_id) ...@@ -545,8 +545,10 @@ static void ipc_period_elapsed(struct snd_sof_dev *sdev, u32 msg_id)
memcpy(&stream->posn, &posn, sizeof(posn)); memcpy(&stream->posn, &posn, sizeof(posn));
/* only inform ALSA for period_wakeup mode */ if (spcm->pcm.compress)
if (!stream->substream->runtime->no_period_wakeup) snd_sof_compr_fragment_elapsed(stream->cstream);
else if (!stream->substream->runtime->no_period_wakeup)
/* only inform ALSA for period_wakeup mode */
snd_sof_pcm_period_elapsed(stream->substream); snd_sof_pcm_period_elapsed(stream->substream);
} }
......
...@@ -312,6 +312,21 @@ static inline int snd_sof_dsp_block_write(struct snd_sof_dev *sdev, ...@@ -312,6 +312,21 @@ static inline int snd_sof_dsp_block_write(struct snd_sof_dev *sdev,
return sof_ops(sdev)->block_write(sdev, blk_type, offset, src, bytes); return sof_ops(sdev)->block_write(sdev, blk_type, offset, src, bytes);
} }
/* mailbox IO */
static inline void snd_sof_dsp_mailbox_read(struct snd_sof_dev *sdev,
u32 offset, void *dest, size_t bytes)
{
if (sof_ops(sdev)->mailbox_read)
sof_ops(sdev)->mailbox_read(sdev, offset, dest, bytes);
}
static inline void snd_sof_dsp_mailbox_write(struct snd_sof_dev *sdev,
u32 offset, void *src, size_t bytes)
{
if (sof_ops(sdev)->mailbox_write)
sof_ops(sdev)->mailbox_write(sdev, offset, src, bytes);
}
/* ipc */ /* ipc */
static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev, static inline int snd_sof_dsp_send_msg(struct snd_sof_dev *sdev,
struct snd_sof_ipc_msg *msg) struct snd_sof_ipc_msg *msg)
......
...@@ -57,7 +57,7 @@ static int sof_pcm_dsp_params(struct snd_sof_pcm *spcm, struct snd_pcm_substream ...@@ -57,7 +57,7 @@ static int sof_pcm_dsp_params(struct snd_sof_pcm *spcm, struct snd_pcm_substream
/* /*
* sof pcm period elapse work * sof pcm period elapse work
*/ */
void snd_sof_pcm_period_elapsed_work(struct work_struct *work) static void snd_sof_pcm_period_elapsed_work(struct work_struct *work)
{ {
struct snd_sof_pcm_stream *sps = struct snd_sof_pcm_stream *sps =
container_of(work, struct snd_sof_pcm_stream, container_of(work, struct snd_sof_pcm_stream,
...@@ -66,6 +66,11 @@ void snd_sof_pcm_period_elapsed_work(struct work_struct *work) ...@@ -66,6 +66,11 @@ void snd_sof_pcm_period_elapsed_work(struct work_struct *work)
snd_pcm_period_elapsed(sps->substream); snd_pcm_period_elapsed(sps->substream);
} }
void snd_sof_pcm_init_elapsed_work(struct work_struct *work)
{
INIT_WORK(work, snd_sof_pcm_period_elapsed_work);
}
/* /*
* sof pcm period elapse, this could be called at irq thread context. * sof pcm period elapse, this could be called at irq thread context.
*/ */
......
...@@ -36,6 +36,7 @@ struct snd_sof_pcm_stream { ...@@ -36,6 +36,7 @@ struct snd_sof_pcm_stream {
struct snd_dma_buffer page_table; struct snd_dma_buffer page_table;
struct sof_ipc_stream_posn posn; struct sof_ipc_stream_posn posn;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
struct snd_compr_stream *cstream;
struct work_struct period_elapsed_work; struct work_struct period_elapsed_work;
struct snd_soc_dapm_widget_list *list; /* list of connected DAPM widgets */ struct snd_soc_dapm_widget_list *list; /* list of connected DAPM widgets */
bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */ bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */
...@@ -231,7 +232,15 @@ struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp, ...@@ -231,7 +232,15 @@ struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp,
const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev, const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
int pipeline_id); int pipeline_id);
void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream); void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream);
void snd_sof_pcm_period_elapsed_work(struct work_struct *work); void snd_sof_pcm_init_elapsed_work(struct work_struct *work);
#if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS)
void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream);
void snd_sof_compr_init_elapsed_work(struct work_struct *work);
#else
static inline void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream) { }
static inline void snd_sof_compr_init_elapsed_work(struct work_struct *work) { }
#endif
/* /*
* Mixer IPC * Mixer IPC
......
...@@ -154,6 +154,14 @@ struct snd_sof_dsp_ops { ...@@ -154,6 +154,14 @@ struct snd_sof_dsp_ops {
enum snd_sof_fw_blk_type type, u32 offset, enum snd_sof_fw_blk_type type, u32 offset,
void *src, size_t size); /* mandatory */ void *src, size_t size); /* mandatory */
/* Mailbox IO */
void (*mailbox_read)(struct snd_sof_dev *sof_dev,
u32 offset, void *dest,
size_t size); /* optional */
void (*mailbox_write)(struct snd_sof_dev *sof_dev,
u32 offset, void *src,
size_t size); /* optional */
/* doorbell */ /* doorbell */
irqreturn_t (*irq_handler)(int irq, void *context); /* optional */ irqreturn_t (*irq_handler)(int irq, void *context); /* optional */
irqreturn_t (*irq_thread)(int irq, void *context); /* optional */ irqreturn_t (*irq_thread)(int irq, void *context); /* optional */
...@@ -592,17 +600,17 @@ int sof_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type, ...@@ -592,17 +600,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 sof_fw_ready(struct snd_sof_dev *sdev, u32 msg_id);
int intel_ipc_msg_data(struct snd_sof_dev *sdev, int 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, struct snd_pcm_substream *substream,
void *p, size_t sz); const struct sof_ipc_pcm_params_reply *reply);
int intel_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream, int sof_stream_pcm_open(struct snd_sof_dev *sdev,
const struct sof_ipc_pcm_params_reply *reply); struct snd_pcm_substream *substream);
int sof_stream_pcm_close(struct snd_sof_dev *sdev,
int intel_pcm_open(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
struct snd_pcm_substream *substream);
int intel_pcm_close(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream);
int sof_machine_check(struct snd_sof_dev *sdev); int sof_machine_check(struct snd_sof_dev *sdev);
#endif #endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// //
// Authors: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> // Authors: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
/* Intel-specific SOF IPC code */ /* Generic SOF IPC code */
#include <linux/device.h> #include <linux/device.h>
#include <linux/export.h> #include <linux/export.h>
...@@ -17,39 +17,39 @@ ...@@ -17,39 +17,39 @@
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/sof/stream.h> #include <sound/sof/stream.h>
#include "../ops.h" #include "ops.h"
#include "../sof-priv.h" #include "sof-priv.h"
struct intel_stream { struct sof_stream {
size_t posn_offset; size_t posn_offset;
}; };
/* Mailbox-based Intel IPC implementation */ /* Mailbox-based Generic IPC implementation */
int intel_ipc_msg_data(struct snd_sof_dev *sdev, int sof_ipc_msg_data(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream, struct snd_pcm_substream *substream,
void *p, size_t sz) void *p, size_t sz)
{ {
if (!substream || !sdev->stream_box.size) { 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 { } else {
struct intel_stream *stream = substream->runtime->private_data; struct sof_stream *stream = substream->runtime->private_data;
/* The stream might already be closed */ /* The stream might already be closed */
if (!stream) if (!stream)
return -ESTRPIPE; return -ESTRPIPE;
sof_mailbox_read(sdev, stream->posn_offset, p, sz); snd_sof_dsp_mailbox_read(sdev, stream->posn_offset, p, sz);
} }
return 0; 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, int sof_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream, struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply) 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; size_t posn_offset = reply->posn_offset;
/* check if offset is overflow or it is not aligned */ /* check if offset is overflow or it is not aligned */
...@@ -64,12 +64,12 @@ int intel_ipc_pcm_params(struct snd_sof_dev *sdev, ...@@ -64,12 +64,12 @@ int intel_ipc_pcm_params(struct snd_sof_dev *sdev,
return 0; 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, int sof_stream_pcm_open(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream) 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) if (!stream)
return -ENOMEM; return -ENOMEM;
...@@ -86,18 +86,18 @@ int intel_pcm_open(struct snd_sof_dev *sdev, ...@@ -86,18 +86,18 @@ int intel_pcm_open(struct snd_sof_dev *sdev,
return 0; 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, int sof_stream_pcm_close(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream) 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; substream->runtime->private_data = NULL;
kfree(stream); kfree(stream);
return 0; 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"); MODULE_LICENSE("Dual BSD/GPL");
...@@ -2601,8 +2601,10 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index, ...@@ -2601,8 +2601,10 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
for_each_pcm_streams(stream) { for_each_pcm_streams(stream) {
spcm->stream[stream].comp_id = COMP_ID_UNASSIGNED; spcm->stream[stream].comp_id = COMP_ID_UNASSIGNED;
INIT_WORK(&spcm->stream[stream].period_elapsed_work, if (pcm->compress)
snd_sof_pcm_period_elapsed_work); snd_sof_compr_init_elapsed_work(&spcm->stream[stream].period_elapsed_work);
else
snd_sof_pcm_init_elapsed_work(&spcm->stream[stream].period_elapsed_work);
} }
spcm->pcm = *pcm; spcm->pcm = *pcm;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment