2

On a custom platform utilizing Congatec's SA5 module and an attached CS4207 HDA-codec I'm trying to use the codecs digital SPDIF input and output. The HDA-design was copied from Congatec'S conga-SEVAL evaluation board.

The SPDIF output (connected to an amplifier) was working out of the box - no problems here.
But the SPDIF input (signal needs to be recorded) is giving me some headaches.

During testing I'm using a Xubuntu 20.04

Linux Test-01 5.4.0-48-generic #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

later we are going to implement these features in a buildroot.

What I've done so far

By using the hda_analyser.py tool i was able to see that the SPDIF input widgets are by default disabled. Manually enabling them made no difference in outcome:

# Node 0x07 SPDIF Reciver Input Converter - Enable
hda-verb /dev/snd/hwC0D0 0x07 0x70d 0x01
# Node 0x0f SPDIF Reciver Input Pin - Enable
hda-verb /dev/snd/hwC0D0 0x0f 0x707 0x20

When i provide a signal to the SPDIF input hda_analyser shows the valid flag and the control word contents of the signal. So i assume the source good. hda_analyser without and with valid signal

By manually enabling the CS4207's "SPDIF RX to TX1 loopthru" feature:

# Enable Rx to Tx1 Loopthru
hda-verb /dev/snd/hwC0D0 0x11 0x0500 0x01 && hda-verb /dev/snd/hwC0D0 0x11 0x0400 0x402a

I was able too hear the signal fed into the SPDIF input out of speaker attached to the SPDIF output.

-> So my conclusion is that the hardware part should be ok.

On the ALSA side I think there's a configuration problem because the IEC958 digital capture device isn't listed. But that's the part where i can't get my head around. There are so many configuration paths (/usr/share/pulseaudio/alsa-mixer/ /etc/alsa/conf.d/ /usr/share/alsa/) and even more configuration templates with placeholders that seem to be filled by something else. But i didn't find a way to figure out the configuration that's effectively in use.
Within the ALSA documentation couldn't find any hints either.

Output of aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CS4207 Analog [CS4207 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: CS4207 Digital [CS4207 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Output of arecord -l (no Digital input listed here):

**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CS4207 Analog [CS4207 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Output of pacmd list-cards:

1 card(s) available.
    index: 0
        name: <alsa_card.pci-0000_00_0e.0>
        driver: <module-alsa-card.c>
        owner module: 7
        properties:
                alsa.card = "0"
                alsa.card_name = "HDA Intel PCH"
                alsa.long_card_name = "HDA Intel PCH at 0x91410000 irq 143"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:0e.0"
                sysfs.path = "/devices/pci0000:00/0000:00:0e.0/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "5a98"
                device.product.name = "Celeron N3350/Pentium N4200/Atom E3900 Series Audio Cluster"
                device.form_factor = "internal"
                device.string = "0"
                device.description = "Built-in Audio"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        profiles:
                input:analog-stereo: Analog Stereo Input (priority 65, available: unknown)
                output:analog-stereo: Analog Stereo Output (priority 6500, available: unknown)
                output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6565, available: unknown)
                output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)
                output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output + Analog Stereo Input (priority 5565, available: unknown)
                output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5900, available: no)
                output:hdmi-stereo+input:analog-stereo: Digital Stereo (HDMI) Output + Analog Stereo Input (priority 5965, available: no)
                output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 800, available: no)
                output:hdmi-surround+input:analog-stereo: Digital Surround 5.1 (HDMI) Output + Analog Stereo Input (priority 865, available: no)
                output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 800, available: no)
                output:hdmi-surround71+input:analog-stereo: Digital Surround 7.1 (HDMI) Output + Analog Stereo Input (priority 865, available: no)
                output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5700, available: no)
                output:hdmi-stereo-extra1+input:analog-stereo: Digital Stereo (HDMI 2) Output + Analog Stereo Input (priority 5765, available: no)
                output:hdmi-surround-extra1: Digital Surround 5.1 (HDMI 2) Output (priority 600, available: no)
                output:hdmi-surround-extra1+input:analog-stereo: Digital Surround 5.1 (HDMI 2) Output + Analog Stereo Input (priority 665, available: no)
                output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output (priority 600, available: no)
                output:hdmi-surround71-extra1+input:analog-stereo: Digital Surround 7.1 (HDMI 2) Output + Analog Stereo Input (priority 665, available: no)
                output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 5700, available: no)
                output:hdmi-stereo-extra2+input:analog-stereo: Digital Stereo (HDMI 3) Output + Analog Stereo Input (priority 5765, available: no)
                output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority 600, available: no)
                output:hdmi-surround-extra2+input:analog-stereo: Digital Surround 5.1 (HDMI 3) Output + Analog Stereo Input (priority 665, available: no)
                output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (priority 600, available: no)
                output:hdmi-surround71-extra2+input:analog-stereo: Digital Surround 7.1 (HDMI 3) Output + Analog Stereo Input (priority 665, available: no)
                output:hdmi-stereo-extra3: Digital Stereo (HDMI 4) Output (priority 5700, available: no)
                output:hdmi-stereo-extra3+input:analog-stereo: Digital Stereo (HDMI 4) Output + Analog Stereo Input (priority 5765, available: no)
                output:hdmi-surround-extra3: Digital Surround 5.1 (HDMI 4) Output (priority 600, available: no)
                output:hdmi-surround-extra3+input:analog-stereo: Digital Surround 5.1 (HDMI 4) Output + Analog Stereo Input (priority 665, available: no)
                output:hdmi-surround71-extra3: Digital Surround 7.1 (HDMI 4) Output (priority 600, available: no)
                output:hdmi-surround71-extra3+input:analog-stereo: Digital Surround 7.1 (HDMI 4) Output + Analog Stereo Input (priority 665, available: no)
                output:hdmi-stereo-extra4: Digital Stereo (HDMI 5) Output (priority 5700, available: no)
                output:hdmi-stereo-extra4+input:analog-stereo: Digital Stereo (HDMI 5) Output + Analog Stereo Input (priority 5765, available: no)
                output:hdmi-surround-extra4: Digital Surround 5.1 (HDMI 5) Output (priority 600, available: no)
                output:hdmi-surround-extra4+input:analog-stereo: Digital Surround 5.1 (HDMI 5) Output + Analog Stereo Input (priority 665, available: no)
                output:hdmi-surround71-extra4: Digital Surround 7.1 (HDMI 5) Output (priority 600, available: no)
                output:hdmi-surround71-extra4+input:analog-stereo: Digital Surround 7.1 (HDMI 5) Output + Analog Stereo Input (priority 665, available: no)
                off: Off (priority 0, available: unknown)
        active profile: <output:analog-stereo+input:analog-stereo>
        sinks:
                alsa_output.pci-0000_00_0e.0.analog-stereo/#0: Built-in Audio Analog Stereo
        sources:
                alsa_output.pci-0000_00_0e.0.analog-stereo.monitor/#0: Monitor of Built-in Audio Analog Stereo
                alsa_input.pci-0000_00_0e.0.analog-stereo/#1: Built-in Audio Analog Stereo
        ports:
                analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-input-microphone"
                analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: yes)
                        properties:

                analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: no)
                        properties:

                analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
                        properties:
                                device.icon_name = "audio-speakers"
                analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "audio-headphones"
                iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
                        properties:

                hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-3: HDMI / DisplayPort 4 (priority 5600, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"
                hdmi-output-4: HDMI / DisplayPort 5 (priority 5500, latency offset 0 usec, available: no)
                        properties:
                                device.icon_name = "video-display"

Another thing that caught my attention was a comment in /usr/share/pulseaudio/alsa-mixer/paths/analog-input.conf.common

;  We explicitly don't want to wrap the following sources:
;
;       CD
[...]
;       Digital/SPDIF

What now

So is there an easy way to simply enable the IEC958 capture device?
Where or how do i obtain the currently effective alsa configuration to modify?
--> See this answer

EDIT

The SPDIF-In feature for the CS4207 codec got lost somewhere between kernel 3.5 and 3.8. During that time major refactoring of the patch_cirrus.c took place.

So even when i add the ALSA controls for the IEC958-Inputs (copied from the default config of kernel 3.5) to the contiguration of the current kernel:

    control.67 {
        iface MIXER
        name 'IEC958 Capture Switch'
        value false
        comment {
            access 'read write'
            type BOOLEAN
            count 1
        }
    }
    control.68 {
        iface MIXER
        name 'IEC958 Capture Default'
        value '0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
        comment {
            access read
            type IEC958
            count 1
        }
    }

i get in return:

Found hardware: "HDA-Intel" "Cirrus Logic CS4207" "HDA:10134207,10134207,00100302 HDA:8086280a,80860101,00100000" "0x8086" "0x7270"
Hardware is initialized using a generic method
alsactl: set_control:1325: failed to obtain info for control #67 (No such file or directory)
alsactl: set_control:1325: failed to obtain info for control #68 (No such file or directory)

So it seems that the hda-driver doesn't provide the SPDIF input to the system. The problem therefore isn't about ALSA-configuration anymore but is hda-driver related.

0

See the EDIT in the original post for additional (ALSA unrelated) problems

Answer to the original question about ALSA-configuration:

It seems that alsa-info is the best place too look at in first place.
According to that script you can save the currently effective ALSA-confiruration via:

alsactl -f /tmp/alsa-config.txt store

afterwards the configuration can be changed in within the file (in this case /tmp/alsa-config.txt) and the config can be restored by

alsactl -f /tmp/alsa-config.txt restore

Also the currently effective ALSA-configuration is by default stored in

/var/lib/alsa/asound.state
0

Make the SPDIF-In available

The main problem is that snd_hda framework currently only supports one digital input pin and the CS4207 has 3 of them.
During parsing of the codec-pins all three of them pass the loop and the last one wins and gets presented to ALSA. The trick is that pins without any configured connection get skipped in the loop.

Usually the pin configurations are set by the BIOS. Since we don't control the BIOS in this setup that's not an option.

An other alternative is to set the pin configurations by using a patch file (as described here in the section Early Patching).

To do that i need the pins Node IDs in this case 0x0E and 0x12 and read their current pin configuration:

# hda-verb /dev/snd/hwC0D0 0x0e GET_CONFIG_DEFAULT 0x00
nid = 0xe, verb = 0xf1c, param = 0x0
value = 0xb7d6003e
# hda-verb /dev/snd/hwC0D0 0x12 GET_CONFIG_DEFAULT 0x00
nid = 0x12, verb = 0xf1c, param = 0x0
value = 0xb7d6005e

alternative

# cat /sys/class/sound/hwC0D0/init_pin_configs
0x09 0x022140f0
0x0a 0x010140f0
0x0b 0x901700f0
0x0c 0x01813051
0x0d 0x01a19031
0x0e 0xb7d6003e
0x0f 0x02c4e0f0
0x10 0x014460f0
0x12 0xb7d6005e
0x15 0x014510f0

Then change the first 2 bits in the configuration to "no connection" (01). The meaning of the configuration bits is documented in the HDA-specification 7.3.3.31 Configuration Default.
So 0x0e 0xb7d6003e -> 0x0e 0x77d6003e and 0x12 0xb7d6005e -> 0x12 0xb7d6005e.

Using these values a patch file e.g /lib/firmware/patch_cs4207 with the following content can be created:

[codec]
0x10134207 0x10134207 0

[pincfg]
0x0e 0x77d6003e
0x12 0x77d6005e

Under [codec] the vendor_id, subsystem_id and address needs to be listed.

After that the patch file needs to be loaded by snd_hda_intel. To do that the following line needs to be added to the /etc/modprobe.d/alsa-base.conf:

options snd-hda-intel patch=patch_cs4207

After a reboot no further ALSA tweaking is necessary and the SPDIF-In is recognized:

# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CS4207 Analog [CS4207 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: CS4207 Digital [CS4207 Digital]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.