Internal microphone setup question

I have a T470s, and I haven't been able to get my mic to work in Chromium for Google Meet.

The sound card is working, and the permissions are set in Chromium. I think the issue is that Chromium is listening to the default input, but the mic is not the default.

I used mixer to set the default rec device to mic -- and it shows Recording device: mic -- but that didn't work.

I looked at cat /dev/sndstat and got

Code:
Installed devices:
pcm0: <Realtek ALC298 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Realtek ALC298 (Internal Analog Mic)> (rec)
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> (play)

I tested in Audacity, where I am able to select input source, and selecting dsp1 (which I guess = pcm1), the internal mic was fine.

The handbook covers changing default device but I don't see something about just changing the default input.

Any ideas?
 
Code:
Installed devices:
pcm0: <Realtek ALC298 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Realtek ALC298 (Internal Analog Mic)> (rec)
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> (play)
So your microphone seems to be device #1.
Thus, what is the output from mixer -f /dev/mixer1?
 
Code:
mixer -f /dev/mixer1
Mixer rec      is currently set to  53:53
Mixer monitor  is currently set to  67:67
Recording source: monitor

Yes, this looks like the default recording source is wrong. So how to change it?

I tried
Code:
mixer +rec mic
and the output was
Code:
Recording source: mic

But then
Code:
mixer -f /dev/mixer1
still showed
Code:
recording source: monitor

Same when I used
Code:
mixer =rec mic
and
Code:
mixer =rec /dev/mixer1
 
I think I would try
Code:
mixer -f /dev/mixer1 =rec mic

This gives the error
Code:
mixer -f /dev/mixer1 =rec mic
mixer: unknown recording device: mic
usage: mixer [-f device] [-s | -S] [dev [+|-][voll[:[+|-]volr]] ...
       mixer [-f device] [-s | -S] recsrc ...
       mixer [-f device] [-s | -S] {^|+|-|=}rec rdev ...
devices: rec, monitor
rec devices: speaker, monitor

It seems nonsensical to me that speaker and monitor would be rec devices. I'm also not clear on what the device mixer1 is or how it differs from mixer.
 
Okay... Then next I would try
Code:
mixer -f /dev/mixer1 +rec mic
mixer -f /dev/mixer1 =rec mic

I would agree that it is a little crazy that speaker and monitor are listed as recording devices... According to mixer(8) you can add or remove rdev using + or - respectfully.... I have no idea why /dev/mixer1 is needed, I just used it because olli@ used it to determine the mixer levels in your case... If I had to guess, I would say it's because your internal mic is listed as pcm1... With any luck he will stop back in and impart some more knowledge upon us...
 
This gives the error
Code:
mixer -f /dev/mixer1 =rec mic
mixer: unknown recording device: mic
That was to be expected as mixer1 doesn't have a mic device, only monitor. I found that naming entirely unintuitive and highly confusing myself, mic1 - micN would have made more sense in my opinion, but monitor is supposedly your internal microphone.

It seems nonsensical to me that speaker and monitor would be rec devices. I'm also not clear on what the device mixer1 is or how it differs from mixer.
Each of the different pcm devices comes with it's own mixer device.
Code:
Installed devices:
pcm0: <Realtek ALC298 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Realtek ALC298 (Internal Analog Mic)> (rec)
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> (play)
So according to your information above mixer controls analog inputs/outputs + headphones, whereas mixer1 controls the internal microphone (pcm1).
 
Thanks for the responses.

The documentation is in snd_hda(4). In it you can assign the mic to the default group. Specifically, the Mic is in the pcm1 group and needs to be moved to pcm0.

I read snd_hda, but I apologize that I'm confused still.

pcm0 is my default sound device, including an input called mic.
pcm1 is my analog mic only.

So conceptually, the mic input on pcm0 is not actually the mic and can be ignored. Instead, I need to route the real mic input from pcm1 into pcm0?

e.g.
Code:
Each pcm(4) device    uses two associations: one for playback    and one    for
     recording.     Associations processed    and assigned to    pcm(4) devices in in-
     creasing numerical    order.    In this    case association #0 (1)    will become
     pcm0 device playback, using the internal speakers and Headphones jack
     with speaker automute on the headphones jack connection.  Association #1
     (2) will become pcm1 playback, using the Line-out jack.  Association #2
     (3) will become pcm0 recording, using the external    microphones and    the
     Line-in jack.

I can grasp this idea, but what this looks like in a line of loader.conf code "hint.[...]" I don't know quite where to start.
 
Unfortunately, changing the audio hardware settings is somewhat complex, especially if the vendor wired the codecs in unusual ways, and/or if the BIOS contains bugs pertaining to the audio configuration.

A good start is to type grep hda /var/run/dmesg.boot. First, this tells you what audio controllers are present (hdac<X>). Just as an example, these are mine:
Code:
hdac0: <NVIDIA (0x0fb8) HDA Controller> mem 0xf7080000-0xf7083fff irq 55 at device 0.1 on pci10
hdac1: <AMD (0x1457) HDA Controller> mem 0xf7900000-0xf7907fff irq 43 at device 0.3 on pci13
So, hdac0 is my Nvidia card that supports audio output through HDMI and DisplayPort, and hdac1 is the audio hardware on my mainboard.

Second, you can see what audio codecs are present on those controllers (hdacc<X>). You can think of a “codec” as a chip on that controller. In most cases there is just one codec per controller, numbered “cad 0”:
Code:
hdacc0: <NVIDIA (0x0081) HDA CODEC> at cad 0 on hdac0
hdacc1: <Realtek ALC1220 HDA CODEC> at cad 0 on hdac1

Third, there are so-called “audio function groups” named hdaa<X>. In my case there is just one such group per codec, but I’m not sure if that’s the common case. Mayber there can be more than one. Anyway, this is how it looks for me:
Code:
hdaa0: <NVIDIA (0x0081) Audio Function Group> at nid 1 on hdacc0
hdaa1: <Realtek ALC1220 Audio Function Group> at nid 1 on hdacc1
Every function group has a number of “nodes”. This is what the “nid” (node ID) number refers to. Nodes can be input (line-in, microphone, CD audio, …), output (line-out, headphones, spdif, …), or various other functional units like mixer nodes and vendor-specific nodes. Usually there are several nodes that are disabled, because not all channels supported by the codec are actually used by the hardware. The function group itself is always identified as nid 1, as far as I know.

And finally there are the actual pcm devices. Every pcm device is associated with a number of nids (node IDs) on a function group:
Code:
pcm0: <NVIDIA (0x0081) (HDMI/DP 8ch)> at nid 4 on hdaa0
pcm1: <NVIDIA (0x0081) (HDMI/DP 8ch)> at nid 5 on hdaa0
pcm2: <Realtek ALC1220 (Analog 5.1+HP/2.0)> at nid 20,22,21,27 and 24,26 on hdaa1
pcm3: <Realtek ALC1220 (Rear Digital)> at nid 30 on hdaa1
pcm4: <Realtek ALC1220 (Front Analog Mic)> at nid 25 on hdaa1
In my case, I have a 2.1 speaker system connected to the mainboard’s line-out jack, which is pcm2, so I have the following line in my /etc/sysctl.conf:
Code:
hw.snd.default_unit=2

In your case, you want to change the association of the built-in microphone. You want to associate it with your default pcm device. In order to do that, you have to find out the function group (i.e. the hdaa<X> device) and the nid number <Y> of that microphone, then create a tunable entry for /etc/loader.conf that looks like this:
Code:
hint.hdaa.<X>.nid<Y>.config="..."
where <X> is the number of the hdaa device (function group) and <X> is the ID number of the microphone node.

The value of the entry needs to be constructed so the node is assigned to the same association as your default pcm device.
You can see the current configuration with this command:
Code:
sysctl dev.hdaa.<X>.nid<Y>_config
For example:
Code:
$ sysctl dev.hdaa.1.nid25_config
dev.hdaa.1.nid25_config: 0x02a19050 as=5 seq=0 device=Mic conn=Jack ctype=1/8 loc=Front color=Pink misc=0
Here you can see that the microphone is connected to the 5th association (as=5), which is pcm4 (association numbering starts at 1, while pcm device numbering starts at 0, thus as=5 refers to pcm4). You want to swap this with the node ID that is currently associated with the recoding channel of your default pcm device.
In my particular case, that would be:
Code:
hint.hdaa.1.nid25.config="as=3"
hint.hdaa.1.nid24.config="as=5"
hint.hdaa.1.nid26.config="as=5"
I haven’t actually tried that (my PC doesn’t have a built-in microphone, and I don’t own an external microphone), but I think it should work like that. This is similar to the “Example 1” in the snd_hda(4) manual page.

By the way, you can type sysctl dev.hdaa | less to see a very detailed (and long!) description of your audio setup. However, I’m not really sure if that really helps in this situation… maybe it just creates even more confusion. :)
 
maybe it just creates even more confusion. :)

First, this is excellent. Thank you. I followed every step, and vastly improved my understanding of the audio system.

I found that my internal mic is this
Code:
dev.hdaa.0.nid18_config: 0x90a60140 as=4 seq=0 device=Mic conn=Fixed ctype=Digital loc=Internal color=Unknown misc=1

This is unexpected, since there are only pcm0, pcm1 and pcm2 (pcm2 being HDMI audio). So as=4 implies there would be pcm3?

Anyway, when I added this to /boot/device.hints

Code:
hint.hdaa.0.nid18.config="as=1"

on reboot, the default pcm0 was gone and replaced by what used to be pcm1

before reboot:
Code:
Installed devices:
pcm0: <Realtek ALC298 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Realtek ALC298 (Internal Analog Mic)> (rec)
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> (play)

after reboot:
Code:
Installed devices:
pcm0: <Realtek ALC298 (Internal Analog Mic)> (rec) default
pcm1: <Intel Kaby Lake (HDMI/DP 8ch)> (play)

Commenting out the hint restored previous defaults.

Also I noticed you made 3 hints, but where did nid24 and nid26 come from in your example?
 
Also I noticed you made 3 hints, but where did nid24 and nid26 come from in your example?
Those are the recording devices associated with my pcm2 by default:
Code:
pcm2: <Realtek ALC1220 (Analog 5.1+HP/2.0)> at nid 20,22,21,27 and 24,26 on hdaa1
It’s not possible to add more recording devices to existing ones, so they have to moved way. That’s what the other two hints in my example do. Basically, it moves nid24+nid26 from pcm2 to pcm4, and nid25 from pcm4 to pcm2.
 
Ok, I'm going to bump this thread back because the mic is still no-go

I found virtual_oss and a page in the wiki that describes assigning the internal mic to the primary sound bus.

But the manual is not easy to follow. Having installed the pkg, there's no virtual_oss file in /etc/rc.d. So I made one and added

virtual_oss_enable="YES"
virtual_oss_flags="-R /dev/dsp1"

I chose dsp1 because that's where the mic works in audacity (which can select inputs).

But still no mic in Chrome.

Invoking virtual_oss from the cli as root
Code:
virtual_oss -R /dev/dsp1
virtual_oss: Missing -r or -s parameters

but also
Code:
virtual_oss -r 48000 -R /dev/dsp1
virtual_oss: Missing -r or -s parameters

Is anyone using an internal mic in Chrome that can report success, or is this not supported?
 
Following up, this microphone problem seems have been haunting the forum for a while


I installed pulseaudio -- which I hoped to skip since I was happy with pure alsa -- but immediately this rectified the problem in Firefox. Now the mic is easily selectable in FF. It's also easy to see mic input and adjust it in pavucontrol. Definitely a win for pulseaudio.

However, Chromium is still unable to select from among audio devices. This parallels the threads above.

Is this a bug in Chromium, or something that could be adjusted in the pkg by the maintainer?

Anyway, pulseaudio is at least a solution for web conferencing using Firefox pending something better.
 
Here you can see that the microphone is connected to the 5th association (as=5), which is pcm4 (association numbering starts at 1, while pcm device numbering starts at 0, thus as=5 refers to pcm4). You want to swap this with the node ID that is currently associated with the recoding channel of your default pcm device.

Firstly, olli@ I would like to thank you for your walkthrough, I had to get a microphone working earlier today on one of my reserve machines and never had to fiddle with this stuff before. Your insight was a big help!

Oddly enough my front mic port worked (pcm1) and my rear headphone port worked (pcm0) but not vice versa so my headphone cable couldn't stretch around the entire machine and plug into both, and I couldn't listen from pcm1 whilst playing to pcm0 so some fiddling had to be done to move the mic into the same pcmX as the headphones.

A few things I had noticed whilst following your guide and referring to the manpage here: https://www.freebsd.org/cgi/man.cgi?snd_hda

Each pcm(4) device uses two associations: one for playback and one for
recording. Associations processed and assigned to pcm(4) devices in
increasing numerical order. In this case association #0 (1) will become
pcm0 device playback, using the internal speakers and Headphones jack
with speaker automute on the headphones jack connection. Association #1
(2) will become pcm1 playback, using the Line-out jack. Association #2
(3) will become pcm0 recording, using the external microphones and the
Line-in jack.
It seems that these associations are interleaved and don't just count up in pcmN number. Instead a playback and record is part of the increments:

as=1 is pcm0 (playback)
as=2 is pcm1 (playback)
as=3 is pcm0 (record)
as=4 is pcm1 (record)

Oddly enough I tried to move the headphone out to pcm1 first and it didn't quite work. Either a duplicate pin or invalid pin direction error. However moving the mic to pcm0 did then work instead.

I noticed that upon changing my mic (nid25) association, then nid27 (my headphone) would be changed to something random and generally cause a duplicate pin error. I also found that seq=1, 2 or 3 wasn't always enough and instead 15 had to be used.

There are still a few things that I don't quite understand but I will have a play over the next few days and put together a guide. The man-pages and handbook do not explain this very well.

Probably very specific to my hardware but if anyone owns a Z400 and your microphone isn't working well, feel free to use:

Code:
# Swap mics between pcm0 and pcm1
hint.hdaa.0.nid25.config="as=3" # move front mic to pcm0
hint.hdaa.0.nid24.config="as=4" # move rear mic to pcm1
hint.hdaa.0.nid27.config="as=1 seq=15" # keep headphone in pcm0 (stop it being set some random value)
 
I'm not sure if I'm understanding the ins and outs of "as=n", "nid" and "seq=n" etc but some trial and error got my built-in web cam on a Toshiba Tecra M11 working.
Code:
dev.hdaa.0.nid25_original: 0x90a701f0 as=15 seq=0 device=Mic conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
dev.hdaa.0.nid25_config: 0x90a701ff as=15 seq=15 device=Mic conn=Fixed ctype=Analog loc=Internal color=Unknown misc=1
dev.hdaa.0.nid25: pin: Mic (Fixed)
dev.hdaa.0.nid24_original: 0x04a110f0 as=15 seq=0 device=Mic conn=Jack ctype=1/8 loc=Right color=Black misc=0
dev.hdaa.0.nid24_config: 0x04a11000 as=0 seq=0 device=Mic conn=Jack ctype=1/8 loc=Right color=Black misc=0
dev.hdaa.0.nid24: pin: Mic (Black Jack) [DISABLED]

As you can see, I ended up with hints lines that disabled the jack mic.

What was odd, and had me stumped, is that the jack and speakers are on pcm0 while the webcam mic is on pcm1. But both pcm0 and pcm1 seem to be on hdaa0. WShile there is an hdda1, that's the HDMI device and not used at all in this case.

Anyway, the hint lines I used are:

Code:
hint.hdaa.0.nid25.config="as=15 seq=15"
hint.hdaa.0.nid24.config="as=16 seq=0"

I'm not sure if that as=16 is valid or useful, but using that plus seq=0 disabled the mic jack device on mixer0 and the 1st line seems to have moved the "monitor" (webcam mic) from mixer1 to mixer0
 
Back
Top