Adapt xf86-video-intel to xserver 1.19 ABI changes. Mostly

from upstreams commits.
Tested by many. Thanks.
This commit is contained in:
matthieu 2017-11-19 20:16:12 +00:00
parent e172c9b2ce
commit cc0541860a
8 changed files with 115 additions and 32 deletions

View File

@ -30,6 +30,7 @@
#include <xorg-server.h>
#include <xorgVersion.h>
#include <xf86Module.h>
#include <picturestr.h>
#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
@ -42,6 +43,10 @@
#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
#endif
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 22
#define HAVE_NOTIFY_FD 1
#endif
#ifndef XF86_SCRN_INTERFACE
#define SCRN_ARG_TYPE int
@ -228,3 +233,13 @@ static inline void FreePixmap(PixmapPtr pixmap)
#if HAS_DIRTYTRACKING_ROTATION
#define PixmapSyncDirtyHelper(d, dd) PixmapSyncDirtyHelper(d)
#endif
#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(22, 0)
#define OsBlockSIGIO()
#define OsReleaseSIGIO()
#endif
#if !HAVE_NOTIFY_FD
#define SetNotifyFd(fd, cb, mode, data) AddGeneralSocket(fd);
#define RemoveNotifyFd(fd) RemoveGeneralSocket(fd)
#endif

View File

@ -367,8 +367,10 @@ struct sna {
EntityInfoPtr pEnt;
const struct intel_device_info *info;
#if !HAVE_NOTIFY_FD
ScreenBlockHandlerProcPtr BlockHandler;
ScreenWakeupHandlerProcPtr WakeupHandler;
#endif
CloseScreenProcPtr CloseScreen;
PicturePtr clear;
@ -995,8 +997,7 @@ static inline uint32_t pixmap_size(PixmapPtr pixmap)
bool sna_accel_init(ScreenPtr sreen, struct sna *sna);
void sna_accel_create(struct sna *sna);
void sna_accel_block_handler(struct sna *sna, struct timeval **tv);
void sna_accel_wakeup_handler(struct sna *sna);
void sna_accel_block(struct sna *sna, struct timeval **tv);
void sna_accel_watch_flush(struct sna *sna, int enable);
void sna_accel_flush(struct sna *sna);
void sna_accel_enter(struct sna *sna);

View File

@ -112,6 +112,11 @@
#define MAKE_COW_OWNER(ptr) ((void*)((uintptr_t)(ptr) | 1))
#define COW(ptr) (void *)((uintptr_t)(ptr) & ~1)
#if XFONT2_CLIENT_FUNCS_VERSION >= 1
#define AllocateFontPrivateIndex() xfont2_allocate_font_private_index()
#define FontSetPrivate(font, idx, data) xfont2_font_set_private(font, idx, data)
#endif
#if 0
static void __sna_fallback_flush(DrawablePtr d)
{
@ -17676,6 +17681,13 @@ static bool sna_option_accel_blt(struct sna *sna)
return strcasecmp(s, "blt") == 0;
}
#if HAVE_NOTIFY_FD
static void sna_accel_notify(int fd, int ready, void *data)
{
sna_mode_wakeup(data);
}
#endif
bool sna_accel_init(ScreenPtr screen, struct sna *sna)
{
const char *backend;
@ -17687,7 +17699,7 @@ bool sna_accel_init(ScreenPtr screen, struct sna *sna)
list_init(&sna->flush_pixmaps);
list_init(&sna->active_pixmaps);
AddGeneralSocket(sna->kgem.fd);
SetNotifyFd(sna->kgem.fd, sna_accel_notify, X_NOTIFY_READ, sna);
#ifdef DEBUG_MEMORY
sna->timer_expire[DEBUG_MEMORY_TIMER] = GetTimeInMillis()+ 10 * 1000;
@ -17862,12 +17874,12 @@ void sna_accel_close(struct sna *sna)
sna_pixmap_expire(sna);
DeleteCallback(&FlushCallback, sna_accel_flush_callback, sna);
RemoveGeneralSocket(sna->kgem.fd);
RemoveNotifyFd(sna->kgem.fd);
kgem_cleanup_cache(&sna->kgem);
}
void sna_accel_block_handler(struct sna *sna, struct timeval **tv)
void sna_accel_block(struct sna *sna, struct timeval **tv)
{
sigtrap_assert_inactive();
@ -17944,22 +17956,6 @@ set_tv:
}
}
void sna_accel_wakeup_handler(struct sna *sna)
{
DBG(("%s: nbatch=%d, need_retire=%d, need_purge=%d\n", __FUNCTION__,
sna->kgem.nbatch, sna->kgem.need_retire, sna->kgem.need_purge));
if (!sna->kgem.nbatch)
return;
if (kgem_is_idle(&sna->kgem)) {
DBG(("%s: GPU idle, flushing\n", __FUNCTION__));
_kgem_submit(&sna->kgem);
}
sigtrap_assert_inactive();
}
void sna_accel_free(struct sna *sna)
{
DBG(("%s\n", __FUNCTION__));

View File

@ -92,7 +92,7 @@ void _sna_acpi_wakeup(struct sna *sna)
DBG(("%s: error [%d], detaching from acpid\n", __FUNCTION__, n));
/* XXX reattach later? */
RemoveGeneralSocket(sna->acpi.fd);
RemoveNotifyFd(sna->acpi.fd);
sna_acpi_fini(sna);
return;
}
@ -136,6 +136,13 @@ void _sna_acpi_wakeup(struct sna *sna)
} while (n);
}
#if HAVE_NOTIFY_FD
static void sna_acpi_notify(int fd, int read, void *data)
{
_sna_acpi_wakeup(data);
}
#endif
static int read_power_state(const char *path)
{
DIR *dir;
@ -200,7 +207,7 @@ void sna_acpi_init(struct sna *sna)
DBG(("%s: attaching to acpid\n", __FUNCTION__));
AddGeneralSocket(sna->acpi.fd);
SetNotifyFd(sna->acpi.fd, sna_acpi_notify, X_NOTIFY_READ, sna);
sna->acpi.remain = sizeof(sna->acpi.event) - 1;
sna->acpi.offset = 0;

View File

@ -729,6 +729,7 @@ cleanup:
return FALSE;
}
#if !HAVE_NOTIFY_FD
static bool has_shadow(struct sna *sna)
{
if (!sna->mode.shadow_damage)
@ -756,7 +757,7 @@ sna_block_handler(BLOCKHANDLER_ARGS_DECL)
sna->BlockHandler(BLOCKHANDLER_ARGS);
if (*tv == NULL || ((*tv)->tv_usec | (*tv)->tv_sec) || has_shadow(sna))
sna_accel_block_handler(sna, tv);
sna_accel_block(sna, tv);
}
static void
@ -778,11 +779,34 @@ sna_wakeup_handler(WAKEUPHANDLER_ARGS_DECL)
sna->WakeupHandler(WAKEUPHANDLER_ARGS);
sna_accel_wakeup_handler(sna);
if (FD_ISSET(sna->kgem.fd, (fd_set*)read_mask))
sna_mode_wakeup(sna);
}
#else
static void
sna_block_handler(void *data, void *_timeout)
{
struct sna *sna = data;
int *timeout = _timeout;
struct timeval tv, *tvp;
DBG(("%s (timeout=%d)\n", __FUNCTION__, *timeout));
if (*timeout == 0)
return;
if (*timeout < 0) {
tvp = NULL;
} else {
tv.tv_sec = *timeout / 1000;
tv.tv_usec = (*timeout % 1000) * 1000;
tvp = &tv;
}
sna_accel_block(sna, &tvp);
if (tvp)
*timeout = tvp->tv_sec * 1000 + tvp->tv_usec / 1000;
}
#endif
#if HAVE_UDEV
static void
@ -1132,13 +1156,17 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL)
/* Must force it before EnterVT, so we are in control of VT and
* later memory should be bound when allocating, e.g rotate_mem */
scrn->vtSema = TRUE;
#if !HAVE_NOTIFY_FD
sna->BlockHandler = screen->BlockHandler;
screen->BlockHandler = sna_block_handler;
sna->WakeupHandler = screen->WakeupHandler;
screen->WakeupHandler = sna_wakeup_handler;
#else
RegisterBlockAndWakeupHandlers(sna_block_handler,
(ServerWakeupHandlerProcPtr)NoopDDA,
sna);
#endif
screen->SaveScreen = sna_save_screen;
screen->CreateScreenResources = sna_create_screen_resources;

View File

@ -252,7 +252,9 @@ typedef struct intel_screen_private {
int colorKey;
XF86VideoAdaptorPtr adaptor;
#if! HAVE_NOTIFY_FD
ScreenBlockHandlerProcPtr BlockHandler;
#endif
Bool overlayOn;
struct {

View File

@ -2068,6 +2068,7 @@ intel_pageflip_abort(ScrnInfoPtr scrn, xf86CrtcPtr crtc, void *data)
/*
* Check for pending DRM events and process them.
*/
#if !HAVE_NOTIFY_FD
static void
drm_wakeup_handler(pointer data, int err, pointer p)
{
@ -2082,6 +2083,14 @@ drm_wakeup_handler(pointer data, int err, pointer p)
if (FD_ISSET(mode->fd, read_mask))
drmHandleEvent(mode->fd, &mode->event_context);
}
#else
static void
drm_notify_fd(int fd, int ready, void *data)
{
struct intel_mode *mode = data;
drmHandleEvent(mode->fd, &mode->event_context);
}
#endif
/*
* If there are any available, read drm_events
@ -2246,9 +2255,11 @@ intel_mode_init(struct intel_screen_private *intel)
* registration within ScreenInit and not PreInit.
*/
mode->flip_count = 0;
AddGeneralSocket(mode->fd);
SetNotifyFd(mode->fd, drm_notify_fd, X_NOTIFY_READ, mode);
#if !HAVE_NOTIFY_FD
RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
drm_wakeup_handler, mode);
#endif
}
void
@ -2272,9 +2283,11 @@ intel_mode_close(intel_screen_private *intel)
intel_drm_abort_scrn(intel->scrn);
#if !HAVE_NOTIFY_FD
RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
drm_wakeup_handler, mode);
RemoveGeneralSocket(mode->fd);
#endif
RemoveNotifyFd(mode->fd);
}
void

View File

@ -672,8 +672,9 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
}
static void
intel_dirty_update(ScreenPtr screen)
intel_dirty_update(intel_screen_private *intel)
{
ScreenPtr screen = xf86ScrnToScreen(intel->scrn);
RegionPtr region;
PixmapDirtyUpdatePtr ent;
@ -690,6 +691,7 @@ intel_dirty_update(ScreenPtr screen)
}
#endif
#if !HAVE_NOTIFY_FD
static void
I830BlockHandler(BLOCKHANDLER_ARGS_DECL)
{
@ -707,9 +709,22 @@ I830BlockHandler(BLOCKHANDLER_ARGS_DECL)
intel_uxa_block_handler(intel);
intel_video_block_handler(intel);
#ifdef INTEL_PIXMAP_SHARING
intel_dirty_update(screen);
intel_dirty_update(intel);
#endif
}
#else
static void
I830BlockHandler(void *data, void *timeout)
{
intel_screen_private *intel = data;
intel_uxa_block_handler(intel);
intel_video_block_handler(intel);
#ifdef INTEL_PIXMAP_SHARING
intel_dirty_update(intel);
#endif
}
#endif
static Bool
intel_init_initial_framebuffer(ScrnInfoPtr scrn)
@ -959,8 +974,14 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
"Hardware cursor initialization failed\n");
}
#if !HAVE_NOTIFY_FD
intel->BlockHandler = screen->BlockHandler;
screen->BlockHandler = I830BlockHandler;
#else
RegisterBlockAndWakeupHandlers(I830BlockHandler,
(ServerWakeupHandlerProcPtr)NoopDDA,
intel);
#endif
#ifdef INTEL_PIXMAP_SHARING
screen->StartPixmapTracking = PixmapStartDirtyTracking;