Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC 20190402 #772

Merged
merged 11 commits into from
Apr 9, 2019
8 changes: 2 additions & 6 deletions sound/soc/sof/hw-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* Memory copy.
*/

static void spi_block_read(struct snd_sof_dev *sdev, u32 bar, u32 offset,
static void spi_block_read(struct snd_sof_dev *sdev, u32 offset,
void *dest, size_t size)
{
u8 *buf;
Expand All @@ -62,7 +62,7 @@ static void spi_block_read(struct snd_sof_dev *sdev, u32 bar, u32 offset,
}
}

static void spi_block_write(struct snd_sof_dev *sdev, u32 bar, u32 offset,
static void spi_block_write(struct snd_sof_dev *sdev, u32 offset,
void *src, size_t size)
{
int ret;
Expand Down Expand Up @@ -280,10 +280,6 @@ const struct snd_sof_dsp_ops snd_sof_spi_ops = {
.irq_handler = spi_irq_handler,
.irq_thread = spi_irq_thread,

/* mailbox */
.mailbox_read = spi_mailbox_read,
.mailbox_write = spi_mailbox_write,

/* ipc */
.send_msg = spi_send_msg,
.fw_ready = spi_fw_ready,
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/intel/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ config SND_SOC_SOF_INTEL_PCI
This option is not user-selectable but automagically handled by
'select' statements at a higher level

config SND_SOC_SOF_INTEL_HIFI_EP_IPC
tristate
help
This option is not user-selectable but automagically handled by
'select' statements at a higher level

config SND_SOC_SOF_INTEL_ATOM_HIFI_EP
tristate
select SND_SOC_INTEL_COMMON
select SND_SOC_SOF_INTEL_HIFI_EP_IPC
help
This option is not user-selectable but automagically handled by
'select' statements at a higher level
Expand Down Expand Up @@ -76,6 +83,7 @@ config SND_SOC_SOF_HASWELL_SUPPORT
config SND_SOC_SOF_HASWELL
tristate
select SND_SOC_SOF_INTEL_COMMON
select SND_SOC_SOF_INTEL_HIFI_EP_IPC
help
This option is not user-selectable but automagically handled by
'select' statements at a higher level
Expand All @@ -91,6 +99,7 @@ config SND_SOC_SOF_BROADWELL_SUPPORT
config SND_SOC_SOF_BROADWELL
tristate
select SND_SOC_SOF_INTEL_COMMON
select SND_SOC_SOF_INTEL_HIFI_EP_IPC
help
This option is not user-selectable but automagically handled by
'select' statements at a higher level
Expand Down
4 changes: 4 additions & 0 deletions sound/soc/sof/intel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ ccflags-y += -DDEBUG
snd-sof-intel-byt-objs := byt.o
snd-sof-intel-hsw-objs := hsw.o
snd-sof-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 hda-loader-skl.o \
Expand All @@ -15,5 +18,6 @@ snd-sof-intel-hda-objs := hda-codec.o
obj-$(CONFIG_SND_SOC_SOF_INTEL_ATOM_HIFI_EP) += snd-sof-intel-byt.o
obj-$(CONFIG_SND_SOC_SOF_HASWELL) += snd-sof-intel-hsw.o
obj-$(CONFIG_SND_SOC_SOF_BROADWELL) += snd-sof-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
7 changes: 3 additions & 4 deletions sound/soc/sof/intel/apl.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ const struct snd_sof_dsp_ops sof_apl_ops = {
.irq_handler = hda_dsp_ipc_irq_handler,
.irq_thread = hda_dsp_ipc_irq_thread,

/* mailbox */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,

/* ipc */
.send_msg = hda_dsp_ipc_send_msg,
.fw_ready = hda_dsp_ipc_fw_ready,

.ipc_msg_data = hda_ipc_msg_data,
.ipc_pcm_params = hda_ipc_pcm_params,

/* debug */
.debug_map = apl_dsp_debugfs,
.debug_map_count = ARRAY_SIZE(apl_dsp_debugfs),
Expand Down
16 changes: 9 additions & 7 deletions sound/soc/sof/intel/bdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,7 @@ static int bdw_fw_ready(struct snd_sof_dev *sdev, u32 msg_id)
return 0;

/* copy data from the DSP FW ready offset */
sof_block_read(sdev, sdev->mmio_bar, offset, fw_ready,
sizeof(*fw_ready));
sof_block_read(sdev, offset, fw_ready, sizeof(*fw_ready));

snd_sof_dsp_mailbox_init(sdev, fw_ready->dspbox_offset,
fw_ready->dspbox_size,
Expand All @@ -459,7 +458,7 @@ static int bdw_fw_ready(struct snd_sof_dev *sdev, u32 msg_id)
return ret;

/* now check for extended data */
snd_sof_fw_parse_ext_data(sdev, sdev->mmio_bar, MBOX_OFFSET +
snd_sof_fw_parse_ext_data(sdev, MBOX_OFFSET +
sizeof(struct sof_ipc_fw_ready));

bdw_get_windows(sdev);
Expand Down Expand Up @@ -666,19 +665,22 @@ const struct snd_sof_dsp_ops sof_bdw_ops = {
.block_read = sof_block_read,
.block_write = sof_block_write,

/* mailbox */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,

/* ipc */
.send_msg = bdw_send_msg,
.fw_ready = bdw_fw_ready,

.ipc_msg_data = intel_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params,

/* debug */
.debug_map = bdw_debugfs,
.debug_map_count = ARRAY_SIZE(bdw_debugfs),
.dbg_dump = bdw_dump,

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

/* Module loading */
.load_module = snd_sof_parse_module_memcpy,

Expand Down
38 changes: 23 additions & 15 deletions sound/soc/sof/intel/byt.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ static int byt_fw_ready(struct snd_sof_dev *sdev, u32 msg_id)
return 0;

/* copy data from the DSP FW ready offset */
sof_block_read(sdev, sdev->mmio_bar, offset, fw_ready,
sizeof(*fw_ready));
sof_block_read(sdev, offset, fw_ready, sizeof(*fw_ready));

snd_sof_dsp_mailbox_init(sdev, fw_ready->dspbox_offset,
fw_ready->dspbox_size,
Expand All @@ -248,7 +247,7 @@ static int byt_fw_ready(struct snd_sof_dev *sdev, u32 msg_id)
return ret;

/* now check for extended data */
snd_sof_fw_parse_ext_data(sdev, sdev->mmio_bar, MBOX_OFFSET +
snd_sof_fw_parse_ext_data(sdev, MBOX_OFFSET +
sizeof(struct sof_ipc_fw_ready));

byt_get_windows(sdev);
Expand Down Expand Up @@ -605,19 +604,22 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
.irq_handler = byt_irq_handler,
.irq_thread = byt_irq_thread,

/* mailbox */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,

/* ipc */
.send_msg = byt_send_msg,
.fw_ready = byt_fw_ready,

.ipc_msg_data = intel_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params,

/* debug */
.debug_map = byt_debugfs,
.debug_map_count = ARRAY_SIZE(byt_debugfs),
.dbg_dump = byt_dump,

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

/* module loading */
.load_module = snd_sof_parse_module_memcpy,

Expand Down Expand Up @@ -764,19 +766,22 @@ const struct snd_sof_dsp_ops sof_byt_ops = {
.irq_handler = byt_irq_handler,
.irq_thread = byt_irq_thread,

/* mailbox */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,

/* ipc */
.send_msg = byt_send_msg,
.fw_ready = byt_fw_ready,

.ipc_msg_data = intel_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params,

/* debug */
.debug_map = byt_debugfs,
.debug_map_count = ARRAY_SIZE(byt_debugfs),
.dbg_dump = byt_dump,

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

/* module loading */
.load_module = snd_sof_parse_module_memcpy,

Expand Down Expand Up @@ -818,19 +823,22 @@ const struct snd_sof_dsp_ops sof_cht_ops = {
.irq_handler = byt_irq_handler,
.irq_thread = byt_irq_thread,

/* mailbox */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,

/* ipc */
.send_msg = byt_send_msg,
.fw_ready = byt_fw_ready,

.ipc_msg_data = intel_ipc_msg_data,
.ipc_pcm_params = intel_ipc_pcm_params,

/* debug */
.debug_map = cht_debugfs,
.debug_map_count = ARRAY_SIZE(cht_debugfs),
.dbg_dump = byt_dump,

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

plbossart marked this conversation as resolved.
Show resolved Hide resolved
/* module loading */
.load_module = snd_sof_parse_module_memcpy,

Expand Down
7 changes: 3 additions & 4 deletions sound/soc/sof/intel/cnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,13 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
.irq_handler = hda_dsp_ipc_irq_handler,
.irq_thread = cnl_ipc_irq_thread,

/* mailbox */
.mailbox_read = sof_mailbox_read,
.mailbox_write = sof_mailbox_write,

/* ipc */
.send_msg = cnl_ipc_send_msg,
.fw_ready = hda_dsp_ipc_fw_ready,

.ipc_msg_data = hda_ipc_msg_data,
.ipc_pcm_params = hda_ipc_pcm_params,

/* debug */
.debug_map = cnl_dsp_debugfs,
.debug_map_count = ARRAY_SIZE(cnl_dsp_debugfs),
Expand Down
52 changes: 48 additions & 4 deletions sound/soc/sof/intel/hda-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,64 @@ int hda_dsp_ipc_fw_ready(struct snd_sof_dev *sdev, u32 msg_id)
return 0;

/* copy data from the DSP FW ready offset */
sof_block_read(sdev, sdev->mmio_bar, offset, fw_ready,
sizeof(*fw_ready));
sof_block_read(sdev, offset, fw_ready, sizeof(*fw_ready));

/* make sure ABI version is compatible */
ret = snd_sof_ipc_valid(sdev);
if (ret < 0)
return ret;

/* now check for extended data */
snd_sof_fw_parse_ext_data(sdev, sdev->mmio_bar,
HDA_DSP_MBOX_UPLINK_OFFSET +
snd_sof_fw_parse_ext_data(sdev, HDA_DSP_MBOX_UPLINK_OFFSET +
sizeof(struct sof_ipc_fw_ready));

ipc_get_windows(sdev);

return 0;
}

void hda_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);
} else {
struct hdac_stream *hstream = substream->runtime->private_data;
struct sof_intel_hda_stream *hda_stream;

hda_stream = container_of(hstream,
struct sof_intel_hda_stream,
hda_stream.hstream);

/* The stream might already be closed */
if (hstream)
sof_mailbox_read(sdev, hda_stream->stream.posn_offset,
p, sz);
}
}

int hda_ipc_pcm_params(struct snd_sof_dev *sdev,
struct snd_pcm_substream *substream,
const struct sof_ipc_pcm_params_reply *reply)
{
struct hdac_stream *hstream = substream->runtime->private_data;
struct sof_intel_hda_stream *hda_stream;
/* validate offset */
size_t posn_offset = reply->posn_offset;

hda_stream = container_of(hstream, struct sof_intel_hda_stream,
hda_stream.hstream);

/* check if offset is overflow or it is not aligned */
if (posn_offset > sdev->stream_box.size ||
posn_offset % sizeof(struct sof_ipc_stream_posn) != 0)
return -EINVAL;

hda_stream->stream.posn_offset = sdev->stream_box.offset + posn_offset;

dev_dbg(sdev->dev, "pcm: stream dir %d, posn mailbox offset is %zu",
substream->stream, hda_stream->stream.posn_offset);

return 0;
}
21 changes: 16 additions & 5 deletions sound/soc/sof/intel/hda-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,15 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev)

/* create capture streams */
for (i = 0; i < num_capture; i++) {
struct sof_intel_hda_stream *hda_stream;

stream = devm_kzalloc(sdev->dev, sizeof(*stream), GFP_KERNEL);
if (!stream)
hda_stream = devm_kzalloc(sdev->dev, sizeof(*hda_stream),
GFP_KERNEL);
if (!hda_stream)
return -ENOMEM;

stream = &hda_stream->hda_stream;

stream->pphc_addr = sdev->bar[HDA_DSP_PP_BAR] +
SOF_HDA_PPHC_BASE + SOF_HDA_PPHC_INTERVAL * i;

Expand Down Expand Up @@ -600,11 +604,15 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev)

/* create playback streams */
for (i = num_capture; i < num_total; i++) {
struct sof_intel_hda_stream *hda_stream;

stream = devm_kzalloc(sdev->dev, sizeof(*stream), GFP_KERNEL);
if (!stream)
hda_stream = devm_kzalloc(sdev->dev, sizeof(*hda_stream),
GFP_KERNEL);
if (!hda_stream)
return -ENOMEM;

stream = &hda_stream->hda_stream;

/* we always have DSP support */
stream->pphc_addr = sdev->bar[HDA_DSP_PP_BAR] +
SOF_HDA_PPHC_BASE + SOF_HDA_PPHC_INTERVAL * i;
Expand Down Expand Up @@ -657,6 +665,7 @@ void hda_dsp_stream_free(struct snd_sof_dev *sdev)
struct hdac_bus *bus = sof_to_bus(sdev);
struct hdac_stream *s, *_s;
struct hdac_ext_stream *stream;
struct sof_intel_hda_stream *hda_stream;

/* free position buffer */
if (bus->posbuf.area)
Expand All @@ -676,6 +685,8 @@ void hda_dsp_stream_free(struct snd_sof_dev *sdev)
snd_dma_free_pages(&s->bdl);
list_del(&s->list);
stream = stream_to_hdac_ext_stream(s);
devm_kfree(sdev->dev, stream);
hda_stream = container_of(stream, struct sof_intel_hda_stream,
hda_stream);
devm_kfree(sdev->dev, hda_stream);
}
}
Loading