fix(audiod): 开机武装 hbc3000 FPGA — 启动时无条件写 Output Port Switch(4.4→3/3.5→2/无插孔→4, 同值先写5强制重烧), 根治 PCM 启动内核死锁(未烧 FPGA 时第二次 hbc3000_start 挂死); port_name 补 4/5。真机验证: arm 日志正确+tone played=88200 underrun=0 不挂

This commit is contained in:
MeowOS committed 2026-09-01 04:02:33 +08:00
1 parent ca2290e691
commit d8898afa09
2 files changed
+17

No files matched your search

Binary file not shown.
+17
View File
@@ -405,6 +405,8 @@ static const char *port_name(int port)
switch (port) {
case 2: return "3.5 headset";
case 3: return "4.4 balance";
case 4: return "i2s/spdif digital";
case 5: return "none(disable)";
default: return "idle";
}
}
@@ -1121,6 +1123,21 @@ static void *route_thread(void *arg)
(void)arg;
int last_hb = -1, last_bal = -1, last_target = -1;
logmsg("route thread init (numid=9, %s)", g_amixer);
/* M2.91 挂死根治(AUDIO_HANG_INVESTIGATION.md):hbc3000 FPGA 未烧录+enable 时
* 启动 PCM 会在第二次 hbc3000_start 死锁整机。写 Output Port Switch 是烧录触发器
* (驱动 put:set_spdif_mode→program_ram→enabled)。开机端口恒 0=未烧,故启动时
* 无条件写一次:4.4 在→3,3.5 在→2,都没→4(官方播放器拔插孔后的选择,保 FPGA 已烧)。
* 端口已是目标值(audiod 重启场景,驱动同值短路不写)→ 先写 5(disable) 强制重烧。 */
{
int hb = read_switch("/sys/class/switch/headset/state");
int bal = read_switch("/sys/class/switch/balance/state");
int target = (bal == 1) ? 3 : (hb == 1) ? 2 : 4;
int cur = amixer_get(9, 1);
if (cur == target) { logmsg("route: port already %d, force re-arm via 5", target); apply_route(5); }
apply_route(target);
last_hb = hb; last_bal = bal; last_target = (hb == 0 && bal == 0) ? -1 : target;
logmsg("route: boot arm done (port %d %s, FPGA programmed)", target, port_name(target));
}
while (!g_stop) {
pthread_mutex_lock(&g_mu);
route_evaluate(&last_hb, &last_bal, &last_target);