diff --git a/packaging/session/speakerguardd-selfcheck b/packaging/session/speakerguardd-selfcheck index f91cd521..0d4b84f5 100755 --- a/packaging/session/speakerguardd-selfcheck +++ b/packaging/session/speakerguardd-selfcheck @@ -706,7 +706,10 @@ def check_sense(ctl, idx, card, devs, w, runs, widths=None): names = {} for a in amps: for kind in ("V", "I"): - names[(a["prefix"], kind)] = f"{a['prefix']} {kind}SENSE Switch" + # The amp's own control prefix: none on a lone desktop amp + # (wiring.derive labels it "Speaker", ALSA does not). + ctl_prefix = a.get("control_prefix", a["prefix"]) + names[(a["prefix"], kind)] = f"{ctl_prefix} {kind}SENSE Switch".lstrip() saved = {} for nm in names.values(): v = switch_get(card, nm) diff --git a/packaging/session/test_wiring.py b/packaging/session/test_wiring.py index 5b48f9cf..d0bc7fb4 100644 --- a/packaging/session/test_wiring.py +++ b/packaging/session/test_wiring.py @@ -712,6 +712,34 @@ def test_mono_needs_one_amp_and_one_lane(self): wiring.derive(h, fx("j313")["tuning"]) self.assertIn("no sound-name-prefix", str(cm.exception)) + def test_mono_amp_sense_switches_have_no_prefix(self): + # The lone desktop amp has no sound-name-prefix, so ALSA names its + # switches "VSENSE Switch"/"ISENSE Switch" (the J473's card); the + # derivation's "Speaker" is a label, not part of the control name. + for board in ("j274", "j473"): + f = fx(board) + w = wiring.derive(f["hw"], f["tuning"]) + self.assertEqual(w["amps"][0]["prefix"], "Speaker") + self.assertEqual(w["amps"][0]["control_prefix"], "") + asked = [] + + def get(card, name): + asked.append(name) + return None + + saved = sgsc.switch_get + sgsc.switch_get = get + try: + errs, fmt = sgsc.check_sense(None, 0, "Apple" + board.upper(), (1, 2), w, {}) + finally: + sgsc.switch_get = saved + self.assertEqual(asked, ["VSENSE Switch"], board) + self.assertEqual(errs, ["no 'VSENSE Switch' control"]) + # an amp that names itself keeps its prefix in the control name + f = fx("j413") + w = wiring.derive(f["hw"], f["tuning"]) + self.assertNotIn("control_prefix", w["amps"][0]) + def test_tas2770_register_check(self): w = wiring.derive(fx("j313")["hw"], fx("j313")["tuning"]) for p, a in enumerate(w["amps"]): diff --git a/packaging/session/wiring.py b/packaging/session/wiring.py index 2e337fb9..2c815565 100644 --- a/packaging/session/wiring.py +++ b/packaging/session/wiring.py @@ -650,6 +650,11 @@ def hardware(hw): families.add(fam) side, role, ordinal = parse_prefix(c["prefix"]) a = {"prefix": c["prefix"], "family": fam[0], "slot": slot, "side": side, "role": role, "ordinal": ordinal} + if mono: + # "Speaker" only labels the lone amp here: with no + # sound-name-prefix its ALSA controls carry no prefix at all + # ("VSENSE Switch", "Speaker Volume"). + a["control_prefix"] = "" if c.get("i2c"): a["i2c"] = c["i2c"] if fam[1] and not sensed: