summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorTzung-Bi Shih <tzungbi@google.com>2020-12-11 13:12:23 +0800
committerMark Brown <broonie@kernel.org>2020-12-11 13:22:18 +0000
commit4ab9301710760b99b4229d608eb5599040b2e07e (patch)
treec7e777951f599ff32767096b106f2d6dbc02c92f /sound
parent3759d5edc07598d55124d87bd292a95f79f47997 (diff)
ASoC: rt1015p: move SDB control from trigger to DAPM
Moves SDB control from DAI ops trigger to DAPM. As long as BCLK and LRCLK are ready, SDB can be toggled earlier. Changes from using gpiod_set_value() to gpiod_set_value_cansleep() because it executes in non-atomic context. Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Link: https://lore.kernel.org/r/20201211051224.2307349-2-tzungbi@google.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/rt1015p.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/sound/soc/codecs/rt1015p.c b/sound/soc/codecs/rt1015p.c
index 59bb60682270..ee9dfa2dbbf0 100644
--- a/sound/soc/codecs/rt1015p.c
+++ b/sound/soc/codecs/rt1015p.c
@@ -19,60 +19,40 @@
struct rt1015p_priv {
struct gpio_desc *sdb;
- int sdb_switch;
};
-static int rt1015p_daiops_trigger(struct snd_pcm_substream *substream,
- int cmd, struct snd_soc_dai *dai)
+static int rt1015p_sdb_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
{
- struct snd_soc_component *component = dai->component;
+ struct snd_soc_component *component =
+ snd_soc_dapm_to_component(w->dapm);
struct rt1015p_priv *rt1015p =
snd_soc_component_get_drvdata(component);
if (!rt1015p->sdb)
return 0;
- switch (cmd) {
- case SNDRV_PCM_TRIGGER_START:
- case SNDRV_PCM_TRIGGER_RESUME:
- case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- if (rt1015p->sdb_switch) {
- gpiod_set_value(rt1015p->sdb, 1);
- dev_dbg(component->dev, "set sdb to 1");
- }
+ switch (event) {
+ case SND_SOC_DAPM_PRE_PMU:
+ gpiod_set_value_cansleep(rt1015p->sdb, 1);
+ dev_dbg(component->dev, "set sdb to 1");
break;
- case SNDRV_PCM_TRIGGER_STOP:
- case SNDRV_PCM_TRIGGER_SUSPEND:
- case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- gpiod_set_value(rt1015p->sdb, 0);
+ case SND_SOC_DAPM_POST_PMD:
+ gpiod_set_value_cansleep(rt1015p->sdb, 0);
dev_dbg(component->dev, "set sdb to 0");
break;
+ default:
+ break;
}
return 0;
}
-static int rt1015p_sdb_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
-{
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
- struct rt1015p_priv *rt1015p =
- snd_soc_component_get_drvdata(component);
-
- if (event & SND_SOC_DAPM_POST_PMU)
- rt1015p->sdb_switch = 1;
- else if (event & SND_SOC_DAPM_POST_PMD)
- rt1015p->sdb_switch = 0;
-
- return 0;
-}
-
static const struct snd_soc_dapm_widget rt1015p_dapm_widgets[] = {
SND_SOC_DAPM_OUTPUT("Speaker"),
SND_SOC_DAPM_OUT_DRV_E("SDB", SND_SOC_NOPM, 0, 0, NULL, 0,
rt1015p_sdb_event,
- SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
};
static const struct snd_soc_dapm_route rt1015p_dapm_routes[] = {
@@ -91,10 +71,6 @@ static const struct snd_soc_component_driver rt1015p_component_driver = {
.non_legacy_dai_naming = 1,
};
-static const struct snd_soc_dai_ops rt1015p_dai_ops = {
- .trigger = rt1015p_daiops_trigger,
-};
-
static struct snd_soc_dai_driver rt1015p_dai_driver = {
.name = "HiFi",
.playback = {
@@ -104,7 +80,6 @@ static struct snd_soc_dai_driver rt1015p_dai_driver = {
.channels_min = 1,
.channels_max = 2,
},
- .ops = &rt1015p_dai_ops,
};
static int rt1015p_platform_probe(struct platform_device *pdev)