From ace0fe09aee48d57cd0079260cd8d20d041e8eb6 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 8 Jun 2009 14:45:47 -0400 Subject: [PATCH] ddc: Yet more code motion --- hw/xfree86/ddc/Makefile.am | 5 +- hw/xfree86/ddc/ddcPriv.h | 9 --- hw/xfree86/ddc/edid.c | 140 ------------------------------------- hw/xfree86/ddc/xf86DDC.c | 121 +++++++++++++++++++++++++++++++- 4 files changed, 122 insertions(+), 153 deletions(-) delete mode 100644 hw/xfree86/ddc/ddcPriv.h delete mode 100644 hw/xfree86/ddc/edid.c diff --git a/hw/xfree86/ddc/Makefile.am b/hw/xfree86/ddc/Makefile.am index d32e2f4ab..8ffe43377 100644 --- a/hw/xfree86/ddc/Makefile.am +++ b/hw/xfree86/ddc/Makefile.am @@ -2,11 +2,10 @@ sdk_HEADERS = edid.h xf86DDC.h noinst_LTLIBRARIES = libddc.la -libddc_la_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \ - ddcProperty.c +libddc_la_SOURCES = xf86DDC.c interpret_edid.c print_edid.c ddcProperty.c INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) -EXTRA_DIST = ddcPriv.h DDC.HOWTO +EXTRA_DIST = DDC.HOWTO diff --git a/hw/xfree86/ddc/ddcPriv.h b/hw/xfree86/ddc/ddcPriv.h deleted file mode 100644 index b5cb9b836..000000000 --- a/hw/xfree86/ddc/ddcPriv.h +++ /dev/null @@ -1,9 +0,0 @@ -extern unsigned char *GetEDID_DDC1( - unsigned int * -); - -extern int DDC_checksum( - unsigned char *, - int -); - diff --git a/hw/xfree86/ddc/edid.c b/hw/xfree86/ddc/edid.c deleted file mode 100644 index 3ebafbbba..000000000 --- a/hw/xfree86/ddc/edid.c +++ /dev/null @@ -1,140 +0,0 @@ - -/* edid.c: retrieve EDID record from raw DDC1 data stream: data - * is contained in an array of unsigned int each unsigned int - * contains one bit if bit is 0 unsigned int has to be zero else - * unsigned int > 0 - * - * Copyright 1998 by Egbert Eich - */ -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86DDC.h" -#include "ddcPriv.h" -#include - -static int find_start(unsigned int *); -static unsigned char * find_header(unsigned char *); -static unsigned char * resort(unsigned char *); - -unsigned char * -GetEDID_DDC1(unsigned int *s_ptr) -{ - unsigned char *d_block, *d_pos; - unsigned int *s_pos, *s_end; - int s_start; - int i,j; - s_start = find_start(s_ptr); - if (s_start==-1) return NULL; - s_end = s_ptr + NUM; - s_pos = s_ptr + s_start; - d_block=xalloc(EDID1_LEN); - if (!d_block) return NULL; - d_pos = d_block; - for (i=0;i #define RETRIES 4 @@ -36,6 +35,124 @@ static const OptionInfoRec DDCOptions[] = { { -1, NULL, OPTV_NONE, {0}, FALSE }, }; +/* DDC1 */ + +static int +find_start(unsigned int *ptr) +{ + unsigned int comp[9], test[9]; + int i,j; + + for (i=0;i<9;i++){ + comp[i] = *(ptr++); + test[i] = 1; + } + for (i=0;i<127;i++){ + for (j=0;j<9;j++){ + test[j] = test[j] & !(comp[j] ^ *(ptr++)); + } + } + for (i=0;i<9;i++) + if (test[i]) return (i+1); + return (-1); +} + +static unsigned char * +find_header(unsigned char *block) +{ + unsigned char *ptr, *head_ptr, *end; + unsigned char header[]={0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}; + + ptr = block; + end = block + EDID1_LEN; + while (ptr