2 * Copyright 2006 Luc Verhaegen.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sub license,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #ifdef HAVE_XORG_CONFIG_H
25 #include <xorg-config.h>
30 #include <X11/Xatom.h>
32 #include "propertyst.h"
34 #include "xf86_ansic.h"
36 #define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA"
37 #define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA"
40 addRootWindowProperties(ScrnInfoPtr pScrn
, xf86MonPtr DDC
)
42 Atom EDID1Atom
=-1, EDID2Atom
=-1;
43 CARD8
*EDID1rawdata
= NULL
;
44 CARD8
*EDID2rawdata
= NULL
;
45 int i
, scrnIndex
= pScrn
->scrnIndex
;
46 Bool makeEDID1prop
= FALSE
;
47 Bool makeEDID2prop
= FALSE
;
49 if (DDC
->ver
.version
== 1) {
51 } else if (DDC
->ver
.version
== 2) {
56 /* Some monitors (eg Panasonic PanaSync4)
57 * report version==2 because they used EDID v2 spec document,
58 * although they use EDID v1 data structure :-(
60 * Try using checksum to determine when we have such a monitor.
63 for (i
= 0; i
< 256; i
++)
64 checksum2
+= DDC
->rawData
[i
];
65 if (checksum2
% 256) {
66 xf86DrvMsg(scrnIndex
, X_INFO
, "Monitor EDID v2 checksum failed\n");
67 xf86DrvMsg(scrnIndex
, X_INFO
,
68 "XFree86_DDC_EDID2_RAWDATA property may be bad\n");
70 for (i
= 0; i
< 128; i
++)
71 checksum1
+= DDC
->rawData
[i
];
72 if (!(checksum1
% 256)) {
73 xf86DrvMsg(scrnIndex
, X_INFO
,
74 "Monitor EDID v1 checksum passed,\n");
75 xf86DrvMsg(scrnIndex
, X_INFO
,
76 "XFree86_DDC_EDID1_RAWDATA property created\n");
81 xf86DrvMsg(scrnIndex
, X_PROBED
, "unexpected EDID version %d.%d\n",
82 DDC
->ver
.version
, DDC
->ver
.revision
);
87 if ((EDID1rawdata
= xalloc(128*sizeof(CARD8
)))==NULL
)
90 EDID1Atom
= MakeAtom(EDID1_ATOM_NAME
, sizeof(EDID1_ATOM_NAME
) - 1, TRUE
);
91 memcpy(EDID1rawdata
, DDC
->rawData
, 128);
92 xf86RegisterRootWindowProperty(scrnIndex
, EDID1Atom
, XA_INTEGER
, 8,
93 128, (unsigned char *)EDID1rawdata
);
97 if ((EDID2rawdata
= xalloc(256*sizeof(CARD8
)))==NULL
)
100 memcpy(EDID2rawdata
, DDC
->rawData
, 256);
101 EDID2Atom
= MakeAtom(EDID2_ATOM_NAME
, sizeof(EDID2_ATOM_NAME
) - 1, TRUE
);
102 xf86RegisterRootWindowProperty(scrnIndex
, EDID2Atom
, XA_INTEGER
, 8,
103 256, (unsigned char *)EDID2rawdata
);
108 xf86SetDDCproperties(ScrnInfoPtr pScrn
, xf86MonPtr DDC
)
110 if (!pScrn
|| !pScrn
->monitor
|| !DDC
)
113 xf86DDCMonitorSet(pScrn
->scrnIndex
, pScrn
->monitor
, DDC
);
115 addRootWindowProperties(pScrn
, DDC
);