summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac73
-rw-r--r--man/intel.man5
-rw-r--r--src/intel_device.c84
-rw-r--r--src/intel_driver.h1
-rw-r--r--src/intel_options.c1
-rw-r--r--src/intel_options.h1
6 files changed, 139 insertions, 26 deletions
diff --git a/configure.ac b/configure.ac
index f9f3836a..ec237c45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -276,7 +276,9 @@ AC_ARG_WITH(xorg-module-dir,
AC_ARG_ENABLE(dri,
AS_HELP_STRING([--disable-dri],
- [Disable DRI support [[default=auto]]]))
+ [Disable DRI support [[default=auto]]]),
+ [DRI=$enableval],
+ [DRI=auto])
AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--disable-xvmc],
[Disable XvMC support [[default=yes]]]),
@@ -445,13 +447,13 @@ fi
DRI1=no
-if test "x$enable_dri" != "xno" -a "x$UMS" = "xyes"; then
- PKG_CHECK_MODULES(DRI1, [xf86driproto], [DRI1="yes"], [DRI1="no"])
+if test "x$DRI" != "xno" -a "x$UMS" = "xyes"; then
+ PKG_CHECK_MODULES(DRI1, [xf86driproto], [DRI1=$DRI], [DRI1=no])
save_CFLAGS="$CFLAGS"
save_CPPFLAGS="$CPPFLAGS"
CFLAGS="$CFLAGS $XORG_CFLAGS $DRI1_CFLAGS $DRM_CFLAGS"
CPPFLAGS="$CPPFLAGS $XORG_CFLAGS $DRI1_CFLAGS $DRM_CFLAGS"
- AC_CHECK_HEADERS([dri.h sarea.h dristruct.h], [DRI1="yes"], [DRI1="no"],
+ AC_CHECK_HEADERS([dri.h sarea.h dristruct.h], [], [DRI1=no],
[/* for dri.h */
#include <xf86str.h>
/* for dristruct.h */
@@ -463,7 +465,7 @@ if test "x$enable_dri" != "xno" -a "x$UMS" = "xyes"; then
# include <sarea.h>
#endif
])
- CFLAGS="$save_CFLAGS $DEBUGFLAGS"
+ CFLAGS="$save_CFLAGS"
CPPFLAGS="$save_CPPFLAGS"
fi
@@ -478,14 +480,15 @@ else
DRI1_CFLAGS=""
DRI1_LIBS=""
- if test "x$enable_dri" = "xyes" -a "x$UMS" = "xyes"; then
+ if test "x$DRI" = "xyes" -a "x$UMS" = "xyes"; then
AC_MSG_ERROR([DRI1 requested but prerequisites not found])
fi
fi
DRI2=no
-if test "x$enable_dri" != "xno"; then
- PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6], DRI2="yes", DRI2="no")
+DRI3=no
+if test "x$DRI" != "xno"; then
+ PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6], [DRI2=$DRI], [DRI2=no])
dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
if test "x$dridriverdir" = "x"; then
dridriverdir="$libdir/dri"
@@ -494,21 +497,38 @@ if test "x$enable_dri" != "xno"; then
if test "x$DRI2" != "xno"; then
save_CFLAGS=$CFLAGS
CFLAGS="$XORG_CFLAGS $DRM_CFLAGS $DRI1_CFLAGS $DRI2_CFLAGS"
- AC_CHECK_HEADERS([dri2.h], DRI2="yes", DRI2="no", [
+ AC_CHECK_HEADERS([dri2.h], [], [DRI2=no], [
#include <dixstruct.h>
#include <drm.h>
])
CFLAGS=$save_CFLAGS
fi
+
+ XORG_DRIVER_CHECK_EXT(DRI3, dri3proto)
+ if test "x$_EXT_CHECK" != "xno"; then
+ DRI3=$DRI
+ fi
+ if test "x$DRI3" != "xno"; then
+ save_CFLAGS=$CFLAGS
+ CFLAGS="$XORG_CFLAGS $DRI3_CFLAGS"
+ AC_CHECK_DECL(DRI3, [], [DRI3=no], [#include <xorg-server.h>])
+ AC_CHECK_HEADERS([misyncstr.h misyncshm.h], [], [DRI3=no], [
+#include <xorg-server.h>
+#include <xf86str.h>
+#include <misync.h>
+])
+ CFLAGS=$save_CFLAGS
+ fi
fi
+
AC_MSG_CHECKING([whether to include DRI2 support])
-AM_CONDITIONAL(DRI2, test "x$DRI2" = "xyes")
+AM_CONDITIONAL(DRI2, test "x$DRI2" != "xno")
AC_MSG_RESULT([$DRI2])
if test "x$DRI2" != "xno"; then
AC_DEFINE(HAVE_DRI2,1,[Enable DRI2 driver support])
dri_msg="$dri_msg DRI2"
else
- if test "x$enable_dri" = "xyes" -a "x$KMS" = "xyes"; then
+ if test "x$DRI" = "xyes" -a "x$KMS" = "xyes"; then
AC_MSG_ERROR([DRI2 requested but prerequisites not found])
fi
@@ -516,8 +536,39 @@ else
UXA=no
fi
+AC_MSG_CHECKING([whether to include DRI3 support])
+AM_CONDITIONAL(DRI3, test "x$DRI3" != "xno")
+AC_MSG_RESULT([$DRI3])
+if test "x$DRI3" != "xno"; then
+ AC_DEFINE(HAVE_DRI3,1,[Enable DRI3 driver support])
+ dri_msg="$dri_msg DRI3"
+else
+ if test "x$DRI" = "xyes" -a "x$KMS" = "xyes"; then
+ AC_MSG_ERROR([DRI3 requested but prerequisites not found])
+ fi
+fi
+
AC_CHECK_HEADERS([X11/extensions/dpmsconst.h])
+has_present="no"
+XORG_DRIVER_CHECK_EXT(PRESENT, presentproto)
+if test "x$_EXT_CHECK" != "xno"; then
+ save_CFLAGS=$CFLAGS
+ CFLAGS=$XORG_CFLAGS
+ AC_CHECK_HEADERS([present.h], [has_present="yes"], [], [
+#include <xorg-server.h>
+#include <xf86str.h>
+])
+ CFLAGS=$save_CFLAGS
+fi
+AC_MSG_CHECKING([whether to include PRESENT support])
+AM_CONDITIONAL(PRESENT, test "x$has_present" != "xno")
+AC_MSG_RESULT([$has_present])
+if test "x$has_present" != "xno"; then
+ AC_DEFINE(HAVE_PRESENT,1,[Enable PRESENT driver support])
+ dri_msg="$dri_msg Present"
+fi
+
AC_MSG_CHECKING([whether to include UXA support])
AC_MSG_RESULT([$UXA])
AM_CONDITIONAL(UXA, test "x$UXA" != "xno")
diff --git a/man/intel.man b/man/intel.man
index e1361bf6..27206e37 100644
--- a/man/intel.man
+++ b/man/intel.man
@@ -121,6 +121,11 @@ Disable or enable acceleration.
.IP
Default: acceleration is enabled.
.TP
+.BI "Option \*qPresent\*q \*q" boolean \*q
+Enable use of hardware counters and flow control for the Present extension.
+.IP
+Default: Enabled
+.TP
.BI "Option \*qAccelMethod\*q \*q" string \*q
Select acceleration method.
There are a couple of backends available for accelerating the DDX. \*qUXA\*q (Unified
diff --git a/src/intel_device.c b/src/intel_device.c
index 43372284..7140bebd 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -104,7 +104,7 @@ static inline void intel_set_device(ScrnInfoPtr scrn, struct intel_device *dev)
xf86GetEntityPrivate(scrn->entityList[0], intel_device_key)->ptr = dev;
}
-static Bool is_i915_device(int fd)
+static int is_i915_device(int fd)
{
drm_version_t version;
char name[5] = "";
@@ -114,30 +114,40 @@ static Bool is_i915_device(int fd)
version.name = name;
if (drmIoctl(fd, DRM_IOCTL_VERSION, &version))
- return FALSE;
+ return 0;
return strcmp("i915", name) == 0;
}
-static int __intel_check_device(int fd)
+static int is_i915_gem(int fd)
{
- int ret;
+ int ret = is_i915_device(fd);
- /* Confirm that this is a i915.ko device with GEM/KMS enabled */
- ret = is_i915_device(fd);
if (ret) {
struct drm_i915_getparam gp;
+
gp.param = I915_PARAM_HAS_GEM;
gp.value = &ret;
+
if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
- ret = FALSE;
+ ret = 0;
}
+
+ return ret;
+}
+
+static int __intel_check_device(int fd)
+{
+ int ret;
+
+ /* Confirm that this is a i915.ko device with GEM/KMS enabled */
+ ret = is_i915_gem(fd);
if (ret && !hosted()) {
struct drm_mode_card_res res;
memset(&res, 0, sizeof(res));
if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
- ret = FALSE;
+ ret = 0;
}
return ret;
@@ -203,20 +213,25 @@ static char *find_master_node(int fd)
return drmGetDeviceNameFromFd(fd);
}
+static int is_render_node(int fd, struct stat *st)
+{
+ if (fstat(fd, st))
+ return 0;
+
+ if (!S_ISCHR(st->st_mode))
+ return 0;
+
+ return st->st_rdev & 0x80;
+}
+
static char *find_render_node(int fd)
{
#if defined(USE_RENDERNODE)
struct stat master, render;
char buf[128];
- if (fstat(fd, &master))
- return NULL;
-
- if (!S_ISCHR(master.st_mode))
- return NULL;
-
/* Are we a render-node ourselves? */
- if (master.st_rdev & 0x80)
+ if (is_render_node(fd, &master))
return NULL;
sprintf(buf, "/dev/dri/renderD%d", (int)((master.st_rdev | 0x80) & 0xbf));
@@ -400,6 +415,45 @@ const char *intel_get_client_name(ScrnInfoPtr scrn)
return dev->render_node;
}
+static int authorise(struct intel_device *dev, int fd)
+{
+ struct stat st;
+ drm_magic_t magic;
+
+ assert(is_i915_gem(fd));
+
+ if (is_render_node(fd, &st)) /* restricted authority, do not elevate */
+ return 1;
+
+ return drmGetMagic(fd, &magic) == 0 && drmAuthMagic(dev->fd, magic) == 0;
+}
+
+int intel_get_client_fd(ScrnInfoPtr scrn)
+{
+ struct intel_device *dev;
+ int fd = -1;
+
+ dev = intel_device(scrn);
+ assert(dev);
+ assert(dev->fd != -1);
+ assert(dev->render_node);
+
+#ifdef O_CLOEXEC
+ fd = open(dev->render_node, O_RDWR | O_CLOEXEC);
+#endif
+ if (fd < 0)
+ fd = fd_set_cloexec(open(dev->render_node, O_RDWR));
+ if (fd < 0)
+ return -BadAlloc;
+
+ if (!authorise(dev, fd)) {
+ close(fd);
+ return -BadMatch;
+ }
+
+ return fd;
+}
+
int intel_get_device_id(ScrnInfoPtr scrn)
{
struct intel_device *dev = intel_device(scrn);
diff --git a/src/intel_driver.h b/src/intel_driver.h
index 182a30eb..3dc640cf 100644
--- a/src/intel_driver.h
+++ b/src/intel_driver.h
@@ -127,6 +127,7 @@ int intel_open_device(int entity_num,
struct xf86_platform_device *dev);
int intel_get_device(ScrnInfoPtr scrn);
const char *intel_get_client_name(ScrnInfoPtr scrn);
+int intel_get_client_fd(ScrnInfoPtr scrn);
int intel_get_device_id(ScrnInfoPtr scrn);
int intel_get_master(ScrnInfoPtr scrn);
int intel_put_master(ScrnInfoPtr scrn);
diff --git a/src/intel_options.c b/src/intel_options.c
index 51d5462d..ff8541a4 100644
--- a/src/intel_options.c
+++ b/src/intel_options.c
@@ -9,6 +9,7 @@ const OptionInfoRec intel_options[] = {
{OPTION_ACCEL_METHOD, "AccelMethod", OPTV_STRING, {0}, 0},
{OPTION_BACKLIGHT, "Backlight", OPTV_STRING, {0}, 0},
{OPTION_DRI, "DRI", OPTV_STRING, {0}, 0},
+ {OPTION_PRESENT, "Present", OPTV_BOOLEAN, {0}, 1},
{OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, 0},
{OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, 0},
{OPTION_TILING_2D, "Tiling", OPTV_BOOLEAN, {0}, 1},
diff --git a/src/intel_options.h b/src/intel_options.h
index 6873a6dd..7e2cbd9b 100644
--- a/src/intel_options.h
+++ b/src/intel_options.h
@@ -16,6 +16,7 @@ enum intel_options {
OPTION_ACCEL_METHOD,
OPTION_BACKLIGHT,
OPTION_DRI,
+ OPTION_PRESENT,
OPTION_VIDEO_KEY,
OPTION_COLOR_KEY,
OPTION_TILING_2D,