From: Michel Dänzer <michel.daen...@amd.com>

And make amdgpu_drm_queue_handler not directly accessible outside of
amdgpu_drm_queue.c.

Signed-off-by: Michel Dänzer <michel.daen...@amd.com>
---
 src/amdgpu_dri2.c      | 14 ++++++++------
 src/amdgpu_drm_queue.c | 11 +++++++++--
 src/amdgpu_drm_queue.h |  5 +----
 src/amdgpu_kms.c       |  2 +-
 src/drmmode_display.c  |  4 ----
 5 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index a9238e536..96b2d1760 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -873,13 +873,15 @@ CARD32 amdgpu_dri2_deferred_event(OsTimerPtr timer, 
CARD32 now, pointer data)
 
        scrn = crtc->scrn;
        pAMDGPUEnt = AMDGPUEntPriv(scrn);
+       drmmode_crtc = event_info->crtc->driver_private;
        ret = drmmode_get_current_ust(pAMDGPUEnt->fd, &drm_now);
        if (ret) {
                xf86DrvMsg(scrn->scrnIndex, X_ERROR,
                           "%s cannot get current time\n", __func__);
                if (event_info->drm_queue_seq)
-                       amdgpu_drm_queue_handler(pAMDGPUEnt->fd, 0, 0, 0,
-                                                
(void*)event_info->drm_queue_seq);
+                       drmmode_crtc->drmmode->event_context.
+                               vblank_handler(pAMDGPUEnt->fd, 0, 0, 0,
+                                              
(void*)event_info->drm_queue_seq);
                else
                        amdgpu_dri2_frame_event_handler(crtc, 0, 0, data);
                return 0;
@@ -888,15 +890,15 @@ CARD32 amdgpu_dri2_deferred_event(OsTimerPtr timer, 
CARD32 now, pointer data)
         * calculate the frame number from current time
         * that would come from CRTC if it were running
         */
-       drmmode_crtc = event_info->crtc->driver_private;
        delta_t = drm_now - (CARD64) drmmode_crtc->dpms_last_ust;
        delta_seq = delta_t * drmmode_crtc->dpms_last_fps;
        delta_seq /= 1000000;
        frame = (CARD64) drmmode_crtc->dpms_last_seq + delta_seq;
        if (event_info->drm_queue_seq)
-               amdgpu_drm_queue_handler(pAMDGPUEnt->fd, frame, drm_now / 
1000000,
-                                        drm_now % 1000000,
-                                        (void*)event_info->drm_queue_seq);
+               drmmode_crtc->drmmode->event_context.
+                       vblank_handler(pAMDGPUEnt->fd, frame, drm_now / 1000000,
+                                      drm_now % 1000000,
+                                      (void*)event_info->drm_queue_seq);
        else
                amdgpu_dri2_frame_event_handler(crtc, frame, drm_now, data);
        return 0;
diff --git a/src/amdgpu_drm_queue.c b/src/amdgpu_drm_queue.c
index d1456ca84..dfe0148c8 100644
--- a/src/amdgpu_drm_queue.c
+++ b/src/amdgpu_drm_queue.c
@@ -57,7 +57,7 @@ static uintptr_t amdgpu_drm_queue_seq;
 /*
  * Handle a DRM event
  */
-void
+static void
 amdgpu_drm_queue_handler(int fd, unsigned int frame, unsigned int sec,
                         unsigned int usec, void *user_ptr)
 {
@@ -181,8 +181,15 @@ amdgpu_drm_abort_id(uint64_t id)
  * Initialize the DRM event queue
  */
 void
-amdgpu_drm_queue_init()
+amdgpu_drm_queue_init(ScrnInfoPtr scrn)
 {
+       AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+       drmmode_ptr drmmode = &info->drmmode;
+
+       drmmode->event_context.version = 2;
+       drmmode->event_context.vblank_handler = amdgpu_drm_queue_handler;
+       drmmode->event_context.page_flip_handler = amdgpu_drm_queue_handler;
+
        if (amdgpu_drm_queue_refcnt++)
                return;
 
diff --git a/src/amdgpu_drm_queue.h b/src/amdgpu_drm_queue.h
index 36ee900aa..328b5e6b1 100644
--- a/src/amdgpu_drm_queue.h
+++ b/src/amdgpu_drm_queue.h
@@ -42,9 +42,6 @@ typedef void (*amdgpu_drm_handler_proc)(xf86CrtcPtr crtc, 
uint32_t seq,
                                        uint64_t usec, void *data);
 typedef void (*amdgpu_drm_abort_proc)(xf86CrtcPtr crtc, void *data);
 
-void amdgpu_drm_queue_handler(int fd, unsigned int frame,
-                             unsigned int tv_sec, unsigned int tv_usec,
-                             void *user_ptr);
 uintptr_t amdgpu_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
                                 uint64_t id, void *data,
                                 amdgpu_drm_handler_proc handler,
@@ -52,7 +49,7 @@ uintptr_t amdgpu_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr 
client,
 void amdgpu_drm_abort_client(ClientPtr client);
 void amdgpu_drm_abort_entry(uintptr_t seq);
 void amdgpu_drm_abort_id(uint64_t id);
-void amdgpu_drm_queue_init();
+void amdgpu_drm_queue_init(ScrnInfoPtr scrn);
 void amdgpu_drm_queue_close(ScrnInfoPtr scrn);
 
 #endif /* _AMDGPU_DRM_QUEUE_H_ */
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 7b13d777e..e2925cc83 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -1407,7 +1407,7 @@ Bool AMDGPUPreInit_KMS(ScrnInfoPtr pScrn, int flags)
        if (!AMDGPUPreInitAccel_KMS(pScrn))
                return FALSE;
 
-       amdgpu_drm_queue_init();
+       amdgpu_drm_queue_init(pScrn);
 
        /* don't enable tiling if accel is not enabled */
        if (info->use_glamor) {
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 92f58c157..c45b79d21 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -3315,10 +3315,6 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr 
drmmode, int cpp)
 
        xf86InitialConfiguration(pScrn, TRUE);
 
-       drmmode->event_context.version = 2;
-       drmmode->event_context.vblank_handler = amdgpu_drm_queue_handler;
-       drmmode->event_context.page_flip_handler = amdgpu_drm_queue_handler;
-
        pAMDGPUEnt->has_page_flip_target = 
drmmode_probe_page_flip_target(pAMDGPUEnt);
 
        drmModeFreeResources(mode_res);
-- 
2.18.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to