m1n1.fw.dcp: Parse AVPropChunks in parse_log

Signed-off-by: Janne Grunau <j@jannau.net>
This commit is contained in:
Janne Grunau 2022-11-26 17:49:11 +01:00
parent 7498b785ae
commit cc6b58f13e
2 changed files with 48 additions and 0 deletions

View file

@ -952,3 +952,7 @@ class Call:
method.print_long_args(indent, self.in_vals, self.out_vals) method.print_long_args(indent, self.in_vals, self.out_vals)
#if len(method.out_fields) - (self.ret is not None): #if len(method.out_fields) - (self.ret is not None):
#print(self.out_vals) #print(self.out_vals)
def get_method(self):
cls, method = ALL_METHODS.get(self.msg, (None, None))
return method

View file

@ -4,6 +4,34 @@ from m1n1.utils import *
from m1n1.constructutils import Ver from m1n1.constructutils import Ver
from m1n1.fw.dcp.ipc import * from m1n1.fw.dcp.ipc import *
class DCPAVPropHandler:
def __init__(self):
self.dcpav_prop = {}
def setDCPAVPropStart(self, length):
# print(f"setDCPAVPropStart({length:#x})")
self.dcpav_prop_len = length - 1 # off by one?
self.dcpav_prop_off = 0
self.dcpav_prop_data = []
return True
def setDCPAVPropChunk(self, data, offset, length):
# print(f"setDCPAVPropChunk(..., {offset:#x}, {length:#x})")
assert offset == self.dcpav_prop_off
self.dcpav_prop_data.append(data)
self.dcpav_prop_off += len(data)
return True
def setDCPAVPropEnd(self, key):
# print(f"setDCPAVPropEnd({key!r})")
blob = b"".join(self.dcpav_prop_data)
assert self.dcpav_prop_len == len(blob)
self.dcpav_prop[key] = OSSerialize().parse(blob)
self.dcpav_prop_data = self.dcpav_prop_len = self.dcpav_prop_off = None
pprint.pprint(self.dcpav_prop[key])
return True
def parse_log(fd): def parse_log(fd):
op_stack = {} op_stack = {}
for line in fd: for line in fd:
@ -34,8 +62,24 @@ def dump_log(fd):
"": 0, "": 0,
"OOB": 0, "OOB": 0,
} }
handler = DCPAVPropHandler()
for op in parse_log(fd): for op in parse_log(fd):
ctx = "" ctx = ""
if Ver.check("V < V13_2"):
dcpavprop_cbs = ["D122", "D123", "D124"]
else:
dcpavprop_cbs = ["D125", "D126", "D127"]
if not op.complete and op.msg in dcpavprop_cbs:
method = op.get_method()
if op.msg == dcpavprop_cbs[0]:
method.callback(handler.setDCPAVPropStart, op.in_data)
if op.msg == dcpavprop_cbs[1]:
method.callback(handler.setDCPAVPropChunk, op.in_data)
if op.msg == dcpavprop_cbs[2]:
method.callback(handler.setDCPAVPropEnd, op.in_data)
if "OOB" in op.chan: if "OOB" in op.chan:
ctx = "[OOB] -----------> " ctx = "[OOB] -----------> "
if not op.complete: if not op.complete: