mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 05:34:13 +08:00
ASoC: max98357a: use mdelay for sdmode-delay
max98357a_daiops_trigger() is possible to be called in atomic context if
the .nonatomic flag is equal to 0 in the DAI links.
When cancel_delayed_work_sync() in max98357a_daiops_trigger() is called
in atomic context, kernel emits the following message: "BUG: sleeping
function called from invalid context".
According to the DT binding document, value less than or equal to 5ms of
sdmod-delay should be sufficient to avoid the pop noise. Use mdelay
(i.e. busy loop) for such low delay should be acceptable.
Fixes: cec5b01f8f
("ASoC: max98357a: avoid speaker pop when playback
startup")
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20190708141901.68797-1-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
87a6fe80d5
commit
6cd249cfad
@ -20,20 +20,10 @@
|
|||||||
#include <sound/soc-dapm.h>
|
#include <sound/soc-dapm.h>
|
||||||
|
|
||||||
struct max98357a_priv {
|
struct max98357a_priv {
|
||||||
struct delayed_work enable_sdmode_work;
|
|
||||||
struct gpio_desc *sdmode;
|
struct gpio_desc *sdmode;
|
||||||
unsigned int sdmode_delay;
|
unsigned int sdmode_delay;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void max98357a_enable_sdmode_work(struct work_struct *work)
|
|
||||||
{
|
|
||||||
struct max98357a_priv *max98357a =
|
|
||||||
container_of(work, struct max98357a_priv,
|
|
||||||
enable_sdmode_work.work);
|
|
||||||
|
|
||||||
gpiod_set_value(max98357a->sdmode, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
|
static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
|
||||||
int cmd, struct snd_soc_dai *dai)
|
int cmd, struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
@ -46,14 +36,12 @@ static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
|
|||||||
case SNDRV_PCM_TRIGGER_START:
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
case SNDRV_PCM_TRIGGER_RESUME:
|
case SNDRV_PCM_TRIGGER_RESUME:
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||||
queue_delayed_work(system_power_efficient_wq,
|
mdelay(max98357a->sdmode_delay);
|
||||||
&max98357a->enable_sdmode_work,
|
gpiod_set_value(max98357a->sdmode, 1);
|
||||||
msecs_to_jiffies(max98357a->sdmode_delay));
|
|
||||||
break;
|
break;
|
||||||
case SNDRV_PCM_TRIGGER_STOP:
|
case SNDRV_PCM_TRIGGER_STOP:
|
||||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||||
cancel_delayed_work_sync(&max98357a->enable_sdmode_work);
|
|
||||||
gpiod_set_value(max98357a->sdmode, 0);
|
gpiod_set_value(max98357a->sdmode, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -112,30 +100,25 @@ static int max98357a_platform_probe(struct platform_device *pdev)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
max98357a = devm_kzalloc(&pdev->dev, sizeof(*max98357a), GFP_KERNEL);
|
max98357a = devm_kzalloc(&pdev->dev, sizeof(*max98357a), GFP_KERNEL);
|
||||||
|
|
||||||
if (!max98357a)
|
if (!max98357a)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
max98357a->sdmode = devm_gpiod_get_optional(&pdev->dev,
|
max98357a->sdmode = devm_gpiod_get_optional(&pdev->dev,
|
||||||
"sdmode", GPIOD_OUT_LOW);
|
"sdmode", GPIOD_OUT_LOW);
|
||||||
|
|
||||||
if (IS_ERR(max98357a->sdmode))
|
if (IS_ERR(max98357a->sdmode))
|
||||||
return PTR_ERR(max98357a->sdmode);
|
return PTR_ERR(max98357a->sdmode);
|
||||||
|
|
||||||
ret = device_property_read_u32(&pdev->dev, "sdmode-delay",
|
ret = device_property_read_u32(&pdev->dev, "sdmode-delay",
|
||||||
&max98357a->sdmode_delay);
|
&max98357a->sdmode_delay);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
max98357a->sdmode_delay = 0;
|
max98357a->sdmode_delay = 0;
|
||||||
dev_dbg(&pdev->dev,
|
dev_dbg(&pdev->dev,
|
||||||
"no optional property 'sdmode-delay' found, default: no delay\n");
|
"no optional property 'sdmode-delay' found, "
|
||||||
|
"default: no delay\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_set_drvdata(&pdev->dev, max98357a);
|
dev_set_drvdata(&pdev->dev, max98357a);
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&max98357a->enable_sdmode_work,
|
|
||||||
max98357a_enable_sdmode_work);
|
|
||||||
|
|
||||||
return devm_snd_soc_register_component(&pdev->dev,
|
return devm_snd_soc_register_component(&pdev->dev,
|
||||||
&max98357a_component_driver,
|
&max98357a_component_driver,
|
||||||
&max98357a_dai_driver, 1);
|
&max98357a_dai_driver, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user