2003-11-14 17:48:57 +01:00
|
|
|
/* xf86DDC.c
|
|
|
|
*
|
|
|
|
* Copyright 1998,1999 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
|
|
|
|
*/
|
2007-12-03 21:47:39 +01:00
|
|
|
|
|
|
|
/*
|
2009-06-08 20:30:53 +02:00
|
|
|
* A note on terminology. DDC1 is the original dumb serial protocol, and
|
|
|
|
* can only do up to 128 bytes of EDID. DDC2 is I2C-encapsulated and
|
|
|
|
* introduces extension blocks. EDID is the old display identification
|
|
|
|
* block, DisplayID is the new one.
|
2007-12-03 21:47:39 +01:00
|
|
|
*/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86_OSproc.h"
|
|
|
|
#include "xf86DDC.h"
|
2006-02-10 23:00:30 +01:00
|
|
|
#include <string.h>
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
#define RETRIES 4
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
DDCOPT_NODDC1,
|
|
|
|
DDCOPT_NODDC2,
|
|
|
|
DDCOPT_NODDC
|
|
|
|
} 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 },
|
|
|
|
};
|
|
|
|
|
2009-06-08 20:45:47 +02:00
|
|
|
/* 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<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);
|
|
|
|
return (ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char *
|
|
|
|
resort(unsigned char *s_block)
|
|
|
|
{
|
|
|
|
unsigned char *d_new, *d_ptr, *d_end, *s_ptr, *s_end;
|
|
|
|
unsigned char tmp;
|
|
|
|
|
|
|
|
s_end = s_block + EDID1_LEN;
|
|
|
|
d_new = xalloc(EDID1_LEN);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
xfree(s_block);
|
|
|
|
return (d_new);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
DDC_checksum(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];
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
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;
|
|
|
|
|
|
|
|
return (result&0xFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
static 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<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++;
|
|
|
|
}
|
|
|
|
xfree(s_ptr);
|
|
|
|
if (d_block && DDC_checksum(d_block,EDID1_LEN)) return NULL;
|
|
|
|
return (resort(d_block));
|
|
|
|
}
|
|
|
|
|
2009-06-08 20:37:38 +02:00
|
|
|
/* fetch entire EDID record; DDC bit needs to be masked */
|
|
|
|
static unsigned int *
|
|
|
|
FetchEDID_DDC1(register ScrnInfoPtr pScrn,
|
|
|
|
register unsigned int (*read_DDC)(ScrnInfoPtr))
|
|
|
|
{
|
|
|
|
int count = NUM;
|
|
|
|
unsigned int *ptr, *xp;
|
|
|
|
|
|
|
|
ptr=xp=xalloc(sizeof(int)*NUM);
|
|
|
|
|
|
|
|
if (!ptr) return NULL;
|
|
|
|
do {
|
|
|
|
/* 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))
|
|
|
|
{
|
|
|
|
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--);
|
|
|
|
return (count);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* read EDID record , pass it to callback function to interpret.
|
|
|
|
* callback function will store it for further use by calling
|
|
|
|
* 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))
|
|
|
|
{
|
|
|
|
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 (TestDDC1(pScrn,read_DDC)==-1) {
|
|
|
|
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n");
|
|
|
|
return NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (DDCSpeed) DDCSpeed(pScrn,DDC_FAST);
|
|
|
|
do {
|
|
|
|
EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn,read_DDC));
|
|
|
|
count --;
|
|
|
|
} while (!EDID_block && count);
|
|
|
|
if (DDCSpeed) DDCSpeed(pScrn,DDC_SLOW);
|
|
|
|
|
|
|
|
return EDID_block;
|
|
|
|
}
|
|
|
|
|
2006-06-19 04:47:29 +02:00
|
|
|
/**
|
|
|
|
* Attempts to probe the monitor for EDID information, if NoDDC and NoDDC1 are
|
|
|
|
* unset. EDID information blocks are interpreted and the results returned in
|
|
|
|
* an xf86MonPtr.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
xf86MonPtr
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86DoEDID_DDC1(
|
2004-07-31 03:21:19 +02:00
|
|
|
int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
|
2003-11-14 17:48:57 +01:00
|
|
|
unsigned int (*DDC1Read)(ScrnInfoPtr)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
|
|
|
|
unsigned char *EDID_block = NULL;
|
|
|
|
xf86MonPtr tmp = NULL;
|
|
|
|
int sigio;
|
|
|
|
/* Default DDC and DDC1 to enabled. */
|
|
|
|
Bool noddc = FALSE, noddc1 = FALSE;
|
|
|
|
OptionInfoPtr options;
|
|
|
|
|
|
|
|
options = xnfalloc(sizeof(DDCOptions));
|
|
|
|
(void)memcpy(options, DDCOptions, sizeof(DDCOptions));
|
|
|
|
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
|
|
|
|
|
|
|
|
xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
|
|
|
|
xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
|
|
|
|
xfree(options);
|
|
|
|
|
|
|
|
if (noddc || noddc1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
sigio = xf86BlockSIGIO();
|
|
|
|
EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read);
|
|
|
|
xf86UnblockSIGIO(sigio);
|
|
|
|
|
|
|
|
if (EDID_block){
|
|
|
|
tmp = xf86InterpretEDID(scrnIndex,EDID_block);
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else ErrorF("No EDID block returned\n");
|
|
|
|
if (!tmp)
|
|
|
|
ErrorF("Cannot interpret EDID block\n");
|
|
|
|
#endif
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2009-06-08 20:45:47 +02:00
|
|
|
/* DDC2 */
|
|
|
|
|
2007-12-03 22:00:00 +01:00
|
|
|
static I2CDevPtr
|
2007-12-03 23:38:53 +01:00
|
|
|
DDC2MakeDevice(I2CBusPtr pBus, int address, char *name)
|
2007-12-03 22:00:00 +01:00
|
|
|
{
|
|
|
|
I2CDevPtr dev = NULL;
|
2007-12-03 23:38:53 +01:00
|
|
|
|
|
|
|
if (!(dev = xf86I2CFindDev(pBus, address))) {
|
2007-12-03 22:00:00 +01:00
|
|
|
dev = xf86CreateI2CDevRec();
|
2007-12-03 23:38:53 +01:00
|
|
|
dev->DevName = name;
|
|
|
|
dev->SlaveAddr = address;
|
2007-12-03 22:00:00 +01:00
|
|
|
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)) {
|
2008-03-28 22:53:55 +01:00
|
|
|
xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n");
|
2007-12-03 22:00:00 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
2007-12-03 23:38:53 +01:00
|
|
|
static I2CDevPtr
|
|
|
|
DDC2Init(int scrnIndex, I2CBusPtr pBus)
|
2007-12-03 22:00:00 +01:00
|
|
|
{
|
2007-12-03 23:38:53 +01:00
|
|
|
I2CDevPtr dev = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Slow down the bus so that older monitors don't
|
|
|
|
* miss things.
|
|
|
|
*/
|
|
|
|
pBus->RiseFallTime = 20;
|
|
|
|
|
|
|
|
dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2");
|
2009-02-27 18:42:43 +01:00
|
|
|
if (xf86I2CProbeAddress(pBus, 0x0060))
|
|
|
|
DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
|
|
|
|
if (xf86I2CProbeAddress(pBus, 0x0062))
|
|
|
|
DDC2MakeDevice(pBus, 0x0062, "EDID EEPROM interface");
|
|
|
|
if (xf86I2CProbeAddress(pBus, 0x006E))
|
|
|
|
DDC2MakeDevice(pBus, 0x006E, "DDC control interface");
|
2007-12-03 23:38:53 +01:00
|
|
|
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mmmm, smell the hacks */
|
|
|
|
static void
|
|
|
|
EEDIDStop(I2CDevPtr d)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* block is the EDID block number. a segment is two blocks. */
|
|
|
|
static Bool
|
|
|
|
DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer)
|
|
|
|
{
|
|
|
|
unsigned char W_Buffer[1];
|
|
|
|
int i, segment;
|
|
|
|
I2CDevPtr seg;
|
|
|
|
void (*stop)(I2CDevPtr);
|
2007-12-03 22:00:00 +01:00
|
|
|
|
|
|
|
for (i = 0; i < RETRIES; i++) {
|
2007-12-03 23:38:53 +01:00
|
|
|
/* 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;
|
2007-12-03 22:00:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-03 23:38:53 +01:00
|
|
|
return FALSE;
|
2007-12-03 22:00:00 +01:00
|
|
|
}
|
|
|
|
|
2006-06-19 04:47:29 +02:00
|
|
|
/**
|
|
|
|
* Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are
|
|
|
|
* unset. EDID information blocks are interpreted and the results returned in
|
2007-12-03 21:47:39 +01:00
|
|
|
* an xf86MonPtr. Unlike xf86DoEDID_DDC[12](), this function will return
|
2008-06-21 22:00:05 +02:00
|
|
|
* the complete EDID data, including all extension blocks, if the 'complete'
|
|
|
|
* parameter is TRUE;
|
2006-06-19 04:47:29 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
xf86MonPtr
|
2008-06-21 22:00:05 +02:00
|
|
|
xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
|
|
|
|
unsigned char *EDID_block = NULL;
|
|
|
|
xf86MonPtr tmp = NULL;
|
2007-12-03 22:00:00 +01:00
|
|
|
I2CDevPtr dev = NULL;
|
2003-11-14 17:48:57 +01:00
|
|
|
/* Default DDC and DDC2 to enabled. */
|
|
|
|
Bool noddc = FALSE, noddc2 = FALSE;
|
|
|
|
OptionInfoPtr options;
|
|
|
|
|
2007-12-03 23:38:53 +01:00
|
|
|
options = xalloc(sizeof(DDCOptions));
|
|
|
|
if (!options)
|
|
|
|
return NULL;
|
2007-12-03 21:47:39 +01:00
|
|
|
memcpy(options, DDCOptions, sizeof(DDCOptions));
|
2003-11-14 17:48:57 +01:00
|
|
|
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
|
|
|
|
|
|
|
|
xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
|
|
|
|
xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
|
|
|
|
xfree(options);
|
2007-12-03 22:00:00 +01:00
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
if (noddc || noddc2)
|
|
|
|
return NULL;
|
|
|
|
|
2007-12-03 22:00:00 +01:00
|
|
|
if (!(dev = DDC2Init(scrnIndex, pBus)))
|
|
|
|
return NULL;
|
|
|
|
|
2007-12-03 23:38:53 +01:00
|
|
|
EDID_block = xcalloc(1, EDID1_LEN);
|
|
|
|
if (!EDID_block)
|
|
|
|
return NULL;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-12-03 23:38:53 +01:00
|
|
|
if (DDC2Read(dev, 0, EDID_block)) {
|
2008-06-21 22:00:05 +02:00
|
|
|
int i, n = EDID_block[0x7e];
|
|
|
|
|
|
|
|
if (complete && n) {
|
|
|
|
EDID_block = xrealloc(EDID_block, EDID1_LEN * (1+n));
|
2007-12-03 21:47:39 +01:00
|
|
|
|
2008-06-21 22:00:05 +02:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
DDC2Read(dev, i+1, EDID_block + (EDID1_LEN * (1+i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2007-12-03 21:47:39 +01:00
|
|
|
|
2008-06-21 22:00:05 +02:00
|
|
|
if (tmp && complete)
|
2009-06-08 23:42:10 +02:00
|
|
|
tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
|
2008-06-21 22:00:05 +02:00
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2007-12-03 21:47:39 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
xf86MonPtr
|
2007-12-03 21:47:39 +01:00
|
|
|
xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus)
|
|
|
|
{
|
2008-06-21 22:00:05 +02:00
|
|
|
return xf86DoEEDID(scrnIndex, pBus, FALSE);
|
2007-12-03 21:47:39 +01:00
|
|
|
}
|
2009-06-08 23:42:10 +02:00
|
|
|
|
|
|
|
/* XXX write me */
|
|
|
|
static void *
|
|
|
|
DDC2ReadDisplayID(void)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to probe the monitor for DisplayID information, if NoDDC and
|
|
|
|
* NoDDC2 are unset. DisplayID blocks are interpreted and the results
|
|
|
|
* returned in an xf86MonPtr.
|
|
|
|
*
|
|
|
|
* 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 DisplayID information.
|
|
|
|
*
|
|
|
|
* @return pointer to a new xf86MonPtr containing the DisplayID information.
|
|
|
|
* @return NULL if no monitor attached or failure to interpret the DisplayID.
|
|
|
|
*/
|
|
|
|
xf86MonPtr
|
|
|
|
xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
|
|
|
|
{
|
|
|
|
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
|
|
|
|
unsigned char *did = NULL;
|
|
|
|
xf86MonPtr tmp = NULL;
|
|
|
|
I2CDevPtr dev = NULL;
|
|
|
|
/* Default DDC and DDC2 to enabled. */
|
|
|
|
Bool noddc = FALSE, noddc2 = FALSE;
|
|
|
|
OptionInfoPtr options;
|
|
|
|
|
|
|
|
options = xalloc(sizeof(DDCOptions));
|
|
|
|
if (!options)
|
|
|
|
return NULL;
|
|
|
|
memcpy(options, DDCOptions, sizeof(DDCOptions));
|
|
|
|
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
|
|
|
|
|
|
|
|
xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
|
|
|
|
xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
|
|
|
|
xfree(options);
|
|
|
|
|
|
|
|
if (noddc || noddc2)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!(dev = DDC2Init(scrnIndex, pBus)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if ((did = DDC2ReadDisplayID())) {
|
|
|
|
tmp = xcalloc(1, sizeof(*tmp));
|
|
|
|
if (!tmp)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
tmp->scrnIndex = scrnIndex;
|
|
|
|
tmp->flags |= MONITOR_DISPLAYID;
|
|
|
|
tmp->rawData = did;
|
|
|
|
}
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|