summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2006-04-20 17:51:19 +1000
committerDave Airlie <airlied@linux.ie>2006-06-02 10:02:05 +1000
commit9c99ce3ccdc04086d63cd7d186f3d2b1e477b27a (patch)
tree1d76ee6bcdd2f269b74a7d8eba05c1ee6ee0f708 /src
parent6dd54e2afb1536bec09fb392e32c173423a4b44c (diff)
fix up SDVO code similiar to the intel driver
should find the SDVOB chip
Diffstat (limited to 'src')
-rw-r--r--src/i830.h2
-rw-r--r--src/i830_driver.c44
-rw-r--r--src/i830_i2c.c34
-rw-r--r--src/i830_raw.c6
-rw-r--r--src/i830_sdvo.c77
5 files changed, 76 insertions, 87 deletions
diff --git a/src/i830.h b/src/i830.h
index 7420d051..5ec4859b 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -252,9 +252,9 @@ struct _I830DVODriver {
};
typedef struct _I830SDVODriver {
- int found;
I2CDevRec d;
unsigned char sdvo_regs[20];
+ CARD32 output_device;
} I830SDVORec, *I830SDVOPtr;
struct _I830OutputRec {
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 950e7151..55df6990 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -2230,15 +2230,17 @@ void
I830SetupOutputBusses(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
+ int i = 0;
int ret;
/* everyone has at least a single analog output */
pI830->num_outputs = 1;
- pI830->output[0].type = I830_OUTPUT_ANALOG;
+ pI830->output[i].type = I830_OUTPUT_ANALOG;
/* setup the DDC bus for the analog output */
- I830I2CInit(pScrn, &pI830->output[0].pDDCBus, GPIOA, "CRTDDC_A");
-
+ I830I2CInit(pScrn, &pI830->output[i].pDDCBus, GPIOA, "CRTDDC_A");
+ i++;
+
/* need to add the output busses for each device
- this function is very incomplete
- i915GM has LVDS and TVOUT for example
@@ -2249,10 +2251,10 @@ I830SetupOutputBusses(ScrnInfoPtr pScrn)
case PCI_CHIP_845_G:
case PCI_CHIP_I855_GM:
case PCI_CHIP_I865_G:
- pI830->num_outputs = 2;
- pI830->output[1].type = I830_OUTPUT_DVO;
- I830I2CInit(pScrn, &pI830->output[1].pDDCBus, GPIOD, "DVODDC_D");
- I830I2CInit(pScrn, &pI830->output[1].pI2CBus, GPIOE, "DVOI2C_E");
+ pI830->output[i].type = I830_OUTPUT_DVO;
+ I830I2CInit(pScrn, &pI830->output[i].pDDCBus, GPIOD, "DVODDC_D");
+ I830I2CInit(pScrn, &pI830->output[i].pI2CBus, GPIOE, "DVOI2C_E");
+ i++;
break;
case PCI_CHIP_I915_G:
case PCI_CHIP_E7221_G:
@@ -2260,20 +2262,20 @@ I830SetupOutputBusses(ScrnInfoPtr pScrn)
/* has some LVDS + tv-out */
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
- /* SDVO ports have a single control bus */
- pI830->num_outputs = 2;
- pI830->output[1].type = I830_OUTPUT_SDVO;
- I830I2CInit(pScrn, &pI830->output[1].pI2CBus, GPIOE, "SDVOCTRL_E");
-
- pI830->output[1].sdvo_drv = I830SDVOInit(pI830->output[1].pI2CBus);
- ret = I830I2CDetectSDVOController(pScrn, 1);
- if (ret == TRUE)
- {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Found sDVO\n");
- }
+ /* SDVO ports have a single control bus - 2 devices */
+ pI830->output[i].type = I830_OUTPUT_SDVO;
+ I830I2CInit(pScrn, &pI830->output[i].pI2CBus, GPIOE, "SDVOCTRL_E");
+ I830SDVOInit(pScrn, i, DVOB);
+ i++;
+
+ /* set up SDVOC */
+ pI830->output[i].type = I830_OUTPUT_SDVO;
+ pI830->output[i].pI2CBus = pI830->output[i-1].pI2CBus;
+ I830SDVOInit(pScrn, i, DVOC);
+ i++;
break;
}
-
+ pI830->num_outputs = i;
}
void
@@ -2344,14 +2346,16 @@ void I830DetectMonitors(ScrnInfoPtr pScrn)
}
break;
case I830_OUTPUT_SDVO:
- if (pI830->output[i].sdvo_drv->found)
+ if (pI830->output[i].sdvo_drv)
{
+#if 0
I830SDVOSetupDDC(pI830->output[i].sdvo_drv, 2);
pI830->output[i].MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pI830->output[i].pI2CBus);
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DDC SDVO %d, %08X\n", i, pI830->output[i].pI2CBus->DriverPrivate.uval);
xf86PrintEDID(pI830->output[i].MonInfo);
+#endif
}
break;
case I830_OUTPUT_UNUSED:
diff --git a/src/i830_i2c.c b/src/i830_i2c.c
index 1740fd8a..eca8ab31 100644
--- a/src/i830_i2c.c
+++ b/src/i830_i2c.c
@@ -475,37 +475,3 @@ I830I2CDetectDVOControllers(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus, struct _I830DV
return FALSE;
}
-
-Bool
-I830I2CDetectSDVOController(ScrnInfoPtr pScrn, int output_index)
-{
- I830Ptr pI830 = I830PTR(pScrn);
- I2CDevRec d;
- unsigned char ch[64];
- int i;
- int addr = 0x39 << 1;
- I2CBusPtr b = pI830->output[output_index].pI2CBus;
-
- /* attempt to talk to an SDVO controller */
- d.DevName = "SDVO";
- d.SlaveAddr = addr;
- d.pI2CBus = b;
- d.StartTimeout = b->StartTimeout;
- d.BitTimeout = b->BitTimeout;
- d.AcknTimeout = b->AcknTimeout;
- d.ByteTimeout = b->ByteTimeout;
-
- for (i=0; i<0x40; i++)
- {
- if (!xf86I2CReadByte(&d, i, &ch[i]))
- {
- xf86DrvMsg(b->scrnIndex, X_ERROR, "unable to read from %d on %s\n", addr, b->BusName);
- return FALSE;
- }
- }
-
- if (pI830->output[output_index].sdvo_drv)
- pI830->output[output_index].sdvo_drv->found = 1;
-
- return TRUE;
-}
diff --git a/src/i830_raw.c b/src/i830_raw.c
index 7deb06d9..b20a0674 100644
--- a/src/i830_raw.c
+++ b/src/i830_raw.c
@@ -422,7 +422,7 @@ I830RawSetHw(ScrnInfoPtr pScrn, DisplayModePtr pMode)
*dpll &= ~DPLL_2X_CLOCK_ENABLE;
for (i=0; i<pI830->num_outputs; i++)
{
- if (pI830->output[i].sdvo_drv && pI830->output[i].sdvo_drv->found)
+ if (pI830->output[i].sdvo_drv)
*dpll |= DPLL_2X_CLOCK_ENABLE;
}
/* leave these alone for now */
@@ -851,7 +851,7 @@ I830RawSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
/* do SDVO setup */
for (i = 0; i < pI830->num_outputs; i++)
{
- if (pI830->output[i].sdvo_drv && pI830->output[i].sdvo_drv->found)
+ if (pI830->output[i].sdvo_drv)
{
I830SDVOPreSetMode(pI830->output[i].sdvo_drv, mode);
}
@@ -861,7 +861,7 @@ I830RawSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
for (i = 0; i < pI830->num_outputs; i++)
{
- if (pI830->output[i].sdvo_drv && pI830->output[i].sdvo_drv->found)
+ if (pI830->output[i].sdvo_drv)
{
ret = I830SDVOPostSetMode(pI830->output[i].sdvo_drv, mode);
/* if it didn't enable the DFP on the output */
diff --git a/src/i830_sdvo.c b/src/i830_sdvo.c
index beaf4e59..ba1465e6 100644
--- a/src/i830_sdvo.c
+++ b/src/i830_sdvo.c
@@ -22,7 +22,9 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "xf86.h"
#include "xf86_ansic.h"
#include "xf86_OSproc.h"
@@ -95,34 +97,6 @@ static Bool sWriteByte(I830SDVOPtr s, int addr, unsigned char ch)
return TRUE;
}
-void *
-I830SDVOInit(I2CBusPtr b)
-{
- /**/
- I830SDVOPtr sdvo;
-
- sdvo = xcalloc(1, sizeof(I830SDVORec));
- if (sdvo==NULL)
- return NULL;
-
- sdvo->d.DevName = "SDVO Controller";
- sdvo->d.SlaveAddr = 0x39 << 1;
- sdvo->d.pI2CBus = b;
- sdvo->d.StartTimeout = b->StartTimeout;
- sdvo->d.BitTimeout = b->BitTimeout;
- sdvo->d.AcknTimeout = b->AcknTimeout;
- sdvo->d.ByteTimeout = b->ByteTimeout;
- sdvo->d.DriverPrivate.ptr = sdvo;
-
- if (!xf86I2CDevInit(&(sdvo->d)))
- goto out;
- return sdvo;
-
- out:
- xfree(sdvo);
- return NULL;
-}
-
/* following on from tracing the intel BIOS i2c routines */
Bool
I830SDVOWriteOutputs(I830SDVOPtr s, int num_out)
@@ -598,3 +572,48 @@ I830SDVOPostSetMode(I830SDVOPtr s, DisplayModePtr mode)
return ret;
}
+
+I830SDVOPtr
+I830SDVOInit(ScrnInfoPtr pScrn, int output_index, CARD32 output_device)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ I830SDVOPtr sdvo;
+ unsigned char ch[0x40];
+ int i;
+
+ sdvo = xcalloc(1, sizeof(I830SDVORec));
+ if (sdvo == NULL)
+ return NULL;
+
+ if (output_device == DVOB) {
+ sdvo->d.DevName = "SDVO Controller B";
+ sdvo->d.SlaveAddr = 0x70;
+ } else {
+ sdvo->d.DevName = "SDVO Controller C";
+ sdvo->d.SlaveAddr = 0x72;
+ }
+ sdvo->d.pI2CBus = pI830->output[output_index].pI2CBus;
+ sdvo->d.DriverPrivate.ptr = sdvo;
+ sdvo->output_device = output_device;
+
+ if (!xf86I2CDevInit(&sdvo->d)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to initialize SDVO I2C device %s\n",
+ sdvo->d.DevName);
+ xfree(sdvo);
+ return NULL;
+ }
+
+ /* Read the regs to test if we can talk to the device */
+ for (i = 0; i < 0x40; i++) {
+ if (!sReadByte(sdvo, i, &ch[i])) {
+ xf86DestroyI2CDevRec(&sdvo->d, 0);
+ xfree(sdvo);
+ return NULL;
+ }
+ }
+
+ pI830->output[output_index].sdvo_drv = sdvo;
+
+ return sdvo;
+}