aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/ddc/ddc.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
committermarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
commit76bcc36ed305418a3ddc5752d287ede894243e1b (patch)
treebacb320c825768471ce56f058f17ce863d592376 /xorg-server/hw/xfree86/ddc/ddc.c
parent7d894e32566b710952c44cbc71939ad1d9e2fa8d (diff)
parent0f834b91a4768673833ab4917e87d86c237bb1a6 (diff)
downloadvcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.gz
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.bz2
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.zip
Merge remote-tracking branch 'origin/released'
Conflicts: pixman/pixman/pixman-mmx.c xorg-server/Xext/shm.c xorg-server/Xext/syncsrv.h xorg-server/Xext/xvmain.c xorg-server/Xi/exevents.c xorg-server/Xi/opendev.c xorg-server/composite/compalloc.c xorg-server/composite/compoverlay.c xorg-server/dix/colormap.c xorg-server/dix/devices.c xorg-server/dix/dispatch.c xorg-server/dix/dixfonts.c xorg-server/dix/eventconvert.c xorg-server/dix/events.c xorg-server/dix/gc.c xorg-server/dix/getevents.c xorg-server/dix/main.c xorg-server/dix/privates.c xorg-server/dix/registry.c xorg-server/dix/resource.c xorg-server/exa/exa_accel.c xorg-server/exa/exa_migration_classic.c xorg-server/exa/exa_unaccel.c xorg-server/fb/fb.h xorg-server/fb/fbcopy.c xorg-server/fb/fbpixmap.c xorg-server/glx/dispatch.h xorg-server/glx/glapi.h xorg-server/glx/glapi_gentable.c xorg-server/glx/glapitable.h xorg-server/glx/glprocs.h xorg-server/glx/glxcmds.c xorg-server/glx/glxcmdsswap.c xorg-server/glx/glxdricommon.c xorg-server/glx/glxdriswrast.c xorg-server/glx/glxext.c xorg-server/glx/indirect_dispatch.c xorg-server/glx/indirect_dispatch.h xorg-server/glx/indirect_dispatch_swap.c xorg-server/glx/indirect_size.h xorg-server/glx/indirect_size_get.h xorg-server/glx/indirect_table.c xorg-server/glx/indirect_util.c xorg-server/glx/rensize.c xorg-server/glx/single2swap.c xorg-server/glx/singlepix.c xorg-server/glx/singlepixswap.c xorg-server/glx/singlesize.c xorg-server/hw/dmx/dmxinit.c xorg-server/hw/kdrive/ephyr/ephyr.c xorg-server/hw/kdrive/ephyr/hostx.c xorg-server/hw/kdrive/ephyr/hostx.h xorg-server/hw/kdrive/src/kinput.c xorg-server/hw/xfree86/common/compiler.h xorg-server/hw/xwin/InitInput.c xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/ddraw.h xorg-server/hw/xwin/glx/glwrap.c xorg-server/hw/xwin/glx/indirect.c xorg-server/hw/xwin/glx/wgl_ext_api.h xorg-server/hw/xwin/glx/winpriv.c xorg-server/hw/xwin/win.h xorg-server/hw/xwin/winallpriv.c xorg-server/hw/xwin/winauth.c xorg-server/hw/xwin/winclipboard.h xorg-server/hw/xwin/winclipboardinit.c xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardunicode.c xorg-server/hw/xwin/winclipboardwndproc.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winclipboardxevents.c xorg-server/hw/xwin/wincmap.c xorg-server/hw/xwin/winconfig.c xorg-server/hw/xwin/wincreatewnd.c xorg-server/hw/xwin/wincursor.c xorg-server/hw/xwin/windialogs.c xorg-server/hw/xwin/winengine.c xorg-server/hw/xwin/winerror.c xorg-server/hw/xwin/wingc.c xorg-server/hw/xwin/wingetsp.c xorg-server/hw/xwin/winkeybd.c xorg-server/hw/xwin/winkeybd.h xorg-server/hw/xwin/winlayouts.h xorg-server/hw/xwin/winmisc.c xorg-server/hw/xwin/winmonitors.c xorg-server/hw/xwin/winmouse.c xorg-server/hw/xwin/winmsg.c xorg-server/hw/xwin/winmsg.h xorg-server/hw/xwin/winmultiwindowclass.c xorg-server/hw/xwin/winmultiwindowicons.c xorg-server/hw/xwin/winmultiwindowshape.c xorg-server/hw/xwin/winmultiwindowwindow.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winmultiwindowwndproc.c xorg-server/hw/xwin/winnativegdi.c xorg-server/hw/xwin/winpfbdd.c xorg-server/hw/xwin/winpixmap.c xorg-server/hw/xwin/winpolyline.c xorg-server/hw/xwin/winprefs.c xorg-server/hw/xwin/winprocarg.c xorg-server/hw/xwin/winregistry.c xorg-server/hw/xwin/winscrinit.c xorg-server/hw/xwin/winsetsp.c xorg-server/hw/xwin/winshaddd.c xorg-server/hw/xwin/winshadddnl.c xorg-server/hw/xwin/winshadgdi.c xorg-server/hw/xwin/wintrayicon.c xorg-server/hw/xwin/winwin32rootless.c xorg-server/hw/xwin/winwin32rootlesswindow.c xorg-server/hw/xwin/winwin32rootlesswndproc.c xorg-server/hw/xwin/winwindow.c xorg-server/hw/xwin/winwindow.h xorg-server/hw/xwin/winwindowswm.c xorg-server/hw/xwin/winwndproc.c xorg-server/include/callback.h xorg-server/include/dixstruct.h xorg-server/include/misc.h xorg-server/include/os.h xorg-server/include/scrnintstr.h xorg-server/mi/micmap.c xorg-server/mi/miinitext.c xorg-server/mi/mioverlay.c xorg-server/mi/misprite.c xorg-server/mi/mivaltree.c xorg-server/mi/miwindow.c xorg-server/miext/damage/damage.c xorg-server/miext/rootless/rootlessGC.c xorg-server/miext/rootless/rootlessWindow.c xorg-server/os/WaitFor.c xorg-server/os/access.c xorg-server/os/connection.c xorg-server/os/io.c xorg-server/os/log.c xorg-server/os/osinit.c xorg-server/os/utils.c xorg-server/os/xdmcp.c xorg-server/os/xprintf.c xorg-server/os/xstrans.c xorg-server/render/mipict.c xorg-server/xkb/xkbActions.c xorg-server/xkb/xkbInit.c xorg-server/xkeyboard-config/compat/default.in
Diffstat (limited to 'xorg-server/hw/xfree86/ddc/ddc.c')
-rw-r--r--xorg-server/hw/xfree86/ddc/ddc.c351
1 files changed, 189 insertions, 162 deletions
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c
index 179f42ccd..a1281d735 100644
--- a/xorg-server/hw/xfree86/ddc/ddc.c
+++ b/xorg-server/hw/xfree86/ddc/ddc.c
@@ -29,10 +29,10 @@ typedef enum {
} DDCOpts;
static const OptionInfoRec DDCOptions[] = {
- { DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE },
- { DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE },
- { DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE },
+ {DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE},
+ {DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE},
+ {DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE},
+ {-1, NULL, OPTV_NONE, {0}, FALSE},
};
/* DDC1 */
@@ -41,19 +41,20 @@ 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;
+ 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 < 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;
+ for (i = 0; i < 9; i++)
+ if (test[i])
+ return i + 1;
return -1;
}
@@ -61,21 +62,26 @@ 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};
-
+ unsigned char header[] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 };
+
ptr = block;
end = block + EDID1_LEN;
- while (ptr<end) {
- int i;
- head_ptr = ptr;
- for (i=0;i<8;i++){
- if (header[i] != *(head_ptr++)) break;
- if (head_ptr == end) head_ptr = block;
- }
- if (i==8) break;
- ptr++;
+ while (ptr < end) {
+ int i;
+
+ head_ptr = ptr;
+ for (i = 0; i < 8; i++) {
+ if (header[i] != *(head_ptr++))
+ break;
+ if (head_ptr == end)
+ head_ptr = block;
+ }
+ if (i == 8)
+ break;
+ ptr++;
}
- if (ptr == end) return NULL;
+ if (ptr == end)
+ return NULL;
return ptr;
}
@@ -87,15 +93,18 @@ resort(unsigned char *s_block)
s_end = s_block + EDID1_LEN;
d_new = malloc(EDID1_LEN);
- if (!d_new) return NULL;
+ if (!d_new)
+ return NULL;
d_end = d_new + EDID1_LEN;
s_ptr = find_header(s_block);
- if (!s_ptr) return NULL;
- for (d_ptr=d_new;d_ptr<d_end;d_ptr++){
- tmp = *(s_ptr++);
- *d_ptr = tmp;
- if (s_ptr == s_end) s_ptr = s_block;
+ if (!s_ptr)
+ return NULL;
+ for (d_ptr = d_new; d_ptr < d_end; d_ptr++) {
+ tmp = *(s_ptr++);
+ *d_ptr = tmp;
+ if (s_ptr == s_end)
+ s_ptr = s_block;
}
free(s_block);
return d_new;
@@ -106,21 +115,24 @@ DDC_checksum(const unsigned char *block, int len)
{
int i, result = 0;
int not_null = 0;
-
- for (i=0;i<len;i++) {
- not_null |= block[i];
- result += block[i];
+
+ for (i = 0; i < len; i++) {
+ not_null |= block[i];
+ result += block[i];
}
-
+
#ifdef DEBUG
- if (result & 0xFF) ErrorF("DDC checksum not correct\n");
- if (!not_null) ErrorF("DDC read all Null\n");
+ if (result & 0xFF)
+ ErrorF("DDC checksum not correct\n");
+ if (!not_null)
+ ErrorF("DDC read all Null\n");
#endif
/* catch the trivial case where all bytes are 0 */
- if (!not_null) return 1;
+ if (!not_null)
+ return 1;
- return result&0xFF;
+ return result & 0xFF;
}
static unsigned char *
@@ -129,64 +141,73 @@ GetEDID_DDC1(unsigned int *s_ptr)
unsigned char *d_block, *d_pos;
unsigned int *s_pos, *s_end;
int s_start;
- int i,j;
+ int i, j;
+
s_start = find_start(s_ptr);
- if (s_start==-1) return NULL;
+ if (s_start == -1)
+ return NULL;
s_end = s_ptr + NUM;
s_pos = s_ptr + s_start;
- d_block=malloc(EDID1_LEN);
- if (!d_block) return NULL;
+ d_block = malloc(EDID1_LEN);
+ if (!d_block)
+ return NULL;
d_pos = d_block;
- for (i=0;i<EDID1_LEN;i++) {
- for (j=0;j<8;j++) {
- *d_pos <<= 1;
- if (*s_pos) {
- *d_pos |= 0x01;
- }
- s_pos++; if (s_pos == s_end) s_pos=s_ptr;
- };
- s_pos++; if (s_pos == s_end) s_pos=s_ptr;
- d_pos++;
+ for (i = 0; i < EDID1_LEN; i++) {
+ for (j = 0; j < 8; j++) {
+ *d_pos <<= 1;
+ if (*s_pos) {
+ *d_pos |= 0x01;
+ }
+ s_pos++;
+ if (s_pos == s_end)
+ s_pos = s_ptr;
+ };
+ s_pos++;
+ if (s_pos == s_end)
+ s_pos = s_ptr;
+ d_pos++;
}
free(s_ptr);
- if (d_block && DDC_checksum(d_block,EDID1_LEN)) {
- free(d_block);
- return NULL;
+ if (d_block && DDC_checksum(d_block, EDID1_LEN)) {
+ free(d_block);
+ return NULL;
}
return (resort(d_block));
}
/* fetch entire EDID record; DDC bit needs to be masked */
-static unsigned int *
+static unsigned int *
FetchEDID_DDC1(register ScrnInfoPtr pScrn,
- register unsigned int (*read_DDC)(ScrnInfoPtr))
+ register unsigned int (*read_DDC) (ScrnInfoPtr))
{
int count = NUM;
unsigned int *ptr, *xp;
- ptr=xp=malloc(sizeof(int)*NUM);
+ ptr = xp = malloc(sizeof(int) * NUM);
- if (!ptr) return NULL;
+ if (!ptr)
+ return NULL;
do {
- /* wait for next retrace */
- *xp = read_DDC(pScrn);
- xp++;
- } while(--count);
+ /* wait for next retrace */
+ *xp = read_DDC(pScrn);
+ xp++;
+ } while (--count);
return ptr;
}
/* test if DDC1 return 0 if not */
static Bool
-TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr))
+TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC) (ScrnInfoPtr))
{
int old, count;
old = read_DDC(pScrn);
count = HEADER * BITS_PER_BYTE;
do {
- /* wait for next retrace */
- if (old != read_DDC(pScrn)) break;
- } while(count--);
+ /* wait for next retrace */
+ if (old != read_DDC(pScrn))
+ break;
+ } while (count--);
return count;
}
@@ -196,29 +217,31 @@ TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr))
* function; it will also decide if we need to reread it
*/
static unsigned char *
-EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
- unsigned int (*read_DDC)(ScrnInfoPtr))
+EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
+ unsigned int (*read_DDC) (ScrnInfoPtr))
{
unsigned char *EDID_block = NULL;
int count = RETRIES;
- if (!read_DDC) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "chipset doesn't support DDC1\n");
- return NULL;
+ if (!read_DDC) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "chipset doesn't support DDC1\n");
+ return NULL;
};
- if (TestDDC1(pScrn,read_DDC)==-1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n");
- return NULL;
+ if (TestDDC1(pScrn, read_DDC) == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n");
+ return NULL;
};
- if (DDCSpeed) DDCSpeed(pScrn,DDC_FAST);
+ if (DDCSpeed)
+ DDCSpeed(pScrn, DDC_FAST);
do {
- EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn,read_DDC));
- count --;
+ EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn, read_DDC));
+ count--;
} while (!EDID_block && count);
- if (DDCSpeed) DDCSpeed(pScrn,DDC_SLOW);
+ if (DDCSpeed)
+ DDCSpeed(pScrn, DDC_SLOW);
return EDID_block;
}
@@ -235,40 +258,42 @@ EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
* @return NULL if no monitor attached or failure to interpret the EDID.
*/
xf86MonPtr
-xf86DoEDID_DDC1(int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
- unsigned int (*DDC1Read)(ScrnInfoPtr))
+xf86DoEDID_DDC1(int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
+ unsigned int (*DDC1Read) (ScrnInfoPtr))
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
unsigned char *EDID_block = NULL;
xf86MonPtr tmp = NULL;
+
/* Default DDC and DDC1 to enabled. */
Bool noddc = FALSE, noddc1 = FALSE;
OptionInfoPtr options;
options = xnfalloc(sizeof(DDCOptions));
- (void)memcpy(options, DDCOptions, sizeof(DDCOptions));
+ (void) memcpy(options, DDCOptions, sizeof(DDCOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
free(options);
-
+
if (noddc || noddc1)
- return NULL;
-
+ return NULL;
+
OsBlockSignals();
- EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read);
+ EDID_block = EDIDRead_DDC1(pScrn, DDC1SetSpeed, DDC1Read);
OsReleaseSignals();
- if (EDID_block){
- tmp = xf86InterpretEDID(scrnIndex,EDID_block);
+ if (EDID_block) {
+ tmp = xf86InterpretEDID(scrnIndex, EDID_block);
}
#ifdef DEBUG
- else ErrorF("No EDID block returned\n");
+ else
+ ErrorF("No EDID block returned\n");
if (!tmp)
- ErrorF("Cannot interpret EDID block\n");
+ ErrorF("Cannot interpret EDID block\n");
#endif
- return tmp;
+ return tmp;
}
/* DDC2 */
@@ -279,19 +304,19 @@ DDC2MakeDevice(I2CBusPtr pBus, int address, char *name)
I2CDevPtr dev = NULL;
if (!(dev = xf86I2CFindDev(pBus, address))) {
- dev = xf86CreateI2CDevRec();
- dev->DevName = name;
- dev->SlaveAddr = address;
- dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
- dev->StartTimeout = 550;
- dev->BitTimeout = 40;
- dev->AcknTimeout = 40;
-
- dev->pI2CBus = pBus;
- if (!xf86I2CDevInit(dev)) {
- xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n");
- return NULL;
- }
+ dev = xf86CreateI2CDevRec();
+ dev->DevName = name;
+ dev->SlaveAddr = address;
+ dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
+ dev->StartTimeout = 550;
+ dev->BitTimeout = 40;
+ dev->AcknTimeout = 40;
+
+ dev->pI2CBus = pBus;
+ if (!xf86I2CDevInit(dev)) {
+ xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n");
+ return NULL;
+ }
}
return dev;
@@ -307,10 +332,10 @@ DDC2Init(int scrnIndex, I2CBusPtr pBus)
* miss things.
*/
pBus->RiseFallTime = 20;
-
+
dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2");
if (xf86I2CProbeAddress(pBus, 0x0060))
- DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
+ DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
return dev;
}
@@ -328,39 +353,39 @@ DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer)
unsigned char W_Buffer[1];
int i, segment;
I2CDevPtr seg;
- void (*stop)(I2CDevPtr);
+ void (*stop) (I2CDevPtr);
for (i = 0; i < RETRIES; i++) {
- /* Stop bits reset the segment pointer to 0, so be careful here. */
- segment = block >> 1;
- if (segment) {
- Bool b;
-
- if (!(seg = xf86I2CFindDev(dev->pI2CBus, 0x0060)))
- return FALSE;
-
- W_Buffer[0] = segment;
-
- stop = dev->pI2CBus->I2CStop;
- dev->pI2CBus->I2CStop = EEDIDStop;
-
- b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
-
- dev->pI2CBus->I2CStop = stop;
- if (!b) {
- dev->pI2CBus->I2CStop(dev);
- continue;
- }
- }
-
- W_Buffer[0] = (block & 0x01) * EDID1_LEN;
-
- if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) {
- if (!DDC_checksum(R_Buffer, EDID1_LEN))
- return TRUE;
- }
+ /* Stop bits reset the segment pointer to 0, so be careful here. */
+ segment = block >> 1;
+ if (segment) {
+ Bool b;
+
+ if (!(seg = xf86I2CFindDev(dev->pI2CBus, 0x0060)))
+ return FALSE;
+
+ W_Buffer[0] = segment;
+
+ stop = dev->pI2CBus->I2CStop;
+ dev->pI2CBus->I2CStop = EEDIDStop;
+
+ b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
+
+ dev->pI2CBus->I2CStop = stop;
+ if (!b) {
+ dev->pI2CBus->I2CStop(dev);
+ continue;
+ }
+ }
+
+ W_Buffer[0] = (block & 0x01) * EDID1_LEN;
+
+ if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) {
+ if (!DDC_checksum(R_Buffer, EDID1_LEN))
+ return TRUE;
+ }
}
-
+
return FALSE;
}
@@ -384,13 +409,14 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
unsigned char *EDID_block = NULL;
xf86MonPtr tmp = NULL;
I2CDevPtr dev = NULL;
+
/* Default DDC and DDC2 to enabled. */
Bool noddc = FALSE, noddc2 = FALSE;
OptionInfoPtr options;
options = malloc(sizeof(DDCOptions));
if (!options)
- return NULL;
+ return NULL;
memcpy(options, DDCOptions, sizeof(DDCOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
@@ -399,30 +425,30 @@ xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
free(options);
if (noddc || noddc2)
- return NULL;
+ return NULL;
if (!(dev = DDC2Init(scrnIndex, pBus)))
- return NULL;
+ return NULL;
EDID_block = calloc(1, EDID1_LEN);
if (!EDID_block)
- return NULL;
+ return NULL;
if (DDC2Read(dev, 0, EDID_block)) {
- int i, n = EDID_block[0x7e];
+ int i, n = EDID_block[0x7e];
- if (complete && n) {
- EDID_block = realloc(EDID_block, EDID1_LEN * (1+n));
+ if (complete && n) {
+ EDID_block = realloc(EDID_block, EDID1_LEN * (1 + n));
- for (i = 0; i < n; i++)
- DDC2Read(dev, i+1, EDID_block + (EDID1_LEN * (1+i)));
- }
+ for (i = 0; i < n; i++)
+ DDC2Read(dev, i + 1, EDID_block + (EDID1_LEN * (1 + i)));
+ }
- tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
+ tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
}
if (tmp && complete)
- tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
+ tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
return tmp;
}
@@ -469,13 +495,14 @@ xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
unsigned char *did = NULL;
xf86MonPtr tmp = NULL;
I2CDevPtr dev = NULL;
+
/* Default DDC and DDC2 to enabled. */
Bool noddc = FALSE, noddc2 = FALSE;
OptionInfoPtr options;
options = malloc(sizeof(DDCOptions));
if (!options)
- return NULL;
+ return NULL;
memcpy(options, DDCOptions, sizeof(DDCOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
@@ -484,19 +511,19 @@ xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
free(options);
if (noddc || noddc2)
- return NULL;
+ return NULL;
if (!(dev = DDC2Init(scrnIndex, pBus)))
- return NULL;
+ return NULL;
if ((did = DDC2ReadDisplayID())) {
- tmp = calloc(1, sizeof(*tmp));
- if (!tmp)
- return NULL;
+ tmp = calloc(1, sizeof(*tmp));
+ if (!tmp)
+ return NULL;
- tmp->scrnIndex = scrnIndex;
- tmp->flags |= MONITOR_DISPLAYID;
- tmp->rawData = did;
+ tmp->scrnIndex = scrnIndex;
+ tmp->flags |= MONITOR_DISPLAYID;
+ tmp->rawData = did;
}
return tmp;