Skip to content

[BUG][ADL]: maxim 98373 speaker pop sound when switching audio output device #6379

Closed

Description

@macchian

Describe the bug
98373 speaker pop sound occurred on upstream adl-004-drop-stable and main branch as well.

experiment:

  1. bypass all smart amp DSM, lib module and binary.
  2. moving FE SSP stop sequence before BE amp shutdown.

both still have pop sound.

To Reproduce

  1. plug in headset
  2. playing music on Youtube.com.
  3. switching audio devices by CRAS UI
  4. speaker pop suddenly when switching audio routing path back to speaker.

Reproduction Rate
100%

Expected behavior
no pop sound.

Environment

  1. Branch name and commit hash of the 2 repositories: sof (firmware/topology) and linux (kernel driver).

    • Kernel: 5.10
    • SOF: upstream adl-004-drop-stable, main branch
  2. Name of the topology file

    • Topology: sof-adl-max98373-nau8825.tplg
  3. Name of the platform(s) on which the bug is observed.

    • Platform: ADL

Screenshots or console output
attachment. kernel logs. sof-logger trace logs.

  1. 300Hz pop noise capture
  2. trace logs
  3. dmesg
  4. pop noise.wav

Activity

  1. added
    bugSomething isn't working as expected
    on Oct 7, 2022
  2. macchian commented on Oct 7, 2022

    @macchian
    ContributorAuthor
  3. added
    ADLApplies to Alder Lake platform
    P1Blocker bugs or important features
    on Oct 7, 2022
  4. macchian commented on Oct 7, 2022

    @macchian
    ContributorAuthor
  5. macchian commented on Oct 7, 2022

    @macchian
    ContributorAuthor

    RanderWang, need your advices.

  6. macchian commented on Oct 11, 2022

    @macchian
    ContributorAuthor

    @lgirdwood, @mwasko, pop also be reproduced on main branch, any comments?

  7. plbossart commented on Oct 12, 2022

    @plbossart
    Member

    @macchian your dmesg log seems wrong, it contains major errors:

    [    5.034902] sof-audio-pci-intel-tgl 0000:00:1f.3: error: ipc error for 0x30010000 size 20
    [    5.034907] sof-audio-pci-intel-tgl 0000:00:1f.3: error: failed to load widget CODEC_ADAPTER1.0
    [    5.035022] sof-audio-pci-intel-tgl 0000:00:1f.3: error: tplg component load failed -22
    [    5.035031] sof-audio-pci-intel-tgl 0000:00:1f.3: error: failed to load DSP topology -22
    [    5.035034] sof-audio-pci-intel-tgl 0000:00:1f.3: ASoC: error at snd_soc_component_probe on 0000:00:1f.3: -22
    [    5.035060] sof_nau8825 adl_max98373_nau8825: ASoC: failed to instantiate card -22
    [    5.035140] sof_nau8825: probe of adl_max98373_nau8825 failed with error -22
    
  8. plbossart commented on Oct 12, 2022

    @plbossart
    Member

    @macchian we need to experiment with simpler setups at the hw: device level, i.e. without CRAS in the picture

    Suggestions:
    a) play on headset, stop 10s, play on amp, and check if there is any pop.
    b) play on the amp while playing on the headset
    c) try to play on the headset, wait 500ms and play on the amp with a script to simulate a switch.

  9. macchian commented on Oct 13, 2022

    @macchian
    ContributorAuthor

    a) play on headset, stop 10s, play on amp, and check if there is any pop.

    my bad... wrong file. reattached the correct one.
    dmesg_pop.txt

  10. macchian commented on Oct 13, 2022

    @macchian
    ContributorAuthor

    @macchian we need to experiment with simpler setups at the hw: device level, i.e. without CRAS in the picture

    Suggestions: a) play on headset, stop 10s, play on amp, and check if there is any pop. b) play on the amp while playing on the headset c) try to play on the headset, wait 500ms and play on the amp with a script to simulate a switch.

    @plbossart Thanks for your advices! As you mentioned, I write a script spk_switch_on_off.sh and gen a 1k_sine_48k_16bits_60s.wav
    1k_sine_48k_16bits_60s.zip

    spk_switch_on_off.zip

    The script is playing 1k sine wav in background and every 500ms switching speaker(-D hw:0,0) to headphone (-D hw:0,1) repeatedly.

    Summarize test result below:

    a) play on headset, stop 10s, play on amp, and check if there is any pop.

    • Speaker still has pop but not every time.

    b) play on the amp while playing on the headset
    c) try to play on the headset, wait 500ms and play on the amp with a script to simulate a switch.

    • Speaker and headphone have pop during every on/off switching.
  11. mengdonglin commented on Oct 14, 2022

    @mengdonglin
    Collaborator

    @macchian It's not likely to be SOF FW or driver issue, as the firmware and driver are not really involved in switching endpoints. It's more likely to be a codec or machine driver or UCM issue.

  12. 16 remaining items

  13. bardliao commented on Oct 27, 2022

    @bardliao
    Collaborator

    BTW, If someone can probe the I2S pins physically with a logic analyzer to get the audio data from I2S pins directly, it would be
    a better way to clarify where is the pop from.

  14. bardliao commented on Oct 27, 2022

    @bardliao
    Collaborator

    I can hear pop noise when speaker playback starts AND stops. And I also hear obvious pop noise when headphone playback stops.
    The test wav is 1K_0dB.zip

  15. ujfalusi commented on Oct 27, 2022

    @ujfalusi
    Contributor

    @bardliao, can you isolate the pop with dapm_pop_time of 2 seconds?
    Does the codec have Mute switch on headset, speaker? Does toggling it produces pop noise as well?

  16. bardliao commented on Oct 28, 2022

    @bardliao
    Collaborator

    @ujfalusi @lgirdwood @macchian I am pretty sure the pop is from the codec itself after doing some experiment.
    There are two speaker codecs (left and right) in the device.
    And a pop is generated when a speaker is started and stopped. That's why we can hear two pops when speaker playback starts and two pops when speaker playback stops.
    If I set dapm_pop_time = 2sec, there are some "da" "da" sound in the transition stage.
    Below is the dmesg tested with dapm_pop_time = 2000, I added some empty line when I hear pop.

    [Apr22 14:02] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 2000ms
    [  +2.028752] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 2000ms
    [  +2.050928] max98373 i2c-MX98373:00: pop test : Queue Right HiFi Playback: reg=0xffffffff, 0x0/0x0
    [  +0.000046] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue Smart Amplifier Playback 0: reg=0xffffffff, 0x0/0x0
    [  +0.000023] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue PCM0P: reg=0xffffffff, 0x1/0x0
    [  +0.000020] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue SSP1.OUT: reg=0xffffffff, 0x1/0x0
    [  +0.000022] max98373 i2c-MX98373:00: pop test : Queue Right BE_OUT: reg=0xffffffff, 0x0/0x0
    [  +0.000022] max98373 i2c-MX98373:00: pop test : Queue Right DAI Sel Mux: reg=0xffffffff, 0x1/0x1
    [  +0.000020] max98373 i2c-MX98373:00: pop test : Queue Right Amp Enable: reg=0x202b, 0x1/0x1
    [  +0.000021] max98373 i2c-MX98373:00: pop test : Applying 0x1/0x1 to 202b in 2000ms
    [  +2.057783] max98373 i2c-MX98373:00: pop test : Right Amp Enable POST_PMU
    [  +0.032544] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue BUF1.0: reg=0xffffffff, 0x1/0x0
    [  +0.000025] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue SMART_AMP1.0: reg=0xffffffff, 0x1/0x0
    [  +0.000010] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue BUF1.1: reg=0xffffffff, 0x1/0x0
    [  +0.000015] sof_nau8825 adl_max98373_nau8825: pop test : Queue Right Spk: reg=0xffffffff, 0x0/0x0
    [  +0.000203] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 2000ms
    
    
    
    
    
    [  +2.002763] max98373 i2c-MX98373:01: pop test : Queue Left HiFi Playback: reg=0xffffffff, 0x0/0x0
    [  +0.000027] max98373 i2c-MX98373:01: pop test : Queue Left BE_OUT: reg=0xffffffff, 0x0/0x0
    [  +0.000011] max98373 i2c-MX98373:01: pop test : Queue Left DAI Sel Mux: reg=0xffffffff, 0x1/0x1
    [  +0.000012] max98373 i2c-MX98373:01: pop test : Queue Left Amp Enable: reg=0x202b, 0x1/0x1
    [  +0.000012] max98373 i2c-MX98373:01: pop test : Applying 0x1/0x1 to 202b in 2000ms
    [  +2.060351] max98373 i2c-MX98373:01: pop test : Left Amp Enable POST_PMU
    [  +0.032063] sof_nau8825 adl_max98373_nau8825: pop test : Queue Left Spk: reg=0xffffffff, 0x0/0x0
    [  +0.000335] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 2000ms
    
    
    
    
    
    [  +5.758428] sof_nau8825 adl_max98373_nau8825: pop test : Queue Right Spk: reg=0xffffffff, 0x0/0x0
    [  +0.000030] max98373 i2c-MX98373:00: pop test : Queue Right Amp Enable: reg=0x202b, 0x0/0x1
    [  +0.000012] max98373 i2c-MX98373:00: pop test : Applying 0x0/0x1 to 202b in 2000ms
    
    
    
    
    
    [  +2.017122] max98373 i2c-MX98373:00: pop test : Right Amp Enable POST_PMD
    [  +0.032060] max98373 i2c-MX98373:00: pop test : Queue Right BE_OUT: reg=0xffffffff, 0x0/0x0
    [  +0.000027] max98373 i2c-MX98373:00: pop test : Queue Right DAI Sel Mux: reg=0xffffffff, 0x0/0x1
    [  +0.000010] max98373 i2c-MX98373:00: pop test : Queue Right HiFi Playback: reg=0xffffffff, 0x0/0x0
    [  +0.000280] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 2000ms
    [  +2.004029] sof_nau8825 adl_max98373_nau8825: pop test : Queue Left Spk: reg=0xffffffff, 0x0/0x0
    [  +0.000028] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue BUF1.0: reg=0xffffffff, 0x0/0x0
    [  +0.000009] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue SMART_AMP1.0: reg=0xffffffff, 0x0/0x0
    [  +0.000009] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue BUF1.1: reg=0xffffffff, 0x0/0x0
    [  +0.000014] max98373 i2c-MX98373:01: pop test : Queue Left Amp Enable: reg=0x202b, 0x0/0x1
    [  +0.000010] max98373 i2c-MX98373:01: pop test : Applying 0x0/0x1 to 202b in 2000ms
    [  +2.059528] max98373 i2c-MX98373:01: pop test : Left Amp Enable POST_PMD
    [  +0.032118] max98373 i2c-MX98373:01: pop test : Queue Left BE_OUT: reg=0xffffffff, 0x0/0x0
    [  +0.000025] max98373 i2c-MX98373:01: pop test : Queue Left DAI Sel Mux: reg=0xffffffff, 0x0/0x1
    [  +0.000010] max98373 i2c-MX98373:01: pop test : Queue Left HiFi Playback: reg=0xffffffff, 0x0/0x0
    [  +0.000012] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue Smart Amplifier Playback 0: reg=0xffffffff, 0x0/0x0
    [  +0.000008] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue PCM0P: reg=0xffffffff, 0x0/0x0
    [  +0.000008] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue SSP1.OUT: reg=0xffffffff, 0x0/0x0
    [  +0.000267] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 2000ms
    
    
    [  +2.006744] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 2000ms
    

    There is no single mute switch for speaker, but we have "Spk Switch" that can enable/disable Speakers.
    controls.txt
    And I can hear the pop when I set amixer -c0 cset name='Left Spk Switch' 0 and amixer -c0 cset name='Left Spk Switch' 1 during playback is running.
    However, there is no "da" "da" noise when I switch "Spk Switch" on or off.
    Below is the dmesg when I switch 'Left Spk Switch'.

    [  +9.274429] max98373 i2c-MX98373:01: pop test : Queue Left HiFi Playback: reg=0xffffffff, 0x0/0x0
    [  +0.000028] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue Smart Amplifier Playback 0: reg=0xffffffff, 0x0/0x0
    [  +0.000009] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue PCM0P: reg=0xffffffff, 0x1/0x0
    [  +0.000007] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue SSP1.OUT: reg=0xffffffff, 0x1/0x0
    [  +0.000009] max98373 i2c-MX98373:01: pop test : Queue Left BE_OUT: reg=0xffffffff, 0x0/0x0
    [  +0.000008] max98373 i2c-MX98373:01: pop test : Queue Left DAI Sel Mux: reg=0xffffffff, 0x1/0x1
    [  +0.000008] max98373 i2c-MX98373:01: pop test : Queue Left Amp Enable: reg=0x202b, 0x1/0x1
    [  +0.000008] max98373 i2c-MX98373:01: pop test : Applying 0x1/0x1 to 202b in 1000ms
    [  +1.060734] max98373 i2c-MX98373:01: pop test : Left Amp Enable POST_PMU
    [  +0.032465] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue BUF1.0: reg=0xffffffff, 0x1/0x0
    [  +0.000026] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue SMART_AMP1.0: reg=0xffffffff, 0x1/0x0
    [  +0.000009] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue BUF1.1: reg=0xffffffff, 0x1/0x0
    [  +0.000014] sof_nau8825 adl_max98373_nau8825: pop test : Queue Left Spk: reg=0xffffffff, 0x0/0x0
    [  +0.000278] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 1000ms
    
    
    
    
    
    [  +9.379184] sof_nau8825 adl_max98373_nau8825: pop test : Queue Left Spk: reg=0xffffffff, 0x0/0x0
    [  +0.000012] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue BUF1.0: reg=0xffffffff, 0x0/0x0
    [  +0.000001] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue SMART_AMP1.0: reg=0xffffffff, 0x0/0x0
    [  +0.000002] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue BUF1.1: reg=0xffffffff, 0x0/0x0
    [  +0.000002] max98373 i2c-MX98373:01: pop test : Queue Left Amp Enable: reg=0x202b, 0x0/0x1
    [  +0.000002] max98373 i2c-MX98373:01: pop test : Applying 0x0/0x1 to 202b in 1000ms
    [  +1.020111] max98373 i2c-MX98373:01: pop test : Left Amp Enable POST_PMD
    [  +0.032485] max98373 i2c-MX98373:01: pop test : Queue Left BE_OUT: reg=0xffffffff, 0x0/0x0
    [  +0.000043] max98373 i2c-MX98373:01: pop test : Queue Left DAI Sel Mux: reg=0xffffffff, 0x0/0x1
    [  +0.000022] max98373 i2c-MX98373:01: pop test : Queue Left HiFi Playback: reg=0xffffffff, 0x0/0x0
    [  +0.000027] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue Smart Amplifier Playback 0: reg=0xffffffff, 0x0/0x0
    [  +0.000017] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue PCM0P: reg=0xffffffff, 0x0/0x0
    [  +0.000017] sof-audio-pci-intel-tgl 0000:00:1f.3: pop test : Queue SSP1.OUT: reg=0xffffffff, 0x0/0x0
    [  +0.000267] sof_nau8825 adl_max98373_nau8825: DAPM sequencing finished, waiting 1000ms
    

    Intel Audio DSP doesn't know user is switching the "Spk Switch", so, the audio data is consistent.
    It implies that the pop is generated when the codec is doing the enabling/disabling process.
    Like
    Queue Left Amp Enable: reg=0x202b, 0x1/0x1
    Queue Left Amp Enable: reg=0x202b, 0x0/0x1

  17. bardliao commented on Oct 28, 2022

    @bardliao
    Collaborator

    Hi @mengdonglin , From Maxim's debugging results, it looks like not relevant to codec or DSM issue. Because the experiments below still hear the pop sound. There is 300Hz signal producing. (see attachment file pop picture) Is it a possible way by eq-iir reducing it?

    Currently it reproduces on TGL and ADL/RPL, I believe MTL should as well. Could you suggest further method to fix it?

    Maxim's test:

    1. bypass DSM algo, the pop still occurs.
    2. Keep the codec amp pin power always On , the pop exists.

    @macchian Do you know if they do anything to prevent the codec driver from accessing the codec registers?
    For example, let regcache_cache_only be always true, or use the dummy codec driver instead of max98373 codec driver.
    If they didn't do that, the codec driver will still act as usual, and it didn't prove the pop is not from the enabling/disabling process.

    1. I also modified the FE SSP stop sequence before BE amp shutdown.
      The sequence ensures the i2s data stop before codec amp shutdown. In this case, pop can hear.
  18. macchian commented on Nov 2, 2022

    @macchian
    ContributorAuthor

    Hi all,
    As per working with @bardliao and @ryans-lee from Maxim, I summarize the pop test results below:

    1. Make ‘Digital Volume’ mute and test if it generates the same amount of noise.
    • Pop sound level is following by ‘Digital Volume’ boost/attenuate [Confirmed]
    • I2S signal scope need ODM rework I2S. Jonathan. [TBD]
    1. Manually turn on/off 0x20FF(Global en) register while playing silent music and check the noise level. This amount of noise is how much we can expect from the amp.
    • During playing by aplay -D hw:0,0 -f dat 1k.wav,
      a. turn off left Spk global_en first
      #echo 0 0x20FF > /sys/kernel/debug/regmap/i2c-MX98373:01 (One pop sound)
      b. then turn off right Spk global_en
      #echo 0 0x20ff > /sys/kernel/debug/regmap/i2c-MX98373:00 (One pop sound)
      c. turn on right spk global_en again
      #echo 1 0x20ff > /sys/kernel/debug/regmap/i2c-MX98373:00 (speaker sound not resume sound when set global_en on)
      So in this case, I only observe pop when running right spk global_en off.
    1. Make the 0x202B always ON and do the same test in 2).
    • Applied the codes from Bard.
      Pop occurs:
      1 pop occurs when aplay starting, 2 pop occur when aplay stopped. [Confirmed]

    static const struct snd_soc_dapm_widget max98373_dapm_widgets[] = {
    SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback",
    ─ MAX98373_R202B_PCM_RX_EN, 0, 0, max98373_dac_event,
    ┼ SND_SOC_NOPM, 0, 0, max98373_dac_event,
    SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD |
    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),

    static int max98373_probe(struct snd_soc_component *component)
    MAX98373_R2043_AMP_EN,
    MAX98373_SPK_EN_MASK, 1);
    ─
    ┼ regmap_write(max98373->regmap, MAX98373_R202B_PCM_RX_EN, 0x1);

    1. Switch ‘Digital Volume’during playing 1k sine
    • During aplay -D hw:0,0 -f dat 1k.wav, switch Speaker Digital Volume from 0 to 100 repeatedly. No pop. Confirmed by Bard and Mac.
    1. Switch ‘Spk Switch’ during playing 1k sine
    • During aplay -D hw:0,0 -f dat 1k.wav, switch ‘Left/Right Spk Switch’ repeatedly, 1 pop occurs from aplay starting and 2 pops from aplay stopped. Confirmed by Bard and Mac.
    1. Play silence.wav and stop
    • No pop from aplay starting and stopped. [Confirmed]
  19. added
    P2Critical bugs or normal features
    and removed
    P1Blocker bugs or important features
    on Nov 8, 2022
  20. plbossart commented on Dec 13, 2022

    @plbossart
    Member

    @bardliao can you provide a summary? My understanding is that the issue is at the codec driver level?

  21. bardliao commented on Dec 13, 2022

    @bardliao
    Collaborator

    @plbossart There are 2 issues.
    a. When we run aplay with a 1k tone and stop during playback, we will hear a noise due to the discontinuous audio.
    b.

    1. Start playback with Chrom UI on speaker
    2. Insert a headphone -> audio output will switch to the headphone
    3. remove the headphone -> ideally, audio should stop. But it will start speaker and stop. We will hear a pop when the speaker is powered on.

    We measured the I2S signal from I2S pins with a logic analyzer and the captured signal looks good. So, I don't think it is a SOF issue.

  22. macchian commented on Feb 8, 2023

    @macchian
    ContributorAuthor

    refer to #7048 and #4179

  23. johnylin76 commented on Feb 8, 2023

    @johnylin76
    Contributor

    FYI, the production build for ADL-P devices have been migrated from adl-004 to rpl-001, which means the fix commit should be merged back to rpl-001-drop-stable instead.

  24. lgirdwood commented on Feb 21, 2023

    @lgirdwood
    Member

    @macchian can we close ?

  25. macchian commented on Feb 22, 2023

    @macchian
    ContributorAuthor

    @macchian can we close ?

    @lgirdwood Yes, the remaining fix PR #4179 has approved and to be merged. We can close it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ADLApplies to Alder Lake platformP2Critical bugs or normal featuresbugSomething isn't working as expected

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions