diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2012-03-03 14:39:14 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2012-03-04 15:10:10 +0100 |
commit | 09059016e02db5d83b4862a3adcf8ddf101f6991 (patch) | |
tree | fd79cb7820e98be7a59af2a3c47a72a64f8d8f68 /decoders/edid | |
parent | 0082d592076fdc3fe06a760d432a48163ee0bd97 (diff) | |
download | libsigrokdecode-09059016e02db5d83b4862a3adcf8ddf101f6991.tar.gz libsigrokdecode-09059016e02db5d83b4862a3adcf8ddf101f6991.zip |
srd: PDs: Consistency/cosmetic fixes.
Diffstat (limited to 'decoders/edid')
-rw-r--r-- | decoders/edid/edid.py | 171 |
1 files changed, 87 insertions, 84 deletions
diff --git a/decoders/edid/edid.py b/decoders/edid/edid.py index a56bb57..b4b5f84 100644 --- a/decoders/edid/edid.py +++ b/decoders/edid/edid.py @@ -43,23 +43,23 @@ OFF_CHECKSUM = 127 # Pre-EDID established timing modes est_modes = [ - "720x400@70Hz", - "720x400@88Hz", - "640x480@60Hz", - "640x480@67Hz", - "640x480@72Hz", - "640x480@75Hz", - "800x600@56Hz", - "800x600@60Hz", - "800x600@72Hz", - "800x600@75Hz", - "832x624@75Hz", - "1024x768@87Hz(i)", - "1024x768@60Hz", - "1024x768@70Hz", - "1024x768@75Hz", - "1280x1024@75Hz", - "1152x870@75Hz", + '720x400@70Hz', + '720x400@88Hz', + '640x480@60Hz', + '640x480@67Hz', + '640x480@72Hz', + '640x480@75Hz', + '800x600@56Hz', + '800x600@60Hz', + '800x600@72Hz', + '800x600@75Hz', + '832x624@75Hz', + '1024x768@87Hz(i)', + '1024x768@60Hz', + '1024x768@70Hz', + '1024x768@75Hz', + '1280x1024@75Hz', + '1152x870@75Hz', ] # X:Y display aspect ratios, as used in standard timing modes @@ -108,7 +108,7 @@ class Decoder(srd.Decoder): self.sn.append([ss, es]) self.cache.append(data) # debug -# self.put(ss, es, self.out_ann, [0, ["%d: [%.2x]" % (self.cnt, data)]]) +# self.put(ss, es, self.out_ann, [0, ['%d: [%.2x]' % (self.cnt, data)]]) if self.state is None: # Wait for the EDID header @@ -119,7 +119,7 @@ class Decoder(srd.Decoder): self.cache = self.cache[-8:] self.cnt = 8 self.state = 'edid' - self.put(ss, es, self.out_ann, [0, ["EDID header"]]) + self.put(ss, es, self.out_ann, [0, ['EDID header']]) elif self.state == 'edid': if self.cnt == OFF_VERSION: self.decode_vid(-10) @@ -127,7 +127,7 @@ class Decoder(srd.Decoder): self.decode_serial(-6) self.decode_mfrdate(-2) elif self.cnt == OFF_BASIC: - version = "EDID version: %d.%d" % (self.cache[-2], self.cache[-1]) + version = 'EDID version: %d.%d' % (self.cache[-2], self.cache[-1]) self.put(ss, es, self.out_ann, [0, [version]]) elif self.cnt == OFF_CHROM: self.decode_basicdisplay(-5) @@ -140,23 +140,25 @@ class Decoder(srd.Decoder): elif self.cnt == OFF_NUM_EXT: self.decode_descriptors(-72) elif self.cnt == OFF_CHECKSUM: - self.put(ss, es, self.out_ann, [0, ["Extensions present: %d" % self.cache[self.cnt-1]]]) + self.put(ss, es, self.out_ann, + [0, ['Extensions present: %d' % self.cache[self.cnt-1]]]) elif self.cnt == OFF_CHECKSUM+1: checksum = 0 for i in range(128): checksum += self.cache[i] if checksum % 256 == 0: - csstr = "OK" + csstr = 'OK' else: - csstr = "WRONG!" - self.put(ss, es, self.out_ann, [0, ["Checksum: %d (%s)" % ( - self.cache[self.cnt-1], csstr)]]) + csstr = 'WRONG!' + self.put(ss, es, self.out_ann, [0, ['Checksum: %d (%s)' % ( + self.cache[self.cnt-1], csstr)]]) self.state = 'extensions' elif self.state == 'extensions': pass def ann_field(self, start, end, annotation): - self.put(self.sn[start][0], self.sn[end][1], self.out_ann, [ANN_FIELDS, [annotation]]) + self.put(self.sn[start][0], self.sn[end][1], + self.out_ann, [ANN_FIELDS, [annotation]]) def lookup_pnpid(self, pnpid): pnpid_file = os.path.join(os.path.dirname(__file__), 'pnpids.txt') @@ -173,11 +175,11 @@ class Decoder(srd.Decoder): pnpid += chr(64 + (self.cache[offset+1] & 0x1f)) vendor = self.lookup_pnpid(pnpid) if vendor: - pnpid += " (%s)" % vendor + pnpid += ' (%s)' % vendor self.ann_field(offset, offset+1, pnpid) def decode_pid(self, offset): - pidstr = "Product 0x%.2x%.2x" % (self.cache[offset+1], self.cache[offset]) + pidstr = 'Product 0x%.2x%.2x' % (self.cache[offset+1], self.cache[offset]) self.ann_field(offset, offset+1, pidstr) def decode_serial(self, offset): @@ -192,32 +194,29 @@ class Decoder(srd.Decoder): is_alnum = False break serialstr += chr(self.cache[offset+3-i]) - if is_alnum: - serial = serialstr - else: - serial = str(serialnum) - self.ann_field(offset, offset+3, "Serial " + serial) + serial = serialstr if is_alnum else str(serialnum) + self.ann_field(offset, offset+3, 'Serial ' + serial) def decode_mfrdate(self, offset): datestr = '' if self.cache[offset]: - datestr += "week %d, " % self.cache[offset] + datestr += 'week %d, ' % self.cache[offset] datestr += str(1990 + self.cache[offset+1]) if datestr: - self.ann_field(offset, offset+1, "Manufactured " + datestr) + self.ann_field(offset, offset+1, 'Manufactured ' + datestr) def decode_basicdisplay(self, offset): # Video input definition vid = self.cache[offset] if vid & 0x80: # Digital - self.ann_field(offset, offset, "Video input: VESA DFP 1.") + self.ann_field(offset, offset, 'Video input: VESA DFP 1.') else: # Analog sls = (vid & 60) >> 5 - self.ann_field(offset, offset, "Signal level standard: %.2x" % sls) + self.ann_field(offset, offset, 'Signal level standard: %.2x' % sls) if vid & 0x10: - self.ann_field(offset, offset, "Blank-to-black setup expected") + self.ann_field(offset, offset, 'Blank-to-black setup expected') syncs = '' if vid & 0x08: syncs += 'separate syncs, ' @@ -228,16 +227,16 @@ class Decoder(srd.Decoder): if vid & 0x01: syncs += 'Vsync serration required, ' if syncs: - self.ann_field(offset, offset, "Supported syncs: %s" % syncs[:-2]) + self.ann_field(offset, offset, 'Supported syncs: %s' % syncs[:-2]) # Max horizontal/vertical image size if self.cache[offset+1] != 0 and self.cache[offset+2] != 0: # Projectors have this set to 0 - sizestr = "%dx%dcm" % (self.cache[offset+1], self.cache[offset+2]) - self.ann_field(offset+1, offset+2, "Physical size: " + sizestr) + sizestr = '%dx%dcm' % (self.cache[offset+1], self.cache[offset+2]) + self.ann_field(offset+1, offset+2, 'Physical size: ' + sizestr) # Display transfer characteristic (gamma) if self.cache[offset+3] != 0xff: gamma = (self.cache[offset+3] + 100) / 100 - self.ann_field(offset+3, offset+3, "Gamma: %1.2f" % gamma) + self.ann_field(offset+3, offset+3, 'Gamma: %1.2f' % gamma) # Feature support fs = self.cache[offset+4] dpms = '' @@ -248,7 +247,7 @@ class Decoder(srd.Decoder): if fs & 0x20: dpms += 'active off, ' if dpms: - self.ann_field(offset+4, offset+4, "DPMS support: %s" % dpms[:-2]) + self.ann_field(offset+4, offset+4, 'DPMS support: %s' % dpms[:-2]) dt = (fs & 0x18) >> 3 dtstr = '' if dt == 0: @@ -258,16 +257,17 @@ class Decoder(srd.Decoder): elif dt == 2: dtstr = 'non-RGB multicolor' if dtstr: - self.ann_field(offset+4, offset+4, "Display type: %s" % dtstr) + self.ann_field(offset+4, offset+4, 'Display type: %s' % dtstr) if fs & 0x04: - self.ann_field(offset+4, offset+4, "Color space: standard sRGB") + self.ann_field(offset+4, offset+4, 'Color space: standard sRGB') # Save this for when we decode the first detailed timing descriptor self.have_preferred_timing = (fs & 0x02) == 0x02 if fs & 0x01: gft = '' else: gft = 'not ' - self.ann_field(offset+4, offset+4, "Generalized timing formula: %ssupported" % gft) + self.ann_field(offset+4, offset+4, + 'Generalized timing formula: %ssupported' % gft) def convert_color(self, value): # Convert from 10-bit packet format to float @@ -281,23 +281,23 @@ class Decoder(srd.Decoder): def decode_chromaticity(self, offset): redx = (self.cache[offset+2] << 2) + ((self.cache[offset] & 0xc0) >> 6) redy = (self.cache[offset+3] << 2) + ((self.cache[offset] & 0x30) >> 4) - self.ann_field(offset, offset+9, "Chromacity red: X %1.3f, Y %1.3f" % ( - self.convert_color(redx), self.convert_color(redy))) + self.ann_field(offset, offset+9, 'Chromacity red: X %1.3f, Y %1.3f' % ( + self.convert_color(redx), self.convert_color(redy))) greenx = (self.cache[offset+4] << 2) + ((self.cache[offset] & 0x0c) >> 6) greeny = (self.cache[offset+5] << 2) + ((self.cache[offset] & 0x03) >> 4) - self.ann_field(offset, offset+9, "Chromacity green: X %1.3f, Y %1.3f" % ( - self.convert_color(greenx), self.convert_color(greeny))) + self.ann_field(offset, offset+9, 'Chromacity green: X %1.3f, Y %1.3f' % ( + self.convert_color(greenx), self.convert_color(greeny))) bluex = (self.cache[offset+6] << 2) + ((self.cache[offset+1] & 0xc0) >> 6) bluey = (self.cache[offset+7] << 2) + ((self.cache[offset+1] & 0x30) >> 4) - self.ann_field(offset, offset+9, "Chromacity blue: X %1.3f, Y %1.3f" % ( - self.convert_color(bluex), self.convert_color(bluey))) + self.ann_field(offset, offset+9, 'Chromacity blue: X %1.3f, Y %1.3f' % ( + self.convert_color(bluex), self.convert_color(bluey))) whitex = (self.cache[offset+8] << 2) + ((self.cache[offset+1] & 0x0c) >> 6) whitey = (self.cache[offset+9] << 2) + ((self.cache[offset+1] & 0x03) >> 4) - self.ann_field(offset, offset+9, "Chromacity white: X %1.3f, Y %1.3f" % ( - self.convert_color(whitex), self.convert_color(whitey))) + self.ann_field(offset, offset+9, 'Chromacity white: X %1.3f, Y %1.3f' % ( + self.convert_color(whitex), self.convert_color(whitey))) def decode_est_timing(self, offset): # Pre-EDID modes @@ -309,7 +309,8 @@ class Decoder(srd.Decoder): if bitmap & (1 << (16-i)): modestr += est_modes[i] + ', ' if modestr: - self.ann_field(offset, offset+2, "Supported establised modes: %s" % modestr[:-2]) + self.ann_field(offset, offset+2, + 'Supported establised modes: %s' % modestr[:-2]) def decode_std_timing(self, offset): modestr = '' @@ -322,9 +323,10 @@ class Decoder(srd.Decoder): ratio_x, ratio_y = xy_ratio[ratio] y = x / ratio_x * ratio_y refresh = (self.cache[offset+i+1] & 0x3f) + 60 - modestr += "%dx%d@%dHz, " % (x, y, refresh) + modestr += '%dx%d@%dHz, ' % (x, y, refresh) if modestr: - self.ann_field(offset, offset+2, "Supported standard modes: %s" % modestr[:-2]) + self.ann_field(offset, offset+2, + 'Supported standard modes: %s' % modestr[:-2]) def decode_detailed_timing(self, offset): if offset == -72 and self.have_preferred_timing: @@ -337,44 +339,44 @@ class Decoder(srd.Decoder): self.out_ann, [ANN_SECTIONS, [section]]) pixclock = float((self.cache[offset+1] << 8) + self.cache[offset]) / 100 - self.ann_field(offset, offset+1, "Pixel clock: %.2f MHz" % pixclock) + self.ann_field(offset, offset+1, 'Pixel clock: %.2f MHz' % pixclock) horiz_active = ((self.cache[offset+4] & 0xf0) << 4) + self.cache[offset+2] - self.ann_field(offset+2, offset+4, "Horizontal active: %d" % horiz_active) + self.ann_field(offset+2, offset+4, 'Horizontal active: %d' % horiz_active) horiz_blank = ((self.cache[offset+4] & 0x0f) << 8) + self.cache[offset+3] - self.ann_field(offset+3, offset+4, "Horizontal blanking: %d" % horiz_blank) + self.ann_field(offset+3, offset+4, 'Horizontal blanking: %d' % horiz_blank) vert_active = ((self.cache[offset+7] & 0xf0) << 4) + self.cache[offset+5] - self.ann_field(offset+5, offset+7, "Vertical active: %d" % vert_active) + self.ann_field(offset+5, offset+7, 'Vertical active: %d' % vert_active) vert_blank = ((self.cache[offset+7] & 0x0f) << 8) + self.cache[offset+6] - self.ann_field(offset+6, offset+7, "Vertical blanking: %d" % vert_blank) + self.ann_field(offset+6, offset+7, 'Vertical blanking: %d' % vert_blank) horiz_sync_off = ((self.cache[offset+11] & 0xc0) << 2) + self.cache[offset+8] - self.ann_field(offset+8, offset+11, "Horizontal sync offset: %d" % horiz_sync_off) + self.ann_field(offset+8, offset+11, 'Horizontal sync offset: %d' % horiz_sync_off) horiz_sync_pw = ((self.cache[offset+11] & 0x30) << 4) + self.cache[offset+9] - self.ann_field(offset+9, offset+11, "Horizontal sync pulse width: %d" % horiz_sync_pw) + self.ann_field(offset+9, offset+11, 'Horizontal sync pulse width: %d' % horiz_sync_pw) vert_sync_off = ((self.cache[offset+11] & 0x0c) << 2) \ + ((self.cache[offset+10] & 0xf0) >> 4) - self.ann_field(offset+10, offset+11, "Vertical sync offset: %d" % vert_sync_off) + self.ann_field(offset+10, offset+11, 'Vertical sync offset: %d' % vert_sync_off) vert_sync_pw = ((self.cache[offset+11] & 0x03) << 4) \ + (self.cache[offset+10] & 0x0f) - self.ann_field(offset+10, offset+11, "Vertical sync pulse width: %d" % vert_sync_pw) + self.ann_field(offset+10, offset+11, 'Vertical sync pulse width: %d' % vert_sync_pw) horiz_size = ((self.cache[offset+14] & 0xf0) << 4) + self.cache[offset+12] vert_size = ((self.cache[offset+14] & 0x0f) << 8) + self.cache[offset+13] - self.ann_field(offset+12, offset+14, "Physical size: %dx%dmm" % (horiz_size, vert_size)) + self.ann_field(offset+12, offset+14, 'Physical size: %dx%dmm' % (horiz_size, vert_size)) horiz_border = self.cache[offset+15] if horiz_border: - self.ann_field(offset+15, offset+15, "Horizontal border: %d pixels" % horiz_border) + self.ann_field(offset+15, offset+15, 'Horizontal border: %d pixels' % horiz_border) vert_border = self.cache[offset+16] if vert_border: - self.ann_field(offset+16, offset+16, "Vertical border: %d lines" % vert_border) + self.ann_field(offset+16, offset+16, 'Vertical border: %d lines' % vert_border) features = 'Flags: ' if self.cache[offset+17] & 0x80: @@ -383,7 +385,8 @@ class Decoder(srd.Decoder): if stereo: if self.cache[offset+17] & 0x01: features += '2-way interleaved stereo (' - features += ['right image on even lines', 'left image on even lines', + features += ['right image on even lines', + 'left image on even lines', 'side-by-side'][stereo-1] features += '), ' else: @@ -401,7 +404,7 @@ class Decoder(srd.Decoder): features += 'bipolar analog composite (serrate on RGB)' elif sync == 0x02: features += 'digital composite (serrate on composite polarity ' \ - + (posneg[sync2 & 0x01]) + ')' + + (posneg[sync2 & 0x01]) + ')' elif sync == 0x03: features += 'digital separate (' features += 'Vsync polarity ' + (posneg[(sync2 & 0x02) >> 1]) @@ -415,43 +418,43 @@ class Decoder(srd.Decoder): if tag == 0xff: # Monitor serial number text = bytes(self.cache[offset+5:][:13]).decode(encoding='cp437', errors='replace') - self.ann_field(offset, offset+17, "Serial number: %s" % text.strip()) + self.ann_field(offset, offset+17, 'Serial number: %s' % text.strip()) elif tag == 0xfe: # Text text = bytes(self.cache[offset+5:][:13]).decode(encoding='cp437', errors='replace') - self.ann_field(offset, offset+17, "Info: %s" % text.strip()) + self.ann_field(offset, offset+17, 'Info: %s' % text.strip()) elif tag == 0xfc: # Monitor name text = bytes(self.cache[offset+5:][:13]).decode(encoding='cp437', errors='replace') - self.ann_field(offset, offset+17, "Model name: %s" % text.strip()) + self.ann_field(offset, offset+17, 'Model name: %s' % text.strip()) elif tag == 0xfd: # Monitor range limits self.put(self.sn[offset][0], self.sn[offset+17][1], self.out_ann, - [ANN_SECTIONS, ["Monitor range limits"]]) - self.ann_field(offset+5, offset+5, "Minimum vertical rate: %dHz" % + [ANN_SECTIONS, ['Monitor range limits']]) + self.ann_field(offset+5, offset+5, 'Minimum vertical rate: %dHz' % self.cache[offset+5]) - self.ann_field(offset+6, offset+6, "Maximum vertical rate: %dHz" % + self.ann_field(offset+6, offset+6, 'Maximum vertical rate: %dHz' % self.cache[offset+6]) - self.ann_field(offset+7, offset+7, "Minimum horizontal rate: %dkHz" % + self.ann_field(offset+7, offset+7, 'Minimum horizontal rate: %dkHz' % self.cache[offset+7]) - self.ann_field(offset+8, offset+8, "Maximum horizontal rate: %dkHz" % + self.ann_field(offset+8, offset+8, 'Maximum horizontal rate: %dkHz' % self.cache[offset+8]) - self.ann_field(offset+9, offset+9, "Maximum pixel clock: %dMHz" % + self.ann_field(offset+9, offset+9, 'Maximum pixel clock: %dMHz' % (self.cache[offset+9] * 10)) if self.cache[offset+10] == 0x02: # Secondary GTF curve supported - self.ann_field(offset+10, offset+17, "Secondary timing formula supported") + self.ann_field(offset+10, offset+17, 'Secondary timing formula supported') elif tag == 0xfb: # Additional color point data self.put(self.sn[offset][0], self.sn[offset+17][1], self.out_ann, - [ANN_SECTIONS, ["Additional color point data"]]) + [ANN_SECTIONS, ['Additional color point data']]) elif tag == 0xfa: # Additional standard timing definitions self.put(self.sn[offset][0], self.sn[offset+17][1], self.out_ann, - [ANN_SECTIONS, ["Additional standard timing definitions"]]) + [ANN_SECTIONS, ['Additional standard timing definitions']]) else: self.put(self.sn[offset][0], self.sn[offset+17][1], self.out_ann, - [ANN_SECTIONS, ["Unknown descriptor"]]) + [ANN_SECTIONS, ['Unknown descriptor']]) def decode_descriptors(self, offset): # 4 consecutive 18-byte descriptor blocks |