summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-13 20:43:03 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-13 20:43:03 +0200
commit6953a745a5d83e395246d33c476892f06c1c835b (patch)
tree44d8a17d048e8618c8a1b5f079c1b0fe1ce72418
parentderp (diff)
downloadblueshift-6953a745a5d83e395246d33c476892f06c1c835b.tar.gz
blueshift-6953a745a5d83e395246d33c476892f06c1c835b.tar.bz2
blueshift-6953a745a5d83e395246d33c476892f06c1c835b.tar.xz
add a little edid parsing, can get physical dimensions and gamma
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/monitor.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/monitor.py b/src/monitor.py
index fa3d4c5..78eb59b 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -498,6 +498,33 @@ class Output:
return '[Name: %s, Connected: %s, Width: %s, Height: %s, CRTC: %s, Screen: %s, EDID: %s]' % rc
+class EDID: # TODO demo and document this
+ def __init__(self, edid):
+ if not len(edid) == 256:
+ raise Exception('EDID version not support, length mismatch')
+ if not edid[:16].upper() == '00FFFFFFFFFFFF00':
+ raise Exception('EDID version not support, magic number mismatch')
+ edid = [int(edid[i * 2 : i * 2 + 2], 16) for i in range(128)]
+ if not edid[18] == 1:
+ raise Exception('EDID version not support, version mismatch, only 1.3 supported')
+ if not edid[19] == 3:
+ raise Exception('EDID version not support, revision mismatch, only 1.3 supported')
+ self.widthmm = edid[21] * 10
+ self.heightmm = edid[22] * 10
+ if (self.widthmm == 0) or (self.heightmm == 0):
+ self.widthmm = None
+ self.heightmm = None
+ if (edid[23] == 255):
+ self.gamma = None
+ self.gamma_correction = None
+ else:
+ self.gamma = (edid[23] + 100) / 100
+ self.gamma_correction = self.gamma / 2.2
+ if not sum(edid) % 256 == 0:
+ raise Exception('Incorrect EDID checksum')
+
+
+
def list_screens(method = 'randr', display = None):
'''
Retrieve informantion about all screens, outputs and CRTC:s