Fix MBHC wired headphone autodetection across all targets for a1125 (ampere)

Retain PM8909 MBHC digital debounce clock (DIG_CLK_CTL_D_MBHC_CLK_EN) and master bias (CDC_A_MASTER_BIAS_CTL = 0x30) across s2 standby gating while keeping the 100 uA button ISRC and button IRQs disabled when unplugged, check CDC_A_MBHC_RESULT_2 on boot/set_jack/switch IRQs with 3/4-pole FSM classification, fix iface=CARD jack queries, event coalescing, and stale unplugged Headphones boot fallback in bananarchy-soundmonitor and sxmo audio scripts, harden host tests against CPU contention, and rebuild all a1125 (ampere) target images.
This commit is contained in:
Luxferre committed 2026-11-24 11:00:06 +02:00
1 parent aba38a58f2
commit 9619cc9541
19 files changed
+516 -93

No files matched your search

+77 -1
View File
@@ -200,11 +200,21 @@ def check_patch_0015():
"pm8916_wcd_analog_enable_hphr_dac",
"pm8916_wcd_analog_enable_hph_pa",
"pm8916_wcd_analog_apply_defaults(component, true);",
"CDC_A_MBHC_RESULT_2_SWCH_LEVEL_REMOVE",
"pm8916_mbhc_plug_present",
"DIG_CLK_CTL_D_MBHC_CLK_EN",
"CDC_A_MASTER_BIAS_CTL, 0x30",
"snd_soc_jack_report(jack, initial_report, hs_jack_mask);",
"phys_ins != waiting_ins",
]
for tok in required:
if tok not in txt:
return fail(f"0015 patch missing required token: {tok}")
analog_diff = txt.split("diff --git a/sound/soc/codecs/msm8916-wcd-digital.c")[0]
if "+ snd_soc_component_write(component, CDC_A_MASTER_BIAS_CTL, 0x00);" in analog_diff:
return fail("0015 must not zero CDC_A_MASTER_BIAS_CTL on s2 idle gating")
if ".volatile_reg" in txt:
return fail("0015 patch must not set .volatile_reg on msm8916_codec_regmap_config")
@@ -313,10 +323,76 @@ def check_gain_staging():
return fail("sxmo_audio.sh missing PipeWire unity sync guard, @DEFAULT_AUDIO_SINK@, or sink wait")
soundmon_txt = read_text(SOUNDMONITOR_C)
for tok in ("has_internal_sink", "internal_synced"):
for tok in (
"has_internal_sink",
"internal_synced",
"drain_jack_events",
"last_hp_plugged",
"iface=CARD,name='Headphone Jack'",
"iface=CARD,name='Mic Jack'",
):
if tok not in soundmon_txt:
return fail(f"bananarchy-soundmonitor.c missing {tok}")
gcc = shutil.which("gcc")
if gcc:
with tempfile.TemporaryDirectory(prefix="ba_soundmon_") as td:
exe = os.path.join(td, "bananarchy-soundmonitor")
bld = subprocess.run(
[
gcc, "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror",
"-I", os.path.dirname(SOUNDMONITOR_C),
SOUNDMONITOR_C, "-o", exe,
],
capture_output=True,
text=True,
)
if bld.returncode != 0:
return fail(f"host gcc build of bananarchy-soundmonitor.c failed:\n{bld.stderr}")
with tempfile.TemporaryDirectory(prefix="ba_audio_dev_") as td:
tmp_dir = os.path.join(td, "tmp")
cfg_dir = os.path.join(td, "cfg")
bin_dir = os.path.join(td, "bin")
os.makedirs(tmp_dir, exist_ok=True)
os.makedirs(cfg_dir, exist_ok=True)
os.makedirs(bin_dir, exist_ok=True)
mock_pactl = os.path.join(bin_dir, "pactl")
with open(mock_pactl, "w", encoding="utf-8") as handle:
handle.write("#!/bin/sh\nexit 0\n")
os.chmod(mock_pactl, 0o755)
patched_sh = os.path.join(td, "sxmo_audio.sh")
with open(patched_sh, "w", encoding="utf-8") as handle:
handle.write(audio_txt.replace("/tmp/", tmp_dir + "/"))
env = dict(os.environ)
env["XDG_CONFIG_HOME"] = td
env["CFG_DIR"] = cfg_dir
env["PATH"] = bin_dir + ":" + env.get("PATH", "")
# Rewrite CFG_DIR to cfg_dir explicitly via a symlink sxmo -> cfg_dir.
os.symlink(cfg_dir, os.path.join(td, "sxmo"))
with open(os.path.join(cfg_dir, "audio_out_device"), "w", encoding="utf-8") as handle:
handle.write("Headphones\n")
with open(os.path.join(cfg_dir, "audio_in_device"), "w", encoding="utf-8") as handle:
handle.write("Headset\n")
with open(os.path.join(tmp_dir, "sxmo_jack_plugged"), "w", encoding="utf-8") as handle:
handle.write("0\n")
r_out = subprocess.run(["sh", patched_sh, "device", "get"], env=env, capture_output=True, text=True, check=True)
r_in = subprocess.run(["sh", patched_sh, "device", "getinput"], env=env, capture_output=True, text=True, check=True)
if r_out.stdout.strip() != "Speaker" or r_in.stdout.strip() != "Mic1":
return fail(f"unplugged boot fallback failed: out={r_out.stdout!r} in={r_in.stdout!r}")
for p in ("sxmo_audio_out_device", "sxmo_audio_in_device"):
fp = os.path.join(tmp_dir, p)
if os.path.exists(fp):
os.unlink(fp)
with open(os.path.join(tmp_dir, "sxmo_jack_plugged"), "w", encoding="utf-8") as handle:
handle.write("1\n")
r_out2 = subprocess.run(["sh", patched_sh, "device", "get"], env=env, capture_output=True, text=True, check=True)
r_in2 = subprocess.run(["sh", patched_sh, "device", "getinput"], env=env, capture_output=True, text=True, check=True)
if r_out2.stdout.strip() != "Headphones" or r_in2.stdout.strip() != "Headset":
return fail(f"plugged boot preservation failed: out={r_out2.stdout!r} in={r_in2.stdout!r}")
probe_script = r"""
set -eu
. "%s" >/dev/null 2>&1 || true