~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/sof/amd/acp-pcm.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
  2 //
  3 // This file is provided under a dual BSD/GPLv2 license. When using or
  4 // redistributing this file, you may do so under either license.
  5 //
  6 // Copyright(c) 2021 Advanced Micro Devices, Inc.
  7 //
  8 // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
  9 
 10 /*
 11  * PCM interface for generic AMD audio ACP DSP block
 12  */
 13 #include <sound/pcm_params.h>
 14 
 15 #include "../ops.h"
 16 #include "acp.h"
 17 #include "acp-dsp-offset.h"
 18 
 19 int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
 20                       struct snd_pcm_hw_params *params,
 21                       struct snd_sof_platform_stream_params *platform_params)
 22 {
 23         struct snd_pcm_runtime *runtime = substream->runtime;
 24         struct acp_dsp_stream *stream = runtime->private_data;
 25         unsigned int buf_offset, index;
 26         u32 size;
 27         int ret;
 28 
 29         size = runtime->dma_bytes;
 30         stream->num_pages = PFN_UP(runtime->dma_bytes);
 31         stream->dmab = substream->runtime->dma_buffer_p;
 32 
 33         ret = acp_dsp_stream_config(sdev, stream);
 34         if (ret < 0) {
 35                 dev_err(sdev->dev, "stream configuration failed\n");
 36                 return ret;
 37         }
 38 
 39         platform_params->use_phy_address = true;
 40         platform_params->phy_addr = stream->reg_offset;
 41         platform_params->stream_tag = stream->stream_tag;
 42         platform_params->cont_update_posn = 1;
 43 
 44         /* write buffer size of stream in scratch memory */
 45 
 46         buf_offset = sdev->debug_box.offset +
 47                      offsetof(struct scratch_reg_conf, buf_size);
 48         index = stream->stream_tag - 1;
 49         buf_offset = buf_offset + index * 4;
 50 
 51         snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + buf_offset, size);
 52 
 53         return 0;
 54 }
 55 EXPORT_SYMBOL_NS(acp_pcm_hw_params, SND_SOC_SOF_AMD_COMMON);
 56 
 57 int acp_pcm_open(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream)
 58 {
 59         struct acp_dsp_stream *stream;
 60 
 61         stream = acp_dsp_stream_get(sdev, 0);
 62         if (!stream)
 63                 return -ENODEV;
 64 
 65         substream->runtime->private_data = stream;
 66         stream->substream = substream;
 67 
 68         return 0;
 69 }
 70 EXPORT_SYMBOL_NS(acp_pcm_open, SND_SOC_SOF_AMD_COMMON);
 71 
 72 int acp_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream)
 73 {
 74         struct acp_dsp_stream *stream;
 75 
 76         stream = substream->runtime->private_data;
 77         if (!stream) {
 78                 dev_err(sdev->dev, "No open stream\n");
 79                 return -EINVAL;
 80         }
 81 
 82         stream->substream = NULL;
 83         substream->runtime->private_data = NULL;
 84 
 85         return acp_dsp_stream_put(sdev, stream);
 86 }
 87 EXPORT_SYMBOL_NS(acp_pcm_close, SND_SOC_SOF_AMD_COMMON);
 88 
 89 snd_pcm_uframes_t acp_pcm_pointer(struct snd_sof_dev *sdev,
 90                                   struct snd_pcm_substream *substream)
 91 {
 92         struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 93         struct snd_soc_component *scomp = sdev->component;
 94         struct snd_sof_pcm_stream *stream;
 95         struct sof_ipc_stream_posn posn;
 96         struct snd_sof_pcm *spcm;
 97         snd_pcm_uframes_t pos;
 98         int ret;
 99 
100         spcm = snd_sof_find_spcm_dai(scomp, rtd);
101         if (!spcm) {
102                 dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n",
103                                      rtd->dai_link->id);
104                 return 0;
105         }
106 
107         stream = &spcm->stream[substream->stream];
108         ret = snd_sof_ipc_msg_data(sdev, stream, &posn, sizeof(posn));
109         if (ret < 0) {
110                 dev_warn(sdev->dev, "failed to read stream position: %d\n", ret);
111                 return 0;
112         }
113 
114         memcpy(&stream->posn, &posn, sizeof(posn));
115         pos = spcm->stream[substream->stream].posn.host_posn;
116         pos = bytes_to_frames(substream->runtime, pos);
117 
118         return pos;
119 }
120 EXPORT_SYMBOL_NS(acp_pcm_pointer, SND_SOC_SOF_AMD_COMMON);
121 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php