yangxiaohua2009 / custom-kernel

22 stars 5 forks source link

No sound in Headphones, Internal microphone not working #12

Open fbolgar opened 2 years ago

fbolgar commented 2 years ago

Hello,

First of all, thanks for you work !

I have followed carefully the instructions and installed the kernel on my fresh install Huawei Matebook d14, ubuntu 22.04. I also tried, for that matter, to compile and install https://github.com/thesofproject/linux/tree/es8336-v5.19

I also used the following commands: amixer cset name='Speaker Switch' on amixer cset name='Headphone Playback Volume' 3,3 amixer cset name='Right Headphone Mixer Right DAC Switch' on amixer cset name='Left Headphone Mixer Left DAC Switch' on amixer cset name='DAC Playback Volume' 999,999 amixer cset name='Headphone Mixer Volume' 999,999 amixer cset name='ADC PGA Gain Volume' 999 amixer cset name='ADC Capture Volume' 999 amixer cset name='Internal Mic Switch' on amixer cset name='Headset Mic Switch' on

sudo cp -r sof-essx8336 /usr/share/alsa/ucm2/

In both kernels, I have the sound from speaker that works rather well (great improvement !), even though I hear a kind of brief scratch (noise) at login screen.

However, my microphone is not recognized at all. Also, when I plug in my headphones, it is detected and everything looks perfect, but no sound comes out of it. In pavucontrol I can see the sound that is supposed to go through my headphones, but absolutely no sound actually comes through.

Here below I have attached my alsamixer levels. I have played with it a little bit in order to make it work, without success, so they might not be in their default levels.

Could you help me figure this out ? I am kinda clueless right now.

Capture d’écran du 2022-08-29 13-32-26 Capture d’écran du 2022-08-29 13-32-57 Capture d’écran du 2022-08-29 13-34-35

PS: I also noticed that in the kernel that you provide, my exfat external drive is not supported, I had to switch back to the other kernel to use it.

yangxiaohua2009 commented 2 years ago

For headphone, you may have two gpios, see https://github.com/yangxiaohua2009/custom-kernel/issues/5#issuecomment-1220403029. Dose your headset mic work? For internal mic, make sure that you don't have a PCH Dmic. Please turn off the dmic if you are using an amic.

fbolgar commented 2 years ago

Indeed, I am exactly in the same situation as the issue you suggested, I have 2 GPIOS as shown here:

Capture d’écran du 2022-08-30 21-59-10

As for the output of dmesg, it is here:

[    3.532090] nvme 0000:01:00.0: platform quirk: setting simple suspend
[    7.543389] sof-essx8336 sof-essx8336: quirk mask 0x20
[    7.543392] sof-essx8336 sof-essx8336: quirk SSP0
[    7.543393] sof-essx8336 sof-essx8336: quirk DMIC enabled
[    7.544508] sof-audio-pci-intel-cnl 0000:00:1f.3: tplg: overriding topology mclk_id 1 by quirk 0
[    7.544509] sof-audio-pci-intel-cnl 0000:00:1f.3: tplg: config SSP0 fmt 0x4001 mclk 19200000 bclk 4800000 fclk 48000 width (24)32 slots 2 mclk id 0 quirks 0 clks_control 0x0
[    7.544521] sof-audio-pci-intel-cnl 0000:00:1f.3: tplg: overriding topology mclk_id 1 by quirk 0
[    7.544521] sof-audio-pci-intel-cnl 0000:00:1f.3: tplg: config SSP0 fmt 0x4001 mclk 19200000 bclk 4800000 fclk 48000 width (24)32 slots 2 mclk id 0 quirks 0 clks_control 0x0

However, I am not so sure what I shall add in /etc/modprobe.d/alsa-base.conf, I tried to add this:

options snd-soc-sof-es8336 quirk=0x20

but it did not change anything

Also, I do not have a headset with microphone to test it unfortunately. As for the internal mic, I don't understand what is a PCH Dmic or a Amic for that matter, I can give you the output (translated in english) of sudo arecord -l

card 0 : sofessx8336 [sof-essx8336], device 0 : ES8336 (*) []
  subdevice : 1/1
  subdevice #0 : subdevice #0
card 0 : sofessx8336 [sof-essx8336], device 1 : DMIC (*) []
  subdevice : 1/1
  subdevice #0 : subdevice #0
card 0 : sofessx8336 [sof-essx8336], device 2 : DMIC16kHz (*) []
  subdevice : 1/1
  subdevice #0 : subdevice #0
yangxiaohua2009 commented 2 years ago

You may already know that changing qurik means changing the defination in sound/soc/intel/boards/sof_es8336.c. For quirk 0x20, you enabled bit 5, SOF_ES8336_ENABLE_DMIC, which enables DMIC.

You need to first remove defined quirk so that you can get the original value of your quirk. Then add quirk bit7 SOF_ES8336_HEADPHONE_GPIO to the quirk value. Now the headphone gpio is enabled.

cat /sys/kernel/debug/gpio now shows two gpios instead of one.

Now test your speaker and headphones. @fbolgar

fbolgar commented 2 years ago

Well actually, I did the dmesg before adding the line to the alsa-base.conf, so the 0x20 (00100000 in binary) quirk was the original one I guess. If I take this and want to add bit7, I get quirk 0xA0 (10100000 in binary) Then I added this line: options snd-soc-sof-es8336 quirk=0xA0 at the end of /etc/modprobe.d/alsa-base.conf I powered off and on, and now headset works !! brilliant thanks. Indeed, the /sys/kernel/debug/gpio now shows two gpio, one for "speakers-enable" and one for "headphone-enable".

However, the internal microphone still doesn't work, do you think that this is something that can be fixed somehow ?

yangxiaohua2009 commented 2 years ago

If you are using a dmic, backup and try the lastest ucm config. UCM files lies in /usr/share/alsa/ucm2 alsa-ucm-conf If this doesn't work then please live without am internal mic. No backward support is provided for dmic.

ameenjuz commented 2 years ago

@yangxiaohua2009 puting this quirk=1b0 under /etc/modprobe.d/alsa-base.conf worked fine for me cat /sys/kernel/debug/gpio now shows headphone enable Speaker enable Everything is working except headset because i didn't test yet I have little issue after wake from sleep When i put to sleep my laptop with headphone plugged Then when i got wake up my laptop from sleep the headphone is not working Only working speaker
to workaround unplugged the headphone and replugged then sound become Do you have any i dea? how to fix this issue

yangxiaohua2009 commented 2 years ago

@ameenjuz See https://github.com/yangxiaohua2009/custom-kernel/issues/9

ameenjuz commented 2 years ago

@yangxiaohua2009
Headphone and usb headphone is very low volume also speaker I saw alsamixs all setting to 100% How to increae volume to high I tested my headphone and usb headphone to another os like win 11 on macos it is oky enough volume but on ubuntu 22.04 low volume

fbolgar commented 2 years ago

@yangxiaohua2009 I tried recently with a headset with integrated microphone and after a few tweaks worked properly.

However, I have a problem with the volume of sound, basically when I plug the headphones, the sound is fine, but when I unplug the headphones, the sound from the speakers is very low and bad quality. I realized that I could make the speakers work properly by setting the "Headphone" volume to 100. Let me show you the alsamixer at different steps:

First I plug in the headphones, they work properly: with_headphones_plugged_in

Then I unplug the headphones, the sound from the speaker is very low: headphones_unplugged_low_speaker_volume

Finally I increase the volume from "headphone" to 100, and the volume returns back to normal with the speakers headphones_unplugged_correct_speaker_volume

Basically what would make me happy is a way of keeping the first bar "headphone" to 100, even when I unplug the headphones. Do you know how I could do that ?

Thanks a lot,

fbolgar commented 2 years ago

Also I realize that there is not way to switch from "headphone" to "speaker". Say for instance that I want to use the headset microphone but the speakers, I cannot do that because when I plug the headphones, the speakers are not available anymore as output device. Is there a way to change that ?

yangxiaohua2009 commented 2 years ago

You need a ucm to automatically set kcontrols. ucm.zip

yangxiaohua2009 commented 2 years ago

Also, use pavucontrol to manually switch output.

ameenjuz commented 2 years ago

@yangxiaohua2009 i appreciate your helping i have little issue when i recording screen with kooha app through speaker then my voice is very low recoded and system sound playing video recorded enough voice by my voice is very low and everything is recording fine but i think this is due to mono interference during screen recording by speaker
other hand with headphone everything record fine how to disable mono from speaker please reply i have essx8336 and i attached alsa-info alsa-info.zip

yangxiaohua2009 commented 2 years ago

@ameenjuz May be you need the aec pulseaudio module see link here

Change the file /etc/pulse/default.pa and add the line load-module module-echo-chancel