Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packaging/session/speakerguardd-selfcheck
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions packaging/session/test_wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]):
Expand Down
5 changes: 5 additions & 0 deletions packaging/session/wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading