Module: Mesa
Branch: master
Commit: 259fc154f1fdcabbc0a6c02c524962b063f9dee6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=259fc154f1fdcabbc0a6c02c524962b063f9dee6
Author: Kristian Høgsberg
Date: Sun Oct 21 13:00:28 2012 -0400
gbm: Use the kms dumb ioctls for cursor instead of libkms
We need to create bos suitable for cursor usage that we can map and
write data into. The kms dumb ioctls is all we need for this, so drop
the dependency on libkms.
---
configure.ac |2 -
src/gbm/backends/dri/gbm_dri.c| 117 +++-
src/gbm/backends/dri/gbm_driint.h |8 +--
3 files changed, 77 insertions(+), 50 deletions(-)
diff --git a/configure.ac b/configure.ac
index ca24856..9439291 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1222,8 +1222,6 @@ if test "x$enable_gbm" = xyes; then
if test "x$enable_shared_glapi" = xno; then
AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi])
fi
-PKG_CHECK_MODULES([LIBKMS], [libkms], [],
- AC_MSG_ERROR([gbm needs libkms]))
fi
fi
GBM_PC_REQ_PRIV="libudev"
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 70ea668..519929e 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -33,8 +33,10 @@
#include
#include
+#include
#include
#include
+#include
#include /* dri_interface needs GL types */
#include
@@ -300,19 +302,12 @@ static int
gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, size_t count)
{
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
- void *ptr;
- int ret;
-
- if (bo->bo == NULL)
- return -1;
- ret = kms_bo_map(bo->bo, &ptr);
- if (ret < 0)
+ if (bo->image != NULL)
return -1;
- memcpy(ptr, buf, count);
+ memcpy(bo->map, buf, count);
- kms_bo_unmap(bo->bo);
return 0;
}
@@ -321,11 +316,17 @@ gbm_dri_bo_destroy(struct gbm_bo *_bo)
{
struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
+ struct drm_mode_destroy_dumb arg;
- if (bo->image != NULL)
+ if (bo->image != NULL) {
dri->image->destroyImage(bo->image);
- if (bo->bo != NULL)
- kms_bo_destroy(&bo->bo);
+ } else {
+ munmap(bo->map, bo->size);
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = bo->handle;
+ drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
+ }
+
free(bo);
}
@@ -448,49 +449,86 @@ gbm_dri_bo_import(struct gbm_device *gbm,
}
static struct gbm_bo *
-gbm_dri_bo_create(struct gbm_device *gbm,
+create_dumb(struct gbm_device *gbm,
uint32_t width, uint32_t height,
uint32_t format, uint32_t usage)
{
struct gbm_dri_device *dri = gbm_dri_device(gbm);
+ struct drm_mode_create_dumb create_arg;
+ struct drm_mode_map_dumb map_arg;
struct gbm_dri_bo *bo;
- int dri_format;
- unsigned dri_use = 0;
+ struct drm_mode_destroy_dumb destroy_arg;
+ int ret;
+
+ if (!(usage & GBM_BO_USE_CURSOR_64X64))
+ return NULL;
+ if (format != GBM_FORMAT_ARGB)
+ return NULL;
bo = calloc(1, sizeof *bo);
if (bo == NULL)
return NULL;
+ create_arg.bpp = 32;
+ create_arg.width = width;
+ create_arg.height = height;
+
+ ret = drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_arg);
+ if (ret)
+ goto free_bo;
+
bo->base.base.gbm = gbm;
bo->base.base.width = width;
bo->base.base.height = height;
+ bo->base.base.stride = create_arg.pitch;
+ bo->base.base.handle.u32 = create_arg.handle;
+ bo->handle = create_arg.handle;
+ bo->size = create_arg.size;
- if (usage & GBM_BO_USE_WRITE) {
- int ret;
- unsigned attrs[7] = {
- KMS_WIDTH, 64,
- KMS_HEIGHT, 64,
- KMS_BO_TYPE, KMS_BO_TYPE_SCANOUT_X8R8G8B8,
- KMS_TERMINATE_PROP_LIST,
- };
+ memset(&map_arg, 0, sizeof(map_arg));
+ map_arg.handle = bo->handle;
- if (!(usage & GBM_BO_USE_CURSOR_64X64))
- return NULL;
+ ret = drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_MAP_DUMB, &map_arg);
+ if (ret)
+ goto destroy_dumb;
- if (dri->kms == NULL)
- return NULL;
+ bo->map = mmap(0, bo->size, PROT_WRITE,
+ MAP_SHARED, dri->base.base.fd, map_arg.offset);
+ if (bo->map == MAP_FAILED)
+ goto destroy_dumb;
- ret = kms_bo_create(dri->kms, attrs, &bo->bo);
- if (ret < 0) {
- free(bo);
- return NULL;
- }
+ return &bo->base.base;
+
+destroy_dumb:
+ memset(&destroy_arg, 0, sizeof destroy_arg);
+ destroy_arg.handle = create_arg.handle;
+ drmIoctl(dri->base.base.fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg);
+free_bo:
+ free(bo);
- kms_bo_get_prop(bo->bo, KMS_PITCH, &bo->base.base.stride);
- kms_bo_get_prop(bo->bo, KMS_HANDLE, (unsigned*)&bo->base.base.handle);
+ return NULL;
+}
- return &bo->base.base;
- }
+static struct