summaryrefslogtreecommitdiff
path: root/hw/xfree86/ddc
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2009-06-09 10:10:18 -0400
committerAdam Jackson <ajax@redhat.com>2009-07-17 13:42:54 -0400
commitd0cb4f5a91932e901d10cac5f2a4ba12bb8a0e6f (patch)
tree8762ba29dc249dd22bc1ee26adc4f574c70d75d3 /hw/xfree86/ddc
parent14103b781201bc36896cbe9112a2e0d991fb785d (diff)
ddc: Refactor root window property code
Diffstat (limited to 'hw/xfree86/ddc')
-rw-r--r--hw/xfree86/ddc/ddcProperty.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c
index 66d734afe..834f695bb 100644
--- a/hw/xfree86/ddc/ddcProperty.c
+++ b/hw/xfree86/ddc/ddcProperty.c
@@ -31,16 +31,28 @@
#include "property.h"
#include "propertyst.h"
#include "xf86DDC.h"
+#include <string.h>
#define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA"
#define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA"
static void
+edidMakeAtom(int i, const char *name, CARD8 *data, int size)
+{
+ Atom atom;
+ unsigned char *atom_data;
+
+ if (!(atom_data = xalloc(size*sizeof(CARD8))))
+ return;
+
+ atom = MakeAtom(name, strlen(name), TRUE);
+ memcpy(atom_data, data, size);
+ xf86RegisterRootWindowProperty(i, atom, XA_INTEGER, 8, size, atom_data);
+}
+
+static void
addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
{
- Atom EDID1Atom=-1, EDID2Atom=-1;
- CARD8 *EDID1rawdata = NULL;
- CARD8 *EDID2rawdata = NULL;
int i, scrnIndex = pScrn->scrnIndex;
Bool makeEDID1prop = FALSE;
Bool makeEDID2prop = FALSE;
@@ -86,29 +98,14 @@ addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
}
if (makeEDID1prop) {
- int size = 128;
-
- if (DDC->flags & EDID_COMPLETE_RAWDATA)
- size += DDC->no_sections * 128;
-
- if ((EDID1rawdata = xalloc(size*sizeof(CARD8)))==NULL)
- return;
+ int size = 128 +
+ (DDC->flags & EDID_COMPLETE_RAWDATA ? DDC->no_sections * 128 : 0);
- EDID1Atom = MakeAtom(EDID1_ATOM_NAME, sizeof(EDID1_ATOM_NAME) - 1, TRUE);
- memcpy(EDID1rawdata, DDC->rawData, size);
- xf86RegisterRootWindowProperty(scrnIndex, EDID1Atom, XA_INTEGER, 8,
- size, (unsigned char *)EDID1rawdata);
+ edidMakeAtom(scrnIndex, EDID1_ATOM_NAME, DDC->rawData, size);
}
- if (makeEDID2prop) {
- if ((EDID2rawdata = xalloc(256*sizeof(CARD8)))==NULL)
- return;
-
- memcpy(EDID2rawdata, DDC->rawData, 256);
- EDID2Atom = MakeAtom(EDID2_ATOM_NAME, sizeof(EDID2_ATOM_NAME) - 1, TRUE);
- xf86RegisterRootWindowProperty(scrnIndex, EDID2Atom, XA_INTEGER, 8,
- 256, (unsigned char *)EDID2rawdata);
- }
+ if (makeEDID2prop)
+ edidMakeAtom(scrnIndex, EDID2_ATOM_NAME, DDC->rawData, 256);
}
Bool