# Audio on a Macbook 5.1



## UglyJoe (Aug 31, 2012)

I've recently installed FreeBSD 9.0 on my Macbook. I've got everything up and running except the WiFi and audio. The WiFi I've given up on for now, but every resource I've come across online seemed to have no audio issues and therefore no troubleshooting for getting the audio to work. I've tried the snd_hda(4) driver, which I think is the correct driver for this card, but no luck. Any suggestions? Apologies if this is in the wrong forum.


----------



## SirDice (Aug 31, 2012)

After loading snd_hda(4) what does `$ cat /dev/sndstat` tell you?


----------



## UglyJoe (Aug 31, 2012)

SirDice said:
			
		

> After loading snd_hda(4) what does `$ cat /dev/sndstat` tell you?



Sorry, I should have listed this before:

Relevant portion of dmesg(8):


```
freebsd# dmesg | grep pcm
pcm0: <HDA Realtek ALC885 PCM #0 Analog> at cad 0 nid 1 on hdac0
pcm1: <HDA Realtek ALC885 PCM #1 Analog> at cad 0 nid 1 on hdac0
pcm2: <HDA Realtek ALC885 PCM #2 Digital> at cad 0 nid 1 on hdac0
freebsd#
```

And *cat /dev/sndstat*:


```
freebsd# cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
Installed devices:
pcm0: <HDA Realtek ALC885 PCM #0 Analog> (play/rec) default
pcm1: <HDA Realtek ALC885 PCM #1 Analog> (play/rec)
pcm2: <HDA Realtek ALC885 PCM #2 Digital> (play/rec)
freebsd#
```

Also *cat Filename > /dev/dsp* gives no sound from the speakers.

Thanks,
UJ


----------



## SirDice (Aug 31, 2012)

At least it's detected :e

Have a look at the snd_hda(4) man page. Not all HDA compatible devices are wired the same way. You may need to fiddle with the outputs. The man page explains it in a lot more detail.


----------



## UglyJoe (Aug 31, 2012)

I have looked at it... unfortunately I can't make heads or tails of it. I'm not sure where or what to change. If it's not painfully obvious I'm brand new to BSD and UNIX in general; I can handle reading the manuals on commands, but the ones on drivers are much more confusing. Any suggested resources to look at and learn from?


----------



## lme@ (Aug 31, 2012)

Try this: `# sysctl hw.snd.default_unit=1`
If it works, add it without "sysctl" to /etc/sysctl.conf so that it survives a reboot.


----------



## UglyJoe (Sep 1, 2012)

lme@ said:
			
		

> Try this: `# sysctl hw.snd.default_unit=1`
> If it works, add it without "sysctl" to /etc/sysctl.conf so that it survives a reboot.



Unfortunately this did not work. I would like to look at the associations and sequencing as per the snd_hda(4) driver manual page, as here:


```
So high codec uniformity and flexibility allow driver to configure it in
     many different ways, depending on requested pins usage described by pins
     configuration.  The driver reports such default pin configuration when
     verbose messages enabled:

     hdac0: nid 20 0x01014020 as  2 seq  0   Line-out  Jack jack 1 loc	1 color   Green misc 0
     hdac0: nid 21 0x99130110 as  1 seq  0    Speaker Fixed jack 3 loc 25 color Unknown misc 1
     hdac0: nid 22 0x411111f0 as 15 seq  0    Speaker  None jack 1 loc	1 color   Black misc 1
     hdac0: nid 23 0x411111f0 as 15 seq  0    Speaker  None jack 1 loc	1 color   Black misc 1
     hdac0: nid 24 0x01a19830 as  3 seq  0	  Mic  Jack jack 1 loc	1 color    Pink misc 8
     hdac0: nid 25 0x02a1983f as  3 seq 15	  Mic  Jack jack 1 loc	2 color    Pink misc 8
     hdac0: nid 26 0x01813031 as  3 seq  1    Line-in  Jack jack 1 loc	1 color    Blue misc 0
     hdac0: nid 27 0x0221401f as  1 seq 15 Headphones  Jack jack 1 loc	2 color   Green misc 0
     hdac0: nid 28 0x411111f0 as 15 seq  0    Speaker  None jack 1 loc	1 color   Black misc 1
     hdac0: nid 30 0x411111f0 as 15 seq  0    Speaker  None jack 1 loc	1 color   Black misc 1
     hdac0: nid 31 0x411111f0 as 15 seq  0    Speaker  None jack 1 loc	1 color   Black misc 1
```

to see if there is anything I can play around with with the device.hints(5) file to get things working, but I can't get the above data. I tried using sysctl hw.snd.verbose=4 and then cat /dev/sndstat but I didn't get anything like the above printout. What am I missing to get this data?

Thanks,
UJ


----------



## UglyJoe (Sep 1, 2012)

Ok, I got the pindump:


```
hdac0: Dumping AFG cad=0 nid=1 pins:
hdac0:  nid 20 0x012b4050 as  5 seq  0    Headphones  Jack jack 11 loc  1 color   Green misc 0
hdac0:  nid 21 0x018b3020 as  2 seq  0       Line-in  Jack jack 11 loc  1 color    Blue misc 0
hdac0:  nid 22 0x400000f0 as 15 seq  0      Line-out  None jack  0 loc  0 color Unknown misc 0 [DISABLED]
hdac0:  nid 23 0x400000f0 as 15 seq  0      Line-out  None jack  0 loc  0 color Unknown misc 0 [DISABLED]
hdac0:  nid 24 0x90100140 as  4 seq  0       Speaker Fixed jack  0 loc 16 color Unknown misc 1
hdac0:  nid 25 0x90a00110 as  1 seq  0           Mic Fixed jack  0 loc 16 color Unknown misc 1
hdac0:  nid 26 0x90100141 as  4 seq  1       Speaker Fixed jack  0 loc 16 color Unknown misc 1
hdac0:  nid 27 0x400000f0 as 15 seq  0      Line-out  None jack  0 loc  0 color Unknown misc 0 [DISABLED]
hdac0:  nid 28 0x400000f0 as 15 seq  0      Line-out  None jack  0 loc  0 color Unknown misc 0 [DISABLED]
hdac0:  nid 30 0x014be060 as  6 seq  0     SPDIF-out  Jack jack 11 loc  1 color   White misc 0
hdac0:  nid 31 0x01cbe030 as  3 seq  0      SPDIF-in  Jack jack 11 loc  1 color   White misc 0
```

So, I guess I should play around with the associations until I find the right ones to set with device.hints to get sound working? Any suggestions which ones to start with?

Thanks,
UJ


----------



## plamaiziere (Sep 1, 2012)

UglyJoe said:
			
		

> Ok, I got the pindump:
> 
> So, I guess I should play around with the associations until I find the right ones to set with device.hints to get sound working? Any suggestions which ones to start with?



Try to change the gpio too, something like hint.hdac.0.config="gpio0" 

Good luck!


----------



## UglyJoe (Sep 1, 2012)

plamaiziere said:
			
		

> Try to change the gpio too, something like hint.hdac.0.config="gpio0"
> 
> Good luck!



I'll try this; have to read up on it first and make sure I understand what is going on.

I tried to play around with the associations last night, to no avail. I've attached a file with the relevant portion of verbose dmesg. By the way, where can I host longer code files so that they are viewable via url link?

I'm not exactly sure what most of this means, but I see that it looks like nid 24 in Association 0 is Disabled; I think this is the internal speakers, and I'm not sure how to fix this. Any help?


----------



## UglyJoe (Sep 2, 2012)

Okay, after digging around in dmesg some more I think that I've found some interesting things:


```
hdac0:             nid: 24
hdac0:            Name: pin: Speaker (Fixed)
hdac0:      Widget cap: 0x0040018f
hdac0:                  UNSOL STEREO
hdac0:     Association: 3 (0x00000001)
hdac0:         Pin cap: 0x0000373c
hdac0:                  PDC HP OUT IN VREF[ 50 80 100 GROUND HIZ ]
hdac0:      Pin config: 0x90100140
hdac0:     Pin control: 0x00000040 OUT
hdac0:      Output amp: 0x80000000
hdac0:                  mute=1 step=0 size=0 offset=0
hdac0:       Input amp: 0x00270300
hdac0:                  mute=0 step=3 size=39 offset=0
hdac0:     connections: 5
hdac0:           |
hdac0:           + <- nid=12 [audio mixer] (selected)
hdac0:           + [DISABLED] <- nid=13 [audio mixer]
hdac0:           + [DISABLED] <- nid=14 [audio mixer]
hdac0:           + [DISABLED] <- nid=15 [audio mixer] [DISABLED]
hdac0:           + [DISABLED] <- nid=38 [audio mixer] [DISABLED]
```

It appears that nid 24 (internal speaker) is muted by default. Also there is this from dmesg | grep -i pcm:


```
pcm0: +-------------------------+
pcm0: | DUMPING Volume Controls |
pcm0: +-------------------------+
pcm0: 
pcm0: Master Volume (OSS: vol)
pcm0:    |
pcm0:    +- ctl 14 (nid  12 out):    -64/0dB (65 steps)
pcm0:    +- ctl 15 (nid  12 in   0): mute
pcm0:    +- ctl 16 (nid  12 in   1): mute
pcm0:    +- ctl 17 (nid  13 out):    -64/0dB (65 steps)
pcm0:    +- ctl 18 (nid  13 in   0): mute
pcm0:    +- ctl 19 (nid  13 in   1): mute
pcm0:    +- ctl 34 (nid  24 in ):    mute
pcm0:    +- ctl 38 (nid  26 in ):    mute
pcm0: 
pcm0: PCM Volume (OSS: pcm)
pcm0:    |
pcm0:    +- ctl 15 (nid  12 in   0): mute
pcm0:    +- ctl 18 (nid  13 in   0): mute
pcm0: 
pcm0: Microphone2 Volume (OSS: monitor)
pcm0:    |
pcm0:    +- ctl 37 (nid  25 out):    0/30dB (4 steps)
pcm0:    +- ctl 65 (nid  36 in   1): mute
pcm0: 
pcm0: Speaker/Beep Volume (OSS: speaker)
pcm0:    |
pcm0:    +- ctl  9 (nid  11 in   5): -34/12dB (32 steps) + mute
pcm0:    +- ctl 69 (nid  36 in   5): mute
pcm0: 
pcm0: Recording Level (OSS: rec)
pcm0:    |
pcm0:    +- ctl  1 (nid   7 in   0): -16/30dB (47 steps) + mute
pcm0:    +- ctl 65 (nid  36 in   1): mute
pcm0:    +- ctl 69 (nid  36 in   5): mute
pcm0:    +- ctl 74 (nid  36 in  10): mute
pcm0: 
pcm0: Input Mix Level (OSS: mix)
pcm0:    |
pcm0:    +- ctl  5 (nid  11 in   1): -34/12dB (32 steps) + mute
pcm0:    +- ctl  9 (nid  11 in   5): -34/12dB (32 steps) + mute
pcm0:    +- ctl 16 (nid  12 in   1): mute
pcm0:    +- ctl 19 (nid  13 in   1): mute
pcm0:    +- ctl 74 (nid  36 in  10): mute
pcm0: 
pcm0: Input Monitoring Level (OSS: igain)
pcm0:    |
pcm0:    +- ctl 16 (nid  12 in   1): mute
pcm0:    +- ctl 19 (nid  13 in   1): mute
pcm0: 
pcm0: Enabling Soft PCM volume
pcm0: Mixer "vol":
pcm0: Mixer "pcm":
pcm0: Mixer "speaker":
pcm0: Mixer "mix":
pcm0: Mixer "rec":
pcm0: Mixer "igain":
pcm0: Mixer "monitor":
pcm0: Soft PCM mixer ENABLED
pcm0: clone manager: deadline=750ms flags=0x8000001e
pcm0: sndbuf_setmap 47f0000, 4000; 0xffffff808c8b9000 -> 47f0000
pcm0: sndbuf_setmap 42e0000, 4000; 0xffffff808c8c9000 -> 42e0000
pcm1: <HDA Realtek ALC885 PCM #1 Analog> at cad 0 nid 1 on hdac0
```

mixer:


```
Mixer vol      is currently set to 100:100
Mixer pcm      is currently set to  75:75
Mixer speaker  is currently set to  75:75
Mixer mix      is currently set to   0:0
Mixer rec      is currently set to  75:75
Mixer igain    is currently set to  75:75
Mixer monitor  is currently set to  75:75
Recording source: monitor
```

Any suggestions on how to unmute these?


----------



## UglyJoe (Sep 3, 2012)

Any help on this? I tried setting gpio to each of the 8 allowed values and no luck...


----------

