Skip to contentSkip to conversation

sof-soundwire: the `Headphone Switch` cset in rt721.conf breaks the whole HiFi verb on amd-soundwire cards

DISCUSSION GitHub issues - opened 1 participant 1 message Aug 5 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

alsa-project/alsa-ucm-conf issue #825 was opened from Robin-Everaars:

### Summary

On AMD SoundWire cards, snd_use_case_set(uc_mgr, "_verb", "HiFi") fails with -ENOENT because ucm2/sof-soundwire/rt721.conf csets a control named Headphone Switch that the card does not expose. ucm2/sof-soundwire/HiFi.conf uses disdevall "" as its verb EnableSequence, so every device DisableSequence runs during verb activation. The Headphones DisableSequence therefore takes the verb down before any device is selected, and the card ends up with no usable verb at all.

conf.d/amd-soundwire/amd-soundwire.conf is a symlink to ../../sof-soundwire/sof-soundwire.conf, so an AMD card inherits the Intel SOF device definitions verbatim, including that cset.

Downstream, PipeWire's ACP layer calls the same function, gets the same -ENOENT and silently falls back to its built-in profile set. That fallback binds the sink to PCM 0 (the RT721 headset path) instead of the speakers, so audio comes out of the headphone jack and the speaker amps are never addressed.

### Hardware

* ASUS ProArt PX13 HN7306EAC (AMD Strix Halo)
* Card 1 amdsoundwire, driver amd-soundwire, longname ASUSTeKCOMPUTERINC.-ProArtPX13HN7306EAC-1.0-HN7306EAC
* Components string: cfg-amp:2 mic:acp-dmic cfg-mics:1 hs:rt721 spk:tas2783
* Realtek RT721 SDCA on SoundWire, two TI TAS2783 SmartAmps on SDW1, AMD ACP PDM DMIC array
* Kernel 7.1.5, alsa-lib and alsa-ucm-conf 1.2.16.1, alsa-utils 1.2.16, PipeWire 1.6.8, WirePlumber 0.5.15, NixOS
* ALSA_CONFIG_UCM2 points at a copy of stock alsa-ucm-conf 1.2.16.1 plus one added file, sof-soundwire/tas2783.conf. Without it the mandatory Include.a.File "/sof-soundwire/${var:SpeakerCodecFile}.conf" in sof-soundwire.conf aborts snd_use_case_mgr_open with -2. That part is what PR #812 addresses.

### Reproducer

```
$ alsaucm -c hw:1 list _verbs
  0: HiFi
    Play HiFi quality Music

$ alsaucm -c hw:1 set _verb HiFi
ALSA lib main.c:843:(execute_sequence) [error.ucm] unable to execute cset 'name='Headphone Switch' off'
ALSA lib main.c:2866:(set_verb_user) [error.ucm] failed to initialize new use case: HiFi
alsaucm: error failed to set _verb=HiFi: No such file or directory
```

Enumeration works, activation does not. The card has 19 controls and none of them is Headphone Switch:

```
$ amixer -c 1 controls
numid=19,iface=MIXER,name='rt721 ADC 07 L Mux'
numid=18,iface=MIXER,name='rt721 ADC 07 R Mux'
numid=15,iface=MIXER,name='rt721 ADC 08 L Mux'
numid=14,iface=MIXER,name='rt721 ADC 08 R Mux'
numid=13,iface=MIXER,name='rt721 ADC 09 Mux'
numid=17,iface=MIXER,name='rt721 ADC 10 L Mux'
numid=16,iface=MIXER,name='rt721 ADC 10 R Mux'
numid=1,iface=MIXER,name='rt721 FU05 Playback Volume'
numid=5,iface=MIXER,name='rt721 FU06 Playback Volume'
numid=2,iface=MIXER,name='rt721 FU0F Capture Switch'
numid=3,iface=MIXER,name='rt721 FU0F Capture Volume'
numid=8,iface=MIXER,name='rt721 FU15 Boost Volume'
numid=6,iface=MIXER,name='rt721 FU1E Capture Switch'
numid=7,iface=MIXER,name='rt721 FU1E Capture Volume'
numid=4,iface=MIXER,name='rt721 FU33 Boost Volume'
numid=9,iface=MIXER,name='tas2783-1 Amp Volume'
numid=10,iface=MIXER,name='tas2783-1 Speaker Volume'
numid=11,iface=MIXER,name='tas2783-2 Amp Volume'
numid=12,iface=MIXER,name='tas2783-2 Speaker Volume'
```

The offending lines are ucm2/sof-soundwire/rt721.conf 58 to 70 (v1.2.16.1), the two csets being lines 62 and 66:

```
SectionDevice."Headphones" {
	Comment	"Headphones"

	EnableSequence [
		cset "name='Headphone Switch' on"
	]

	DisableSequence [
		cset "name='Headphone Switch' off"
	]

	Value {
	      PlaybackPriority 200
	      PlaybackPCM "hw:${CardId}"
	      JackControl "Headphone Jack"
	}
}
```

and the verb sequence that pulls the DisableSequence in, ucm2/sof-soundwire/HiFi.conf 3 to 6:

```
SectionVerb {
	EnableSequence [
		disdevall ""
	]
```

### Proof that this single cset is the whole problem

Copy the tree, guard those two sequences with a ControlExists condition and change nothing else:

```diff
--- a/ucm2/sof-soundwire/rt721.conf
+++ b/ucm2/sof-soundwire/rt721.conf
@@ -58,12 +58,18 @@
 SectionDevice."Headphones" {
 	Comment	"Headphones"
 
-	EnableSequence [
-		cset "name='Headphone Switch' on"
-	]
-
-	DisableSequence [
-		cset "name='Headphone Switch' off"
-	]
+	If.headphone_switch {
+		Condition {
+			Type ControlExists
+			Control "name='Headphone Switch'"
+		}
+		True.EnableSequence [
+			cset "name='Headphone Switch' on"
+		]
+		True.DisableSequence [
+			cset "name='Headphone Switch' off"
+		]
+	}
 
 	Value {
 	      PlaybackPriority 200
```
```
$ ALSA_CONFIG_UCM2=/tmp/ucm2-test alsaucm -c hw:1 set _verb HiFi
$ echo $?
0
```

Deleting the two cset lines outright works too, and returns 0 the same way. Prefixing the control name with - does not work: cset "-name='Headphone Switch' off" still fails, now with -EINVAL, so the ignore-error prefix documented for exec does not apply to cset.

### Downstream effect on PipeWire

PipeWire's ACP layer calls the same function, so it inherits the failure and drops to its built-in profile set. With stock rt721.conf:

```
$ spa-acp-tool -vvv -c 1 list-profiles
I       alsa-ucm.c:1019      UCM available for card hw:1
I       alsa-ucm.c:1128      Set UCM verb to HiFi
I           main.c:843       unable to execute cset 'name='Headphone Switch' off'
I           main.c:2866      failed to initialize new use case: HiFi
E       alsa-ucm.c:1044  Failed to get the verb HiFi
E       alsa-ucm.c:1052  No UCM verb is valid for hw:1
I     alsa-mixer.c:4932      Loading profile set: .../profile-sets/default.conf
    profile 0: name:"off" prio:0 (available: yes)
    profile 1: name:"output:stereo-fallback" prio:5100 (available: unknown)
  * profile 2: name:"pro-audio" prio:1 (available: yes)
```

With the guard in place:

```
$ ALSA_CONFIG_UCM2=/tmp/ucm2-test spa-acp-tool -vvv -c 1 list-profiles
I       alsa-ucm.c:1019      UCM available for card hw:1
D       alsa-ucm.c:467         Got PlaybackPCM for device Speaker: _ucm0001.hw:amdsoundwire,2
D       alsa-ucm.c:467         Got PlaybackPCM for device Headphones: _ucm0001.hw:amdsoundwire
I            acp.c:2010      Found UCM profiles
    profile 0: name:"off" prio:0 (available: yes)
    profile 1: name:"HiFi" prio:8600 (available: unknown)
  * profile 2: name:"pro-audio" prio:1 (available: yes)
```

output:stereo-fallback binds to PCM 0, the RT721 headset path, which is why audio came out of the headphone jack and the speakers were never addressed.

### Suggested fix

Any of these would work and I am happy to send a PR for whichever you prefer:

1. Guard the Headphones sequences with Condition { Type ControlExists Control "name='Headphone Switch'" }, the pattern sof-soundwire.conf already uses for its PGA BootSequences at lines 198 to 226. This is the variant in the diff above, and it is the one I tested on hardware.
2. Use an RT721 SDCA function-unit control the card actually exposes, for example a mute on the same FU as rt721 FU05 Playback Volume, instead of the DAPM pin switch.
3. Give amd-soundwire its own conf.d entry and headset conf that omits the pin switch, rather than symlinking straight at sof-soundwire.conf.

### A second, related gap

Once the verb activates, the HiFi profile is correct: Speaker on hw:amdsoundwire,2, Headphones on hw:amdsoundwire, Mic on hw:amdsoundwire,4 and Headset on hw:amdsoundwire,1. Jack detection still does not work, because this card registers no jack kcontrol either:

```
I       alsa-ucm.c:2556      UCM jack Headphone has_control=0
I       alsa-ucm.c:2556      UCM jack Headset Mic has_control=0
D            acp.c:1909        Pruned singleton availability group Headphone from port [Out] Headphones
D            acp.c:969         Found 0 jacks.
```

So JackControl "Headphone Jack" and JackControl "Headset Mic Jack" name controls that do not exist on amd-soundwire either. Treat that as background for this bug rather than a second request. If the right answer is that the AMD machine driver ought to register the Headphone Switch and Headphone Jack controls the way the Intel sof_sdw boards do, please say so and I will take the whole thing to the ASoC list instead. I have not read the AMD machine driver, so I cannot say which side is wrong.

### Related

* #805 same laptop, RT721 capture switches default to OFF, still open
* #806 the PR for #805
* #812 adds the tas2783 profile this card needs, does not touch rt721.conf
* #227 the same "Failed to get the verb" symptom on ALC4080
* #356 the policy discussion about failing early on a missing control

Issue URL : https://github.com/alsa-project/alsa-ucm-conf/issues/825
Repository URL: https://github.com/alsa-project/alsa-ucm-conf