From 0232768b3935625a185876657873868c8fe0603b Mon Sep 17 00:00:00 2001 From: Kevin Brace Date: Sun, 17 Jan 2016 00:24:01 -0600 Subject: [PATCH 5/7] General improvement of via_dvi_init function Added debug messages to via_dvi_init function inside via_outputs.c in order to aid the debugging effort. Changed the function return type to boolean type. Made small adjustments to better handle error conditions as well. --- src/via_outputs.c | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/src/via_outputs.c b/src/via_outputs.c index ef48226..968262d 100644 --- a/src/via_outputs.c +++ b/src/via_outputs.c @@ -1018,7 +1018,7 @@ static const xf86OutputFuncsRec via_dvi_funcs = { .destroy = via_dvi_destroy, }; -void +static Bool via_dvi_init(ScrnInfoPtr pScrn) { VIAPtr pVia = VIAPTR(pScrn); @@ -1027,41 +1027,67 @@ via_dvi_init(ScrnInfoPtr pScrn) I2CBusPtr pBus = NULL; I2CDevPtr pDev = NULL; + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Entered via_dvi_init.\n")); + if (!pVia->pI2CBus2 || !pVia->pI2CBus3) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "I2C Bus 2 or I2C Bus 3 does not exist.\n"); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting via_dvi_init.\n")); return; } pDev = xf86CreateI2CDevRec(); if (!pDev) { - return; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to initialize I2C bus.\n"); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting via_dvi_init.\n")); + return FALSE; } - pDev->DevName = "VT1632"; + pDev->DevName = "VT1632A"; pDev->SlaveAddr = 0x10; if (xf86I2CProbeAddress(pVia->pI2CBus3, pDev->SlaveAddr)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "VT1632A found on I2C Bus 3.\n"); pDev->pI2CBus = pVia->pI2CBus3; } else if (xf86I2CProbeAddress(pVia->pI2CBus2, pDev->SlaveAddr)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "VT1632A found on I2C Bus 2.\n"); pDev->pI2CBus = pVia->pI2CBus2; } else { - xf86DestroyI2CDevRec(pDev, TRUE); - return; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "VT1632A not found on I2C Bus 2 or I2C Bus 3.\n"); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting via_dvi_init.\n")); + return FALSE; } if (!xf86I2CDevInit(pDev)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to initialize a device on I2C bus.\n"); xf86DestroyI2CDevRec(pDev, TRUE); - return; + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting via_dvi_init.\n")); + return FALSE; } if (!via_vt1632_probe(pScrn, pDev)) { xf86DestroyI2CDevRec(pDev, TRUE); - return; + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting via_dvi_init.\n")); + return FALSE; } private_data = via_vt1632_init(pScrn, pDev); if (!private_data) { xf86DestroyI2CDevRec(pDev, TRUE); - return; + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting via_dvi_init.\n")); + return FALSE; } output = xf86OutputCreate(pScrn, &via_dvi_funcs, "DVI-1"); @@ -1071,7 +1097,17 @@ via_dvi_init(ScrnInfoPtr pScrn) output->possible_clones = 0; output->interlaceAllowed = FALSE; output->doubleScanAllowed = FALSE; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to register DVI-1.\n"); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting via_dvi_init.\n")); + return FALSE; } + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting via_dvi_init.\n")); + return TRUE; } /* -- 1.7.9.5