summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--dix/dispatch.c2
-rw-r--r--dix/getevents.c6
-rw-r--r--glamor/glamor.c28
-rw-r--r--glamor/glamor.h3
-rw-r--r--glamor/glamor_egl.c18
-rw-r--r--glamor/glamor_fbo.c4
-rw-r--r--glamor/glamor_priv.h1
-rw-r--r--glamor/glamor_xv.c26
-rw-r--r--hw/xfree86/Makefile.am2
-rw-r--r--hw/xfree86/Xorg.sh.in4
-rw-r--r--hw/xfree86/common/xf86AutoConfig.c1
-rw-r--r--hw/xfree86/drivers/modesetting/Makefile.am3
-rw-r--r--hw/xfree86/drivers/modesetting/dri2.c2
-rw-r--r--hw/xfree86/drivers/modesetting/driver.c92
-rw-r--r--hw/xfree86/drivers/modesetting/driver.h14
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.c341
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.h28
-rw-r--r--hw/xfree86/drivers/modesetting/dumb_bo.c134
-rw-r--r--hw/xfree86/drivers/modesetting/dumb_bo.h45
-rw-r--r--hw/xfree86/drivers/modesetting/present.c228
-rw-r--r--hw/xfree86/drivers/modesetting/vblank.c28
-rw-r--r--hw/xfree86/man/Xorg.wrap.man2
-rw-r--r--hw/xfree86/os-support/solaris/sun_init.c33
-rw-r--r--hw/xfree86/os-support/xf86_OSlib.h5
-rw-r--r--hw/xfree86/xorg-wrapper.c10
-rw-r--r--hw/xwayland/Makefile.am1
-rw-r--r--hw/xwayland/xwayland-input.c7
-rw-r--r--os/osinit.c6
-rw-r--r--os/xsha1.c25
-rw-r--r--present/present.c15
31 files changed, 787 insertions, 329 deletions
diff --git a/configure.ac b/configure.ac
index 96524c58b..b593fc75a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -923,7 +923,7 @@ if test "x$SUID_WRAPPER" = xyes; then
PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
dnl This is a define so that if some platforms want to put the wrapper
dnl somewhere else this can be easily changed
- AC_DEFINE_DIR(SUID_WRAPPER_DIR, libexecdir, [Where to install Xorg.bin and Xorg.wrap])
+ AC_DEFINE_DIR(SUID_WRAPPER_DIR, libexecdir, [Where to install the Xorg binary and Xorg.wrap])
SETUID="no"
fi
AM_CONDITIONAL(SUID_WRAPPER, [test "x$SUID_WRAPPER" = xyes])
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 55b978dea..9044ac786 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) +
diff --git a/dix/getevents.c b/dix/getevents.c
index dd9626526..6fb12c5c1 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -2044,7 +2044,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
event->root = scr->root->drawable.id;
- event_set_root_coordinates(event, screenx, screeny);
+ event_set_root_coordinates(event, screenx - scr->x, screeny - scr->y);
event->touchid = client_id;
event->flags = flags;
@@ -2082,8 +2082,8 @@ GetDixTouchEnd(InternalEvent *ievent, DeviceIntPtr dev, TouchPointInfoPtr ti,
/* Get screen event coordinates from the sprite. Is this really the best
* we can do? */
event_set_root_coordinates(event,
- dev->last.valuators[0],
- dev->last.valuators[1]);
+ dev->last.valuators[0] - scr->x,
+ dev->last.valuators[1] - scr->y);
event->touchid = ti->client_id;
event->flags = flags;
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 6cf9bdf9d..78e827809 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -216,17 +216,24 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
return pixmap;
}
-Bool
-glamor_destroy_pixmap(PixmapPtr pixmap)
+void
+glamor_destroy_textured_pixmap(PixmapPtr pixmap)
{
if (pixmap->refcnt == 1) {
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
- if (pixmap_priv != NULL)
- glamor_pixmap_destroy_fbo(pixmap_priv);
+ if (pixmap_priv != NULL) {
#if GLAMOR_HAS_GBM
- glamor_egl_destroy_pixmap_image(pixmap);
+ glamor_egl_destroy_pixmap_image(pixmap);
#endif
+ glamor_set_pixmap_private(pixmap, NULL);
+ }
}
+}
+
+Bool
+glamor_destroy_pixmap(PixmapPtr pixmap)
+{
+ glamor_destroy_textured_pixmap(pixmap);
return fbDestroyPixmap(pixmap);
}
@@ -416,6 +423,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_set_debug_level(&glamor_debug_level);
+ glamor_priv->saved_procs.close_screen = screen->CloseScreen;
+ screen->CloseScreen = glamor_close_screen;
+
/* If we are using egl screen, call egl screen init to
* register correct close screen function. */
if (flags & GLAMOR_USE_EGL_SCREEN) {
@@ -425,9 +435,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
goto fail;
}
- glamor_priv->saved_procs.close_screen = screen->CloseScreen;
- screen->CloseScreen = glamor_close_screen;
-
glamor_priv->saved_procs.create_screen_resources =
screen->CreateScreenResources;
screen->CreateScreenResources = glamor_create_screen_resources;
@@ -546,7 +553,6 @@ _X_EXPORT void
glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
{
glamor_pixmap_private *old_priv;
- glamor_pixmap_fbo *fbo;
old_priv = dixGetPrivate(&pixmap->devPrivates, &glamor_pixmap_private_key);
@@ -556,8 +562,8 @@ glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
else {
if (old_priv == NULL)
return;
- fbo = glamor_pixmap_detach_fbo(old_priv);
- glamor_purge_fbo(fbo);
+
+ glamor_pixmap_destroy_fbo(old_priv);
free(old_priv);
}
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 168341443..206158c02 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -132,6 +132,7 @@ extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
glamor_pixmap_type_t type);
+extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
@@ -171,6 +172,8 @@ extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap);
+extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen);
+
/* @glamor_supports_pixmap_import_export: Returns whether
* glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
* glamor_pixmap_from_fd() are supported.
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index e821601ac..113450c8d 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -174,6 +174,18 @@ glamor_create_texture_from_image(ScreenPtr screen,
return TRUE;
}
+void *
+glamor_egl_get_gbm_device(ScreenPtr screen)
+{
+#ifdef GLAMOR_HAS_GBM
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
+ return glamor_egl->gbm;
+#else
+ return NULL;
+#endif
+}
+
unsigned int
glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
{
@@ -558,6 +570,12 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
}
+void
+glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
+{
+ glamor_destroy_textured_pixmap(pixmap);
+}
+
static Bool
glamor_egl_close_screen(ScreenPtr screen)
{
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 42738268c..8d73e4765 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -126,7 +126,7 @@ glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
#endif
}
-void
+static void
glamor_purge_fbo(glamor_pixmap_fbo *fbo)
{
glamor_make_current(fbo->glamor_priv);
@@ -540,8 +540,6 @@ glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv)
if (fbo)
glamor_destroy_fbo(fbo);
}
-
- free(priv);
}
Bool
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index ffd327e13..f69949790 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -653,7 +653,6 @@ glamor_pixmap_fbo *glamor_create_fbo(glamor_screen_private *glamor_priv, int w,
int h, GLenum format, int flag);
void glamor_destroy_fbo(glamor_pixmap_fbo *fbo);
void glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv);
-void glamor_purge_fbo(glamor_pixmap_fbo *fbo);
void glamor_init_pixmap_fbo(ScreenPtr screen);
void glamor_fini_pixmap_fbo(ScreenPtr screen);
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 26bdef66b..83e24adb2 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -208,15 +208,14 @@ glamor_xv_query_image_attributes(int id,
switch (id) {
case FOURCC_YV12:
case FOURCC_I420:
- *h = *h;
- *w = *w;
- size = *w;
+ *h = ALIGN(*h, 2);
+ size = ALIGN(*w, 4);
if (pitches)
pitches[0] = size;
size *= *h;
if (offsets)
offsets[1] = size;
- tmp = *w >> 1;
+ tmp = ALIGN(*w >> 1, 4);
if (pitches)
pitches[1] = pitches[2] = tmp;
tmp *= (*h >> 1);
@@ -413,9 +412,6 @@ glamor_xv_put_image(glamor_port_private *port_priv,
s2offset = s3offset = srcPitch2 = 0;
- srcPitch = width;
- srcPitch2 = width >> 1;
-
if (!port_priv->src_pix[0] ||
(width != port_priv->src_pix_w || height != port_priv->src_pix_h)) {
int i;
@@ -439,11 +435,13 @@ glamor_xv_put_image(glamor_port_private *port_priv,
}
top = (src_y) & ~1;
- nlines = (src_y + height) - top;
+ nlines = (src_y + src_h) - top;
switch (id) {
case FOURCC_YV12:
case FOURCC_I420:
+ srcPitch = ALIGN(width, 4);
+ srcPitch2 = ALIGN(width >> 1, 4);
s2offset = srcPitch * height;
s3offset = s2offset + (srcPitch2 * ((height + 1) >> 1));
s2offset += ((top >> 1) * srcPitch2);
@@ -454,18 +452,18 @@ glamor_xv_put_image(glamor_port_private *port_priv,
s3offset = tmp;
}
glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[0],
- 0, 0, srcPitch, nlines,
- port_priv->src_pix[0]->devKind,
+ 0, 0, width, nlines,
+ srcPitch,
buf + (top * srcPitch), 0);
glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[1],
- 0, 0, srcPitch2, (nlines + 1) >> 1,
- port_priv->src_pix[1]->devKind,
+ 0, 0, width >> 1, (nlines + 1) >> 1,
+ srcPitch2,
buf + s2offset, 0);
glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[2],
- 0, 0, srcPitch2, (nlines + 1) >> 1,
- port_priv->src_pix[2]->devKind,
+ 0, 0, width >> 1, (nlines + 1) >> 1,
+ srcPitch2,
buf + s3offset, 0);
break;
default:
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index d46bf0a86..27f2cc6cb 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -106,7 +106,7 @@ if INSTALL_SETUID
endif
if SUID_WRAPPER
$(MKDIR_P) $(DESTDIR)$(SUID_WRAPPER_DIR)
- mv $(DESTDIR)$(bindir)/Xorg $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg.bin
+ mv $(DESTDIR)$(bindir)/Xorg $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg
${INSTALL} -m 755 Xorg.sh $(DESTDIR)$(bindir)/Xorg
-chown root $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg.wrap && chmod u+s $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg.wrap
endif
diff --git a/hw/xfree86/Xorg.sh.in b/hw/xfree86/Xorg.sh.in
index cef4859c8..481413523 100644
--- a/hw/xfree86/Xorg.sh.in
+++ b/hw/xfree86/Xorg.sh.in
@@ -1,11 +1,11 @@
#!/bin/sh
#
-# Execute Xorg.wrap if it exists otherwise execute Xorg.bin directly.
+# Execute Xorg.wrap if it exists otherwise execute Xorg directly.
# This allows distros to put the suid wrapper in a separate package.
basedir=@SUID_WRAPPER_DIR@
if [ -x "$basedir"/Xorg.wrap ]; then
exec "$basedir"/Xorg.wrap "$@"
else
- exec "$basedir"/Xorg.bin "$@"
+ exec "$basedir"/Xorg "$@"
fi
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 03dad150a..1450afbfc 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -208,7 +208,6 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
if (xf86Info.consoleFd >= 0 && (i < (nmatches - 1))) {
struct vis_identifier visid;
const char *cp;
- extern char xf86SolarisFbDev[PATH_MAX];
int iret;
SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid));
diff --git a/hw/xfree86/drivers/modesetting/Makefile.am b/hw/xfree86/drivers/modesetting/Makefile.am
index 5b08600c1..82c4f2f32 100644
--- a/hw/xfree86/drivers/modesetting/Makefile.am
+++ b/hw/xfree86/drivers/modesetting/Makefile.am
@@ -48,6 +48,9 @@ modesetting_drv_la_SOURCES = \
driver.h \
drmmode_display.c \
drmmode_display.h \
+ dumb_bo.c \
+ dumb_bo.h \
+ present.c \
vblank.c \
$(NULL)
diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index 6c88060b0..63cb0659d 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -43,8 +43,6 @@
#include "dri2.h"
#ifdef GLAMOR
-#define GLAMOR_FOR_XORG 1
-#include "glamor.h"
enum ms_dri2_frame_event_type {
MS_DRI2_QUEUE_SWAP,
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index d1284c6fc..1ebf807e5 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -61,11 +61,6 @@
#include "driver.h"
-#ifdef GLAMOR
-#define GLAMOR_FOR_XORG 1
-#include "glamor.h"
-#endif
-
static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
static Bool CloseScreen(ScreenPtr pScreen);
static Bool EnterVT(ScrnInfoPtr pScrn);
@@ -453,11 +448,12 @@ dispatch_dirty_region(ScrnInfoPtr scrn,
modesettingPtr ms = modesettingPTR(scrn);
RegionPtr dirty = DamageRegion(damage);
unsigned num_cliprects = REGION_NUM_RECTS(dirty);
+ int ret = 0;
if (num_cliprects) {
drmModeClip *clip = malloc(num_cliprects * sizeof(drmModeClip));
BoxPtr rect = REGION_RECTS(dirty);
- int i, ret;
+ int i;
if (!clip)
return -ENOMEM;
@@ -474,12 +470,8 @@ dispatch_dirty_region(ScrnInfoPtr scrn,
ret = drmModeDirtyFB(ms->fd, fb_id, clip, num_cliprects);
free(clip);
DamageEmpty(damage);
- if (ret) {
- if (ret == -EINVAL)
- return ret;
- }
}
- return 0;
+ return ret;
}
static void
@@ -861,7 +853,7 @@ msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode,
stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8;
*size = stride;
- return ((uint8_t *) ms->drmmode.front_bo->ptr + row * stride + offset);
+ return ((uint8_t *) ms->drmmode.front_bo.dumb->ptr + row * stride + offset);
}
static void
@@ -877,7 +869,8 @@ CreateScreenResources(ScreenPtr pScreen)
modesettingPtr ms = modesettingPTR(pScrn);
PixmapPtr rootPixmap;
Bool ret;
- void *pixels;
+ void *pixels = NULL;
+ int err;
pScreen->CreateScreenResources = ms->createScreenResources;
ret = pScreen->CreateScreenResources(pScreen);
@@ -886,27 +879,19 @@ CreateScreenResources(ScreenPtr pScreen)
if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
return FALSE;
-#ifdef GLAMOR
- if (ms->drmmode.glamor) {
- if (!glamor_egl_create_textured_screen_ext(pScreen,
- ms->drmmode.front_bo->handle,
- pScrn->displayWidth *
- pScrn->bitsPerPixel / 8,
- NULL)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "glamor_egl_create_textured_screen_ext() failed\n");
- return FALSE;
- }
- }
-#endif
+ if (!drmmode_glamor_handle_new_screen_pixmap(&ms->drmmode))
+ return FALSE;
drmmode_uevent_init(pScrn, &ms->drmmode);
if (!ms->drmmode.sw_cursor)
drmmode_map_cursor_bos(pScrn, &ms->drmmode);
- pixels = drmmode_map_front_bo(&ms->drmmode);
- if (!pixels)
- return FALSE;
+
+ if (!ms->drmmode.gbm) {
+ pixels = drmmode_map_front_bo(&ms->drmmode);
+ if (!pixels)
+ return FALSE;
+ }
rootPixmap = pScreen->GetScreenPixmap(pScreen);
@@ -922,18 +907,22 @@ CreateScreenResources(ScreenPtr pScreen)
return FALSE;
}
- ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE,
- pScreen, rootPixmap);
+ err = drmModeDirtyFB(ms->fd, ms->drmmode.fb_id, NULL, 0);
- if (ms->damage) {
- DamageRegister(&rootPixmap->drawable, ms->damage);
- ms->dirty_enabled = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n");
- }
- else {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to create screen damage record\n");
- return FALSE;
+ if (err != -EINVAL && err != -ENOSYS) {
+ ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE,
+ pScreen, rootPixmap);
+
+ if (ms->damage) {
+ DamageRegister(&rootPixmap->drawable, ms->damage);
+ ms->dirty_enabled = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n");
+ }
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to create screen damage record\n");
+ return FALSE;
+ }
}
return ret;
}
@@ -996,6 +985,11 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
if (!SetMaster(pScrn))
return FALSE;
+#ifdef GLAMOR_HAS_GBM
+ if (ms->drmmode.glamor)
+ ms->drmmode.gbm = glamor_egl_get_gbm_device(pScreen);
+#endif
+
/* HW dependent - FIXME */
pScrn->displayWidth = pScrn->virtualX;
if (!drmmode_create_initial_bos(pScrn, &ms->drmmode))
@@ -1106,6 +1100,19 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
xf86DPMSInit(pScreen, xf86DPMSSet, 0);
+#ifdef GLAMOR
+ if (ms->drmmode.glamor) {
+ XF86VideoAdaptorPtr glamor_adaptor;
+
+ glamor_adaptor = glamor_xv_init(pScreen, 16);
+ if (glamor_adaptor != NULL)
+ xf86XVScreenInit(pScreen, &glamor_adaptor, 1);
+ else
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to initialize XV support.\n");
+ }
+#endif
+
if (serverGeneration == 1)
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
@@ -1121,6 +1128,11 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Failed to initialize the DRI2 extension.\n");
}
+
+ if (!ms_present_screen_init(pScreen)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to initialize the Present extension.\n");
+ }
}
#endif
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index bbf1ae029..3decc3eea 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -33,6 +33,14 @@
#include <xf86Crtc.h>
#include <damage.h>
+#ifdef GLAMOR
+#define GLAMOR_FOR_XORG 1
+#include "glamor.h"
+#ifdef GLAMOR_HAS_GBM
+#include <gbm.h>
+#endif
+#endif
+
#include "drmmode_display.h"
#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
@@ -106,6 +114,10 @@ uint32_t ms_drm_queue_alloc(xf86CrtcPtr crtc,
ms_drm_handler_proc handler,
ms_drm_abort_proc abort);
+void ms_drm_abort(ScrnInfoPtr scrn,
+ Bool (*match)(void *data, void *match_data),
+ void *match_data);
+
xf86CrtcPtr ms_dri2_crtc_covering_drawable(DrawablePtr pDraw);
xf86CrtcPtr ms_covering_crtc(ScrnInfoPtr scrn, BoxPtr box,
xf86CrtcPtr desired, BoxPtr crtc_box_ret);
@@ -121,3 +133,5 @@ void ms_dri2_close_screen(ScreenPtr screen);
Bool ms_vblank_screen_init(ScreenPtr screen);
void ms_vblank_close_screen(ScreenPtr screen);
+
+Bool ms_present_screen_init(ScreenPtr screen);
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index d5b7d0008..824500bae 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -33,6 +33,7 @@
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <unistd.h>
+#include "dumb_bo.h"
#include "xf86str.h"
#include "X11/Xatom.h"
#include "micmap.h"
@@ -49,117 +50,64 @@
#include "driver.h"
-#ifdef GLAMOR
-#define GLAMOR_FOR_XORG 1
-#include "glamor.h"
-#endif
-
-static struct dumb_bo *
-dumb_bo_create(int fd,
- const unsigned width, const unsigned height, const unsigned bpp)
-{
- struct drm_mode_create_dumb arg;
- struct dumb_bo *bo;
- int ret;
-
- bo = calloc(1, sizeof(*bo));
- if (!bo)
- return NULL;
-
- memset(&arg, 0, sizeof(arg));
- arg.width = width;
- arg.height = height;
- arg.bpp = bpp;
-
- ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
- if (ret)
- goto err_free;
-
- bo->handle = arg.handle;
- bo->size = arg.size;
- bo->pitch = arg.pitch;
-
- return bo;
- err_free:
- free(bo);
- return NULL;
-}
-
static int
-dumb_bo_map(int fd, struct dumb_bo *bo)
+drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo)
{
- struct drm_mode_map_dumb arg;
int ret;
- void *map;
- if (bo->ptr) {
- bo->map_count++;
- return 0;
+#ifdef GLAMOR_HAS_GBM
+ if (bo->gbm) {
+ gbm_bo_destroy(bo->gbm);
+ bo->gbm = NULL;
}
+#endif
- memset(&arg, 0, sizeof(arg));
- arg.handle = bo->handle;
-
- ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
- if (ret)
- return ret;
-
- map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, arg.offset);
- if (map == MAP_FAILED)
- return -errno;
+ if (bo->dumb) {
+ ret = dumb_bo_destroy(drmmode->fd, bo->dumb);
+ if (ret == 0)
+ bo->dumb = NULL;
+ }
- bo->ptr = map;
return 0;
}
-#if 0
-static int
-dumb_bo_unmap(int fd, struct dumb_bo *bo)
+static uint32_t
+drmmode_bo_get_pitch(drmmode_bo *bo)
{
- bo->map_count--;
- return 0;
-}
+#ifdef GLAMOR_HAS_GBM
+ if (bo->gbm)
+ return gbm_bo_get_stride(bo->gbm);
#endif
-int
-dumb_bo_destroy(int fd, struct dumb_bo *bo)
-{
- struct drm_mode_destroy_dumb arg;
- int ret;
-
- if (bo->ptr) {
- munmap(bo->ptr, bo->size);
- bo->ptr = NULL;
- }
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = bo->handle;
- ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
- if (ret)
- return -errno;
-
- free(bo);
- return 0;
+ return bo->dumb->pitch;
}
-struct dumb_bo *
-dumb_get_bo_from_fd(int fd, int handle, int pitch, int size)
+uint32_t
+drmmode_bo_get_handle(drmmode_bo *bo)
{
- struct dumb_bo *bo;
- int ret;
+#ifdef GLAMOR_HAS_GBM
+ if (bo->gbm)
+ return gbm_bo_get_handle(bo->gbm).u32;
+#endif
- bo = calloc(1, sizeof(*bo));
- if (!bo)
- return NULL;
+ return bo->dumb->handle;
+}
- ret = drmPrimeFDToHandle(fd, handle, &bo->handle);
- if (ret) {
- free(bo);
- return NULL;
+static Bool
+drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
+ unsigned width, unsigned height, unsigned bpp)
+{
+#ifdef GLAMOR_HAS_GBM
+ if (drmmode->glamor) {
+ bo->gbm = gbm_bo_create(drmmode->gbm, width, height,
+ GBM_FORMAT_ARGB8888,
+ GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
+ return bo->gbm != NULL;
}
- bo->pitch = pitch;
- bo->size = size;
- return bo;
+#endif
+
+ bo->dumb = dumb_bo_create(drmmode->fd, width, height, bpp);
+ return bo->dumb != NULL;
}
Bool
@@ -237,18 +185,8 @@ drmmode_ConvertToKMode(ScrnInfoPtr scrn,
static void
drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
{
-#if 0
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-
-// drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-// drmmode_ptr drmmode = drmmode_crtc->drmmode;
-
- /* bonghits in the randr 1.2 - uses dpms to disable crtc - bad buzz */
- if (mode == DPMSModeOff) {
-// drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-// 0, 0, 0, NULL, 0, NULL);
- }
-#endif
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_crtc->dpms_mode = mode;
}
#if 0
@@ -320,8 +258,9 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
ret = drmModeAddFB(drmmode->fd,
pScrn->virtualX, height,
pScrn->depth, pScrn->bitsPerPixel,
- drmmode->front_bo->pitch,
- drmmode->front_bo->handle, &drmmode->fb_id);
+ drmmode_bo_get_pitch(&drmmode->front_bo),
+ drmmode_bo_get_handle(&drmmode->front_bo),
+ &drmmode->fb_id);
if (ret < 0) {
ErrorF("failed to add fb %d\n", ret);
return FALSE;
@@ -390,6 +329,9 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
if (crtc->scrn->pScreen)
xf86CrtcSetScreenSubpixelOrder(crtc->scrn->pScreen);
+
+ crtc->funcs->dpms(crtc, DPMSModeOn);
+
/* go through all the outputs and force DPMS them back on? */
for (i = 0; i < xf86_config->num_output; i++) {
xf86OutputPtr output = xf86_config->output[i];
@@ -437,25 +379,32 @@ drmmode_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
}
static void
-drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
+drmmode_set_cursor(xf86CrtcPtr crtc)
{
- modesettingPtr ms = modesettingPTR(crtc->scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
- int i;
- uint32_t *ptr;
+ drmmode_ptr drmmode = drmmode_crtc->drmmode;
uint32_t handle = drmmode_crtc->cursor_bo->handle;
+ modesettingPtr ms = modesettingPTR(crtc->scrn);
+ static Bool use_set_cursor2 = TRUE;
int ret;
- /* cursor should be mapped already */
- ptr = (uint32_t *) (drmmode_crtc->cursor_bo->ptr);
+ if (use_set_cursor2) {
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+ CursorPtr cursor = xf86_config->cursor;
- for (i = 0; i < ms->cursor_width * ms->cursor_height; i++)
- ptr[i] = image[i]; // cpu_to_le32(image[i]);
+ ret =
+ drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+ handle, ms->cursor_width, ms->cursor_height,
+ cursor->bits->xhot, cursor->bits->yhot);
+ if (ret == -EINVAL)
+ use_set_cursor2 = FALSE;
+ else
+ return;
+ }
+
+ ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
+ ms->cursor_width, ms->cursor_height);
- ret =
- drmModeSetCursor(drmmode_crtc->drmmode->fd,
- drmmode_crtc->mode_crtc->crtc_id, handle,
- ms->cursor_width, ms->cursor_height);
if (ret) {
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
@@ -467,46 +416,44 @@ drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
}
static void
-drmmode_hide_cursor(xf86CrtcPtr crtc)
+drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
{
modesettingPtr ms = modesettingPTR(crtc->scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
- drmmode_ptr drmmode = drmmode_crtc->drmmode;
+ int i;
+ uint32_t *ptr;
- drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
- ms->cursor_width, ms->cursor_height);
+ /* cursor should be mapped already */
+ ptr = (uint32_t *) (drmmode_crtc->cursor_bo->ptr);
+
+ for (i = 0; i < ms->cursor_width * ms->cursor_height; i++)
+ ptr[i] = image[i]; // cpu_to_le32(image[i]);
+ if (drmmode_crtc->cursor_up)
+ drmmode_set_cursor(crtc);
}
static void
-drmmode_show_cursor(xf86CrtcPtr crtc)
+drmmode_hide_cursor(xf86CrtcPtr crtc)
{
modesettingPtr ms = modesettingPTR(crtc->scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
- uint32_t handle = drmmode_crtc->cursor_bo->handle;
- static Bool use_set_cursor2 = TRUE;
-
- if (use_set_cursor2) {
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
- CursorPtr cursor = xf86_config->cursor;
- int ret;
-
- ret =
- drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
- handle, ms->cursor_width, ms->cursor_height,
- cursor->bits->xhot, cursor->bits->yhot);
- if (ret == -EINVAL)
- use_set_cursor2 = FALSE;
- else
- return;
- }
- drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
+ drmmode_crtc->cursor_up = FALSE;
+ drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
ms->cursor_width, ms->cursor_height);
}
static void
+drmmode_show_cursor(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ drmmode_crtc->cursor_up = TRUE;
+ drmmode_set_cursor(crtc);
+}
+
+static void
drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t * red, uint16_t * green,
uint16_t * blue, int size)
{
@@ -1176,6 +1123,42 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
}
}
+Bool
+drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
+{
+#ifdef GLAMOR
+ ScrnInfoPtr scrn = drmmode->scrn;
+ ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn);
+ PixmapPtr screen_pixmap;
+ void *gbm_bo;
+
+ if (!drmmode->glamor)
+ return TRUE;
+
+#ifdef GLAMOR_HAS_GBM
+ gbm_bo = drmmode->front_bo.gbm;
+ screen_pixmap = screen->GetScreenPixmap(screen);
+
+ if (!glamor_egl_create_textured_pixmap_from_gbm_bo(screen_pixmap, gbm_bo)) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed");
+ return FALSE;
+ }
+ glamor_set_screen_pixmap(screen_pixmap, NULL);
+#else
+ if (!glamor_egl_create_textured_screen(screen,
+ drmmode_bo_get_handle(&drmmode->front_bo),
+ scrn->displayWidth *
+ scrn->bitsPerPixel / 8)) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "glamor_egl_create_textured_screen() failed\n");
+ return FALSE;
+ }
+#endif
+#endif
+
+ return TRUE;
+}
+
static Bool
drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
{
@@ -1184,14 +1167,14 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
drmmode_crtc_private_ptr
drmmode_crtc = xf86_config->crtc[0]->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
- struct dumb_bo *old_front = NULL;
+ drmmode_bo old_front;
Bool ret;
ScreenPtr screen = xf86ScrnToScreen(scrn);
uint32_t old_fb_id;
int i, pitch, old_width, old_height, old_pitch;
int cpp = (scrn->bitsPerPixel + 7) / 8;
PixmapPtr ppix = screen->GetScreenPixmap(screen);
- void *new_pixels;
+ void *new_pixels = NULL;
if (scrn->virtualX == width && scrn->virtualY == height)
return TRUE;
@@ -1206,16 +1189,15 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
old_width = scrn->virtualX;
old_height = scrn->virtualY;
- old_pitch = drmmode->front_bo->pitch;
+ old_pitch = drmmode_bo_get_pitch(&drmmode->front_bo);
old_fb_id = drmmode->fb_id;
old_front = drmmode->front_bo;
- drmmode->front_bo =
- dumb_bo_create(drmmode->fd, width, height, scrn->bitsPerPixel);
- if (!drmmode->front_bo)
+ if (!drmmode_create_bo(drmmode, &drmmode->front_bo,
+ width, height, scrn->bitsPerPixel))
goto fail;
- pitch = drmmode->front_bo->pitch;
+ pitch = drmmode_bo_get_pitch(&drmmode->front_bo);
scrn->virtualX = width;
scrn->virtualY = height;
@@ -1223,43 +1205,31 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
ret = drmModeAddFB(drmmode->fd, width, height, scrn->depth,
scrn->bitsPerPixel, pitch,
- drmmode->front_bo->handle, &drmmode->fb_id);
+ drmmode_bo_get_handle(&drmmode->front_bo),
+ &drmmode->fb_id);
if (ret)
goto fail;
- new_pixels = drmmode_map_front_bo(drmmode);
- if (!new_pixels)
- goto fail;
+ if (!drmmode->gbm) {
+ new_pixels = drmmode_map_front_bo(drmmode);
+ if (!new_pixels)
+ goto fail;
+ }
- if (!drmmode->shadow_enable)
- screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
- pitch, new_pixels);
- else {
- void *new_shadow;
+ if (drmmode->shadow_enable) {
uint32_t size = scrn->displayWidth * scrn->virtualY *
((scrn->bitsPerPixel + 7) >> 3);
- new_shadow = calloc(1, size);
- if (new_shadow == NULL)
+ new_pixels = calloc(1, size);
+ if (new_pixels == NULL)
goto fail;
free(drmmode->shadow_fb);
- drmmode->shadow_fb = new_shadow;
- screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
- pitch, drmmode->shadow_fb);
+ drmmode->shadow_fb = new_pixels;
}
-#ifdef GLAMOR
- if (drmmode->glamor) {
- if (!glamor_egl_create_textured_screen_ext(screen,
- drmmode->front_bo->handle,
- scrn->displayWidth *
- scrn->bitsPerPixel / 8,
- NULL)) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "glamor_egl_create_textured_screen_ext() failed\n");
- goto fail;
- }
- }
-#endif
+ screen->ModifyPixmapHeader(ppix, width, height, -1, -1, pitch, new_pixels);
+
+ if (!drmmode_glamor_handle_new_screen_pixmap(drmmode))
+ goto fail;
for (i = 0; i < xf86_config->num_crtc; i++) {
xf86CrtcPtr crtc = xf86_config->crtc[i];
@@ -1273,14 +1243,13 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
if (old_fb_id) {
drmModeRmFB(drmmode->fd, old_fb_id);
- dumb_bo_destroy(drmmode->fd, old_front);
+ drmmode_bo_destroy(drmmode, &old_front);
}
return TRUE;
fail:
- if (drmmode->front_bo)
- dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
+ drmmode_bo_destroy(drmmode, &drmmode->front_bo);
drmmode->front_bo = old_front;
scrn->virtualX = old_width;
scrn->virtualY = old_height;
@@ -1566,10 +1535,9 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
width = pScrn->virtualX;
height = pScrn->virtualY;
- drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
- if (!drmmode->front_bo)
+ if (!drmmode_create_bo(drmmode, &drmmode->front_bo, width, height, bpp))
return FALSE;
- pScrn->displayWidth = drmmode->front_bo->pitch / cpp;
+ pScrn->displayWidth = drmmode_bo_get_pitch(&drmmode->front_bo) / cpp;
width = ms->cursor_width;
height = ms->cursor_height;
@@ -1589,14 +1557,14 @@ drmmode_map_front_bo(drmmode_ptr drmmode)
{
int ret;
- if (drmmode->front_bo->ptr)
- return drmmode->front_bo->ptr;
+ if (drmmode->front_bo.dumb->ptr)
+ return drmmode->front_bo.dumb->ptr;
- ret = dumb_bo_map(drmmode->fd, drmmode->front_bo);
+ ret = dumb_bo_map(drmmode->fd, drmmode->front_bo.dumb);
if (ret)
return NULL;
- return drmmode->front_bo->ptr;
+ return drmmode->front_bo.dumb->ptr;
}
@@ -1643,8 +1611,7 @@ drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
drmmode->fb_id = 0;
}
- dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
- drmmode->front_bo = NULL;
+ drmmode_bo_destroy(drmmode, &drmmode->front_bo);
for (i = 0; i < xf86_config->num_crtc; i++) {
xf86CrtcPtr crtc = xf86_config->crtc[i];
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 92e2816de..66d0ca260 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -32,13 +32,16 @@
#include "libudev.h"
#endif
-struct dumb_bo {
- uint32_t handle;
- uint32_t size;
- void *ptr;
- int map_count;
- uint32_t pitch;
-};
+#include "dumb_bo.h"
+
+struct gbm_device;
+
+typedef struct {
+ struct dumb_bo *dumb;
+#ifdef GLAMOR_HAS_GBM
+ struct gbm_bo *gbm;
+#endif
+} drmmode_bo;
typedef struct {
int fd;
@@ -48,12 +51,15 @@ typedef struct {
drmModeFBPtr mode_fb;
int cpp;
ScrnInfoPtr scrn;
+
+ struct gbm_device *gbm;
+
#ifdef CONFIG_UDEV_KMS
struct udev_monitor *uevent_monitor;
InputHandlerProc uevent_handler;
#endif
drmEventContext event_context;
- struct dumb_bo *front_bo;
+ drmmode_bo front_bo;
Bool sw_cursor;
Bool glamor;
@@ -80,7 +86,9 @@ typedef struct {
drmmode_ptr drmmode;
drmModeCrtcPtr mode_crtc;
uint32_t vblank_pipe;
+ int dpms_mode;
struct dumb_bo *cursor_bo;
+ Bool cursor_up;
unsigned rotate_fb_id;
uint16_t lut_r[256], lut_g[256], lut_b[256];
DamagePtr slave_damage;
@@ -129,6 +137,8 @@ extern DevPrivateKeyRec msPixmapPrivateKeyRec;
#define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
+uint32_t drmmode_bo_get_handle(drmmode_bo *bo);
+Bool drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode);
void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv);
Bool drmmode_SetSlaveBO(PixmapPtr ppix,
drmmode_ptr drmmode,
@@ -148,8 +158,6 @@ Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
int *depth, int *bpp);
-struct dumb_bo *dumb_get_bo_from_fd(int drm_fd, int fd, int pitch, int size);
-int dumb_bo_destroy(int fd, struct dumb_bo *bo);
#ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
diff --git a/hw/xfree86/drivers/modesetting/dumb_bo.c b/hw/xfree86/drivers/modesetting/dumb_bo.c
new file mode 100644
index 000000000..58d420e07
--- /dev/null
+++ b/hw/xfree86/drivers/modesetting/dumb_bo.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ * Dave Airlie <airlied@redhat.com>
+ *
+ */
+
+#include "dumb_bo.h"
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <xf86drm.h>
+
+struct dumb_bo *
+dumb_bo_create(int fd,
+ const unsigned width, const unsigned height, const unsigned bpp)
+{
+ struct drm_mode_create_dumb arg;
+ struct dumb_bo *bo;
+ int ret;
+
+ bo = calloc(1, sizeof(*bo));
+ if (!bo)
+ return NULL;
+
+ memset(&arg, 0, sizeof(arg));
+ arg.width = width;
+ arg.height = height;
+ arg.bpp = bpp;
+
+ ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
+ if (ret)
+ goto err_free;
+
+ bo->handle = arg.handle;
+ bo->size = arg.size;
+ bo->pitch = arg.pitch;
+
+ return bo;
+ err_free:
+ free(bo);
+ return NULL;
+}
+
+int
+dumb_bo_map(int fd, struct dumb_bo *bo)
+{
+ struct drm_mode_map_dumb arg;
+ int ret;
+ void *map;
+
+ if (bo->ptr) {
+ return 0;
+ }
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = bo->handle;
+
+ ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+ if (ret)
+ return ret;
+
+ map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, arg.offset);
+ if (map == MAP_FAILED)
+ return -errno;
+
+ bo->ptr = map;
+ return 0;
+}
+
+int
+dumb_bo_destroy(int fd, struct dumb_bo *bo)
+{
+ struct drm_mode_destroy_dumb arg;
+ int ret;
+
+ if (bo->ptr) {
+ munmap(bo->ptr, bo->size);
+ bo->ptr = NULL;
+ }
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = bo->handle;
+ ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
+ if (ret)
+ return -errno;
+
+ free(bo);
+ return 0;
+}
+
+struct dumb_bo *
+dumb_get_bo_from_fd(int fd, int handle, int pitch, int size)
+{
+ struct dumb_bo *bo;
+ int ret;
+
+ bo = calloc(1, sizeof(*bo));
+ if (!bo)
+ return NULL;
+
+ ret = drmPrimeFDToHandle(fd, handle, &bo->handle);
+ if (ret) {
+ free(bo);
+ return NULL;
+ }
+ bo->pitch = pitch;
+ bo->size = size;
+ return bo;
+}
diff --git a/hw/xfree86/drivers/modesetting/dumb_bo.h b/hw/xfree86/drivers/modesetting/dumb_bo.h
new file mode 100644
index 000000000..9235e61e2
--- /dev/null
+++ b/hw/xfree86/drivers/modesetting/dumb_bo.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ * Dave Airlie <airlied@redhat.com>
+ *
+ */
+#ifndef DUMB_BO_H
+#define DUMB_BO_H
+
+#include <stdint.h>
+
+struct dumb_bo {
+ uint32_t handle;
+ uint32_t size;
+ void *ptr;
+ uint32_t pitch;
+};
+
+struct dumb_bo *dumb_bo_create(int fd, const unsigned width,
+ const unsigned height, const unsigned bpp);
+int dumb_bo_map(int fd, struct dumb_bo *bo);
+int dumb_bo_destroy(int fd, struct dumb_bo *bo);
+struct dumb_bo *dumb_get_bo_from_fd(int fd, int handle, int pitch, int size);
+
+#endif
diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c
new file mode 100644
index 000000000..359e11316
--- /dev/null
+++ b/hw/xfree86/drivers/modesetting/present.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <time.h>
+
+#include <xf86.h>
+#include <xf86Crtc.h>
+#include <xf86drm.h>
+#include <xf86str.h>
+#include <present.h>
+
+#include "driver.h"
+
+#if 0
+#define DebugPresent(x) ErrorF x
+#else
+#define DebugPresent(x)
+#endif
+
+struct ms_present_vblank_event {
+ uint64_t event_id;
+};
+
+static RRCrtcPtr
+ms_present_get_crtc(WindowPtr window)
+{
+ xf86CrtcPtr xf86_crtc = ms_dri2_crtc_covering_drawable(&window->drawable);
+ return xf86_crtc ? xf86_crtc->randr_crtc : NULL;
+}
+
+static int
+ms_present_get_ust_msc(RRCrtcPtr crtc, CARD64 *ust, CARD64 *msc)
+{
+ xf86CrtcPtr xf86_crtc = crtc->devPrivate;
+
+ return ms_get_crtc_ust_msc(xf86_crtc, ust, msc);
+}
+
+/*
+ * Flush the DRM event queue when full; makes space for new events.
+ */
+static Bool
+ms_flush_drm_events(ScreenPtr screen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ struct pollfd p = { .fd = ms->fd, .events = POLLIN };
+ int r;
+
+ do {
+ r = poll(&p, 1, 0);
+ } while (r == -1 && (errno == EINTR || errno == EAGAIN));
+
+ if (r <= 0)
+ return TRUE;
+
+ return drmHandleEvent(ms->fd, &ms->event_context) >= 0;
+}
+
+/*
+ * Called when the queued vblank event has occurred
+ */
+static void
+ms_present_vblank_handler(uint64_t msc, uint64_t usec, void *data)
+{
+ struct ms_present_vblank_event *event = data;
+
+ DebugPresent(("\t\tmh %lld msc %llu\n",
+ (long long) event->event_id, (long long) msc));
+
+ present_event_notify(event->event_id, usec, msc);
+ free(event);
+}
+
+/*
+ * Called when the queued vblank is aborted
+ */
+static void
+ms_present_vblank_abort(void *data)
+{
+ struct ms_present_vblank_event *event = data;
+
+ DebugPresent(("\t\tma %lld\n", (long long) event->event_id));
+
+ free(event);
+}
+
+/*
+ * Queue an event to report back to the Present extension when the specified
+ * MSC has past
+ */
+static int
+ms_present_queue_vblank(RRCrtcPtr crtc,
+ uint64_t event_id,
+ uint64_t msc)
+{
+ xf86CrtcPtr xf86_crtc = crtc->devPrivate;
+ ScreenPtr screen = crtc->pScreen;
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ modesettingPtr ms = modesettingPTR(scrn);
+ drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
+ struct ms_present_vblank_event *event;
+ drmVBlank vbl;
+ int ret;
+ uint32_t seq;
+
+ event = calloc(sizeof(struct ms_present_vblank_event), 1);
+ if (!event)
+ return BadAlloc;
+ event->event_id = event_id;
+ seq = ms_drm_queue_alloc(xf86_crtc, event,
+ ms_present_vblank_handler,
+ ms_present_vblank_abort);
+ if (!seq) {
+ free(event);
+ return BadAlloc;
+ }
+
+ vbl.request.type =
+ DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT | drmmode_crtc->vblank_pipe;
+ vbl.request.sequence = ms_crtc_msc_to_kernel_msc(xf86_crtc, msc);
+ vbl.request.signal = seq;
+ for (;;) {
+ ret = drmWaitVBlank(ms->fd, &vbl);
+ if (!ret)
+ break;
+ if (errno != EBUSY || !ms_flush_drm_events(screen))
+ return BadAlloc;
+ }
+ DebugPresent(("\t\tmq %lld seq %u msc %llu (hw msc %u)\n",
+ (long long) event_id, seq, (long long) msc,
+ vbl.request.sequence));
+ return Success;
+}
+
+static Bool
+ms_present_event_match(void *data, void *match_data)
+{
+ struct ms_present_vblank_event *event = data;
+ uint64_t *match = match_data;
+
+ return *match == event->event_id;
+}
+
+/*
+ * Remove a pending vblank event from the DRM queue so that it is not reported
+ * to the extension
+ */
+static void
+ms_present_abort_vblank(RRCrtcPtr crtc, uint64_t event_id, uint64_t msc)
+{
+ ScreenPtr screen = crtc->pScreen;
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+
+ ms_drm_abort(scrn, ms_present_event_match, &event_id);
+}
+
+/*
+ * Flush our batch buffer when requested by the Present extension.
+ */
+static void
+ms_present_flush(WindowPtr window)
+{
+#ifdef GLAMOR
+ ScreenPtr screen = window->drawable.pScreen;
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ if (ms->drmmode.glamor)
+ glamor_block_handler(screen);
+#endif
+}
+
+static present_screen_info_rec ms_present_screen_info = {
+ .version = PRESENT_SCREEN_INFO_VERSION,
+
+ .get_crtc = ms_present_get_crtc,
+ .get_ust_msc = ms_present_get_ust_msc,
+ .queue_vblank = ms_present_queue_vblank,
+ .abort_vblank = ms_present_abort_vblank,
+ .flush = ms_present_flush,
+
+ .capabilities = PresentCapabilityNone,
+ .check_flip = 0,
+ .flip = 0,
+ .unflip = 0,
+};
+
+Bool
+ms_present_screen_init(ScreenPtr screen)
+{
+ return present_screen_init(screen, &ms_present_screen_info);
+}
diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c
index 5031ef8ff..711f6edb3 100644
--- a/hw/xfree86/drivers/modesetting/vblank.c
+++ b/hw/xfree86/drivers/modesetting/vblank.c
@@ -88,6 +88,14 @@ static int ms_box_area(BoxPtr box)
return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1);
}
+static Bool
+ms_crtc_on(xf86CrtcPtr crtc)
+{
+ drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+ return crtc->enabled && drmmode_crtc->dpms_mode == DPMSModeOn;
+}
+
/*
* Return the crtc covering 'box'. If two crtcs cover a portion of
* 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc
@@ -114,7 +122,7 @@ ms_covering_crtc(ScrnInfoPtr scrn,
crtc = xf86_config->crtc[c];
/* If the CRTC is off, treat it as not covering */
- if (!crtc->enabled)
+ if (!ms_crtc_on(crtc))
continue;
ms_crtc_box(crtc, &crtc_box);
@@ -323,6 +331,24 @@ ms_drm_abort_scrn(ScrnInfoPtr scrn)
}
/*
+ * Externally usable abort function that uses a callback to match a single
+ * queued entry to abort
+ */
+void
+ms_drm_abort(ScrnInfoPtr scrn, Bool (*match)(void *data, void *match_data),
+ void *match_data)
+{
+ struct ms_drm_queue *q;
+
+ xorg_list_for_each_entry(q, &ms_drm_queue, list) {
+ if (match(q->data, match_data)) {
+ ms_drm_abort_one(q);
+ break;
+ }
+ }
+}
+
+/*
* General DRM kernel handler. Looks for the matching sequence number in the
* drm event queue and calls the handler for it.
*/
diff --git a/hw/xfree86/man/Xorg.wrap.man b/hw/xfree86/man/Xorg.wrap.man
index 58937c74b..11090f1f4 100644
--- a/hw/xfree86/man/Xorg.wrap.man
+++ b/hw/xfree86/man/Xorg.wrap.man
@@ -33,7 +33,7 @@ Xorg.wrap \- Xorg X server binary wrapper
The Xorg X server may need root rights to function properly. To start the
Xorg X server with these rights your system is using a suid root wrapper
installed as __suid_wrapper_dir__/Xorg.wrap which will execute the real
-X server which is installed as __suid_wrapper_dir__/Xorg.bin .
+X server which is installed as __suid_wrapper_dir__/Xorg.
.PP
By default Xorg.wrap will autodetect if root rights are necessary, and
if not it will drop its elevated rights before starting the real X server.
diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index 16fc1b739..cc50f36c4 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -46,15 +46,12 @@
#define SOL_CONSOLE_DEV "/dev/console"
static Bool KeepTty = FALSE;
-static Bool Protect0 = FALSE;
static Bool UseConsole = FALSE;
#ifdef HAS_USL_VTS
static int VTnum = -1;
static int xf86StartVT = -1;
static int vtEnabled = 0;
-extern void xf86VTAcquire(int);
-extern void xf86VTRelease(int);
#endif
/* Device to open as xf86Info.consoleFd */
@@ -97,27 +94,6 @@ xf86OpenConsole(void)
if (geteuid() != 0)
FatalError("xf86OpenConsole: Server must be suid root\n");
- /* Protect page 0 to help find NULL dereferencing */
- /* mprotect() doesn't seem to work */
- if (Protect0) {
- int fd = -1;
-
- if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: cannot open /dev/zero (%s)\n",
- strerror(errno));
- }
- else {
- if (mmap(0, 0x1000, PROT_NONE,
- MAP_FIXED | MAP_SHARED, fd, 0) == MAP_FAILED)
- xf86Msg(X_WARNING,
- "xf86OpenConsole: failed to protect page 0 (%s)\n",
- strerror(errno));
-
- close(fd);
- }
- }
-
#ifdef HAS_USL_VTS
/*
@@ -371,15 +347,6 @@ xf86ProcessArgument(int argc, char **argv, int i)
}
/*
- * Undocumented flag to protect page 0 from read/write to help catch NULL
- * pointer dereferences. This is purely a debugging flag.
- */
- if (!strcmp(argv[i], "-protect0")) {
- Protect0 = TRUE;
- return 1;
- }
-
- /*
* Use /dev/console as the console device.
*/
if (!strcmp(argv[i], "-C")) {
diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 3a83f348f..6190fe6a0 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -134,10 +134,15 @@
#endif
#include <sys/kd.h>
#include <sys/vt.h>
+
+extern _X_HIDDEN void xf86VTAcquire(int);
+extern _X_HIDDEN void xf86VTRelease(int);
#endif
#if defined(sun)
#include <sys/fbio.h>
+extern _X_HIDDEN char xf86SolarisFbDev[PATH_MAX];
+
#include <sys/kbd.h>
#include <sys/kbio.h>
diff --git a/hw/xfree86/xorg-wrapper.c b/hw/xfree86/xorg-wrapper.c
index 4ea47331b..22e97ad5d 100644
--- a/hw/xfree86/xorg-wrapper.c
+++ b/hw/xfree86/xorg-wrapper.c
@@ -255,18 +255,18 @@ int main(int argc, char *argv[])
}
}
- snprintf(buf, sizeof(buf), "%s/Xorg.bin", SUID_WRAPPER_DIR);
+ snprintf(buf, sizeof(buf), "%s/Xorg", SUID_WRAPPER_DIR);
/* Check if the server is executable by our real uid */
if (access(buf, X_OK) != 0) {
- fprintf(stderr, "%s: Missing execute permissions for %s/Xorg.bin: %s\n",
- progname, SUID_WRAPPER_DIR, strerror(errno));
+ fprintf(stderr, "%s: Missing execute permissions for %s: %s\n",
+ progname, buf, strerror(errno));
exit(1);
}
argv[0] = buf;
(void) execv(argv[0], argv);
- fprintf(stderr, "%s: Failed to execute %s/Xorg.bin: %s\n",
- progname, SUID_WRAPPER_DIR, strerror(errno));
+ fprintf(stderr, "%s: Failed to execute %s: %s\n",
+ progname, buf, strerror(errno));
exit(1);
}
diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index 4e0e1bb00..994554088 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -26,7 +26,6 @@ Xwayland_LDADD = \
$(XWAYLAND_LIBS) \
$(XWAYLAND_SYS_LIBS) \
$(XSERVER_SYS_LIBS)
-Xwayland_DEPENDENCIES = $(XWAYLAND_LIBS)
Xwayland_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index b8c543ce4..5e204189f 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -233,6 +233,9 @@ pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
xwl_seat->xwl_screen->serial = serial;
switch (button) {
+ case BTN_LEFT:
+ index = 1;
+ break;
case BTN_MIDDLE:
index = 2;
break;
@@ -240,7 +243,9 @@ pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
index = 3;
break;
default:
- index = button - BTN_LEFT + 1;
+ /* Skip indexes 4-7: they are used for vertical and horizontal scroll.
+ The rest of the buttons go in order: BTN_SIDE becomes 8, etc. */
+ index = 8 + button - BTN_SIDE;
break;
}
diff --git a/os/osinit.c b/os/osinit.c
index ff0979ac8..91e3e068c 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -208,9 +208,11 @@ OsInit(void)
* for failures to load libraries/modules at runtime so we can clean up
* after ourselves.
*/
- int failure_signal = SIGQUIT;
+ {
+ int failure_signal = SIGQUIT;
- dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
+ dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
+ }
#endif
#if !defined(XQUARTZ) /* STDIN is already /dev/null and STDOUT/STDERR is managed by console_redirect.c */
diff --git a/os/xsha1.c b/os/xsha1.c
index 24c0aa284..c54e68c83 100644
--- a/os/xsha1.c
+++ b/os/xsha1.c
@@ -1,3 +1,28 @@
+/* Copyright © 2007 Carl Worth
+ * Copyright © 2009 Jeremy Huddleston, Julien Cristau, and Matthieu Herrb
+ * Copyright © 2009-2010 Mikhail Gusarov
+ * Copyright © 2012 Yaakov Selkowitz and Keith Packard
+ *
+ * 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
+ * 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.
+ */
+
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
diff --git a/present/present.c b/present/present.c
index e27fe30ad..2a705a968 100644
--- a/present/present.c
+++ b/present/present.c
@@ -871,19 +871,18 @@ present_pixmap(WindowPtr window,
vblank->queued = TRUE;
if ((pixmap && target_msc >= crtc_msc) || (!pixmap && target_msc > crtc_msc)) {
ret = present_queue_vblank(screen, target_crtc, vblank->event_id, target_msc);
- if (ret != Success) {
- xorg_list_del(&vblank->event_queue);
- vblank->queued = FALSE;
- goto failure;
- }
- } else
- present_execute(vblank, ust, crtc_msc);
+ if (ret == Success)
+ return Success;
+
+ DebugPresent(("present_queue_vblank failed\n"));
+ }
+
+ present_execute(vblank, ust, crtc_msc);
return Success;
no_mem:
ret = BadAlloc;
-failure:
vblank->notifies = NULL;
present_vblank_destroy(vblank);
return ret;