summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorAndy Hu <andy.hu@starfivetech.com>2023-08-31 05:06:00 +0300
committerAndy Hu <andy.hu@starfivetech.com>2023-08-31 05:06:00 +0300
commitc698aee1b2dc0772f4a8ea5f2777b9e5710630d2 (patch)
tree076e91dc5144cc79f24696064026ac844e1449c9 /sound/soc
parent05533e9c31d6f0da20efc2d436a3b0f6d516ed4b (diff)
parent45c6eeaad9c30b4b558b1ad8380332eb257b4884 (diff)
downloadlinux-c698aee1b2dc0772f4a8ea5f2777b9e5710630d2.tar.xz
Merge tag 'JH7110_515_SDK_v5.7.0' into vf2-515-devel
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/starfive/starfive_pwmdac.c52
-rw-r--r--sound/soc/starfive/starfive_tdm.c46
2 files changed, 29 insertions, 69 deletions
diff --git a/sound/soc/starfive/starfive_pwmdac.c b/sound/soc/starfive/starfive_pwmdac.c
index fba58e22d7ef..231bf192590c 100644
--- a/sound/soc/starfive/starfive_pwmdac.c
+++ b/sound/soc/starfive/starfive_pwmdac.c
@@ -495,6 +495,17 @@ static int pwmdac_config(struct sf_pwmdac_dev *dev)
return 0;
}
+static int sf_pwmdac_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *cpu_dai)
+{
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_dai_link *dai_link = rtd->dai_link;
+
+ dai_link->stop_dma_first = 1;
+
+ return 0;
+}
+
static int sf_pwmdac_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -565,10 +576,6 @@ static int sf_pwmdac_hw_params(struct snd_pcm_substream *substream,
int ret = 0;
unsigned long mclk_dac_value;
struct sf_pwmdac_dev *dev = dev_get_drvdata(dai->dev);
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
- struct snd_soc_dai_link *dai_link = rtd->dai_link;
-
- dai_link->stop_dma_first = 1;
dev->play_dma_data.addr = dev->mapbase + PWMDAC_WDATA;
@@ -829,40 +836,15 @@ static int pwmdac_probe(struct snd_soc_component *component)
}
static const struct snd_soc_dai_ops sf_pwmdac_dai_ops = {
- .hw_params = sf_pwmdac_hw_params,
- .prepare = sf_pwmdac_prepare,
- .trigger = sf_pwmdac_trigger,
+ .startup = sf_pwmdac_startup,
+ .hw_params = sf_pwmdac_hw_params,
+ .prepare = sf_pwmdac_prepare,
+ .trigger = sf_pwmdac_trigger,
};
-static int pwmdac_component_trigger(struct snd_soc_component *component,
- struct snd_pcm_substream *substream, int cmd)
-{
- int ret = 0;
- struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
-
- switch (cmd) {
- case SNDRV_PCM_TRIGGER_START:
- case SNDRV_PCM_TRIGGER_RESUME:
- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- break;
-
- case SNDRV_PCM_TRIGGER_STOP:
- case SNDRV_PCM_TRIGGER_SUSPEND:
- case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- axi_dma_cyclic_stop(chan);
- break;
-
- default:
- ret = -EINVAL;
- break;
- }
- return ret;
-}
-
static const struct snd_soc_component_driver sf_pwmdac_component = {
- .name = "starfive-pwmdac",
- .probe = pwmdac_probe,
- .trigger = pwmdac_component_trigger,
+ .name = "starfive-pwmdac",
+ .probe = pwmdac_probe,
};
static struct snd_soc_dai_driver pwmdac_dai = {
diff --git a/sound/soc/starfive/starfive_tdm.c b/sound/soc/starfive/starfive_tdm.c
index 375e266046a2..42d369bc3af3 100644
--- a/sound/soc/starfive/starfive_tdm.c
+++ b/sound/soc/starfive/starfive_tdm.c
@@ -255,42 +255,23 @@ static int sf_tdm_resume(struct snd_soc_component *component)
#define sf_tdm_resume NULL
#endif
-/*
- * To stop dma first, we must implement this function, because it is
- * called before stopping the stream.
- */
-static int sf_pcm_trigger(struct snd_soc_component *component,
- struct snd_pcm_substream *substream, int cmd)
-{
- int ret = 0;
- struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
-
- switch (cmd) {
- case SNDRV_PCM_TRIGGER_START:
- case SNDRV_PCM_TRIGGER_RESUME:
- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- break;
-
- case SNDRV_PCM_TRIGGER_STOP:
- case SNDRV_PCM_TRIGGER_SUSPEND:
- case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- axi_dma_cyclic_stop(chan);
- break;
-
- default:
- ret = -EINVAL;
- break;
- }
- return ret;
-}
-
static const struct snd_soc_component_driver sf_tdm_component = {
.name = "jh7110-tdm",
.suspend = sf_tdm_suspend,
.resume = sf_tdm_resume,
- .trigger = sf_pcm_trigger,
};
+static int sf_tdm_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *cpu_dai)
+{
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+ struct snd_soc_dai_link *dai_link = rtd->dai_link;
+
+ dai_link->stop_dma_first = 1;
+
+ return 0;
+}
+
static int sf_tdm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
@@ -302,10 +283,6 @@ static int sf_tdm_hw_params(struct snd_pcm_substream *substream,
int channels;
int ret;
struct snd_dmaengine_dai_dma_data *dma_data = NULL;
- struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
- struct snd_soc_dai_link *dai_link = rtd->dai_link;
-
- dai_link->stop_dma_first = 1;
channels = params_channels(params);
data_width = params_width(params);
@@ -490,6 +467,7 @@ static int sf_tdm_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
}
static const struct snd_soc_dai_ops sf_tdm_dai_ops = {
+ .startup = sf_tdm_startup,
.hw_params = sf_tdm_hw_params,
.trigger = sf_tdm_trigger,
.set_fmt = sf_tdm_set_fmt,