From 585a32be887835758cbdf85185cf1c955a0c5687 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Feb 2007 11:27:35 -0800 Subject: [PATCH 01/85] Allow new modes code to build inside drivers as well as server. Use config.h for driver builds where xorg-config.h isn't available. --- hw/xfree86/modes/xf86Crtc.c | 4 ++++ hw/xfree86/modes/xf86DiDGA.c | 4 ++++ hw/xfree86/modes/xf86EdidModes.c | 4 ++++ hw/xfree86/modes/xf86Modes.c | 4 ++++ hw/xfree86/modes/xf86RandR12.c | 4 ++++ hw/xfree86/modes/xf86Rotate.c | 4 ++++ hw/xfree86/modes/xf86cvt.c | 4 ++++ 7 files changed, 28 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index ab7070be6..5e0a0c602 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -22,6 +22,10 @@ #ifdef HAVE_XORG_CONFIG_H #include +#else +#ifdef HAVE_CONFIG_H +#include +#endif #endif #include diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c index f4ac4ded3..551f052c9 100644 --- a/hw/xfree86/modes/xf86DiDGA.c +++ b/hw/xfree86/modes/xf86DiDGA.c @@ -22,6 +22,10 @@ #ifdef HAVE_XORG_CONFIG_H #include +#else +#ifdef HAVE_CONFIG_H +#include +#endif #endif #include "xf86.h" diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c index 0476a6838..77c0c875c 100644 --- a/hw/xfree86/modes/xf86EdidModes.c +++ b/hw/xfree86/modes/xf86EdidModes.c @@ -27,6 +27,10 @@ */ #ifdef HAVE_XORG_CONFIG_H #include +#else +#ifdef HAVE_CONFIG_H +#include +#endif #endif #include "xf86.h" diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c index d126e5edc..0706783ae 100644 --- a/hw/xfree86/modes/xf86Modes.c +++ b/hw/xfree86/modes/xf86Modes.c @@ -30,6 +30,10 @@ #ifdef HAVE_XORG_CONFIG_H #include +#else +#ifdef HAVE_CONFIG_H +#include +#endif #endif #include diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index bafe71f70..2a5d7bab2 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -25,6 +25,10 @@ #ifdef HAVE_XORG_CONFIG_H #include +#else +#ifdef HAVE_CONFIG_H +#include +#endif #endif #include "xf86.h" diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 1e79063a7..1d55a6e79 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -22,6 +22,10 @@ #ifdef HAVE_XORG_CONFIG_H #include +#else +#ifdef HAVE_CONFIG_H +#include +#endif #endif #include diff --git a/hw/xfree86/modes/xf86cvt.c b/hw/xfree86/modes/xf86cvt.c index 425657762..dd6febf2c 100644 --- a/hw/xfree86/modes/xf86cvt.c +++ b/hw/xfree86/modes/xf86cvt.c @@ -33,6 +33,10 @@ #ifdef HAVE_XORG_CONFIG_H #include +#else +#ifdef HAVE_CONFIG_H +#include +#endif #endif #include "xf86.h" From 3eebfb0a99f679bc53b674f730f2895331fd8974 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Feb 2007 20:13:15 -0800 Subject: [PATCH 02/85] Report correct RandR 1.0 sizeID. Report correct subpixel order. RandR 1.0 sizeID must be computed the same way every time, so when reporting it in the ScreenChangeNotify event, just construct the usual 1.0 data block and use that. subpixel geometry information can be computed by looking at the connected outputs and finding any with subpixel geometry and using one of those for the global screen subpixel geometry. This might be improved by reporting None if more than one screen has information and they conflict. --- hw/xfree86/modes/xf86Crtc.c | 67 ++++++++++++++++++++++++++++++++++ hw/xfree86/modes/xf86Crtc.h | 8 ++++ hw/xfree86/modes/xf86RandR12.c | 1 + hw/xfree86/modes/xf86Rename.h | 1 + randr/rrscreen.c | 62 ++++++++++++++++--------------- 5 files changed, 110 insertions(+), 29 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 5e0a0c602..bda805519 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -144,6 +144,71 @@ xf86CrtcInUse (xf86CrtcPtr crtc) return FALSE; } +void +xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen) +{ +#ifdef RENDER + int subpixel_order = SubPixelUnknown; + Bool has_none = FALSE; + ScrnInfoPtr scrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c, o; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + for (o = 0; o < xf86_config->num_output; o++) + { + xf86OutputPtr output = xf86_config->output[o]; + + if (output->crtc == crtc) + { + switch (output->subpixel_order) { + case SubPixelNone: + has_none = TRUE; + break; + case SubPixelUnknown: + break; + default: + subpixel_order = output->subpixel_order; + break; + } + } + if (subpixel_order != SubPixelUnknown) + break; + } + if (subpixel_order != SubPixelUnknown) + { + static const int circle[4] = { + SubPixelHorizontalRGB, + SubPixelVerticalRGB, + SubPixelHorizontalBGR, + SubPixelVerticalBGR, + }; + int rotate; + int c; + for (rotate = 0; rotate < 4; rotate++) + if (crtc->rotation & (1 << rotate)) + break; + for (c = 0; c < 4; c++) + if (circle[c] == subpixel_order) + break; + c = (c + rotate) & 0x3; + if ((crtc->rotation & RR_Reflect_X) && !(c & 1)) + c ^= 2; + if ((crtc->rotation & RR_Reflect_Y) && (c & 1)) + c ^= 2; + subpixel_order = circle[c]; + break; + } + } + if (subpixel_order == SubPixelUnknown && has_none) + subpixel_order = SubPixelNone; + PictureSetSubpixelOrder (pScreen, subpixel_order); +#endif +} + /** * Sets the given video mode on the given crtc */ @@ -245,6 +310,8 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, /* XXX free adjustedmode */ ret = TRUE; + xf86CrtcSetScreenSubpixelOrder (scrn->pScreen); + done: if (!ret) { crtc->x = saved_x; diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 49f4965ba..07f7d4960 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -552,4 +552,12 @@ xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address); Bool xf86DiDGAReInit (ScreenPtr pScreen); +/* + * Set the subpixel order reported for the screen using + * the information from the outputs + */ + +void +xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen); + #endif /* _XF86CRTC_H_ */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 2a5d7bab2..1dacb6f34 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -433,6 +433,7 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) randrp->virtualX = pScrn->virtualX; randrp->virtualY = pScrn->virtualY; } + xf86CrtcSetScreenSubpixelOrder (pScreen); #if RANDR_12_INTERFACE if (xf86RandR12CreateScreenResources12 (pScreen)) return TRUE; diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h index a00253d56..ce4d21796 100644 --- a/hw/xfree86/modes/xf86Rename.h +++ b/hw/xfree86/modes/xf86Rename.h @@ -73,5 +73,6 @@ #define xf86RandR12SetConfig XF86NAME(xf86RandR12SetConfig) #define xf86RandR12SetRotations XF86NAME(xf86RandR12SetRotations) #define xf86SaveScreen XF86NAME(xf86SaveScreen) +#define xf86CrtcSetScreenSubpixelOrder XF86NAME(xf86CrtcSetScreenSubpixelOrder) #endif /* _XF86RENAME_H_ */ diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 7b0fbb8e3..7a33ef674 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -26,6 +26,9 @@ extern char *ConnectionInfo; static int padlength[4] = {0, 3, 2, 1}; +static CARD16 +RR10CurrentSizeID (ScreenPtr pScreen); + /* * Edit connection information block so that new clients * see the current screen size on connect @@ -96,10 +99,7 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) rrScrPriv (pScreen); xRRScreenChangeNotifyEvent se; RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; - RROutputPtr output = pScrPriv->numOutputs ? pScrPriv->outputs[0] : NULL; - RRModePtr mode = crtc ? crtc->mode : NULL; WindowPtr pRoot = WindowTable[pScreen->myNum]; - int i; se.type = RRScreenChangeNotify + RREventBase; se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); @@ -115,32 +115,12 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) #endif se.sequenceNumber = client->sequence; - if (mode) - { - se.sizeID = -1; - for (i = 0; i < output->numModes; i++) - if (mode == output->modes[i]) - { - se.sizeID = i; - break; - } - se.widthInPixels = mode->mode.width; - se.heightInPixels = mode->mode.height; - se.widthInMillimeters = pScreen->mmWidth; - se.heightInMillimeters = pScreen->mmHeight; - } - else - { - /* - * This "shouldn't happen", but a broken DDX can - * forget to set the current configuration on GetInfo - */ - se.sizeID = 0xffff; - se.widthInPixels = 0; - se.heightInPixels = 0; - se.widthInMillimeters = 0; - se.heightInMillimeters = 0; - } + se.sizeID = RR10CurrentSizeID (pScreen); + + se.widthInPixels = pScreen->width; + se.heightInPixels = pScreen->height; + se.widthInMillimeters = pScreen->mmWidth; + se.heightInMillimeters = pScreen->mmHeight; WriteEventsToClient (client, 1, (xEvent *) &se); } @@ -956,3 +936,27 @@ sendReply: return (client->noClientException); } +static CARD16 +RR10CurrentSizeID (ScreenPtr pScreen) +{ + CARD16 sizeID = 0xffff; + RROutputPtr output = RRFirstOutput (pScreen); + + if (output) + { + RR10DataPtr data = RR10GetData (pScreen, output); + if (data) + { + int i; + for (i = 0; i < data->nsize; i++) + if (data->sizes[i].width == pScreen->width && + data->sizes[i].height == pScreen->height) + { + sizeID = (CARD16) i; + break; + } + xfree (data); + } + } + return sizeID; +} From eabeede69308b2c7eb80d77021340b71c32564d2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Feb 2007 22:23:16 -0800 Subject: [PATCH 03/85] RRConfigureOutputProperty is a variable length request. Replace REQUEST_SIZE_MATCH with REQUEST_AT_LEAST_SIZE --- randr/rrproperty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 03a1b5c94..e020d5bc7 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -410,7 +410,7 @@ ProcRRConfigureOutputProperty (ClientPtr client) RROutputPtr output; int num_valid; - REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq); + REQUEST_AT_LEAST_SIZE(xRRConfigureOutputPropertyReq); output = LookupOutput (client, stuff->output, SecurityReadAccess); From 5f1046f6d3d798f1547b5418af8874c13821ae93 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 16 Feb 2007 00:41:29 -0800 Subject: [PATCH 04/85] Enable startup-time rotation; change rotation pixmap creation API. Add monitor "Rotate" option taking one of "normal", "left", "inverted" or "right". However, because initial mode selection is made before the screen is completely initialized, we cannot create the shadow pixmap object at this point. Pend the shadow pixmap creation until the block handler. Note that this code is not completely functional yet. --- hw/xfree86/modes/xf86Crtc.c | 84 +++++++++++++++++++------- hw/xfree86/modes/xf86Crtc.h | 17 +++++- hw/xfree86/modes/xf86Modes.c | 30 ++++++++++ hw/xfree86/modes/xf86Modes.h | 7 +++ hw/xfree86/modes/xf86Rename.h | 2 + hw/xfree86/modes/xf86Rotate.c | 108 +++++++++++++++++----------------- hw/xfree86/modes/xf86cvt.c | 1 + 7 files changed, 172 insertions(+), 77 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index bda805519..74e4c76c7 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -344,6 +344,7 @@ typedef enum { OPTION_MIN_CLOCK, OPTION_MAX_CLOCK, OPTION_IGNORE, + OPTION_ROTATE, } OutputOpts; static OptionInfoRec xf86OutputOptions[] = { @@ -358,6 +359,7 @@ static OptionInfoRec xf86OutputOptions[] = { {OPTION_MIN_CLOCK, "MinClock", OPTV_FREQ, {0}, FALSE }, {OPTION_MAX_CLOCK, "MaxClock", OPTV_FREQ, {0}, FALSE }, {OPTION_IGNORE, "Ignore", OPTV_BOOLEAN, {0}, FALSE }, + {OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE }, {-1, NULL, OPTV_NONE, {0}, FALSE }, }; @@ -413,6 +415,29 @@ xf86OutputIgnored (xf86OutputPtr output) return xf86ReturnOptValBool (output->options, OPTION_IGNORE, FALSE); } +static char *direction[4] = { + "normal", + "left", + "inverted", + "right" +}; + +static Rotation +xf86OutputInitialRotation (xf86OutputPtr output) +{ + char *rotate_name = xf86GetOptValString (output->options, + OPTION_ROTATE); + int i; + + if (!rotate_name) + return RR_Rotate_0; + + for (i = 0; i < 4; i++) + if (xf86nameCompare (direction[i], rotate_name) == 0) + return (1 << i); + return RR_Rotate_0; +} + xf86OutputPtr xf86OutputCreate (ScrnInfoPtr scrn, const xf86OutputFuncsRec *funcs, @@ -533,8 +558,12 @@ xf86DefaultMode (xf86OutputPtr output, int width, int height) int preferred = (mode->type & M_T_PREFERRED) != 0; int diff; - if (mode->HDisplay > width || mode->VDisplay > height) continue; - dpi = (mode->HDisplay * 254) / (mm_height * 10); + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; + + /* yes, use VDisplay here, not xf86ModeHeight */ + dpi = (mode->VDisplay * 254) / (mm_height * 10); diff = dpi - 96; diff = diff < 0 ? -diff : diff; if (target_mode == NULL || (preferred > target_preferred) || @@ -549,7 +578,8 @@ xf86DefaultMode (xf86OutputPtr output, int width, int height) } static DisplayModePtr -xf86ClosestMode (xf86OutputPtr output, DisplayModePtr match, +xf86ClosestMode (xf86OutputPtr output, + DisplayModePtr match, Rotation match_rotation, int width, int height) { DisplayModePtr target_mode = NULL; @@ -564,14 +594,17 @@ xf86ClosestMode (xf86OutputPtr output, DisplayModePtr match, int dx, dy; int diff; - if (mode->HDisplay > width || mode->VDisplay > height) continue; + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; /* exact matches are preferred */ - if (xf86ModesEqual (mode, match)) + if (output->initial_rotation == match_rotation && + xf86ModesEqual (mode, match)) return mode; - dx = match->HDisplay - mode->HDisplay; - dy = match->VDisplay - mode->VDisplay; + dx = xf86ModeWidth (match, match_rotation) - xf86ModeWidth (mode, output->initial_rotation); + dy = xf86ModeHeight (match, match_rotation) - xf86ModeHeight (mode, output->initial_rotation); diff = dx * dx + dy * dy; if (target_mode == NULL || diff < target_diff) { @@ -589,7 +622,10 @@ xf86OutputHasPreferredMode (xf86OutputPtr output, int width, int height) for (mode = output->probed_modes; mode; mode = mode->next) { - if (mode->HDisplay > width || mode->VDisplay > height) continue; + if (xf86ModeWidth (mode, output->initial_rotation) > width || + xf86ModeHeight (mode, output->initial_rotation) > height) + continue; + if (mode->type & M_T_PREFERRED) return TRUE; } @@ -605,7 +641,7 @@ xf86PickCrtcs (ScrnInfoPtr scrn, int height) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); - int c, o, l; + int c, o; xf86OutputPtr output; xf86CrtcPtr crtc; xf86CrtcPtr *crtcs; @@ -663,13 +699,11 @@ xf86PickCrtcs (ScrnInfoPtr scrn, * see if they can be cloned */ if (xf86ModesEqual (modes[o], modes[n]) && + config->output[0]->initial_rotation == config->output[n]->initial_rotation && config->output[o]->initial_x == config->output[n]->initial_x && config->output[o]->initial_y == config->output[n]->initial_y) { - for (l = 0; l < config->num_output; l++) - if (output->possible_clones & (1 << l)) - break; - if (l == config->num_output) + if ((output->possible_clones & (1 << o)) == 0) continue; /* nope, try next CRTC */ } else @@ -712,8 +746,8 @@ xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp) if (crtc->enabled) { - crtc_width = crtc->x + crtc->desiredMode.HDisplay; - crtc_height = crtc->y + crtc->desiredMode.VDisplay; + crtc_width = crtc->x + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation); + crtc_height = crtc->y + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation); } for (o = 0; o < config->num_output; o++) { @@ -727,8 +761,12 @@ xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp) { if (mode->HDisplay > crtc_width) crtc_width = mode->HDisplay; + if (mode->VDisplay > crtc_width) + crtc_width = mode->VDisplay; if (mode->VDisplay > crtc_height) crtc_height = mode->VDisplay; + if (mode->HDisplay > crtc_height) + crtc_height = mode->HDisplay; } } } @@ -858,16 +896,16 @@ xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes) output->initial_y = relative->initial_y; switch (relation) { case OPTION_BELOW: - output->initial_y += modes[or]->VDisplay; + output->initial_y += xf86ModeHeight (modes[or], relative->initial_rotation); break; case OPTION_RIGHT_OF: - output->initial_x += modes[or]->HDisplay; + output->initial_x += xf86ModeWidth (modes[or], relative->initial_rotation); break; case OPTION_ABOVE: - output->initial_y -= modes[o]->VDisplay; + output->initial_y -= xf86ModeHeight (modes[or], relative->initial_rotation); break; case OPTION_LEFT_OF: - output->initial_x -= modes[o]->HDisplay; + output->initial_x -= xf86ModeWidth (modes[or], relative->initial_rotation); break; default: break; @@ -1208,6 +1246,8 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY) } } + output->initial_rotation = xf86OutputInitialRotation (output); + #ifdef DEBUG_REPROBE if (output->probed_modes != NULL) { xf86DrvMsg(scrn->scrnIndex, X_INFO, @@ -1310,6 +1350,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn) xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); int o, c; DisplayModePtr target_mode = NULL; + Rotation target_rotation = RR_Rotate_0; xf86CrtcPtr *crtcs; DisplayModePtr *modes; Bool *enabled; @@ -1351,6 +1392,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn) xf86OutputHasPreferredMode (output, width, height)) { target_mode = xf86DefaultMode (output, width, height); + target_rotation = output->initial_rotation; if (target_mode) { modes[o] = target_mode; @@ -1367,6 +1409,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn) if (enabled[o]) { target_mode = xf86DefaultMode (output, width, height); + target_rotation = output->initial_rotation; if (target_mode) { modes[o] = target_mode; @@ -1381,7 +1424,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn) xf86OutputPtr output = config->output[o]; if (enabled[o] && !modes[o]) - modes[o] = xf86ClosestMode (output, target_mode, width, height); + modes[o] = xf86ClosestMode (output, target_mode, target_rotation, width, height); } /* @@ -1429,6 +1472,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn) if (mode && crtc) { crtc->desiredMode = *mode; + crtc->desiredRotation = output->initial_rotation; crtc->enabled = TRUE; crtc->x = output->initial_x; crtc->y = output->initial_y; diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 07f7d4960..9a70be4b9 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -111,17 +111,23 @@ typedef struct _xf86CrtcFuncs { (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, int size); + /** + * Allocate the shadow area, delay the pixmap creation until needed + */ + void * + (*shadow_allocate) (xf86CrtcPtr crtc, int width, int height); + /** * Create shadow pixmap for rotation support */ PixmapPtr - (*shadow_create) (xf86CrtcPtr crtc, int width, int height); + (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height); /** * Destroy shadow pixmap */ void - (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap); + (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data); /** * Clean up driver-specific bits of the crtc @@ -159,6 +165,8 @@ struct _xf86Crtc { DisplayModeRec mode; Rotation rotation; PixmapPtr rotatedPixmap; + void *rotatedData; + /** * Position on screen * @@ -356,6 +364,11 @@ struct _xf86Output { */ int initial_x, initial_y; + /** + * Desired initial rotation + */ + Rotation initial_rotation; + /** * Current connection status * diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c index 0706783ae..37d0eb656 100644 --- a/hw/xfree86/modes/xf86Modes.c +++ b/hw/xfree86/modes/xf86Modes.c @@ -94,6 +94,36 @@ xf86ModeVRefresh(DisplayModePtr mode) return refresh; } +int +xf86ModeWidth (DisplayModePtr mode, Rotation rotation) +{ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_180: + return mode->HDisplay; + case RR_Rotate_90: + case RR_Rotate_270: + return mode->VDisplay; + default: + return 0; + } +} + +int +xf86ModeHeight (DisplayModePtr mode, Rotation rotation) +{ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_180: + return mode->VDisplay; + case RR_Rotate_90: + case RR_Rotate_270: + return mode->HDisplay; + default: + return 0; + } +} + /** Sets a default mode name of x on a mode. */ void xf86SetModeDefaultName(DisplayModePtr mode) diff --git a/hw/xfree86/modes/xf86Modes.h b/hw/xfree86/modes/xf86Modes.h index 60e279083..94943339e 100644 --- a/hw/xfree86/modes/xf86Modes.h +++ b/hw/xfree86/modes/xf86Modes.h @@ -36,6 +36,13 @@ double xf86ModeHSync(DisplayModePtr mode); double xf86ModeVRefresh(DisplayModePtr mode); + +int +xf86ModeWidth (DisplayModePtr mode, Rotation rotation); + +int +xf86ModeHeight (DisplayModePtr mode, Rotation rotation); + DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode); DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList); diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h index ce4d21796..6cfa5caa1 100644 --- a/hw/xfree86/modes/xf86Rename.h +++ b/hw/xfree86/modes/xf86Rename.h @@ -74,5 +74,7 @@ #define xf86RandR12SetRotations XF86NAME(xf86RandR12SetRotations) #define xf86SaveScreen XF86NAME(xf86SaveScreen) #define xf86CrtcSetScreenSubpixelOrder XF86NAME(xf86CrtcSetScreenSubpixelOrder) +#define xf86ModeWidth XF86NAME(xf86ModeWidth) +#define xf86ModeHeight XF86NAME(xf86ModeHeight) #endif /* _XF86RENAME_H_ */ diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 1d55a6e79..7b20498cc 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -44,36 +44,6 @@ #include "X11/extensions/dpms.h" #include "X11/Xatom.h" -static int -mode_height (DisplayModePtr mode, Rotation rotation) -{ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_180: - return mode->VDisplay; - case RR_Rotate_90: - case RR_Rotate_270: - return mode->HDisplay; - default: - return 0; - } -} - -static int -mode_width (DisplayModePtr mode, Rotation rotation) -{ - switch (rotation & 0xf) { - case RR_Rotate_0: - case RR_Rotate_180: - return mode->HDisplay; - case RR_Rotate_90: - case RR_Rotate_270: - return mode->VDisplay; - default: - return 0; - } -} - /* borrowed from composite extension, move to Render and publish? */ static VisualPtr @@ -237,6 +207,42 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) FreePicture (dst, None); } +static void +xf86RotatePrepare (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->rotatedData && !crtc->rotatedPixmap) + { + BoxRec damage_box; + RegionRec damage_region; + + crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, + crtc->rotatedData, + crtc->mode.HDisplay, + crtc->mode.VDisplay); + /* Hook damage to screen pixmap */ + DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + xf86_config->rotationDamage); + + damage_box.x1 = 0; + damage_box.y1 = 0; + damage_box.x2 = xf86ModeWidth (&crtc->mode, crtc->rotation); + damage_box.y2 = xf86ModeHeight (&crtc->mode, crtc->rotation); + REGION_INIT (pScreen, &damage_region, &damage_box, 1); + DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + &damage_region); + REGION_UNINIT (pScreen, &damage_region); + } + } +} + static void xf86RotateRedisplay(ScreenPtr pScreen) { @@ -247,6 +253,7 @@ xf86RotateRedisplay(ScreenPtr pScreen) if (!damage) return; + xf86RotatePrepare (pScreen); region = DamageRegion(damage); if (REGION_NOTEMPTY(pScreen, region)) { @@ -263,9 +270,9 @@ xf86RotateRedisplay(ScreenPtr pScreen) /* compute portion of damage that overlaps crtc */ box.x1 = crtc->x; - box.x2 = crtc->x + mode_width (&crtc->mode, crtc->rotation); + box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); box.y1 = crtc->y; - box.y2 = crtc->y + mode_height (&crtc->mode, crtc->rotation); + box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); REGION_INIT(pScreen, &crtc_damage, &box, 1); REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region); @@ -303,10 +310,11 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) if (rotation == RR_Rotate_0) { /* Free memory from rotation */ - if (crtc->rotatedPixmap) + if (crtc->rotatedPixmap || crtc->rotatedData) { - crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap); + crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData); crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; } if (xf86_config->rotationDamage) @@ -331,24 +339,24 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) */ int width = mode->HDisplay; int height = mode->VDisplay; + void *shadowData = crtc->rotatedData; PixmapPtr shadow = crtc->rotatedPixmap; int old_width = shadow ? shadow->drawable.width : 0; int old_height = shadow ? shadow->drawable.height : 0; - BoxRec damage_box; - RegionRec damage_region; /* Allocate memory for rotation */ if (old_width != width || old_height != height) { - if (shadow) + if (shadow || shadowData) { - crtc->funcs->shadow_destroy (crtc, shadow); + crtc->funcs->shadow_destroy (crtc, shadow, shadowData); crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; } - shadow = crtc->funcs->shadow_create (crtc, width, height); - if (!shadow) + shadowData = crtc->funcs->shadow_allocate (crtc, width, height); + if (!shadowData) goto bail1; - crtc->rotatedPixmap = shadow; + crtc->rotatedData = shadowData; } if (!xf86_config->rotationDamage) @@ -360,10 +368,6 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) if (!xf86_config->rotationDamage) goto bail2; - /* Hook damage to screen pixmap */ - DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - xf86_config->rotationDamage); - /* Assign block/wakeup handler */ if (!RegisterBlockAndWakeupHandlers (xf86RotateBlockHandler, xf86RotateWakeupHandler, @@ -371,14 +375,6 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) { goto bail3; } - damage_box.x1 = 0; - damage_box.y1 = 0; - damage_box.x2 = mode_width (mode, rotation); - damage_box.y2 = mode_height (mode, rotation); - REGION_INIT (pScreen, &damage_region, &damage_box, 1); - DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - &damage_region); - REGION_UNINIT (pScreen, &damage_region); } if (0) { @@ -387,14 +383,16 @@ bail3: xf86_config->rotationDamage = NULL; bail2: - if (shadow) + if (shadow || shadowData) { - crtc->funcs->shadow_destroy (crtc, shadow); + crtc->funcs->shadow_destroy (crtc, shadow, shadowData); crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; } bail1: if (old_width && old_height) crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, + NULL, old_width, old_height); return FALSE; diff --git a/hw/xfree86/modes/xf86cvt.c b/hw/xfree86/modes/xf86cvt.c index dd6febf2c..69ccc4259 100644 --- a/hw/xfree86/modes/xf86cvt.c +++ b/hw/xfree86/modes/xf86cvt.c @@ -40,6 +40,7 @@ #endif #include "xf86.h" +#include "xf86Modes.h" #include From 3d5e2bc5a622d09ba98c50df1018586dcba5c3df Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 16 Feb 2007 00:56:00 -0800 Subject: [PATCH 05/85] Respect rotation in initial screen size computation. --- hw/xfree86/modes/xf86RandR12.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 1dacb6f34..c8ea7785d 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -394,8 +394,8 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; - int crtc_width = crtc->x + crtc->mode.HDisplay; - int crtc_height = crtc->y + crtc->mode.VDisplay; + int crtc_width = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); + int crtc_height = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); if (crtc->enabled && crtc_width > width) width = crtc_width; From 0ab6c03c179cea58266f5fefc69931de395fcb24 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 16 Feb 2007 02:17:11 -0800 Subject: [PATCH 06/85] Ensure drivers can use new modes header files. New modes header files required a few minor changes to be used by external drivers, the most notable of which is the publication of the config file parser header files. --- hw/xfree86/modes/xf86Crtc.c | 3 +++ hw/xfree86/modes/xf86Crtc.h | 1 - hw/xfree86/modes/xf86DiDGA.c | 2 ++ hw/xfree86/modes/xf86Modes.c | 5 ----- hw/xfree86/modes/xf86Modes.h | 14 ++++++++++---- hw/xfree86/modes/xf86RandR12.c | 11 +++++------ hw/xfree86/parser/Makefile.am | 4 +++- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 74e4c76c7..37a3025d1 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -41,6 +41,9 @@ #define DPMS_SERVER #include "X11/extensions/dpms.h" #include "X11/Xatom.h" +#ifdef RENDER +#include "picturestr.h" +#endif /* * Initialize xf86CrtcConfig structure diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 9a70be4b9..756730e7b 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -28,7 +28,6 @@ #include "xf86Rename.h" #endif #include "xf86Modes.h" -#include "xf86Parser.h" #include "damage.h" /* Compat definitions for older X Servers. */ diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c index 551f052c9..0964cefa7 100644 --- a/hw/xfree86/modes/xf86DiDGA.c +++ b/hw/xfree86/modes/xf86DiDGA.c @@ -35,6 +35,8 @@ #include "xf86Crtc.h" #include "xf86Modes.h" #include "gcstruct.h" +#include "scrnintstr.h" +#include "windowstr.h" static Bool xf86_dga_get_modes (ScreenPtr pScreen) diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c index 37d0eb656..5b52bd76c 100644 --- a/hw/xfree86/modes/xf86Modes.c +++ b/hw/xfree86/modes/xf86Modes.c @@ -36,11 +36,6 @@ #endif #endif -#include -#include -#include - -#include "xf86.h" #include "xf86Modes.h" #include "xf86Priv.h" diff --git a/hw/xfree86/modes/xf86Modes.h b/hw/xfree86/modes/xf86Modes.h index 94943339e..2bd4edeba 100644 --- a/hw/xfree86/modes/xf86Modes.h +++ b/hw/xfree86/modes/xf86Modes.h @@ -25,11 +25,17 @@ * */ -#ifndef _I830_XF86MODES_H_ -#define _I830_XF86MODES_H_ +#ifndef _XF86MODES_H_ +#define _XF86MODES_H_ + +#include +#include +#include + +#include "xf86.h" #include "xorgVersion.h" -#include "xf86Parser.h" #include "edid.h" +#include "xf86Parser.h" #if XF86_MODES_RENAME #include "xf86Rename.h" #endif @@ -89,4 +95,4 @@ xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor); DisplayModePtr xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed); -#endif /* _I830_XF86MODES_H_ */ +#endif /* _XF86MODES_H_ */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index c8ea7785d..abdf92e78 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -496,19 +496,18 @@ void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) { XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - int c; - - randrp->supported_rotations = rotations; - #if RANDR_12_INTERFACE + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + int c; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; RRCrtcSetRotations (crtc->randr_crtc, rotations); } #endif + randrp->supported_rotations = rotations; } void diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am index 46ef79060..d9c4f4b5e 100644 --- a/hw/xfree86/parser/Makefile.am +++ b/hw/xfree86/parser/Makefile.am @@ -37,4 +37,6 @@ EXTRA_DIST = \ cpconfig.c sdk_HEADERS = \ - $(LIBHEADERS) + $(LIBHEADERS) \ + xf86Parser.h \ + xf86Optrec.h From 5f6f8616d862ce4a37f6d3df4bdbc44fd21cc82a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 16 Feb 2007 10:06:22 -0800 Subject: [PATCH 07/85] Don't set subpixel order during startup; the screen won't be ready. in xf86CrtcSetMode, scrn->pScreen will be NULL during server startup time, so don't try to set the subpixel order. subpixel order will be set in the randr initialization anyways. --- hw/xfree86/modes/xf86Crtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 37a3025d1..29042a0ee 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -313,7 +313,8 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, /* XXX free adjustedmode */ ret = TRUE; - xf86CrtcSetScreenSubpixelOrder (scrn->pScreen); + if (scrn->pScreen) + xf86CrtcSetScreenSubpixelOrder (scrn->pScreen); done: if (!ret) { From 69073a48e35d5f3cdd6a41d18d3b3cc94072b2c1 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 15 Feb 2007 19:09:00 +0200 Subject: [PATCH 08/85] os: fix client privates leak Minor leak here. Oops. (cherry picked from commit 811675733e97416c990e6dc9c19271b43d96248d) --- os/connection.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/os/connection.c b/os/connection.c index 96ad11921..98e83ae4c 100644 --- a/os/connection.c +++ b/os/connection.c @@ -1042,6 +1042,8 @@ CloseDownConnection(ClientPtr client) XdmcpCloseDisplay(oc->fd); #endif CloseDownFileDescriptor(oc); + FreeOsBuffers(oc); + xfree(client->osPrivate); client->osPrivate = (pointer)NULL; if (auditTrailLevel > 1) AuditF("client %d disconnected\n", client->index); From 33c2d2ce8ae00d89b91100cd5d7aba4b18b4117d Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 15 Feb 2007 16:14:57 +0200 Subject: [PATCH 09/85] kdrive/ephyr: free screen struct Free screen->driver on screenFini, instead of just leaking it. (cherry picked from commit 0f6dd4aea6176507dbe1c90c950d332fecbcaacb) --- hw/kdrive/ephyr/ephyr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index fbb16a465..7c39af361 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -675,6 +675,8 @@ ephyrRestore (KdCardInfo *card) void ephyrScreenFini (KdScreenInfo *screen) { + xfree(screen->driver); + screen->driver = NULL; } /* From 8a16682892dd73e1b17955ded89a74c077d54f7f Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 2 Feb 2007 14:44:55 -0800 Subject: [PATCH 10/85] Fix bus error on startup in 64-bit Xephyr hostx_get_visual_masks takes unsigned long * arguments, but was being passed pointers to CARD32's. (cherry picked from commit 5dcad9e9d7d9993d65f989219bee94a060bbf476) --- hw/kdrive/ephyr/ephyr.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index 7c39af361..6f2e3deb4 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -75,7 +75,8 @@ Bool ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv) { int width = 640, height = 480; - + unsigned long redMask, greenMask, blueMask; + if (hostx_want_screen_size(&width, &height) || !screen->width || !screen->height) { @@ -127,30 +128,24 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv) { screen->fb[0].depth = 15; screen->fb[0].bitsPerPixel = 16; - - hostx_get_visual_masks (&screen->fb[0].redMask, - &screen->fb[0].greenMask, - &screen->fb[0].blueMask); - } else if (screen->fb[0].depth <= 16) { screen->fb[0].depth = 16; screen->fb[0].bitsPerPixel = 16; - - hostx_get_visual_masks (&screen->fb[0].redMask, - &screen->fb[0].greenMask, - &screen->fb[0].blueMask); } else { screen->fb[0].depth = 24; screen->fb[0].bitsPerPixel = 32; - - hostx_get_visual_masks (&screen->fb[0].redMask, - &screen->fb[0].greenMask, - &screen->fb[0].blueMask); } + + hostx_get_visual_masks (&redMask, &greenMask, &blueMask); + + screen->fb[0].redMask = (Pixel) redMask; + screen->fb[0].greenMask = (Pixel) greenMask; + screen->fb[0].blueMask = (Pixel) blueMask; + } scrpriv->randr = screen->randr; From d3f507c2a2cc190d417a257b40a49a4a2926e3d3 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Tue, 6 Feb 2007 14:57:22 -0800 Subject: [PATCH 11/85] Add an RDTSC implementation to the x86 emulator. This instruction is being used in some debug VBIOSes. This implementation doesn't even try to be accurate. Instead, it just increments the counter by a fixed amount every time an rdtsc instruction in encountered, to avoid divides by zero. --- hw/xfree86/x86emu/ops2.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/x86emu/ops2.c b/hw/xfree86/x86emu/ops2.c index 7b0156aaa..8c6c53539 100644 --- a/hw/xfree86/x86emu/ops2.c +++ b/hw/xfree86/x86emu/ops2.c @@ -63,6 +63,40 @@ static void x86emuOp2_illegal_op( #define xorl(a,b) ((a) && !(b)) || (!(a) && (b)) +/**************************************************************************** +REMARKS: +Handles opcode 0x0f,0x31 +****************************************************************************/ +static void x86emuOp2_rdtsc(u8 X86EMU_UNUSED(op2)) +{ +#ifdef __HAS_LONG_LONG__ + static u64 counter = 0; +#else + static u32 counter = 0; +#endif + + counter += 0x10000; + + /* read timestamp counter */ + /* + * Note that instead of actually trying to accurately measure this, we just + * increase the counter by a fixed amount every time we hit one of these + * instructions. Feel free to come up with a better method. + */ + START_OF_INSTR(); + DECODE_PRINTF("RDTSC\n"); + TRACE_AND_STEP(); +#ifdef __HAS_LONG_LONG__ + M.x86.R_EAX = counter & 0xffffffff; + M.x86.R_EDX = counter >> 32; +#else + M.x86.R_EAX = counter; + M.x86.R_EDX = 0; +#endif + DECODE_CLEAR_SEGOVR(); + END_OF_INSTR(); +} + /**************************************************************************** REMARKS: Handles opcode 0x0f,0x80-0x8F @@ -2580,7 +2614,7 @@ void (*x86emu_optab2[256])(u8) = /* 0x2f */ x86emuOp2_illegal_op, /* 0x30 */ x86emuOp2_illegal_op, -/* 0x31 */ x86emuOp2_illegal_op, +/* 0x31 */ x86emuOp2_rdtsc, /* 0x32 */ x86emuOp2_illegal_op, /* 0x33 */ x86emuOp2_illegal_op, /* 0x34 */ x86emuOp2_illegal_op, From 6fd297e362af7e8d3770801f34cb84f757397898 Mon Sep 17 00:00:00 2001 From: Carl Switzky Date: Thu, 19 Oct 2006 17:30:54 -0700 Subject: [PATCH 12/85] Add ast driver/device info to Xorg server & config utilities (cherry picked from commit edd5f1745461f995670969cb736d1569ca94643f) --- hw/xfree86/common/xf86PciInfo.h | 4 ++++ hw/xfree86/utils/xorgcfg/text-mode.c | 1 + hw/xfree86/utils/xorgconfig/Cards | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/hw/xfree86/common/xf86PciInfo.h b/hw/xfree86/common/xf86PciInfo.h index b8ba73f6a..0630cfa82 100644 --- a/hw/xfree86/common/xf86PciInfo.h +++ b/hw/xfree86/common/xf86PciInfo.h @@ -92,6 +92,7 @@ #define PCI_VENDOR_TRITECH 0x1292 #define PCI_VENDOR_NVIDIA_SGS 0x12D2 #define PCI_VENDOR_VMWARE 0x15AD +#define PCI_VENDOR_AST 0x1A03 #define PCI_VENDOR_3DLABS 0x3D3D #define PCI_VENDOR_AVANCE_2 0x4005 #define PCI_VENDOR_HERCULES 0x4843 @@ -358,6 +359,9 @@ #define PCI_CHIP_RS350_7834 0x7834 #define PCI_CHIP_RS350_7835 0x7835 +/* ASPEED Technology (AST) */ +#define PCI_CHIP_AST2000 0x2000 + /* Avance Logic */ #define PCI_CHIP_ALG2064 0x2064 #define PCI_CHIP_ALG2301 0x2301 diff --git a/hw/xfree86/utils/xorgcfg/text-mode.c b/hw/xfree86/utils/xorgcfg/text-mode.c index 0430a5463..91d9be262 100644 --- a/hw/xfree86/utils/xorgcfg/text-mode.c +++ b/hw/xfree86/utils/xorgcfg/text-mode.c @@ -1128,6 +1128,7 @@ CardConfig(void) static char *xdrivers[] = { "apm", "ark", + "ast", "ati", "r128", "radeon", diff --git a/hw/xfree86/utils/xorgconfig/Cards b/hw/xfree86/utils/xorgconfig/Cards index bf30eab1d..b95928c37 100644 --- a/hw/xfree86/utils/xorgconfig/Cards +++ b/hw/xfree86/utils/xorgconfig/Cards @@ -51,6 +51,11 @@ NAME ** Ark Logic (generic) [ark] SERVER SVGA DRIVER ark +NAME ** ASPEED Technology (generic) [ast] +#CHIPSET ast +SERVER SVGA +DRIVER ast + NAME ** ATI (generic) [ati] #CHIPSET ati SERVER SVGA From 68b79fb193b72bacbdd03ad214bf105e269f2ec1 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 1 Nov 2006 14:34:46 -0800 Subject: [PATCH 13/85] Propogate $LIBS for xtrans, clock_gettime, libm, etc. to libs used for each server (cherry picked from commit 40f84793bca40dcc6883d51aefa1bda44bd1ac61) --- configure.ac | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 073edf75b..a54e06d1d 100644 --- a/configure.ac +++ b/configure.ac @@ -872,7 +872,7 @@ PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS]) PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS]) XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS}" -XSERVER_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} -lm" +XSERVER_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS}" AC_SUBST([SYS_LIBS]) AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], @@ -883,9 +883,9 @@ AC_MSG_CHECKING([for a useful monotonic clock ...]) if ! test "x$have_clock_gettime" = xno; then if ! test "x$have_clock_gettime" = xyes; then - LIBS="$have_clock_gettime" + CLOCK_LIBS="$have_clock_gettime" else - LIBS="" + CLOCK_LIBS="" fi AC_RUN_IFELSE([ @@ -910,7 +910,8 @@ AC_MSG_RESULT([$MONOTONIC_CLOCK]) if test "x$MONOTONIC_CLOCK" = xyes; then AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()]) - XSERVER_LIBS="$XSERVER_LIBS $LIBS" + XSERVER_LIBS="$XSERVER_LIBS $CLOCK_LIBS" + LIBS="$LIBS $CLOCK_LIBS" fi dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so @@ -988,7 +989,7 @@ AC_MSG_RESULT([$XVFB]) AM_CONDITIONAL(XVFB, [test "x$XVFB" = xyes]) if test "x$XVFB" = xyes; then - XVFB_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB" + XVFB_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB $LIBS" AC_SUBST([XVFB_LIBS]) fi @@ -1004,7 +1005,7 @@ AC_MSG_RESULT([$XNEST]) AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes]) if test "x$XNEST" = xyes; then - XNEST_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB" + XNEST_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB $LIBS" AC_SUBST([XNEST_LIBS]) fi @@ -1364,7 +1365,7 @@ AC_MSG_RESULT([$XPRINT]) if test "x$XPRINT" = xyes; then PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau]) XPRINT_EXTENSIONS="$XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS" - XPRINT_LIBS="$XPRINT_LIBS $DIX_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB" + XPRINT_LIBS="$XPRINT_LIBS $DIX_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB $LIBS" AC_SUBST([XPRINT_CFLAGS]) AC_SUBST([XPRINT_LIBS]) From 9ad0811a54cb041267554c3cda03fcb1602c9ddf Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 4 Dec 2006 13:36:30 -0800 Subject: [PATCH 14/85] Check for __sparc as well as __sparc__ for compatibility with Sun cc (gcc defines __sparc__, Sun cc defines __sparc) (cherry picked from commit f9f7d7f3be53c808abb5eaceb7a1abc55744a210) --- hw/xfree86/common/compiler.h | 4 ++-- hw/xfree86/common/xf86.h | 2 +- hw/xfree86/common/xf86Bus.c | 8 ++++---- hw/xfree86/common/xf86Bus.h | 2 +- hw/xfree86/common/xf86Configure.c | 8 ++++---- hw/xfree86/loader/xf86sym.c | 2 +- hw/xfree86/utils/xorgcfg/loadmod.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h index a330fadf4..ea995eda1 100644 --- a/hw/xfree86/common/compiler.h +++ b/hw/xfree86/common/compiler.h @@ -118,7 +118,7 @@ extern int ffs(unsigned long); # if defined(NO_INLINE) || defined(DO_PROTOTYPES) # if !defined(__arm__) -# if !defined(__sparc__) && !defined(__arm32__) \ +# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) \ && !(defined(__alpha__) && defined(linux)) \ && !(defined(__ia64__) && defined(linux)) \ @@ -1697,7 +1697,7 @@ static __inline__ void ppc_flush_icache(char *addr) : : "r"(addr) : "memory"); } -# elif defined(__sparc__) || defined(sparc) +# elif defined(__sparc__) || defined(sparc) || defined(__sparc) /* * Like powerpc, we provide byteswapping and no byteswapping functions * here with byteswapping as default, drivers that don't need byteswapping diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index 51125304e..485a4b300 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -64,7 +64,7 @@ extern ScrnInfoPtr xf86CurrentScreen; extern Bool pciSlotClaimed; extern Bool isaSlotClaimed; extern Bool fbSlotClaimed; -#ifdef __sparc__ +#if defined(__sparc__) || defined(__sparc) extern Bool sbusSlotClaimed; #endif extern confDRIRec xf86ConfigDRI; diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index e20837851..7617bf78a 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -113,7 +113,7 @@ void xf86BusProbe(void) { xf86PciProbe(); -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) xf86SbusProbe(); #endif } @@ -2373,7 +2373,7 @@ xf86PostProbe(void) if (fbSlotClaimed) { if (pciSlotClaimed || isaSlotClaimed -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) || sbusSlotClaimed #endif ) { @@ -3006,7 +3006,7 @@ xf86FindPrimaryDevice() } -#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) +#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) #include "vgaHW.h" #include "compiler.h" #endif @@ -3018,7 +3018,7 @@ static void CheckGenericGA() { /* This needs to be changed for multiple domains */ -#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__) +#if !defined(__sparc__) && !defined(__sparc) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__) IOADDRESS GenericIOBase = VGAHW_GET_IOBASE(); CARD8 CurrentValue, TestValue; diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h index b7d16089c..b638e9026 100644 --- a/hw/xfree86/common/xf86Bus.h +++ b/hw/xfree86/common/xf86Bus.h @@ -40,7 +40,7 @@ #define _XF86_BUS_H #include "xf86pciBus.h" -#ifdef __sparc__ +#if defined(__sparc__) || defined(__sparc) #include "xf86sbusBus.h" #endif diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c index cb091080c..3a6012123 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c @@ -48,7 +48,7 @@ #include "Configint.h" #include "vbe.h" #include "xf86DDC.h" -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) #include "xf86Bus.h" #include "xf86Sbus.h" #endif @@ -57,7 +57,7 @@ typedef struct _DevToConfig { GDevRec GDev; pciVideoPtr pVideo; -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) sbusDevicePtr sVideo; #endif int iDriver; @@ -134,7 +134,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int if (!DevToConfig[i].pVideo) return NULL; break; -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: for (i = 0; i < nDevToConfig; i++) if (DevToConfig[i].sVideo && @@ -213,7 +213,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int NewDevice.GDev.identifier = "ISA Adapter"; NewDevice.GDev.busID = "ISA"; break; -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: { char *promPath = NULL; NewDevice.sVideo = (sbusDevicePtr) busData; diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 2d1b88776..2f1f6af01 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -510,7 +510,7 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86AddModuleInfo) SYMFUNC(xf86DeleteModuleInfo) -#if defined(__sparc__) && !defined(__OpenBSD__) +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) /* xf86sbusBus.c */ SYMFUNC(xf86MatchSbusInstances) SYMFUNC(xf86GetSbusInfoForEntity) diff --git a/hw/xfree86/utils/xorgcfg/loadmod.c b/hw/xfree86/utils/xorgcfg/loadmod.c index 598d0c06a..6f83f3509 100644 --- a/hw/xfree86/utils/xorgcfg/loadmod.c +++ b/hw/xfree86/utils/xorgcfg/loadmod.c @@ -181,7 +181,7 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(xf86memchr) SYMFUNC(xf86memcmp) SYMFUNC(xf86memcpy) -#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) || defined(__ia64__) || defined (__amd64__) +#if (defined(__powerpc__) && (defined(Lynx) || defined(linux))) || defined(__sparc__) || defined(__sparc) || defined(__ia64__) || defined (__amd64__) /* * Some PPC, SPARC, and IA64 compilers generate calls to memcpy to handle * structure copies. This causes a problem both here and in shared From 63cc2a51ef87130c632a874672a8c9167f14314e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 18 Feb 2007 23:49:38 -0800 Subject: [PATCH 15/85] Add support for user-defined modelines in RandR. The RandR protocol spec has several requests in support of user-defined modes, but the implementation was stubbed out inside the X server. Fill out the DIX portion and start on the xf86 DDX portion. It might be necessary to add more code to the DDX to insert the user-defined modes into the output mode list. --- hw/xfree86/modes/xf86RandR12.c | 50 ++++++++ randr/mirandr.c | 17 ++- randr/randrstr.h | 34 ++++- randr/rrcrtc.c | 11 +- randr/rrinfo.c | 6 +- randr/rrmode.c | 218 ++++++++++++++++++++++++++++----- randr/rroutput.c | 98 +++++++++++++-- randr/rrscreen.c | 16 ++- 8 files changed, 400 insertions(+), 50 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index abdf92e78..4e8984c58 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -701,6 +701,54 @@ xf86RandR12OutputSetProperty (ScreenPtr pScreen, return output->funcs->set_property(output, property, value); } +static Bool +xf86RandR12OutputValidateMode (ScreenPtr pScreen, + RROutputPtr randr_output, + RRModePtr randr_mode) +{ + xf86OutputPtr output = randr_output->devPrivate; + DisplayModePtr mode = randr_mode->devPrivate; + + if (!mode) + { + mode = xalloc (sizeof (DisplayModeRec) + randr_mode->mode.nameLength + 1); + if (!mode) + return FALSE; + mode->name = (char *) mode + 1; + memcpy (mode->name, randr_mode->name, randr_mode->mode.nameLength); + mode->name[randr_mode->mode.nameLength] = '\0'; + mode->Clock = randr_mode->mode.dotClock / 1000; + mode->HDisplay = randr_mode->mode.width; + mode->HSyncStart = randr_mode->mode.hSyncStart; + mode->HSyncEnd = randr_mode->mode.hSyncEnd; + mode->HTotal = randr_mode->mode.hTotal; + mode->HSkew = randr_mode->mode.hSkew; + + mode->VDisplay = randr_mode->mode.height; + mode->VSyncStart = randr_mode->mode.vSyncStart; + mode->VSyncEnd = randr_mode->mode.vSyncEnd; + mode->VTotal = randr_mode->mode.vTotal; + + mode->Flags = randr_mode->mode.modeFlags; + randr_mode->devPrivate = mode; + } + if (!output->funcs->mode_valid (output, mode)) + return FALSE; + return TRUE; +} + +static void +xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode) +{ + DisplayModePtr mode = randr_mode->devPrivate; + + if (mode) + { + xfree (mode); + randr_mode->devPrivate = NULL; + } +} + /** * Given a list of xf86 modes and a RandR Output object, construct * RandR modes and assign them to the output @@ -932,6 +980,8 @@ xf86RandR12Init12 (ScreenPtr pScreen) rp->rrCrtcSet = xf86RandR12CrtcSet; rp->rrCrtcSetGamma = xf86RandR12CrtcSetGamma; rp->rrOutputSetProperty = xf86RandR12OutputSetProperty; + rp->rrOutputValidateMode = xf86RandR12OutputValidateMode; + rp->rrModeDestroy = xf86RandR12ModeDestroy; rp->rrSetConfig = NULL; pScrn->PointerMoved = xf86RandR12PointerMoved; if (!xf86RandR12CreateObjects12 (pScreen)) diff --git a/randr/mirandr.c b/randr/mirandr.c index 0b763e111..47136fb96 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -73,6 +73,20 @@ miRROutputSetProperty (ScreenPtr pScreen, return TRUE; } +Bool +miRROutputValidateMode (ScreenPtr pScreen, + RROutputPtr output, + RRModePtr mode) +{ + return FALSE; +} + +void +miRRModeDestroy (ScreenPtr pScreen, + RRModePtr mode) +{ +} + /* * This function assumes that only a single depth can be * displayed at a time, but that all visuals of that depth @@ -102,7 +116,8 @@ miRandRInit (ScreenPtr pScreen) pScrPriv->rrCrtcSet = miRRCrtcSet; pScrPriv->rrCrtcSetGamma = miRRCrtcSetGamma; pScrPriv->rrOutputSetProperty = miRROutputSetProperty; - + pScrPriv->rrOutputValidateMode = miRROutputValidateMode; + pScrPriv->rrModeDestroy = miRRModeDestroy; RRScreenSetSizeRange (pScreen, pScreen->width, pScreen->height, diff --git a/randr/randrstr.h b/randr/randrstr.h index f86f9b5d0..1fc2520be 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -80,7 +80,7 @@ struct _rrMode { xRRModeInfo mode; char *name; void *devPrivate; - Bool userDefined; + ScreenPtr userScreen; }; struct _rrPropertyValue { @@ -135,6 +135,8 @@ struct _rrOutput { int numModes; int numPreferred; RRModePtr *modes; + int numUserModes; + RRModePtr *userModes; Bool changed; RRPropertyPtr properties; void *devPrivate; @@ -164,6 +166,13 @@ typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr pScreen, Atom property, RRPropertyValuePtr value); +typedef Bool (*RROutputValidateModeProcPtr) (ScreenPtr pScreen, + RROutputPtr output, + RRModePtr mode); + +typedef void (*RRModeDestroyProcPtr) (ScreenPtr pScreen, + RRModePtr mode); + #endif typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation *rotations); @@ -208,6 +217,8 @@ typedef struct _rrScrPriv { RRCrtcSetProcPtr rrCrtcSet; RRCrtcSetGammaProcPtr rrCrtcSetGamma; RROutputSetPropertyProcPtr rrOutputSetProperty; + RROutputValidateModeProcPtr rrOutputValidateMode; + RRModeDestroyProcPtr rrModeDestroy; #endif /* @@ -394,6 +405,15 @@ miRROutputSetProperty (ScreenPtr pScreen, Atom property, RRPropertyValuePtr value); +Bool +miRROutputValidateMode (ScreenPtr pScreen, + RROutputPtr output, + RRModePtr mode); + +void +miRRModeDestroy (ScreenPtr pScreen, + RRModePtr mode); + /* randr.c */ /* * Send all pending events @@ -548,6 +568,10 @@ Bool RRCrtcGammaSetSize (RRCrtcPtr crtc, int size); +/* + * Return the area of the frame buffer scanned out by the crtc, + * taking into account the current mode and rotation + */ void RRCrtcGetScanoutSize(RRCrtcPtr crtc, int *width, int *height); @@ -671,6 +695,14 @@ RROutputSetModes (RROutputPtr output, int numModes, int numPreferred); +int +RROutputAddUserMode (RROutputPtr output, + RRModePtr mode); + +int +RROutputDeleteUserMode (RROutputPtr output, + RRModePtr mode); + Bool RROutputSetCrtcs (RROutputPtr output, RRCrtcPtr *crtcs, diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 2ae9040d1..a90b07289 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -655,10 +655,15 @@ ProcRRSetCrtcConfig (ClientPtr client) return BadMatch; } /* validate mode for this output */ - for (j = 0; j < outputs[i]->numModes; j++) - if (outputs[i]->modes[j] == mode) + for (j = 0; j < outputs[i]->numModes + outputs[i]->numUserModes; j++) + { + RRModePtr m = (j < outputs[i]->numModes ? + outputs[i]->modes[j] : + outputs[i]->userModes[j - outputs[i]->numModes]); + if (m == mode) break; - if (j == outputs[i]->numModes) + } + if (j == outputs[i]->numModes + outputs[i]->numUserModes) { if (outputs) xfree (outputs); diff --git a/randr/rrinfo.c b/randr/rrinfo.c index 797cdb1b4..549d501dc 100644 --- a/randr/rrinfo.c +++ b/randr/rrinfo.c @@ -157,9 +157,11 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) pScrPriv->nSizes = 0; /* find size bounds */ - for (i = 0; i < output->numModes; i++) + for (i = 0; i < output->numModes + output->numUserModes; i++) { - RRModePtr mode = output->modes[i]; + RRModePtr mode = (i < output->numModes ? + output->modes[i] : + output->userModes[i-output->numModes]); CARD16 width = mode->mode.width; CARD16 height = mode->mode.height; diff --git a/randr/rrmode.c b/randr/rrmode.c index 261e1b75f..e268cc2f3 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -48,25 +48,13 @@ RRModeEqual (xRRModeInfo *a, xRRModeInfo *b) static int num_modes; static RRModePtr *modes; -RRModePtr -RRModeGet (xRRModeInfo *modeInfo, - const char *name) +static RRModePtr +RRModeCreate (xRRModeInfo *modeInfo, + const char *name, + ScreenPtr userScreen) { - int i; - RRModePtr mode; - RRModePtr *newModes; - - for (i = 0; i < num_modes; i++) - { - mode = modes[i]; - if (RRModeEqual (&mode->mode, modeInfo) && - !memcmp (name, mode->name, modeInfo->nameLength)) - { - ++mode->refcnt; - return mode; - } - } - + RRModePtr mode, *newModes; + if (!RRInit ()) return NULL; @@ -78,7 +66,7 @@ RRModeGet (xRRModeInfo *modeInfo, mode->name = (char *) (mode + 1); memcpy (mode->name, name, modeInfo->nameLength); mode->name[modeInfo->nameLength] = '\0'; - mode->userDefined = FALSE; + mode->userScreen = userScreen; if (num_modes) newModes = xrealloc (modes, (num_modes + 1) * sizeof (RRModePtr)); @@ -104,11 +92,75 @@ RRModeGet (xRRModeInfo *modeInfo, return mode; } +static RRModePtr +RRModeFindByName (const char *name, + CARD16 nameLength) +{ + int i; + RRModePtr mode; + + for (i = 0; i < num_modes; i++) + { + mode = modes[i]; + if (mode->mode.nameLength == nameLength && + !memcmp (name, mode->name, nameLength)) + { + return mode; + } + } + return NULL; +} + +RRModePtr +RRModeGet (xRRModeInfo *modeInfo, + const char *name) +{ + int i; + + for (i = 0; i < num_modes; i++) + { + RRModePtr mode = modes[i]; + if (RRModeEqual (&mode->mode, modeInfo) && + !memcmp (name, mode->name, modeInfo->nameLength)) + { + ++mode->refcnt; + return mode; + } + } + + return RRModeCreate (modeInfo, name, NULL); +} + +static RRModePtr +RRModeCreateUser (ScreenPtr pScreen, + xRRModeInfo *modeInfo, + const char *name, + int *error) +{ + RRModePtr mode; + + mode = RRModeFindByName (name, modeInfo->nameLength); + if (mode) + { + *error = BadName; + return NULL; + } + + mode = RRModeCreate (modeInfo, name, pScreen); + if (!mode) + { + *error = BadAlloc; + return NULL; + } + *error = Success; + return mode; +} + RRModePtr * RRModesForScreen (ScreenPtr pScreen, int *num_ret) { rrScrPriv(pScreen); - int o, c; + int o, c, m; RRModePtr *screen_modes; int num_screen_modes = 0; @@ -122,9 +174,11 @@ RRModesForScreen (ScreenPtr pScreen, int *num_ret) RROutputPtr output = pScrPriv->outputs[o]; int m, n; - for (m = 0; m < output->numModes; m++) + for (m = 0; m < output->numModes + output->numUserModes; m++) { - RRModePtr mode = output->modes[m]; + RRModePtr mode = (m < output->numModes ? + output->modes[m] : + output->userModes[m-output->numModes]); for (n = 0; n < num_screen_modes; n++) if (screen_modes[n] == mode) break; @@ -150,6 +204,23 @@ RRModesForScreen (ScreenPtr pScreen, int *num_ret) if (n == num_screen_modes) screen_modes[num_screen_modes++] = mode; } + /* + * Add all user modes for this screen + */ + for (m = 0; m < num_modes; m++) + { + RRModePtr mode = modes[m]; + int n; + + if (mode->userScreen != pScreen) + continue; + for (n = 0; n < num_screen_modes; n++) + if (screen_modes[n] == mode) + break; + if (n == num_screen_modes) + screen_modes[num_screen_modes++] = mode; + } + *num_ret = num_screen_modes; return screen_modes; } @@ -205,38 +276,123 @@ int ProcRRCreateMode (ClientPtr client) { REQUEST(xRRCreateModeReq); + xRRCreateModeReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + xRRModeInfo *modeInfo; + long units_after; + char *name; + int error; + RRModePtr mode; - REQUEST_SIZE_MATCH(xRRCreateModeReq); - (void) stuff; - return BadImplementation; + REQUEST_AT_LEAST_SIZE (xRRCreateModeReq); + pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client, + SecurityReadAccess); + + if (!pWin) + return BadWindow; + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + modeInfo = &stuff->modeInfo; + name = (char *) (stuff + 1); + units_after = (stuff->length - (sizeof (xRRCreateModeReq) >> 2)); + + /* check to make sure requested name fits within the data provided */ + if ((int) (modeInfo->nameLength + 3) >> 2 > units_after) + return BadLength; + + mode = RRModeCreateUser (pScreen, modeInfo, name, &error); + if (!mode) + return error; + + rep.type = X_Reply; + rep.pad0 = 0; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.mode = mode->mode.id; + if (client->swapped) + { + int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.mode, n); + } + WriteToClient(client, sizeof(xRRCreateModeReply), (char *)&rep); + + return client->noClientException; } int ProcRRDestroyMode (ClientPtr client) { REQUEST(xRRDestroyModeReq); + RRModePtr mode; REQUEST_SIZE_MATCH(xRRDestroyModeReq); - (void) stuff; - return BadImplementation; + mode = LookupIDByType (stuff->mode, RRModeType); + if (!mode) + { + client->errorValue = stuff->mode; + return RRErrorBase + BadRRMode; + } + if (!mode->userScreen) + return BadMatch; + if (mode->refcnt > 1) + return BadAccess; + FreeResource (stuff->mode, 0); + return Success; } int ProcRRAddOutputMode (ClientPtr client) { REQUEST(xRRAddOutputModeReq); + RRModePtr mode; + RROutputPtr output; REQUEST_SIZE_MATCH(xRRAddOutputModeReq); - (void) stuff; - return BadImplementation; + output = LookupOutput(client, stuff->output, SecurityReadAccess); + + if (!output) + { + client->errorValue = stuff->output; + return RRErrorBase + BadRROutput; + } + + mode = LookupIDByType (stuff->mode, RRModeType); + if (!mode) + { + client->errorValue = stuff->mode; + return RRErrorBase + BadRRMode; + } + + return RROutputAddUserMode (output, mode); } int ProcRRDeleteOutputMode (ClientPtr client) { REQUEST(xRRDeleteOutputModeReq); + RRModePtr mode; + RROutputPtr output; REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq); - (void) stuff; - return BadImplementation; + output = LookupOutput(client, stuff->output, SecurityReadAccess); + + if (!output) + { + client->errorValue = stuff->output; + return RRErrorBase + BadRROutput; + } + + mode = LookupIDByType (stuff->mode, RRModeType); + if (!mode) + { + client->errorValue = stuff->mode; + return RRErrorBase + BadRRMode; + } + + return RROutputDeleteUserMode (output, mode); } diff --git a/randr/rroutput.c b/randr/rroutput.c index 8007a8a55..31ec92421 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -76,6 +76,8 @@ RROutputCreate (const char *name, output->numModes = 0; output->numPreferred = 0; output->modes = NULL; + output->numUserModes = 0; + output->userModes = NULL; output->properties = NULL; output->changed = FALSE; output->devPrivate = devPrivate; @@ -192,6 +194,74 @@ RROutputSetModes (RROutputPtr output, return TRUE; } +int +RROutputAddUserMode (RROutputPtr output, + RRModePtr mode) +{ + int m; + ScreenPtr pScreen = output->pScreen; + rrScrPriv(pScreen); + RRModePtr *newModes; + + /* Check to see if this mode is already listed for this output */ + for (m = 0; m < output->numModes + output->numUserModes; m++) + { + RRModePtr e = (m < output->numModes ? + output->modes[m] : + output->userModes[m - output->numModes]); + if (mode == e) + return Success; + } + + /* Check with the DDX to see if this mode is OK */ + if (pScrPriv->rrOutputValidateMode) + if (!pScrPriv->rrOutputValidateMode (pScreen, output, mode)) + return BadMatch; + + if (output->userModes) + newModes = xrealloc (output->userModes, + (output->numUserModes + 1) * sizeof (RRModePtr)); + else + newModes = xalloc (sizeof (RRModePtr)); + if (!newModes) + return BadAlloc; + + output->userModes = newModes; + output->userModes[output->numUserModes++] = mode; + ++mode->refcnt; + RROutputChanged (output, TRUE); + RRTellChanged (pScreen); + return Success; +} + +int +RROutputDeleteUserMode (RROutputPtr output, + RRModePtr mode) +{ + int m; + + /* Find this mode in the user mode list */ + for (m = 0; m < output->numUserModes; m++) + { + RRModePtr e = output->userModes[m]; + + if (mode == e) + break; + } + /* Not there, access error */ + if (m == output->numUserModes) + return BadAccess; + + /* make sure the mode isn't active for this output */ + if (output->crtc && output->crtc->mode == mode) + return BadMatch; + + memmove (output->userModes + m, output->userModes + m + 1, + (output->numUserModes - m - 1) * sizeof (RRModePtr)); + RRModeDestroy (mode); + return Success; +} + Bool RROutputSetCrtcs (RROutputPtr output, RRCrtcPtr *crtcs, @@ -308,9 +378,9 @@ RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output) * Destroy a Output at shutdown */ void -RROutputDestroy (RROutputPtr crtc) +RROutputDestroy (RROutputPtr output) { - FreeResource (crtc->id, 0); + FreeResource (output->id, 0); } static int @@ -318,6 +388,7 @@ RROutputDestroyResource (pointer value, XID pid) { RROutputPtr output = (RROutputPtr) value; ScreenPtr pScreen = output->pScreen; + int m; if (pScreen) { @@ -335,8 +406,15 @@ RROutputDestroyResource (pointer value, XID pid) } } } + /* XXX destroy all modes? */ if (output->modes) xfree (output->modes); + + for (m = 0; m < output->numUserModes; m++) + RRModeDestroy (output->userModes[m]); + if (output->userModes) + xfree (output->userModes); + if (output->crtcs) xfree (output->crtcs); if (output->clones) @@ -383,7 +461,10 @@ ProcRRGetOutputInfo (ClientPtr client) output = LookupOutput(client, stuff->output, SecurityReadAccess); if (!output) + { + client->errorValue = stuff->output; return RRErrorBase + BadRROutput; + } pScreen = output->pScreen; pScrPriv = rrGetScrPriv(pScreen); @@ -398,13 +479,13 @@ ProcRRGetOutputInfo (ClientPtr client) rep.connection = output->connection; rep.subpixelOrder = output->subpixelOrder; rep.nCrtcs = output->numCrtcs; - rep.nModes = output->numModes; + rep.nModes = output->numModes + output->numUserModes; rep.nPreferred = output->numPreferred; rep.nClones = output->numClones; rep.nameLength = output->nameLength; extraLen = ((output->numCrtcs + - output->numModes + + output->numModes + output->numUserModes + output->numClones + ((rep.nameLength + 3) >> 2)) << 2); @@ -420,7 +501,7 @@ ProcRRGetOutputInfo (ClientPtr client) crtcs = (RRCrtc *) extra; modes = (RRMode *) (crtcs + output->numCrtcs); - clones = (RROutput *) (modes + output->numModes); + clones = (RROutput *) (modes + output->numModes + output->numUserModes); name = (char *) (clones + output->numClones); for (i = 0; i < output->numCrtcs; i++) @@ -429,9 +510,12 @@ ProcRRGetOutputInfo (ClientPtr client) if (client->swapped) swapl (&crtcs[i], n); } - for (i = 0; i < output->numModes; i++) + for (i = 0; i < output->numModes + output->numUserModes; i++) { - modes[i] = output->modes[i]->mode.id; + if (i < output->numModes) + modes[i] = output->modes[i]->mode.id; + else + modes[i] = output->userModes[i - output->numModes]->mode.id; if (client->swapped) swapl (&modes[i], n); } diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 7a33ef674..8aa26fa90 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -479,7 +479,7 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output) { RR10DataPtr data; RRScreenSizePtr size; - int nmode = output->numModes; + int nmode = output->numModes + output->numUserModes; int o, os, l, r; RRScreenRatePtr refresh; CARD16 vRefresh; @@ -506,11 +506,14 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output) /* * find modes not yet listed */ - for (o = 0; o < output->numModes; o++) + for (o = 0; o < output->numModes + output->numUserModes; o++) { if (used[o]) continue; - mode = output->modes[o]; + if (o < output->numModes) + mode = output->modes[o]; + else + mode = output->userModes[o - output->numModes]; l = data->nsize; size[l].id = data->nsize; @@ -530,9 +533,12 @@ RR10GetData (ScreenPtr pScreen, RROutputPtr output) /* * Find all modes with matching size */ - for (os = o; os < output->numModes; os++) + for (os = o; os < output->numModes + output->numUserModes; os++) { - mode = output->modes[os]; + if (os < output->numModes) + mode = output->modes[os]; + else + mode = output->userModes[os - output->numModes]; if (mode->mode.width == size[l].width && mode->mode.height == size[l].height) { From d3e3490ac02cfe31b04637f847b30acf849a619a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 19 Feb 2007 15:28:37 -0800 Subject: [PATCH 16/85] Check for clientGone before sending events from XFixes (bug #1753). Freeing resources during client closedown can cause cursor changes which attempt to send cursor events through the XFixes extension; a client in the process of closing down has no file to send events to, causing a crash when this path is hit. (cherry picked from commit 8a42af6a935b1cf0e15102e986bb527f4fab31a8) --- xfixes/cursor.c | 3 ++- xfixes/select.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xfixes/cursor.c b/xfixes/cursor.c index c75e74442..bfccadb0c 100755 --- a/xfixes/cursor.c +++ b/xfixes/cursor.c @@ -143,7 +143,8 @@ CursorDisplayCursor (ScreenPtr pScreen, CursorCurrent = pCursor; for (e = cursorEvents; e; e = e->next) { - if (e->eventMask & XFixesDisplayCursorNotifyMask) + if ((e->eventMask & XFixesDisplayCursorNotifyMask) && + !e->pClient->clientGone) { xXFixesCursorNotifyEvent ev; ev.type = XFixesEventBase + XFixesCursorNotify; diff --git a/xfixes/select.c b/xfixes/select.c index 4c7a49def..77f2c2702 100755 --- a/xfixes/select.c +++ b/xfixes/select.c @@ -78,7 +78,9 @@ XFixesSelectionCallback (CallbackListPtr *callbacks, pointer data, pointer args) } for (e = selectionEvents; e; e = e->next) { - if (e->selection == selection->selection && (e->eventMask & eventMask)) + if (e->selection == selection->selection && + (e->eventMask & eventMask) && + !e->pClient->clientGone) { xXFixesSelectionNotifyEvent ev; From 3506b9376c2b0db09bfff58d64e07af88a6e8195 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 20 Feb 2007 23:04:26 -0800 Subject: [PATCH 17/85] Eliminate RRModeRec devPrivate field. The xf86 mode setting code was mis-using this field to try and store a pointer to a DisplayModeRec, however, each output has its own copy of every DisplayModeRec leaving the one in in the RRModeRec devPrivate field pointing at a random DisplayModeRec. Instead of attempting to rectify this, eliminating the devPrivate entirely turned out to be very easy; the DDX code now accepts an arbitrary RRModeRec structure and set that to the hardware, converting it on the fly to a DisplayModeRec as needed. --- hw/xfree86/modes/xf86RandR12.c | 147 +++++++++++++++++++++++---------- randr/randrstr.h | 1 - 2 files changed, 103 insertions(+), 45 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 4e8984c58..79580f03f 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -529,6 +529,56 @@ xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y) } #if RANDR_12_INTERFACE + +#define FLAG_BITS (RR_HSyncPositive | \ + RR_HSyncNegative | \ + RR_VSyncPositive | \ + RR_VSyncNegative | \ + RR_Interlace | \ + RR_DoubleScan | \ + RR_CSync | \ + RR_CSyncPositive | \ + RR_CSyncNegative | \ + RR_HSkewPresent | \ + RR_BCast | \ + RR_PixelMultiplex | \ + RR_DoubleClock | \ + RR_ClockDivideBy2) + +static Bool +xf86RandRModeMatches (RRModePtr randr_mode, + DisplayModePtr mode) +{ +#if 0 + if (match_name) + { + /* check for same name */ + int len = strlen (mode->name); + if (randr_mode->mode.nameLength != len) return FALSE; + if (memcmp (randr_mode->name, mode->name, len) != 0) return FALSE; + } +#endif + + /* check for same timings */ + if (randr_mode->mode.dotClock / 1000 != mode->Clock) return FALSE; + if (randr_mode->mode.width != mode->HDisplay) return FALSE; + if (randr_mode->mode.hSyncStart != mode->HSyncStart) return FALSE; + if (randr_mode->mode.hSyncEnd != mode->HSyncEnd) return FALSE; + if (randr_mode->mode.hTotal != mode->HTotal) return FALSE; + if (randr_mode->mode.hSkew != mode->HSkew) return FALSE; + if (randr_mode->mode.height != mode->VDisplay) return FALSE; + if (randr_mode->mode.vSyncStart != mode->VSyncStart) return FALSE; + if (randr_mode->mode.vSyncEnd != mode->VSyncEnd) return FALSE; + if (randr_mode->mode.vTotal != mode->VTotal) return FALSE; + + /* check for same flags (using only the XF86 valid flag bits) */ + if ((randr_mode->mode.modeFlags & FLAG_BITS) != (mode->Flags & FLAG_BITS)) + return FALSE; + + /* everything matches */ + return TRUE; +} + static Bool xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc) { @@ -567,12 +617,15 @@ xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc) * We make copies of modes, so pointer equality * isn't sufficient */ - for (j = 0; j < randr_output->numModes; j++) + for (j = 0; j < randr_output->numModes + randr_output->numUserModes; j++) { - DisplayModePtr outMode = randr_output->modes[j]->devPrivate; - if (xf86ModesEqual(mode, outMode)) + RRModePtr m = (j < randr_output->numModes ? + randr_output->modes[j] : + randr_output->userModes[j-randr_output->numModes]); + + if (xf86RandRModeMatches (m, mode)) { - randr_mode = randr_output->modes[j]; + randr_mode = m; break; } } @@ -584,6 +637,39 @@ xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc) return ret; } +/* + * Convert a RandR mode to a DisplayMode + */ +static void +xf86RandRModeConvert (ScrnInfoPtr scrn, + RRModePtr randr_mode, + DisplayModePtr mode) +{ + mode->prev = NULL; + mode->next = NULL; + mode->name = NULL; + mode->status = MODE_OK; + mode->type = 0; + + mode->Clock = randr_mode->mode.dotClock / 1000; + + mode->HDisplay = randr_mode->mode.width; + mode->HSyncStart = randr_mode->mode.hSyncStart; + mode->HSyncEnd = randr_mode->mode.hSyncEnd; + mode->HTotal = randr_mode->mode.hTotal; + mode->HSkew = randr_mode->mode.hSkew; + + mode->VDisplay = randr_mode->mode.height; + mode->VSyncStart = randr_mode->mode.vSyncStart; + mode->VSyncEnd = randr_mode->mode.vSyncEnd; + mode->VTotal = randr_mode->mode.vTotal; + mode->VScan = 0; + + mode->Flags = randr_mode->mode.modeFlags & FLAG_BITS; + + xf86SetModeCrtc (mode, scrn->adjustFlags); +} + static Bool xf86RandR12CrtcSet (ScreenPtr pScreen, RRCrtcPtr randr_crtc, @@ -597,16 +683,15 @@ xf86RandR12CrtcSet (ScreenPtr pScreen, ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); xf86CrtcPtr crtc = randr_crtc->devPrivate; - DisplayModePtr mode = randr_mode ? randr_mode->devPrivate : NULL; Bool changed = FALSE; int o, ro; xf86CrtcPtr *save_crtcs; Bool save_enabled = crtc->enabled; save_crtcs = ALLOCATE_LOCAL(config->num_crtc * sizeof (xf86CrtcPtr)); - if ((mode != NULL) != crtc->enabled) + if ((randr_mode != NULL) != crtc->enabled) changed = TRUE; - else if (mode && !xf86ModesEqual (&crtc->mode, mode)) + else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode)) changed = TRUE; if (rotation != crtc->rotation) @@ -640,11 +725,14 @@ xf86RandR12CrtcSet (ScreenPtr pScreen, /* XXX need device-independent mode setting code through an API */ if (changed) { - crtc->enabled = mode != NULL; + crtc->enabled = randr_mode != NULL; - if (mode) + if (randr_mode) { - if (!xf86CrtcSetMode (crtc, mode, rotation, x, y)) + DisplayModeRec mode; + + xf86RandRModeConvert (pScrn, randr_mode, &mode); + if (!xf86CrtcSetMode (crtc, &mode, rotation, x, y)) { crtc->enabled = save_enabled; for (o = 0; o < config->num_output; o++) @@ -658,7 +746,7 @@ xf86RandR12CrtcSet (ScreenPtr pScreen, /* * Save the last successful setting for EnterVT */ - crtc->desiredMode = *mode; + crtc->desiredMode = mode; crtc->desiredRotation = rotation; crtc->desiredX = x; crtc->desiredY = y; @@ -706,33 +794,12 @@ xf86RandR12OutputValidateMode (ScreenPtr pScreen, RROutputPtr randr_output, RRModePtr randr_mode) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86OutputPtr output = randr_output->devPrivate; - DisplayModePtr mode = randr_mode->devPrivate; + DisplayModeRec mode; - if (!mode) - { - mode = xalloc (sizeof (DisplayModeRec) + randr_mode->mode.nameLength + 1); - if (!mode) - return FALSE; - mode->name = (char *) mode + 1; - memcpy (mode->name, randr_mode->name, randr_mode->mode.nameLength); - mode->name[randr_mode->mode.nameLength] = '\0'; - mode->Clock = randr_mode->mode.dotClock / 1000; - mode->HDisplay = randr_mode->mode.width; - mode->HSyncStart = randr_mode->mode.hSyncStart; - mode->HSyncEnd = randr_mode->mode.hSyncEnd; - mode->HTotal = randr_mode->mode.hTotal; - mode->HSkew = randr_mode->mode.hSkew; - - mode->VDisplay = randr_mode->mode.height; - mode->VSyncStart = randr_mode->mode.vSyncStart; - mode->VSyncEnd = randr_mode->mode.vSyncEnd; - mode->VTotal = randr_mode->mode.vTotal; - - mode->Flags = randr_mode->mode.modeFlags; - randr_mode->devPrivate = mode; - } - if (!output->funcs->mode_valid (output, mode)) + xf86RandRModeConvert (pScrn, randr_mode, &mode); + if (output->funcs->mode_valid (output, &mode) != MODE_OK) return FALSE; return TRUE; } @@ -740,13 +807,6 @@ xf86RandR12OutputValidateMode (ScreenPtr pScreen, static void xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode) { - DisplayModePtr mode = randr_mode->devPrivate; - - if (mode) - { - xfree (mode); - randr_mode->devPrivate = NULL; - } } /** @@ -795,7 +855,6 @@ xf86RROutputSetModes (RROutputPtr randr_output, DisplayModePtr modes) rrmode = RRModeGet (&modeInfo, mode->name); if (rrmode) { - rrmode->devPrivate = mode; rrmodes[nmode++] = rrmode; npreferred += pref; } diff --git a/randr/randrstr.h b/randr/randrstr.h index 1fc2520be..396810332 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -79,7 +79,6 @@ struct _rrMode { int refcnt; xRRModeInfo mode; char *name; - void *devPrivate; ScreenPtr userScreen; }; From 1fbb3458a5620f87486a24156f6aafdc4eca99b8 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 23 Feb 2007 15:20:35 -0500 Subject: [PATCH 18/85] Don't install libi2c.a --- hw/xfree86/i2c/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/i2c/Makefile.am b/hw/xfree86/i2c/Makefile.am index f7c04345f..d2f48e30a 100644 --- a/hw/xfree86/i2c/Makefile.am +++ b/hw/xfree86/i2c/Makefile.am @@ -1,4 +1,4 @@ -module_LIBRARIES = libi2c.a +noinst_LIBRARIES = libi2c.a multimediadir = $(moduledir)/multimedia multimedia_LTLIBRARIES = \ From ee3000f97d7561b2137e247495468a17e6e3b4c3 Mon Sep 17 00:00:00 2001 From: Drew Parsons Date: Sun, 4 Mar 2007 16:00:52 +1100 Subject: [PATCH 19/85] Support for Hurd and other non-linux GNU systems. Non-linux GNU systems such as Hurd will define __GLIBC__ or __GNU__ rather than __linux__. This must be tested for in order to get byteswap.h included. See commit 594d180fe4f5d508569f9b263799da5af5a97087 (24 Dec 2006) and other related patches (fixed in upstream HEAD then, why was the patch not brought across to the 1.3 branch?). --- GL/glx/indirect_dispatch_swap.c | 2 +- GL/glx/indirect_program.c | 2 +- GL/glx/indirect_texture_compression.c | 2 +- GL/glx/swap_interval.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GL/glx/indirect_dispatch_swap.c b/GL/glx/indirect_dispatch_swap.c index 9c58ef1cd..136f0d010 100644 --- a/GL/glx/indirect_dispatch_swap.c +++ b/GL/glx/indirect_dispatch_swap.c @@ -28,7 +28,7 @@ #include #include #include -#ifdef __linux__ +#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) #include #elif defined(__OpenBSD__) #include diff --git a/GL/glx/indirect_program.c b/GL/glx/indirect_program.c index d0fd3d135..eae128a26 100644 --- a/GL/glx/indirect_program.c +++ b/GL/glx/indirect_program.c @@ -46,7 +46,7 @@ #include "dispatch.h" #include "glapioffsets.h" -#ifdef __linux__ +#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) #include #elif defined(__OpenBSD__) #include diff --git a/GL/glx/indirect_texture_compression.c b/GL/glx/indirect_texture_compression.c index 0c42ea034..11f63c2f0 100644 --- a/GL/glx/indirect_texture_compression.c +++ b/GL/glx/indirect_texture_compression.c @@ -39,7 +39,7 @@ #include "glthread.h" #include "dispatch.h" -#ifdef __linux__ +#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) #include #elif defined(__OpenBSD__) #include diff --git a/GL/glx/swap_interval.c b/GL/glx/swap_interval.c index bcc1c4793..f049ce51d 100644 --- a/GL/glx/swap_interval.c +++ b/GL/glx/swap_interval.c @@ -40,7 +40,7 @@ #include "dispatch.h" #include "glapioffsets.h" -#ifdef __linux__ +#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) #include #elif defined(__OpenBSD__) #include From aeabf2a1f873f884b8a8c33b1517c3f3cab4c7f5 Mon Sep 17 00:00:00 2001 From: Drew Parsons Date: Sun, 4 Mar 2007 16:28:54 +1100 Subject: [PATCH 20/85] Xprint: fix font symlinks Change symlinks to Xprint base fonts in model/PSdefault using local relative links. This facilitates moving the Xprint config files, for instance for FHS compliance placing data files in /usr/share rather than /usr/lib. Also ensures NewCenturySchlbk-BoldItalic.pmf is installed. --- hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am | 2 +- hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am | 2 +- hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am | 1 + hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am b/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am index 5be5419ba..c574c5cde 100644 --- a/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am @@ -1,6 +1,6 @@ xpcdir = @xpconfigdir@/C/print/models/CANONC3200-PS/fonts -parentdir = @xpconfigdir@/C/print/models/PSdefault/fonts +parentdir = ../../PSdefault/fonts XPFONTS = \ AvantGarde-Book.pmf \ diff --git a/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am b/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am index 2ff9ab7e7..634db1f39 100644 --- a/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am @@ -1,6 +1,6 @@ xpcdir = @xpconfigdir@/C/print/models/HPLJ4050-PS/fonts -parentdir = @xpconfigdir@/C/print/models/PSdefault/fonts +parentdir = ../../PSdefault/fonts XPFONTS = \ AvantGarde-Book.pmf \ diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am index e7ddb6c0f..1e8c8a781 100644 --- a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am @@ -18,6 +18,7 @@ dist_xpc_DATA = \ LubalinGraph-DemiOblique.pmf \ LubalinGraph-Demi.pmf \ NewCenturySchlbk-Bold.pmf \ + NewCenturySchlbk-BoldItalic.pmf \ NewCenturySchlbk-Italic.pmf \ NewCenturySchlbk-Roman.pmf \ Souvenir-DemiItalic.pmf \ diff --git a/hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am b/hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am index 8cc269459..d1ee6cf42 100644 --- a/hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am @@ -1,6 +1,6 @@ xpcdir = @xpconfigdir@/C/print/models/SPSPARC2/fonts -parentdir = @xpconfigdir@/C/print/models/PSdefault/fonts +parentdir = ../../PSdefault/fonts XPFONTS = \ Courier-Bold.pmf \ From 0104f5737bf16ad9cdf0cd3a0e20328c5364e8c7 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Mon, 26 Feb 2007 17:45:40 -0800 Subject: [PATCH 21/85] Return BadMatch if a client tries to clone non-cloneable outputs. (cherry picked from commit 8b245758845523d5f8f017bb9d0e9aa57b616c28) --- randr/rrcrtc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index a90b07289..3cdf12c9f 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -670,6 +670,27 @@ ProcRRSetCrtcConfig (ClientPtr client) return BadMatch; } } + /* validate clones */ + for (i = 0; i < numOutputs; i++) + { + for (j = 0; j < numOutputs; j++) + { + int k; + if (i == j) + continue; + for (k = 0; k < outputs[i]->numClones; k++) + { + if (outputs[i]->clones[k] == outputs[j]) + break; + } + if (k == outputs[i]->numClones) + { + if (outputs) + xfree (outputs); + return BadMatch; + } + } + } pScreen = crtc->pScreen; pScrPriv = rrGetScrPriv(pScreen); From 8a0a0d7db04c657c3b7e2e37f78f68f19d478983 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Wed, 28 Feb 2007 16:09:11 -0800 Subject: [PATCH 22/85] Don't crash setting a NULL mode with a randr classic DDX. Also remember to update the screen size during modesets. --- randr/rrcrtc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 3cdf12c9f..43a6fcac9 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -299,6 +299,12 @@ RRCrtcSet (RRCrtcPtr crtc, RRScreenRate rate; Bool ret; + if (!mode) + { + RRCrtcNotify (crtc, NULL, x, y, rotation, 0, NULL); + return TRUE; + } + size.width = mode->mode.width; size.height = mode->mode.height; if (outputs[0]->mmWidth && outputs[0]->mmHeight) @@ -319,7 +325,10 @@ RRCrtcSet (RRCrtcPtr crtc, * Old 1.0 interface tied screen size to mode size */ if (ret) + { RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs); + RRScreenSizeNotify (pScreen); + } return ret; } #endif From 1ce0c6877a2c1c2d7c78c7f496e91dd3493257eb Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Wed, 28 Feb 2007 13:36:58 -0800 Subject: [PATCH 23/85] Add a screen resize hook to xf86CrtcConfigRec. This hook is called when the DDX needs to resize the screen. The driver is responsible for changing virtualX and virtualY, along with any other related screen properties (devPrivate.ptr, devKind, displayWidth, etc.). Use the size range from the crtc config instead of randrp->virtual[XY] when reporting the min and max screen sizes to the DDX. --- hw/xfree86/modes/xf86Crtc.c | 6 +++++- hw/xfree86/modes/xf86Crtc.h | 24 +++++++++++++++++++++++- hw/xfree86/modes/xf86RandR12.c | 24 +++++++++++++++--------- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 29042a0ee..ebc0f8fc7 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -52,13 +52,17 @@ int xf86CrtcConfigPrivateIndex = -1; void -xf86CrtcConfigInit (ScrnInfoPtr scrn) +xf86CrtcConfigInit (ScrnInfoPtr scrn, + const xf86CrtcConfigFuncsRec *funcs) { xf86CrtcConfigPtr config; if (xf86CrtcConfigPrivateIndex == -1) xf86CrtcConfigPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); config = xnfcalloc (1, sizeof (xf86CrtcConfigRec)); + + config->funcs = funcs; + scrn->privates[xf86CrtcConfigPrivateIndex].ptr = config; } diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 756730e7b..345332b5d 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -407,6 +407,25 @@ struct _xf86Output { #endif }; +typedef struct _xf86CrtcConfigFuncs { + /** + * Requests that the driver resize the screen. + * + * The driver is responsible for updating scrn->virtualX and scrn->virtualY. + * If the requested size cannot be set, the driver should leave those values + * alone and return FALSE. + * + * A naive driver that cannot reallocate the screen may simply change + * virtual[XY]. A more advanced driver will want to also change the + * devPrivate.ptr and devKind of the screen pixmap, update any offscreen + * pixmaps it may have moved, and change pScrn->displayWidth. + */ + Bool + (*resize)(ScrnInfoPtr scrn, + int width, + int height); +} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr; + typedef struct _xf86CrtcConfig { int num_output; xf86OutputPtr *output; @@ -435,6 +454,8 @@ typedef struct _xf86CrtcConfig { int dga_width, dga_height, dga_stride; DisplayModePtr dga_save_mode; + const xf86CrtcConfigFuncsRec *funcs; + } xf86CrtcConfigRec, *xf86CrtcConfigPtr; extern int xf86CrtcConfigPrivateIndex; @@ -446,7 +467,8 @@ extern int xf86CrtcConfigPrivateIndex; */ void -xf86CrtcConfigInit (ScrnInfoPtr scrn); +xf86CrtcConfigInit (ScrnInfoPtr scrn, + const xf86CrtcConfigFuncsRec *funcs); void xf86CrtcSetSizeRange (ScrnInfoPtr scrn, diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 79580f03f..1a349ef0e 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -335,8 +335,9 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen, { XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); WindowPtr pRoot = WindowTable[pScreen->myNum]; - Bool ret = TRUE; + Bool ret = FALSE; if (randrp->virtualX == -1 || randrp->virtualY == -1) { @@ -345,20 +346,26 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen, } if (pRoot) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); - pScrn->virtualX = width; - pScrn->virtualY = height; - pScreen->width = pScrn->virtualX; - pScreen->height = pScrn->virtualY; + /* Let the driver update virtualX and virtualY */ + if (!(*config->funcs->resize)(pScrn, width, height)) + goto finish; + + ret = TRUE; + + pScreen->width = width; + pScreen->height = height; pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1); xf86SetViewport (pScreen, 0, 0); + +finish: if (pRoot) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); #if RANDR_12_INTERFACE - if (WindowTable[pScreen->myNum]) + if (WindowTable[pScreen->myNum] && ret) RRScreenSizeNotify (pScreen); #endif return ret; @@ -1011,15 +1018,14 @@ xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) { int c; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); for (c = 0; c < config->num_crtc; c++) xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); - RRScreenSetSizeRange (pScreen, 320, 240, - randrp->virtualX, randrp->virtualY); + RRScreenSetSizeRange (pScreen, config->minWidth, config->minHeight, + config->maxWidth, config->maxHeight); return TRUE; } From 629515a159d49dfc11004bac32e9da747e595099 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Wed, 28 Feb 2007 14:26:47 -0800 Subject: [PATCH 24/85] Add a canGrow argument to xf86InitialConfiguration. canGrow indicates to the DDX that the driver can enlarge the desktop via the xf86_config->funcs->resize hook. If so, xf86InitialConfiguration will set virtual[XY] to match the configuration it chooses and will leave the crtc config size ranges alone. If FALSE, it will bloat the screen to fit the largest probed mode and also set the crtc config max size to limit the desktop to the initial virtual[XY] size. --- hw/xfree86/modes/xf86Crtc.c | 78 +++++++++++++++++++++++++------------ hw/xfree86/modes/xf86Crtc.h | 2 +- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index ebc0f8fc7..c53d2a87b 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -734,12 +734,16 @@ xf86PickCrtcs (ScrnInfoPtr scrn, /* * Compute the virtual size necessary to place all of the available - * crtcs in the specified configuration and also large enough to - * resize any crtc to the largest available mode + * crtcs in the specified configuration. + * + * canGrow indicates that the driver can make the screen larger than its initial + * configuration. If FALSE, this function will enlarge the screen to include + * the largest available mode. */ static void -xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp) +xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp, + Bool canGrow) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); int width = 0, height = 0; @@ -757,26 +761,28 @@ xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp) crtc_width = crtc->x + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation); crtc_height = crtc->y + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation); } - for (o = 0; o < config->num_output; o++) - { - xf86OutputPtr output = config->output[o]; + if (!canGrow) { + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; - for (s = 0; s < config->num_crtc; s++) - if (output->possible_crtcs & (1 << s)) - { - DisplayModePtr mode; - for (mode = output->probed_modes; mode; mode = mode->next) + for (s = 0; s < config->num_crtc; s++) + if (output->possible_crtcs & (1 << s)) { - if (mode->HDisplay > crtc_width) - crtc_width = mode->HDisplay; - if (mode->VDisplay > crtc_width) - crtc_width = mode->VDisplay; - if (mode->VDisplay > crtc_height) - crtc_height = mode->VDisplay; - if (mode->HDisplay > crtc_height) - crtc_height = mode->HDisplay; + DisplayModePtr mode; + for (mode = output->probed_modes; mode; mode = mode->next) + { + if (mode->HDisplay > crtc_width) + crtc_width = mode->HDisplay; + if (mode->VDisplay > crtc_width) + crtc_width = mode->VDisplay; + if (mode->VDisplay > crtc_height) + crtc_height = mode->VDisplay; + if (mode->HDisplay > crtc_height) + crtc_height = mode->HDisplay; + } } - } + } } if (crtc_width > width) width = crtc_width; @@ -1350,10 +1356,17 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn) * * Given auto-detected (and, eventually, configured) values, * construct a usable configuration for the system + * + * canGrow indicates that the driver can resize the screen to larger than its + * initially configured size via the config->funcs->resize hook. If TRUE, this + * function will set virtualX and virtualY to match the initial configuration + * and leave config->max{Width,Height} alone. If FALSE, it will bloat + * virtual[XY] to include the largest modes and set config->max{Width,Height} + * accordingly. */ Bool -xf86InitialConfiguration (ScrnInfoPtr scrn) +xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); int o, c; @@ -1491,9 +1504,10 @@ xf86InitialConfiguration (ScrnInfoPtr scrn) if (scrn->display->virtualX == 0) { /* - * Expand virtual size to cover potential mode switches + * Expand virtual size to cover the current config and potential mode + * switches, if the driver can't enlarge the screen later. */ - xf86DefaultScreenLimits (scrn, &width, &height); + xf86DefaultScreenLimits (scrn, &width, &height, canGrow); scrn->display->virtualX = width; scrn->display->virtualY = height; @@ -1503,7 +1517,23 @@ xf86InitialConfiguration (ScrnInfoPtr scrn) scrn->virtualX = width; if (height > scrn->virtualY) scrn->virtualY = height; - + + /* + * Make sure the configuration isn't too small. + */ + if (width < config->minWidth || height < config->minHeight) + return FALSE; + + /* + * Limit the crtc config to virtual[XY] if the driver can't grow the + * desktop. + */ + if (!canGrow) + { + xf86CrtcSetSizeRange (scrn, config->minWidth, config->minHeight, + width, height); + } + /* Mirror output modes to scrn mode list */ xf86SetScrnInfoModes (scrn); diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 345332b5d..b04f7f3f1 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -545,7 +545,7 @@ void xf86SetScrnInfoModes (ScrnInfoPtr pScrn); Bool -xf86InitialConfiguration (ScrnInfoPtr pScrn); +xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow); void xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); From 2a50ca2160bc05af1c24421ec079e902ff730277 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 4 Mar 2007 17:06:37 -0800 Subject: [PATCH 25/85] Handle non-zero origin rotated crtc. Damage crtc area on re-rotate. Box transformation from source to dest area was broken, leaving the wrong areas painted when the crtc origin was non-zero. When rotating from left to right, the pixmap doesn't get reallocated, and so no damage was left in the pixmap from xf86RotatePrepare. Separately damage the whole crtc area when this occurs to repaint the area. --- hw/xfree86/modes/xf86Rotate.c | 88 ++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 28 deletions(-) diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 7b20498cc..ef637eea0 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -69,31 +69,44 @@ compWindowFormat (WindowPtr pWin) } static void -xf86RotateBox (BoxPtr dst, BoxPtr src, Rotation rotation, - int dest_width, int dest_height) +xf86TranslateBox (BoxPtr b, int dx, int dy) { + b->x1 += dx; + b->y1 += dy; + b->x2 += dx; + b->y2 += dy; +} + +static void +xf86TransformBox (BoxPtr dst, BoxPtr src, Rotation rotation, + int xoff, int yoff, + int dest_width, int dest_height) +{ + BoxRec stmp = *src; + + xf86TranslateBox (&stmp, -xoff, -yoff); switch (rotation & 0xf) { default: case RR_Rotate_0: - *dst = *src; + *dst = stmp; break; case RR_Rotate_90: - dst->x1 = src->y1; - dst->y1 = dest_height - src->x2; - dst->x2 = src->y2; - dst->y2 = dest_height - src->x1; + dst->x1 = stmp.y1; + dst->y1 = dest_height - stmp.x2; + dst->x2 = stmp.y2; + dst->y2 = dest_height - stmp.x1; break; case RR_Rotate_180: - dst->x1 = dest_width - src->x2; - dst->y1 = dest_height - src->y2; - dst->x2 = dest_width - src->x1; - dst->y2 = dest_height - src->y1; + dst->x1 = dest_width - stmp.x2; + dst->y1 = dest_height - stmp.y2; + dst->x2 = dest_width - stmp.x1; + dst->y2 = dest_height - stmp.y1; break; case RR_Rotate_270: - dst->x1 = dest_width - src->y2; - dst->y1 = src->x1; - dst->y2 = src->x2; - dst->x2 = dest_width - src->y1; + dst->x1 = dest_width - stmp.y2; + dst->y1 = stmp.x1; + dst->y2 = stmp.x2; + dst->x2 = dest_width - stmp.y1; break; } if (rotation & RR_Reflect_X) { @@ -194,8 +207,11 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) { BoxRec dst_box; - xf86RotateBox (&dst_box, b, crtc->rotation, - crtc->mode.HDisplay, crtc->mode.VDisplay); + ErrorF ("painting %d,%d - %d,%d\n", + b->x1, b->y1, b->x2, b->y2); + xf86TransformBox (&dst_box, b, crtc->rotation, + crtc->x, crtc->y, + crtc->mode.HDisplay, crtc->mode.VDisplay); CompositePicture (PictOpSrc, src, NULL, dst, dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1, @@ -207,6 +223,26 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) FreePicture (dst, None); } +static void +xf86CrtcDamageShadow (xf86CrtcPtr crtc) +{ + ScrnInfoPtr pScrn = crtc->scrn; + BoxRec damage_box; + RegionRec damage_region; + ScreenPtr pScreen = pScrn->pScreen; + + damage_box.x1 = crtc->x; + damage_box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); + damage_box.y1 = crtc->y; + damage_box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); + ErrorF ("damaged %d,%d - %d,%d\n", + damage_box.x1, damage_box.y1, damage_box.x2, damage_box.y2); + REGION_INIT (pScreen, &damage_region, &damage_box, 1); + DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + &damage_region); + REGION_UNINIT (pScreen, &damage_region); +} + static void xf86RotatePrepare (ScreenPtr pScreen) { @@ -220,9 +256,6 @@ xf86RotatePrepare (ScreenPtr pScreen) if (crtc->rotatedData && !crtc->rotatedPixmap) { - BoxRec damage_box; - RegionRec damage_region; - crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc, crtc->rotatedData, crtc->mode.HDisplay, @@ -231,14 +264,7 @@ xf86RotatePrepare (ScreenPtr pScreen) DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, xf86_config->rotationDamage); - damage_box.x1 = 0; - damage_box.y1 = 0; - damage_box.x2 = xf86ModeWidth (&crtc->mode, crtc->rotation); - damage_box.y2 = xf86ModeHeight (&crtc->mode, crtc->rotation); - REGION_INIT (pScreen, &damage_region, &damage_box, 1); - DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - &damage_region); - REGION_UNINIT (pScreen, &damage_region); + xf86CrtcDamageShadow (crtc); } } } @@ -357,6 +383,12 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) if (!shadowData) goto bail1; crtc->rotatedData = shadowData; + /* shadow will be damaged in xf86RotatePrepare */ + } + else + { + /* mark shadowed area as damaged so it will be repainted */ + xf86CrtcDamageShadow (crtc); } if (!xf86_config->rotationDamage) From e6af7569f201842b4754aec6e72b30dc2daefdfb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 4 Mar 2007 17:15:24 -0800 Subject: [PATCH 26/85] Remove debugging ErrorF from rotation code. --- hw/xfree86/modes/xf86Rotate.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index ef637eea0..6826b6277 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -143,10 +143,9 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) &include_inferiors, serverClient, &error); - if (!src) { - ErrorF("couldn't create src pict\n"); + if (!src) return; - } + dst = CreatePicture (None, &dst_pixmap->drawable, format, @@ -154,10 +153,8 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) NULL, serverClient, &error); - if (!dst) { - ErrorF("couldn't create src pict\n"); + if (!dst) return; - } memset (&transform, '\0', sizeof (transform)); transform.matrix[2][2] = IntToxFixed(1); @@ -198,17 +195,13 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region) } error = SetPictureTransform (src, &transform); - if (error) { - ErrorF("Couldn't set transform\n"); + if (error) return; - } while (n--) { BoxRec dst_box; - ErrorF ("painting %d,%d - %d,%d\n", - b->x1, b->y1, b->x2, b->y2); xf86TransformBox (&dst_box, b, crtc->rotation, crtc->x, crtc->y, crtc->mode.HDisplay, crtc->mode.VDisplay); @@ -235,8 +228,6 @@ xf86CrtcDamageShadow (xf86CrtcPtr crtc) damage_box.x2 = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation); damage_box.y1 = crtc->y; damage_box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation); - ErrorF ("damaged %d,%d - %d,%d\n", - damage_box.x1, damage_box.y1, damage_box.x2, damage_box.y2); REGION_INIT (pScreen, &damage_region, &damage_box, 1); DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, &damage_region); From 90f5e77eab88522d64c6e20cd77a7a680eab3b1b Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 26 Feb 2007 09:40:00 +1100 Subject: [PATCH 27/85] modes: add commit/prepare hooks (cherry picked from commit 2e31872e05c2408d53ba0182bcddc5dabb3615fe) --- hw/xfree86/modes/xf86Crtc.c | 10 +++++----- hw/xfree86/modes/xf86Crtc.h | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index c53d2a87b..8b13e2bdb 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -282,7 +282,7 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, goto done; } - /* Disable the outputs and CRTCs before setting the mode. */ + /* Prepare the outputs and CRTCs before setting the mode. */ for (i = 0; i < xf86_config->num_output; i++) { xf86OutputPtr output = xf86_config->output[i]; @@ -290,10 +290,10 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, continue; /* Disable the output as the first thing we do. */ - output->funcs->dpms(output, DPMSModeOff); + output->funcs->prepare(output); } - crtc->funcs->dpms(crtc, DPMSModeOff); + crtc->funcs->prepare(crtc); /* Set up the DPLL and any output state that needs to adjust or depend * on the DPLL. @@ -307,12 +307,12 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, } /* Now, enable the clocks, plane, pipe, and outputs that we set up. */ - crtc->funcs->dpms(crtc, DPMSModeOn); + crtc->funcs->commit(crtc); for (i = 0; i < xf86_config->num_output; i++) { xf86OutputPtr output = xf86_config->output[i]; if (output->crtc == crtc) - output->funcs->dpms(output, DPMSModeOn); + output->funcs->commit(output); } /* XXX free adjustedmode */ diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index b04f7f3f1..c8aafc1ea 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -96,6 +96,12 @@ typedef struct _xf86CrtcFuncs { DisplayModePtr mode, DisplayModePtr adjusted_mode); + /** + * Prepare CRTC for an upcoming mode set. + */ + void + (*prepare)(xf86CrtcPtr crtc); + /** * Callback for setting up a video mode after fixups have been made. */ @@ -105,6 +111,12 @@ typedef struct _xf86CrtcFuncs { DisplayModePtr adjusted_mode, int x, int y); + /** + * Commit mode changes to a CRTC + */ + void + (*commit)(xf86CrtcPtr crtc); + /* Set the color ramps for the CRTC to the given values. */ void (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, @@ -263,6 +275,18 @@ typedef struct _xf86OutputFuncs { DisplayModePtr mode, DisplayModePtr adjusted_mode); + /** + * Callback for preparing mode changes on an output + */ + void + (*prepare)(xf86OutputPtr output); + + /** + * Callback for committing mode changes on an output + */ + void + (*commit)(xf86OutputPtr output); + /** * Callback for setting up a video mode after fixups have been made. * From 6b63fb399a904c3953b7b347483980a9768c7878 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 5 Mar 2007 13:46:41 +1100 Subject: [PATCH 28/85] add a standard connector type and name for us as an output property (cherry picked from commit 8ba5e8d82014b774a52f3e050ddbbb8bde4e0933) --- hw/xfree86/modes/xf86Crtc.c | 9 +++++++++ hw/xfree86/modes/xf86Crtc.h | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 8b13e2bdb..2ffa9567c 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1738,3 +1738,12 @@ xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus) return xf86DoEDID_DDC2 (scrn->scrnIndex, pDDCBus); } + +static char *_xf86ConnectorNames[] = { "None", "VGA", "DVI-I", "DVI-D", + "DVI-A", "Composite", "S-Video", + "Component", "LFP", "Proprietary" }; +char * +xf86ConnectorGetName(xf86ConnectorType connector) +{ + return _xf86ConnectorNames[connector]; +} diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index c8aafc1ea..537df3a3b 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -41,6 +41,20 @@ typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr; typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr; +/* define a standard for connector types */ +typedef enum _xf86ConnectorType { + XF86ConnectorNone, + XF86ConnectorVGA, + XF86ConnectorDVI_I, + XF86ConnectorDVI_D, + XF86ConnectorDVI_A, + XF86ConnectorComposite, + XF86ConnectorSvideo, + XF86ConnectorComponent, + XF86ConnectorLFP, + XF86ConnectorProprietary, +} xf86ConnectorType; + typedef enum _xf86OutputStatus { XF86OutputStatusConnected, XF86OutputStatusDisconnected, @@ -618,4 +632,10 @@ xf86DiDGAReInit (ScreenPtr pScreen); void xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen); +/* + * Get a standard string name for a connector type + */ +char * +xf86ConnectorGetName(xf86ConnectorType connector); + #endif /* _XF86CRTC_H_ */ From e707604ab3fd45c1f9d07b666181fc181e68a827 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 27 Feb 2007 09:55:48 -0800 Subject: [PATCH 29/85] Sun bug 6529003: Xorg should not be including on Solaris was removed from the latest Solaris Nevada build, but it's been useless to Xorg for a long time (it only declared a couple of kernel variables) --- hw/xfree86/os-support/xf86_OSlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h index e04854729..934c52a86 100644 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -130,8 +130,8 @@ typedef signed long xf86ssize_t; # include # if defined(_NEED_SYSI86) -# include # if !(defined (sun) && defined (SVR4)) +# include # include # endif # include From cb86fced0e379badd96af5ad303710af30fafd2e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 4 Mar 2007 19:48:40 -0800 Subject: [PATCH 30/85] Set version to 1.3-rc1 (1.2.99.901). --- configure.ac | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index a54e06d1d..c2909267b 100644 --- a/configure.ac +++ b/configure.ac @@ -25,11 +25,25 @@ dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) dnl This is the not the Xorg version number, it's the server version number. dnl Yes, that's weird. -AC_INIT([xorg-server], 1.2.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +AC_INIT([xorg-server], 1.2.99.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE +dnl +dnl Make sure these line up with the version number above. Automatically +dnl extracting them would be cool. +dnl + +DEFAULT_VENDOR_NAME="The X.Org Foundation" +DEFAULT_VENDOR_NAME_SHORT="X.Org" +DEFAULT_VERSION_MAJOR=1 +DEFAULT_VERSION_MINOR=2 +DEFAULT_VERSION_PATCH=99 +DEFAULT_VERSION_SNAP=901 +DEFAULT_RELEASE_DATE="4 March 2007" +DEFAULT_VENDOR_WEB="http://wiki.x.org" + dnl this gets generated by autoheader, and thus contains all the defines. we dnl don't ever actually use it, internally. AC_CONFIG_HEADERS(include/do-not-use-config.h) @@ -292,14 +306,6 @@ OSNAME=`uname -srm` AC_DEFINE_UNQUOTED(OSNAME, "$OSNAME", [Define to OS Name string to display for build OS in Xorg log]) -DEFAULT_VENDOR_NAME="The X.Org Foundation" -DEFAULT_VENDOR_NAME_SHORT="X.Org" -DEFAULT_VERSION_MAJOR=7 -DEFAULT_VERSION_MINOR=2 -DEFAULT_VERSION_PATCH=0 -DEFAULT_VERSION_SNAP=0 -DEFAULT_RELEASE_DATE="22 January 2007" -DEFAULT_VENDOR_WEB="http://wiki.x.org" m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))]) From 73904d953f2f9cbe941a215ba240b46bc7a61357 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 4 Mar 2007 21:07:35 -0800 Subject: [PATCH 31/85] Xprint includes a filename which is too long for tar. --- hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am index 1e8c8a781..e7ddb6c0f 100644 --- a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am @@ -18,7 +18,6 @@ dist_xpc_DATA = \ LubalinGraph-DemiOblique.pmf \ LubalinGraph-Demi.pmf \ NewCenturySchlbk-Bold.pmf \ - NewCenturySchlbk-BoldItalic.pmf \ NewCenturySchlbk-Italic.pmf \ NewCenturySchlbk-Roman.pmf \ Souvenir-DemiItalic.pmf \ From 5a595c1f767a8d666348b845d18934aee0cfe38f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 3 Mar 2007 23:10:31 -0800 Subject: [PATCH 32/85] Move xf86SetSingleMode into X server from intel driver. This function applies a single mode to the screen (as from RandR 1.1, XFree86-VidModeExtension or XFree86-DGA) using a policy that selects one output to reconfigure to the requested mode and then makes all other outputs fit within that size. --- hw/xfree86/modes/xf86Crtc.c | 126 ++++++++++++++++++++++++++++++++++++ hw/xfree86/modes/xf86Crtc.h | 6 ++ 2 files changed, 132 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 2ffa9567c..3d28293c8 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1542,6 +1542,132 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) 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 + * selection. Find the closest one, in the following preference order: + * + * - Equality + * - Closer in size to the requested mode, but no larger + * - Closer in refresh rate to the requested mode. + */ + +DisplayModePtr +xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired) +{ + DisplayModePtr best = NULL, scan = NULL; + + for (scan = output->probed_modes; scan != NULL; scan = scan->next) + { + /* If there's an exact match, we're done. */ + if (xf86ModesEqual(scan, desired)) { + best = desired; + break; + } + + /* Reject if it's larger than the desired mode. */ + if (scan->HDisplay > desired->HDisplay || + scan->VDisplay > desired->VDisplay) + { + continue; + } + + /* + * If we haven't picked a best mode yet, use the first + * one in the size range + */ + if (best == NULL) + { + best = scan; + continue; + } + + /* Find if it's closer to the right size than the current best + * option. + */ + if ((scan->HDisplay > best->HDisplay && + scan->VDisplay >= best->VDisplay) || + (scan->HDisplay >= best->HDisplay && + scan->VDisplay > best->VDisplay)) + { + best = scan; + continue; + } + + /* Find if it's still closer to the right refresh than the current + * best resolution. + */ + if (scan->HDisplay == best->HDisplay && + scan->VDisplay == best->VDisplay && + (fabs(scan->VRefresh - desired->VRefresh) < + fabs(best->VRefresh - desired->VRefresh))) { + best = scan; + } + } + return best; +} + +/** + * When setting a mode through XFree86-VidModeExtension or XFree86-DGA, + * take the specified mode and apply it to the crtc connected to the compat + * output. Then, find similar modes for the other outputs, as with the + * InitialConfiguration code above. The goal is to clone the desired + * mode across all outputs that are currently active. + */ + +Bool +xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + Bool ok = TRUE; + xf86OutputPtr compat_output = config->output[config->compat_output]; + DisplayModePtr compat_mode; + int c; + + /* + * Let the compat output drive the final mode selection + */ + compat_mode = xf86OutputFindClosestMode (compat_output, desired); + if (compat_mode) + desired = compat_mode; + + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + DisplayModePtr crtc_mode = NULL; + int o; + + if (!crtc->enabled) + continue; + + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + DisplayModePtr output_mode; + + /* skip outputs not on this crtc */ + if (output->crtc != crtc) + continue; + + if (crtc_mode) + { + output_mode = xf86OutputFindClosestMode (output, crtc_mode); + if (output_mode != crtc_mode) + output->crtc = NULL; + } + else + crtc_mode = xf86OutputFindClosestMode (output, desired); + } + if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0)) + ok = FALSE; + else + crtc->desiredMode = *crtc_mode; + } + xf86DisableUnusedFunctions(pScrn); + return ok; +} + + /** * Set the DPMS power mode of all outputs and CRTCs. * diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 537df3a3b..56c7769cf 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -594,6 +594,12 @@ xf86SaveScreen(ScreenPtr pScreen, int mode); void xf86DisableUnusedFunctions(ScrnInfoPtr pScrn); +DisplayModePtr +xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired); + +Bool +xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation); + /** * Set the EDID information for the specified output */ From bcade98ccaa18298d844a606cb44271f0254c185 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 Mar 2007 22:07:01 -0800 Subject: [PATCH 33/85] 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. --- 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 843077f23a1b49bd712d931421753e3a09d4008c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 Mar 2007 23:36:00 -0800 Subject: [PATCH 34/85] 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. --- 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 1a349ef0e..4213fea52 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 3f5cedf00a82f08a433c95ffbb7f8ac69dcf6a50 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 Mar 2007 23:49:35 -0800 Subject: [PATCH 35/85] 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. --- 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; From 558a4f5588ad2ec11254e0b5d6ce9515b137369e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 6 Mar 2007 23:15:34 -0800 Subject: [PATCH 36/85] Add xf86CrtcScreenInit to share initialization across drivers. xf86CrtcScreenInit performs initialization that needs to happen at ScreenInit time. --- hw/xfree86/modes/xf86Crtc.c | 54 +++++++++++++++++++++++++++++++++++ hw/xfree86/modes/xf86Crtc.h | 23 +++------------ hw/xfree86/modes/xf86Rename.h | 1 + 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 46515fdcc..279449688 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -545,6 +545,60 @@ xf86OutputDestroy (xf86OutputPtr output) xfree (output); } +/* + * Called during CreateScreenResources to hook up RandR + */ +static Bool +xf86CrtcCreateScreenResources (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + + screen->CreateScreenResources = config->CreateScreenResources; + + if (!(*screen->CreateScreenResources)(screen)) + return FALSE; + + if (!xf86RandR12CreateScreenResources (screen)) + return FALSE; + + return TRUE; +} + +/* + * Called at ScreenInit time to set up + */ +Bool +xf86CrtcScreenInit (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + /* Rotation */ + xf86DrvMsg(scrn->scrnIndex, X_INFO, "RandR 1.2 enabled, ignore the following RandR disabled message.\n"); + xf86DisableRandR(); /* Disable old RandR extension support */ + xf86RandR12Init (screen); + + /* support all rotations if every crtc has the shadow alloc funcs */ + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + if (!crtc->funcs->shadow_allocate || !crtc->funcs->shadow_create) + break; + } + if (c == config->num_crtc) + xf86RandR12SetRotations (screen, RR_Rotate_0 | RR_Rotate_90 | + RR_Rotate_180 | RR_Rotate_270); + else + xf86RandR12SetRotations (screen, RR_Rotate_0); + + /* Wrap CreateScreenResources so we can initialize the RandR code */ + config->CreateScreenResources = screen->CreateScreenResources; + screen->CreateScreenResources = xf86CrtcCreateScreenResources; + return TRUE; +} + static DisplayModePtr xf86DefaultMode (xf86OutputPtr output, int width, int height) { diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 062a2dbec..6152ae4c9 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -494,6 +494,7 @@ typedef struct _xf86CrtcConfig { const xf86CrtcConfigFuncsRec *funcs; + CreateScreenResourcesProcPtr CreateScreenResources; } xf86CrtcConfigRec, *xf86CrtcConfigPtr; extern int xf86CrtcConfigPrivateIndex; @@ -524,25 +525,6 @@ void xf86CrtcDestroy (xf86CrtcPtr crtc); -/** - * Allocate a crtc for the specified output - * - * Find a currently unused CRTC which is suitable for - * the specified output - */ - -xf86CrtcPtr -xf86AllocCrtc (xf86OutputPtr output); - -/** - * Free a crtc - * - * Mark the crtc as unused by any outputs - */ - -void -xf86FreeCrtc (xf86CrtcPtr crtc); - /** * Sets the given video mode on the given crtc */ @@ -582,6 +564,9 @@ xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY); void xf86SetScrnInfoModes (ScrnInfoPtr pScrn); +Bool +xf86CrtcScreenInit (ScreenPtr pScreen); + Bool xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow); diff --git a/hw/xfree86/modes/xf86Rename.h b/hw/xfree86/modes/xf86Rename.h index eae6d64d5..9dcfef5da 100644 --- a/hw/xfree86/modes/xf86Rename.h +++ b/hw/xfree86/modes/xf86Rename.h @@ -31,6 +31,7 @@ #define xf86CrtcDestroy XF86NAME(xf86CrtcDestroy) #define xf86CrtcInUse XF86NAME(xf86CrtcInUse) #define xf86CrtcRotate XF86NAME(xf86CrtcRotate) +#define xf86CrtcScreenInit XF86NAME(xf86CrtcScreenInit) #define xf86CrtcSetMode XF86NAME(xf86CrtcSetMode) #define xf86CrtcSetSizeRange XF86NAME(xf86CrtcSetSizeRange) #define xf86CVTMode XF86NAME(xf86CVTMode) From a59c31b0f7b94ed1f395c7586c37ef5fe7ba2a25 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 6 Mar 2007 23:19:30 -0800 Subject: [PATCH 37/85] Add hw/xfree86/docs/README.modes, documenting new mode setting APIs. This document covers both API and xorg.conf usage of the new mode setting APIs. --- hw/xfree86/doc/README.modes | 474 ++++++++++++++++++++++++++++++++++++ 1 file changed, 474 insertions(+) create mode 100644 hw/xfree86/doc/README.modes diff --git a/hw/xfree86/doc/README.modes b/hw/xfree86/doc/README.modes new file mode 100644 index 000000000..894e21313 --- /dev/null +++ b/hw/xfree86/doc/README.modes @@ -0,0 +1,474 @@ + Multi-monitor Mode Setting APIs + Keith Packard, SaveScreen and the core X screen saver will be +implemented by disabling outputs and crtcs using their dpms functions. + + void + xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags) + +Pass this function to xf86DPMSInit and all DPMS mode switching will be +managed by using the dpms functions provided by the Outputs and CRTCs. + + Bool + xf86CrtcScreenInit (ScreenPtr screen) + +This function completes the screen initialization process for the crtc and +output objects. Call it near the end of the ScreenInit function, after the +frame buffer and acceleration layers have been added. + +3.3 EnterVT functions + +Functions used during EnterVT, or whenever the current configuration needs +to be applied to the hardware. + + Bool + xf86SetDesiredModes (ScrnInfoPtr scrn) + +xf86InitialConfiguration selects the desired configuration at PreInit time; +when the server finally hits ScreenInit, xf86SetDesiredModes is used by the +driver to take that configuration and apply it to the hardware. In addition, +successful mode selection at other times updates the configuration that will +be used by this function, so LeaveVT/EnterVT pairs can simply invoke this +and return to the previous configuration. + +3.4 SwitchMode functions + +Functions called from the pScrn->SwitchMode hook, which is used by the +XFree86-VidModeExtension and the keypad mode switch commands. + + Bool + xf86SetSingleMode (ScrnInfoPtr scrn, + DisplayModePtr desired, + Rotation rotation) + +This function applies the specified mode to all active outputs. Which is to +say, it picks reasonable modes for all active outputs, attempting to get the +screen to the specified size while not breaking anything that is currently +working. + +3.7 get_modes functions + +Functions called during output->get_modes to help build lists of modes + + xf86MonPtr + xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus) + +This returns the EDID data structure for the 'output' using the I2C bus +'pDDCBus'. This has no effect on 'output' itself. + + void + xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon) + +Once the EDID data has been fetched, this call applies the EDID data to the +output object, setting the physical size and also various properties, like +the DDC root window property (when output is the 'compat' output), and the +RandR 1.2 EDID output properties. + + DisplayModePtr + xf86OutputGetEDIDModes (xf86OutputPtr output) + +Given an EDID data structure, this function computes a list of suitable +modes. This function also applies a sequence of 'quirks' during this process +so that the returned modes may not actually match the mode data present in +the EDID data. + +3.6 Other functions + +These remaining functions in the API can be used by the driver as needed. + + Bool + xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, + int x, int y) + +Applies a mode to a CRTC. All of the outputs which are currently using the +specified CRTC are included in the mode setting process. 'x' and 'y' are the +offset within the frame buffer that the crtc is placed at. No checking is +done in this function to ensure that the mode is usable by the active +outputs. + + void + xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY) + +This discards the mode lists for all outputs, re-detects monitor presence +and then acquires new mode lists for all monitors which are not disconnected. +Monitor configuration data is used to modify the mode lists returned by the +outputs. 'maxX' and 'maxY' limit the maximum size modes that will be +returned. + + void + xf86SetScrnInfoModes (ScrnInfoPtr pScrn) + +This copies the 'compat' output mode list into the pScrn modes list which is +used by the XFree86-VidModeExtension and the keypad mode switching +operations. The current 'desired' mode for the CRTC associated with the +'compat' output is placed first in this list to indicate the current mode. +Usually, the driver won't need to call this function as +xf86InitialConfiguration will do so automatically, as well as any RandR +functions which reprobe for modes. However, if the driver reprobes for modes +at other times using xf86ProbeOutputModes, this function needs to be called. + + Bool + xf86DiDGAReInit (ScreenPtr pScreen) + +This is similar to xf86SetScrnInfoModes, but it applies the 'compat' output +mode list to the set of modes advertised by the DGA extension; it needs to +be called whenever xf86ProbeOutputModes is invoked. + + void + xf86DisableUnusedFunctions(ScrnInfoPtr pScrn) + +After any sequence of calls using xf86CrtcSetMode, this function cleans up +any leftover Output and CRTC objects by disabling them, saving power. It is +safe to call this whenever the server is running as it only disables objects +which are not currently in use. + +4. CRTC operations + +4.1 CRTC functions + +These functions provide an abstract interface for the CRTC object; most +manipulation of the CRTC object is done through these functions. + + void + crtc->funcs->dpms (xf86CrtcPtr crtc, int mode) + +Where 'mode' is one of DPMSModeOff, DPMSModeSuspend, DPMSModeStandby or +DPMSModeOn. This requests that the crtc go to the specified power state. +When changing power states, the output dpms functions are invoked before the +crtc dpms functions. + + void + crtc->funcs->save (xf86CrtcPtr crtc) + + void + crtc->funcs->restore (xf86CrtcPtr crtc) + +Preserve/restore any register contents related to the CRTC. These are +strictly a convenience for the driver writer; if the existing driver has +fully operation save/restore functions, you need not place any additional +code here. In particular, the server itself never uses this function. + + Bool + crtc->funcs->lock (xf86CrtcPtr crtc) + + void + crtc->funcs->unlock (xf86CrtcPtr crtc) + +These functions are invoked around mode setting operations; the intent is +that DRI locking be done here to prevent DRI applications from manipulating +the hardware while the server is busy changing the output configuration. If +the lock function returns FALSE, the unlock function will not be invoked. + + Bool + crtc->funcs->mode_fixup (xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode) + +This call gives the CRTC a chance to see what mode will be set and to +comment on the mode by changing 'adjusted_mode' as needed. This function +shall not modify the state of the crtc hardware at all. If the CRTC cannot +accept this mode, this function may return FALSE. + + void + crtc->funcs->prepare (xf86CrtcPtr crtc) + +This call is made just before the mode is set to make the hardware ready for +the operation. A usual function to perform here is to disable the crtc so +that mode setting can occur with clocks turned off and outputs deactivated. + + void + crtc->funcs->mode_set (xf86CrtcPtr crtc, + DisplayModePtr mode, + DisplayModePtr adjusted_mode) + +This function applies the specified mode (possibly adjusted by the CRTC +and/or Outputs). + + void + crtc->funcs->commit (xf86CrtcPtr crtc) + +Once the mode has been applied to the CRTC and Outputs, this function is +invoked to let the hardware turn things back on. + + void + crtc->funcs->gamma_set (xf86CrtcPtr crtc, CARD16 *red, + CARD16 *green, CARD16 *blue, int size) + +This function adjusts the gamma ramps for the specified crtc. + + void * + crtc->funcs->shadow_allocate (xf86CrtcPtr crtc, int width, int height) + +This function allocates frame buffer space for a shadow frame buffer. When +allocated, the crtc must scan from the shadow instead of the main frame +buffer. This is used for rotation. The address returned is passed to the +shadow_create function. This function should return NULL on failure. + + PixmapPtr + crtc->funcs->shadow_create (xf86CrtcPtr crtc, void *data, + int width, int height) + +This function creates a pixmap object that will be used as a shadow of the +main frame buffer for CRTCs which are rotated or reflected. 'data' is the +value returned by shadow_allocate. + + void + crtc->funcs->shadow_destroy (xf86CrtcPtr crtc, PixmapPtr pPixmap, + void *data) + +Destroys any associated shadow objects. If pPixmap is NULL, then a pixmap +was not created, but 'data' may still be non-NULL indicating that the shadow +had been allocated. + + void + crtc->funcs->destroy (xf86CrtcPtr crtc) + +When a CRTC is destroyed (which only happens in error cases), this function +can clean up any driver-specific data. + +4.2 CRTC fields + +The CRTC object is not opaque; there are several fields of interest to the +driver writer. + + struct _xf86Crtc { + /** + * Associated ScrnInfo + */ + ScrnInfoPtr scrn; + + /** + * Active state of this CRTC + * + * Set when this CRTC is driving one or more outputs + */ + Bool enabled; + + /** Track whether cursor is within CRTC range */ + Bool cursorInRange; + + /** Track state of cursor associated with this CRTC */ + Bool cursorShown; + + /** + * Active mode + * + * This reflects the mode as set in the CRTC currently + * It will be cleared when the VT is not active or + * during server startup + */ + DisplayModeRec mode; + Rotation rotation; + PixmapPtr rotatedPixmap; + void *rotatedData; + + /** + * Position on screen + * + * Locates this CRTC within the frame buffer + */ + int x, y; + + /** + * Desired mode + * + * This is set to the requested mode, independent of + * whether the VT is active. In particular, it receives + * the startup configured mode and saves the active mode + * on VT switch. + */ + DisplayModeRec desiredMode; + Rotation desiredRotation; + int desiredX, desiredY; + + /** crtc-specific functions */ + const xf86CrtcFuncsRec *funcs; + + /** + * Driver private + * + * Holds driver-private information + */ + void *driver_private; + #ifdef RANDR_12_INTERFACE + /** + * RandR crtc + * + * When RandR 1.2 is available, this + * points at the associated crtc object + */ + RRCrtcPtr randr_crtc; + #else + void *randr_crtc; + #endif + }; + + +5. Output functions. + +6. Configuration + +Because the configuration file syntax is fixed, +this was done by creating new "Driver" section options that hook specific +outputs to specific "Monitor" sections in the file. The option: +section of the form: + + Option "monitor-VGA" "My VGA Monitor" + +connects the VGA output of this driver to the "Monitor" section with +Identifier "My VGA Monitor". All of the usual monitor options can now be +placed in that "Monitor" section and will be applied to the VGA output +configuration. From ae9d5aa479dd50cc81b755079fcf96a0d02f135a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Mar 2007 20:52:31 -0800 Subject: [PATCH 38/85] Remove stale monitor data when output becomes disconnected. Remove parsed EDID and EDID property from disconnected outputs. --- hw/xfree86/modes/xf86Crtc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 279449688..1a4292092 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1158,7 +1158,10 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY) output->status = (*output->funcs->detect)(output); if (output->status == XF86OutputStatusDisconnected) + { + xf86OutputSetEDID (output, NULL); continue; + } memset (&mon_rec, '\0', sizeof (mon_rec)); From 318faed5a88891dd07d6ebb4d7c0d337ffb08be4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 14 Mar 2007 11:42:42 -0700 Subject: [PATCH 39/85] Revert "Xprint includes a filename which is too long for tar." This reverts commit 73904d953f2f9cbe941a215ba240b46bc7a61357. The next patch will fix the filenames so that they work with tar. --- hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am index e7ddb6c0f..1e8c8a781 100644 --- a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am @@ -18,6 +18,7 @@ dist_xpc_DATA = \ LubalinGraph-DemiOblique.pmf \ LubalinGraph-Demi.pmf \ NewCenturySchlbk-Bold.pmf \ + NewCenturySchlbk-BoldItalic.pmf \ NewCenturySchlbk-Italic.pmf \ NewCenturySchlbk-Roman.pmf \ Souvenir-DemiItalic.pmf \ From d3c3d31782c233cd32db04ea08f5d9a6f7dbc6c7 Mon Sep 17 00:00:00 2001 From: Drew Parsons Date: Tue, 6 Mar 2007 23:53:23 +1100 Subject: [PATCH 40/85] Xprint: shorten font filename to fit in tar length limit The length of the Xprint font file NewCenturySchlbk-BoldItalic.pmf pushes the full path over the traditional 100 character limit for tarballs (when module version number is included). Shorten it to NewCentSchlbk-BoldItal.pmf to get back below the limit and rename other font files in that family to match. (cherry picked from commit d5aba03feff41722c72b4c6193f09d141cbf1678) --- .../C/print/models/CANONC3200-PS/fonts/Makefile.am | 8 ++++---- .../C/print/models/HPLJ4050-PS/fonts/Makefile.am | 8 ++++---- .../C/print/models/PSdefault/fonts/Makefile.am | 8 ++++---- ...enturySchlbk-Bold.pmf => NewCentSchlbk-Bold.pmf} | Bin ...bk-BoldItalic.pmf => NewCentSchlbk-BoldItal.pmf} | Bin ...turySchlbk-Italic.pmf => NewCentSchlbk-Ital.pmf} | Bin ...turySchlbk-Roman.pmf => NewCentSchlbk-Roman.pmf} | Bin 7 files changed, 12 insertions(+), 12 deletions(-) rename hw/xprint/config/C/print/models/PSdefault/fonts/{NewCenturySchlbk-Bold.pmf => NewCentSchlbk-Bold.pmf} (100%) rename hw/xprint/config/C/print/models/PSdefault/fonts/{NewCenturySchlbk-BoldItalic.pmf => NewCentSchlbk-BoldItal.pmf} (100%) rename hw/xprint/config/C/print/models/PSdefault/fonts/{NewCenturySchlbk-Italic.pmf => NewCentSchlbk-Ital.pmf} (100%) rename hw/xprint/config/C/print/models/PSdefault/fonts/{NewCenturySchlbk-Roman.pmf => NewCentSchlbk-Roman.pmf} (100%) diff --git a/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am b/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am index c574c5cde..7a7ecc31a 100644 --- a/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am @@ -19,10 +19,10 @@ XPFONTS = \ LubalinGraph-BookOblique.pmf \ LubalinGraph-Demi.pmf \ LubalinGraph-DemiOblique.pmf \ - NewCenturySchlbk-Bold.pmf \ - NewCenturySchlbk-BoldItalic.pmf \ - NewCenturySchlbk-Italic.pmf \ - NewCenturySchlbk-Roman.pmf \ + NewCentSchlbk-Bold.pmf \ + NewCentSchlbk-BoldItal.pmf \ + NewCentSchlbk-Ital.pmf \ + NewCentSchlbk-Roman.pmf \ Souvenir-Demi.pmf \ Souvenir-DemiItalic.pmf \ Souvenir-Light.pmf \ diff --git a/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am b/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am index 634db1f39..f4f4243e9 100644 --- a/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am @@ -19,10 +19,10 @@ XPFONTS = \ LubalinGraph-BookOblique.pmf \ LubalinGraph-Demi.pmf \ LubalinGraph-DemiOblique.pmf \ - NewCenturySchlbk-Bold.pmf \ - NewCenturySchlbk-BoldItalic.pmf \ - NewCenturySchlbk-Italic.pmf \ - NewCenturySchlbk-Roman.pmf \ + NewCentSchlbk-Bold.pmf \ + NewCentSchlbk-BoldItal.pmf \ + NewCentSchlbk-Ital.pmf \ + NewCentSchlbk-Roman.pmf \ Souvenir-Demi.pmf \ Souvenir-DemiItalic.pmf \ Souvenir-Light.pmf \ diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am index 1e8c8a781..40f1e3da5 100644 --- a/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am +++ b/hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am @@ -17,10 +17,10 @@ dist_xpc_DATA = \ LubalinGraph-Book.pmf \ LubalinGraph-DemiOblique.pmf \ LubalinGraph-Demi.pmf \ - NewCenturySchlbk-Bold.pmf \ - NewCenturySchlbk-BoldItalic.pmf \ - NewCenturySchlbk-Italic.pmf \ - NewCenturySchlbk-Roman.pmf \ + NewCentSchlbk-Bold.pmf \ + NewCentSchlbk-BoldItal.pmf \ + NewCentSchlbk-Ital.pmf \ + NewCentSchlbk-Roman.pmf \ Souvenir-DemiItalic.pmf \ Souvenir-Demi.pmf \ Souvenir-LightItalic.pmf \ diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Bold.pmf similarity index 100% rename from hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf rename to hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Bold.pmf diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-BoldItal.pmf similarity index 100% rename from hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf rename to hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-BoldItal.pmf diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Ital.pmf similarity index 100% rename from hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf rename to hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Ital.pmf diff --git a/hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf b/hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Roman.pmf similarity index 100% rename from hw/xprint/config/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf rename to hw/xprint/config/C/print/models/PSdefault/fonts/NewCentSchlbk-Roman.pmf From 4c5837c940024cffc8990b602a97ef6ece08e875 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 1 Mar 2007 09:51:20 +1030 Subject: [PATCH 41/85] Xext: Update device's lastx/lasty when sending a motion event with XTest. (cherry picked from commit 68c64ad7b1eea79c786b5a7f3459076780163a47) --- Xext/xtest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xext/xtest.c b/Xext/xtest.c index 83f8b8cc6..922dfce62 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -442,6 +442,8 @@ ProcXTestFakeInput(client) (root->drawable.pScreen, ev->u.keyButtonPointer.rootX, ev->u.keyButtonPointer.rootY, FALSE); + dev->valuator->lastx = ev->u.keyButtonPointer.rootX; + dev->valuator->lasty = ev->u.keyButtonPointer.rootY; break; case ButtonPress: case ButtonRelease: From f8636dd4a2b6efedaf98e5bf3d27389b673dc38a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 14 Mar 2007 12:00:06 -0700 Subject: [PATCH 42/85] Revert "Xext: Update device's lastx/lasty when sending a motion event with XTest." This reverts commit 4c5837c940024cffc8990b602a97ef6ece08e875. There is no lastx/lasty in a valuator on this branch. --- Xext/xtest.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/Xext/xtest.c b/Xext/xtest.c index 922dfce62..83f8b8cc6 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -442,8 +442,6 @@ ProcXTestFakeInput(client) (root->drawable.pScreen, ev->u.keyButtonPointer.rootX, ev->u.keyButtonPointer.rootY, FALSE); - dev->valuator->lastx = ev->u.keyButtonPointer.rootX; - dev->valuator->lasty = ev->u.keyButtonPointer.rootY; break; case ButtonPress: case ButtonRelease: From 0ebe537983a46361ec0fb7d7bf57268792264007 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 14 Mar 2007 16:36:13 -0700 Subject: [PATCH 43/85] Update to version 1.2.99.902 --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index c2909267b..ed2c631a9 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) dnl This is the not the Xorg version number, it's the server version number. dnl Yes, that's weird. -AC_INIT([xorg-server], 1.2.99.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +AC_INIT([xorg-server], 1.2.99.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE @@ -40,8 +40,8 @@ DEFAULT_VENDOR_NAME_SHORT="X.Org" DEFAULT_VERSION_MAJOR=1 DEFAULT_VERSION_MINOR=2 DEFAULT_VERSION_PATCH=99 -DEFAULT_VERSION_SNAP=901 -DEFAULT_RELEASE_DATE="4 March 2007" +DEFAULT_VERSION_SNAP=902 +DEFAULT_RELEASE_DATE="14 March 2007" DEFAULT_VENDOR_WEB="http://wiki.x.org" dnl this gets generated by autoheader, and thus contains all the defines. we From 4d81c99a4660a0bf9014f789de55edabd185bd14 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 14 Mar 2007 23:59:29 -0700 Subject: [PATCH 44/85] Create driver-independent CRTC-based cursor layer. This moves most of the cursor management code out of the intel driver and into the general server code. Of course, the hope is that this code will be useful for other driver writers as well. Check out xf86Crtc.h for the usage information, making sure you add the needed hooks to the crtc funcs structure for your driver. --- hw/xfree86/Makefile.am | 1 + hw/xfree86/loader/Makefile.am | 3 +- hw/xfree86/loader/loadmod.c | 3 +- hw/xfree86/loader/xf86sym.c | 5 + hw/xfree86/modes/Makefile.am | 4 +- hw/xfree86/modes/xf86Crtc.h | 103 +++++- hw/xfree86/modes/xf86Cursors.c | 595 +++++++++++++++++++++++++++++++++ hw/xfree86/ramdac/Makefile.am | 6 +- hw/xfree86/ramdac/xf86Cursor.h | 3 + 9 files changed, 710 insertions(+), 13 deletions(-) create mode 100644 hw/xfree86/modes/xf86Cursors.c diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am index 35f1aa974..0701cf5ab 100644 --- a/hw/xfree86/Makefile.am +++ b/hw/xfree86/Makefile.am @@ -48,6 +48,7 @@ XORG_LIBS = \ parser/libxf86config.a \ dixmods/libdixmods.la \ modes/libxf86modes.a \ + ramdac/libramdac.a \ ddc/libddc.a \ i2c/libi2c.a \ @XORG_LIBS@ diff --git a/hw/xfree86/loader/Makefile.am b/hw/xfree86/loader/Makefile.am index 0a89d0833..61bcb2257 100644 --- a/hw/xfree86/loader/Makefile.am +++ b/hw/xfree86/loader/Makefile.am @@ -2,7 +2,8 @@ noinst_LIBRARIES = libloader.a INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../dixmods/extmod \ -I$(srcdir)/../vbe -I$(top_srcdir)/miext/cw -I$(srcdir)/../int10 \ - -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes + -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \ + -I$(srcdir)/../ramdac #AM_LDFLAGS = -r AM_CFLAGS = -DIN_LOADER $(XORG_CFLAGS) diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index e4892123b..c220d8a61 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -841,6 +841,7 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) static const char *compiled_in_modules[] = { "ddc", "i2c", + "ramdac", NULL }; @@ -861,7 +862,7 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, PatternPtr patterns = NULL; int noncanonical = 0; char *m = NULL; - char **cim; + const char **cim; xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module); diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 2f1f6af01..f468b1f07 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -1230,6 +1230,11 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86RandR12SetConfig) SYMFUNC(xf86RandR12SetRotations) #endif + SYMFUNC(xf86_cursors_init) + SYMFUNC(xf86_reload_cursors) + SYMFUNC(xf86_show_cursors) + SYMFUNC(xf86_hide_cursors) + SYMFUNC(xf86_cursors_fini) SYMFUNC(xf86DoEDID_DDC1) SYMFUNC(xf86DoEDID_DDC2) diff --git a/hw/xfree86/modes/Makefile.am b/hw/xfree86/modes/Makefile.am index 60d25536e..0841a6d29 100644 --- a/hw/xfree86/modes/Makefile.am +++ b/hw/xfree86/modes/Makefile.am @@ -3,6 +3,7 @@ noinst_LIBRARIES = libxf86modes.a libxf86modes_a_SOURCES = \ xf86Crtc.c \ xf86Crtc.h \ + xf86Cursors.c \ xf86cvt.c \ xf86DiDGA.c \ xf86EdidModes.c \ @@ -16,7 +17,8 @@ libxf86modes_a_SOURCES = \ INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \ -I$(srcdir)/../scanpci -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ - -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod + -I$(srcdir)/../vgahw -I$(srcdir)/../ramdac \ + -I$(srcdir)/../dixmods/extmod sdk_HEADERS = \ xf86Crtc.h \ diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 6152ae4c9..df8a8aad9 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -28,6 +28,7 @@ #include "xf86Rename.h" #endif #include "xf86Modes.h" +#include "xf86Cursor.h" #include "damage.h" /* Compat definitions for older X Servers. */ @@ -37,6 +38,9 @@ #ifndef M_T_DRIVER #define M_T_DRIVER 0x40 #endif +#ifndef HARDWARE_CURSOR_ARGB +#define HARDWARE_CURSOR_ARGB 0x00004000 +#endif typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr; typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr; @@ -154,6 +158,42 @@ typedef struct _xf86CrtcFuncs { void (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data); + /** + * Set cursor colors + */ + void + (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg); + + /** + * Set cursor position + */ + void + (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y); + + /** + * Show cursor + */ + void + (*show_cursor) (xf86CrtcPtr crtc); + + /** + * Hide cursor + */ + void + (*hide_cursor) (xf86CrtcPtr crtc); + + /** + * Load monochrome image + */ + void + (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image); + + /** + * Load ARGB image + */ + void + (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image); + /** * Clean up driver-specific bits of the crtc */ @@ -174,12 +214,6 @@ struct _xf86Crtc { */ Bool enabled; - /** Track whether cursor is within CRTC range */ - Bool cursorInRange; - - /** Track state of cursor associated with this CRTC */ - Bool cursorShown; - /** * Active mode * @@ -232,6 +266,19 @@ struct _xf86Crtc { #else void *randr_crtc; #endif + + /** + * Current cursor is ARGB + */ + Bool cursor_argb; + /** + * Track whether cursor is within CRTC range + */ + Bool cursor_in_range; + /** + * Track state of cursor associated with this CRTC + */ + Bool cursor_shown; }; typedef struct _xf86OutputFuncs { @@ -495,6 +542,13 @@ typedef struct _xf86CrtcConfig { const xf86CrtcConfigFuncsRec *funcs; CreateScreenResourcesProcPtr CreateScreenResources; + + /* Cursor information */ + xf86CursorInfoPtr cursor_info; + CursorPtr cursor; + CARD8 *cursor_image; + Bool cursor_on; + CARD32 cursor_fg, cursor_bg; } xf86CrtcConfigRec, *xf86CrtcConfigPtr; extern int xf86CrtcConfigPrivateIndex; @@ -637,4 +691,41 @@ xf86ConnectorGetName(xf86ConnectorType connector); Bool xf86SetDesiredModes (ScrnInfoPtr pScrn); +/** + * Initialize the CRTC-based cursor code. CRTC function vectors must + * contain relevant cursor setting functions. + * + * Driver should call this from ScreenInit function + */ +Bool +xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags); + +/** + * Called when anything on the screen is reconfigured. + * + * Reloads cursor images as needed, then adjusts cursor positions. + * + * Driver should call this from crtc commit function. + */ +void +xf86_reload_cursors (ScreenPtr screen); + +/** + * Called from EnterVT to turn the cursors back on + */ +void +xf86_show_cursors (ScrnInfoPtr scrn); + +/** + * Called by the driver to turn cursors off + */ +void +xf86_hide_cursors (ScrnInfoPtr scrn); + +/** + * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time. + */ +void +xf86_cursors_fini (ScreenPtr screen); + #endif /* _XF86CRTC_H_ */ diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c new file mode 100644 index 000000000..095df4845 --- /dev/null +++ b/hw/xfree86/modes/xf86Cursors.c @@ -0,0 +1,595 @@ +/* + * Copyright © 2007 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#else +#ifdef HAVE_CONFIG_H +#include +#endif +#endif + +#include +#include +#include + +#include "xf86.h" +#include "xf86DDC.h" +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "xf86RandR12.h" +#include "X11/extensions/render.h" +#define DPMS_SERVER +#include "X11/extensions/dpms.h" +#include "X11/Xatom.h" +#ifdef RENDER +#include "picturestr.h" +#endif +#include "cursorstr.h" + +/* + * Given a screen coordinate, rotate back to a cursor source coordinate + */ +static void +xf86_crtc_rotate_coord (Rotation rotation, + int width, + int height, + int x_dst, + int y_dst, + int *x_src, + int *y_src) +{ + if (rotation & RR_Reflect_X) + x_dst = width - x_dst - 1; + if (rotation & RR_Reflect_Y) + y_dst = height - y_dst - 1; + + switch (rotation & 0xf) { + case RR_Rotate_0: + *x_src = x_dst; + *y_src = y_dst; + break; + case RR_Rotate_90: + *x_src = height - y_dst - 1; + *y_src = x_dst; + break; + case RR_Rotate_180: + *x_src = width - x_dst - 1; + *y_src = height - y_dst - 1; + break; + case RR_Rotate_270: + *x_src = y_dst; + *y_src = width - x_dst - 1; + break; + } +} + +/* + * Convert an x coordinate to a position within the cursor bitmap + */ +static int +cursor_bitpos (int flags, int x, Bool mask) +{ + if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK) + mask = !mask; + if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED) + x = (x & ~3) | (3 - (x & 3)); + if (flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) + x = (x & ~7) | (7 - (x & 7)); + if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1) + x = (x << 1) + mask; + else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8) + x = ((x & ~7) << 1) | (mask << 3) | (x & 7); + else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16) + x = ((x & ~15) << 1) | (mask << 4) | (x & 15); + else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32) + x = ((x & ~31) << 1) | (mask << 5) | (x & 31); + else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64) + x = ((x & ~63) << 1) | (mask << 6) | (x & 63); + return x; +} + +/* + * Fetch one bit from a cursor bitmap + */ +static CARD8 +get_bit (CARD8 *image, int stride, int flags, int x, int y, Bool mask) +{ + x = cursor_bitpos (flags, x, mask); + image += y * stride; + return (image[(x >> 3)] >> (x & 7)) & 1; +} + +/* + * Set one bit in a cursor bitmap + */ +static void +set_bit (CARD8 *image, int stride, int flags, int x, int y, Bool mask) +{ + x = cursor_bitpos (flags, x, mask); + image += y * stride; + image[(x >> 3)] |= 1 << (x & 7); +} + +/* + * Load a two color cursor into a driver that supports only ARGB cursors + */ +static void +xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image; + int x, y; + int xin, yin; + int stride = cursor_info->MaxWidth >> 2; + int flags = cursor_info->Flags; + CARD32 bits; + +#ifdef ARGB_CURSOR + crtc->cursor_argb = FALSE; +#endif + + for (y = 0; y < cursor_info->MaxHeight; y++) + for (x = 0; x < cursor_info->MaxWidth; x++) + { + xf86_crtc_rotate_coord (crtc->rotation, + cursor_info->MaxWidth, + cursor_info->MaxHeight, + x, y, &xin, &yin); + if (get_bit (src, stride, flags, xin, yin, TRUE) == + ((flags & HARDWARE_CURSOR_INVERT_MASK) == 0)) + { + if (get_bit (src, stride, flags, xin, yin, FALSE)) + bits = xf86_config->cursor_fg; + else + bits = xf86_config->cursor_bg; + } + else + bits = 0; + cursor_image[y * cursor_info->MaxWidth + x] = bits; + } + crtc->funcs->load_cursor_argb (crtc, cursor_image); +} + +/* + * Set the colors for a two-color cursor (ignore for ARGB cursors) + */ +static void +xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg) +{ + ScreenPtr screen = scrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + CursorPtr cursor = xf86_config->cursor; + int c; + CARD8 *bits = cursor ? cursor->devPriv[screen->myNum] : NULL; + + /* Save ARGB versions of these colors */ + xf86_config->cursor_fg = (CARD32) fg | 0xff000000; + xf86_config->cursor_bg = (CARD32) bg | 0xff000000; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled && !crtc->cursor_argb) + { + if (crtc->funcs->load_cursor_image) + crtc->funcs->set_cursor_colors (crtc, bg, fg); + else if (bits) + xf86_crtc_convert_cursor_to_argb (crtc, bits); + } + } +} + +static void +xf86_crtc_hide_cursor (xf86CrtcPtr crtc) +{ + if (crtc->cursor_shown) + { + crtc->funcs->hide_cursor (crtc); + crtc->cursor_shown = FALSE; + } +} + +void +xf86_hide_cursors (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + xf86_config->cursor_on = FALSE; + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + xf86_crtc_hide_cursor (crtc); + } +} + +static void +xf86_crtc_show_cursor (xf86CrtcPtr crtc) +{ + if (!crtc->cursor_shown && crtc->cursor_in_range) + { + crtc->funcs->show_cursor (crtc); + crtc->cursor_shown = TRUE; + } +} + +void +xf86_show_cursors (ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + xf86_config->cursor_on = TRUE; + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + xf86_crtc_show_cursor (crtc); + } +} + +static void +xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + DisplayModePtr mode = &crtc->mode; + int x_temp; + int y_temp; + Bool in_range; + + /* + * Move to crtc coordinate space + */ + x -= crtc->x; + y -= crtc->y; + + /* + * Rotate + */ + switch ((crtc->rotation) & 0xf) { + case RR_Rotate_0: + break; + case RR_Rotate_90: + x_temp = y; + y_temp = mode->VDisplay - cursor_info->MaxWidth - x; + x = x_temp; + y = y_temp; + break; + case RR_Rotate_180: + x_temp = mode->HDisplay - cursor_info->MaxWidth - x; + y_temp = mode->VDisplay - cursor_info->MaxHeight - y; + x = x_temp; + y = y_temp; + break; + case RR_Rotate_270: + x_temp = mode->HDisplay - cursor_info->MaxHeight - y; + y_temp = x; + x = x_temp; + y = y_temp; + break; + } + + /* + * Reflect + */ + if (crtc->rotation & RR_Reflect_X) + x = mode->HDisplay - cursor_info->MaxWidth - x; + if (crtc->rotation & RR_Reflect_Y) + y = mode->VDisplay - cursor_info->MaxHeight - y; + + /* + * Disable the cursor when it is outside the viewport + */ + in_range = TRUE; + if (x >= mode->HDisplay || y >= mode->VDisplay || + x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight) + { + in_range = FALSE; + x = 0; + y = 0; + } + + crtc->cursor_in_range = in_range; + + if (in_range) + { + crtc->funcs->set_cursor_position (crtc, x, y); + xf86_crtc_show_cursor (crtc); + } + else + xf86_crtc_hide_cursor (crtc); +} + +static void +xf86_set_cursor_position (ScrnInfoPtr scrn, int x, int y) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + /* undo what xf86HWCurs did to the coordinates */ + x += scrn->frameX0; + y += scrn->frameY0; + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + xf86_crtc_set_cursor_position (crtc, x, y); + } +} + +/* + * Load a two-color cursor into a crtc, performing rotation as needed + */ +static void +xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + CARD8 *cursor_image; + +#ifdef ARGB_CURSOR + crtc->cursor_argb = FALSE; +#endif + + if (crtc->rotation == RR_Rotate_0) + cursor_image = src; + else + { + int x, y; + int xin, yin; + int stride = cursor_info->MaxWidth >> 2; + int flags = cursor_info->Flags; + + cursor_image = xf86_config->cursor_image; + memset(cursor_image, 0, cursor_info->MaxWidth * stride); + + for (y = 0; y < cursor_info->MaxHeight; y++) + for (x = 0; x < cursor_info->MaxWidth; x++) + { + xf86_crtc_rotate_coord (crtc->rotation, + cursor_info->MaxWidth, + cursor_info->MaxHeight, + x, y, &xin, &yin); + if (get_bit(src, stride, flags, xin, yin, FALSE)) + set_bit(cursor_image, stride, flags, x, y, FALSE); + if (get_bit(src, stride, flags, xin, yin, TRUE)) + set_bit(cursor_image, stride, flags, x, y, TRUE); + } + } + crtc->funcs->load_cursor_image (crtc, cursor_image); +} + +/* + * Load a cursor image into all active CRTCs + */ +static void +xf86_load_cursor_image (ScrnInfoPtr scrn, unsigned char *src) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + { + if (crtc->funcs->load_cursor_image) + xf86_crtc_load_cursor_image (crtc, src); + else if (crtc->funcs->load_cursor_argb) + xf86_crtc_convert_cursor_to_argb (crtc, src); + } + } +} + +static Bool +xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + + xf86_config->cursor = cursor; + + if (cursor->bits->width > cursor_info->MaxWidth || + cursor->bits->height> cursor_info->MaxHeight) + return FALSE; + + return TRUE; +} + +static Bool +xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + + xf86_config->cursor = cursor; + + /* Make sure ARGB support is available */ + if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0) + return FALSE; + + if (cursor->bits->width > cursor_info->MaxWidth || + cursor->bits->height> cursor_info->MaxHeight) + return FALSE; + + return TRUE; +} + +static void +xf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor) +{ + ScrnInfoPtr scrn = crtc->scrn; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image; + CARD32 *cursor_source = (CARD32 *) cursor->bits->argb; + int x, y; + int xin, yin; + CARD32 bits; + int source_width = cursor->bits->width; + int source_height = cursor->bits->height; + int image_width = cursor_info->MaxWidth; + int image_height = cursor_info->MaxHeight; + + for (y = 0; y < image_height; y++) + for (x = 0; x < image_width; x++) + { + xf86_crtc_rotate_coord (crtc->rotation, image_width, image_height, + x, y, &xin, &yin); + if (xin < source_width && yin < source_height) + bits = cursor_source[yin * source_width + xin]; + else + bits = 0; + cursor_image[y * image_width + x] = bits; + } + + crtc->funcs->load_cursor_argb (crtc, cursor_image); +} + +static void +xf86_load_cursor_argb (ScrnInfoPtr scrn, CursorPtr cursor) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + { + xf86CrtcPtr crtc = xf86_config->crtc[c]; + + if (crtc->enabled) + xf86_crtc_load_cursor_argb (crtc, cursor); + } +} + +Bool +xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info; + + cursor_info = xf86CreateCursorInfoRec(); + if (!cursor_info) + return FALSE; + + xf86_config->cursor_image = xalloc (max_width * max_height * 4); + + if (!xf86_config->cursor_image) + { + xf86DestroyCursorInfoRec (cursor_info); + return FALSE; + } + + xf86_config->cursor_info = cursor_info; + + cursor_info->MaxWidth = max_width; + cursor_info->MaxHeight = max_height; + cursor_info->Flags = flags; + + cursor_info->SetCursorColors = xf86_set_cursor_colors; + cursor_info->SetCursorPosition = xf86_set_cursor_position; + cursor_info->LoadCursorImage = xf86_load_cursor_image; + cursor_info->HideCursor = xf86_hide_cursors; + cursor_info->ShowCursor = xf86_show_cursors; + cursor_info->UseHWCursor = xf86_use_hw_cursor; +#ifdef ARGB_CURSOR + if (flags & HARDWARE_CURSOR_ARGB) + { + cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb; + cursor_info->LoadCursorARGB = xf86_load_cursor_argb; + } +#endif + + xf86_config->cursor = NULL; + xf86_hide_cursors (scrn); + + return xf86InitCursor (screen, cursor_info); +} + +/** + * Called when anything on the screen is reconfigured. + * + * Reloads cursor images as needed, then adjusts cursor positions + */ + +void +xf86_reload_cursors (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + CursorPtr cursor = xf86_config->cursor; + int x, y; + + GetSpritePosition (&x, &y); + if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) + (*cursor_info->HideCursor)(scrn); + + if (cursor) + { +#ifdef ARGB_CURSOR + if (cursor->bits->argb && cursor_info->LoadCursorARGB) + (*cursor_info->LoadCursorARGB) (scrn, cursor); + else +#endif + (*cursor_info->LoadCursorImage)(cursor_info->pScrn, + cursor->devPriv[screen->myNum]); + + (*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y); + (*cursor_info->ShowCursor)(cursor_info->pScrn); + } +} + +/** + * Clean up CRTC-based cursor code + */ +void +xf86_cursors_fini (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + if (xf86_config->cursor_info) + { + xf86DestroyCursorInfoRec (xf86_config->cursor_info); + xf86_config->cursor_info = NULL; + } + if (xf86_config->cursor_image) + { + xfree (xf86_config->cursor_image); + xf86_config->cursor_image = NULL; + } +} diff --git a/hw/xfree86/ramdac/Makefile.am b/hw/xfree86/ramdac/Makefile.am index c9afdad60..6725ed397 100644 --- a/hw/xfree86/ramdac/Makefile.am +++ b/hw/xfree86/ramdac/Makefile.am @@ -1,8 +1,6 @@ -module_LTLIBRARIES = libramdac.la +noinst_LIBRARIES = libramdac.a -libramdac_la_LDFLAGS = -avoid-version - -libramdac_la_SOURCES = xf86RamDacMod.c xf86RamDac.c xf86RamDacCmap.c \ +libramdac_a_SOURCES = xf86RamDac.c xf86RamDacCmap.c \ xf86Cursor.c xf86HWCurs.c IBM.c BT.c TI.c \ xf86BitOrder.c diff --git a/hw/xfree86/ramdac/xf86Cursor.h b/hw/xfree86/ramdac/xf86Cursor.h index 08cca6b96..469f48f01 100644 --- a/hw/xfree86/ramdac/xf86Cursor.h +++ b/hw/xfree86/ramdac/xf86Cursor.h @@ -44,5 +44,8 @@ void xf86ForceHWCursor (ScreenPtr pScreen, Bool on); #define HARDWARE_CURSOR_NIBBLE_SWAPPED 0x00000800 #define HARDWARE_CURSOR_SHOW_TRANSPARENT 0x00001000 #define HARDWARE_CURSOR_UPDATE_UNHIDDEN 0x00002000 +#ifdef ARGB_CURSOR +#define HARDWARE_CURSOR_ARGB 0x00004000 +#endif #endif /* _XF86CURSOR_H */ From 5b77bf2d020b1ee56c1c5f2db089a8f7f64a76a6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Mar 2007 10:50:45 -0700 Subject: [PATCH 45/85] Allow xf86_reload_cursors during server init. xf86_reload_cursors is supposed to be called from the crtc mode setting commit hook; as that happens during server initialization, check for this case. --- hw/xfree86/modes/xf86Cursors.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index 095df4845..009cccf89 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -548,12 +548,24 @@ xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags) void xf86_reload_cursors (ScreenPtr screen) { - ScrnInfoPtr scrn = xf86Screens[screen->myNum]; - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; - CursorPtr cursor = xf86_config->cursor; + ScrnInfoPtr scrn; + xf86CrtcConfigPtr xf86_config; + xf86CursorInfoPtr cursor_info; + CursorPtr cursor; int x, y; + /* initial mode setting will not have set a screen yet */ + if (!screen) + return; + scrn = xf86Screens[screen->myNum]; + xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + /* make sure the cursor code has been initialized */ + cursor_info = xf86_config->cursor_info; + if (!cursor_info) + return; + + cursor = xf86_config->cursor; GetSpritePosition (&x, &y); if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) (*cursor_info->HideCursor)(scrn); From b14f003b0ed1252766c9e3b1c086ea2809521047 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Mar 2007 16:16:16 -0700 Subject: [PATCH 46/85] Don't wedge when rotating more than one CRTC. Rotation block handler was re-registering the rotation damage structure, creating an infinite loop in the damage code. Track registration of the damage structure to avoid this. --- hw/xfree86/modes/xf86Crtc.h | 3 ++- hw/xfree86/modes/xf86Rotate.c | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index df8a8aad9..b7515928e 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -529,7 +529,8 @@ typedef struct _xf86CrtcConfig { int maxWidth, maxHeight; /* For crtc-based rotation */ - DamagePtr rotationDamage; + DamagePtr rotation_damage; + Bool rotation_damage_registered; /* DGA */ unsigned int dga_flags; diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 6826b6277..e82b69e1b 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -251,9 +251,13 @@ xf86RotatePrepare (ScreenPtr pScreen) crtc->rotatedData, crtc->mode.HDisplay, crtc->mode.VDisplay); - /* Hook damage to screen pixmap */ - DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - xf86_config->rotationDamage); + if (!xf86_config->rotation_damage_registered) + { + /* Hook damage to screen pixmap */ + DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + xf86_config->rotation_damage); + xf86_config->rotation_damage_registered = TRUE; + } xf86CrtcDamageShadow (crtc); } @@ -265,7 +269,7 @@ xf86RotateRedisplay(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - DamagePtr damage = xf86_config->rotationDamage; + DamagePtr damage = xf86_config->rotation_damage; RegionPtr region; if (!damage) @@ -334,13 +338,14 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) crtc->rotatedData = NULL; } - if (xf86_config->rotationDamage) + if (xf86_config->rotation_damage) { /* Free damage structure */ DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - xf86_config->rotationDamage); - DamageDestroy (xf86_config->rotationDamage); - xf86_config->rotationDamage = NULL; + xf86_config->rotation_damage); + xf86_config->rotation_damage_registered = FALSE; + DamageDestroy (xf86_config->rotation_damage); + xf86_config->rotation_damage = NULL; /* Free block/wakeup handler */ RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler, xf86RotateWakeupHandler, @@ -382,13 +387,13 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) xf86CrtcDamageShadow (crtc); } - if (!xf86_config->rotationDamage) + if (!xf86_config->rotation_damage) { /* Create damage structure */ - xf86_config->rotationDamage = DamageCreate (NULL, NULL, + xf86_config->rotation_damage = DamageCreate (NULL, NULL, DamageReportNone, TRUE, pScreen, pScreen); - if (!xf86_config->rotationDamage) + if (!xf86_config->rotation_damage) goto bail2; /* Assign block/wakeup handler */ @@ -402,8 +407,8 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) if (0) { bail3: - DamageDestroy (xf86_config->rotationDamage); - xf86_config->rotationDamage = NULL; + DamageDestroy (xf86_config->rotation_damage); + xf86_config->rotation_damage = NULL; bail2: if (shadow || shadowData) From f521308ad2c06afa00143d3ab407e18d5293d497 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Mar 2007 20:26:07 -0700 Subject: [PATCH 47/85] Correct ref counting of RRMode structures RRModes are referenced by the resource db, RROutput and RRCrtc structures. Ensure that the mode reference count is decremented each time a reference is lost from one of these sources. The missing destroys were in RRCrtcDestroyResource and RROutputDestroyResource, which only happen at server reset time, so modes would be unavailable in subsequent server generations. --- randr/rrcrtc.c | 2 ++ randr/rroutput.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 43a6fcac9..1b3c230f5 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -370,6 +370,8 @@ RRCrtcDestroyResource (pointer value, XID pid) } if (crtc->gammaRed) xfree (crtc->gammaRed); + if (crtc->mode) + RRModeDestroy (crtc->mode); xfree (crtc); return 1; } diff --git a/randr/rroutput.c b/randr/rroutput.c index 31ec92421..09f2afd87 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -406,9 +406,12 @@ RROutputDestroyResource (pointer value, XID pid) } } } - /* XXX destroy all modes? */ if (output->modes) + { + for (m = 0; m < output->numModes; m++) + RRModeDestroy (output->modes[m]); xfree (output->modes); + } for (m = 0; m < output->numUserModes; m++) RRModeDestroy (output->userModes[m]); From 52fccb9d9fdbb1c9dc3f5225600004cd94e42a4a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 17 Mar 2007 17:26:11 -0700 Subject: [PATCH 48/85] Remove extra (and wrong) I2C ByteTimeout setting in DDC code. The DDC code sets the I2C timeouts to VESA standards, except that it had an extra setting of the ByteTimeout value which was wrong (off by a factor of 50). Removing this should help DDC work on many more monitors. Note that the Intel driver duplicated these settings, along with the error. Yay for cult and paste coding. --- hw/xfree86/ddc/xf86DDC.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c index 4ce585c9f..0f24c520e 100644 --- a/hw/xfree86/ddc/xf86DDC.c +++ b/hw/xfree86/ddc/xf86DDC.c @@ -344,7 +344,6 @@ DDCRead_DDC2(int scrnIndex, I2CBusPtr pBus, int start, int len) dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */ dev->StartTimeout = 550; dev->BitTimeout = 40; - dev->ByteTimeout = 40; dev->AcknTimeout = 40; dev->pI2CBus = pBus; From 0f80340a526b2838b9f39145f29941222e84184b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 17 Mar 2007 20:14:05 -0700 Subject: [PATCH 49/85] Slow down DDC I2C bus using a RiseFallTime of 20us for old monitors. This time value makes the bus run slowly enough for even the least reliable of monitors. Thanks to Pavel Troller for finding the necessary change. --- hw/xfree86/ddc/xf86DDC.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c index 0f24c520e..8080c8d2a 100644 --- a/hw/xfree86/ddc/xf86DDC.c +++ b/hw/xfree86/ddc/xf86DDC.c @@ -337,6 +337,12 @@ DDCRead_DDC2(int scrnIndex, I2CBusPtr pBus, int start, int len) unsigned char *R_Buffer; int i; + /* + * Slow down the bus so that older monitors don't + * miss things. + */ + pBus->RiseFallTime = 20; + if (!(dev = xf86I2CFindDev(pBus, 0x00A0))) { dev = xf86CreateI2CDevRec(); dev->DevName = "ddc2"; From f8db7665dcd7af78ca4db2461e0bf787ec662cb1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 20 Mar 2007 07:17:27 -0700 Subject: [PATCH 50/85] Clean up Rotate state on server reset. The rotation state is stored in the xf86_config structure which is not re-initialized at server reset time. Clean it up at CloseScreen time. --- hw/xfree86/loader/xf86sym.c | 1 + hw/xfree86/modes/xf86Crtc.c | 20 ++++++++++ hw/xfree86/modes/xf86Crtc.h | 8 ++++ hw/xfree86/modes/xf86Rotate.c | 74 +++++++++++++++++++++++++---------- 4 files changed, 82 insertions(+), 21 deletions(-) diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index f468b1f07..31039761f 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -1180,6 +1180,7 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMVAR(pciNumBuses) /* modes */ + SYMVAR(xf86CrtcConfigPrivateIndex) SYMFUNC(xf86CrtcConfigInit) SYMFUNC(xf86CrtcConfigPrivateIndex) SYMFUNC(xf86CrtcCreate) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 1a4292092..a875cdf39 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -565,6 +565,22 @@ xf86CrtcCreateScreenResources (ScreenPtr screen) return TRUE; } +/* + * Clean up config on server reset + */ +static Bool +xf86CrtcCloseScreen (int index, ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + + screen->CloseScreen = config->CloseScreen; + + xf86RotateCloseScreen (screen); + + return screen->CloseScreen (index, screen); +} + /* * Called at ScreenInit time to set up */ @@ -596,6 +612,10 @@ xf86CrtcScreenInit (ScreenPtr screen) /* Wrap CreateScreenResources so we can initialize the RandR code */ config->CreateScreenResources = screen->CreateScreenResources; screen->CreateScreenResources = xf86CrtcCreateScreenResources; + + config->CloseScreen = screen->CloseScreen; + screen->CloseScreen = xf86CrtcCloseScreen; + return TRUE; } diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index b7515928e..42daf6079 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -544,6 +544,8 @@ typedef struct _xf86CrtcConfig { CreateScreenResourcesProcPtr CreateScreenResources; + CloseScreenProcPtr CloseScreen; + /* Cursor information */ xf86CursorInfoPtr cursor_info; CursorPtr cursor; @@ -593,6 +595,12 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, Bool xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation); +/* + * Clean up rotation during CloseScreen + */ +void +xf86RotateCloseScreen (ScreenPtr pScreen); + /** * Return whether any output is assigned to the crtc */ diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index e82b69e1b..e8fafd073 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -321,6 +321,58 @@ xf86RotateWakeupHandler(pointer data, int i, pointer LastSelectMask) { } +static void +xf86RotateDestroy (xf86CrtcPtr crtc) +{ + ScrnInfoPtr pScrn = crtc->scrn; + ScreenPtr pScreen = pScrn->pScreen; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + int c; + + /* Free memory from rotation */ + if (crtc->rotatedPixmap || crtc->rotatedData) + { + crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData); + crtc->rotatedPixmap = NULL; + crtc->rotatedData = NULL; + } + + for (c = 0; c < xf86_config->num_crtc; c++) + if (crtc->rotatedPixmap || crtc->rotatedData) + return; + + /* + * Clean up damage structures when no crtcs are rotated + */ + if (xf86_config->rotation_damage) + { + /* Free damage structure */ + if (xf86_config->rotation_damage_registered) + { + DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, + xf86_config->rotation_damage); + xf86_config->rotation_damage_registered = FALSE; + } + DamageDestroy (xf86_config->rotation_damage); + xf86_config->rotation_damage = NULL; + /* Free block/wakeup handler */ + RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler, + xf86RotateWakeupHandler, + (pointer) pScreen); + } +} + +void +xf86RotateCloseScreen (ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c < xf86_config->num_crtc; c++) + xf86RotateDestroy (xf86_config->crtc[c]); +} + Bool xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) { @@ -330,27 +382,7 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation) if (rotation == RR_Rotate_0) { - /* Free memory from rotation */ - if (crtc->rotatedPixmap || crtc->rotatedData) - { - crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData); - crtc->rotatedPixmap = NULL; - crtc->rotatedData = NULL; - } - - if (xf86_config->rotation_damage) - { - /* Free damage structure */ - DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, - xf86_config->rotation_damage); - xf86_config->rotation_damage_registered = FALSE; - DamageDestroy (xf86_config->rotation_damage); - xf86_config->rotation_damage = NULL; - /* Free block/wakeup handler */ - RemoveBlockAndWakeupHandlers (xf86RotateBlockHandler, - xf86RotateWakeupHandler, - (pointer) pScreen); - } + xf86RotateDestroy (crtc); } else { From 16f4c0c1750824f2e5a001cef82a4122a7a2beb0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 23 Mar 2007 00:57:18 -0700 Subject: [PATCH 51/85] Clear allocated RandR screen private structure. Use xcalloc instead of xalloc when allocating this structure to ensure consistent contents at startup. --- randr/randr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/randr/randr.c b/randr/randr.c index 5fa9baf84..4dd0ee5b4 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -230,7 +230,7 @@ Bool RRScreenInit(ScreenPtr pScreen) RRScreenGeneration = serverGeneration; } - pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec)); + pScrPriv = (rrScrPrivPtr) xcalloc (1, sizeof (rrScrPrivRec)); if (!pScrPriv) return FALSE; From 492c768065f49306a2194a88edf96b85de0ff4ff Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 23 Mar 2007 00:59:11 -0700 Subject: [PATCH 52/85] Clean up xf86CrtcRec and xf86OutputRec objects at CloseScreen. Erase pointers to structures which are freed at server reset time. --- hw/xfree86/modes/xf86Crtc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index a875cdf39..fad0752eb 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -573,11 +573,25 @@ xf86CrtcCloseScreen (int index, ScreenPtr screen) { ScrnInfoPtr scrn = xf86Screens[screen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int o, c; screen->CloseScreen = config->CloseScreen; xf86RotateCloseScreen (screen); + for (o = 0; o < config->num_output; o++) + { + xf86OutputPtr output = config->output[o]; + + output->crtc = NULL; + output->randr_output = NULL; + } + for (c = 0; c < config->num_crtc; c++) + { + xf86CrtcPtr crtc = config->crtc[c]; + + crtc->randr_crtc = NULL; + } return screen->CloseScreen (index, screen); } From 9ca7ba5d6012295a77ed773c656e786440da973d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 23 Mar 2007 01:03:40 -0700 Subject: [PATCH 53/85] Make sure RandR events are delivered from RRCrtcSet. Some paths were skipping the event delivery stage. --- randr/rrcrtc.c | 93 +++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 1b3c230f5..da8825346 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -271,6 +271,8 @@ RRCrtcSet (RRCrtcPtr crtc, RROutputPtr *outputs) { ScreenPtr pScreen = crtc->pScreen; + Bool ret = FALSE; + rrScrPriv(pScreen); /* See if nothing changed */ if (crtc->mode == mode && @@ -280,61 +282,64 @@ RRCrtcSet (RRCrtcPtr crtc, crtc->numOutputs == numOutputs && !memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr))) { - return TRUE; + ret = TRUE; } - if (pScreen) + else { #if RANDR_12_INTERFACE - rrScrPriv(pScreen); if (pScrPriv->rrCrtcSet) { - return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, - rotation, numOutputs, outputs); + ret = (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, + rotation, numOutputs, outputs); } + else #endif -#if RANDR_10_INTERFACE - if (pScrPriv->rrSetConfig) { - RRScreenSize size; - RRScreenRate rate; - Bool ret; +#if RANDR_10_INTERFACE + if (pScrPriv->rrSetConfig) + { + RRScreenSize size; + RRScreenRate rate; - if (!mode) - { - RRCrtcNotify (crtc, NULL, x, y, rotation, 0, NULL); - return TRUE; + if (!mode) + { + RRCrtcNotify (crtc, NULL, x, y, rotation, 0, NULL); + ret = TRUE; + } + else + { + size.width = mode->mode.width; + size.height = mode->mode.height; + if (outputs[0]->mmWidth && outputs[0]->mmHeight) + { + size.mmWidth = outputs[0]->mmWidth; + size.mmHeight = outputs[0]->mmHeight; + } + else + { + size.mmWidth = pScreen->mmWidth; + size.mmHeight = pScreen->mmHeight; + } + size.nRates = 1; + rate.rate = RRVerticalRefresh (&mode->mode); + size.pRates = &rate; + ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size); + /* + * Old 1.0 interface tied screen size to mode size + */ + if (ret) + { + RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs); + RRScreenSizeNotify (pScreen); + } + } } - - size.width = mode->mode.width; - size.height = mode->mode.height; - if (outputs[0]->mmWidth && outputs[0]->mmHeight) - { - size.mmWidth = outputs[0]->mmWidth; - size.mmHeight = outputs[0]->mmHeight; - } - else - { - size.mmWidth = pScreen->mmWidth; - size.mmHeight = pScreen->mmHeight; - } - size.nRates = 1; - rate.rate = RRVerticalRefresh (&mode->mode); - size.pRates = &rate; - ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size); - /* - * Old 1.0 interface tied screen size to mode size - */ - if (ret) - { - RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs); - RRScreenSizeNotify (pScreen); - } - return ret; - } #endif - RRTellChanged (pScreen); + } + if (ret) + RRTellChanged (pScreen); } - return FALSE; + return ret; } /* @@ -716,6 +721,7 @@ ProcRRSetCrtcConfig (ClientPtr client) goto sendReply; } +#if 0 /* * if the client's config timestamp is not the same as the last config * timestamp, then the config information isn't up-to-date and @@ -726,6 +732,7 @@ ProcRRSetCrtcConfig (ClientPtr client) rep.status = RRSetConfigInvalidConfigTime; goto sendReply; } +#endif /* * Validate requested rotation From 8eb288fbd69e2ffd02521d2c6a964c8180d08ec8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 23 Mar 2007 01:05:55 -0700 Subject: [PATCH 54/85] Fix Pending property API, adding RRPostPendingProperty. Pending Properties take effect when the driver says they do, so provide an API to tell DIX when a property effect is made. Also, allow driver to reject property values in RRChangeOutputProperty. --- hw/xfree86/modes/xf86Crtc.c | 2 +- randr/randrstr.h | 5 +- randr/rrproperty.c | 151 ++++++++++++++++++++++-------------- 3 files changed, 99 insertions(+), 59 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index fad0752eb..2341715e7 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1923,7 +1923,7 @@ xf86OutputSetEDIDProperty (xf86OutputPtr output, void *data, int data_len) if (data_len != 0) { RRChangeOutputProperty(output->randr_output, edid_atom, XA_INTEGER, 8, - PropModeReplace, data_len, data, FALSE); + PropModeReplace, data_len, data, FALSE, TRUE); } else { RRDeleteOutputProperty(output->randr_output, edid_atom); } diff --git a/randr/randrstr.h b/randr/randrstr.h index 396810332..40d3eec8d 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -759,10 +759,13 @@ RRQueryOutputProperty (RROutputPtr output, Atom property); void RRDeleteOutputProperty (RROutputPtr output, Atom property); +Bool +RRPostPendingProperty (RROutputPtr output, Atom property); + int RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, int format, int mode, unsigned long len, - pointer value, Bool sendevent); + pointer value, Bool sendevent, Bool pending); int RRConfigureOutputProperty (RROutputPtr output, Atom property, diff --git a/randr/rrproperty.c b/randr/rrproperty.c index e020d5bc7..a57bd74bd 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -121,19 +121,19 @@ RRDeleteOutputProperty (RROutputPtr output, Atom property) int RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, int format, int mode, unsigned long len, - pointer value, Bool sendevent) + pointer value, Bool sendevent, Bool pending) { RRPropertyPtr prop; xRROutputPropertyNotifyEvent event; rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen); - int sizeInBytes; - int totalSize; - pointer data; + int size_in_bytes; + int total_size; + unsigned long total_len; RRPropertyValuePtr prop_value; + RRPropertyValueRec new_value; Bool add = FALSE; - sizeInBytes = format >> 3; - totalSize = len * sizeInBytes; + size_in_bytes = format >> 3; /* first see if property already exists */ prop = RRQueryOutputProperty (output, property); @@ -145,7 +145,7 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, add = TRUE; mode = PropModeReplace; } - if (prop->is_pending) + if (pending && prop->is_pending) prop_value = &prop->pending; else prop_value = &prop->current; @@ -159,68 +159,75 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, return(BadMatch); if ((prop_value->type != type) && (mode != PropModeReplace)) return(BadMatch); + new_value = *prop_value; if (mode == PropModeReplace) + total_len = len; + else + total_len = prop_value->size + len; + + if (mode == PropModeReplace || len > 0) { - if (totalSize != prop_value->size * (prop_value->format >> 3)) + pointer new_data, old_data; + + total_size = total_len * size_in_bytes; + new_value.data = (pointer)xalloc (total_size); + if (!new_value.data && total_size) { - if (prop_value->data) - data = (pointer)xrealloc(prop_value->data, totalSize); - else - data = (pointer)xalloc (totalSize); - if (!data && len) - { - if (add) - RRDestroyOutputProperty (prop); - return(BadAlloc); - } - prop_value->data = data; + if (add) + RRDestroyOutputProperty (prop); + return BadAlloc; } if (len) - memmove((char *)prop_value->data, (char *)value, totalSize); - prop_value->size = len; - prop_value->type = type; - prop_value->format = format; + memmove((char *)new_value.data, (char *)value, total_size); + new_value.size = len; + new_value.type = type; + new_value.format = format; + + switch (mode) { + case PropModeReplace: + new_data = new_value.data; + old_data = NULL; + break; + case PropModeAppend: + new_data = (pointer) (((char *) new_value.data) + + (prop_value->size * size_in_bytes)); + old_data = new_value.data; + break; + case PropModePrepend: + new_data = new_value.data; + old_data = (pointer) (((char *) new_value.data) + + (prop_value->size * size_in_bytes)); + break; + } + memcpy ((char *) new_data, (char *) value, len * size_in_bytes); + if (old_data) + memcpy ((char *) old_data, (char *) prop_value->data, + prop_value->size * size_in_bytes); + + if (pending && pScrPriv->rrOutputSetProperty && + !pScrPriv->rrOutputSetProperty(output->pScreen, output, + prop->propertyName, &new_value)) + { + if (new_value.data) + xfree (new_value.data); + return (BadValue); + } + if (prop_value->data) + xfree (prop_value->data); + *prop_value = new_value; } + else if (len == 0) { /* do nothing */ } - else if (mode == PropModeAppend) - { - data = (pointer)xrealloc(prop_value->data, - sizeInBytes * (len + prop_value->size)); - if (!data) - return(BadAlloc); - prop_value->data = data; - memmove(&((char *)data)[prop_value->size * sizeInBytes], - (char *)value, - totalSize); - prop_value->size += len; - } - else if (mode == PropModePrepend) - { - data = (pointer)xalloc(sizeInBytes * (len + prop_value->size)); - if (!data) - return(BadAlloc); - memmove(&((char *)data)[totalSize], (char *)prop_value->data, - (int)(prop_value->size * sizeInBytes)); - memmove((char *)data, (char *)value, totalSize); - xfree(prop_value->data); - prop_value->data = data; - prop_value->size += len; - } + if (add) { prop->next = output->properties; output->properties = prop; } - if (!prop->is_pending && pScrPriv->rrOutputSetProperty) { - /* What should we do in case of failure? */ - pScrPriv->rrOutputSetProperty(output->pScreen, output, - prop->propertyName, prop_value); - } - if (sendevent) { event.type = RREventBase + RRNotify; @@ -234,6 +241,33 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, return(Success); } +Bool +RRPostPendingProperty (RROutputPtr output, Atom property) +{ + RRPropertyPtr prop = RRQueryOutputProperty (output, property); + RRPropertyValuePtr pending_value; + RRPropertyValuePtr current_value; + + if (!prop) + return FALSE; + if (!prop->is_pending) + return FALSE; + pending_value = &prop->pending; + current_value = &prop->current; + + if (pending_value->type == current_value->type && + pending_value->format == current_value->format && + pending_value->size == current_value->size && + !memcmp (pending_value->data, current_value->data, pending_value->size)) + return TRUE; + + if (RRChangeOutputProperty (output, property, + pending_value->type, pending_value->format, PropModeReplace, + pending_value->size, pending_value->data, TRUE, FALSE) != Success) + return FALSE; + return TRUE; +} + RRPropertyPtr RRQueryOutputProperty (RROutputPtr output, Atom property) { @@ -474,7 +508,7 @@ ProcRRChangeOutputProperty (ClientPtr client) err = RRChangeOutputProperty(output, stuff->property, stuff->type, (int)format, - (int)mode, len, (pointer)&stuff[1], TRUE); + (int)mode, len, (pointer)&stuff[1], TRUE, TRUE); if (err != Success) return err; else @@ -508,8 +542,8 @@ int ProcRRGetOutputProperty (ClientPtr client) { REQUEST(xRRGetOutputPropertyReq); - RRPropertyPtr prop, *prev; - RRPropertyValuePtr prop_value; + RRPropertyPtr prop, *prev; + RRPropertyValuePtr prop_value; unsigned long n, len, ind; RROutputPtr output; xRRGetOutputPropertyReply reply; @@ -600,7 +634,10 @@ ProcRRGetOutputProperty (ClientPtr client) reply.bytesAfter = n - (ind + len); reply.format = prop_value->format; reply.length = (len + 3) >> 2; - reply.nItems = len / (prop_value->format / 8 ); + if (prop_value->format) + reply.nItems = len / (prop_value->format / 8); + else + reply.nItems = 0; reply.propertyType = prop_value->type; if (stuff->delete && (reply.bytesAfter == 0)) From 945aa0aa556429b50dea8e8ebc0008304b093eb7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 23 Mar 2007 01:17:14 -0700 Subject: [PATCH 55/85] Incorrect extra memory copy in RRChangeOutputProperty. Left over from previous version of the code, this memmove will break when the mode is not Replace. --- randr/rrproperty.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/randr/rrproperty.c b/randr/rrproperty.c index a57bd74bd..afac351e3 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -177,8 +177,6 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, RRDestroyOutputProperty (prop); return BadAlloc; } - if (len) - memmove((char *)new_value.data, (char *)value, total_size); new_value.size = len; new_value.type = type; new_value.format = format; From 36e5227215e0912ddf8a010db042467f00efe0fc Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 23 Mar 2007 14:39:10 -0700 Subject: [PATCH 56/85] Ensure that crtc desired values track most recent mode. desiredX and desiredY were not recorded during xf86InitialConfiguration. desiredX, desiredY and desiredRotation were not recorded during xf86SetSingleMode. --- hw/xfree86/modes/xf86Crtc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 2341715e7..b9895d9da 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1589,6 +1589,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) { crtc->desiredMode = *mode; crtc->desiredRotation = output->initial_rotation; + crtc->desiredX = output->initial_x; + crtc->desiredY = output->initial_y; crtc->enabled = TRUE; crtc->x = output->initial_x; crtc->y = output->initial_y; @@ -1813,7 +1815,12 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation) if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0)) ok = FALSE; else + { crtc->desiredMode = *crtc_mode; + crtc->desiredRotation = rotation; + crtc->desiredX = 0; + crtc->desiredY = 0; + } } xf86DisableUnusedFunctions(pScrn); return ok; From 57e87e0d006cbf1f5b175fe02eeb981f741d92f0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 23 Mar 2007 23:41:36 -0700 Subject: [PATCH 57/85] Make pending properties force mode set. And, remove AttachScreen calls. Yes, two changes in one commit. Sorry 'bout that. The first change ensures that when pending property values have been changed, a mode set to the current mode will actually do something, rather than being identified as a no-op. In addition, the driver no longer needs to manage the migration of pending to current values, that is handled both within the xf86 mode setting code (to deal with non-RandR changes) as well as within the RandR extension itself. The second change eliminates the two-call Create/AttachScreen stuff that was done in a failed attempt to create RandR resources before the screen structures were allocated. Merging these back into the Create function is cleaner. --- hw/xfree86/modes/xf86Crtc.c | 6 +++ hw/xfree86/modes/xf86RandR12.c | 7 ++- randr/mirandr.c | 11 +---- randr/randrstr.h | 24 ++-------- randr/rrcrtc.c | 82 ++++++++++++++++++-------------- randr/rrinfo.c | 11 +---- randr/rroutput.c | 49 ++++++++----------- randr/rrproperty.c | 87 +++++++++++++++++++++------------- 8 files changed, 138 insertions(+), 139 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index b9895d9da..7d86b6606 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -312,7 +312,13 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, { xf86OutputPtr output = xf86_config->output[i]; if (output->crtc == crtc) + { output->funcs->commit(output); +#ifdef RANDR_12_INTERFACE + if (output->randr_output) + RRPostPendingProperties (output->randr_output); +#endif + } } /* XXX free adjustedmode */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 4213fea52..6f52ee2d9 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1011,8 +1011,7 @@ xf86RandR12CreateObjects12 (ScreenPtr pScreen) { xf86CrtcPtr crtc = config->crtc[c]; - crtc->randr_crtc = RRCrtcCreate (crtc); - RRCrtcAttachScreen (crtc->randr_crtc, pScreen); + crtc->randr_crtc = RRCrtcCreate (pScreen, crtc); RRCrtcGammaSetSize (crtc->randr_crtc, 256); } /* @@ -1022,13 +1021,13 @@ xf86RandR12CreateObjects12 (ScreenPtr pScreen) { xf86OutputPtr output = config->output[o]; - output->randr_output = RROutputCreate (output->name, + output->randr_output = RROutputCreate (pScreen, output->name, strlen (output->name), output); - RROutputAttachScreen (output->randr_output, pScreen); if (output->funcs->create_resources != NULL) output->funcs->create_resources(output); + RRPostPendingProperties (output->randr_output); } return TRUE; } diff --git a/randr/mirandr.c b/randr/mirandr.c index 47136fb96..3c4991e5a 100644 --- a/randr/mirandr.c +++ b/randr/mirandr.c @@ -133,20 +133,13 @@ miRandRInit (ScreenPtr pScreen) if (!mode) return FALSE; - crtc = RRCrtcCreate (NULL); + crtc = RRCrtcCreate (pScreen, NULL); if (!crtc) return FALSE; - if (!RRCrtcAttachScreen (crtc, pScreen)) - { - RRCrtcDestroy (crtc); - return FALSE; - } - output = RROutputCreate ("screen", 6, NULL); + output = RROutputCreate (pScreen, "screen", 6, NULL); if (!output) return FALSE; - if (!RROutputAttachScreen (output, pScreen)) - return FALSE; if (!RROutputSetClones (output, NULL, 0)) return FALSE; if (!RROutputSetModes (output, &mode, 1, 0)) diff --git a/randr/randrstr.h b/randr/randrstr.h index 40d3eec8d..6deaf4732 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -138,6 +138,7 @@ struct _rrOutput { RRModePtr *userModes; Bool changed; RRPropertyPtr properties; + Bool pendingProperties; void *devPrivate; }; @@ -496,7 +497,7 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged); * Create a CRTC */ RRCrtcPtr -RRCrtcCreate (void *devPrivate); +RRCrtcCreate (ScreenPtr pScreen, void *devPrivate); /* * Set the allowed rotations on a CRTC @@ -504,14 +505,6 @@ RRCrtcCreate (void *devPrivate); void RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations); -/* - * Attach a CRTC to a screen. Once done, this cannot be - * undone without destroying the CRTC; it is separate from Create - * only to allow an xf86-based driver to create objects in preinit - */ -Bool -RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen); - /* * Notify the extension that the Crtc has been reconfigured, * the driver calls this whenever it has updated the mode @@ -668,18 +661,11 @@ RROutputChanged (RROutputPtr output, Bool configChanged); */ RROutputPtr -RROutputCreate (const char *name, +RROutputCreate (ScreenPtr pScreen, + const char *name, int nameLength, void *devPrivate); -/* - * Attach an output to a screen, again split from creation so - * xf86 DDXen can create randr resources before the ScreenRec - * exists - */ -Bool -RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen); - /* * Notify extension that output parameters have been changed */ @@ -760,7 +746,7 @@ void RRDeleteOutputProperty (RROutputPtr output, Atom property); Bool -RRPostPendingProperty (RROutputPtr output, Atom property); +RRPostPendingProperties (RROutputPtr output); int RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index da8825346..1a2a3a7c5 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -51,17 +51,32 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged) * Create a CRTC */ RRCrtcPtr -RRCrtcCreate (void *devPrivate) +RRCrtcCreate (ScreenPtr pScreen, void *devPrivate) { - RRCrtcPtr crtc; - + RRCrtcPtr crtc; + RRCrtcPtr *crtcs; + rrScrPrivPtr pScrPriv; + if (!RRInit()) return NULL; + + pScrPriv = rrGetScrPriv(pScreen); + + /* make space for the crtc pointer */ + if (pScrPriv->numCrtcs) + crtcs = xrealloc (pScrPriv->crtcs, + (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr)); + else + crtcs = xalloc (sizeof (RRCrtcPtr)); + if (!crtcs) + return FALSE; + pScrPriv->crtcs = crtcs; + crtc = xalloc (sizeof (RRCrtcRec)); if (!crtc) return NULL; crtc->id = FakeClientID (0); - crtc->pScreen = NULL; + crtc->pScreen = pScreen; crtc->mode = NULL; crtc->x = 0; crtc->y = 0; @@ -77,6 +92,10 @@ RRCrtcCreate (void *devPrivate) if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc)) return NULL; + /* attach the screen and crtc together */ + crtc->pScreen = pScreen; + pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc; + return crtc; } @@ -89,36 +108,6 @@ RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations) crtc->rotations = rotations; } -/* - * Attach a Crtc to a screen. This is done as a separate step - * so that an xf86-based driver can create CRTCs in PreInit - * before the Screen has been created - */ - -Bool -RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen) -{ - rrScrPriv (pScreen); - RRCrtcPtr *crtcs; - - /* make space for the crtc pointer */ - if (pScrPriv->numCrtcs) - crtcs = xrealloc (pScrPriv->crtcs, - (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr)); - else - crtcs = xalloc (sizeof (RRCrtcPtr)); - if (!crtcs) - return FALSE; - - /* attach the screen and crtc together */ - crtc->pScreen = pScreen; - pScrPriv->crtcs = crtcs; - pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc; - - RRCrtcChanged (crtc, TRUE); - return TRUE; -} - /* * Notify the extension that the Crtc has been reconfigured, * the driver calls this whenever it has updated the mode @@ -258,6 +247,22 @@ RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc) WriteEventsToClient (client, 1, (xEvent *) &ce); } +static Bool +RRCrtcPendingProperties (RRCrtcPtr crtc) +{ + ScreenPtr pScreen = crtc->pScreen; + rrScrPriv(pScreen); + int o; + + for (o = 0; o < pScrPriv->numOutputs; o++) + { + RROutputPtr output = pScrPriv->outputs[o]; + if (output->crtc == crtc && output->pendingProperties) + return TRUE; + } + return FALSE; +} + /* * Request that the Crtc be reconfigured */ @@ -280,7 +285,8 @@ RRCrtcSet (RRCrtcPtr crtc, crtc->y == y && crtc->rotation == rotation && crtc->numOutputs == numOutputs && - !memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr))) + !memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)) && + !RRCrtcPendingProperties (crtc)) { ret = TRUE; } @@ -337,7 +343,13 @@ RRCrtcSet (RRCrtcPtr crtc, #endif } if (ret) + { + int o; RRTellChanged (pScreen); + + for (o = 0; o < numOutputs; o++) + RRPostPendingProperties (outputs[o]); + } } return ret; } diff --git a/randr/rrinfo.c b/randr/rrinfo.c index 549d501dc..5ef1a6b83 100644 --- a/randr/rrinfo.c +++ b/randr/rrinfo.c @@ -91,19 +91,12 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations) if (pScrPriv->numOutputs == 0 && pScrPriv->numCrtcs == 0) { - crtc = RRCrtcCreate (NULL); + crtc = RRCrtcCreate (pScreen, NULL); if (!crtc) return; - if (!RRCrtcAttachScreen (crtc, pScreen)) - { - RRCrtcDestroy (crtc); - return; - } - output = RROutputCreate ("default", 7, NULL); + output = RROutputCreate (pScreen, "default", 7, NULL); if (!output) return; - if (!RROutputAttachScreen (output, pScreen)) - return; RROutputSetCrtcs (output, &crtc, 1); RROutputSetCrtc (output, crtc); RROutputSetConnection (output, RR_Connected); diff --git a/randr/rroutput.c b/randr/rroutput.c index 09f2afd87..c7732798e 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -47,19 +47,35 @@ RROutputChanged (RROutputPtr output, Bool configChanged) */ RROutputPtr -RROutputCreate (const char *name, +RROutputCreate (ScreenPtr pScreen, + const char *name, int nameLength, void *devPrivate) { - RROutputPtr output; + RROutputPtr output; + RROutputPtr *outputs; + rrScrPrivPtr pScrPriv; if (!RRInit()) return NULL; + + pScrPriv = rrGetScrPriv(pScreen); + + if (pScrPriv->numOutputs) + outputs = xrealloc (pScrPriv->outputs, + (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); + else + outputs = xalloc (sizeof (RROutputPtr)); + if (!outputs) + return FALSE; + + pScrPriv->outputs = outputs; + output = xalloc (sizeof (RROutputRec) + nameLength + 1); if (!output) return NULL; output->id = FakeClientID (0); - output->pScreen = NULL; + output->pScreen = pScreen; output->name = (char *) (output + 1); output->nameLength = nameLength; memcpy (output->name, name, nameLength); @@ -85,35 +101,10 @@ RROutputCreate (const char *name, if (!AddResource (output->id, RROutputType, (pointer) output)) return NULL; + pScrPriv->outputs[pScrPriv->numOutputs++] = output; return output; } -/* - * Attach an Output to a screen. This is done as a separate step - * so that an xf86-based driver can create Outputs in PreInit - * before the Screen has been created - */ - -Bool -RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen) -{ - rrScrPriv (pScreen); - RROutputPtr *outputs; - - if (pScrPriv->numOutputs) - outputs = xrealloc (pScrPriv->outputs, - (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr)); - else - outputs = xalloc (sizeof (RROutputPtr)); - if (!outputs) - return FALSE; - output->pScreen = pScreen; - pScrPriv->outputs = outputs; - pScrPriv->outputs[pScrPriv->numOutputs++] = output; - RROutputChanged (output, FALSE); - return TRUE; -} - /* * Notify extension that output parameters have been changed */ diff --git a/randr/rrproperty.c b/randr/rrproperty.c index afac351e3..00dd750d9 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -27,7 +27,7 @@ static void RRDeliverEvent (ScreenPtr pScreen, xEvent *event, CARD32 mask) { - + } void @@ -50,7 +50,7 @@ RRDeleteAllOutputProperties (RROutputPtr output) xfree(prop->current.data); if (prop->pending.data) xfree(prop->pending.data); - xfree(prop); + xfree(prop); } } @@ -67,7 +67,7 @@ static RRPropertyPtr RRCreateOutputProperty (Atom property) { RRPropertyPtr prop; - + prop = (RRPropertyPtr)xalloc(sizeof(RRPropertyRec)); if (!prop) return NULL; @@ -139,7 +139,7 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, prop = RRQueryOutputProperty (output, property); if (!prop) /* just add to list */ { - prop = RRCreateOutputProperty (property); + prop = RRCreateOutputProperty (property); if (!prop) return(BadAlloc); add = TRUE; @@ -149,11 +149,11 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, prop_value = &prop->pending; else prop_value = &prop->current; - + /* To append or prepend to a property the request format and type - must match those of the already defined property. The - existing format and type are irrelevant when using the mode - "PropModeReplace" since they will be written over. */ + must match those of the already defined property. The + existing format and type are irrelevant when using the mode + "PropModeReplace" since they will be written over. */ if ((format != prop_value->format) && (mode != PropModeReplace)) return(BadMatch); @@ -167,8 +167,8 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, if (mode == PropModeReplace || len > 0) { - pointer new_data, old_data; - + pointer new_data = NULL, old_data = NULL; + total_size = total_len * size_in_bytes; new_value.data = (pointer)xalloc (total_size); if (!new_value.data && total_size) @@ -197,11 +197,12 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, (prop_value->size * size_in_bytes)); break; } - memcpy ((char *) new_data, (char *) value, len * size_in_bytes); + if (new_data) + memcpy ((char *) new_data, (char *) value, len * size_in_bytes); if (old_data) memcpy ((char *) old_data, (char *) prop_value->data, prop_value->size * size_in_bytes); - + if (pending && pScrPriv->rrOutputSetProperty && !pScrPriv->rrOutputSetProperty(output->pScreen, output, prop->propertyName, &new_value)) @@ -214,18 +215,21 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, xfree (prop_value->data); *prop_value = new_value; } - + else if (len == 0) { /* do nothing */ } - + if (add) { prop->next = output->properties; output->properties = prop; } + if (pending && prop->is_pending) + output->pendingProperties = TRUE; + if (sendevent) { event.type = RREventBase + RRNotify; @@ -240,30 +244,45 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, } Bool -RRPostPendingProperty (RROutputPtr output, Atom property) +RRPostPendingProperties (RROutputPtr output) { - RRPropertyPtr prop = RRQueryOutputProperty (output, property); - RRPropertyValuePtr pending_value; - RRPropertyValuePtr current_value; - - if (!prop) - return FALSE; - if (!prop->is_pending) - return FALSE; - pending_value = &prop->pending; - current_value = &prop->current; + RRPropertyValuePtr pending_value; + RRPropertyValuePtr current_value; + RRPropertyPtr property; + Bool ret = TRUE; - if (pending_value->type == current_value->type && - pending_value->format == current_value->format && - pending_value->size == current_value->size && - !memcmp (pending_value->data, current_value->data, pending_value->size)) + if (!output->pendingProperties) return TRUE; - if (RRChangeOutputProperty (output, property, - pending_value->type, pending_value->format, PropModeReplace, - pending_value->size, pending_value->data, TRUE, FALSE) != Success) - return FALSE; - return TRUE; + output->pendingProperties = FALSE; + for (property = output->properties; property; property = property->next) + { + /* Skip non-pending properties */ + if (!property->is_pending) + continue; + + pending_value = &property->pending; + current_value = &property->current; + + /* + * If the pending and current values are equal, don't mark it + * as changed (which would deliver an event) + */ + if (pending_value->type == current_value->type && + pending_value->format == current_value->format && + pending_value->size == current_value->size && + !memcmp (pending_value->data, current_value->data, + pending_value->size)) + continue; + + if (RRChangeOutputProperty (output, property->propertyName, + pending_value->type, pending_value->format, + PropModeReplace, pending_value->size, + pending_value->data, TRUE, + FALSE) != Success) + ret = FALSE; + } + return ret; } RRPropertyPtr From c0459d7476f408806b1e7202b960ee0b3911774a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sat, 30 Dec 2006 10:18:28 +0100 Subject: [PATCH 58/85] fbdevhw: Consolidate modeset ioctl calling, report failure if it modifies mode. The fbdev API allows the driver to 'accept' modes it doesn't really support by modifying it to the nearest supported mode. Without this check, e.g. vesafb would appear to accept all modes, even though it actually can't set any modes other than the bootup mode at all. (cherry picked from commit f6815cb68b0f6698497348fc6e4214dacef33b95) --- hw/xfree86/fbdevhw/fbdevhw.c | 127 ++++++++++++++++++++++------------- 1 file changed, 81 insertions(+), 46 deletions(-) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 70bed620b..303ad14de 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -227,6 +227,26 @@ xfree2fbdev_timing(DisplayModePtr mode, struct fb_var_screeninfo *var) var->vmode = FB_VMODE_NONINTERLACED; } +static Bool +fbdev_modes_equal(struct fb_var_screeninfo *one, struct fb_var_screeninfo *two) +{ + return (one->xres_virtual == two->xres_virtual && + one->yres_virtual == two->yres_virtual && + one->bits_per_pixel == two->bits_per_pixel && + one->red.length == two->red.length && + one->green.length == two->green.length && + one->blue.length == two->blue.length && + one->xres == two->xres && one->yres == two->yres && + one->pixclock == two->pixclock && + one->right_margin == two->right_margin && + one->hsync_len == two->hsync_len && + one->left_margin == two->left_margin && + one->lower_margin == two->lower_margin && + one->vsync_len == two->vsync_len && + one->upper_margin == two->upper_margin && + one->sync == two->sync && one->vmode == two->vmode); +} + static void fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode) { @@ -470,13 +490,52 @@ fbdevHWGetVidmem(ScrnInfoPtr pScrn) return fPtr->fix.smem_len; } +static Bool +fbdevHWSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool check) +{ + fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); + struct fb_var_screeninfo req_var = fPtr->var, set_var; + + TRACE_ENTER("ModeInit"); + + xfree2fbdev_fblayout(pScrn, &req_var); + xfree2fbdev_timing(mode, &req_var); + +#if DEBUG + print_xfree_mode("init", mode); + print_fbdev_mode("init", &req_var); +#endif + + set_var = req_var; + + if (check) + set_var.activate = FB_ACTIVATE_TEST; + + if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void*)(&set_var))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); + return FALSE; + } + + if (!fbdev_modes_equal(&set_var, &req_var)) { + if (!check) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "FBIOPUT_VSCREENINFO succeeded but modified " + "mode\n"); +#if DEBUG + print_fbdev_mode("returned", &set_var); +#endif + return FALSE; + } + + fPtr->var = set_var; + + return TRUE; +} + void fbdevHWSetVideoModes(ScrnInfoPtr pScrn) { - fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); - int virtX = pScrn->display->virtualX; - int virtY = pScrn->display->virtualY; - struct fb_var_screeninfo var; char **modename; DisplayModePtr mode,this,last = pScrn->modes; @@ -484,6 +543,9 @@ fbdevHWSetVideoModes(ScrnInfoPtr pScrn) if (NULL == pScrn->display->modes) return; + pScrn->virtualX = pScrn->display->virtualX; + pScrn->virtualY = pScrn->display->virtualY; + for (modename = pScrn->display->modes; *modename != NULL; modename++) { for (mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next) if (0 == strcmp(mode->name,*modename)) @@ -493,27 +555,20 @@ fbdevHWSetVideoModes(ScrnInfoPtr pScrn) "\tmode \"%s\" not found\n", *modename); continue; } - memset(&var,0,sizeof(var)); - xfree2fbdev_timing(mode,&var); - var.xres_virtual = virtX; - var.yres_virtual = virtY; - var.bits_per_pixel = pScrn->bitsPerPixel; - var.red.length = pScrn->weight.red; - var.green.length = pScrn->weight.green; - var.blue.length = pScrn->weight.blue; - var.activate = FB_ACTIVATE_TEST; - if (var.xres_virtual < var.xres) var.xres_virtual = var.xres; - if (var.yres_virtual < var.yres) var.yres_virtual = var.yres; - if (-1 == ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&var))) { + if (!fbdevHWSetMode(pScrn, mode, TRUE)) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmode \"%s\" test failed\n", *modename); continue; } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmode \"%s\" ok\n", *modename); - if (virtX < var.xres) virtX = var.xres; - if (virtY < var.yres) virtY = var.yres; + + if (pScrn->virtualX < mode->HDisplay) + pScrn->virtualX = mode->HDisplay; + if (pScrn->virtualY < mode->VDisplay) + pScrn->virtualY = mode->VDisplay; + if (NULL == pScrn->modes) { pScrn->modes = xnfalloc(sizeof(DisplayModeRec)); this = pScrn->modes; @@ -530,8 +585,6 @@ fbdevHWSetVideoModes(ScrnInfoPtr pScrn) } last = this; } - pScrn->virtualX = virtX; - pScrn->virtualY = virtY; } DisplayModePtr @@ -673,21 +726,12 @@ fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) { fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); - TRACE_ENTER("ModeInit"); - xfree2fbdev_fblayout(pScrn, &fPtr->var); - xfree2fbdev_timing(mode, &fPtr->var); -#if DEBUG - print_xfree_mode("init",mode); - print_fbdev_mode("init",&fPtr->var); -#endif pScrn->vtSema = TRUE; /* set */ - if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->var))) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); + if (!fbdevHWSetMode(pScrn, mode, FALSE)) return FALSE; - } + /* read back */ if (0 != ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -767,18 +811,12 @@ ModeStatus fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); - struct fb_var_screeninfo var; TRACE_ENTER("ValidMode"); - memcpy(&var,&fPtr->var,sizeof(var)); - xfree2fbdev_timing(mode, &var); - var.activate = FB_ACTIVATE_TEST; - if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->var))) { - xf86DrvMsg(scrnIndex, X_ERROR, - "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); + + if (!fbdevHWSetMode(pScrn, mode, TRUE)) return MODE_BAD; - } + return MODE_OK; } @@ -786,15 +824,12 @@ Bool fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); TRACE_ENTER("SwitchMode"); - xfree2fbdev_timing(mode, &fPtr->var); - if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->var))) { - xf86DrvMsg(scrnIndex, X_ERROR, - "FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); + + if (!fbdevHWSetMode(pScrn, mode, FALSE)) return FALSE; - } + return TRUE; } From 28af734cb7f2e5e40f6524411f77eba0e3960a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sat, 30 Dec 2006 16:44:31 +0100 Subject: [PATCH 59/85] fbdevhw: Fix some issues with the previous commit. Fix a TRACE_ENTER typo and only update the internal fbdev mode state cache after actually setting a mode. (cherry picked from commit c385bcf0bde38dd869f7065f859dd4b4126f5690) --- hw/xfree86/fbdevhw/fbdevhw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 303ad14de..83b0dc156 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -496,7 +496,7 @@ fbdevHWSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool check) fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); struct fb_var_screeninfo req_var = fPtr->var, set_var; - TRACE_ENTER("ModeInit"); + TRACE_ENTER("SetMode"); xfree2fbdev_fblayout(pScrn, &req_var); xfree2fbdev_timing(mode, &req_var); @@ -528,7 +528,8 @@ fbdevHWSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool check) return FALSE; } - fPtr->var = set_var; + if (!check) + fPtr->var = set_var; return TRUE; } From d7bcad9c694a13c702e429d8364035850d8f8bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sun, 31 Dec 2006 17:23:31 +0100 Subject: [PATCH 60/85] fbdevhw: Use displayWidth for fbdev virtual width when appropriate. The fbdev API doesn't allow setting the pitch explicitly, so we have to set the virtual width to the pitch we're using for drawing. This fixes corruption after changing the virtual width with RandR. (cherry picked from commit d077c0da470ab7291e8d838eaace57b066477d6f) --- hw/xfree86/fbdevhw/fbdevhw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 83b0dc156..a9288a753 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -183,7 +183,8 @@ print_xfree_mode(char *txt, DisplayModePtr mode) static void xfree2fbdev_fblayout(ScrnInfoPtr pScrn, struct fb_var_screeninfo *var) { - var->xres_virtual = pScrn->virtualX; + var->xres_virtual = pScrn->displayWidth ? pScrn->displayWidth : + pScrn->virtualX; var->yres_virtual = pScrn->virtualY; var->bits_per_pixel = pScrn->bitsPerPixel; var->red.length = pScrn->weight.red; From 1c2793d3ec4c82c7205abb10a1f4d093864425ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sun, 31 Dec 2006 17:59:44 +0100 Subject: [PATCH 61/85] fbdevhw: Override RGB offsets and masks after setting initial mode. This is a hack, but it should be a NOP for all the setups that worked before and actually seems to fix some others... Based on a patch by Peter Teichmann from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=338241 . (cherry picked from commit dc5eb4523298f966bd5fd9ae6672160034b5e82c) --- hw/xfree86/fbdevhw/fbdevhw.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index a9288a753..8f78b85af 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -745,6 +745,17 @@ fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); return FALSE; } + + /* XXX: This is a hack, but it should be a NOP for all the setups that + * worked before and actually seems to fix some others... + */ + pScrn->offset.red = fPtr->var.red.offset; + pScrn->offset.green = fPtr->var.green.offset; + pScrn->offset.blue = fPtr->var.blue.offset; + pScrn->mask.red = ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset; + pScrn->mask.green = ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset; + pScrn->mask.blue = ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset; + return TRUE; } From 7679b2c6139ee7345b4f65ab84384162bbd796ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Fri, 19 Jan 2007 18:28:05 +0100 Subject: [PATCH 62/85] fbdevhw: Consider mode set equal to mode requested if virtual width is larger. (cherry picked from commit 27a01e100bff21ac0b70c6d72071d7226fc91264) --- hw/xfree86/fbdevhw/fbdevhw.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 8f78b85af..8b163beba 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -229,23 +229,23 @@ xfree2fbdev_timing(DisplayModePtr mode, struct fb_var_screeninfo *var) } static Bool -fbdev_modes_equal(struct fb_var_screeninfo *one, struct fb_var_screeninfo *two) +fbdev_modes_equal(struct fb_var_screeninfo *set, struct fb_var_screeninfo *req) { - return (one->xres_virtual == two->xres_virtual && - one->yres_virtual == two->yres_virtual && - one->bits_per_pixel == two->bits_per_pixel && - one->red.length == two->red.length && - one->green.length == two->green.length && - one->blue.length == two->blue.length && - one->xres == two->xres && one->yres == two->yres && - one->pixclock == two->pixclock && - one->right_margin == two->right_margin && - one->hsync_len == two->hsync_len && - one->left_margin == two->left_margin && - one->lower_margin == two->lower_margin && - one->vsync_len == two->vsync_len && - one->upper_margin == two->upper_margin && - one->sync == two->sync && one->vmode == two->vmode); + return (set->xres_virtual >= req->xres_virtual && + set->yres_virtual == req->yres_virtual && + set->bits_per_pixel == req->bits_per_pixel && + set->red.length == req->red.length && + set->green.length == req->green.length && + set->blue.length == req->blue.length && + set->xres == req->xres && set->yres == req->yres && + set->pixclock == req->pixclock && + set->right_margin == req->right_margin && + set->hsync_len == req->hsync_len && + set->left_margin == req->left_margin && + set->lower_margin == req->lower_margin && + set->vsync_len == req->vsync_len && + set->upper_margin == req->upper_margin && + set->sync == req->sync && set->vmode == req->vmode); } static void From 96636598ee8a024b2fc93e2779b581446fa22d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Fri, 19 Jan 2007 18:30:21 +0100 Subject: [PATCH 63/85] fbdevhw: Only deal with RGB weight if default visual is True- or DirectColor. (cherry picked from commit 14d6a9b327381a6bb2dac59c62728e5fd0f0bcfb) --- hw/xfree86/fbdevhw/fbdevhw.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 8b163beba..a573b8f5b 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -187,9 +187,16 @@ xfree2fbdev_fblayout(ScrnInfoPtr pScrn, struct fb_var_screeninfo *var) pScrn->virtualX; var->yres_virtual = pScrn->virtualY; var->bits_per_pixel = pScrn->bitsPerPixel; - var->red.length = pScrn->weight.red; - var->green.length = pScrn->weight.green; - var->blue.length = pScrn->weight.blue; + if (pScrn->defaultVisual == TrueColor || + pScrn->defaultVisual == DirectColor) { + var->red.length = pScrn->weight.red; + var->green.length = pScrn->weight.green; + var->blue.length = pScrn->weight.blue; + } else { + var->red.length = 8; + var->green.length = 8; + var->blue.length = 8; + } } static void @@ -746,15 +753,18 @@ fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) return FALSE; } - /* XXX: This is a hack, but it should be a NOP for all the setups that - * worked before and actually seems to fix some others... - */ - pScrn->offset.red = fPtr->var.red.offset; - pScrn->offset.green = fPtr->var.green.offset; - pScrn->offset.blue = fPtr->var.blue.offset; - pScrn->mask.red = ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset; - pScrn->mask.green = ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset; - pScrn->mask.blue = ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset; + if (pScrn->defaultVisual == TrueColor || + pScrn->defaultVisual == DirectColor) { + /* XXX: This is a hack, but it should be a NOP for all the setups that + * worked before and actually seems to fix some others... + */ + pScrn->offset.red = fPtr->var.red.offset; + pScrn->offset.green = fPtr->var.green.offset; + pScrn->offset.blue = fPtr->var.blue.offset; + pScrn->mask.red = ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset; + pScrn->mask.green = ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset; + pScrn->mask.blue = ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset; + } return TRUE; } From dc914ced69e1e619a944c7dcb940c25e195cd4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Sun, 15 Oct 2006 16:48:59 +0200 Subject: [PATCH 64/85] Add per-drawable Xv colour key helper function. This allows overlay Xv adaptors to work slightly better with compositing managers. Bump the video driver ABI minor so drivers only need to check for this at build time. (cherry picked from commit a232693c8c2a206aac47c07b133c071938204e0b) Conflicts: hw/xfree86/common/xf86Module.h Avoid picking up XInput ABI version change. --- hw/xfree86/common/xf86xv.c | 66 ++++++++++++++++++++++++++++++++-- hw/xfree86/common/xf86xv.h | 3 ++ hw/xfree86/common/xf86xvpriv.h | 1 + hw/xfree86/loader/xf86sym.c | 1 + 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index 89cb6bac4..3e908b86a 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -974,6 +974,7 @@ xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) if(!winPriv) { winPriv = xalloc(sizeof(XF86XVWindowRec)); if(!winPriv) return BadAlloc; + memset(winPriv, 0, sizeof(XF86XVWindowRec)); winPriv->PortRec = portPriv; winPriv->next = PrivRoot; pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv; @@ -1026,6 +1027,9 @@ xf86XVDestroyWindow(WindowPtr pWin) pPriv->pDraw = NULL; tmp = WinPriv; + if(WinPriv->pGC) { + FreeGC(WinPriv->pGC, 0); + } WinPriv = WinPriv->next; xfree(tmp); } @@ -1118,6 +1122,8 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) while(WinPriv) { pPriv = WinPriv->PortRec; + if(!pPriv) goto next; + if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) REGION_DESTROY(pScreen, pPriv->pCompositeClip); @@ -1148,6 +1154,7 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy) } } +next: pPrev = WinPriv; WinPriv = WinPriv->next; } @@ -1739,9 +1746,13 @@ xf86XVPutImage( REGION_UNINIT(pScreen, &VPReg); } - if(portPriv->pDraw) { + /* If we are changing windows, unregister our port in the old window */ + if(portPriv->pDraw && (portPriv->pDraw != pDraw)) xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); - } + + /* Register our port with the new window */ + ret = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); + if(ret != Success) goto PUT_IMAGE_BAILOUT; if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { clippedAway = TRUE; @@ -1772,7 +1783,6 @@ xf86XVPutImage( if((ret == Success) && (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) { - xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv); portPriv->isOn = XV_ON; portPriv->pDraw = pDraw; portPriv->drw_x = drw_x; portPriv->drw_y = drw_y; @@ -1813,6 +1823,56 @@ xf86XVQueryImageAttributes( format->id, width, height, pitches, offsets); } + +_X_EXPORT void +xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes) +{ + ScreenPtr pScreen = pDraw->pScreen; + WindowPtr pWin = (WindowPtr)pDraw; + XF86XVWindowPtr pPriv = GET_XF86XV_WINDOW(pWin); + GCPtr pGC = NULL; + XID pval[2]; + BoxPtr pbox = REGION_RECTS(clipboxes); + int i, nbox = REGION_NUM_RECTS(clipboxes); + xRectangle *rects; + + if(!xf86Screens[pScreen->myNum]->vtSema) return; + + if(pPriv) + pGC = pPriv->pGC; + + if(!pGC) { + int status; + pval[0] = key; + pval[1] = IncludeInferiors; + pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status); + if(!pGC) return; + ValidateGC(pDraw, pGC); + if (pPriv) pPriv->pGC = pGC; + } else if (key != pGC->fgPixel){ + pval[0] = key; + ChangeGC(pGC, GCForeground, pval); + ValidateGC(pDraw, pGC); + } + + REGION_TRANSLATE(pDraw->pScreen, clipboxes, -pDraw->x, -pDraw->y); + + rects = ALLOCATE_LOCAL(nbox * sizeof(xRectangle)); + + for(i = 0; i < nbox; i++, pbox++) { + rects[i].x = pbox->x1; + rects[i].y = pbox->y1; + rects[i].width = pbox->x2 - pbox->x1; + rects[i].height = pbox->y2 - pbox->y1; + } + + (*pGC->ops->PolyFillRect)(pDraw, pGC, nbox, rects); + + if (!pPriv) FreeGC(pGC, 0); + + DEALLOCATE_LOCAL(rects); +} + _X_EXPORT void xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes) { diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h index e0feb57b8..817e2b994 100644 --- a/hw/xfree86/common/xf86xv.h +++ b/hw/xfree86/common/xf86xv.h @@ -232,6 +232,9 @@ void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr); void xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes); +void +xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes); + Bool xf86XVClipVideoHelper( BoxPtr dst, diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h index ced053679..e716c9c6a 100644 --- a/hw/xfree86/common/xf86xvpriv.h +++ b/hw/xfree86/common/xf86xvpriv.h @@ -80,6 +80,7 @@ typedef struct { typedef struct _XF86XVWindowRec{ XvPortRecPrivatePtr PortRec; struct _XF86XVWindowRec *next; + GCPtr pGC; } XF86XVWindowRec, *XF86XVWindowPtr; #endif /* _XF86XVPRIV_H_ */ diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 31039761f..09d6681a4 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -632,6 +632,7 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86XVAllocateVideoAdaptorRec) SYMFUNC(xf86XVFreeVideoAdaptorRec) SYMFUNC(xf86XVFillKeyHelper) + SYMFUNC(xf86XVFillKeyHelperDrawable) SYMFUNC(xf86XVClipVideoHelper) SYMFUNC(xf86XVCopyYUV12ToPacked) SYMFUNC(xf86XVCopyPacked) From 4fd2d3aedfae838940d61598466f89fdb47b1557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 23 Jan 2007 10:15:22 +0100 Subject: [PATCH 65/85] Bump video driver ABI version to 1.2. This is necessary because server-1.2-branch bumped to 1.1 for xf86CVTMode and we have xf86XVFillKeyHelperDrawable on top of that. (cherry picked from commit 788cfce911793a26aed16f38f30678ecee82c873) Conflicts: hw/xfree86/common/xf86Module.h Avoid picking up XInput ABI change. --- hw/xfree86/common/xf86Module.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index edae6f297..e54d9bea8 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -84,7 +84,7 @@ typedef enum { * mask is 0xFFFF0000. */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 3) -#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(1, 1) +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(1, 2) #define ABI_XINPUT_VERSION SET_ABI_VERSION(0, 7) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(0, 3) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 5) From 00e33f87f429a5e9e29da30071f03972a4033b8d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 26 Mar 2007 21:21:50 -0700 Subject: [PATCH 66/85] Set version to 1.2.99.903 (1.3 RC3) --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index ed2c631a9..6ba4d03f0 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) dnl This is the not the Xorg version number, it's the server version number. dnl Yes, that's weird. -AC_INIT([xorg-server], 1.2.99.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +AC_INIT([xorg-server], 1.2.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE @@ -40,8 +40,8 @@ DEFAULT_VENDOR_NAME_SHORT="X.Org" DEFAULT_VERSION_MAJOR=1 DEFAULT_VERSION_MINOR=2 DEFAULT_VERSION_PATCH=99 -DEFAULT_VERSION_SNAP=902 -DEFAULT_RELEASE_DATE="14 March 2007" +DEFAULT_VERSION_SNAP=903 +DEFAULT_RELEASE_DATE="26 March 2007" DEFAULT_VENDOR_WEB="http://wiki.x.org" dnl this gets generated by autoheader, and thus contains all the defines. we From 56262a4ee943f328d089a8eb4aa70b9a4bd5d135 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Apr 2007 14:15:36 -0700 Subject: [PATCH 67/85] Don't erase current crtc for outputs on CloseScreen Erasing this variable causes some outputs (SDVO on intel) to fail to be correctly reset at server reset time. --- hw/xfree86/modes/xf86Crtc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 7d86b6606..325fb640b 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -589,7 +589,6 @@ xf86CrtcCloseScreen (int index, ScreenPtr screen) { xf86OutputPtr output = config->output[o]; - output->crtc = NULL; output->randr_output = NULL; } for (c = 0; c < config->num_crtc; c++) From 042ef1f573d6e98756cc98c296bddd1aa9e4c8ca Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 5 Apr 2007 23:21:19 -0700 Subject: [PATCH 68/85] Bump version to 1.2.99.904 (1.3 RC4) --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 6ba4d03f0..2c69c3004 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) dnl This is the not the Xorg version number, it's the server version number. dnl Yes, that's weird. -AC_INIT([xorg-server], 1.2.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +AC_INIT([xorg-server], 1.2.99.904, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE @@ -40,8 +40,8 @@ DEFAULT_VENDOR_NAME_SHORT="X.Org" DEFAULT_VERSION_MAJOR=1 DEFAULT_VERSION_MINOR=2 DEFAULT_VERSION_PATCH=99 -DEFAULT_VERSION_SNAP=903 -DEFAULT_RELEASE_DATE="26 March 2007" +DEFAULT_VERSION_SNAP=904 +DEFAULT_RELEASE_DATE="05 April 2007" DEFAULT_VENDOR_WEB="http://wiki.x.org" dnl this gets generated by autoheader, and thus contains all the defines. we From 44ea7a3e0d8fa636f4e5dd392caf618120d98413 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Wed, 28 Mar 2007 14:46:30 -0400 Subject: [PATCH 69/85] Bug #10296: Fix timer rescheduling. (cherry picked from commit 8c7f56d92d8471ee059c14d322af5f7f555dd5c6) --- os/WaitFor.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/os/WaitFor.c b/os/WaitFor.c index ba227a3b6..d0f9f62f1 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -125,7 +125,7 @@ struct _OsTimerRec { }; static void DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev); -static void CheckAllTimers(CARD32 now); +static void CheckAllTimers(void); static OsTimerPtr timers = NULL; /***************** @@ -204,7 +204,7 @@ WaitForSomething(int *pClientsReady) timeout = timers->expires - now; if (timeout > 0 && timeout > timers->delta + 250) { /* time has rewound. reset the timers. */ - CheckAllTimers(now); + CheckAllTimers(); } if (timers) { @@ -439,11 +439,14 @@ ANYSET(FdMask *src) /* If time has rewound, re-run every affected timer. * Timers might drop out of the list, so we have to restart every time. */ static void -CheckAllTimers(CARD32 now) +CheckAllTimers(void) { OsTimerPtr timer; + CARD32 now; start: + now = GetTimeInMillis(); + for (timer = timers; timer; timer = timer->next) { if (timer->expires - now > timer->delta + 250) { TimerForce(timer); From 44c4bd5df3aae191be9fc836be26f91497d02901 Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Tue, 3 Apr 2007 15:47:18 +0200 Subject: [PATCH 70/85] CVE-2007-1003: XC-MISC Extension ProcXCMiscGetXIDList() Memory Corruption (cherry picked from commit 645d87cf8ef724d4591614f9994cdc4d7549a7a8) --- Xext/xcmisc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c index f26218e97..8c7a86e6a 100644 --- a/Xext/xcmisc.c +++ b/Xext/xcmisc.c @@ -42,6 +42,12 @@ from The Open Group. #include #include "modinit.h" +#if HAVE_STDINT_H +#include +#elif !defined(UINT32_MAX) +#define UINT32_MAX 0xffffffffU +#endif + #if 0 static unsigned char XCMiscCode; #endif @@ -143,7 +149,10 @@ ProcXCMiscGetXIDList(client) REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq); - pids = (XID *)ALLOCATE_LOCAL(stuff->count * sizeof(XID)); + if (stuff->count > UINT32_MAX / sizeof(XID)) + return BadAlloc; + + pids = (XID *)Xalloc(stuff->count * sizeof(XID)); if (!pids) { return BadAlloc; @@ -164,7 +173,7 @@ ProcXCMiscGetXIDList(client) client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, count * sizeof(XID), pids); } - DEALLOCATE_LOCAL(pids); + Xfree(pids); return(client->noClientException); } From 970cacb264a597573e0927410dde5a3d3aa6549b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 5 Apr 2007 23:48:40 -0700 Subject: [PATCH 71/85] Bump to version 1.2.99.905 (1.3 RC5) --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2c69c3004..360419cea 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) dnl This is the not the Xorg version number, it's the server version number. dnl Yes, that's weird. -AC_INIT([xorg-server], 1.2.99.904, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +AC_INIT([xorg-server], 1.2.99.905, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE @@ -40,7 +40,7 @@ DEFAULT_VENDOR_NAME_SHORT="X.Org" DEFAULT_VERSION_MAJOR=1 DEFAULT_VERSION_MINOR=2 DEFAULT_VERSION_PATCH=99 -DEFAULT_VERSION_SNAP=904 +DEFAULT_VERSION_SNAP=905 DEFAULT_RELEASE_DATE="05 April 2007" DEFAULT_VENDOR_WEB="http://wiki.x.org" From 7cf3a0e0b954cc3bfdf158cdc1ca145d1620fe0c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 9 Apr 2007 12:30:31 -0700 Subject: [PATCH 72/85] In AIGLX EnterVT processing, invoke driver EnterVT before resuming glx. As the driver EnterVT function generally re-enables the hardware and prepares it for rendering, it must be called before any gl functions are called which could touch the hardware. (cherry picked from commit f24391dbfd12a84253dfec794ee7884afd52e197) --- GL/glx/glxdri.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c index 36464a6e9..788b87d79 100644 --- a/GL/glx/glxdri.c +++ b/GL/glx/glxdri.c @@ -815,12 +815,16 @@ static Bool glxDRIEnterVT (int index, int flags) { __GLXDRIscreen *screen = (__GLXDRIscreen *) __glXgetActiveScreen(index); + Bool ret; LogMessage(X_INFO, "AIGLX: Resuming AIGLX clients after VT switch\n"); + if (!(*screen->enterVT) (index, flags)) + return FALSE; + glxResumeClients(); - return (*screen->enterVT) (index, flags); + return TRUE; } static void From dc6c4f6989f87149d8605604f4514f5cbf11de67 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 9 Apr 2007 14:12:27 -0700 Subject: [PATCH 73/85] Disable CRTC when SetSingleMode has no matching mode. Update RandR as well. xf86SetSingleMode tries to resize all crtcs to match the selected mode. When a CRTC has no matching mode, it now disables the CRTC (instead of crashing). Also, poke the RandR extension when xf86SetSingleMode is done so that appropriate events can be delivered, and so that future RandR queries return correct information. --- hw/xfree86/modes/xf86Crtc.c | 10 ++++++++-- hw/xfree86/modes/xf86RandR12.c | 22 ++++++++++++++++++++++ hw/xfree86/modes/xf86RandR12.h | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 325fb640b..eba32e493 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -233,8 +233,6 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, int saved_x, saved_y; Rotation saved_rotation; - adjusted_mode = xf86DuplicateMode(mode); - crtc->enabled = xf86CrtcInUse (crtc); if (!crtc->enabled) @@ -243,6 +241,8 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, return TRUE; } + adjusted_mode = xf86DuplicateMode(mode); + didLock = crtc->funcs->lock (crtc); saved_mode = crtc->mode; @@ -1817,6 +1817,11 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation) else crtc_mode = xf86OutputFindClosestMode (output, desired); } + if (!crtc_mode) + { + crtc->enabled = FALSE; + continue; + } if (!xf86CrtcSetMode (crtc, crtc_mode, rotation, 0, 0)) ok = FALSE; else @@ -1828,6 +1833,7 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation) } } xf86DisableUnusedFunctions(pScrn); + xf86RandR12TellChanged (pScrn->pScreen); return ok; } diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 6f52ee2d9..90de585f5 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1048,6 +1048,28 @@ xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) return TRUE; } +/* + * Something happened within the screen configuration due + * to DGA, VidMode or hot key. Tell RandR + */ + +void +xf86RandR12TellChanged (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + int c; + + if (!randrp) + return; + xf86RandR12SetInfo12 (pScreen); + for (c = 0; c < config->num_crtc; c++) + xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc); + + RRTellChanged (pScreen); +} + static void xf86RandR12PointerMoved (int scrnIndex, int x, int y) { diff --git a/hw/xfree86/modes/xf86RandR12.h b/hw/xfree86/modes/xf86RandR12.h index 8a4668b46..0d3346a77 100644 --- a/hw/xfree86/modes/xf86RandR12.h +++ b/hw/xfree86/modes/xf86RandR12.h @@ -33,5 +33,6 @@ Bool xf86RandR12SetConfig(ScreenPtr pScreen, Rotation rotation, int rate, Rotation xf86RandR12GetRotation(ScreenPtr pScreen); void xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y); Bool xf86RandR12PreInit (ScrnInfoPtr pScrn); +void xf86RandR12TellChanged (ScreenPtr pScreen); #endif /* _XF86_RANDR_H_ */ From efcec7dbd3c2736c7b421d29c4d37e231aa681d2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 9 Apr 2007 14:29:46 -0700 Subject: [PATCH 74/85] Rotate screen size as needed from RandR 1.1 change requests. Screen size must reflect rotated mode size when setting rotated mode using RandR 1.1 SetScreenConfig request. --- randr/rrscreen.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 8aa26fa90..f2981b087 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -741,6 +741,7 @@ ProcRRSetScreenConfig (ClientPtr client) RRModePtr mode; RR10DataPtr pData = NULL; RRScreenSizePtr pSize; + int width, height; UpdateCurrentTime (); @@ -882,8 +883,14 @@ ProcRRSetScreenConfig (ClientPtr client) * If the screen size is changing, adjust all of the other outputs * to fit the new size, mirroring as much as possible */ - if (mode->mode.width != pScreen->width || - mode->mode.height != pScreen->height) + width = mode->mode.width; + height = mode->mode.height; + if (rotation & (RR_Rotate_90|RR_Rotate_270)) + { + width = mode->mode.height; + height = mode->mode.width; + } + if (width != pScreen->width || height != pScreen->height) { int c; @@ -897,7 +904,7 @@ ProcRRSetScreenConfig (ClientPtr client) goto sendReply; } } - if (!RRScreenSizeSet (pScreen, mode->mode.width, mode->mode.height, + if (!RRScreenSizeSet (pScreen, width, height, pScreen->mmWidth, pScreen->mmHeight)) { rep.status = RRSetConfigFailed; From 1328a288e9030a472a915077160f090d1afd4126 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Apr 2007 15:04:29 -0300 Subject: [PATCH 75/85] Add quirk for Acer AL1706 monitor to force 60hz refresh. This Acer monitor reports support for 75hz refresh via EDID, and yet when that rate is delivered, the monitor does not sync and reports out of range. Use the existing 60hz quirk for this monitor. --- hw/xfree86/modes/xf86EdidModes.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c index 77c0c875c..b6689bb76 100644 --- a/hw/xfree86/modes/xf86EdidModes.c +++ b/hw/xfree86/modes/xf86EdidModes.c @@ -82,6 +82,11 @@ static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) DDC->vendor.prod_id == 1516) return TRUE; + /* Acer AL1706 */ + if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && + DDC->vendor.prod_id == 44358) + return TRUE; + return FALSE; } From e2e7c47a528447e90cff6cf10d2ce457742ef48d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 15 Apr 2007 22:59:19 -0300 Subject: [PATCH 76/85] RandR 1.2 spec says CRTC info contains screen-relative geometry. Was reporting mode size instead of adjusting for rotation. --- randr/rrcrtc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 1a2a3a7c5..63da829d7 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -518,6 +518,7 @@ ProcRRGetCrtcInfo (ClientPtr client) RROutput *outputs; RROutput *possible; int i, j, k, n; + int width, height; REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq); crtc = LookupCrtc(client, stuff->crtc, SecurityReadAccess); @@ -540,8 +541,9 @@ ProcRRGetCrtcInfo (ClientPtr client) rep.timestamp = pScrPriv->lastSetTime.milliseconds; rep.x = crtc->x; rep.y = crtc->y; - rep.width = mode ? mode->mode.width : 0; - rep.height = mode ? mode->mode.height : 0; + RRCrtcGetScanoutSize (crtc, &width, &height); + rep.width = width; + rep.height = height; rep.mode = mode ? mode->mode.id : 0; rep.rotation = crtc->rotation; rep.rotations = crtc->rotations; From 00cfd1f765895b4d1b2234f3203727a8871b64b0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Apr 2007 09:39:47 -0700 Subject: [PATCH 77/85] typo in built-in module log message --- hw/xfree86/loader/loadmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index c220d8a61..6f8f871d1 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -869,7 +869,7 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, for (cim = compiled_in_modules; *cim; cim++) if (!strcmp (module, *cim)) { - xf86MsgVerb(X_INFO, 3, "Module alread ybuilt-in"); + xf86MsgVerb(X_INFO, 0, "Module already built-in\n"); return (ModuleDescPtr) 1; } From f4a8e54caf6b9431711383a39f55a18e7fd654f4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Apr 2007 09:53:42 -0700 Subject: [PATCH 78/85] Use default screen monitor for one of the outputs. By default, use the screen monitor section for output 0, however, a driver can change which output gets the screen monitor by calling xf86OutputUseScreenMonitor. --- hw/xfree86/modes/xf86Crtc.c | 31 ++++++++++++++++++++++++++++++- hw/xfree86/modes/xf86Crtc.h | 12 +++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index eba32e493..6366222c4 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -405,10 +405,25 @@ xf86OutputSetMonitor (xf86OutputPtr output) xfree (option_name); output->conf_monitor = xf86findMonitor (monitor, xf86configptr->conf_monitor_lst); + /* + * Find the monitor section of the screen and use that + */ + if (!output->conf_monitor && output->use_screen_monitor) + output->conf_monitor = xf86findMonitor (output->scrn->monitor->id, + xf86configptr->conf_monitor_lst); if (output->conf_monitor) + { + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s using monitor section %s\n", + output->name, output->conf_monitor->mon_identifier); xf86ProcessOptions (output->scrn->scrnIndex, output->conf_monitor->mon_option_lst, output->options); + } + else + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s has no monitor section\n", + output->name); } static Bool @@ -454,7 +469,7 @@ xf86OutputInitialRotation (xf86OutputPtr output) xf86OutputPtr xf86OutputCreate (ScrnInfoPtr scrn, - const xf86OutputFuncsRec *funcs, + const xf86OutputFuncsRec *funcs, const char *name) { xf86OutputPtr output, *outputs; @@ -477,6 +492,10 @@ xf86OutputCreate (ScrnInfoPtr scrn, strcpy (output->name, name); } output->subpixel_order = SubPixelUnknown; + /* + * Use the old per-screen monitor section for the first output + */ + output->use_screen_monitor = (xf86_config->num_output == 0); #ifdef RANDR_12_INTERFACE output->randr_output = NULL; #endif @@ -527,6 +546,16 @@ xf86OutputRename (xf86OutputPtr output, const char *name) return TRUE; } +void +xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor) +{ + if (use_screen_monitor != output->use_screen_monitor) + { + output->use_screen_monitor = use_screen_monitor; + xf86OutputSetMonitor (output); + } +} + void xf86OutputDestroy (xf86OutputPtr output) { diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 42daf6079..e64ce1ecd 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -479,6 +479,9 @@ struct _xf86Output { /** driver private information */ void *driver_private; + /** Whether to use the old per-screen Monitor config section */ + Bool use_screen_monitor; + #ifdef RANDR_12_INTERFACE /** * RandR 1.2 output structure. @@ -611,9 +614,12 @@ xf86CrtcInUse (xf86CrtcPtr crtc); * Output functions */ xf86OutputPtr -xf86OutputCreate (ScrnInfoPtr scrn, - const xf86OutputFuncsRec *funcs, - const char *name); +xf86OutputCreate (ScrnInfoPtr scrn, + const xf86OutputFuncsRec *funcs, + const char *name); + +void +xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor); Bool xf86OutputRename (xf86OutputPtr output, const char *name); From a3d73ba2cb7e13a6d129cd88d6a7f7d756e2ced2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Apr 2007 09:55:58 -0700 Subject: [PATCH 79/85] Allow outputs to be explicitly enabled in config, overriding detect. Option "Enable" "True" will force the server to enable an output at startup time, even if the output is not connected. This also causes the default modes to be added for this output, allowing even sync ranges to be used to pick out standard modes. --- hw/xfree86/modes/xf86Crtc.c | 45 ++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 6366222c4..b293639a9 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -427,15 +427,29 @@ xf86OutputSetMonitor (xf86OutputPtr output) } static Bool -xf86OutputEnabled (xf86OutputPtr output) +xf86OutputEnabled (xf86OutputPtr output) { - /* Check to see if this output was disabled in the config file */ - if (xf86ReturnOptValBool (output->options, OPTION_ENABLE, TRUE) == FALSE || - xf86ReturnOptValBool (output->options, OPTION_DISABLE, FALSE) == TRUE) + Bool enable, disable; + + /* check to see if this output was enabled in the config file */ + if (xf86GetOptValBool (output->options, OPTION_ENABLE, &enable) && enable) { + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s enabled by config file\n", output->name); + return TRUE; + } + /* or if this output was disabled in the config file */ + if (xf86GetOptValBool (output->options, OPTION_DISABLE, &disable) && disable) + { + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s disabled by config file\n", output->name); return FALSE; } - return TRUE; + /* otherwise, enable if it is not disconnected */ + enable = output->status != XF86OutputStatusDisconnected; + xf86DrvMsg (output->scrn->scrnIndex, X_INFO, + "Output %s %sconnected\n", output->name, enable ? "" : "dis"); + return enable; } static Bool @@ -1225,7 +1239,7 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY) */ output->status = (*output->funcs->detect)(output); - if (output->status == XF86OutputStatusDisconnected) + if (!xf86OutputEnabled (output)) { xf86OutputSetEDID (output, NULL); continue; @@ -1527,8 +1541,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) xf86OutputPtr output = config->output[o]; modes[o] = NULL; - enabled[o] = (xf86OutputEnabled (output) && - output->status != XF86OutputStatusDisconnected); + enabled[o] = xf86OutputEnabled (output); } /* @@ -1573,8 +1586,20 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) { xf86OutputPtr output = config->output[o]; - if (enabled[o] && !modes[o]) - modes[o] = xf86ClosestMode (output, target_mode, target_rotation, width, height); + if (enabled[o]) + { + if (!modes[o]) + modes[o] = xf86ClosestMode (output, target_mode, + target_rotation, width, height); + if (!modes[o]) + xf86DrvMsg (scrn->scrnIndex, X_ERROR, + "Output %s enabled but has no modes\n", + output->name); + else + xf86DrvMsg (scrn->scrnIndex, X_INFO, + "Output %s using initial mode %s\n", + output->name, modes[o]->name); + } } /* From a63704f14a1d97b9a00fef6fa290e74e51b9732b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Andr=C3=A9n?= Date: Tue, 17 Apr 2007 21:34:47 -0700 Subject: [PATCH 80/85] Syncmaster 226 monitor needs 60Hz refresh (#10545). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I've managed to solve my own bug (#10545) by applying the following patch to the xserver. Please apply. This monitor is "Vista Certified". I wonder if this is a pure coincidence... With kind regards Erik Andrén --- hw/xfree86/modes/xf86EdidModes.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c index b6689bb76..edcd63630 100644 --- a/hw/xfree86/modes/xf86EdidModes.c +++ b/hw/xfree86/modes/xf86EdidModes.c @@ -86,6 +86,11 @@ static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && DDC->vendor.prod_id == 44358) return TRUE; + + /* Samsung SyncMaster 226BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 638) + return TRUE; return FALSE; } From 8b217dee3a6c46b13fc9571a4a9a95bc55686cdb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 19 Apr 2007 17:37:18 -0700 Subject: [PATCH 81/85] Was accidentally disabling rotation updates in mode set. Setting a mode on an unrotated CRTC was causing all of the rotation updates to be disabled; the loop looking for active rotation wasn't actually looking at each crtc, it was looking at the modified crtc many times. --- hw/xfree86/modes/xf86Rotate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index e8fafd073..94f95a0d7 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -284,7 +284,7 @@ xf86RotateRedisplay(ScreenPtr pScreen) { xf86CrtcPtr crtc = xf86_config->crtc[c]; - if (crtc->rotation != RR_Rotate_0) + if (crtc->rotation != RR_Rotate_0 && crtc->enabled) { BoxRec box; RegionRec crtc_damage; @@ -338,7 +338,8 @@ xf86RotateDestroy (xf86CrtcPtr crtc) } for (c = 0; c < xf86_config->num_crtc; c++) - if (crtc->rotatedPixmap || crtc->rotatedData) + if (xf86_config->crtc[c]->rotatedPixmap || + xf86_config->crtc[c]->rotatedData) return; /* From 05e1c45ade9c558820685bfd2541617a2e8de816 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 19 Apr 2007 17:39:51 -0700 Subject: [PATCH 82/85] Disable SourceValidate in rotation to capture cursor. SourceValidate is used exclusively by the software cursor code to pull the cursor off of the screen before using the screen as a source operand. This eliminates the software cursor from the frame buffer while painting the rotated image though. Disabling this function by temporarily setting the screen function pointer to NULL causes the cursor image to be captured. --- hw/xfree86/modes/xf86Rotate.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 94f95a0d7..359501e38 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -278,8 +278,18 @@ xf86RotateRedisplay(ScreenPtr pScreen) region = DamageRegion(damage); if (REGION_NOTEMPTY(pScreen, region)) { - int c; - + int c; + SourceValidateProcPtr SourceValidate; + + /* + * SourceValidate is used by the software cursor code + * to pull the cursor off of the screen when reading + * bits from the frame buffer. Bypassing this function + * leaves the software cursor in place + */ + SourceValidate = pScreen->SourceValidate; + pScreen->SourceValidate = NULL; + for (c = 0; c < xf86_config->num_crtc; c++) { xf86CrtcPtr crtc = xf86_config->crtc[c]; @@ -304,6 +314,7 @@ xf86RotateRedisplay(ScreenPtr pScreen) REGION_UNINIT (pScreen, &crtc_damage); } } + pScreen->SourceValidate = SourceValidate; DamageEmpty(damage); } } From f9a0b936600cd2665a90e6ddcd5a6bfe7a88f6e9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 19 Apr 2007 19:09:43 -0700 Subject: [PATCH 83/85] Update version to 1.3.0.0 --- configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 360419cea..9e3c0a089 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) dnl This is the not the Xorg version number, it's the server version number. dnl Yes, that's weird. -AC_INIT([xorg-server], 1.2.99.905, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +AC_INIT([xorg-server], 1.3.0.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE @@ -38,10 +38,10 @@ dnl DEFAULT_VENDOR_NAME="The X.Org Foundation" DEFAULT_VENDOR_NAME_SHORT="X.Org" DEFAULT_VERSION_MAJOR=1 -DEFAULT_VERSION_MINOR=2 -DEFAULT_VERSION_PATCH=99 -DEFAULT_VERSION_SNAP=905 -DEFAULT_RELEASE_DATE="05 April 2007" +DEFAULT_VERSION_MINOR=3 +DEFAULT_VERSION_PATCH=0 +DEFAULT_VERSION_SNAP=0 +DEFAULT_RELEASE_DATE="19 April 2007" DEFAULT_VENDOR_WEB="http://wiki.x.org" dnl this gets generated by autoheader, and thus contains all the defines. we From 1d7fbdfea4f4dbbbb685c7407a1c060ac3875874 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 21 Apr 2007 18:52:14 -0700 Subject: [PATCH 84/85] Disable use of xf86RandR12TellChanged when unavailable (1.2 server). When building the new mode setting code out-of-tree against an older server, don't use xf86RandR12TellChanged as that is a RandR 1.2 specific interface. --- hw/xfree86/modes/xf86Crtc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index b293639a9..2d8a7adf5 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1887,7 +1887,9 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation) } } xf86DisableUnusedFunctions(pScrn); +#ifdef RANDR_12_INTERFACE xf86RandR12TellChanged (pScrn->pScreen); +#endif return ok; } From dcc3de91d2b80be98e4488df29ec6b551c7ff6d1 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 18 Aug 2007 11:50:33 +0200 Subject: [PATCH 85/85] Xephyr: fix immediat segfault on amd64 This closes bug https://bugs.freedesktop.org/show_bug.cgi?id=11582 --- hw/kdrive/ephyr/hostx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index d0a2f2f95..12118da69 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -40,6 +40,7 @@ #include #include #include +#include /* * All xlib calls go here, which gets built as its own .a . @@ -79,7 +80,7 @@ static int HostXWantDamageDebug = 0; extern KeySym EphyrKeymap[]; -extern KeySym kdKeymap[]; +extern CARD32 kdKeymap[]; extern int kdMinScanCode; extern int kdMaxScanCode; extern int kdMinKeyCode;