From: Qiang Yu <Qiang.Yu-5C7GfCeVMHo@public.gmane.org>
To: xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org
Cc: Qiang Yu <Qiang.Yu-5C7GfCeVMHo@public.gmane.org>,
michel-otUistvHUpPR7s880joybQ@public.gmane.org,
emil.l.velikov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH v3 xserver 3/4] modesetting: move common page flip handle to pageflip.c
Date: Mon, 22 Aug 2016 11:53:57 +0800 [thread overview]
Message-ID: <1471838038-16382-4-git-send-email-Qiang.Yu@amd.com> (raw)
In-Reply-To: <1471838038-16382-1-git-send-email-Qiang.Yu-5C7GfCeVMHo@public.gmane.org>
The common page flip handle framework can be shared with DRI2
page flip.
Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
---
hw/xfree86/drivers/modesetting/driver.h | 28 --------
hw/xfree86/drivers/modesetting/pageflip.c | 102 ++++++++++++++++++++++++++++--
hw/xfree86/drivers/modesetting/present.c | 63 +++---------------
3 files changed, 104 insertions(+), 89 deletions(-)
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index c0d80a8..38f0ec0 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -156,34 +156,6 @@ Bool ms_present_screen_init(ScreenPtr screen);
#ifdef GLAMOR
-/*
- * Event data for an in progress flip.
- * This contains a pointer to the vblank event,
- * and information about the flip in progress.
- * a reference to this is stored in the per-crtc
- * flips.
- */
-struct ms_flipdata {
- ScreenPtr screen;
- void *event;
- /* number of CRTC events referencing this */
- int flip_count;
- uint64_t fe_msc;
- uint64_t fe_usec;
- uint32_t old_fb_id;
-};
-
-/*
- * Per crtc pageflipping infomation,
- * These are submitted to the queuing code
- * one of them per crtc per flip.
- */
-struct ms_crtc_pageflip {
- Bool on_reference_crtc;
- /* reference to the ms_flipdata */
- struct ms_flipdata *flipdata;
-};
-
typedef void (*ms_pageflip_handler_proc)(uint64_t frame,
uint64_t usec,
void *data);
diff --git a/hw/xfree86/drivers/modesetting/pageflip.c b/hw/xfree86/drivers/modesetting/pageflip.c
index 4549792..5f35999 100644
--- a/hw/xfree86/drivers/modesetting/pageflip.c
+++ b/hw/xfree86/drivers/modesetting/pageflip.c
@@ -32,6 +32,97 @@
#ifdef GLAMOR
/*
+ * Event data for an in progress flip.
+ * This contains a pointer to the vblank event,
+ * and information about the flip in progress.
+ * a reference to this is stored in the per-crtc
+ * flips.
+ */
+struct ms_flipdata {
+ ScreenPtr screen;
+ void *event;
+ ms_pageflip_handler_proc event_handler;
+ ms_pageflip_abort_proc abort_handler;
+ /* number of CRTC events referencing this */
+ int flip_count;
+ uint64_t fe_msc;
+ uint64_t fe_usec;
+ uint32_t old_fb_id;
+};
+
+/*
+ * Per crtc pageflipping infomation,
+ * These are submitted to the queuing code
+ * one of them per crtc per flip.
+ */
+struct ms_crtc_pageflip {
+ Bool on_reference_crtc;
+ /* reference to the ms_flipdata */
+ struct ms_flipdata *flipdata;
+};
+
+/**
+ * Free an ms_crtc_pageflip.
+ *
+ * Drops the reference count on the flipdata.
+ */
+static void
+ms_pageflip_free(struct ms_crtc_pageflip *flip)
+{
+ struct ms_flipdata *flipdata = flip->flipdata;
+
+ free(flip);
+ if (--flipdata->flip_count > 0)
+ return;
+ free(flipdata);
+}
+
+/**
+ * Callback for the DRM event queue when a single flip has completed
+ *
+ * Once the flip has been completed on all pipes, notify the
+ * extension code telling it when that happened
+ */
+static void
+ms_pageflip_handler(uint64_t msc, uint64_t ust, void *data)
+{
+ struct ms_crtc_pageflip *flip = data;
+ struct ms_flipdata *flipdata = flip->flipdata;
+ ScreenPtr screen = flipdata->screen;
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ if (flip->on_reference_crtc) {
+ flipdata->fe_msc = msc;
+ flipdata->fe_usec = ust;
+ }
+
+ if (flipdata->flip_count == 1) {
+ flipdata->event_handler(flipdata->fe_msc,
+ flipdata->fe_usec,
+ flipdata->event);
+
+ drmModeRmFB(ms->fd, flipdata->old_fb_id);
+ }
+ ms_pageflip_free(flip);
+}
+
+/*
+ * Callback for the DRM queue abort code. A flip has been aborted.
+ */
+static void
+ms_pageflip_abort(void *data)
+{
+ struct ms_crtc_pageflip *flip = data;
+ struct ms_flipdata *flipdata = flip->flipdata;
+
+ if (flipdata->flip_count == 1)
+ flipdata->abort_handler(flipdata->event);
+
+ ms_pageflip_free(flip);
+}
+
+/*
* Flush the DRM event queue when full; makes space for new events.
*
* Returns a negative value on error, 0 if there was nothing to process,
@@ -68,9 +159,7 @@ ms_flush_drm_events(ScreenPtr screen)
static Bool
queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
struct ms_flipdata *flipdata,
- int ref_crtc_vblank_pipe, uint32_t flags,
- ms_pageflip_handler_proc pageflip_handler,
- ms_pageflip_abort_proc pageflip_abort)
+ int ref_crtc_vblank_pipe, uint32_t flags)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
@@ -92,7 +181,7 @@ queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
flip->on_reference_crtc = (drmmode_crtc->vblank_pipe == ref_crtc_vblank_pipe);
flip->flipdata = flipdata;
- seq = ms_drm_queue_alloc(crtc, flip, pageflip_handler, pageflip_abort);
+ seq = ms_drm_queue_alloc(crtc, flip, ms_pageflip_handler, ms_pageflip_abort);
if (!seq) {
free(flip);
return FALSE;
@@ -164,6 +253,8 @@ ms_do_pageflip(ScreenPtr screen,
flipdata->event = event;
flipdata->screen = screen;
+ flipdata->event_handler = pageflip_handler;
+ flipdata->abort_handler = pageflip_abort;
/*
* Take a local reference on flipdata.
@@ -206,8 +297,7 @@ ms_do_pageflip(ScreenPtr screen,
if (!queue_flip_on_crtc(screen, crtc, flipdata,
ref_crtc_vblank_pipe,
- flags, pageflip_handler,
- pageflip_abort)) {
+ flags)) {
goto error_undo;
}
}
diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c
index 18c82cd..deee1f1 100644
--- a/hw/xfree86/drivers/modesetting/present.c
+++ b/hw/xfree86/drivers/modesetting/present.c
@@ -192,77 +192,30 @@ ms_present_flush(WindowPtr window)
#ifdef GLAMOR
/**
- * Free an ms_crtc_pageflip.
- *
- * Drops the reference count on the flipdata.
- */
-static void
-ms_present_flip_free(struct ms_crtc_pageflip *flip)
-{
- struct ms_flipdata *flipdata = flip->flipdata;
-
- free(flip);
- if (--flipdata->flip_count > 0)
- return;
- free(flipdata);
-}
-
-/**
- * Callback for the DRM event queue when a single flip has completed
- *
- * Once the flip has been completed on all pipes, notify the
+ * Callback for the flip has been completed on all pipes, notify the
* extension code telling it when that happened
*/
static void
ms_present_flip_handler(uint64_t msc, uint64_t ust, void *data)
{
- struct ms_crtc_pageflip *flip = data;
- ScreenPtr screen = flip->flipdata->screen;
- ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
- modesettingPtr ms = modesettingPTR(scrn);
- struct ms_flipdata *flipdata = flip->flipdata;
+ struct ms_present_vblank_event *event = data;
- DebugPresent(("\t\tms:fh %lld c %d msc %llu ust %llu\n",
- (long long) flipdata->event->event_id,
- flipdata->flip_count,
+ DebugPresent(("\t\tms:fc %lld msc %llu ust %llu\n",
+ (long long) event->event_id,
(long long) msc, (long long) ust));
- if (flip->on_reference_crtc) {
- flipdata->fe_msc = msc;
- flipdata->fe_usec = ust;
- }
-
- if (flipdata->flip_count == 1) {
- DebugPresent(("\t\tms:fc %lld c %d msc %llu ust %llu\n",
- (long long) flipdata->event->event_id,
- flipdata->flip_count,
- (long long) flipdata->fe_msc, (long long) flipdata->fe_usec));
-
-
- ms_present_vblank_handler(flipdata->fe_msc,
- flipdata->fe_usec,
- flipdata->event);
-
- drmModeRmFB(ms->fd, flipdata->old_fb_id);
- }
- ms_present_flip_free(flip);
+ ms_present_vblank_handler(msc, ust, event);
}
/*
- * Callback for the DRM queue abort code. A flip has been aborted.
+ * Callback for the flip has been aborted.
*/
static void
ms_present_flip_abort(void *data)
{
- struct ms_crtc_pageflip *flip = data;
- struct ms_flipdata *flipdata = flip->flipdata;
-
- DebugPresent(("\t\tms:fa %lld c %d\n", (long long) flipdata->event->event_id, flipdata->flip_count));
-
- if (flipdata->flip_count == 1)
- free(flipdata->event);
+ struct ms_present_vblank_event *event = data;
- ms_present_flip_free(flip);
+ free(event);
}
/*
--
2.7.4
_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel
next prev parent reply other threads:[~2016-08-22 3:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-22 3:53 [PATCH v3 xserver 0/4] modesetting: add DRI2 page flip support Qiang Yu
[not found] ` <1471838038-16382-1-git-send-email-Qiang.Yu-5C7GfCeVMHo@public.gmane.org>
2016-08-22 3:53 ` [PATCH v3 xserver 1/4] modesetting: make ms_do_pageflip generic for share with DRI2 Qiang Yu
[not found] ` <1471838038-16382-2-git-send-email-Qiang.Yu-5C7GfCeVMHo@public.gmane.org>
2016-08-22 7:58 ` Michel Dänzer
2016-08-22 3:53 ` [PATCH v3 xserver 2/4] modesetting: move ms_do_pageflip to pageflip.c Qiang Yu
2016-08-22 3:53 ` Qiang Yu [this message]
[not found] ` <1471838038-16382-4-git-send-email-Qiang.Yu-5C7GfCeVMHo@public.gmane.org>
2016-08-22 7:59 ` [PATCH v3 xserver 3/4] modesetting: move common page flip handle " Michel Dänzer
2016-08-22 3:53 ` [PATCH v3 xserver 4/4] modesetting: add DRI2 page flip support Qiang Yu
[not found] ` <1471838038-16382-5-git-send-email-Qiang.Yu-5C7GfCeVMHo@public.gmane.org>
2016-08-22 6:30 ` Daniel Martin
[not found] ` <CADscph0CQsVXmYTLetbXyzrJHoapPfF=3r1K3ZSGBPYoooas5A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-22 6:54 ` Yu, Qiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1471838038-16382-4-git-send-email-Qiang.Yu@amd.com \
--to=qiang.yu-5c7gfcevmho@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=emil.l.velikov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=michel-otUistvHUpPR7s880joybQ@public.gmane.org \
--cc=xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.