You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Broadwell: channel inversion on SSP0 output #2459
update: this does not look like a frame polarity issue, in DSP_A mode with a single bit pulse, the left channel is in the wrong location
This looks more like a bad DMA programming or a true data error
Edit: I double-checked my connections with the legacy driver + closed source firmware, and the left channel comes out in the expected location. This is really an SOF firmware issue
The channel inversion appears to happen on pulseaudio --start. Without UCM files and running the UCM manually with amixer, everything is correct in ALSA without pulseaudio. I'm seeing
@caseorum Fwiw, pulseaudio start does "probe" each PCM by opening and trying many different params for each PCM (which will configure different SSP settings). I wonder here if the probing is setting some SSP register transitions that swap the channels ?
Could you try and "reset" the SSP settings (probably by writing all 0s or defaults to SSP regs) at the start of ssp_set_config().
@caseorum sorry but not buying the results. I have a Samus blue-wired to see the SSP signals and I could see the inversion at the lowest level, it's not related to amixer settings. I also see the inversion on Dell 9343 which uses a different codec.
@lgirdwood That's what I was thinking, whatever probing or other init pulseaudio is doing has the effect. I was hoping this might give someone who knows pulseaudio's probing better than I an idea. I'll take a look. It looks like ssp_set_config() already has some sensible resetting. Do you have something specific worth trying?
@plbossart I set amixer settings manually just to rule out any auto-UCM weirdness in pulseaudio, it's not related. This looks like firmware or kernel driver. Are you able to repro this? I don't have any plans to blue-wire mine. I boot a torvalds/master kernel with built-in FW/tplg through depthcharge directly into a minimal arch linux userspace with git master alsa and pulseaudio, and no initramfs, kernel modules, or non-default alsa/PA configs. It's almost the simplest possible testing environment.
@lgirdwood@plbossart Here are the PA logs with SST and SOF, all else being equal. It looks like PA initially uses a period size of 1199 samples, then 1200 afterwards. That might be an off-by-one channel inversion. Thoughts? palog-sof.txt palog-sst.txt
D: [pulseaudio] alsa-util.c: Set buffer size first (to 4797 samples), period size second (to 1199 samples).
I: [pulseaudio] alsa-util.c: Device hw:1 doesn't support 44100 Hz, changed to 48000 Hz.
there's no way SOF can work with odd period sizes.
Looking at ssp_config() it looks like rate and bit size are the only things PA could change (if permitted in teh topology). The only other thing that could impact here is whether PA was also trying to do some capture probing (and somehow capture probing cuases the swap by setting other SSP bits). @caseorum may be worth a try disabling PA alsa-source module and try the test again. This would narrow down the possibilites further to rate and sample size.
@caseorum can you disable PA again and try an arecord -Dhw:1,0 -f dat -d 5 > test.wav prior to speaker test. I would like to know if its capture or PA probing capture that causing the swap.
Also please try running the arecord and then run speaker test whilst arecord is still running.
speaker-test is correct if started before or during arecord capture, and stays that way as long as it runs, even after arecord has stopped. Channels are swapped if speaker-test is started after arecord exits.
Activity
plbossart commentedon Feb 27, 2020
update: this does not look like a frame polarity issue, in DSP_A mode with a single bit pulse, the left channel is in the wrong location
This looks more like a bad DMA programming or a true data error
Edit: I double-checked my connections with the legacy driver + closed source firmware, and the left channel comes out in the expected location. This is really an SOF firmware issue
[-][BUG] Broadwell: SSP channel inversion[/-][+][BUG] Broadwell: channel inversion on SSP0 output[/+]lgirdwood commentedon Feb 27, 2020
@plbossart I wonder if the DMA word size is 16 bits rather than 32 bit writes to the SSP FIFO.
plbossart commentedon Feb 27, 2020
oh, so all samples would be off by 16 bits then, i.e. not a channel inversion but a delay pushing the right sample into the next frame?
lgirdwood commentedon Feb 28, 2020
DMA looks ok, but I do see lots of comments in ssp.c for frame polarity and "logic for inverted_frame" flag.
plbossart commentedon Feb 28, 2020
For DSP_A the frame polarity looks fine.
plbossart commentedon Aug 11, 2020
@lyakh FYI since you are scrubbing the DW-DMA code, might be something related to this issue.
caseorum commentedon Sep 19, 2020
The channel inversion appears to happen on
pulseaudio --start. Without UCM files and running the UCM manually with amixer, everything is correct in ALSA without pulseaudio. I'm seeingAnyone else?
lgirdwood commentedon Sep 21, 2020
@caseorum Fwiw, pulseaudio start does "probe" each PCM by opening and trying many different params for each PCM (which will configure different SSP settings). I wonder here if the probing is setting some SSP register transitions that swap the channels ?
Could you try and "reset" the SSP settings (probably by writing all 0s or defaults to SSP regs) at the start of ssp_set_config().
plbossart commentedon Sep 21, 2020
@caseorum sorry but not buying the results. I have a Samus blue-wired to see the SSP signals and I could see the inversion at the lowest level, it's not related to amixer settings. I also see the inversion on Dell 9343 which uses a different codec.
caseorum commentedon Sep 21, 2020
@lgirdwood That's what I was thinking, whatever probing or other init pulseaudio is doing has the effect. I was hoping this might give someone who knows pulseaudio's probing better than I an idea. I'll take a look. It looks like ssp_set_config() already has some sensible resetting. Do you have something specific worth trying?
@plbossart I set amixer settings manually just to rule out any auto-UCM weirdness in pulseaudio, it's not related. This looks like firmware or kernel driver. Are you able to repro this? I don't have any plans to blue-wire mine. I boot a torvalds/master kernel with built-in FW/tplg through depthcharge directly into a minimal arch linux userspace with git master alsa and pulseaudio, and no initramfs, kernel modules, or non-default alsa/PA configs. It's almost the simplest possible testing environment.
plbossart commentedon Sep 21, 2020
@caseorum you can take pulseaudio out of the equation by using -Dhw:0,0 (or -Dhw:1,0 if you have HDMI first).
4 remaining items
caseorum commentedon Sep 22, 2020
@lgirdwood Both the correct and inverted state are 100% reproducible and stable. They invert only on PA start and stay that way.
caseorum commentedon Sep 22, 2020
@lgirdwood @plbossart Here are the PA logs with SST and SOF, all else being equal. It looks like PA initially uses a period size of 1199 samples, then 1200 afterwards. That might be an off-by-one channel inversion. Thoughts?
palog-sof.txt
palog-sst.txt
plbossart commentedon Sep 22, 2020
that looks like a red-herring to me:
there's no way SOF can work with odd period sizes.
lgirdwood commentedon Sep 22, 2020
Looking at ssp_config() it looks like rate and bit size are the only things PA could change (if permitted in teh topology). The only other thing that could impact here is whether PA was also trying to do some capture probing (and somehow capture probing cuases the swap by setting other SSP bits).
@caseorum may be worth a try disabling PA alsa-source module and try the test again. This would narrow down the possibilites further to rate and sample size.
caseorum commentedon Sep 23, 2020
@lgirdwood Good call. alsa-source is exactly the module causing the inversion.
caseorum commentedon Sep 23, 2020
Is there a trace or a dump you'd be interested in?
lgirdwood commentedon Sep 23, 2020
@caseorum can you disable PA again and try an
arecord -Dhw:1,0 -f dat -d 5 > test.wavprior to speaker test. I would like to know if its capture or PA probing capture that causing the swap.Also please try running the arecord and then run speaker test whilst arecord is still running.
caseorum commentedon Sep 23, 2020
speaker-test is correct if started before or during arecord capture, and stays that way as long as it runs, even after arecord has stopped. Channels are swapped if speaker-test is started after arecord exits.
lgirdwood commentedon Sep 23, 2020
@caseorum thanks, very useful info. One thing I do notice is that
that we never clear SSRSA_RSEN or SSRSA_TSEN in ssp_stop() after we set them in ssp_start(). @plbossart ?
plbossart commentedon Sep 23, 2020
This is awesome, thanks @caseorum for finding this. I will look into this later this week.
caseorum commentedon Sep 23, 2020
@lgirdwood I think you found the bug. I've tested the change you're suggesting (9702bfd) and it works on my samus. Want a PR for this?
keyonjie commentedon Sep 24, 2020
Yes, please send a PR for that, thanks.
lgirdwood commentedon Sep 24, 2020
@caseorum yes please 👍 We can hopefully get this in v1.6-rc1 today and definately v1.6
caseorum commentedon Oct 2, 2020
Just want to say thanks @lgirdwood, @plbossart, and everyone. This project is awesome work.