diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 6b845b7..9f35e2a 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1863,6 +1863,29 @@ xf86TargetUserpref(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, return FALSE; } +/* + * Core functions depend on having an accurate view of the current + * output & crtc configuration. + */ +static void +xf86GetCurrentConfig (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o; + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + output->status = output->funcs->detect(output); + +#ifdef RANDR_GET_CRTC_INTERFACE + /* We can consider disconnected outputs as not having assigned CRTCs */ + if (output->status == XF86OutputStatusConnected) + output->crtc = output->funcs->get_crtc(output); +#endif + } +} + /** * Construct default screen configuration @@ -2042,26 +2065,14 @@ _X_EXPORT Bool xf86SetDesiredModes (ScrnInfoPtr scrn) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int c, o; + int c; /* - * Turn off everything so mode setting is done - * with hardware in a consistent state + * Get current config from driver so we know which outputs are on and what + * CRTCs they're mapped to. */ - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; - (*output->funcs->dpms)(output, DPMSModeOff); - } + xf86GetCurrentConfig(scrn); - for (c = 0; c < config->num_crtc; c++) - { - xf86CrtcPtr crtc = config->crtc[c]; - - crtc->funcs->dpms(crtc, DPMSModeOff); - memset(&crtc->mode, 0, sizeof(crtc->mode)); - } - for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index a542e7f..2d723a5 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -425,6 +425,13 @@ typedef struct _xf86OutputFuncs { (*get_property)(xf86OutputPtr output, Atom property); #endif +#ifdef RANDR_GET_CRTC_INTERFACE + /** + * Callback to get current CRTC for a given output + */ + xf86CrtcPtr + (*get_crtc)(xf86OutputPtr output); +#endif /** * Clean up driver-specific bits of the output */ diff --git a/randr/randrstr.h b/randr/randrstr.h index 4d7c9cc..62d4bbf 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -55,6 +55,7 @@ #define RANDR_10_INTERFACE 1 #define RANDR_12_INTERFACE 1 #define RANDR_13_INTERFACE 1 /* requires RANDR_12_INTERFACE */ +#define RANDR_GET_CRTC_INTERFACE 1 #define RANDR_INTERFACE_VERSION 0x0103