Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3089353
omamobile-modem-sit 0.3.22: add opt-in tegu speakerphone audio
W4HO-ham Nov 2, 2026
d5b1f69
device/tegu MODEM-PLAN, DEVICES: the 9a's first calls
W4HO-ham Nov 3, 2026
93be99e
tegu: plan Phone and Messages integration through mmd
W4HO-ham Nov 3, 2026
f75a6cf
tegu: attach Phone and Messages to an attended running sitd
W4HO-ham Nov 3, 2026
e99705a
device/tegu TELEPHONY-APPS-PLAN: the 2026-11-02 run, the two ways to …
W4HO-ham Nov 3, 2026
3c4494c
TELEPHONY-APPS-PLAN, omamobile-telephony-tegu: mmd's Conflicts= goes …
W4HO-ham Nov 3, 2026
5571f3a
omamobile-telephony-tegu: the bridge's service check accepts its own …
W4HO-ham Nov 4, 2026
68fa848
omamobile-device-tegu 0.2.10: start the modem and phone service at bo…
W4HO-ham Nov 3, 2026
6d95060
omamobile-device-tegu 0.2.11: run the modem profile's check after the…
W4HO-ham Nov 3, 2026
309b6e5
omamobile-device-tegu 0.2.12, omamobile-modem-sit 0.3.24: keep the mo…
W4HO-ham Nov 3, 2026
1a15d6e
omamobile-device-tegu: queue sitd and the bridge at boot, and DEVICES…
W4HO-ham Nov 3, 2026
c5e3dca
omamobile-device-tegu: a deliberate restart after ONLINE doesn't cost…
W4HO-ham Nov 3, 2026
c563763
omamobile-device-tegu: start gnssd with the modem at boot, for Omarch…
W4HO-ham Nov 3, 2026
8821fe4
DEVICES: the 9a's modem and GNSS work, started at boot
W4HO-ham Nov 3, 2026
fda61e0
device/tegu TELEPHONY-PLAN: the boot start's first record (2.7)
W4HO-ham Nov 3, 2026
fcb2c9d
device/tegu TELEPHONY-PLAN: section 2's items 2 to 6 read as sentence…
W4HO-ham Nov 3, 2026
12ab38f
omamobile-device-tegu: a reboot with the modem up clears its latch
W4HO-ham Nov 3, 2026
8d4eddc
DEVICES, TELEPHONY-PLAN, omamobile-device-tegu: the 9a's modem and GN…
W4HO-ham Nov 3, 2026
61062dc
device/tegu TELEPHONY-PLAN, omamobile-device-tegu README: the NV chec…
W4HO-ham Nov 4, 2026
a762f36
omamobile-modem-sit 0.3.16: add opt-in tegu call tuning and earpiece …
W4HO-ham Nov 3, 2026
70c3ed0
Merge main into tegu-call-aec
W4HO-ham Nov 11, 2026
d780ed1
Merge remote-tracking branch 'origin/main' into tegu-call-aec
W4HO-ham Nov 11, 2026
95170c1
extract-vendor-firmware: a 9a image without all six call tuning files…
W4HO-ham Nov 12, 2026
ac49fc8
Merge remote-tracking branch 'origin/main' into tegu-call-aec
W4HO-ham Nov 12, 2026
0a134c6
omamobile-modem-sit 0.3.19: accept the AoC's tuning acknowledgement a…
W4HO-ham Nov 3, 2026
6bc88e8
omamobile-modem-sit 0.3.20: put the AoC's DSP in its APMg3 telephony …
W4HO-ham Nov 3, 2026
979bb15
device/tegu CALL-AUDIO-TUNING: the 2026-11-02 calls, and the transpor…
W4HO-ham Nov 3, 2026
ee1986a
device/tegu CALL-AUDIO-TUNING: what to try next for the echo
W4HO-ham Nov 3, 2026
d56dd0a
omamobile-modem-sit: turn the modem mixer's ASP on for echo cancellation
W4HO-ham Nov 3, 2026
90900a8
omamobile-modem-sit: send the call tuning after the voice streams start
W4HO-ham Nov 3, 2026
3034989
device/tegu CALL-AUDIO-TUNING: the calls of 2026-11-03, 11-11 and 11-…
W4HO-ham Nov 12, 2026
6d1c5a8
device/tegu CALL-AUDIO-TUNING: the clock calls without the tuning, wi…
W4HO-ham Nov 12, 2026
0e4d3e2
Merge main into tegu-call-aec
W4HO-ham Nov 13, 2026
b1b85eb
omamobile-modem-sit, device/tegu CALL-AUDIO-TUNING: where the call tu…
W4HO-ham Nov 13, 2026
821d2b6
Merge remote-tracking branch 'origin/main' into tegu-call-aec
W4HO-ham Nov 13, 2026
90e5275
Merge main into tegu-call-aec
W4HO-ham Nov 18, 2026
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
385 changes: 385 additions & 0 deletions device/tegu/CALL-AUDIO-TUNING.md

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions device/tegu/bringup/call-audio-watch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# On the palmtop: watch the AoC through a phone call, read-only. For D seconds it reads
# the call's mixer controls every half second and prints one line whenever a value
# changes, and it reads the AoC's own log (/dev/acd-logging) and prints its text as it
# arrives, every line stamped with the seconds since the start and the wall clock. Start
# it, place the call, hang up, and read where the lines change about 2 s into the call.
# Nothing is written to the mixer or the AoC. CTL=0 leaves the controls unread (the log
# alone), in case reading them changes what the call does.
# python3 call-audio-watch.py [D s, default 120] > /run/call-audio-watch.txt
import os, re, subprocess, sys, threading, time

D = float(sys.argv[1]) if len(sys.argv) > 1 else 120
CARD = "0"
CTLS = ["Audio DSP Mode", "AoC Modem Mixer ASP Mode", "AoC Speaker Mixer ASP Mode",
"AoC Modem Downlink ASRC Mode", "AoC Modem Sink Channel Bitmap", "Incall Mic Gain (dB)",
"Incall Mic Mute", "Incall Sink Mute", "MIC HW Gain (cB)", "BUILTIN MIC Process Mode",
"FT AEC Reference Source", "Audio Capture Mic Source", "BUILDIN MIC POWER STATE",
"Incall Capture Stream0", "Incall Playback Stream0"]
t0 = time.monotonic()
lock = threading.Lock()


def say(kind, text):
with lock:
print("%7.2f %s %s %s" % (time.monotonic() - t0, time.strftime("%H:%M:%S"), kind, text), flush=True)


def get(name):
r = subprocess.run(["amixer", "-c", CARD, "cget", "name=" + name], capture_output=True, text=True)
m = re.search(r": values=(.*)", r.stdout)
return m.group(1).strip() if m else "?"


def aoclog():
try:
fd = os.open("/dev/acd-logging", os.O_RDONLY)
except OSError as e:
say("log", "can't open /dev/acd-logging: %s" % e); return
while time.monotonic() - t0 < D:
try:
b = os.read(fd, 65536)
except OSError as e:
say("log", "read failed: %s" % e); return
for s in re.findall(rb"[\x20-\x7e]{6,}", b):
say("log", s.decode())


threading.Thread(target=aoclog, daemon=True).start()
say("start", open("/proc/sys/kernel/osrelease").read().strip())
last = {}
while time.monotonic() - t0 < D:
if os.environ.get("CTL", "1") != "0":
for c in CTLS:
v = get(c)
if last.get(c) != v:
say("ctl", "%s: %s%s" % (c, v, "" if c not in last else " (was %s)" % last[c]))
last[c] = v
time.sleep(0.5)
say("end", "")
27 changes: 27 additions & 0 deletions device/tegu/bringup/call-levels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# Laptop: from a call-audio-watch log, the uplink (Tx) and downlink (Rx) sample values the
# AoC prints about three times a second, per session and in 5 s windows after its start:
# how many, the median and the largest magnitude of each. One sample per 0.32 s is a rough
# level, enough to tell a silent uplink from one that carries speech.
# call-levels.py call-watch-N.txt
import re, sys, statistics
s = lambda h: (int(h, 16) ^ 0x8000) - 0x8000
rows = {}
for l in open(sys.argv[1]):
m = re.match(r"\s*([\d.]+) \S+ log #### PCIe Session (\d+) .*Tx:\s*\d+ \(0x([0-9a-f]+)\), Rx:\s*\d+ \(0x([0-9a-f]+)\)", l)
if m:
rows.setdefault(m.group(2), []).append((float(m.group(1)), abs(s(m.group(3))), abs(s(m.group(4)))))
for sid, r in rows.items():
t0 = r[0][0]
print("session %s: %d samples over %.0f s from %.1f" % (sid, len(r), r[-1][0] - t0, t0))
w = 0
while True:
x = [(a, b) for t, a, b in r if w <= t - t0 < w + 5]
if not x:
if w > r[-1][0] - t0: break
w += 5; continue
tx = [a for a, b in x]; rx = [b for a, b in x]
print(" %3d-%3d s: n %2d uplink median %5d max %6d over100 %2d | downlink median %5d max %6d over100 %2d" % (
w, w + 5, len(x), statistics.median(tx), max(tx), sum(a > 100 for a in tx), statistics.median(rx), max(rx), sum(b > 100 for b in rx)))
w += 5
3 changes: 3 additions & 0 deletions docs/TELEPHONY-APPS-PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ On gs201 the voice path never passes through the application processor. **The Ao

Beyond the mixer paths, the working stack on this phone model sets `Voice Call Audio Enable`, `Voice Call Mic Source` 1, `Incall Sink Mute` 0, `AoC Modem Downlink ASRC Mode` 1 and a mic gain of 130 cB plus 6 dB. It opens **PCM 4 playback (EP5)** and **PCM 11 capture (EP4)** (MODEM-PLAN 6.1). Our card numbers its PCMs as stock does (AGENTS.md), so those numbers hold. `omamobile-sitd`'s `voice_audio.py` does exactly this and restores every control after the call. Our sound card already describes the back ends these paths need: `BT_RX`/`BT_TX`, `USB_RX`/`USB_TX` and `INCALL_RX`/`INCALL_TX` (`device/cheetah/overlays/aoc-sound-test.dtso`).

The 9a's opt-in AEC upload and conservative earpiece route have a separate
[offline implementation and qualification note](../device/tegu/CALL-AUDIO-TUNING.md).

### 2.2 The work, per audio route

| Route | What's needed | Depends on | Effort |
Expand Down
13 changes: 13 additions & 0 deletions packages/omamobile-modem-sit/etc/omamobile/modem-sit.conf
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,16 @@ earpiece = yes
# louder and clean in calls on the 7 Pro) or 0 (stock). The 9a always uses
# stock's 130 cB, with no boost.
mic_boost_db = 6

# Experimental 9a call tuning, from this phone's own factory image.
# Keep off: in the trials (2026-11-02 to 11-12) the AoC took the tuning and
# the echo was not cancelled; with it the echo comes through in louder
# bursts (device/tegu/CALL-AUDIO-TUNING.md). card = none still disables all
# audio.
# AEC uploads owner files from /usr/lib/firmware/updates/omamobile/tegu/aoc.
tegu_aec = no
# speaker: both amplifiers at -20 dB; earpiece: top at -30 dB, bottom at
# the minimum digital gain. Earpiece requires tegu_aec = yes and the full
# amplifier profile 0; the stock voice profile has no standalone native
# equivalent. Changing routes mid-call is not implemented.
tegu_route = speaker
124 changes: 124 additions & 0 deletions packages/omamobile-modem-sit/lib/aoc_tuning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# SPDX-License-Identifier: MIT
"""Bounded AoC telephony tuning upload, using the owner's tegu protobufs.

Only the APMg3 telephony component on audio_output_tuning is addressed.
The GPL AoC interface defines CMD_HDR / SET_PARAMETER_BULK; the route
adapter adds an envelope with tag 2 around each unchanged protobuf. No
vendor executable, shared memory mapping, or arbitrary command API.
"""
import os
from pathlib import Path
import select
import struct

from paths import RUN

ROOT = Path('/usr/lib/firmware/updates/omamobile/tegu/aoc')
BULK_SIZE = 16384
HEADER = struct.Struct('<BBHHh')
SET_BULK = 210
UNCERTAIN = RUN / 'aoc-voice-tuning-uncertain'


class TuningError(RuntimeError):
"""Tuning could not be confirmed; keep the call sink muted."""


def package(data, operation):
if operation not in (19, 20) or not 0 < len(data) <= BULK_SIZE - 12:
raise TuningError('Invalid AoC telephony tuning package')
return struct.pack('<HHII', 2, len(data) + 12, operation, len(data)) + data


class VoiceTuning:
def __init__(self, route, *, root=ROOT):
if route not in ('speaker', 'earpiece'):
raise ValueError('Unsupported tegu tuning route')
device = 'speaker' if route == 'speaker' else 'handset'
# Load all three before touching any service. An off package is
# required for cleanup even if the on package is the only big one.
self.on = self.read(root / f'uplink_{device}_aec_on_config.pb', 19)
self.off = self.read(root / f'uplink_{device}_aec_off_config.pb', 19)
self.downlink = self.read(root / f'downlink_{device}_config.pb', 20)
self.command_fd = self.bulk_fd = None
self.counter = 0
self.touched = False
self.uncertain = False

@staticmethod
def read(path, operation):
with path.open('rb') as source:
data = source.read(BULK_SIZE + 1)
return package(data, operation)

@staticmethod
def write(fd, packet):
if not select.select([], [fd], [], 1)[1]:
raise TuningError('AoC tuning write deadline exceeded')
# These are service records, not a byte stream: a short write has
# an unknown outcome, so never send its tail or repeat the record.
if os.write(fd, packet) != len(packet):
raise TuningError('Short AoC tuning write')

def upload(self, data):
self.counter = (self.counter + 1) & 0xff
command = HEADER.pack(0, self.counter, 22, SET_BULK, 0)
command += struct.pack('<BBIII', 19, 24, 0, 0, len(data))
# Stock stages a full 16 KiB output block; tx_size selects the
# actual envelope. Never stream a partially written block.
# Mark before either write. An unknown outcome must not lead to
# another call replaying or cleaning up on this service blindly.
self.uncertain = True
UNCERTAIN.write_text('AoC voice tuning needs attended recovery\n')
UNCERTAIN.chmod(0o600)
self.write(self.bulk_fd, data.ljust(BULK_SIZE, b'\0'))
self.write(self.command_fd, command)
if not select.select([self.command_fd], [], [], 1)[0]:
raise TuningError('AoC tuning acknowledgement deadline exceeded')
reply = os.read(self.command_fd, 4096)
# The AoC answers with the command's size and ID; it rewrites the
# second header byte (sent 0x01, came back 0x3e on the palmtop,
# 2026-11-02), so that byte isn't compared.
if len(reply) != len(command) or reply[0] != command[0] or reply[2:6] != command[2:6]:
raise TuningError('Unexpected AoC tuning acknowledgement')
self.uncertain = False
UNCERTAIN.unlink()
if HEADER.unpack_from(reply)[4] != 0:
raise TuningError('AoC refused telephony tuning')

def start(self):
if self.command_fd is not None or self.bulk_fd is not None:
raise TuningError('AoC tuning session already open')
if UNCERTAIN.exists():
self.uncertain = True
raise TuningError('Previous AoC tuning outcome is unknown; attended recovery required')
flags = os.O_NONBLOCK | os.O_CLOEXEC
try:
self.command_fd = os.open('/dev/acd-audio_output_tuning', os.O_RDWR | flags)
self.bulk_fd = os.open('/dev/acd-audio_bulk_tx', os.O_WRONLY | flags)
# Refuse stale responses rather than associating them with a
# new call's upload. Opening these services is exclusive in ACD.
if select.select([self.command_fd], [], [], 0)[0]:
raise TuningError('AoC tuning channel has a pending response')
self.touched = True
self.upload(self.on)
self.upload(self.downlink)
except BaseException:
self.close()
raise

def close(self):
try:
if self.uncertain:
raise TuningError('AoC tuning outcome unknown; keeping call audio muted')
if self.touched:
self.touched = False
# The telephony component gets the same route's AEC-off
# package. This is not a restore of an unknown old blob.
self.upload(self.off)
finally:
for name in ('bulk_fd', 'command_fd'):
fd = getattr(self, name)
if fd is not None:
setattr(self, name, None)
os.close(fd)
3 changes: 2 additions & 1 deletion packages/omamobile-modem-sit/lib/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
'profiles': {},
'data': {'route': 'yes', 'metric': '700', 'roaming': 'yes'},
'control': {'group': 'wheel', 'follow_screen': 'no'},
'audio': {'card': 'none', 'mic_boost_db': '6', 'earpiece': 'yes'},
'audio': {'card': 'none', 'mic_boost_db': '6', 'earpiece': 'yes', 'tegu_route': 'speaker',
'tegu_aec': 'no'},
}


Expand Down
10 changes: 7 additions & 3 deletions packages/omamobile-modem-sit/lib/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,16 @@ def audio_start(self):
# in the status's audio error, as with [audio] card = none.
try:
self.audio = VoiceAudio(mic_boost_db=audio.getint('mic_boost_db', 6), card=card,
earpiece=audio.getboolean('earpiece', True))
earpiece=audio.getboolean('earpiece', True),
tegu_route=audio.get('tegu_route', 'speaker'),
tegu_aec=audio.getboolean('tegu_aec', False))
self.audio.__enter__()
except (OSError, RuntimeError, ValueError, subprocess.TimeoutExpired) as error:
self.audio = None
self.audio_error = str(error)
print('Call audio refused, the call goes on without audio:', error, flush=True)
# The cause says why (an AoC tuning reply, a gain read-back).
cause = f' ({error.__cause__})' if error.__cause__ else ''
self.audio_error = f'{error}{cause}'
print('Call audio refused, the call goes on without audio:', self.audio_error, flush=True)
return
self.audio_error = ''
self.muted = False
Expand Down
Loading