# No sound with sound card Intel Comet Lake PCH-LP cAVS



## Moli (Nov 13, 2022)

Hello everyone, 

I just installed FreeBSD 13.1 on my new PC which has an *Intel Comet Lake PCH-LP cAVS* sound card and unfortunately I can't get the sound to work.

I understand from this link (https://github.com/freebsd/freebsd-src/blob/master/sys/dev/sound/pci/hda/hdac.h#L67) that the Intel High Definition Audio bridge device driver would supports the PCH version. So as indicated on snd_hda(4), I added the line `snd_hda_load="YES"` in /boot/loader.conf.

And then, when I try a `cat /dev/sndstat`, I can see my card: 

```
# cat /dev/sndstat
Installed devices:
pcm0: <Intel Kaby Lake (HDMI/DP 8ch)> (play) default
No devices installed from userspace.
```

But I still have no sound. Would you have an idea please?


----------



## T-Daemon (Nov 14, 2022)

Moli said:


> So as indicated on snd_hda(4), I added the line `snd_hda_load="YES"` in /boot/loader.conf.


That setting is not needed, snd_hda(4) is compiled in the GENERIC kernel.



Moli said:


> Would you have an idea please?


Check mixer(8) settings  "vol" and "pcm".

Try `cat /COPYRIGHT > /dev/dsp`

Try from a multimedia player choosing the audio device. For example multimedia/vlc hotkey *Shift + A* to cycle through audio devices, or menu "Audio" -> "Audio Device".

Or multimedia/mpv `--audio-device=<name>`. List devices with `mpv  --audio-device=help`.

If neither of the suggestions work you can try patching hdac.c (HDA controller driver), see posts from Thread audio-through-hdmi-not-working-with-intel-hd-graphics-530.87041

https://forums.freebsd.org/threads/...-with-intel-hd-graphics-530.87041/post-587521 .
https://forums.freebsd.org/threads/...-with-intel-hd-graphics-530.87041/post-587572 .


----------



## shepper (Nov 14, 2022)

Moli said:


> # cat /dev/sndstat Installed devices: pcm0: <Intel Kaby Lake (HDMI/DP 8ch)> (play) default No devices installed from userspace.


At boot, FreeBSD sorts pcm devices, usually by location and assigns each location a pcm#.  For example, pcm0 is the rear jacks ports, pcm1 is the group of front jacks, pcm2 could be the motherboard hdmi and pcm3 could be a sound card.  By default only one is used and /dev/dsp is linked to the one used.

Review the FreeBSD handbook on multimedia:
https://docs.freebsd.org/en/books/handbook/multimedia/

and use sysctl to set the default sound unit accordingly.


----------



## Moli (Nov 14, 2022)

Thank you very much for your help to both of you.



T-Daemon said:


> If neither of the suggestions work you can try patching hdac.c (HDA controller driver), see posts from Thread audio-through-hdmi-not-working-with-intel-hd-graphics-530.87041


T-Daemon indeed unfortunately nothing worked. But I see that the link you recommended is for sound through HDMI. The problem is that I already can't get it to work "normally" without being connected to HDMI. Here is the feedback of mpv --audio-device=help:

```
# mpv --audio-device=help
List of detected audio devices:
  'auto' (Autoselect device)
  'oss//dev/dsp' (Default)
  'oss//dev/dsp0' (Intel Kaby Lake (HDMI/DP 8ch))
```





shepper said:


> At boot, FreeBSD sorts pcm devices, usually by location and assigns each location a pcm#. For example, pcm0 is the rear audio ports, pcm1 is the group of front ports, pcm2 could be the motherboard hdmi and pcm3 could be the a sound card. By default only one is used and /dev/dsp is linked to the one used.


shepper it looks like I only have one sound card, here is the feedback from dmesg | grep pcm:

```
# dmesg | grep pcm
pcm0: <Intel Kaby Lake (HDMI/DP 8ch)> at nid 3 on hdaa0
pcm0: <Intel Kaby Lake (HDMI/DP 8ch)> at nid 3 on hdaa0
```


----------



## shepper (Nov 14, 2022)

Moli said:


> # mpv --audio-device=help List of detected audio devices: 'auto' (Autoselect device) 'oss//dev/dsp' (Default) 'oss//dev/dsp0' (Intel Kaby Lake (HDMI/DP 8ch))


If you `ls -al /dev/ds*` you should see that /dev/dsp is a soft link to /dev/dsp0.  I'm suprised that you only have one numbered dsp.  Physically, do you have audio jacks?  Does dmesg have other "hda" matches?

My last intel laptop had both SoC (system on chip) and a traditional sound chip.  It's running Arch Linux and I had 2 alsa sound cards generated.  I'm not sure where FreeBSD is with SoC drivers.


----------



## T-Daemon (Nov 15, 2022)

Moli said:


> But I see that the link you recommended is for sound through HDMI. The problem is that I already can't get it to work "normally" without being connected to HDMI.


I see. I assumed you are looking for sound on the HDMI.



Moli said:


> I understand from this link (https://github.com/freebsd/freebsd-src/blob/master/sys/dev/sound/pci/hda/hdac.h#L67) that the Intel High Definition Audio bridge device driver would supports the PCH version.


Check the device ID of the sound device on your PC if it matches with the defined in sys/dev/sound/pci/hda/hdac.h, run `pciconf -lv | grep -B3 multimedia`, look for `device=`. Eventually there will be multiple HD audio controller listed.

```
#define HDA_INTEL_PCH           HDA_MODEL_CONSTRUCT(INTEL, *0x3b56*)
     #define HDA_INTEL_PCH2          HDA_MODEL_CONSTRUCT(INTEL, *0x3b57*)
```


----------



## Moli (Nov 15, 2022)

shepper said:


> If you `ls -al /dev/ds*` you should see that /dev/dsp is a soft link to /dev/dsp0. I'm suprised that you only have one numbered dsp. Physically, do you have audio jacks? Does dmesg have other "hda" matches?


I am indeed surprised to see that I do not have a /dev/dsp link.

```
#  ls -al /dev/ds*
crw-rw-rw-  1 root  wheel  0x180 Nov 15 20:47 /dev/dsp0.0
```
Yes, I have a jack, but unfortunately I don't have sound either.
I have indeed two other lines but I confess I don't know what to do with them :

```
# dmesg | grep hda
hdac0: <Intel Comet Lake-LP HDA Controller> mem 0xb1218000-0xb121bfff,0xb1000000-0xb10fffff at device 31.3 on pci0
hdacc0: <Intel Kaby Lake HDA CODEC> at cad 2 on hdac0
hdaa0: <Intel Kaby Lake Audio Function Group>GEOM_ELI: Encryption: AES-XTS 256
 at nid 1 on hdacc0
pcm0: <Intel Kaby Lake (HDMI/DP 8ch)> at nid 3 on hdaa0
```



T-Daemon said:


> I see. I assumed you are looking for sound on the HDMI.


No, I'm sorry, I misspoke, I apologize.



T-Daemon said:


> Check the device ID of the sound device on your PC if it matches with the defined in sys/dev/sound/pci/hda/hdac.h, run `pciconf -lv | grep -B3 multimedia`, look for `device=`. Eventually there will be multiple HD audio controller listed.


Well apparently I was wrong about it being a PCH but it is a HDA_INTEL_CMLKLP which is also present in sys/dev/sound/pci/hda/hdac.h : 

```
#  pciconf -lv | grep -B3 multimedia
hdac0@pci0:0:31:3:      class=0x040100 rev=0x00 hdr=0x00 vendor=0x8086 device=0x02c8 subvendor=0x1e39 subdevice=0xb993
    vendor     = 'Intel Corporation'
    device     = 'Comet Lake PCH-LP cAVS'
    class      = multimedia
```


----------



## shepper (Nov 16, 2022)

Moli said:


> I am indeed surprised to see that I do not have a /dev/dsp link.


Something is amiss.
I noticed that you loaded snd_hda in /boot/loader.conf.  This is no longer necessary as snd_hda is statically built into the default kernel  Did you enable i915kms in /etc/rc.conf?
https://forums.freebsd.org/threads/...-with-intel-hd-graphics-530.87041/post-587432


----------



## T-Daemon (Nov 16, 2022)

Moli said:


> No, I'm sorry, I misspoke, I apologize.


No problem at all.

I must also apologize. Focusing on the HDMI, it escaped me that there are no analog devices listed in the /dev/sndstat output from your post # 1, and I managed to  subsequently missing that fact.

Have you checked with another OS the functionality of the analog sound system? If not, check the PC's UEFI/BIOS for audio settings.

If UEFi/BIOS settings are alright, it might be a bug because of missing pcm devices for the analog audio device.

snd_hda(4)

```
BUGS
     *Some Hardware/OEM vendors tend to screw up BIOS settings or use custom
     unusual CODEC wiring that create problems to the driver.  This may result
     in missing pcm devices*, or a state where the snd_hda driver seems to
     attach and work, but no sound is played.  Some cases can be solved by
     tuning loader.conf variables.  But before trying to fix problem that way,
     make sure that there really is a problem and that the PCM audio device in
     use really corresponds to the expected audio connector.

     Some vendors use non-standardized General Purpose I/O (GPIO) pins of the
     codec to control external amplifiers.  In some cases setting a
     combination of GPIO bits may be needed to make sound work on a specific
     device.

     HDMI and DisplayPort audio may also require support from video driver.
```

Found some hardware probes listing the 'Intel Comet Lake PCH-LP':

Here a ThinkPad T14 dmesg excerpt:

```
hdac0: <Intel Comet Lake-LP HDA Controller> mem 0xef83c000-0xef83ffff,0xeea00000-0xeeafffff at device 31.3 on pci0
...
hdacc0: <Realtek ALC257 HDA CODEC> at cad 0 on hdac0
hdaa0: <Realtek ALC257 Audio Function Group> at nid 1 on hdacc0
pcm0: <Realtek ALC257 (Analog)> at nid 20 and 25 on hdaa0
pcm1: <Realtek ALC257 (Right Analog Headphones)> at nid 33 on hdaa0
hdacc1: <Intel Kaby Lake HDA CODEC> at cad 2 on hdac0
hdaa1: <Intel Kaby Lake Audio Function Group> at nid 1 on hdacc1
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> at nid 3 on hdaa1
```

A ThinkPad E14:

```
hdac0: <Intel Comet Lake-LP HDA Controller> mem 0xc131c000-0xc131ffff,0xc1000000-0xc10fffff at device 31.3 on pci0
...
hdacc0: <Conexant (0x1f86) HDA CODEC> at cad 0 on hdac0
hdaa0: <Conexant (0x1f86) Audio Function Group> at nid 1 on hdacc0
pcm0: <Conexant (0x1f86) (Analog)> at nid 23 and 26 on hdaa0
pcm1: <Conexant (0x1f86) (Left Analog Headphones)> at nid 22 on hdaa0
hdacc1: <Intel Kaby Lake HDA CODEC> at cad 2 on hdac0
hdaa1: <Intel Kaby Lake Audio Function Group> at nid 1 on hdacc1
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> at nid 3 on hdaa1
```

A Intel NUC, also missing pcm devices:

```
hdac0: <Intel Comet Lake-LP HDA Controller> mem 0x6023110000-0x6023113fff,0x6023000000-0x60230fffff at device 31.3 on pci0
...
hdacc0: <Intel Kaby Lake HDA CODEC> at cad 2 on hdac0
hdaa0: <Intel Kaby Lake Audio Function Group> at nid 1 on hdacc0
```

In case UEFI/BIOS settings don't resolve the issue, I suggest you open a bug report to address the problem to a FreeBSD developer familiar with the systems sound infrastructure. It's more likely to get their attention there than here in forums.


----------



## Moli (Nov 16, 2022)

shepper said:


> I noticed that you loaded snd_hda in /boot/loader.conf. This is no longer necessary as snd_hda is statically built into the default kernel Did you enable i915kms in /etc/rc.conf?


I have unloaded snd_hda and have this line kld_list="fusefs i915kms" in /etc/rc.conf.



T-Daemon said:


> In case UEFI/BIOS settings don't resolve the issue, I suggest you open a bug report to address the problem to a FreeBSD developer familiar with the systems sound infrastructure. It's more likely to get their attention there than here in forums.


I will indeed try to open a ticket, thank you very much for your advice.


----------



## Partmedia (Nov 19, 2022)

Hi Moli ,

The intel_hda driver depends on some preconfigured "associations" set by BIOS to determine which sound devices to create in `/dev/sndstat`.

It is likely that your particularly computer (the physical box with the motherboard) has poorly-configured audio defaults.

I would suggest running this command (non-root):

`$ sysctl dev.hdaa.0`

This will dump all the 'nodes' that your audio driver sees, some of which may be analog output devices.

From there, you will need to set the associations of your analog devices that are not showing up to appropriate values so that audio devices are created for them. See snd_hda() for more details.

If you are having trouble with this, run the command and attach the output here.

I should write a guide for doing this on the wiki at some point...


----------



## Partmedia (Nov 19, 2022)

Take a look at this forum post for example: https://forums.freebsd.org/threads/snd_hda-line-in-jack-does-not-work.77468/


----------



## Moli (Nov 20, 2022)

Hi Partmedia , 

Thank you very much for your help. From what I understand I have the impression that the pin configuration for my audio output (*dev.hdaa.0.nid2*) is missing.

Indeed, here is the output of sysctl dev.hdaa.0 :

```
$ sysctl dev.hdaa.0
dev.hdaa.0.init_clear: 0
dev.hdaa.0.reconfig: 0
dev.hdaa.0.gpo_config:  
dev.hdaa.0.gpo_state:  
dev.hdaa.0.gpio_config:  
dev.hdaa.0.gpio_state:  
dev.hdaa.0.gpi_state:  
dev.hdaa.0.config: forcestereo,ivref50,ivref80,ivref100,ivref,vref
dev.hdaa.0.nid3_original: 0x18560020 as=2 seq=0 device=Digital-out conn=Jack ctype=Digital loc=0x18 color=Unknown misc=0
dev.hdaa.0.nid3_config: 0x18560020 as=2 seq=0 device=Digital-out conn=Jack ctype=Digital loc=0x18 color=Unknown misc=0
dev.hdaa.0.nid3: pin: Digital-out (Jack)
     Widget cap: 0x0040778d PWR DIGITAL UNSOL 8CH
    Association: 0 (0x0001)
        Pin cap: 0x09000094 PDC OUT HDMI DP HBR
     Pin config: 0x18560020 as=2 seq=0 device=Digital-out conn=Jack ctype=Digital loc=0x18 color=Unknown misc=0
    Pin control: 0x00000040 OUT
     Output amp: 0x80000000 mute=1 step=0 size=0 offset=0 (0/0dB)
    Connections: 1
          + <- nid=2 [audio output]

dev.hdaa.0.nid2: audio output
     Widget cap: 0x00006611 PWR DIGITAL 8CH
    Association: 0 (0x0001)
            OSS: pcm (pcm)
     Stream cap: 0x00000005 AC3 PCM
        PCM cap: 0x001a07f0 16 24 32 bits, 32 44 48 88 96 176 192 KHz

dev.hdaa.0.%parent: hdacc0
dev.hdaa.0.%pnpinfo: type=0x01 subsystem=0x80860101
dev.hdaa.0.%location: nid=1
dev.hdaa.0.%driver: hdaa
dev.hdaa.0.%desc: Intel Kaby Lake Audio Function Group
```

When I do sysctl dev.hdaa.0.nid3_config (from what I understand, the jack output, which does not work either, despite the fact that the association number of the pin is different from 0, so maybe I don't understand anything at all...  ), I get :

```
$ sysctl dev.hdaa.0.nid3_config
dev.hdaa.0.nid3_config: 0x18560020 as=2 seq=0 device=Digital-out conn=Jack ctype=Digital loc=0x18 color=Unknown misc=0
```

But when I do sysctl dev.hdaa.0.nid2_config, it tells me that the _oid_ does not exist:

```
$ sysctl dev.hdaa.0.nid2_config
sysctl: unknown oid 'dev.hdaa.0.nid2_config'
```


----------

