thesofproject / linux

Linux kernel source tree
Other
91 stars 133 forks source link

[BUG] Distorted sound from right speaker on Dell XPS 17 9710 #3896

Closed JuanFcoMiranda closed 1 year ago

JuanFcoMiranda commented 2 years ago

Describe the bug Everytime I reproduce a sound or avideo, I can hear the sound distorted from the left speaker and even I can hear it if a switch back to Windows, and I have to flash my laptop bios from windows to restore the normal sound from the right speaker. I use debian with the kernel 5.19.x and the version 2.1.1-1 of this driver.

To Reproduce Play any videos from youtube.

Reproduction Rate All the time.

Expected behavior Both speakers sound clear and without any distorted sound.

Impact It's very annoying when reproducing any video to hear the distorted sound from the right speaker. The left one works pretty fine.

Environment Branch name and commit hash of the 2 repositories: sof (firmware/topology) and linux (kernel driver). Kernel: 5.19.12 SOF: 2.1.1-1 Name of the topology file Topology: intel/sof-tplg/sof-tgl-rt711-rt1308-rt715.tplg Name of the platform(s) on which the bug is observed. Platform: Dell XPS 17 9710 Bios version: 1.13.1

Example sound: New Recording 14.zip alsa-info.txt

plbossart commented 2 years ago

@JuanFcoMiranda in your topology you have a single amplifier which deals with both left and right channels. I don't see what the BIOS would have to do with the audio subsystem and what reflashing it would do.

I would recommend creating two stereo files at 48kHz, one with a 440Hz sine wave on the left channel and one with the sine wave in the right channel. Try to record what happens then and provide wav files. I was not able to listen to your m4a provided earlier.

IMHO it's likely that you are missing some alsa mixer values or something related to the configuration of the amplifier.

You also want to attach the results of 'alsa-info' since we only track Dell platforms by SKU number, not product codes.

JuanFcoMiranda commented 2 years ago

Hi, I have updated the info in the first post, attached the alsa-info and the bios version installed.

I don't know why, but if I reflash the bios, the distortioned sound disappears after reboot.

plbossart commented 2 years ago

@shumingfan do you know if the BIOS or UEFI layers configure the rt1308 amplifier with some presets? I don't have any explanation for the behavior reported by @JuanFcoMiranda other than the kernel drivers setting a state that can only be restored by re-executing basic configurations - but that's a theory only.

shumingfan commented 2 years ago

@plbossart Sorry, I have no idea if the BIOS or UEFI layers configure the rt1308 amplifier. @JuanFcoMiranda May I ask if the normal status (left/right speaker are normal after BIOS updated) is temporary? Could you also provide the kernel log when the distorted sound from the right speaker? Please enable dynamic debug. Copy this file sof-dyndbg.conf.txt as /etc/modprobe.d/sof-dyndbg.conf, then reboot.

JuanFcoMiranda commented 2 years ago

@shumingfan If I run only Windows, the speakers sound normal, always, but when I switch to debian, the distortioned sound starts on the right speaker. I have tried several kernels, 5.19.11, 5.19.12 and 6.0.0, and it happens in all of them.

I'll add the kernel logs ASAP.

I also reported this bug some time ago: https://github.com/thesofproject/sof/issues/5436

Another rare bug.

Thank you very much for your help.

Edit, here are the logs: mess2.txt

shumingfan commented 2 years ago

@JuanFcoMiranda I checked the https://github.com/thesofproject/sof/issues/5436 which is the popping noise issue, not the distorted sound problem. Do you have the distorted sound issue at that time after the popping noise fixes?

Another question is that you said

I don't know why, but if I reflash the bios, the distortioned sound disappears after reboot.

Does the distorted sound happen again after the cold reboot?

I also use the same machine with the same kernel version and SOF version to test this issue. Unfortunately, I can't reproduce this issue. alsa-info.txt

Could you test the amixer controls below to change the channel and test again? $ amixer cset name='rt1308-1 RX Channel Select' 'RR' $ amixer cset name='rt1308-2 RX Channel Select' 'LL' I also want to check the register dump. Please keep the playback while dumping the registers. $ cat /sys/kernel/debug/regmap/sdw:1:025d/1308:00/registers $ cat /sys/kernel/debug/regmap/sdw:2:025d/1308:00/registers

JuanFcoMiranda commented 2 years ago

@JuanFcoMiranda I checked the thesofproject/sof#5436 which is the popping noise issue, not the distorted sound problem. Do you have the distorted sound issue at that time after the popping noise fixes?

No, with the patches from kernel 5.18.x and bios v1.12, I had no problems at all, both speakers sounded good.

Another question is that you said

I don't know why, but if I reflash the bios, the distortioned sound disappears after reboot.

Does the distorted sound happen again after the cold reboot?

If I only reboot the laptop, the distortion persists, but, after the bios reflash, the sound becomes normal on the right speaker.

I also use the same machine with the same kernel version and SOF version to test this issue. Unfortunately, I can't reproduce this issue. alsa-info.txt

It's like the popping sound bug, it's pretty weird.

Could you test the amixer controls below to change the channel and test again? $ amixer cset name='rt1308-1 RX Channel Select' 'RR' $ amixer cset name='rt1308-2 RX Channel Select' 'LL' I also want to check the register dump. Please keep the playback while dumping the registers. $ cat /sys/kernel/debug/regmap/sdw:1:025d/1308:00/registers $ cat /sys/kernel/debug/regmap/sdw:2:025d/1308:00/registers

$ sudo amixer cset name='rt1308-1 RX Channel Select' 'RR'
numid=9,iface=MIXER,name='rt1308-1 RX Channel Select'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'LR'
  ; Item #1 'LL'
  ; Item #2 'RL'
  ; Item #3 'RR'
  : values=3
$ sudo amixer cset name='rt1308-2 RX Channel Select' 'LL'
numid=10,iface=MIXER,name='rt1308-2 RX Channel Select'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'LR'
  ; Item #1 'LL'
  ; Item #2 'RL'
  ; Item #3 'RR'
  : values=1
$ sudo cat /sys/kernel/debug/regmap/sdw:1:025d/1308:00/registers
cat: '/sys/kernel/debug/regmap/sdw:1:025d/1308:00/registers': No such file or directory
$ sudo cat /sys/kernel/debug/regmap/sdw:2:025d/1308:00/registers
cat: '/sys/kernel/debug/regmap/sdw:2:025d/1308:00/registers': No such file or directory
shumingfan commented 2 years ago

No, with the patches from kernel 5.18.x and bios v1.12, I had no problems at all, both speakers sounded good.

Could you use bios v1.12 + kernel 5.19.x to test?

If I only reboot the laptop, the distortion persists, but, after the bios reflash, the sound becomes normal on the right speaker.

You just bios reflash with the same version v1.13.1, right?

$ sudo amixer cset name='rt1308-1 RX Channel Select' 'RR' numid=9,iface=MIXER,name='rt1308-1 RX Channel Select' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'LR' ; Item #1 'LL' ; Item #2 'RL' ; Item #3 'RR' : values=3 $ sudo amixer cset name='rt1308-2 RX Channel Select' 'LL' numid=10,iface=MIXER,name='rt1308-2 RX Channel Select' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'LR' ; Item #1 'LL' ; Item #2 'RL' ; Item #3 'RR' : values=1

How about the test result? Does the right speaker still have the distorted sound?

$ sudo cat /sys/kernel/debug/regmap/sdw:1:025d/1308:00/registers cat: '/sys/kernel/debug/regmap/sdw:1:025d/1308:00/registers': No such file or directory $ sudo cat /sys/kernel/debug/regmap/sdw:2:025d/1308:00/registers cat: '/sys/kernel/debug/regmap/sdw:2:025d/1308:00/registers': No such file or directory

sorry, typo. $ sudo cat /sys/kernel/debug/regmap/sdw:1:025d:1308:00/registers $ sudo cat /sys/kernel/debug/regmap/sdw:2:025d:1308:00/registers

JuanFcoMiranda commented 2 years ago

No, with the patches from kernel 5.18.x and bios v1.12, I had no problems at all, both speakers sounded good.

Could you use bios v1.12 + kernel 5.19.x to test?

I tried, but the bios downgrade does not work well.

If I only reboot the laptop, the distortion persists, but, after the bios reflash, the sound becomes normal on the right speaker.

You just bios reflash with the same version v1.13.1, right?

Yes, correct.

$ sudo amixer cset name='rt1308-1 RX Channel Select' 'RR' numid=9,iface=MIXER,name='rt1308-1 RX Channel Select' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'LR' ; Item #1 'LL' ; Item #2 'RL' ; Item #3 'RR' : values=3 $ sudo amixer cset name='rt1308-2 RX Channel Select' 'LL' numid=10,iface=MIXER,name='rt1308-2 RX Channel Select' ; type=ENUMERATED,access=rw------,values=1,items=4 ; Item #0 'LR' ; Item #1 'LL' ; Item #2 'RL' ; Item #3 'RR' : values=1

How about the test result? Does the right speaker still have the distorted sound?

Yes, the distorted sound is still here.

$ sudo cat /sys/kernel/debug/regmap/sdw:1:025d/1308:00/registers cat: '/sys/kernel/debug/regmap/sdw:1:025d/1308:00/registers': No such file or directory $ sudo cat /sys/kernel/debug/regmap/sdw:2:025d/1308:00/registers cat: '/sys/kernel/debug/regmap/sdw:2:025d/1308:00/registers': No such file or directory

sorry, typo. $ sudo cat /sys/kernel/debug/regmap/sdw:1:025d:1308:00/registers

registers1.txt

$ sudo cat /sys/kernel/debug/regmap/sdw:2:025d:1308:00/registers

registers2.txt

shumingfan commented 2 years ago

Could you use bios v1.12 + kernel 5.19.x to test?

I tried, but the bios downgrade does not work well.

Could you try to update BIOS manually? Please check the Dell website (https://www.dell.com/support/kbdoc/zh-tw/000124211/dell-bios-updates?lang=en). a. Download the BIOS update file (https://www.dell.com/support/home/en-ai/drivers/driversdetails?driverid=3gdt5&oscode=wt64a&productcode=xps-17-9710-laptop) and save it to the USB drive. b. Power off the Dell computer. c. Connect the USB drive and restart the Dell computer. d. Press F12 key at the Dell logo screen to enter One Time Boot Menu. e. Using the arrow keys, select BIOS UPDATE -> Flash from file -> USB Storage Device and select the file name (XPS_17_9710_Precision_5760_1.12.0.exe), then press Enter key. f. Follow the instructions in the BIOS Update Utility screen to complete the update process.

shumingfan commented 2 years ago

@JuanFcoMiranda Could you also try to test with this patch (917d1053f65d4fd6ee7d359bc6cf92d5e70f3b5e)? I checked with our hardware engineer, then there are some different settings between version C and D of rt1308. This patch will check the chip version to set the different settings.

JuanFcoMiranda commented 2 years ago

Hi, @shumingfan, I tried the patch, but the distortion is still here.

shumingfan commented 2 years ago

@JuanFcoMiranda Oh, that is bad news to me. I discussed this with the hardware engineer, but we have no idea to figure out what's the root cause. I want to do some experiments. That needs your help to test the scripts. Please run the script while the right speaker outputs the distorted sound. And check if the distorted sound becomes normal or not. It needs to cold reboot the system if you will run another script.

Before the test, you should enable the 'REGMAP_ALLOW_WRITE_DEBUGFS' and rebuild the kernel.

--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -290,7 +290,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
                                   count, ppos);
 }

-#undef REGMAP_ALLOW_WRITE_DEBUGFS
+#define REGMAP_ALLOW_WRITE_DEBUGFS
 #ifdef REGMAP_ALLOW_WRITE_DEBUGFS

rt1308_presetD_test1.sh.txt rt1308_presetD_test2.sh.txt rt1308_presetD_test3.sh.txt rt1308_presetD_test4.sh.txt rt1308_presetD_test5.sh.txt

JuanFcoMiranda commented 2 years ago

@JuanFcoMiranda Oh, that is bad news to me. I discussed this with the hardware engineer, but we have no idea to figure out what's the root cause.

I don't know either what is the cause, because I also tried a pendrive with the latest live version of Ubuntu, and the problem is still there even without install it.

I want to do some experiments. That needs your help to test the scripts. Please run the script while the right speaker outputs the distorted sound. And check if the distorted sound becomes normal or not. It needs to cold reboot the system if you will run another script.

Before the test, you should enable the 'REGMAP_ALLOW_WRITE_DEBUGFS' and rebuild the kernel.

--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -290,7 +290,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
                                   count, ppos);
 }

-#undef REGMAP_ALLOW_WRITE_DEBUGFS
+#define REGMAP_ALLOW_WRITE_DEBUGFS
 #ifdef REGMAP_ALLOW_WRITE_DEBUGFS

rt1308_presetD_test1.sh.txt rt1308_presetD_test2.sh.txt rt1308_presetD_test3.sh.txt rt1308_presetD_test4.sh.txt rt1308_presetD_test5.sh.txt

With the first script the sound from right speaker is no more distortioned, although it seems the sound from the left one is a bit louder. New Recording 15.m4a.gz

On Windows, it sounds normal too.

Thank you very much for your help.

shumingfan commented 2 years ago

@JuanFcoMiranda Could you please test each script? And please tell me the test result. Each script has some different settings that I want to figure out what setting will make it sound normal. Thanks.

JuanFcoMiranda commented 2 years ago

I have tried all scripts, and the test1, test4 and test5 works almost the same way, the distortion is gone and it seems the left speaker is a bit louder than the right one, but with test2 and test3, the distortion persists on the right speaker.

shumingfan commented 2 years ago

@JuanFcoMiranda Thanks for your testing. Could you help to test another two test items below? a. build Linux kernel with two patches and test again. 917d1053f65d4fd6ee7d359bc6cf92d5e70f3b5e and 3fd500da0b1597e006c581720c15d082b54e7063

b. run the test6 script while the right speaker outputs the distorted sound rt1308_presetD_test6.sh.txt

JuanFcoMiranda commented 2 years ago

Hi @shumingfan,

I tried this last options, kernel with both patches only, the distortion is still present, but applying the test6 script, the distortion dissapears, but its a little difference with the other scripts, after applying it, there is no extrange sound before vanishing the distortioned sound, it's a more sweet transition, but I still believe the left speaker is a bit louder than the right one.

shumingfan commented 2 years ago

but I still believe the left speaker is a bit louder than the right one.

@JuanFcoMiranda I checked this with the hardware engineer, and he said this model uses the tweeter speakers on the rt1308-1 amplifier. The rt1308-2 amplifier uses woofer speakers. I think that's why you feel the left speaker is a bit louder than the right one.

I updated the patches. (08bc7cf294a79aafa8af904219074c158f451cc2 and eb1b283fe766692b0714dced696968db4de45cf0) Could you help to test these two patches? If the test result is ok, I will send the patches to upstream.

plbossart commented 2 years ago

wow. Shouldn't this be handled at the machine driver level @shumingfan, with a property set before the rt1308 component probe?

It's likely that other 4-speaker models have this confusion and that UCM changes need to happen as well so that settings are applied knowing what amp1 and amp2 do, no?

shumingfan commented 2 years ago

@plbossart Do you mean that the BQ settings could be set in the sof_sdw_rt1308.c? If yes, I will try to move the settings to the m/c driver level. I checked with the hardware engineer about the BQ settings. He said each model has its own BQ settings if it needs to be set. There are no common settings for all 4-speaker models. I am also not sure if the 4-speaker model all uses the tweeter/woofer speakers.

shumingfan commented 2 years ago

@plbossart @JuanFcoMiranda I updated the patches. (81fd1096d6a82375d30b4c47173ae4988bfc40d1, 15b82d393b88b8829ed02a289a88376d8a009bbe, 94fb79b2afda3f426b3913512db11a15cd3e386b) I tried to implement your concept at the machine driver level. If there is any suggestion, please let me know. Thanks.

plbossart commented 2 years ago

@plbossart Do you mean that the BQ settings could be set in the sof_sdw_rt1308.c? If yes, I will try to move the settings to the m/c driver level. I checked with the hardware engineer about the BQ settings. He said each model has its own BQ settings if it needs to be set. There are no common settings for all 4-speaker models. I am also not sure if the 4-speaker model all uses the tweeter/woofer speakers.

I don't know what BQ stands for.

My point is that we assume that the two amps are handled in symmetrical ways without any specific settings other than enabling DACs.

https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/sof-soundwire/rt1308-1.conf https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/sof-soundwire/rt1308-2.conf

it seems obvious to me that if the two amps deal with two woofers and two tweaters each, obviously the default settings cannot be the same. That is what @JuanFcoMiranda has been complaining.

My question is whether this hardware topology change can be entirely handled in the driver, or if userpace needs to know about it with some controls being applied.

JuanFcoMiranda commented 2 years ago

@plbossart @JuanFcoMiranda I updated the patches. (81fd109, 15b82d3, 94fb79b) I tried to implement your concept at the machine driver level. If there is any suggestion, please let me know. Thanks.

Hi, I tried all those patches with latest kernel, 6.0.2, and the distortion has disappeared.

Thank you very much for your help.

shumingfan commented 2 years ago

@plbossart Sorry, there are some misunderstandings the with hardware engineer. The correct tweeter/woofer arrangement is: The left channel of rt1308-1/rt1308-2 connects to a woofer speaker. The right channel of rt1308-1/rt1308-2 connects to a tweeter speaker. The hardware engineer will use the crossover filter (biquad filter) to control the frequency for the woofer (left channel) and tweeter (right channel). Therefore, it uses the same settings of biqual filter for rt1308-1 and rt1308-2. The hardware engineer calls the design the 2-way speaker amplifier. There is an illustration below. The tweeter speaker is upper side and the woofer is the bigger one on the bottom side. 2-way-speaker

plbossart commented 2 years ago

@shumingfan thanks for the explanations, this is what I was expected, it's also aligned with the SDCA definitions. So if we are in agreement on what amplifiers do, why do we need a set of DMI-dependent patches, what do they fix?

shumingfan commented 2 years ago

@plbossart The hardware engineer said that each model may have different speakers (different transducers), hence they will tune the different biquad settings for them.

plbossart commented 2 years ago

Thanks @shumingfan that tuning should not be in the kernel but the values stored in UCM or other configuration files. It'll be an endless battle to get this right, i.e. we don't even have a description of all the SKUs, just today we learned about a new 0B14 that we didn't know about.

plbossart commented 2 years ago

@shumingfan would you happen to know how those filter coefficients are stored in Windows? Are they read from the DSDT/BIOS or from some .INI file?

shumingfan commented 2 years ago

@plbossart I checked with the Windows software engineer. Those filter coefficients are hard coding in the driver.

plbossart commented 2 years ago

Thanks @shumingfan, in that case we'll have to track the Windows changes and use your suggested solution with tables in the machine driver that are applied as codec properties. One day SDCA will solve all this but until then we have to handle such quirks manually. Gah.

shumingfan commented 2 years ago

@plbossart Hmm, I understand that pain. I think I send the PR here first. Thanks.

JuanFcoMiranda commented 2 years ago

Hi, I have tried the sound recorded from the mic, and seems it also sounds like distorted.

plbossart commented 2 years ago

@JuanFcoMiranda please file another issue for microphones, different chip and different problem. Thanks