[argyllcms] Fix for loading dual monitor profiles with dispwin

  • From: corvus@xxxxxxx (James E. Blair)
  • To: argyllcms@xxxxxxxxxxxxx
  • Date: Mon, 02 Apr 2012 18:26:18 -0700

Hi,

I have a dual-monitor setup, and noticed that when I apply saved
profiles with dispwin, it works on monitor #2 but fails on #1 with
this error:

----------------------------------------------------------------------
Dispwin: Error - Failed to get the displays current ICC profile
----------------------------------------------------------------------

The full output from runs for both monitors is:

----------------------------------------------------------------------
corvus@fuligin:/nfs/home/corvus$ dispwin -v -d1 -c -L
About to open dispwin object on the display
About to clear the calibration
Dispwin: Error - Failed to get the displays current ICC profile

corvus@fuligin:/nfs/home/corvus$ dispwin -v -d2 -c -L
About to open dispwin object on the display
About to clear the calibration
About to set display to given calibration
Calibration set
About to destroy dispwin object
----------------------------------------------------------------------

And the contents of ~/.config/color.jcnf are:

----------------------------------------------------------------------
{
  "devices": {
    "display": {
      "1": {
        "EDID": 
"0x00FFFFFFFFFFFF004C2D0F0139314A4D140E010380261E782AEE95A3544C99260F5054BFEF808180714F010101010101010101010101302A009851002A4030701300782D1100001E000000FD00384B1E510E000A202020202020000000FC0053796E634D61737465720A2020000000FF00484348583531303039380A202000C8",
        "ICC_PROFILE": 
"/home/corvus/.local/share/color/icc/devices/display/Screen 1 2012-02-18 max 
native min native sRGB HQ 3xCurve+MTX.icc"
      },
      "2": {
        "EDID": 
"0x00FFFFFFFFFFFF004C2D0F0139314A4D1F0E010380261E782AEE95A3544C99260F5054BFEF808180714F010101010101010101010101302A009851002A4030701300782D1100001E000000FD00384B1E510E000A202020202020000000FC0053796E634D61737465720A2020000000FF0048434A583732333231380A202000BB",
        "ICC_PROFILE": 
"/home/corvus/.local/share/color/icc/devices/display/Screen 2 2012-02-18 max 
native min native sRGB HQ 3xCurve+MTX.icc"
      }
    }
  }
}
----------------------------------------------------------------------

Both of the EDIDs are correct, and the ICC files exist at those paths.
I recompiled with debugging on:

----------------------------------------------------------------------
corvus@fuligin:/tmp/Argyll_V1.3.7$ ./spectro/dispwin -v -d1 -c -L
About to open dispwin object on the display
About to clear the calibration
ucmm_get_monitor_profile called edid 0xe510a6e7, disp ':0.0'
Searching for EDID = 
'0x00FFFFFFFFFFFF004C2D0F0139314A4D140E010380261E782AEE95A3544C99260F5054BFEF808180714F010101010101010101010101302A009851002A4030701300782D1100001E000000FD00384B1E510E000A202020202020000000FC0053796E634D61737465720A2020000000FF00484348583531303039380A202000C8'
Looking up record 1 key 'devices/display/1/ICC_PROFILE'
jcnf locate/get_key failed with error 16
Searching for EDID = 
'0x00FFFFFFFFFFFF004C2D0F0139314A4D140E010380261E782AEE95A3544C99260F5054BFEF808180714F010101010101010101010101302A009851002A4030701300782D1100001E000000FD00384B1E510E000A202020202020000000FC0053796E634D61737465720A2020000000FF00484348583531303039380A202000C8'
Looking up record 1 key 'devices/display/1/ICC_PROFILE'
jcnf locate/get_key failed with error 16
Failed to find a current profile
Dispwin: Error - Failed to get the displays current ICC profile

corvus@fuligin:/tmp/Argyll_V1.3.7$ ./spectro/dispwin -v -d2 -c -L
About to open dispwin object on the display
About to clear the calibration
ucmm_get_monitor_profile called edid 0x22980f5, disp ':0.0'
Searching for EDID = 
'0x00FFFFFFFFFFFF004C2D0F0139314A4D1F0E010380261E782AEE95A3544C99260F5054BFEF808180714F010101010101010101010101302A009851002A4030701300782D1100001E000000FD00384B1E510E000A202020202020000000FC0053796E634D61737465720A2020000000FF0048434A583732333231380A202000BB'
Looking up record 2 key 'devices/display/2/ICC_PROFILE'
About to set display to given calibration
Calibration set
About to destroy dispwin object
----------------------------------------------------------------------

Which lead me to jcnf.c.  It looks like in jcnf_locate_key, when ix
was -1 (to indicate a search), it would always set the start of the
search to nkeys-1, which explains why the second monitor works but not
the first.  Since jcnf_locate_key can be called to search both
backwards and forwards, I think it needs to initialize the start index
accordingly.  The attached patch sets ix to 0 if it's called to do a
forward search, and the current behavior for a backward search.  After
making that change, it seems to have solved the initial problem:

----------------------------------------------------------------------
corvus@fuligin:/tmp/Argyll_V1.3.7$ ./spectro/dispwin -v -d1 -c -L
About to open dispwin object on the display
About to clear the calibration
ucmm_get_monitor_profile called edid 0xe510a6e7, disp ':0.0'
Searching for EDID = 
'0x00FFFFFFFFFFFF004C2D0F0139314A4D140E010380261E782AEE95A3544C99260F5054BFEF808180714F010101010101010101010101302A009851002A4030701300782D1100001E000000FD00384B1E510E000A202020202020000000FC0053796E634D61737465720A2020000000FF00484348583531303039380A202000C8'
Looking up record 1 key 'devices/display/1/ICC_PROFILE'
About to set display to given calibration
Calibration set
About to destroy dispwin object

corvus@fuligin:/tmp/Argyll_V1.3.7$ ./spectro/dispwin -v -d2 -c -L
About to open dispwin object on the display
About to clear the calibration
ucmm_get_monitor_profile called edid 0x22980f5, disp ':0.0'
Searching for EDID = 
'0x00FFFFFFFFFFFF004C2D0F0139314A4D1F0E010380261E782AEE95A3544C99260F5054BFEF808180714F010101010101010101010101302A009851002A4030701300782D1100001E000000FD00384B1E510E000A202020202020000000FC0053796E634D61737465720A2020000000FF0048434A583732333231380A202000BB'
Looking up record 2 key 'devices/display/2/ICC_PROFILE'
About to set display to given calibration
Calibration set
About to destroy dispwin object
----------------------------------------------------------------------

Thanks.
--- Argyll_V1.3.7-orig/jcnf/jcnf.c      2012-03-25 22:20:59.000000000 -0700
+++ Argyll_V1.3.7/jcnf/jcnf.c   2012-04-02 17:55:28.000000000 -0700
@@ -261,9 +261,12 @@
        int ix = *pix;
        int sl;
 
-       if (ix == -1)
+       if (ix == -1 && bwd)
                ix = p->nkeys-1;
 
+       if (ix == -1 && ! bwd)
+               ix = 0;
+
        if (ix < 0 || ix >= p->nkeys)
                return jc_ix_oorange;
 

Other related posts: