From b4fbc31e109f1efe78613597f9a91d5363523493 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Sat, 21 Jun 2008 16:00:05 -0400 Subject: [PATCH] Actually fetch all blocks of EEDID if asked to. --- hw/xfree86/ddc/edid.h | 5 ++++- hw/xfree86/ddc/interpret_edid.c | 14 ++++++++++++++ hw/xfree86/ddc/xf86DDC.c | 32 ++++++++++++++++---------------- hw/xfree86/ddc/xf86DDC.h | 2 +- hw/xfree86/loader/xf86sym.c | 1 + 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/hw/xfree86/ddc/edid.h b/hw/xfree86/ddc/edid.h index a4e79dae0..45caf6ea9 100644 --- a/hw/xfree86/ddc/edid.h +++ b/hw/xfree86/ddc/edid.h @@ -531,6 +531,9 @@ struct detailed_monitor_section { } section; /* max: 80 */ }; +/* flags */ +#define EDID_COMPLETE_RAWDATA 0x1 + typedef struct { int scrnIndex; struct vendor vendor; @@ -539,7 +542,7 @@ typedef struct { struct established_timings timings1; struct std_timings timings2[8]; struct detailed_monitor_section det_mon[4]; - void *vdif; /* unused */ + unsigned long flags; int no_sections; Uchar *rawData; } xf86Monitor, *xf86MonPtr; diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c index b31969914..941fec2fd 100644 --- a/hw/xfree86/ddc/interpret_edid.c +++ b/hw/xfree86/ddc/interpret_edid.c @@ -118,6 +118,20 @@ xf86InterpretEDID(int scrnIndex, Uchar *block) return NULL; } +xf86MonPtr +xf86InterpretEEDID(int scrnIndex, Uchar *block) +{ + xf86MonPtr m; + + m = xf86InterpretEDID(scrnIndex, block); + if (!m) + return NULL; + + /* extension parse */ + + return m; +} + static void get_vendor_section(Uchar *c, struct vendor *r) { diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c index 8dda35ac4..0d8677637 100644 --- a/hw/xfree86/ddc/xf86DDC.c +++ b/hw/xfree86/ddc/xf86DDC.c @@ -197,21 +197,17 @@ DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer) * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are * unset. EDID information blocks are interpreted and the results returned in * an xf86MonPtr. Unlike xf86DoEDID_DDC[12](), this function will return - * the complete EDID data, including all extension blocks. + * the complete EDID data, including all extension blocks, if the 'complete' + * parameter is TRUE; * * This function does not affect the list of modes used by drivers -- it is up * to the driver to decide policy on what to do with EDID information. * * @return pointer to a new xf86MonPtr containing the EDID information. * @return NULL if no monitor attached or failure to interpret the EDID. - * - * nblocks is an in/out parameter. If non-zero, it defines the number of - * blocks to read from the monitor; zero (or NULL pointer) means read all. - * If non-NULL, on return it will be filled in with the number of blocks - * read. */ xf86MonPtr -xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, int *nblocks) +xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; unsigned char *EDID_block = NULL; @@ -242,15 +238,20 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, int *nblocks) return NULL; if (DDC2Read(dev, 0, EDID_block)) { - tmp = xf86InterpretEDID(scrnIndex, EDID_block); + int i, n = EDID_block[0x7e]; + + if (complete && n) { + EDID_block = xrealloc(EDID_block, EDID1_LEN * (1+n)); + + for (i = 0; i < n; i++) + DDC2Read(dev, i+1, EDID_block + (EDID1_LEN * (1+i))); + } + + tmp = xf86InterpretEEDID(scrnIndex, EDID_block); } - if (nblocks) { - if (tmp) - *nblocks = tmp->no_sections; - else - *nblocks = 0; - } + if (tmp && complete) + tmp->flags |= EDID_COMPLETE_RAWDATA; return tmp; } @@ -269,8 +270,7 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, int *nblocks) xf86MonPtr xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus) { - int nblocks = 1; - return xf86DoEEDID(scrnIndex, pBus, &nblocks); + return xf86DoEEDID(scrnIndex, pBus, FALSE); } /* diff --git a/hw/xfree86/ddc/xf86DDC.h b/hw/xfree86/ddc/xf86DDC.h index 6e5bf6f7a..8e1eaaca3 100644 --- a/hw/xfree86/ddc/xf86DDC.h +++ b/hw/xfree86/ddc/xf86DDC.h @@ -35,7 +35,7 @@ extern xf86MonPtr xf86DoEDID_DDC2( I2CBusPtr pBus ); -extern xf86MonPtr xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, int *nblocks); +extern xf86MonPtr xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool); extern xf86MonPtr xf86PrintEDID( xf86MonPtr monPtr diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 91ca4f71a..6576fe8e9 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -1007,6 +1007,7 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86DoEDID_DDC2) SYMFUNC(xf86InterpretEDID) SYMFUNC(xf86PrintEDID) + SYMFUNC(xf86DoEEDID) SYMFUNC(xf86DDCMonitorSet) SYMFUNC(xf86SetDDCproperties)