Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 9 additions & 4 deletions device/cheetah/MODEM-CLIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ registration indication), unless `ims_required = yes`.
- **Outgoing SMS** carry a durable 32-hex request id; an interrupted or
uncertain send is marked `unknown`, never repeated automatically.
- **Calls**: a hangup whose release isn't confirmed within 12 s, or a call
left over from a previous run, stops the modem unit (CP off, then rfsd):
the only way to be sure the radio isn't still carrying a call. That is a
CP power-off (one UFS handler pass) and is the one place the RIL powers
the modem off.
left over from a previous run, turns the radio off (best effort, AT+CFUN=0)
and stops sitd with the call still recorded as its own, for an attended
reboot. The journal says "Call release not confirmed: <reason>", the radio
and CP states, and "attended reboot required". The RIL no longer stops the
modem unit or powers the CP off: an in-place power-off reset the 9a once,
and on the 7 Pro every power-off costs a UFS error-handler pass. The unit
has `Restart=no`, so a manual restart in the same boot finds the recorded
call, turns the radio off again and exits. This path has run only in the
simulator.
- **Storage**: received SMS in `/var/lib/omamobile-sit` (0700, files 0600):
numbers and text, never to be copied into the repository.

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 @@ -1527,7 +1527,8 @@ tools/phone-ssh 'omamobile-sit hangup; sleep 2; omamobile-sit status;
# "AoC call routes restored". Then the human calls the phone: `omamobile-sit answer`, talk, hangup
# stop: no audio either way (record the journal: "voice PCM ... failed" means the AoC card; check that
# PipeWire does not hold PCM 4/11), distorted or loud audio (hang up at once), a release that is
# never confirmed (the RIL stops the modem unit by design after 12 s: one UFS pass; reboot after)
# never confirmed (after 12 s the RIL turns the radio off and exits: "Call release not confirmed",
# "attended reboot required"; reboot, which powers the CP off: one UFS pass)
# rollback: omamobile-sit hangup

# M4.6 at boot (asks the human: reboots; risk: medium: from now on every boot powers the modem on,
Expand Down Expand Up @@ -2645,8 +2646,8 @@ tools/phone-ssh 'omamobile-sit answer; sleep 10; omamobile-sit status | grep -E
# outgoing, to the human's other phone (international form); answer it there, hang up there after ~10 s:
tools/phone-ssh 'omamobile-sit dial <NUMBER>; sleep 30; omamobile-sit status | grep -E "^call"'
# pass: the other phone rings and connects (silent), then "terminated" after the remote hang-up
# stop: "Call release was not confirmed; modem stopped" (the RIL powered the CP off by design: one UFS
# pass; reboot before anything else); a CP crash; any sound from the phone's speakers (stop at once:
# stop: "Call release not confirmed" and "attended reboot required" (the RIL turned the radio off and
# exited, leaving the CP on; reboot before anything else, one UFS pass on the way down); a CP crash; any sound from the phone's speakers (stop at once:
# nothing should route audio: record `amixer -c <aoc card> cget name="TDM_0_RX Mixer EP5"`)
# rollback: omamobile-sit hangup
# Never dial an emergency number to test (refused anyway; TELEPHONY-APPS-PLAN 3.3)
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**.
46 changes: 46 additions & 0 deletions device/tegu/CALL-AUDIO-WINDOW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!-- SPDX-License-Identifier: MIT -->
# Pixel 9a: AoC voice-window audit

2026-11-02, offline. This supports TELEPHONY-PLAN section 1 (PR #360);
no call, memory access or phone operation was performed.

**The firmware voice path has a shared SRAM window; the Linux call-audio
route does not need a new CPU mapping of it.** The checked CPIF and AoC
paths provide no evidence that adding the omitted CPIF region is required
to start a PCIe call. Whether the running firmware's path works remains
unqualified until the attended call test.

Where it comes from:

- MODEM-PLAN F3 records tegu's own stock DT capture: `cp_aoc_rmem` is
12 KiB at AP physical address `0x197fd000`. The stock `cp_shmem` node's
fourth `memory-region` references it; `VSS_AOC` selects `SHMEM_VSS`
(index 1), rmem index 3, offset 0, size `0x3000`, uncached. This is AoC
SRAM, not a buffer for userspace to allocate. Google's
[GPL reservation](https://android.googlesource.com/kernel/devices/google/zuma/+/eb90f2862e78b4c409ff992e116c44e81f836e9e/dts/zuma-rmem.dtsi)
and [shared-memory description](https://android.googlesource.com/kernel/devices/google/zuma/+/b0dfdfc378dd37d7c1662bbd942240d55db83d68/dts/zuma-cp-s5300-sit.dtsi)
describe the same resource; tegu's capture is the board-specific evidence.
- Our tegu `zumapro-reserved-memory.dtsi` already reserves this range as
`cp-aoc@197fd000`, with `no-map`. Omitting the CPIF region from the
bring-up overlay does not remove that reservation.
- In the GPL CPIF port, `init_shmem_maps()` maps VSS only in the
`LINKDEV_SHMEM` case; tegu uses `LINKDEV_PCIE`. Its PCIe path does not
require `vss_base` to start. Google's
[GPL implementation](https://android.googlesource.com/kernel/google-modules/radio/samsung/s5300/+/refs/tags/android-16.0.0_r0.10/link_device.c)
preserves that distinction. Diagnostic accessors/dump support are not
the voice-stream transport.
- `aoc_alsa_voice.c` prepares the voice PCM through `prepare_phonecall()`
in `aoc_alsa_hw.c`. For playback PCM 4 it sends
`CMD_AUDIO_OUTPUT_TELEPHONY_MODEM_START_ID` (256); close sends STOP
(257). Both are header-only AoC commands, with no supplied memory
address (also confirmed in the saved GPL Zuma interface header).
The speech stays between the modem and AoC; sitd owns the PCM handles
and mixers, not the SRAM.

Keep the reservation and leave the window CPU-unmapped. This change adds
no DT region, PCIe translation, S2MPU permission or userspace memory
access. If a later call establishes a missing firmware-side window, trace
the stock tegu firmware/translation setup separately before any kernel
change; do not substitute another board's address or map the SRAM to
inspect it. The first call still needs the plan's gain checks, log stream,
watchdog, stop conditions and attended recovery.
Loading