Commit 9fa15bef authored by Maarten Maathuis's avatar Maarten Maathuis

randr: some improvements, fixes and crtc abi bump

- Add active field to crtc.
- Set gamma (only) whenever a crtc becomes active.
- Check for xf86_config being NULL.
- Increase crtc abi to 3.
- A few other fixes.
parent bf65523a
......@@ -267,9 +267,11 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
crtc->enabled = xf86CrtcInUse (crtc);
/* We only hit this if someone explicitly sends a "disabled" modeset. */
if (!crtc->enabled)
{
/* XXX disable crtc? */
/* Check everything for stuff that should be off. */
xf86DisableUnusedFunctions(scrn);
return TRUE;
}
......@@ -378,6 +380,11 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
output->funcs->mode_set(output, mode, adjusted_mode);
}
/* Only upload when needed, to avoid unneeded delays. */
if (!crtc->active)
crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
crtc->gamma_blue, crtc->gamma_size);
/* Now, enable the clocks, plane, pipe, and outputs that we set up. */
crtc->funcs->commit(crtc);
for (i = 0; i < xf86_config->num_output; i++)
......@@ -387,8 +394,8 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
output->funcs->commit(output);
}
/* XXX free adjustedmode */
ret = TRUE;
crtc->active = TRUE;
if (scrn->pScreen)
xf86CrtcSetScreenSubpixelOrder (scrn->pScreen);
......@@ -403,6 +410,8 @@ done:
crtc->transformPresent = saved_transform_present;
}
free(adjusted_mode);
if (didLock)
crtc->funcs->unlock (crtc);
......@@ -2265,8 +2274,7 @@ xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green,
memcpy (crtc->gamma_blue, blue, crtc->gamma_size * sizeof (CARD16));
/* Use copied values, the perfect way to test if all went well. */
crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
crtc->gamma_blue, crtc->gamma_size);
free(red);
......@@ -2440,8 +2448,6 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
crtc->desiredY = output->initial_y;
crtc->desiredTransformPresent = FALSE;
crtc->enabled = TRUE;
crtc->x = output->initial_x;
crtc->y = output->initial_y;
memcpy (&crtc->panningTotalArea, &output->initialTotalArea, sizeof(BoxRec));
memcpy (&crtc->panningTrackingArea, &output->initialTrackingArea, sizeof(BoxRec));
memcpy (crtc->panningBorder, output->initialBorder, 4*sizeof(INT16));
......@@ -2846,6 +2852,7 @@ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
crtc->funcs->dpms(crtc, DPMSModeOff);
memset(&crtc->mode, 0, sizeof(crtc->mode));
xf86RotateDestroy(crtc);
crtc->active = FALSE;
}
}
if (pScrn->pScreen)
......@@ -3141,15 +3148,13 @@ xf86_crtc_supports_gamma(ScrnInfoPtr pScrn)
{
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
xf86CrtcPtr crtc;
int c;
for (c = 0; c < xf86_config->num_crtc; c++) {
crtc = xf86_config->crtc[c];
if (crtc->funcs->gamma_set)
return TRUE;
else
return FALSE;
}
if (!xf86_config)
return FALSE;
return FALSE;
if (xf86_config->num_crtc == 0)
return FALSE;
crtc = xf86_config->crtc[0];
return (crtc->funcs->gamma_set != NULL);
}
......@@ -222,7 +222,7 @@ typedef struct _xf86CrtcFuncs {
} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
#define XF86_CRTC_VERSION 2
#define XF86_CRTC_VERSION 3
struct _xf86Crtc {
/**
......@@ -236,9 +236,9 @@ struct _xf86Crtc {
ScrnInfoPtr scrn;
/**
* Active state of this CRTC
* Desired state of this CRTC
*
* Set when this CRTC is driving one or more outputs
* Set when this CRTC should be driving one or more outputs
*/
Bool enabled;
......@@ -340,11 +340,20 @@ struct _xf86Crtc {
/**
* Current gamma, especially useful after initial config.
* Added in ABI version 3
*/
CARD16 *gamma_red;
CARD16 *gamma_green;
CARD16 *gamma_blue;
int gamma_size;
/**
* Actual state of this CRTC
*
* Set to TRUE after modesetting, set to FALSE if no outputs are connected
* Added in ABI version 3
*/
Bool active;
};
typedef struct _xf86OutputFuncs {
......
......@@ -1062,9 +1062,12 @@ xf86RandR12CrtcSetGamma (ScreenPtr pScreen,
memcpy (crtc->gamma_green, randr_crtc->gammaGreen, crtc->gamma_size * sizeof (CARD16));
memcpy (crtc->gamma_blue, randr_crtc->gammaBlue, crtc->gamma_size * sizeof (CARD16));
/* Use copied values, the perfect way to test if all went well. */
crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
crtc->gamma_blue, crtc->gamma_size);
/* Only set it when the crtc is actually running.
* Otherwise it will be set when it's activated.
*/
if (crtc->active)
crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
crtc->gamma_blue, crtc->gamma_size);
return TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment