# Is sound possible in Xorg on FreeBSD?



## PhenomII (Jun 9, 2010)

Greetings all,
 I'm struggling with getting sound after installing Xorg on an 8.1-PRERELEASE/amd64 (custom kernel).
DMESG(8) output can be found here. My sig indicates my motherboard brand and model (if the DMESG(8) output isn't enough).
The manual indicates onboard sound is powered by a Realtek ALC892 chip.

Thank you for all your time and consideration.

Additional information provided on request. 

P.S. When I first put this hardware together, I shoved a Fedora 13 Live DVD in, and booted to it. The sound worked in the KDE 4.4 desktop. So I know that the BIOS is at least set OK.


----------



## phoenix (Jun 9, 2010)

Unless you have a need for network sound, you should remove all traces of PulseAudio from your FreeBSD system.  It's not needed.

Search the forums.  There are many, many, many threads on how to get sound working.  A couple search terms to use:  snd_driver, sound, sndstat.

No sound drivers are part of the GENERIC kernel.  You need to manually load sound drivers via kldstat() until you find the right one.  Then set that in /boot/loader.conf to have it loaded automatically at boot.


----------



## PhenomII (Jun 9, 2010)

Greetings phoenix, and thank you for your prompt reply.
I _did_ search the forms prior to asking. Problem is - you're correct, there _are_ many, many posts. I was unable to figure _which_ driver was best suited for FBSD. Olny that pulseaudio "sucked". So now I'm left wondering if I should use Arts, OSS, or...

So I was hoping with the details I provided, that someone might be willing to suggest the direction best suited for my hardware.
Yes. I *know* the first step is to remove pulseaudio. 

Thanks again phoenix, for taking the time to respond.


----------



## sixtydoses (Jun 9, 2010)

You could try this:



			
				phoenix said:
			
		

> `# kldload snd_driver` will load every sound module.  Then `# cat /dev/sndstat` to see which one attached to the hardware.  If nothing shows up, then there's probably no driver for that chipset.


----------



## mousaka (Jun 9, 2010)

From your dmesg I guess, that you didn't load a kernel module for your sound card at all. Read the following chapter in the handbook: Setting Up the Sound Card.

Very likely you need to load the snd_hda driver.

mousaka

EDIT:sixtydoses was faster ...


----------



## PhenomII (Jun 9, 2010)

Greetings, and thank you all for your thoughtful responses.
I continued to search the forums after my last reply to phoenix.
I eventually found the "magic" script in this thread. And of course you were correct; the output from running the script:

```
# ./soundloader 
kldload: can't load snd_ad1816.ko.symbols: Exec format error
kldunload: can't find file snd_ad1816.ko.symbols
kldload: can't load snd_als4000.ko.symbols: Exec format error
kldunload: can't find file snd_als4000.ko.symbols
kldload: can't load snd_atiixp.ko.symbols: Exec format error
kldunload: can't find file snd_atiixp.ko.symbols
kldload: can't load snd_cmi.ko.symbols: Exec format error
kldunload: can't find file snd_cmi.ko.symbols
kldload: can't load snd_cs4281.ko.symbols: Exec format error
kldunload: can't find file snd_cs4281.ko.symbols
kldload: can't load snd_csa.ko.symbols: Exec format error
kldunload: can't find file snd_csa.ko.symbols
kldload: can't load snd_ds1.ko.symbols: Exec format error
kldunload: can't find file snd_ds1.ko.symbols
kldload: can't load snd_emu10k1.ko.symbols: Exec format error
kldunload: can't find file snd_emu10k1.ko.symbols
kldload: can't load snd_emu10kx.ko.symbols: Exec format error
kldunload: can't find file snd_emu10kx.ko.symbols
kldload: can't load snd_envy24.ko.symbols: Exec format error
kldunload: can't find file snd_envy24.ko.symbols
kldload: can't load snd_envy24ht.ko.symbols: Exec format error
kldunload: can't find file snd_envy24ht.ko.symbols
kldload: can't load snd_es137x.ko.symbols: Exec format error
kldunload: can't find file snd_es137x.ko.symbols
kldload: can't load snd_ess.ko.symbols: Exec format error
kldunload: can't find file snd_ess.ko.symbols
kldload: can't load snd_fm801.ko.symbols: Exec format error
kldunload: can't find file snd_fm801.ko.symbols
A driver was found : 'snd_hda.ko'
Add the driver to /boot/loader.conf'
```

So now all I need to do is get rid of pulseaudio. But one question remains:

Which is best for a KDE-4.4 install?

Any takers?

Thank you all again for your thoughtful and informative responses - greatly appreciated!


----------



## PhenomII (Jun 9, 2010)

*new kernel with driver but no sound*

Greetings,
 I built/installed a new kernel with the sound/sound driver declaration(s). The sound device shows up in dmesg(8). But I still have no sound. The output regarding the sound is a bit overwhelming. Would anyone dare to take a look, and suggest my best choices from here? output is here.

Thank you for all your time and consideration.

P.S. I've been riding BSD since the early '80's, and over those years I've literally build hundreds of kernels. But until now, they have all been servers. The only multimedia device on any of my server boards, was a PC beeper. The most I ever bothered with in the kernel, was
[CMD=""]option    speaker[/CMD]


----------



## SirDice (Jun 9, 2010)

To see which driver is installed do [cmd=]cat /dev/sndstat[/cmd]
Looking at your output it's probably snd_hda. Just add this to /boot/loader.conf:

```
snd_hda_load="YES"
```

No need to recompile your kernel. Also make sure you read the snd_hda(4) man page. You probably need to define which output does what.


----------



## PhenomII (Jun 9, 2010)

Greetings SirDice, and thank you for your reply.
 Been there done that. In fact, I made a kernel with the following
new declarations:

```
# ADDING SOUND
device		sound
# Intel High Definition Audio bridge device driver
device		snd_hda
```

I posted output from dmesg(8) here

In case it's not crystal clear - I'm pretty dumbfounded.
I can see it's available, given the message output during boot.
I

```
# cd /usr/ports/multimedia/kdemultimedia4
# make deinstall
# make config

# cd ../pulseaudio
# make deinstall

# cd ../kdemultimedia4
# make install clean

# rehash

# cd /root
# halt
...
```

after reboot

`startx`

Same fsck'n bullschmidt!
OSS mixer shows 3 PCM devices - yet there is only 1 in /dev
(pcm0) && none of them work.

There *are* 3 dsp's in /dev
dsp0.0, dsp1.0, and dsp.2.0

There are also 3 mixers in /dev
mixer0, mixer1, and mixer2

If I crank up the volume on line-in, I can hear hissing - like
when if sound came through, you *know* it would blow your ear drums out.

But apparently the sound drivers w/FreeBSD/KDE,... I dunno.


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

Thank you for all your time and consideration.

P.S. Please pardon me if this sounds really stupid - it's been a l-o-n-g day. Anyway, do I still need to

```
snd_hda.ko_load="YES"
```
in /boot/loader.conf
now that I have it defined in my new kernel.

Thanks again...


----------



## SirDice (Jun 9, 2010)

PhenomII said:
			
		

> P.S. Please pardon me if this sounds really stupid - it's been a l-o-n-g day. Anyway, do I still need to
> [CMD=""]snd_hda.ko_load="YES"[/CMD]
> in /boot/loader.conf
> now that I have it defined in my new kernel.


It should be *snd_hda_load="YES"* and no, you don't need to add it to loader.conf if it's already build into the kernel. Loader.conf is used to load _additional_ modules, those not build into the kernel i.e.

As for no sound, read the man page. I don't have HDA audio so I can't help with that. There are however several threads here related to snd_hda and how to define which port on the card does what.


----------



## adamk (Jun 9, 2010)

What, exactly, have you tried to play sound with?


----------



## Beastie (Jun 9, 2010)

`% cat /dev/random > /dev/dsp` will tell you right away if the sound card driver is working or not.


----------



## dennylin93 (Jun 9, 2010)

Try plugging the speakers into different ports.


----------



## DutchDaemon (Jun 9, 2010)

Also try the snddetect script @ http://forums.freebsd.org/showthread.php?t=290


----------



## DutchDaemon (Jun 9, 2010)

As an aside: please use the correct posting tags. The [cmd] tag is for posting commands, the [code] tag is for posting system output, configuration files, etc. -> http://forums.freebsd.org/showthread.php?t=8816


----------



## PhenomII (Jun 10, 2010)

SirDice said:
			
		

> It should be *snd_hda_load="YES"* and no, you don't need to add it to loader.conf if it's already build into the kernel. Loader.conf is used to load _additional_ modules, those not build into the kernel i.e.


Thank you again SirDice.
 That has always been my understanding. I had had to work for 2 days straight w/o sleep, so my mind wasn't functioning very well, I'm afraid.



			
				SirDice said:
			
		

> As for no sound, read the man page. I don't have HDA audio so I can't help with that. There are however several threads here related to snd_hda and how to define which port on the card does what.


Will do. I did read the man page for the driver. But I'll look it over again, now that I'm better rested. 

Thanks again, for your thoughtful reply.


----------



## PhenomII (Jun 10, 2010)

adamk said:
			
		

> What, exactly, have you tried to play sound with?


Thank you for your reply adamk.
Thus far, I've only worked out of the KDE-4.4.4 env. Which currnetly anounces that PCM #0 is not functioning. The listing of devices that KDE acknowledges can be seen here:







I have only attempted to produce sound within: System Settings > Multimedia > Highlighting one of the Devices, and pressing "test".
I have setup the mixer so the volumes of all the output/input ports are at a level high enough to ensure audible output.

The really frustrating part of all this, is that if I raise the volume past 60% on the mic input, I can hear "hissing". So I *know* FreeBSD has enabled it. But KDE is apparently "clueless". But then again, as this my first attempt with multimedia devices on FreeBSD, I'm a bit "clueless" too 

Thank you again for your thoughtful response.


----------



## PhenomII (Jun 10, 2010)

DutchDaemon said:
			
		

> Also try the snddetect script @ http://forums.freebsd.org/showthread.php?t=290



Thank you for your reply DutchDaemon. That is a great link, to an even better script - no offense, but if you look closer at my posting of the output produced by a script I named "soundloader",
you'll notice that it is the script referenced in the link you provided:


			
				PhenomII said:
			
		

> Greetings, and thank you all for your thoughtful responses.
> I continued to search the forums after my last reply to phoenix.
> I eventually found the "magic" script in this thread. And of course you were correct; the output from running the script:



Good call though. You are "spot on". That script _DID_ give me the knowlege I needed to load a suitable driver for my hardware.

So _now_ who's not reading.  - sorry, I couldn't resist. 

Thank you for the thoughtful reply DutchDaemon.


----------



## carlton_draught (Jun 10, 2010)

Beastie said:
			
		

> `% cat /dev/random > /dev/dsp` will tell you right away if the sound card driver is working or not.


Do this before anything else (pseudocode):
For each port on the back of your soundcard do:
  plug in the sound card;
`% cat /dev/random > /dev/dsp0.0`
`% cat /dev/random > /dev/dsp1.0`
`% cat /dev/random > /dev/dsp2.0`
done

This should find which port is working with which device node, which will be necessary before you try and get KDE working with sound, or at least help you so that you can get mp3s or flacs playing in the background.


			
				PhenomII said:
			
		

> So now who's not reading. - sorry, I couldn't resist.


If you want help, try not to be snarky. It erases any goodwill built up by thanking people, and makes the thanks look like they aren't meant. And especially to DutchDaemon, who is unpaid and from what I can gather has provided thousands of hours of volunteer effort to FreeBSD by his presence on the forums. (The thanks btw is probably better done by using the forum "thanks" function, as it will bump up their thanks score.)

I would not have replied but I'm also curious about getting more sound functionality with my setup than being able to cat mp3 files to sox etc.


----------



## PhenomII (Jun 10, 2010)

Greetings carlton, and thank you for your response.





			
				carlton_draught said:
			
		

> Beastie said:
> 
> 
> 
> > `% cat /dev/random > /dev/dsp` will tell you right away if the sound card driver is working or not.


FWIW I don't have a:
/dev/dsp

I _do_ have:
/dev/dsp0.0
/dev/dsp0.1
/dev/dsp1.0
/dev/dsp2.0

Is this an issue?


			
				carlton_draught said:
			
		

> Do this before anything else (pseudocode):
> For each port on the back of your soundcard do:
> plug in the sound card;
> `% cat /dev/random > /dev/dsp0.0`
> ...


I should first preface this by stating that I think that's good advice, and couldn't agree more.
That said, in retrospect, I should have provided a bit of history. So that those, like yourself, would have a better understanding what would posess me to make such a statement.
So I'll do so now. For the record, DutchDaemon (rightfully) gave me the "buisness" for a comment in my sig which read:
@sysop why can't I edit my posts?
To which he appended to my sig; "please read the documentation regarding the forums" - paraphrased.
In fact I _had_ read them in their entirity. But for the life of me, I was unable to find the part related "post editing".
_Eventually_, I found it, and thanked DuchDaemon for his patience, and his indulgence.
So, as you now probably realize, my "snarky" comment was a bit of what one might call, an "inside joke". But it was clearly an oversight on my part, as I could/should not have expected anyone else to understand that. I hope my intention(s) are clearer now. 


			
				carlton_draught said:
			
		

> I would not have replied but I'm also curious about getting more sound functionality with my setup than being able to cat mp3 files to sox etc.



Thank you again carlton, for taking the time to respond.


----------



## PhenomII (Jun 10, 2010)

carlton_draught said:
			
		

> Do this before anything else (pseudocode):
> For each port on the back of your soundcard do:
> plug in the sound card;
> [cmd=""]% cat /dev/random > /dev/dsp0.0[/cmd]
> ...




```
# cat /dev/random > /dev/dsp0.0
/dev/dsp0.0: Device busy.
```
Performing the same on:
/dev/dsp0.1
/dev/dsp1.0
/dev/dsp2.0
causes the command not to return (^C required to end the command)

The only sound related devices I now have are:
/dev/dsp0.0
/dev/dsp0.1
/dev/dsp1.0
/dev/dsp2.0

/dev/mixer0
/dev/mixer1
/dev/mixer2

/dev/psm0


```
# cat /dev/random > /dev/psm0 
/dev/psm0: Device busy.
```

I *do* hear "hissing" when I crank up the "mic" volume. But I don't hear anything
performing the # cat /dev/random > /dev/<sound-device-here>.

Any thoughts?

Thank you for all your time and consideration.


----------



## PhenomII (Jun 10, 2010)

DutchDaemon said:
			
		

> As an aside: please use the correct posting tags. The [cmd] tag is for posting commands, the [code] tag is for posting system output, configuration files, etc. -> http://forums.freebsd.org/showthread.php?t=8816


Greetings DutchDaemon,
I tried that originally. But no matter which browser I use, using the 
	
	



```
tags, causes scrolling within the [CODE] section (a crollbar on the bottom, and one on the right). This makes it impossible to read the last (bottom) line within the [CODE] sections of peoples posts. I'm forced to open an editor and
CTRL+A in the [CODE] setion, and paste it into the open editor to read the entire [CODE] listing. I hope it's not too big of a deal to substitute [CMD], as it [i]really[/i] helps make the content easier to read.

Thank you for all your time and consideration.
```


----------



## PhenomII (Jun 10, 2010)

PhenomII said:
			
		

> I hope it's not too big of a deal to substitute `, as it [i]really[/i] helps make the content easier to read.[/quote]
> That should have read
> 
> I hope it's not too big of a deal [u][b]I[/b][/u] substitute [CMD]
> ...


----------



## carlton_draught (Jun 10, 2010)

PhenomII said:
			
		

> [cmd=""]# cat /dev/random > /dev/dsp0.0
> /dev/dsp0.0: Device busy.[/cmd]
> Performing the same on:
> /dev/dsp0.1
> ...


Well, the idea behind sending output from /dev/random to your dsp (as you did) was that when you hit on the correct combination of dspx.y, combined with audio port at the back, you will get the sound of static (from memory, it's similar to the white noise from a CRT TV not tuned to any station. It won't be a hiss and it will be unmistakeable.

The command is not returning because /dev/random is an infinite stream of random bits. Try catting it to your terminal some time, you will see what I mean. As long as it is sending, your dsp (digital signal processor?) device will try and play it.

So, if you have tested your audio lead/speakers correctly (e.g. against another OS) and your speakers will output a working volume, and you have your driver loaded, then the next step is to see which device node and port combination work. I would probably try and do this straight from the terminal without X11 loaded. If you have tested every port and device combo, my guess is that the problem is with the busy device and you will have to figure out why it's busy. Good luck.


----------



## Beastie (Jun 10, 2010)

PhenomII said:
			
		

> /dev/psm0
> 
> 
> ```
> ...


Of all things, why would you do this? What are you trying next? /dev/ad0?


----------



## adamk (Jun 10, 2010)

Install a program like mpg123 and try playing an mp3 file with it.

Adam


----------



## PhenomII (Jun 10, 2010)

Beastie said:
			
		

> PhenomII said:
> 
> 
> 
> ...


*D'OH!* That *should* have read:

```
# cat /dev/random > /dev/p[color="Red"]c[/color]m0
/dev/p[color="Red"]c[/color]m0: Device busy.
```

sigh...


----------



## PhenomII (Jun 10, 2010)

adamk said:
			
		

> Install a program like mpg123 and try playing an mp3 file with it.
> 
> Adam


Greetings Adam,
 Thanks for your reply, and suggestion.

Well, as it turns out, I've got it working - well, mostly.
I bailed out of KDE, and tried to reconcile things while in XFCE-4.6.2.
It was there that I found a different Mixer sound setup - It's from
the KDE-3.5 branch. Hmmm. As I chose not to use any of the KDE "meta" ports for installing KDE-4.4.4 in an effort to avoid getting KDE-edu, KDE-games, and a few others. I used the instructions (method) outlined on KDE on FreeBSD team's (FAQ). Specifically


> *Say I decide that I don't want to use the KDE meta port/package. What is the proper order to install the various KDE components?*
> qt, arts, kdelibs, kdebase. The installation order of the other KDE modules (kdeedu, kdegames, kdegraphics, etc.) does not really matter, except that (if you install it) kdeaddons must be installed after  all other modules.


Well, after installing QT4,ARTS,KDELIBS4, and KDEBASE4. I started installing the applications that I felt I would actually need/use - always trying to use those with *4* appended. A few of them didn't have the *4*. So one of them apparently pulled in a portion of the 3.5 tree. Bottom line:
the 3.5 version allows controlling the sound system, and the 4 version complains that the PCM(0-2) are non functional. I can listen to all my mp3's with Mplayer, but the quality of the sound could be better (likely due to competition between the 2 versions attempting to gain control). I'll probably just have to wipe the disk, and start anew, but use the META version of KDE, and 
	
	



```
# make -DFORCE_DELETE deinstall
```
 the EDU && GAMES afterwards - sigh...

Oh well, at least I have a handle on this whole mess now. 

Thank you again for your reply.
A big thanks to all those who suffered though my stupid questions, and were kind enough to respond anyway. 

Best wishes.


----------



## zeiz (Jun 10, 2010)

PhenomII said:
			
		

> anew, but use the META version of KDE, and
> 
> 
> 
> ...



I would rather run *make config* in x11/kde4 directory. 
KDE4 metaport installs full set of KDE4 modules or part of them according to the config.


----------



## PhenomII (Jun 10, 2010)

zeiz said:
			
		

> I would rather run *make config* in x11/kde4 directory.
> KDE4 metaport installs full set of KDE4 modules or part of them according to the config.



Thanks for the reply, zeiz.

That's good advice, I'll go that route after I wipe this disk.
I'd rather not attempt to untangle the mess I've already made. 

Thanks again, I really appreciate it.


----------

