Skip to content

Torn audio on Up^2 with Hifiberry #616

Closed

Description

@lyakh

This is the first time, that I'm testing a Up^2 board with a Hifiberry codec, so, it's possible, that I've done something wrong. Take this with a grain of salt. Still. Kernel topic/sof-dev as of today, HEAD at

commit 937cff15d4133659084cd7f399c628e8137ae74c
Author: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date:   Wed Jan 30 10:34:12 2019 -0600

    ASoC: SOF: trace: fix trivial typo

SOF master branch with HEAD at

commit cb70ef9e350bf06eae545c5a3e484e8d2dc2353e
Author: Janusz Jankowski <janusz.jankowski@linux.intel.com>
Date:   Thu Jan 31 15:22:34 2019 +0100

    cmake: check rimage dependecies

Topology used: sof-apl-src-pcm512x.tplg. When playing audio either with aplay or using the Ubuntu audio settings application, audio is torn, or maybe better described as echoed.
Another problem was, that some mixers, specifically xmix and aumix were reporting memory allocation failures. strace showed the MIXER_READ ioctl returning with errno = ENOMEM. Attached kernel messages from front-left and front-right playback tests.

Activity

  1. lyakh commented on Feb 1, 2019

    @lyakh
    CollaboratorAuthor
  2. plbossart commented on Feb 1, 2019

    @plbossart
    Member
  3. lyakh commented on Feb 2, 2019

    @lyakh
    CollaboratorAuthor

    With that topology SOF doesn't initialise for me at all, I'm getting repeated

    [   10.580287] sof-audio sof-audio: rate_min: 48000 rate_max: 48000
    [   10.580291] sof-audio sof-audio: channels_min: 2 channels_max: 2
    [   10.580296] sof-audio sof-audio: rate_min: 48000 rate_max: 48000
    [   10.580299] sof-audio sof-audio: channels_min: 2 channels_max: 2
    [   10.580310] sof-audio sof-audio: rate_min: 48000 rate_max: 48000
    [   10.580313] sof-audio sof-audio: channels_min: 2 channels_max: 2
    [   10.580321] HDMI HDA Codec ehdaudio0D2: ASoC: can't set intel-hdmi-hifi1 hw params: -19
    [   10.580329]  iDisp1: ASoC: hw_params BE failed -19
    [   10.582892]  Port5: ASoC: hw_params BE failed -19
    [   10.582914] sof-audio sof-audio: pcm: free stream 0 dir 0
    [   10.582944] sof-audio sof-audio: ipc tx: 0x60030000
    [   10.583098] sof-audio sof-audio: ipc tx succeeded: 0x60030000
    

    and I'm not getting any audio playback. But maybe because of a different topology I have to select a different device to play? Because with that topology there are more devices created, e.g. aplay -l produces

    **** List of PLAYBACK Hardware Devices ****
    card 0: sofbxtpcm512x [sof-bxt-pcm512x], device 0: Port5 (*) []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 0: sofbxtpcm512x [sof-bxt-pcm512x], device 1: HDMI1 (*) []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 0: sofbxtpcm512x [sof-bxt-pcm512x], device 2: HDMI2 (*) []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 0: sofbxtpcm512x [sof-bxt-pcm512x], device 3: HDMI3 (*) []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    
  4. ranj063 commented on Feb 2, 2019

    @ranj063
    Collaborator

    @lyakh have you set the amixer settings properly?

    you need to set Pin5-Port0/1/2, to cvt 2
    Pin6 -Port0/1/2 to cvt 3
    Pin7-Port0/1/2 to cvt 4
    and then try
    aplay -Dhw:0,2 test.wav

  5. lyakh commented on Feb 4, 2019

    @lyakh
    CollaboratorAuthor

    Thanks to @singalsu for a tip - I removed pulseaudio and now the sound isn't corrupted any more. But also to even have the card recognised I have to run a mixer once, which seems to set some (default) configuration, which then makes aplay and co. to work properly. Maybe that's what @ranj063 meant in the above post, but I'm not sure what exactly that means - could you explain? Are there instructions online? I haven't found any in https://thesofproject.github.io/latest/getting_started/setup/setup_up_2_board.html

  6. plbossart commented on Feb 4, 2019

    @plbossart
    Member
  7. ranj063 commented on Feb 4, 2019

    @ranj063
    Collaborator

    @plbossart in the case of src should CONFIG_SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION be set because we're using the no_irq mode by default

  8. plbossart commented on Feb 4, 2019

    @plbossart
    Member

    Oh wow, this is bad. It's not a debug option, it just overrides the stream settings:

            /* set host_period_bytes to 0 if no IPC position */
    	if (hda && hda->no_ipc_position)
    		ipc_params->host_period_bytes = 0;

    sound/soc/sof/intel/hda-stream.c:

           ioc = hda->no_ipc_position ? !stream->no_period_wakeup : 0;

    Not to mention that double-negations are a sure way to lose everyone. !no_ipc_position should be ipc_position. Gah.

  9. lyakh commented on Feb 8, 2019

    @lyakh
    CollaboratorAuthor

    @plbossart so this issue should be renamed to something like "pulseaudio broken on Up^2?" Not sure about your comment above - it is bad but that isn't the reason for this problem anyway? And we don't have a fix for it yet?

  10. plbossart commented on Feb 13, 2019

    @plbossart
    Member

    @lyakh my point was that the driver is told to operate in no_irq mode with the no_period_wakeup setting, but if this debug option is set we override the settings and will generate an interrupt on a period boundary userspace may not need/want. The real fix would be to remove support for no_period_wakeup, not override settings that were accepted in the userspace/driver negociation.

  11. fredoh9 commented on Mar 5, 2019

    @fredoh9
    Collaborator

    I'm able to reproduce this issue when I enabled SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION with current latest build. It looks to me PCM position update has some problems. I will debug a bit more, I will share my proposal soon.

  12. fredoh9 commented on Mar 14, 2019

    @fredoh9
    Collaborator

    There was some confusion in this CR description, I'm re-writing CR description.

    The issue only happens with the debug feature, SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION. And even after enabling this feature, aplay is always fine. The issue can be reproduced only with Ubuntu Music App(Rhythmbox). I think any Music app something to do with PulseAudio has same issue. Again, the build with default defconfig has no issue with aplay or any player.

    Interesting part was even the build with SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION flag, the issue will be come if pulseaudio(/usr/bin/) is removed. Without deep knowledge of pulseaudio, I guess, PulseAudio relies on timer-based scheduling. Without pulseaudio deamon the Music Player switches to best effort mode, not relying on internal scheduling.

    The fix I'm proposing is simple. This debugging feature is not implemented completely. If SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION is enabled, it must provide IPC POSITION callback from IPC context.
    ipc_msgs_rx() -> ipc_stream_message() -> ipc_period_elapsed() -> snd_pcm_period_elapsed()

    I will submit the PR soon.

    On side note, i tracked four variables interestingly,

    1. no_ipc_position
    2. no_period_wakeup
    3. IOC
    4. host_period_bytes
  13. lyakh commented on Mar 15, 2019

    @lyakh
    CollaboratorAuthor

    @fredoh9 FWIW I initially noticed those problems with aplay.

  14. fredoh9 commented on Mar 15, 2019

    @fredoh9
    Collaborator

    @lyakh really? i tested with your build also(after checking out both HEAD), I couldn't reproduce this with aplay.

  15. fredoh9 commented on Apr 11, 2019

    @fredoh9
    Collaborator

    the PR #721 moved to [DO NOT MERGE] for now. This will be handled in bigger scope. More details are in the PR thread.

  16. plbossart commented on Jan 17, 2020

    @plbossart
    Member

    @lyakh I guess we can close this issue?

  17. lyakh commented on Jan 17, 2020

    @lyakh
    CollaboratorAuthor

    @lyakh I guess we can close this issue?

    @plbossart it's old so, perhaps, yes, although I haven't tested SRC with pulseaudio on Up^2 in ages

  18. plbossart commented on Jan 17, 2020

    @plbossart
    Member

    ok let's close and re-open if we see something bad

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

Metadata

Metadata

Assignees

Labels

discussionOpen discussion and clarificationenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions