0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <sound/pcm_params.h>
0014
0015 #include "../ops.h"
0016 #include "acp.h"
0017 #include "acp-dsp-offset.h"
0018
0019 int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
0020 struct snd_pcm_hw_params *params,
0021 struct snd_sof_platform_stream_params *platform_params)
0022 {
0023 struct snd_pcm_runtime *runtime = substream->runtime;
0024 struct acp_dsp_stream *stream = runtime->private_data;
0025 unsigned int buf_offset, index;
0026 u32 size;
0027 int ret;
0028
0029 size = runtime->dma_bytes;
0030 stream->num_pages = PFN_UP(runtime->dma_bytes);
0031 stream->dmab = substream->runtime->dma_buffer_p;
0032
0033 ret = acp_dsp_stream_config(sdev, stream);
0034 if (ret < 0) {
0035 dev_err(sdev->dev, "stream configuration failed\n");
0036 return ret;
0037 }
0038
0039 platform_params->use_phy_address = true;
0040 platform_params->phy_addr = stream->reg_offset;
0041 platform_params->stream_tag = stream->stream_tag;
0042
0043
0044
0045 buf_offset = offsetof(struct scratch_reg_conf, buf_size);
0046 index = stream->stream_tag - 1;
0047 buf_offset = buf_offset + index * 4;
0048
0049 snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + buf_offset, size);
0050
0051 return 0;
0052 }
0053 EXPORT_SYMBOL_NS(acp_pcm_hw_params, SND_SOC_SOF_AMD_COMMON);
0054
0055 int acp_pcm_open(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream)
0056 {
0057 struct acp_dsp_stream *stream;
0058
0059 stream = acp_dsp_stream_get(sdev, 0);
0060 if (!stream)
0061 return -ENODEV;
0062
0063 substream->runtime->private_data = stream;
0064 stream->substream = substream;
0065
0066 return 0;
0067 }
0068 EXPORT_SYMBOL_NS(acp_pcm_open, SND_SOC_SOF_AMD_COMMON);
0069
0070 int acp_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream)
0071 {
0072 struct acp_dsp_stream *stream;
0073
0074 stream = substream->runtime->private_data;
0075 if (!stream) {
0076 dev_err(sdev->dev, "No open stream\n");
0077 return -EINVAL;
0078 }
0079
0080 stream->substream = NULL;
0081 substream->runtime->private_data = NULL;
0082
0083 return acp_dsp_stream_put(sdev, stream);
0084 }
0085 EXPORT_SYMBOL_NS(acp_pcm_close, SND_SOC_SOF_AMD_COMMON);