summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-10 20:17:35 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-10 20:17:35 +0100
commit3af89b858c7d86cb23bb75a68a3643449a4b15c3 (patch)
treec6cc9f27b28fb92d8e4e34c18a88f055640a1062
parentupdate todo (diff)
downloadblueshift-3af89b858c7d86cb23bb75a68a3643449a4b15c3.tar.gz
blueshift-3af89b858c7d86cb23bb75a68a3643449a4b15c3.tar.bz2
blueshift-3af89b858c7d86cb23bb75a68a3643449a4b15c3.tar.xz
add EDID support
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--TODO1
-rw-r--r--examples/crtc-detection22
-rw-r--r--examples/crtc-searching6
-rw-r--r--examples/lisp-esque10
-rw-r--r--examples/lisp-esque.conf5
-rw-r--r--info/blueshift.texinfo4
-rw-r--r--src/blueshift_idcrtc.c15
-rw-r--r--src/monitor.py35
8 files changed, 81 insertions, 17 deletions
diff --git a/TODO b/TODO
index 0347be6..823f082 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
Medium priority:
- Finish support for EDID
Document related software
Add example that parses text-based conf file
diff --git a/examples/crtc-detection b/examples/crtc-detection
index 5f60d6c..2da0e9d 100644
--- a/examples/crtc-detection
+++ b/examples/crtc-detection
@@ -10,24 +10,34 @@ temp = 6500
# List all connected outputs.
outputs = list_screens().find_by_connected(True)
+# EDID of the primary monitors
+edid_0 = '00ffffffffffff0010ac00504d5730372f0c01030e281e962b0cc9a057479b2712484ca44380a959a94f615971594559c28f31590101863d00c05100304040a013006c231100001e000000fd0030aa1e821d000a202020202020000000fc0044454c4c2050313133300a2020000000ff00364432353232424c3730574d0a00ea'
+
+# EDID of the secondary monitor
+edid_1 = '00ffffffffffff0010ac005045413035320c01030e281e962b0cc9a057479b2712484ca44380a959a94f615971594559c28f31590101863d00c05100304040a013006c231100001e000000fd0030aa1e821d000a202020202020000000fc0044454c4c2050313133300a2020000000ff003644323532324339353041450a0039'
+
+# Gamma of the monitors
+gammas = [(1.16, 1.15, 1.11), (1.10, 1.16, 1.10)]
+
# Configure each monitor.
for output in outputs:
# Data that identifies the monitor.
- monitor = (output.name, output.widthmm, output.heightmm)
+ edid = output.edid
+ monitor = (output.name, output.widthmm, output.heightmm, edid is not None)
# Default gamma settings.
- r_gamma, g_gamma, b_gamma = 1, 1, 1
+ monitor_gamma = (1, 1, 1)
# Get the correct gamma settings for the monitor.
- if monitor == ('DVI-0', 364, 291): r_gamma, g_gamma, b_gamma = 1.16, 1.15, 1.11
- elif monitor == ('VGA-0', 364, 291): r_gamma, g_gamma, b_gamma = 1.10, 1.16, 1.10
+ if (monitor == ('DVI-0', 364, 291, False)) or (edid == edid_0): monitor_gamma = gammas[0]
+ elif (monitor == ('VGA-0', 364, 291, False)) or (edid == edid_1): monitor_gamma = gammas[1]
else:
- print('Warning: unknown monitor at %s at size of %i mm by %i mm' % monitor)
+ print('Warning: unknown monitor at %s at size of %i mm by %i mm' % monitor[:3])
# Perform adjustments.
start_over()
temperature(temp, lambda t : divide_by_maximum(cmf_10deg(t)))
- gamma(r_gamma, g_gamma, b_gamma)
+ gamma(*monitor_gamma)
# Apply adjustments.
randr(output.crtc, screen = output.screen)
diff --git a/examples/crtc-searching b/examples/crtc-searching
index 9633b2a..521ffc5 100644
--- a/examples/crtc-searching
+++ b/examples/crtc-searching
@@ -40,6 +40,7 @@ parser = ArgParser('Colour temputare controller',
parser.add_argumentless(['-h', '-?', '--help'], 0, 'Print this help information')
parser.add_argumented(['-n', '--name'], 0, 'NAME', 'Select output by name')
+parser.add_argumented(['-e', '--edid'], 0, 'EDID', 'Select output by monitor extended display information data')
parser.add_argumented(['-s', '--size'], 0, 'WIDTH_MM:HEIGHT_MM', 'Select output by monitor size')
parser.parse(conf_opts)
@@ -59,6 +60,11 @@ if parser.opts['--name'] is not None:
for name in parser.opts['--name']:
outputs += screens.find_by_name(name)
+# Find CRTC:s by monitor extended display infomation data.
+if parser.opts['--edid'] is not None:
+ for edid in parser.opts['--edid']:
+ outputs += screens.find_by_edid(edid)
+
# Find CRTC:s by monitor size.
if parser.opts['--size'] is not None:
for size in parser.opts['--size']:
diff --git a/examples/lisp-esque b/examples/lisp-esque
index 72af2bc..53fd63a 100644
--- a/examples/lisp-esque
+++ b/examples/lisp-esque
@@ -167,6 +167,16 @@ def _size(mods, args):
'''
pass
+def _edid(mods, args):
+ '''
+ Find monitors by extended display information data
+
+ @param mods:[]|[str] Optionally the number of monitors to list
+ @param args:list<str> EDID of outputs' monitors
+ @return :list<str> <screen>:<output> encoding of found monitors
+ '''
+ pass
+
def _coordinates(mods, args):
'''
Specify geographical location by coordinates
diff --git a/examples/lisp-esque.conf b/examples/lisp-esque.conf
index 30ae4fb..cd9116f 100644
--- a/examples/lisp-esque.conf
+++ b/examples/lisp-esque.conf
@@ -26,9 +26,10 @@
; For monitors with output name DVI-0: (monitors :crtc "DVI-0")
; For monitors with output name DVI-0 or VGA-0: (monitors :crtc ("DVI-0" "VGA-0"))
; For monitors with size 364 mm × 291 mm: (monitors :size (364 291))
- ; If you want :crtc or :size to add an exact number of monitors
+ ; For monitors with EDID xyz: (monitors :edid xyz)
+ ; If you want :crtc, :size or :edid to add an exact number of monitors
; (non-found will monitors be skipped when it is time to use them)
- ; you can use :crtc:n or :size:n, where n is the number of monitors.
+ ; you can use :crtc:n, :size:n and :edid, where n is the number of monitors.
; Geographical coodinates: latitude longitude (northwards and eastwards in degrees)
diff --git a/info/blueshift.texinfo b/info/blueshift.texinfo
index 44cdea7..48cd214 100644
--- a/info/blueshift.texinfo
+++ b/info/blueshift.texinfo
@@ -827,6 +827,10 @@ that are either unused or not known whether
they are used or not (if @code{status} is
@code{False}.)
+@item find_by_edid(name)
+Matches outputs by monitor extended display
+information data.
+
@end table
These functions returns a list of matching
diff --git a/src/blueshift_idcrtc.c b/src/blueshift_idcrtc.c
index d55f6eb..c4ddf3b 100644
--- a/src/blueshift_idcrtc.c
+++ b/src/blueshift_idcrtc.c
@@ -65,6 +65,7 @@ int main(int argc, char** argv)
int screen_count;
xcb_screen_t* screens;
int screen_i;
+ int i;
(void) argc;
(void) argv;
@@ -238,7 +239,7 @@ int main(int argc, char** argv)
char* atom_data;
atom_cookie = xcb_randr_get_output_property(connection, outputs[output_i], *atoms,
- XCB_GET_PROPERTY_TYPE_ANY, 0, 0, 0, 0);
+ XCB_GET_PROPERTY_TYPE_ANY, 0, 128, 0, 0);
atom_reply = xcb_randr_get_output_property_reply(connection, atom_cookie, &error);
@@ -256,11 +257,15 @@ int main(int argc, char** argv)
atom_data_ = xcb_randr_get_output_property_data(atom_reply);
length = xcb_randr_get_output_property_data_length(atom_reply);
- atom_data = alloca((length + 1) * sizeof(char));
- memcpy(atom_data, atom_data_, length * sizeof(char));
- *(atom_data + length) = 0;
+ atom_data = alloca((2 * length + 1) * sizeof(char));
+ for (i = 0; i < length; i++)
+ {
+ *(atom_data + i * 2 + 0) = "0123456789abcdef"[(*(atom_data_ + i) >> 4) & 15];
+ *(atom_data + i * 2 + 1) = "0123456789abcdef"[(*(atom_data_ + i) >> 0) & 15];
+ }
+ *(atom_data + 2 * length) = 0;
- /* printf(" %s: %s\n", atom_name, atom_data); TODO */
+ printf(" %s: %s\n", atom_name, atom_data);
free(atom_reply);
}
diff --git a/src/monitor.py b/src/monitor.py
index 70a86e6..7e81d5a 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -267,6 +267,18 @@ class Screens:
rc += screen.find_by_connected(status)
return rc
+ def find_by_edid(self, edid):
+ '''
+ Find output by extended display identification data
+
+ @param edid:str? The extended display identification data of the monitor
+ @return :list<Output> Matching outputs
+ '''
+ rc = []
+ for screen in self.screens:
+ rc += screen.find_by_edid(edid)
+ return rc
+
def __contains__(self, other):
return other in self.screens
def __getitem__(self, index):
@@ -350,6 +362,19 @@ class Screen:
rc.append(self.outputs[i])
return rc
+ def find_by_edid(self, edid):
+ '''
+ Find output by extended display identification data
+
+ @param edid:str? The extended display identification data of the monitor
+ @return :list<Output> Matching outputs
+ '''
+ rc = []
+ for i in range(len(self.outputs)):
+ if self.outputs[i].edid == edid:
+ rc.append(self.outputs[i])
+ return rc
+
def __repr__(self):
'''
Return a string representation of the instance
@@ -366,6 +391,7 @@ class Output:
@variable heigthmm:int? The physical height of the monitor, measured in millimetres, `None` if unknown or not connected
@variable crtc:int? The CRTC index, `None` if not connected
@variable screen:int? The screen index, `None` if none
+ @variable edid:str? Extended display identification data, `None` if none
'''
def __init__(self):
'''
@@ -377,14 +403,15 @@ class Output:
self.heightmm = None
self.crtc = None
self.screen = None
+ self.edid = None
def __repr__(self):
'''
Return a string representation of the instance
'''
- rc = [self.name, self.connected, self.widthmm, self.heightmm, self.crtc, self.screen]
- rc = tuple([self.name] + list(map(lambda x : repr(x), rc[1:])))
- rc = '[Name: %s, Connected: %s, Width: %s, Height: %s, CRTC: %s, Screen: %s]' % rc
+ rc = [self.name, self.connected, self.widthmm, self.heightmm, self.crtc, self.screen, self.edid]
+ rc = tuple(rc[:1] + list(map(lambda x : repr(x), rc[1 : -1])) + [str(rc[-1])])
+ rc = '[Name: %s, Connected: %s, Width: %s, Height: %s, CRTC: %s, Screen: %s, EDID: %s]' % rc
return rc
def list_screens():
@@ -423,6 +450,8 @@ def list_screens():
output.widthmm, output.heightmm = None, None
elif line.startswith('CRTC: '):
output.crtc = int(line[len('CRTC: '):])
+ elif line.startswith('EDID: '):
+ output.edid = line[len('EDID: '):]
rc = Screens()
rc.screens = screens
return rc