From 47f8361c3a64834587e54507653d8d5b258c2530 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 Mar 2007 22:07:01 -0800 Subject: [PATCH 1/3] Add xf86SetDesiredModes to apply desired modes to crtcs. xf86SetDesiredModes applies the desired modes to each crtc (as selected by xf86InitialConfiguration initially and modified by successful mode settings afterwards). For crtcs without a desired mode, pScrn->currentMode is used to select something workable. (cherry picked from commit bcade98ccaa18298d844a606cb44271f0254c185) --- hw/xfree86/modes/xf86Crtc.c | 57 +++++++++++++++++++++++++++++++++++ hw/xfree86/modes/xf86Crtc.h | 8 +++++ hw/xfree86/modes/xf86Rename.h | 3 ++ 3 files changed, 68 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 3d28293c8..c38da62ce 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1542,6 +1542,63 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) return TRUE; } +/* + * Using the desired mode information in each crtc, set + * modes (used in EnterVT functions, or at server startup) + */ + +Bool +xf86SetDesiredModes (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + xf86OutputPtr output = NULL; + int o; + + if (config->output[config->compat_output]->crtc == crtc) + output = config->output[config->compat_output]; + else + { + for (o = 0; o < config->num_output; o++) + if (config->output[o]->crtc == crtc) + { + output = config->output[o]; + break; + } + } + /* + * Skip disabled crtcs + */ + if (!output) + continue; + + /* Mark that we'll need to re-set the mode for sure */ + memset(&crtc->mode, 0, sizeof(crtc->mode)); + if (!crtc->desiredMode.CrtcHDisplay) + { + DisplayModePtr mode = xf86OutputFindClosestMode (output, scrn->currentMode); + + if (!mode) + return FALSE; + crtc->desiredMode = *mode; + crtc->desiredRotation = RR_Rotate_0; + crtc->desiredX = 0; + crtc->desiredY = 0; + } + + if (!xf86CrtcSetMode (crtc, &crtc->desiredMode, crtc->desiredRotation, + crtc->desiredX, crtc->desiredY)) + return FALSE; + } + + xf86DisableUnusedFunctions(scrn); + return TRUE; +} + /** * In the current world order, there are lists of modes per output, which may * or may not include the mode that was asked to be set by XFree86's mode diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 56c7769cf..062a2dbec 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -644,4 +644,12 @@ xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen); char * xf86ConnectorGetName(xf86ConnectorType connector); +/* + * Using the desired mode information in each crtc, set + * modes (used in EnterVT functions, or at server startup) + */ + +Bool +xf86SetDesiredModes (ScrnInfoPtr pScrn); + #endif /* _XF86CRTC_H_ */ diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h index 6cfa5caa1..eae6d64d5 100644 --- a/hw/xfree86/modes/xf86Rename.h +++ b/hw/xfree86/modes/xf86Rename.h @@ -76,5 +76,8 @@ #define xf86CrtcSetScreenSubpixelOrder XF86NAME(xf86CrtcSetScreenSubpixelOrder) #define xf86ModeWidth XF86NAME(xf86ModeWidth) #define xf86ModeHeight XF86NAME(xf86ModeHeight) +#define xf86OutputFindClosestMode XF86NAME(xf86OutputFindClosestMode) +#define xf86SetSingleMode XF86NAME(xf86SetSingleMode) +#define xf86SetDesiredModes XF86NAME(xf86SetDesiredModes) #endif /* _XF86RENAME_H_ */ From bed76caa6caaea6a6598755b82a54425a9d9f73e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 Mar 2007 23:36:00 -0800 Subject: [PATCH 2/3] Use EDID data to set screen physical size at server startup. Screen physical size is set to a random value before the RandR code gets control, override that and reset it to a value based on the compat_output physical size (if available). If that output has no physical size, just use 96dpi as the default resolution and set the physical size as appropriate. (cherry picked from commit 843077f23a1b49bd712d931421753e3a09d4008c) --- hw/xfree86/modes/xf86RandR12.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 052d12aa3..ce780b6ef 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -422,8 +422,28 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) } else { - mmWidth = pScreen->mmWidth; - mmHeight = pScreen->mmHeight; + xf86OutputPtr output = config->output[config->compat_output]; + xf86CrtcPtr crtc = output->crtc; + + if (crtc && crtc->mode.HDisplay && + output->mm_width && output->mm_height) + { + /* + * If the output has a mode and a declared size, use that + * to scale the screen size + */ + DisplayModePtr mode = &crtc->mode; + mmWidth = output->mm_width * width / mode->HDisplay; + mmHeight = output->mm_height * height / mode->VDisplay; + } + else + { + /* + * Otherwise, just set the screen to 96dpi + */ + mmWidth = width * 25.4 / 96; + mmHeight = height * 25.4 / 96; + } } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Setting screen physical size to %d x %d\n", From 9b6bb06f13a71f6078f762b4a78fa516faccb638 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 Mar 2007 23:49:35 -0800 Subject: [PATCH 3/3] Allow relative positions to use output names or monitor identifiers. Previous version used monitor identifiers if present, otherwise output names. That caused existing working configurations to break when additional information was added to the configuration file. (cherry picked from commit 3f5cedf00a82f08a433c95ffbb7f8ac69dcf6a50) --- hw/xfree86/modes/xf86Crtc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index c38da62ce..46515fdcc 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -879,13 +879,17 @@ xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes) { xf86OutputPtr out_rel = config->output[or]; XF86ConfMonitorPtr rel_mon = out_rel->conf_monitor; - char *name; if (rel_mon) - name = rel_mon->mon_identifier; - else - name = out_rel->name; - if (!strcmp (relative_name, name)) + { + if (xf86nameCompare (rel_mon->mon_identifier, + relative_name) == 0) + { + relative = config->output[or]; + break; + } + } + if (strcmp (out_rel->name, relative_name) == 0) { relative = config->output[or]; break;