From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
To: unlisted-recipients:; (no To-header on input)
Cc: <vijendar.mukunda@amd.com>, <Alexander.Deucher@amd.com>,
<Vishnuvardhanrao.Ravulapati@amd.com>,
Vijendar Mukunda <Vijendar.Mukunda@amd.com>,
Maruthi Bayyavarapu <maruthi.bayyavarapu@amd.com>,
Liam Girdwood <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
MANAGEM..." <alsa-devel@alsa-project.org>,
open list <linux-kernel@vger.kernel.org>
Subject: [PATCH 07/11] ASoC: amd: add acp3x i2s ops
Date: Mon, 12 Nov 2018 11:04:58 +0530 [thread overview]
Message-ID: <1542000903-19020-8-git-send-email-Vijendar.Mukunda@amd.com> (raw)
In-Reply-To: <1542000903-19020-1-git-send-email-Vijendar.Mukunda@amd.com>
ACP3x has a i2s controller block for playback and capture.
This patch adds ACP3x i2s DAI operations.
Signed-off-by: Maruthi Bayyavarapu <maruthi.bayyavarapu@amd.com>
Tested-by: Ravulapati Vishnu vardhan Rao <Vishnuvardhanrao.Ravulapati@amd.com>
Signed-off-by: Vijendar Mukunda <vijendar.mukunda@amd.com>
---
sound/soc/amd/raven/acp3x-pcm-dma.c | 89 +++++++++++++++++++++++++++++++++++--
1 file changed, 86 insertions(+), 3 deletions(-)
diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c
index 06c1985..ed2c163 100644
--- a/sound/soc/amd/raven/acp3x-pcm-dma.c
+++ b/sound/soc/amd/raven/acp3x-pcm-dma.c
@@ -423,10 +423,93 @@ static struct snd_pcm_ops acp3x_dma_ops = {
.mmap = acp3x_dma_mmap,
};
+static int acp3x_dai_i2s_hwparams(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
+{
+ u32 val = 0;
+ struct i2s_stream_instance *rtd = substream->runtime->private_data;
+
+ switch (params_format(params)) {
+ case SNDRV_PCM_FORMAT_U8:
+ case SNDRV_PCM_FORMAT_S8:
+ rtd->xfer_resolution = 0x0;
+ break;
+ case SNDRV_PCM_FORMAT_S16_LE:
+ rtd->xfer_resolution = 0x02;
+ break;
+ case SNDRV_PCM_FORMAT_S24_LE:
+ rtd->xfer_resolution = 0x04;
+ break;
+ case SNDRV_PCM_FORMAT_S32_LE:
+ rtd->xfer_resolution = 0x05;
+ break;
+ default:
+ return -EINVAL;
+ }
+ val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER);
+ val = val | (rtd->xfer_resolution << 3);
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER);
+ else
+ rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER);
+
+ return 0;
+}
+
+static int acp3x_dai_i2s_trigger(struct snd_pcm_substream *substream,
+ int cmd, struct snd_soc_dai *dai)
+{
+ int ret = 0;
+ struct i2s_stream_instance *rtd = substream->runtime->private_data;
+ u32 val, period_bytes;
+
+ period_bytes = frames_to_bytes(substream->runtime,
+ substream->runtime->period_size);
+ switch (cmd) {
+ case SNDRV_PCM_TRIGGER_START:
+ case SNDRV_PCM_TRIGGER_RESUME:
+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ rv_writel(period_bytes, rtd->acp3x_base +
+ mmACP_BT_TX_INTR_WATERMARK_SIZE);
+ val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER);
+ val = val | BIT(0);
+ rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER);
+ } else {
+ rv_writel(period_bytes, rtd->acp3x_base +
+ mmACP_BT_RX_INTR_WATERMARK_SIZE);
+ val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER);
+ val = val | BIT(0);
+ rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER);
+ }
+ rv_writel(1, rtd->acp3x_base + mmACP_BTTDM_IER);
+ break;
+ case SNDRV_PCM_TRIGGER_STOP:
+ case SNDRV_PCM_TRIGGER_SUSPEND:
+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER);
+ val = val & ~BIT(0);
+ rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER);
+ } else {
+ val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER);
+ val = val & ~BIT(0);
+ rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER);
+ }
+ rv_writel(0, rtd->acp3x_base + mmACP_BTTDM_IER);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
struct snd_soc_dai_ops acp3x_dai_i2s_ops = {
- .hw_params = NULL,
- .trigger = NULL,
- .set_fmt = NULL,
+ .hw_params = acp3x_dai_i2s_hwparams,
+ .trigger = acp3x_dai_i2s_trigger,
};
static struct snd_soc_dai_driver acp3x_i2s_dai_driver = {
--
2.7.4
next prev parent reply other threads:[~2018-11-12 5:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1542000903-19020-1-git-send-email-Vijendar.Mukunda@amd.com>
2018-11-12 5:34 ` [PATCH 01/11] ASoC: AMD: add ACP 3.x IP register header Vijendar Mukunda
2018-11-13 19:36 ` Mark Brown
2018-11-14 15:35 ` Mukunda, Vijendar
2018-11-13 19:46 ` Applied "ASoC: AMD: add ACP 3.x IP register header" to the asoc tree Mark Brown
2018-11-12 5:34 ` [PATCH 02/11] ASoC: AMD: add ACP3.0 PCI driver Vijendar Mukunda
2018-11-13 19:46 ` Applied "ASoC: AMD: add ACP3.0 PCI driver" to the asoc tree Mark Brown
2018-11-12 5:34 ` [PATCH 03/11] ASoC: amd: create ACP3x PCM platform device Vijendar Mukunda
2018-11-13 19:46 ` Applied "ASoC: amd: create ACP3x PCM platform device" to the asoc tree Mark Brown
2018-11-12 5:34 ` [PATCH 04/11] ASoC: amd: add ACP3x PCM platform driver Vijendar Mukunda
2018-11-13 19:41 ` Mark Brown
2018-11-13 19:46 ` Applied "ASoC: amd: add ACP3x PCM platform driver" to the asoc tree Mark Brown
2018-11-12 5:34 ` [PATCH 05/11] ASoC: amd: Interrupt handler changes for ACP3x DMA driver Vijendar Mukunda
2018-11-13 19:46 ` Applied "ASoC: amd: Interrupt handler changes for ACP3x DMA driver" to the asoc tree Mark Brown
2018-11-12 5:34 ` [PATCH 06/11] ASoC: amd: add acp3x pcm driver dma ops Vijendar Mukunda
2018-11-13 19:46 ` Applied "ASoC: amd: add acp3x pcm driver dma ops" to the asoc tree Mark Brown
2018-11-12 5:34 ` Vijendar Mukunda [this message]
2018-11-13 19:45 ` Applied "ASoC: amd: add acp3x i2s " Mark Brown
2018-11-12 5:34 ` [PATCH 08/11] ASoC: amd: add acp3x tdm mode support Vijendar Mukunda
2018-11-13 19:45 ` Applied "ASoC: amd: add acp3x tdm mode support" to the asoc tree Mark Brown
2018-11-12 5:35 ` [PATCH 09/11] ASoC: amd: add acp3x runtime pm ops Vijendar Mukunda
2018-11-13 19:45 ` Applied "ASoC: amd: add acp3x runtime pm ops" to the asoc tree Mark Brown
2018-11-12 5:35 ` [PATCH 10/11] ASoC: amd: add acp3x system resume pm op Vijendar Mukunda
2018-11-13 19:45 ` Applied "ASoC: amd: add acp3x system resume pm op" to the asoc tree Mark Brown
2018-11-12 5:35 ` [PATCH 11/11] ASoC: amd: enable acp3x drivers build Vijendar Mukunda
2018-11-13 19:45 ` Mark Brown
2018-11-13 19:45 ` Applied "ASoC: amd: enable acp3x drivers build" to the asoc tree Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1542000903-19020-8-git-send-email-Vijendar.Mukunda@amd.com \
--to=vijendar.mukunda@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Vishnuvardhanrao.Ravulapati@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maruthi.bayyavarapu@amd.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).