Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] plain arecord issue found when testing RT711 headset recording on TGLU_SKU0A3E_SDW #3804

Closed
keqiaozhang opened this issue Aug 8, 2022 · 15 comments
Labels
bug Something isn't working codec Codec HW or driver restriction P1 Blocker bugs or important features

Comments

@keqiaozhang
Copy link
Collaborator

Describe the bug
We observed this issue after upgrading Ubuntu from 20.04 to 22.04. The issue is that when testing plain arecord on headset, the Max peak will be reached to 100% in verbose logs, it should be 0%.

arecord -D hw:0,1 -r 48000 -c 2 -f S16_LE -vvv -i /dev/null -d 10
Recording WAVE '/dev/null' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Hardware PCM card 0 'sof-soundwire' device 1 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 16384
  period_size  : 4096
  period_time  : 85333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 4096
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 16384
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
  appl_ptr     : 0
  hw_ptr       : 0
Max peak (8192 samples): 0x00000515 #                    3%
Max peak (8192 samples): 0x00000713 ##                   5%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00007fff #################### 99%
Max peak (8192 samples): 0x00007fff #################### 99%
Max peak (8192 samples): 0x00007fff #################### 99%
Max peak (8192 samples): 0x00007fff #################### 99%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
....

Checked the amixer setting, this issue is related to control 'rt711 ADC 08 Capture Volume'. The default value set in UCM2 is 63.
please refer to https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/codecs/rt711/init.conf.
The issue will disappear if I change the volume to 0: amixer -c sofsoundwire cset name='rt711 ADC 08 Capture Volume' 0

@keqiaozhang keqiaozhang added bug Something isn't working P1 Blocker bugs or important features codec Codec HW or driver restriction labels Aug 8, 2022
@keqiaozhang
Copy link
Collaborator Author

@shumingfan , could you please take a look at this issue? We have a similar issue on RT714:#3766 and we changed the rt714 FU02 Capture Volume to 0dB.

@shumingfan
Copy link

@keqiaozhang I can't reproduce this issue on SKU_0A5D which installed Ubuntu 22.04.
Could you test the DP loopback to check if this issue still exists or not?
$ cd /sys/kernel/debug/soundwire/master-0-0/intel-sdw/
$ echo 4 > cdns-pdi-loopback-target
$ echo 3 > cdns-pdi-loopback-source
// aplay first
$ aplay -D hw:0,0 -f dat /dev/zero
// arecord test
$ arecord -D hw:0,1 -r 48000 -c 2 -f S16_LE -vvv -i /dev/null -d 10

@keqiaozhang
Copy link
Collaborator Author

@shumingfan, I still can reproduce the issue with above steps.

    4  cd /sys/kernel/debug/soundwire/master-0-0/intel-sdw/
    5  echo 4 > cdns-pdi-loopback-target
    6  echo 3 > cdns-pdi-loopback-source
    7  aplay -D hw:0,0 -f dat /dev/zero -vvv -d 5
    8  arecord -D hw:0,1 -r 48000 -c 2 -f S16_LE -vvv -i /dev/null -d 10

arecord -D hw:0,1 -r 48000 -c 2 -f S16_LE -vvv -i /dev/null -d 10
Recording WAVE '/dev/null' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Hardware PCM card 0 'sof-soundwire' device 1 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 16384
  period_size  : 4096
  period_time  : 85333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 4096
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 16384
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
  appl_ptr     : 0
  hw_ptr       : 0
Max peak (8192 samples): 0x00000ac8 ##                   8%
Max peak (8192 samples): 0x00000eca ###                  11%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00007fff #################### 99%
Max peak (8192 samples): 0x00007fff #################### 99%
Max peak (8192 samples): 0x00007fff #################### 99%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
Max peak (8192 samples): 0x00008000 #################### 100%
...

@plbossart
Copy link
Member

@bardliao can you chime in out this one reported by @keqiaozhang and @shumingfan? it's my understanding that if we have an issue with the loopback, then the problem is NOT the codec settings. The loopback will discard the data from the codec . Am I right?

@shumingfan
Copy link

@keqiaozhang Thanks for the testing.
@plbossart I also think this problem is not the codec settings.
The DP loopback makes the capture data equal to the playback data.

@bardliao
Copy link
Collaborator

bardliao commented Aug 8, 2022

@plbossart @shumingfan @keqiaozhang Sure, I will look into it.

@keqiaozhang
Copy link
Collaborator Author

@shumingfan I have checked with Bard. First we need to set the PGA* capture volume to 0dB:

amixer -c sofsoundwire cset name='PGA2.0 2 Master Capture Volume' 50 
amixer -c sofsoundwire cset name='PGA5.0 5 Master Capture Volume' 50 

Then even with the default value of rt711 ADC 08 Capture Volume set in UCM2, the Max peak will not reach to 100%.

For the loopback mode. I did the wrong steps before, I need to keep the playback running when doing the capture.
But the target and source ID you provided are also not right.
I tested with below steps and loopback works:

1.  cd  /sys/kernel/debug/soundwire/master-1-1/intel-sdw
2.  echo 3 > cdns-pdi-loopback-target
3.  echo 2 > cdns-pdi-loopback-source
4.  aplay -D hw:0,0 -f dat /dev/zero &
5.  arecord -D hw:0,1 -r 48000 -c 2 -f S16_LE -vvv -i /dev/null
arecord -D hw:0,1 -r 48000 -c 2 -f S16_LE -vvv -i /dev/null -d 10
Recording WAVE '/dev/null' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Hardware PCM card 0 'sof-soundwire' device 1 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 16384
  period_size  : 4096
  period_time  : 85333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 4096
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 16384
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
  appl_ptr     : 0
  hw_ptr       : 0
Max peak (8192 samples): 0x00000000 #                    0%
Max peak (8192 samples): 0x00000000 #                    0%
Max peak (8192 samples): 0x00000000 #                    0%
Max peak (8192 samples): 0x00000000 #                    0%
Max peak (8192 samples): 0x00000000 #                    0%
Max peak (8192 samples): 0x00000000 #                    0%
Max peak (8192 samples): 0x00000000 #                    0%
Max peak (8192 samples): 0x00000000 #                    0%
....

@plbossart
Copy link
Member

@shumingfan I have checked with Bard. First we need to set the PGA* capture volume to 0dB:

amixer -c sofsoundwire cset name='PGA2.0 2 Master Capture Volume' 50 
amixer -c sofsoundwire cset name='PGA5.0 5 Master Capture Volume' 50 

Why is this needed @keqiaozhang ? All the PGA volumes should be set to 0dB already, If this is not the case, then something or someone changed those settings in the past. We should NEVER have any PGA gains set to anything other than 0dB

@bardliao
Copy link
Collaborator

bardliao commented Aug 9, 2022

@shumingfan I have checked with Bard. First we need to set the PGA* capture volume to 0dB:

amixer -c sofsoundwire cset name='PGA2.0 2 Master Capture Volume' 50 
amixer -c sofsoundwire cset name='PGA5.0 5 Master Capture Volume' 50 

Why is this needed @keqiaozhang ? All the PGA volumes should be set to 0dB already, If this is not the case, then something or someone changed those settings in the past. We should NEVER have any PGA gains set to anything other than 0dB

@plbossart 50 is 0dB, and it was 80 which is 30dB while we met the issue.

@plbossart
Copy link
Member

@bardliao why was it set to 80, that's what I don't understand.

@keqiaozhang
Copy link
Collaborator Author

keqiaozhang commented Aug 16, 2022

@bardliao why was it set to 80, that's what I don't understand.

It seems that volume-basic-test-100.sh changes all PGA* volume to Max.
[EDIT]: I will add a function to restore the PGA* volume at end of volume-basic-test.sh

@plbossart
Copy link
Member

@keqiaozhang all PGA volumes should be set to 0dB or 100%. We should do this with a script so that any changes in names or topology are supported. So far I only found this hack but I am sure it can be improved:

RES=`amixer -Dhw:0 controls | grep Volume | awk -F'numid=' '{print $2}' | awk -F',' '{print $1}'`
for i in $RES;
    do amixer -Dhw:0 cset numid=$i 100%;
done

@keqiaozhang
Copy link
Collaborator Author

all PGA volumes should be set to 0dB or 100%. We should do this with a script so that any changes in names or topology are supported

I have submitted thesofproject/sof-test#953. Please help to review.

@plbossart
Copy link
Member

can we close this issue @keqiaozhang ?

@keqiaozhang
Copy link
Collaborator Author

This issue is fixed by thesofproject/sof-test#953. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working codec Codec HW or driver restriction P1 Blocker bugs or important features
Projects
None yet
Development

No branches or pull requests

4 participants