sebanc / brunch

Boot ChromeOS on x86_64 PC - Supports Intel CPU/GPU from 8th gen or AMD Ryzen
GNU General Public License v3.0
3.68k stars 392 forks source link

Internal microphone not working #56

Open frigis1 opened 4 years ago

frigis1 commented 4 years ago

This is on an Acer Spin SP111-31. Internal microphone is not working, but if I plug in a headset with a microphone, the headset mic works fine. Currently using r80 k4.19 stable - r81 k4.19 testing does not work on this laptop.

omminp commented 4 years ago

@Adkatka I have the same result on my Dell 3185.
However, I find that "amixer -c1 set "Internal Mic" toggle" works without the error, and then "amixer -c1 set "Capture" 40% also works. And the mic function is restored.
Perhaps the device 0 does not exist for this machine.

parinay602 commented 4 years ago

guys nothing is working....PLease help

CreaticaONG commented 3 years ago

Hello, First of all sorry for my bad English, I didn't practice for a long time... I have the same issue on my Dell Latitude E5450. I got it working following these steps:

  1. My Dell laptop has two sound cards: HDMI and PCH. You can verify your sound cards typing in a shell aplay -l
  2. In my case HDMI sound card has the 0 id and the PCH has id 1. CRAS (Chrome OS Audio Server) use default id 0 sound card (in my case HDMI that don't have capture function) and that's why the commands above not work for me. To change default sound card I modified /etc/modprobe.b/alsa.conf adding:
options snd cards_limit=2
options snd-hda-intel id=PCH index=0
options snd-hda-intel id=HDMI index=1
  1. Save file and reboot.
  2. Check the order with aplay -l
  3. Perform the steps described above:
sudo mkdir /var/brunch/bootscripts
echo 'amixer -c0 set "Internal Mic" toggle' | sudo tee /var/brunch/bootscripts/sound.sh
echo 'amixer -c0 set "Capture" 40%' | sudo tee -a /var/brunch/bootscripts/sound.sh
sudo chmod 0755 /var/brunch/bootscripts/sound.sh

Thanks @sebanc for the brunch project!

omminp commented 3 years ago

@sebanc Folllowing on from the previous comment, I can confirm that in my case also
aplay -l gives

List of PLAYBACK Hardware Devices card 0: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Generic [HD-Audio Generic], device 0: ALC3204 Analog [ALC3204 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0

AND chronos@localhost ~/Downloads $ amixer -c 0 set "Internal Mic" toggle amixer: Unable to find simple control 'Internal Mic',0

AND chronos@localhost ~/Downloads $ amixer -c 1 set "Internal Mic" toggle Simple mixer control 'Internal Mic',0 Capabilities: cswitch cswitch-joined cswitch-exclusive Capture exclusive group: 0 Capture channels: Mono Mono: Capture [on]

With -c 0 the 'set' command returns a null , with the error message. Perhaps the current internal_mic_fix script could include both cases by checking for a null return from amixer -c 0 set "Internal Mic" toggle

and in that case execute amixer -c 1 set "Internal Mic" toggle

It will mean more users will be fixed. It seems to be an ongoing issue for users.

sebanc commented 3 years ago

@CreaticaONG @omminp Thanks for your investigations and feedback, it is really helpful :)

@omminp I am thinking that forcing the forcing the HDMI soundcard as 2nd might be the proper way to move on with this. If you set only options snd-hda-intel id=HDMI index=1 in /etc/modprobe.b/alsa.conf, does it change the soundcard order on your device ?

omminp commented 3 years ago

As requested, added 1 option to alsa.conf

Set this to the correct number of cards.

options snd cards_limit=1

options snd-hda-intel id=HDMI index=1

The line snd cards_limit=1 was already in the file, and hasn't been changed.

After reboot, the soundcard order is reversed, as here:

chronos@localhost / $ aplay -l List of PLAYBACK Hardware Devices card 0: Generic [HD-Audio Generic], device 0: ALC3204 Analog [ALC3204 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0

I hope this helps you work out the best way to proceed. Let me know if I can do any further testing for you.

sebanc commented 3 years ago

@omminp Thanks for the feedback :) I just have a last doubt, could you confirm that with "options=internal_mic_fix" added to the grub config and "options snd-hda-intel id=HDMI index=1" added to /etc/modprobe.b/alsa.conf your microphone works correctly ?

(if the rootfs is rebuilt when you add "options=internal_mic_fix", you will have to add "options snd-hda-intel id=HDMI index=1" to /etc/modprobe.b/alsa.conf again)

omminp commented 3 years ago

Well it took a while to realize that I had a file /var/brunch/bootstrap/alsa.sh which I hadn't removed and which enabled the mic...

After deleting that, here are the test results:

mic tests.pdf

Not sure what the doubt was, but I can confirm that mic works only with both options added. Tested on 2 installations on the same machine.

sebanc commented 3 years ago

@omminp Thanks a lot for the report, it is very clear :)

I have modified the "internal_mic_fix" option accordingly and will add a comment here when I have a new test build with this change included.

ulrichunter commented 3 years ago

@CreaticaONG what do i have to change in alsa.conf to change the sound cards? Your options don't work for me: options snd cards_limit=2 options snd-hda-intel id=PCH index=0 options snd-hda-intel id=HDMI index=1

chronos@localhost / $ aplay -l List of PLAYBACK Hardware Devices card 0: Audio [Intel HDMI/DP LPE Audio], device 0: HdmiLpeAudio [Intel HDMI/DP LPE Audi] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: Audio [Intel HDMI/DP LPE Audio], device 1: HdmiLpeAudio [Intel HDMI/DP LPE Audi] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: bytcrrt5640 [bytcr-rt5640], device 0: 1 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: bytcrrt5640 [bytcr-rt5640], device 1: Deep-Buffer Audio (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0

Thank You!

sebanc commented 3 years ago

@ulrichunter Could you try "options snd_hdmi_lpe_audio index=1" ?

ulrichunter commented 3 years ago

@sebanc the sound cards have changed, but mic is not working...

chronos@localhost / $ aplay -l List of PLAYBACK Hardware Devices card 0: bytcrrt5640 [bytcr-rt5640], device 0: 1 [] Subdevices: 0/1 Subdevice #0: subdevice #0 card 0: bytcrrt5640 [bytcr-rt5640], device 1: Deep-Buffer Audio (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Audio [Intel HDMI/DP LPE Audio], device 0: HdmiLpeAudio [Intel HDMI/DP LPE Audi] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Audio [Intel HDMI/DP LPE Audio], device 1: HdmiLpeAudio [Intel HDMI/DP LPE Audi] Subdevices: 1/1 Subdevice #0: subdevice #0

Thank You!

sebanc commented 3 years ago

@ulrichunter As far as I can tell, now that the sound cards are in the right order and that you have enabled "options=internal_mic_fix", you would need the correct alsa ucm files.

You could try: https://github.com/alsa-project/alsa-ucm-conf/tree/master/ucm2/bytcr-rt5640

or other ones.

Alsa ucm files go in /usr/share/alsa/ucm directory

ulrichunter commented 3 years ago

@sebanc when i add "options=internal_mic_fix" to "grub.cfg" then sound is off also... i have tryed the original ucm-files and then deleted the original ucm-files and copied the ucm-files from your link to that folder, but mic is not working...

chronos@localhost / $ amixer -c0 set "Internal Mic" toggle Simple mixer control 'Internal Mic',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [on]

chronos@localhost / $ amixer -c0 set "Capture" 40% amixer: Unable to find simple control 'Capture',0

Thank You!

sebanc commented 3 years ago

Actually, "internal_mic_fix" option just runs amixer -q -c 0 set "Internal Mic" toggle on boot, I am not sure why it turns sound off for your device.

Maybe 5.4 kernel might help (I have no clue), I have sent you a github email invite for "brunch-testing" repo.

ulrichunter commented 3 years ago

@sebanc I have tryed the testing repo, it's the same... maybe CRAS is still using the wrong card, when I start "alsamixer" and hit TAB once to switch to CAPTURE then I see a message "this sound device does not have any capture controls" when I start alsamixer --card=0 then I have many bars in PLAYBACK and CAPTURE which I can change with the arrow-keys. Thank You!

sebanc commented 3 years ago

There is not really a setup for cras, I believe it is just a virtual interface. Cras might be searching for a specific microphone control name and in your case ucm files might need to be tweaked to be compatible.

Unfortunately, there are many things I still don't understand regarding audio in ChromeOS (even in linux I don't have much audio framework knowledge) so I cannot really help further with this.

ulrichunter commented 3 years ago

@sebanc I can live without a mic... it's a great framework! Thank You!

k0gen commented 3 years ago

On Lenovo x270 and older C50-30 I have found out that: options snd_hda_intel index=0 model=headset-mic in /etc/modprobe.d/alsa.conf fixes muted headphone jack. How can we make it permanent so we don’t have to reapply it after changing and trying some other options in grub?

sebanc commented 3 years ago

@k0gen Adding "snd_hda_intel.index=0 snd_hda_intel.model=headset-mic" on the kernel command line should work the same and be robust against updates.

k0gen commented 3 years ago

@k0gen Adding "snd_hda_intel.index=0 snd_hda_intel.model=headset-mic" on the kernel command line should work the same and be robust against updates.

Just did that and can confirm this works perfectly! Thank You. (I'll go and update my wiki entry regarding lenovo x270 now)

ludem commented 3 years ago

@sebanc the sound cards have changed, but mic is not working...

chronos@localhost / $ aplay -l List of PLAYBACK Hardware Devices card 0: bytcrrt5640 [bytcr-rt5640], device 0: 1 [] Subdevices: 0/1 Subdevice #0: subdevice #0 card 0: bytcrrt5640 [bytcr-rt5640], device 1: Deep-Buffer Audio (*) [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Audio [Intel HDMI/DP LPE Audio], device 0: HdmiLpeAudio [Intel HDMI/DP LPE Audi] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Audio [Intel HDMI/DP LPE Audio], device 1: HdmiLpeAudio [Intel HDMI/DP LPE Audi] Subdevices: 1/1 Subdevice #0: subdevice #0

Thank You!

Same card here: internal mic doesn't work and headset is not recognized when plugged in and the audio doesn't switch. I've tried suggested kernel options with no luck.

On Lubuntu Linux everything works out of the box.

xellotath commented 3 years ago

@sebanc So I don't know a lot about the internals but I played with this for a while and did some testing on my Lenovo Yoga c940, and found some things:

arecord -L returns only one card, sof-hda-dsp. alsamixer -c0 reports the chip as Realtek ALC298. arecord -l returns 4 devices(it used to be only HDA Analog, but after some tweaking in the options, including disable_intel_hda, got them all to show up). The rest are now called HDA Digital, DMIC, and DMIC16kHz.

alsamixer -c0 showed however the ones that appeared under amixer -c0 scontents that had capture channels under them. Those were Mic Boost, Capture, Dmic0, Dmic1 2nd, PGA2.0 2 Master, and PGA4.0 4 Master. Using mic-test.com I could see whether there was input and from where by playing with their volumes on alsamixer. Out of all these I should mention, only Capture and Dmic could toggle through amixer -c0 set [...] toggle. Interestingly enough amixer also reported a device called 'Mic' that has playback but no capture channels. Toggling it on or changing its volume did nothing.

Anyway, I came down to the following: Capture records the audio jack for me. It produces white noise until you connect headphones, after which it records the sounds played back on them. Dmic is my actual mic, but I could only tell after booting in mint where I could see changes in alsamixer reflected the mic's(Dmic) settings(it's properly recognized there, and everything is identical). PGA2.0 2 Master is the volume of the headphone microphone, when there is one connected. It cannot be toggled. Toggling the ones that can be toggled does not disable the headphone mic.

So basically I know my mic is the Dmic device on my sound card, but the one being used is the wrong device. And I don't really know how to change it.

JamesMaria commented 3 years ago

@sebanc How to open up kernel lines and also any more updates on fixing microphone?

omminp commented 2 years ago

I found the laptop mic had stopped working, it had responded to the internal_mic_fix when I applied it earlier. I found a couple of things that may be worth updating, since internal mic operation still seems to cause problems for some users.

  1. I need the option "internal_mic_fix2" for my laptop
  2. that option is not listed under 'Framework options' in the Readme.md - should be added there
  3. that option is not listed in the setup routine in GRUB - should be added there
  4. editing the GRUB at boot now shows 'options=$options' rather than the options that have been set, additional options added after and separated by a comma are executed after whatever is listed in $options . This needs to be explained in the paragraph at the end of 'Framework options' .

I was able to add 'internal_mic_fix2' to GRUB and see it added in dmesg after booting - mic then operates correctly for me.

channelup69 commented 2 years ago

mod

Did you ever get this resolved I have a very similar set up

omminp commented 2 years ago

the option for "internal_mic_fix2" has been reinstated to the Brunch setup screen and works for me.

RuBronyCone commented 1 year ago

I have found that the problem goes away if I turn off one of the stereo channels in Capture. Is there a way to change the built-in microphone from stereo to mono? Or how to save these changes if the microphone constantly resets its settings? He resets them only when, after a reboot, the microphone is first accessed.

RuBronyCone commented 1 year ago

The only way I'm going to get the microphone to work properly on the Lenovo 330 is to place the script in the usr/local/bin directory, grant permissions, and run it through a shell. Here is the script:

arecord -f cd -d 5 /tmp/test-mic.wav
amixer -c0 set "Capture" 0%,100% unmute cap

When I put this script in var/brunch/bootscript and give it the right permissions, nothing happens when I restart it. Either this sequence does not work at the stage at which the bootscripts work, or I'm doing something wrong. How can I force this script to run on login?