Skip to content

[CML][HDA] arecord cannot record the 48K rate audio correctly with DMIC16 #836

Closed

Description

@stevyan

Summary
arecord can record the sound with following parameters (channel: 2, fmt: s16_le, rate: 48000), and no error occurred during the recording phase.
But when try to playback the record wav with the same parameters, the sound changes to very sharp, likes frequency has changed.

To Reproduce

  1. arecord -Dhw:0,7 -f s16_le -r 48000 -c 2 test.wav -vv -i
  2. aplay -Dhw:0,0 -f s16_le -r 48000 -c 2 test.wav

Actual result
Incorrect sound heard.

Test Recipe
Kernel: 2de29fa [thesofproject/linux: topic/sof-dev] +[RanderWang/linux: cml-validation-20190415] d04ccf4 + bfb0729 + 8a2b13a + 63ceb8f + db89510
Firmware: bardliao/sof@00bbb11 + bardliao/sof@5738003
Topology: sof-hda-generic.tplg

sof-logger log

326     0      2          DMA            129574.062500         3.177083 src/drivers/dw/dma.c:408    dw-dma 0 request channel
327     0      2          IPC            129701.354167       127.291664    src/ipc/handler.c:541    ipc: hdr 0x80010000 tx (144) > rx (120)
328     0      2          IPC            129704.791667         3.437500    src/ipc/handler.c:544    ipc: dai 2,1 -> config
329     0      2          DAI            129708.177083         3.385417        src/lib/dai.c:87     dai_get(), d = 0xbe05c794, sref = 2
330     0      2         DMIC            129711.458333         3.281250 rs/intel/cavs/dmic.c:1124   dmic_set_config(), dai->index = 1
331     0      2         DMIC            129717.552083         6.093750 rs/intel/cavs/dmic.c:1195   dmic_set_config(), prm config->dmic.num_pdm_active = 1
332     0      2         DMIC            129720.416667         2.864583 rs/intel/cavs/dmic.c:1197   dmic_set_config(), prm pdmclk_min = 500000, pdmclk_max = 4800000
333     0      2         DMIC            129723.385417         2.968750 rs/intel/cavs/dmic.c:1199   dmic_set_config(), prm duty_min = 40, duty_max = 60
334     0      2         DMIC            129726.250000         2.864583 rs/intel/cavs/dmic.c:1201   dmic_set_config(), prm fifo_fs = 16000, fifo_bits = 16
335     0      2         DMIC            129790.989583        64.739586 rs/intel/cavs/dmic.c:1243   dmic_set_config(), cfg clkdiv = 10, mcic = 25
336     0      2         DMIC            129794.062500         3.072917 rs/intel/cavs/dmic.c:1245   dmic_set_config(), cfg mfir_a = 2, mfir_b = 6
337     0      2         DMIC            129796.875000         2.812500 rs/intel/cavs/dmic.c:1246   dmic_set_config(), cfg cic_shift = 3
338     0      2         DMIC            129799.687500         2.812500 rs/intel/cavs/dmic.c:1248   dmic_set_config(), cfg fir_a_shift = 0, cfg.fir_b_shift = 1
339     0      2         DMIC            129802.656250         2.968750 rs/intel/cavs/dmic.c:1250   dmic_set_config(), cfg fir_a_length = 101, fir_b_length = 249
340     0      2         DMIC            129805.989583         3.333333 rs/intel/cavs/dmic.c:912    configure_registers(), OUTCONTROL0 = 37224448
341     0      2         DMIC            129808.802083         2.812500 rs/intel/cavs/dmic.c:923    configure_registers(), OUTCONTROL1 = 36700160
342     0      2         DMIC            129811.927083         3.125000 rs/intel/cavs/dmic.c:977    configure_registers(), CIC_CONTROL = 65539
343     0      2         DMIC            129814.791667         2.864583 rs/intel/cavs/dmic.c:982    configure_registers(), CIC_CONFIG = 184555520
344     0      2         DMIC            129817.760417         2.968750 rs/intel/cavs/dmic.c:998    configure_registers(), MIC_CONTROL = 2048
345     0      2         DMIC            129820.781250         3.020833 rs/intel/cavs/dmic.c:1009   configure_registers(), FIR_CONTROL_A = 19
346     0      2         DMIC            129823.750000         2.968750 rs/intel/cavs/dmic.c:1015   configure_registers(), FIR_CONFIG_A = 65636
347     0      2         DMIC            129826.562500         2.812500 rs/intel/cavs/dmic.c:1020   configure_registers(), DC_OFFSET_LEFT_A = 0
348     0      2         DMIC            129829.531250         2.968750 rs/intel/cavs/dmic.c:1025   configure_registers(), DC_OFFSET_RIGHT_A = 0
349     0      2         DMIC            129832.447917         2.916667 rs/intel/cavs/dmic.c:1029   configure_registers(), OUT_GAIN_LEFT_A = 0
350     0      2         DMIC            129835.260417         2.812500 rs/intel/cavs/dmic.c:1033   configure_registers(), OUT_GAIN_RIGHT_A = 0
351     0      2         DMIC            129838.229167         2.968750 rs/intel/cavs/dmic.c:1044   configure_registers(), FIR_CONTROL_B = 19
352     0      2         DMIC            129841.093750         2.864583 rs/intel/cavs/dmic.c:1050   configure_registers(), FIR_CONFIG_B = 328184

Activity

  1. added
    bugSomething isn't working
    CMLApplies to Comet Lake platform
    HDAApplies to HD-Audio bus for codec connection
    on Apr 15, 2019
  2. wenqingfu commented on Apr 15, 2019

    @wenqingfu

    and no error occurred during the recording phase.

    still worth attaching a dmesg log. @stevyan thanks.

  3. stevyan commented on Apr 16, 2019

    @stevyan
    Author

    Attach the dmesg log as reference.

    arecord_dmesg.log

  4. singalsu commented on Apr 16, 2019

    @singalsu
    Collaborator

    You should try with command

    time arecord -Dhw:0,7 -f s16_le -r 48000 -c 2 test.wav -d 10 -vv -i

    If time reports something else then the 10 seconds duration for arecord then the used sample rate wasn't what was requested.

    Probably the recording happened with 16 kHz since the second DAI is usually configured in topology for 16 kHz rate. Also attaching the recorded test.wav file would be nice in this kind of error reports.

    If in the topology the PCM capability is edited from min, max 48000, 48000 into 8000, 96000 you should be able to do a working 16 kHz recording.

    Currently the PCM capability is set to min, max 48000, 48000 because there's another issue happening if we allow the 8k-96k or 16k-48k range. Sound servers probe the PCM capability and if the DAI then doesn't capture successfully with some requested rate they report errors. Maybe that error needs another type of fix maybe at DAI component params() call when the capture starts (check the actual sample rate vs. what was configured for DMIC in topology, make the call return -EINVAL in that case).

  5. stevyan commented on Apr 17, 2019

    @stevyan
    Author
    ubuntu@sh-whl-dell-hda-01:~$ time arecord -Dhw:0,7 -r 48000 -c2 -fs16_le wav/cap_0_16.wav -d 10 -vv -i
    Recording WAVE 'wav/cap_0_16.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Hardware PCM card 0 'sof-skl_hda_card' device 7 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  : 16368
      period_size  : 4080
      period_time  : 85000
      tstamp_mode  : NONE
      tstamp_type  : MONOTONIC
      period_step  : 1
      avail_min    : 4080
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 16368
      silence_threshold: 0
      silence_size : 0
      boundary     : 9214364837600034816
      appl_ptr     : 0
      hw_ptr       : 0
    #+                                                 | 00%
    
    real	0m30.314s
    user	0m0.012s
    sys	0m0.049s
    
  6. libinyang commented on Apr 17, 2019

    @libinyang

    DMIC only supports 16KHz. It doesn't support 48KHz because of the HW/FW limitation.

  7. libinyang commented on Apr 20, 2019

    @libinyang

    This issue can be fixed thesofproject/sof#1271 and bardliao/sof@e8d5622

  8. singalsu commented on Apr 25, 2019

    @singalsu
    Collaborator

    @libinyang I would like to add that the DMIC driver supports for both DAI most of the usual N*8 kHz 8 - 96 kHz sample rates. Though not all combinations are possible when >1 DAI are created due to HW internal dependencies. But it supports capture only with the rate that was defined in topology for the DAI.

  9. libinyang commented on Apr 25, 2019

    @libinyang

    @singalsu I think that the driver has already supported all the sample rates? The limitation comes from the topology.

  10. singalsu commented on Apr 25, 2019

    @singalsu
    Collaborator

    @libinyang Yep, that's correct.

  11. mengdonglin commented on May 7, 2019

    @mengdonglin

    @libinyang @ClarexZhou Please close this issue if it's fixed.

  12. ClarexZhou commented on May 7, 2019

    @ClarexZhou

    Retest on latest CML, behevior is changed: Warning note is shown when trying to use 48khz, and cover to 16khz to record. Recorded file also can be played normally. But the recorded actual time is wrong, 3 times than expected.

    
    test@test-Inspiron-5490:~$ time arecord -Dhw:0,7 -r 48000 -c2 -fs16_le cap_48K.wav -d 3 -vv -i
    Recording WAVE 'cap_48K.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
    Warning: rate is not accurate (requested = 48000Hz, got = 16000Hz)
             please, try the plug plugin
    Hardware PCM card 0 'sof-skl_hda_card' device 7 subdevice 0
    Its setup is:
      stream       : CAPTURE
      access       : RW_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 2
      rate         : 16000
      exact rate   : 16000 (16000/1)
      msbits       : 16
      buffer_size  : 8016
      period_size  : 2016
      period_time  : 126000
      tstamp_mode  : NONE
      tstamp_type  : MONOTONIC
      period_step  : 1
      avail_min    : 2016
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 8016
      silence_threshold: 0
      silence_size : 0
      boundary     : 9025213653250473984
      appl_ptr     : 0
      hw_ptr       : 0
    ##########                                        +| 99%
    
    real    0m10.360s
    user    0m0.010s
    sys     0m0.028s
    
    
    Test Recipe '+Rander UCM https://github.com/RanderWang/intel-UCM  
    Kernel repo https://github.com/thesofproject/linux/tree/release/sof-v5.0  
      d698c4f kernel topic/sof-dev branch
      PR #853 ASoC: sof: hda: fix fw loading failure
      PR #868 ASoC: soc-pcm: BE dai needs prepare when pause release after resume
         
    Firmware repo https://github.com/thesofproject/sof/commits/master  
      47fcac2 [thesofproject/sof: master] top of master branch
         
    Topology: https://github.com/thesofproject/sof/commits/master Same as above SOF repo
      file: tools/topology/sof-hda-generic.m4, sof-hda-generic-2ch.tplg  
  13. ClarexZhou commented on May 7, 2019

    @ClarexZhou

    @libinyang , please comment on this.

  14. ClarexZhou commented on May 7, 2019

    @ClarexZhou

    Recording time is right when capturing via 16khz.

    test@test-Inspiron-5490:~$ time arecord -Dhw:0,7 -r16000 -c2 -fs16_le wav/cap_0_16.wav -d 10 -vv -i
    Recording WAVE 'wav/cap_0_16.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Stereo
    Hardware PCM card 0 'sof-skl_hda_card' device 7 subdevice 0
    Its setup is:
      stream       : CAPTURE
      access       : RW_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 2
      rate         : 16000
      exact rate   : 16000 (16000/1)
      msbits       : 16
      buffer_size  : 8016
      period_size  : 2016
      period_time  : 126000
      tstamp_mode  : NONE
      tstamp_type  : MONOTONIC
      period_step  : 1
      avail_min    : 2016
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 8016
      silence_threshold: 0
      silence_size : 0
      boundary     : 9025213653250473984
      appl_ptr     : 0
      hw_ptr       : 0
    #########        +                                 | 33%
    
    real    0m11.364s
    user    0m0.016s
    sys     0m0.019s
    
  15. libinyang commented on May 7, 2019

    @libinyang

    So record with 16KHz is OK now. It is the application behavior that record with 48KHz will record 3 times length. So let's close this bug now.

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

Metadata

Metadata

Assignees

Labels

CMLApplies to Comet Lake platformHDAApplies to HD-Audio bus for codec connectionbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions