From 514aa592cd3c569e4033d7c64bc12dfc1507a951 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 16 Jan 2009 15:37:55 +0000 Subject: libdrm-psb: Update to use a 2.6.27 kernel and simplify patches --- meta-moblin/packages/drm/files/menlow-config | 98 +- meta-moblin/packages/drm/files/poulsbo.patch | 4050 ++ .../packages/drm/files/poulsbo_libdrm_update.patch | 63492 ------------------- meta-moblin/packages/drm/libdrm-psb_2.3.1.bb | 17 + meta-moblin/packages/drm/libdrm-psb_git.bb | 21 - .../packages/drm/linux-psb-modules_2.6.24.bb | 27 - .../packages/drm/linux-psb-modules_2.6.27.bb | 30 + 7 files changed, 4146 insertions(+), 63589 deletions(-) create mode 100644 meta-moblin/packages/drm/files/poulsbo.patch delete mode 100644 meta-moblin/packages/drm/files/poulsbo_libdrm_update.patch create mode 100644 meta-moblin/packages/drm/libdrm-psb_2.3.1.bb delete mode 100644 meta-moblin/packages/drm/libdrm-psb_git.bb delete mode 100644 meta-moblin/packages/drm/linux-psb-modules_2.6.24.bb create mode 100644 meta-moblin/packages/drm/linux-psb-modules_2.6.27.bb diff --git a/meta-moblin/packages/drm/files/menlow-config b/meta-moblin/packages/drm/files/menlow-config index 3a699b587b..da527613f0 100644 --- a/meta-moblin/packages/drm/files/menlow-config +++ b/meta-moblin/packages/drm/files/menlow-config @@ -1,84 +1,84 @@ # Ubuntu config -CONFIG_BLK_DEV_GNBD=m +# CONFIG_BLK_DEV_GNBD is not set # Requires some headers from drivers/md #CONFIG_BLK_DEV_DM_BBR=m -CONFIG_SND_BTSCO=m +# CONFIG_SND_BTSCO is not set -CONFIG_INPUT_ACERHK=m -CONFIG_AVERATEC_5100P=m -CONFIG_PACKARDBELL_E5=m -CONFIG_LMPCM_USB=m -CONFIG_NOZOMI=m +# CONFIG_INPUT_ACERHK is not set +# CONFIG_AVERATEC_5100P is not set +# CONFIG_PACKARDBELL_E5 is not set +# CONFIG_LMPCM_USB is not set +# CONFIG_NOZOMI is not set -CONFIG_NDISWRAPPER=m - CONFIG_NDISWRAPPER_WQ=y +# CONFIG_NDISWRAPPER is not set +# CONFIG_NDISWRAPPER_WQ is not set -#CONFIG_MOL=m +# CONFIG_MOL is not set -CONFIG_ASFS_FS=m +# CONFIG_ASFS_FS is not set # Uses unexported functions from gfs2 -CONFIG_GFS_FS=m +# CONFIG_GFS_FS is not set -CONFIG_SQUASHFS=m +# CONFIG_SQUASHFS is not set # CONFIG_UNION_FS is not set -CONFIG_USB_APPLEIR=m +# CONFIG_USB_APPLEIR is not set -CONFIG_GSPCA=m +# CONFIG_GSPCA is not set -CONFIG_USB_OV511_NEW=m -CONFIG_QUICKCAM=m -CONFIG_USB_UVCCAM=m +# CONFIG_USB_OV511_NEW is not set +# CONFIG_QUICKCAM is not set +# CONFIG_USB_UVCCAM is not set -CONFIG_NET_ACX=m -CONFIG_IPW3945=m -CONFIG_IWLWIFI=m -CONFIG_USB_ATMEL=m -CONFIG_PRISM2_USB=m +# CONFIG_NET_ACX is not set +# CONFIG_IPW3945 is not set +# CONFIG_IWLWIFI is not set +# CONFIG_USB_ATMEL is not set +# CONFIG_PRISM2_USB is not set -CONFIG_IPW2100_FS_AMILO_M7400=m +# CONFIG_IPW2100_FS_AMILO_M7400 is not set -CONFIG_LIRC_DEV=m -CONFIG_LIRC_ATIUSB=m -CONFIG_LIRC_BT829=m -CONFIG_LIRC_CMDIR=m -#CONFIG_LIRC_GPIO=m -CONFIG_LIRC_I2C=m -CONFIG_LIRC_IGORPLUGUSB=m -CONFIG_LIRC_IMON=m -CONFIG_LIRC_IT87=m -CONFIG_LIRC_MCEUSB=m -CONFIG_LIRC_MCEUSB2=m -#CONFIG_LIRC_PARALLEL=m -CONFIG_LIRC_PVR150=m -CONFIG_LIRC_SASEM=m -CONFIG_LIRC_SERIAL=m -CONFIG_LIRC_SERIAL_IGOR=m -CONFIG_LIRC_SIR=m -CONFIG_LIRC_STREAMZAP=m -CONFIG_LIRC_TTUSBIR=m +# CONFIG_LIRC_DEV is not set +# CONFIG_LIRC_ATIUSB is not set +# CONFIG_LIRC_BT829 is not set +# CONFIG_LIRC_CMDIR is not set +# CONFIG_LIRC_GPIO is not set +# CONFIG_LIRC_I2C is not set +# CONFIG_LIRC_IGORPLUGUSB is not set +# CONFIG_LIRC_IMON is not set +# CONFIG_LIRC_IT87 is not set +# CONFIG_LIRC_MCEUSB is not set +# CONFIG_LIRC_MCEUSB2 is not set +# CONFIG_LIRC_PARALLEL is not set +# CONFIG_LIRC_PVR150 is not set +# CONFIG_LIRC_SASEM is not set +# CONFIG_LIRC_SERIAL is not set +# CONFIG_LIRC_SERIAL_IGOR is not set +# CONFIG_LIRC_SIR is not set +# CONFIG_LIRC_STREAMZAP is not set +# CONFIG_LIRC_TTUSBIR is not set CONFIG_DRM_PSB=m -CONFIG_AMT_HECI=m +# CONFIG_AMT_HECI is not set -CONFIG_ET131X=m +# CONFIG_ET131X is not set -CONFIG_STK11XX=m +# CONFIG_STK11XX is not set -CONFIG_MMC_SD8686=m -CONFIG_MMC_SD8688=m +# CONFIG_MMC_SD8686 is not set +# CONFIG_MMC_SD8688 is not set -CONFIG_WIMAX_I2400M=m +# CONFIG_WIMAX_I2400M is not set # CONFIG_DVB_SIANO_SMS1XXX is not set diff --git a/meta-moblin/packages/drm/files/poulsbo.patch b/meta-moblin/packages/drm/files/poulsbo.patch new file mode 100644 index 0000000000..13a16bfd74 --- /dev/null +++ b/meta-moblin/packages/drm/files/poulsbo.patch @@ -0,0 +1,4050 @@ +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 ++ * ++ * \par Acknowledgements: ++ * Feb 2007, Dave Airlie ++ */ ++ ++/* ++ * Copyright (c) ++ * ++ * 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 ++ ++#include "xf86drmMode.h" ++#include "xf86drm.h" ++#include ++#include ++ ++/* ++ * 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 ++ * ++ * \par Acknowledgements: ++ * Feb 2007, Dave Airlie ++ */ ++ ++/* ++ * Copyright (c) ++ * ++ * 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 ++#include "xf86mm.h" ++ ++/* ++ * This is the interface for modesetting for drm. ++ * ++ * In order to use this interface you must include either 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; /**< Outputs that are connected */ ++ ++ int count_possibles; ++ uint32_t possibles; /**< Outputs that can be connected */ ++ ++ int gamma_size; /**< Number of gamma stops */ ++ ++} drmModeCrtc, *drmModeCrtcPtr; ++ ++typedef enum { ++ DRM_MODE_CONNECTED = 1, ++ DRM_MODE_DISCONNECTED = 2, ++ DRM_MODE_UNKNOWNCONNECTION = 3 ++} drmModeConnection; ++ ++typedef enum { ++ DRM_MODE_SUBPIXEL_UNKNOWN = 1, ++ DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2, ++ DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3, ++ DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4, ++ DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5, ++ DRM_MODE_SUBPIXEL_NONE = 6 ++} drmModeSubPixel; ++ ++typedef struct _drmModeOutput { ++ unsigned int output_id; ++ ++ unsigned int crtc; /**< Crtc currently connected to */ ++ unsigned char name[DRM_OUTPUT_NAME_LEN]; ++ drmModeConnection connection; ++ uint32_t mmWidth, mmHeight; /**< HxW in millimeters */ ++ drmModeSubPixel subpixel; ++ ++ int count_crtcs; ++ uint32_t crtcs; /**< Possible crtc to connect to */ ++ ++ int count_clones; ++ uint32_t clones; /**< Mask of clones */ ++ ++ int count_modes; ++ uint32_t *modes; /**< List of modes ids */ ++ ++ int count_props; ++ uint32_t *props; /**< List of property ids */ ++ uint32_t *prop_values; /**< List of property values */ ++ ++} drmModeOutput, *drmModeOutputPtr; ++ ++ ++ ++extern void drmModeFreeModeInfo( struct drm_mode_modeinfo *ptr ); ++extern void drmModeFreeResources( drmModeResPtr ptr ); ++extern void drmModeFreeFB( drmModeFBPtr ptr ); ++extern void drmModeFreeCrtc( drmModeCrtcPtr ptr ); ++extern void drmModeFreeOutput( drmModeOutputPtr ptr ); ++ ++/** ++ * Retrives all of the resources associated with a card. ++ */ ++extern drmModeResPtr drmModeGetResources(int fd); ++ ++ ++/* ++ * FrameBuffer manipulation. ++ */ ++ ++/** ++ * Retrive information about framebuffer bufferId ++ */ ++extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId); ++ ++/** ++ * Creates a new framebuffer with an buffer object as its scanout buffer. ++ */ ++extern 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); ++/** ++ * Destroies the given framebuffer. ++ */ ++extern int drmModeRmFB(int fd, uint32_t bufferId); ++ ++ ++/* ++ * Crtc functions ++ */ ++ ++/** ++ * Retrive information about the ctrt crtcId ++ */ ++extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId); ++ ++/** ++ * Set the mode on a crtc crtcId with the given mode modeId. ++ */ ++extern int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, ++ uint32_t x, uint32_t y, uint32_t modeId, ++ uint32_t *outputs, int count); ++ ++ ++/* ++ * Output manipulation ++ */ ++ ++/** ++ * Retrive information about the output outputId. ++ */ ++extern drmModeOutputPtr drmModeGetOutput(int fd, ++ uint32_t outputId); ++ ++/** ++ * Adds a new mode from the given mode info. ++ * Name must be unique. ++ */ ++extern uint32_t drmModeAddMode(int fd, struct drm_mode_modeinfo *modeInfo); ++ ++/** ++ * Removes a mode created with AddMode, must be unused. ++ */ ++extern int drmModeRmMode(int fd, uint32_t modeId); ++ ++/** ++ * Attaches the given mode to an output. ++ */ ++extern int drmModeAttachMode(int fd, uint32_t outputId, uint32_t modeId); ++ ++/** ++ * Detaches a mode from the output ++ * must be unused, by the given mode. ++ */ ++extern int drmModeDetachMode(int fd, uint32_t outputId, uint32_t modeId); ++ ++extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId); ++extern void drmModeFreeProperty(drmModePropertyPtr ptr); +Index: libdrm-2.3.1/libdrm/xf86mm.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ libdrm-2.3.1/libdrm/xf86mm.h 2009-01-14 18:26:59.000000000 +0000 +@@ -0,0 +1,185 @@ ++/************************************************************************** ++ * ++ * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. 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 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. ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * ++ **************************************************************************/ ++ ++#ifndef _XF86MM_H_ ++#define _XF86MM_H_ ++#include ++#include ++#include "drm.h" ++ ++/* ++ * Note on multithreaded applications using this interface. ++ * Libdrm is not threadsafe, so common buffer, TTM, and fence objects need to ++ * be protected using an external mutex. ++ * ++ * Note: Don't protect the following functions, as it may lead to deadlocks: ++ * drmBOUnmap(). ++ * The kernel is synchronizing and refcounting buffer maps. ++ * User space only needs to refcount object usage within the same application. ++ */ ++ ++ ++/* ++ * List macros heavily inspired by the Linux kernel ++ * list handling. No list looping yet. ++ */ ++ ++typedef struct _drmMMListHead ++{ ++ struct _drmMMListHead *prev; ++ struct _drmMMListHead *next; ++} drmMMListHead; ++ ++#define DRMINITLISTHEAD(__item) \ ++ do{ \ ++ (__item)->prev = (__item); \ ++ (__item)->next = (__item); \ ++ } while (0) ++ ++#define DRMLISTADD(__item, __list) \ ++ do { \ ++ (__item)->prev = (__list); \ ++ (__item)->next = (__list)->next; \ ++ (__list)->next->prev = (__item); \ ++ (__list)->next = (__item); \ ++ } while (0) ++ ++#define DRMLISTADDTAIL(__item, __list) \ ++ do { \ ++ (__item)->next = (__list); \ ++ (__item)->prev = (__list)->prev; \ ++ (__list)->prev->next = (__item); \ ++ (__list)->prev = (__item); \ ++ } while(0) ++ ++#define DRMLISTDEL(__item) \ ++ do { \ ++ (__item)->prev->next = (__item)->next; \ ++ (__item)->next->prev = (__item)->prev; \ ++ } while(0) ++ ++#define DRMLISTDELINIT(__item) \ ++ do { \ ++ (__item)->prev->next = (__item)->next; \ ++ (__item)->next->prev = (__item)->prev; \ ++ (__item)->next = (__item); \ ++ (__item)->prev = (__item); \ ++ } while(0) ++ ++#define DRMLISTENTRY(__type, __item, __field) \ ++ ((__type *)(((char *) (__item)) - offsetof(__type, __field))) ++ ++typedef struct _drmFence ++{ ++ unsigned handle; ++ int fence_class; ++ unsigned type; ++ unsigned flags; ++ unsigned signaled; ++ uint32_t sequence; ++ unsigned pad[4]; /* for future expansion */ ++} drmFence; ++ ++typedef struct _drmBO ++{ ++ unsigned handle; ++ uint64_t mapHandle; ++ uint64_t flags; ++ uint64_t mask; ++ unsigned mapFlags; ++ unsigned long size; ++ unsigned long offset; ++ unsigned long start; ++ unsigned replyFlags; ++ unsigned fenceFlags; ++ unsigned pageAlignment; ++ unsigned tileInfo; ++ unsigned hwTileStride; ++ unsigned desiredTileStride; ++ void *virtual; ++ void *mapVirtual; ++ int mapCount; ++ unsigned pad[8]; /* for future expansion */ ++} drmBO; ++ ++/* ++ * Fence functions. ++ */ ++ ++extern int drmFenceCreate(int fd, unsigned flags, int fence_class, ++ unsigned type, drmFence *fence); ++extern int drmFenceReference(int fd, unsigned handle, drmFence *fence); ++extern int drmFenceUnreference(int fd, const drmFence *fence); ++extern int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type); ++extern int drmFenceSignaled(int fd, drmFence *fence, ++ unsigned fenceType, int *signaled); ++extern int drmFenceWait(int fd, unsigned flags, drmFence *fence, ++ unsigned flush_type); ++extern int drmFenceEmit(int fd, unsigned flags, drmFence *fence, ++ unsigned emit_type); ++extern int drmFenceBuffers(int fd, unsigned flags, uint32_t fence_class, drmFence *fence); ++ ++ ++/* ++ * Buffer object functions. ++ */ ++ ++extern int drmBOCreate(int fd, unsigned long size, ++ unsigned pageAlignment, void *user_buffer, ++ uint64_t mask, unsigned hint, drmBO *buf); ++extern int drmBOReference(int fd, unsigned handle, drmBO *buf); ++extern int drmBOUnreference(int fd, drmBO *buf); ++extern int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint, ++ void **address); ++extern int drmBOUnmap(int fd, drmBO *buf); ++extern int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle); ++extern int drmBOInfo(int fd, drmBO *buf); ++extern int drmBOBusy(int fd, drmBO *buf, int *busy); ++ ++extern int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint); ++ ++/* ++ * Initialization functions. ++ */ ++ ++extern int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize, ++ unsigned memType); ++extern int drmMMTakedown(int fd, unsigned memType); ++extern int drmMMLock(int fd, unsigned memType, int lockBM, int ignoreNoEvict); ++extern int drmMMUnlock(int fd, unsigned memType, int unlockBM); ++extern int drmBOSetStatus(int fd, drmBO *buf, ++ uint64_t flags, uint64_t mask, ++ unsigned int hint, ++ unsigned int desired_tile_stride, ++ unsigned int tile_info); ++extern int drmBOVersion(int fd, unsigned int *major, ++ unsigned int *minor, ++ unsigned int *patchlevel); ++ ++ ++#endif +Index: libdrm-2.3.1/Makefile.am +=================================================================== +--- libdrm-2.3.1.orig/Makefile.am 2008-07-01 08:50:43.000000000 +0100 ++++ libdrm-2.3.1/Makefile.am 2009-01-14 18:26:59.000000000 +0000 +@@ -22,7 +22,7 @@ + # here too, but let's just do libdrm for now + + AUTOMAKE_OPTIONS = foreign +-SUBDIRS = libdrm shared-core tests ++SUBDIRS = libdrm shared-core + + pkgconfigdir = @pkgconfigdir@ + pkgconfig_DATA = libdrm.pc +Index: libdrm-2.3.1/shared-core/drm.h +=================================================================== +--- libdrm-2.3.1.orig/shared-core/drm.h 2008-07-01 08:55:17.000000000 +0100 ++++ libdrm-2.3.1/shared-core/drm.h 2009-01-14 18:26:59.000000000 +0000 +@@ -236,6 +236,7 @@ + _DRM_AGP = 3, /**< AGP/GART */ + _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */ + _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */ ++ _DRM_TTM = 6 + }; + + /** +@@ -640,6 +641,398 @@ + int drm_dd_minor; + }; + ++ ++#define DRM_FENCE_FLAG_EMIT 0x00000001 ++#define DRM_FENCE_FLAG_SHAREABLE 0x00000002 ++#define DRM_FENCE_FLAG_WAIT_LAZY 0x00000004 ++#define DRM_FENCE_FLAG_WAIT_IGNORE_SIGNALS 0x00000008 ++#define DRM_FENCE_FLAG_NO_USER 0x00000010 ++ ++/* Reserved for driver use */ ++#define DRM_FENCE_MASK_DRIVER 0xFF000000 ++ ++#define DRM_FENCE_TYPE_EXE 0x00000001 ++ ++struct drm_fence_arg { ++ unsigned int handle; ++ unsigned int fence_class; ++ unsigned int type; ++ unsigned int flags; ++ unsigned int signaled; ++ unsigned int error; ++ unsigned int sequence; ++ unsigned int pad64; ++ uint64_t expand_pad[2]; /*Future expansion */ ++}; ++ ++/* Buffer permissions, referring to how the GPU uses the buffers. ++ * these translate to fence types used for the buffers. ++ * Typically a texture buffer is read, A destination buffer is write and ++ * a command (batch-) buffer is exe. Can be or-ed together. ++ */ ++ ++#define DRM_BO_FLAG_READ (1ULL << 0) ++#define DRM_BO_FLAG_WRITE (1ULL << 1) ++#define DRM_BO_FLAG_EXE (1ULL << 2) ++ ++/* ++ * Status flags. Can be read to determine the actual state of a buffer. ++ * Can also be set in the buffer mask before validation. ++ */ ++ ++/* ++ * Mask: Never evict this buffer. Not even with force. This type of buffer is only ++ * available to root and must be manually removed before buffer manager shutdown ++ * or lock. ++ * Flags: Acknowledge ++ */ ++#define DRM_BO_FLAG_NO_EVICT (1ULL << 4) ++ ++/* ++ * Mask: Require that the buffer is placed in mappable memory when validated. ++ * If not set the buffer may or may not be in mappable memory when validated. ++ * Flags: If set, the buffer is in mappable memory. ++ */ ++#define DRM_BO_FLAG_MAPPABLE (1ULL << 5) ++ ++/* Mask: The buffer should be shareable with other processes. ++ * Flags: The buffer is shareable with other processes. ++ */ ++#define DRM_BO_FLAG_SHAREABLE (1ULL << 6) ++ ++/* Mask: If set, place the buffer in cache-coherent memory if available. ++ * If clear, never place the buffer in cache coherent memory if validated. ++ * Flags: The buffer is currently in cache-coherent memory. ++ */ ++#define DRM_BO_FLAG_CACHED (1ULL << 7) ++ ++/* Mask: Make sure that every time this buffer is validated, ++ * it ends up on the same location provided that the memory mask is the same. ++ * The buffer will also not be evicted when claiming space for ++ * other buffers. Basically a pinned buffer but it may be thrown out as ++ * part of buffer manager shutdown or locking. ++ * Flags: Acknowledge. ++ */ ++#define DRM_BO_FLAG_NO_MOVE (1ULL << 8) ++ ++/* Mask: Make sure the buffer is in cached memory when mapped ++ * Flags: Acknowledge. ++ * Buffers allocated with this flag should not be used for suballocators ++ * This type may have issues on CPUs with over-aggressive caching ++ * http://marc.info/?l=linux-kernel&m=102376926732464&w=2 ++ */ ++#define DRM_BO_FLAG_CACHED_MAPPED (1ULL << 19) ++ ++ ++/* Mask: Force DRM_BO_FLAG_CACHED flag strictly also if it is set. ++ * Flags: Acknowledge. ++ */ ++#define DRM_BO_FLAG_FORCE_CACHING (1ULL << 13) ++ ++/* ++ * Mask: Force DRM_BO_FLAG_MAPPABLE flag strictly also if it is clear. ++ * Flags: Acknowledge. ++ */ ++#define DRM_BO_FLAG_FORCE_MAPPABLE (1ULL << 14) ++#define DRM_BO_FLAG_TILE (1ULL << 15) ++ ++/* ++ * Memory type flags that can be or'ed together in the mask, but only ++ * one appears in flags. ++ */ ++ ++/* System memory */ ++#define DRM_BO_FLAG_MEM_LOCAL (1ULL << 24) ++/* Translation table memory */ ++#define DRM_BO_FLAG_MEM_TT (1ULL << 25) ++/* Vram memory */ ++#define DRM_BO_FLAG_MEM_VRAM (1ULL << 26) ++/* Up to the driver to define. */ ++#define DRM_BO_FLAG_MEM_PRIV0 (1ULL << 27) ++#define DRM_BO_FLAG_MEM_PRIV1 (1ULL << 28) ++#define DRM_BO_FLAG_MEM_PRIV2 (1ULL << 29) ++#define DRM_BO_FLAG_MEM_PRIV3 (1ULL << 30) ++#define DRM_BO_FLAG_MEM_PRIV4 (1ULL << 31) ++/* We can add more of these now with a 64-bit flag type */ ++ ++/* Memory flag mask */ ++#define DRM_BO_MASK_MEM 0x00000000FF000000ULL ++#define DRM_BO_MASK_MEMTYPE 0x00000000FF0800A0ULL ++ ++/* Driver-private flags */ ++#define DRM_BO_MASK_DRIVER 0xFFFF000000000000ULL ++ ++/* Don't block on validate and map */ ++#define DRM_BO_HINT_DONT_BLOCK 0x00000002 ++/* Don't place this buffer on the unfenced list.*/ ++#define DRM_BO_HINT_DONT_FENCE 0x00000004 ++#define DRM_BO_HINT_WAIT_LAZY 0x00000008 ++ ++#define DRM_BO_INIT_MAGIC 0xfe769812 ++#define DRM_BO_INIT_MAJOR 1 ++#define DRM_BO_INIT_MINOR 0 ++#define DRM_BO_INIT_PATCH 0 ++ ++ ++struct drm_bo_info_req { ++ uint64_t mask; ++ uint64_t flags; ++ unsigned int handle; ++ unsigned int hint; ++ unsigned int fence_class; ++ unsigned int desired_tile_stride; ++ unsigned int tile_info; ++ unsigned int pad64; ++}; ++ ++struct drm_bo_create_req { ++ uint64_t mask; ++ uint64_t size; ++ uint64_t buffer_start; ++ unsigned int hint; ++ unsigned int page_alignment; ++}; ++ ++ ++/* ++ * Reply flags ++ */ ++ ++#define DRM_BO_REP_BUSY 0x00000001 ++ ++struct drm_bo_info_rep { ++ uint64_t flags; ++ uint64_t mask; ++ uint64_t size; ++ uint64_t offset; ++ uint64_t arg_handle; ++ uint64_t buffer_start; ++ unsigned int handle; ++ unsigned int fence_flags; ++ unsigned int rep_flags; ++ unsigned int page_alignment; ++ unsigned int desired_tile_stride; ++ unsigned int hw_tile_stride; ++ unsigned int tile_info; ++ unsigned int pad64; ++ uint64_t expand_pad[4]; /*Future expansion */ ++}; ++ ++struct drm_bo_arg_rep { ++ struct drm_bo_info_rep bo_info; ++ int ret; ++ unsigned int pad64; ++}; ++ ++struct drm_bo_create_arg { ++ union { ++ struct drm_bo_create_req req; ++ struct drm_bo_info_rep rep; ++ } d; ++}; ++ ++struct drm_bo_handle_arg { ++ unsigned int handle; ++}; ++ ++struct drm_bo_reference_info_arg { ++ union { ++ struct drm_bo_handle_arg req; ++ struct drm_bo_info_rep rep; ++ } d; ++}; ++ ++struct drm_bo_map_wait_idle_arg { ++ union { ++ struct drm_bo_info_req req; ++ struct drm_bo_info_rep rep; ++ } d; ++}; ++ ++struct drm_bo_op_req { ++ enum { ++ drm_bo_validate, ++ drm_bo_fence, ++ drm_bo_ref_fence, ++ } op; ++ unsigned int arg_handle; ++ struct drm_bo_info_req bo_req; ++}; ++ ++ ++struct drm_bo_op_arg { ++ uint64_t next; ++ union { ++ struct drm_bo_op_req req; ++ struct drm_bo_arg_rep rep; ++ } d; ++ int handled; ++ unsigned int pad64; ++}; ++ ++ ++#define DRM_BO_MEM_LOCAL 0 ++#define DRM_BO_MEM_TT 1 ++#define DRM_BO_MEM_VRAM 2 ++#define DRM_BO_MEM_PRIV0 3 ++#define DRM_BO_MEM_PRIV1 4 ++#define DRM_BO_MEM_PRIV2 5 ++#define DRM_BO_MEM_PRIV3 6 ++#define DRM_BO_MEM_PRIV4 7 ++ ++#define DRM_BO_MEM_TYPES 8 /* For now. */ ++ ++#define DRM_BO_LOCK_UNLOCK_BM (1 << 0) ++#define DRM_BO_LOCK_IGNORE_NO_EVICT (1 << 1) ++ ++struct drm_bo_version_arg { ++ uint32_t major; ++ uint32_t minor; ++ uint32_t patchlevel; ++}; ++ ++struct drm_mm_type_arg { ++ unsigned int mem_type; ++ unsigned int lock_flags; ++}; ++ ++struct drm_mm_init_arg { ++ unsigned int magic; ++ unsigned int major; ++ unsigned int minor; ++ unsigned int mem_type; ++ uint64_t p_offset; ++ uint64_t p_size; ++}; ++ ++/* ++ * Drm mode setting ++ */ ++#define DRM_DISPLAY_INFO_LEN 32 ++#define DRM_OUTPUT_NAME_LEN 32 ++#define DRM_DISPLAY_MODE_LEN 32 ++#define DRM_PROP_NAME_LEN 32 ++ ++#define DRM_MODE_TYPE_BUILTIN (1<<0) ++#define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN) ++#define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN) ++#define DRM_MODE_TYPE_PREFERRED (1<<3) ++#define DRM_MODE_TYPE_DEFAULT (1<<4) ++#define DRM_MODE_TYPE_USERDEF (1<<5) ++#define DRM_MODE_TYPE_DRIVER (1<<6) ++ ++struct drm_mode_modeinfo { ++ ++ unsigned int id; ++ ++ unsigned int clock; ++ unsigned short hdisplay, hsync_start, hsync_end, htotal, hskew; ++ unsigned short vdisplay, vsync_start, vsync_end, vtotal, vscan; ++ ++ unsigned int vrefresh; /* vertical refresh * 1000 */ ++ ++ unsigned int flags; ++ unsigned int type; ++ char name[DRM_DISPLAY_MODE_LEN]; ++}; ++ ++struct drm_mode_card_res { ++ ++ int count_fbs; ++ unsigned int __user *fb_id; ++ ++ int count_crtcs; ++ unsigned int __user *crtc_id; ++ ++ int count_outputs; ++ unsigned int __user *output_id; ++ ++ int count_modes; ++ struct drm_mode_modeinfo __user *modes; ++ ++}; ++ ++struct drm_mode_crtc { ++ unsigned int crtc_id; /**< Id */ ++ unsigned int fb_id; /**< Id of framebuffer */ ++ ++ int x, y; /**< Position on the frameuffer */ ++ ++ unsigned int mode; /**< Current mode used */ ++ ++ int count_outputs; ++ unsigned int outputs; /**< Outputs that are connected */ ++ ++ int count_possibles; ++ unsigned int possibles; /**< Outputs that can be connected */ ++ ++ unsigned int __user *set_outputs; /**< Outputs to be connected */ ++ ++ int gamma_size; ++ ++}; ++ ++struct drm_mode_get_output { ++ ++ unsigned int output; /**< Id */ ++ unsigned int crtc; /**< Id of crtc */ ++ unsigned char name[DRM_OUTPUT_NAME_LEN]; ++ ++ unsigned int connection; ++ unsigned int mm_width, mm_height; /**< HxW in millimeters */ ++ unsigned int subpixel; ++ ++ int count_crtcs; ++ unsigned int crtcs; /**< possible crtc to connect to */ ++ ++ int count_clones; ++ unsigned int clones; /**< list of clones */ ++ ++ int count_modes; ++ unsigned int __user *modes; /**< list of modes it supports */ ++ ++ int count_props; ++ unsigned int __user *props; ++ unsigned int __user *prop_values; ++}; ++ ++#define DRM_MODE_PROP_PENDING (1<<0) ++#define DRM_MODE_PROP_RANGE (1<<1) ++#define DRM_MODE_PROP_IMMUTABLE (1<<2) ++#define DRM_MODE_PROP_ENUM (1<<3) // enumerated type with text strings ++ ++struct drm_mode_property_enum { ++ uint32_t value; ++ unsigned char name[DRM_PROP_NAME_LEN]; ++}; ++ ++struct drm_mode_get_property { ++ ++ unsigned int prop_id; ++ unsigned int flags; ++ unsigned char name[DRM_PROP_NAME_LEN]; ++ ++ int count_values; ++ uint32_t __user *values; ++ ++ int count_enums; ++ struct drm_mode_property_enum *enums; ++}; ++ ++struct drm_mode_fb_cmd { ++ unsigned int buffer_id; ++ unsigned int width, height; ++ unsigned int pitch; ++ unsigned int bpp; ++ unsigned int handle; ++ unsigned int depth; ++}; ++ ++struct drm_mode_mode_cmd { ++ unsigned int output_id; ++ unsigned int mode_id; ++}; ++ + /** + * \name Ioctls Definitions + */ +@@ -708,6 +1101,45 @@ + + #define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw) + ++#define DRM_IOCTL_MM_INIT DRM_IOWR(0xc0, struct drm_mm_init_arg) ++#define DRM_IOCTL_MM_TAKEDOWN DRM_IOWR(0xc1, struct drm_mm_type_arg) ++#define DRM_IOCTL_MM_LOCK DRM_IOWR(0xc2, struct drm_mm_type_arg) ++#define DRM_IOCTL_MM_UNLOCK DRM_IOWR(0xc3, struct drm_mm_type_arg) ++ ++#define DRM_IOCTL_FENCE_CREATE DRM_IOWR(0xc4, struct drm_fence_arg) ++#define DRM_IOCTL_FENCE_REFERENCE DRM_IOWR(0xc6, struct drm_fence_arg) ++#define DRM_IOCTL_FENCE_UNREFERENCE DRM_IOWR(0xc7, struct drm_fence_arg) ++#define DRM_IOCTL_FENCE_SIGNALED DRM_IOWR(0xc8, struct drm_fence_arg) ++#define DRM_IOCTL_FENCE_FLUSH DRM_IOWR(0xc9, struct drm_fence_arg) ++#define DRM_IOCTL_FENCE_WAIT DRM_IOWR(0xca, struct drm_fence_arg) ++#define DRM_IOCTL_FENCE_EMIT DRM_IOWR(0xcb, struct drm_fence_arg) ++#define DRM_IOCTL_FENCE_BUFFERS DRM_IOWR(0xcc, struct drm_fence_arg) ++ ++#define DRM_IOCTL_BO_CREATE DRM_IOWR(0xcd, struct drm_bo_create_arg) ++#define DRM_IOCTL_BO_MAP DRM_IOWR(0xcf, struct drm_bo_map_wait_idle_arg) ++#define DRM_IOCTL_BO_UNMAP DRM_IOWR(0xd0, struct drm_bo_handle_arg) ++#define DRM_IOCTL_BO_REFERENCE DRM_IOWR(0xd1, struct drm_bo_reference_info_arg) ++#define DRM_IOCTL_BO_UNREFERENCE DRM_IOWR(0xd2, struct drm_bo_handle_arg) ++#define DRM_IOCTL_BO_SETSTATUS DRM_IOWR(0xd3, struct drm_bo_map_wait_idle_arg) ++#define DRM_IOCTL_BO_INFO DRM_IOWR(0xd4, struct drm_bo_reference_info_arg) ++#define DRM_IOCTL_BO_WAIT_IDLE DRM_IOWR(0xd5, struct drm_bo_map_wait_idle_arg) ++#define DRM_IOCTL_BO_VERSION DRM_IOR(0xd6, struct drm_bo_version_arg) ++ ++ ++#define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res) ++#define DRM_IOCTL_MODE_GETCRTC DRM_IOWR(0xA1, struct drm_mode_crtc) ++#define DRM_IOCTL_MODE_GETOUTPUT DRM_IOWR(0xA2, struct drm_mode_get_output) ++#define DRM_IOCTL_MODE_SETCRTC DRM_IOWR(0xA3, struct drm_mode_crtc) ++#define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xA4, struct drm_mode_fb_cmd) ++#define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int) ++#define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd) ++ ++#define DRM_IOCTL_MODE_ADDMODE DRM_IOWR(0xA7, struct drm_mode_modeinfo) ++#define DRM_IOCTL_MODE_RMMODE DRM_IOWR(0xA8, unsigned int) ++#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) ++#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) ++ ++#define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAB, struct drm_mode_get_property) + /*@}*/ + + /** +@@ -763,6 +1195,10 @@ + typedef struct drm_scatter_gather drm_scatter_gather_t; + typedef struct drm_set_version drm_set_version_t; + ++typedef struct drm_fence_arg drm_fence_arg_t; ++typedef struct drm_mm_type_arg drm_mm_type_arg_t; ++typedef struct drm_mm_init_arg drm_mm_init_arg_t; ++typedef enum drm_bo_type drm_bo_type_t; + #endif + + #endif +Index: libdrm-2.3.1/shared-core/i915_drm.h +=================================================================== +--- libdrm-2.3.1.orig/shared-core/i915_drm.h 2008-07-01 08:51:40.000000000 +0100 ++++ libdrm-2.3.1/shared-core/i915_drm.h 2009-01-14 18:26:59.000000000 +0000 +@@ -138,6 +138,14 @@ + + /* Driver specific fence types and classes. + */ ++ ++/* The only fence class we support */ ++#define DRM_I915_FENCE_CLASS_ACCEL 0 ++/* Fence type that guarantees read-write flush */ ++#define DRM_I915_FENCE_TYPE_RW 2 ++/* MI_FLUSH programmed just before the fence */ ++#define DRM_I915_FENCE_FLAG_FLUSHED 0x01000000 ++ + /* Flags for perf_boxes + */ + #define I915_BOX_RING_EMPTY 0x1 +@@ -167,6 +175,7 @@ + #define DRM_I915_VBLANK_SWAP 0x0f + #define DRM_I915_MMIO 0x10 + #define DRM_I915_HWS_ADDR 0x11 ++#define DRM_I915_EXECBUFFER 0x12 + + #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) + #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) +@@ -184,7 +193,7 @@ + #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t) + #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t) + #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t) +-#define DRM_IOCTL_I915_MMIO DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_MMIO, drm_i915_mmio) ++#define DRM_IOCTL_I915_EXECBUFFER DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_EXECBUFFER, struct drm_i915_execbuffer) + + /* Asynchronous page flipping: + */ +@@ -333,4 +342,40 @@ + uint64_t addr; + } drm_i915_hws_addr_t; + ++/* ++ * Relocation header is 4 uint32_ts ++ * 0 - (16-bit relocation type << 16)| 16 bit reloc count ++ * 1 - buffer handle for another list of relocs ++ * 2-3 - spare. ++ */ ++#define I915_RELOC_HEADER 4 ++ ++/* ++ * type 0 relocation has 4-uint32_t stride ++ * 0 - offset into buffer ++ * 1 - delta to add in ++ * 2 - index into buffer list ++ * 3 - reserved (for optimisations later). ++ */ ++#define I915_RELOC_TYPE_0 0 ++#define I915_RELOC0_STRIDE 4 ++ ++struct drm_i915_op_arg { ++ uint64_t next; ++ uint32_t reloc_handle; ++ int handled; ++ union { ++ struct drm_bo_op_req req; ++ struct drm_bo_arg_rep rep; ++ } d; ++ ++}; ++ ++struct drm_i915_execbuffer { ++ uint64_t ops_list; ++ uint32_t num_buffers; ++ struct drm_i915_batchbuffer batch; ++ struct drm_fence_arg fence_arg; ++}; ++ + #endif /* _I915_DRM_H_ */ +Index: libdrm-2.3.1/shared-core/Makefile.am +=================================================================== +--- libdrm-2.3.1.orig/shared-core/Makefile.am 2008-07-01 08:51:40.000000000 +0100 ++++ libdrm-2.3.1/shared-core/Makefile.am 2009-01-14 18:26:59.000000000 +0000 +@@ -29,10 +29,14 @@ + i915_drm.h \ + mach64_drm.h \ + mga_drm.h \ ++ nouveau_drm.h \ ++ psb_drm.h \ ++ psb_reg.h \ + r128_drm.h \ + radeon_drm.h \ + savage_drm.h \ + sis_drm.h \ + via_drm.h \ ++ psb_reg.h \ + r300_reg.h \ + via_3d_reg.h +Index: libdrm-2.3.1/shared-core/nouveau_drm.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ libdrm-2.3.1/shared-core/nouveau_drm.h 2009-01-14 18:26:59.000000000 +0000 +@@ -0,0 +1,164 @@ ++/* ++ * Copyright 2005 Stephane Marchesin. ++ * 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, 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL ++ * VA LINUX SYSTEMS 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 __NOUVEAU_DRM_H__ ++#define __NOUVEAU_DRM_H__ ++ ++#define NOUVEAU_DRM_HEADER_PATCHLEVEL 10 ++ ++struct drm_nouveau_channel_alloc { ++ uint32_t fb_ctxdma_handle; ++ uint32_t tt_ctxdma_handle; ++ ++ int channel; ++ uint32_t put_base; ++ /* FIFO control regs */ ++ drm_handle_t ctrl; ++ int ctrl_size; ++ /* DMA command buffer */ ++ drm_handle_t cmdbuf; ++ int cmdbuf_size; ++ /* Notifier memory */ ++ drm_handle_t notifier; ++ int notifier_size; ++}; ++ ++struct drm_nouveau_channel_free { ++ int channel; ++}; ++ ++struct drm_nouveau_grobj_alloc { ++ int channel; ++ uint32_t handle; ++ int class; ++}; ++ ++#define NOUVEAU_MEM_ACCESS_RO 1 ++#define NOUVEAU_MEM_ACCESS_WO 2 ++#define NOUVEAU_MEM_ACCESS_RW 3 ++struct drm_nouveau_notifierobj_alloc { ++ int channel; ++ uint32_t handle; ++ int count; ++ ++ uint32_t offset; ++}; ++ ++struct drm_nouveau_gpuobj_free { ++ int channel; ++ uint32_t handle; ++}; ++ ++#define NOUVEAU_MEM_FB 0