diff options
Diffstat (limited to 'xorg-server/hw/xfree86/dri2/dri2ext.c')
-rw-r--r-- | xorg-server/hw/xfree86/dri2/dri2ext.c | 153 |
1 files changed, 78 insertions, 75 deletions
diff --git a/xorg-server/hw/xfree86/dri2/dri2ext.c b/xorg-server/hw/xfree86/dri2/dri2ext.c index c6f5b4e11..eb6fd44fc 100644 --- a/xorg-server/hw/xfree86/dri2/dri2ext.c +++ b/xorg-server/hw/xfree86/dri2/dri2ext.c @@ -44,13 +44,15 @@ #include "extnsionst.h" #include "xfixes.h" #include "dri2.h" +#include "dri2int.h" #include "protocol-versions.h" -/* The only xf86 include */ +/* The only xf86 includes */ #include "xf86Module.h" +#include "xf86Extensions.h" + +static int DRI2EventBase; -static ExtensionEntry *dri2Extension; -extern Bool DRI2ModuleSetup(void); static Bool validDrawable(ClientPtr client, XID drawable, Mask access_mode, @@ -71,17 +73,18 @@ static int ProcDRI2QueryVersion(ClientPtr client) { REQUEST(xDRI2QueryVersionReq); - xDRI2QueryVersionReply rep; + xDRI2QueryVersionReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .majorVersion = dri2_major, + .minorVersion = dri2_minor + }; if (client->swapped) swaps(&stuff->length); REQUEST_SIZE_MATCH(xDRI2QueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = dri2_major; - rep.minorVersion = dri2_minor; if (client->swapped) { swaps(&rep.sequenceNumber); @@ -99,7 +102,13 @@ static int ProcDRI2Connect(ClientPtr client) { REQUEST(xDRI2ConnectReq); - xDRI2ConnectReply rep; + xDRI2ConnectReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .driverNameLength = 0, + .deviceNameLength = 0 + }; DrawablePtr pDraw; int fd, status; const char *driverName; @@ -110,13 +119,7 @@ ProcDRI2Connect(ClientPtr client) &pDraw, &status)) return status; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.driverNameLength = 0; - rep.deviceNameLength = 0; - - if (!DRI2Connect(pDraw->pScreen, + if (!DRI2Connect(client, pDraw->pScreen, stuff->driverType, &fd, &driverName, &deviceName)) goto fail; @@ -146,10 +149,12 @@ ProcDRI2Authenticate(ClientPtr client) &pDraw, &status)) return status; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.authenticated = DRI2Authenticate(pDraw->pScreen, stuff->magic); + rep = (xDRI2AuthenticateReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .authenticated = DRI2Authenticate(client, pDraw->pScreen, stuff->magic) + }; WriteToClient(client, sizeof(xDRI2AuthenticateReply), &rep); return Success; @@ -158,11 +163,11 @@ ProcDRI2Authenticate(ClientPtr client) static void DRI2InvalidateBuffersEvent(DrawablePtr pDraw, void *priv, XID id) { - xDRI2InvalidateBuffers event; ClientPtr client = priv; - - event.type = DRI2EventBase + DRI2_InvalidateBuffers; - event.drawable = id; + xDRI2InvalidateBuffers event = { + .type = DRI2EventBase + DRI2_InvalidateBuffers, + .drawable = id + }; WriteEventsToClient(client, 1, (xEvent *) &event); } @@ -225,12 +230,14 @@ send_buffers_reply(ClientPtr client, DrawablePtr pDrawable, } } - rep.type = X_Reply; - rep.length = (count - skip) * sizeof(xDRI2Buffer) / 4; - rep.sequenceNumber = client->sequence; - rep.width = width; - rep.height = height; - rep.count = count - skip; + rep = (xDRI2GetBuffersReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = (count - skip) * sizeof(xDRI2Buffer) / 4, + .width = width, + .height = height, + .count = count - skip + }; WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep); for (i = 0; i < count; i++) { @@ -330,9 +337,11 @@ ProcDRI2CopyRegion(ClientPtr client) * that yet. */ - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; + rep = (xDRI2CopyRegionReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; WriteToClient(client, sizeof(xDRI2CopyRegionReply), &rep); @@ -356,17 +365,17 @@ static void DRI2SwapEvent(ClientPtr client, void *data, int type, CARD64 ust, CARD64 msc, CARD32 sbc) { - xDRI2BufferSwapComplete2 event; DrawablePtr pDrawable = data; - - event.type = DRI2EventBase + DRI2_BufferSwapComplete; - event.event_type = type; - event.drawable = pDrawable->id; - event.ust_hi = (CARD64) ust >> 32; - event.ust_lo = ust & 0xffffffff; - event.msc_hi = (CARD64) msc >> 32; - event.msc_lo = msc & 0xffffffff; - event.sbc = sbc; + xDRI2BufferSwapComplete2 event = { + .type = DRI2EventBase + DRI2_BufferSwapComplete, + .event_type = type, + .drawable = pDrawable->id, + .ust_hi = (CARD64) ust >> 32, + .ust_lo = ust & 0xffffffff, + .msc_hi = (CARD64) msc >> 32, + .msc_lo = msc & 0xffffffff, + .sbc = sbc + }; WriteEventsToClient(client, 1, (xEvent *) &event); } @@ -375,7 +384,11 @@ static int ProcDRI2SwapBuffers(ClientPtr client) { REQUEST(xDRI2SwapBuffersReq); - xDRI2SwapBuffersReply rep; + xDRI2SwapBuffersReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; DrawablePtr pDrawable; CARD64 target_msc, divisor, remainder, swap_target; int status; @@ -402,9 +415,6 @@ ProcDRI2SwapBuffers(ClientPtr client) if (status != Success) return BadDrawable; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; load_swap_reply(&rep, swap_target); WriteToClient(client, sizeof(xDRI2SwapBuffersReply), &rep); @@ -427,7 +437,11 @@ static int ProcDRI2GetMSC(ClientPtr client) { REQUEST(xDRI2GetMSCReq); - xDRI2MSCReply rep; + xDRI2MSCReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; DrawablePtr pDrawable; CARD64 ust, msc, sbc; int status; @@ -442,9 +456,6 @@ ProcDRI2GetMSC(ClientPtr client) if (status != Success) return status; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; load_msc_reply(&rep, ust, msc, sbc); WriteToClient(client, sizeof(xDRI2MSCReply), &rep); @@ -482,11 +493,12 @@ ProcDRI2WaitMSC(ClientPtr client) int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust, CARD64 msc, CARD64 sbc) { - xDRI2MSCReply rep; + xDRI2MSCReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; load_msc_reply(&rep, ust, msc, sbc); WriteToClient(client, sizeof(xDRI2MSCReply), &rep); @@ -614,7 +626,13 @@ static int SProcDRI2Connect(ClientPtr client) { REQUEST(xDRI2ConnectReq); - xDRI2ConnectReply rep; + xDRI2ConnectReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .driverNameLength = 0, + .deviceNameLength = 0 + }; /* If the client is swapped, it's not local. Talk to the hand. */ @@ -622,12 +640,7 @@ SProcDRI2Connect(ClientPtr client) if (sizeof(*stuff) / 4 != client->req_len) return BadLength; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; swaps(&rep.sequenceNumber); - rep.length = 0; - rep.driverNameLength = 0; - rep.deviceNameLength = 0; WriteToClient(client, sizeof(xDRI2ConnectReply), &rep); @@ -653,11 +666,11 @@ SProcDRI2Dispatch(ClientPtr client) } } -int DRI2EventBase; - -static void +void DRI2ExtensionInit(void) { + ExtensionEntry *dri2Extension; + dri2Extension = AddExtension(DRI2_NAME, DRI2NumberEvents, DRI2NumberErrors, @@ -668,13 +681,3 @@ DRI2ExtensionInit(void) DRI2ModuleSetup(); } - -extern Bool noDRI2Extension; - -_X_HIDDEN ExtensionModule dri2ExtensionModule = { - DRI2ExtensionInit, - DRI2_NAME, - &noDRI2Extension, - NULL, - NULL -}; |