# snd_hda multichannel sound



## xa (Mar 27, 2010)

Hello. I'm using FreeBSD 8.0-STABLE with snd_hda driver, but i have some problem with multichannel on my notebook with 5.1 speaker system.

Now, i have 3 separated devices:

```
% mpg321 -a /dev/dsp1.0 test.mp3  [B]<- 2 speakers[/B]
% mpg321 -a /dev/dsp2.0 test.mp3  [B]<- other 2 speakers[/B]
% mpg321 -a /dev/dsp3.0 test.mp3  [B]<- subwoofer[/B]
```
Also, muting, when i plug-in headphones works. Microphone jack works fine too.

But i can't merge all speakers to one device in /dev, so, please, help me do it.

My system info:

```
% uname -a 
FreeBSD *** 8.0-STABLE FreeBSD 8.0-STABLE #0: Fri Mar 12 13:24:39 MSK 2010     ***:/usr/obj/usr/src/sys/NOTEBOOK  i386
% cat /dev/sndstat 
FreeBSD Audio Driver (newpcm: 32bit 2009061500/i386)
Installed devices:
pcm0: <HDA Realtek ALC888 PCM #0 Analog> (play/rec) default
pcm1: <HDA Realtek ALC888 PCM #1 Analog> (play)
pcm2: <HDA Realtek ALC888 PCM #2 Analog> (play)
pcm3: <HDA Realtek ALC888 PCM #3 Digital> (play)
% ls /dev/dsp*    
/dev/dsp0.0	/dev/dsp1.0	/dev/dsp2.0	/dev/dsp3.0
```

Verbose snd_hda loading: http://pastebin.org/126277

p.s. This don't works - one device with only 2 speakers:
	
	



```
hint.hdac.0.cad0.nid20.config="as=1 seq=0"
hint.hdac.0.cad0.nid21.config="as=1 seq=1"
hint.hdac.0.cad0.nid22.config="as=1 seq=2"
```
Sorry for my english...


----------



## mav@ (Mar 29, 2010)

Device hints you've shown should work, but the proper set of sequence numbers for 5.1 output is 0,1,4, not 0,1,2.

Make sure you have also set proper speaker system type with `sysctl dev.pcm.0.play.vchanformat=xxx` and you are playing some really multichannel content. Stereo content such as mp3 will be always played to the front speakers.


----------



## xa (Mar 29, 2010)

mav@ said:
			
		

> Device hints you've shown should work, but the proper set of sequence numbers for 5.1 output is 0,1,4, not 0,1,2.
> 
> Make sure you have also set proper speaker system type with `sysctl dev.pcm.0.play.vchanformat=xxx` and you are playing some really multichannel content. Stereo content such as mp3 will be always played to the front speakers.


Oh, i don't try play real 5.1 sound.
I want to play stereo content to 5.1 system, is it possible? Just send one stereo signal to all 3 devices.


----------



## mav@ (Mar 29, 2010)

Kernel doesn't do any up-mixing stuff now. It could be achieved via patching kernel, but not via configuration. It was already discussed somewhere here.


----------



## xa (Mar 30, 2010)

Thanks! I search this forum and find what are you talking about and fix my problem in 3 steps:

1. In /usr/src/sys/dev/sound/pci/hda/hdac.c
Replace in hdac_stream_setup():

```
uint16_t chmap[2][5] = {{ 0x0010, 0x0001, 0x0201, 0x0231, 0x0231 }, /* 5.1 */
```
To:

```
uint16_t chmap[2][5] = {{ 0x0010, 0x0111, 0x0201, 0x0231, 0x0231 }, /* 5.1 */
```

2. Rebuild snd_hda module (if you are using it as kernel module!) 

```
# cd /usr/src/sys/modules/sound/driver/hda
# make install
```

3. In /boot/loader.conf add

```
hint.hdac.0.cad0.nid20.config="as=1 seq=0"
hint.hdac.0.cad0.nid21.config="as=1 seq=1"
hint.hdac.0.cad0.nid22.config="as=1 seq=4"
```

4. Reboot

Now i have what i want, mute when headphones plug-in also works. I will test microphone soon.


----------

