Bug 99607 - Lack of hardware volume no longer supported with HifimeDIY Tiny
Summary: Lack of hardware volume no longer supported with HifimeDIY Tiny
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: alsa (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-30 22:12 UTC by Jerome
Modified: 2018-07-30 10:29 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Output of alsa-info.sh during the missing DAC IEC958 output issue (6.91 KB, application/gzip)
2017-04-18 20:40 UTC, Jerome
Details

Description Jerome 2017-01-30 22:12:57 UTC
Hi,

I'm using a HifimeDIY Tiny USB DAC (http://hifimediy.com/DACs/ready-made-dacs/tiny-dac), which doesn't support hardware volume (fixed analog gain). This used to work on Debian Jessie, but no longer with Stretch.

This USB DAC is peculiar: it has a first DAC, the TI Burr-Brown, which is only used for its USB interface. Its analog interface is not connected nor used, but the Burr-Brown SPDIF output is connected to the input of a Sabre DAC. It's the Sabre that is actually used to generate the analog output. And the set-up has a fixed analog gain, so the volume control must be done in software.

In Debian Jessie, I could see the two outputs of the Burr-Brown under pulseaudio, analog and SPDIF  (IEC958). Analog was the default and of course gave no output, but I just had to select the IEC958 output to get a working system, with proper volume control.

Now on Stretch I don't see the IEC958 output at all. The output is configured as analog stereo by default, and I do have audio output! So the SPDIF output of the burr-Brown must be used then? However pulseaudio/alsa believe there is hardware volume control, which is not the case: if the volume is at any value but zero, then the output level is full blast. It's really a step function: mute or max output.

I guess this could be solved in one of two ways?:
 1) show back the IEC958 option
 2) disable hardware volume control for this card
I've tried to look for ways to do this without success, but then Linux sound support is new to me so I may have missed something. Thanks for any help/pointer.

I add some info on the dongle as seen by the system:

== pacmd list-cards (just the dongle) ===========================

    index: 2
        name: <alsa_card.usb-Burr-Brown_from_TI_USB_Audio_DAC-00>
        driver: <module-alsa-card.c>
        owner module: 29
        properties:
                alsa.card = "2"
                alsa.card_name = "USB Audio DAC"
                alsa.long_card_name = "Burr-Brown from TI USB Audio DAC at usb-0000:00:14.0-1, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:00:14.0-usb-0:1:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/sound/card2"
                udev.id = "usb-Burr-Brown_from_TI_USB_Audio_DAC-00"
                device.bus = "usb"
                device.vendor.id = "08bb"
                device.vendor.name = "Texas Instruments"
                device.product.id = "2706"
                device.product.name = "PCM2706 Audio Codec"
                device.serial = "Burr-Brown_from_TI_USB_Audio_DAC"
                device.string = "2"
                device.description = "PCM2706 Audio Codec"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        profiles:
                output:analog-mono: Analog Mono Output (priority 200, available: unknown)
                output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
                off: Off (priority 0, available: unknown)
        active profile: <output:analog-stereo>
        sinks:
                alsa_output.usb-Burr-Brown_from_TI_USB_Audio_DAC-00.analog-stereo/#2: PCM2706 Audio Codec Analog Stereo
        sources:
                alsa_output.usb-Burr-Brown_from_TI_USB_Audio_DAC-00.analog-stereo.monitor/#3: Monitor of PCM2706 Audio Codec Analog Stereo
        ports:
                analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
                        properties:

== pacmd list-sources (only USB DAC) =====================

    index: 3
        name: <alsa_output.usb-Burr-Brown_from_TI_USB_Audio_DAC-00.analog-stereo.monitor>
        driver: <module-alsa-card.c>
        flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: SUSPENDED
        suspend cause: IDLE 
        priority: 1040
        volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 0.00 ms
        max rewind: 0 KiB
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 0
        configured latency: 0.00 ms; range is 0.50 .. 2000.00 ms
        monitor_of: 2
        card: 2 <alsa_card.usb-Burr-Brown_from_TI_USB_Audio_DAC-00>
        module: 29
        properties:
                device.description = "Monitor of PCM2706 Audio Codec Analog Stereo"
                device.class = "monitor"
                alsa.card = "2"
                alsa.card_name = "USB Audio DAC"
                alsa.long_card_name = "Burr-Brown from TI USB Audio DAC at usb-0000:00:14.0-1, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:00:14.0-usb-0:1:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/sound/card2"
                udev.id = "usb-Burr-Brown_from_TI_USB_Audio_DAC-00"
                device.bus = "usb"
                device.vendor.id = "08bb"
                device.vendor.name = "Texas Instruments"
                device.product.id = "2706"
                device.product.name = "PCM2706 Audio Codec"
                device.serial = "Burr-Brown_from_TI_USB_Audio_DAC"
                device.string = "2"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"

== lsusb -d 08bb:2706 -v ==========================

Bus 001 Device 005: ID 08bb:2706 Texas Instruments PCM2706 Audio Codec
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x08bb Texas Instruments
  idProduct          0x2706 PCM2706 Audio Codec
  bcdDevice            1.00
  iManufacturer           1 Burr-Brown from TI              
  iProduct                2 USB Audio DAC   
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          190
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0 
      iInterface              0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength           40
        bInCollection           1
        baInterfaceNr( 0)       1
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             2
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID               3
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 3
        bSourceID               1
        bControlSize            1
        bmaControls( 0)      0x01
          Mute Control
        bmaControls( 1)      0x02
          Volume Control
        bmaControls( 2)      0x02
          Volume Control
        iFeature                0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           1
        bDelay                  0 frames
        wFormatTag              1 PCM
      AudioStreaming Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            3 Discrete
        tSamFreq[ 0]        32000
        tSamFreq[ 1]        44100
        tSamFreq[ 2]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            9
          Transfer Type            Isochronous
          Synch Type               Adaptive
          Usage Type               Data
        wMaxPacketSize     0x00c0  1x 192 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioControl Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay            512 Decoded PCM samples
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           1
        bDelay                  0 frames
        wFormatTag              1 PCM
      AudioStreaming Interface Descriptor:
        bLength                17
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             1
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            3 Discrete
        tSamFreq[ 0]        32000
        tSamFreq[ 1]        44100
        tSamFreq[ 2]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            9
          Transfer Type            Isochronous
          Synch Type               Adaptive
          Usage Type               Data
        wMaxPacketSize     0x0060  1x 96 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioControl Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bLockDelayUnits         2 Decoded PCM samples
          wLockDelay            512 Decoded PCM samples
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      36
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0001  1x 1 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)
Comment 1 Jerome 2017-01-31 20:58:59 UTC
Another strange behavior: if I change the sound volume using the keyboard media key, the sound revert to the pulseaudio volume configuration for about a second, but jump back to 100% after. In case it's not clear enough, an example:

 - the USB DAC is at 100% volume, the current stream at something low like 20%. The stream volume has no effect, the DAC volume is at the max;

 - I lower the volume using the keyboard media: this controls the USB DAC and it shows going from 100% to 95% (this value doesn't seem to matter). Immediately the DAC volume matches subjectively the 20% pulse volume;

 - After a short duration, about 1 second, the volume jump back to maximum.

This behavior is independent of the USB DAC volume setting. The only thing affecting the volume is the playing stream setting, for a short second.
So it seems that the volume can be properly set, but something overrides it.
Any pointers on things to check to fix this welcomed...
Comment 2 Tanu Kaskinen 2017-02-04 11:30:27 UTC
If the card presents a volume element that doesn't do anything, that's a kernel driver bug, and should be reported to the alsa developers:
http://alsa-project.org/main/index.php/Bug_Tracking

There's currently no simple way to disable hardware volume. One way to do it is to set the card profile to "off" and then load module-alsa-sink. When you set the card profile to "off", the module-alsa-card instance that was loaded automatically by module-udev-detect will not try to use the device, so it won't conflict with the module-alsa-sink instance that you load manually. module-alsa-sink doesn't use hardware volume unless you explicitly tell it to.

Here's the command to set the profile to "off" (you can also do this with pavucontrol):

pactl set-card-profile alsa_card.usb-Burr-Brown_from_TI_USB_Audio_DAC-00 off

Here's the command to load module-alsa-sink:

pactl load-module module-alsa-sink device=hw:2

("hw:2" assumes that the alsa card index is 2.)

The set-card-profile command needs to be given only once. The load-module command needs to be given every time you boot or plug in the sound card. If the sound card is always plugged in, you can put the load-module command in /etc/pulse/default.pa.

Btw, attachments are nicer for big dumps of information, because if they're in the message body, reading the bug discussion requires a lot of scrolling.
Comment 3 Tanu Kaskinen 2017-02-04 11:34:10 UTC
If you put "flat-volumes = no" to ~/.pulse/config/daemon.conf, I think the stream volume should have the expected effect. I don't know why the volume jumps temporarily to a low level in your experiment, but with flat volumes enabled the stream volume is mostly implemented in hardware, which doesn't work with your sound card.
Comment 4 Jerome 2017-02-04 13:56:53 UTC
Hi Tanu,

Thanks for your time and advice. What you recommended in #comment 2 worked perfectly, and solved both issues I noticed. Disabling the card and re-enabling it manually without relying on auto-detection indeed gets the software volume working immediately. I can also see the SPDIF/iec958 output explicitly listed for the USB DAC, as before the regression.

Please excuse a maybe naive question (I've only superficial knowledge of the Linux audio stack): if it's possible to get the card properly set-up, wouldn't this be an auto-detection issue rather than a driver one? Unless the driver somehow drives/influence in a bad way the auto-detection process?

Thanks again,

Jerome
Comment 5 Tanu Kaskinen 2017-02-04 14:49:57 UTC
(In reply to Jerome from comment #4)
> if it's possible to get the card properly set-up,
> wouldn't this be an auto-detection issue rather than a driver one? Unless
> the driver somehow drives/influence in a bad way the auto-detection process?

The driver claims that the sound card provides hardware volume control, but actually it doesn't. Should PulseAudio ignore all hardware volume controls, because on some cards they do nothing? Surely not. There's no way PulseAudio can automatically figure out whether a hardware volume control does something or not, other than by having a list of hardware with broken drivers. Rather than working around broken drivers in PulseAudio, the drivers should be fixed.
Comment 6 Jerome 2017-02-05 18:09:11 UTC
Sure, this policy makes sense. After digging more, the issue is mostly on the hardware side. There may be a way to be more user friendly however, TBC.

There are two levels of oddities for the hardware, at the device architecture and USB levels. The device architecture is:

          ----------------------              -------------
  USB --->| PCM2706 Burr Brown |-- IEC958 --->| Sabre DAC |---> Analog out
          ----------------------              -------------     Headset
                    |
                    V
                Analog out
                 UNUSED!

The PCM2706 is only used for its USB interface. It has an internal DAC with an analog output, but this output is not used. Instead, the PCM2706 has a digital output, which is used to feed another better DAC from Sabre. This other DAC output is the device output (headset 3.5 mm jack).

But at the USB level, only the PCM2706 is seen with a completely stock configuration. Even the USB id is generic for the PCM2706, so there's no way to identify this specific set-up.

And the USB audio class descriptors of the PCM2706 do not even reflect its internal set-up. It would have been possible to describe at the USB level both analog and digital output, but that's not done. From the USB descriptors, the PCM2706 is a simple pipe with just the analog output:

   --------------------     ---------------     -----------------
   | USB input stream |---->| Mute+Volume |---->| Analog output |
   --------------------     ---------------     -----------------

There is indeed hardware volume support, but from the PCM2706 datasheet it applies only to the (unused) analog output, not to the digital IEC958 interface.

I saw two changes when upgrading from Jessie to Stretch:
  1) selecting the analog profile used to give no sound, now it does
     with a step volume effect;
  2) the IEC95 profile had disappeared.

The first change (1) I now understand: it's just that the IEC958 output is enabled too when the analog output is enabled. The driver level correctly report a hardware volume control for the analog output. But it doesn't apply to the actually used IEC958 output (per the PCM2706 datasheet). And when the volume is set to 0, the mute is likely enabled and this does apply to the IEC958 output too. So the observed behavior is OK. Enabling the IEC958 output too confused me, but why not.
(I still don't understand why using the keyboard volume control switches to software volume for a split second before going back to hardware, but it's a minor point)

The second change (2) was the real problem in my case. But after the suggested work-around the IEC958 profile is back, and when using it all is ok again. I set it as default profile, and it's sticky across reboots / plug and unplug now. I didn't see it disappear again since.

Because the IEC958 output is not part of the USB description, this profile must be added by a driver handling the PCM2706. I tried to grep around for the Burr Brown id and this device family (270[4567]) in the kernel source and ALSA data, but couldn't find where it is managed. The datasheet is not clear either on how the digital output is controlled. So I don't understand how this interface is handled and why it disappeared.

Anyway, considering the situation and with the IEC958 profile back, both pulseaudio and the driver level both reflect the reality of the device hardware.

The only improvement (maybe?) could be to prefer the IEC958 profile to the analog output of the PCM2706, if this digital port is connected. From what I see the PCM2706 is now mostly used for its USB interface, and the HifimeDIY type of design is common. There are other better cheap DAC for the analog ouput, and even a cheap USB DAC dongle like the HifimeDIY can afford one. This would avoid the strange experience with the default analog output (higher priority for now). 
However this would require reliably detecting that the PCM2706 digital output is used, to avoid a regression for old PCM2706 only device using its built-in DAC and where the IEC958 output is not used. I don't know if this is possible.
Even if it's not, this comment can at least help clarify what's happening for users of this USB DAC or similar designs ;)

Thanks
Comment 7 Tanu Kaskinen 2017-04-18 14:23:00 UTC
Sorry for slow reply, I have trouble keeping up with the pace of incoming emails...

(In reply to Jerome from comment #6)
> Sure, this policy makes sense. After digging more, the issue is mostly on
> the hardware side. There may be a way to be more user friendly however, TBC.
> 
> There are two levels of oddities for the hardware, at the device
> architecture and USB levels. The device architecture is:
> 
>           ----------------------              -------------
>   USB --->| PCM2706 Burr Brown |-- IEC958 --->| Sabre DAC |---> Analog out
>           ----------------------              -------------     Headset
>                     |
>                     V
>                 Analog out
>                  UNUSED!
> 
> The PCM2706 is only used for its USB interface. It has an internal DAC with
> an analog output, but this output is not used. Instead, the PCM2706 has a
> digital output, which is used to feed another better DAC from Sabre. This
> other DAC output is the device output (headset 3.5 mm jack).
> 
> But at the USB level, only the PCM2706 is seen with a completely stock
> configuration. Even the USB id is generic for the PCM2706, so there's no way
> to identify this specific set-up.
> 
> And the USB audio class descriptors of the PCM2706 do not even reflect its
> internal set-up. It would have been possible to describe at the USB level
> both analog and digital output, but that's not done. From the USB
> descriptors, the PCM2706 is a simple pipe with just the analog output:
> 
>    --------------------     ---------------     -----------------
>    | USB input stream |---->| Mute+Volume |---->| Analog output |
>    --------------------     ---------------     -----------------
> 
> There is indeed hardware volume support, but from the PCM2706 datasheet it
> applies only to the (unused) analog output, not to the digital IEC958
> interface.
> 
> I saw two changes when upgrading from Jessie to Stretch:
>   1) selecting the analog profile used to give no sound, now it does
>      with a step volume effect;
>   2) the IEC95 profile had disappeared.
> 
> The first change (1) I now understand: it's just that the IEC958 output is
> enabled too when the analog output is enabled. The driver level correctly
> report a hardware volume control for the analog output. But it doesn't apply
> to the actually used IEC958 output (per the PCM2706 datasheet). And when the
> volume is set to 0, the mute is likely enabled and this does apply to the
> IEC958 output too. So the observed behavior is OK. Enabling the IEC958
> output too confused me, but why not.

What does "aplay -l" print? Your description sounds like on Jessie there were separate alsa PCM devices for analog and digital (likely "hw:x,0" for analog and "hw:x,1" for digital, with the latter mapped to "iec958:x"), but now there's only digital, which pulseaudio incorrectly guesses is analog (for analog stereo output, pulseaudio tries first "front:x" and if that doesn't work, pulseaudio tries "hw:x,0" and if that works, pulseaudio assumes that it's an analog device even if it isn't).

> (I still don't understand why using the keyboard volume control switches to
> software volume for a split second before going back to hardware, but it's a
> minor point)
> 
> The second change (2) was the real problem in my case. But after the
> suggested work-around the IEC958 profile is back, and when using it all is
> ok again. I set it as default profile, and it's sticky across reboots / plug
> and unplug now. I didn't see it disappear again since.

Which work-around are you referring to? Setting the card profile to "off" and loading module-alsa-sink? If that's the workaround, what does "the IEC958 profile is back" mean? If you load module-alsa-sink, that shouldn't have any effect on the set of available profiles on the card object.

> Because the IEC958 output is not part of the USB description, this profile
> must be added by a driver handling the PCM2706. I tried to grep around for
> the Burr Brown id and this device family (270[4567]) in the kernel source
> and ALSA data, but couldn't find where it is managed. The datasheet is not
> clear either on how the digital output is controlled. So I don't understand
> how this interface is handled and why it disappeared.

I don't know all the details either, but since pulseaudio doesn't any more present a digital profile on the card, the "iec958" PCM device has apparently been removed for the card in the alsa configuration (shipped in alsa-lib). To verify, you can check the output of "aplay -L" - does it show that a device named iec958 exists?
Comment 8 Jerome 2017-04-18 20:40:20 UTC
Created attachment 130906 [details]
Output of alsa-info.sh during the missing DAC IEC958 output issue
Comment 9 Jerome 2017-04-18 21:02:14 UTC
(In reply to Tanu Kaskinen from comment #7)
> Sorry for slow reply, I have trouble keeping up with the pace of incoming
> emails...

It's ok, and thanks a lot for your time. I cannot reproduce the issue anymore, the IEC958 interface is now always there and working fine. If you want me to check some things I'd be happy to help, but otherwise I don't think you should spend time on this. It looks like a transient glitch at a time when Stretch was still moving quite fast.

Besides this glitch, a change that could make sense IMHO is to set the IEC958 interface of a PCM2706 chip (when seen ;) at a higher priority than it's analog output: it seems today the PCM2706 is mostly used for its USB interface only and not as a DAC. The D/A conversion is done by a better DAC chip, as for my dongle:

[...] The device architecture is:
> > 
> >           ----------------------              -------------
> >   USB --->| PCM2706 Burr Brown |-- IEC958 --->| Sabre DAC |---> Analog out
> >           ----------------------              -------------     Headset
> >                     |
> >                     V
> >                 Analog out
> >                  UNUSED!

When I plugged the dongle on a Win7 PC, audio worked out of the box with a fixed level so Win7 did use the IEC958 port by default. So it looks like a safe choice. And for now PA gives higher priority to the analog output, as shown by "pacmd list-cards":

 profiles:
    output:analog-mono: Analog Mono Output (priority 200, available: unknown)
    output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
    output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)
    off: Off (priority 0, available: unknown)

So a user plugging this DAC will not have any sound until manually selecting the IEC958 output. Having the IEC958 as highest priority would give sound out of the box. Do you think it's worth creating a bug entry for this? If yes would it be for PA, or are the priority set elsewhere?

I reply to your questions below, but again feel free to skip.

> What does "aplay -l" print? Your description sounds like on Jessie there
> were separate alsa PCM devices for analog and digital (likely "hw:x,0" for
> analog and "hw:x,1" for digital, with the latter mapped to "iec958:x"), but
> now there's only digital, which pulseaudio incorrectly guesses is analog
> (for analog stereo output, pulseaudio tries first "front:x" and if that
> doesn't work, pulseaudio tries "hw:x,0" and if that works, pulseaudio
> assumes that it's an analog device even if it isn't).

I can't reproduce the issue, but see the output of alsa-info.sh in comment #7.

Now on stretch with things back ok, "aplay -l" gives only one entry for the USB DAC:

 card 2: DAC [USB Audio DAC], device 0: USB Audio [USB Audio]
   Subdevices: 1/1
   Subdevice #0: subdevice #0

> > The second change (2) was the real problem in my case. But after the
> > suggested work-around the IEC958 profile is back, and when using it all is
> > ok again. I set it as default profile, and it's sticky across reboots / plug
> > and unplug now. I didn't see it disappear again since.
> 
> Which work-around are you referring to? Setting the card profile to "off"
> and loading module-alsa-sink?

Yes, doing as in comment #2.

> If that's the workaround, what does "the IEC958 profile is back" mean?

The "IEC958 profile is back" means I can see it at pulseaudio level. When doing a "pactl list cards" the entry for the USB DAC "Profiles" section is now:

 Profiles:
    output:analog-mono: Analog Mono Output (sinks: 1, sources: 0, priority: 200, available: yes)
    output:analog-stereo: Analog Stereo Output (sinks: 1, sources: 0, priority: 6000, available: yes)
    output:iec958-stereo: Digital Stereo (IEC958) Output (sinks: 1, sources: 0, priority: 5500, available: yes)
    off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
 Active Profile: output:iec958-stereo

So the IEC958 profile is properly listed again.

Before, when I had the issue, the IEC958 profile was missing at PA level. Only the analog mono, stereo and off profiles were shown. When I tried to force select a (not shown) iec958-stereo profile from the CLI, it was rejected as an error. So only the analog output was usable, and the IEC958 was gone and not shown in any PA UI (CLI or GUI).

> If you load module-alsa-sink, that shouldn't
> have any effect on the set of available profiles on the card object.

Stretch was quite a moving target at the time, I can't rule out that something else changed that got the IEC958 back. But subjectively, I ran the 2 commands and noticed the IEC958 being back again. And it's been fine since then.

> > Because the IEC958 output is not part of the USB description, this profile
> > must be added by a driver handling the PCM2706. I tried to grep around for
> > the Burr Brown id and this device family (270[4567]) in the kernel source
> > and ALSA data, but couldn't find where it is managed. The datasheet is not
> > clear either on how the digital output is controlled. So I don't understand
> > how this interface is handled and why it disappeared.
> 
> I don't know all the details either, but since pulseaudio doesn't any more
> present a digital profile on the card, the "iec958" PCM device has
> apparently been removed for the card in the alsa configuration (shipped in
> alsa-lib). To verify, you can check the output of "aplay -L" - does it show
> that a device named iec958 exists?

I can't reproduce the issue now, but I do have the output of alsa-info.sh from when the USB DAC IEC958 was gone. It does not show any iec958 interface for the USB DAC, so ALSA wasn't seeing it (attached as comment #7).

Now things are back to normal "aplay -L" does show an IEC958 entry for the DAC:

  iec958:CARD=DAC,DEV=0
  USB Audio DAC, USB Audio
  IEC958 (S/PDIF) Digital Audio Output

So it looks like it was a transient ALSA level detection issue. 

Thanks again.
Comment 10 GitLab Migration User 2018-07-30 10:29:46 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/463.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.