Fix WCD 48 kHz interpolators, CAJON analog codec, PipeWire mono downmix, and gain staging for a1125 (ampere)
- Add patches/kernel/0015-msm8909-wcd-digital-interpolator-cajon-analog.patch and rebuild kernel + audio codec modules (prebuilt/ + overlay/rootfs/) so REGCACHE_FLAT keeps 48 kHz POR interpolator/decimator defaults (RX1/2/3_B5_CTL=0x68, TX1/2_CLK_FS_CTL=0x03) and PM8909 CAJON_2_0 analog defaults, non-boost Class-D SPK PA, HPH DAC/PA sequencing, EAR +6 dB headroom, and pm8909_s2 wakeup restore apply cleanly. - Add WirePlumber create-item.lua item.features.mono = true support and PipeWire client drop-ins so Speaker and Earpiece present a positioned [ MONO ] PortConfig (0.5 * FL + 0.5 * FR with channelmix.normalize = true and triangular TPDF dithering) over 2 ch 48 kHz S16LE hardware while keeping Headphones and Bluetooth A2DP sinks stereo. - Sync unity 100% PipeWire software sink volume when card0 is present and cap UCM2/plugin digital ALSA playback ceiling at <= 84 (0 dB). - Add scripts/test-audio-quality.py wired into scripts/check-rebuild.sh, pin all 7 rebuilt a1125 (ampere) image SHA-256 hashes, and update CHANGELOG.md, MANUAL.md, and AGENTS.md.
This commit is contained in:
1 parent
1a229b0587
commit
4f73c28e5e
39 files changed
+1398
-55
No files matched your search
@@ -112,6 +112,10 @@ EOF
|
||||
echo "[2m/5] Applying system-core keypad debouncer patch..."
|
||||
patch -p1 < /bananarchy/patches/kernel/0014-input-core-keypad-debouncer.patch
|
||||
fi
|
||||
if ! grep -q "msm8916_wcd_digital_reg_defaults" sound/soc/codecs/msm8916-wcd-digital.c 2>/dev/null; then
|
||||
echo "[2n/5] Applying WCD digital 48 kHz interpolator and CAJON analog codec patch..."
|
||||
patch -p1 < /bananarchy/patches/kernel/0015-msm8909-wcd-digital-interpolator-cajon-analog.patch
|
||||
fi
|
||||
if [ ! -f include/config/auto.conf ] || \
|
||||
! grep -q "CONFIG_NETFILTER_XT_MATCH_OWNER=m" .config 2>/dev/null || \
|
||||
! grep -q "CONFIG_INTERCONNECT_QCOM_MSM8909=y" .config 2>/dev/null || \
|
||||
@@ -162,6 +166,8 @@ EOF
|
||||
patch -p1 < /bananarchy/patches/kernel/0013-msm8909-early-scm-smp-cpufreq.patch
|
||||
echo "[2m/5] Applying system-core keypad debouncer patch..."
|
||||
patch -p1 < /bananarchy/patches/kernel/0014-input-core-keypad-debouncer.patch
|
||||
echo "[2n/5] Applying WCD digital 48 kHz interpolator and CAJON analog codec patch..."
|
||||
patch -p1 < /bananarchy/patches/kernel/0015-msm8909-wcd-digital-interpolator-cajon-analog.patch
|
||||
|
||||
echo "[3/5] Preparing kernel configuration and Module.symvers..."
|
||||
cp /bananarchy/patches/kernel/config-bananarchy-msm8909.armv7 .config
|
||||
|
||||
@@ -564,15 +564,15 @@ fi
|
||||
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"2ba4620680a981a87fa8adf7a2fb6ab98d932c73f9de9be1c69981edc096d2a8 images/bananarchy-nokia-argon.img" \
|
||||
"23d1fdd6598bf0c5497b1e41a16888d966ad4ac3f4eee3aa04623b339c896c59 images/bananarchy-nokia-beatles.img" \
|
||||
"0459151f37c746963dc734539a4284a0524b1b8ad777cd8690a87f928d2cec58 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"e15e0fff0e68d059000caf28f73a061170a9da62368531499c6d82b275821903 images/bananarchy-nokia-argon.img" \
|
||||
"64fcf14fbe8863490d8a3b2838e66baa9e9b5712450526ca0b9e3bed5d724437 images/bananarchy-nokia-beatles.img" \
|
||||
"7c6aec20941b074cd36c856f62cb9b51b4ad2fe111c4f43f68844e07b828fb84 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"f13db705a714aaebd2d8fcc2e0f7266d0e40268c0a276208117dfdf9d8f45351 images/boot-lk2nd-nokia-beatles-display.img" \
|
||||
"1f47b0f6b96c1637e1febaa6b5d150c2dd661ba9d200286315cb0400ca61a6a0 images/bananarchy-nokia-coconut.img" \
|
||||
"81695b3242403ebbd8631957a0ca67128b9791199e8121f58ed5e8f32ea2cc77 images/boot-bananarchy-nokia-coconut.img" \
|
||||
"753029acf664a78b6990d799c060ee29ccb8b464bc0a4c40c1909b1a1a5dbfcb images/bananarchy-nokia-coconut.img" \
|
||||
"948c44097e069624d60cf952de065961b38e9d45c77bcee958684b96d86dbb7c images/boot-bananarchy-nokia-coconut.img" \
|
||||
"9a5bd2da6cfd95c745d9c1acb2e3bc61afa339824810e3d160bf079e17b23192 images/boot-lk2nd-nokia-coconut-display.img" \
|
||||
"7e6b7bdc1ac96f748c46c6fde0f7debe2ae5562d0c2feb1f5ddfc274fd22717e images/bananarchy-nokia-sparkler.img" \
|
||||
"5fde23c229bcfcec276bfa064308a37736dc9f34bcb80c6f5b6c16400417adfa images/boot-bananarchy-nokia-sparkler.img" \
|
||||
"36e3a663de0d2586422aa5303a18ce2a70f05274d4d2ff7e377cf5dad243c777 images/bananarchy-nokia-sparkler.img" \
|
||||
"f40757646fb9a5c0c489df370f59a97a5638d36bda037042a98be894b47bcf8e images/boot-bananarchy-nokia-sparkler.img" \
|
||||
"120ade81bc5416263a1afd95a29981675358b98516e105e5ed611edf258a29f7 images/boot-lk2nd-nokia-sparkler-display.img"; do
|
||||
set -- $pair
|
||||
want=$1
|
||||
@@ -2531,6 +2531,13 @@ elif ! "$BASE_DIR/scripts/test-keypad-debouncer.py" >/dev/null 2>&1; then
|
||||
fail "host keypad debouncer test failed"
|
||||
fi
|
||||
|
||||
echo "[check] WCD 48 kHz interpolators, CAJON_2_0 analog codec, PipeWire downmix, and gain staging..."
|
||||
if [ ! -x "$BASE_DIR/scripts/test-audio-quality.py" ]; then
|
||||
fail "missing executable host test scripts/test-audio-quality.py"
|
||||
elif ! "$BASE_DIR/scripts/test-audio-quality.py" >/dev/null 2>&1; then
|
||||
fail "host audio quality test failed"
|
||||
fi
|
||||
|
||||
echo "[check] microSD sdhci@7864000 non-removable and zero-polling invariants..."
|
||||
for dts in \
|
||||
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
|
||||
|
||||
Executable
+348
@@ -0,0 +1,348 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Offline regression test for MSM8905/MSM8909 audio quality fixes (patch 0015, PipeWire downmix, gain staging)."""
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
PATCH_0015 = os.path.join(
|
||||
BASE_DIR, "patches/kernel/0015-msm8909-wcd-digital-interpolator-cajon-analog.patch"
|
||||
)
|
||||
BUILD_KERNEL = os.path.join(BASE_DIR, "scripts/build-kernel-audio.sh")
|
||||
SXMO_AUDIO = os.path.join(BASE_DIR, "overlay/rootfs/usr/bin/sxmo_audio.sh")
|
||||
SXMO_RING = os.path.join(
|
||||
BASE_DIR, "overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_ring.sh"
|
||||
)
|
||||
CALLSCREEN_CPP = os.path.join(BASE_DIR, "src/dwm-plugins/callscreen_plugin.cpp")
|
||||
FILES_CPP = os.path.join(BASE_DIR, "src/dwm-plugins/files_plugin.cpp")
|
||||
RINGTONES_CPP = os.path.join(BASE_DIR, "src/dwm-plugins/ringtones_plugin.cpp")
|
||||
XDRAWER_CPP = os.path.join(BASE_DIR, "src/xdrawer/xdrawer.cpp")
|
||||
|
||||
WP_S16LE_PATHS = [
|
||||
"overlay/rootfs/etc/wireplumber/wireplumber.conf.d/msm8916-s16le.conf",
|
||||
"overlay/rootfs/usr/share/wireplumber/wireplumber.conf.d/msm8916-s16le.conf",
|
||||
"overlay/rootfs/etc/skel/.config/wireplumber/wireplumber.conf.d/msm8916-s16le.conf",
|
||||
"overlay/rootfs/home/user/.config/wireplumber/wireplumber.conf.d/msm8916-s16le.conf",
|
||||
]
|
||||
|
||||
WP_BT_PATHS = [
|
||||
"overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-bluetooth.conf",
|
||||
"overlay/rootfs/usr/share/wireplumber/wireplumber.conf.d/50-bluetooth.conf",
|
||||
"overlay/rootfs/etc/skel/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf",
|
||||
"overlay/rootfs/home/user/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf",
|
||||
]
|
||||
|
||||
WP_CREATE_ITEM_LUA = (
|
||||
"overlay/rootfs/usr/share/wireplumber/scripts/node/create-item.lua"
|
||||
)
|
||||
|
||||
PW_STREAM_DROPINS = [
|
||||
"overlay/rootfs/etc/pipewire/client.conf.d/10-bananarchy-audio.conf",
|
||||
"overlay/rootfs/etc/pipewire/pipewire-pulse.conf.d/10-bananarchy-audio.conf",
|
||||
]
|
||||
|
||||
UCM_FILES = {
|
||||
"overlay/rootfs/usr/share/alsa/ucm2/codecs/msm8916-wcd/Speaker.conf": ("RX3 Digital Volume", 84),
|
||||
"overlay/rootfs/usr/share/alsa/ucm2/codecs/msm8916-wcd/Headphones.conf": ("RX1 Digital Volume", 84),
|
||||
"overlay/rootfs/usr/share/alsa/ucm2/codecs/msm8916-wcd/Earpiece.conf": ("RX1 Digital Volume", 84),
|
||||
}
|
||||
|
||||
|
||||
def read_text(path):
|
||||
with open(path, "r", encoding="utf-8") as handle:
|
||||
return handle.read()
|
||||
|
||||
|
||||
def fail(msg):
|
||||
sys.stderr.write(f"[fail] {msg}\n")
|
||||
return 1
|
||||
|
||||
|
||||
def run_c_codec_harness():
|
||||
gcc = shutil.which("gcc")
|
||||
if not gcc:
|
||||
print("[skip] host gcc unavailable; skipping C codec register verification")
|
||||
return
|
||||
|
||||
c_src = r"""
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define GENMASK(h, l) (((~0U) - (1U << (l)) + 1) & (~0U >> (31 - (h))))
|
||||
#define BIT(n) (1U << (n))
|
||||
|
||||
#define RXn_B5_CTL_INTERP_FS_RATE_MASK GENMASK(7, 5)
|
||||
#define RXn_B5_CTL_INTERP_FS_RATE_SHIFT 5
|
||||
#define RXn_B5_CTL_INTERP_HALFBAND_EN BIT(3)
|
||||
#define TXn_CLK_FS_CTL_FS_RATE_MASK GENMASK(2, 0)
|
||||
|
||||
#define SPKR_DRV_CTL_DEF_MASK 0xEFU
|
||||
#define SPKR_DRV_CLASSD_PA_EN_MASK BIT(7)
|
||||
#define SPKR_DRV_CLASSD_PA_EN_ENABLE BIT(7)
|
||||
#define SPKR_DRV_CAL_EN BIT(6)
|
||||
#define SPKR_DRV_SETTLE_EN BIT(5)
|
||||
#define SPKR_DRV_FW_EN BIT(3)
|
||||
#define SPKR_DRV_BOOST_SET BIT(2)
|
||||
#define SPKR_DRV_CMFB_SET BIT(1)
|
||||
#define SPKR_DRV_GAIN_SET BIT(0)
|
||||
#define SPKR_DRV_CTL_NO_BOOST_VAL (SPKR_DRV_CAL_EN | SPKR_DRV_SETTLE_EN | \
|
||||
SPKR_DRV_FW_EN | SPKR_DRV_GAIN_SET)
|
||||
#define SPKR_DRV_CTL_DEF_VAL (SPKR_DRV_CLASSD_PA_EN_ENABLE | SPKR_DRV_CAL_EN | \
|
||||
SPKR_DRV_SETTLE_EN | SPKR_DRV_FW_EN | \
|
||||
SPKR_DRV_BOOST_SET | SPKR_DRV_CMFB_SET | \
|
||||
SPKR_DRV_GAIN_SET)
|
||||
|
||||
static uint32_t update_bits(uint32_t cur, uint32_t mask, uint32_t val) {
|
||||
return (cur & ~mask) | (val & mask);
|
||||
}
|
||||
|
||||
static uint32_t compute_rx_b5(uint32_t cur_b5, unsigned int rate) {
|
||||
uint32_t rx_fs = 3;
|
||||
if (rate == 8000) rx_fs = 0;
|
||||
else if (rate == 16000) rx_fs = 1;
|
||||
else if (rate == 32000) rx_fs = 2;
|
||||
else if (rate == 48000) rx_fs = 3;
|
||||
return update_bits(cur_b5,
|
||||
RXn_B5_CTL_INTERP_FS_RATE_MASK | RXn_B5_CTL_INTERP_HALFBAND_EN,
|
||||
(rx_fs << RXn_B5_CTL_INTERP_FS_RATE_SHIFT) | RXn_B5_CTL_INTERP_HALFBAND_EN);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
/* 1. Verify B5_CTL updates fs rate and halfband while preserving DCB switch (BIT 2). */
|
||||
if (compute_rx_b5(0x00, 48000) != 0x68 ||
|
||||
compute_rx_b5(0x04, 48000) != 0x6C ||
|
||||
compute_rx_b5(0x6C, 8000) != 0x0C ||
|
||||
compute_rx_b5(0x08, 16000) != 0x28 ||
|
||||
compute_rx_b5(0x08, 32000) != 0x48) {
|
||||
fprintf(stderr, "RXn_B5_CTL rate transition mismatch\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 2. Verify TXn_CLK_FS_CTL lower 3 bits update without clobbering reserved bits. */
|
||||
if (update_bits(0x03, TXn_CLK_FS_CTL_FS_RATE_MASK, 0) != 0x00 ||
|
||||
update_bits(0x00, TXn_CLK_FS_CTL_FS_RATE_MASK, 3) != 0x03) {
|
||||
fprintf(stderr, "TXn_CLK_FS_CTL update mismatch\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* 3. Verify CAJON speaker PA clears BOOST_SET & CMFB_SET (0xE9 vs 0xEF). */
|
||||
uint32_t drv = 0x29; /* after DAPM sets CAL_EN -> 0x69 */
|
||||
drv = update_bits(drv, SPKR_DRV_CTL_DEF_MASK & ~SPKR_DRV_CLASSD_PA_EN_MASK,
|
||||
SPKR_DRV_CTL_NO_BOOST_VAL);
|
||||
if (drv != 0x69) {
|
||||
fprintf(stderr, "CAJON pre-PA DRV_CTL expected 0x69, got 0x%x\n", drv);
|
||||
return 3;
|
||||
}
|
||||
drv = update_bits(drv, SPKR_DRV_CLASSD_PA_EN_MASK, SPKR_DRV_CLASSD_PA_EN_ENABLE);
|
||||
if (drv != 0xE9 || (drv & (SPKR_DRV_BOOST_SET | SPKR_DRV_CMFB_SET)) != 0) {
|
||||
fprintf(stderr, "CAJON active DRV_CTL expected 0xE9 without boost bits, got 0x%x\n", drv);
|
||||
return 4;
|
||||
}
|
||||
|
||||
/* 4. Verify s2 wakeup preserves SPK DAC Switch bit 7 while restoring CAJON 0x03. */
|
||||
uint32_t spkr_dac_ctl = 0x80; /* SPK DAC Switch ON before standby */
|
||||
spkr_dac_ctl = update_bits(spkr_dac_ctl, 0x7FU, 0x03U);
|
||||
if (spkr_dac_ctl != 0x83U) {
|
||||
fprintf(stderr, "s2 restore clobbered SPK DAC Switch: 0x%x\n", spkr_dac_ctl);
|
||||
return 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
with tempfile.TemporaryDirectory(prefix="ba_audio_q_") as td:
|
||||
src = os.path.join(td, "test_audio_q.c")
|
||||
exe = os.path.join(td, "test_audio_q")
|
||||
with open(src, "w", encoding="utf-8") as handle:
|
||||
handle.write(c_src)
|
||||
subprocess.run([gcc, "-Wall", "-Wextra", "-Werror", "-O2", src, "-o", exe], check=True)
|
||||
subprocess.run([exe], check=True)
|
||||
|
||||
|
||||
def check_patch_0015():
|
||||
if not os.path.isfile(PATCH_0015):
|
||||
return fail("missing patches/kernel/0015-msm8909-wcd-digital-interpolator-cajon-analog.patch")
|
||||
txt = read_text(PATCH_0015)
|
||||
required = [
|
||||
"msm8916_wcd_digital_reg_defaults",
|
||||
"{ LPASS_CDC_RX1_B5_CTL, 0x68 }",
|
||||
"{ LPASS_CDC_RX2_B5_CTL, 0x68 }",
|
||||
"{ LPASS_CDC_RX3_B5_CTL, 0x68 }",
|
||||
"{ LPASS_CDC_TX1_CLK_FS_CTL, 0x03 }",
|
||||
"{ LPASS_CDC_TX2_CLK_FS_CTL, 0x03 }",
|
||||
"{ LPASS_CDC_CLK_OTHR_CTL, 0x04 }",
|
||||
"RXn_B5_CTL_INTERP_FS_RATE_MASK",
|
||||
"TXn_CLK_FS_CTL_FS_RATE_MASK",
|
||||
"wcd_reg_defaults_cajon_2_0",
|
||||
"{CDC_A_NCP_FBCTRL, 0xA8}",
|
||||
"{CDC_A_NCP_VCTRL, 0xA4}",
|
||||
"{CDC_A_RX_HPH_BIAS_PA, 0xFA}",
|
||||
"{CDC_A_SPKR_ANA_BIAS_SET, 0x41}",
|
||||
"{CDC_A_SPKR_DRV_CTL, 0x69}",
|
||||
"SPKR_DRV_CTL_NO_BOOST_VAL",
|
||||
"CDC_A_PERPH_SUBTYPE_CAJON",
|
||||
"pm8916_wcd_analog_enable_hphl_dac",
|
||||
"pm8916_wcd_analog_enable_hphr_dac",
|
||||
"pm8916_wcd_analog_enable_hph_pa",
|
||||
"pm8916_wcd_analog_apply_defaults(component, true);",
|
||||
]
|
||||
for tok in required:
|
||||
if tok not in txt:
|
||||
return fail(f"0015 patch missing required token: {tok}")
|
||||
|
||||
build_txt = read_text(BUILD_KERNEL)
|
||||
if build_txt.count("0015-msm8909-wcd-digital-interpolator-cajon-analog.patch") != 2:
|
||||
return fail("scripts/build-kernel-audio.sh must apply 0015 in both kcache and tarball paths")
|
||||
return 0
|
||||
|
||||
|
||||
def check_wireplumber():
|
||||
s16_ref = None
|
||||
for rel in WP_S16LE_PATHS:
|
||||
path = os.path.join(BASE_DIR, rel)
|
||||
if not os.path.isfile(path):
|
||||
return fail(f"missing {rel}")
|
||||
raw = read_text(path)
|
||||
if s16_ref is None:
|
||||
s16_ref = raw
|
||||
elif raw != s16_ref:
|
||||
return fail(f"wireplumber msm8916-s16le.conf drifted in {rel}")
|
||||
|
||||
for tok in (
|
||||
'audio.format = "S16LE"',
|
||||
"audio.rate = 48000",
|
||||
'dither.method = "triangular"',
|
||||
"~alsa_output.platform-7702000.*.HiFi__Speaker__sink",
|
||||
"~alsa_output.platform-sound.*.HiFi__Speaker__sink",
|
||||
"~alsa_output.platform-7702000.*.HiFi__Earpiece__sink",
|
||||
"~alsa_output.platform-sound.*.HiFi__Earpiece__sink",
|
||||
"item.features.mono = true",
|
||||
"channelmix.normalize = true",
|
||||
):
|
||||
if tok not in s16_ref:
|
||||
return fail(f"msm8916-s16le.conf missing {tok}")
|
||||
for forbidden in ("AUX0", "channelmix.upmix = false"):
|
||||
if forbidden in s16_ref:
|
||||
return fail(f"msm8916-s16le.conf must not contain unpositioned/no-upmix token {forbidden}")
|
||||
|
||||
create_item_path = os.path.join(BASE_DIR, WP_CREATE_ITEM_LUA)
|
||||
if not os.path.isfile(create_item_path):
|
||||
return fail(f"missing {WP_CREATE_ITEM_LUA}")
|
||||
create_item_txt = read_text(create_item_path)
|
||||
for tok in (
|
||||
'Settings.get_boolean ("node.features.audio.mono")',
|
||||
'cutils.parseBool (properties ["item.features.mono"])',
|
||||
):
|
||||
if tok not in create_item_txt:
|
||||
return fail(f"{WP_CREATE_ITEM_LUA} missing {tok}")
|
||||
|
||||
pw_ref = None
|
||||
for rel in PW_STREAM_DROPINS:
|
||||
path = os.path.join(BASE_DIR, rel)
|
||||
if not os.path.isfile(path):
|
||||
return fail(f"missing {rel}")
|
||||
raw = read_text(path)
|
||||
if pw_ref is None:
|
||||
pw_ref = raw
|
||||
elif raw != pw_ref:
|
||||
return fail(f"PipeWire stream drop-in drifted in {rel}")
|
||||
for tok in ("channelmix.normalize = true", 'dither.method = "triangular"'):
|
||||
if tok not in pw_ref:
|
||||
return fail(f"PipeWire stream drop-in missing {tok}")
|
||||
|
||||
bt_ref = None
|
||||
for rel in WP_BT_PATHS:
|
||||
path = os.path.join(BASE_DIR, rel)
|
||||
raw = read_text(path)
|
||||
if bt_ref is None:
|
||||
bt_ref = raw
|
||||
elif raw != bt_ref:
|
||||
return fail(f"wireplumber 50-bluetooth.conf drifted in {rel}")
|
||||
if "bluez5.roles = [ a2dp_sink hsp_hs hfp_hf ]" not in bt_ref:
|
||||
return fail("50-bluetooth.conf lost bluez5.roles invariant")
|
||||
return 0
|
||||
|
||||
|
||||
def check_gain_staging():
|
||||
for rel, (ctl_name, max_vol) in UCM_FILES.items():
|
||||
txt = read_text(os.path.join(BASE_DIR, rel))
|
||||
matches = re.findall(rf'{re.escape(ctl_name)}\x27\s+(\d+)', txt)
|
||||
if not matches:
|
||||
return fail(f"{rel} missing {ctl_name}")
|
||||
for m in matches:
|
||||
if int(m) > max_vol:
|
||||
return fail(f"{rel} {ctl_name}={m} exceeds 0 dB unity ceiling ({max_vol})")
|
||||
|
||||
audio_txt = read_text(SXMO_AUDIO)
|
||||
if "bananarchy_set_sink_volume" not in audio_txt or \
|
||||
"bananarchy_sync_internal_pw_vol" not in audio_txt or \
|
||||
"[ -d /proc/asound/card0 ]" not in audio_txt:
|
||||
return fail("sxmo_audio.sh missing PipeWire unity sync guard for card0")
|
||||
|
||||
probe_script = r"""
|
||||
set -eu
|
||||
. "%s" >/dev/null 2>&1 || true
|
||||
""" % SXMO_AUDIO
|
||||
# Extract pct_to_hw_out + dependencies and evaluate edge percentages with sh
|
||||
res = subprocess.run(
|
||||
[
|
||||
"sh", "-eu", "-c",
|
||||
f"""
|
||||
eval "$(sed -n '/^normalize_out_dev()/,/^}}/p; /^clamp_pct()/,/^}}/p; /^pct_to_hw_out()/,/^}}/p' '{SXMO_AUDIO}')"
|
||||
for dev in Speaker Headphones Earpiece; do
|
||||
v0="$(pct_to_hw_out "$dev" 0)"
|
||||
v1="$(pct_to_hw_out "$dev" 1)"
|
||||
v85="$(pct_to_hw_out "$dev" 85)"
|
||||
v100="$(pct_to_hw_out "$dev" 100)"
|
||||
printf '%s %s %s %s %s\n' "$dev" "$v0" "$v1" "$v85" "$v100"
|
||||
done
|
||||
""",
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
expected = {
|
||||
"Speaker": (0, 52, 79, 84),
|
||||
"Earpiece": (0, 52, 79, 84),
|
||||
"Headphones": (0, 51, 78, 83),
|
||||
}
|
||||
for line in res.stdout.strip().splitlines():
|
||||
dev, v0, v1, v85, v100 = line.split()
|
||||
got = (int(v0), int(v1), int(v85), int(v100))
|
||||
if got != expected[dev]:
|
||||
return fail(f"sxmo_audio.sh pct_to_hw_out {dev} expected {expected[dev]}, got {got}")
|
||||
|
||||
ring_txt = read_text(SXMO_RING)
|
||||
if "ring_rx3=$(( 52 +" not in ring_txt or "ring_hp=$(( 51 +" not in ring_txt:
|
||||
return fail("sxmo_hook_ring.sh volume curve out of sync with unity ceiling")
|
||||
|
||||
for path, label, needles in [
|
||||
(CALLSCREEN_CPP, "callscreen_plugin.cpp", ["51 + (c * 32 + 50) / 100", "52 + (c * 32 + 50) / 100"]),
|
||||
(FILES_CPP, "files_plugin.cpp", ["52 + (rvol * 32 + 50) / 100", "51 + (rvol * 32 + 50) / 100"]),
|
||||
(RINGTONES_CPP, "ringtones_plugin.cpp", ["52 + (rvol * 32 + 50) / 100", "51 + (rvol * 32 + 50) / 100"]),
|
||||
(XDRAWER_CPP, "xdrawer.cpp", ["rx1 >= 83", "rx3 >= 84", "51 + std::lround", "52 + std::lround"]),
|
||||
]:
|
||||
txt = read_text(path)
|
||||
for n in needles:
|
||||
if n not in txt:
|
||||
return fail(f"{label} missing synced gain staging expression: {n}")
|
||||
return 0
|
||||
|
||||
|
||||
def main():
|
||||
for fn in (check_patch_0015, check_wireplumber, check_gain_staging):
|
||||
rc = fn()
|
||||
if rc != 0:
|
||||
return rc
|
||||
run_c_codec_harness()
|
||||
print("[ok] 0015 WCD digital 48 kHz interpolator, CAJON analog codec, WirePlumber item.features.mono downmix, and <= 0 dB gain staging passed")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user