ALSA: 6fire: S/PDIF output as playback channels 7/8 or as, a second PCM device?
Hello,
I have a patch that enables the S/PDIF output of the TerraTec DMX 6Fire USB (sound/usb/6fire). Before I send it, I would like to know which of two ways of exposing the output you would accept.
The hardware
------------
The card has six analog outputs and one S/PDIF transmitter. All playback data goes to the card in one isochronous OUT stream. At 44.1 to 96 kHz the packets have space for 8 slots of 32 bits per frame: six for the analog outputs and two for the S/PDIF transmitter. The mainline driver sends only the six analog slots. At 176.4 and 192 kHz (altsetting 3) a packet carries only the six analog slots (604 = 4 + 25 * 6 * 4 bytes), so the S/PDIF output is available up to 96 kHz. The card has one sample rate for all outputs and the analog inputs.
The driver shares the isochronous streams between the playback and the capture substream: the first prepare sets the card rate, and while the stream runs, open offers only that rate.
In its multi-channel mode, the Windows driver of the vendor exposes the analog outputs and the S/PDIF output as two devices. The manual says:
"This is a multi-channel driver that signals all six analogue output drivers to the operating system as one multi-channel driver. [...] The digital driver is available separately, with the designation "DMX 6Fire Digital Out"." In its multi-device mode the driver exposes four stereo devices, and the S/PDIF output is again a separate device.
Option A: one PCM device with 8 playback channels (patch available)
-------------------------------------------------------------------
Playback channels 7 and 8 are the S/PDIF pair. The hw_params rules allow 7 or 8 channels only at rates up to 96 kHz; at 176.4 and 192 kHz they allow at most 6. A channel map gives channels 7 and 8 the position UNKNOWN. I tested the S/PDIF output on the hardware at 44.1, 48 and 96 kHz.
ICE1712, hdsp and the FireWire drivers put an S/PDIF pair that shares a stream with analog channels into the same PCM device. alsa-lib splits the ICE1712 device with a card file (ICE1712.conf), and UCM splits several USB-Audio devices with SplitPCMDevice. alsa-lib has no card file for the driver name 6FireUSB.
The drawback: a client that opens hw:X,0 with the largest channel count gets 8 channels and at most 96 kHz. Without the patch the same client gets 6 channels at up to 192 kHz. With the Pro Audio profile of PipeWire 1.6.9 and the rate set to 176.4 or 192 kHz, PipeWire ran the card at 96 kHz. A client that ignores the channel map and assumes a 7.1 layout sends the side pair to the S/PDIF output.
Option B: S/PDIF as PCM device 1 (no patch)
-------------------------------------------
Device 0 stays as in mainline: 6 playback channels, up to 192 kHz. Device 1 has one playback substream with 2 channels, up to 96 kHz. In the URB handler a third substream writes slots 7 and 8 of the same OUT packets. While device 1 is closed, these slots carry zeros. The rate is handled as between playback and capture in mainline: while the card runs, open offers only the rate of the card. In addition, while the card runs at 176.4 or 192 kHz, opening device 1 fails with -EBUSY. The IEC958 controls are attached to device 1. I plan the S/PDIF input as a later patch; it would be the capture substream of device 1, because the receiver outputs frames at the rate of the source, which can differ from the rate of the card.
The drawback: device 0 and device 1 start independently. Unless the driver supports a linked start (snd_pcm_link()) and starts both in the same packet, the analog and the digital channels are not aligned to the sample. I did not find an in-tree driver that splits one shared stream into two PCM devices. The drivers with a separate S/PDIF PCM device that I found (ice1724, oxygen) have a separate DMA channel for it.
The question
------------
Which option do you prefer? If option B, is a driver that sends the data of two PCM devices in one isochronous stream acceptable?
Thanks,
Piotr
Jaroslav Kysela
maintainerQuoted 75 lines · Piotr Gliźniewicz
Hello,
I have a patch that enables the S/PDIF output of the TerraTec DMX 6Fire USB (
sound/usb/6fire). Before I send it, I would like to know which of two ways of exposing the output you would accept.The hardware
------------The card has six analog outputs and one S/PDIF transmitter. All playback data goes to the card in one isochronous OUT stream. At 44.1 to 96 kHz the packets have space for 8 slots of 32 bits per frame: six for the analog outputs and two for the S/PDIF transmitter. The mainline driver sends only the six analog slots. At 176.4 and 192 kHz (altsetting 3) a packet carries only the six analog slots (604 = 4 + 25 * 6 * 4 bytes), so the S/PDIF output is available up to 96 kHz. The card has one sample rate for all outputs and the analog inputs.
The driver shares the isochronous streams between the playback and the capture substream: the first prepare sets the card rate, and while the stream runs, open offers only that rate.
In its multi-channel mode, the Windows driver of the vendor exposes the analog outputs and the S/PDIF output as two devices. The manual says:
"This is a multi-channel driver that signals all six analogue output drivers to the operating system as one multi-channel driver. [...] The digital driver is available separately, with the designation "DMX 6Fire Digital Out"." In its multi-device mode the driver exposes four stereo devices, and the S/PDIF output is again a separate device.Option A: one PCM device with 8 playback channels (patch available)
-------------------------------------------------------------------Playback channels 7 and 8 are the S/PDIF pair. The
hw_paramsrules allow 7 or 8 channels only at rates up to 96 kHz; at 176.4 and 192 kHz they allow at most 6. A channel map gives channels 7 and 8 the position UNKNOWN. I tested the S/PDIF output on the hardware at 44.1, 48 and 96 kHz.ICE1712, hdsp and the FireWire drivers put an S/PDIF pair that shares a stream with analog channels into the same PCM device. alsa-lib splits the ICE1712 device with a card file (ICE1712.conf), and UCM splits several USB-Audio devices with SplitPCMDevice. alsa-lib has no card file for the driver name 6FireUSB.
The drawback: a client that opens hw:X,0 with the largest channel count gets 8 channels and at most 96 kHz. Without the patch the same client gets 6 channels at up to 192 kHz. With the Pro Audio profile of PipeWire 1.6.9 and the rate set to 176.4 or 192 kHz, PipeWire ran the card at 96 kHz. A client that ignores the channel map and assumes a 7.1 layout sends the side pair to the S/PDIF output.
Option B: S/PDIF as PCM device 1 (no patch)
-------------------------------------------Device 0 stays as in mainline: 6 playback channels, up to 192 kHz. Device 1 has one playback substream with 2 channels, up to 96 kHz. In the URB handler a third substream writes slots 7 and 8 of the same OUT packets. While device 1 is closed, these slots carry zeros. The rate is handled as between playback and capture in mainline: while the card runs, open offers only the rate of the card. In addition, while the card runs at 176.4 or 192 kHz, opening device 1 fails with
-EBUSY. The IEC958 controls are attached to device 1. I plan the S/PDIF input as a later patch; it would be the capture substream of device 1, because the receiver outputs frames at the rate of the source, which can differ from the rate of the card.The drawback: device 0 and device 1 start independently. Unless the driver supports a linked start (
snd_pcm_link()) and starts both in the same packet, the analog and the digital channels are not aligned to the sample. I did not find an in-tree driver that splits one shared stream into two PCM devices. The drivers with a separate S/PDIF PCM device that I found (ice1724, oxygen) have a separate DMA channel for it.
Quoted 5 lines
The question
------------Which option do you prefer? If option B, is a driver that sends the data of two PCM devices in one isochronous stream acceptable?
We prefer to not add complexity to the drivers, so option A with correct UCM channel description is best IMHO. Pipewire supports the split now. The apps should follow the channel maps for direct hw:X,Y access.
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat