Skip to content

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

Closed

Description

@keqiaozhang

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

Activity

  1. added
    bugSomething isn't working
    P1Blocker bugs or important features
    codecCodec HW or driver restriction
    on Aug 8, 2022
  2. keqiaozhang commented on Aug 8, 2022

    @keqiaozhang
    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.

  3. shumingfan commented on Aug 8, 2022

    @shumingfan

    @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

  4. keqiaozhang commented on Aug 8, 2022

    @keqiaozhang
    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%
    ...
    
  5. plbossart commented on Aug 8, 2022

    @plbossart
    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?

  6. shumingfan commented on Aug 8, 2022

    @shumingfan

    @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.

  7. bardliao commented on Aug 8, 2022

    @bardliao
    Collaborator

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

  8. keqiaozhang commented on Aug 9, 2022

    @keqiaozhang
    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%
    ....
    
  9. plbossart commented on Aug 9, 2022

    @plbossart
    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

  10. bardliao commented on Aug 9, 2022

    @bardliao
    Collaborator

    @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.

  11. plbossart commented on Aug 9, 2022

    @plbossart
    Member

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

  12. keqiaozhang commented on Aug 16, 2022

    @keqiaozhang
    Author

    @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

  13. plbossart commented on Aug 18, 2022

    @plbossart
    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
    
  14. keqiaozhang commented on Aug 29, 2022

    @keqiaozhang
    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.

  15. plbossart commented on Sep 12, 2022

    @plbossart
    Member

    can we close this issue @keqiaozhang ?

  16. keqiaozhang commented on Sep 13, 2022

    @keqiaozhang
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Blocker bugs or important featuresbugSomething isn't workingcodecCodec HW or driver restriction

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions