diff options
author | Keith Packard <keithp@neko.keithp.com> | 2006-11-26 16:44:17 -0800 |
---|---|---|
committer | Keith Packard <keithp@neko.keithp.com> | 2006-11-26 16:44:17 -0800 |
commit | 2529863a1ade782819d76be2d0dc16e89028c1e3 (patch) | |
tree | be9973bb1f83a633c998f137caa132b5f1a84bb8 /src/i830_sdvo.c | |
parent | 9aca4e207440119f4280b78199a221f85d50c511 (diff) |
Start output/crtc restructuring work. It compiles.
Outputs and Crtcs are now split between 'generic'
and 'driver specific' pieces in the hope that more code
will be able to migrate to the xf86-generic layer.
Right now, the code remains tangled together, significant
work remains to tease the pieces apart. First the code
needs to be made to actually work as-is though.
Diffstat (limited to 'src/i830_sdvo.c')
-rw-r--r-- | src/i830_sdvo.c | 272 |
1 files changed, 159 insertions, 113 deletions
diff --git a/src/i830_sdvo.c b/src/i830_sdvo.c index fedb8a6a..a8eba4c0 100644 --- a/src/i830_sdvo.c +++ b/src/i830_sdvo.c @@ -80,30 +80,32 @@ struct i830_sdvo_priv { }; /** Read a single byte from the given address on the SDVO device. */ -static Bool i830_sdvo_read_byte(I830OutputPtr output, int addr, +static Bool i830_sdvo_read_byte(I830_xf86OutputPtr output, int addr, unsigned char *ch) { - struct i830_sdvo_priv *dev_priv = output->dev_priv; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; if (!xf86I2CReadByte(&dev_priv->d, addr, ch)) { - xf86DrvMsg(output->pI2CBus->scrnIndex, X_ERROR, + xf86DrvMsg(intel_output->pI2CBus->scrnIndex, X_ERROR, "Unable to read from %s slave %d.\n", - output->pI2CBus->BusName, dev_priv->d.SlaveAddr); + intel_output->pI2CBus->BusName, dev_priv->d.SlaveAddr); return FALSE; } return TRUE; } /** Write a single byte to the given address on the SDVO device. */ -static Bool i830_sdvo_write_byte(I830OutputPtr output, +static Bool i830_sdvo_write_byte(I830_xf86OutputPtr output, int addr, unsigned char ch) { - struct i830_sdvo_priv *dev_priv = output->dev_priv; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; if (!xf86I2CWriteByte(&dev_priv->d, addr, ch)) { - xf86DrvMsg(output->pI2CBus->scrnIndex, X_ERROR, + xf86DrvMsg(intel_output->pI2CBus->scrnIndex, X_ERROR, "Unable to write to %s Slave %d.\n", - output->pI2CBus->BusName, dev_priv->d.SlaveAddr); + intel_output->pI2CBus->BusName, dev_priv->d.SlaveAddr); return FALSE; } return TRUE; @@ -164,16 +166,17 @@ static I2CSlaveAddr slaveAddr; * Writes out the data given in args (up to 8 bytes), followed by the opcode. */ static void -i830_sdvo_write_cmd(I830OutputPtr output, CARD8 cmd, void *args, int args_len) +i830_sdvo_write_cmd(I830_xf86OutputPtr output, CARD8 cmd, void *args, int args_len) { - int i; - struct i830_sdvo_priv *dev_priv = output->dev_priv; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; + int i; if (slaveAddr && slaveAddr != dev_priv->d.SlaveAddr) ErrorF ("Mismatch slave addr %x != %x\n", slaveAddr, dev_priv->d.SlaveAddr); /* Write the SDVO command logging */ - xf86DrvMsg(output->pI2CBus->scrnIndex, X_INFO, "%s: W: %02X ", SDVO_NAME(dev_priv), cmd); + xf86DrvMsg(intel_output->pI2CBus->scrnIndex, X_INFO, "%s: W: %02X ", SDVO_NAME(dev_priv), cmd); for (i = 0; i < args_len; i++) LogWrite(1, "%02X ", ((CARD8 *)args)[i]); for (; i < 8; i++) @@ -210,10 +213,11 @@ static const char *cmd_status_names[] = { * Reads back response_len bytes from the SDVO device, and returns the status. */ static CARD8 -i830_sdvo_read_response(I830OutputPtr output, void *response, int response_len) +i830_sdvo_read_response(I830_xf86OutputPtr output, void *response, int response_len) { - int i; - CARD8 status; + I830OutputPrivatePtr intel_output = output->driver_private; + int i; + CARD8 status; /* Read the command response */ for (i = 0; i < response_len; i++) { @@ -225,8 +229,8 @@ i830_sdvo_read_response(I830OutputPtr output, void *response, int response_len) i830_sdvo_read_byte(output, SDVO_I2C_CMD_STATUS, &status); /* Write the SDVO command logging */ - xf86DrvMsg(output->pI2CBus->scrnIndex, X_INFO, - "%s: R: ", SDVO_NAME(SDVO_PRIV(output))); + xf86DrvMsg(intel_output->pI2CBus->scrnIndex, X_INFO, + "%s: R: ", SDVO_NAME(SDVO_PRIV(intel_output))); for (i = 0; i < response_len; i++) LogWrite(1, "%02X ", ((CARD8 *)response)[i]); for (; i < 8; i++) @@ -258,13 +262,13 @@ i830_sdvo_get_pixel_multiplier(DisplayModePtr pMode) * STOP. PROM access is terminated by accessing an internal register. */ static void -i830_sdvo_set_control_bus_switch(I830OutputPtr output, CARD8 target) +i830_sdvo_set_control_bus_switch(I830_xf86OutputPtr output, CARD8 target) { i830_sdvo_write_cmd(output, SDVO_CMD_SET_CONTROL_BUS_SWITCH, &target, 1); } static Bool -i830_sdvo_set_target_input(I830OutputPtr output, Bool target_0, Bool target_1) +i830_sdvo_set_target_input(I830_xf86OutputPtr output, Bool target_0, Bool target_1) { struct i830_sdvo_set_target_input_args targets = {0}; CARD8 status; @@ -290,7 +294,7 @@ i830_sdvo_set_target_input(I830OutputPtr output, Bool target_0, Bool target_1) * which should be checked against the docs. */ static Bool -i830_sdvo_get_trained_inputs(I830OutputPtr output, Bool *input_1, Bool *input_2) +i830_sdvo_get_trained_inputs(I830_xf86OutputPtr output, Bool *input_1, Bool *input_2) { struct i830_sdvo_get_trained_inputs_response response; CARD8 status; @@ -308,7 +312,7 @@ i830_sdvo_get_trained_inputs(I830OutputPtr output, Bool *input_1, Bool *input_2) } static Bool -i830_sdvo_get_active_outputs(I830OutputPtr output, +i830_sdvo_get_active_outputs(I830_xf86OutputPtr output, CARD16 *outputs) { CARD8 status; @@ -320,7 +324,7 @@ i830_sdvo_get_active_outputs(I830OutputPtr output, } static Bool -i830_sdvo_set_active_outputs(I830OutputPtr output, +i830_sdvo_set_active_outputs(I830_xf86OutputPtr output, CARD16 outputs) { CARD8 status; @@ -336,7 +340,7 @@ i830_sdvo_set_active_outputs(I830OutputPtr output, * Returns the pixel clock range limits of the current target input in kHz. */ static Bool -i830_sdvo_get_input_pixel_clock_range(I830OutputPtr output, int *clock_min, +i830_sdvo_get_input_pixel_clock_range(I830_xf86OutputPtr output, int *clock_min, int *clock_max) { struct i830_sdvo_pixel_clock_range clocks; @@ -357,7 +361,7 @@ i830_sdvo_get_input_pixel_clock_range(I830OutputPtr output, int *clock_min, } static Bool -i830_sdvo_set_target_output(I830OutputPtr output, CARD16 outputs) +i830_sdvo_set_target_output(I830_xf86OutputPtr output, CARD16 outputs) { CARD8 status; @@ -371,7 +375,7 @@ i830_sdvo_set_target_output(I830OutputPtr output, CARD16 outputs) /** Fetches either input or output timings to *dtd, depending on cmd. */ static Bool -i830_sdvo_get_timing(I830OutputPtr output, CARD8 cmd, struct i830_sdvo_dtd *dtd) +i830_sdvo_get_timing(I830_xf86OutputPtr output, CARD8 cmd, struct i830_sdvo_dtd *dtd) { CARD8 status; @@ -391,20 +395,20 @@ i830_sdvo_get_timing(I830OutputPtr output, CARD8 cmd, struct i830_sdvo_dtd *dtd) } static Bool -i830_sdvo_get_input_timing(I830OutputPtr output, struct i830_sdvo_dtd *dtd) +i830_sdvo_get_input_timing(I830_xf86OutputPtr output, struct i830_sdvo_dtd *dtd) { return i830_sdvo_get_timing(output, SDVO_CMD_GET_INPUT_TIMINGS_PART1, dtd); } static Bool -i830_sdvo_get_output_timing(I830OutputPtr output, struct i830_sdvo_dtd *dtd) +i830_sdvo_get_output_timing(I830_xf86OutputPtr output, struct i830_sdvo_dtd *dtd) { return i830_sdvo_get_timing(output, SDVO_CMD_GET_OUTPUT_TIMINGS_PART1, dtd); } /** Sets either input or output timings from *dtd, depending on cmd. */ static Bool -i830_sdvo_set_timing(I830OutputPtr output, CARD8 cmd, struct i830_sdvo_dtd *dtd) +i830_sdvo_set_timing(I830_xf86OutputPtr output, CARD8 cmd, struct i830_sdvo_dtd *dtd) { CARD8 status; @@ -422,20 +426,20 @@ i830_sdvo_set_timing(I830OutputPtr output, CARD8 cmd, struct i830_sdvo_dtd *dtd) } static Bool -i830_sdvo_set_input_timing(I830OutputPtr output, struct i830_sdvo_dtd *dtd) +i830_sdvo_set_input_timing(I830_xf86OutputPtr output, struct i830_sdvo_dtd *dtd) { return i830_sdvo_set_timing(output, SDVO_CMD_SET_INPUT_TIMINGS_PART1, dtd); } static Bool -i830_sdvo_set_output_timing(I830OutputPtr output, struct i830_sdvo_dtd *dtd) +i830_sdvo_set_output_timing(I830_xf86OutputPtr output, struct i830_sdvo_dtd *dtd) { return i830_sdvo_set_timing(output, SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd); } #if 0 static Bool -i830_sdvo_create_preferred_input_timing(I830OutputPtr output, CARD16 clock, +i830_sdvo_create_preferred_input_timing(I830_xf86OutputPtr output, CARD16 clock, CARD16 width, CARD16 height) { struct i830_sdvo_priv *dev_priv = output->dev_priv; @@ -479,9 +483,10 @@ i830_sdvo_get_preferred_input_timing(I830OutputPtr output, /** Returns the SDVO_CLOCK_RATE_MULT_* for the current clock multiplier */ static int -i830_sdvo_get_clock_rate_mult(I830OutputPtr output) +i830_sdvo_get_clock_rate_mult(I830_xf86OutputPtr output) { - struct i830_sdvo_priv *dev_priv = output->dev_priv; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; CARD8 response; CARD8 status; @@ -507,7 +512,7 @@ i830_sdvo_get_clock_rate_mult(I830OutputPtr output) * is actually turned on. */ static Bool -i830_sdvo_set_clock_rate_mult(I830OutputPtr output, CARD8 val) +i830_sdvo_set_clock_rate_mult(I830_xf86OutputPtr output, CARD8 val) { CARD8 status; @@ -520,11 +525,12 @@ i830_sdvo_set_clock_rate_mult(I830OutputPtr output, CARD8 val) } static void -i830_sdvo_pre_set_mode(ScrnInfoPtr pScrn, I830OutputPtr output, - DisplayModePtr mode) +i830_sdvo_pre_set_mode(I830_xf86OutputPtr output, DisplayModePtr mode) { + ScrnInfoPtr pScrn = output->scrn; I830Ptr pI830 = I830PTR(pScrn); - struct i830_sdvo_priv *dev_priv = output->dev_priv; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; CARD16 width; CARD16 height; CARD16 h_blank_len, h_sync_len, v_blank_len, v_sync_len; @@ -621,15 +627,18 @@ i830_sdvo_pre_set_mode(ScrnInfoPtr pScrn, I830OutputPtr output, } static void -i830_sdvo_post_set_mode(ScrnInfoPtr pScrn, I830OutputPtr output, - DisplayModePtr mode) +i830_sdvo_post_set_mode(I830_xf86OutputPtr output, DisplayModePtr mode) { + ScrnInfoPtr pScrn = output->scrn; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; + I830_xf86CrtcPtr crtc = output->crtc; + I830CrtcPrivatePtr intel_crtc = crtc->driver_private; I830Ptr pI830 = I830PTR(pScrn); - struct i830_sdvo_priv *dev_priv = output->dev_priv; Bool input1, input2; CARD32 dpll, sdvox; - int dpll_reg = (output->pipe == 0) ? DPLL_A : DPLL_B; - int dpll_md_reg = (output->pipe == 0) ? DPLL_A_MD : DPLL_B_MD; + int dpll_reg = (intel_crtc->pipe == 0) ? DPLL_A : DPLL_B; + int dpll_md_reg = (intel_crtc->pipe == 0) ? DPLL_A_MD : DPLL_B_MD; int sdvo_pixel_multiply; int i; CARD8 status; @@ -645,7 +654,7 @@ i830_sdvo_post_set_mode(ScrnInfoPtr pScrn, I830OutputPtr output, break; } sdvox |= SDVO_ENABLE | (9 << 19) | SDVO_BORDER_ENABLE; - if (output->pipe == 1) + if (intel_crtc->pipe == 1) sdvox |= SDVO_PIPE_B_SELECT; dpll = INREG(dpll_reg); @@ -681,10 +690,12 @@ i830_sdvo_post_set_mode(ScrnInfoPtr pScrn, I830OutputPtr output, } static void -i830_sdvo_dpms(ScrnInfoPtr pScrn, I830OutputPtr output, int mode) +i830_sdvo_dpms(I830_xf86OutputPtr output, int mode) { + ScrnInfoPtr pScrn = output->scrn; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; I830Ptr pI830 = I830PTR(pScrn); - struct i830_sdvo_priv *dev_priv = output->dev_priv; if (mode != DPMSModeOn) { i830_sdvo_set_active_outputs(output, 0); @@ -696,11 +707,13 @@ i830_sdvo_dpms(ScrnInfoPtr pScrn, I830OutputPtr output, int mode) } static void -i830_sdvo_save(ScrnInfoPtr pScrn, I830OutputPtr output) +i830_sdvo_save(I830_xf86OutputPtr output) { - I830Ptr pI830 = I830PTR(pScrn); - struct i830_sdvo_priv *dev_priv = output->dev_priv; - int o; + ScrnInfoPtr pScrn = output->scrn; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; + I830Ptr pI830 = I830PTR(pScrn); + int o; /* XXX: We should save the in/out mapping. */ @@ -731,11 +744,13 @@ i830_sdvo_save(ScrnInfoPtr pScrn, I830OutputPtr output) } static void -i830_sdvo_restore(ScrnInfoPtr pScrn, I830OutputPtr output) +i830_sdvo_restore(I830_xf86OutputPtr output) { - I830Ptr pI830 = I830PTR(pScrn); - struct i830_sdvo_priv *dev_priv = output->dev_priv; - int o; + ScrnInfoPtr pScrn = output->scrn; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; + I830Ptr pI830 = I830PTR(pScrn); + int o; if (dev_priv->caps.sdvo_inputs_mask & 0x1) { i830_sdvo_set_target_input(output, TRUE, FALSE); @@ -764,10 +779,10 @@ i830_sdvo_restore(ScrnInfoPtr pScrn, I830OutputPtr output) } static int -i830_sdvo_mode_valid(ScrnInfoPtr pScrn, I830OutputPtr output, - DisplayModePtr pMode) +i830_sdvo_mode_valid(I830_xf86OutputPtr output, DisplayModePtr pMode) { - struct i830_sdvo_priv *dev_priv = output->dev_priv; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; if (pMode->Flags & V_DBLSCAN) return MODE_NO_DBLESCAN; @@ -782,7 +797,7 @@ i830_sdvo_mode_valid(ScrnInfoPtr pScrn, I830OutputPtr output, } static Bool -i830_sdvo_get_capabilities(I830OutputPtr output, struct i830_sdvo_caps *caps) +i830_sdvo_get_capabilities(I830_xf86OutputPtr output, struct i830_sdvo_caps *caps) { CARD8 status; @@ -836,8 +851,9 @@ i830_sdvo_ddc_i2c_put_byte(I2CDevPtr d, I2CByte c) static Bool i830_sdvo_ddc_i2c_start(I2CBusPtr b, int timeout) { - I830OutputPtr output = b->DriverPrivate.ptr; - I2CBusPtr i2cbus = output->pI2CBus; + I830_xf86OutputPtr output = b->DriverPrivate.ptr; + I830OutputPrivatePtr intel_output = output->driver_private; + I2CBusPtr i2cbus = intel_output->pI2CBus; i830_sdvo_set_control_bus_switch(output, SDVO_CONTROL_BUS_DDC2); return i2cbus->I2CStart(i2cbus, timeout); @@ -847,8 +863,9 @@ i830_sdvo_ddc_i2c_start(I2CBusPtr b, int timeout) static void i830_sdvo_ddc_i2c_stop(I2CDevPtr d) { - I830OutputPtr output = d->pI2CBus->DriverPrivate.ptr; - I2CBusPtr i2cbus = output->pI2CBus, savebus; + I830_xf86OutputPtr output = d->DriverPrivate.ptr; + I830OutputPrivatePtr intel_output = output->driver_private; + I2CBusPtr i2cbus = intel_output->pI2CBus, savebus; savebus = d->pI2CBus; d->pI2CBus = i2cbus; @@ -883,18 +900,19 @@ i830_sdvo_ddc_i2c_address(I2CDevPtr d, I2CSlaveAddr addr) } static void -i830_sdvo_dump_cmd(I830OutputPtr output, int opcode) +i830_sdvo_dump_cmd(I830_xf86OutputPtr output, int opcode) { - CARD8 response[8]; + CARD8 response[8]; i830_sdvo_write_cmd(output, opcode, NULL, 0); i830_sdvo_read_response(output, response, 8); } static void -i830_sdvo_dump_device(I830OutputPtr output) +i830_sdvo_dump_device(I830_xf86OutputPtr output) { - struct i830_sdvo_priv *dev_priv = output->dev_priv; + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; ErrorF("Dump %s\n", dev_priv->d.DevName); i830_sdvo_dump_cmd(output, SDVO_CMD_GET_DEVICE_CAPS); @@ -926,9 +944,13 @@ i830_sdvo_dump(ScrnInfoPtr pScrn) I830Ptr pI830 = I830PTR(pScrn); int i; - for (i = 0; i < pI830->num_outputs; i++) { - if (pI830->output[i].type == I830_OUTPUT_SDVO) - i830_sdvo_dump_device(&pI830->output[i]); + for (i = 0; i < pI830->num_outputs; i++) + { + I830_xf86OutputPtr output = pI830->xf86_output[i]; + I830OutputPrivatePtr intel_output = output->driver_private; + + if (intel_output->type == I830_OUTPUT_SDVO) + i830_sdvo_dump_device(output); } } @@ -942,7 +964,7 @@ i830_sdvo_dump(ScrnInfoPtr pScrn) * Takes 14ms on average on my i945G. */ static enum detect_status -i830_sdvo_detect(ScrnInfoPtr pScrn, I830OutputPtr output) +i830_sdvo_detect(I830_xf86OutputPtr output) { CARD8 response[2]; CARD8 status; @@ -959,25 +981,59 @@ i830_sdvo_detect(ScrnInfoPtr pScrn, I830OutputPtr output) return OUTPUT_STATUS_DISCONNECTED; } +static void +i830_sdvo_destroy (I830_xf86OutputPtr output) +{ + I830OutputPrivatePtr intel_output = output->driver_private; + + if (intel_output) + { + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; + + xf86DestroyI2CBusRec (intel_output->pDDCBus, FALSE, FALSE); + xf86DestroyI2CDevRec (&dev_priv->d, FALSE); + xf86DestroyI2CBusRec (dev_priv->d.pI2CBus, TRUE, TRUE); + xfree (intel_output); + } +} + +static const I830_xf86OutputFuncsRec i830_sdvo_output_funcs = { + .dpms = i830_sdvo_dpms, + .save = i830_sdvo_save, + .restore = i830_sdvo_restore, + .mode_valid = i830_sdvo_mode_valid, + .pre_set_mode = i830_sdvo_pre_set_mode, + .post_set_mode = i830_sdvo_post_set_mode, + .detect = i830_sdvo_detect, + .get_modes = i830_ddc_get_modes, + .destroy = i830_sdvo_destroy +}; + void i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) { - I830Ptr pI830 = I830PTR(pScrn); - I830OutputPtr output = &pI830->output[pI830->num_outputs]; - struct i830_sdvo_priv *dev_priv; - int i; - unsigned char ch[0x40]; - I2CBusPtr i2cbus = NULL, ddcbus; - - output->type = I830_OUTPUT_SDVO; - output->dpms = i830_sdvo_dpms; - output->save = i830_sdvo_save; - output->restore = i830_sdvo_restore; - output->mode_valid = i830_sdvo_mode_valid; - output->pre_set_mode = i830_sdvo_pre_set_mode; - output->post_set_mode = i830_sdvo_post_set_mode; - output->detect = i830_sdvo_detect; - output->get_modes = i830_ddc_get_modes; + I830_xf86OutputPtr output; + I830OutputPrivatePtr intel_output; + struct i830_sdvo_priv *dev_priv; + int i; + unsigned char ch[0x40]; + I2CBusPtr i2cbus = NULL, ddcbus; + + output = i830xf86OutputCreate (pScrn, &i830_sdvo_output_funcs, + "ADD2 PCIE card"); + if (!output) + return; + intel_output = xnfcalloc (sizeof (I830OutputPrivateRec) + + sizeof (struct i830_sdvo_priv), 1); + if (!intel_output) + { + i830xf86OutputDestroy (output); + return; + } + output->driver_private = intel_output; + + dev_priv = (struct i830_sdvo_priv *) (intel_output + 1); + intel_output->type = I830_OUTPUT_SDVO; /* While it's the same bus, we just initialize a new copy to avoid trouble * with tracking refcounting ourselves, since the XFree86 DDX bits don't. @@ -988,12 +1044,8 @@ i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) I830I2CInit(pScrn, &i2cbus, GPIOE, "SDVOCTRL_E for SDVOC"); if (i2cbus == NULL) - return; - - /* Allocate the SDVO output private data */ - dev_priv = xcalloc(1, sizeof(struct i830_sdvo_priv)); - if (dev_priv == NULL) { - xf86DestroyI2CBusRec(i2cbus, TRUE, TRUE); + { + i830xf86OutputDestroy (output); return; } @@ -1008,12 +1060,12 @@ i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) dev_priv->d.DriverPrivate.ptr = output; dev_priv->output_device = output_device; - if (!xf86I2CDevInit(&dev_priv->d)) { + if (!xf86I2CDevInit(&dev_priv->d)) + { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize %s I2C device\n", SDVO_NAME(dev_priv)); - xf86DestroyI2CBusRec(i2cbus, TRUE, TRUE); - xfree(dev_priv); + i830xf86OutputDestroy (output); return; } @@ -1023,10 +1075,9 @@ i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) * Start, extra attempts should be harmless. */ ddcbus = xf86CreateI2CBusRec(); - if (ddcbus == NULL) { - xf86DestroyI2CDevRec(&dev_priv->d, FALSE); - xf86DestroyI2CBusRec(i2cbus, TRUE, TRUE); - xfree(dev_priv); + if (ddcbus == NULL) + { + i830xf86OutputDestroy (output); return; } if (output_device == SDVOB) @@ -1039,25 +1090,22 @@ i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) ddcbus->I2CStart = i830_sdvo_ddc_i2c_start; ddcbus->I2CStop = i830_sdvo_ddc_i2c_stop; ddcbus->I2CAddress = i830_sdvo_ddc_i2c_address; - ddcbus->DriverPrivate.ptr = &pI830->output[pI830->num_outputs]; - if (!xf86I2CBusInit(ddcbus)) { - xf86DestroyI2CDevRec(&dev_priv->d, FALSE); - xf86DestroyI2CBusRec(i2cbus, TRUE, TRUE); - xfree(dev_priv); + ddcbus->DriverPrivate.ptr = output; + + if (!xf86I2CBusInit(ddcbus)) + { + i830xf86OutputDestroy (output); return; } - output->pI2CBus = i2cbus; - output->pDDCBus = ddcbus; - output->dev_priv = dev_priv; + intel_output->pI2CBus = i2cbus; + intel_output->pDDCBus = ddcbus; + intel_output->dev_priv = dev_priv; /* Read the regs to test if we can talk to the device */ for (i = 0; i < 0x40; i++) { if (!i830_sdvo_read_byte(output, i, &ch[i])) { - xf86DestroyI2CBusRec(output->pDDCBus, FALSE, FALSE); - xf86DestroyI2CDevRec(&dev_priv->d, FALSE); - xf86DestroyI2CBusRec(i2cbus, TRUE, TRUE); - xfree(dev_priv); + i830xf86OutputDestroy (output); return; } } @@ -1074,7 +1122,7 @@ i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) unsigned char bytes[2]; memcpy (bytes, &dev_priv->caps.output_flags, 2); - xf86DrvMsg(output->pI2CBus->scrnIndex, X_ERROR, + xf86DrvMsg(intel_output->pI2CBus->scrnIndex, X_ERROR, "%s: No active TMDS outputs (0x%02x%02x)\n", SDVO_NAME(dev_priv), bytes[0], bytes[1]); @@ -1100,6 +1148,4 @@ i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) (dev_priv->caps.sdvo_inputs_mask & 0x2) ? 'Y' : 'N', dev_priv->caps.output_flags & SDVO_OUTPUT_TMDS0 ? 'Y' : 'N', dev_priv->caps.output_flags & SDVO_OUTPUT_TMDS1 ? 'Y' : 'N'); - - pI830->num_outputs++; } |