libkms: Add libkms

main
Jakob Bornecrantz 2009-11-24 17:54:10 +01:00
parent 28eae30689
commit 8c0571a733
10 changed files with 973 additions and 1 deletions

1
.gitignore vendored
View File

@ -42,6 +42,7 @@ libdrm.pc
libdrm_intel.pc
libdrm_nouveau.pc
libdrm_radeon.pc
libkms.pc
libtool
ltmain.sh
mach64.kld

View File

@ -25,6 +25,10 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-nouveau-experimental-api --enable-radeon-ex
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libdrm.pc
if HAVE_LIBKMS
LIBKMS_SUBDIR = libkms
endif
if HAVE_INTEL
INTEL_SUBDIR = intel
endif
@ -37,7 +41,7 @@ if HAVE_RADEON
RADEON_SUBDIR = radeon
endif
SUBDIRS = . $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) $(RADEON_SUBDIR) tests include
SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) $(RADEON_SUBDIR) tests include
libdrm_la_LTLIBRARIES = libdrm.la
libdrm_ladir = $(libdir)

View File

@ -43,6 +43,11 @@ AC_ARG_ENABLE(udev, AS_HELP_STRING([--enable-udev],
[Enable support for using udev instead of mknod (default: disabled)]),
[UDEV=$enableval], [UDEV=no])
AC_ARG_ENABLE(libkms,
AS_HELP_STRING([--disable-libkms],
[Enable KMS mm abstraction library (default: yes)]),
[LIBKMS=$enableval], [LIBKMS=yes])
AC_ARG_ENABLE(intel,
AS_HELP_STRING([--disable-intel],
[Enable support for intel's KMS API (default: auto)]),
@ -134,6 +139,8 @@ if test "x$UDEV" = xyes; then
AC_DEFINE(UDEV, 1, [Have UDEV support])
fi
AM_CONDITIONAL(HAVE_LIBKMS, [test "x$LIBKMS" = xyes])
AM_CONDITIONAL(HAVE_NOUVEAU, [test "x$NOUVEAU" = xyes])
AM_CONDITIONAL(HAVE_RADEON, [test "x$RADEON" = xyes])
@ -199,6 +206,8 @@ AC_SUBST(kernel_source)
AC_SUBST(WARN_CFLAGS)
AC_OUTPUT([
Makefile
libkms/Makefile
libkms/libkms.pc
intel/Makefile
intel/libdrm_intel.pc
radeon/Makefile
@ -215,6 +224,7 @@ AC_OUTPUT([
echo ""
echo "$PACKAGE_STRING will be compiled with:"
echo ""
echo " libkms $LIBKMS"
echo " Intel API $INTEL"
echo " Radeon API $RADEON"
echo " Nouveau API $NOUVEAU"

20
libkms/Makefile.am Normal file
View File

@ -0,0 +1,20 @@
AM_CFLAGS = \
$(WARN_CFLAGS) \
-I$(top_srcdir)/include/drm
libkms_la_LTLIBRARIES = libkms.la
libkms_ladir = $(libdir)
libkms_la_LDFLAGS = -version-number 1:0:0 -no-undefined
libkms_la_LIBADD =
libkms_la_SOURCES = \
api.c \
vmwgfx.c
libkmsincludedir = ${includedir}/libkms
libkmsinclude_HEADERS = libkms.h
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libkms.pc
EXTRA_DIST = libkms.pc.in

124
libkms/api.c Normal file
View File

@ -0,0 +1,124 @@
/**************************************************************************
*
* Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "internal.h"
int kms_create(int fd, struct kms_driver **out)
{
return vmwgfx_create(fd, out);
}
int kms_get_prop(struct kms_driver *kms, unsigned key, unsigned *out)
{
switch (key) {
case KMS_MAX_SCANOUT_WIDTH:
case KMS_MAX_SCANOUT_HEIGHT:
case KMS_MIN_SCANOUT_WIDTH:
case KMS_MIN_SCANOUT_HEIGHT:
case KMS_MAX_CURSOR_WIDTH:
case KMS_MAX_CURSOR_HEIGHT:
case KMS_MIN_CURSOR_WIDTH:
case KMS_MIN_CURSOR_HEIGHT:
break;
default:
return -EINVAL;
}
return kms->get_prop(kms, key, out);
}
int kms_destroy(struct kms_driver *kms)
{
free(kms);
return 0;
}
int kms_bo_create(struct kms_driver *kms, const unsigned *attr, struct kms_bo **out)
{
unsigned width = 0;
unsigned height = 0;
enum kms_bo_type type = KMS_BO_TYPE_SCANOUT;
int i;
for (i = 0; attr[i];) {
unsigned key = attr[i++];
unsigned value = attr[i++];
switch (key) {
case KMS_WIDTH:
width = value;
break;
case KMS_HEIGHT:
height = value;
break;
case KMS_BO_TYPE:
type = value;
break;
default:
return EINVAL;
}
}
if (width == 0 || height == 0)
return -EINVAL;
return kms->bo_create(kms, width, height, type, attr, out);
}
int kms_bo_get_prop(struct kms_bo *bo, unsigned key, unsigned *out)
{
switch (key) {
case KMS_PITCH:
*out = bo->pitch;
break;
case KMS_HANDLE:
*out = bo->handle;
break;
default:
return -EINVAL;
}
return 0;
}
int kms_bo_map(struct kms_bo *bo, void **out)
{
return bo->kms->bo_map(bo, out);
}
int kms_bo_unmap(struct kms_bo *bo)
{
return bo->kms->bo_unmap(bo);
}
int kms_bo_destroy(struct kms_bo *bo)
{
return bo->kms->bo_destroy(bo);
}

67
libkms/internal.h Normal file
View File

@ -0,0 +1,67 @@
/**************************************************************************
*
* Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef INTERNAL_H_
#define INTERNAL_H_
#include "libkms.h"
struct kms_driver
{
int (*get_prop)(struct kms_driver *kms, const unsigned key,
unsigned *out);
int (*destroy)(struct kms_driver *kms);
int (*bo_create)(struct kms_driver *kms,
unsigned width,
unsigned height,
enum kms_bo_type type,
const unsigned *attr,
struct kms_bo **out);
int (*bo_get_prop)(struct kms_bo *bo, const unsigned key,
unsigned *out);
int (*bo_map)(struct kms_bo *bo, void **out);
int (*bo_unmap)(struct kms_bo *bo);
int (*bo_destroy)(struct kms_bo *bo);
int fd;
};
struct kms_bo
{
struct kms_driver *kms;
void *ptr;
size_t size;
size_t offset;
size_t pitch;
unsigned handle;
};
int vmwgfx_create(int fd, struct kms_driver **out);
#endif

69
libkms/libkms.h Normal file
View File

@ -0,0 +1,69 @@
/**************************************************************************
*
* Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef _LIBKMS_H_
#define _LIBKMS_H_
struct kms_driver;
struct kms_bo;
enum kms_attrib
{
KMS_TERMINATE_PROP_LIST,
KMS_BO_TYPE,
KMS_WIDTH,
KMS_HEIGHT,
KMS_PITCH,
KMS_HANDLE,
KMS_MAX_SCANOUT_WIDTH,
KMS_MAX_SCANOUT_HEIGHT,
KMS_MIN_SCANOUT_WIDTH,
KMS_MIN_SCANOUT_HEIGHT,
KMS_MAX_CURSOR_WIDTH,
KMS_MAX_CURSOR_HEIGHT,
KMS_MIN_CURSOR_WIDTH,
KMS_MIN_CURSOR_HEIGHT,
};
enum kms_bo_type
{
KMS_BO_TYPE_SCANOUT = (1 << 0),
KMS_BO_TYPE_CURSOR = (1 << 1),
};
int kms_create(int fd, struct kms_driver **out);
int kms_get_prop(struct kms_driver *kms, unsigned key, unsigned *out);
int kms_destroy(struct kms_driver *kms);
int kms_bo_create(struct kms_driver *kms, const unsigned *attr, struct kms_bo **out);
int kms_bo_get_prop(struct kms_bo *bo, unsigned key, unsigned *out);
int kms_bo_map(struct kms_bo *bo, void **out);
int kms_bo_unmap(struct kms_bo *bo);
int kms_bo_destroy(struct kms_bo *bo);
#endif

10
libkms/libkms.pc.in Normal file
View File

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libkms
Description: Library that abstract aways the different mm interface for kernel drivers
Version: 1.0
Libs: -L${libdir} -lkms
Cflags: -I${includedir}/libkms

226
libkms/vmwgfx.c Normal file
View File

@ -0,0 +1,226 @@
/**************************************************************************
*
* Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#define HAVE_STDINT_H
#define _FILE_OFFSET_BITS 64
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "internal.h"
#include <sys/mman.h>
#include "xf86drm.h"
#include "vmwgfx_drm.h"
struct vmwgfx_bo
{
struct kms_bo base;
uint64_t map_handle;
unsigned map_count;
};
static int
vmwgfx_get_prop(struct kms_driver *kms, unsigned key, unsigned *out)
{
switch (key) {
case KMS_MAX_SCANOUT_WIDTH:
*out = 2048;
break;
case KMS_MAX_SCANOUT_HEIGHT:
*out = 2048;
break;
case KMS_MIN_SCANOUT_WIDTH:
*out = 1;
break;
case KMS_MIN_SCANOUT_HEIGHT:
*out = 1;
break;
case KMS_MAX_CURSOR_WIDTH:
*out = 64;
break;
case KMS_MAX_CURSOR_HEIGHT:
*out = 64;
break;
case KMS_MIN_CURSOR_WIDTH:
*out = 64;
break;
case KMS_MIN_CURSOR_HEIGHT:
*out = 64;
break;
default:
return -EINVAL;
}
return 0;
}
static int
vmwgfx_destroy(struct kms_driver *kms)
{
free(kms);
return 0;
}
static int
vmwgfx_bo_create(struct kms_driver *kms,
const unsigned width, const unsigned height,
const enum kms_bo_type type, const unsigned *attr,
struct kms_bo **out)
{
struct vmwgfx_bo *bo;
int i, ret;
for (i = 0; attr[i]; i += 2) {
switch (attr[i]) {
case KMS_WIDTH:
case KMS_HEIGHT:
case KMS_BO_TYPE:
break;
default:
return EINVAL;
}
}
bo = calloc(1, sizeof(*bo));
if (!bo)
return -EINVAL;
{
union drm_vmw_alloc_dmabuf_arg arg;
struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
struct drm_vmw_dmabuf_rep *rep = &arg.rep;
memset(&arg, 0, sizeof(arg));
req->size = width * height * 4;
bo->base.size = req->size;
bo->base.pitch = width * 4;
bo->base.kms = kms;
do {
ret = drmCommandWriteRead(bo->base.kms->fd,
DRM_VMW_ALLOC_DMABUF,
&arg, sizeof(arg));
} while (ret == -ERESTART);
if (ret)
goto err_free;
bo->base.handle = rep->handle;
bo->map_handle = rep->map_handle;
bo->base.handle = rep->cur_gmr_id;
bo->base.offset = rep->cur_gmr_offset;
}
*out = &bo->base;
return 0;
err_free:
free(bo);
return ret;
}
static int
vmwgfx_bo_get_prop(struct kms_bo *bo, unsigned key, unsigned *out)
{
switch (key) {
default:
return -EINVAL;
}
}
static int
vmwgfx_bo_map(struct kms_bo *_bo, void **out)
{
struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo;
void *map;
if (!bo->map_count) {
map = mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE,
MAP_SHARED, bo->base.kms->fd, bo->map_handle);
if (!map)
return -ENOMEM;
bo->base.ptr = map;
}
bo->map_count++;
*out = bo->base.ptr;
return 0;
}
static int
vmwgfx_bo_unmap(struct kms_bo *_bo)
{
struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo;
bo->map_count--;
return 0;
}
static int
vmwgfx_bo_destroy(struct kms_bo *_bo)
{
struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo;
struct drm_vmw_unref_dmabuf_arg arg;
if (bo->map_count) {
munmap(bo->base.ptr, bo->base.size);
bo->base.ptr = NULL;
}
memset(&arg, 0, sizeof(arg));
arg.handle = bo->base.handle;
drmCommandWrite(bo->base.kms->fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
free(bo);
return 0;
}
int
vmwgfx_create(int fd, struct kms_driver **out)
{
struct kms_driver *kms;
kms = calloc(1, sizeof(*kms));
if (!kms)
return -ENOMEM;
kms->fd = fd;
kms->bo_create = vmwgfx_bo_create;
kms->bo_map = vmwgfx_bo_map;
kms->bo_unmap = vmwgfx_bo_unmap;
kms->bo_get_prop = vmwgfx_bo_get_prop;
kms->bo_destroy = vmwgfx_bo_destroy;
kms->get_prop = vmwgfx_get_prop;
kms->destroy = vmwgfx_destroy;
*out = kms;
return 0;
}

441
libkms/vmwgfx_drm.h Normal file
View File

@ -0,0 +1,441 @@
/**************************************************************************
*
* Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef _VMWGFX_DRM_H_
#define _VMWGFX_DRM_H_
#define DRM_VMW_MAX_SURFACE_FACES 6
#define DRM_VMW_MAX_MIP_LEVELS 24
#define DRM_VMW_EXT_NAME_LEN 128
#define DRM_VMW_GET_PARAM 1
#define DRM_VMW_EXTENSION 2
#define DRM_VMW_CREATE_CONTEXT 3
#define DRM_VMW_UNREF_CONTEXT 4
#define DRM_VMW_CREATE_SURFACE 5
#define DRM_VMW_UNREF_SURFACE 6
#define DRM_VMW_REF_SURFACE 7
#define DRM_VMW_EXECBUF 8
#define DRM_VMW_ALLOC_DMABUF 9
#define DRM_VMW_UNREF_DMABUF 10
#define DRM_VMW_FIFO_DEBUG 11
#define DRM_VMW_FENCE_WAIT 12
/*************************************************************************/
/**
* DRM_VMW_GET_PARAM - get device information.
*
* Currently we support only one parameter:
*
* DRM_VMW_PARAM_FIFO_OFFSET:
* Offset to use to map the first page of the FIFO read-only.
* The fifo is mapped using the mmap() system call on the drm device.
*/
#define DRM_VMW_PARAM_FIFO_OFFSET 0
/**
* struct drm_vmw_getparam_arg
*
* @value: Returned value. //Out
* @param: Parameter to query. //In.
*
* Argument to the DRM_VMW_GET_PARAM Ioctl.
*/
struct drm_vmw_getparam_arg {
uint64_t value;
uint32_t param;
uint32_t pad64;
};
/*************************************************************************/
/**
* DRM_VMW_EXTENSION - Query device extensions.
*/
/**
* struct drm_vmw_extension_rep
*
* @exists: The queried extension exists.
* @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
* @driver_sarea_offset: Offset to any space in the DRI SAREA
* used by the extension.
* @major: Major version number of the extension.
* @minor: Minor version number of the extension.
* @pl: Patch level version number of the extension.
*
* Output argument to the DRM_VMW_EXTENSION Ioctl.
*/
struct drm_vmw_extension_rep {
int32_t exists;
uint32_t driver_ioctl_offset;
uint32_t driver_sarea_offset;
uint32_t major;
uint32_t minor;
uint32_t pl;
uint32_t pad64;
};
/**
* union drm_vmw_extension_arg
*
* @extension - Ascii name of the extension to be queried. //In
* @rep - Reply as defined above. //Out
*
* Argument to the DRM_VMW_EXTENSION Ioctl.
*/
union drm_vmw_extension_arg {
char extension[DRM_VMW_EXT_NAME_LEN];
struct drm_vmw_extension_rep rep;
};
/*************************************************************************/
/**
* DRM_VMW_CREATE_CONTEXT - Create a host context.
*
* Allocates a device unique context id, and queues a create context command
* for the host. Does not wait for host completion.
*/
/**
* struct drm_vmw_context_arg
*
* @cid: Device unique context ID.
*
* Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
* Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
*/
struct drm_vmw_context_arg {
int32_t cid;
uint32_t pad64;
};
/*************************************************************************/
/**
* DRM_VMW_UNREF_CONTEXT - Create a host context.
*
* Frees a global context id, and queues a destroy host command for the host.
* Does not wait for host completion. The context ID can be used directly
* in the command stream and shows up as the same context ID on the host.
*/
/*************************************************************************/
/**
* DRM_VMW_CREATE_SURFACE - Create a host suface.
*
* Allocates a device unique surface id, and queues a create surface command
* for the host. Does not wait for host completion. The surface ID can be
* used directly in the command stream and shows up as the same surface
* ID on the host.
*/
/**
* struct drm_wmv_surface_create_req
*
* @flags: Surface flags as understood by the host.
* @format: Surface format as understood by the host.
* @mip_levels: Number of mip levels for each face.
* An unused face should have 0 encoded.
* @size_addr: Address of a user-space array of sruct drm_vmw_size
* cast to an uint64_t for 32-64 bit compatibility.
* The size of the array should equal the total number of mipmap levels.
* @shareable: Boolean whether other clients (as identified by file descriptors)
* may reference this surface.
*
* Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
* Output data from the DRM_VMW_REF_SURFACE Ioctl.
*/
struct drm_vmw_surface_create_req {
uint32_t flags;
uint32_t format;
uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
uint64_t size_addr;
int32_t shareable;
uint32_t pad64;
};
/**
* struct drm_wmv_surface_arg
*
* @sid: Surface id of created surface or surface to destroy or reference.
*
* Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
* Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
* Input argument to the DRM_VMW_REF_SURFACE Ioctl.
*/
struct drm_vmw_surface_arg {
int32_t sid;
uint32_t pad64;
};
/**
* struct drm_vmw_size ioctl.
*
* @width - mip level width
* @height - mip level height
* @depth - mip level depth
*
* Description of a mip level.
* Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
*/
struct drm_vmw_size {
uint32_t width;
uint32_t height;
uint32_t depth;
uint32_t pad64;
};
/**
* union drm_vmw_surface_create_arg
*
* @rep: Output data as described above.
* @req: Input data as described above.
*
* Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
*/
union drm_vmw_surface_create_arg {
struct drm_vmw_surface_arg rep;
struct drm_vmw_surface_create_req req;
};
/*************************************************************************/
/**
* DRM_VMW_REF_SURFACE - Reference a host surface.
*
* Puts a reference on a host surface with a give sid, as previously
* returned by the DRM_VMW_CREATE_SURFACE ioctl.
* A reference will make sure the surface isn't destroyed while we hold
* it and will allow the calling client to use the surface ID in the command
* stream.
*
* On successful return, the Ioctl returns the surface information given
* in the DRM_VMW_CREATE_SURFACE ioctl.
*/
/**
* union drm_vmw_surface_reference_arg
*
* @rep: Output data as described above.
* @req: Input data as described above.
*
* Argument to the DRM_VMW_REF_SURFACE Ioctl.
*/
union drm_vmw_surface_reference_arg {
struct drm_vmw_surface_create_req rep;
struct drm_vmw_surface_arg req;
};
/*************************************************************************/
/**
* DRM_VMW_UNREF_SURFACE - Unreference a host surface.
*
* Clear a reference previously put on a host surface.
* When all references are gone, including the one implicitly placed
* on creation,
* a destroy surface command will be queued for the host.
* Does not wait for completion.
*/
/*************************************************************************/
/**
* DRM_VMW_EXECBUF
*
* Submit a command buffer for execution on the host, and return a
* fence sequence that when signaled, indicates that the command buffer has
* executed.
*/
/**
* struct drm_vmw_execbuf_arg
*
* @commands: User-space address of a command buffer cast to an uint64_t.
* @command-size: Size in bytes of the command buffer.
* @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
* uint64_t.
*
* Argument to the DRM_VMW_EXECBUF Ioctl.
*/
struct drm_vmw_execbuf_arg {
uint64_t commands;
uint32_t command_size;
uint32_t pad64;
uint64_t fence_rep;
};
/**
* struct drm_vmw_fence_rep
*
* @fence_seq: Fence sequence associated with a command submission.
* @error: This member should've been set to -EFAULT on submission.
* The following actions should be take on completion:
* error == -EFAULT: Fence communication failed. The host is synchronized.
* Use the last fence id read from the FIFO fence register.
* error != 0 && error != -EFAULT:
* Fence submission failed. The host is synchronized. Use the fence_seq member.
* error == 0: All is OK, The host may not be synchronized.
* Use the fence_seq member.
*
* Input / Output data to the DRM_VMW_EXECBUF Ioctl.
*/
struct drm_vmw_fence_rep {
uint64_t fence_seq;
int32_t error;
uint32_t pad64;
};
/*************************************************************************/
/**
* DRM_VMW_ALLOC_DMABUF
*
* Allocate a DMA buffer that is visible also to the host.
* NOTE: The buffer is
* identified by a handle and an offset, which are private to the guest, but
* useable in the command stream. The guest kernel may translate these
* and patch up the command stream accordingly. In the future, the offset may
* be zero at all times, or it may disappear from the interface before it is
* fixed.
*
* The DMA buffer may stay user-space mapped in the guest at all times,
* and is thus suitable for sub-allocation.
*
* DMA buffers are mapped using the mmap() syscall on the drm device.
*/
/**
* struct drm_vmw_alloc_dmabuf_req
*
* @size: Required minimum size of the buffer.
*
* Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
*/
struct drm_vmw_alloc_dmabuf_req {
uint32_t size;
uint32_t pad64;
};
/**
* struct drm_vmw_dmabuf_rep
*
* @map_handle: Offset to use in the mmap() call used to map the buffer.
* @handle: Handle unique to this buffer. Used for unreferencing.
* @cur_gmr_id: GMR id to use in the command stream when this buffer is
* referenced. See not above.
* @cur_gmr_offset: Offset to use in the command stream when this buffer is
* referenced. See note above.
*
* Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
*/
struct drm_vmw_dmabuf_rep {
uint64_t map_handle;
uint32_t handle;
uint32_t cur_gmr_id;
uint32_t cur_gmr_offset;
uint32_t pad64;
};
/**
* union drm_vmw_dmabuf_arg
*
* @req: Input data as described above.
* @rep: Output data as described above.
*
* Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
*/
union drm_vmw_alloc_dmabuf_arg {
struct drm_vmw_alloc_dmabuf_req req;
struct drm_vmw_dmabuf_rep rep;
};
/*************************************************************************/
/**
* DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
*
*/
/**
* struct drm_vmw_unref_dmabuf_arg
*
* @handle: Handle indicating what buffer to free. Obtained from the
* DRM_VMW_ALLOC_DMABUF Ioctl.
*
* Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
*/
struct drm_vmw_unref_dmabuf_arg {
uint32_t handle;
uint32_t pad64;
};
/*************************************************************************/
/**
* DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
*
* This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
*/
/**
* struct drm_vmw_fifo_debug_arg
*
* @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
* @debug_buffer_size: Size in bytes of debug buffer //In
* @used_size: Number of bytes copied to the buffer // Out
* @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
*
* Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
*/
struct drm_vmw_fifo_debug_arg {
uint64_t debug_buffer;
uint32_t debug_buffer_size;
uint32_t used_size;
int32_t did_not_fit;
uint32_t pad64;
};
struct drm_vmw_fence_wait_arg {
uint64_t sequence;
uint64_t kernel_cookie;
int32_t cookie_valid;
int32_t pad64;
};
#endif