Re: cmpci(4) and S/PDIF?

2011-06-16 Thread Alexandre Ratchov
On Wed, Jun 15, 2011 at 05:24:20PM +0200, Christian Weisgerber wrote:
 Alexandre Ratchov:
 
   I would, but there shouldn't be anything required to make it work.
   The point of AC3/DTS pass-through mode is that it sends what looks
   like 16-bit stereo audio at the S/PDIF level.  It's only the receiver
   that, on seeing a signature bit pattern, re-interprets the data and
   decodes it according to AC3 or DTS.
  
  So, I don't even understand how AC3 would work at all. I mean, a lot
  of programs (ie all using sio_onmove(3)) expect that one second of
  s16le at 48kHz be exactly 192000 bytes of data. If AC3 is used, that
  wouldn't be true anymore (AC3 is 320kbit/s iirc) and audio would be
  broken.
 
 Padding, of course.  A video player like MPlayer will format the
 AC3 or DTS audio (both of which support numerous bit rates) in such
 a way that the result is a 192000 byte/s stream.
 
 The data on a DTS CD is already preformatted to 176400 byte/s and
 just needs to be passed through.  I put the disk in, cdio cdplay,
 and the drive, cdio(1), and azalia(4) all think they are dealing
 with 44.1 kHz 16-bit stereo audio when in fact it is 6-channel DTS.
 
 As designed, S/PDIF only transmits 20(!)-bit stereo audio at various
 sample rates.  However, ISO/IEC 61937 specifies how to carry various
 non-PCM audio formats over S/PDIF by formatting them like a 16-bit
 stereo stream.  This is widely implemented for AC3 and DTS, rarely
 for MPEG audio.

You're right. If data is properly padded, sndio can't make the
difference between linear and compressed data (it counts bytes to
extract the clock)

  And this can't be fixed without adding AC3 specific code.
 
 It is handled at the application level.  Check out libmpcodecs/ad_hwac3.c
 in the MPlayer source.  There is nothing OpenBSD-specific about
 this.  It's the same for FreeBSD, Linux, and probably others.
 

indeed no code is needed as long as padding is handled by apps.

-- Alexandre



Re: cmpci(4) and S/PDIF?

2011-06-15 Thread Alexandre Ratchov
On Fri, Jun 10, 2011 at 03:36:48PM +, Christian Weisgerber wrote:
 Jacob Meuser jake...@sdf.org wrote:
 
   Strangely, AC3/DTS pass-through does *not* work.
  
  there's this comment in cmpci.c:
  
   /* disable ac3 and 24 and 32 bit s/pdif modes */
  
  and then the relevant register bits are cleared.  feel free to play
  with making it work ;)
 
 I would, but there shouldn't be anything required to make it work.
 The point of AC3/DTS pass-through mode is that it sends what looks
 like 16-bit stereo audio at the S/PDIF level.  It's only the receiver
 that, on seeing a signature bit pattern, re-interprets the data and
 decodes it according to AC3 or DTS.
 

audio is not only about data transfers, it's also a clock source. AC3
data could be sent on the wire, but to make audio work at least the
clock must be properly handled.

So, I don't even understand how AC3 would work at all. I mean, a lot
of programs (ie all using sio_onmove(3)) expect that one second of
s16le at 48kHz be exactly 192000 bytes of data. If AC3 is used, that
wouldn't be true anymore (AC3 is 320kbit/s iirc) and audio would be
broken. And this can't be fixed without adding AC3 specific code.

AFAICS, pass-through would be better outside the audio subsystem,
after all AC3/DTS and friends is to transmit opaque data from one
computer to another without processing it. While audio interfaces are
to play and/or capture analog signals to process them.

 We don't use any AC3 mode for azalia(4) either and pass-through
 works there.
 

I bet it only works in few special cases, probably because the clock
is not involved

-- Alexandre



Re: cmpci(4) and S/PDIF?

2011-06-15 Thread Christian Weisgerber
Alexandre Ratchov:

  I would, but there shouldn't be anything required to make it work.
  The point of AC3/DTS pass-through mode is that it sends what looks
  like 16-bit stereo audio at the S/PDIF level.  It's only the receiver
  that, on seeing a signature bit pattern, re-interprets the data and
  decodes it according to AC3 or DTS.
 
 So, I don't even understand how AC3 would work at all. I mean, a lot
 of programs (ie all using sio_onmove(3)) expect that one second of
 s16le at 48kHz be exactly 192000 bytes of data. If AC3 is used, that
 wouldn't be true anymore (AC3 is 320kbit/s iirc) and audio would be
 broken.

Padding, of course.  A video player like MPlayer will format the
AC3 or DTS audio (both of which support numerous bit rates) in such
a way that the result is a 192000 byte/s stream.

The data on a DTS CD is already preformatted to 176400 byte/s and
just needs to be passed through.  I put the disk in, cdio cdplay,
and the drive, cdio(1), and azalia(4) all think they are dealing
with 44.1 kHz 16-bit stereo audio when in fact it is 6-channel DTS.

As designed, S/PDIF only transmits 20(!)-bit stereo audio at various
sample rates.  However, ISO/IEC 61937 specifies how to carry various
non-PCM audio formats over S/PDIF by formatting them like a 16-bit
stereo stream.  This is widely implemented for AC3 and DTS, rarely
for MPEG audio.

 And this can't be fixed without adding AC3 specific code.

It is handled at the application level.  Check out libmpcodecs/ad_hwac3.c
in the MPlayer source.  There is nothing OpenBSD-specific about
this.  It's the same for FreeBSD, Linux, and probably others.

  We don't use any AC3 mode for azalia(4) either and pass-through
  works there.
 
 I bet it only works in few special cases, probably because the clock
 is not involved

And you will lose that bet.  There is no theoretical reason why it
shouldn't work, and in practice it does with everything I've thrown at
it:
* DVD audio tracks, AC3 (2.0, 4.1, 5.1; 192/224/384/448 kbit/s) and
  DTS (5.1; 768 and 1536 kbit/s)
* DTS CD (44.1 kHz)
* AC3 from digital television (2.0 and 5.1; 192/256/384/448 kbit/s)
* DTS extracted from Blu-ray (at the maximum 1536 kbit/s)

-- 
Christian naddy Weisgerber  na...@mips.inka.de



Re: cmpci(4) and S/PDIF?

2011-06-10 Thread Christian Weisgerber
Jacob Meuser jake...@sdf.org wrote:

  Strangely, AC3/DTS pass-through does *not* work.
 
 there's this comment in cmpci.c:
 
  /* disable ac3 and 24 and 32 bit s/pdif modes */
 
 and then the relevant register bits are cleared.  feel free to play
 with making it work ;)

I would, but there shouldn't be anything required to make it work.
The point of AC3/DTS pass-through mode is that it sends what looks
like 16-bit stereo audio at the S/PDIF level.  It's only the receiver
that, on seeing a signature bit pattern, re-interprets the data and
decodes it according to AC3 or DTS.

We don't use any AC3 mode for azalia(4) either and pass-through
works there.

The failure with cmpci(4) is quite mystifying.  If you munge the
bits of an AC3/DTS pass-through stream, for example by running it
through aucat -v100, the signature will be destroyed and the receiver
will simply treat the data as PCM audio.  This doesn't happen here.
My receiver seems to see a signature but never synchonize.

-- 
Christian naddy Weisgerber  na...@mips.inka.de



Re: cmpci(4) and S/PDIF?

2011-06-09 Thread Christian Weisgerber
Eventually I also picked up a Sweex SC015 card.  (These are readily
available in Europe at the time of writing.)

cmpci0 at pci1 dev 2 function 0 C-Media Electronics CMI8738/C3DX Audio rev 
0x10: ivec 0x7d5
audio1 at cmpci0
opl at cmpci0 not configured
mpu at cmpci0 not configured

Playing stereo audio at 44.1 and 48 kHz over S/PDIF works.  The
relevant mixer knob is this:

  playback.mode=dac  [ dac spdif ]

Set to spdif for S/PDIF output, dac (default) for analog output.

This particular card also has a two-pin CD S/PDIF header.  If you
have an optical drive with a two-pin digital audio output, you
can connect it to the card, and then enable a by-pass mode where
audio from the drive is directly output to S/PDIF without the CPU
having to read any data.  The mixer controls involved are these:

  spdif.input=spdin1  [ spdin1 spdin2 spdout ]
  spdif.output=playback  [ playback spdin ]

Set spdif.input=spdin2 to select the CD input and spdif.output=spdin
to direct it to the card's S/PDIF output.

Strangely, AC3/DTS pass-through does *not* work.  Neither for normal
playback with MPlayer, nor for a DTS CD using the S/PDIF by-pass.
My A/V receiver just remains silent or reports a decoding error.

-- 
Christian naddy Weisgerber  na...@mips.inka.de



Re: cmpci(4) and S/PDIF?

2011-06-09 Thread Jacob Meuser
On Thu, Jun 09, 2011 at 05:01:39PM +, Christian Weisgerber wrote:
 Eventually I also picked up a Sweex SC015 card.  (These are readily
 available in Europe at the time of writing.)
 
 cmpci0 at pci1 dev 2 function 0 C-Media Electronics CMI8738/C3DX Audio rev 
 0x10: ivec 0x7d5
 audio1 at cmpci0
 opl at cmpci0 not configured
 mpu at cmpci0 not configured
 
 Playing stereo audio at 44.1 and 48 kHz over S/PDIF works.  The
 relevant mixer knob is this:
 
   playback.mode=dac  [ dac spdif ]
 
 Set to spdif for S/PDIF output, dac (default) for analog output.
 
 This particular card also has a two-pin CD S/PDIF header.  If you
 have an optical drive with a two-pin digital audio output, you
 can connect it to the card, and then enable a by-pass mode where
 audio from the drive is directly output to S/PDIF without the CPU
 having to read any data.  The mixer controls involved are these:
 
   spdif.input=spdin1  [ spdin1 spdin2 spdout ]
   spdif.output=playback  [ playback spdin ]
 
 Set spdif.input=spdin2 to select the CD input and spdif.output=spdin
 to direct it to the card's S/PDIF output.
 
 Strangely, AC3/DTS pass-through does *not* work.  Neither for normal
 playback with MPlayer, nor for a DTS CD using the S/PDIF by-pass.
 My A/V receiver just remains silent or reports a decoding error.

there's this comment in cmpci.c:

 /* disable ac3 and 24 and 32 bit s/pdif modes */

and then the relevant register bits are cleared.  feel free to play
with making it work ;)  I imagine you'll need a mixer control to
select ac3 mode.

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org



Re: cmpci(4) and S/PDIF?

2011-05-11 Thread David Steiner
On Wed, May 04, 2011 at 05:35:07PM +, Christian Weisgerber wrote:
 Has anybody had success using the S/PDIF output of a cmpci(4) sound
 card?
 
 -- 
 Christian naddy Weisgerber  na...@mips.inka.de
 

yes! my soundcard just arrived, which i bought for SPDIF playback with the
C-Media chipset. sofar it works like a charm. here's how i got it
working:

aucat -r 44100 -b 8192 -l
mixerctl -t playback.mode # this puts it in SPDIF playback mode

dmesg specs:
cmpci0 at pci3 dev 0 function 0 C-Media Electronics CMI8738/C3DX Audio
rev 0x10: apic 2 int 20
model: Sweex SC015, 7.1 PCI Sound Card (http://www.sweex.com/SC015)



Re: cmpci(4) and S/PDIF?

2011-05-11 Thread Alexandre Ratchov
On Wed, May 11, 2011 at 03:36:47PM +0200, David Steiner wrote:
 On Wed, May 04, 2011 at 05:35:07PM +, Christian Weisgerber wrote:
  Has anybody had success using the S/PDIF output of a cmpci(4) sound
  card?
  
  -- 
  Christian naddy Weisgerber  na...@mips.inka.de
  
 
 yes! my soundcard just arrived, which i bought for SPDIF playback with the
 C-Media chipset. sofar it works like a charm. here's how i got it
 working:
 
 aucat -r 44100 -b 8192 -l
 mixerctl -t playback.mode # this puts it in SPDIF playback mode
 
 dmesg specs:
 cmpci0 at pci3 dev 0 function 0 C-Media Electronics CMI8738/C3DX Audio
 rev 0x10: apic 2 int 20
 model: Sweex SC015, 7.1 PCI Sound Card (http://www.sweex.com/SC015)

if you do aucat -i /dev/zero, does the server crash after a certain
amount of time?

-- Alexandre



Re: cmpci(4) and S/PDIF?

2011-05-11 Thread David Steiner
On Wed, May 11, 2011 at 05:23:36PM +0200, Christian Weisgerber wrote:
 In article 20110511133647.ga3...@mango.fritz.box you write:
 
   Has anybody had success using the S/PDIF output of a cmpci(4) sound
   card?
  
  yes! my soundcard just arrived, which i bought for SPDIF playback with the
  C-Media chipset. sofar it works like a charm. here's how i got it
  working:
  
  mixerctl -t playback.mode # this puts it in SPDIF playback mode
 
 Can you send me the output of mixerctl -v please?
 
 -- 
 Christian naddy Weisgerber  na...@mips.inka.de

$ mixerctl -v
inputs.dac=192,192 volume
inputs.dac.mute=off  [ off on ]
inputs.fmsynth=192,192 volume
inputs.fmsynth.mute=off  [ off on ]
inputs.cd=0,0 volume
inputs.cd.mute=on  [ off on ]
inputs.line=0,0 volume
inputs.line.mute=on  [ off on ]
inputs.aux=0,0 volume
inputs.aux.mute=on  [ off on ]
inputs.mic=0 volume
inputs.mic.mute=on  [ off on ]
inputs.mic.preamp=off  [ off on ]
inputs.spkr=128 volume
record.source=  { mic cd line aux wave fmsynth spdif }
record.mic=0 volume
playback.mode=spdif  [ dac spdif ]
spdif.input=spdin1  [ spdin1 spdin2 spdout ]
spdif.input.phase=positive  [ positive negative ]
spdif.output=playback  [ playback spdin ]
spdif.output.playback=wave  [ wave legacy ]
spdif.output.voltage=5V  [ 5V 0.5V ]
spdif.monitor=spdout  [ off spdin spdout ]
outputs.master=128,128 volume
outputs.rear=off  [ off on ]
outputs.rear.individual=off  [ off on ]
outputs.rear.reverse=off  [ off on ]
outputs.surround=off  [ off on ]



Re: cmpci(4) and S/PDIF?

2011-05-11 Thread Christian Weisgerber
David Steiner davidsteiner2...@gmail.com wrote:

 yes! my soundcard just arrived, which i bought for SPDIF playback with the
 C-Media chipset. sofar it works like a charm. here's how i got it
 working:
 
 aucat -r 44100 -b 8192 -l
 mixerctl -t playback.mode # this puts it in SPDIF playback mode
 
 dmesg specs:
 cmpci0 at pci3 dev 0 function 0 C-Media Electronics CMI8738/C3DX Audio
 rev 0x10: apic 2 int 20
 model: Sweex SC015, 7.1 PCI Sound Card (http://www.sweex.com/SC015)

Hmm.

I have a similar card (it has only four analog jacks and an additional
joystick port) with the very same chipset...

cmpci0 at pci4 dev 6 function 0 C-Media Electronics CMI8738/C3DX Audio
rev 0x10: apic 2 int 20

... but I can't get it to output anything on the S/PDIF port.

Mysterious.  I'm beginning to wonder if the port on my card is
simply shot.

-- 
Christian naddy Weisgerber  na...@mips.inka.de



cmpci(4) and S/PDIF?

2011-05-04 Thread Christian Weisgerber
Has anybody had success using the S/PDIF output of a cmpci(4) sound
card?

-- 
Christian naddy Weisgerber  na...@mips.inka.de