Skip to content

Commit

Permalink
exp/aop: Handle API breaks from merging AFK code
Browse files Browse the repository at this point in the history
Make the experiment scripts run again. Looks a lot cleaner now too.

Signed-off-by: Eileen Yoon <[email protected]>
  • Loading branch information
eiln committed Jan 23, 2024
1 parent ee6ae9f commit aa0f71b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 55 deletions.
25 changes: 10 additions & 15 deletions proxyclient/experiments/aop_als.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,15 @@
aop.start()
for epno in [0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x27, 0x28]:
aop.start_ep(epno)
timeout = 5
while (not aop.als.ready) and timeout:
aop.work_for(0.1)
timeout -= 1
if not timeout:
raise Exception("Timed out waiting on als endpoint")
print("Finished boot")
aop.work_for(0.3)
alsep = aop.als
alsep.VERBOSE = True

def start():
ret = alsep.roundtrip(GetProperty(key=AOPPropKey.MANUFACTURER))
print(ret.rets.value.decode("ascii")) # FireFish2

ret = alsep.roundtrip(ALSSetPropertyVerbosity(level=0xffffffff))
#ret = alsep.roundtrip(GetProperty(key=AOPPropKey.MANUFACTURER))
#print(ret.rets.value.decode("ascii")) # FireFish2
ret = alsep.send_notify(GetProperty(key=AOPPropKey.MANUFACTURER))
ret = alsep.send_notify(ALSSetPropertyVerbosity(level=0xffffffff)) # retcode: 0
# [syslog] * [ALSAOPDriver.cpp:267]setProperty Setting log level = -1

dump = """
Expand All @@ -66,19 +60,20 @@ def start():
000000b0 7e 00 00 00 00 00 06 75 7e 38 7f 69 7f bf 83 f2 |~......u~8.i....|
000000c0 7e 16 7f 4e 7f 33 7f 1f 7d |~..N.3..} |
"""
ret = alsep.roundtrip(ALSSetPropertyCalibration(value=chexundump(dump)[0x38:]))
ret = alsep.send_notify(ALSSetPropertyCalibration(value=chexundump(dump)[0x38:]))
# [syslog] * [ALSCT720.cpp:1138]loadALSCalibrationData: ALS sensor is calibrated
# retcode: 0xe00002bc

ret = alsep.roundtrip(ALSSetPropertyInterval(interval=200000))
ret = alsep.send_notify(ALSSetPropertyInterval(interval=200000))
# [syslog] * [ALSCT720.cpp:690]configureSensor - Configure sensor with gain 8 and integration time 197380
# [syslog] * [ALSCT720.cpp:708]setSensorEnabled - Enabling the sensor.

if 0: # test that on/off works
aop.work_for(0.5)
ret = alsep.roundtrip(ALSSetPropertyInterval(interval=0))
ret = alsep.send_notify(ALSSetPropertyInterval(interval=0))
# [syslog] * [ALSCT720.cpp:598]setProperty: set report interval 0, _wakeHintMode = 0
# [syslog] * [ALSCT720.cpp:735]setSensorEnabled - Disabling the sensor.
ret = alsep.roundtrip(ALSSetPropertyInterval(interval=200000))
ret = alsep.send_notify(ALSSetPropertyInterval(interval=200000))
while True:
aop.work()

Expand Down
64 changes: 24 additions & 40 deletions proxyclient/experiments/aop_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
from m1n1.fw.aop.client import AOPClient
from m1n1.fw.aop.ipc import *

# on the first terminal: M1N1DEVICE=/dev/ttyACM0 python3 experiments/aop_audio.py
# at that point (hpai at pw1), aop powers on admac and you should be dropped into a shell
# on a second terminal in parallel: M1N1DEVICE=/dev/ttyACM1 M1N1DEVICE=/dev/ttyACM1 tools/admac_stream.py \
# --node admac-aop-audio --channel 1 -v | xxd -g 4 -c 12 -e
# inside the shell (on the first terminal), aop_start()
# there should now be microphone samples streamed to admac
# see povik's commit #fc66046

# 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")
Expand Down Expand Up @@ -87,7 +95,7 @@
# shutdown sequence must also be pwrd -> pw1 -> idle

def aop_start():
aop.audio.indirect(SetDeviceProp(
aop.audio.send_notify(SetDeviceProp(
devid=u'hpai',
modifier=202,
data=Container(
Expand All @@ -96,10 +104,10 @@ def aop_start():
target_pstate=u'pwrd',
unk2=1,
)
)).check_retcode()
))

def aop_stop():
aop.audio.indirect(SetDeviceProp(
aop.audio.send_notify(SetDeviceProp(
devid='hpai',
modifier=202,
data=Container(
Expand All @@ -108,9 +116,9 @@ def aop_stop():
target_pstate='pw1 ',
unk2=1,
)
)).check_retcode()
))

aop.audio.indirect(SetDeviceProp(
aop.audio.send_notify(SetDeviceProp(
devid='hpai',
modifier=202,
data=Container(
Expand All @@ -119,47 +127,23 @@ def aop_stop():
target_pstate='idle',
unk2=0,
)
)).check_retcode()
))

def main():
aop.start()
for epno in [0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x27, 0x28]:
aop.start_ep(epno)
timeout = 5
while (not aop.audio.ready) and timeout:
aop.work_for(0.1)
timeout -= 1
if not timeout:
raise Exception("Timed out waiting on audio endpoint")
print("Finished boot")
aop.work_for(0.3)
audep = aop.audio

audep.roundtrip(AttachDevice(devid='pdm0')).check_retcode() # leap signal processor and etc; leap is low-energy audio processor I think
audep.roundtrip(AttachDevice(devid='hpai')).check_retcode() # high power audio input? actual mic
audep.roundtrip(AttachDevice(devid='lpai')).check_retcode() # low power audio input? seems to be voice trigger mic
audep.roundtrip(SetDeviceProp(
devid='lpai', modifier=301, data=Container(unk1=7, unk2=7, unk3=1, unk4=7))
).check_retcode()
audep.indirect(SetDeviceProp(
devid='pdm0', modifier=200, data=pdm_config)
).check_retcode()
audep.indirect(SetDeviceProp(
devid='pdm0', modifier=210, data=decimator_config)
).check_retcode()

dump = """
00000000 08 00 00 10 00 00 00 00 02 2d 00 00 00 00 00 00 |.........-......|
00000010 00 00 00 00 00 00 00 00 34 00 00 00 02 10 20 00 |........4..... .|
00000020 2d 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 |-...............|
00000030 00 00 00 00 ff ff ff ff 04 00 00 c3 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 a0 61 70 68 |.............aph|
00000050 30 00 00 00 00 00 00 00 69 61 70 68 c8 00 00 00 |0.......iaph....|
00000060 01 00 00 00 |.... |
"""
audep.send_ipc(chexundump(dump)) # optional hello. gets "idle" for response
aop.work_for(0.1)

audep.indirect(SetDeviceProp(
audep.send_notify(AttachDevice(devid='pdm0')) # leap signal processor and etc; leap is low-energy audio processor I think
audep.send_notify(AttachDevice(devid='hpai')) # high power audio input? actual mic
audep.send_notify(AttachDevice(devid='lpai')) # low power audio input? seems to be voice trigger mic
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))

audep.send_notify(SetDeviceProp(
devid='hpai',
modifier=202,
data=Container(
Expand All @@ -168,7 +152,7 @@ def main():
target_pstate='pw1 ',
unk2=0,
)
)).check_retcode()
))

try:
main()
Expand Down

0 comments on commit aa0f71b

Please sign in to comment.