2014-12-11 22:37:14 +01:00
|
|
|
/*
|
|
|
|
* 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 <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"
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
#include "drmmode_display.h"
|
2014-12-11 22:37:14 +01:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
#define DebugPresent(x) ErrorF x
|
|
|
|
#else
|
|
|
|
#define DebugPresent(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct ms_present_vblank_event {
|
|
|
|
uint64_t event_id;
|
2016-08-22 12:14:18 +02:00
|
|
|
Bool unflip;
|
2014-12-11 22:37:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static RRCrtcPtr
|
|
|
|
ms_present_get_crtc(WindowPtr window)
|
|
|
|
{
|
2019-09-18 01:36:35 +02:00
|
|
|
return ms_randr_crtc_covering_drawable(&window->drawable);
|
2014-12-11 22:37:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-06-18 08:01:31 +02:00
|
|
|
/*
|
|
|
|
* Changes the variable refresh state for every CRTC on the screen.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ms_present_set_screen_vrr(ScrnInfoPtr scrn, Bool vrr_enabled)
|
|
|
|
{
|
|
|
|
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
xf86CrtcPtr crtc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < config->num_crtc; i++) {
|
|
|
|
crtc = config->crtc[i];
|
|
|
|
drmmode_crtc_set_vrr(crtc, vrr_enabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-11 22:37:14 +01:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
struct ms_present_vblank_event *event;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-09-29 17:48:33 +02:00
|
|
|
if (!ms_queue_vblank(xf86_crtc, MS_QUEUE_ABSOLUTE, msc, NULL, seq))
|
|
|
|
return BadAlloc;
|
|
|
|
|
2020-11-26 14:39:32 +01:00
|
|
|
DebugPresent(("\t\tmq %lld seq %u msc %llu\n",
|
|
|
|
(long long) event_id, seq, (long long) msc));
|
2014-12-11 22:37:14 +01:00
|
|
|
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)
|
|
|
|
{
|
2017-05-16 20:37:14 +02:00
|
|
|
#ifdef GLAMOR_HAS_GBM
|
2014-12-11 22:37:14 +01:00
|
|
|
ScreenPtr screen = window->drawable.pScreen;
|
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
|
|
|
modesettingPtr ms = modesettingPTR(scrn);
|
|
|
|
|
|
|
|
if (ms->drmmode.glamor)
|
2019-11-18 22:46:44 +01:00
|
|
|
ms->glamor.block_handler(screen);
|
2014-12-30 20:51:43 +01:00
|
|
|
#endif
|
2014-12-11 22:37:14 +01:00
|
|
|
}
|
|
|
|
|
2017-05-16 20:37:14 +02:00
|
|
|
#ifdef GLAMOR_HAS_GBM
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
|
|
|
|
/**
|
2016-08-22 12:14:17 +02:00
|
|
|
* Callback for the DRM event queue when a flip has completed on all pipes
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
*
|
2016-08-22 12:14:17 +02:00
|
|
|
* Notify the extension code
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
*/
|
|
|
|
static void
|
2016-08-22 12:14:18 +02:00
|
|
|
ms_present_flip_handler(modesettingPtr ms, uint64_t msc,
|
|
|
|
uint64_t ust, void *data)
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
{
|
2016-08-22 12:14:17 +02:00
|
|
|
struct ms_present_vblank_event *event = data;
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
|
2016-08-22 12:14:17 +02:00
|
|
|
DebugPresent(("\t\tms:fc %lld msc %llu ust %llu\n",
|
|
|
|
(long long) event->event_id,
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
(long long) msc, (long long) ust));
|
|
|
|
|
2016-08-22 12:14:18 +02:00
|
|
|
if (event->unflip)
|
|
|
|
ms->drmmode.present_flipping = FALSE;
|
|
|
|
|
2016-08-22 12:14:17 +02:00
|
|
|
ms_present_vblank_handler(msc, ust, event);
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback for the DRM queue abort code. A flip has been aborted.
|
|
|
|
*/
|
|
|
|
static void
|
2016-08-22 12:14:18 +02:00
|
|
|
ms_present_flip_abort(modesettingPtr ms, void *data)
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
{
|
2016-08-22 12:14:17 +02:00
|
|
|
struct ms_present_vblank_event *event = data;
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
|
2016-08-22 12:14:17 +02:00
|
|
|
DebugPresent(("\t\tms:fa %lld\n", (long long) event->event_id));
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
|
2016-08-22 12:14:17 +02:00
|
|
|
free(event);
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test to see if page flipping is possible on the target crtc
|
2019-06-24 21:46:26 +02:00
|
|
|
*
|
|
|
|
* We ignore sw-cursors when *disabling* flipping, we may very well be
|
|
|
|
* returning to scanning out the normal framebuffer *because* we just
|
|
|
|
* switched to sw-cursor mode and check_flip just failed because of that.
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
*/
|
|
|
|
static Bool
|
2019-06-24 21:46:26 +02:00
|
|
|
ms_present_check_unflip(RRCrtcPtr crtc,
|
|
|
|
WindowPtr window,
|
|
|
|
PixmapPtr pixmap,
|
|
|
|
Bool sync_flip,
|
|
|
|
PresentFlipReason *reason)
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
{
|
|
|
|
ScreenPtr screen = window->drawable.pScreen;
|
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
|
|
|
modesettingPtr ms = modesettingPTR(scrn);
|
|
|
|
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
int num_crtcs_on = 0;
|
|
|
|
int i;
|
2018-02-28 02:19:42 +01:00
|
|
|
struct gbm_bo *gbm;
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
|
|
|
|
if (!ms->drmmode.pageflip)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-08-22 12:14:18 +02:00
|
|
|
if (ms->drmmode.dri2_flipping)
|
|
|
|
return FALSE;
|
|
|
|
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
if (!scrn->vtSema)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (i = 0; i < config->num_crtc; i++) {
|
|
|
|
drmmode_crtc_private_ptr drmmode_crtc = config->crtc[i]->driver_private;
|
|
|
|
|
|
|
|
/* Don't do pageflipping if CRTCs are rotated. */
|
|
|
|
if (drmmode_crtc->rotate_bo.gbm)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-09-18 14:32:01 +02:00
|
|
|
if (xf86_crtc_on(config->crtc[i]))
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
num_crtcs_on++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We can't do pageflipping if all the CRTCs are off. */
|
|
|
|
if (num_crtcs_on == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Check stride, can't change that on flip */
|
2018-02-28 02:19:39 +01:00
|
|
|
if (!ms->atomic_modeset &&
|
|
|
|
pixmap->devKind != drmmode_bo_get_pitch(&ms->drmmode.front_bo))
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-07-22 13:12:05 +02:00
|
|
|
if (!ms->drmmode.glamor)
|
|
|
|
return FALSE;
|
|
|
|
|
2018-03-07 19:45:30 +01:00
|
|
|
#ifdef GBM_BO_WITH_MODIFIERS
|
2018-02-28 02:19:42 +01:00
|
|
|
/* Check if buffer format/modifier is supported by all active CRTCs */
|
2019-11-18 22:46:44 +01:00
|
|
|
gbm = ms->glamor.gbm_bo_from_pixmap(screen, pixmap);
|
2018-02-28 02:19:42 +01:00
|
|
|
if (gbm) {
|
|
|
|
uint32_t format;
|
|
|
|
uint64_t modifier;
|
|
|
|
|
|
|
|
format = gbm_bo_get_format(gbm);
|
|
|
|
modifier = gbm_bo_get_modifier(gbm);
|
2018-04-26 17:04:15 +02:00
|
|
|
gbm_bo_destroy(gbm);
|
|
|
|
|
2018-02-28 02:19:42 +01:00
|
|
|
if (!drmmode_is_format_supported(scrn, format, modifier)) {
|
|
|
|
if (reason)
|
|
|
|
*reason = PRESENT_FLIP_REASON_BUFFER_FORMAT;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
/* Make sure there's a bo we can get to */
|
|
|
|
/* XXX: actually do this. also...is it sufficient?
|
|
|
|
* if (!glamor_get_pixmap_private(pixmap))
|
|
|
|
* return FALSE;
|
|
|
|
*/
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-06-24 21:46:26 +02:00
|
|
|
static Bool
|
|
|
|
ms_present_check_flip(RRCrtcPtr crtc,
|
|
|
|
WindowPtr window,
|
|
|
|
PixmapPtr pixmap,
|
|
|
|
Bool sync_flip,
|
|
|
|
PresentFlipReason *reason)
|
|
|
|
{
|
|
|
|
ScreenPtr screen = window->drawable.pScreen;
|
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
|
|
|
modesettingPtr ms = modesettingPTR(scrn);
|
|
|
|
|
|
|
|
if (ms->drmmode.sprites_visible > 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-06-18 08:01:31 +02:00
|
|
|
if(!ms_present_check_unflip(crtc, window, pixmap, sync_flip, reason))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ms->flip_window = window;
|
|
|
|
|
|
|
|
return TRUE;
|
2019-06-24 21:46:26 +02:00
|
|
|
}
|
|
|
|
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
/*
|
|
|
|
* Queue a flip on 'crtc' to 'pixmap' at 'target_msc'. If 'sync_flip' is true,
|
|
|
|
* then wait for vblank. Otherwise, flip immediately
|
|
|
|
*/
|
|
|
|
static Bool
|
|
|
|
ms_present_flip(RRCrtcPtr crtc,
|
|
|
|
uint64_t event_id,
|
|
|
|
uint64_t target_msc,
|
|
|
|
PixmapPtr pixmap,
|
|
|
|
Bool sync_flip)
|
|
|
|
{
|
|
|
|
ScreenPtr screen = crtc->pScreen;
|
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
2016-08-22 12:14:18 +02:00
|
|
|
modesettingPtr ms = modesettingPTR(scrn);
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
xf86CrtcPtr xf86_crtc = crtc->devPrivate;
|
|
|
|
drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
|
|
|
|
Bool ret;
|
|
|
|
struct ms_present_vblank_event *event;
|
|
|
|
|
2020-06-18 08:01:31 +02:00
|
|
|
if (!ms_present_check_flip(crtc, ms->flip_window, pixmap, sync_flip, NULL))
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
event = calloc(1, sizeof(struct ms_present_vblank_event));
|
|
|
|
if (!event)
|
|
|
|
return FALSE;
|
|
|
|
|
2016-08-22 12:14:15 +02:00
|
|
|
DebugPresent(("\t\tms:pf %lld msc %llu\n",
|
|
|
|
(long long) event_id, (long long) target_msc));
|
|
|
|
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
event->event_id = event_id;
|
2016-08-22 12:14:18 +02:00
|
|
|
event->unflip = FALSE;
|
|
|
|
|
2020-06-18 08:01:31 +02:00
|
|
|
/* A window can only flip if it covers the entire X screen.
|
|
|
|
* Only one window can flip at a time.
|
|
|
|
*
|
|
|
|
* If the window also has the variable refresh property then
|
|
|
|
* variable refresh supported can be enabled on every CRTC.
|
|
|
|
*/
|
|
|
|
if (ms->vrr_support && ms->is_connector_vrr_capable &&
|
|
|
|
ms_window_has_variable_refresh(ms, ms->flip_window)) {
|
|
|
|
ms_present_set_screen_vrr(scrn, TRUE);
|
|
|
|
}
|
|
|
|
|
2016-08-22 12:14:15 +02:00
|
|
|
ret = ms_do_pageflip(screen, pixmap, event, drmmode_crtc->vblank_pipe, !sync_flip,
|
2019-07-15 14:35:49 +02:00
|
|
|
ms_present_flip_handler, ms_present_flip_abort,
|
|
|
|
"Present-flip");
|
|
|
|
if (ret)
|
2016-08-22 12:14:18 +02:00
|
|
|
ms->drmmode.present_flipping = TRUE;
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue a flip back to the normal frame buffer
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ms_present_unflip(ScreenPtr screen, uint64_t event_id)
|
|
|
|
{
|
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
2016-08-22 12:14:18 +02:00
|
|
|
modesettingPtr ms = modesettingPTR(scrn);
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
|
|
|
|
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
|
|
|
|
int i;
|
|
|
|
struct ms_present_vblank_event *event;
|
|
|
|
|
2020-06-18 08:01:31 +02:00
|
|
|
ms_present_set_screen_vrr(scrn, FALSE);
|
|
|
|
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
event = calloc(1, sizeof(struct ms_present_vblank_event));
|
|
|
|
if (!event)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event->event_id = event_id;
|
2016-08-22 12:14:18 +02:00
|
|
|
event->unflip = TRUE;
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
|
2019-06-24 21:46:26 +02:00
|
|
|
if (ms_present_check_unflip(NULL, screen->root, pixmap, TRUE, NULL) &&
|
2016-08-22 12:14:15 +02:00
|
|
|
ms_do_pageflip(screen, pixmap, event, -1, FALSE,
|
2019-07-15 14:35:49 +02:00
|
|
|
ms_present_flip_handler, ms_present_flip_abort,
|
|
|
|
"Present-unflip")) {
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < config->num_crtc; i++) {
|
|
|
|
xf86CrtcPtr crtc = config->crtc[i];
|
|
|
|
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
|
|
|
|
|
|
|
|
if (!crtc->enabled)
|
|
|
|
continue;
|
|
|
|
|
2016-06-13 21:31:02 +02:00
|
|
|
/* info->drmmode.fb_id still points to the FB for the last flipped BO.
|
|
|
|
* Clear it, drmmode_set_mode_major will re-create it
|
|
|
|
*/
|
|
|
|
if (drmmode_crtc->drmmode->fb_id) {
|
|
|
|
drmModeRmFB(drmmode_crtc->drmmode->fd,
|
|
|
|
drmmode_crtc->drmmode->fb_id);
|
|
|
|
drmmode_crtc->drmmode->fb_id = 0;
|
|
|
|
}
|
|
|
|
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
if (drmmode_crtc->dpms_mode == DPMSModeOn)
|
|
|
|
crtc->funcs->set_mode_major(crtc, &crtc->mode, crtc->rotation,
|
|
|
|
crtc->x, crtc->y);
|
|
|
|
else
|
|
|
|
drmmode_crtc->need_modeset = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
present_event_notify(event_id, 0, 0);
|
2016-08-22 12:14:18 +02:00
|
|
|
ms->drmmode.present_flipping = FALSE;
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-11 22:37:14 +01:00
|
|
|
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,
|
2017-05-16 20:37:14 +02:00
|
|
|
#ifdef GLAMOR_HAS_GBM
|
2018-02-28 02:19:42 +01:00
|
|
|
.check_flip = NULL,
|
|
|
|
.check_flip2 = ms_present_check_flip,
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
.flip = ms_present_flip,
|
|
|
|
.unflip = ms_present_unflip,
|
|
|
|
#endif
|
2014-12-11 22:37:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Bool
|
|
|
|
ms_present_screen_init(ScreenPtr screen)
|
|
|
|
{
|
modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-01-27 06:29:23 +01:00
|
|
|
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
|
|
|
|
modesettingPtr ms = modesettingPTR(scrn);
|
|
|
|
uint64_t value;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = drmGetCap(ms->fd, DRM_CAP_ASYNC_PAGE_FLIP, &value);
|
|
|
|
if (ret == 0 && value == 1)
|
|
|
|
ms_present_screen_info.capabilities |= PresentCapabilityAsync;
|
|
|
|
|
2014-12-11 22:37:14 +01:00
|
|
|
return present_screen_init(screen, &ms_present_screen_info);
|
|
|
|
}
|