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.
(cherry picked from commit 57e87e0d006cbf1f5b175fe02eeb981f741d92f0)

Conflicts:

	randr/randrstr.h
	randr/rrcrtc.c

I think master and server-1.3-branch are more in sync now.
This commit is contained in:
Keith Packard 2007-03-23 23:41:36 -07:00
parent 1f77120775
commit 804080a709
8 changed files with 146 additions and 150 deletions

View File

@ -312,7 +312,13 @@ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
{ {
xf86OutputPtr output = xf86_config->output[i]; xf86OutputPtr output = xf86_config->output[i];
if (output->crtc == crtc) if (output->crtc == crtc)
{
output->funcs->commit(output); output->funcs->commit(output);
#ifdef RANDR_12_INTERFACE
if (output->randr_output)
RRPostPendingProperties (output->randr_output);
#endif
}
} }
/* XXX free adjustedmode */ /* XXX free adjustedmode */

View File

@ -1011,8 +1011,7 @@ xf86RandR12CreateObjects12 (ScreenPtr pScreen)
{ {
xf86CrtcPtr crtc = config->crtc[c]; xf86CrtcPtr crtc = config->crtc[c];
crtc->randr_crtc = RRCrtcCreate (crtc); crtc->randr_crtc = RRCrtcCreate (pScreen, crtc);
RRCrtcAttachScreen (crtc->randr_crtc, pScreen);
RRCrtcGammaSetSize (crtc->randr_crtc, 256); RRCrtcGammaSetSize (crtc->randr_crtc, 256);
} }
/* /*
@ -1022,13 +1021,13 @@ xf86RandR12CreateObjects12 (ScreenPtr pScreen)
{ {
xf86OutputPtr output = config->output[o]; xf86OutputPtr output = config->output[o];
output->randr_output = RROutputCreate (output->name, output->randr_output = RROutputCreate (pScreen, output->name,
strlen (output->name), strlen (output->name),
output); output);
RROutputAttachScreen (output->randr_output, pScreen);
if (output->funcs->create_resources != NULL) if (output->funcs->create_resources != NULL)
output->funcs->create_resources(output); output->funcs->create_resources(output);
RRPostPendingProperties (output->randr_output);
} }
return TRUE; return TRUE;
} }

View File

@ -133,20 +133,13 @@ miRandRInit (ScreenPtr pScreen)
if (!mode) if (!mode)
return FALSE; return FALSE;
crtc = RRCrtcCreate (NULL); crtc = RRCrtcCreate (pScreen, NULL);
if (!crtc) if (!crtc)
return FALSE; return FALSE;
if (!RRCrtcAttachScreen (crtc, pScreen))
{
RRCrtcDestroy (crtc);
return FALSE;
}
output = RROutputCreate ("screen", 6, NULL); output = RROutputCreate (pScreen, "screen", 6, NULL);
if (!output) if (!output)
return FALSE; return FALSE;
if (!RROutputAttachScreen (output, pScreen))
return FALSE;
if (!RROutputSetClones (output, NULL, 0)) if (!RROutputSetClones (output, NULL, 0))
return FALSE; return FALSE;
if (!RROutputSetModes (output, &mode, 1, 0)) if (!RROutputSetModes (output, &mode, 1, 0))

View File

@ -138,6 +138,7 @@ struct _rrOutput {
RRModePtr *userModes; RRModePtr *userModes;
Bool changed; Bool changed;
RRPropertyPtr properties; RRPropertyPtr properties;
Bool pendingProperties;
void *devPrivate; void *devPrivate;
}; };
@ -496,15 +497,13 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged);
* Create a CRTC * Create a CRTC
*/ */
RRCrtcPtr RRCrtcPtr
RRCrtcCreate (void *devPrivate); RRCrtcCreate (ScreenPtr pScreen, void *devPrivate);
/* /*
* Attach a CRTC to a screen. Once done, this cannot be * Set the allowed rotations on a CRTC
* undone without destroying the CRTC; it is separate from Create
* only to allow an xf86-based driver to create objects in preinit
*/ */
Bool void
RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen); RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations);
/* /*
* Notify the extension that the Crtc has been reconfigured, * Notify the extension that the Crtc has been reconfigured,
@ -561,13 +560,6 @@ Bool
RRCrtcGammaSetSize (RRCrtcPtr crtc, RRCrtcGammaSetSize (RRCrtcPtr crtc,
int size); int size);
/*
* Set the allowable rotations of the CRTC.
*/
Bool
RRCrtcSetRotations (RRCrtcPtr crtc,
Rotation rotations);
/* /*
* Return the area of the frame buffer scanned out by the crtc, * Return the area of the frame buffer scanned out by the crtc,
* taking into account the current mode and rotation * taking into account the current mode and rotation
@ -670,18 +662,11 @@ RROutputChanged (RROutputPtr output, Bool configChanged);
*/ */
RROutputPtr RROutputPtr
RROutputCreate (const char *name, RROutputCreate (ScreenPtr pScreen,
const char *name,
int nameLength, int nameLength,
void *devPrivate); 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 * Notify extension that output parameters have been changed
*/ */
@ -762,7 +747,7 @@ void
RRDeleteOutputProperty (RROutputPtr output, Atom property); RRDeleteOutputProperty (RROutputPtr output, Atom property);
Bool Bool
RRPostPendingProperty (RROutputPtr output, Atom property); RRPostPendingProperties (RROutputPtr output);
int int
RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type, RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,

View File

@ -51,17 +51,32 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged)
* Create a CRTC * Create a CRTC
*/ */
RRCrtcPtr RRCrtcPtr
RRCrtcCreate (void *devPrivate) RRCrtcCreate (ScreenPtr pScreen, void *devPrivate)
{ {
RRCrtcPtr crtc; RRCrtcPtr crtc;
RRCrtcPtr *crtcs;
rrScrPrivPtr pScrPriv;
if (!RRInit()) if (!RRInit())
return NULL; 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)); crtc = xalloc (sizeof (RRCrtcRec));
if (!crtc) if (!crtc)
return NULL; return NULL;
crtc->id = FakeClientID (0); crtc->id = FakeClientID (0);
crtc->pScreen = NULL; crtc->pScreen = pScreen;
crtc->mode = NULL; crtc->mode = NULL;
crtc->x = 0; crtc->x = 0;
crtc->y = 0; crtc->y = 0;
@ -77,37 +92,20 @@ RRCrtcCreate (void *devPrivate)
if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc)) if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc))
return NULL; return NULL;
/* attach the screen and crtc together */
crtc->pScreen = pScreen;
pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
return crtc; return crtc;
} }
/* /*
* Attach a Crtc to a screen. This is done as a separate step * Set the allowed rotations on a CRTC
* so that an xf86-based driver can create CRTCs in PreInit
* before the Screen has been created
*/ */
void
Bool RRCrtcSetRotations (RRCrtcPtr crtc, Rotation rotations)
RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen)
{ {
rrScrPriv (pScreen); crtc->rotations = rotations;
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;
} }
/* /*
@ -249,6 +247,22 @@ RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
WriteEventsToClient (client, 1, (xEvent *) &ce); 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 * Request that the Crtc be reconfigured
*/ */
@ -271,7 +285,8 @@ RRCrtcSet (RRCrtcPtr crtc,
crtc->y == y && crtc->y == y &&
crtc->rotation == rotation && crtc->rotation == rotation &&
crtc->numOutputs == numOutputs && crtc->numOutputs == numOutputs &&
!memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr))) !memcmp (crtc->outputs, outputs, numOutputs * sizeof (RROutputPtr)) &&
!RRCrtcPendingProperties (crtc))
{ {
ret = TRUE; ret = TRUE;
} }
@ -328,7 +343,13 @@ RRCrtcSet (RRCrtcPtr crtc,
#endif #endif
} }
if (ret) if (ret)
{
int o;
RRTellChanged (pScreen); RRTellChanged (pScreen);
for (o = 0; o < numOutputs; o++)
RRPostPendingProperties (outputs[o]);
}
} }
return ret; return ret;
} }
@ -468,17 +489,6 @@ RRCrtcGammaSetSize (RRCrtcPtr crtc,
return TRUE; return TRUE;
} }
/*
* Set the allowable rotations of the CRTC.
*/
Bool
RRCrtcSetRotations (RRCrtcPtr crtc,
Rotation rotations)
{
crtc->rotations = rotations;
return TRUE;
}
/* /*
* Initialize crtc type * Initialize crtc type
*/ */

View File

@ -91,19 +91,12 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
if (pScrPriv->numOutputs == 0 && if (pScrPriv->numOutputs == 0 &&
pScrPriv->numCrtcs == 0) pScrPriv->numCrtcs == 0)
{ {
crtc = RRCrtcCreate (NULL); crtc = RRCrtcCreate (pScreen, NULL);
if (!crtc) if (!crtc)
return; return;
if (!RRCrtcAttachScreen (crtc, pScreen)) output = RROutputCreate (pScreen, "default", 7, NULL);
{
RRCrtcDestroy (crtc);
return;
}
output = RROutputCreate ("default", 7, NULL);
if (!output) if (!output)
return; return;
if (!RROutputAttachScreen (output, pScreen))
return;
RROutputSetCrtcs (output, &crtc, 1); RROutputSetCrtcs (output, &crtc, 1);
RROutputSetCrtc (output, crtc); RROutputSetCrtc (output, crtc);
RROutputSetConnection (output, RR_Connected); RROutputSetConnection (output, RR_Connected);

View File

@ -47,19 +47,35 @@ RROutputChanged (RROutputPtr output, Bool configChanged)
*/ */
RROutputPtr RROutputPtr
RROutputCreate (const char *name, RROutputCreate (ScreenPtr pScreen,
const char *name,
int nameLength, int nameLength,
void *devPrivate) void *devPrivate)
{ {
RROutputPtr output; RROutputPtr output;
RROutputPtr *outputs;
rrScrPrivPtr pScrPriv;
if (!RRInit()) if (!RRInit())
return NULL; 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); output = xalloc (sizeof (RROutputRec) + nameLength + 1);
if (!output) if (!output)
return NULL; return NULL;
output->id = FakeClientID (0); output->id = FakeClientID (0);
output->pScreen = NULL; output->pScreen = pScreen;
output->name = (char *) (output + 1); output->name = (char *) (output + 1);
output->nameLength = nameLength; output->nameLength = nameLength;
memcpy (output->name, name, nameLength); memcpy (output->name, name, nameLength);
@ -85,33 +101,8 @@ RROutputCreate (const char *name,
if (!AddResource (output->id, RROutputType, (pointer) output)) if (!AddResource (output->id, RROutputType, (pointer) output))
return NULL; return NULL;
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; pScrPriv->outputs[pScrPriv->numOutputs++] = output;
RROutputChanged (output, FALSE); return output;
return TRUE;
} }
/* /*

View File

@ -50,7 +50,7 @@ RRDeleteAllOutputProperties (RROutputPtr output)
xfree(prop->current.data); xfree(prop->current.data);
if (prop->pending.data) if (prop->pending.data)
xfree(prop->pending.data); xfree(prop->pending.data);
xfree(prop); xfree(prop);
} }
} }
@ -139,7 +139,7 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
prop = RRQueryOutputProperty (output, property); prop = RRQueryOutputProperty (output, property);
if (!prop) /* just add to list */ if (!prop) /* just add to list */
{ {
prop = RRCreateOutputProperty (property); prop = RRCreateOutputProperty (property);
if (!prop) if (!prop)
return(BadAlloc); return(BadAlloc);
add = TRUE; add = TRUE;
@ -151,9 +151,9 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
prop_value = &prop->current; prop_value = &prop->current;
/* To append or prepend to a property the request format and type /* To append or prepend to a property the request format and type
must match those of the already defined property. The must match those of the already defined property. The
existing format and type are irrelevant when using the mode existing format and type are irrelevant when using the mode
"PropModeReplace" since they will be written over. */ "PropModeReplace" since they will be written over. */
if ((format != prop_value->format) && (mode != PropModeReplace)) if ((format != prop_value->format) && (mode != PropModeReplace))
return(BadMatch); return(BadMatch);
@ -167,7 +167,7 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
if (mode == PropModeReplace || len > 0) if (mode == PropModeReplace || len > 0)
{ {
pointer new_data, old_data; pointer new_data = NULL, old_data = NULL;
total_size = total_len * size_in_bytes; total_size = total_len * size_in_bytes;
new_value.data = (pointer)xalloc (total_size); new_value.data = (pointer)xalloc (total_size);
@ -197,7 +197,8 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
(prop_value->size * size_in_bytes)); (prop_value->size * size_in_bytes));
break; 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) if (old_data)
memcpy ((char *) old_data, (char *) prop_value->data, memcpy ((char *) old_data, (char *) prop_value->data,
prop_value->size * size_in_bytes); prop_value->size * size_in_bytes);
@ -226,6 +227,9 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
output->properties = prop; output->properties = prop;
} }
if (pending && prop->is_pending)
output->pendingProperties = TRUE;
if (sendevent) if (sendevent)
{ {
event.type = RREventBase + RRNotify; event.type = RREventBase + RRNotify;
@ -240,30 +244,45 @@ RRChangeOutputProperty (RROutputPtr output, Atom property, Atom type,
} }
Bool Bool
RRPostPendingProperty (RROutputPtr output, Atom property) RRPostPendingProperties (RROutputPtr output)
{ {
RRPropertyPtr prop = RRQueryOutputProperty (output, property); RRPropertyValuePtr pending_value;
RRPropertyValuePtr pending_value; RRPropertyValuePtr current_value;
RRPropertyValuePtr current_value; RRPropertyPtr property;
Bool ret = TRUE;
if (!prop) if (!output->pendingProperties)
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; return TRUE;
if (RRChangeOutputProperty (output, property, output->pendingProperties = FALSE;
pending_value->type, pending_value->format, PropModeReplace, for (property = output->properties; property; property = property->next)
pending_value->size, pending_value->data, TRUE, FALSE) != Success) {
return FALSE; /* Skip non-pending properties */
return TRUE; 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 RRPropertyPtr