ddc: Refactor root window property code
This commit is contained in:
		
							parent
							
								
									14103b7812
								
							
						
					
					
						commit
						d0cb4f5a91
					
				| 
						 | 
					@ -31,16 +31,28 @@
 | 
				
			||||||
#include "property.h"
 | 
					#include "property.h"
 | 
				
			||||||
#include "propertyst.h"
 | 
					#include "propertyst.h"
 | 
				
			||||||
#include "xf86DDC.h"
 | 
					#include "xf86DDC.h"
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define EDID1_ATOM_NAME         "XFree86_DDC_EDID1_RAWDATA"
 | 
					#define EDID1_ATOM_NAME         "XFree86_DDC_EDID1_RAWDATA"
 | 
				
			||||||
#define EDID2_ATOM_NAME         "XFree86_DDC_EDID2_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
 | 
					static void
 | 
				
			||||||
addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
 | 
					addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Atom EDID1Atom=-1, EDID2Atom=-1;
 | 
					 | 
				
			||||||
    CARD8 *EDID1rawdata = NULL;
 | 
					 | 
				
			||||||
    CARD8 *EDID2rawdata = NULL;
 | 
					 | 
				
			||||||
    int i, scrnIndex = pScrn->scrnIndex;
 | 
					    int i, scrnIndex = pScrn->scrnIndex;
 | 
				
			||||||
    Bool makeEDID1prop = FALSE;
 | 
					    Bool makeEDID1prop = FALSE;
 | 
				
			||||||
    Bool makeEDID2prop = FALSE;
 | 
					    Bool makeEDID2prop = FALSE;
 | 
				
			||||||
| 
						 | 
					@ -86,29 +98,14 @@ addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (makeEDID1prop) {
 | 
					    if (makeEDID1prop) {
 | 
				
			||||||
	int size = 128;
 | 
						int size = 128 +
 | 
				
			||||||
 | 
						    (DDC->flags & EDID_COMPLETE_RAWDATA ? DDC->no_sections * 128 : 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (DDC->flags & EDID_COMPLETE_RAWDATA)
 | 
						edidMakeAtom(scrnIndex, EDID1_ATOM_NAME, DDC->rawData, size);
 | 
				
			||||||
	    size += DDC->no_sections * 128;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((EDID1rawdata = xalloc(size*sizeof(CARD8)))==NULL)
 | 
					 | 
				
			||||||
	    return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	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);
 | 
					 | 
				
			||||||
    } 
 | 
					    } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (makeEDID2prop) {
 | 
					    if (makeEDID2prop)
 | 
				
			||||||
	if ((EDID2rawdata = xalloc(256*sizeof(CARD8)))==NULL)
 | 
						edidMakeAtom(scrnIndex, EDID2_ATOM_NAME, DDC->rawData, 256);
 | 
				
			||||||
	    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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Bool
 | 
					Bool
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue