diff options
Diffstat (limited to 'xorg-server/hw/xfree86/dri2')
-rw-r--r-- | xorg-server/hw/xfree86/dri2/dri2.c | 946 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dri2/dri2.h | 178 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dri2/dri2ext.c | 228 |
3 files changed, 674 insertions, 678 deletions
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c index 5cc9068af..591ff3ace 100644 --- a/xorg-server/hw/xfree86/dri2/dri2.c +++ b/xorg-server/hw/xfree86/dri2/dri2.c @@ -48,66 +48,69 @@ #include "xf86.h" -CARD8 dri2_major; /* version of DRI2 supported by DDX */ +CARD8 dri2_major; /* version of DRI2 supported by DDX */ CARD8 dri2_minor; static DevPrivateKeyRec dri2ScreenPrivateKeyRec; + #define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec) static DevPrivateKeyRec dri2WindowPrivateKeyRec; + #define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec) static DevPrivateKeyRec dri2PixmapPrivateKeyRec; + #define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec) -static RESTYPE dri2DrawableRes; +static RESTYPE dri2DrawableRes; typedef struct _DRI2Screen *DRI2ScreenPtr; typedef struct _DRI2Drawable { - DRI2ScreenPtr dri2_screen; - DrawablePtr drawable; - struct xorg_list reference_list; - int width; - int height; - DRI2BufferPtr *buffers; - int bufferCount; - unsigned int swapsPending; - ClientPtr blockedClient; - Bool blockedOnMsc; - int swap_interval; - CARD64 swap_count; - int64_t target_sbc; /* -1 means no SBC wait outstanding */ - CARD64 last_swap_target; /* most recently queued swap target */ - CARD64 last_swap_msc; /* msc at completion of most recent swap */ - CARD64 last_swap_ust; /* ust at completion of most recent swap */ - int swap_limit; /* for N-buffering */ - unsigned long serialNumber; - Bool needInvalidate; + DRI2ScreenPtr dri2_screen; + DrawablePtr drawable; + struct xorg_list reference_list; + int width; + int height; + DRI2BufferPtr *buffers; + int bufferCount; + unsigned int swapsPending; + ClientPtr blockedClient; + Bool blockedOnMsc; + int swap_interval; + CARD64 swap_count; + int64_t target_sbc; /* -1 means no SBC wait outstanding */ + CARD64 last_swap_target; /* most recently queued swap target */ + CARD64 last_swap_msc; /* msc at completion of most recent swap */ + CARD64 last_swap_ust; /* ust at completion of most recent swap */ + int swap_limit; /* for N-buffering */ + unsigned long serialNumber; + Bool needInvalidate; } DRI2DrawableRec, *DRI2DrawablePtr; typedef struct _DRI2Screen { - ScreenPtr screen; - int refcnt; - unsigned int numDrivers; - const char **driverNames; - const char *deviceName; - int fd; - unsigned int lastSequence; - - DRI2CreateBufferProcPtr CreateBuffer; - DRI2DestroyBufferProcPtr DestroyBuffer; - DRI2CopyRegionProcPtr CopyRegion; - DRI2ScheduleSwapProcPtr ScheduleSwap; - DRI2GetMSCProcPtr GetMSC; - DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC; - DRI2AuthMagicProcPtr AuthMagic; + ScreenPtr screen; + int refcnt; + unsigned int numDrivers; + const char **driverNames; + const char *deviceName; + int fd; + unsigned int lastSequence; + + DRI2CreateBufferProcPtr CreateBuffer; + DRI2DestroyBufferProcPtr DestroyBuffer; + DRI2CopyRegionProcPtr CopyRegion; + DRI2ScheduleSwapProcPtr ScheduleSwap; + DRI2GetMSCProcPtr GetMSC; + DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC; + DRI2AuthMagicProcPtr AuthMagic; DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify; DRI2SwapLimitValidateProcPtr SwapLimitValidate; - HandleExposuresProcPtr HandleExposures; + HandleExposuresProcPtr HandleExposures; - ConfigNotifyProcPtr ConfigNotify; + ConfigNotifyProcPtr ConfigNotify; } DRI2ScreenRec; static DRI2ScreenPtr @@ -124,13 +127,13 @@ DRI2GetDrawable(DrawablePtr pDraw) switch (pDraw->type) { case DRAWABLE_WINDOW: - pWin = (WindowPtr) pDraw; - return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); + pWin = (WindowPtr) pDraw; + return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey); case DRAWABLE_PIXMAP: - pPixmap = (PixmapPtr) pDraw; - return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); + pPixmap = (PixmapPtr) pDraw; + return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey); default: - return NULL; + return NULL; } } @@ -141,24 +144,24 @@ DRI2DrawableSerial(DrawablePtr pDraw) PixmapPtr pPix; if (pDraw->type != DRAWABLE_WINDOW) - return pDraw->serialNumber; + return pDraw->serialNumber; - pPix = pScreen->GetWindowPixmap((WindowPtr)pDraw); + pPix = pScreen->GetWindowPixmap((WindowPtr) pDraw); return pPix->drawable.serialNumber; } static DRI2DrawablePtr DRI2AllocateDrawable(DrawablePtr pDraw) { - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); + DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); DRI2DrawablePtr pPriv; - CARD64 ust; + CARD64 ust; WindowPtr pWin; PixmapPtr pPixmap; pPriv = malloc(sizeof *pPriv); if (pPriv == NULL) - return NULL; + return NULL; pPriv->dri2_screen = ds; pPriv->drawable = pDraw; @@ -173,10 +176,10 @@ DRI2AllocateDrawable(DrawablePtr pDraw) pPriv->target_sbc = -1; pPriv->swap_interval = 1; /* Initialize last swap target from DDX if possible */ - if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target)) - pPriv->last_swap_target = 0; + if (!ds->GetMSC || !(*ds->GetMSC) (pDraw, &ust, &pPriv->last_swap_target)) + pPriv->last_swap_target = 0; - pPriv->swap_limit = 1; /* default to double buffering */ + pPriv->swap_limit = 1; /* default to double buffering */ pPriv->last_swap_msc = 0; pPriv->last_swap_ust = 0; xorg_list_init(&pPriv->reference_list); @@ -184,11 +187,12 @@ DRI2AllocateDrawable(DrawablePtr pDraw) pPriv->needInvalidate = FALSE; if (pDraw->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr) pDraw; - dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv); - } else { - pPixmap = (PixmapPtr) pDraw; - dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv); + pWin = (WindowPtr) pDraw; + dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv); + } + else { + pPixmap = (PixmapPtr) pDraw; + dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv); } return pPriv; @@ -199,37 +203,37 @@ DRI2SwapLimit(DrawablePtr pDraw, int swap_limit) { DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw); DRI2ScreenPtr ds; + if (!pPriv) - return FALSE; + return FALSE; ds = pPriv->dri2_screen; - if (!ds->SwapLimitValidate - || !ds->SwapLimitValidate(pDraw, swap_limit)) - return FALSE; + if (!ds->SwapLimitValidate || !ds->SwapLimitValidate(pDraw, swap_limit)) + return FALSE; pPriv->swap_limit = swap_limit; /* Check throttling */ if (pPriv->swapsPending >= pPriv->swap_limit) - return TRUE; + return TRUE; if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) { - if (pPriv->blockedClient) { - AttendClient(pPriv->blockedClient); - pPriv->blockedClient = NULL; - } + if (pPriv->blockedClient) { + AttendClient(pPriv->blockedClient); + pPriv->blockedClient = NULL; + } } return TRUE; } typedef struct DRI2DrawableRefRec { - XID id; - XID dri2_id; - DRI2InvalidateProcPtr invalidate; - void *priv; - struct xorg_list link; + XID id; + XID dri2_id; + DRI2InvalidateProcPtr invalidate; + void *priv; + struct xorg_list link; } DRI2DrawableRefRec, *DRI2DrawableRefPtr; static DRI2DrawableRefPtr @@ -238,36 +242,36 @@ DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id) DRI2DrawableRefPtr ref; xorg_list_for_each_entry(ref, &pPriv->reference_list, link) { - if (ref->id == id) - return ref; + if (ref->id == id) + return ref; } - + return NULL; } static int DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id, - DRI2InvalidateProcPtr invalidate, void *priv) + DRI2InvalidateProcPtr invalidate, void *priv) { DRI2DrawableRefPtr ref; ref = malloc(sizeof *ref); if (ref == NULL) - return BadAlloc; - + return BadAlloc; + if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) { - free(ref); - return BadAlloc; + free(ref); + return BadAlloc; } if (!DRI2LookupDrawableRef(pPriv, id)) - if (!AddResource(id, dri2DrawableRes, pPriv)) { - FreeResourceByType(dri2_id, dri2DrawableRes, TRUE); - free(ref); - return BadAlloc; + if (!AddResource(id, dri2DrawableRes, pPriv)) { + FreeResourceByType(dri2_id, dri2DrawableRes, TRUE); + free(ref); + return BadAlloc; } ref->id = id; - ref->dri2_id = dri2_id; + ref->dri2_id = dri2_id; ref->invalidate = invalidate; ref->priv = priv; xorg_list_add(&ref->link, &pPriv->reference_list); @@ -277,7 +281,7 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id, int DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id, - DRI2InvalidateProcPtr invalidate, void *priv) + DRI2InvalidateProcPtr invalidate, void *priv) { DRI2DrawablePtr pPriv; XID dri2_id; @@ -285,22 +289,23 @@ DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id, pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) - pPriv = DRI2AllocateDrawable(pDraw); + pPriv = DRI2AllocateDrawable(pDraw); if (pPriv == NULL) - return BadAlloc; - + return BadAlloc; + dri2_id = FakeClientID(client->index); rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv); if (rc != Success) - return rc; + return rc; return Success; } -static int DRI2DrawableGone(pointer p, XID id) +static int +DRI2DrawableGone(pointer p, XID id) { DRI2DrawablePtr pPriv = p; - DRI2ScreenPtr ds = pPriv->dri2_screen; + DRI2ScreenPtr ds = pPriv->dri2_screen; DRI2DrawableRefPtr ref, next; WindowPtr pWin; PixmapPtr pPixmap; @@ -308,40 +313,41 @@ static int DRI2DrawableGone(pointer p, XID id) int i; xorg_list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) { - if (ref->dri2_id == id) { - xorg_list_del(&ref->link); - /* If this was the last ref under this X drawable XID, - * unregister the X drawable resource. */ - if (!DRI2LookupDrawableRef(pPriv, ref->id)) - FreeResourceByType(ref->id, dri2DrawableRes, TRUE); - free(ref); - break; - } - - if (ref->id == id) { - xorg_list_del(&ref->link); - FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE); - free(ref); - } + if (ref->dri2_id == id) { + xorg_list_del(&ref->link); + /* If this was the last ref under this X drawable XID, + * unregister the X drawable resource. */ + if (!DRI2LookupDrawableRef(pPriv, ref->id)) + FreeResourceByType(ref->id, dri2DrawableRes, TRUE); + free(ref); + break; + } + + if (ref->id == id) { + xorg_list_del(&ref->link); + FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE); + free(ref); + } } if (!xorg_list_is_empty(&pPriv->reference_list)) - return Success; + return Success; pDraw = pPriv->drawable; if (pDraw->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr) pDraw; - dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL); - } else { - pPixmap = (PixmapPtr) pDraw; - dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL); + pWin = (WindowPtr) pDraw; + dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL); + } + else { + pPixmap = (PixmapPtr) pDraw; + dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL); } if (pPriv->buffers != NULL) { - for (i = 0; i < pPriv->bufferCount; i++) - (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]); + for (i = 0; i < pPriv->bufferCount; i++) + (*ds->DestroyBuffer) (pDraw, pPriv->buffers[i]); - free(pPriv->buffers); + free(pPriv->buffers); } free(pPriv); @@ -355,14 +361,14 @@ find_attachment(DRI2DrawablePtr pPriv, unsigned attachment) int i; if (pPriv->buffers == NULL) { - return -1; + return -1; } for (i = 0; i < pPriv->bufferCount; i++) { - if ((pPriv->buffers[i] != NULL) - && (pPriv->buffers[i]->attachment == attachment)) { - return i; - } + if ((pPriv->buffers[i] != NULL) + && (pPriv->buffers[i]->attachment == attachment)) { + return i; + } } return -1; @@ -370,46 +376,47 @@ find_attachment(DRI2DrawablePtr pPriv, unsigned attachment) static Bool allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds, - DRI2DrawablePtr pPriv, - unsigned int attachment, unsigned int format, - int dimensions_match, DRI2BufferPtr *buffer) + DRI2DrawablePtr pPriv, + unsigned int attachment, unsigned int format, + int dimensions_match, DRI2BufferPtr * buffer) { int old_buf = find_attachment(pPriv, attachment); if ((old_buf < 0) - || attachment == DRI2BufferFrontLeft - || !dimensions_match - || (pPriv->buffers[old_buf]->format != format)) { - *buffer = (*ds->CreateBuffer)(pDraw, attachment, format); - pPriv->serialNumber = DRI2DrawableSerial(pDraw); - return TRUE; + || attachment == DRI2BufferFrontLeft + || !dimensions_match || (pPriv->buffers[old_buf]->format != format)) { + *buffer = (*ds->CreateBuffer) (pDraw, attachment, format); + pPriv->serialNumber = DRI2DrawableSerial(pDraw); + return TRUE; - } else { - *buffer = pPriv->buffers[old_buf]; + } + else { + *buffer = pPriv->buffers[old_buf]; - if (ds->ReuseBufferNotify) - (*ds->ReuseBufferNotify)(pDraw, *buffer); + if (ds->ReuseBufferNotify) + (*ds->ReuseBufferNotify) (pDraw, *buffer); - pPriv->buffers[old_buf] = NULL; - return FALSE; + pPriv->buffers[old_buf] = NULL; + return FALSE; } } static void update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw, - DRI2BufferPtr *buffers, int out_count, int *width, int *height) + DRI2BufferPtr * buffers, int out_count, int *width, + int *height) { - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); + DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); int i; if (pPriv->buffers != NULL) { - for (i = 0; i < pPriv->bufferCount; i++) { - if (pPriv->buffers[i] != NULL) { - (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]); - } - } + for (i = 0; i < pPriv->bufferCount; i++) { + if (pPriv->buffers[i] != NULL) { + (*ds->DestroyBuffer) (pDraw, pPriv->buffers[i]); + } + } - free(pPriv->buffers); + free(pPriv->buffers); } pPriv->buffers = buffers; @@ -422,12 +429,12 @@ update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw, static DRI2BufferPtr * do_get_buffers(DrawablePtr pDraw, int *width, int *height, - unsigned int *attachments, int count, int *out_count, - int has_format) + unsigned int *attachments, int count, int *out_count, + int has_format) { - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); + DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw); - DRI2BufferPtr *buffers; + DRI2BufferPtr *buffers; int need_real_front = 0; int need_fake_front = 0; int have_fake_front = 0; @@ -437,142 +444,143 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height, int i; if (!pPriv) { - *width = pDraw->width; - *height = pDraw->height; - *out_count = 0; - return NULL; + *width = pDraw->width; + *height = pDraw->height; + *out_count = 0; + return NULL; } dimensions_match = (pDraw->width == pPriv->width) - && (pDraw->height == pPriv->height) - && (pPriv->serialNumber == DRI2DrawableSerial(pDraw)); + && (pDraw->height == pPriv->height) + && (pPriv->serialNumber == DRI2DrawableSerial(pDraw)); buffers = calloc((count + 1), sizeof(buffers[0])); if (!buffers) - goto err_out; + goto err_out; for (i = 0; i < count; i++) { - const unsigned attachment = *(attachments++); - const unsigned format = (has_format) ? *(attachments++) : 0; - - if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment, - format, dimensions_match, - &buffers[i])) - buffers_changed = 1; - - if (buffers[i] == NULL) - goto err_out; - - /* If the drawable is a window and the front-buffer is requested, - * silently add the fake front-buffer to the list of requested - * attachments. The counting logic in the loop accounts for the case - * where the client requests both the fake and real front-buffer. - */ - if (attachment == DRI2BufferBackLeft) { - need_real_front++; - front_format = format; - } - - if (attachment == DRI2BufferFrontLeft) { - need_real_front--; - front_format = format; - - if (pDraw->type == DRAWABLE_WINDOW) { - need_fake_front++; - } - } - - if (pDraw->type == DRAWABLE_WINDOW) { - if (attachment == DRI2BufferFakeFrontLeft) { - need_fake_front--; - have_fake_front = 1; - } - } + const unsigned attachment = *(attachments++); + const unsigned format = (has_format) ? *(attachments++) : 0; + + if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment, + format, dimensions_match, &buffers[i])) + buffers_changed = 1; + + if (buffers[i] == NULL) + goto err_out; + + /* If the drawable is a window and the front-buffer is requested, + * silently add the fake front-buffer to the list of requested + * attachments. The counting logic in the loop accounts for the case + * where the client requests both the fake and real front-buffer. + */ + if (attachment == DRI2BufferBackLeft) { + need_real_front++; + front_format = format; + } + + if (attachment == DRI2BufferFrontLeft) { + need_real_front--; + front_format = format; + + if (pDraw->type == DRAWABLE_WINDOW) { + need_fake_front++; + } + } + + if (pDraw->type == DRAWABLE_WINDOW) { + if (attachment == DRI2BufferFakeFrontLeft) { + need_fake_front--; + have_fake_front = 1; + } + } } if (need_real_front > 0) { - if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft, - front_format, dimensions_match, - &buffers[i])) - buffers_changed = 1; - - if (buffers[i] == NULL) - goto err_out; - i++; + if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft, + front_format, dimensions_match, + &buffers[i])) + buffers_changed = 1; + + if (buffers[i] == NULL) + goto err_out; + i++; } if (need_fake_front > 0) { - if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft, - front_format, dimensions_match, - &buffers[i])) - buffers_changed = 1; + if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft, + front_format, dimensions_match, + &buffers[i])) + buffers_changed = 1; - if (buffers[i] == NULL) - goto err_out; + if (buffers[i] == NULL) + goto err_out; - i++; - have_fake_front = 1; + i++; + have_fake_front = 1; } *out_count = i; - update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, height); + update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, + height); /* If the client is getting a fake front-buffer, pre-fill it with the * contents of the real front-buffer. This ensures correct operation of * applications that call glXWaitX before calling glDrawBuffer. */ if (have_fake_front && buffers_changed) { - BoxRec box; - RegionRec region; + BoxRec box; + RegionRec region; - box.x1 = 0; - box.y1 = 0; - box.x2 = pPriv->width; - box.y2 = pPriv->height; - RegionInit(®ion, &box, 0); + box.x1 = 0; + box.y1 = 0; + box.x2 = pPriv->width; + box.y2 = pPriv->height; + RegionInit(®ion, &box, 0); - DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft, - DRI2BufferFrontLeft); + DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft, + DRI2BufferFrontLeft); } pPriv->needInvalidate = TRUE; return pPriv->buffers; -err_out: + err_out: *out_count = 0; if (buffers) { - for (i = 0; i < count; i++) { - if (buffers[i] != NULL) - (*ds->DestroyBuffer)(pDraw, buffers[i]); - } + for (i = 0; i < count; i++) { + if (buffers[i] != NULL) + (*ds->DestroyBuffer) (pDraw, buffers[i]); + } - free(buffers); - buffers = NULL; + free(buffers); + buffers = NULL; } - update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, height); + update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, + height); return buffers; } DRI2BufferPtr * DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, - unsigned int *attachments, int count, int *out_count) + unsigned int *attachments, int count, int *out_count) { return do_get_buffers(pDraw, width, height, attachments, count, - out_count, FALSE); + out_count, FALSE); } DRI2BufferPtr * DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height, - unsigned int *attachments, int count, int *out_count) + unsigned int *attachments, int count, int *out_count) { return do_get_buffers(pDraw, width, height, attachments, count, - out_count, TRUE); + out_count, TRUE); } static void @@ -587,7 +595,7 @@ DRI2InvalidateDrawable(DrawablePtr pDraw) pPriv->needInvalidate = FALSE; xorg_list_for_each_entry(ref, &pPriv->reference_list, link) - ref->invalidate(pDraw, ref->priv, ref->id); + ref->invalidate(pDraw, ref->priv, ref->id); } /* @@ -604,16 +612,15 @@ DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw) pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) - return FALSE; + return FALSE; /* Throttle to swap limit */ - if ((pPriv->swapsPending >= pPriv->swap_limit) && - !pPriv->blockedClient) { - ResetCurrentRequest(client); - client->sequence--; - IgnoreClient(client); - pPriv->blockedClient = client; - return TRUE; + if ((pPriv->swapsPending >= pPriv->swap_limit) && !pPriv->blockedClient) { + ResetCurrentRequest(client); + client->sequence--; + IgnoreClient(client); + pPriv->blockedClient = client; + return TRUE; } return FALSE; @@ -623,8 +630,8 @@ static void __DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv) { if (pPriv->blockedClient == NULL) { - IgnoreClient(client); - pPriv->blockedClient = client; + IgnoreClient(client); + pPriv->blockedClient = client; } } @@ -635,7 +642,7 @@ DRI2BlockClient(ClientPtr client, DrawablePtr pDraw) pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) - return; + return; __DRI2BlockClient(client, pPriv); pPriv->blockedOnMsc = TRUE; @@ -643,30 +650,29 @@ DRI2BlockClient(ClientPtr client, DrawablePtr pDraw) int DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion, - unsigned int dest, unsigned int src) + unsigned int dest, unsigned int src) { - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); + DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); DRI2DrawablePtr pPriv; - DRI2BufferPtr pDestBuffer, pSrcBuffer; - int i; + DRI2BufferPtr pDestBuffer, pSrcBuffer; + int i; pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) - return BadDrawable; + return BadDrawable; pDestBuffer = NULL; pSrcBuffer = NULL; - for (i = 0; i < pPriv->bufferCount; i++) - { - if (pPriv->buffers[i]->attachment == dest) - pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i]; - if (pPriv->buffers[i]->attachment == src) - pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i]; + for (i = 0; i < pPriv->bufferCount; i++) { + if (pPriv->buffers[i]->attachment == dest) + pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i]; + if (pPriv->buffers[i]->attachment == src) + pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i]; } if (pSrcBuffer == NULL || pDestBuffer == NULL) - return BadValue; + return BadValue; - (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer); + (*ds->CopyRegion) (pDraw, pRegion, pDestBuffer, pSrcBuffer); return Success; } @@ -680,7 +686,7 @@ DRI2CanFlip(DrawablePtr pDraw) PixmapPtr pWinPixmap, pRootPixmap; if (pDraw->type == DRAWABLE_PIXMAP) - return TRUE; + return TRUE; pRoot = pScreen->root; pRootPixmap = pScreen->GetWindowPixmap(pRoot); @@ -688,20 +694,18 @@ DRI2CanFlip(DrawablePtr pDraw) pWin = (WindowPtr) pDraw; pWinPixmap = pScreen->GetWindowPixmap(pWin); if (pRootPixmap != pWinPixmap) - return FALSE; + return FALSE; if (!RegionEqual(&pWin->clipList, &pRoot->winSize)) - return FALSE; + return FALSE; /* Does the window match the pixmap exactly? */ - if (pDraw->x != 0 || - pDraw->y != 0 || + if (pDraw->x != 0 || pDraw->y != 0 || #ifdef COMPOSITE - pDraw->x != pWinPixmap->screen_x || - pDraw->y != pWinPixmap->screen_y || + pDraw->x != pWinPixmap->screen_x || pDraw->y != pWinPixmap->screen_y || #endif - pDraw->width != pWinPixmap->drawable.width || - pDraw->height != pWinPixmap->drawable.height) - return FALSE; + pDraw->width != pWinPixmap->drawable.width || + pDraw->height != pWinPixmap->drawable.height) + return FALSE; return TRUE; } @@ -715,19 +719,19 @@ DRI2CanExchange(DrawablePtr pDraw) void DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame, - unsigned int tv_sec, unsigned int tv_usec) + unsigned int tv_sec, unsigned int tv_usec) { DRI2DrawablePtr pPriv; pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) - return; + return; - ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec, - frame, pPriv->swap_count); + ProcDRI2WaitMSCReply(client, ((CARD64) tv_sec * 1000000) + tv_usec, + frame, pPriv->swap_count); if (pPriv->blockedClient) - AttendClient(pPriv->blockedClient); + AttendClient(pPriv->blockedClient); pPriv->blockedClient = NULL; pPriv->blockedOnMsc = FALSE; @@ -735,16 +739,16 @@ DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame, static void DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame, - unsigned int tv_sec, unsigned int tv_usec) + unsigned int tv_sec, unsigned int tv_usec) { - ScreenPtr pScreen = pDraw->pScreen; + ScreenPtr pScreen = pDraw->pScreen; DRI2DrawablePtr pPriv; pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return; + "[DRI2] %s: bad drawable\n", __func__); + return; } /* @@ -755,38 +759,38 @@ DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame, * - was blocked due to swap throttling * - is not blocked due to an MSC wait */ - if (pPriv->target_sbc != -1 && - pPriv->target_sbc <= pPriv->swap_count) { - ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec, - frame, pPriv->swap_count); - pPriv->target_sbc = -1; - - AttendClient(pPriv->blockedClient); - pPriv->blockedClient = NULL; - } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) { - if (pPriv->blockedClient) { - AttendClient(pPriv->blockedClient); - pPriv->blockedClient = NULL; - } + if (pPriv->target_sbc != -1 && pPriv->target_sbc <= pPriv->swap_count) { + ProcDRI2WaitMSCReply(client, ((CARD64) tv_sec * 1000000) + tv_usec, + frame, pPriv->swap_count); + pPriv->target_sbc = -1; + + AttendClient(pPriv->blockedClient); + pPriv->blockedClient = NULL; + } + else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) { + if (pPriv->blockedClient) { + AttendClient(pPriv->blockedClient); + pPriv->blockedClient = NULL; + } } } void DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame, - unsigned int tv_sec, unsigned int tv_usec, int type, - DRI2SwapEventPtr swap_complete, void *swap_data) + unsigned int tv_sec, unsigned int tv_usec, int type, + DRI2SwapEventPtr swap_complete, void *swap_data) { - ScreenPtr pScreen = pDraw->pScreen; + ScreenPtr pScreen = pDraw->pScreen; DRI2DrawablePtr pPriv; - CARD64 ust = 0; - BoxRec box; - RegionRec region; + CARD64 ust = 0; + BoxRec box; + RegionRec region; pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return; + "[DRI2] %s: bad drawable\n", __func__); + return; } pPriv->swapsPending--; @@ -798,11 +802,11 @@ DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame, box.y2 = pDraw->height; RegionInit(®ion, &box, 0); DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft, - DRI2BufferFrontLeft); + DRI2BufferFrontLeft); - ust = ((CARD64)tv_sec * 1000000) + tv_usec; + ust = ((CARD64) tv_sec * 1000000) + tv_usec; if (swap_complete) - swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count); + swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count); pPriv->last_swap_msc = frame; pPriv->last_swap_ust = ust; @@ -818,13 +822,11 @@ DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable) /* If we're currently waiting for a swap on this drawable, reset * the request and suspend the client. We only support one * blocked client per drawable. */ - if (pPriv && - pPriv->swapsPending && - pPriv->blockedClient == NULL) { - ResetCurrentRequest(client); - client->sequence--; - __DRI2BlockClient(client, pPriv); - return TRUE; + if (pPriv && pPriv->swapsPending && pPriv->blockedClient == NULL) { + ResetCurrentRequest(client); + client->sequence--; + __DRI2BlockClient(client, pPriv); + return TRUE; } return FALSE; @@ -838,59 +840,59 @@ static int DRI2InvalidateWalk(WindowPtr pWin, pointer data) { if (pWin->drawable.pScreen->GetWindowPixmap(pWin) != data) - return WT_DONTWALKCHILDREN; + return WT_DONTWALKCHILDREN; DRI2InvalidateDrawable(&pWin->drawable); return WT_WALKCHILDREN; } int DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, - CARD64 divisor, CARD64 remainder, CARD64 *swap_target, - DRI2SwapEventPtr func, void *data) + CARD64 divisor, CARD64 remainder, CARD64 * swap_target, + DRI2SwapEventPtr func, void *data) { - ScreenPtr pScreen = pDraw->pScreen; - DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); + ScreenPtr pScreen = pDraw->pScreen; + DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); DRI2DrawablePtr pPriv; - DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL; - int ret, i; - CARD64 ust, current_msc; + DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL; + int ret, i; + CARD64 ust, current_msc; pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return BadDrawable; + "[DRI2] %s: bad drawable\n", __func__); + return BadDrawable; } for (i = 0; i < pPriv->bufferCount; i++) { - if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft) - pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i]; - if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft) - pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i]; + if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft) + pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i]; + if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft) + pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i]; } if (pSrcBuffer == NULL || pDestBuffer == NULL) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: drawable has no back or front?\n", __func__); - return BadDrawable; + "[DRI2] %s: drawable has no back or front?\n", __func__); + return BadDrawable; } /* Old DDX or no swap interval, just blit */ if (!ds->ScheduleSwap || !pPriv->swap_interval) { - BoxRec box; - RegionRec region; + BoxRec box; + RegionRec region; - box.x1 = 0; - box.y1 = 0; - box.x2 = pDraw->width; - box.y2 = pDraw->height; - RegionInit(®ion, &box, 0); + box.x1 = 0; + box.y1 = 0; + box.x2 = pDraw->width; + box.y2 = pDraw->height; + RegionInit(®ion, &box, 0); - pPriv->swapsPending++; + pPriv->swapsPending++; - (*ds->CopyRegion)(pDraw, ®ion, pDestBuffer, pSrcBuffer); - DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE, - func, data); - return Success; + (*ds->CopyRegion) (pDraw, ®ion, pDestBuffer, pSrcBuffer); + DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE, + func, data); + return Success; } /* @@ -898,42 +900,43 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, * need to schedule a swap for the last swap target + the swap interval. */ if (target_msc == 0 && divisor == 0 && remainder == 0) { - /* If the current vblank count of the drawable's crtc is lower - * than the count stored in last_swap_target from a previous swap - * then reinitialize last_swap_target to the current crtc's msc, - * otherwise the swap will hang. This will happen if the drawable - * is moved to a crtc with a lower refresh rate, or a crtc that just - * got enabled. - */ - if (ds->GetMSC) { - if (!(*ds->GetMSC)(pDraw, &ust, ¤t_msc)) - pPriv->last_swap_target = 0; - - if (current_msc < pPriv->last_swap_target) - pPriv->last_swap_target = current_msc; - - } - - /* - * Swap target for this swap is last swap target + swap interval since - * we have to account for the current swap count, interval, and the - * number of pending swaps. - */ - *swap_target = pPriv->last_swap_target + pPriv->swap_interval; - - } else { - /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */ - *swap_target = target_msc; + /* If the current vblank count of the drawable's crtc is lower + * than the count stored in last_swap_target from a previous swap + * then reinitialize last_swap_target to the current crtc's msc, + * otherwise the swap will hang. This will happen if the drawable + * is moved to a crtc with a lower refresh rate, or a crtc that just + * got enabled. + */ + if (ds->GetMSC) { + if (!(*ds->GetMSC) (pDraw, &ust, ¤t_msc)) + pPriv->last_swap_target = 0; + + if (current_msc < pPriv->last_swap_target) + pPriv->last_swap_target = current_msc; + + } + + /* + * Swap target for this swap is last swap target + swap interval since + * we have to account for the current swap count, interval, and the + * number of pending swaps. + */ + *swap_target = pPriv->last_swap_target + pPriv->swap_interval; + + } + else { + /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */ + *swap_target = target_msc; } pPriv->swapsPending++; - ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer, - swap_target, divisor, remainder, func, data); + ret = (*ds->ScheduleSwap) (client, pDraw, pDestBuffer, pSrcBuffer, + swap_target, divisor, remainder, func, data); if (!ret) { - pPriv->swapsPending--; /* didn't schedule */ + pPriv->swapsPending--; /* didn't schedule */ xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: driver failed to schedule swap\n", __func__); - return BadDrawable; + "[DRI2] %s: driver failed to schedule swap\n", __func__); + return BadDrawable; } pPriv->last_swap_target = *swap_target; @@ -944,23 +947,25 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, *swap_target = pPriv->swap_count + pPriv->swapsPending; if (pDraw->type == DRAWABLE_WINDOW) { - WindowPtr pWin = (WindowPtr) pDraw; - PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin); - - /* - * Find the top-most window using this pixmap - */ - while (pWin->parent && pScreen->GetWindowPixmap(pWin->parent) == pPixmap) - pWin = pWin->parent; - - /* - * Walk the sub-tree to invalidate all of the - * windows using the same pixmap - */ - TraverseTree(pWin, DRI2InvalidateWalk, pPixmap); - DRI2InvalidateDrawable(&pPixmap->drawable); - } else - DRI2InvalidateDrawable(pDraw); + WindowPtr pWin = (WindowPtr) pDraw; + PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin); + + /* + * Find the top-most window using this pixmap + */ + while (pWin->parent && + pScreen->GetWindowPixmap(pWin->parent) == pPixmap) + pWin = pWin->parent; + + /* + * Walk the sub-tree to invalidate all of the + * windows using the same pixmap + */ + TraverseTree(pWin, DRI2InvalidateWalk, pPixmap); + DRI2InvalidateDrawable(&pPixmap->drawable); + } + else + DRI2InvalidateDrawable(pDraw); return Success; } @@ -968,13 +973,13 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, void DRI2SwapInterval(DrawablePtr pDrawable, int interval) { - ScreenPtr pScreen = pDrawable->pScreen; + ScreenPtr pScreen = pDrawable->pScreen; DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable); if (pPriv == NULL) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return; + "[DRI2] %s: bad drawable\n", __func__); + return; } /* fixme: check against arbitrary max? */ @@ -982,7 +987,7 @@ DRI2SwapInterval(DrawablePtr pDrawable, int interval) } int -DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc) +DRI2GetMSC(DrawablePtr pDraw, CARD64 * ust, CARD64 * msc, CARD64 * sbc) { ScreenPtr pScreen = pDraw->pScreen; DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); @@ -992,15 +997,15 @@ DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc) pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "[DRI2] %s: bad drawable\n", __func__); - return BadDrawable; + "[DRI2] %s: bad drawable\n", __func__); + return BadDrawable; } if (!ds->GetMSC) { - *ust = 0; - *msc = 0; - *sbc = pPriv->swap_count; - return Success; + *ust = 0; + *msc = 0; + *sbc = pPriv->swap_count; + return Success; } /* @@ -1008,9 +1013,9 @@ DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc) * drawables */ - ret = (*ds->GetMSC)(pDraw, ust, msc); + ret = (*ds->GetMSC) (pDraw, ust, msc); if (!ret) - return BadDrawable; + return BadDrawable; *sbc = pPriv->swap_count; @@ -1019,7 +1024,7 @@ DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc) int DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, - CARD64 divisor, CARD64 remainder) + CARD64 divisor, CARD64 remainder) { DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen); DRI2DrawablePtr pPriv; @@ -1027,18 +1032,19 @@ DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc, pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) - return BadDrawable; + return BadDrawable; /* Old DDX just completes immediately */ if (!ds->ScheduleWaitMSC) { - DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0); + DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0); - return Success; + return Success; } - ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder); + ret = + (*ds->ScheduleWaitMSC) (client, pDraw, target_msc, divisor, remainder); if (!ret) - return BadDrawable; + return BadDrawable; return Success; } @@ -1050,7 +1056,7 @@ DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc) pPriv = DRI2GetDrawable(pDraw); if (pPriv == NULL) - return BadDrawable; + return BadDrawable; /* target_sbc == 0 means to block until all pending swaps are * finished. Recalculate target_sbc to get that behaviour. @@ -1084,17 +1090,17 @@ DRI2HasSwapControl(ScreenPtr pScreen) Bool DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd, - const char **driverName, const char **deviceName) + const char **driverName, const char **deviceName) { DRI2ScreenPtr ds; if (!dixPrivateKeyRegistered(dri2ScreenPrivateKey)) - return FALSE; + return FALSE; ds = DRI2GetScreen(pScreen); if (ds == NULL || driverType >= ds->numDrivers || - !ds->driverNames[driverType]) - return FALSE; + !ds->driverNames[driverType]) + return FALSE; *fd = ds->fd; *driverName = ds->driverNames[driverType]; @@ -1108,7 +1114,7 @@ DRI2Authenticate(ScreenPtr pScreen, uint32_t magic) { DRI2ScreenPtr ds = DRI2GetScreen(pScreen); - if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic)) + if (ds == NULL || (*ds->AuthMagic) (ds->fd, magic)) return FALSE; return TRUE; @@ -1116,27 +1122,27 @@ DRI2Authenticate(ScreenPtr pScreen, uint32_t magic) static int DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw, - WindowPtr pSib) + WindowPtr pSib) { - DrawablePtr pDraw = (DrawablePtr)pWin; + DrawablePtr pDraw = (DrawablePtr) pWin; ScreenPtr pScreen = pDraw->pScreen; DRI2ScreenPtr ds = DRI2GetScreen(pScreen); DRI2DrawablePtr dd = DRI2GetDrawable(pDraw); int ret; if (ds->ConfigNotify) { - pScreen->ConfigNotify = ds->ConfigNotify; + pScreen->ConfigNotify = ds->ConfigNotify; - ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib); + ret = (*pScreen->ConfigNotify) (pWin, x, y, w, h, bw, pSib); - ds->ConfigNotify = pScreen->ConfigNotify; - pScreen->ConfigNotify = DRI2ConfigNotify; - if (ret) - return ret; + ds->ConfigNotify = pScreen->ConfigNotify; + pScreen->ConfigNotify = DRI2ConfigNotify; + if (ret) + return ret; } if (!dd || (dd->width == w && dd->height == h)) - return Success; + return Success; DRI2InvalidateDrawable(pDraw); return Success; @@ -1146,51 +1152,53 @@ Bool DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) { DRI2ScreenPtr ds; - const char* driverTypeNames[] = { - "DRI", /* DRI2DriverDRI */ - "VDPAU", /* DRI2DriverVDPAU */ + + const char *driverTypeNames[] = { + "DRI", /* DRI2DriverDRI */ + "VDPAU", /* DRI2DriverVDPAU */ }; unsigned int i; CARD8 cur_minor; if (info->version < 3) - return FALSE; + return FALSE; if (!xf86VGAarbiterAllowDRI(pScreen)) { xf86DrvMsg(pScreen->myNum, X_WARNING, - "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n"); + "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n"); return FALSE; } if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; + return FALSE; if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0)) - return FALSE; + return FALSE; if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0)) - return FALSE; + return FALSE; ds = calloc(1, sizeof *ds); if (!ds) - return FALSE; + return FALSE; - ds->screen = pScreen; - ds->fd = info->fd; - ds->deviceName = info->deviceName; - dri2_major = 1; + ds->screen = pScreen; + ds->fd = info->fd; + ds->deviceName = info->deviceName; + dri2_major = 1; - ds->CreateBuffer = info->CreateBuffer; - ds->DestroyBuffer = info->DestroyBuffer; - ds->CopyRegion = info->CopyRegion; + ds->CreateBuffer = info->CreateBuffer; + ds->DestroyBuffer = info->DestroyBuffer; + ds->CopyRegion = info->CopyRegion; if (info->version >= 4) { - ds->ScheduleSwap = info->ScheduleSwap; - ds->ScheduleWaitMSC = info->ScheduleWaitMSC; - ds->GetMSC = info->GetMSC; - cur_minor = 3; - } else { - cur_minor = 1; + ds->ScheduleSwap = info->ScheduleSwap; + ds->ScheduleWaitMSC = info->ScheduleWaitMSC; + ds->GetMSC = info->GetMSC; + cur_minor = 3; + } + else { + cur_minor = 1; } if (info->version >= 5) { @@ -1198,8 +1206,8 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) } if (info->version >= 6) { - ds->ReuseBufferNotify = info->ReuseBufferNotify; - ds->SwapLimitValidate = info->SwapLimitValidate; + ds->ReuseBufferNotify = info->ReuseBufferNotify; + ds->SwapLimitValidate = info->SwapLimitValidate; } /* @@ -1215,22 +1223,23 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) /* Initialize minor if needed and set to minimum provied by DDX */ if (!dri2_minor || dri2_minor > cur_minor) - dri2_minor = cur_minor; + dri2_minor = cur_minor; if (info->version == 3 || info->numDrivers == 0) { - /* Driver too old: use the old-style driverName field */ - ds->numDrivers = 1; - ds->driverNames = malloc(sizeof(*ds->driverNames)); - if (!ds->driverNames) - goto err_out; - ds->driverNames[0] = info->driverName; - } else { - ds->numDrivers = info->numDrivers; - ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames)); - if (!ds->driverNames) - goto err_out; - memcpy(ds->driverNames, info->driverNames, - info->numDrivers * sizeof(*ds->driverNames)); + /* Driver too old: use the old-style driverName field */ + ds->numDrivers = 1; + ds->driverNames = malloc(sizeof(*ds->driverNames)); + if (!ds->driverNames) + goto err_out; + ds->driverNames[0] = info->driverName; + } + else { + ds->numDrivers = info->numDrivers; + ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames)); + if (!ds->driverNames) + goto err_out; + memcpy(ds->driverNames, info->driverNames, + info->numDrivers * sizeof(*ds->driverNames)); } dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds); @@ -1240,17 +1249,18 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n"); for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) { - if (i < ds->numDrivers && ds->driverNames[i]) { - xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n", - driverTypeNames[i], ds->driverNames[i]); - } + if (i < ds->numDrivers && ds->driverNames[i]) { + xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n", + driverTypeNames[i], ds->driverNames[i]); + } } return TRUE; -err_out: + err_out: xf86DrvMsg(pScreen->myNum, X_WARNING, - "[DRI2] Initialization failed for info version %d.\n", info->version); + "[DRI2] Initialization failed for info version %d.\n", + info->version); free(ds); return FALSE; } @@ -1259,6 +1269,7 @@ void DRI2CloseScreen(ScreenPtr pScreen) { DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + pScreen->ConfigNotify = ds->ConfigNotify; free(ds->driverNames); @@ -1275,7 +1286,7 @@ DRI2ModuleSetup(void) { dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable"); if (!dri2DrawableRes) - return FALSE; + return FALSE; return TRUE; } @@ -1285,22 +1296,19 @@ DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin) { static Bool setupDone = FALSE; - if (!setupDone) - { - setupDone = TRUE; - LoadExtension(&dri2ExtensionModule, FALSE); + if (!setupDone) { + setupDone = TRUE; + LoadExtension(&dri2ExtensionModule, FALSE); } - else - { - if (errmaj) - *errmaj = LDR_ONCEONLY; + else { + if (errmaj) + *errmaj = LDR_ONCEONLY; } return (pointer) 1; } -static XF86ModuleVersionInfo DRI2VersRec = -{ +static XF86ModuleVersionInfo DRI2VersRec = { "dri2", MODULEVENDORSTRING, MODINFOSTRING1, @@ -1310,7 +1318,7 @@ static XF86ModuleVersionInfo DRI2VersRec = ABI_CLASS_EXTENSION, ABI_EXTENSION_VERSION, MOD_CLASS_NONE, - { 0, 0, 0, 0 } + {0, 0, 0, 0} }; _X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL }; @@ -1319,8 +1327,8 @@ void DRI2Version(int *major, int *minor) { if (major != NULL) - *major = DRI2VersRec.majorversion; + *major = DRI2VersRec.majorversion; if (minor != NULL) - *minor = DRI2VersRec.minorversion; + *minor = DRI2VersRec.minorversion; } diff --git a/xorg-server/hw/xfree86/dri2/dri2.h b/xorg-server/hw/xfree86/dri2/dri2.h index a67e35f73..00b3668cc 100644 --- a/xorg-server/hw/xfree86/dri2/dri2.h +++ b/xorg-server/hw/xfree86/dri2/dri2.h @@ -46,27 +46,24 @@ typedef struct { void *driverPrivate; } DRI2BufferRec, *DRI2BufferPtr; -extern CARD8 dri2_major; /* version of DRI2 supported by DDX */ +extern CARD8 dri2_major; /* version of DRI2 supported by DDX */ extern CARD8 dri2_minor; typedef DRI2BufferRec DRI2Buffer2Rec, *DRI2Buffer2Ptr; -typedef void (*DRI2SwapEventPtr)(ClientPtr client, void *data, int type, - CARD64 ust, CARD64 msc, CARD32 sbc); - - -typedef DRI2BufferPtr (*DRI2CreateBuffersProcPtr)(DrawablePtr pDraw, - unsigned int *attachments, - int count); -typedef void (*DRI2DestroyBuffersProcPtr)(DrawablePtr pDraw, - DRI2BufferPtr buffers, - int count); -typedef void (*DRI2CopyRegionProcPtr)(DrawablePtr pDraw, - RegionPtr pRegion, - DRI2BufferPtr pDestBuffer, - DRI2BufferPtr pSrcBuffer); -typedef void (*DRI2WaitProcPtr)(WindowPtr pWin, - unsigned int sequence); -typedef int (*DRI2AuthMagicProcPtr)(int fd, uint32_t magic); +typedef void (*DRI2SwapEventPtr) (ClientPtr client, void *data, int type, + CARD64 ust, CARD64 msc, CARD32 sbc); + +typedef DRI2BufferPtr(*DRI2CreateBuffersProcPtr) (DrawablePtr pDraw, + unsigned int *attachments, + int count); +typedef void (*DRI2DestroyBuffersProcPtr) (DrawablePtr pDraw, + DRI2BufferPtr buffers, int count); +typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw, + RegionPtr pRegion, + DRI2BufferPtr pDestBuffer, + DRI2BufferPtr pSrcBuffer); +typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence); +typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic); /** * Schedule a buffer swap @@ -95,20 +92,19 @@ typedef int (*DRI2AuthMagicProcPtr)(int fd, uint32_t magic); * \param func function to call when the swap completes * \param data data for the callback \p func. */ -typedef int (*DRI2ScheduleSwapProcPtr)(ClientPtr client, - DrawablePtr pDraw, - DRI2BufferPtr pDestBuffer, - DRI2BufferPtr pSrcBuffer, - CARD64 *target_msc, - CARD64 divisor, - CARD64 remainder, - DRI2SwapEventPtr func, - void *data); -typedef DRI2BufferPtr (*DRI2CreateBufferProcPtr)(DrawablePtr pDraw, - unsigned int attachment, - unsigned int format); -typedef void (*DRI2DestroyBufferProcPtr)(DrawablePtr pDraw, - DRI2BufferPtr buffer); +typedef int (*DRI2ScheduleSwapProcPtr) (ClientPtr client, + DrawablePtr pDraw, + DRI2BufferPtr pDestBuffer, + DRI2BufferPtr pSrcBuffer, + CARD64 * target_msc, + CARD64 divisor, + CARD64 remainder, + DRI2SwapEventPtr func, void *data); +typedef DRI2BufferPtr(*DRI2CreateBufferProcPtr) (DrawablePtr pDraw, + unsigned int attachment, + unsigned int format); +typedef void (*DRI2DestroyBufferProcPtr) (DrawablePtr pDraw, + DRI2BufferPtr buffer); /** * Notifies driver when DRI2GetBuffers reuses a dri2 buffer. * @@ -117,8 +113,8 @@ typedef void (*DRI2DestroyBufferProcPtr)(DrawablePtr pDraw, * \param pDraw drawable whose count we want * \param buffer buffer that will be returned to client */ -typedef void (*DRI2ReuseBufferNotifyProcPtr)(DrawablePtr pDraw, - DRI2BufferPtr buffer); +typedef void (*DRI2ReuseBufferNotifyProcPtr) (DrawablePtr pDraw, + DRI2BufferPtr buffer); /** * Get current media stamp counter values * @@ -137,8 +133,8 @@ typedef void (*DRI2ReuseBufferNotifyProcPtr)(DrawablePtr pDraw, * \param ust timestamp from when the count was last incremented. * \param mst current frame count */ -typedef int (*DRI2GetMSCProcPtr)(DrawablePtr pDraw, CARD64 *ust, - CARD64 *msc); +typedef int (*DRI2GetMSCProcPtr) (DrawablePtr pDraw, CARD64 * ust, + CARD64 * msc); /** * Schedule a frame count related wait * @@ -159,15 +155,12 @@ typedef int (*DRI2GetMSCProcPtr)(DrawablePtr pDraw, CARD64 *ust, * \param divisor divisor for condition equation * \param remainder remainder for division equation */ -typedef int (*DRI2ScheduleWaitMSCProcPtr)(ClientPtr client, - DrawablePtr pDraw, - CARD64 target_msc, - CARD64 divisor, - CARD64 remainder); +typedef int (*DRI2ScheduleWaitMSCProcPtr) (ClientPtr client, + DrawablePtr pDraw, + CARD64 target_msc, + CARD64 divisor, CARD64 remainder); -typedef void (*DRI2InvalidateProcPtr)(DrawablePtr pDraw, - void *data, - XID id); +typedef void (*DRI2InvalidateProcPtr) (DrawablePtr pDraw, void *data, XID id); /** * DRI2 calls this hook when ever swap_limit is going to be changed. Default @@ -179,8 +172,8 @@ typedef void (*DRI2InvalidateProcPtr)(DrawablePtr pDraw, * \param swap_limit new swap_limit that going to be set * \return TRUE if limit is support, FALSE if not. */ -typedef Bool (*DRI2SwapLimitValidateProcPtr)(DrawablePtr pDraw, - int swap_limit); +typedef Bool (*DRI2SwapLimitValidateProcPtr) (DrawablePtr pDraw, + int swap_limit); /** * Version of the DRI2InfoRec structure defined in this header @@ -188,74 +181,71 @@ typedef Bool (*DRI2SwapLimitValidateProcPtr)(DrawablePtr pDraw, #define DRI2INFOREC_VERSION 6 typedef struct { - unsigned int version; /**< Version of this struct */ + unsigned int version; /**< Version of this struct */ int fd; const char *driverName; const char *deviceName; - DRI2CreateBufferProcPtr CreateBuffer; - DRI2DestroyBufferProcPtr DestroyBuffer; - DRI2CopyRegionProcPtr CopyRegion; - DRI2WaitProcPtr Wait; + DRI2CreateBufferProcPtr CreateBuffer; + DRI2DestroyBufferProcPtr DestroyBuffer; + DRI2CopyRegionProcPtr CopyRegion; + DRI2WaitProcPtr Wait; /* added in version 4 */ - DRI2ScheduleSwapProcPtr ScheduleSwap; - DRI2GetMSCProcPtr GetMSC; - DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC; + DRI2ScheduleSwapProcPtr ScheduleSwap; + DRI2GetMSCProcPtr GetMSC; + DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC; /* number of drivers in the driverNames array */ unsigned int numDrivers; /* array of driver names, indexed by DRI2Driver* driver types */ /* a name of NULL means that driver is not supported */ - const char * const *driverNames; + const char *const *driverNames; /* added in version 5 */ - DRI2AuthMagicProcPtr AuthMagic; + DRI2AuthMagicProcPtr AuthMagic; /* added in version 6 */ DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify; DRI2SwapLimitValidateProcPtr SwapLimitValidate; -} DRI2InfoRec, *DRI2InfoPtr; +} DRI2InfoRec, *DRI2InfoPtr; extern _X_EXPORT int DRI2EventBase; -extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, - DRI2InfoPtr info); +extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info); extern _X_EXPORT void DRI2CloseScreen(ScreenPtr pScreen); extern _X_EXPORT Bool DRI2HasSwapControl(ScreenPtr pScreen); extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen, - unsigned int driverType, - int *fd, - const char **driverName, - const char **deviceName); + unsigned int driverType, + int *fd, + const char **driverName, + const char **deviceName); extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, uint32_t magic); extern _X_EXPORT int DRI2CreateDrawable(ClientPtr client, - DrawablePtr pDraw, - XID id, - DRI2InvalidateProcPtr invalidate, - void *priv); + DrawablePtr pDraw, + XID id, + DRI2InvalidateProcPtr invalidate, + void *priv); extern _X_EXPORT void DRI2DestroyDrawable(DrawablePtr pDraw); extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffers(DrawablePtr pDraw, - int *width, - int *height, - unsigned int *attachments, - int count, - int *out_count); + int *width, + int *height, + unsigned int *attachments, + int count, int *out_count); extern _X_EXPORT int DRI2CopyRegion(DrawablePtr pDraw, - RegionPtr pRegion, - unsigned int dest, - unsigned int src); + RegionPtr pRegion, + unsigned int dest, unsigned int src); /** * Determine the major and minor version of the DRI2 extension. @@ -276,26 +266,30 @@ extern _X_EXPORT int DRI2CopyRegion(DrawablePtr pDraw, extern _X_EXPORT void DRI2Version(int *major, int *minor); extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw, - int *width, int *height, unsigned int *attachments, int count, - int *out_count); + int *width, + int *height, + unsigned int + *attachments, + int count, + int *out_count); extern _X_EXPORT void DRI2SwapInterval(DrawablePtr pDrawable, int interval); extern _X_EXPORT Bool DRI2SwapLimit(DrawablePtr pDraw, int swap_limit); extern _X_EXPORT int DRI2SwapBuffers(ClientPtr client, DrawablePtr pDrawable, - CARD64 target_msc, CARD64 divisor, - CARD64 remainder, CARD64 *swap_target, - DRI2SwapEventPtr func, void *data); + CARD64 target_msc, CARD64 divisor, + CARD64 remainder, CARD64 * swap_target, + DRI2SwapEventPtr func, void *data); extern _X_EXPORT Bool DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable); -extern _X_EXPORT int DRI2GetMSC(DrawablePtr pDrawable, CARD64 *ust, - CARD64 *msc, CARD64 *sbc); +extern _X_EXPORT int DRI2GetMSC(DrawablePtr pDrawable, CARD64 * ust, + CARD64 * msc, CARD64 * sbc); extern _X_EXPORT int DRI2WaitMSC(ClientPtr client, DrawablePtr pDrawable, - CARD64 target_msc, CARD64 divisor, - CARD64 remainder); + CARD64 target_msc, CARD64 divisor, + CARD64 remainder); extern _X_EXPORT int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust, - CARD64 msc, CARD64 sbc); + CARD64 msc, CARD64 sbc); extern _X_EXPORT int DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, - CARD64 target_sbc); + CARD64 target_sbc); extern _X_EXPORT Bool DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw); extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw); @@ -306,12 +300,12 @@ extern _X_EXPORT Bool DRI2CanExchange(DrawablePtr pDraw); extern _X_EXPORT void DRI2BlockClient(ClientPtr client, DrawablePtr pDraw); extern _X_EXPORT void DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, - int frame, unsigned int tv_sec, - unsigned int tv_usec, int type, - DRI2SwapEventPtr swap_complete, - void *swap_data); + int frame, unsigned int tv_sec, + unsigned int tv_usec, int type, + DRI2SwapEventPtr swap_complete, + void *swap_data); extern _X_EXPORT void DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, - int frame, unsigned int tv_sec, - unsigned int tv_usec); + int frame, unsigned int tv_sec, + unsigned int tv_usec); #endif diff --git a/xorg-server/hw/xfree86/dri2/dri2ext.c b/xorg-server/hw/xfree86/dri2/dri2ext.c index 73ef7f25e..2579a5c86 100644 --- a/xorg-server/hw/xfree86/dri2/dri2ext.c +++ b/xorg-server/hw/xfree86/dri2/dri2ext.c @@ -49,19 +49,19 @@ /* The only xf86 include */ #include "xf86Module.h" -static ExtensionEntry *dri2Extension; +static ExtensionEntry *dri2Extension; extern Bool DRI2ModuleSetup(void); static Bool validDrawable(ClientPtr client, XID drawable, Mask access_mode, - DrawablePtr *pDrawable, int *status) + DrawablePtr *pDrawable, int *status) { *status = dixLookupDrawable(pDrawable, drawable, client, - M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP, - access_mode); + M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP, + access_mode); if (*status != Success) { - client->errorValue = drawable; - return FALSE; + client->errorValue = drawable; + return FALSE; } return TRUE; @@ -74,7 +74,7 @@ ProcDRI2QueryVersion(ClientPtr client) xDRI2QueryVersionReply rep; if (client->swapped) - swaps(&stuff->length); + swaps(&stuff->length); REQUEST_SIZE_MATCH(xDRI2QueryVersionReq); rep.type = X_Reply; @@ -84,10 +84,10 @@ ProcDRI2QueryVersion(ClientPtr client) rep.minorVersion = dri2_minor; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.majorVersion); - swapl(&rep.minorVersion); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swapl(&rep.majorVersion); + swapl(&rep.minorVersion); } WriteToClient(client, sizeof(xDRI2QueryVersionReply), &rep); @@ -107,9 +107,9 @@ ProcDRI2Connect(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2ConnectReq); if (!validDrawable(client, stuff->window, DixGetAttrAccess, - &pDraw, &status)) - return status; - + &pDraw, &status)) + return status; + rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -117,13 +117,13 @@ ProcDRI2Connect(ClientPtr client) rep.deviceNameLength = 0; if (!DRI2Connect(pDraw->pScreen, - stuff->driverType, &fd, &driverName, &deviceName)) - goto fail; + stuff->driverType, &fd, &driverName, &deviceName)) + goto fail; rep.driverNameLength = strlen(driverName); rep.deviceNameLength = strlen(deviceName); rep.length = (rep.driverNameLength + 3) / 4 + - (rep.deviceNameLength + 3) / 4; + (rep.deviceNameLength + 3) / 4; fail: WriteToClient(client, sizeof(xDRI2ConnectReply), &rep); @@ -143,8 +143,8 @@ ProcDRI2Authenticate(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2AuthenticateReq); if (!validDrawable(client, stuff->window, DixGetAttrAccess, - &pDraw, &status)) - return status; + &pDraw, &status)) + return status; rep.type = X_Reply; rep.sequenceNumber = client->sequence; @@ -164,7 +164,7 @@ DRI2InvalidateBuffersEvent(DrawablePtr pDraw, void *priv, XID id) event.type = DRI2EventBase + DRI2_InvalidateBuffers; event.drawable = id; - WriteEventsToClient(client, 1, (xEvent *)&event); + WriteEventsToClient(client, 1, (xEvent *) &event); } static int @@ -177,13 +177,13 @@ ProcDRI2CreateDrawable(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2CreateDrawableReq); if (!validDrawable(client, stuff->drawable, DixAddAccess, - &pDrawable, &status)) - return status; + &pDrawable, &status)) + return status; status = DRI2CreateDrawable(client, pDrawable, stuff->drawable, - DRI2InvalidateBuffersEvent, client); + DRI2InvalidateBuffersEvent, client); if (status != Success) - return status; + return status; return Success; } @@ -197,33 +197,32 @@ ProcDRI2DestroyDrawable(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2DestroyDrawableReq); if (!validDrawable(client, stuff->drawable, DixRemoveAccess, - &pDrawable, &status)) - return status; + &pDrawable, &status)) + return status; return Success; } - static int send_buffers_reply(ClientPtr client, DrawablePtr pDrawable, - DRI2BufferPtr *buffers, int count, int width, int height) + DRI2BufferPtr * buffers, int count, int width, int height) { xDRI2GetBuffersReply rep; int skip = 0; int i; if (buffers == NULL) - return BadAlloc; + return BadAlloc; if (pDrawable->type == DRAWABLE_WINDOW) { - for (i = 0; i < count; i++) { - /* Do not send the real front buffer of a window to the client. - */ - if (buffers[i]->attachment == DRI2BufferFrontLeft) { - skip++; - continue; - } - } + for (i = 0; i < count; i++) { + /* Do not send the real front buffer of a window to the client. + */ + if (buffers[i]->attachment == DRI2BufferFrontLeft) { + skip++; + continue; + } + } } rep.type = X_Reply; @@ -235,26 +234,25 @@ send_buffers_reply(ClientPtr client, DrawablePtr pDrawable, WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep); for (i = 0; i < count; i++) { - xDRI2Buffer buffer; - - /* Do not send the real front buffer of a window to the client. - */ - if ((pDrawable->type == DRAWABLE_WINDOW) - && (buffers[i]->attachment == DRI2BufferFrontLeft)) { - continue; - } - - buffer.attachment = buffers[i]->attachment; - buffer.name = buffers[i]->name; - buffer.pitch = buffers[i]->pitch; - buffer.cpp = buffers[i]->cpp; - buffer.flags = buffers[i]->flags; - WriteToClient(client, sizeof(xDRI2Buffer), &buffer); + xDRI2Buffer buffer; + + /* Do not send the real front buffer of a window to the client. + */ + if ((pDrawable->type == DRAWABLE_WINDOW) + && (buffers[i]->attachment == DRI2BufferFrontLeft)) { + continue; + } + + buffer.attachment = buffers[i]->attachment; + buffer.name = buffers[i]->name; + buffer.pitch = buffers[i]->pitch; + buffer.cpp = buffers[i]->cpp; + buffer.flags = buffers[i]->flags; + WriteToClient(client, sizeof(xDRI2Buffer), &buffer); } return Success; } - static int ProcDRI2GetBuffers(ClientPtr client) { @@ -266,16 +264,15 @@ ProcDRI2GetBuffers(ClientPtr client) REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * 4); if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess, - &pDrawable, &status)) - return status; + &pDrawable, &status)) + return status; if (DRI2ThrottleClient(client, pDrawable)) - return Success; + return Success; attachments = (unsigned int *) &stuff[1]; buffers = DRI2GetBuffers(pDrawable, &width, &height, - attachments, stuff->count, &count); - + attachments, stuff->count, &count); return send_buffers_reply(client, pDrawable, buffers, count, width, height); @@ -292,15 +289,15 @@ ProcDRI2GetBuffersWithFormat(ClientPtr client) REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * (2 * 4)); if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess, - &pDrawable, &status)) - return status; + &pDrawable, &status)) + return status; if (DRI2ThrottleClient(client, pDrawable)) - return Success; + return Success; attachments = (unsigned int *) &stuff[1]; buffers = DRI2GetBuffersWithFormat(pDrawable, &width, &height, - attachments, stuff->count, &count); + attachments, stuff->count, &count); return send_buffers_reply(client, pDrawable, buffers, count, width, height); } @@ -317,14 +314,14 @@ ProcDRI2CopyRegion(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2CopyRegionReq); if (!validDrawable(client, stuff->drawable, DixWriteAccess, - &pDrawable, &status)) - return status; + &pDrawable, &status)) + return status; VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess); status = DRI2CopyRegion(pDrawable, pRegion, stuff->dest, stuff->src); if (status != Success) - return status; + return status; /* CopyRegion needs to be a round trip to make sure the X server * queues the swap buffer rendering commands before the DRI client @@ -343,7 +340,7 @@ ProcDRI2CopyRegion(ClientPtr client) } static void -load_swap_reply(xDRI2SwapBuffersReply *rep, CARD64 sbc) +load_swap_reply(xDRI2SwapBuffersReply * rep, CARD64 sbc) { rep->swap_hi = sbc >> 32; rep->swap_lo = sbc & 0xffffffff; @@ -352,12 +349,12 @@ load_swap_reply(xDRI2SwapBuffersReply *rep, CARD64 sbc) static CARD64 vals_to_card64(CARD32 lo, CARD32 hi) { - return (CARD64)hi << 32 | lo; + return (CARD64) hi << 32 | lo; } static void DRI2SwapEvent(ClientPtr client, void *data, int type, CARD64 ust, CARD64 msc, - CARD32 sbc) + CARD32 sbc) { xDRI2BufferSwapComplete2 event; DrawablePtr pDrawable = data; @@ -365,13 +362,13 @@ DRI2SwapEvent(ClientPtr client, void *data, int type, CARD64 ust, CARD64 msc, event.type = DRI2EventBase + DRI2_BufferSwapComplete; event.event_type = type; event.drawable = pDrawable->id; - event.ust_hi = (CARD64)ust >> 32; + event.ust_hi = (CARD64) ust >> 32; event.ust_lo = ust & 0xffffffff; - event.msc_hi = (CARD64)msc >> 32; + event.msc_hi = (CARD64) msc >> 32; event.msc_lo = msc & 0xffffffff; event.sbc = sbc; - WriteEventsToClient(client, 1, (xEvent *)&event); + WriteEventsToClient(client, 1, (xEvent *) &event); } static int @@ -386,24 +383,24 @@ ProcDRI2SwapBuffers(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2SwapBuffersReq); if (!validDrawable(client, stuff->drawable, - DixReadAccess | DixWriteAccess, &pDrawable, &status)) - return status; + DixReadAccess | DixWriteAccess, &pDrawable, &status)) + return status; /* * Ensures an out of control client can't exhaust our swap queue, and * also orders swaps. */ if (DRI2ThrottleClient(client, pDrawable)) - return Success; + return Success; target_msc = vals_to_card64(stuff->target_msc_lo, stuff->target_msc_hi); divisor = vals_to_card64(stuff->divisor_lo, stuff->divisor_hi); remainder = vals_to_card64(stuff->remainder_lo, stuff->remainder_hi); status = DRI2SwapBuffers(client, pDrawable, target_msc, divisor, remainder, - &swap_target, DRI2SwapEvent, pDrawable); + &swap_target, DRI2SwapEvent, pDrawable); if (status != Success) - return BadDrawable; + return BadDrawable; rep.type = X_Reply; rep.length = 0; @@ -416,7 +413,7 @@ ProcDRI2SwapBuffers(ClientPtr client) } static void -load_msc_reply(xDRI2MSCReply *rep, CARD64 ust, CARD64 msc, CARD64 sbc) +load_msc_reply(xDRI2MSCReply * rep, CARD64 ust, CARD64 msc, CARD64 sbc) { rep->ust_hi = ust >> 32; rep->ust_lo = ust & 0xffffffff; @@ -438,12 +435,12 @@ ProcDRI2GetMSC(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2GetMSCReq); if (!validDrawable(client, stuff->drawable, DixReadAccess, &pDrawable, - &status)) - return status; + &status)) + return status; status = DRI2GetMSC(pDrawable, &ust, &msc, &sbc); if (status != Success) - return status; + return status; rep.type = X_Reply; rep.length = 0; @@ -468,8 +465,8 @@ ProcDRI2WaitMSC(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2WaitMSCReq); if (!validDrawable(client, stuff->drawable, DixReadAccess, &pDrawable, - &status)) - return status; + &status)) + return status; target = vals_to_card64(stuff->target_msc_lo, stuff->target_msc_hi); divisor = vals_to_card64(stuff->divisor_lo, stuff->divisor_hi); @@ -477,7 +474,7 @@ ProcDRI2WaitMSC(ClientPtr client) status = DRI2WaitMSC(client, pDrawable, target, divisor, remainder); if (status != Success) - return status; + return status; return Success; } @@ -509,8 +506,8 @@ ProcDRI2SwapInterval(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2SwapIntervalReq); if (!validDrawable(client, stuff->drawable, DixReadAccess | DixWriteAccess, - &pDrawable, &status)) - return status; + &pDrawable, &status)) + return status; DRI2SwapInterval(pDrawable, stuff->interval); @@ -528,8 +525,8 @@ ProcDRI2WaitSBC(ClientPtr client) REQUEST_SIZE_MATCH(xDRI2WaitSBCReq); if (!validDrawable(client, stuff->drawable, DixReadAccess, &pDrawable, - &status)) - return status; + &status)) + return status; target = vals_to_card64(stuff->target_sbc_lo, stuff->target_sbc_hi); status = DRI2WaitSBC(client, pDrawable, target); @@ -538,45 +535,45 @@ ProcDRI2WaitSBC(ClientPtr client) } static int -ProcDRI2Dispatch (ClientPtr client) +ProcDRI2Dispatch(ClientPtr client) { REQUEST(xReq); - + switch (stuff->data) { case X_DRI2QueryVersion: - return ProcDRI2QueryVersion(client); + return ProcDRI2QueryVersion(client); } if (!LocalClient(client)) - return BadRequest; + return BadRequest; switch (stuff->data) { case X_DRI2Connect: - return ProcDRI2Connect(client); + return ProcDRI2Connect(client); case X_DRI2Authenticate: - return ProcDRI2Authenticate(client); + return ProcDRI2Authenticate(client); case X_DRI2CreateDrawable: - return ProcDRI2CreateDrawable(client); + return ProcDRI2CreateDrawable(client); case X_DRI2DestroyDrawable: - return ProcDRI2DestroyDrawable(client); + return ProcDRI2DestroyDrawable(client); case X_DRI2GetBuffers: - return ProcDRI2GetBuffers(client); + return ProcDRI2GetBuffers(client); case X_DRI2CopyRegion: - return ProcDRI2CopyRegion(client); + return ProcDRI2CopyRegion(client); case X_DRI2GetBuffersWithFormat: - return ProcDRI2GetBuffersWithFormat(client); + return ProcDRI2GetBuffersWithFormat(client); case X_DRI2SwapBuffers: - return ProcDRI2SwapBuffers(client); + return ProcDRI2SwapBuffers(client); case X_DRI2GetMSC: - return ProcDRI2GetMSC(client); + return ProcDRI2GetMSC(client); case X_DRI2WaitMSC: - return ProcDRI2WaitMSC(client); + return ProcDRI2WaitMSC(client); case X_DRI2WaitSBC: - return ProcDRI2WaitSBC(client); + return ProcDRI2WaitSBC(client); case X_DRI2SwapInterval: - return ProcDRI2SwapInterval(client); + return ProcDRI2SwapInterval(client); default: - return BadRequest; + return BadRequest; } } @@ -590,7 +587,7 @@ SProcDRI2Connect(ClientPtr client) swaps(&stuff->length); if (sizeof(*stuff) / 4 != client->req_len) - return BadLength; + return BadLength; rep.sequenceNumber = client->sequence; swaps(&rep.sequenceNumber); @@ -602,7 +599,7 @@ SProcDRI2Connect(ClientPtr client) } static int -SProcDRI2Dispatch (ClientPtr client) +SProcDRI2Dispatch(ClientPtr client) { REQUEST(xReq); @@ -610,14 +607,13 @@ SProcDRI2Dispatch (ClientPtr client) * Only local clients are allowed DRI access, but remote clients * still need these requests to find out cleanly. */ - switch (stuff->data) - { + switch (stuff->data) { case X_DRI2QueryVersion: - return ProcDRI2QueryVersion(client); + return ProcDRI2QueryVersion(client); case X_DRI2Connect: - return SProcDRI2Connect(client); + return SProcDRI2Connect(client); default: - return BadRequest; + return BadRequest; } } @@ -627,12 +623,10 @@ static void DRI2ExtensionInit(void) { dri2Extension = AddExtension(DRI2_NAME, - DRI2NumberEvents, - DRI2NumberErrors, - ProcDRI2Dispatch, - SProcDRI2Dispatch, - NULL, - StandardMinorOpcode); + DRI2NumberEvents, + DRI2NumberErrors, + ProcDRI2Dispatch, + SProcDRI2Dispatch, NULL, StandardMinorOpcode); DRI2EventBase = dri2Extension->eventBase; |