mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-21 14:23:01 +00:00
aop: Add lpai + voicetrigger test (doesn't work)
I'm getting garbage from the low-power audio input (lpai) mic which exists solely for voicetrigger. The garbage specifically is `61 7b` repeated. Obviously no voicetrigger report because there's nothing useful in lpai output. I'm suspecting its an mca/clock issue (maybe even SEP/permissions) because there's nothing suspicious from the aop RX/TX IPC side. ``` [audio.audio] Report REPORT/0xee #0 [audio.audio] unknown report: 0xee 00000000 c5 96 20 01 00 00 00 00 9c f5 10 00 00 00 00 00 |.. .............| 00000010 b8 07 00 00 20 30 6e 69 01 00 00 00 43 02 00 00 |.... 0ni....C...| 00000020 00 00 00 00 c5 96 20 01 00 00 00 00 00 00 00 00 |...... .........| 00000030 a4 07 00 00 9a 07 00 00 61 7b 61 7b 61 7b 61 7b |........a{a{a{a{| 00000040 61 7b 61 7b 61 7b 61 7b 61 7b 61 7b 61 7b 61 7b |a{a{a{a{a{a{a{a{| 00000050 * 000007b0 61 7b 61 7b 61 7b 61 7b |a{a{a{a{ | ``` Signed-off-by: Eileen Yoon <eyn@gmx.com>
This commit is contained in:
parent
5c5d3966f3
commit
d649c8803f
1 changed files with 143 additions and 0 deletions
143
proxyclient/experiments/aop_vt.py
Executable file
143
proxyclient/experiments/aop_vt.py
Executable file
|
@ -0,0 +1,143 @@
|
|||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
import sys, pathlib
|
||||
sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
import struct
|
||||
from construct import *
|
||||
|
||||
from m1n1.setup import *
|
||||
from m1n1.shell import run_shell
|
||||
from m1n1.hw.dart import DART
|
||||
from m1n1.fw.aop.client import AOPClient
|
||||
from m1n1.fw.aop.ipc import *
|
||||
|
||||
# aop nodes have no clocks described in adt for j293. it does it itself
|
||||
p.pmgr_adt_clocks_enable("/arm-io/aop")
|
||||
p.pmgr_adt_clocks_enable("/arm-io/dart-aop")
|
||||
|
||||
p.usb_iodev_vuart_setup(p.iodev_whoami())
|
||||
p.iodev_set_usage(IODEV.USB_VUART, USAGE.UARTPROXY)
|
||||
pdm2 = u.adt["/arm-io/aop/iop-aop-nub/aop-audio/audio-pdm2"]
|
||||
decm = u.adt["/arm-io/aop/iop-aop-nub/aop-audio/dc-2400000"]
|
||||
|
||||
dart = DART.from_adt(u, "/arm-io/dart-aop",
|
||||
iova_range=(u.adt["/arm-io/dart-aop"].vm_base, 0x1000000000))
|
||||
dart.initialize()
|
||||
|
||||
aop = AOPClient(u, "/arm-io/aop", dart)
|
||||
aop.update_bootargs({
|
||||
'p0CE': 0x20000,
|
||||
'laCn': 0x0,
|
||||
'tPOA': 0x1,
|
||||
"gila": 0x80,
|
||||
'gbda': 0xffffffff,
|
||||
})
|
||||
aop.verbose = 4
|
||||
|
||||
p.dapf_init_all()
|
||||
aop.asc.OUTBOX_CTRL.val = 0x20001 # (FIFOCNT=0x0, OVERFLOW=0, EMPTY=1, FULL=0, RPTR=0x0, WPTR=0x0, ENABLE=1)
|
||||
|
||||
pdm2 = u.adt["/arm-io/aop/iop-aop-nub/aop-audio/audio-pdm2"]
|
||||
decm = u.adt["/arm-io/aop/iop-aop-nub/aop-audio/dc-2400000"]
|
||||
|
||||
pdm_config = Container(
|
||||
bytesPerSample=pdm2.bytesPerSample, # 2 ??
|
||||
clockSource=pdm2.clockSource, # 'pll '
|
||||
pdmFrequency=pdm2.pdmFrequency, # 2400000
|
||||
pdmcFrequency=pdm2.pdmcFrequency, # 24000000
|
||||
slowClockSpeed=pdm2.slowClockSpeed, # 24000000
|
||||
fastClockSpeed=pdm2.fastClockSpeed, # 24000000
|
||||
channelPolaritySelect=pdm2.channelPolaritySelect, # 256
|
||||
channelPhaseSelect=99, # traces say 99 but device tree says 0 pdm2.channelPhaseSelect
|
||||
unk8=0xf7600,
|
||||
unk9=0, # this should be latency (thus 15, see below) but traces say 0
|
||||
ratios=Container(
|
||||
r1=decm.ratios.r0,
|
||||
r2=decm.ratios.r1,
|
||||
r3=decm.ratios.r2,
|
||||
),
|
||||
filterLengths=decm.filterLengths,
|
||||
coeff_bulk=120,
|
||||
coefficients=GreedyRange(Int32sl).parse(decm.coefficients),
|
||||
unk10=1,
|
||||
micTurnOnTimeMs=pdm2.micTurnOnTimeMs, # 20
|
||||
unk11=1,
|
||||
micSettleTimeMs=pdm2.micSettleTimeMs, # 50
|
||||
)
|
||||
|
||||
decimator_config = Container(
|
||||
latency=decm.latency, # 15
|
||||
ratios=Container(
|
||||
r1=decm.ratios.r0, # 15
|
||||
r2=decm.ratios.r1, # 5
|
||||
r3=decm.ratios.r2, # 2
|
||||
),
|
||||
filterLengths=decm.filterLengths,
|
||||
coeff_bulk=120,
|
||||
coefficients=GreedyRange(Int32sl).parse(decm.coefficients),
|
||||
)
|
||||
|
||||
def main():
|
||||
aop.start()
|
||||
for epno in [0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x27, 0x28]:
|
||||
aop.start_ep(epno)
|
||||
aop.work_for(0.3)
|
||||
audep = aop.audio
|
||||
vtep = aop.voicetrigger
|
||||
|
||||
#ret = aop.spuapp.send_roundtrip("i2c", ALSSetPropertyUnkE4())
|
||||
#print(ret)
|
||||
|
||||
audep.send_notify(AudioAttachDevice(devid='pdm0'))
|
||||
audep.send_notify(AudioAttachDevice(devid='hpai'))
|
||||
audep.send_notify(AudioAttachDevice(devid='lpai'))
|
||||
|
||||
audep.send_notify(SetDeviceProp(devid='lpai', modifier=301, data=Container(unk1=7, unk2=7, unk3=1, unk4=7)))
|
||||
audep.send_notify(SetDeviceProp(devid='pdm0', modifier=200, data=pdm_config))
|
||||
audep.send_notify(SetDeviceProp(devid='pdm0', modifier=210, data=decimator_config))
|
||||
|
||||
data = open("data/aop/dump.voicetrigger.2024-01-29T01:49:14.803544.bin", "rb").read()
|
||||
ret = vtep.send_cmd(0x22, data[:0xa000])
|
||||
for n in range(3):
|
||||
ret = vtep.send_roundtrip(GetPropertyIsReady())
|
||||
print("state: %s" % (ret.state)) # cnfg
|
||||
assert(ret.state == "cnfg")
|
||||
|
||||
#ret = vtep.send_notifycmd(0x24, struct.pack("<I", 0)) # reset
|
||||
ret = vtep.send_cmd(0x23, struct.pack("<I", 0))
|
||||
for n in range(3):
|
||||
ret = vtep.send_roundtrip(GetPropertyIsReady())
|
||||
print("state: %s" % (ret.state)) # runn
|
||||
assert(ret.state == "runn")
|
||||
|
||||
if 1:
|
||||
ret = audep.send_notify(AudioPropertyPower(devid='lai ',
|
||||
data=Container(
|
||||
devid='lai ',
|
||||
unk1=1,
|
||||
target_pstate='runn',
|
||||
unk2=0,
|
||||
)
|
||||
))
|
||||
|
||||
# TODO garbage from lpai mic. Not sure why
|
||||
if 1:
|
||||
ret = audep.send_notify(AudioPropertyPower(devid='lpai',
|
||||
data=Container(
|
||||
devid='lpai',
|
||||
unk1=2,
|
||||
target_pstate='runn',
|
||||
unk2=1,
|
||||
)
|
||||
))
|
||||
|
||||
aop.work_forever()
|
||||
|
||||
try:
|
||||
main()
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
#run_shell(locals(), poll_func=aop.work)
|
Loading…
Reference in a new issue