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"
35 #define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA"
38 edidMakeAtom(int i
, const char *name
, CARD8
*data
, int size
)
41 unsigned char *atom_data
;
43 if (!(atom_data
= malloc(size
* sizeof(CARD8
))))
46 atom
= MakeAtom(name
, strlen(name
), TRUE
);
47 memcpy(atom_data
, data
, size
);
48 xf86RegisterRootWindowProperty(i
, atom
, XA_INTEGER
, 8, size
, atom_data
);
52 addRootWindowProperties(ScrnInfoPtr pScrn
, xf86MonPtr DDC
)
54 int scrnIndex
= pScrn
->scrnIndex
;
56 if (DDC
->flags
& MONITOR_DISPLAYID
) {
57 /* Don't bother, use RANDR already */
60 else if (DDC
->ver
.version
== 1) {
62 (DDC
->flags
& EDID_COMPLETE_RAWDATA
? DDC
->no_sections
* 128 : 0);
64 edidMakeAtom(scrnIndex
, EDID1_ATOM_NAME
, DDC
->rawData
, size
);
67 xf86DrvMsg(scrnIndex
, X_PROBED
, "unexpected EDID version %d.%d\n",
68 DDC
->ver
.version
, DDC
->ver
.revision
);
74 xf86SetDDCproperties(ScrnInfoPtr pScrn
, xf86MonPtr DDC
)
76 if (!pScrn
|| !pScrn
->monitor
|| !DDC
)
79 if (DDC
->flags
& MONITOR_DISPLAYID
);
81 xf86EdidMonitorSet(pScrn
->scrnIndex
, pScrn
->monitor
, DDC
);
83 addRootWindowProperties(pScrn
, DDC
);