solaris-drm-port.patch revision 1089
546N/A# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
546N/A#
546N/A# Permission is hereby granted, free of charge, to any person obtaining a
546N/A# copy of this software and associated documentation files (the
546N/A# "Software"), to deal in the Software without restriction, including
546N/A# without limitation the rights to use, copy, modify, merge, publish,
546N/A# distribute, and/or sell copies of the Software, and to permit persons
546N/A# to whom the Software is furnished to do so, provided that the above
546N/A# copyright notice(s) and this permission notice appear in all copies of
546N/A# the Software and that both the above copyright notice(s) and this
546N/A# permission notice appear in supporting documentation.
546N/A#
546N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
546N/A# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
546N/A# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
546N/A# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
546N/A# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
546N/A# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
546N/A# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
546N/A# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
546N/A# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
546N/A#
546N/A# Except as contained in this notice, the name of a copyright holder
546N/A# shall not be used in advertising or otherwise to promote the sale, use
546N/A# or other dealings in this Software without prior written authorization
546N/A# of the copyright holder.
546N/A
546N/Adiff -urp -x '*~' -x '*.orig' include/drm/drm.h include/drm/drm.h
546N/A--- include/drm/drm.h 2010-06-06 18:11:46.000000000 -0700
546N/A+++ include/drm/drm.h 2011-01-24 19:15:45.548418714 -0800
546N/A@@ -54,10 +54,39 @@ typedef int32_t __s32;
546N/A typedef uint32_t __u32;
546N/A typedef int64_t __s64;
546N/A typedef uint64_t __u64;
546N/A+#if defined(__SOLARIS__) || defined(__sun)
546N/A+#include <sys/types32.h>
546N/A+typedef unsigned long long drm_handle_t;
546N/A+#else
546N/A typedef unsigned long drm_handle_t;
546N/A+#endif
546N/A
546N/A #endif
546N/A
546N/A+/* Solaris-specific. */
546N/A+#if defined(__SOLARIS__) || defined(__sun)
546N/A+
546N/A+#define _IOC_NRBITS 8
546N/A+#define _IOC_TYPEBITS 8
546N/A+#define _IOC_SIZEBITS 14
546N/A+#define _IOC_DIRBITS 2
546N/A+
546N/A+#define _IOC_NRSHIFT 0
546N/A+#define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS)
546N/A+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS)
546N/A+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS)
546N/A+
546N/A+#define _IOC(dir, type, nr, size) \
546N/A+ (((dir) /* already shifted */) | \
546N/A+ ((type) << _IOC_TYPESHIFT) | \
546N/A+ ((nr) << _IOC_NRSHIFT) | \
546N/A+ ((size) << _IOC_SIZESHIFT))
546N/A+
546N/A+#endif /* __Solaris__ or __sun */
546N/A+
546N/A+
546N/A+
546N/A+
546N/A #define DRM_NAME "drm" /**< Name in kernel, /dev, and /proc */
546N/A #define DRM_MIN_ORDER 5 /**< At least 2^5 bytes = 32 bytes */
546N/A #define DRM_MAX_ORDER 22 /**< Up to 2^22 bytes = 4MB */
546N/A@@ -210,12 +239,13 @@ struct drm_ctx_priv_map {
546N/A * \sa drmAddMap().
546N/A */
546N/A struct drm_map {
546N/A- unsigned long offset; /**< Requested physical address (0 for SAREA)*/
546N/A+ unsigned long long offset; /**< Requested physical address (0 for SAREA)*/
546N/A+ unsigned long long handle;
546N/A+ /**< User-space: "Handle" to pass to mmap() */
546N/A+ /**< Kernel-space: kernel-virtual address */
546N/A unsigned long size; /**< Requested physical size (bytes) */
546N/A enum drm_map_type type; /**< Type of memory to map */
546N/A enum drm_map_flags flags; /**< Flags */
546N/A- void *handle; /**< User-space: "Handle" to pass to mmap() */
546N/A- /**< Kernel-space: kernel-virtual address */
546N/A int mtrr; /**< MTRR slot used */
546N/A /* Private data */
546N/A };
546N/A@@ -322,18 +352,22 @@ enum drm_dma_flags {
546N/A *
546N/A * \sa drmAddBufs().
546N/A */
546N/A+
546N/A+typedef enum {
546N/A+ _DRM_PAGE_ALIGN = 0x01, /**< Align on page boundaries for DMA */
546N/A+ _DRM_AGP_BUFFER = 0x02, /**< Buffer is in AGP space */
546N/A+ _DRM_SG_BUFFER = 0x04, /**< Scatter/gather memory buffer */
546N/A+ _DRM_FB_BUFFER = 0x08, /**< Buffer is in frame buffer */
546N/A+ _DRM_PCI_BUFFER_RO = 0x10 /**< Map PCI DMA buffer read-only */
546N/A+} drm_buf_flag;
546N/A+
546N/A+
546N/A struct drm_buf_desc {
546N/A int count; /**< Number of buffers of this size */
546N/A int size; /**< Size in bytes */
546N/A int low_mark; /**< Low water mark */
546N/A int high_mark; /**< High water mark */
546N/A- enum {
546N/A- _DRM_PAGE_ALIGN = 0x01, /**< Align on page boundaries for DMA */
546N/A- _DRM_AGP_BUFFER = 0x02, /**< Buffer is in AGP space */
546N/A- _DRM_SG_BUFFER = 0x04, /**< Scatter/gather memory buffer */
546N/A- _DRM_FB_BUFFER = 0x08, /**< Buffer is in frame buffer */
546N/A- _DRM_PCI_BUFFER_RO = 0x10 /**< Map PCI DMA buffer read-only */
546N/A- } flags;
546N/A+ drm_buf_flag flags;
546N/A unsigned long agp_start; /**<
546N/A * Start address of where the AGP buffers are
546N/A * in the AGP aperture
546N/A@@ -375,6 +409,7 @@ struct drm_buf_map {
546N/A int count; /**< Length of the buffer list */
546N/A void *virtual; /**< Mmap'd area in user-virtual */
546N/A struct drm_buf_pub *list; /**< Buffer information */
546N/A+ int fd;
546N/A };
546N/A
546N/A /**
546N/Adiff -urp -x '*~' -x '*.orig' include/drm/i915_drm.h include/drm/i915_drm.h
546N/A--- include/drm/i915_drm.h 2010-06-07 16:33:16.000000000 -0700
546N/A+++ include/drm/i915_drm.h 2011-01-24 19:15:45.548058832 -0800
546N/A@@ -75,6 +75,7 @@ typedef struct _drm_i915_sarea {
546N/A int pf_current_page; /* which buffer is being displayed? */
546N/A int perf_boxes; /* performance boxes to be displayed */
546N/A int width, height; /* screen size in pixels */
546N/A+ int pad0;
546N/A
546N/A drm_handle_t front_handle;
546N/A int front_offset;
546N/A@@ -114,6 +115,8 @@ typedef struct _drm_i915_sarea {
546N/A int pipeB_w;
546N/A int pipeB_h;
546N/A
546N/A+ int pad1;
546N/A+
546N/A /* fill out some space for old userspace triple buffer */
546N/A drm_handle_t unused_handle;
546N/A __u32 unused1, unused2, unused3;
546N/Adiff -urp -x '*~' -x '*.orig' libkms/intel.c libkms/intel.c
546N/A--- libkms/intel.c 2010-06-06 18:11:46.000000000 -0700
546N/A+++ libkms/intel.c 2011-01-24 19:15:45.549160465 -0800
546N/A@@ -37,6 +37,7 @@
546N/A
546N/A #include <sys/mman.h>
546N/A #include <sys/ioctl.h>
546N/A+#include <unistd.h>
546N/A #include "xf86drm.h"
546N/A
546N/A #include "i915_drm.h"
546N/A@@ -190,6 +191,30 @@ intel_bo_unmap(struct kms_bo *_bo)
546N/A return 0;
546N/A }
546N/A
546N/A+int
546N/A+drmIoctl(int fd, unsigned long request, void *arg)
546N/A+{
546N/A+ int ret;
546N/A+
546N/A+ do {
546N/A+ ret = ioctl(fd, request, arg);
546N/A+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
546N/A+ return ret;
546N/A+}
546N/A+
546N/A+int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data,
546N/A+ unsigned long size)
546N/A+{
546N/A+ unsigned long request;
546N/A+
546N/A+ request = DRM_IOC( DRM_IOC_READ|DRM_IOC_WRITE, DRM_IOCTL_BASE,
546N/A+ DRM_COMMAND_BASE + drmCommandIndex, size);
546N/A+
546N/A+ if (drmIoctl(fd, request, data))
546N/A+ return -errno;
546N/A+ return 0;
546N/A+}
546N/A+
546N/A static int
546N/A intel_bo_destroy(struct kms_bo *_bo)
546N/A {
546N/Adiff -urp -x '*~' -x '*.orig' libkms/linux.c libkms/linux.c
--- libkms/linux.c 2010-06-06 18:11:46.000000000 -0700
+++ libkms/linux.c 2011-01-24 19:15:45.548957995 -0800
@@ -39,6 +39,7 @@
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include "internal.h"
diff -urp -x '*~' -x '*.orig' tests/Makefile.am tests/Makefile.am
--- tests/Makefile.am 2010-06-06 18:11:45.000000000 -0700
+++ tests/Makefile.am 2011-01-24 19:15:45.549320900 -0800
@@ -1,5 +1,3 @@
-NULL:=#
-
AM_CPPFLAGS = \
-I $(top_srcdir)/include/drm \
-I $(top_srcdir)
diff -urp -x '*~' -x '*.orig' xf86drm.c xf86drm.c
--- xf86drm.c 2010-06-06 18:11:46.000000000 -0700
+++ xf86drm.c 2011-01-24 19:15:45.547448918 -0800
@@ -967,7 +967,7 @@ int drmRmMap(int fd, drm_handle_t handle
{
drm_map_t map;
- map.handle = (void *)handle;
+ map.handle = (drm_handle_t)handle;
if(drmIoctl(fd, DRM_IOCTL_RM_MAP, &map))
return -errno;
diff -urp -x '*~' -x '*.orig' xf86drm.h xf86drm.h
--- xf86drm.h 2010-06-06 18:11:46.000000000 -0700
+++ xf86drm.h 2011-01-24 19:15:45.547758484 -0800
@@ -451,6 +451,17 @@ do { register unsigned int __old __asm("
#endif /* architecture */
#endif /* __GNUC__ >= 2 */
+#if defined(__SUNPRO_C)
+#include <atomic.h>
+#define atomic_cmpset_int(p, c, n) ((c == atomic_cas_uint(p, c, n)) ? 1 : 0)
+#define DRM_CAS(lock,old,new,__ret) \
+ do { \
+ unsigned int __result, __old = (old);\
+ __result = !atomic_cmpset_int(lock,__old,new);\
+ __ret = __result; \
+ } while(0)
+#endif
+
#ifndef DRM_CAS
#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
#endif
diff -urp -x '*~' -x '*.orig' xf86drmMode.c xf86drmMode.c
--- xf86drmMode.c 2010-06-06 18:11:45.000000000 -0700
+++ xf86drmMode.c 2011-01-24 19:15:45.548770835 -0800
@@ -708,7 +708,9 @@ int drmCheckModesettingSupported(const c
if (found)
return 0;
#endif
- return -ENOSYS;
+
+/* for now return 0 on solaris */
+ return 0;
}