dri3: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
dc39130899
commit
9c6271258c
|
@ -90,7 +90,7 @@ dri3_extension_init(void)
|
|||
#endif /* XINERAMA */
|
||||
|
||||
extension = AddExtension(DRI3_NAME, DRI3NumberEvents, DRI3NumberErrors,
|
||||
proc_dri3_dispatch, sproc_dri3_dispatch,
|
||||
proc_dri3_dispatch, proc_dri3_dispatch,
|
||||
NULL, StandardMinorOpcode);
|
||||
if (!extension)
|
||||
goto bail;
|
||||
|
|
|
@ -81,9 +81,6 @@ dri3_screen_priv(ScreenPtr screen)
|
|||
int
|
||||
proc_dri3_dispatch(ClientPtr client);
|
||||
|
||||
int
|
||||
sproc_dri3_dispatch(ClientPtr client);
|
||||
|
||||
/* DDX interface */
|
||||
|
||||
int
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/request_priv.h"
|
||||
#include "os/client_priv.h"
|
||||
|
||||
#include "dri3_priv.h"
|
||||
|
@ -63,7 +64,9 @@ dri3_screen_can_one_point_two(ScreenPtr screen)
|
|||
static int
|
||||
proc_dri3_query_version(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3QueryVersionReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3QueryVersionReq);
|
||||
REQUEST_FIELD_CARD32(majorVersion);
|
||||
REQUEST_FIELD_CARD32(minorVersion);
|
||||
|
||||
xDRI3QueryVersionReply rep = {
|
||||
.type = X_Reply,
|
||||
|
@ -72,8 +75,6 @@ proc_dri3_query_version(ClientPtr client)
|
|||
.minorVersion = SERVER_DRI3_MINOR_VERSION
|
||||
};
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3QueryVersionReq);
|
||||
|
||||
for (int i = 0; i < screenInfo.numScreens; i++) {
|
||||
if (!dri3_screen_can_one_point_two(screenInfo.screens[i])) {
|
||||
rep.minorVersion = 0;
|
||||
|
@ -147,15 +148,16 @@ dri3_send_open_reply(ClientPtr client, int fd)
|
|||
static int
|
||||
proc_dri3_open(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3OpenReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3OpenReq);
|
||||
REQUEST_FIELD_CARD32(drawable);
|
||||
REQUEST_FIELD_CARD32(provider);
|
||||
|
||||
RRProviderPtr provider;
|
||||
DrawablePtr drawable;
|
||||
ScreenPtr screen;
|
||||
int fd;
|
||||
int status;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3OpenReq);
|
||||
|
||||
status = dixLookupDrawable(&drawable, stuff->drawable, client, 0, DixGetAttrAccess);
|
||||
if (status != Success)
|
||||
return status;
|
||||
|
@ -184,14 +186,20 @@ proc_dri3_open(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_pixmap_from_buffer(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3PixmapFromBufferReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3PixmapFromBufferReq);
|
||||
REQUEST_FIELD_CARD32(pixmap);
|
||||
REQUEST_FIELD_CARD32(drawable);
|
||||
REQUEST_FIELD_CARD32(size);
|
||||
REQUEST_FIELD_CARD16(width);
|
||||
REQUEST_FIELD_CARD16(height);
|
||||
REQUEST_FIELD_CARD16(stride);
|
||||
|
||||
int fd;
|
||||
DrawablePtr drawable;
|
||||
PixmapPtr pixmap;
|
||||
CARD32 stride, offset;
|
||||
int rc;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3PixmapFromBufferReq);
|
||||
LEGAL_NEW_RESOURCE(stuff->pixmap, client);
|
||||
rc = dixLookupDrawable(&drawable, stuff->drawable, client, M_ANY, DixGetAttrAccess);
|
||||
if (rc != Success) {
|
||||
|
@ -255,13 +263,13 @@ proc_dri3_pixmap_from_buffer(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_buffer_from_pixmap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3BufferFromPixmapReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3BufferFromPixmapReq);
|
||||
REQUEST_FIELD_CARD32(pixmap);
|
||||
|
||||
int rc;
|
||||
int fd;
|
||||
PixmapPtr pixmap;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3BufferFromPixmapReq);
|
||||
rc = dixLookupResourceByType((void **) &pixmap, stuff->pixmap, X11_RESTYPE_PIXMAP,
|
||||
client, DixWriteAccess);
|
||||
if (rc != Success) {
|
||||
|
@ -304,12 +312,14 @@ proc_dri3_buffer_from_pixmap(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_fence_from_fd(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3FenceFromFDReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3FenceFromFDReq);
|
||||
REQUEST_FIELD_CARD32(drawable);
|
||||
REQUEST_FIELD_CARD32(fence);
|
||||
|
||||
DrawablePtr drawable;
|
||||
int fd;
|
||||
int status;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3FenceFromFDReq);
|
||||
LEGAL_NEW_RESOURCE(stuff->fence, client);
|
||||
|
||||
status = dixLookupDrawable(&drawable, stuff->drawable, client, M_ANY, DixGetAttrAccess);
|
||||
|
@ -330,7 +340,10 @@ proc_dri3_fence_from_fd(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_fd_from_fence(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3FDFromFenceReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3FDFromFenceReq);
|
||||
REQUEST_FIELD_CARD32(drawable);
|
||||
REQUEST_FIELD_CARD32(fence);
|
||||
|
||||
xDRI3FDFromFenceReply rep = {
|
||||
.type = X_Reply,
|
||||
.nfd = 1,
|
||||
|
@ -341,8 +354,6 @@ proc_dri3_fd_from_fence(ClientPtr client)
|
|||
int status;
|
||||
SyncFence *fence;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3FDFromFenceReq);
|
||||
|
||||
status = dixLookupDrawable(&drawable, stuff->drawable, client, M_ANY, DixGetAttrAccess);
|
||||
if (status != Success)
|
||||
return status;
|
||||
|
@ -369,7 +380,9 @@ proc_dri3_fd_from_fence(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_get_supported_modifiers(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3GetSupportedModifiersReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3GetSupportedModifiersReq);
|
||||
REQUEST_FIELD_CARD32(window);
|
||||
|
||||
WindowPtr window;
|
||||
ScreenPtr pScreen;
|
||||
CARD64 *window_modifiers = NULL;
|
||||
|
@ -379,8 +392,6 @@ proc_dri3_get_supported_modifiers(ClientPtr client)
|
|||
int status;
|
||||
int i;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3GetSupportedModifiersReq);
|
||||
|
||||
status = dixLookupWindow(&window, stuff->window, client, DixGetAttrAccess);
|
||||
if (status != Success)
|
||||
return status;
|
||||
|
@ -423,7 +434,21 @@ proc_dri3_get_supported_modifiers(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_pixmap_from_buffers(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3PixmapFromBuffersReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3PixmapFromBuffersReq);
|
||||
REQUEST_FIELD_CARD32(pixmap);
|
||||
REQUEST_FIELD_CARD32(window);
|
||||
REQUEST_FIELD_CARD16(width);
|
||||
REQUEST_FIELD_CARD16(height);
|
||||
REQUEST_FIELD_CARD32(stride0);
|
||||
REQUEST_FIELD_CARD32(offset0);
|
||||
REQUEST_FIELD_CARD32(stride1);
|
||||
REQUEST_FIELD_CARD32(offset1);
|
||||
REQUEST_FIELD_CARD32(stride2);
|
||||
REQUEST_FIELD_CARD32(offset2);
|
||||
REQUEST_FIELD_CARD32(stride3);
|
||||
REQUEST_FIELD_CARD32(offset3);
|
||||
REQUEST_FIELD_CARD64(modifier);
|
||||
|
||||
int fds[4];
|
||||
CARD32 strides[4], offsets[4];
|
||||
ScreenPtr screen;
|
||||
|
@ -432,7 +457,6 @@ proc_dri3_pixmap_from_buffers(ClientPtr client)
|
|||
int rc;
|
||||
int i;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3PixmapFromBuffersReq);
|
||||
LEGAL_NEW_RESOURCE(stuff->pixmap, client);
|
||||
rc = dixLookupWindow(&window, stuff->window, client, DixGetAttrAccess);
|
||||
if (rc != Success) {
|
||||
|
@ -516,7 +540,9 @@ proc_dri3_pixmap_from_buffers(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_buffers_from_pixmap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3BuffersFromPixmapReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3BuffersFromPixmapReq);
|
||||
REQUEST_FIELD_CARD32(pixmap);
|
||||
|
||||
int rc;
|
||||
int fds[4];
|
||||
int num_fds;
|
||||
|
@ -525,7 +551,6 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
|
|||
int i;
|
||||
PixmapPtr pixmap;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3BuffersFromPixmapReq);
|
||||
rc = dixLookupResourceByType((void **) &pixmap, stuff->pixmap, X11_RESTYPE_PIXMAP,
|
||||
client, DixWriteAccess);
|
||||
if (rc != Success) {
|
||||
|
@ -580,11 +605,14 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_set_drm_device_in_use(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3SetDRMDeviceInUseReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3SetDRMDeviceInUseReq);
|
||||
REQUEST_FIELD_CARD32(window);
|
||||
REQUEST_FIELD_CARD32(drmMajor);
|
||||
REQUEST_FIELD_CARD32(drmMinor);
|
||||
|
||||
WindowPtr window;
|
||||
int status;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3SetDRMDeviceInUseReq);
|
||||
status = dixLookupWindow(&window, stuff->window, client,
|
||||
DixGetAttrAccess);
|
||||
if (status != Success)
|
||||
|
@ -601,13 +629,15 @@ proc_dri3_set_drm_device_in_use(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_import_syncobj(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3ImportSyncobjReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3ImportSyncobjReq);
|
||||
REQUEST_FIELD_CARD32(syncobj);
|
||||
REQUEST_FIELD_CARD32(drawable);
|
||||
|
||||
DrawablePtr drawable;
|
||||
ScreenPtr screen;
|
||||
int fd;
|
||||
int status;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3ImportSyncobjReq);
|
||||
LEGAL_NEW_RESOURCE(stuff->syncobj, client);
|
||||
|
||||
status = dixLookupDrawable(&drawable, stuff->drawable, client,
|
||||
|
@ -628,12 +658,12 @@ proc_dri3_import_syncobj(ClientPtr client)
|
|||
static int
|
||||
proc_dri3_free_syncobj(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3FreeSyncobjReq);
|
||||
REQUEST_HEAD_STRUCT(xDRI3FreeSyncobjReq);
|
||||
REQUEST_FIELD_CARD32(syncobj);
|
||||
|
||||
struct dri3_syncobj *syncobj;
|
||||
int status;
|
||||
|
||||
REQUEST_SIZE_MATCH(xDRI3FreeSyncobjReq);
|
||||
|
||||
status = dixLookupResourceByType((void **) &syncobj, stuff->syncobj,
|
||||
dri3_syncobj_type, client, DixWriteAccess);
|
||||
if (status != Success)
|
||||
|
@ -685,178 +715,3 @@ proc_dri3_dispatch(ClientPtr client)
|
|||
return BadRequest;
|
||||
}
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_query_version(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3QueryVersionReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3QueryVersionReq);
|
||||
swapl(&stuff->majorVersion);
|
||||
swapl(&stuff->minorVersion);
|
||||
return proc_dri3_query_version(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_open(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3OpenReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3OpenReq);
|
||||
swapl(&stuff->drawable);
|
||||
swapl(&stuff->provider);
|
||||
return proc_dri3_open(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_pixmap_from_buffer(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3PixmapFromBufferReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3PixmapFromBufferReq);
|
||||
swapl(&stuff->pixmap);
|
||||
swapl(&stuff->drawable);
|
||||
swapl(&stuff->size);
|
||||
swaps(&stuff->width);
|
||||
swaps(&stuff->height);
|
||||
swaps(&stuff->stride);
|
||||
return proc_dri3_pixmap_from_buffer(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_buffer_from_pixmap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3BufferFromPixmapReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3BufferFromPixmapReq);
|
||||
swapl(&stuff->pixmap);
|
||||
return proc_dri3_buffer_from_pixmap(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_fence_from_fd(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3FenceFromFDReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3FenceFromFDReq);
|
||||
swapl(&stuff->drawable);
|
||||
swapl(&stuff->fence);
|
||||
return proc_dri3_fence_from_fd(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_fd_from_fence(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3FDFromFenceReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3FDFromFenceReq);
|
||||
swapl(&stuff->drawable);
|
||||
swapl(&stuff->fence);
|
||||
return proc_dri3_fd_from_fence(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_get_supported_modifiers(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3GetSupportedModifiersReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3GetSupportedModifiersReq);
|
||||
swapl(&stuff->window);
|
||||
return proc_dri3_get_supported_modifiers(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_pixmap_from_buffers(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3PixmapFromBuffersReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3PixmapFromBuffersReq);
|
||||
swapl(&stuff->pixmap);
|
||||
swapl(&stuff->window);
|
||||
swaps(&stuff->width);
|
||||
swaps(&stuff->height);
|
||||
swapl(&stuff->stride0);
|
||||
swapl(&stuff->offset0);
|
||||
swapl(&stuff->stride1);
|
||||
swapl(&stuff->offset1);
|
||||
swapl(&stuff->stride2);
|
||||
swapl(&stuff->offset2);
|
||||
swapl(&stuff->stride3);
|
||||
swapl(&stuff->offset3);
|
||||
swapll(&stuff->modifier);
|
||||
return proc_dri3_pixmap_from_buffers(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_buffers_from_pixmap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3BuffersFromPixmapReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3BuffersFromPixmapReq);
|
||||
swapl(&stuff->pixmap);
|
||||
return proc_dri3_buffers_from_pixmap(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_set_drm_device_in_use(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3SetDRMDeviceInUseReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3SetDRMDeviceInUseReq);
|
||||
swapl(&stuff->window);
|
||||
swapl(&stuff->drmMajor);
|
||||
swapl(&stuff->drmMinor);
|
||||
return proc_dri3_set_drm_device_in_use(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_import_syncobj(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3ImportSyncobjReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3ImportSyncobjReq);
|
||||
swapl(&stuff->syncobj);
|
||||
swapl(&stuff->drawable);
|
||||
return proc_dri3_import_syncobj(client);
|
||||
}
|
||||
|
||||
static int _X_COLD
|
||||
sproc_dri3_free_syncobj(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3FreeSyncobjReq);
|
||||
REQUEST_SIZE_MATCH(xDRI3FreeSyncobjReq);
|
||||
swapl(&stuff->syncobj);
|
||||
return proc_dri3_free_syncobj(client);
|
||||
}
|
||||
|
||||
int _X_COLD
|
||||
sproc_dri3_dispatch(ClientPtr client)
|
||||
{
|
||||
REQUEST(xReq);
|
||||
if (!client->local)
|
||||
return BadMatch;
|
||||
|
||||
switch (stuff->data) {
|
||||
case X_DRI3QueryVersion:
|
||||
return sproc_dri3_query_version(client);
|
||||
case X_DRI3Open:
|
||||
return sproc_dri3_open(client);
|
||||
case X_DRI3PixmapFromBuffer:
|
||||
return sproc_dri3_pixmap_from_buffer(client);
|
||||
case X_DRI3BufferFromPixmap:
|
||||
return sproc_dri3_buffer_from_pixmap(client);
|
||||
case X_DRI3FenceFromFD:
|
||||
return sproc_dri3_fence_from_fd(client);
|
||||
case X_DRI3FDFromFence:
|
||||
return sproc_dri3_fd_from_fence(client);
|
||||
|
||||
/* v1.2 */
|
||||
case xDRI3GetSupportedModifiers:
|
||||
return sproc_dri3_get_supported_modifiers(client);
|
||||
case xDRI3PixmapFromBuffers:
|
||||
return sproc_dri3_pixmap_from_buffers(client);
|
||||
case xDRI3BuffersFromPixmap:
|
||||
return sproc_dri3_buffers_from_pixmap(client);
|
||||
|
||||
/* v1.3 */
|
||||
case xDRI3SetDRMDeviceInUse:
|
||||
return sproc_dri3_set_drm_device_in_use(client);
|
||||
|
||||
/* v1.4 */
|
||||
case xDRI3ImportSyncobj:
|
||||
return sproc_dri3_import_syncobj(client);
|
||||
case xDRI3FreeSyncobj:
|
||||
return sproc_dri3_free_syncobj(client);
|
||||
default:
|
||||
return BadRequest;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue