diff --git a/src/i830.h b/src/i830.h index 3866a25..8fc9422 100644 --- a/src/i830.h +++ b/src/i830.h @@ -679,6 +679,8 @@ extern void i830_crtc_dpms_video(xf86CrtcPtr crtc, Bool on); int i830_crtc_pipe (xf86CrtcPtr crtc); +extern xf86CrtcPtr i830_pipe_to_crtc(ScrnInfoPtr pScrn, int pipe); + Bool i830_pipe_a_require_activate (ScrnInfoPtr scrn); diff --git a/src/i830_crt.c b/src/i830_crt.c index 3705233..fb4823b 100644 --- a/src/i830_crt.c +++ b/src/i830_crt.c @@ -391,6 +391,16 @@ i830_crt_destroy (xf86OutputPtr output) xfree (output->driver_private); } +static xf86CrtcPtr +i830_crt_get_crtc(xf86OutputPtr output) +{ + ScrnInfoPtr pScrn = output->scrn; + I830Ptr pI830 = I830PTR(pScrn); + int pipe = !!(INREG(ADPA) & ADPA_PIPE_SELECT_MASK); + + return i830_pipe_to_crtc(pScrn, pipe); +} + static const xf86OutputFuncsRec i830_crt_output_funcs = { .dpms = i830_crt_dpms, .save = i830_crt_save, @@ -402,7 +412,8 @@ static const xf86OutputFuncsRec i830_crt_output_funcs = { .commit = i830_output_commit, .detect = i830_crt_detect, .get_modes = i830_ddc_get_modes, - .destroy = i830_crt_destroy + .destroy = i830_crt_destroy, + .get_crtc = i830_crt_get_crtc, }; void diff --git a/src/i830_display.c b/src/i830_display.c index b589896..26c3d37 100644 --- a/src/i830_display.c +++ b/src/i830_display.c @@ -1816,6 +1816,22 @@ static const xf86CrtcFuncsRec i830_crtc_funcs = { .destroy = NULL, /* XXX */ }; +static void +i830_crtc_get_config(ScrnInfoPtr pScrn, xf86CrtcPtr crtc) +{ + I830Ptr pI830 = I830PTR(pScrn); + I830CrtcPrivatePtr intel_crtc = crtc->driver_private; + int pipe = intel_crtc->pipe; + int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF; + + intel_crtc->dpms_mode = DPMSModeOff; + + if (INREG(pipeconf_reg) & PIPEACONF_ENABLE) { + intel_crtc->dpms_mode = DPMSModeOn; + crtc->enabled = 1; + } +} + void i830_crtc_init(ScrnInfoPtr pScrn, int pipe) { @@ -1829,7 +1845,6 @@ i830_crtc_init(ScrnInfoPtr pScrn, int pipe) intel_crtc = xnfcalloc (sizeof (I830CrtcPrivateRec), 1); intel_crtc->pipe = pipe; - intel_crtc->dpms_mode = DPMSModeOff; intel_crtc->plane = pipe; /* Initialize the LUTs for when we turn on the CRTC. */ @@ -1839,5 +1854,7 @@ i830_crtc_init(ScrnInfoPtr pScrn, int pipe) intel_crtc->lut_b[i] = i; } crtc->driver_private = intel_crtc; + + i830_crtc_get_config(pScrn, crtc); } diff --git a/src/i830_driver.c b/src/i830_driver.c index 644a11c..10b2468 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -3165,8 +3165,6 @@ I830EnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; I830Ptr pI830 = I830PTR(pScrn); - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - int o; DPRINTF(PFX, "Enter VT\n"); @@ -3213,11 +3211,6 @@ I830EnterVT(int scrnIndex, int flags) memset(pI830->FbBase + pScrn->fbOffset, 0, pScrn->virtualY * pScrn->displayWidth * pI830->cpp); - for (o = 0; o < config->num_output; o++) { - xf86OutputPtr output = config->output[o]; - output->funcs->dpms(output, DPMSModeOff); - } - if (!xf86SetDesiredModes (pScrn)) return FALSE; @@ -3483,6 +3476,23 @@ I830PMEvent(int scrnIndex, pmEvent event, Bool undo) return TRUE; } +xf86CrtcPtr +i830_pipe_to_crtc(ScrnInfoPtr pScrn, int pipe) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR (pScrn); + int c; + + for (c = 0; c < config->num_crtc; c++) { + xf86CrtcPtr crtc = config->crtc[c]; + I830CrtcPrivatePtr intel_crtc = crtc->driver_private; + + if (intel_crtc->pipe == pipe) + return crtc; + } + + return NULL; +} + #if 0 /** * This function is used for testing of the screen detect functions from the diff --git a/src/i830_dvo.c b/src/i830_dvo.c index c0f76e3..0f097a8 100644 --- a/src/i830_dvo.c +++ b/src/i830_dvo.c @@ -330,6 +330,18 @@ i830_dvo_destroy (xf86OutputPtr output) } } +static xf86CrtcPtr +i830_dvo_get_crtc(xf86OutputPtr output) +{ + ScrnInfoPtr pScrn = output->scrn; + I830Ptr pI830 = I830PTR(pScrn); + I830OutputPrivatePtr intel_output = output->driver_private; + struct _I830DVODriver *drv = intel_output->i2c_drv; + int pipe = !!(INREG(drv->dvo_reg) & SDVO_PIPE_B_SELECT); + + return i830_pipe_to_crtc(pScrn, pipe); +} + static const xf86OutputFuncsRec i830_dvo_output_funcs = { .dpms = i830_dvo_dpms, .save = i830_dvo_save, @@ -341,7 +353,8 @@ static const xf86OutputFuncsRec i830_dvo_output_funcs = { .commit = i830_output_commit, .detect = i830_dvo_detect, .get_modes = i830_dvo_get_modes, - .destroy = i830_dvo_destroy + .destroy = i830_dvo_destroy, + .get_crtc = i830_dvo_get_crtc, }; /** diff --git a/src/i830_lvds.c b/src/i830_lvds.c index a23631c..73cbcc7 100644 --- a/src/i830_lvds.c +++ b/src/i830_lvds.c @@ -618,6 +618,19 @@ i830_lvds_get_modes(xf86OutputPtr output) return NULL; } +/* LVDS doesn't need to do anything to prepare/commit */ +void +i830_lvds_prepare (xf86OutputPtr output) +{ + return; +} + +void +i830_lvds_commit (xf86OutputPtr output) +{ + return; +} + static void i830_lvds_destroy (xf86OutputPtr output) { @@ -878,6 +891,16 @@ i830_lvds_get_property(xf86OutputPtr output, Atom property) } #endif /* RANDR_13_INTERFACE */ +static xf86CrtcPtr +i830_lvds_get_crtc(xf86OutputPtr output) +{ + ScrnInfoPtr pScrn = output->scrn; + I830Ptr pI830 = I830PTR(pScrn); + int pipe = !!(INREG(LVDS) & LVDS_PIPEB_SELECT); + + return i830_pipe_to_crtc(pScrn, pipe); +} + static const xf86OutputFuncsRec i830_lvds_output_funcs = { .create_resources = i830_lvds_create_resources, .dpms = i830_lvds_dpms, @@ -885,9 +908,9 @@ static const xf86OutputFuncsRec i830_lvds_output_funcs = { .restore = i830_lvds_restore, .mode_valid = i830_lvds_mode_valid, .mode_fixup = i830_lvds_mode_fixup, - .prepare = i830_output_prepare, + .prepare = i830_lvds_prepare, .mode_set = i830_lvds_mode_set, - .commit = i830_output_commit, + .commit = i830_lvds_commit, .detect = i830_lvds_detect, .get_modes = i830_lvds_get_modes, #ifdef RANDR_12_INTERFACE @@ -896,7 +919,8 @@ static const xf86OutputFuncsRec i830_lvds_output_funcs = { #ifdef RANDR_13_INTERFACE .get_property = i830_lvds_get_property, #endif - .destroy = i830_lvds_destroy + .destroy = i830_lvds_destroy, + .get_crtc = i830_lvds_get_crtc, }; void diff --git a/src/i830_sdvo.c b/src/i830_sdvo.c index 9a89cc9..9f788c2 100644 --- a/src/i830_sdvo.c +++ b/src/i830_sdvo.c @@ -1146,6 +1146,18 @@ i830_sdvo_destroy (xf86OutputPtr output) } } +static xf86CrtcPtr +i830_sdvo_get_crtc(xf86OutputPtr output) +{ + ScrnInfoPtr pScrn = output->scrn; + I830Ptr pI830 = I830PTR(pScrn); + I830OutputPrivatePtr intel_output = output->driver_private; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; + int pipe = !!(INREG(dev_priv->output_device) & SDVO_PIPE_B_SELECT); + + return i830_pipe_to_crtc(pScrn, pipe); +} + static const xf86OutputFuncsRec i830_sdvo_output_funcs = { .dpms = i830_sdvo_dpms, .save = i830_sdvo_save, @@ -1157,7 +1169,8 @@ static const xf86OutputFuncsRec i830_sdvo_output_funcs = { .commit = i830_output_commit, .detect = i830_sdvo_detect, .get_modes = i830_sdvo_get_modes, - .destroy = i830_sdvo_destroy + .destroy = i830_sdvo_destroy, + .get_crtc = i830_sdvo_get_crtc, }; void diff --git a/src/i830_tv.c b/src/i830_tv.c index 095f59b..cf9ba16 100644 --- a/src/i830_tv.c +++ b/src/i830_tv.c @@ -1640,6 +1640,16 @@ i830_tv_set_property(xf86OutputPtr output, Atom property, } #endif /* RANDR_12_INTERFACE */ +static xf86CrtcPtr +i830_tv_get_crtc(xf86OutputPtr output) +{ + ScrnInfoPtr pScrn = output->scrn; + I830Ptr pI830 = I830PTR(pScrn); + int pipe = !!(INREG(TV_CTL) & TV_ENC_PIPEB_SELECT); + + return i830_pipe_to_crtc(pScrn, pipe); +} + static const xf86OutputFuncsRec i830_tv_output_funcs = { .create_resources = i830_tv_create_resources, .dpms = i830_tv_dpms, @@ -1656,6 +1666,7 @@ static const xf86OutputFuncsRec i830_tv_output_funcs = { #ifdef RANDR_12_INTERFACE .set_property = i830_tv_set_property, #endif + .get_crtc = i830_tv_get_crtc, }; void