[PATCH xf86-video-ati 1/5] Move DRM event queue related initialization to radeon_drm_queue_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Michel Dänzer <michel.daenzer@xxxxxxx>

And make radeon_drm_queue_handler not directly accessible outside of
radeon_drm_queue.c.

(Ported from amdgpu commit 0148283984c77f7a6e97026edc3093497547e0a4)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/drmmode_display.c  |  4 ----
 src/radeon_dri2.c      | 14 ++++++++------
 src/radeon_drm_queue.c | 11 +++++++++--
 src/radeon_drm_queue.h |  5 +----
 src/radeon_kms.c       |  2 +-
 5 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 0b92b70c6..2e8f91d6e 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2742,10 +2742,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 = radeon_drm_queue_handler;
-	drmmode->event_context.page_flip_handler = radeon_drm_queue_handler;
-
 	pRADEONEnt->has_page_flip_target = drmmode_probe_page_flip_target(pRADEONEnt);
 
 	drmModeFreeResources(mode_res);
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index c36e06f22..4d12fc09a 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -968,13 +968,15 @@ CARD32 radeon_dri2_deferred_event(OsTimerPtr timer, CARD32 now, pointer data)
 
     scrn = crtc->scrn;
     pRADEONEnt = RADEONEntPriv(scrn);
+    drmmode_crtc = event_info->crtc->driver_private;
     ret = drmmode_get_current_ust(pRADEONEnt->fd, &drm_now);
     if (ret) {
 	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 		   "%s cannot get current time\n", __func__);
 	if (event_info->drm_queue_seq)
-	    radeon_drm_queue_handler(pRADEONEnt->fd, 0, 0, 0,
-				     (void*)event_info->drm_queue_seq);
+	    drmmode_crtc->drmmode->event_context.
+		vblank_handler(pRADEONEnt->fd, 0, 0, 0,
+			       (void*)event_info->drm_queue_seq);
 	else
 	    radeon_dri2_frame_event_handler(crtc, 0, 0, data);
 	return 0;
@@ -983,15 +985,15 @@ CARD32 radeon_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)
-	radeon_drm_queue_handler(pRADEONEnt->fd, frame, drm_now / 1000000,
-				 drm_now % 1000000,
-				 (void*)event_info->drm_queue_seq);
+	drmmode_crtc->drmmode->event_context.
+	    vblank_handler(pRADEONEnt->fd, frame, drm_now / 1000000,
+			   drm_now % 1000000,
+			   (void*)event_info->drm_queue_seq);
     else
 	radeon_dri2_frame_event_handler(crtc, frame, drm_now, data);
     return 0;
diff --git a/src/radeon_drm_queue.c b/src/radeon_drm_queue.c
index ac775f86a..bff010fa3 100644
--- a/src/radeon_drm_queue.c
+++ b/src/radeon_drm_queue.c
@@ -57,7 +57,7 @@ static uintptr_t radeon_drm_queue_seq;
 /*
  * Handle a DRM event
  */
-void
+static void
 radeon_drm_queue_handler(int fd, unsigned int frame, unsigned int sec,
 			 unsigned int usec, void *user_ptr)
 {
@@ -181,8 +181,15 @@ radeon_drm_abort_id(uint64_t id)
  * Initialize the DRM event queue
  */
 void
-radeon_drm_queue_init()
+radeon_drm_queue_init(ScrnInfoPtr scrn)
 {
+    RADEONInfoPtr info = RADEONPTR(scrn);
+    drmmode_ptr drmmode = &info->drmmode;
+
+    drmmode->event_context.version = 2;
+    drmmode->event_context.vblank_handler = radeon_drm_queue_handler;
+    drmmode->event_context.page_flip_handler = radeon_drm_queue_handler;
+
     if (radeon_drm_queue_refcnt++)
 	return;
 
diff --git a/src/radeon_drm_queue.h b/src/radeon_drm_queue.h
index c3e2076db..b6aab37c5 100644
--- a/src/radeon_drm_queue.h
+++ b/src/radeon_drm_queue.h
@@ -40,9 +40,6 @@ typedef void (*radeon_drm_handler_proc)(xf86CrtcPtr crtc, uint32_t seq,
 					uint64_t usec, void *data);
 typedef void (*radeon_drm_abort_proc)(xf86CrtcPtr crtc, void *data);
 
-void radeon_drm_queue_handler(int fd, unsigned int frame,
-			      unsigned int tv_sec, unsigned int tv_usec,
-			      void *user_ptr);
 uintptr_t radeon_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
 				 uint64_t id, void *data,
 				 radeon_drm_handler_proc handler,
@@ -50,7 +47,7 @@ uintptr_t radeon_drm_queue_alloc(xf86CrtcPtr crtc, ClientPtr client,
 void radeon_drm_abort_client(ClientPtr client);
 void radeon_drm_abort_entry(uintptr_t seq);
 void radeon_drm_abort_id(uint64_t id);
-void radeon_drm_queue_init();
+void radeon_drm_queue_init(ScrnInfoPtr scrn);
 void radeon_drm_queue_close(ScrnInfoPtr scrn);
 
 #endif /* _RADEON_DRM_QUEUE_H_ */
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 36840ad36..809d24469 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -1789,7 +1789,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 	return FALSE;
     }
 
-    radeon_drm_queue_init();
+    radeon_drm_queue_init(pScrn);
 
     info->allowColorTiling2D = FALSE;
 
-- 
2.18.0



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux