mirror of
https://github.com/AsahiLinux/m1n1
synced 2025-02-16 21:58:27 +00:00
m1n1.fw.mtp: Fix parsing of init messages
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
36bcc36173
commit
9b7ae1b443
1 changed files with 8 additions and 3 deletions
|
@ -20,13 +20,13 @@ class GPIOInit(ConstructClass):
|
||||||
class InitBlock(ConstructClass):
|
class InitBlock(ConstructClass):
|
||||||
subcon = Struct(
|
subcon = Struct(
|
||||||
"type" / Int16ul,
|
"type" / Int16ul,
|
||||||
"subtype" / Int16ul,
|
|
||||||
"length" / Int16ul,
|
"length" / Int16ul,
|
||||||
"payload" / FixedSized(this.length,
|
"payload" / FixedSized(this.length,
|
||||||
Switch(this.type, {
|
Switch(this.type, {
|
||||||
0: HIDDescriptor,
|
0: HIDDescriptor,
|
||||||
1: GPIOInit,
|
1: GPIOInit,
|
||||||
2: Bytes(0),
|
2: GreedyBytes, # Unknown 6 bytes terminator
|
||||||
|
7: GreedyBytes, # Device name
|
||||||
}, default=GreedyBytes))
|
}, default=GreedyBytes))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ class InitMsg(ConstructClass):
|
||||||
"unk" / Const(0x00, Int8ul),
|
"unk" / Const(0x00, Int8ul),
|
||||||
"device_id" / Int8ul,
|
"device_id" / Int8ul,
|
||||||
"device_name" / PaddedString(16, "ascii"),
|
"device_name" / PaddedString(16, "ascii"),
|
||||||
|
"more_packets" / Int16ul,
|
||||||
"msg" / RepeatUntil(lambda obj, lst, ctx: lst[-1].type == 2, InitBlock)
|
"msg" / RepeatUntil(lambda obj, lst, ctx: lst[-1].type == 2, InitBlock)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -254,7 +255,6 @@ class MTPCommInterface(MTPInterface):
|
||||||
self.log(f"Got HID descriptor for {iface}:")
|
self.log(f"Got HID descriptor for {iface}:")
|
||||||
iface.descriptor = blk.payload.descriptor
|
iface.descriptor = blk.payload.descriptor
|
||||||
self.log(hexdump(iface.descriptor))
|
self.log(hexdump(iface.descriptor))
|
||||||
iface.initialize()
|
|
||||||
elif isinstance(blk.payload, GPIOInit):
|
elif isinstance(blk.payload, GPIOInit):
|
||||||
self.log(f"GPIO Init: {blk.payload}")
|
self.log(f"GPIO Init: {blk.payload}")
|
||||||
prop = getattr(self.proto.node[msg.device_name],
|
prop = getattr(self.proto.node[msg.device_name],
|
||||||
|
@ -263,6 +263,8 @@ class MTPCommInterface(MTPInterface):
|
||||||
val = prop.args[1]
|
val = prop.args[1]
|
||||||
self.log(f"GPIO key: {key}")
|
self.log(f"GPIO key: {key}")
|
||||||
self.gpios[(msg.device_id, blk.payload.gpio_id)] = key, val
|
self.gpios[(msg.device_id, blk.payload.gpio_id)] = key, val
|
||||||
|
if not msg.more_packets:
|
||||||
|
iface.initialize()
|
||||||
elif isinstance(msg, GPIORequestMsg):
|
elif isinstance(msg, GPIORequestMsg):
|
||||||
self.log(f"GPIO request: {msg}")
|
self.log(f"GPIO request: {msg}")
|
||||||
smcep = self.proto.smc.epmap[0x20]
|
smcep = self.proto.smc.epmap[0x20]
|
||||||
|
@ -275,6 +277,9 @@ class MTPCommInterface(MTPInterface):
|
||||||
ackmsg.unk = 0
|
ackmsg.unk = 0
|
||||||
ackmsg.msg = msg
|
ackmsg.msg = msg
|
||||||
self.device_control(ackmsg)
|
self.device_control(ackmsg)
|
||||||
|
else:
|
||||||
|
self.log("Unknown message!")
|
||||||
|
print(msg)
|
||||||
|
|
||||||
def ack(self, retcode, msg):
|
def ack(self, retcode, msg):
|
||||||
msg = DeviceControlAck.parse(msg)
|
msg = DeviceControlAck.parse(msg)
|
||||||
|
|
Loading…
Add table
Reference in a new issue