summaryrefslogtreecommitdiff
path: root/meta-moblin
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-02-05 14:05:03 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2009-02-05 14:05:03 +0000
commitcc01c77c99811094c6dbdaddfaf9fe4445d8afb8 (patch)
tree5cea7dfcfa9165253a0a67dd57f96fde3003f4df /meta-moblin
parente5f1566660f4434ac26c9fb056b6ec7a7d68bff8 (diff)
downloadopenembedded-core-cc01c77c99811094c6dbdaddfaf9fe4445d8afb8.tar.gz
openembedded-core-cc01c77c99811094c6dbdaddfaf9fe4445d8afb8.tar.bz2
openembedded-core-cc01c77c99811094c6dbdaddfaf9fe4445d8afb8.zip
meta-moblin: Drop now uneeded libdrm-psb
Diffstat (limited to 'meta-moblin')
-rw-r--r--meta-moblin/packages/drm/files/poulsbo.patch4050
-rw-r--r--meta-moblin/packages/drm/libdrm-psb_2.3.1.bb17
2 files changed, 0 insertions, 4067 deletions
diff --git a/meta-moblin/packages/drm/files/poulsbo.patch b/meta-moblin/packages/drm/files/poulsbo.patch
deleted file mode 100644
index 13a16bfd74..0000000000
--- a/meta-moblin/packages/drm/files/poulsbo.patch
+++ /dev/null
@@ -1,4050 +0,0 @@
-Index: libdrm-2.3.1/configure.ac
-===================================================================
---- libdrm-2.3.1.orig/configure.ac 2008-07-01 08:50:43.000000000 +0100
-+++ libdrm-2.3.1/configure.ac 2009-01-14 18:26:59.000000000 +0000
-@@ -39,5 +39,4 @@
- Makefile
- libdrm/Makefile
- shared-core/Makefile
-- tests/Makefile
- libdrm.pc])
-Index: libdrm-2.3.1/libdrm/Makefile.am
-===================================================================
---- libdrm-2.3.1.orig/libdrm/Makefile.am 2008-07-01 08:51:40.000000000 +0100
-+++ libdrm-2.3.1/libdrm/Makefile.am 2009-01-14 18:26:59.000000000 +0000
-@@ -23,10 +23,9 @@
- libdrm_la_LDFLAGS = -version-number 2:3:1 -no-undefined
-
- AM_CFLAGS = -I$(top_srcdir)/shared-core
--libdrm_la_SOURCES = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c
-+libdrm_la_SOURCES = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmMode.c
-
- libdrmincludedir = ${includedir}
--
--libdrminclude_HEADERS = xf86drm.h
-+libdrminclude_HEADERS = xf86drm.h xf86mm.h xf86drmMode.h
-
- EXTRA_DIST = ChangeLog TODO
-Index: libdrm-2.3.1/libdrm/xf86drm.c
-===================================================================
---- libdrm-2.3.1.orig/libdrm/xf86drm.c 2008-07-01 08:51:40.000000000 +0100
-+++ libdrm-2.3.1/libdrm/xf86drm.c 2009-01-14 18:26:59.000000000 +0000
-@@ -2337,6 +2337,569 @@
- return 0;
- }
-
-+
-+/*
-+ * Valid flags are
-+ * DRM_FENCE_FLAG_EMIT
-+ * DRM_FENCE_FLAG_SHAREABLE
-+ * DRM_FENCE_MASK_DRIVER
-+ */
-+
-+int drmFenceCreate(int fd, unsigned flags, int fence_class, unsigned type,
-+ drmFence *fence)
-+{
-+ drm_fence_arg_t arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.flags = flags;
-+ arg.type = type;
-+ arg.fence_class = fence_class;
-+
-+ if (ioctl(fd, DRM_IOCTL_FENCE_CREATE, &arg))
-+ return -errno;
-+ fence->handle = arg.handle;
-+ fence->fence_class = arg.fence_class;
-+ fence->type = arg.type;
-+ fence->flags = arg.flags;
-+ fence->signaled = 0;
-+ return 0;
-+}
-+
-+/*
-+ * Valid flags are
-+ * DRM_FENCE_FLAG_SHAREABLE
-+ * DRM_FENCE_MASK_DRIVER
-+ */
-+
-+int drmFenceBuffers(int fd, unsigned flags, uint32_t fence_class, drmFence *fence)
-+{
-+ drm_fence_arg_t arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.flags = flags;
-+ arg.fence_class = fence_class;
-+
-+ if (ioctl(fd, DRM_IOCTL_FENCE_BUFFERS, &arg))
-+ return -errno;
-+ fence->handle = arg.handle;
-+ fence->fence_class = arg.fence_class;
-+ fence->type = arg.type;
-+ fence->flags = arg.flags;
-+ fence->sequence = arg.sequence;
-+ fence->signaled = 0;
-+ return 0;
-+}
-+
-+int drmFenceReference(int fd, unsigned handle, drmFence *fence)
-+{
-+ drm_fence_arg_t arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.handle = handle;
-+
-+ if (ioctl(fd, DRM_IOCTL_FENCE_REFERENCE, &arg))
-+ return -errno;
-+ fence->handle = arg.handle;
-+ fence->fence_class = arg.fence_class;
-+ fence->type = arg.type;
-+ fence->flags = arg.flags;
-+ fence->signaled = arg.signaled;
-+ return 0;
-+}
-+
-+int drmFenceUnreference(int fd, const drmFence *fence)
-+{
-+ drm_fence_arg_t arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.handle = fence->handle;
-+
-+ if (ioctl(fd, DRM_IOCTL_FENCE_UNREFERENCE, &arg))
-+ return -errno;
-+ return 0;
-+}
-+
-+int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type)
-+{
-+ drm_fence_arg_t arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.handle = fence->handle;
-+ arg.type = flush_type;
-+
-+ if (ioctl(fd, DRM_IOCTL_FENCE_FLUSH, &arg))
-+ return -errno;
-+ fence->fence_class = arg.fence_class;
-+ fence->type = arg.type;
-+ fence->signaled = arg.signaled;
-+ return arg.error;
-+}
-+
-+int drmFenceUpdate(int fd, drmFence *fence)
-+{
-+ drm_fence_arg_t arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.handle = fence->handle;
-+
-+ if (ioctl(fd, DRM_IOCTL_FENCE_SIGNALED, &arg))
-+ return -errno;
-+ fence->fence_class = arg.fence_class;
-+ fence->type = arg.type;
-+ fence->signaled = arg.signaled;
-+ return 0;
-+}
-+
-+int drmFenceSignaled(int fd, drmFence *fence, unsigned fenceType,
-+ int *signaled)
-+{
-+ if ((fence->flags & DRM_FENCE_FLAG_SHAREABLE) ||
-+ ((fenceType & fence->signaled) != fenceType)) {
-+ int ret = drmFenceFlush(fd, fence, fenceType);
-+ if (ret)
-+ return ret;
-+ }
-+
-+ *signaled = ((fenceType & fence->signaled) == fenceType);
-+
-+ return 0;
-+}
-+
-+/*
-+ * Valid flags are
-+ * DRM_FENCE_FLAG_SHAREABLE
-+ * DRM_FENCE_MASK_DRIVER
-+ */
-+
-+
-+int drmFenceEmit(int fd, unsigned flags, drmFence *fence, unsigned emit_type)
-+{
-+ drm_fence_arg_t arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.fence_class = fence->fence_class;
-+ arg.flags = flags;
-+ arg.handle = fence->handle;
-+ arg.type = emit_type;
-+
-+ if (ioctl(fd, DRM_IOCTL_FENCE_EMIT, &arg))
-+ return -errno;
-+ fence->fence_class = arg.fence_class;
-+ fence->type = arg.type;
-+ fence->signaled = arg.signaled;
-+ fence->sequence = arg.sequence;
-+ return 0;
-+}
-+
-+/*
-+ * Valid flags are
-+ * DRM_FENCE_FLAG_WAIT_LAZY
-+ * DRM_FENCE_FLAG_WAIT_IGNORE_SIGNALS
-+ */
-+
-+#define DRM_IOCTL_TIMEOUT_USEC 3000000UL
-+
-+static unsigned long
-+drmTimeDiff(struct timeval *now, struct timeval *then)
-+{
-+ uint64_t val;
-+
-+ val = now->tv_sec - then->tv_sec;
-+ val *= 1000000LL;
-+ val += now->tv_usec;
-+ val -= then->tv_usec;
-+
-+ return (unsigned long) val;
-+}
-+
-+static int
-+drmIoctlTimeout(int fd, unsigned long request, void *argp)
-+{
-+ int haveThen = 0;
-+ struct timeval then, now;
-+ int ret;
-+
-+ do {
-+ ret = ioctl(fd, request, argp);
-+ if (ret != 0 && errno == EAGAIN) {
-+ if (!haveThen) {
-+ gettimeofday(&then, NULL);
-+ haveThen = 1;
-+ }
-+ gettimeofday(&now, NULL);
-+ }
-+ } while (ret != 0 && errno == EAGAIN &&
-+ drmTimeDiff(&now, &then) < DRM_IOCTL_TIMEOUT_USEC);
-+
-+ if (ret != 0)
-+ return ((errno == EAGAIN) ? -EBUSY : -errno);
-+
-+ return 0;
-+}
-+
-+
-+
-+
-+int drmFenceWait(int fd, unsigned flags, drmFence *fence, unsigned flush_type)
-+{
-+ drm_fence_arg_t arg;
-+ int ret;
-+
-+ if (flush_type == 0) {
-+ flush_type = fence->type;
-+ }
-+
-+ if (!(fence->flags & DRM_FENCE_FLAG_SHAREABLE)) {
-+ if ((flush_type & fence->signaled) == flush_type) {
-+ return 0;
-+ }
-+ }
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.handle = fence->handle;
-+ arg.type = flush_type;
-+ arg.flags = flags;
-+
-+
-+ ret = drmIoctlTimeout(fd, DRM_IOCTL_FENCE_WAIT, &arg);
-+ if (ret)
-+ return ret;
-+
-+ fence->fence_class = arg.fence_class;
-+ fence->type = arg.type;
-+ fence->signaled = arg.signaled;
-+ return arg.error;
-+}
-+
-+static void drmBOCopyReply(const struct drm_bo_info_rep *rep, drmBO *buf)
-+{
-+ buf->handle = rep->handle;
-+ buf->flags = rep->flags;
-+ buf->size = rep->size;
-+ buf->offset = rep->offset;
-+ buf->mapHandle = rep->arg_handle;
-+ buf->mask = rep->mask;
-+ buf->start = rep->buffer_start;
-+ buf->fenceFlags = rep->fence_flags;
-+ buf->replyFlags = rep->rep_flags;
-+ buf->pageAlignment = rep->page_alignment;
-+ buf->tileInfo = rep->tile_info;
-+ buf->hwTileStride = rep->hw_tile_stride;
-+ buf->desiredTileStride = rep->desired_tile_stride;
-+}
-+
-+
-+
-+int drmBOCreate(int fd, unsigned long size,
-+ unsigned pageAlignment, void *user_buffer,
-+ uint64_t mask,
-+ unsigned hint, drmBO *buf)
-+{
-+ struct drm_bo_create_arg arg;
-+ struct drm_bo_create_req *req = &arg.d.req;
-+ struct drm_bo_info_rep *rep = &arg.d.rep;
-+ int ret;
-+
-+ memset(buf, 0, sizeof(*buf));
-+ memset(&arg, 0, sizeof(arg));
-+ req->mask = mask;
-+ req->hint = hint;
-+ req->size = size;
-+ req->page_alignment = pageAlignment;
-+ req->buffer_start = (unsigned long) user_buffer;
-+
-+ buf->virtual = NULL;
-+
-+ ret = drmIoctlTimeout(fd, DRM_IOCTL_BO_CREATE, &arg);
-+ if (ret)
-+ return ret;
-+
-+ drmBOCopyReply(rep, buf);
-+ buf->virtual = user_buffer;
-+ buf->mapCount = 0;
-+
-+ return 0;
-+}
-+
-+int drmBOReference(int fd, unsigned handle, drmBO *buf)
-+{
-+ struct drm_bo_reference_info_arg arg;
-+ struct drm_bo_handle_arg *req = &arg.d.req;
-+ struct drm_bo_info_rep *rep = &arg.d.rep;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ req->handle = handle;
-+
-+ if (ioctl(fd, DRM_IOCTL_BO_REFERENCE, &arg))
-+ return -errno;
-+
-+ drmBOCopyReply(rep, buf);
-+ buf->mapVirtual = NULL;
-+ buf->mapCount = 0;
-+ buf->virtual = NULL;
-+
-+ return 0;
-+}
-+
-+int drmBOUnreference(int fd, drmBO *buf)
-+{
-+ struct drm_bo_handle_arg arg;
-+
-+ if (buf->mapVirtual && buf->mapHandle) {
-+ (void) munmap(buf->mapVirtual, buf->start + buf->size);
-+ buf->mapVirtual = NULL;
-+ buf->virtual = NULL;
-+ }
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.handle = buf->handle;
-+
-+ if (ioctl(fd, DRM_IOCTL_BO_UNREFERENCE, &arg))
-+ return -errno;
-+
-+ buf->handle = 0;
-+ return 0;
-+}
-+
-+
-+/*
-+ * Flags can be DRM_BO_FLAG_READ, DRM_BO_FLAG_WRITE or'ed together
-+ * Hint currently be DRM_BO_HINT_DONT_BLOCK, which makes the
-+ * call return an -EBUSY if it can' immediately honor the mapping request.
-+ */
-+
-+int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
-+ void **address)
-+{
-+ struct drm_bo_map_wait_idle_arg arg;
-+ struct drm_bo_info_req *req = &arg.d.req;
-+ struct drm_bo_info_rep *rep = &arg.d.rep;
-+ int ret = 0;
-+
-+ /*
-+ * Make sure we have a virtual address of the buffer.
-+ */
-+
-+ if (!buf->virtual) {
-+ drmAddress virtual;
-+ virtual = mmap(0, buf->size + buf->start,
-+ PROT_READ | PROT_WRITE, MAP_SHARED,
-+ fd, buf->mapHandle);
-+ if (virtual == MAP_FAILED) {
-+ ret = -errno;
-+ }
-+ if (ret)
-+ return ret;
-+ buf->mapVirtual = virtual;
-+ buf->virtual = ((char *) virtual) + buf->start;
-+ }
-+
-+ memset(&arg, 0, sizeof(arg));
-+ req->handle = buf->handle;
-+ req->mask = mapFlags;
-+ req->hint = mapHint;
-+
-+ /*
-+ * May hang if the buffer object is busy.
-+ * This IOCTL synchronizes the buffer.
-+ */
-+
-+ ret = drmIoctlTimeout(fd, DRM_IOCTL_BO_MAP, &arg);
-+ if (ret)
-+ return ret;
-+
-+ drmBOCopyReply(rep, buf);
-+ buf->mapFlags = mapFlags;
-+ ++buf->mapCount;
-+ *address = buf->virtual;
-+
-+ return 0;
-+}
-+
-+
-+int drmBOUnmap(int fd, drmBO *buf)
-+{
-+ struct drm_bo_handle_arg arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.handle = buf->handle;
-+
-+ if (ioctl(fd, DRM_IOCTL_BO_UNMAP, &arg)) {
-+ return -errno;
-+ }
-+ buf->mapCount--;
-+ return 0;
-+}
-+
-+int drmBOSetStatus(int fd, drmBO *buf,
-+ uint64_t flags, uint64_t mask,
-+ unsigned int hint,
-+ unsigned int desired_tile_stride,
-+ unsigned int tile_info)
-+{
-+
-+ struct drm_bo_map_wait_idle_arg arg;
-+ struct drm_bo_info_req *req = &arg.d.req;
-+ struct drm_bo_info_rep *rep = &arg.d.rep;
-+ int ret = 0;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ req->mask = mask;
-+ req->flags = flags;
-+ req->handle = buf->handle;
-+ req->hint = hint;
-+ req->desired_tile_stride = desired_tile_stride;
-+ req->tile_info = tile_info;
-+
-+ ret = drmIoctlTimeout(fd, DRM_IOCTL_BO_SETSTATUS, &arg);
-+ if (ret)
-+ return ret;
-+
-+ drmBOCopyReply(rep, buf);
-+ return 0;
-+}
-+
-+
-+int drmBOInfo(int fd, drmBO *buf)
-+{
-+ struct drm_bo_reference_info_arg arg;
-+ struct drm_bo_handle_arg *req = &arg.d.req;
-+ struct drm_bo_info_rep *rep = &arg.d.rep;
-+ int ret = 0;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ req->handle = buf->handle;
-+
-+ ret = ioctl(fd, DRM_IOCTL_BO_INFO, &arg);
-+ if (ret)
-+ return -errno;
-+
-+ drmBOCopyReply(rep, buf);
-+ return 0;
-+}
-+
-+int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint)
-+{
-+ struct drm_bo_map_wait_idle_arg arg;
-+ struct drm_bo_info_req *req = &arg.d.req;
-+ struct drm_bo_info_rep *rep = &arg.d.rep;
-+ int ret = 0;
-+
-+ if ((buf->flags & DRM_BO_FLAG_SHAREABLE) ||
-+ (buf->replyFlags & DRM_BO_REP_BUSY)) {
-+ memset(&arg, 0, sizeof(arg));
-+ req->handle = buf->handle;
-+ req->hint = hint;
-+
-+ ret = drmIoctlTimeout(fd, DRM_IOCTL_BO_WAIT_IDLE, &arg);
-+ if (ret)
-+ return ret;
-+
-+ drmBOCopyReply(rep, buf);
-+ }
-+ return 0;
-+}
-+
-+int drmBOBusy(int fd, drmBO *buf, int *busy)
-+{
-+ if (!(buf->flags & DRM_BO_FLAG_SHAREABLE) &&
-+ !(buf->replyFlags & DRM_BO_REP_BUSY)) {
-+ *busy = 0;
-+ return 0;
-+ }
-+ else {
-+ int ret = drmBOInfo(fd, buf);
-+ if (ret)
-+ return ret;
-+ *busy = (buf->replyFlags & DRM_BO_REP_BUSY);
-+ return 0;
-+ }
-+}
-+
-+int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize,
-+ unsigned memType)
-+{
-+ struct drm_mm_init_arg arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+
-+ arg.magic = DRM_BO_INIT_MAGIC;
-+ arg.major = DRM_BO_INIT_MAJOR;
-+ arg.minor = DRM_BO_INIT_MINOR;
-+ arg.p_offset = pOffset;
-+ arg.p_size = pSize;
-+ arg.mem_type = memType;
-+
-+ if (ioctl(fd, DRM_IOCTL_MM_INIT, &arg))
-+ return -errno;
-+ return 0;
-+}
-+
-+int drmMMTakedown(int fd, unsigned memType)
-+{
-+ struct drm_mm_type_arg arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.mem_type = memType;
-+
-+ if (ioctl(fd, DRM_IOCTL_MM_TAKEDOWN, &arg))
-+ return -errno;
-+ return 0;
-+}
-+
-+/*
-+ * If this function returns an error, and lockBM was set to 1,
-+ * the buffer manager is NOT locked.
-+ */
-+
-+int drmMMLock(int fd, unsigned memType, int lockBM, int ignoreNoEvict)
-+{
-+ struct drm_mm_type_arg arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ arg.mem_type = memType;
-+ arg.lock_flags |= (lockBM) ? DRM_BO_LOCK_UNLOCK_BM : 0;
-+ arg.lock_flags |= (ignoreNoEvict) ? DRM_BO_LOCK_IGNORE_NO_EVICT : 0;
-+
-+ return drmIoctlTimeout(fd, DRM_IOCTL_MM_LOCK, &arg);
-+}
-+
-+int drmMMUnlock(int fd, unsigned memType, int unlockBM)
-+{
-+ struct drm_mm_type_arg arg;
-+
-+ memset(&arg, 0, sizeof(arg));
-+
-+ arg.mem_type = memType;
-+ arg.lock_flags |= (unlockBM) ? DRM_BO_LOCK_UNLOCK_BM : 0;
-+
-+ return drmIoctlTimeout(fd, DRM_IOCTL_MM_UNLOCK, &arg);
-+}
-+
-+int drmBOVersion(int fd, unsigned int *major,
-+ unsigned int *minor,
-+ unsigned int *patchlevel)
-+{
-+ struct drm_bo_version_arg arg;
-+ int ret;
-+
-+ memset(&arg, 0, sizeof(arg));
-+ ret = ioctl(fd, DRM_IOCTL_BO_VERSION, &arg);
-+ if (ret)
-+ return -errno;
-+
-+ if (major)
-+ *major = arg.major;
-+ if (minor)
-+ *minor = arg.minor;
-+ if (patchlevel)
-+ *patchlevel = arg.patchlevel;
-+
-+ return 0;
-+}
-+
-+
-+
- #define DRM_MAX_FDS 16
- static struct {
- char *BusID;
-Index: libdrm-2.3.1/libdrm/xf86drm.h
-===================================================================
---- libdrm-2.3.1.orig/libdrm/xf86drm.h 2008-07-01 08:51:40.000000000 +0100
-+++ libdrm-2.3.1/libdrm/xf86drm.h 2009-01-14 18:26:59.000000000 +0000
-@@ -658,4 +658,6 @@
- extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
- extern void drmCloseOnce(int fd);
-
-+#include "xf86mm.h"
-+
- #endif
-Index: libdrm-2.3.1/libdrm/xf86drmMode.c
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ libdrm-2.3.1/libdrm/xf86drmMode.c 2009-01-14 18:26:59.000000000 +0000
-@@ -0,0 +1,465 @@
-+/*
-+ * \file xf86drmMode.c
-+ * Header for DRM modesetting interface.
-+ *
-+ * \author Jakob Bornecrantz <wallbraker@gmail.com>
-+ *
-+ * \par Acknowledgements:
-+ * Feb 2007, Dave Airlie <airlied@linux.ie>
-+ */
-+
-+/*
-+ * Copyright (c) <year> <copyright holders>
-+ *
-+ * 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, sublicense,
-+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
-+ * AUTHORS OR COPYRIGHT HOLDERS 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.
-+ *
-+ */
-+
-+/*
-+ * TODO the types we are after are defined in diffrent headers on diffrent
-+ * platforms find which headers to include to get uint32_t
-+ */
-+#include <stdint.h>
-+
-+#include "xf86drmMode.h"
-+#include "xf86drm.h"
-+#include <drm.h>
-+#include <string.h>
-+
-+/*
-+ * Util functions
-+ */
-+
-+void* drmAllocCpy(void *array, int count, int entry_size)
-+{
-+ char *r;
-+ int i;
-+
-+ if (!count || !array || !entry_size)
-+ return 0;
-+
-+ if (!(r = drmMalloc(count*entry_size)))
-+ return 0;
-+
-+ for (i = 0; i < count; i++)
-+ memcpy(r+(entry_size*i), array+(entry_size*i), entry_size);
-+
-+ return r;
-+}
-+
-+/**
-+ * Generate crtc and output ids.
-+ *
-+ * Will generate ids starting from 1 up to count if count is greater then 0.
-+ */
-+static uint32_t* drmAllocGenerate(int count)
-+{
-+ uint32_t *r;
-+ int i;
-+
-+ if(0 <= count)
-+ return 0;
-+
-+ if (!(r = drmMalloc(count*sizeof(*r))))
-+ return 0;
-+
-+ for (i = 0; i < count; r[i] = ++i);
-+
-+ return 0;
-+}
-+
-+/*
-+ * A couple of free functions.
-+ */
-+
-+void drmModeFreeModeInfo(struct drm_mode_modeinfo *ptr)
-+{
-+ if (!ptr)
-+ return;
-+
-+ drmFree(ptr);
-+}
-+
-+void drmModeFreeResources(drmModeResPtr ptr)
-+{
-+ if (!ptr)
-+ return;
-+
-+ drmFree(ptr->modes);
-+ drmFree(ptr);
-+
-+}
-+
-+void drmModeFreeFB(drmModeFBPtr ptr)
-+{
-+ if (!ptr)
-+ return;
-+
-+ /* we might add more frees later. */
-+ drmFree(ptr);
-+}
-+
-+void drmModeFreeCrtc(drmModeCrtcPtr ptr)
-+{
-+ if (!ptr)
-+ return;
-+
-+ drmFree(ptr);
-+
-+}
-+
-+void drmModeFreeOutput(drmModeOutputPtr ptr)
-+{
-+ if (!ptr)
-+ return;
-+
-+ drmFree(ptr->modes);
-+ drmFree(ptr);
-+
-+}
-+
-+/*
-+ * ModeSetting functions.
-+ */
-+
-+drmModeResPtr drmModeGetResources(int fd)
-+{
-+ struct drm_mode_card_res res;
-+ int i;
-+ drmModeResPtr r = 0;
-+
-+ memset(&res, 0, sizeof(struct drm_mode_card_res));
-+
-+ if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
-+ return 0;
-+
-+ if (res.count_fbs)
-+ res.fb_id = drmMalloc(res.count_fbs*sizeof(uint32_t));
-+ if (res.count_crtcs)
-+ res.crtc_id = drmMalloc(res.count_crtcs*sizeof(uint32_t));
-+ if (res.count_outputs)
-+ res.output_id = drmMalloc(res.count_outputs*sizeof(uint32_t));
-+ if (res.count_modes)
-+ res.modes = drmMalloc(res.count_modes*sizeof(*res.modes));
-+
-+ if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) {
-+ r = NULL;
-+ goto err_allocs;
-+ }
-+
-+ /*
-+ * return
-+ */
-+
-+
-+ if (!(r = drmMalloc(sizeof(*r))))
-+ return 0;
-+
-+ r->count_fbs = res.count_fbs;
-+ r->count_crtcs = res.count_crtcs;
-+ r->count_outputs = res.count_outputs;
-+ r->count_modes = res.count_modes;
-+ /* TODO we realy should test if these allocs fails. */
-+ r->fbs = drmAllocCpy(res.fb_id, res.count_fbs, sizeof(uint32_t));
-+ r->crtcs = drmAllocCpy(res.crtc_id, res.count_crtcs, sizeof(uint32_t));
-+ r->outputs = drmAllocCpy(res.output_id, res.count_outputs, sizeof(uint32_t));
-+ r->modes = drmAllocCpy(res.modes, res.count_modes, sizeof(struct drm_mode_modeinfo));
-+
-+err_allocs:
-+ drmFree(res.fb_id);
-+ drmFree(res.crtc_id);
-+ drmFree(res.output_id);
-+ drmFree(res.modes);
-+
-+ return r;
-+}
-+
-+int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
-+ uint8_t bpp, uint32_t pitch, drmBO *bo, uint32_t *buf_id)
-+{
-+ struct drm_mode_fb_cmd f;
-+ int ret;
-+
-+ f.width = width;
-+ f.height = height;
-+ f.pitch = pitch;
-+ f.bpp = bpp;
-+ f.depth = depth;
-+ f.handle = bo->handle;
-+
-+ if (ret = ioctl(fd, DRM_IOCTL_MODE_ADDFB, &f))
-+ return ret;
-+
-+ *buf_id = f.buffer_id;
-+ return 0;
-+}
-+
-+int drmModeRmFB(int fd, uint32_t bufferId)
-+{
-+ return ioctl(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
-+}
-+
-+drmModeFBPtr drmModeGetFB(int fd, uint32_t buf)
-+{
-+ struct drm_mode_fb_cmd info;
-+ drmModeFBPtr r;
-+
-+ info.buffer_id = buf;
-+
-+ if (ioctl(fd, DRM_IOCTL_MODE_GETFB, &info))
-+ return NULL;
-+
-+ if (!(r = drmMalloc(sizeof(*r))))
-+ return NULL;
-+
-+ r->buffer_id = info.buffer_id;
-+ r->width = info.width;
-+ r->height = info.height;
-+ r->pitch = info.pitch;
-+ r->bpp = info.bpp;
-+ r->handle = info.handle;
-+ r->depth = info.depth;
-+
-+ return r;
-+}
-+
-+
-+/*
-+ * Crtc functions
-+ */
-+
-+drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
-+{
-+ struct drm_mode_crtc crtc;
-+ drmModeCrtcPtr r;
-+ int i = 0;
-+
-+ crtc.count_outputs = 0;
-+ crtc.outputs = 0;
-+ crtc.count_possibles = 0;
-+ crtc.possibles = 0;
-+ crtc.crtc_id = crtcId;
-+
-+ if (ioctl(fd, DRM_IOCTL_MODE_GETCRTC, &crtc))
-+ return 0;
-+
-+ /*
-+ * return
-+ */
-+
-+ if (!(r = drmMalloc(sizeof(*r))))
-+ return 0;
-+
-+ r->crtc_id = crtc.crtc_id;
-+ r->x = crtc.x;
-+ r->y = crtc.y;
-+ r->mode = crtc.mode;
-+ r->buffer_id = crtc.fb_id;
-+ r->gamma_size = crtc.gamma_size;
-+ r->count_outputs = crtc.count_outputs;
-+ r->count_possibles = crtc.count_possibles;
-+ /* TODO we realy should test if these alloc & cpy fails. */
-+ r->outputs = crtc.outputs;
-+ r->possibles = crtc.possibles;
-+
-+ return r;
-+
-+err_allocs:
-+
-+ return 0;
-+}
-+
-+
-+int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
-+ uint32_t x, uint32_t y, uint32_t modeId,
-+ uint32_t *outputs, int count)
-+{
-+ struct drm_mode_crtc crtc;
-+
-+ crtc.count_outputs = 0;
-+ crtc.outputs = 0;
-+ crtc.count_possibles = 0;
-+ crtc.possibles = 0;
-+
-+ crtc.x = x;
-+ crtc.y = y;
-+ crtc.crtc_id = crtcId;
-+ crtc.fb_id = bufferId;
-+ crtc.set_outputs = outputs;
-+ crtc.count_outputs = count;
-+ crtc.mode = modeId;
-+
-+ return ioctl(fd, DRM_IOCTL_MODE_SETCRTC, &crtc);
-+}
-+
-+
-+/*
-+ * Output manipulation
-+ */
-+
-+drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id)
-+{
-+ struct drm_mode_get_output out;
-+ drmModeOutputPtr r = NULL;
-+
-+ out.output = output_id;
-+ out.count_crtcs = 0;
-+ out.crtcs = 0;
-+ out.count_clones = 0;
-+ out.clones = 0;
-+ out.count_modes = 0;
-+ out.modes = 0;
-+ out.count_props = 0;
-+ out.props = NULL;
-+ out.prop_values = NULL;
-+
-+ if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out))
-+ return 0;
-+
-+ if (out.count_props) {
-+ out.props = drmMalloc(out.count_props*sizeof(uint32_t));
-+ out.prop_values = drmMalloc(out.count_props*sizeof(uint32_t));
-+ }
-+
-+ if (out.count_modes)
-+ out.modes = drmMalloc(out.count_modes*sizeof(uint32_t));
-+
-+ if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out))
-+ goto err_allocs;
-+
-+ if(!(r = drmMalloc(sizeof(*r)))) {
-+ goto err_allocs;
-+ }
-+
-+ r->output_id = out.output;
-+ r->crtc = out.crtc;
-+ r->connection = out.connection;
-+ r->mmWidth = out.mm_width;
-+ r->mmHeight = out.mm_height;
-+ r->subpixel = out.subpixel;
-+ r->count_crtcs = out.count_crtcs;
-+ r->count_clones = out.count_clones;
-+ r->count_modes = out.count_modes;
-+ /* TODO we should test if these alloc & cpy fails. */
-+ r->crtcs = out.crtcs;
-+ r->clones = out.clones;
-+ r->count_props = out.count_props;
-+ r->props = drmAllocCpy(out.props, out.count_props, sizeof(uint32_t));
-+ r->prop_values = drmAllocCpy(out.prop_values, out.count_props, sizeof(uint32_t));
-+ r->modes = drmAllocCpy(out.modes, out.count_modes, sizeof(uint32_t));
-+ strncpy(r->name, out.name, DRM_OUTPUT_NAME_LEN);
-+ r->name[DRM_OUTPUT_NAME_LEN-1] = 0;
-+
-+err_allocs:
-+ drmFree(out.prop_values);
-+ drmFree(out.props);
-+ drmFree(out.modes);
-+
-+ return r;
-+}
-+
-+uint32_t drmModeAddMode(int fd, struct drm_mode_modeinfo *mode_info)
-+{
-+ if (ioctl(fd, DRM_IOCTL_MODE_ADDMODE, mode_info))
-+ return 0;
-+
-+ return mode_info->id;
-+}
-+
-+int drmModeRmMode(int fd, uint32_t mode_id)
-+{
-+ return ioctl(fd, DRM_IOCTL_MODE_RMMODE, &mode_id);
-+}
-+
-+int drmModeAttachMode(int fd, uint32_t output_id, uint32_t mode_id)
-+{
-+
-+ struct drm_mode_mode_cmd res;
-+
-+ res.output_id = output_id;
-+ res.mode_id = mode_id;
-+
-+ return ioctl(fd, DRM_IOCTL_MODE_ATTACHMODE, &res);
-+}
-+
-+int drmModeDetachMode(int fd, uint32_t output_id, uint32_t mode_id)
-+{
-+ struct drm_mode_mode_cmd res;
-+
-+ res.output_id = output_id;
-+ res.mode_id = mode_id;
-+
-+ return ioctl(fd, DRM_IOCTL_MODE_DETACHMODE, &res);
-+}
-+
-+
-+drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
-+{
-+ struct drm_mode_get_property prop;
-+ drmModePropertyPtr r;
-+
-+ prop.prop_id = property_id;
-+ prop.count_enums = 0;
-+ prop.count_values = 0;
-+ prop.flags = 0;
-+ prop.enums = NULL;
-+ prop.values = NULL;
-+
-+ if (ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop))
-+ return 0;
-+
-+ if (prop.count_values)
-+ prop.values = drmMalloc(prop.count_values * sizeof(uint32_t));
-+
-+ if (prop.count_enums)
-+ prop.enums = drmMalloc(prop.count_enums * sizeof(struct drm_mode_property_enum));
-+
-+ if (ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop)) {
-+ r = NULL;
-+ goto err_allocs;
-+ }
-+
-+ if (!(r = drmMalloc(sizeof(*r))))
-+ return NULL;
-+
-+ r->prop_id = prop.prop_id;
-+ r->count_values = prop.count_values;
-+ r->count_enums = prop.count_enums;
-+
-+ r->values = drmAllocCpy(prop.values, prop.count_values, sizeof(uint32_t));
-+ r->enums = drmAllocCpy(prop.enums, prop.count_enums, sizeof(struct drm_mode_property_enum));
-+ strncpy(r->name, prop.name, DRM_PROP_NAME_LEN);
-+ r->name[DRM_PROP_NAME_LEN-1] = 0;
-+
-+err_allocs:
-+ drmFree(prop.values);
-+ drmFree(prop.enums);
-+
-+ return r;
-+}
-+
-+void drmModeFreeProperty(drmModePropertyPtr ptr)
-+{
-+ if (!ptr)
-+ return;
-+
-+ drmFree(ptr->values);
-+ drmFree(ptr->enums);
-+ drmFree(ptr);
-+}
-Index: libdrm-2.3.1/libdrm/xf86drmMode.h
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ libdrm-2.3.1/libdrm/xf86drmMode.h 2009-01-14 18:26:59.000000000 +0000
-@@ -0,0 +1,226 @@
-+/*
-+ * \file xf86drmMode.h
-+ * Header for DRM modesetting interface.
-+ *
-+ * \author Jakob Bornecrantz <wallbraker@gmail.com>
-+ *
-+ * \par Acknowledgements:
-+ * Feb 2007, Dave Airlie <airlied@linux.ie>
-+ */
-+
-+/*
-+ * Copyright (c) <year> <copyright holders>
-+ *
-+ * 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, sublicense,
-+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
-+ * AUTHORS OR COPYRIGHT HOLDERS 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 <drm.h>
-+#include "xf86mm.h"
-+
-+/*
-+ * This is the interface for modesetting for drm.
-+ *
-+ * In order to use this interface you must include either <stdint.h> or another
-+ * header defining uint32_t, int32_t and uint16_t.
-+ *
-+ * It aims to provide a randr1.2 compatible interface for modesettings in the
-+ * kernel, the interface is also ment to be used by libraries like EGL.
-+ *
-+ * More information can be found in randrproto.txt which can be found here:
-+ * http://gitweb.freedesktop.org/?p=xorg/proto/randrproto.git
-+ *
-+ * There are some major diffrences to be noted. Unlike the randr1.2 proto you
-+ * need to create the memory object of the framebuffer yourself with the ttm
-+ * buffer object interface. This object needs to be pinned.
-+ */
-+
-+
-+typedef struct _drmModeRes {
-+
-+ int count_fbs;
-+ uint32_t *fbs;
-+
-+ int count_crtcs;
-+ uint32_t *crtcs;
-+
-+ int count_outputs;
-+ uint32_t *outputs;
-+
-+ int count_modes;
-+ struct drm_mode_modeinfo *modes;
-+
-+} drmModeRes, *drmModeResPtr;
-+
-+typedef struct drm_mode_fb_cmd drmModeFB, *drmModeFBPtr;
-+
-+typedef struct _drmModeProperty {
-+ unsigned int prop_id;
-+ unsigned int flags;
-+ unsigned char name[DRM_PROP_NAME_LEN];
-+ int count_values;
-+ uint32_t *values;
-+ int count_enums;
-+ struct drm_mode_property_enum *enums;
-+
-+} drmModePropertyRes, *drmModePropertyPtr;
-+
-+typedef struct _drmModeCrtc {
-+ unsigned int crtc_id;
-+ unsigned int buffer_id; /**< FB id to connect to 0 = disconnect*/
-+
-+ uint32_t x, y; /**< Position on the frameuffer */
-+ uint32_t width, height;
-+ uint32_t mode; /**< Current mode used */
-+
-+ int count_outputs;
-+ uint32_t outputs; /**< Outpu