X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fddc.py;h=f83909323b8b2a70d6d894f6e0db1a2ef22d91d4;hp=b4681d0fbe0566cca9028bed096e7035bd0d086c;hb=56270764cd4dd3d255979a283092765057a0d3de;hpb=e97b6ef569f73e387b2597dfa144c01838c0e27c
diff --git a/decoders/ddc.py b/decoders/ddc.py
index b4681d0..f839093 100644
--- a/decoders/ddc.py
+++ b/decoders/ddc.py
@@ -17,58 +17,58 @@
## along with this program; if not, If not, see .
##
-#
-# DDC protocol decoder
-#
-# This decoder extracts a DDC stream from an I2C session between a computer
-# and a display device. The stream is output as plain bytes.
-#
+'''
+This decoder extracts a DDC stream from an I2C session between a computer
+and a display device. The stream is output as plain bytes.
-import sigrokdecode
+Details:
+https://en.wikipedia.org/wiki/Display_Data_Channel
+'''
+import sigrokdecode as srd
-class Decoder(sigrokdecode.Decoder):
+class Decoder(srd.Decoder):
id = 'ddc'
name = 'DDC'
longname = 'Display Data Channel'
- desc = 'DDC is a protocol for communication between computers and displays.'
+ desc = 'A protocol for communication between computers and displays.'
longdesc = ''
- author = 'Bert Vermeulen '
license = 'gplv3+'
inputs = ['i2c']
outputs = ['ddc']
+ probes = []
+ options = {}
annotations = [
- ["Byte stream", "DDC byte stream as read from display."],
+ ['Byte stream', 'DDC byte stream as read from display.'],
]
def __init__(self, **kwargs):
self.state = None
def start(self, metadata):
- self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'ddc')
+ self.out_ann = self.add(srd.OUTPUT_ANN, 'ddc')
- def decode(self, start_sample, end_sample, i2c_data):
+ def decode(self, ss, es, data):
try:
- cmd, data, ack_bit = i2c_data
+ cmd, data, ack_bit = data
except Exception as e:
- raise Exception("malformed I2C input: %s" % str(e)) from e
+ raise Exception('malformed I2C input: %s' % str(e)) from e
if self.state is None:
- # waiting for the DDC session to start
- if cmd in ('START', 'START_REPEAT'):
+ # Wait for the DDC session to start.
+ if cmd in ('START', 'START REPEAT'):
self.state = 'start'
elif self.state == 'start':
- if cmd == 'ADDRESS_READ' and data == 80:
+ if cmd == 'ADDRESS READ' and data == 80:
# 80 is the I2C slave address of a connected display,
# so this marks the start of the DDC data transfer.
self.state = 'transfer'
elif cmd == 'STOP':
- # back to idle
+ # Got back to the idle state.
self.state = None
elif self.state == 'transfer':
- if cmd == 'DATA_READ':
- # there shouldn't be anything but data reads on this
- # address, so ignore everything else
- self.put(start_sample, end_sample, self.out_ann,
- [0, ["0x%.2x" % data]])
+ if cmd == 'DATA READ':
+ # There shouldn't be anything but data reads on this
+ # address, so ignore everything else.
+ self.put(ss, es, self.out_ann, [0, ['0x%.2x' % data]])