Skip to content

Commit 1eb0dcd

Browse files
committed
ASoC: iqaudio-codec: Add mic-only start-up delay
Prior to this change, every stream start was subject to a 1 second delay to allow for the microphone circuitry to settle, even if a microphone is not being used. This blocking delay, as well as being pointless for non- capture applications, can be problematic for synchronous use-cases such as alsa_recover() in PipeWire. Add a dedicated widget to handle the microphone delay, and link it into the microphone routes. See: #7525 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent 7afb7e9 commit 1eb0dcd

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

sound/soc/bcm/iqaudio-codec.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,15 @@ static int snd_rpi_iqaudio_pll_control(struct snd_soc_dapm_widget *w,
5959
return ret;
6060
}
6161

62-
static int snd_rpi_iqaudio_post_dapm_event(struct snd_soc_dapm_widget *w,
63-
struct snd_kcontrol *kcontrol,
64-
int event)
62+
static int snd_rpi_iqaudio_mic_bias_event(struct snd_soc_dapm_widget *w,
63+
struct snd_kcontrol *kcontrol,
64+
int event)
6565
{
66-
switch (event) {
67-
case SND_SOC_DAPM_POST_PMU:
68-
/* Delay for mic bias ramp */
69-
msleep(1000);
70-
break;
71-
default:
72-
break;
73-
}
74-
75-
return 0;
66+
if (event == SND_SOC_DAPM_POST_PMU)
67+
/* Delay for mic bias ramp */
68+
msleep(1000);
69+
70+
return 0;
7671
}
7772

7873
static const struct snd_kcontrol_new dapm_controls[] = {
@@ -90,7 +85,9 @@ static const struct snd_soc_dapm_widget dapm_widgets[] = {
9085
SND_SOC_DAPM_SUPPLY("PLL Control", SND_SOC_NOPM, 0, 0,
9186
snd_rpi_iqaudio_pll_control,
9287
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
93-
SND_SOC_DAPM_POST("Post Power Up Event", snd_rpi_iqaudio_post_dapm_event),
88+
SND_SOC_DAPM_SUPPLY("Mic Bias Ramp", SND_SOC_NOPM, 0, 0,
89+
snd_rpi_iqaudio_mic_bias_event,
90+
SND_SOC_DAPM_POST_PMU),
9491
};
9592

9693
static const struct snd_soc_dapm_route audio_map[] = {
@@ -105,8 +102,10 @@ static const struct snd_soc_dapm_route audio_map[] = {
105102
/* Assume Mic1 is linked to Headset and Mic2 to on-board mic */
106103
{"MIC1", NULL, "MIC Jack"},
107104
{"MIC Jack", NULL, "PLL Control"},
105+
{"MIC Jack", NULL, "Mic Bias Ramp"},
108106
{"MIC2", NULL, "Onboard MIC"},
109107
{"Onboard MIC", NULL, "PLL Control"},
108+
{"Onboard MIC", NULL, "Mic Bias Ramp"},
110109
};
111110

112111
/* machine stream operations */

0 commit comments

Comments
 (0)