Split out RandR dispatch code from randr.c to rr*dispatch.c.

More disassembly to ease ongoing development.
This commit is contained in:
Keith Packard 2006-09-17 23:03:23 -07:00
parent 3e745745fe
commit bf07893947
8 changed files with 1575 additions and 1087 deletions

View File

@ -11,6 +11,8 @@ librandr_la_SOURCES = \
randr.c \
randrstr.h \
rrcrtc.c \
rrdispatch.c \
rrmode.c \
rroutput.c \
rrscreen.c
rrscreen.c \
rrsdispatch.c

File diff suppressed because it is too large Load Diff

View File

@ -59,8 +59,11 @@ typedef XID RRMode;
typedef XID RROutput;
typedef XID RRCrtc;
extern int RREventBase;
extern int RREventBase, RRErrorBase;
extern int (*ProcRandrVector[RRNumberRequests])(ClientPtr);
extern int (*SProcRandrVector[RRNumberRequests])(ClientPtr);
/*
* Modeline for a monitor. Name follows directly after this struct
*/
@ -101,7 +104,7 @@ struct _rrOutput {
int numCrtcs;
RRCrtcPtr *crtcs;
int numClones;
RROutputPtr *outputs;
RROutputPtr *clones;
int numModes;
RRModePtr *modes;
Bool changed;
@ -210,6 +213,42 @@ extern int rrPrivIndex;
#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr)
#define SetRRScreen(s,p) ((s)->devPrivates[rrPrivIndex].ptr = (pointer) (p))
/*
* each window has a list of clients requesting
* RRNotify events. Each client has a resource
* for each window it selects RRNotify input for,
* this resource is used to delete the RRNotifyRec
* entry from the per-window queue.
*/
typedef struct _RREvent *RREventPtr;
typedef struct _RREvent {
RREventPtr next;
ClientPtr client;
WindowPtr window;
XID clientResource;
int mask;
} RREventRec;
typedef struct _RRTimes {
TimeStamp setTime;
TimeStamp configTime;
} RRTimesRec, *RRTimesPtr;
typedef struct _RRClient {
int major_version;
int minor_version;
/* RRTimesRec times[0]; */
} RRClientRec, *RRClientPtr;
extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
extern int RRClientPrivateIndex;
extern RESTYPE RRCrtcType, RRModeType, RROutputType;
#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr)
#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
/* Initialize the extension */
void
RRExtensionInit (void);
@ -278,8 +317,17 @@ miRRCrtcSet (ScreenPtr pScreen,
void
RRTellChanged (ScreenPtr pScreen);
/*
* Poll the driver for changed information
*/
Bool
RRGetInfo (ScreenPtr pScreen);
Bool RRScreenInit(ScreenPtr pScreen);
RROutputPtr
RRFirstOutput (ScreenPtr pScreen);
Rotation
RRGetRotation (ScreenPtr pScreen);
@ -338,13 +386,6 @@ RRCrtcPtr
RRCrtcCreate (ScreenPtr pScreen,
void *devPrivate);
/*
* Use this value for any num parameter to indicate that
* the related data are unchanged
*/
#define RR_NUM_UNCHANGED -1
/*
* Notify the extension that the Crtc has been reconfigured,
* the driver calls this whenever it has updated the mode
@ -358,6 +399,9 @@ RRCrtcNotify (RRCrtcPtr crtc,
int numOutput,
RROutputPtr *outputs);
void
RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc);
/*
* Request that the Crtc be reconfigured
*/
@ -382,6 +426,10 @@ RRCrtcDestroy (RRCrtcPtr crtc);
Bool
RRCrtcInit (void);
/* rrdispatch.c */
Bool
RRClientKnowsRates (ClientPtr pClient);
/* rrmode.c */
/*
* Find, and if necessary, create a mode
@ -438,6 +486,9 @@ Bool
RROutputSetConnection (RROutputPtr output,
CARD8 connection);
void
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output);
void
RROutputDestroy (RROutputPtr output);

View File

@ -22,7 +22,7 @@
#include "randrstr.h"
static RESTYPE CrtcType;
RESTYPE RRCrtcType;
/*
* Create a CRTC
@ -144,6 +144,12 @@ RRCrtcNotify (RRCrtcPtr crtc,
return TRUE;
}
void
RRDeliverCrtcEvent (ClientPtr client, WindowPtr pWin, RRCrtcPtr crtc)
{
}
/*
* Request that the Crtc be reconfigured
*/
@ -216,6 +222,7 @@ RRCrtcDestroyResource (pointer value, XID pid)
memmove (pScrPriv->crtcs, pScrPriv->crtcs + 1,
(pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr));
--pScrPriv->numCrtcs;
break;
}
}
free (value);
@ -228,11 +235,11 @@ RRCrtcDestroyResource (pointer value, XID pid)
Bool
RRCrtcInit (void)
{
CrtcType = CreateNewResourceType (RRCrtcDestroyResource);
if (!CrtcType)
RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource);
if (!RRCrtcType)
return FALSE;
#ifdef XResExtension
RegisterResourceName (CrtcType, "CRTC");
RegisterResourceName (RRCrtcType, "CRTC");
#endif
return TRUE;
}

1034
randr/rrdispatch.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
#include "randrstr.h"
static RESTYPE ModeType;
RESTYPE RRModeType;
RRModePtr
RRModeGet (ScreenPtr pScreen,
@ -50,7 +50,7 @@ RRModeGet (ScreenPtr pScreen,
memcpy (mode->name, name, modeInfo->nameLength);
mode->name[modeInfo->nameLength] = '\0';
mode->id = FakeClientID(0);
if (!AddResource (mode->id, ModeType, (pointer) mode))
if (!AddResource (mode->id, RRModeType, (pointer) mode))
return NULL;
++mode->refcnt;
pScrPriv->changed = TRUE;
@ -75,11 +75,11 @@ RRModeDestroyResource (pointer value, XID pid)
Bool
RRModeInit (void)
{
ModeType = CreateNewResourceType (RRModeDestroyResource);
if (!ModeType)
RRModeType = CreateNewResourceType (RRModeDestroyResource);
if (!RRModeType)
return FALSE;
#ifdef XResExtension
RegisterResourceName (ModeType, "MODE");
RegisterResourceName (RRModeType, "MODE");
#endif
return TRUE;
}

View File

@ -22,7 +22,124 @@
#include "randrstr.h"
static RESTYPE OutputType;
RESTYPE RROutputType;
/*
* Create an output
*/
RROutputPtr
RROutputCreate (ScreenPtr pScreen,
char *name,
int nameLength,
void *devPrivate)
{
rrScrPriv (pScreen);
RROutputPtr output;
RROutputPtr *outputs;
output = xalloc (sizeof (RROutputRec) + nameLength + 1);
if (!output)
return NULL;
if (pScrPriv->numOutputs)
outputs = xrealloc (pScrPriv->outputs,
(pScrPriv->numOutputs + 1) * sizeof (RROutputPtr));
else
outputs = xalloc (sizeof (RROutputPtr));
if (!outputs)
{
xfree (output);
return NULL;
}
output->id = FakeClientID (0);
output->pScreen = pScreen;
output->name = (char *) (output + 1);
output->nameLength = nameLength;
memcpy (output->name, name, nameLength);
output->connection = RR_UnknownConnection;
output->subpixelOrder = SubPixelUnknown;
output->crtc = NULL;
output->numCrtcs = 0;
output->crtcs = NULL;
output->numClones = 0;
output->clones = NULL;
output->numModes = 0;
output->modes = NULL;
output->changed = TRUE;
output->devPrivate = devPrivate;
pScrPriv->outputs[pScrPriv->numOutputs++] = output;
return output;
}
/*
* Notify extension that output parameters have been changed
*/
Bool
RROutputSetClones (RROutputPtr output,
RROutputPtr *clones,
int numClones)
{
RROutputPtr *newClones;
newClones = xalloc (numClones * sizeof (RROutputPtr));
if (!newClones)
return FALSE;
if (output->clones)
xfree (output->clones);
memcpy (newClones, clones, numClones * sizeof (RROutputPtr));
output->clones = newClones;
output->numClones = numClones;
return TRUE;
}
Bool
RROutputSetModes (RROutputPtr output,
RRModePtr *modes,
int numModes)
{
RRModePtr *newModes;
newModes = xalloc (numModes * sizeof (RRModePtr));
if (!newModes)
return FALSE;
if (output->modes)
xfree (output->modes);
memcpy (newModes, modes, numModes * sizeof (RRModePtr));
output->modes = newModes;
output->numModes = numModes;
return TRUE;
}
Bool
RROutputSetCrtcs (RROutputPtr output,
RRCrtcPtr *crtcs,
int numCrtcs)
{
RRCrtcPtr *newCrtcs;
newCrtcs = xalloc (numCrtcs * sizeof (RRCrtcPtr));
if (!newCrtcs)
return FALSE;
if (output->crtcs)
xfree (output->crtcs);
memcpy (newCrtcs, crtcs, numCrtcs * sizeof (RRCrtcPtr));
output->crtcs = newCrtcs;
output->numCrtcs = numCrtcs;
return TRUE;
}
Bool
RROutputSetConnection (RROutputPtr output,
CARD8 connection)
{
output->connection = connection;
return TRUE;
}
void
RRDeliverOutputEvent(ClientPtr client, WindowPtr pWin, RROutputPtr output)
{
}
/*
* Destroy a Output at shutdown
@ -36,7 +153,28 @@ RROutputDestroy (RROutputPtr crtc)
static int
RROutputDestroyResource (pointer value, XID pid)
{
free (value);
RROutputPtr output = (RROutputPtr) value;
ScreenPtr pScreen = output->pScreen;
rrScrPriv(pScreen);
int i;
for (i = 0; i < pScrPriv->numOutputs; i++)
{
if (pScrPriv->outputs[i] == output)
{
memmove (pScrPriv->outputs, pScrPriv->outputs + 1,
(pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr));
--pScrPriv->numOutputs;
break;
}
}
if (output->modes)
xfree (output->modes);
if (output->crtcs)
xfree (output->crtcs);
if (output->clones)
xfree (output->clones);
xfree (output);
return 1;
}
@ -46,11 +184,11 @@ RROutputDestroyResource (pointer value, XID pid)
Bool
RROutputInit (void)
{
OutputType = CreateNewResourceType (RROutputDestroyResource);
if (!OutputType)
RROutputType = CreateNewResourceType (RROutputDestroyResource);
if (!RROutputType)
return FALSE;
#ifdef XResExtension
RegisterResourceName (OutputType, "OUTPUT");
RegisterResourceName (RROutputType, "OUTPUT");
#endif
return TRUE;
}

282
randr/rrsdispatch.c Normal file
View File

@ -0,0 +1,282 @@
/*
* Copyright © 2006 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.
*/
#include "randrstr.h"
static int
SProcRRQueryVersion (ClientPtr client)
{
register int n;
REQUEST(xRRQueryVersionReq);
swaps(&stuff->length, n);
swapl(&stuff->majorVersion, n);
swapl(&stuff->minorVersion, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
}
static int
SProcRRGetScreenInfo (ClientPtr client)
{
register int n;
REQUEST(xRRGetScreenInfoReq);
swaps(&stuff->length, n);
swapl(&stuff->window, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
}
static int
SProcRRSetScreenConfig (ClientPtr client)
{
register int n;
REQUEST(xRRSetScreenConfigReq);
if (RRClientKnowsRates (client))
{
REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
swaps (&stuff->rate, n);
}
else
{
REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
}
swaps(&stuff->length, n);
swapl(&stuff->drawable, n);
swapl(&stuff->timestamp, n);
swaps(&stuff->sizeID, n);
swaps(&stuff->rotation, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
}
static int
SProcRRSelectInput (ClientPtr client)
{
register int n;
REQUEST(xRRSelectInputReq);
swaps(&stuff->length, n);
swapl(&stuff->window, n);
return (*ProcRandrVector[stuff->randrReqType]) (client);
}
static int
SProcRRGetScreenSizeRange (ClientPtr client)
{
REQUEST(xRRGetScreenSizeRangeReq);
REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRSetScreenSize (ClientPtr client)
{
REQUEST(xRRSetScreenSizeReq);
REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRGetScreenResources (ClientPtr client)
{
REQUEST(xRRGetScreenResourcesReq);
REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRGetOutputInfo (ClientPtr client)
{
REQUEST(xRRGetOutputInfoReq);;
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRListOutputProperties (ClientPtr client)
{
REQUEST(xRRListOutputPropertiesReq);
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRChangeOutputProperty (ClientPtr client)
{
REQUEST(xRRChangeOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRChangeOutputPropertyReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRDeleteOutputProperty (ClientPtr client)
{
REQUEST(xRRDeleteOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRGetOutputProperty (ClientPtr client)
{
REQUEST(xRRGetOutputPropertyReq);
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRCreateMode (ClientPtr client)
{
REQUEST(xRRCreateModeReq);
REQUEST_SIZE_MATCH(xRRCreateModeReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRDestroyMode (ClientPtr client)
{
REQUEST(xRRDestroyModeReq);
REQUEST_SIZE_MATCH(xRRDestroyModeReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRAddOutputMode (ClientPtr client)
{
REQUEST(xRRAddOutputModeReq);
REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRDeleteOutputMode (ClientPtr client)
{
REQUEST(xRRDeleteOutputModeReq);
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRGetCrtcInfo (ClientPtr client)
{
REQUEST(xRRGetCrtcInfoReq);
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRSetCrtcConfig (ClientPtr client)
{
REQUEST(xRRSetCrtcConfigReq);
REQUEST_SIZE_MATCH(xRRSetCrtcConfigReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRGetCrtcGammaSize (ClientPtr client)
{
REQUEST(xRRGetCrtcGammaSizeReq);
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRGetCrtcGamma (ClientPtr client)
{
REQUEST(xRRGetCrtcGammaReq);
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
(void) stuff;
return BadImplementation;
}
static int
SProcRRSetCrtcGamma (ClientPtr client)
{
REQUEST(xRRSetCrtcGammaReq);
REQUEST_SIZE_MATCH(xRRSetCrtcGammaReq);
(void) stuff;
return BadImplementation;
}
int (*SProcRandrVector[RRNumberRequests])(ClientPtr) = {
SProcRRQueryVersion, /* 0 */
/* we skip 1 to make old clients fail pretty immediately */
NULL, /* 1 SProcRandrOldGetScreenInfo */
/* V1.0 apps share the same set screen config request id */
SProcRRSetScreenConfig, /* 2 */
NULL, /* 3 SProcRandrOldScreenChangeSelectInput */
/* 3 used to be ScreenChangeSelectInput; deprecated */
SProcRRSelectInput, /* 4 */
SProcRRGetScreenInfo, /* 5 */
/* V1.2 additions */
SProcRRGetScreenSizeRange, /* 6 */
SProcRRSetScreenSize, /* 7 */
SProcRRGetScreenResources, /* 8 */
SProcRRGetOutputInfo, /* 9 */
SProcRRListOutputProperties,/* 10 */
SProcRRChangeOutputProperty,/* 11 */
SProcRRDeleteOutputProperty,/* 12 */
SProcRRGetOutputProperty, /* 13 */
SProcRRCreateMode, /* 14 */
SProcRRDestroyMode, /* 15 */
SProcRRAddOutputMode, /* 16 */
SProcRRDeleteOutputMode, /* 17 */
SProcRRGetCrtcInfo, /* 18 */
SProcRRSetCrtcConfig, /* 19 */
SProcRRGetCrtcGammaSize, /* 20 */
SProcRRGetCrtcGamma, /* 21 */
SProcRRSetCrtcGamma, /* 22 */
};