Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 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
1ce21c7
omamobile-modem-sit: a second start in the same boot gets data and IM…
W4HO-ham Nov 3, 2026
4a4bf5a
omamobile-modem-sit: a restart with the radio on releases the earlier…
W4HO-ham Nov 3, 2026
01e2313
omamobile-modem-sit test: stub the restart cleanup in #373's bring-up…
W4HO-ham Nov 3, 2026
5dd68e9
Merge main into tegu-sitd-restart
W4HO-ham Nov 11, 2026
96aee7b
Merge remote-tracking branch 'origin/main' into tegu-sitd-restart
W4HO-ham Nov 11, 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
9 changes: 7 additions & 2 deletions device/cheetah/MODEM-CLIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ Two packages:
Units (`systemd/`), none enabled by the package:

- `omamobile-sitd.service`: `Type=notify`, `Requires=`/`After=omamobile-modem.service`,
`ExecStart=omamobile-sitd --bringup`, `Restart=no` (a second start-up on
the same CP is not supported: reboot), `TimeoutStartSec=15min`.
`ExecStart=omamobile-sitd --bringup`, `Restart=no` (it never restarts on
its own), `TimeoutStartSec=15min`. A second start-up on the same CP after
a clean stop clears the earlier start's bearer records whose setup was
confirmed (a reservation with no confirmed outcome stays, and the start
refuses), withdraws the old IMS PDN with DelPdnInfo, and sets up again.
On the 9a this brought data back (2026-11-02); IMS after the withdrawal
hasn't run yet. After a failed start-up, reboot.
- `omamobile-sit-data.service`: after the RIL is ready; `omamobile-sit data
on|off` starts and stops it.
- `/usr/lib/NetworkManager/conf.d/90-omamobile-rmnet.conf`: `rmnet*` unmanaged.
Expand Down
7 changes: 4 additions & 3 deletions device/cheetah/MODEM-PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ tools/phone-ssh 'omamobile-sit status; systemctl is-active omamobile-sitd'
# pass: "network: home LTE ..."; "IMS voice: yes, SMS: yes, data bearer: up"; active
# stop: the unit fails (journal names the step: SIM timeout, registration deadline, "data call
# did not become active" with its status, IMS deadline). Record the step and status, then reboot
# before another try (a second start-up on the same CP isn't supported; about one start in twenty
# before another try (a second start-up after a failed one isn't qualified; about one start in twenty
# crashed the CP during registration on this phone model: the watcher records it)
# rollback: `omamobile-sit radio off` (AT+CFUN=0: deregisters; turning it on again may stall
# registration until a reboot), then `systemctl stop omamobile-sitd`; or reboot
Expand Down Expand Up @@ -2510,8 +2510,9 @@ a status.

About one fresh CP start in twenty crashed during registration on this
phone model (section 4): a crash is recorded, and a reboot recovers it.
**A second start-up on the same CP is not supported**: after any failed
step, reboot before the next try. Every reboot with the modem up powers
**A second start-up after a failed step isn't qualified**: reboot before
the next try. (After a clean stop, a second start-up sets up again:
MODEM-CLIENT, the sitd unit.) Every reboot with the modem up powers
it off: one recovered UFS error-handler pass, expected (M2.6, not yet
attributed to an edge; M4.1j/M4.1k proved the reboot itself clean).

Expand Down
186 changes: 186 additions & 0 deletions device/tegu/CALL-AUDIO-TUNING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<!-- SPDX-License-Identifier: MIT -->
# Pixel 9a: call tuning and the first earpiece route

Status, 2026-11-03: **implemented and tested offline, no phone trial**.
Branch `tegu-call-audio-aec-earpiece` builds on `sitd-tegu-call-audio`
(`d826388`); omamobile-modem-sit 0.3.13. AEC is off by default and call
audio still defaults to `card = none`. The earpiece mode below is a
conservative top-speaker route, not a reproduction of every stock codec
profile setting. This note records the remaining distinction explicitly.

## Sources and the tuning transport

Read the owner's saved 9a audio HAL, its AoC utility library, mixer paths,
platform configuration and factory-image `/vendor/etc/aoc` files as data.
No vendor program was run or copied into the repository. Compare the
functional interface with our GPL kernel at
[`253ddb231a89792ea845549c55fb0f04536c9317`](https://github.com/derekross/linux-omarchy-mobile/tree/253ddb231a89792ea845549c55fb0f04536c9317):
`drivers/soc/google/aoc/aoc-interface-gs201.h`, `aoc_char_dev.c`,
`alsa/aoc_alsa_ctl.c`, `alsa/aoc_alsa_hw.c`, and
`sound/soc/codecs/tas2781-{i2c,fmwlib}.c` / `include/sound/tas2x20-tlv.h`.
The kernel worktree is `~/android/mainline/wt-call-test`.

Stock uses the `fmapmg3hybrid` telephony tuner. Its APMg3 adapter wraps
an unchanged protobuf with this **12-byte little-endian envelope**:

| Offset | Type | Meaning used by the adapter |
| --- | --- | --- |
| 0 | u16 | 2 (envelope tag; its semantic name is not established here) |
| 2 | u16 | Total envelope plus protobuf length |
| 4 | u32 | 19 for uplink tuning, 20 for downlink tuning |
| 8 | u32 | Protobuf length |
| 12 | bytes | Original protobuf |

Both operations use AoC address **block 19, component 24, address type 0**.
In `AocTuningCommands::SetParameterBulk`, type 0 selects
**`audio_output_tuning`**, not `audio_input_tuning`: block/component names
do not select the character channel. Write the envelope padded to a full
**16384-byte block** to `/dev/acd-audio_bulk_tx`, then send a **22-byte**
CMD_AUDIO_OUTPUT_SET_PARAMETER_BULK (ID 210 / `0x00d2`) record on
`/dev/acd-audio_output_tuning`:

| Bytes | Field |
| --- | --- |
| 0, 1 | CMD type 0, counter |
| 2–3 | u16 length 22 |
| 4–5, 6–7 | u16 command ID 210, signed i16 reply initially 0 |
| 8, 9 | u8 block 19, component 24 |
| 10–13, 14–17 | u32 TX offset 0, TX address 0 |
| 18–21 | u32 envelope length, not the padding length |

Stock's utility has a separate type-1 family using `audio_input_tuning`,
`audio_input_bulk_tx/rx`, ID 234 and a 5120-byte staging buffer. That is
not the APMg3 upload described above. Stock opens the output bulk RX service
as part of its generic descriptor set; this write-only implementation
needs no bulk RX read. The tuning reply comes back on the tuning service.

`aoc_tuning.py` implements only the two uplink/downlink operations, with
bounded nonblocking writes, one-second readiness/acknowledgement deadlines,
exact record lengths, command/counter matching and a zero reply required.
It never resumes a short record, retries an unknown command, maps SRAM or
opens the CP/AoC shared voice window. `aoc_char_dev` makes the service
opens exclusive. An uncertain write/reply leaves the private RAM marker
`/run/omamobile-sit/aoc-voice-tuning-uncertain`; later tuning attempts refuse.
The unit already preserves its runtime directory. Do not delete the marker
to retry on the same AoC session.

**Echo reference is a separate ALSA step.**
`VoiceCall::EchoReferencePath::Set` selects **FT AEC Reference Source =
SPEAKER** for the speaker and handset paths. Our kernel's setter caches
that choice; `aoc_audio_modem_mic_input()` uses it as the reference input
when constructing MODEM_INPUT_START_2. Set it before EP4 capture starts.
Its saved value is restored after the PCMs stop. There is no additional SIT
request. The existing EP4/EP5 preparation starts the modem voice path.

`SendCommonCommand` is not the AEC protobuf transport. Its observed caller
here toggles **microphone compensation** with input-family command 355/356,
using an eight-byte CMD_HDR. Sending those would enable a different feature;
the implementation does not send them. The complete stock hybrid tuner's
band, volume and processing-mode policy is outside this first loader.
Actual echo cancellation still needs a far-end listening test.

## Files and lifecycle

`tools/extract-vendor-firmware -d tegu` now copies these six owner files
unchanged into **`usr/lib/firmware/updates/omamobile/tegu/aoc/`** in its
output tree, included in `vendor-firmware.sha256`:

| Route | Uplink on | Uplink cleanup | Downlink |
| --- | --- | --- | --- |
| Speakerphone | `uplink_speaker_aec_on_config.pb` | `uplink_speaker_aec_off_config.pb` | `downlink_speaker_config.pb` |
| Earpiece | `uplink_handset_aec_on_config.pb` | `uplink_handset_aec_off_config.pb` | `downlink_handset_config.pb` |

The source is `/vendor/etc/aoc/` in the owner's own 9a image. Do not use
another device's protobufs. HAC, wired, Bluetooth, dock and external-speaker
configs are unnecessary for these two routes. Missing any of these six
fails extraction. The loader requires the selected route's on, off and
downlink files before any upload. Files are not shipped in the package.

With `[audio] tegu_aec = yes`, the route first saves the mixer state and
verifies sink mute, sets the echo reference, uploads uplink-on and downlink,
and starts capture/playback once with the existing voice parameters. It
then applies and reads back the amplifier attenuation before unmuting.
Hang-up mutes, stops both PCMs, sends the same route's uplink-off package,
closes the tuning services and restores the mixers. **This turns AEC off;
it does not claim to restore an unknown previous protobuf**, and leaves the
selected downlink tuning resident in the inactive telephony component.

A missing or refused tuning setup refuses audio while call signalling
continues. Unknown setup or failed cleanup leaves the sink muted; the CP
is never stopped or reset. Tests cover cleanup, stale/mismatched/negative
acknowledgements, short writes and an unknown outcome blocking another call.

## Earpiece mapping and the limit of the stock comparison

The stock GPL TAS parser is
[Google amplifiers `33976d763bc0ace11603e7ecb207fc2b6e3f2608`](https://android.googlesource.com/kernel/google-modules/amplifiers/+/33976d763bc0ace11603e7ecb207fc2b6e3f2608/tas25xx/src/tas25xx-regbin-parser.c).
It builds playback-volume controls from the image's KCNTR table; values
are table indices, not decibels. A bounded private inspection of the owner's
table, following that parser, established:

| Stock setting | Mainline mapping / implementation |
| --- | --- |
| PLAYBACK_VOLUME_LEFT = 55 | Its coefficient matches **tas2x20 DVC index 220 (unity)**, not index 55. Use a lower first-test level: **Top Speaker Digital Volume = 160 (-30 dB)** |
| Top amplifier only | **Bottom Speaker Digital Volume = 0**, read back before unmuting. This is the table's minimum (-110 dB), not power-off or a hardware mute |
| CODEC PROFILE = voice | Mainline exposes per-amplifier **Speaker Profile Id**, not the vendor enum. The examined native RCA's index **4** is `case05-voice-handset`, but that case contains only one power-state write. It lacks profile 0's full initialization. Selecting 4 on a fresh, uninitialized amplifier is not a complete voice route |
| EM LEFT/RIGHT = OFF | Mainline has **no EM mixer control**. The stock driver writes bits 7:6 of register 0:0:3. The examined full native profile 0 writes EM off; no userspace register write or invented control is added |
| AoC Modem Sink Channel Bitmap | **Read-only**: its SOC_SINGLE_EXT has a get handler and NULL put. It reports a sink's active channel bitmap; it is not a writable TDM-slot selector in this kernel |

For the first usable top-only mode, retain the existing **full profile 0**
on both amplifiers, load handset AEC/downlink tuning, and attenuate/mute as
above. Refuse earpiece audio if the selected amplifier profiles are not 0,
or AEC was not enabled. This keeps startup on the already working native
initialization instead of treating a profile label as sufficient evidence.
Only the top is intended to be audible; the bottom still powers up.
Exact stock voice-profile and per-amplifier EM control remain a separate
firmware/kernel task if needed after this route is qualified. Gains have
not been acoustically qualified at the ear.

Configuration (changes apply on the next **fresh CP** session):

```ini
[audio]
card = none
tegu_aec = no
tegu_route = speaker
```

The attended trial chooses `card = auto`, `tegu_aec = yes`, then `speaker`
or `earpiece`. The earpiece mode does not affect the 7 Pro's CS35L41 route;
there is no mid-call route switch in this change. Do not enable it globally.

## Verification and the attended gate

Laptop checks, risk **low**, with synthetic service records and an ext4
fixture containing fictional data only:

```sh
tests/packages omamobile-modem-sit
tests/extract-tegu-call-tuning
tools/pr-check d826388
```

Expect: all package tests, including the existing cheetah route and sit-sim
calls/SMS, pass; six synthetic tuning files are copied byte-for-byte and
checksummed; missing cleanup tuning fails; the PR gate passes. Stop on a
failure. Rollback is the parent branch or removal of this isolated
worktree. Nothing contacts the phone or executes the saved HAL.

Before any phone trial, the human reviews a device-specific runbook and
approves the install and fresh boot. First **read-only**, confirm the NV
backup checksums, exact daily kernel/modules, mixer control availability,
profile files and their checksums, and no active call/PCMs. Keep the modem's
sleep inhibitor and once-per-boot rule. Record the actual `uname -r` with
results; no phone kernel release is claimed for these offline checks.

Then test **speaker AEC only first**, with live kmsg streamed to the laptop,
a watchdog and the human ready to recover. Check command replies, gain
readbacks, two-way audio and the far end's echo before trying the earpiece
on another approved fresh session. Risk **medium**: new AoC tuning and an
unqualified acoustic path. Begin the earpiece test away from the ear at the
fixed attenuation. Stop on an AoC timeout/reset, any NV/UFS error,
unexpected gain, feedback, missing bottom attenuation or unconfirmed
cleanup. Hang up and retain the mute/uncertainty state. Never retry or reset
the running CP in place. Rollback is the previous package/config on an
attended fresh boot; no automatic unit restart, warm modem restart or
manual marker deletion. Hardware results: **not run**.
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
10 changes: 10 additions & 0 deletions packages/omamobile-modem-sit/etc/omamobile/modem-sit.conf
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,13 @@ 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 until an attended trial; 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
121 changes: 121 additions & 0 deletions packages/omamobile-modem-sit/lib/aoc_tuning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# 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)
if len(reply) != len(command) or reply[:6] != command[: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)
Loading