diff options
author | Keith Packard <keithp@neko.keithp.com> | 2007-01-15 08:05:32 +1100 |
---|---|---|
committer | Keith Packard <keithp@neko.keithp.com> | 2007-01-15 08:05:32 +1100 |
commit | bfeda3bfc59d309772398f688d29452ba97f3973 (patch) | |
tree | d1ee5f4430098d64f413b991ee54b35a6a34558d /src/i830_display.c | |
parent | da6a00f787e4d13e6b75768c1976f1c44ae5bf72 (diff) |
Convert I830PipeSetMode to xf86CrtcSetMode. Add rotation structures.
Makes the mode setting logic device independent.
Magic rename hooks allow multiple drivers to provide the
generic code without name conflicts.
Rotation code requires special pixmap creation hook, and uses
Render to perform the actual rotation.
Diffstat (limited to 'src/i830_display.c')
-rw-r--r-- | src/i830_display.c | 208 |
1 files changed, 30 insertions, 178 deletions
diff --git a/src/i830_display.c b/src/i830_display.c index f47a9dbf..d80eb4e0 100644 --- a/src/i830_display.c +++ b/src/i830_display.c @@ -465,23 +465,6 @@ i830PipeFindClosestMode(xf86CrtcPtr crtc, DisplayModePtr pMode) } /** - * Return whether any outputs are connected to the specified pipe - */ - -Bool -i830PipeInUse (xf86CrtcPtr crtc) -{ - ScrnInfoPtr pScrn = crtc->scrn; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - int i; - - for (i = 0; i < xf86_config->num_output; i++) - if (xf86_config->output[i]->crtc == crtc) - return TRUE; - return FALSE; -} - -/** * Sets the power management mode of the pipe and plane. * * This code should probably grow support for turning the cursor off and back @@ -581,6 +564,27 @@ i830_crtc_dpms(xf86CrtcPtr crtc, int mode) } static Bool +i830_crtc_lock (xf86CrtcPtr crtc) +{ + /* Sync the engine before mode switch */ + i830WaitSync(crtc->scrn); + +#ifdef XF86DRI + return I830DRILock(crtc->scrn); +#else + return FALSE; +#endif +} + +static void +i830_crtc_unlock (xf86CrtcPtr crtc) +{ +#ifdef XF86DRI + I830DRIUnlock (crtc->scrn); +#endif +} + +static Bool i830_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode, DisplayModePtr adjusted_mode) { @@ -881,165 +885,11 @@ i830_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, } /** - * Sets the given video mode on the given pipe. - * - * Plane A is always output to pipe A, and plane B to pipe B. The plane - * will not be enabled if plane_enable is FALSE, which is used for - * load detection, when something else will be output to the pipe other than - * display data. - */ -Bool -i830PipeSetMode(xf86CrtcPtr crtc, DisplayModePtr pMode, - Bool plane_enable) -{ - ScrnInfoPtr pScrn = crtc->scrn; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - int i; - Bool ret = FALSE; -#ifdef XF86DRI - Bool didLock = FALSE; -#endif - DisplayModePtr adjusted_mode; - - /* XXX: curMode */ - - adjusted_mode = xf86DuplicateMode(pMode); - - crtc->enabled = i830PipeInUse (crtc); - - if (!crtc->enabled) - { - /* XXX disable crtc? */ - return TRUE; - } - -#ifdef XF86DRI - didLock = I830DRILock(pScrn); -#endif - - /* Pass our mode to the outputs and the CRTC to give them a chance to - * adjust it according to limitations or output properties, and also - * a chance to reject the mode entirely. - */ - for (i = 0; i < xf86_config->num_output; i++) { - xf86OutputPtr output = xf86_config->output[i]; - - if (output->crtc != crtc) - continue; - - if (!output->funcs->mode_fixup(output, pMode, adjusted_mode)) { - ret = FALSE; - goto done; - } - } - - if (!crtc->funcs->mode_fixup(crtc, pMode, adjusted_mode)) { - ret = FALSE; - goto done; - } - - /* Disable the outputs and CRTCs before setting the mode. */ - for (i = 0; i < xf86_config->num_output; i++) { - xf86OutputPtr output = xf86_config->output[i]; - - if (output->crtc != crtc) - continue; - - /* Disable the output as the first thing we do. */ - output->funcs->dpms(output, DPMSModeOff); - } - - crtc->funcs->dpms(crtc, DPMSModeOff); - - /* Set up the DPLL and any output state that needs to adjust or depend - * on the DPLL. - */ - crtc->funcs->mode_set(crtc, pMode, adjusted_mode); - for (i = 0; i < xf86_config->num_output; i++) { - xf86OutputPtr output = xf86_config->output[i]; - if (output->crtc == crtc) - output->funcs->mode_set(output, pMode, adjusted_mode); - } - - /* Now, enable the clocks, plane, pipe, and outputs that we set up. */ - crtc->funcs->dpms(crtc, DPMSModeOn); - for (i = 0; i < xf86_config->num_output; i++) { - xf86OutputPtr output = xf86_config->output[i]; - if (output->crtc == crtc) - output->funcs->dpms(output, DPMSModeOn); - } - -#if 0 - /* - * If the display isn't solid, it may be running out - * of memory bandwidth. This code will dump out the - * pipe status, if bit 31 is on, the fifo underran - */ - for (i = 0; i < 4; i++) { - i830WaitForVblank(pScrn); - - OUTREG(pipestat_reg, INREG(pipestat_reg) | 0x80000000); - - i830WaitForVblank(pScrn); - - temp = INREG(pipestat_reg); - ErrorF ("pipe status 0x%x\n", temp); - } -#endif - - crtc->curMode = *pMode; - - /* XXX free adjustedmode */ - ret = TRUE; -done: -#ifdef XF86DRI - if (didLock) - I830DRIUnlock(pScrn); -#endif - return ret; -} - -void -i830DisableUnusedFunctions(ScrnInfoPtr pScrn) -{ - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - int o, pipe; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling unused functions\n"); - - for (o = 0; o < xf86_config->num_output; o++) - { - xf86OutputPtr output = xf86_config->output[o]; - if (!output->crtc) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling output %s\n", - output->name); - (*output->funcs->dpms)(output, DPMSModeOff); - } - } - - for (pipe = 0; pipe < xf86_config->num_crtc; pipe++) - { - xf86CrtcPtr crtc = xf86_config->crtc[pipe]; - I830CrtcPrivatePtr intel_crtc = crtc->driver_private; - int pipe = intel_crtc->pipe; - char *pipe_name = pipe == 0 ? "A" : "B"; - - if (!crtc->enabled) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling CRTC %s\n", - pipe_name); - crtc->funcs->dpms(crtc, DPMSModeOff); - - memset(&crtc->curMode, 0, sizeof(crtc->curMode)); - } - } -} - -/** * This function configures the screens in clone mode on * all active outputs using a mode similar to the specified mode. */ Bool -i830SetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) +i830SetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode, Rotation rotation) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); Bool ok = TRUE; @@ -1049,9 +899,9 @@ i830SetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) if (crtc && crtc->enabled) { - ok = i830PipeSetMode(crtc, - i830PipeFindClosestMode(crtc, pMode), - TRUE); + ok = xf86CrtcSetMode(crtc, + i830PipeFindClosestMode(crtc, pMode), + rotation); if (!ok) goto done; crtc->desiredMode = *pMode; @@ -1061,7 +911,7 @@ i830SetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) (int)(pMode->HDisplay * pMode->VDisplay * pMode->VRefresh / 1000000)); - i830DisableUnusedFunctions(pScrn); + xf86DisableUnusedFunctions(pScrn); i830DescribeOutputConfiguration(pScrn); @@ -1153,7 +1003,7 @@ i830GetLoadDetectPipe(xf86OutputPtr output) return output->crtc; for (i = 0; i < xf86_config->num_crtc; i++) - if (!i830PipeInUse(xf86_config->crtc[i])) + if (!xf86CrtcInUse (xf86_config->crtc[i])) break; if (i == xf86_config->num_crtc) @@ -1177,7 +1027,7 @@ i830ReleaseLoadDetectPipe(xf86OutputPtr output) { output->crtc = NULL; intel_output->load_detect_temp = FALSE; - i830DisableUnusedFunctions(pScrn); + xf86DisableUnusedFunctions(pScrn); } } @@ -1185,6 +1035,8 @@ static const xf86CrtcFuncsRec i830_crtc_funcs = { .dpms = i830_crtc_dpms, .save = NULL, /* XXX */ .restore = NULL, /* XXX */ + .lock = i830_crtc_lock, + .unlock = i830_crtc_unlock, .mode_fixup = i830_crtc_mode_fixup, .mode_set = i830_crtc_mode_set, .gamma_set = i830_crtc_gamma_set, |