···2121 select SND_SOC_SOF_PCI_DEV2222 select SND_AMD_ACP_CONFIG2323 select SND_SOC_SOF_XTENSA2424+ select SND_SOC_SOF_ACP_PROBES2425 select SND_SOC_ACPI if ACPI2526 help2627 This option is not user-selectable but automatically handled by···4241 Select this option for SOF support on AMD Rembrandt platform4342 Say Y if you want to enable SOF on Rembrandt.4443 If unsure select "N".4444+4545+config SND_SOC_SOF_ACP_PROBES4646+ tristate4747+ select SND_SOC_SOF_DEBUG_PROBES4848+ help4949+ This option is not user-selectable but automatically handled by5050+ 'select' statements at a higher level45514652endif
+1
sound/soc/sof/amd/Makefile
···55# Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.6677snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o acp-pcm.o acp-stream.o acp-trace.o acp-common.o88+snd-sof-amd-acp-$(CONFIG_SND_SOC_SOF_ACP_PROBES) = acp-probes.o89snd-sof-amd-renoir-objs := pci-rn.o renoir.o910snd-sof-amd-rembrandt-objs := pci-rmb.o rembrandt.o1011
···155155irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context)156156{157157 struct snd_sof_dev *sdev = context;158158+ const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata);159159+ struct acp_dev_data *adata = sdev->pdata->hw_pdata;158160 unsigned int dsp_msg_write = sdev->debug_box.offset +159161 offsetof(struct scratch_ipc_conf, sof_dsp_msg_write);160162 unsigned int dsp_ack_write = sdev->debug_box.offset +···200198 if ((status & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) {201199 snd_sof_dsp_panic(sdev, sdev->dsp_oops_offset, true);202200 return IRQ_HANDLED;201201+ }202202+203203+ if (desc->probe_reg_offset) {204204+ u32 val;205205+ u32 posn;206206+207207+ /* Probe register consists of two parts208208+ * (0-30) bit has cumulative position value209209+ * 31 bit is a synchronization flag between DSP and CPU210210+ * for the position update211211+ */212212+ val = snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->probe_reg_offset);213213+ if (val & PROBE_STATUS_BIT) {214214+ posn = val & ~PROBE_STATUS_BIT;215215+ if (adata->probe_stream) {216216+ /* Probe related posn value is of 31 bits limited to 2GB217217+ * once wrapped DSP won't send posn interrupt.218218+ */219219+ adata->probe_stream->cstream_posn = posn;220220+ snd_compr_fragment_elapsed(adata->probe_stream->cstream);221221+ snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->probe_reg_offset, posn);222222+ ipc_irq = true;223223+ }224224+ }203225 }204226205227 if (!ipc_irq)
+147
sound/soc/sof/amd/acp-probes.c
···11+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)22+//33+// This file is provided under a dual BSD/GPLv2 license. When using or44+// redistributing this file, you may do so under either license.55+//66+// Copyright(c) 2023 Advanced Micro Devices, Inc.77+//88+// Authors: V Sujith Kumar Reddy <Vsujithkumar.Reddy@amd.com>99+1010+/*1111+ * Probe interface for generic AMD audio ACP DSP block1212+ */1313+1414+#include <linux/module.h>1515+#include <sound/soc.h>1616+#include "../sof-priv.h"1717+#include "../sof-client-probes.h"1818+#include "../sof-client.h"1919+#include "../ops.h"2020+#include "acp.h"2121+#include "acp-dsp-offset.h"2222+2323+static int acp_probes_compr_startup(struct sof_client_dev *cdev,2424+ struct snd_compr_stream *cstream,2525+ struct snd_soc_dai *dai, u32 *stream_id)2626+{2727+ struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);2828+ struct acp_dsp_stream *stream;2929+ struct acp_dev_data *adata;3030+3131+ adata = sdev->pdata->hw_pdata;3232+ stream = acp_dsp_stream_get(sdev, 0);3333+ if (!stream)3434+ return -ENODEV;3535+3636+ stream->cstream = cstream;3737+ cstream->runtime->private_data = stream;3838+3939+ adata->probe_stream = stream;4040+ *stream_id = stream->stream_tag;4141+4242+ return 0;4343+}4444+4545+static int acp_probes_compr_shutdown(struct sof_client_dev *cdev,4646+ struct snd_compr_stream *cstream,4747+ struct snd_soc_dai *dai)4848+{4949+ struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);5050+ struct acp_dsp_stream *stream = cstream->runtime->private_data;5151+ struct acp_dev_data *adata;5252+ int ret;5353+5454+ ret = acp_dsp_stream_put(sdev, stream);5555+ if (ret < 0) {5656+ dev_err(sdev->dev, "Failed to release probe compress stream\n");5757+ return ret;5858+ }5959+6060+ adata = sdev->pdata->hw_pdata;6161+ stream->cstream = NULL;6262+ cstream->runtime->private_data = NULL;6363+ adata->probe_stream = NULL;6464+6565+ return 0;6666+}6767+6868+static int acp_probes_compr_set_params(struct sof_client_dev *cdev,6969+ struct snd_compr_stream *cstream,7070+ struct snd_compr_params *params,7171+ struct snd_soc_dai *dai)7272+{7373+ struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);7474+ struct acp_dsp_stream *stream = cstream->runtime->private_data;7575+ unsigned int buf_offset, index;7676+ u32 size;7777+ int ret;7878+7979+ stream->dmab = cstream->runtime->dma_buffer_p;8080+ stream->num_pages = PFN_UP(cstream->runtime->dma_bytes);8181+ size = cstream->runtime->buffer_size;8282+8383+ ret = acp_dsp_stream_config(sdev, stream);8484+ if (ret < 0) {8585+ acp_dsp_stream_put(sdev, stream);8686+ return ret;8787+ }8888+8989+ /* write buffer size of stream in scratch memory */9090+9191+ buf_offset = sdev->debug_box.offset +9292+ offsetof(struct scratch_reg_conf, buf_size);9393+ index = stream->stream_tag - 1;9494+ buf_offset = buf_offset + index * 4;9595+9696+ snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + buf_offset, size);9797+9898+ return 0;9999+}100100+101101+static int acp_probes_compr_trigger(struct sof_client_dev *cdev,102102+ struct snd_compr_stream *cstream,103103+ int cmd, struct snd_soc_dai *dai)104104+{105105+ /* Nothing to do here, as it is a mandatory callback just defined */106106+ return 0;107107+}108108+109109+static int acp_probes_compr_pointer(struct sof_client_dev *cdev,110110+ struct snd_compr_stream *cstream,111111+ struct snd_compr_tstamp *tstamp,112112+ struct snd_soc_dai *dai)113113+{114114+ struct acp_dsp_stream *stream = cstream->runtime->private_data;115115+ struct snd_soc_pcm_stream *pstream;116116+117117+ pstream = &dai->driver->capture;118118+ tstamp->copied_total = stream->cstream_posn;119119+ tstamp->sampling_rate = snd_pcm_rate_bit_to_rate(pstream->rates);120120+121121+ return 0;122122+}123123+124124+/* SOF client implementation */125125+static const struct sof_probes_host_ops acp_probes_ops = {126126+ .startup = acp_probes_compr_startup,127127+ .shutdown = acp_probes_compr_shutdown,128128+ .set_params = acp_probes_compr_set_params,129129+ .trigger = acp_probes_compr_trigger,130130+ .pointer = acp_probes_compr_pointer,131131+};132132+133133+int acp_probes_register(struct snd_sof_dev *sdev)134134+{135135+ return sof_client_dev_register(sdev, "acp-probes", 0, &acp_probes_ops,136136+ sizeof(acp_probes_ops));137137+}138138+EXPORT_SYMBOL_NS(acp_probes_register, SND_SOC_SOF_AMD_COMMON);139139+140140+void acp_probes_unregister(struct snd_sof_dev *sdev)141141+{142142+ sof_client_dev_unregister(sdev, "acp-probes", 0);143143+}144144+EXPORT_SYMBOL_NS(acp_probes_unregister, SND_SOC_SOF_AMD_COMMON);145145+146146+MODULE_IMPORT_NS(SND_SOC_SOF_CLIENT);147147+