summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2019-12-07 16:31:25 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2019-12-07 16:42:07 +0100
commit4abd552b354cedc416c19722c7264292f29a9ca9 (patch)
treee91ac0d20e6521fcb7f8fad43104bee464d26303
parent3e5bd72eeeb0bee1e601b36d19ecae2450841395 (diff)
downloadlibsigrokdecode-4abd552b354cedc416c19722c7264292f29a9ca9.tar.gz
libsigrokdecode-4abd552b354cedc416c19722c7264292f29a9ca9.zip
hdcp: Simplify some code snippets.
-rw-r--r--decoders/hdcp/pd.py71
1 files changed, 26 insertions, 45 deletions
diff --git a/decoders/hdcp/pd.py b/decoders/hdcp/pd.py
index f289f91..38ea99a 100644
--- a/decoders/hdcp/pd.py
+++ b/decoders/hdcp/pd.py
@@ -39,6 +39,27 @@ msg_ids = {
17: 'RepeaterAuth_Stream_Ready',
}
+write_items = {
+ 0x00: '1.4 Bksv - Receiver KSV',
+ 0x08: '1.4 Ri\' - Link Verification',
+ 0x0a: '1.4 Pj\' - Enhanced Link Verification',
+ 0x10: '1.4 Aksv - Transmitter KSV',
+ 0x15: '1.4 Ainfo - Transmitter KSV',
+ 0x18: '1.4 An - Session random number',
+ 0x20: '1.4 V\'H0',
+ 0x24: '1.4 V\'H1',
+ 0x28: '1.4 V\'H2',
+ 0x2c: '1.4 V\'H3',
+ 0x30: '1.4 V\'H4',
+ 0x40: '1.4 Bcaps',
+ 0x41: '1.4 Bstatus',
+ 0x43: '1.4 KSV FIFO',
+ 0x50: 'HDCP2Version',
+ 0x60: 'Write_Message',
+ 0x70: 'RxStatus',
+ 0x80: 'Read_Message',
+}
+
class Decoder(srd.Decoder):
api_version = 3
id = 'hdcp'
@@ -98,7 +119,6 @@ class Decoder(srd.Decoder):
elif cmd != 'START REPEAT':
return
self.state = 'GET SLAVE ADDR'
-
elif self.state == 'GET SLAVE ADDR':
if cmd == 'ADDRESS READ':
self.state = 'BUFFER DATA'
@@ -108,59 +128,20 @@ class Decoder(srd.Decoder):
self.state = 'WRITE OFFSET'
if databyte != 0x3a:
self.state = 'IDLE'
-
elif self.state == 'WRITE OFFSET':
if cmd == 'DATA WRITE':
- if databyte == 0x00:
- self.type = '1.4 Bksv - Receiver KSV'
- elif databyte == 0x08:
- self.type = '1.4 Ri\' - Link Verification'
- elif databyte == 0x0a:
- self.type = '1.4 Pj\' - Enhanced Link Verification'
- elif databyte == 0x10:
- self.type = '1.4 Aksv - Transmitter KSV'
- self.state = 'BUFFER DATA'
- elif databyte == 0x15:
- self.type = '1.4 Ainfo- Transmitter KSV'
+ if databyte in write_items:
+ self.type = write_items[databyte]
+ if databyte in (0x10, 0x15, 0x18, 0x60):
self.state = 'BUFFER DATA'
- elif databyte == 0x18:
- self.type = '1.4 An- Session random number'
- self.state = 'BUFFER DATA'
- elif databyte == 0x20:
- self.type = '1.4 V\'H0'
- elif databyte == 0x24:
- self.type = '1.4 V\'H1'
- elif databyte == 0x28:
- self.type = '1.4 V\'H2'
- elif databyte == 0x2c:
- self.type = '1.4 V\'H3'
- elif databyte == 0x30:
- self.type = '1.4 V\'H4'
- elif databyte == 0x40:
- self.type = '1.4 Bcaps'
- elif databyte == 0x41:
- self.type = '1.4 Bstatus'
- elif databyte == 0x43:
- self.type = '1.4 KSV FIFO'
- elif databyte == 0x50:
- self.type = 'HDCP2Version'
- elif databyte == 0x60:
- self.type = 'Write_Message'
- self.state = 'BUFFER DATA'
- elif databyte == 0x70:
- self.type = 'RxStatus'
- elif databyte == 0x80:
- self.type = 'Read_Message'
-
# If we are reading, then jump back to IDLE for a start repeat.
# If we are writing, then just continue onwards.
if self.state == 'BUFFER DATA':
- self.state = 'BUFFER DATA'
+ pass
elif self.type != '':
self.state = 'IDLE'
-
elif self.state == 'BUFFER DATA':
- if (cmd == 'STOP') or (cmd == 'NACK'):
+ if cmd in ('STOP', 'NACK'):
self.es_block = es
self.state = 'IDLE'
if self.type != '':