Commit 5c5c1b77 authored by Keith Packard's avatar Keith Packard

present: Add Present extension

Provides both a software implementation using timers and driver hooks
to base everything on vblank intervals.
Signed-off-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson's avatarAdam Jackson <ajax@redhat.com>
parent 56313829
......@@ -21,6 +21,10 @@ if DRI3
DRI3_DIR=dri3
endif
if PRESENT
PRESENT_DIR=present
endif
SUBDIRS = \
doc \
man \
......@@ -42,6 +46,7 @@ SUBDIRS = \
damageext \
$(COMPOSITE_DIR) \
$(GLX_DIR) \
$(PRESENT_DIR) \
$(DRI3_DIR) \
exa \
config \
......
......@@ -614,6 +614,7 @@ AC_ARG_ENABLE(glx, AS_HELP_STRING([--disable-glx], [Build GLX extensi
AC_ARG_ENABLE(dri, AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
AC_ARG_ENABLE(dri2, AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: auto)]), [DRI2=$enableval], [DRI2=auto])
AC_ARG_ENABLE(dri3, AS_HELP_STRING([--enable-dri3], [Build DRI3 extension (default: auto)]), [DRI3=$enableval], [DRI3=auto])
AC_ARG_ENABLE(present, AS_HELP_STRING([--disable-present], [Build Present extension (default: enabled)]), [PRESENT=$enableval], [PRESENT=yes])
AC_ARG_ENABLE(xinerama, AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
AC_ARG_ENABLE(xf86vidmode, AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
AC_ARG_ENABLE(xace, AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
......@@ -807,6 +808,7 @@ DAMAGEPROTO="damageproto >= 1.1"
XCMISCPROTO="xcmiscproto >= 1.2.0"
BIGREQSPROTO="bigreqsproto >= 1.1.0"
XTRANS="xtrans >= 1.2.2"
PRESENTPROTO="presentproto >= 1.0"
dnl List of libraries that require a specific version
LIBAPPLEWM="applewm >= 1.4"
......@@ -1160,6 +1162,14 @@ if test "x$DRI2" = xyes; then
fi
AM_CONDITIONAL(DRI2_AIGLX, test "x$DRI2_AIGLX" = xyes)
AM_CONDITIONAL(PRESENT, [test "x$PRESENT" = xyes])
if test "x$PRESENT" = xyes; then
AC_DEFINE(PRESENT, 1, [Support Present extension])
REQUIRED_MODULES="$REQUIRED_MODULES $PRESENTPROTO"
SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $PRESENTPROTO"
PRESENT_INC='-I$(top_srcdir)/present'
PRESENT_LIB='$(top_builddir)/present/libpresent.la'
fi
AM_CONDITIONAL(XINERAMA, [test "x$XINERAMA" = xyes])
if test "x$XINERAMA" = xyes; then
......@@ -1584,7 +1594,7 @@ AC_EGREP_CPP([I_AM_SVR4],[
AC_DEFINE([SVR4],1,[Define to 1 on systems derived from System V Release 4])
AC_MSG_RESULT([yes])], AC_MSG_RESULT([no]))
XSERVER_CFLAGS="$XSERVER_CFLAGS $CORE_INCS $XEXT_INC $COMPOSITE_INC $DAMAGE_INC $FIXES_INC $XI_INC $MI_INC $MIEXT_SYNC_INC $MIEXT_SHADOW_INC $MIEXT_LAYER_INC $MIEXT_DAMAGE_INC $RENDER_INC $RANDR_INC $FB_INC $DBE_INC"
XSERVER_CFLAGS="$XSERVER_CFLAGS $CORE_INCS $XEXT_INC $COMPOSITE_INC $DAMAGE_INC $FIXES_INC $XI_INC $MI_INC $MIEXT_SYNC_INC $MIEXT_SHADOW_INC $MIEXT_LAYER_INC $MIEXT_DAMAGE_INC $RENDER_INC $RANDR_INC $FB_INC $DBE_INC $PRESENT_INC"
dnl ---------------------------------------------------------------------------
dnl DDX section.
......@@ -1597,7 +1607,7 @@ AC_MSG_RESULT([$XVFB])
AM_CONDITIONAL(XVFB, [test "x$XVFB" = xyes])
if test "x$XVFB" = xyes; then
XVFB_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB"
XVFB_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB"
XVFB_SYS_LIBS="$XVFBMODULES_LIBS $GLX_SYS_LIBS"
AC_SUBST([XVFB_LIBS])
AC_SUBST([XVFB_SYS_LIBS])
......@@ -1618,7 +1628,7 @@ if test "x$XNEST" = xyes; then
if test "x$have_xnest" = xno; then
AC_MSG_ERROR([Xnest build explicitly requested, but required modules not found.])
fi
XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB $DIX_LIB $OS_LIB"
XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB $DIX_LIB $OS_LIB"
XNEST_SYS_LIBS="$XNESTMODULES_LIBS $GLX_SYS_LIBS"
AC_SUBST([XNEST_LIBS])
AC_SUBST([XNEST_SYS_LIBS])
......@@ -1643,7 +1653,7 @@ if test "x$XORG" = xyes; then
XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $XI_LIB $XKB_LIB"
XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $XI_LIB $XKB_LIB"
dnl ==================================================================
dnl symbol visibility
......@@ -2056,7 +2066,7 @@ if test "x$DMX" = xyes; then
fi
DMX_INCLUDES="$XEXT_INC $RENDER_INC $RECORD_INC"
XDMX_CFLAGS="$DMXMODULES_CFLAGS"
XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $DRI3_LIB $MIEXT_SYNC_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $COMPOSITE_LIB $DAMAGE_LIB $MAIN_LIB $DIX_LIB $CONFIG_LIB $OS_LIB $FIXES_LIB"
XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $COMPOSITE_LIB $DAMAGE_LIB $MAIN_LIB $DIX_LIB $CONFIG_LIB $OS_LIB $FIXES_LIB"
XDMX_SYS_LIBS="$DMXMODULES_LIBS"
AC_SUBST([XDMX_CFLAGS])
AC_SUBST([XDMX_LIBS])
......@@ -2165,7 +2175,7 @@ if test "$KDRIVE" = yes; then
KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS"
KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $OS_LIB"
KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $OS_LIB"
KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.la'
case $host_os in
*linux*)
......@@ -2288,6 +2298,7 @@ Xi/Makefile
xfixes/Makefile
exa/Makefile
dri3/Makefile
present/Makefile
hw/Makefile
hw/xfree86/Makefile
hw/xfree86/common/Makefile
......
......@@ -68,6 +68,9 @@
* _any_ header files. */
extern FontPtr defaultFont;
/* Hack to get Present to build (present requires RandR) */
RESTYPE RRCrtcType;
/** This routine provides information to the DMX protocol extension
* about a particular screen. */
Bool
......
......@@ -255,6 +255,9 @@
/* Internal define for Xinerama */
#undef PANORAMIX
/* Support Present extension */
#undef PRESENT
/* Overall prefix */
#undef PROJECTROOT
......
......@@ -181,4 +181,9 @@ extern void XvMCExtensionInit(void);
extern void dri3_extension_init(void);
#endif
#if defined(PRESENT)
#include <X11/extensions/presentproto.h>
#include "presentext.h"
#endif
#endif
......@@ -70,6 +70,9 @@
/* Internal define for Xinerama */
#undef PANORAMIX
/* Support Present extension */
#undef PRESENT
/* Support RANDR extension */
#undef RANDR
......
......@@ -287,7 +287,10 @@ static ExtensionModule staticExtensions[] = {
#ifdef DPMSExtension
{DPMSExtensionInit, DPMSExtensionName, &noDPMSExtension},
#endif
{present_extension_init, PRESENT_NAME, NULL},
#ifdef DRI3
{dri3_extension_init, DRI3_NAME, NULL},
#endif
#ifdef RES
{ResExtensionInit, XRES_NAME, &noResExtension},
#endif
......
noinst_LTLIBRARIES = libpresent.la
AM_CFLAGS = \
-DHAVE_XORG_CONFIG_H \
@DIX_CFLAGS@ @XORG_CFLAGS@
libpresent_la_SOURCES = \
present.h \
present.c \
present_event.c \
present_fake.c \
present_fence.c \
present_notify.c \
present_priv.h \
present_request.c \
present_screen.c
sdk_HEADERS = present.h presentext.h
This diff is collapsed.
/*
* Copyright © 2013 Keith Packard
*
* 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.
*/
#ifndef _PRESENT_H_
#define _PRESENT_H_
#include <X11/extensions/presentproto.h>
#include "randrstr.h"
#include "presentext.h"
typedef struct present_vblank present_vblank_rec, *present_vblank_ptr;
/* Return the current CRTC for 'window'.
*/
typedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window);
/* Return the current ust/msc for 'crtc'
*/
typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc);
/* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 'event_id'
* at or after 'msc'. Return false if it didn't happen (which might occur if 'crtc'
* is not currently generating vblanks).
*/
typedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc,
uint64_t event_id,
uint64_t msc);
/* Abort pending vblank. The extension is no longer interested in
* 'event_id' which was to be notified at 'msc'. If possible, the
* driver is free to de-queue the notification.
*/
typedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, uint64_t msc);
/* Flush pending drawing on 'window' to the hardware.
*/
typedef void (*present_flush_ptr) (WindowPtr window);
/* Check if 'pixmap' is suitable for flipping to 'window'.
*/
typedef Bool (*present_check_flip_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip);
/* Flip pixmap, return false if it didn't happen.
*
* 'crtc' is to be used for any necessary synchronization.
*
* 'sync_flip' requests that the flip be performed at the next
* vertical blank interval to avoid tearing artifacts. If false, the
* flip should be performed as soon as possible.
*
* present_event_notify should be called with 'event_id' when the flip
* occurs
*/
typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
uint64_t event_id,
uint64_t target_msc,
PixmapPtr pixmap,
Bool sync_flip);
/* "unflip" back to the regular screen scanout buffer
*
* present_event_notify should be called with 'event_id' when the unflip occurs.
*/
typedef void (*present_unflip_ptr) (ScreenPtr screen,
uint64_t event_id);
#define PRESENT_SCREEN_INFO_VERSION 0
typedef struct present_screen_info {
uint32_t version;
present_get_crtc_ptr get_crtc;
present_get_ust_msc_ptr get_ust_msc;
present_queue_vblank_ptr queue_vblank;
present_abort_vblank_ptr abort_vblank;
present_flush_ptr flush;
uint32_t capabilities;
present_check_flip_ptr check_flip;
present_flip_ptr flip;
present_unflip_ptr unflip;
} present_screen_info_rec, *present_screen_info_ptr;
/*
* Called when 'event_id' occurs. 'ust' and 'msc' indicate when the
* event actually happened
*/
extern _X_EXPORT void
present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc);
/* 'crtc' has been turned off, so any pending events will never occur.
*/
extern _X_EXPORT void
present_event_abandon(RRCrtcPtr crtc);
extern _X_EXPORT Bool
present_screen_init(ScreenPtr screen, present_screen_info_ptr info);
#endif /* _PRESENT_H_ */
/*
* Copyright © 2013 Keith Packard
*
* 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_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include "present_priv.h"
#include "present_priv.h"
RESTYPE present_event_type;
static int
present_free_event(pointer data, XID id)
{
present_event_ptr present_event = (present_event_ptr) data;
present_window_priv_ptr window_priv = present_window_priv(present_event->window);
present_event_ptr *previous, current;
for (previous = &window_priv->events; (current = *previous); previous = &current->next) {
if (current == present_event) {
*previous = present_event->next;
break;
}
}
free((pointer) present_event);
return 1;
}
void
present_free_events(WindowPtr window)
{
present_window_priv_ptr window_priv = present_window_priv(window);
present_event_ptr event;
if (!window_priv)
return;
while ((event = window_priv->events))
FreeResource(event->id, RT_NONE);
}
static void
present_event_swap(xGenericEvent *from, xGenericEvent *to)
{
*to = *from;
swaps(&to->sequenceNumber);
swapl(&to->length);
swaps(&to->evtype);
switch (from->evtype) {
case PresentConfigureNotify: {
xPresentConfigureNotify *c = (xPresentConfigureNotify *) to;
swapl(&c->eid);
swapl(&c->window);
swaps(&c->x);
swaps(&c->y);
swaps(&c->width);
swaps(&c->height);
swaps(&c->off_x);
swaps(&c->off_y);
swaps(&c->pixmap_width);
swaps(&c->pixmap_height);
swapl(&c->pixmap_flags);
break;
}
case PresentCompleteNotify:
{
xPresentCompleteNotify *c = (xPresentCompleteNotify *) to;
swapl(&c->eid);
swapl(&c->window);
swapl(&c->serial);
swapll(&c->ust);
swapll(&c->msc);
}
case PresentIdleNotify:
{
xPresentIdleNotify *c = (xPresentIdleNotify *) to;
swapl(&c->eid);
swapl(&c->window);
swapl(&c->serial);
swapl(&c->idle_fence);
}
}
}
void
present_send_config_notify(WindowPtr window, int x, int y, int w, int h, int bw, WindowPtr sibling)
{
present_window_priv_ptr window_priv = present_window_priv(window);
if (window_priv) {
xPresentConfigureNotify cn = {
.type = GenericEvent,
.extension = present_request,
.length = (sizeof(xPresentConfigureNotify) - 32) >> 2,
.evtype = PresentConfigureNotify,
.eid = 0,
.window = window->drawable.id,
.x = x,
.y = y,
.width = w,
.height = h,
.off_x = 0,
.off_y = 0,
.pixmap_width = w,
.pixmap_height = h,
.pixmap_flags = 0
};
present_event_ptr event;
for (event = window_priv->events; event; event = event->next) {
if (event->mask & (1 << PresentConfigureNotify)) {
cn.eid = event->id;
WriteEventsToClient(event->client, 1, (xEvent *) &cn);
}
}
}
}
void
present_send_complete_notify(WindowPtr window, CARD8 kind, CARD8 mode, CARD32 serial, uint64_t ust, uint64_t msc)
{
present_window_priv_ptr window_priv = present_window_priv(window);
if (window_priv) {
xPresentCompleteNotify cn = {
.type = GenericEvent,
.extension = present_request,
.length = (sizeof(xPresentCompleteNotify) - 32) >> 2,
.evtype = PresentCompleteNotify,
.kind = kind,
.mode = mode,
.eid = 0,
.window = window->drawable.id,
.serial = serial,
.ust = ust,
.msc = msc,
};
present_event_ptr event;
for (event = window_priv->events; event; event = event->next) {
if (event->mask & PresentCompleteNotifyMask) {
cn.eid = event->id;
WriteEventsToClient(event->client, 1, (xEvent *) &cn);
}
}
}
}
void
present_send_idle_notify(WindowPtr window, CARD32 serial, PixmapPtr pixmap, struct present_fence *idle_fence)
{
present_window_priv_ptr window_priv = present_window_priv(window);
if (window_priv) {
xPresentIdleNotify in = {
.type = GenericEvent,
.extension = present_request,
.length = (sizeof(xPresentIdleNotify) - 32) >> 2,
.evtype = PresentIdleNotify,
.eid = 0,
.window = window->drawable.id,
.serial = serial,
.pixmap = pixmap->drawable.id,
.idle_fence = present_fence_id(idle_fence)
};
present_event_ptr event;
for (event = window_priv->events; event; event = event->next) {
if (event->mask & PresentIdleNotifyMask) {
in.eid = event->id;
WriteEventsToClient(event->client, 1, (xEvent *) &in);
}
}
}
}
int
present_select_input(ClientPtr client, XID eid, WindowPtr window, CARD32 mask)
{
present_window_priv_ptr window_priv = present_get_window_priv(window, mask != 0);
present_event_ptr event;
if (!window_priv) {
if (mask)
return BadAlloc;
return Success;
}
event = calloc (1, sizeof (present_event_rec));
if (!event)
return BadAlloc;
event->client = client;
event->window = window;
event->id = eid;
event->mask = mask;
event->next = window_priv->events;
window_priv->events = event;
if (!AddResource(event->id, present_event_type, (pointer) event))
return BadAlloc;
return Success;
}
Bool
present_event_init(void)
{
present_event_type = CreateNewResourceType(present_free_event, "PresentEvent");
if (!present_event_type)
return FALSE;
GERegisterExtension(present_request, present_event_swap);
return TRUE;
}
/*
* Copyright © 2013 Keith Packard
*
* 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_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include "present_priv.h"
#include "list.h"
static struct xorg_list fake_vblank_queue;
typedef struct present_fake_vblank {
struct xorg_list list;
uint64_t event_id;
OsTimerPtr timer;
ScreenPtr screen;
} present_fake_vblank_rec, *present_fake_vblank_ptr;
int
present_fake_get_ust_msc(ScreenPtr screen, uint64_t *ust, uint64_t *msc)
{
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
*ust = GetTimeInMicros();
*msc = *ust / screen_priv->fake_interval;
return Success;
}
static void
present_fake_notify(ScreenPtr screen, uint64_t event_id)
{
uint64_t ust, msc;
present_fake_get_ust_msc(screen, &ust, &msc);
present_event_notify(event_id, ust, msc);
}
static CARD32
present_fake_do_timer(OsTimerPtr timer,
CARD32 time,
pointer arg)
{
present_fake_vblank_ptr fake_vblank = arg;
present_fake_notify(fake_vblank->screen, fake_vblank->event_id);
xorg_list_del(&fake_vblank->list);
free(fake_vblank);
return 0;
}
void
present_fake_abort_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc)
{
present_fake_vblank_ptr fake_vblank, tmp;
xorg_list_for_each_entry_safe(fake_vblank, tmp, &fake_vblank_queue, list) {
if (fake_vblank->event_id == event_id) {
TimerCancel(fake_vblank->timer);
xorg_list_del(&fake_vblank->list);
free (fake_vblank);
break;
}
}
}
int
present_fake_queue_vblank(ScreenPtr screen,
uint64_t event_id,
uint64_t msc)
{
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
uint64_t ust = msc * screen_priv->fake_interval;
uint64_t now = GetTimeInMicros();
INT32 delay = ((int64_t) (ust - now)) / 1000;
present_fake_vblank_ptr fake_vblank;
if (delay <= 0) {
present_fake_notify(screen, event_id);
return Success;
}
fake_vblank = calloc (1, sizeof (present_fake_vblank_rec));
if (!fake_vblank)
return BadAlloc;
fake_vblank->screen = screen;
fake_vblank->event_id = event_id;
fake_vblank->timer = TimerSet(NULL, 0, delay, present_fake_do_timer, fake_vblank);
if (!fake_vblank->timer) {
free(fake_vblank);
return BadAlloc;
}
xorg_list_add(&fake_vblank->list, &fake_vblank_queue);
return Success;
}
void
present_fake_screen_init(ScreenPtr screen)
{
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
/* For screens with hardware vblank support, the fake code
* will be used for off-screen windows and while screens are blanked,
* in which case we want a slow interval here
*
* Otherwise, pretend that the screen runs at 60Hz
*/
if (screen_priv->info && screen_priv->info->get_crtc)
screen_priv->fake_interval = 1000000;
else
screen_priv->fake_interval = 16667;
}
void
present_fake_queue_init(void)
{
xorg_list_init(&fake_vblank_queue);
}
/*
* Copyright © 2013 Keith Packard
*
* 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_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include "present_priv.h"
#include <gcstruct.h>
#include <misync.h>
#include <misyncstr.h>
/*
* Wraps SyncFence objects so we can add a SyncTrigger to find out
* when the SyncFence gets destroyed and clean up appropriately
*/
struct present_fence {
SyncTrigger trigger;
SyncFence *fence;
};
/*
* SyncTrigger callbacks
*/
static Bool
present_fence_sync_check_trigger(SyncTrigger *trigger, XSyncValue oldval)
{
return FALSE;
}
static void
present_fence_sync_trigger_fired(SyncTrigger *trigger)
{
}
static void
present_fence_sync_counter_destroyed(SyncTrigger *trigger)
{
struct present_fence *present_fence = container_of(trigger, struct present_fence, trigger);
present_fence->fence = NULL;
}
struct present_fence *
present_fence_create(SyncFence *fence)
{
struct present_fence *present_fence;
present_fence = calloc (1, sizeof (struct present_fence));
if (!present_fence)