# OSS with C-Media CM8738 and XBMC



## Energybeing (Jan 12, 2012)

Hi, I am having quite a bit of trouble getting any sound out of the optical interface of my C-Media CM8738.  In order to use the OSS driver as the snd_cmi driver was not working, I had to compile the kernel without the default sound driver support.  Once OSS was compiled and started up, I had some sound with XBMC, but as soon as I changed a single setting, it was gone.  I would like to get 5.1 surround from the optical out for use with XBMC.  Here is my system info:

*cat/dev/sndstat*


```
OSS 4.2 (b 2005/201201081817)BSD (C) 4Front Technologies 1996-2011
Kernel: FreeBSD 9.0-RC3 #0: Sun Jan  8 01:25:58 PST 2012
    root@Medialol:/usr/obj/usr/src/sys/MYKERNEL


Audio devices:
0: CMedia CM8768 (rev 68) (DUPLEX)
   Engine 1 opened INOUT by VMIX/0 @ 48000/48000 Hz Fragment: 2048/768000 (2.6 msec)
   Engine 2 opened OUT by xbmc.bin/1974 @ 44100/48000 Hz Fragment: 32768/192000 (170.6 msec)
1: CMedia CM8768 (playback only) (OUTPUT)

MIDI devices:

Mixers:
0: CMedia CMPCI
```


*ossinfo -v9*


```
Version info: OSS 4.2 (b 2005/201201081817) (0x00040100) BSD
Platform: FreeBSD/amd64 9.0-RC3 FreeBSD 9.0-RC3 #0: Sun Jan  8 01:25:58 PST 2012
     root@Medialol:/usr/obj/usr/src/sys/MYKERNEL (Medialol)

Number of audio devices:	2
Number of audio engines:	6
Number of MIDI devices:		0
Number of mixer devices:	1


Device objects
 0: oss_cmpci0 CMedia CM8738 interrupts=5503491 (6205651)

MIDI devices (/dev/midi*)

Mixer devices
 0: CMedia CMPCI (Mixer 0 of device object 0)
    Device file /dev/oss/oss_cmpci0/mix0, Legacy device /dev/mixer0
    Priority: 1
    Caps: 
    Device handle: OSS-PCI-mx01
    Device priority: 1


Audio devices
CMedia CM8768 (rev 68)            /dev/oss/oss_cmpci0/pcm0  (device index 0)
    Legacy device /dev/dsp0
    Caps: DUPLEX TRIGGER MMAP 
    Modes: IN/OUT 
      Engine      1: 0/CMedia CM8768 (rev 68)
                     Busy (IN/OUT) label 'VMIX' 
      Engine      2: 1/CMedia CM8768 (rev 68) (vmix)
                     Busy (OUT) by PID 1974 / xbmc.bin label 'xbmc.bin' 
      Engine      3: 2/CMedia CM8768 (rev 68) (vmix)
                     Available for use 
      Engine      4: 3/CMedia CM8768 (rev 68) (vmix)
                     Available for use 
      Engine      5: 4/CMedia CM8768 (rev 68) (vmix)
                     Available for use 
    Input formats (0x00000418):
      AFMT_U8		- 8 bit unsigned
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_AC3		- AC3 (Dolby Digital) encoded audio
    Output formats (0x00000418):
      AFMT_U8		- 8 bit unsigned
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_AC3		- AC3 (Dolby Digital) encoded audio
    Device handle: OSS-PCI-au01
    Related mixer dev: 0
    Sample rate source: 0
    Preferred channel configuration: Not indicated
    Supported number of channels (min - max): 2 - 8
    Native sample rates (min - max): 5000 - 48000
    HW Type: ANALOG_OUT ANALOG_IN DIGITAL_OUT DIGITAL_IN     Minimum latency: Not indicated

CMedia CM8768 (playback only)     /dev/oss/oss_cmpci0/pcm1  (device index 1)
    Legacy device /dev/dsp1
    Caps: TRIGGER MMAP 
    Modes: OUTPUT 
      Out engine  1: 5/CMedia CM8768 (playback only)
                     Available for use 
    Input formats (0x00000418):
      AFMT_U8		- 8 bit unsigned
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_AC3		- AC3 (Dolby Digital) encoded audio
    Output formats (0x00000418):
      AFMT_U8		- 8 bit unsigned
      AFMT_S16_LE	- 16 bit signed little endian
      AFMT_AC3		- AC3 (Dolby Digital) encoded audio
    Device handle: OSS-PCI-au02
    Related mixer dev: 0
    Sample rate source: 0
    Preferred channel configuration: Not indicated
    Supported number of channels (min - max): 2 - 8
    Native sample rates (min - max): 5000 - 48000
    HW Type: ANALOG_OUT ANALOG_IN DIGITAL_OUT DIGITAL_IN     Minimum latency: Not indicated


Nodes
  /dev/dsp -> /dev/oss/oss_cmpci0/pcm0
  /dev/dsp_in -> /dev/oss/oss_cmpci0/pcm0
  /dev/dsp_out -> /dev/oss/oss_cmpci0/pcm0
  /dev/dsp_ac3 -> /dev/oss/oss_cmpci0/pcm0
  /dev/dsp_mmap -> /dev/oss/oss_cmpci0/pcm0
  /dev/dsp_multich -> /dev/oss/oss_cmpci0/pcm0
  /dev/dsp_spdifout -> /dev/oss/oss_cmpci0/pcm0
  /dev/dsp_spdifin -> /dev/oss/oss_cmpci0/pcm0
```


*ossmix*


```
Selected mixer 0/CMedia CMPCI
Known controls are:
vol [<leftvol>:<rightvol>] (currently 90:90)
synth [<leftvol>:<rightvol>] (currently 75:75)
synth.rec ON|OFF (currently OFF)
pcm [<leftvol>:<rightvol>] (currently 75:75)
speaker <monovol> (currently 75)
line [<leftvol>:<rightvol>] (currently 75:75)
line.rec ON|OFF (currently OFF)
mic <monovol> (currently 32)
mic.rec ON|OFF (currently ON)
cd [<leftvol>:<rightvol>] (currently 75:75)
cd.rec ON|OFF (currently OFF)
rec [<leftvol>:<rightvol>] (currently 75:75)
igain [<leftvol>:<rightvol>] (currently 75:75)
aux1 [<leftvol>:<rightvol>] (currently 64:64)
aux1.rec ON|OFF (currently OFF)
mutectl.linemute ON|OFF (currently ON)
mutectl.cdmute ON|OFF (currently ON)
mutectl.micmute ON|OFF (currently ON)
mutectl.line1mute ON|OFF (currently ON)
jackctl.rear2line ON|OFF (currently ON)
jackctl.cen2line ON|OFF (currently ON)
jackctl.bass2line ON|OFF (currently ON)
jackctl.cen2mic ON|OFF (currently ON)
mixext.spkmode <FRONT|SPREAD> (currently SPREAD)
mixext.dualdac ON|OFF (currently OFF)
mixext.micboost ON|OFF (currently OFF)
spdif.play ON|OFF (currently ON)
spdif.loop ON|OFF (currently ON)
spdif.record ON|OFF (currently OFF)
spdif.imon ON|OFF (currently ON)
spdif.polrev ON|OFF (currently ON)
spdif.copyprot ON|OFF (currently ON)
spdif.optical ON|OFF (currently ON)
vmix0-enable ON|OFF (currently ON)
vmix0-rate <decimal value> (currently 48000) (Read-only)
vmix0-channels <Stereo|Multich> (currently Multich)
vmix0-src <High|OFF> (currently Fast)
vmix0-outvol <monovol> (currently 24.7 dB)
vmix0-invol <monovol> (currently 25.0 dB)
vmix0.pcm1 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB) ("xbmc.bin")
vmix0.pcm2 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
vmix0.pcm3 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
vmix0.pcm4 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
```

I have tried messing with .asoundrc to no avail.  I have been on IRC and have had a couple people try to help me again without success.  Thank you for any help you can give.


----------



## joel@ (Jan 12, 2012)

You should probably direct this question to the people on the OSS forum instead.


----------



## Energybeing (Jan 13, 2012)

Ah, ok, thank you.


----------



## Energybeing (Jan 13, 2012)

I went ahead and posted on the OSS forum, but that forum is about as active as my 94 year old grandfather...  The next most recent post on the BSD page is a month old with no replies.  The one before that is almost 2 months old with zero replies as well.  If I can't get any help getting sound working I will not be able to use FreeBSD.  It works perfectly fine with several other platforms.  I really would like to use FreeBSD.


----------



## DutchDaemon (Jan 13, 2012)

Maybe have a go over at the freebsd-multimedia list (or freebsd-questions as a more generic platform).


----------



## Energybeing (Jan 14, 2012)

DutchDaemon:

Thanks a lot for your suggestions!

Someone replied to my thread on the OSS forums here. Any suggestions pertaining to the ALSA lib error?  Maybe I should try recompiling alsalib?  Compiling XBMC?  I'm at a loss now about how to troubleshoot and fix this issue.


----------



## Mur77 (Nov 30, 2012)

Hello,

Does this problem still actual? Did you find any solution?


----------



## Tzim (Dec 3, 2012)

Hello. 

I do use XBMC on FreeBSD 9.1 with a CMI8738, and using SPDIF to connect to my amp.

BUT, to make it work, I had to : 
 - use OSS from ports
 - compile XMBC port w/ OSS and w/o ALSA support
 - disable the vmix0. (and enable spdif.play and spdif.optical ).


----------



## Mur77 (Dec 3, 2012)

Hi!

Did you install XBMC port or XBMC-PVR?


----------



## Tzim (Dec 4, 2012)

I did install xbmc port. 
I do not have use of pvr functionality. 

Thus said, I dot not see why it would work with xbmc and not with xbmc-pvr.


----------



## Mur77 (Dec 4, 2012)

There are OSS support in XBMC-port configuration, but no such option in the XBMC-PVR port.

I had a problem with broken sound after pausing and then resume to play video. Similar problem was described by the author of this thread in his thread here. But I have managed it by removing OSS from ports (actualy just stopping in /etc/rc.conf) and enabling native FreeBSD sound drivers.

What kind of remote control are you using? I have a problem with lirc + homebrew serial receiver. My last post in this thread describes the problem.


----------



## Tzim (Dec 11, 2012)

Native Sound Drivers did work. But I could'nt make spdif passthrough work for AC3 or DTS in XBMC.

I use an MCE remote with webcamd, and android phones...


----------



## Mur77 (Dec 12, 2012)

Did you hear noise or nothing?

I have an Intel HDA Audio on motherboard.
In my case, this works:

1. Add to /etc/sysctl.conf:

```
dev.pcm.2.bitperfect=1
```

2. Make ~/.asoungrc as follows:

```
#
# FreeBSD/OSS
#
pcm.!default {
        type oss
        device /dev/dsp0.0
}
ctl.!default {
        type oss
        device /dev/mixer0
}
pcm.!digital {
        type oss
        device /dev/dsp2.0
}
ctl.!digital {
        type oss
        device /dev/mixer2
}
#
# Remap all possible surround stuffs.
#
pcm.!surround40 {
        type oss
        device /dev/dsp_ac3
}
pcm.!surround41 {
        type oss
        device /dev/dsp_ac3
}
pcm.!surround50 {
        type oss
        device /dev/dsp_ac3
}
pcm.!surround51 {
        type oss
        device /dev/dsp_ac3
}
pcm.!surround71 {
        type oss
        device /dev/dsp_ac3
}
```

3. Setup XBMC: *SETTINGS* -> *SYSTEM* -> *Audio Output*: 
- For analog output:
  Audio output: *Analog*
  Audio output device: *Default (ALSA)*
- For digital output:
  Audio output: *Optical/Coax*
  Audio output device: *Default (ALSA)* 
  Passthrough output device: *custom*
  Custom passthrough device: *digital*


----------

