[PATCH 2/6] xfree86: Drop DDC1 support
Adam Jackson
ajax at redhat.com
Thu Dec 1 13:50:57 PST 2011
This was an ancient hack to try to fetch the EDID block by reusing the
vertical sync pin as a serial line. It's never been very reliable, and
DDC2 was introduced in 1994 which is plenty recent enough.
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
hw/xfree86/ddc/ddc.c | 216 -------------------------------------------
hw/xfree86/ddc/xf86DDC.h | 14 ---
hw/xfree86/modes/xf86Crtc.c | 1 -
hw/xfree86/vgahw/vgaHW.c | 94 -------------------
hw/xfree86/vgahw/vgaHW.h | 2 -
5 files changed, 0 insertions(+), 327 deletions(-)
diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c
index 179f42c..614db9b 100644
--- a/hw/xfree86/ddc/ddc.c
+++ b/hw/xfree86/ddc/ddc.c
@@ -23,84 +23,16 @@
#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 },
};
-/* 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 = malloc(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;
- }
- free(s_block);
- return d_new;
-}
-
static int
DDC_checksum(const unsigned char *block, int len)
{
@@ -123,154 +55,6 @@ DDC_checksum(const unsigned char *block, int len)
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=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++;
- }
- free(s_ptr);
- 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 *
-FetchEDID_DDC1(register ScrnInfoPtr pScrn,
- register unsigned int (*read_DDC)(ScrnInfoPtr))
-{
- int count = NUM;
- unsigned int *ptr, *xp;
-
- ptr=xp=malloc(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;
-}
-
-/**
- * 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.
- */
-xf86MonPtr
-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));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
- free(options);
-
- if (noddc || noddc1)
- return NULL;
-
- OsBlockSignals();
- EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read);
- OsReleaseSignals();
-
- 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;
-}
-
/* DDC2 */
static I2CDevPtr
diff --git a/hw/xfree86/ddc/xf86DDC.h b/hw/xfree86/ddc/xf86DDC.h
index 16a8641..448ce8c 100644
--- a/hw/xfree86/ddc/xf86DDC.h
+++ b/hw/xfree86/ddc/xf86DDC.h
@@ -16,20 +16,6 @@
#include "xf86i2c.h"
#include "xf86str.h"
-/* speed up / slow down */
-typedef enum {
- DDC_SLOW,
- DDC_FAST
-} xf86ddcSpeed;
-
-typedef void (* DDC1SetSpeedProc)(ScrnInfoPtr, xf86ddcSpeed);
-
-extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC1(
- int scrnIndex,
- DDC1SetSpeedProc DDC1SetSpeed,
- unsigned int (*DDC1Read)(ScrnInfoPtr)
-);
-
extern _X_EXPORT xf86MonPtr xf86DoEDID_DDC2(
int scrnIndex,
I2CBusPtr pBus
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index da9db34..1deacc6 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -3049,7 +3049,6 @@ xf86OutputGetEDIDModes (xf86OutputPtr output)
return xf86DDCGetModes(scrn->scrnIndex, edid_mon);
}
-/* maybe we should care about DDC1? meh. */
xf86MonPtr
xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus)
{
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index 4036a01..57ea3b7 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -1889,100 +1889,6 @@ vgaHWHandleColormaps(ScreenPtr pScreen)
return TRUE;
}
-/* ----------------------- DDC support ------------------------*/
-/*
- * Adjust v_active, v_blank, v_sync, v_sync_end, v_blank_end, v_total
- * to read out EDID at a faster rate. Allowed maximum is 25kHz with
- * 20 usec v_sync active. Set positive v_sync polarity, turn off lightpen
- * readback, enable access to cr00-cr07.
- */
-
-/* vertical timings */
-#define DISPLAY_END 0x04
-#define BLANK_START DISPLAY_END
-#define SYNC_START BLANK_START
-#define SYNC_END 0x09
-#define BLANK_END SYNC_END
-#define V_TOTAL BLANK_END
-/* this function doesn't have to be reentrant for our purposes */
-struct _vgaDdcSave {
- unsigned char cr03;
- unsigned char cr06;
- unsigned char cr07;
- unsigned char cr09;
- unsigned char cr10;
- unsigned char cr11;
- unsigned char cr12;
- unsigned char cr15;
- unsigned char cr16;
- unsigned char msr;
-};
-
-void
-vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- unsigned char tmp;
- struct _vgaDdcSave* save;
- switch (speed) {
- case DDC_FAST:
-
- if (hwp->ddc != NULL) break;
- hwp->ddc = xnfcalloc(sizeof(struct _vgaDdcSave),1);
- save = (struct _vgaDdcSave *)hwp->ddc;
- /* Lightpen register disable - allow access to cr10 & 11; just in case */
- save->cr03 = hwp->readCrtc(hwp, 0x03);
- hwp->writeCrtc(hwp,0x03,(save->cr03 |0x80));
- save->cr12 = hwp->readCrtc(hwp, 0x12);
- hwp->writeCrtc(hwp,0x12,DISPLAY_END);
- save->cr15 = hwp->readCrtc(hwp, 0x15);
- hwp->writeCrtc(hwp,0x15,BLANK_START);
- save->cr10 = hwp->readCrtc(hwp, 0x10);
- hwp->writeCrtc(hwp,0x10,SYNC_START);
- save->cr11 = hwp->readCrtc(hwp, 0x11);
- /* unprotect group 1 registers; just in case ...*/
- hwp->writeCrtc(hwp,0x11,((save->cr11 & 0x70) | SYNC_END));
- save->cr16 = hwp->readCrtc(hwp, 0x16);
- hwp->writeCrtc(hwp,0x16,BLANK_END);
- save->cr06 = hwp->readCrtc(hwp, 0x06);
- hwp->writeCrtc(hwp,0x06,V_TOTAL);
- /* all values have less than 8 bit - mask out 9th and 10th bits */
- save->cr09 = hwp->readCrtc(hwp, 0x09);
- hwp->writeCrtc(hwp,0x09,(save->cr09 &0xDF));
- save->cr07 = hwp->readCrtc(hwp, 0x07);
- hwp->writeCrtc(hwp,0x07,(save->cr07 &0x10));
- /* vsync polarity negativ & ensure a 25MHz clock */
- save->msr = hwp->readMiscOut(hwp);
- hwp->writeMiscOut(hwp,((save->msr & 0xF3) | 0x80));
- break;
- case DDC_SLOW:
- if (hwp->ddc == NULL) break;
- save = (struct _vgaDdcSave *)hwp->ddc;
- hwp->writeMiscOut(hwp,save->msr);
- hwp->writeCrtc(hwp,0x07,save->cr07);
- tmp = hwp->readCrtc(hwp, 0x09);
- hwp->writeCrtc(hwp,0x09,((save->cr09 & 0x20) | (tmp & 0xDF)));
- hwp->writeCrtc(hwp,0x06,save->cr06);
- hwp->writeCrtc(hwp,0x16,save->cr16);
- hwp->writeCrtc(hwp,0x11,save->cr11);
- hwp->writeCrtc(hwp,0x10,save->cr10);
- hwp->writeCrtc(hwp,0x15,save->cr15);
- hwp->writeCrtc(hwp,0x12,save->cr12);
- hwp->writeCrtc(hwp,0x03,save->cr03);
- free(save);
- hwp->ddc = NULL;
- break;
- default:
- break;
- }
-}
-
-DDC1SetSpeedProc
-vgaHWddc1SetSpeedWeak(void)
-{
- return vgaHWddc1SetSpeed;
-}
-
SaveScreenProcPtr vgaHWSaveScreenWeak(void)
{
return vgaHWSaveScreen;
diff --git a/hw/xfree86/vgahw/vgaHW.h b/hw/xfree86/vgahw/vgaHW.h
index e943aa3..8086c31 100644
--- a/hw/xfree86/vgahw/vgaHW.h
+++ b/hw/xfree86/vgahw/vgaHW.h
@@ -214,14 +214,12 @@ extern _X_EXPORT void vgaHWEnable(vgaHWPtr hwp);
extern _X_EXPORT void vgaHWDisable(vgaHWPtr hwp);
extern _X_EXPORT void vgaHWDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
extern _X_EXPORT Bool vgaHWHandleColormaps(ScreenPtr pScreen);
-extern _X_EXPORT void vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed);
extern _X_EXPORT CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
unsigned int Flags);
extern _X_EXPORT CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits,
unsigned int Flags);
extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp);
-extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void);
extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void);
extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
Bool (*ClockFunc)(ScrnInfoPtr, int),
--
1.7.6.4
More information about the xorg-devel
mailing list